PageSourceSearch

https://static.monarch.com/static/js/6972.0265ac09.chunk.js

js monarch.com collected 2026-10-03 21:24:19 UTC 3,374,069 bytes, 2 lines download raw bytes

1!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},t=(new Error).stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="87b01e9f-5966-476a-a541-e292e445f713",e._sentryDebugIdIdentifier="sentry-dbid-87b01e9f-5966-476a-a541-e292e445f713")}catch(e){}}(),(this.webpackChunkweb=this.webpackChunkweb||[]).push([[6972],{41516:(e,t,n)=>{n.d(t,{F:()=>d});var a=n(13398),l=n(13484),r=n(36938),o=n(88370),i=n(60150),s=n(8134);const c=["balance","previousBalance","className","isLiability","valueFormatter","children"],d=e=>{let t=e.balance,n=e.previousBalance,d=e.className,m=e.isLiability,p=void 0!==m&&m,g=e.valueFormatter,h=void 0===g?s.vv:g,v=e.children,f=(0,a.A)(e,c);const E=(Number(t)-Number(n))*(p?-1:1),y=u(E,p),b=y.color,x=y.sign,w=h(E).replace("-","");return r.createElement("div",Object.assign({"data-external-id":"balance-diff-indicator",className:(0,i.cn)("flex items-center justify-between text-xs",b,d)},f,{"data-zero":0===E||void 0}),r.createElement("span",o.TN,x,(0,l.A)(t)&&(0,l.A)(n)?w:"--",v))},u=function(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return e>0?t?{color:"text-content-success",sign:"-"}:{color:"text-content-success",sign:"+"}:e<0?t?{color:"text-content-danger",sign:"+"}:{color:"text-content-danger",sign:"-"}:{color:"text-content-primary",sign:""}}},72880:(e,t,n)=>{n.d(t,{$:()=>h});var a=n(97920),l=n(36938),r=n(39861),o=n(37380);const i=JSON.parse('{"a":[{"id":"153171984252512629","value":0,"label":"","type":"category","categoryGroupType":"expense"},{"id":"153171984222103998","value":0,"label":"","type":"category","categoryGroupType":"expense"},{"id":"153171984253561206","value":0,"label":"","type":"category","categoryGroupType":"expense"},{"id":"income","value":0,"label":"","type":"category","categoryGroupType":"expense"},{"id":"153171984223152575","value":0,"label":"","type":"category","categoryGroupType":"expense"},{"id":"153171984224201154","value":0,"label":"","type":"category","categoryGroupType":"expense"},{"id":"153171984224201155","value":0,"label":"","type":"category","categoryGroupType":"expense"}],"y":[{"source":"153171984252512629","target":"153171984222103998","value":100},{"source":"153171984253561206","target":"153171984222103998","value":200},{"source":"153171984222103998","target":"income","value":350},{"source":"income","target":"153171984223152575","value":90},{"source":"income","target":"153171984224201154","value":98.47},{"source":"income","target":"153171984224201155","value":83.59}]}');var s=n(20456),c=n(41387),d=n(14728);const u=r.default.div.withConfig({displayName:"CashFlowSankeyPlaceholder__Root",componentId:"pqx7iw-0"})(["position:relative;"]),m=(0,r.default)(o.g).attrs({center:!0}).withConfig({displayName:"CashFlowSankeyPlaceholder__CenterContainer",componentId:"pqx7iw-1"})(["position:absolute;width:100%;height:100%;top:0;left:0;"]),p=(0,r.default)(o.g).attrs({center:!0}).withConfig({displayName:"CashFlowSankeyPlaceholder__PlaceholderBanner",componentId:"pqx7iw-2"})(["padding:"," ",";border:1px solid ",";border-radius:",";background:",";"," font-weight:",";"],(e=>e.theme.spacing.xsmall),(e=>e.theme.spacing.xlarge),(e=>e.theme.color.grayLight),(e=>e.theme.radius.pill),(e=>e.theme.color.white),c.M.medium,(e=>e.theme.fontWeight.medium)),g=e=>{let t=e.width,n=void 0===t?0:t,o=e.text,c=void 0===o?d.b0.SANKEY_EMPTY:o;const g=(0,r.useTheme)(),h=(0,l.useMemo)((()=>({nodes:i.a.flatMap((e=>(0,a.A)((0,a.A)({},e),{},{color:g.color.grayLight}))),links:i.y})),[g.color.grayLight]);return l.createElement(u,{"data-external-id":"cash-flow-sankey-placeholder"},l.createElement(s.uq,{data:h,width:n,formatValue:()=>""}),l.createElement(m,null,l.createElement(p,null,c)))},h=l.memo(g)},81833:(e,t,n)=>{n.d(t,{X:()=>a,f:()=>l});
1const a="https://help.monarch.com/hc/en-us/articles/45946555058964",l="https://help.monarch.com/hc/en-us/articles/48401988544404"},34644:(e,t,n)=>{n.d(t,{r:()=>v});var a=n(68622),l=n(78213),r=n(36938),o=n(39592),i=n(80643),s=n(67242),c=n(44629),d=n(90879),u=n(82818),m=n(39861),p=n(69263),g=n(8235),h=n(39009);const v=e=>{let t=e.data,n=e.width,d=e.height,u=e.innerRadius,p=void 0===u?"50%":u,g=e.outerRadius,h=void 0===g?"70%":g,v=e.isAnimationActive,w=e.showLabels,C=void 0===w||w,A=e.startAngle,I=e.endAngle,k=e.paddingAngle,S=e.tooltip,N=e.showTooltip,T=void 0===N||N,_=e.activeDatumIds,D=e.legendActiveDatumId,R=e.animationIdentity,M=e.onAnimationStateChange,L=e.onChangeActiveDatumId,O=e.onClickDatum;const P=(0,m.useTheme)(),B=(0,r.useRef)(null),z=(0,r.useRef)(void 0),F=(0,r.useRef)(M),G=(0,r.useRef)(L),Y=(0,r.useRef)(_),U=(0,r.useRef)(Boolean(v));z.current=D,F.current=M,G.current=L,Y.current=_;const V=(0,r.useMemo)((()=>(0,l.A)(t)),[t]),W=Boolean(v),j=(0,r.useState)(W),H=(0,a.A)(j,2),K=H[0],q=H[1],$=(0,r.useState)(0),Z=(0,a.A)($,2),J=Z[0],X=Z[1],Q=(0,r.useRef)(""),ee=(0,r.useMemo)((()=>void 0!==R?String(R):V.map((e=>{var t;return"".concat(null!==(t=e.id)&&void 0!==t?t:e.label,":").concat(e.value)})).join("|")),[R,V]);U.current=K,(0,r.useLayoutEffect)((()=>{var e;if(!W)return q(!1),null===(e=F.current)||void 0===e||e.call(F,!1),void(Q.current=ee);const t=0===Q.current.length,n=!t&&Q.current!==ee;var a;(n&&X((e=>e+1)),t||n)&&(q(!0),null===(a=F.current)||void 0===a||a.call(F,!0));Q.current=ee}),[ee,W]);const te=(0,r.useCallback)((()=>{var e;q(!0),null===(e=F.current)||void 0===e||e.call(F,!0)}),[]),ne=(0,r.useCallback)((()=>{var e;q(!1),null===(e=F.current)||void 0===e||e.call(F,!1)}),[]);(0,r.useEffect)((()=>{if(K)return;if(!D||!B.current)return;const e=V.findIndex((e=>e.id===D));if(e<0)return;const t=B.current,n=t.querySelectorAll(".recharts-pie-sector")[e];return n?(n.dispatchEvent(new MouseEvent("mouseover",{bubbles:!0})),()=>{const e=t.querySelector(".recharts-wrapper");null===e||void 0===e||e.dispatchEvent(new MouseEvent("mouseout",{bubbles:!0}))}):void 0}),[K,D,V]),(0,r.useEffect)((()=>{var e;if(!K)return;const t=null===(e=B.current)||void 0===e?void 0:e.querySelector(".recharts-wrapper");null===t||void 0===t||t.dispatchEvent(new MouseEvent("mouseout",{bubbles:!0}))}),[K]);const ae=(0,r.useCallback)(((e,t)=>{var n;const a=null===(n=e.payload)||void 0===n?void 0:n.id,l=U.current?[]:Y.current,r=a&&(null===l||void 0===l?void 0:l.includes(a));return e.isActive||r?b(e):x(e)}),[]),le=(0,r.useCallback)(((e,t)=>{var n;K||z.current||null===(n=G.current)||void 0===n||n.call(G,e.payload.id)}),[K]),re=(0,r.useCallback)((e=>{if(K||z.current)return;const t=e.payload.id;if(!t)return;const n=U.current?[]:Y.current;var a;null!==n&&void 0!==n&&n.includes(t)&&(null===(a=G.current)||void 0===a||a.call(G,void 0))}),[K]);return r.createElement("div",{"data-external-id":"pie-chart",ref:B,style:{display:"contents"}},r.createElement(o.r,{margin:{top:6,bottom:6,left:6,right:6},style:{overflow:"visible"},width:n,height:d,responsive:!0},r.createElement(i.Fq,Object.assign({key:J,data:V,shape:ae,startAngle:A,endAngle:I,paddingAngle:k,dataKey:"value",nameKey:"label",cx:"50%",cy:"50%",stroke:P.color.white,innerRadius:p,outerRadius:h,isAnimationActive:W&&K,onAnimationStart:te,onAnimationEnd:ne,onMouseEnter:le,onMouseLeave:re,onClick:e=>{const t=e.payload.id;return void 0!==t&&"everything_else"!==t&&(null===O||void 0===O?void 0:O(t))},style:{overflow:"visible",pointerEvents:K?"none":"auto"}},C&&{label:f,labelLine:E}),V.map(((e,t)=>{let n=e.color;return r.createElement(s.f,{key:"cell-".concat(t),fill:n,style:{cursor:"pointer"}})}))),T&&r.createElement(c.m,{cursor:!1,content:S||y})))},f=e=>{const t=e.name,n=e.textAnchor,a=e.x,l=e.y,o=e.fill,i=e.percent,s=e.payload,c=null===s||void 0===s?void 0:s.labelColor;return(null!==i&&void 0!==i?i:0)<.02?null:r.createElement("text",{x:a,y:l,fill:null!==c&&void 0!==c?c:o,textAnchor:n,dominantBaseline:"central",fontSize:12},t)},E=e=>{const t=e.percent;return(null!==t&&void 0!==t?t:0)<.02?r.createElement("g",null):r.createElement(d.Ip,Object.assign({},e,{type:"linear"}))},y=e=>{const t=e.active,n=(0,h.WS)(e),a=null!==n&&void 0!==n?n:{},l=a.label,o=a.value,i=a.formattedValue,s=a.color;return r.createElement(p.II,{"data-external-id":"tooltip-content",active:t},r.createElement(g.B,{dotFillColor:s,label:l,value:null!==i&&void 0!==i?i:o}))},b=e=>{var t,n;return r.createElement("g",null,r.createElement(u.h,Object.assign({},e,{innerRadius:Math.max(0,(null!==(t=e.innerRadius)&&void 0!==t?t:0)-6),outerRadius:Math.max(0,(null!==(n=e.outerRadius)&&void 0!==n?n:0)+6)})))},x=e=>r.createElement(u.h,e)},98251:(e,t,n)=>{n.d(t,{OI:()=>f,el:()=>E});var a=n(68622),l=n(36938),r=n(43373),o=n(39861),i=n(37380),s=n(8483),c=n(82429),d=n(34644),u=n(88370),m=n(57432),p=n(47197),g=n(53083),h=n(3664),v=n(4424);const f=235,E=e=>{let t=e.data,n=e.isAnimationActive,r=void 0!==n&&n,o=e.legendTitle,i=e.pieChartTitle,c=e.pieChartSubtitle,m=e.pieChartSize,g=void 0===m?f:m,h=e.className,v=e.tooltip,E=e.renderCustomValue,b=e.renderItemTooltip,S=e.shouldShowSegment,N=e.renderLegendFooter,T=e.onClickDatum,_=e.selectedDatumId,D=e.formatEntityUrl;const R=(0,l.useState)(void 0),M=(0,a.A)(R,2),L=M[0],O=M[1],P=(0,p.Nb)({strict:!1}).hideAmounts,B=(0,l.useMemo)((()=>P||t.every((e=>void 0!==e.percent))),[P,t]),z=(0,l.useMemo)((()=>S?t.filter(S):t),[t,S]),F=[L,_].filter((e=>void 0!==e&&null!==e));return l.createElement(x,{"data-external-id":"pie-chart-with-legend",className:h},l.createElement(w,null,!P&&l.createElement(A,null,!!i&&l.createElement(s.v,Object.assign({size:"large",weight:"medium"},u.zs),i),!!c&&l.createElement(s.v,Object.assign({size:"small"},u.zs),c)),l.createElement(d.r,{data:z,width:g,height:g,showLabels:!1,outerRadius:"100%",innerRadius:"76%",isAnimationActive:r,startAngle:90,endAngle:450,tooltip:v,onClickDatum:T,selectedDatumId:_,activeDatumIds:F,onChangeActiveDatumId:e=>O(e)}
1)),l.createElement(C,null,!!o&&l.createElement(k,null,o),l.createElement(I,{$wide:B},t.map(((e,t)=>l.createElement(y,{key:"".concat(e.label,"-").concat(t),datum:e,showPercentage:B,hideAmounts:P,renderCustomValue:E,renderItemTooltip:b,onClickDatum:T,setActiveDatumId:O,activeDatumId:L,active:_===e.id||L===e.id,formatEntityUrl:D})))),null===N||void 0===N?void 0:N()))},y=e=>{let t=e.datum,n=e.showPercentage,a=e.hideAmounts,o=e.renderCustomValue,i=e.renderItemTooltip,d=e.onClickDatum,p=e.setActiveDatumId,g=e.activeDatumId,v=e.active,f=e.formatEntityUrl;const E=(0,r.Zp)(),y=t.label,b=t.color,x=t.formattedValue,w=t.percent,C=t.id,A=(0,l.useMemo)((()=>null===o||void 0===o?void 0:o(t)),[t,o]),I=(0,l.useMemo)((()=>null===i||void 0===i?void 0:i(t)),[t,i]),k=a?void 0:A||x,_=n&&!A&&w?(0,h.l9)(w):void 0,D=null===f||void 0===f?void 0:f(t),R=!!t.onClick||(f?!!D:!!d&&!!C),M=(0,l.useCallback)((()=>C&&(null===p||void 0===p?void 0:p(C))),[C,p]),L=(0,l.useCallback)((()=>g===C&&(null===p||void 0===p?void 0:p(void 0))),[g,C,p]),O=(0,l.useCallback)((()=>{t.onClick?t.onClick():f?D&&E(D):C&&(null===d||void 0===d||d(C))}),[t,f,D,C,E,d]),P=l.createElement(l.Fragment,null,l.createElement(m.c,{size:12,className:"mt-1.25 mr-xs",color:b}),l.createElement(T,null,l.createElement(s.v,{size:"small",clampLine
1s:1},y),l.createElement(s.v,Object.assign({size:"small",weight:"medium"},u.zs),k," ",k&&_?"(".concat(_,")"):_)));return l.createElement(c.d,{"data-external-id":"legend-item",content:I},R?l.createElement(S,{type:"button",onMouseEnter:M,onMouseLeave:L,onFocus:M,onBlur:L,onClick:O,$active:v,$interactive:!0},P):l.createElement(N,{onMouseEnter:M,onMouseLeave:L,$active:v},P))},b=e=>{let t=e.$active,n=e.$interactive;return["\n    flex overflow-hidden rounded-md border-0 px-sm py-xs text-left\n    text-inherit transition-colors\n    focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-border-info\n    focus-visible:outline-solid\n    ".concat(t?"bg-background-secondary":"bg-transparent"," hover:bg-background-secondary"),n&&"cursor-pointer"]},x=(0,o.default)(i.g).withConfig({displayName:"PieChartWithLegend__Root",componentId:"lcez6g-0"})(["padding:",";gap:",";flex-direction:column;align-items:center;flex-wrap:wrap;@media (min-width:","px){flex-direction:row;justify-content:space-around;}"],g.YK.xxlarge,g.YK.xxlarge,g.nm.sm),w=o.default.div.attrs({"data-sc-tw":"PieChartWithLegend__PieContainer"}).withConfig({displayName:"PieChartWithLegend__PieContainer",componentId:"lcez6g-1"})(["position:relative;.recharts-wrapper > svg{overflow:inherit !important;}"]),C=(0,o.default)(i.g).attrs({column:!0}).withConfig({displayName:"PieChartWithLegend__RightSideContainer",componentId:"lcez6g-2"})(["flex:1;width:100%;max-width:660px;"]),A=(0,o.default)(i.g).attrs({alignCenter:!0,justifyCenter:!0,column:!0}).withConfig({displayName:"PieChartWithLegend__CenterTitleContainer",componentId:"lcez6g-3"})(["position:absolute;top:0;left:0;right:0;bottom:0;"]),I=o.default.div.withConfig({displayName:"PieChartWithLegend__LegendGridContainer",componentId:"lcez6g-4"})(["flex:1;display:grid;grid-template-columns:repeat(auto-fit,minmax(","px,1fr));gap:",";"],(e=>e.$wide?180:130),g.YK.xsmall),k=(0,o.default)(s.v).attrs({weight:"medium"}).withConfig({displayName:"PieChartWithLegend__LegendTitle",componentId:"lcez6g-5"})(["margin-left:",";margin-bottom:",";display:block;"],g.YK.small,g.YK.xsmall),S=v.s.button(b),N=v.s.div(b),T=(0,o.default)(i.g).attrs({column:!0}).withConfig({displayName:"PieChartWithLegend__LegendTitleContainer",componentId:"lcez6g-6"})(["overflow:hidden;"])},20456:(e,t,n)=>{n.d(t,{uq:()=>T});var a=n(68622),l=n(29557),r=n(94061),o=n(99045),i=n(73616),s=n(94391),c=n(66808),d=n(96083),u=n(36938),m=n(39861),p=n(13484),g=n(88370),h=n(725);const v=e=>{var t,n,a,l,r;let o=e.link,i=e.linkCurvature,s=e.formatValue,c=e.getLabelPosition,d=e.getLabelCoordinates,v=e.getLabelText,E=e.getLabelVerticalOffset,y=e.onMouseEnter,b=e.onMouseLeave,x=e.onClick;const w=(0,m.useTheme)(),C=(0,h.P)(o,i);if(null===C)throw new Error;const A=o.source,I=o.target,k=o.index,S=(!!A.isClickable||!!I.isClickable)&&(0,p.A)(x),N=null===s||void 0===s?void 0:s(o),T=null!==(t=null===c||void 0===c?void 0:c(o))&&void 0!==t?t:"middle",_=null===v||void 0===v?void 0:v(o),D=null!==(n=null===E||void 0===E?void 0:E(o))&&void 0!==n?n:0,R=null!==(a=null===d||void 0===d?void 0:d(o,T))&&void 0!==a?a:f(o,T),M=R.x,L=R.y,O=R.textAnchor,P=void 0===O?T:O;return u.createElement(u.Fragment,null,u.createElement("defs",null,u.createElement("linearGradient",{id:"gradient-".concat(k),gradientUnits:"userSpaceOnUse",x1:A.x1,x2:I.x0},u.createElement("stop",{offset:"0",stopColor:null!==(l=A.color)&&void 0!==l?l:w.color.grayFocus}),u.createElement("stop",{offset:"100%",stopColor:null!==(r=I.color)&&void 0!==r?r:w.color.grayFocus}))),u.createElement("path",{d:C,fill:"url(#gradient-".concat(k,")"),fillOpacity:.25,className:["link",S&&"is-clickable"].filter(Boolean).join(" "),"data-target-id":I.id,"data-source-id":A.id,onMouseEnter:()=>y(o),onMouseLeave:b,onClick:()=>null===x||void 0===x?void 0:x(o)}),N&&u.createElement(u.Fragment,null,_&&u.createElement("text",{x:M,y:L+D,dy:"-10px",textAnchor:P,dominantBaseline:"central",fontSize:w.fontSize.small,fill:w.color.text,pointerEvents:"none"},_),u.createElement("text",Object.assign({x:M,y:L+D,dy:_?"10px":"0",textAnchor:P,dominantBaseline:"central",fontSize:w.fontSize.base,fontWeight:500,fill:w.color.text,pointerEvents:"none"},g.TN),N)))},f=(e,t)=>{var n,a;const l=(e=>{var t,n;return((null!==(t=e.y0)&&void 0!==t?t:0)+(null!==(n=e.y1)&&void 0!==n?n:0))/2})(e);var r,o,i,s;return"start"===t?{x:(null!==(r=e.source.x1)&&void 0!==r?r:0)+10,y:null!==(o=e.y0)&&void 0!==o?o:l}:"end"===t?{x:(null!==(i=e.target.x0)&&void 0!==i?i:0)-80,y:null!==(s=e.y1)&&void 0!==s?s:l}:{x:((null!==(n=e.source.x1)&&void 0!==n?n:0)+(null!==(a=e.target.x0)&&void 0!==a?a:0))/2,y:l}},E=e=>{var t,n,a,l;let r=e.node,o=e.diagramWidth,i=e.labelHorizontalPadding,s=void 0===i?10:i,c=e.formatValue,d=e.getSecondaryLabel,p=e.getSecondaryValue,h=e.secondaryPlacement,v=e.onMouseEnter,f=e.onMouseLeave,E=e.onClick;const x=(0,m.useTheme)(),w=r.x0,C=void 0===w?0:w,A=r.x1,I=void 0===A?0:A,k=r.y0,S=void 0===k?0:k,N=r.y1,T=void 0===N?0:N,_=r.color,D=r.index,R=r.label,M=r.isClickable,L=void 0===M?!!E:M,O=(0,u.useMemo)((()=>b(r,c)),[r,c]),P=(0,u.useMemo)((()=>y(R)),[R]),B=(0,u.useMemo)((()=>null===d||void 0===d?void 0:d(r)),[d,r]),z=(0,u.useMemo)((()=>null===p||void 0===p?void 0:p(r)),[p,r]),F=o/2,G=I-C,Y=C+G/2,U=T-S,V=(T+S)/2,W=Y<F?"start":"end",j=Y<F?I+s:C-s,H=null!==(t=null===h||void 0===h?void 0:h.x)&&void 0!==t?t:j,K=null!==(n=null===h||void 0===h?void 0:h.textAnchor)&&void 0!==n?n:W,q=null!==(a=null===h||void 0===h?void 0:h.labelDy)&&void 0!==a?a:28,$=null!==(l=null===h||void 0===h?void 0:h.valueDy)&&void 0!==l?l:B?46:28;return u.createElement("g",{"data-external-id":"sankey-diagram-node",className:["node",L&&"is-clickable"].filter(
1Boolean).join(" "),"data-id":r.id,onClick:()=>null===E||void 0===E?void 0:E(r),onMouseEnter:()=>v(r),onMouseLeave:f},u.createElement("rect",{x:C,y:S,width:G,height:U,fill:null!==_&&void 0!==_?_:x.color.grayFocus,"data-index":D,shapeRendering:"crispEdges"}),!!O&&u.createElement(u.Fragment,null,u.createElement("text",{x:j,y:V,dy:"".concat(-12,"px"),textAnchor:W,fontSize:x.fontSize.small,fill:x.color.text,dominantBaseline:"central",className:"node-label"},P),u.createElement("text",Object.assign({x:j,y:V,dy:"".concat(8,"px"),textAnchor:W,fontWeight:500,fill:x.color.text,fontSize:x.fontSize.base,dominantBaseline:"central"},g.TN),O),B&&u.createElement("text",{x:H,y:V,dy:q,textAnchor:K,fontSize:x.fontSize.small,fill:x.color.text,dominantBaseline:"central"},B),z&&u.createElement("text",Object.assign({x:H,y:V,dy:$,textAnchor:K,fontWeight:500,fill:x.color.text,fontSize:x.fontSize.base,dominantBaseline:"central"},g.TN),z)))},y=e=>e.length>30?"".concat(e.slice(0,30),"..."):e,b=(e,t)=>{var n;const a=null!==(n=null===t||void 0===t?void 0:t(e))&&void 0!==n?n:e.value;return a?String(a):void 0};var x=n(1506),w=n(39250);const C=(e,t)=>e.length*t*.6,A=e=>{let t=e.x,n=e.y,a=e.text,l=e.textAnchor,r=e.fontSizePx,o=e.paddingPx,i=void 0===o?6:o;const s=C(a,r),c=r+4,d="start"===l?t:"middle"===l?t-s/2:t-s;return{left:d-i,right:d+s+i,top:n-c/2-i,bottom:n+c/2+i}},I=e=>{let t=e.nodes,n=e.diagramWidth,a=e.formatValue,l=e.getNodeSecondaryLabel,r=e.getNodeSecondaryValue,o=e.theme;if(!l&&!r)return new Map;const s=new Map,c=[],d=parseInt(o.fontSize.small,10),u=parseInt(o.fontSize.base,10);return t.forEach((e=>{const t=e.id,l=e.x0,r=void 0===l?0:l,o=e.x1,i=void 0===o?0:o,s=e.y0,m=void 0===s?0:s,p=e.y1,g=void 0===p?0:p,h=e.label,v=b(e,a);if(!v)return;const f=(m+g)/2,E=r+(i-r)/2<n/2,x=E?i+10:r-10,w=E?"start":"end";c.push({nodeId:t,box:A({x:x,y:f+-12,text:y(h),textAnchor:w,fontSizePx:d})}),c.push({nodeId:t,box:A({x:x,y:f+8,text:v,textAnchor:w,fontSizePx:u})})})),t.slice().sort(((e,t)=>{var n,a;return(null!==(n=e.y0)&&void 0!==n?n:0)-(null!==(a=t.y0)&&void 0!==a?a:0)})).forEach((e=>{var t;const a=null===l||void 0===l?void 0:l(e),o=null===r||void 0===r?void 0:r(e);if(!a&&!o)return;const m=e.id,p=e.x0,g=void 0===p?0:p,h=e.x1,v=void 0===h?0:h,f=e.y0,E=void 0===f?0:f,y=e.y1,b=(E+(void 0===y?0:y))/2,x=g+(v-g)/2<n/2,w=x?"start":"end",I=[a?C(a,d):0,o?C(o,u):0],k=Math.max(...I),S=e=>{const t=x?v+10:g-10,l=(e=>{let t=e.desiredX,n=e.diagramWidth,a=e.textAnchor,l=e.widestTextWidth;if("start"===a){const e=2,a=Math.max(e,n-l-2);return(0,i.A)(e,a,t)}const r=Math.max(2,n-2),o=Math.min(r,Math.max(2,l+2));return(0,i.A)(o,r,t)})({desiredX:x?t+e:t-e,diagramWidth:n,textAnchor:w,widestTextWidth:k});return{x:l,textAnchor:w,labelDy:28,valueDy:a?46:28}},N=Array.from({length:30},((e,t)=>S(10*t))),T=null!==(t=N.find((e=>[a?A({x:e.x,y:b+e.labelDy,text:a,textAnchor:e.textAnchor,fontSizePx:d,paddingPx:2}):void 0,o?A({x:e.x,y:b+e.valueDy,text:o,textAnchor:e.textAnchor,fontSizePx:u,paddingPx:2}):void 0].filter(Boolean).every((e=>!c.some((t=>{return t.nodeId!==m&&(n=e,a=t.box,n.left<a.right&&n.right>a.left&&n.top<a.bottom&&n.bottom>a.top);var n,a})))))))&&void 0!==t?t:N[0];s.set(e.id,T),a&&c.push({nodeId:m,box:A({x:T.x,y:b+T.labelDy,text:a,textAnchor:T.textAnchor,fontSizePx:d,paddingPx:2})}),o&&c.push({nodeId:m,box:A({x:T.x,y:b+T.valueDy,text:o,textAnchor:T.textAnchor,fontSizePx:u,paddingPx:2})})})),s},k=(e,t)=>{var n,a,l;return(null!==(n=null===(a=e.source)||void 0===a?void 0:a.x1)&&void 0!==n?n:0)<t/2&&(null===(l=e.source)||void 0===l?void 0:l.type)!==x.Z6.Generic?e.source:e.target},S=m.default.div.withConfig({displayName:"SankeyDiagram__Root",componentId:"y9ipuy-0"})(["font-family:inherit;position:relative;margin:0 ","px;svg{margin-right:","px;.node,.link{transition:opacity 0.1s ease-out;}.unselected{opacity:",";}.selected{opacity:1;}.hovered{filter:brightness(",");opacity:1;}.is-clickable{cursor:pointer;}.node:not(.is-clickable){cursor:default;}}"],(e=>e.$marginHorizontal),(e=>e.$marginHorizontal),.32,.75),N=e=>{let t=e.data,n=e.width,i=void 0===n?768:n,p=e.height,g=e.className,f=e.highlightOnHover,y=e.margin,b=void 0===y?24:y,C=e.customNodesColorDeterminer,A=e.formatValue,N=e.getNodeSecondaryLabel,T=e.getNodeSecondaryValue,_=e.onClickNode,D=e.onAlignNode,R=e.onSortNo
1des,M=e.onSortLinks,L=e.getNodeGroup,O=e.getPercentageGroupKey,P=e.getNodeGroupSortKey,B=e.nodeGroupPadding,z=e.applyCrossColumnSpacing,F=e.adjustNodePositions,G=e.formatLinkValue,Y=e.linkCurvature,U=e.getLinkLabelPosition,V=e.getLinkLabelCoordinates,W=e.getLinkLabelText,j=e.getLinkLabelVerticalOffset,H=e.getNodeSelectionKey,K=e.selectedNodeId;const q=(0,m.useTheme)(),$=(0,u.useCallback)((e=>{var t;return null!==(t=null===H||void 0===H?void 0:H(e))&&void 0!==t?t:e.id}),[H]),Z=(0,u.useMemo)((()=>(0,d.A)(b)?b:[b,b]),[b]),J=(0,a.A)(Z,2),X=J[0],Q=J[1],ee=(0,u.useMemo)((()=>Math.max(i,768)-2*Q),[i,Q]),te=(0,u.useMemo)((()=>({transform:"translateY(".concat(X,"px)")})),[X]),ne=u.useState({nodes:[],links:[]}),ae=(0,a.A)(ne,2),le=ae[0],re=ae[1],oe=(0,u.useCallback)((()=>{let e=r.A().nodeId((e=>e.id)).nodeAlign(null!==D&&void 0!==D?D:o.pG).nodePadding(0).nodeWidth(parseInt(q.spacing.default,10)).size([ee,null!==p&&void 0!==p?p:520]);R&&(e=e.nodeSort(R)),M&&(e=e.linkSort(M));const n=e({nodes:(0,s.A)(t.nodes),links:(0,s.A)(t.links)});(0,h.Ft)(n.nodes,void 0,void 0,{getNodeGroup:L,groupPadding:B,getNodeGroupSortKey:P,applyCrossColumnSpacing:z}),null===F||void 0===F||F(n.nodes),(0,h.KN)(n.nodes),C?C(n.nodes,n.links,q):(0,h.tY)(n.nodes,n.links),(0,w.rI)(n.nodes,O);const a=e.update(n);re(a)}),[t,q,ee,p,C,D,R,M,L,O,P,B,z,F]),ie=(0,u.useCallback)((e=>{let t=e.id,n=e.node,a=e.mode;if(!f&&"hover"===a)return;const r="hover"===a?"hovered":"selected",o="hover"===a?"unhovered":"unselected",i=null!==n&&void 0!==n?n:le.nodes.find((e=>e.id===t));if((0,c.A)(i))return;const s=$(i),d=le.nodes.filter((e=>$(e)===s)),u=e=>{var t,n;return(null!==(t=null===e||void 0===e?void 0:e.targetLinks)&&void 0!==t?t:[]).concat(null!==(n=null===e||void 0===e?void 0:e.sourceLinks)&&void 0!==n?n:[]).flatMap((e=>[e.source,e.target])).filter((e=>e.type!==x.Z6.Generic))},m=new Set(d.flatMap((e=>[e.id,...u(e).map((e=>e.id))])));l.Ubm(".link, .node").classed(o,!0).classed(r,!1),m.forEach((e=>{l.Ubm(".link[data-source-id='".concat(e,"'], .link[data-target-id='").concat(e,"'], .node[data-id='").concat(e,"']")).classed(r,!0).classed(o,!1)})),l.Ltv(".node[data-id='".concat(i.id,"']")).raise()}),[le.nodes,f,$]),se=(0,u.useCallback)((e=>{if(!f&&"hover"===e)return;const t="hover"===e?"hovered":"selected",n="hover"===e?"unhovered":"unselected";l.Ubm(".link, .node").classed(n,!1).classed(t,!1)}),[f]),ce=(0,u.useCallback)((e=>ie({node:e,mode:"hover"})),[ie]),de=(0,u.useCallback)((e=>{ie({node:k(e,ee),mode:"hover"})}),[ie,ee]),ue=(0,u.useCallback)((()=>{se("hover")}),[se]),me=(0,u.useCallback)((e=>{null===_||void 0===_||_(k(e,ee))}),[_,ee]);(0,u.useEffect)((()=>{requestAnimationFrame(oe)}),[t,ee,oe]),(0,u.useEffect)((()=>{K?ie({id:K,mode:"select"}):se("select")}),[ie,K,se]);const pe=(0,u.useMemo)((()=>Math.max(null!==p&&void 0!==p?p:(0,h.rd)(le.nodes),520)+2*X),[le.nodes,p,X]),ge=(0,u.useMemo)((()=>I({nodes:le.nodes,diagramWidth:ee,formatValue:A,getNodeSecondaryLabel:N,getNodeSecondaryValue:T,theme:q})),[le.nodes,ee,A,N,T,q]);return u.createElement(S,{"data-external-id":"sankey-diagram",className:g,$marginHorizontal:Q,$marginVertical:X},u.createElement("svg",{width:ee,height:pe,id:"monarch-sankey-diagram"},u.createElement("g",{style:te},le.links.map((e=>u.createElement(v,{key:e.index,link:e,linkCurvature:Y,formatValue:G,getLabelPosition:U,getLabelCoordinates:(e,t)=>null===V||void 0===V?void 0:V(e,t,ee),getLabelText:W,getLabelVerticalOffset:j,onClick:me,onMouseEnter:de,onMouseLeave:ue})))),u.createElement("g",{style:te},le.nodes.map((e=>u.createElement(E,{key:e.id,node:e,diagramWidth:ee,onClick:_,onMouseEnter:ce,onMouseLeave:ue,formatValue:A,getSecondaryLabel:N,getSecondaryValue:T,secondaryPlacement:ge.get(e.id)}))))))},T=u.memo(N)},90565:(e,t,n)=>{n.d(t,{g_:()=>r,q2:()=>o,vD:()=>Q});var a=n(12202);const l=parseInt(a.w.spacing.xsmall,10),r=32,o=1800,i=400,s=[.25,.1,.25,1];var c=n(13398),d=n(97920),u=n(68622),m=n(75317),p=n(84074),g=n(33063),h=n(65131),v=n(13484),f=n(36938),E=n(20761),y=n(39783),b=n(44629),x=n(26792),w=n(14927),C=n(2270),A=n(33994),I=n(95279),k=n(27869),S=n(20606),N=n(39861),T=n(20361),_=n(17706),D=n(81882);const R=e=>{let t=e.labelOffsetXPx,n=e.labelOffsetYPx,a=e.leftLabelText,l=e.rightLabelText,r=e.viewBox,o=r.x,i=r.y;const s=(0,N.useTheme)();return f.createElement("g",{"data-external-id":"reference-line-divider-label"}
1,f.createElement(M,{labelOffsetXPx:t,labelOffsetYPx:n,anchorX:o,anchorY:i,left:!0},a),f.createElement(M,{labelOffsetXPx:t,labelOffsetYPx:n,anchorX:o,anchorY:i},l),f.createElement("line",{x1:o,x2:o,y1:i,stroke:s.color.grayLight}))},M=e=>{let t=e.anchorX,n=e.anchorY,a=e.labelOffsetXPx,l=e.labelOffsetYPx,r=e.left,o=void 0!==r&&r,i=e.children;const s=(0,N.useTheme)();return f.createElement("text",{"data-external-id":"reference-line-label-text",x:t+(o?-1:1)*a,y:n-l,textAnchor:"middle",fontSize:s.fontSize.xsmall,fill:s.color.textLight},i)},L=e=>f.createElement(I.M,Object.assign({"data-external-id":"bar-background"},e,{className:"cursor-pointer",fill:"transparent",stroke:"transparent"}));var O=n(8483),P=n(57432);const B=e=>{let t=e.barDataKeys,n=e.fallbackColor;return f.createElement("div",{"data-external-id":"chart-legend",className:"mt-lg text-center leading-[1.8]"},t.map((e=>{let t=e.name,a=e.label,l=e.color;return f.createElement("div",{key:t,className:"inline-flex items-center justify-center gap-xs not-last:mr-lg"},f.createElement(P.c,{size:12,color:(0,h.A)(l)?n:l}),f.createElement(O.v,{size:"xsmall",color:"textLight",weight:"medium",clampLine
1s:1},null!==a&&void 0!==a?a:t))})))};var z=n(60844),F=n(60150);const G=["className","invisible"],Y=e=>{let t=e.className,n=e.invisible,a=(0,c.A)(e,G);return f.createElement(z.L,Object.assign({"data-external-id":"left-right-scroll"},a,{size:"xsmall",className:(0,F.cn)("size-2xl rounded-round border border-border-primary",n?"cursor-[inherit] opacity-0":"cursor-pointer opacity-100",t)}))};var U=n(71643),V=n(26232);const W=e=>{var t,n,a,l;let r=e.id,i=e.fallbackWidth,c=e.fallbackHeight;const d=(0,V.oM)(),m=(0,f.useState)(!1),p=(0,u.A)(m,2),g=p[0],h=p[1];return f.createElement("defs",{"data-external-id":"line-reveal-clip"},f.createElement("clipPath",{id:r},f.createElement(U.PY1.rect,{x:null!==(t=null===d||void 0===d?void 0:d.x)&&void 0!==t?t:0,y:null!==(n=null===d||void 0===d?void 0:d.y)&&void 0!==n?n:0,height:null!==(a=null===d||void 0===d?void 0:d.height)&&void 0!==a?a:c,initial:{width:0},animate:{width:null!==(l=null===d||void 0===d?void 0:d.width)&&void 0!==l?l:i},transition:g?{duration:0}:{duration:o/1e3,delay:.1,ease:s},onAnimationComplete:()=>h(!0)})))};var j=n(98877);const H=e=>{let t=e.x,n=e.y,a=e.width,l=e.color,r=e.summary;const o=f.createElement("div",{className:"min-w-45 px-sm py-xs"},r.map(((e,t)=>{let n=e.label,a=e.value,l=e.muted;return f.createElement(f.Fragment,{key:t},f.createElement("div",{className:(0,F.cn)("flex items-center justify-between gap-xs",l&&"opacity-60")},f.createElement(O.v,{size:"small",weight:"book"},n),f.createElement(O.v,{size:"small",weight:"medium"},a)))})));return f.createElement("g",{"data-external-id":"summary-info-icon",transform:"translate(".concat(t+a+10,",").concat(n,")")},f.createElement(j.D_,{content:o,side:"top",align:"end"},f.createElement("g",{role:"img","aria-label":r.map((e=>{let t=e.label,n=e.value;return"".concat(t," ").concat(n)})).join(", "),style:{cursor:"pointer",width:"24px",height:"24px"}},f.createElement("rect",{transform:"translate(-12, -12)",width:"24",height:"24",fill:"transparent"}),f.createElement("circle",{r:"6.5",stroke:l,fill:"transparent"}),f.createElement("circle",{r:"3",fill:l}))))};var K=n(88370),q=n(86586),$=n(47197);var Z=n(8134);const J=["y","summary","labels","dashed"],X=["width","height","x","y","index"],Q=e=>{var t,n,a,o,s;let g=e.activeBarIndex,T=e.data,M=e.formatXAxis,O=e.formatYAxis,P=e.heightPx,z=e.barDataKeys,G=e.totalDataKey,U=e.solidLineDataKey,V=e.dashedLineDataKey,j=e.widthPx,Q=e.xAxisDataKey,le=e.tooltipComponent,re=e.xAxisReferenceLines,oe=void 0===re?[]:re,ie=e.xAxisProps,se=e.barWidthPx,ce=e.onBarAreaClick,de=e.activeBarOpacity,ue=void 0===de?1:de,me=e.nonActiveBarOpacity,pe=void 0===me?.32:me,ge=e.barColorInteractive,he=void 0!==ge&&ge,ve=e.yAxis,fe=e.yAxisReferenceLines,Ee=e.hideGrid,ye=e.hideLines,be=e.roundBarCorners,xe=e.minBarWidthPx,we=void 0===xe?48:xe,Ce=e.labelDataKey,Ae=e.labelBarDataKey,Ie=e.labelOffsetPx,ke=void 0===Ie?12:Ie,Se=e.onAnimationEnd,Ne=e.margin,Te=void 0===Ne?{}:Ne,_e=e.withLegend,De=e.horizontalStack,Re=e.formatLabel,Me=e.showSummaryLine,Le=void 0!==Me&&Me,Oe=e.initialPanPosition,Pe=void 0===Oe?"end":Oe,Be=e.verticalLineAtIndex,ze=e.stackOffset,Fe=void 0===ze?"sign":ze,Ge=e.labelColorFn,Ye=e.barStroke,Ue=e.summaryStats;const Ve=(0,$.mM)(),We=null!==(t=Te.top)&&void 0!==t?t:52,je=z.map((e=>e.name)).join(":"),He=String(null!==(n=null===(a=T[0])||void 0===a?void 0:a[Q])&&void 0!==n?n:""),Ke=String(null!==(o=null===(s=T[T.length-1])||void 0===s?void 0:s[Q])&&void 0!==o?o:""),qe="".concat(T.length,":").concat(He,":").concat(Ke,":").concat(je),$e="".concat(j,"-").concat(P,"-").concat(qe),Ze=(0,f.useState)(void 0),Je=(0,u.A)(Ze,2),Xe=Je[0],Qe=Je[1],et=(0,f.useState)($e),tt=(0,u.A)(et,2),nt=tt[0],at=tt[1],lt=(0,f.useState)(!1),rt=(0,u.A)(lt,2),ot=rt[0],it=rt[1],st=(0,f.useState)(!1),ct=(0,u.A)(st,2),dt=ct[0],ut=ct[1],mt=(0,f.useState)(!1),pt=(0,u.A)(mt,2),gt=pt[0],ht=pt[1],vt=(0,f.useMemo)((()=>(0,E.EI)("index")),[]),ft=(0,f.useRef)(qe),Et=(0,f.useRef)(void 0),yt=(0,f.useRef)(!1),bt=(0,f.useRef)(!1),xt="line-reveal-".concat((0,f.useId)().replace(/:/g,"")),wt=(0,f.useRef)(null),Ct=(0,f.useRef)(null),At=(0,f.useCallback)((()=>{ht(!0),Ct.current&&clearTimeout(Ct.current),Ct.current=setTimeout((()=>ht(!1)),i)}),[]);(0,f.useEffect)((()=>{ut(!1);const e=setTimeout((()=>{ut(!0)}),100);return()=>{e&&clearTimeout(e)}}),[nt]),(0,f.useEffect)((()=>()=>{wt.current&&clearTimeout(wt.current),Ct.current&&clearTimeout(Ct.current)}),[nt]);const It=(0,f.useMemo)((()=>T.map(((e,t)=>(0,d.A)((0,d.A)({},e),{},{index:t})))),[T]),kt=(0,N.useTheme)(),St=(0,f.useCallback)(((e,t,n)=>void 0===t?1:he?e===t||e===n?ue:pe:1),[ue,pe,he]),Nt=It.length,Tt=Math.floor((j-2*r)/(1.5*we)),_t=Math.floor(Tt/2),Dt=((e,t)=>{const n=(0,f.useState)(0),a=(0,u.A)(n,2),l=a[0],r=a[1],o=Math.max(0,e-t),i=Math.min(o,Math.max(0,l)),s=i<o,c=0!==i;return(0,f.useEffect)((()=>{r((e=>Math.min(o,Math.max(0,e))))}),[o]),{panLeft:(0,f.useCallback)((e=>{if(s){const t=Math.min(o,i+e);r(t)}}
1),[i,s,o]),panRight:(0,f.useCallback)((e=>{if(c){const t=Math.max(0,i-e);r(t)}}),[i,c]),panCount:i,canPanLeft:s,canPanRight:c,setPanCount:r}})(Nt,Tt),Rt=Dt.panLeft,Mt=Dt.panRight,Lt=Dt.panCount,Ot=Dt.canPanLeft,Pt=Dt.canPanRight,Bt=Dt.setPanCount,zt=ft.current!==qe;zt&&(yt.current=!1,bt.current=!1,Et.current=void 0),nt===$e||!zt&&ot||(ft.current=qe,at($e),ut(!1),ht(!1));const Ft=null!==se&&void 0!==se?se:1===Nt?64:void 0,Gt=!ot&&!bt.current,Yt=Nt>Tt&&!Ve,Ut=Nt-Tt,Vt=j-(Yt?2*r:0);(0,f.useEffect)((()=>{if(!Yt)return yt.current=!1,Et.current=void 0,void Bt(0);if(Tt<=0)return;const e=e=>{yt.current&&(bt.current=!0),Bt((0,q.wq)({dataLength:Nt,barIndex:e,maxBars:Tt})),yt.current=!0,Et.current=e};if(void 0!==g&&g>=0){if(!yt.current)return void e(g);if(Et.current!==g){const t=(0,q.Hh)({dataLength:Nt,maxBars:Tt,offsetFromEnd:Lt}),n=t.start,a=t.end;if(g<n||g>=a)return void e(g);Et.current=g}}else Et.current=void 0,yt.current||(yt.current=!0,Bt("start"===Pe?Ut:0))}),[g,Yt,Nt,Pe,Tt,Ut,Lt,Bt,qe]);const Wt=Nt-Math.min(Tt,Nt)-(Yt?Lt:0),jt=Nt-(Yt?Lt:0),Ht=(0,f.useMemo)((()=>It.slice(Wt,jt)),[It,Wt,jt]),Kt=(0,f.useRef)({lower:Wt,upper:jt}),qt=(0,f.useReducer)(ee,void 0,(()=>(0,d.A)((0,d.A)({},te({lower:Wt,upper:jt,panSizeIntervals:_t,dataLength:Nt})),{},{fromSettle:!1}))),$t=(0,u.A)(qt,2),Zt=$t[0],Jt=$t[1];(zt||Kt.current.lower!==Wt||Kt.current.upper!==jt)&&(Kt.current={lower:Wt,upper:jt},Jt({type:"boundsChanged",lower:Wt,upper:jt,padded:te({lower:Wt,upper:jt,panSizeIntervals:_t,dataLength:Nt}),replace:zt||!bt.current}));const Xt=Zt.fromSettle,Qt=(0,f.useMemo)((()=>It.slice(Zt.lower,Zt.upper)),[It,Zt]),en=(0,f.useMemo)((()=>G?[...It.map((e=>e[G]))]:[]),[It,G]),tn=(0,f.useMemo)((()=>{var e;return Le?null!==(e=null===Ue||void 0===Ue?void 0:Ue.average)&&void 0!==e?e:ne(en):void 0}),[en,Le,Ue]),nn=(0,f.useMemo)((()=>{var e;return Le?null!==(e=null===Ue||void 0===Ue?void 0:Ue.median)&&void 0!==e?e:ae(en):void 0}),[en,Le,Ue]),an=null!==U&&void 0!==U?U:G,ln=(0,f.useMemo)((()=>{const e=z.map((e=>{let t=e.name;return[...Ht.map((e=>e[t]))]})),t=!ye||!De,n=Ht.map((e=>({positive:z.reduce(((t,n)=>{let a=n.name;const l=e[a]||0;return t+(l>0?l:0)}),0),negative:z.reduce(((t,n)=>{let a=n.name;const l=e[a]||0;return t+(l<0?l:0)}),0)}))),a=t?[...n.map((e=>e.positive))]:[],l=t?[...n.map((e=>e.negative))]:[],r=G&&t?[...Ht.map((e=>e[G]))]:[],o=V&&t?[...Ht.map((e=>e[V]))]:[];return(0,q.gE)([...(0,m.A)(e),...a,...l,...r,...o],1.1,0,100)}),[z,ye,De,G,V,Ht]),rn=(0,u.A)(ln,2),on=rn[0],sn=rn[1],cn=[...null!==fe&&void 0!==fe?fe:[],...Le?[{y:tn,stroke:kt.color.gray12,dashed:!0,summary:[{label:"Average",value:(0,Z.vv)(tn)},{label:"Median",value:(0,Z.vv)(nn),muted:!0}]}]:[],{y:0,labels:[]}],dn=Ve?void 0:"url(#".concat(xt,")");return f.createElement("div",{"data-external-id":"stacked-bar-chart",className:(0,F.cn)("flex items-center [&_.recharts-tooltip-wrapper]:z-tooltip",K.TN.className)},Yt&&f.createElement(Y,{icon:"arrow-left",invisible:!Ot,onClick:()=>{bt.current=!0,Rt(_t),At()}}),f.createElement(y.X,{data:Qt,height:P,width:Vt,stackOffset:Fe,margin:(0,d.A)({top:52,bottom:5,left:0,right:Yt?30:0},Te),key:nt,barCategoryGap:"15%"},!ye&&!Ve&&f.createElement(W,{id:xt,fallbackWidth:Vt,fallbackHeight:P}),!Ee&&f.createElement(_.d,null),le&&!Ve&&f.createElement(b.m,{cursor:!1,content:le,offset:parseInt(kt.spacing.xxlarge,10),useTranslate3d:!0}),f.createElement(x.W,Object.assign({tick:{fontSize:kt.fontSize.xsmall,fill:kt.color.textLight,fontWeight:parseInt(kt.fontWeight.medium,10),transform:"translate(0, ".concat(l,")"),width:80},ticks:(0,p.A)(Wt,jt),stroke:kt.color.gray,dataKey:"index",tickFormatter:(e,t)=>{var n,a;return null!==(n=null===M||void 0===M?void 0:M(null===(a=It[e])||void 0===a?void 0:a[Q],e))&&void 0!==n?n:e.toString()},allowDataOverflow:!0,interval:0,type:"number",domain:[-.5+Wt,-.5+jt],tickLine:!1,axisLine:!1},ie)),(()=>{const e=(0,h.A)(ve)?ve(Ht):ve;return void 0!==e?e:f.createElement(w.h,{tick:{fontSize:kt.fontSize.xsmall,fill:kt.color.textLight,fontWeight:parseInt(kt.fontWeight.medium,10),transform:"translate(".concat(-1*l,", 0)")}
1,stroke:kt.color.gray,tickFormatter:O,tickLine:!1,axisLine:!1,allowDataOverflow:!0,domain:[on,sn]})})(),oe.map((e=>{let t=e.x,n=e.leftLabelText,a=e.rightLabelText;const l=It.findIndex((e=>{let n=e[Q];return t===n}));return l!==Wt&&l!==jt?f.createElement(C.e_,{key:"".concat(t,"-").concat(l),x:l-.5,stroke:kt.color.grayFocus,label:e=>f.createElement(R,Object.assign({},e,{leftLabelText:n,rightLabelText:a,labelOffsetXPx:40,labelOffsetYPx:We/2})),position:"start"}):null})),cn.map(((e,t)=>{let n=e.y,a=e.summary,l=e.labels,r=e.dashed,o=(0,c.A)(e,J);return f.createElement(C.e_,Object.assign({key:"".concat(n,"-").concat(t),y:n,stroke:kt.color.grayFocus,strokeDasharray:r?"4 4":void 0,position:"start"},o,{label:e=>{const t=e.viewBox,n=t.x,r=t.y,o=t.width;return(0,v.A)(a)?f.createElement(H,{x:n,y:r,width:o,color:kt.color.gray12,summary:a}):f.createElement("g",{transform:"translate(".concat(n,",").concat(r,")")},f.createElement("text",{x:0,y:0,fill:kt.color.textLight,fontWeight:kt.fontWeight.medium,fontSize:kt.fontSize.small},null===l||void 0===l?void 0:l.map(((e,t)=>f.createElement("tspan",{key:t,x:"0",y:"".concat(21*t),textAnchor:"end"},e)))))}}))})),z.map(((e,t)=>f.createElement(A.yP,Object.assign({key:e.name,dataKey:e.name,stackId:De?e.name:"STACK_ID"},ce?{onClick:e=>ce(e),tabIndex:0,role:"button",onKeyDown:(e,t,n)=>{"Enter"!==n.key&&" "!==n.key||(n.preventDefault(),ce(e))}}:{},{onMouseEnter:he?e=>Qe(e.payload.index):void 0,onMouseLeave:he?()=>Qe(void 0):void 0,isAnimationActive:!Ve&&!Xt,animationMatchBy:vt,onAnimationEnd:()=>{Jt({type:"settle",next:te({lower:Wt,upper:jt,panSizeIntervals:_t,dataLength:Nt})}),ot||t!==z.length-1||(wt.current=setTimeout((()=>{it(!0),null===Se||void 0===Se||Se()}),i*(z.length+1)))},cursor:"pointer",background:e=>{const t=e,n=t.width,a=t.height,l=t.x,r=t.y,o=t.index,i=(0,c.A)(t,X);return f.createElement(L,{key:o,width:2*n,height:a,x:l-n/2,y:r,onClick:()=>null===ce||void 0===ce?void 0:ce(i)})},animationBegin:!De&&Gt?i*(t+1):void 0,animationDuration:De||Gt?i:void 0},Ft?{barSize:Ft}:{},{shape:t=>{var n;const a=t[e.name],l=null!==(n=t.payload)&&void 0!==n?n:t,r=l.index,o=e.color,i="string"===typeof o?o:o({amount:a,index:r,hoveredBarIndex:Xe,activeBarIndex:g}),s=f.createElement(I.M,Object.assign({},t,{key:"rectangle-".concat(r),fill:i,opacity:St(r,g,Xe),radius:be?[6,6,0,0]:[0,0,0,0],stroke:null!==Ye&&void 0!==Ye?Ye:"none",strokeWidth:Ye?1:0,style:{filter:"brightness(".concat(he&&Xe===r?.75:1,")")}}));if(!Ce||De||!dt)return s;if(Wt>r||r>=jt)return s;const c=null!==Ae&&void 0!==Ae?Ae:((e,t)=>{var n,a;const l=[...t].reverse().find((t=>{let n=t.name;const a=e[n];return"number"===typeof a&&a>0}));return null!==(n=null===l||void 0===l?void 0:l.name)&&void 0!==n?n:null===(a=t[t.length-1])||void 0===a?void 0:a.name})(l,z);if(e.name!==c)return s;if(null===t.x||!t.width)return s;const d=l[Ce];let u="";return void 0!==d&&(u=String(Re?Re(d):d)),u?f.createElement("g",null,s,f.createElement("text",{x:t.x+t.width/2,y:t.y-ke,textAnchor:"middle",fill:Ge?Ge(d):kt.color.text,fontSize:kt.fontSize.xsmall,fontWeight:kt.fontWeight.medium,style:{pointerEvents:"none"}},u)):s}})))),!ye&&!!an&&f.createElement(k.N1,{stroke:kt.variables.color.content.primary,strokeWidth:D.DJ,dataKey:an,"aria-label":"Total",strokeLinecap:"round",dot:!1,isAnimationActive:!Ve&&!Xt&&(!ot||gt),animationMatchBy:vt,animationDuration:i,activeDot:{strokeWidth:0,r:6,style:{pointerEvents:"none"}},style:{pointerEvents:"none",clipPath:dn}}),!ye&&!!V&&f.createElement(k.N1,{dataKey:V,"aria-label":"Current period",stroke:kt.variables.color.content.primary,strokeWidth:D.DJ,strokeLinecap:"round",strokeDasharray:"4 10",dot:!1,isAnimationActive:!Ve&&!Xt&&(!ot||gt),animationMatchBy:vt,animationDuration:i,style:{pointerEvents:"none",clipPath:dn}}),void 0!==Be&&Be>=Wt&&Be<=jt&&f.createElement(C.e_,{x:Be,stroke:kt.color.black,strokeWidth:2,label:e=>{const t=e.viewBox,n=t.x,a=t.y;return f.createElement("text",{x:n,y:a-10,textAnchor:"middle",fill:kt.color.text,fontSize:kt.fontSize.small,fontWeight:kt.fontWeight.medium},"Today")}}),_e&&f.createElement(S.s,{content:()=>f.createElement(B,{barDataKeys:z,fallbackColor:kt.color.gray})})),Yt&&f.createElement(Y,{icon:"arrow-right",invisible:!Pt,onClick:()=>{bt.current=!0,Mt(_t),At()}}))},ee=(e,t)=>
1(0,T.YW)(t).with({type:"boundsChanged"},(t=>{let n=t.lower,a=t.upper,l=t.padded;return t.replace?(0,d.A)((0,d.A)({},l),{},{fromSettle:!1}):e.lower<=n&&e.upper>=a?e.fromSettle?(0,d.A)((0,d.A)({},e),{},{fromSettle:!1}):e:{lower:Math.min(e.lower,l.lower),upper:Math.max(e.upper,l.upper),fromSettle:!1}})).with({type:"settle"},(t=>{let n=t.next;return e.lower===n.lower&&e.upper===n.upper?e:(0,d.A)((0,d.A)({},n),{},{fromSettle:!0})})).exhaustive(),te=e=>{let t=e.lower,n=e.upper,a=e.panSizeIntervals,l=e.dataLength;return{lower:Math.max(0,t-a-1),upper:Math.min(l,n+a+1)}},ne=e=>e.reduce(((e,t)=>e+(t||0)),0)/e.length,ae=e=>(0,g.A)(((e,t)=>(e||0)-(t||0)),e)[Math.floor(e.length/2)]},6141:(e,t,n)=>{n.d(t,{$l:()=>o,Ly:()=>u,YY:()=>h,k3:()=>c,nt:()=>s,pT:()=>g,q9:()=>d,y2:()=>i});var a=n(36938),l=n(4731),r=n(88370);const o=14,i=500,s=11,c=400,d=12,u=500,m=18,p={textShadow:"0px 1px 2px rgba(0, 0, 0, 0.55)"},g=e=>{let t=e.primaryLabel,n=e.secondaryLabel,g=e.valueText,h=e.secondaryValueText,v=e.textColor,f=e.anchor,E=e.maxWidth,y=e.primaryMaxLines,b=void 0===y?1:y,x=e.dropShadow,w=void 0===x||x;const C=null!==n,A=void 0!==E?(0,l.$V)(t,E,b,(e=>(0,l.WI)(e,o,i))):[t],I=C&&void 0!==E?(0,l.A4)(n,E,(e=>(0,l.WI)(e,s,c))):n,k=[...A.map((e=>({text:e,fontSize:o,fontWeight:i,lineHeight:20}))),...C?[{text:null!==I&&void 0!==I?I:"",fontSize:s,fontWeight:c,lineHeight:16,opacity:.85}]:[],{text:g,fontSize:d,fontWeight:u,lineHeight:m,sensitive:!0},...h?[{text:h,fontSize:d,fontWeight:u,lineHeight:m,sensitive:!0}]:[]].filter((e=>""!==e.text));return a.createElement("g",{"data-external-id":"pivot-label",style:w?p:void 0},k.reduce(((e,t,n)=>{let l=e.elements,o=e.offsetY;return{elements:[...l,a.createElement("text",Object.assign({key:n,x:f.x,y:f.y+o+t.lineHeight/2,textAnchor:"start",dominantBaseline:"middle",fill:v,fontSize:t.fontSize,fontWeight:t.fontWeight,opacity:t.opacity},t.sensitive?r.TN:void 0),t.text)],offsetY:o+t.lineHeight}}),{elements:[],offsetY:0}).elements)},h=e=>{let t=e.hasSecondaryLabel,n=e.hasValue,a=void 0===n||n,l=e.hasSecondaryValue,r=e.primaryLines,o=void 0===r?1:r;return 20*Math.max(1,o)+(t?16:0)+(a?m:0)+(l?m:0)}},97499:(e,t,n)=>{n.d(t,{V:()=>S});var a=n(68622),l=n(16877),r=n(71643),o=n(36938),i=n(46995),s=n(98877),c=n(88370),d=n(88986);const u=e=>{var t;let n=e.open,a=e.anchorRect,l=e.preferredSide,r=e.layout;const c=null!==r.otherCount;return o.createElement(i.bL,{"data-external-id":"cell-tooltip",open:n},o.createElement(i.l9,{asChild:!0},o.createElement("div",{"aria-hidden":!0,style:{position:"absolute",left:a.x,top:a.y,width:a.width,height:a.height,pointerEvents:"none"}})),o.createElement(d.J,{omitWrapper:!0},o.createElement(i.ZL,null,o.createElement(s.A1,{side:l,sideOffset:4,collisionPadding:8,$maxWidth:256,"data-theme":"dark",className:"pointer-events-none"},c?o.createElement(p,{label:r.tooltip.primaryLabel,count:null!==(t=r.otherCount)&&void 0!==t?t:0,valueText:r.tooltip.valueText,secondaryValueText:r.tooltip.secondaryValueText}):o.createElement(m,{primaryLabel:r.tooltip.primaryLabel,secondaryLabel:r.tooltip.secondaryLabel,valueText:r.tooltip.valueText,secondaryValueText:r.tooltip.secondaryValueText,isInflow:r.isInflow})))))},m=e=>{let t=e.primaryLabel,n=e.secondaryLabel,a=e.valueText,l=e.secondaryValueText,r=e.isInflow,i=void 0!==r&&r;return o.createElement("div",{"data-external-id":"cell-tooltip-content",className:"flex flex-col gap-2xs px-sm py-xs"},t&&o.createElement("div",{className:"text-base/6 font-medium"},t),n&&o.createElement("div",{className:"text-xs/4.5 text-content-secondary"},n),o.createElement("div",{className:"flex flex-col gap-3xs text-xs/4.5 font-medium whitespace-nowrap"},o.createElement("div",c.zs,a),l&&o.createElement("div",c.zs,l)),i&&o.createElement("div",{className:"text-xs/4.5 text-content-secondary"},"This had more inflows than outflows. It is possible that you had a refund, mis-categorized income, or another inflow."))},p=e=>{let t=e.label,n=e.count,a=e.valueText,l=e.secondaryValueText;return o.createElement("div",{"data-external-id":"other-cell-tooltip-content",className:"flex flex-col gap-2xs px-sm py-xs whitespace-nowrap"},t&&o.createElement("div",{className:"text-base/6 font-medium"},t),o.createElement("div",{className:"flex flex-col gap-3xs text-xs/4.5 font-medium"},o.createElement("div",null,n," more"),o.createElement("div",c.zs,a),l&&o.createElement("div",c.zs,l)))};var g=n(59528),h=n(20361),v=n(6141),f=n(4731),E=n(3788);const y=(e,t)=>{var n,a,l,r,o;let i=t.formatValue,s=t.formatSecondaryValue,c=t.minLabelCellWidth,d=t.minLabelCellHeight,u=t.allowCompactLabels,m=void 0!==u&&u;const p=e.data,y=e.rect,b=e.value,x=y.width,w=y.height,C=!(!p.logoUrl&&!p.icon),A=(e=>
1{let t=e.width,n=e.height;return e.hasBadge&&t>=g.p1&&n>=g.rk})({width:x,height:w,hasBadge:C}),I=A?Math.max(0,w-(g.PT+g.Gd)):w,k=null!==(n=(0,E.QK)(p.primaryLabel))&&void 0!==n?n:p.id,S=p.icon?"".concat(p.icon," ").concat(k):k,N=(0,E.UO)(p.primaryLabel),T=(0,E.QK)(p.secondaryLabel),_=(0,E.UO)(p.secondaryLabel),D=i(null!==(a=p.displayValue)&&void 0!==a?a:b),R=null!==(l=null===s||void 0===s?void 0:s(b))&&void 0!==l?l:null,M=null!==(r=p.otherCount)&&void 0!==r?r:null,L=null!==T&&(0,E.tv)(_)?T:null,O={primaryLabel:(0,E.u8)(N)?S:null,secondaryLabel:null!==T&&(0,E.u8)(_)?T:null,valueText:D,secondaryValueText:R},P=null!==L,B=null!==R,z=function(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1;return Math.max(d,(0,v.YY)({hasSecondaryLabel:P,hasValue:e,hasSecondaryValue:t,primaryLines:n})+2*g.rv)},F=Math.max(0,x-2*g.O2),G=e=>(0,f.WI)(e,v.$l,v.y2),Y=null!==L&&(0,f.WI)(L,v.nt,v.k3)>F,U=(0,f.WI)(D,v.q9,v.Ly),V=B?(0,f.WI)(R,v.q9,v.Ly):0,W=x>=c,j=U<=F,H=V<=F,K=z(!0,!1),q=z(!0,B),$=e=>{const t=e+g.GE>=q,n=W&&t&&j&&(!B||H),a=m&&W&&e>=K&&j,l=m&&W&&e>=z(!1,!1);return(0,h.YW)({fitsFull:n,fitsValueOnly:a,fitsNameOnly:l}).with({fitsFull:!0},(()=>({showLabel:!0,showValueLine:!0,showSecondaryValueLine:B}))).with({fitsValueOnly:!0},(()=>({showLabel:!0,showValueLine:!0,showSecondaryValueLine:!1}))).with({fitsNameOnly:!0},(()=>({showLabel:!0,showValueLine:!1,showSecondaryValueLine:!1}))).otherwise((()=>({showLabel:!1,showValueLine:!1,showSecondaryValueLine:!1})))},Z=$(I),J=$(w),X=A&&J.showLabel&&Z.showLabel===J.showLabel&&Z.showValueLine===J.showValueLine&&Z.showSecondaryValueLine===J.showSecondaryValueLine,Q=X?I:w,ee=X?Z:J,te=ee.showLabel,ne=ee.showValueLine,ae=ee.showSecondaryValueLine,le=te?null:(e=>{let t=e.width,n=e.height;return e.hasBadge?t>=g.vF&&n>=g.ws?g.PT:t>=g.cQ&&n>=g.Py?g.bs:null:null})({width:x,height:w,hasBadge:C});let re=null;te&&X?re={mode:"stacked",size:g.PT}:null!==le&&(re={mode:"lone",size:le});const oe="stacked"===(null===(o=re)||void 0===o?void 0:o.mode)?k:S,ie={primaryLabel:(0,E.tv)(N)?oe:null,secondaryLabel:L,valueText:D,secondaryValueText:R},se=null!==ie.primaryLabel&&G(ie.primaryLabel)>F;let ce=1;if(m&&te&&se)for(let h=g.aL;h>1;h-=1)if(Q>=z(ne,ae,h)){ce=h;break}const de=null!==ie.primaryLabel&&(ce>1?(0,f.$V)(ie.primaryLabel,F,ce,G).some((e=>e.endsWith("\u2026"))):se),ue=null!==O.primaryLabel&&null===ie.primaryLabel||null!==O.secondaryLabel&&null===ie.secondaryLabel,me=!te||te&&(!ne||B&&!ae)||de||Y||null!==M||!0===p.isInflow||ue;return{tile:ie,tooltip:O,otherCount:M,isInflow:!0===p.isInflow,badge:re,showLabel:te,showValueLine:ne,showSecondaryValueLine:ae,primaryMaxLines:ce,showTooltip:me,labelMaxWidth:F}},b=e=>{var t,n,a,l,r,i,s,c,d,u;let m=e.renderable,p=e.cellKey,h=e.hoveredKey,v=e.timings,f=e.formatValue,b=e.formatSecondaryValue,w=e.cellCornerRadius,C=e.minLabelCellWidth,A=e.minLabelCellHeight,I=e.allowCompactLabels,k=void 0!==I&&I,S=e.renderLabel,N=e.onClick,T=e.leavesClickable,_=void 0!==T&&T,D=e.isSelected,R=void 0!==D&&D,M=e.isSelectionActive,L=void 0!==M&&M;const O=m.data,P=m.rect,B=m.isDrillable||_,z=P.x,F=P.y,G=P.width,Y=P.height,U=0===m.value?O.empty:void 0,V=null!==(t=null!==(n=null===U||void 0===U?void 0:U.text)&&void 0!==n?n:O.text)&&void 0!==t?t:g.hV,W=!(0,g.Kh)(V),j=y(m,{formatValue:f,formatSecondaryValue:b,minLabelCellWidth:C,minLabelCellHeight:A,allowCompactLabels:k}),H=j.tile,K=j.showLabel,q=j.showValueLine,$=j.showSecondaryValueLine,Z=j.primaryMaxLines,J=j.labelMaxWidth,X=j.badge,Q=null!==(a=(0,E.QK)(O.primaryLabel))&&void 0!==a?a:O.id,ee=(0,E.QK)(O.secondaryLabel),te="".concat(Q).concat(ee?" ".concat(ee):"",": ").concat(H.valueText).concat(H.secondaryValueText?" (".concat(H.secondaryValueText,")"):""),ne=h===p,ae=null!==(l=null!==(r=null===U||void 0===U?void 0:U.background)&&void 0!==r?r:O.background)&&void 0!==l?l:g.Ou,le=ne&&!U&&null!==(i=O.backgroundHover)&&void 0!==i?i:ae,re=L&&!R&&!ne,oe=(0,g.Kh)(V)?g.Im:g.M2,ie=null!==(s=null===U||void 0===U?void 0:U.stripeColor)&&void 0!==s?s:O.isInflow?oe:void 0,se=o.useId().replace(/:/g,""),ce="treemap-hatch-".concat(se),de=Math.min(w,G/2,Y/2),ue=(e=>"stacked"===(null===e||void 0===e?void 0:e.mode)?g.PT+g.Gd:0)(X),me="stacked"===(null===X||void 0===X?void 0:X.mode)?z+g.O2:z+(G-(null!==(c=null===X||void 0===X?void 0:X.size)&&void 0!==c?c:0))/2,pe="stacked"===(null===X||void 0===X?void 0:X.mode)?F+g.rv:F+(Y-(null!==(d=null===X||void 0===X?void 0:X.size)&&void 0!==d?d:0))/2;return o.createElement("g",{"data-external-id":"leaf-cell",onClick:B?()=>N(m):void 0,style:{cursor:B?"pointer":void 0,opacity:re?.5:1,transition:"opacity ".concat(v.hoverDuration,"s ease-out")},"aria-label":te},ie&&o.createElement("defs",null,o.createElement("pattern",{id:ce,width:g.Mk,height:g.Mk,patternUnits:"userSpaceOnUse"},o.createElement("line",{x1:g.Mk+1,y1:-1,x2:-1,y2:g.Mk+1,stroke:ie,strokeWidth:g.Od}))),o.createElement("rect",{x:z,y:F,width:G,height:Y,rx:de,ry:de,fill:le,style:{transition:"fill ".concat(v.hoverDuration,"s ease-out")}}),ie&&o.createElement("rect",{x:z,y:F,width:G,height:Y,rx:w,ry:w,fill:"url(#".concat(ce,")")}),X&&o.createElement(x,{x:me,y:pe,size:X.size,icon:O.icon,logoUrl:O.logoUrl,clipId:"treemap-badge-".concat(se)}),K&&S({primaryLabel:null!==(u=H.primaryLabel)&&void 0!==u?u:"",secondaryLabel:H.secondaryLabel,valueText:q?H.valueText:"",secondaryValueText:$?H.secondaryValueText:null,textColor:V,anchor:{x:z+g.O2,y:F+g.rv+ue},maxWidth:J,primaryMaxLines:Z,dropShadow:W}))},x=e=>
1{let t=e.x,n=e.y,a=e.size,l=e.icon,r=e.logoUrl,i=e.clipId;const s=a/2,c=t+s,d=n+s,u=g.BS/2;return r?o.createElement("g",{"data-external-id":"tile-badge"},o.createElement("defs",null,o.createElement("clipPath",{id:i},o.createElement("circle",{cx:c,cy:d,r:s-u}))),o.createElement("image",{href:r,x:t,y:n,width:a,height:a,preserveAspectRatio:"xMidYMid slice",clipPath:"url(#".concat(i,")")}),o.createElement("circle",{cx:c,cy:d,r:s-u,fill:"none",stroke:g.mc,strokeWidth:g.BS})):l?o.createElement("text",{"data-external-id":"tile-badge",x:c,y:d,fontSize:Math.round(18*a/g.PT),textAnchor:"middle",dominantBaseline:"central"},l):null};var w=n(85451);const C=(e,t)=>e.length===t.length&&e.every(((e,n)=>e===t[n])),A=e=>Array.from({length:e.length+1},((t,n)=>e.slice(0,n)));var I=n(47197),k=n(34527);const S=e=>{var t,n;let i=e.tree,s=e.formatValue,c=e.formatSecondaryValue,d=e.speed,m=void 0===d?g.Mo:d,p=e.cellGap,h=void 0===p?g.Ml:p,v=e.cellCornerRadius,f=void 0===v?g.gR:v,x=e.minLabelCellWidth,S=void 0===x?g.Sj:x,D=e.minLabelCellHeight,R=void 0===D?g.d7:D,M=e.onLeafClick,L=e.onFocusChange,O=e.renderHeader,P=e.renderLabel,B=void 0===P?N:P,z=e.selectedLeafId,F=e.layoutMode,G=void 0===F?"ordered":F,Y=e.contentViewKey,U=e.seedFocusPath;const V=(0,I.mM)(),W=(0,k.W)(),j=(0,a.A)(W,2),H=j[0],K=j[1],q=null!==(t=K.width)&&void 0!==t?t:0,$=null!==(n=K.height)&&void 0!==n?n:0,Z=(e=>(0,o.useMemo)((()=>{const t=.3*e;return{crossfadeDuration:t,crossfadeStartScale:.97,hoverDuration:.15*e,transitionTotalMs:Math.ceil(1e3*t)+50}}),[e]))(m),J=(e=>{let t=e.timings,n=e.resetKey,l=e.seedFocusPath;const r=null!==l&&void 0!==l?l:[],i=r.join("\0"),s=(0,o.useState)((()=>A(r))),c=(0,a.A)(s,2),d=c[0],u=c[1],m=(0,o.useState)(!1),p=(0,a.A)(m,2),g=p[0],h=p[1],v=(0,o.useRef)(),f=(0,o.useCallback)((()=>{h(!0),window.clearTimeout(v.current),v.current=window.setTimeout((()=>h(!1)),t.transitionTotalMs)}),[t.transitionTotalMs]);(0,o.useEffect)((()=>()=>window.clearTimeout(v.current)),[]);const E=(0,o.useRef)(n),y=(0,o.useRef)(i),b=void 0!==n&&E.current!==n,x=y.current!==i;if(b||x){var w;E.current=n,y.current=i;const e=null!==(w=d[d.length-1])&&void 0!==w?w:[];!b&&C(e,r)||u(A(r))}const I=d[d.length-1],k=(0,o.useRef)(!1);(0,o.useEffect)((()=>{void 0!==n&&(k.current?f():k.current=!0)}),[n,f]);const S=(0,o.useCallback)((e=>{g||(f(),u((t=>[...t,e.drillPath])))}),[g,f]),N=(0,o.useCallback)((()=>{g||d.length<=1||(f(),u((e=>e.slice(0,-1))))}),[g,d.length,f]),T=(0,o.useCallback)((e=>{var t;if(g)return;const n=null!==(t=d[d.length-1])&&void 0!==t?t:[];C(n,e)||(f(),u(A(e)))}),[g,d,f]);return{focusPath:I,canGoBack:d.length>1,isAnimating:g,handleDrillIn:S,handleBack:N,handleNavigateTo:T}})({timings:Z,resetKey:Y,seedFocusPath:U}),X=J.focusPath,Q=J.canGoBack,ee=J.isAnimating,te=J.handleDrillIn,ne=J.handleBack,ae=J.handleNavigateTo,le=(0,o.useRef)(L);le.current=L,(0,o.useEffect)((()=>{var e;null===(e=le.current)||void 0===e||e.call(le,X)}),[X]);const re=(0,o.useMemo)((()=>{var e;return null!==(e=(0,w.th)(i,X))&&void 0!==e?e:i}),[i,X]),oe=(0,o.useMemo)((()=>X.reduce(((e,t)=>{var n,a;let l=e.node,r=e.segments;const o=null===l||void 0===l||null===(n=l.children)||void 0===n?void 0:n.find((e=>e.id===t));if(!o)return{node:void 0,segments:r};const i=[...r.map((e=>e.id)),t];return{node:o,segments:[...r,{id:t,label:null!==(a=(0,E.QK)(o.primaryLabel))&&void 0!==a?a:o.id,path:i}]}}),{node:i,segments:[]}).segments),[i,X]),ie=(0,o.useMemo)((()=>q<=0||$<=0?[]:(0,w.ue)(re,X,q,$,i,h,G)),[re,X,q,$,i,h,G]),se=(e=>{let t=e.renderableLeaves,n=e.isAnimating;const l=(0,o.useState)(null),r=(0,a.A)(l,2),i=r[0],s=r[1],c=(0,o.useRef)(null),d=(0,o.useCallback)(((e,n)=>t.reduce(((t,a)=>{const l=a.rect,r=Math.max(l.x-e,0,e-(l.x+l.width)),o=Math.max(l.y-n,0,n-(l.y+l.height)),i=r*r+o*o;return i>=t.distanceSquared?t:{key:"".concat(a.data.id,":").concat(a.drillPath.join(">")),distanceSquared:i}}),{key:null,distanceSquared:1/0}).key),[t]),u=(0,o.useCallback)((e=>{const t=e.currentTarget.getBoundingClientRect(),a=e.clientX-t.left,l=e.clientY-t.top;c.current={x:a,y:l},n||s(d(a,l))}),[n,d]),m=(0,o.useCallback)((()=>{c.current=null,s(null)}),[]);return(0,o.useEffect)((()=>
1{if(n)return;const e=c.current;e&&s(d(e.x,e.y))}),[n,d]),{hoveredKey:i,handleSvgMouseMove:u,handleSvgMouseLeave:m}})({renderableLeaves:ie,isAnimating:ee}),ce=se.hoveredKey,de=se.handleSvgMouseMove,ue=se.handleSvgMouseLeave,me=(0,o.useMemo)((()=>null!==z&&void 0!==z&&ie.some((e=>e.data.id===z))?z:null),[z,ie]),pe=e=>{ee||(e.isDrillable?te(e):null===M||void 0===M||M(e.data,e.drillPath))},ge=X.join(">")||"root",he=Y?"".concat(Y,"::").concat(ge):ge,ve=(0,o.useMemo)((()=>{const e=ie.find((e=>T(e)===ce));return e?{anchorRect:e.rect,preferredSide:_(e.rect,q),layout:y(e,{formatValue:s,formatSecondaryValue:c,minLabelCellWidth:S,minLabelCellHeight:R,allowCompactLabels:"squarify"===G})}:null}),[ie,ce,q,s,c,S,R,G]),fe=!V&&!0===(null===ve||void 0===ve?void 0:ve.layout.showTooltip)&&!ee,Ee=(0,o.useState)(null),ye=(0,a.A)(Ee,2),be=ye[0],xe=ye[1];(0,o.useEffect)((()=>{if(!fe||null===ce)return void xe(null);const e=setTimeout((()=>xe(ce)),200);return()=>clearTimeout(e)}),[fe,ce]);const we=fe&&be===ce,Ce=(0,o.useRef)(ve);we&&ve&&(Ce.current=ve);const Ae=Ce.current,Ie=ie.map((e=>{const t=T(e);return o.createElement(b,{key:t,cellKey:t,renderable:e,hoveredKey:V?null:ce,isSelected:null!==me&&e.data.id===me,isSelectionActive:null!==me,onClick:pe,leavesClickable:!!M,timings:Z,formatValue:s,formatSecondaryValue:c,cellCornerRadius:f,minLabelCellWidth:S,minLabelCellHeight:R,allowCompactLabels:"squarify"===G,renderLabel:B})}));return o.createElement("div",{"data-external-id":"treemap",className:"flex size-full flex-col"},null===O||void 0===O?void 0:O({breadcrumb:oe,canGoBack:Q,onBack:ne,navigateTo:ae}),o.createElement("div",{ref:H,className:"relative min-h-0 flex-1"},q>0&&$>0&&o.createElement("svg",{width:q,height:$,onMouseMove:V?void 0:de,onMouseLeave:V?void 0:ue},V?o.createElement("g",{key:he},Ie):o.createElement(l.N,{initial:!1},o.createElement(r.PY1.g,{key:he,initial:{opacity:0,scale:Z.crossfadeStartScale},animate:{opacity:1,scale:1},exit:{opacity:0,scale:Z.crossfadeStartScale},transition:{duration:Z.crossfadeDuration,ease:"easeInOut"},style:{transformOrigin:"".concat(q/2,"px ").concat($/2,"px")}},Ie))),Ae&&o.createElement(u,{open:we,anchorRect:Ae.anchorRect,preferredSide:Ae.preferredSide,layout:Ae.layout})))},N=e=>o.createElement(v.pT,e),T=e=>"".concat(e.data.id,":").concat(e.drillPath.join(">")),_=(e,t)=>Math.max(t-(e.x+e.width),e.x)>=268?"right":"top"},59528:(e,t,n)=>{n.d(t,{BS:()=>h,GE:()=>A,Gd:()=>f,H6:()=>s,Im:()=>_,Kh:()=>T,M2:()=>D,Mk:()=>R,Ml:()=>l,Mo:()=>I,O2:()=>u,Od:()=>M,Ou:()=>k,PT:()=>p,Py:()=>C,Sj:()=>o,aL:()=>c,bs:()=>g,cQ:()=>w,d7:()=>i,gR:()=>r,hV:()=>S,hr:()=>d,jJ:()=>a,mc:()=>v,p1:()=>E,rk:()=>y,rv:()=>m,vF:()=>b,ws:()=>x});const a=12,l=8,r=12,o=60,i=32,s=70,c=2,d=.08,u=16,m=12,p=28,g=20,h=1.5,v="#FFFFFF",f=6,E=p+2*u,y=p+2*m,b=p+8,x=p+8,w=g+8,C=g+8,A=6,I=.75,k="var(--background-tertiary)",S="var(--content-primary)",N=new Set([S,"var(--content-black)"]),T=e=>N.has(e),_="rgba(0, 0, 0, 0.28)",D="rgba(255, 255, 255, 0.45)",R=12,M=1.5},85451:(e,t,n)=>{n.d(t,{th:()=>u,ue:()=>y});var a=n(97920),l=n(6071),r=n(23908),o=n(61059),i=n(6141),s=n(59528),c=n(4731),d=n(3788);const u=(e,t)=>t.reduce(((e,t)=>{var n,a;return null!==(n=null===e||void 0===e||null===(a=e.children)||void 0===a?void 0:a.find((e=>e.id===t)))&&void 0!==n?n:null}),e),m=e=>{var t,n;return null!==(t=e.children)&&void 0!==t&&t.length?e.children.reduce(((e,t)=>e+m(t)),0):null!==(n=e.value)&&void 0!==n?n:0},p=e=>(0,a.A)((0,a.A)({},e),{},{value:m(e),layoutWeight:void 0,children:void 0}),g=(e,t)=>{const n=t===d.i7.Horizontal?d.i7.Vertical:d.i7.Horizontal;return(e=>e.reduce(((e,t)=>{const n=e.at(-1);return void 0!==n&&void 0!==t.groupKey&&n[n.length-1].groupKey===t.groupKey?[...e.slice(0,-1),[...n,t]]:[...e,[t]]}),[]))(e).map((e=>1===e.length?p(e[0]):{id:"".concat("__group:").concat(e[0].groupKey),__synthetic:!0,tileDirection:n,children:e.map(p)}))},h=e=>{var t,n;return null!==(t=null!==(n=e.layoutWeight)&&void 0!==n?n:e.value)&&void 0!==t?t:0},v=e=>{var t;const n={minWidth:s.H6,minHeight:Math.max(s.d7,(0,i.YY)({hasSecondaryLabel:!1,hasValue:!1,hasSecondaryValue:!1})+2*s.rv)};if(void 0===e.otherCount)return n;const a=null!==(t=(0,d.QK)(e.primaryLabel))&&void 0!==t?t:e.id;return{minWidth:Math.max(n.minWidth,Math.ceil((l=a,l.split(/\s+/).filter(
1Boolean).reduce(((e,t)=>Math.max(e,(0,c.WI)(t,i.$l,i.y2))),0)))+2*s.O2),minHeight:Math.max(n.minHeight,(0,i.YY)({hasSecondaryLabel:!1,hasValue:!0,hasSecondaryValue:!0,primaryLines:s.aL})+2*s.rv)};var l},f=e=>{var t;return!e.__synthetic&&!(null!==(t=e.children)&&void 0!==t&&t.length)},E=(e,t,n)=>{const a=e.length;if(0===a)return[];const l=Math.max(0,t-n*Math.max(0,a-1)),r=l/a;if(l<=0)return e.map((()=>0));const o=e.reduce(((e,t)=>e+(null!==t&&void 0!==t?t:0)),0);if(o<=0)return e.map((()=>r));const i=e.map((e=>null!==e&&void 0!==e?e:0)).sort(((e,t)=>e-t)),c=e=>i.slice(0,e).reduce(((e,t)=>e+t),0),d=i.findIndex(((e,t)=>(e=>{const t=o-c(e),n=l-e*s.jJ;return t>0&&i[e]/t*n>=s.jJ})(t))),u=-1===d?a:d;if(u===a)return e.map((()=>r));const m=u>0?i[u-1]:-1/0,p=o-c(u),g=l-u*s.jJ;return e.map((e=>{const t=null!==e&&void 0!==e?e:0;return t<=m?s.jJ:t/p*g}))},y=function(e,t,n,i,c,m){let p=arguments.length>6&&void 0!==arguments[6]?arguments[6]:"ordered";const y=(e=>{var t;const n=null!==(t=e.tileDirection)&&void 0!==t?t:d.i7.Horizontal;return(0,a.A)((0,a.A)({},e),{},{value:void 0,layoutWeight:void 0,children:e.children?g(e.children,n):void 0})})(e);if("squarify"===p){const e=e=>((e,t,n)=>({minWidth:Math.min(e.minWidth,t),minHeight:Math.min(e.minHeight,n)}))(v(e),n,i);return((e,t,n,a)=>{const l=e.children;if(null===l||void 0===l||!l.length)return;const r=t*n;if(r<=0)return;const o=l.filter(f);if(0===o.length)return;const i=l.reduce(((e,t)=>{var n;return e+(null!==(n=t.value)&&void 0!==n?n:0)}),0);if(!(i<=0))for(const d of o){var c;const e=a(d),t=e.minWidth*e.minHeight/r,n=Math.min(s.hr,t);if(n<=0||n>=1)continue;const l=null!==(c=d.value)&&void 0!==c?c:0,o=n/(1-n)*(i-l);d.layoutWeight=Math.max(l,o)}})(y,n,i,e),((e,t,n,a,i,s)=>{const c=(0,l.Ay)(e);return c.sum((e=>h(e))),(0,r.A)().size([n,a]).tile(o.Ay).paddingInner(s)(c),c.leaves().map((e=>{var n,a,l;const r=e.ancestors().reverse().slice(1).filter((e=>!e.data.__synthetic)).map((e=>e.data.id)),o=[...t,...r],s=u(i,o);return{data:e.data,rect:{x:e.x0,y:e.y0,width:e.x1-e.x0,height:e.y1-e.y0},value:null!==(n=null!==(a=e.data.value)&&void 0!==a?a:e.value)&&void 0!==n?n:0,drillPath:o,isDrillable:!(null===s||void 0===s||null===(l=s.children)||void 0===l||!l.length)}}))})(y,t,n,i,c,m)}const b=(0,l.Ay)(y);b.sum((e=>h(e)));const x=(0,r.A)().size([n,i]);return x.tile((e=>(t,n,a,l,r)=>{var o;const i=t.children;if(null===i||void 0===i||!i.length)return;const s={x:n,y:a,width:l-n,height:r-a},c=(null!==(o=t.data.tileDirection)&&void 0!==o?o:d.i7.Horizontal)===d.i7.Horizontal,u=c?s.width:s.height,m=E(i.map((e=>{var t;return null!==(t=e.value)&&void 0!==t?t:0})),u,e),p=c?s.x:s.y,g=m.reduce(((t,n,a)=>0===a?[p]:[...t,t[a-1]+m[a-1]+e]),[]);i.forEach(((e,t)=>{const n=g[t],a=m[t];c?(e.x0=n,e.y0=s.y,e.x1=n+a,e.y1=s.y+s.height):(e.x0=s.x,e.y0=n,e.x1=s.x+s.width,e.y1=n+a)}))})(m)),x(b),b.leaves().map((e=>{var n,a,l;const r=e.ancestors().reverse().slice(1).filter((e=>!e.data.__synthetic)).map((e=>e.data.id)),o=[...t,...r],i=u(c,o);return{data:e.data,rect:{x:e.x0,y:e.y0,width:e.x1-e.x0,height:e.y1-e.y0},value:null!==(n=null!==(a=e.data.value)&&void 0!==a?a:e.value)&&void 0!==n?n:0,drillPath:o,isDrillable:!(null===i||void 0===i||null===(l=i.children)||void 0===l||!l.length)}}))}},4731:(e,t,n)=>{n.d(t,{$V:()=>r,A4:()=>l,WI:()=>a});const a=(()=>{let e,t=null;return(n,a,l)=>{if(void 0===e)try{e=document.createElement("canvas").getContext("2d")}catch(r){e=null}if(!e)return 0;if(null===t)try{t=getComputedStyle(document.body).fontFamily||"sans-serif"}catch(o){t="sans-serif"}return e.font="".concat(l," ").concat(a,"px ").concat(t),e.measureText(n).width}})(),l=function(e,t,n){let a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"\u2026";if(t<=0||n(e)<=t)return e;let l=0,r=e.length;for(;l<r;){const o=Math.ceil((l+r)/2);n(e.slice(0,o).trimEnd()+a)<=t?l=o:r=o-1}return l<=0?a:e.slice(0,l).trimEnd()+a},r=function(e,t,n,a){let r=arguments.length>4&&void 0!==arguments[4]?arguments[4]:"\u2026";if(n<=1||t<=0||a(e)<=t)return[l(e,t,a,r)];const o=e.split(/\s+/).filter(Boolean);if(o.length<=1)return[l(e,t,a,r)];const i=[];let s="";for(let l=0;l<o.length;l+=1){const e=o[l],r=""===s?e:"".concat(s," ").concat(e);
1if(""===s||a(r)<=t)s=r;else{if(i.push(s),i.length===n-1){s=o.slice(l).join(" ");break}s=e}}return i.push(s),i.slice(0,n).map((e=>l(e,t,a,r)))}},3788:(e,t,n)=>{n.d(t,{MK:()=>l,QK:()=>r,UO:()=>o,i7:()=>a,tv:()=>i,u8:()=>s});let a=function(e){return e.Horizontal="horizontal",e.Vertical="vertical",e}({}),l=function(e){return e.All="all",e.TileOnly="tileOnly",e.TooltipOnly="tooltipOnly",e}({});const r=e=>{var t;return null!==(t=null===e||void 0===e?void 0:e[0])&&void 0!==t?t:null},o=e=>{var t;return null!==(t=null===e||void 0===e?void 0:e[1])&&void 0!==t?t:l.All},i=e=>e!==l.TooltipOnly,s=e=>e!==l.TileOnly},17325:(e,t,n)=>{n.d(t,{l:()=>d});var a=n(36938),l=n(47889),r=n(95925),o=n(94267),i=n(60150),s=n(3664),c=n(8134);const d=e=>{let t=e.title,n=e.section,l=e.bars,r=e.hideAmounts,i=e.onSelectDatum;const c=(0,a.useMemo)((()=>l.length>0?Math.max(...l.map((e=>e.value))):0),[l]),d=(0,a.useMemo)((()=>(0,s.Eb)(l.map((e=>e.value)))),[l]);return a.createElement("div",{"data-external-id":"ranked-bars-section",className:"flex flex-col"},t&&a.createElement(o.c,{weight:"bold",className:"mb-sm"},t),0===l.length&&t&&a.createElement(o.c,{size:"sm",color:"secondary",className:"py-sm"},"No matching ",t.toLowerCase()," for the selected range."),a.createElement("div",{className:"flex flex-col gap-1.5"},l.map(((e,t)=>a.createElement(u,{key:"".concat(n,"-").concat(t),datum:e,section:n,maxValue:c,sectionTotal:d,hideAmounts:r,onSelectDatum:i})))))},u=e=>{let t=e.datum,n=e.section,d=e.maxValue,u=e.sectionTotal,m=e.hideAmounts,p=e.onSelectDatum;const g=0!==d?Math.min(1,Math.abs(t.value/d)):0,h=0!==u?t.value/u:0,v=t.value<0,f="income"===n?!v:v,E="expense"===n&&v?"+".concat((0,c.vv)(Math.abs(t.value))):(0,c.vv)(t.value),y=f?"success":"danger";return a.createElement("button",{"data-external-id":"ranked-bar-row",type:"button",className:" group relative block w-full cursor-pointer appearance-none border-0 bg-transparent p-0 text-left ",onClick:()=>p(t.selection)},a.createElement("div",{className:(0,i.cn)("absolute inset-y-0 rounded-sm opacity-30 group-hover:opacity-50",{"bg-chart-fill-green":f,"bg-chart-fill-red":!f}),style:{width:"".concat(100*g,"%"),transition:"opacity 0.1s ease-out, background-color 0.1s ease-out, width 600ms ease-out"}}),a.createElement("div",{className:"relative flex min-h-10 items-center justify-between px-sm"},a.createElement("div",{className:"flex min-w-0 items-center"},t.icon&&a.createElement(r.x,{className:"mr-2.5"},t.icon),t.isMerchant&&a.createElement(l._,{url:t.logoUrl,size:24,className:"mr-2.5 shrink-0"}),a.createElement(o.c,{size:"sm",className:"truncate"},t.name)),a.createElement(o.c,{size:"sm",color:v?y:void 0,className:"ml-sm shrink-0 whitespace-nowrap"},!m&&"".concat(E," "),a.createElement(o.c,{size:"sm",color:v?y:"secondary"},"(",(0,s.l9)(h),")"))))}},76972:(e,t,n)=>{n.r(t),n.d(t,{InAppRoutes:()=>igt});var a=n(36938),l=n(43373),r=n(20361),o=n(68622),i=n(25253),s=n(80042),c=n(98392),d=n(34327),u=n(39861),m=n(37380),p=n(21127),g=n(91770),h=n(89715),v=n(65144),f=n(2354),E=n(85725),y=n(66982),b=n(19613),x=n(32207),w=n(72412),C=n(55369),A=n(92633),I=n(67102);const k=()=>{const e=(0,l.Zp)(),t=(0,E.wA)(),n=(0,C.RU)(),r=(0,y.R)(),u=r.clientId,m=r.isReady,k=(0,E.pE)("code"),N=(0,E.pE)("state"),T=(0,d.d4)(A.Ai),_=(0,i.n)(h.Hg,{refetchQueries:["Web_GetInstitutionSettings"]}),D=(0,o.A)(_,1)[0],R=(0,v.D)((async(a,l)=>{const r=(0,x.b)(null!==N&&void 0!==N?N:""),o=r.credentialId,i=r.onSuccessRedirectTo,d=r.withParams,m=r.clientId,p=null!==m&&void 0!==m?m:u;if(t((0,g.TE)()),(0,b.y_)(),o)try{var h;const t=await D({variables:{input:{credentialId:o,redirectUri:(0,f.aU)(),code:a,codeVerifier:l,clientId:p}}}),r=(null===t||void 0===t||null===(h=t.data)||void 0===h?void 0:h.fixCoinbaseCredential)||{},s=r.credential,u=r.errors;if((0,c.A)(u))return void n({title:"Error",description:"Something went wrong. Please try again or submit a ticket.",onReport:()=>(0,w.e)("Issue reconnecting Coinbase account")});var v,E;(0,C.oR)({title:"Success",description:"Coinbase account is now reconnected.",actions:null!==s&&void 0!==s&&null!==(v=s.accounts)&&void 0!==v&&null!==(E=v[0])&&void 0!==E&&E.id?[{text:"Open account",onClick:()=>{e(I.JZ.accounts.accountDetails({id:s.accounts[0].id}))}}]:void 0}),i?e(i,{state:d}):e(I.JZ.accounts.path)}catch(y){s.Cp(y,{fingerprint:["fix-coinbase-credential-error"],tags:{provider:"coinbase",flow:"reconnect"}}),n({title:"Error",description:"Something went wrong. Please try again or submit a ticket.",onReport:()=>(0,w.e)("Issue reconnecting Coinbase account")}
1)}}));return(0,a.useEffect)((()=>{if(k||N||e(I.JZ.dashboard.path),k&&N&&T){if(!m)return;if(N===T){const a="cb_pkce_".concat(N),l=sessionStorage.getItem(a);if(sessionStorage.removeItem(a),!l)return t((0,g.TE)()),s.Cp(new Error("Missing PKCE code_verifier in Coinbase OAuth callback"),{fingerprint:["missing-pkce-code-verifier"],tags:{provider:"coinbase",flow:"pkce"}}),n({title:"Something went wrong",description:"Authentication error. Please connect Coinbase again."}),(0,b.y_)(),void e(I.JZ.dashboard.path);R(k,l)}else s.Cp(new Error("Mismatched CSRF token in Coinbase OAuth callback"),{fingerprint:["mismatched-coinbase-csrf-token"],tags:{provider:"coinbase",flow:"oauth",security:"csrf-mismatch"},extra:{returnedState:N,currentState:T}}),n({title:"Something went wrong",description:"Authentication error. Please connect Coinbase again."}),(0,b.y_)(),e(I.JZ.dashboard.path)}}),[k,N,T,m,R]),a.createElement(S,{"data-external-id":"coinbase-o-auth"},a.createElement(p.i,null))},S=(0,u.default)(m.g).withConfig({displayName:"CoinbaseOAuth__StyledFlexContainer",componentId:"sc-9l1igp-0"})(["height:100%;width:100%;align-items:center;justify-content:center;background-color:",";"],(e=>e.theme.color.grayBackground));var N=n(81810),T=n(16877),_=n(37050),D=n(71643),R=n(18583),M=n(72051);const L=(0,a.createContext)(null),O=L.Provider;var P=n(98877),B=n(60844),z=n(97956),F=n(52339),G=n(15707);const Y=()=>{const e=(0,u.useTheme)();return(0,G.U)("only screen and (min-width: ".concat(e.breakPoints.sm,"px)"))};var U=n(97920),V=n(97554);const W=(e,t)=>{t&&e.push(t)},j=(e,t)=>e&&(e instanceof HTMLElement||e instanceof SVGElement)?(e.style.transformOrigin="36px 27px",e.animate([{transform:"scaleY(1)",offset:0},{transform:"scaleY(1)",offset:.92},{transform:"scaleY(0.1)",offset:.96},{transform:"scaleY(1)",offset:1}],{duration:t,iterations:1/0,easing:"ease-in-out"})):null,H=(e,t)=>e?(e.style.transformOrigin="31px 22px",e.animate([{transform:"rotate(0deg)"},{transform:"rotate(-5deg)"},{transform:"rotate(0deg)"}],{duration:t,iterations:1/0,easing:"ease-in-out"})):null,K=(e,t,n)=>{(0,a.useEffect)((()=>{const a=e.current,l=t.current;if(!a||!l)return;const r=window.matchMedia("(prefers-reduced-motion: reduce)"),o=[];let i=0,s=!1;const c=()=>{const e=a.querySelector("[data-hair]");return e instanceof SVGPathElement?e:null},d=()=>{l.style.transform="";const e=c();e&&(e.style.transform="",e.style.strokeDasharray="",e.style.strokeDashoffset="")},u=()=>{i+=1,o.forEach((e=>{e.cancel()})),o.length=0},m=()=>{const e=i,t=()=>e===i&&!s;d();const r=c(),u=a.querySelector("[data-eyes]");"default"===n?((e,t,n)=>{if(!e||"function"!==typeof e.getTotalLength)return void W(t,H(e,4e3));const a=e.getTotalLength();e.style.strokeDasharray="".concat(a),e.style.strokeDashoffset="".concat(-a);const l=e.animate([{strokeDashoffset:-a},{strokeDashoffset:0}],{duration:1100,easing:"cubic-bezier(0,0,0,1)",fill:"forwards"});W(t,l),l.onfinish=()=>{n()&&(e.style.strokeDashoffset="0",W(t,H(e,4e3)))}})(r,o,t):"thinking"===n?((e,t,n,a,l)=>{if(W(l,t.animate([{transform:"rotate(-4.5deg) translateY(0)"},{transform:"rotate(-3.5deg) translateY(-1.2%)"},{transform:"rotate(-4.5deg) translateY(0)"}],{duration:3e3,iterations:1/0,easing:"ease-in-out"})),n&&"function"===typeof n.getTotalLength){const e=n.getTotalLength(),t=.6*e;n.style.strokeDasharray="".concat(t," ").concat(2*e),W(l,n.animate([{strokeDashoffset:0},{strokeDashoffset:-(e-t)}],{duration:1500,iterations:1/0,direction:"alternate",easing:"ease-in-out"}))}const r=e.querySelector("[data-features]");r&&W(l,r.animate([{transform:"translate(-0.6px,-0.5px) rotate(0.4deg)",offset:0},{transform:"translate(0.8px,-0.6px) rotate(-0.4deg)",offset:1}],{duration:3e3,iterations:1/0,direction:"alternate",easing:"ease-in-out"})),W(l,j(a,5200));const o=e.querySelector("[data-mouth]");o&&W(l,o.animate([{d:'path("M32.7 44.2 Q 34.6 44.7 36.5 44.2")',offset:0},{d:'path("M30.4 43.6 Q 34.6 46 38.8 43.6")',offset:.5},{d:'path("M32.7 44.2 Q 34.6 44.7 36.5 44.2")',offset:1}],{duration:3e3,iterations:1/0,direction:"alternate",easing:"ease-in-out"}))})(a,l,r,u,o):"error"===n?((e,t,n,a)=>{t&&(t.style.transformOrigin="31px 22px",t.style.transform="rotate(7deg)"),W(a,j(n,7e3)),W(a,e.animate([{transform:"translate(0,0) rotate(0deg)",offset:0},{transform:"translate(-1.6px,0) rotate(0deg)",offset:.06},{transform:"translate(1.6px,0) rotate(0deg)",offset:.11},{transform:"translate(-1.3px,0) rotate(0deg)",offset:.16},{transform:"translate(1px,0) rotate(0deg)",offset:.21},{transform:"translate(0,0) rotate(0deg)",offset:.26},{transform:"translate(0,3.5px) rotate(2.5deg)",offset:.42},{transform:"translate(0,3.5px) rotate(2.5deg)",offset:.82},{transform:"translate(0,0) rotate(0deg)",offset:1}],{duration:4200,iterations:1/0,easing:"ease-in-out"}))})(l,r,u,o):"inquiring"===n?((e,t,n,a,l)=>{W(l,t.animate([{transform:"rotate(-8deg) translateY(0)"},{transform:"rotate(-5.5deg) translateY(-3%)"},{transform:"rotate(-8deg) translateY(0)"}],{duration:2600,iterations:1/0,easing:"ease-in-out"})),W(l,j(a,5e3));const r=e.querySelector("[data-features]");r&&W(l,r.animate([{transform:"translate(-0.4px,-0.3px) rotate(0.5deg)",offset:0},{transform:"translate(0.6px,-0.5px) rotate(-0.5deg)",offset:1}],{duration:2600,iterations:1/0,direction:"alternate",easing:"ease-in-out"})),n&&W(l,n.animate([{transform:"translateY(0)",offset:0},{transform:"translateY(0)",offset:.32},{transform:"translateY(-2.2px)",offset:.45},{transform:"translateY(-2.2px)",offset:.7},{transform:"translateY(0)",offset:.83},{transform:"translateY(0)",offset:1}],{duration:5200,iterations:1/0,easing:"ease-in-out"}));const o=e.querySelector("[data-mouth]");o&&W(l,o.animate([{d:'path("M31 43.6 Q 34.6 46.4 38.2 43.6")',offset:0},{d:'path("M31 43.6 Q 34.6 46.4 38.2 43.6")',offset:.28},{d:'path("M27.4 43.6 Q 34.6 47.6 41.8 43.6")',offset:.44},{d:'path("M27.4 43.6 Q 34.6 47.6 41.8 43.6")',offset:.68},{d:'path("M31 43.6 Q 34.6 46.4 38.2 43.6")',offset:.84},{d:'path("M31 43.6 Q 34.6 46.4 38.2 43.6")',offset:1}],{duration:5200,iterations:1/0,easing:"ease-in-out"}))})(a,l,r,u,o):((e,t,n,a)=>{var l,r;W(a,(l=1.2,r=4200,t.animate([{transform:"translateY(0)"},{transform:"translateY(-".concat(l,"%)")},{transform:"translateY(0)"}],{duration:r,iterations:1/0,easing:"ease-in-out"}))),W(a,t.animate([{transform:"translateY(0)",offset:0},{transform:"translateY(3px)",offset:.1},{transform:"translateY(0)",offset:.18},{transform:"translateY(3px)",offset:.28},{transform:"translateY(0)",offset:.36},{transform:"translateY(0)",offset:1}],{duration:4200,iterations:1/0,easing:"ease-in-out",composite:"add"}));const o=e.querySelector("[data-blob]");o instanceof SVGElement&&(o.style.transformOrigin="30px 32px",W(a,o.animate([{transform:"scale(0.96)",offset:0},{transform:"scale(0.96)",offset:.4,easing:"ease-out"},{transform:"scale(1.02)",offset:.52},{transform:"scale(1.02)",offset:.6,easing:"ease-out"},{transform:"scale(1.08)",offset:.72},{transform:"scale(0.96)",offset:.9},{transform:"scale(0.96)",offset:1}],{duration:4200,iterations:1/0,easing:"ease-in-out"}))),n&&(n.style.transformOrigin="31px 13px",W(a,n.animate([{transform:"translateY(0)",offset:0},{transform:"translateY(0)",offset:.4},{transform:"translateY(-2.4px)",offset:.6},{transform:"translateY(0)",offset:.85},{transform:"translateY(0)",offset:1}],{duration:4200,iterations:1/0,easing:"ease-in-out"})))})(a,l,r,o)},p=()=>{u(),s||r.matches?d():m()};return p(),r.addEventListener("change",p),()=>{s=!0,r.removeEventListener("change",p),u()}}),[t,n,e])};var q=n(60150);const $="M34.91 31.25C35.75 31.75 37.48 33.1 37.75 35.25C38.08 37.94 34.25 37.11 32.75 37.25",Z="#22201D",J=1.5,X=[{cx:40.1841,cy:27.25,r:1.25}
1,{cx:30.1841,cy:27.25,r:1.25}],Q=30.052,ee=-42.806,te=232.647,ne=28.61,ae=["0.125","0.384615"],le=["#FF6A27","#EFB921"],re=-.16,oe=-.16,ie=1.32,se=1.32,ce=2.55,de=.999,ue=3,me=7601,pe=6.2;var ge=n(24010);const he=e=>{let t=e.color,n=e.size,l=void 0===n?200:n,r=e.label,i=void 0===r?"Goldi":r,s=e.state,c=void 0===s?"default":s,d=e.className;const u=(0,a.useId)().replaceAll(":",""),m=(0,a.useRef)(null),p=(0,a.useRef)(null),g="assistant-body-".concat(u),h="assistant-fuzz-".concat(u),v=(0,ge.nC)(t),f=(x=v.value,w=v.palette,"orange"===x?le:[w[1],w[0]]),E=(0,o.A)(f,2),y=E[0],b=E[1];var x,w;const C="default"===c,A="getting_smarter"===c;K(m,p,c);const I=a.createElement(a.Fragment,null,a.createElement("path",{"data-body":!0,"data-testid":"goldi-body",d:"M6.30781 46.6309C19.9119 63.6426 48.1764 63.5236 57.4409 51.3295C65.4158 40.833 54.4256 34.6798 58.8482 22.736C65.4158 4.99984 50.8735 0.65847 27.4181 1.02042C3.96275 1.38237 -7.29631 29.6192 6.30781 46.6309Z",fill:"url(#".concat(g,")"),filter:"url(#".concat(h,")")}),a.createElement("path",{"data-hair":!0,d:"M50.4341 20.008C41.1217 15.8228 37.0805 1.00001 42.5273 1C50.3021 0.99998 44.856 24.9759 33.7421 22.4852C22.8483 20.0438 20.2127 6.44171 25.8353 7.13926C30.9184 7.76987 31.476 20.6264 22.1636 24.2884C12.8512 27.9505 8.98571 16.4411 13.0269 13.3022",stroke:Z,strokeWidth:A?2.36:J,strokeLinecap:"round",strokeLinejoin:"round"}),a.createElement(ve,{state:c,blinkClassName:C?"goldi-avatar__eyes--blink":void 0}));return a.createElement("div",{"data-external-id":"assistant-avatar",className:(0,q.cn)("inline-grid place-items-center overflow-visible",d)},a.createElement("div",{ref:p,className:(0,q.cn)("inline-grid place-items-center overflow-visible",C&&"goldi-avatar--float")},a.createElement("svg",{ref:m,role:"img","aria-label":i,"data-state":c,viewBox:"0 0 61 61",width:l,height:l,fill:"none",className:"block overflow-visible"},a.createElement("defs",null,a.createElement("linearGradient",{id:g,x1:Q,y1:ee,x2:te,y2:ne,gradientUnits:"userSpaceOnUse"},a.createElement("stop",{"data-testid":"goldi-body-stop-start",offset:ae[0],stopColor:y,stopOpacity:.87}),a.createElement("stop",{"data-testid":"goldi-body-stop-end",offset:ae[1],stopColor:b})),a.createElement("filter",{id:h,"data-testid":"goldi-body-fuzz",filterUnits:"objectBoundingBox",x:re,y:oe,width:ie,height:se,colorInterpolationFilters:"sRGB"},a.createElement("feGaussianBlur",{in:"SourceGraphic",stdDeviation:ce,result:"soft"}),a.createElement("feTurbulence",{type:"fractalNoise",baseFrequency:"".concat(de," ").concat(de),numOctaves:ue,seed:me,result:"noise"}),a.createElement("feDisplacementMap",{in:"soft",in2:"noise",scale:pe,xChannelSelector:"R",yChannelSelector:"G"}))),A?a.createElement("g",{"data-blob":!0},I):I)))},ve=e=>{let t=e.state,n=e.blinkClassName;return"thinking"===t?a.createElement("g",{"data-external-id":"face-features","data-features":!0},a.createElement("g",{"data-eyes":!0,className:n},a.createElement("circle",{cx:"1.45",cy:"1.45",r:"1.45",transform:"matrix(-1 0 0 1 41.6 27)",fill:Z}),a.createElement("circle",{cx:"1.45",cy:"1.45",r:"1.45",transform:"matrix(-1 0 0 1 31.6 27)",fill:Z})),a.createElement("path",{d:"M34.91 33.45C35.75 33.95 37.48 35.3 37.75 37.45C38.08 40.14 34.25 39.31 32.75 39.45",stroke:Z,strokeWidth:J,strokeLinecap:"round",strokeLinejoin:"round"}),a.createElement("path",{"data-mouth":!0,d:"M30.4 43.6 Q 34.6 46 38.8 43.6",stroke:Z,strokeWidth:J,strokeLinecap:"round",fill:"none"})):"error"===t?a.createElement(a.Fragment,null,a.createElement("path",{d:"M27.4 24 L 31.8 22.6",stroke:Z,strokeWidth:J,strokeLinecap:"round"}),a.createElement("path",{d:"M39 22.6 L 43.4 24",stroke:Z,strokeWidth:J,strokeLinecap:"round"}),a.createElement("g",{"data-eyes":!0,className:n},a.createElement("circle",{cx:"1.25",cy:"1.25",r:"1.25",transform:"matrix(-1 0 0 1 41.4341 26.5)",fill:Z}),a.createElement("circle",{cx:"1.25",cy:"1.25",r:"1.25",transform:"matrix(-1 0 0 1 31.4341 26.5)",fill:Z})),a.createElement("path",{d:$,stroke:Z,strokeWidth:J,strokeLinecap:"round",strokeLinejoin:"round"}),a.createElement("path",{d:"M23.5 45 Q 32.9 38 42.5 45",stroke:Z,strokeWidth:J,strokeLinecap:"round",fill:"none"})):"inquiring"===t?a.createElement("g",{"data-external-id":"face-features","data-features":!0}
1,a.createElement("g",{"data-eyes":!0,className:n},a.createElement("circle",{cx:"1.55",cy:"1.55",r:"1.55",transform:"matrix(-1 0 0 1 41.7 26.8)",fill:Z}),a.createElement("circle",{cx:"1.55",cy:"1.55",r:"1.55",transform:"matrix(-1 0 0 1 31.7 26.8)",fill:Z})),a.createElement("path",{d:"M34.91 33.45C35.75 33.95 37.48 35.3 37.75 37.45C38.08 40.14 34.25 39.31 32.75 39.45",stroke:Z,strokeWidth:J,strokeLinecap:"round",strokeLinejoin:"round"}),a.createElement("path",{"data-mouth":!0,d:"M31 43.6 Q 34.6 46.4 38.2 43.6",stroke:Z,strokeWidth:J,strokeLinecap:"round",fill:"none"})):"getting_smarter"===t?a.createElement(a.Fragment,null,a.createElement("path",{"data-eye":!0,d:"M29.45 27.4 Q 29.45 27.4 29.45 27.4",stroke:Z,strokeWidth:"4.7",strokeLinecap:"round",fill:"none"}),a.createElement("path",{"data-eye":!0,d:"M39.85 27.4 Q 39.85 27.4 39.85 27.4",stroke:Z,strokeWidth:"4.7",strokeLinecap:"round",fill:"none"}),a.createElement("path",{d:$,stroke:Z,strokeWidth:"2.36",strokeLinecap:"round",strokeLinejoin:"round"}),a.createElement("path",{"data-mouth":!0,d:"M48.4341 37.5C45 47.5 21 49 15.4341 37.5",stroke:Z,strokeWidth:"2.36",strokeLinecap:"round",strokeLinejoin:"round",fill:"none"})):a.createElement(a.Fragment,null,a.createElement("g",{"data-eyes":!0,className:n},X.map((e=>{let t=e.cx,n=e.cy,l=e.r;return a.createElement("circle",{key:t,cx:t,cy:n,r:l,fill:Z})}))),a.createElement("path",{d:$,stroke:Z,strokeWidth:J,strokeLinecap:"round",strokeLinejoin:"round"}),a.createElement("path",{d:"M47.4341 38C44.9883 45.588 25.5967 51.3615 18.4341 38",stroke:Z,strokeWidth:J,strokeLinecap:"round",strokeLinejoin:"round"}))};var fe=n(39368),Ee=n(15660);const ye={[Ee.WJX.WAYS_TO_SAVE]:{label:"Ways to save",description:"Spot opportunities to keep more of your money"},[Ee.WJX.PROVIDER_RECOMMENDATIONS]:{label:"Provider recommendations",description:"Discover when switching providers could save you money"},[Ee.WJX.PLAN_AND_SUBSCRIPTION_CHANGES]:{label:"Plan and subscription changes",description:"See options to change, downgrade, or bundle plans"},[Ee.WJX.TRENDS_AND_RECAPS]:{label:"Trends & recaps",description:"Follow patterns and milestones in your finances"},[Ee.WJX.FINANCIAL_HAIKUS]:{label:"Financial haikus",description:"Enjoy occasional financial highlights in haiku form"},[Ee.WJX.COMPARISONS]:{label:"Comparisons",description:"See how your finances compare with similar households"},[Ee.WJX.CREDIT_AND_DEBT]:{label:"Credit & debt",description:"Stay on top of your debt, credit score, and credit utilization"},[Ee.WJX.MARKETS_AND_INVESTMENTS]:{label:"Markets & investments",description:"Keep up with meaningful changes in your investments"},[Ee.WJX.ACCOUNT_AND_ACTIVITY_ALERTS]:{label:"Account & activity alerts",description:"Get important updates about accounts and financial activity"}},be=e=>(e=>Object.prototype.hasOwnProperty.call(ye,e))(e)?ye[e]:void 0,xe=(e,t)=>e.flatMap((e=>{const n=!1===t[e.topic];return[e.topic,...e.children].filter((e=>n||!1===t[e]))})),we=(e,t,n,a)=>{var l;const r=(0,U.A)((0,U.A)({},t),{},{[n]:a});if(a)return r;const o=e.find((e=>e.topic===n));for(const i of null!==(l=null===o||void 0===o?void 0:o.children)&&void 0!==l?l:[])r[i]=!1;return r},Ce=e=>{if(!e||"object"!==typeof e)return{};const t=new Set(Object.values(Ee.WJX));return Object.fromEntries(Object.entries(e).filter((e=>t.has(e[0])&&"boolean"===typeof e[1])))},Ae={[Ee.WJX.WAYS_TO_SAVE]:{icon:a.createElement(fe.c3d,null),color:"blue"},[Ee.WJX.TRENDS_AND_RECAPS]:{icon:a.createElement(fe.fD4,null),color:"purple"},[Ee.WJX.CREDIT_AND_DEBT]:{icon:a.createElement(fe.ZuH,null),color:"green"},[Ee.WJX.MARKETS_AND_INVESTMENTS]:{icon:a.createElement(fe.Q7I,null),color:"yellow"},[Ee.WJX.ACCOUNT_AND_ACTIVITY_ALERTS]:{icon:a.createElement(fe.R4U,null),color:"red"}},Ie=e=>{let t=e.groups,n=e.value,l=e.onChange,r=e.className;return a.createElement("div",{"data-external-id":"topic-prefs-fields",className:(0,q.cn)("flex w-full shrink-0 flex-col gap-sm",r)},t.map((e=>{if(!be(e.topic))return null;const r=!1!==n[e.topic],o=e.children.filter((e=>be(e)));return a.createElement("div",{key:e.topic,className:"flex flex-col gap-default rounded-default border border-border-primary p-default"},a.createElement(ke,{topic:e.topic,checked:r,onCheckedChange:a=>l(we(t,n,e.topic,a))}),o.length>0&&a.createElement(a.Fragment,null,a.createElement(fe.AVK,null),a.createElement("div",{className:"flex flex-col gap-default"},o.map((e=>a.createElement(ke,{key:e,topic:e,indented:!0,checked:r&&!1!==n[e],disabled:!r,onCheckedChange:a=>l(we(t,n,e,a))}))))))})))},ke=e=>{let t=e.topic,n=e.checked,l=e.indented,r=void 0!==l&&l,o=e.disabled,i=void 0!==o&&o,s=e.onCheckedChange;const c=be(t),d=Ae[t];
1return c?a.createElement(fe.Qey.Root,{"data-external-id":"topic-switch",className:"p-0"},d?a.createElement(fe.Qey.IconTile,{align:"start",icon:d.icon,color:d.color}):r&&a.createElement(fe.Qey.Media,{"aria-hidden":!0},a.createElement("span",{className:"size-8 shrink-0"})),a.createElement(fe.Qey.Content,{className:"gap-2xs"},a.createElement(fe.Qey.Title,{size:"sm",weight:"medium"},c.label),a.createElement(fe.Qey.Description,{className:"line-clamp-none text-sm text-pretty"},c.description)),a.createElement(fe.Qey.Actions,null,a.createElement(fe.$nr,{checked:n,disabled:i,"aria-label":c.label,onCheckedChange:s}))):null},Se=["household_roster","home_zip_code","income_type","housing_situation","mortgage_rate","employer_match","cash_account_purpose","investment_horizon"],Ne="today_",Te=e=>{const t=e.startsWith(Ne)?e.slice(6):e;return(e=>Se.includes(e))(t)?t:null},_e=e=>[e.previousName!==e.nextName?"name":null,e.previousColor!==e.nextColor?"color":null].filter((e=>null!==e));var De=n(3664);const Re={PAGE_TITLE:"Assistant",NEW_CHAT:"New chat",ASK_PLACEHOLDER:"What's on your mind?",ASK_ANYTHING_PLACEHOLDER:"Ask anything about your money...",GREETING_BODY:"I watched your money overnight. I have some things for you to glance at, but first, is there anything on your mind?",FALLBACK_PROMPTS:["Can I afford a vacation?","Am I on track to retire?","How am I doing this month?","How has my net worth changed this year?","Am I saving enough each month?"],MORE_SUGGESTIONS:"More suggestions",PREVIOUS_SUGGESTIONS:"Previous suggestions",VIEW_ALL:"View all",SAVE:"Save for later",SAVED:"Saved for later",COMPLETE:"Mark as complete",UNDO_COMPLETE:"Undo complete",HELPFUL:"Helpful",NOT_HELPFUL:"Not helpful",DISMISS:"Dismiss",COMPLETE_STUB:"Marked as complete",UNDO:"Undo",RESTORE:"Restore",RESTORED:"Restored",SAVED_TOAST:"Saved for later",UNSAVED_TOAST:"Removed from saved",HELPFUL_TOAST:"Glad this helped \u2014 we'll find more like it",RATING_REMOVED_TOAST:"Rating removed",DISMISSED_TOAST:"Moved to Archived",DISMISSED_ARCHIVED_TOAST:"Moved to Archived.",DISMISSED_NOTE_TOAST:"Sent to the Monarch team. Moved to Archived.",GIVE_FEEDBACK_PROMPT:"Give feedback?",DISMISS_ASK_SHEET_TITLE:"Feedback",DISMISS_ASK_QUESTION:"Why did you dismiss this insight?",DISMISS_ASK_SUBMIT:"Submit",DISMISS_ASK_ERROR:"Couldn't send your feedback. Try again.",FEEDBACK_THANKS_TOAST:"Thanks \u2014 I'll send fewer like this",FEEDBACK_REASON_LABEL:"What's off about this?",FEEDBACK_REASONS:["I already handled this","This isn't accurate"],FEEDBACK_REASON_OTHER:"Something else",FEEDBACK_OTHER_PLACEHOLDER:"Tell me what was off\u2026",FEEDBACK_SEND:"Send feedback",BACKGROUND_FOOTNOTE:"Monarch handles the busywork like categorizing and syncing. Anything that moves your money is always your call.",EDIT_ASSISTANT:"Edit assistant",CUSTOMIZE:"Customize",SETTINGS:"Settings",BETA_FEEDBACK:"Beta feedback",BETA_FEEDBACK_TITLE:"Goldi is in beta",BETA_FEEDBACK_BODY:"We're still working on the insights Goldi provides and the answers it gives. Your feedback goes directly to the team building it and shaping what comes next.",BETA_FEEDBACK_QUESTION:"What would make Goldi more useful?",BETA_FEEDBACK_SHEET_TITLE:"Beta feedback",BETA_FEEDBACK_CANCEL:"Cancel",BETA_FEEDBACK_SUBMIT:"Submit",BETA_FEEDBACK_SENT_TOAST:"Sent to the Monarch team.",BETA_FEEDBACK_ERROR:"Couldn't send your feedback. Try again.",VIEW_FULL_CHAT_HISTORY:"View full chat history",DELETE_THIS_CHAT:"Delete this chat",CHAT_HISTORY:"Chat history",CHAT_HISTORY_EMPTY:"No chats yet",CHAT_HISTORY_MORE:"More options",UNTITLED_CONVERSATION:"Untitled conversation",RAIL_RECENT_CHATS_TITLE:"Recent chats",RAIL_COLLAPSE:"Collapse",RAIL_EXPAND:"Expand",RAIL_TOGGLE_COMMAND:"Toggle Assistant panel",THINKING_PLACEHOLDER:"Thinking",THINKING_DONE_SUMMARY:"Thought",THINKING_DONE_STEP:"Done",HAIKU_DIVIDER:"That's everything",RAIL_OVERVIEW_TITLE:"Overview",RAIL_ACTIVITY_TITLE:"Your activity",RAIL_SAVED_LABEL:"Saved for later",RAIL_COMPLETED_LABEL:"Completed",RAIL_DISMISSED_LABEL:"Archived",ARCHIVED_TAB_DISMISSED:"Dismissed",ARCHIVED_TAB_UNHELPFUL:"Unhelpful",RAIL_ACTIVITY_ROWS:[{id:"saved",icon:"bookmark",tileColor:"purple",label:"Saved for later"},{id:"completed",icon:"check-circle",tileColor:"green",label:"Completed"}
1,{id:"archived",icon:"archive",tileColor:"gray-secondary",label:"Archived"}],SAVED_PAGE_BLURB:"Insights you've saved to come back to.",SAVED_PAGE_EMPTY:"Nothing saved yet. Tap the save icon on any insight to keep it here.",COMPLETED_PAGE_BLURB:"Insights you've marked as done.",COMPLETED_PAGE_EMPTY:"Nothing completed yet. Mark an insight as complete and it'll show up here.",DISMISSED_PAGE_BLURB:"Cards you've X'd out. Restore one to put it back in your feed.",DISMISSED_PAGE_EMPTY:"Nothing here yet. Cards you X out wait here so you can put them back.",UNHELPFUL_PAGE_BLURB:"Cards you marked as not helpful.",UNHELPFUL_PAGE_EMPTY:"Nothing here yet. Thumbs-down ratings wait here.",dismissedArchivedCount:e=>"".concat(e," moved to Archived."),NEEDS_ATTENTION:"Needs attention",IN_THE_BACKGROUND:"In the background",EVERYTHING_ELSE:"Everything else",EVERYTHING_ELSE_PAGE_BLURB:"Recommendations and updates that don't need a decision from you today.",SECTION_PAGE_BLURBS:{needs_attention:"A few things I flagged overnight that may need a decision from you.",recommendations:"Opportunities I spotted to keep more of your money.",updates:"What moved in the markets and how it touches your money. Informational \u2014 nothing here needs action.",in_the_background:"Routine work I handled for you automatically. Anything that moves your money is always your call."},RAIL_OVERVIEW_SAVED:"saved to date",RAIL_OVERVIEW_FOUND:"found for you",RAIL_OVERVIEW_STATS:[{id:"accountsConnected",icon:"institution",label:"accounts connected"},{id:"transactionsCategorized",icon:"credit-card",label:"transactions categorized"},{id:"subscriptionsTracked",icon:"refresh",label:"subscriptions tracked"}],RAIL_WATCHING_TITLE:"Watching for you",RAIL_WATCHING_ACTIVE:"Active",RAIL_WATCHING_STATS:[{id:"accountsConnected",icon:"institution",label:"accounts connected"},{id:"transactionsCategorized",icon:"credit-card",label:"transactions categorized"},{id:"subscriptionsTracked",icon:"refresh",label:"subscriptions tracked"},{id:"goalsOnPace",icon:"target",label:"goals on pace"},{id:"billsDueThisWeek",icon:"calendar",label:"bills due this week"}],RAIL_PROFILE_TITLE:"Household profile",RAIL_PROFILE_COMPLETE:e=>"".concat(e,"% complete"),RAIL_PROFILE_ANSWER:"Answer questions",RAIL_PROFILE_UPDATE:"Update profile",RAIL_PROFILE_INCOME:e=>"Annual income ".concat(e),RAIL_HOUSING_LABELS:{rent:"Renting",own_with_mortgage:"Owning with a mortgage",own_outright:"Owning outright",live_with_family:"Living with family",other:"Other living situation"},RAIL_METRIC_PLACEHOLDER:"\u2014",UPDATE_ERROR_TITLE:"We couldn't update your feed",UPDATE_ERROR_BODY:"Try again later",ERROR_TITLE:"We couldn't load your feed",ERROR_BODY:"Refresh the page to try again.",ERROR_BODY_PULL:"Pull down to try again.",ONBOARDING_INTRO_BODY:"I watch your accounts and tell you what's worth your attention. What I can't see is the life behind the numbers \u2014 who you support, what your money is set aside for, how you earn it. Answer a few questions so what I flag fits your household, not an average one. You can change any of it later.",ONBOARDING_NAME_LABEL:"Assistant name",ONBOARDING_NAME_PLACEHOLDER:"Assistant name",ONBOARDING_NEXT:"Continue",ONBOARDING_SAVE_AND_CLOSE:"Save and Close",ONBOARDING_QUESTION_ERROR:"We couldn't save that answer. Please try again.",ONBOARDING_QUESTIONS_ERROR_TITLE:"I couldn't load your questions",ONBOARDING_QUESTIONS_ERROR_BODY:"Something went wrong on our end. Try again, or come back later and pick up where you left off.",ONBOARDING_QUESTIONS_RETRY:"Try again",ONBOARDING_UNSUPPORTED_TITLE:"This question isn't supported in the mobile app yet.",ONBOARDING_UNSUPPORTED_BODY:"Close setup and finish it on the web for now.",ONBOARDING_OPTIONAL:"(optional)",ONBOARDING_ROSTER_ADULTS:"Who you share your finances with",ONBOARDING_ROSTER_ADULTS_HELP:"A spouse or partner whose income and savings sit alongside yours \u2014 someone you plan and save with, rather than someone who relies on you.",ONBOARDING_ROSTER_BIRTHDAY:"Birthday",ONBOARDING_ROSTER_YEARLY_INCOME:"Yearly income",ONBOARDING_ROSTER_BIRTH_YEAR:"Birth year",ONBOARDING_ROSTER_UNKNOWN_AGE:"Unknown age",ONBOARDING_ROSTER_ADD_PARTNER:"Add a partner",ONBOARDING_ROSTER_DEPENDENTS:"Dependents",ONBOARDING_ROSTER_DEPENDENTS_HELP:"Anyone who relies on your income \u2014 a child, or an adult like a grown child or a parent you help supp
1ort.",ONBOARDING_ROSTER_ADD_DEPENDENT:"Add a dependent",ONBOARDING_ROSTER_ADD_BIRTH_YEAR:"Add birth year",ONBOARDING_ROSTER_ADD_BIRTH_DATE:"Add birth date",ONBOARDING_ROSTER_PARTNER_NAME_LABEL:"Partner name",ONBOARDING_ROSTER_PARTNER_NAME_PLACEHOLDER:"e.g. Jane",ONBOARDING_ROSTER_NAME_LABEL:"Name",ONBOARDING_ROSTER_BIRTH_DATE_LABEL:"Date of birth",ONBOARDING_ROSTER_BIRTH_DATE_HELP:"Age drives retirement timelines and contribution limits",ONBOARDING_ROSTER_BIRTH_DATE_PLACEHOLDER:"March 11, 1986",ONBOARDING_ROSTER_DONE:"Done",ONBOARDING_ROSTER_CLOSE:"Close",ONBOARDING_ROSTER_YEAR_PLACEHOLDER:"YYYY",ONBOARDING_ROSTER_DATE_PLACEHOLDER:"Mar 11, 1992",ONBOARDING_ROSTER_REMOVE:"Remove",ONBOARDING_ZIP_LABEL:"Home ZIP code",ONBOARDING_ZIP_PLACEHOLDER:"90210",ONBOARDING_ZIP_ERROR:"Enter a 5-digit ZIP code.",ONBOARDING_INCOME_NOUN:"total income, before taxes",ONBOARDING_INCOME_TYPE_NOUN:"income sources",ONBOARDING_INCOME_PLACEHOLDER:"",ONBOARDING_EMPLOYER_MATCH_NOUN:"workplace retirement plan",ONBOARDING_RATE_LABEL:"Your APR",ONBOARDING_RATE_HELP:"Use the interest rate on your loan or closing disclosure. An estimate is fine, and you can skip it for now.",ONBOARDING_CURRENT_RATE_LABEL:"Your current APR",ONBOARDING_CURRENT_RATE_HELP:"Use the current interest rate on your most recent statement. An estimate is fine, and you can skip it for now.",ONBOARDING_RATE_PLACEHOLDER:"0.00",ONBOARDING_MATCH_LEAD:"They match",ONBOARDING_MATCH_MID:"of what they put in, up to",ONBOARDING_MATCH_TAIL:"of salary",ONBOARDING_MATCH_PERCENT_PLACEHOLDER:"0",ONBOARDING_MATCH_UP_TO_PLACEHOLDER:"0",ONBOARDING_CONTRIBUTE_LEAD:"They contribute",ONBOARDING_CONTRIBUTE_TAIL:"of salary",ONBOARDING_CONTRIBUTE_PERCENT_PLACEHOLDER:"0",ONBOARDING_CONTRIBUTE_DOLLARS_PLACEHOLDER:"0",ONBOARDING_CURRENCY_PLACEHOLDER:"$0",ONBOARDING_MATCH_OF_CONTRIBUTIONS_UP_TO:"of contributions, up to",ONBOARDING_CONTRIBUTES:"Contributes",ONBOARDING_CONTRIBUTE_A_YEAR:"a year",ONBOARDING_MATCH_PERCENT_LABEL:"Percent of contributions they match",ONBOARDING_MATCH_UP_TO_LABEL:"Percent of salary they match up to",ONBOARDING_CONTRIBUTE_PERCENT_LABEL:"Percent of salary they contribute",ONBOARDING_CONTRIBUTE_DOLLARS_LABEL:"Dollars they contribute a year",ONBOARDING_UNIT_LABEL:"Contribution unit",ONBOARDING_UNIT_PERCENT:"Percent of salary",ONBOARDING_UNIT_DOLLARS:"Dollars per year",ONBOARDING_ROSTER_MULTI_SELECT_PLACEHOLDER:"Select all that apply",ONBOARDING_ACCOUNT_PURPOSE_LABEL:"Cash purpose",ONBOARDING_ACCOUNT_PURPOSE_PLACEHOLDER:"Select a purpose",ONBOARDING_ACCOUNT_PURPOSE_EMPTY:"I don't see any cash accounts on file yet. Link one whenever you like and I'll ask about it then.",ONBOARDING_ACCOUNT_APY_LABEL:"Current APY",ONBOARDING_ACCOUNT_SWEEP_LABEL:"Cash sweep yield",ONBOARDING_ACCOUNT_RATE_PLACEHOLDER:"0.00",ONBOARDING_GOAL_ASSIGNED_LEAD:"I can see this account funds your",ONBOARDING_GOAL_PROMPT_LEAD:"I'd add",ONBOARDING_GOAL_PROMPT_TAIL:"goal so I can track your progress against it.",ONBOARDING_GOAL_PROMPT_LINK:"Add goal.",ONBOARDING_SHOW_TUCKED_ACCOUNTS:e=>"Show ".concat(e," hidden and closed ").concat(1===e?"account":"accounts"),ONBOARDING_COLLAPSE_TUCKED_ACCOUNTS:e=>"Collapse ".concat(e," hidden and closed ").concat(1===e?"account":"accounts"),ONBOARDING_CLOSE:"Close setup",ONBOARDING_BACK:"Go back",ONBOARDING_PROGRESS:"Setup progress",ONBOARDING_DIALOG_LABEL:"Set up your assistant",COMPARISON_REFERENCE_LINE:"Compared to similar households",NETWORTH_COMPARISON_SOURCE:"Based on households your age from the Federal Reserve's Survey of Consumer Finances.",SPENDING_COMPARISON_SOURCE:"Based on household spending from the Bureau of Labor Statistics' Consumer Expenditure Survey.",PRE_ONBOARDING_TITLE:"Money moves, found for you",PRE_ONBOARDING_BODY:"I look after your finances and point out what's worth your attention, like cash that could be earning more or a subscription that crept up.",PRE_ONBOARDING_CTA:"Get started",PRE_ONBOARDING_LLM_NOTE:"Monarch uses 3rd-party LLMs for the Assistant's conversational AI and analysis. Privacy and the security of your data remain our top priority.",THREAD_COMPOSER_DISCLAIMER:"AI Assistant can make mistakes and isn't for financial advice.",ONBOARDING_SETUP_TITLE:"Getting your household set up",ONBOARDING_SETUP_DONE_TITLE:"Your household is set",ONBOARDING_SETUP_SUB:"One moment while I take this in.",ONBOARDING_SETUP_ACCOUNTS_TITLE:"Reading your accounts",ONBOARDING_SETUP_REPEATS_TITLE:"Finding what repeats",ONBOARDING_SETUP_REPEATS_BODY:"Bills, subscriptions and paydays, so I know what to expect.",ONBOARDING_SETUP_FLAG_TITLE:"Choosing what to flag",ONBOARDING_SETUP_FLAG_BODY:"Only the few things worth your time. The rest stays quiet.",ONBOARDING_SETUP_CTA:"Check it out",ONBOARDING_HOUSEHOLD_CONTEXT:"Household context",ONBOARDING_HOUSEHOLD_EDIT:"Edit",ONBOARDING_HOUSEHOLD_TAXES:"Filing taxes jointly",ONBOARDING_HOUSEHOLD_HOME:"Homeowners with a mortgage",DIALOG_CANCEL:"Cancel",DIALOG_SAVE:"Save",EDIT_ASSISTANT_NAME_SAVED_TOAST:"Assistant updated",CUSTOMIZE_SAVED_TOAST:"Preferences saved",CUSTOMIZE_SAVE_ERROR:"Could not save",SETTINGS_HOUSEHOLD_BODY:"Your household context grows over time from the information you share and your chats. Review and update it anytime to improve chat responses and other features across Monarch.",SETTINGS_AI_TITLE:"AI settings",SETTINGS_AI_BODY:"Choose whether to use AI features across Monarch, update your preferences at any time, or permanently delete your chat history.",STATUS_COMING_SOON:"Coming soon",STATUS_SAMPLE_HINT:"Placeholder data, not this household's. We'll swap in real household context later.",STATUS_NOT_WIRED_HINT:"This doesn't do anything yet. We'll come back to it."},Me=[{icon:"piggy-bank",tile:"purple",title:"Your savings could be earning more",figure:"$150/yr"},{icon:"home",tile:"blue",title:"It might be time to refinance your mortgage",figure:"$317/mo"},{icon:"trending-up",tile:"green",title:"AAPL stock had a good week for you",figure:"Up 4.5%"},{icon:"fee-trending-up",tile:"red",title:"Fees in your IRA account could be lower",figure:"$750/yr"},{icon:"copy",tile:"purple",title:"You're paying for Dropbox twice",figure:"$12/mo"},{icon:"shopping-bag",tile:"yellow",title:"Dining has been creeping up lately",figure:"Up 26%"}],Le=(e,t)=>{const n=Me.length,a=((e-t)%n+n)%n;return a<4?"p".concat(a):a===n-1?"out":"wait"},Oe=e=>{let t=e.assistantName,n=e.isPreOnboarding,a=void 0!==n&&n,l=e.completedAgentOnboardingAt,r=e.now,o=void 0===r?N.c9.now().toJSDate():r;return a?"I'm ".concat(t,"\u2014your personal financial assistant."):l&&((e,t)=>{const n=new Date(e);return!Number.isNaN(n.getTime())&&n.getFullYear()===t.getFullYear()&&n.getMonth()===t.getMonth()&&n.getDate()===t.getDate()})(l,o)?(e=>"".concat(e," here\u2014nothing's alarming with your finances. I have some things for you to glance at, but first, is there anything on your mind about your money?"))(t):Re.GREETING_BODY},Pe=e=>"Reply to ".concat(e,"..."),Be=e=>"Birth year for this ".concat(e.toLowerCase()),ze=e=>"".concat((0,De.td)("year",e,{inclusive:!0})," old"),Fe=[["Nothing left undone \u2014","the day's small numbers settled.","Go enjoy the sun."],["Books closed for the night \u2014","every dollar found a home.","Rest. Tomorrow waits."],["Quiet in the feed \u2014","no more flags that need a yes.","Let the evening in."],["Figures in a row \u2014","nothing left that asks a choice.","Walk away, it's done."],["Sunset on the books \u2014","the last small errand is filed.","Go, the day is yours."],["All the tabs are closed \u2014","money slept where it belongs.","Leave the desk behind."]];var Ge=n(9802),Ye=n(62249),Ue=n(47996);const Ve=e=>{let t=e.open,n=e.onOpenChange,l=e.groups,r=e.topicPrefs,i=e.onSave,s=e.draft,c=e.onSavePersona;const d=(e=>{const t=(0,a.useState)(0),n=(0,o.A)(t,2),l=n[0],r=n[1],i=(0,a.useState)(e),s=(0,o.A)(i,2),c=s[0],d=s[1];return e!==c&&(d(e),e&&r((e=>e+1))),l})(t);return a.createElement(fe.hg1.Root,{"data-external-id":"customize-dialog",open:t,onOpenChange:n,size:"xl",scroll:"outside"},a.createElement(We,{key:d,groups:l,topicPrefs:r,onSave:i,draft:s,onSavePersona:c,onOpenChange:n}))},We=e=>{let t=e.groups,n=e.topicPrefs,r=e.onSave,i=e.draft,s=e.onSavePersona,c=e.onOpenChange;const d=(0,l.Zp)(),u=(0,a.useState)(n),m=(0,o.A)(u,2),p=m[0],g=m[1],h=(0,a.useState)(i.displayName),v=(0,o.A)(h,2),f=v[0],E=v[1],y=(0,a.useState)(i.color),b=(0,o.A)(y,2),x=b[0],w=b[1],C=f.trim()||ge.Uk;return a.createElement(fe.hg1.Content,{"data-external-id":"customize-dialog-fields"},a.createElement(fe.hg1.CloseTrigger,null),a.createElement(fe.hg1.Header,null,a.createElement(fe.hg1.Title,null,Re.SETTINGS)),a.createElement(fe.hg1.Body,{className:"flex flex-col gap-lg"},a.createElement(Ie,{groups:t,value:p,onChange:g}),ge.m3&&a.createElement("section",{className:"flex flex-col gap-lg border-t border-divider-primary pt-lg"},a.createElement(fe.c8D,{size:"sm",weight:"medium"},Re.EDIT_ASSISTANT),a.createElement("div",{className:"flex flex-col items-center gap-lg"},a.createElement(he,{color:x,label:C,size:92}),a.createElement("div",{className:"flex w-full max-w-container-xs flex-col items-center gap-default"},a.createElement(fe.RVf.Root,{className:"w-full",optional:!0},a.createElement(fe.D_j,{type:"text",maxLength:ge.B7,"aria-label":Re.ONBOARDING_NAME_LABEL,placeholder:Re.ONBOARDING_NAME_PLACEHOLDER,value:f,onChange:e=>E(e.target.value.slice(0,ge.B7)),className:"text-center text-lg font-medium"})),a.createElement(fe.St9,{columns:4,colors:ge.Rt,value:x,onValueChange:e=>{(0,ge.nM)(e)&&w(e)}})))),a.createElement("section",{className:"flex flex-col gap-sm border-t border-divider-primary pt-lg"},a.createElement(je,{title:Re.ONBOARDING_HOUSEHOLD_CONTEXT,body:Re.SETTINGS_HOUSEHOLD_BODY,onEdit:()=>{(0,Ge.u4)(Ye.xb.AssistantSettingsEditClicked,{field:"household_context"}),c(!1),d(I.JZ.today.onboarding())}}),a.createElement(je,{title:Re.SETTINGS_AI_TITLE,body:Re.SETTINGS_AI_BODY,onEdit:()=>{(0,Ge.u4)(Ye.xb.AssistantSettingsEditClicked,{field:"ai_settings"}),c(!1),d((0,Ue.AI)("preferences","ai-assistant"))}}))),a.createElement(fe.hg1.Footer,null,a.createElement(fe.hg1.Close,{render:a.createElement(fe.XZZ,null)},Re.DIALOG_CANCEL),a.createElement(fe.XZZ,{variant:"primary",onClick:()=>{ge.m3&&(_e({previousName:i.displayName,nextName:C,previousColor:i.color,nextColor:x}
1).forEach((e=>{(0,Ge.u4)(Ye.xb.AssistantSettingsUpdated,{field:e})})),s({displayName:C,color:x})),r(p),c(!1)}},Re.DIALOG_SAVE)))},je=e=>{let t=e.title,n=e.body,l=e.onEdit;return a.createElement("div",{"data-external-id":"settings-feature-row",className:"flex items-center gap-lg rounded-md border border-divider-secondary p-lg"},a.createElement("div",{className:"flex min-w-0 flex-1 flex-col gap-xs"},a.createElement("div",{className:"flex items-center gap-xs"},a.createElement(fe.c8D,{weight:"medium"},t),a.createElement(fe.ucZ,{size:"sm",className:"shrink-0 text-content-secondary"})),a.createElement(fe.c8D,{size:"sm",color:"secondary",className:"text-pretty"},n)),a.createElement(fe.XZZ,{size:"sm",icon:a.createElement(fe.yIO,null),onClick:l},Re.ONBOARDING_HOUSEHOLD_EDIT))};let He,Ke=ge.M3;const qe=new Set,$e=()=>{const e=(()=>{if("undefined"===typeof sessionStorage)return null;try{return sessionStorage.getItem(ge.UV)}catch(e){return null}})();return e===He||(He=e,Ke=(()=>{if("undefined"===typeof sessionStorage)return ge.M3;try{const e=sessionStorage.getItem(ge.UV);if(!e)return ge.M3;const t=JSON.parse(e);if(!t||"object"!==typeof t)return ge.M3;const n=t,a=n.displayName,l=n.color,r=n.householdWho,o=n.householdHome,i=n.householdGoal,s=n.topicPrefs;return{displayName:"string"===typeof a?a.slice(0,ge.B7):ge.M3.displayName,color:(0,ge.nM)(l)?l:ge.M3.color,householdWho:(0,ge.kS)(r)?r:null,householdHome:(0,ge.L3)(o)?o:null,householdGoal:(0,ge.tQ)(i)?i:null,topicPrefs:Ce(s)}}catch(e){return ge.M3}})()),Ke},Ze=e=>(qe.add(e),()=>{qe.delete(e)}),Je=()=>{const e=(0,a.useSyncExternalStore)(Ze,$e,$e),t=(0,a.useCallback)((e=>{(e=>{if("undefined"!==typeof sessionStorage)try{sessionStorage.setItem(ge.UV,JSON.stringify(e))}catch(t){return}})((0,U.A)((0,U.A)({},$e()),e)),He=void 0,qe.forEach((e=>e()))}),[]);return{draft:e,updateDraft:t}};var Xe=n(75439);var Qe=n(7977),et=n(26051);const tt={green:Ee.QSX.GREEN,teal:Ee.QSX.TEAL,yellow:Ee.QSX.YELLOW,purple:Ee.QSX.PURPLE,red:Ee.QSX.RED,pink:Ee.QSX.PINK,indigo:Ee.QSX.INDIGO,orange:Ee.QSX.ORANGE},nt=(e,t)=>({__typename:"UserProfile",assistantName:e.displayName,assistantColor:e.color,completedAgentOnboardingAt:t}),at=function(){let e=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}).skip,t=void 0!==e&&e;var n,l,r;const s=(0,et.I)(Qe.SD,{skip:t}),c=s.data,d=s.isLoadingInitialData,u=(0,i.n)(Qe.X7),m=(0,o.A)(u,1)[0],p=(0,i.n)(Qe.uO),g=(0,o.A)(p,1)[0],h=null===(n=null===c||void 0===c?void 0:c.me)||void 0===n?void 0:n.profile,v=null===h||void 0===h?void 0:h.id,f=null===h||void 0===h?void 0:h.assistantColor,E=(0,a.useCallback)((async function(e){let t=(arguments.length>1&&void 0!==arguments[1]?arguments[1]:{}).completeOnboarding,n=void 0!==t&&t;var a,l,r,o,i,s,c,d,u,p,f,E,y,b,x;const w=e?{assistantName:e.displayName,assistantColor:tt[e.color]}:{};if(n){const t=(new Date).toISOString(),n=await g((0,U.A)({variables:{input:w}},v&&{optimisticResponse:{__typename:"Mutation",completeAgentOnboarding:{__typename:"CompleteAgentOnboarding",userProfile:{id:v,__typename:"UserProfile",assistantName:null!==(l=null!==(a=null===e||void 0===e?void 0:e.displayName)&&void 0!==a?a:null===h||void 0===h?void 0:h.assistantName)&&void 0!==l?l:null,assistantColor:null!==(o=null!==(r=null===e||void 0===e?void 0:e.color)&&void 0!==r?r:null===h||void 0===h?void 0:h.assistantColor)&&void 0!==o?o:null,completedAgentOnboardingAt:t},householdPreferences:null,errors:null}}})),m=n.data,p=n.errors;if((null===p||void 0===p?void 0:p.length)||(null===(s=null===(i=null===m||void 0===m?void 0:m.completeAgentOnboarding)||void 0===i?void 0:i.errors)||void 0===s?void 0:s.message))throw new Error(null!==(u=null===(d=null===(c=null===m||void 0===m?void 0:m.completeAgentOnboarding)||void 0===c?void 0:c.errors)||void 0===d?void 0:d.message)&&void 0!==u?u:"Could not save assistant");return}const C=null!==(p=null===h||void 0===h?void 0:h.completedAgentOnboardingAt)&&void 0!==p?p:null,A=await m((0,U.A)({variables:{input:w}},v&&e&&{optimisticResponse:{__typename:"Mutation",updateUserProfile:{__typename:"UpdateUserProfile",userProfile:(0,U.A)({id:v},nt(e,C)),errors:null}}})),I=A.data,k=A.errors;if((null===k||void 0===k?void 0:k.length)||(null===(E=null===(f=null===I||void 0===I?void 0:I.updateUserProfile)||void 0===f?void 0:f.errors)||void 0===E?void 0:E.message))throw new Error(null!==(x=null===(b=null===(y=null===I||void 0===I?void 0:I.updateUserProfile)||void 0===y?void 0:y.errors)||void 0===b?void 0:b.message)&&void 0!==x?x:"Could not save assistant")}),[g,null===h||void 0===h?void 0:h.assistantColor,null===h||void 0===h?void 0:h.assistantName,null===h||void 0===h?void 0:h.completedAgentOnboardingAt,v,m]);return{assistantName:ge.m3&&(null===(l=null===h||void 0===h?void 0:h.assistantName)||void 0===l?void 0:l.trim())||void 0,assistantColor:ge.m3&&(0,ge.nM)(f)?f:void 0,completedAgentOnboardingAt:null!==(r=null===h||void 0===h?void 0:h.completedAgentOnboardingAt)&&void 0!==r?r:null,isLoadingProfile:d,save:E}};var lt=n(65172);const rt=function(){let e=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}).skip,t=void 0!==e&&e;const n=(0,lt.L7)({skip:t}),l=n.householdPreferences,r=n.insightTopics,o=n.isLoadingInitialData,i=n.updateHouseholdPreferences,s=(0,a.useMemo)((()=>(e=>{var t;const n=new Map,a=[];for(const l of e){const e=l.topic,r=l.parent;if(r){const a=null!==(t=n.get(r))&&void 0!==t?t:[];a.push(e),n.set(r,a)}else a.push(e)}return a.map((e=>{var t;return{topic:e,children:null!==(t=n.get(e))&&void 0!==t?t:[]}}))})(null!==r&&void 0!==r?r:[])),[r]),c=((e,t)=>{const n=new Set(null!==t&&void 0!==t?t:[]);return Object.fromEntries(e.flatMap((e=>[e.topic,...e.children].map((e=>[e,!n.has(e)])))))})(s,null===l||void 0===l?void 0:l.disabledInsightTopics),d=(0,a.useCallback)((e=>i({disabledInsightTopics:xe(s,e)})),[s,i]);return{groups:s,topicPrefs:c,isLoadingTopicPrefs:o,saveTopicPrefs:d}};var ot=n(11723);const it={openSettings:()=>{},isSettingsOpen:!1},st=(0,Xe._)("TodayCustomizeDialog"),ct=(0,o.A)(st,2),dt=ct[0],ut=ct[1],mt=e=>{let t=e.children;const n=(0,ot.M)().isOn;return a.createElement(pt,{"data-external-id":"today-customize-dialog-host",isTodayEnabled:n},t)},pt=e=>{let t=e.children,n=e.isTodayEnabled;const l=(0,V.m)(),r=(0,C.RU)(),i=(0,a.useState)(!1),s=(0,o.A)(i,2),c=s[0],d=s[1],u=Je(),m=u.draft,p=u.updateDraft,g=rt({skip:!n}),h=g.groups,v=g.topicPrefs,f=g.isLoadingTopicPrefs,E=g.saveTopicPrefs,y=at({skip:!n}),b=y.assistantName,x=y.assistantColor,w=y.isLoadingProfile,A=y.save,I=!w&&!f,k=(0,a.useMemo)((()=>(0,U.A)((0,U.A)({},m),(0,ge.Pw)({draft:m,profileName:b,profileColor:x}
1))),[m,x,b]),S=(0,a.useCallback)((e=>{w||A(e).then((()=>(0,C.W7)({message:Re.EDIT_ASSISTANT_NAME_SAVED_TOAST,duration:5e3}))).catch((()=>r()))}),[w,A,r]),N=(0,a.useCallback)((e=>{f||E(e).then((()=>{l.refetchQueries({include:["Common_GetTodayInsights"]}),(0,C.W7)({message:Re.CUSTOMIZE_SAVED_TOAST,duration:5e3})})).catch((()=>r()))}),[l,f,E,r]),T=(0,a.useCallback)((()=>{d(!0)}),[]),_=(0,a.useMemo)((()=>n?{openSettings:T,isSettingsOpen:c}:it),[c,n,T]);return a.createElement(dt.Provider,{"data-external-id":"today-customize-dialog-host-inner",value:_},t,n?a.createElement(Ve,{open:c&&I,onOpenChange:d,groups:h,topicPrefs:v,onSave:N,draft:k,onSavePersona:e=>{p({displayName:e.displayName,color:e.color}),S({displayName:e.displayName,color:e.color})}}):null)};var gt=n(70215),ht=n(31144),vt=n(53083),ft=n(19547);const Et=e=>{let t=e.handleCreateNewThread;const n=(0,z.h)(),r=n.closeAssistant,o=n.toggleExpanded,i=n.minimizeAssistant,s=n.parkAssistantMinimized,c=Y(),u=(0,ot.M)().isOn,m=ut().openSettings,p=(0,d.d4)(ft._S),g=(0,d.d4)(ft.MJ),h=(0,d.d4)(ft.GC),v=(0,F.K)(),f=(0,l.Zp)(),E=(0,ht.S)().isAiFeaturesEnabled,y=(0,a.useCallback)((()=>{(0,Ge.u4)(Ye.xb.AssistantSettingsOpened,{thread_id:null!==g&&void 0!==g?g:void 0}),u?m():(f((0,Ue.AI)("preferences","ai-assistant")),r())}),[g,r,u,f,m]),b=(0,a.useCallback)((()=>{(0,Ge.u4)(p?Ye.xb.AssistantModalRetracted:Ye.xb.AssistantModalExpanded,{thread_id:null!==g&&void 0!==g?g:void 0,source:null!==h&&void 0!==h?h:void 0}),o()}),[o,p,g,h]),x=(0,a.useCallback)((()=>{(0,Ge.u4)(Ye.xb.AssistantModalExpanded,{thread_id:null!==g&&void 0!==g?g:void 0,source:null!==h&&void 0!==h?h:void 0}),f((0,gt.Jk)(g)),s()}),[g,f,s,h]),w="top";return a.createElement(yt,{"data-external-id":"assistant-controls"},g&&E&&a.createElement(P.D_,{content:"New chat",place:w},a.createElement(bt,{icon:"create-new",onClick:t,disabled:v})),a.createElement(P.D_,{content:"Settings",place:w},a.createElement(bt,{icon:"settings",onClick:y})),u?a.createElement(P.D_,{content:"Expand",place:w},a.createElement(bt,{icon:"expand",onClick:x})):c&&a.createElement(P.D_,{content:p?"Shrink":"Expand",place:w},a.createElement(bt,{icon:p?"shrink":"expand",onClick:b})),a.createElement(P.D_,{content:"Minimize",place:w},a.createElement(bt,{icon:"minus",onClick:i})),a.createElement(P.D_,{content:"Close",place:w},a.createElement(bt,{icon:"x",onClick:r})))},yt=(0,u.default)(m.g).withConfig({displayName:"AssistantControls__Actions",componentId:"sc-8m05fl-0"})(["margin-right:-",";"],vt.YK.xxsmall),bt=(0,u.default)(B.L).attrs({size:"xsmall"}).withConfig({displayName:"AssistantControls__ActionIconButton",componentId:"sc-8m05fl-1"})(["color:",";span{display:inline-flex;align-items:center;justify-content:center;line-height:0;}"],vt.Ee.color.content.primary);var xt=n(8483),wt=n(40603),Ct=n(26516),At=n(66405);const It=u.default.span.attrs({"data-sc-tw":"AssistantGradient__AssistantGradientText"}).withConfig({displayName:"AssistantGradient__AssistantGradientText",componentId:"q888wl-0"})(["background:linear-gradient( 178deg,"," ","%,"," ","% ) text;transition:",";color:transparent;font-weight:",";"],At.KG,At.A8,At.A9,At.IY,(e=>e.theme.transition.createDefaultTransition(["background"])),(e=>{let t=e.$fontWeight,n=e.theme;return t?n.fontWeight[t]:n.fontWeight.book})),kt=(0,u.css)(["background:linear-gradient(178deg,"," 20%,"," 80%) text;"],Ct.OQ.red10[0],Ct.OQ.orange9[0]),St=(0,u.css)(["transition:transform 300ms ",",color 150ms ease-in-out;"],"cubic-bezier(0.300, -0.380, 0.000, 1.650)"),Nt=(0,u.css)(["transform:rotate(-90deg);"]),Tt=(0,u.default)(It).withConfig({displayName:"AssistantGradient__AssistantTooltipGradientText",componentId:"q888wl-1"})(["background:linear-gradient( 160deg,"," 20%,"," 100% ) text;font-weight:",";"],vt.Ee.color.chart.fill.orange,vt.Ee.color.chart.fill.yellow,(e=>{let t=e.$fontWeight,n=e.theme;return t?n.fontWeight[t]:n.fontWeight.medium}));var _t=n(14728);const Dt=e=>{let t=e.onClose,n=e.source;const r=(0,l.Zp)(),o=(0,d.d4)(A._S);return a.createElement(Rt,{"data-external-id":"assistant-disabled-state"},a.createElement(Mt,{$isExpanded:o},!o&&a.createElement(Lt,null,a.createElement(fe.bQo,{size:"md",className:"text-content-brand"}),a.createElement(It,{$fontWeight:"medium"},"AI Assistant")),a.createElement(xt.v,{size:o?"xlarge":"20",weight:"medium"},_t.zA.DISABLED_STATE.TITLE),a.createElement(xt.v,{size:o?"base":"small",color:"content.secondary"},_t.zA.DISABLED_STATE.SUBTITLE)),a.createElement(wt.Xb,{size:"medium",onClick:()=>{(0,Ge.u4)(Ye.xb.AISettingsEntryClicked,{source:n}),null===t||void 0===t||t(),r((0,Ue.AI)("preferences","ai-assistant"))}},_t.zA.DISABLED_STATE.BUTTON))},Rt=(0,u.default)(m.g).attrs({alignCenter:!0,column:!0,gap:"xlarge",paddingVertical:"default",paddingHorizontal:"xxxlarge"}).withConfig({displayName:"AssistantDisabledState__RootContainer",componentId:"sc-1ii8259-0"}
1)(["height:100%;text-align:center;"]),Mt=(0,u.default)(m.g).attrs({alignCenter:!0,justifyCenter:!0,column:!0,gap:"xxsmall",paddingTop:"xxxxlarge"}).withConfig({displayName:"AssistantDisabledState__ContentContainer",componentId:"sc-1ii8259-1"})(["max-width:",";"],(e=>e.$isExpanded?"385px":"354px")),Lt=(0,u.default)(m.g).attrs({alignCenter:!0,gap:"xsmall"}).withConfig({displayName:"AssistantDisabledState__TitleContainer",componentId:"sc-1ii8259-2"})([""]),Ot=a.forwardRef(((e,t)=>{let n=e.shouldAnimate,l=void 0!==n&&n;const r=(0,a.useState)(!1),i=(0,o.A)(r,2),s=i[0],c=i[1];return(0,a.useEffect)((()=>{if(!l)return;const e=setTimeout((()=>{c(!0)}),800),t=setTimeout((()=>{c(!1)}),1600);return()=>{clearTimeout(e),clearTimeout(t)}}),[l]),a.createElement("div",{"data-external-id":"assistant-header",ref:t,className:"mb-2xs flex items-center justify-center gap-xs"},a.createElement(fe.bQo,{"data-testid":"assistant-header-sparkles",size:16,className:(0,q.cn)("text-content-brand transition-transform duration-300 ease-sparkle",s&&"-rotate-90")}),a.createElement(It,{$fontWeight:"medium"},"AI Assistant"))})),Pt=e=>{const t=e.getHours();return t>=6&&t<12?"Good morning":t>=12&&t<17?"Good afternoon":t>=17&&t<22?"Good evening":"Hello"},Bt=()=>{const e=(0,d.d4)(A.Nc),t=Pt(new Date),n=at(),l=n.assistantName,r=n.assistantColor,o=n.isLoadingProfile,i=(null===l||void 0===l?void 0:l.trim())||ge.Uk,s=null!==r&&void 0!==r?r:ge.fB;return a.createElement("div",{"data-external-id":"today-overlay-empty-intro",className:"flex flex-col items-center"},o?null:a.createElement(he,{color:s,label:i,size:60}),a.createElement(fe.c8D,{size:"sm",color:"secondary",className:"mt-default text-center"},e?"".concat(t,", ").concat(e):t),a.createElement("h2",{className:" m-0 mt-2xs text-center font-secondary text-2xl/9 font-book tracking-[-0.03em] text-content-primary "},Re.ASK_PLACEHOLDER))},zt=(0,u.css)(["display:flex;flex-direction:column;align-items:center;width:100%;position:absolute;top:38%;transform:translateY(-50%);"]),Ft=(0,u.css)(["min-height:60px;"]),Gt=e=>{var t;let n=e.isNewUser,l=e.measurementElementRef,r=e.shouldShowNonWelcomeFlow,i=e.onAnimationComplete;const s=(0,a.useRef)(null),c=(0,d.d4)(ft._S),u=(0,d.d4)(ft.GC),m=(e=>{let t=e.isNewUser,n=e.messages,l=void 0===n?At.d8:n,r=e.onAnimationStart;var i,s;const c=(0,a.useRef)(t).current,d=(0,v.D)((()=>{null===r||void 0===r||r()})),u=(0,a.useState)(0),m=(0,o.A)(u,2),p=m[0],g=m[1],h=(0,a.useState)(!1),f=(0,o.A)(h,2),E=f[0],y=f[1],b=(0,a.useRef)(!1),x=(0,a.useRef)(null),w=c&&!E;(0,a.useEffect)((()=>{if(c&&!b.current&&l.length>0)return b.current=!0,y(!0),d(),x.current=setTimeout((()=>{g(1)}),3e3),()=>{x.current&&clearTimeout(x.current)}}),[c,l,d]),(0,a.useEffect)((()=>{if(E)return x.current&&clearTimeout(x.current),x.current=setTimeout((()=>{g((e=>e===l.length-1?e:e+1))}),3e3),()=>{x.current&&clearTimeout(x.current)}}),[p,l,E]);const C=(0,a.useMemo)((()=>{var e;return(w||E)&&null!==(e=l[p])&&void 0!==e?e:null}),[w,E,p,l]);return{welcomeMessage:null!==(i=null===C||void 0===C?void 0:C.message)&&void 0!==i?i:null,welcomeMessageMaxWidth:null!==(s=null===C||void 0===C?void 0:C.maxWidth)&&void 0!==s?s:null}})({isNewUser:n,onAnimationStart:(0,a.useCallback)((()=>{(0,Ge.u4)(Ye.xb.AssistantWelcomeAnimationViewed,{source:null!==u&&void 0!==u?u:void 0,modal_state:c?"expanded":"retracted"})}),[u,c])}),p=m.welcomeMessage,g=m.welcomeMessageMaxWidth,h=null!==p&&p===(null===(t=At.d8[At.d8.length-1])||void 0===t?void 0:t.message),f=(0,a.useCallback)((()=>{h&&i()}),[h,i]),E=(0,a.useState)(0),y=(0,o.A)(E,2),b=y[0],x=y[1],w=(0,a.useRef)(!1),C=(0,a.useCallback)((()=>{h&&l.current&&s.current&&!w.current&&(w.current=!0,x(-s.current.offsetTop))}),[h,l,s]);return p?a.createElement(Yt,{"data-external-id":"welcome-flow",ref:s,initial:{y:"-50%",opacity:1},animate:{y:h?b:"-50%",opacity:r?0:1},transition:{y:{duration:.4,ease:"easeOut",delay:h?1:0},opacity:{delay:.3}},onAnimationComplete:f},!c&&a.createElement(Ot,{shouldAnimate:!0}),a.createElement(T.N,{mode:"wait"},p&&a.createElement(D.PY1.div,{key:p,initial:{opacity:0}
1,animate:{opacity:1},exit:{opacity:0},transition:{duration:.3},onAnimationComplete:C,style:{display:"flex",flexDirection:"column",alignItems:"center",width:"100%"}},a.createElement(Ut,{$isAssistantExpanded:c,$maxWidth:g},a.createElement(Vt,{$isAssistantExpanded:c},p))))):null},Yt=(0,u.default)(D.PY1.div).withConfig({displayName:"WelcomeFlow__RootMotionDiv",componentId:"meumh5-0"})(["",""],zt),Ut=u.default.div.withConfig({displayName:"WelcomeFlow__MessageContainer",componentId:"meumh5-1"})(["position:relative;width:100%;text-align:center;display:flex;max-width:",";"," ",""],(e=>{let t=e.$maxWidth;return t?"".concat(t,"px"):"none"}),Ft,(e=>!e.$isAssistantExpanded&&"\n    margin: 0 auto;\n  ")),Vt=(0,u.default)(xt.v).attrs({size:"20",weight:"medium",align:"center",color:"content.primary"}).withConfig({displayName:"WelcomeFlow__WelcomeFlowMessage",componentId:"meumh5-2"})(["width:100%;"]),Wt={merchant:["green","blue"],category:["pink","purple"],amount:["orange","yellow"],budget:["blue","purple"],goal:["red","orange"]};var jt=n(86862);const Ht=function(e,t){let n=(arguments.length>2&&void 0!==arguments[2]?arguments[2]:{}).abbreviateThousands,a=void 0===n||n;if("amount"===t){const t=parseFloat(e);if(!isNaN(t))return a?(0,jt._L)(t):(0,jt.T3)(t)}return e},Kt=e=>{let t=e.prompt,n=e.position,l=e.onClick,r=e.disabled;const o=(0,u.useTheme)(),i=t.promptSegments&&t.promptSegments.length>0;return a.createElement(qt,{"data-external-id":"smart-prompt-card",$disabled:r,onClick:()=>l(t,n)},a.createElement(xt.v,{size:"base",color:"content.primary",align:"center"},i?t.promptSegments.map(((e,t)=>{const n=((e,t)=>{const n=e?Wt[e]:null;if(!n)return null;const a=t.variables.color.chart.fill;return[a[n[0]],a[n[1]]]})(e.entityType,o);return a.createElement($t,{key:t},e.icon?a.createElement(Zt,null,e.icon):null,n?a.createElement(Jt,{$startColor:n[0],$endColor:n[1]},Ht(e.text,e.entityType)):a.createElement("span",null,e.text))})):a.createElement("span",null,t.promptText)))},qt=u.default.div.withConfig({displayName:"SmartPromptCard__PromptItem",componentId:"sc-14c4ixm-0"})(["padding:"," ",";cursor:",";transition:background-color 0.2s,opacity 0.2s;border-radius:",";background-color:",";box-shadow:0 2px 8px ",";opacity:",";pointer-events:",";&:hover{background-color:",";}"],vt.YK.small,vt.YK.default,(e=>e.$disabled?"default":"pointer"),vt.r8.large,vt.Ee.color.background.primary,vt.Ee.color.shadow.medium,(e=>e.$disabled?.5:1),(e=>e.$disabled?"none":"auto"),vt.Ee.color.background.primaryHover),$t=u.default.span.withConfig({displayName:"SmartPromptCard__SegmentWrapper",componentId:"sc-14c4ixm-1"})(["align-items:center;vertical-align:baseline;"]),Zt=u.default.span.withConfig({displayName:"SmartPromptCard__InlineIcon",componentId:"sc-14c4ixm-2"})(["margin-right:",";"],vt.YK.xxxsmall),Jt=u.default.span.withConfig({displayName:"SmartPromptCard__GradientText",componentId:"sc-14c4ixm-3"})(["background:linear-gradient( 135deg,",","," );background-clip:text;-webkit-background-clip:text;-webkit-text-fill-color:transparent;font-weight:500;"],(e=>e.$startColor),(e=>e.$endColor));var Xt=n(88702),Qt=n(95453);const en=(0,Qt.J)("\n  query Common_GetSmartPrompts($limit: Int = 5) {\n    smartPrompts(limit: $limit) {\n      id\n      promptText\n      promptSegments {\n        text\n        entityType\n        icon\n      }\n      category\n      subjectType\n      subjectName\n      impressionCount\n      clickCount\n      createdAt\n      templateName\n    }\n  }\n"),tn=(0,Qt.J)("\n  mutation Common_RecordSmartPromptImpressions($promptIds: [ID!]!) {\n    recordSmartPromptImpressions(promptIds: $promptIds) {\n      updatedCount\n    }\n  }\n"),nn=(0,Qt.J)("\n  mutation Common_RecordSmartPromptClick($promptId: ID!) {\n    recordSmartPromptClick(promptId: $promptId) {\n      success\n    }\n  }\n"),an=()=>{const e=(0,i.n)(tn),t=(0,o.A)(e,1)[0],n=(0,i.n)(nn),l=(0,o.A)(n,1)[0],r=(0,a.useRef)(new Set);return{trackImpressions:(0,a.useCallback)((e=>{const n=e.filter((e=>!r.current.has(e.id)));if(0===n.length)return;const a=n.map((e=>e.id));for(const t of n)r.current.add(t.id);t({variables:{promptIds:a}}).catch((()=>{}))}),[t]),trackClick:(0,a.useCallback)((e=>{l({variables:{promptId:e.id}}).catch((()=>{}))}),[l])}},ln=At.GH.map(((e,t)=>({__typename:"SmartPromptType",id:"hardcoded-".concat(t),promptText:e.prompt,promptSegments:null,category:null,subjectType:null,subjectName:null,impressionCount:0,clickCount:0,createdAt:"",templateName:null}))),rn=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:5,t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];var n;const l=(0,et.I)(en,{variables:{limit:e},skip:!t}),r=l.data,o=l.isLoadingInitialData,i=l.error,s=l.refetch,c=(0,a.useMemo)((()=>ln.slice(0,e)),[e]),d=null!==(n=null===r||void 0===r?void 0:r.smartPrompts)&&void 0!==n?n:[],u=t&&d.length>=3;return{prompts:u?d:c,isUsingSmartPrompts:u,isLoadingInitialData:!!t&&o,error:t?i:void 0,refetch:s}};var on=n(22452);let sn=!1,cn=!1;const dn=e=>{let t=e.isLoadingInitialData,n=e.sendMessage,l=e.messageThreads;const r=(0,d.d4)(ft._S),i=(0,d.d4)(ft.GC),s=(0,ot.M)().isOn,c=(0,F.K)(),u=(0,on.u)("feat-smart-prompts","va-1",{trackImpression:!0}).whichExperimentVariant,m=rn(5,void 0!==u),p=m.prompts,g=m.isUsingSmartPrompts,h=m.isLoadingInitialData,v=an(),f=v.trackImpressions,E=v.trackClick,y=(0,a.useRef)(!1);l.length>0&&(cn=!0);const b=0===l.length&&!sn&&!cn,x=(0,a.useRef)(null),w=(0,a.useState)(!b),C=(0,o.A)(w,2),A=C[0],I=C[1];(0,a.useEffect)((()=>{p.length>0&&(s||A)&&!h&&!y.current&&(y.current=!0,(0,Ge.u4)(Ye.xb.AssistantPromptShown,{source:null!==i&&void 0!==i?i:void 0,prompt_type:g?"smart":"generic"}),g&&f(p))}),[g,p,A,s,h,f,i]),(0,a.useEffect)((()=>{t||b||A||I(!0)}),[t,b,A,I]);const k=(0,a.useCallback)(((e,t)=>{var a;c||(g&&E(e),(0,Ge.u4)(Ye.xb.AssistantPromptSelected,{prompt_template_name:null!==(a=e.templateName)&&void 0!==a?a:void 0,prompt_position:t,source:null!==i&&void 0!==i?i:void 0,prompt_type:g?"smart":"generic"}),n({content:e.promptText,fromRecommendedPrompt:!0,triggerSource:(0,Xt.Q)(i,g?"smart":"generic")}))}),[g,n,i,E,c]),S=(0,a.useCallback)((()=>{I(!0),sn=!0}),[]);return a.createElement(un,{"data-external-id":"persistent-assistant-empty-state",$isAssistantExpanded:r},a.createElement(gn,{ref:x},t&&a.createElement(mn,null,!r&&a.createElement(M.Al,{$height:"24px",$width:"112px"}),a.createElement(fn,null,a.createElement(M.Al,{$height:"30px",$width:"160px"}))),!t&&!s&&a.createElement(Gt,{isNewUser:b,measurementElementRef:x,shouldShowNonWelcomeFlow:A,onAnimationComplete:S}),a.createElement(vn,{$isHidden:t||!s&&!A}
1,s?a.createElement(Bt,null):a.createElement(a.Fragment,null,!r&&a.createElement(Ot,{shouldAnimate:!1}),a.createElement(hn,{$isAssistantExpanded:r},"Ask anything about your money")),a.createElement("div",{className:"mt-xl flex flex-col items-center gap-sm"},p.map(((e,t)=>a.createElement(Kt,{key:"prompt-".concat(e.id),prompt:e,position:t,onClick:k,disabled:c})))))))},un=(0,u.default)(m.g).attrs((e=>({gap:"default",padding:"default",column:!0,justifyCenter:e.$isAssistantExpanded,alignCenter:!0}))).withConfig({displayName:"PersistentAssistantEmptyState__Root",componentId:"sc-1f2e758-0"})(["max-width:768px;width:100%;height:100%;position:relative;min-height:min-content;"]),mn=u.default.div.withConfig({displayName:"PersistentAssistantEmptyState__LoadingCenterOffset",componentId:"sc-1f2e758-1"})([""," gap:",";"],zt,vt.YK.small),pn=u.default.div.withConfig({displayName:"PersistentAssistantEmptyState__Inner",componentId:"sc-1f2e758-2"})(["position:relative;text-align:center;"]),gn=(0,u.default)(pn).withConfig({displayName:"PersistentAssistantEmptyState__LoadedInner",componentId:"sc-1f2e758-3"})(["width:420px;max-width:100%;"]),hn=(0,u.default)(xt.v).attrs({size:"20",weight:"medium",align:"center",color:"content.primary"}).withConfig({displayName:"PersistentAssistantEmptyState__Title",componentId:"sc-1f2e758-4"})(["margin-top:0;",""],(e=>!e.$isAssistantExpanded&&"\n    margin-left: auto;\n    margin-right: auto;\n  ")),vn=u.default.div.withConfig({displayName:"PersistentAssistantEmptyState__EmptyState",componentId:"sc-1f2e758-5"})(["opacity:",";transition:opacity ","s ease-out;",""],(e=>e.$isHidden?0:1),.3,(e=>e.$isHidden&&"\n    pointer-events: none;\n  ")),fn=u.default.div.withConfig({displayName:"PersistentAssistantEmptyState__LoadingSkeletonContainer",componentId:"sc-1f2e758-6"})(["",""],Ft);var En=n(13398),yn=n(76426),bn=n(23663),xn=n(20662),wn=n(41387);const Cn=e=>{let t=e.linkTo,n=e.children,r=e.className;const o=e=>{let n=e.children;return t?a.createElement(l.N_,{"data-external-id":"maybe-link",to:t,className:"text-inherit"},n):a.createElement(a.Fragment,null,n)};return a.createElement(o,{"data-external-id":"message-card"},a.createElement(An,{$clickable:!!t,className:r},n))},An=(0,u.default)(m.g).withConfig({displayName:"MessageCard__Root",componentId:"sc-11jk2zm-0"})(["border-radius:",";border:1px solid ",";"," background:",";padding:",";",""],(e=>e.theme.radius.medium),(e=>e.theme.color.grayFocus),wn.M.small,(e=>e.theme.color.white),(e=>e.theme.spacing.small),(e=>e.$clickable&&(0,u.css)(["cursor:pointer;transition:",";:hover{","}"],(e=>e.theme.transition.default),wn.M.medium))),In=(0,u.default)(Cn).withConfig({displayName:"MessageCard__ChartMessageCard",componentId:"sc-11jk2zm-1"})(["padding:",";width:100%;"],vt.YK.xlarge);var kn=n(31408),Sn=n(86088),Nn=n(59209),Tn=n.n(Nn),_n=n(21705);const Dn=["category","merchant"],Rn={},Mn=e=>(Rn[e.type]=e,e),Ln=Mn({type:"text",parse:e=>({content:e})}),On=e=>Mn({type:e,parse:e=>{const t=[...e.matchAll(/^(\d{12,}?)[,;]/gm)].map((e=>e[1]));let n=[];try{n=Tn().parse(e,{header:!0,delimiter:";"}).data}catch(a){}return{ids:t,rows:n}}}),Pn=On("entity:transactions"),Bn=On("entity:recurring_transactions"),zn=On("entity:goals"),Fn=On("entity:accounts"),Gn=On("entity:transaction_tags"),Yn=e=>{if(!e)return[void 0,void 0];const t=(0,De.$J)(e);let n=(null===e||void 0===e?void 0:e.includes("$"))?"currency":"number";return void 0===t&&(n=void 0),[t,n]},Un=e=>Mn({type:e,parse:(e,t)=>{if(t)return{chartData:[],columns:[]};const n=Tn().parse(e,{delimiter:";"}).data,a=(0,_n.A)(n[0]).map(((e,t)=>{const a=Yn(n[1][t+1]);return{label:e,valueType:(0,o.A)(a,2)[1]}}));return{chartData:(0,_n.A)(n).map((e=>{let t=(0,Sn.A)(e);return{label:t[0],values:(0,kn.A)(t).slice(1).map((e=>{const t=Yn(e);return(0,o.A)(t,1)[0]}))}})),columns:a}}}),Vn=Un("chart:pie"),Wn=Un("chart:bar"),jn=Un("chart:line"),Hn=Mn({type:"question:multiple-choice",parse:e=>{const t=e.toLowerCase().indexOf("options:"),n=e.lastIndexOf("?");let a,l;if(-1!==t)a=e.substring(0,t).trim(),l=e.substring(t+8);else if(-1!==n)a=e.substring(0,n+1).trim(),l=e.substring(n+1);else{const t=e.split("\n").map((e=>e.trim())).filter((e=>""!==e));a=t[0]||e.trim(),l=t.slice(1).join("\n")}return{question:a,choices:l.split("\n").map((e=>e.trim())).filter((e=>""!==e)).map((e=>e.slice(2).trim()))}}}),Kn=Mn({type:"app:link",parse:e=>{var t,n,a;const l=e.trim().split("\n");return{url:(null===(t=l[0])||void 0===t?void 0:t.trim())||"",title:(null===(n=l[1])||void 0===n?void 0:n.trim())||"Link",description:(null===(a=l[2])||void 0===a?void 0:a.trim())||""}}}),qn=e=>({type:"text",value:e}),$n=/\[\[([^:]+):([^:]+):([^\]]+)\]\]/,Zn=e=>e.map((e=>e.map((e=>(e=>{const t=e.match($n);if(t&&t[0]===e){const e=(0,o.A)(t,4),n=e[1],a=e[2],l=e[3];
1return Dn.includes(n)?((e,t,n)=>({type:"entity",value:n,entityId:t,entityType:e}))(n,a,l):qn(l)}return qn(e)})(e||""))))),Jn=Mn({type:"table:data",parse:e=>{const t=Tn().parse(e,{delimiter:";",header:!1}).data;if(0===t.length)return{headers:[],rows:[]};const n=(0,Sn.A)(t),a=n[0],l=(0,kn.A)(n).slice(1);return{headers:a,rows:Zn(l)}}});var Xn=n(76073),Qn=n(20417),ea=n.n(Qn),ta=n(42067),na=n.n(ta);const aa=(e,t)=>{const n=a.memo(e,t);return na()(n,e),n};var la;!function(e){e.Recap="recap",e.Assistant="assistant"}(la||(la={}));const ra=e=>t=>({block:e,render:aa(t,ea())}),oa=e=>(0,Xn.A)((e=>e.block.type),e),ia=e=>{let t=e.block,n=e.blockRenderers,l=e.previousBlockInGroup,r=e.nextBlockInGroup,o=e.nextGroup,i=e.messageType,s=e.renderContext,c=void 0===s?la.Assistant:s,d=e.assistantResponseState;var u;const m=null===(u=n[t.type])||void 0===u?void 0:u.render;return m&&a.createElement(m,{messageType:i,data:t.data,incomplete:t.incomplete,previousBlockInGroup:l,nextBlockInGroup:r,nextGroup:o,renderContext:c,assistantResponseState:d})},sa=ra(Fn)((e=>{let t=e.data.ids,n=e.renderContext;const l=(0,a.useState)(!1),r=(0,o.A)(l,2),i=r[0],s=r[1],c=(0,et.I)(ua,{variables:{ids:t}}),u=c.data,m=c.isLoadingInitialData,g=!(0,d.d4)(A._S)&&n===la.Assistant,h=(null!==u&&void 0!==u?u:{}).accounts,v=void 0===h?[]:h,f=(0,a.useMemo)((()=>v.filter((e=>t.includes(e.id)))),[v,t]),E=i?f:f.slice(0,5),y=f.length>5;return a.createElement(ca,null,a.createElement("div",{className:"flex flex-1 flex-col"},m?a.createElement("div",{className:"flex items-center justify-center"},a.createElement(p.i,{size:"sm"})):a.createElement(a.Fragment,null,E.map((e=>a.createElement(da,{key:e.id,account:e,dragHandle:"none",compacted:g}))),y&&a.createElement("div",{className:"flex justify-center border-t border-divider-primary py-sm"},a.createElement(bn.v,{onClick:()=>s(!i)},i?"View less":"View all (".concat(f.length,")"))))))})),ca=(0,u.default)(Cn).withConfig({displayName:"AccountsBlockRenderer__AccountsMessageCard",componentId:"sc-11ycvtg-0"})(["padding:0;overflow:hidden;"]),da=(0,u.default)(xn.Z).withConfig({displayName:"AccountsBlockRenderer__AccountMessageBlock",componentId:"sc-11ycvtg-1"})(["padding:"," ",";width:100%;"],vt.YK.small,vt.YK.large),ua=Ee.NZJ;var ma=n(12158),pa=n(45285);const ga=Object.values(pa.EC),ha=e=>{let t=e.href,n=e.children;const r=(0,d.d4)(A._S),o=(0,z.h)().toggleExpanded,i=(0,ot.M)().isOn,s=(0,a.useCallback)((()=>{!i&&r&&o()}),[r,i,o]);return a.createElement(fa,{"data-external-id":"route-link",as:l.k2,to:t,onClick:s},n)},va=ra(Kn)((e=>{let t=e.data,n=t.url,l=t.title,r=t.description;const o=(e=>{try{var t,n;const a=new URL(e).pathname,l=ga.find((e=>{let t=e.route;return(0,ma.gQ)(a,t)}));return null!==(t=(0,fe.lSP)(null!==(n=null===l||void 0===l?void 0:l.icon)&&void 0!==n?n:"link"))&&void 0!==t?t:"link"}catch(a){return"link"}})(n);return a.createElement(ha,{href:n},a.createElement("div",{className:" flex items-center justify-between gap-sm rounded-lg border border-border-primary bg-background-primary px-default py-sm "},a.createElement("div",{className:"flex items-center gap-sm"},a.createElement("div",{className:" flex size-10 shrink-0 items-center justify-center rounded-full bg-background-secondary text-content-secondary "},a.createElement(fe.jeH,{name:o,size:"md"})),a.createElement("div",{className:"flex flex-col gap-3xs"},a.createElement(xt.v,{weight:"medium"},l),r&&a.createElement(xt.v,{color:"content.link",size:"small"},r))),a.createElement(fe.Fug,{size:"md"})))})),fa=u.default.a.withConfig({displayName:"AppLinkRenderer__LinkContainer",componentId:"sc-1xal1bh-0"})(["width:100%;color:",";&:hover > *{color:",";background-color:",";}"],vt.Ee.color.content.primary,vt.Ee.color.content.primary,vt.Ee.color.background.primaryHover);var Ea=n(65131),ya=n(1025),ba=n(52360),xa=n(26792),wa=n(14927),Ca=n(33994),Aa=n(44629),Ia=n(20606),ka=n(17706),Sa=n(69263),Na=n(8235),Ta=n(57432),_a=n(39009);const Da=["label"],Ra=u.default.div.withConfig({displayName:"SimpleBarChart__Root",componentId:"sc-1andftp-0"})(["width:100%;.recharts-rectangle{transition:",";}.recharts-tooltip-wrapper{z-index:var(--z-tooltip);}g.recharts-cartesian-grid-horizontal > line:last-child{stroke-opacity:0;}"],vt.kY.default),Ma=u.default.div.withConfig({displayName:"SimpleBarChart__LegendContainer",componentId:"sc-1andftp-1"})(["margin-top:",";text-align:center;line-height:1.8;> *{display:inline-flex;&:not(:last-child){margin-right:",";}}"],vt.YK.large,vt.YK.large),La=(e,t)=>n=>{const l=n.active,r=(0,_a.WS)(n),o=null!==r&&void 0!==r?r:{},i=o.label,s=(0,En.A)(o,Da);return a.createElement(Sa.II,{active:l,header:i&&t?t(i):i},e.map(((e,t)=>{let n=e.dataKey,l=e.color,r=e.label,o=e.valueFormatter;return a.createElement(Na.B,{key:t,dotFillColor:l,label:r,value:o?o(s[n]):s[n]})})))},Oa=e=>{var t;
1let n=e.data,l=e.bars,r=e.width,i=e.height,s=e.yAxisTickFormatter,c=void 0===s?null===(t=l[0])||void 0===t?void 0:t.valueFormatter:s,d=e.formatXAxis,p=void 0===d?e=>e:d,g=e.isAnimationActive,h=e.withLegend,v=e.withCartesianGrid,f=e.tooltipComponent,E=e.margin,y=void 0===E?{}:E,b=e.renderAllTicks,x=e.tooltipHeaderFormatter;const w=(0,a.useState)(),C=(0,o.A)(w,2),A=C[0],I=C[1],k=(0,u.useTheme)(),S=(0,a.useMemo)((()=>({fontSize:k.fontSize.xsmall,fill:k.variables.color.chart.label,fontWeight:parseInt(k.fontWeight.medium,10)})),[k]),N=(0,a.useCallback)((e=>{I(e)}),[I]),T=(0,a.useCallback)((()=>{I(void 0)}),[I]),_=(0,a.useMemo)((()=>void 0===A?n:n.map((e=>e.label===A?(0,U.A)((0,U.A)({},e),{},{style:{filter:"brightness(85%)"}}):e))),[n,A]);return a.createElement(Ra,{"data-external-id":"simple-bar-chart"},a.createElement(ya.u,{width:r,height:i},a.createElement(ba.E,{data:_,margin:y},v&&a.createElement(ka.d,null),a.createElement(xa.W,{dataKey:"label",type:"category",tick:(0,U.A)({},S),stroke:k.variables.color.chart.axis,tickMargin:8,padding:{left:8},tickLine:!1,axisLine:!1,tickFormatter:p,interval:b?0:"preserveStartEnd",tickCount:5,minTickGap:0}),a.createElement(wa.h,{type:"number",tick:(0,U.A)((0,U.A)({},S),{},{textAnchor:"start"}),tickMargin:34+parseInt(k.spacing.xxsmall,10),stroke:k.variables.color.chart.axis,tickLine:!1,axisLine:!1,tickFormatter:c,tickCount:5,padding:{top:20}}),l.map(((e,t)=>{let n=e.dataKey,l=e.color;return a.createElement(Ca.yP,{key:t,dataKey:n,fill:l,isAnimationActive:g,onMouseEnter:(e,t)=>{var n;const a=null===(n=e.payload)||void 0===n?void 0:n.label;a&&N(a)},onMouseLeave:T})})),a.createElement(Aa.m,{cursor:!1,content:null!==f&&void 0!==f?f:La(l,x),useTranslate3d:!0}),h&&a.createElement(Ia.s,{content:()=>a.createElement(Ma,null,l.map((e=>{let t=e.label,n=e.color;return a.createElement(m.g,{key:t,gap:"xsmall",center:!0},a.createElement(Ta.c,{size:12,color:(0,Ea.A)(n)?k.color.gray:n}),a.createElement(xt.v,{size:"xsmall",color:"textLight",weight:"medium",clampLine
1s:1},t))})))}))))},Pa=a.memo(Oa);var Ba=n(15669);const za=(e,t)=>{if(0===e.length)return!1;return e.map((e=>t.find((t=>t.name===e.label)))).filter(Boolean).length/e.length>=.5},Fa=function(e,t,n){let a=arguments.length>3&&void 0!==arguments[3]&&arguments[3];if(t){const t=n.find((t=>t.name===e));if(t)return a?t.icon:"".concat(t.icon," ").concat(t.name)}return e?((e,t)=>(e=>!!e.match(/^\d{4}-\d{2}-\d{2}$/))(e)?(0,Ba.SR)(e):t?e.slice(0,10)+(e.length>10?"\u2026":""):e)(e,a):e},Ga=250,Ya=["blue","green","yellow","orange","purple","pink","indigo","teal","red"];var Ua;!function(e){e.Positive="positive",e.Negative="negative"}(Ua||(Ua={}));const Va="Other",Wa=["Wrong numbers or info","Didn't fully answer","Misunderstood my question","Too generic, didn't use my data","Said it couldn't help",Va],ja="Helpful",Ha="Unhelpful",Ka="Share feedback",qa="What was wrong with this response?",$a="(optional)",Za="Share details",Ja="Cancel",Xa="Submit",Qa="Couldn't save your feedback. Try again.",el="Copy",tl="Copy reply",nl="Copied",al="Couldn't copy this reply. Try again.";var ll=n(93278),rl=n(8134);const ol=(0,u.default)(m.g).attrs({center:!0,column:!0}).withConfig({displayName:"BarChartBlockRenderer__LoadingContainer",componentId:"s5jpai-0"})(["height:","px;width:100%;"],Ga),il=ra(Wn)((e=>{var t;let n=e.data,l=n.chartData,r=n.columns,o=e.incomplete;const i=(0,u.useTheme)(),s=(0,ll.C)().categories,c=(0,a.useMemo)((()=>r.map(((e,t)=>{let n=e.label,a=e.valueType;return{label:n,dataKey:"".concat(n,"-").concat(t),color:i.color[Ya[t%Ya.length]],valueFormatter:e=>"currency"===a?(0,rl.vv)(Math.abs(null!==e&&void 0!==e?e:0)):"".concat(e)}}))),[r,i]),d=(0,a.useMemo)((()=>l.map((e=>{let t=e.label,n=e.values;return(0,U.A)({label:t},c.reduce(((e,t,a)=>{var l;let r=t.dataKey;return(0,U.A)((0,U.A)({},e),{},{[r]:Math.abs(null!==(l=n[a])&&void 0!==l?l:0)})}),{}))}))),[l,c]),m=(0,a.useMemo)((()=>za(l,s)),[s,l]),g=(0,a.useCallback)(((e,t)=>Fa(e,m,s,!0)),[s,m]),h=(0,a.useCallback)((e=>Fa(e,m,s,!1)),[s,m]);return a.createElement(In,null,o?a.createElement(ol,null,a.createElement(p.i,null)):a.createElement(Pa,{width:"100%",height:Ga,data:d,bars:c,yAxisTickFormatter:"currency"===(null===(t=r[0])||void 0===t?void 0:t.valueType)?rl.fw:void 0,isAnimationActive:!1,withCartesianGrid:!0,formatXAxis:g,tooltipHeaderFormatter:h,renderAllTicks:m,margin:{left:-14}}))}));var sl=n(35960),cl=n(12353);const dl=e=>{let t=e.canContinue;const n=(()=>{const e=(0,a.useContext)(L);if(!e)throw new Error("useAssistantContext must be used within an AssistantProvider");return e})(),l=n.sendMessage,r=(0,a.useCallback)((()=>{l({content:_t.zA.CONTINUE_RESPONSE_MESSAGE,triggerSource:Ee.y3I.ASSISTANT})}),[l]);return a.createElement(ul,{"data-external-id":"cancelled-response-notice",alignCenter:!0,gap:"xsmall"},a.createElement(ml,null),a.createElement("div",{className:"flex flex-col"},a.createElement(xt.v,{size:"small",weight:"medium"},_t.zA.CANCELLED_RESPONSE_TITLE),a.createElement(xt.v,{size:"small",color:"content.secondary"},"Ask a new question or"," ",a.createElement(pl,{onClick:t?r:void 0,$disabled:!t},"continue")," ","this response.")))},ul=(0,u.default)(m.g).withConfig({displayName:"CancelledResponseNotice__Root",componentId:"sc-18kpe44-0"})(["border:1px solid ",";border-radius:",";padding:",";"],vt.Ee.color.border.primary,vt.r8.large,vt.YK.small),ml=(0,u.default)(sl.ZQ).attrs({name:"info",size:16}).withConfig({displayName:"CancelledResponseNotice__StyledIcon",componentId:"sc-18kpe44-1"})(["color:",";"],vt.Ee.color.content.secondary),pl=(0,u.default)(cl.M).withConfig({displayName:"CancelledResponseNotice__ContinueLink",componentId:"sc-18kpe44-2"})(["",""],(e=>{let t=e.$disabled,n=e.theme;return t&&"\n    color: ".concat(n.variables.color.content.secondary,";\n    cursor: not-allowed;\n    opacity: 0.5;\n\n    &:hover {\n      color: ").concat(n.variables.color.content.secondary,";\n    }\n  ")})),gl=ra(Fn)((e=>{let t=e.data.rows;const n=(0,d.d4)(A._S);return a.createElement(ca,null,t.map((e=>{let t=e.ID,l=e.Name,r=e.Type,o=e.Balance;return a.createElement(da,{key:t,account:{id:t,displayName:l,type:r,displayBalance:(0,rl.vu)(o),includeInNetWorth:!0},dragHandle:"none",compacted:!n})})))}));
1var hl=n(55441),vl=n(30717),fl=n(88370),El=n(98844),yl=n(41366),bl=n(95542);const xl=e=>{var t;let n=e.goal,l=e.className,r=e.timeframeDisplay,o=void 0===r?"This month":r;const i=n.name,s=n.imageStorageProvider,c=n.imageStorageProviderId,d=n.accountAllocations,u=n.type,p=null!==(t=n.currentAmount)&&void 0!==t?t:0,g=(0,a.useMemo)((()=>(0,yl.SM)(d)),[d]);return a.createElement(wl,{"data-external-id":"goal-dashboard-row",className:l},a.createElement(m.g,{alignCenter:!0},a.createElement(Cl,{size:"small",imageStorageProvider:s,imageStorageProviderId:c,showGradient:!1}),a.createElement(Al,{column:!0,alignStretch:!0},a.createElement(Il,null,i),a.createElement(m.g,{alignEnd:!0,justifyBetween:!0,style:{flex:1}},a.createElement(kl,{value:(0,yl.e3)(n),round:!0}),a.createElement(El.H,{className:"text-sm",startAmount:p,timeframeDisplay:o,endAmount:p+(0,yl.kD)(g,u),isAsset:u!==bl.IW.Debt})))),a.createElement(fe.cqk,{value:(0,yl.We)(n),max:1,color:"progress-success",className:"mt-default"}))},wl=(0,u.default)(m.g).attrs({column:!0}).withConfig({displayName:"GoalDashboardRow__Root",componentId:"v9o3lv-0"})(["padding:"," ",";border-bottom:1px solid ",";"],vt.YK.default,vt.YK.xlarge,vt.yW.grayBackground),Cl=(0,u.default)(vl.b).withConfig({displayName:"GoalDashboardRow__StyledGoalImage",componentId:"v9o3lv-1"})(["width:42px;height:42px;border-radius:",";margin-right:",";position:relative;"],vt.r8.xxsmall,vt.YK.default),Al=(0,u.default)(m.g).withConfig({displayName:"GoalDashboardRow__TitleContainer",componentId:"v9o3lv-2"})(["flex:1;"]),Il=(0,u.default)(xt.v).attrs({color:"textLight",size:"xsmall",weight:"bold"}).withConfig({displayName:"GoalDashboardRow__Title",componentId:"v9o3lv-3"})(["margin-bottom:",";"],vt.YK.xxxsmall),kl=(0,u.default)(hl.t).attrs((0,U.A)({size:"large",weight:"medium",color:"text"},fl.zs)).withConfig({displayName:"GoalDashboardRow__Balance",componentId:"v9o3lv-4"})(["font-size:",";font-weight:",";color:",";"],vt.J.large,vt.Wy.medium,vt.yW.text),Sl=e=>{let t=e.goal,n=e.loading;return a.createElement(Nl,{"data-external-id":"goal-message-block",linkTo:t?I.JZ.goalsV2.goalDetail({id:t.id}):void 0},n||!t?a.createElement(_l,null,a.createElement(p.i,{size:"sm"})):a.createElement(Tl,{goal:t}))},Nl=(0,u.default)(Cn).withConfig({displayName:"GoalMessageBlock__Root",componentId:"j9q9dk-0"})(["width:100%;padding-top:0;padding-bottom:0;"]),Tl=(0,u.default)(xl).withConfig({displayName:"GoalMessageBlock__StyledGoalDashboardRow",componentId:"j9q9dk-1"})(["padding-left:0;padding-right:0;border-bottom:none;width:100%;"]),_l=(0,u.default)(m.g).attrs({center:!0}).withConfig({displayName:"GoalMessageBlock__LoadingContainer",componentId:"j9q9dk-2"})(["height:129px;flex:1;"]),Dl=["ID","Name"],Rl=(0,u.default)(m.g).withConfig({displayName:"DemoGoalsBlockRenderer__Root",componentId:"sc-13m46wd-0"})(["flex:1;gap:",";"],(e=>e.theme.spacing.xsmall)),Ml=ra(zn)((e=>{let t=e.data.rows;return a.createElement(Rl,{column:!0},t.map((e=>{var t,n;let l=e.ID,r=e.Name,o=(0,En.A)(e,Dl);return a.createElement(Sl,{key:l,goal:{__typename:"GoalV2",id:l,name:r,currentAmount:(0,rl.vu)(o["Current Amount"]),completionPercent:(null!==(t=(0,rl.vu)(o["Current Amount"]))&&void 0!==t?t:0)/(null!==(n=(0,rl.vu)(o["Target Amount"]))&&void 0!==n?n:1)*100,archivedAt:null,type:bl.IW.Asset,completedAt:null,imageStorageProvider:"cloudinary",imageStorageProviderId:"production/goals/defaults/a98indaoj1b5jvfys9pi",accountAllocations:[]}})})))}));var Ll=n(1170);const Ol=e=>{let t=e.question,n=e.choices,l=e.onClickChoice;return a.createElement(Pl,{"data-external-id":"multiple-choice-message-block"},a.createElement(Ll.o,{source:t}),n.length>0&&a.createElement(Bl,null,n.map((e=>a.createElement(zl,{key:e,onClick:()=>null===l||void 0===l?void 0:l(e)},e)))))},Pl=(0,u.default)(m.g).withConfig({displayName:"MultipleChoiceMessageBlock__Root",componentId:"sc-1gr9g4i-0"})(["gap:",";flex-direction:column;align-items:flex-start;"],(e=>e.theme.spacing.xsmall)),Bl=(0,u.default)(m.g).withConfig({displayName:"MultipleChoiceMessageBlock__ChoicesContainer",componentId:"sc-1gr9g4i-1"})(["flex:1;gap:",";flex-direction:row;flex-wrap:wrap;justify-content:flex-start;align-items:flex-start;"],(e=>e.theme.spacing.xsmall)),zl=(0,u.default)(wt.Xb).withConfig({displayName:"MultipleChoiceMessageBlock__ChoiceButton",componentId:"sc-1gr9g4i-2"})(["border-radius:",";"],(e=>e.theme.radius.medium)),Fl=ra(Hn)((e=>{let t=e.data,n=t.question,l=t.choices;const r=!!e.nextGroup;return a.createElement(Ol,{question:n,choices:r?[]:l})}));var Gl=n(61975),Yl=n(72141),Ul=n(5356),Vl=n(90402),Wl=n(47889);const jl=e=>{let t=e.id,n=e.isMerchant,a=e.queryParams;return t?n?I.JZ.merchants({id:t,queryParams:a}):I.JZ.accounts.accountDetails({id:t,queryParams:a}):""},Hl=e=>{let t=e.id,n=e.name,r=e.frequency,o=e.logoUrl,i=e.account,s=e.logoSize,c=void 0===s?40:s,d=e.className,u=e.startDate,m=e.isMerchant;const p=u?{date:u.startOf("month").toISODate()}:{},g=jl({id:t,isMerchant:m,queryParams:p});return a.createElement($l,{"data-external-id":"recurring-stream",className:d},a.createElement(l.N_,{to:g},a.createElement(Kl,{$noPadding:!0,$noRelativePosition:!0},a.createElement(Wl._,{url:o,size:c}),!!i&&a.createElement(ql,{logoUrl:i.logoUrl,icon:i.icon,size:16}))),a.createElement(Zl,{column:!0},a.createElement(Vl.W,{to:g,tone:"inherit",weight:"medium",truncate:!0,className:"min-w-0"},n),a.createElement(Ul.w,null,a.createElement(Ul.d,{when:!m},a.createElement(Jl,{color:"textLight"},_t._E.LIABILITY_ACCOUNT_SUBTITLE)),a.createElement(Ul.d,{when:m},a.createElement(Jl,{color:"textLight"},r)))))},Kl=u.default.div.withConfig({displayName:"RecurringStream__ComboAvatar",componentId:"cm5cyv-0"})(["padding:",";position:",";"],(e=>e.$noPadding?0:vt.YK.xxsmall),(e=>e.$noRelativePosition?"static":"relative")),ql=(0,u.default)(Gl.v).withConfig({displayName:"RecurringStream__StyledAccountLogo",componentId:"cm5cyv-1"})(["outline:4px solid ",";position:absolute;right:0;bottom:0;"],vt.yW.white),$l=(0,u.default)(m.g).attrs({alignCenter:!0}).withConfig({displayName:"RecurringStream__Root",componentId:"cm5cyv-2"})(["gap:",";"],vt.YK.default),Zl=(0,u.default)(m.g).withConfig({displayName:"RecurringStream__RightSide",componentId:"cm5cyv-3"})(["min-width:0;overflow:hidden;"]),Jl=(0,u.default)(xt.v).withConfig({displayName:"RecurringStream__Subtitle",componentId:"cm5cyv-4"})(["overflow:hidden;text-wrap:nowrap;text-overflow:ellipsis;"]);var Xl=n(93976),Ql=n(41229);const er=["children"];let tr=function(e){return e.ASC="asc",e.DESC="desc",e}({});const nr=(0,u.default)(Xl.AM).withConfig({displayName:"RecurringList",componentId:"sc-3lco5h-0"})(["margin-bottom:",";background:",";transform:scale( 1 );"],vt.YK.default,vt.yW.white),ar=e=>{let t=e.children,n=(0,En.A)(e,er);return a.createElement(or,{"data-external-id":"recurring-list-header"},a.createElement(ir,n,t))},lr=e=>{let t=e.property,n=e.sortedBy;return(null===n||void 0===n?void 0:n.property)!==t?null:(null===n||void 0===n?void 0:n.direction)===tr.ASC?a.createElement(sl.ZQ,{"data-external-id":"direction-icon",name:"arrow-up"}):a.createElement(sl.ZQ,{"data-external-id":"direction-icon",name:"arrow-down"})},rr=(0,u.default)(Ql.$).attrs({shouldAnimateOnMount:!1}).withConfig({displayName:"RecurringList__RecurringListRows",componentId:"sc-3lco5h-1"})(["padding:0;"]),or=u.default.div.withConfig({displayName:"RecurringList__RecurringListHeaderWrapper",componentId:"sc-3lco5h-2"})(["background:",";position:sticky;top:0;border-bottom-left-radius:",";border-bottom-right-radius:",";overflow:hidden;z-index:1;"],vt.Ee.color.background.page,vt.r8.medium,vt.r8.medium),ir=(0,u.default)(m.g).attrs({alignCenter:!0}).withConfig({displayName:"RecurringList__InnerRecurringListHeader",componentId:"sc-3lco5h-3"})(["background:",";border-top-left-radius:",";border-top-right-radius:",";padding:"," ",";gap:",";transition:",";"],vt.yW.white,vt.r8.medium,vt.r8.medium,vt.YK.small,vt.YK.default,vt.YK.default,(e=>e.theme.transition.default)),sr=u.default.div.withConfig({displayName:"RecurringList__RecurringListCell",componentId:"sc-3lco5h-4"})(["flex-grow:1;width:",";text-align:",";overflow:hidden;text-overflow:ellipsis;text-wrap:nowrap;background:",";margin-right:",";"],(e=>{let t=e.$width;return"".concat(void 0===t?260:t,"px")}),(e=>{let t=e.$align;return void 0===t?"left":t}),vt.yW.white,(e=>{let t=e.$marginRight,n=e.theme;return t?n.spacing.xsmall:0})),cr=(0,u.default)(m.g).attrs({alignCenter:!0}).withConfig({displayName:"RecurringList__RecurringListRow",componentId:"sc-3lco5h-5"})(["padding:"," "," "," ",";gap:",";border-top:1px solid ",";transform:scale(1);"],vt.YK.small,vt.YK.default,vt.YK.small,vt.YK.xlarge,vt.YK.default,vt.Ee.color.divider.primary),dr=(0,u.default)(xt.v).withConfig({displayName:"RecurringList__RecurringHeaderTitle",componentId:"sc-3lco5h-6"})(["font-weight:",";font-size:",";"],vt.Wy.medium,vt.J.large),ur=(0,u.default)(xt.v).withConfig({displayName:"RecurringList__RecurringHeaderText",componentId:"sc-3lco5h-7"})(["font-size:",";color:",";font-weight:",";margin-right:","px;&:hover{cursor:pointer;color:",";}"],vt.J.small,vt.yW.textLight,vt.Wy.medium,(e=>{let t=e.$marginRight;return void 0===t?0:t}),vt.yW.blue),mr=(0,u.default)(xt.v).withConfig({displayName:"RecurringList__PaymentDateLabel",componentId:"sc-3lco5h-8"})(["color:",";font-weight:",";"],(e=>{let t=e.$late,n=e.theme;return t?n.variables.color.content.warning:n.variables.color.content.primary}),(e=>{let t=e.$late,n=e.theme;return t?n.fontWeight.medium:n.fontWeight.book})),pr=(0,u.default)(m.g).attrs({justifyBetween:!0,alignCenter:!0}).withConfig({displayName:"RecurringList__SummaryBox",componentId:"sc-3lco5h-9"})(["background:",";padding:"," 68px "," ",";border-radius:",";margin-bottom:",";"],vt.yW.gray4,vt.YK.small,vt.YK.small,vt.YK.xlarge,vt.r8.medium,vt.YK.default),gr=(0,u.default)(m.g).attrs({column:!0}).withConfig({displayName:"RecurringList__SummaryColumn",componentId:"sc-3lco5h-10"})(["text-align:",";"],(e=>{let t=e.$align;return void 0===t?"right":t})),hr=(0,u.default)(xt.v).withConfig({displayName:"RecurringList__SummaryLabel",componentId:"sc-3lco5h-11"})(["color:",";font-size:",";font-weight:",";"],vt.yW.textLight,vt.J.small,vt.Wy.medium),vr=(0,u.default)(xt.v).withConfig({displayName:"RecurringList__SummaryText",componentId:"sc-3lco5h-12"})(["color:",";font-size:",";font-weight:",";"],(e=>{let t=e.$isIncome,n=e.theme;return t?n.color.greenText:n.color.text}),vt.J.large,vt.Wy.medium),fr=(0,u.default)(m.g).attrs({justifyBetween:!0}).withConfig({displayName:"RecurringList__SummaryAmounts",componentId:"sc-3lco5h-13"})(["gap:56px;"]),Er=(0,u.default)(xt.v).withConfig({displayName:"RecurringList__DateText",componentId:"sc-3lco5h-14"})(["margin-right:",";"],vt.YK.xsmall);var yr=n(96019);const br=e=>{let t=e.merchant,n=e.id,l=e.name,r=e.logoUrl,o=e.frequency,i=e.date,s=e.accountName,c=e.accountLogoUrl,d=e.accountIcon,u=e.isAccountNotSelected,m=e.category,p=e.isCategoryNotSelected,g=e.amount,h=e.compacted;const v=(0,a.useMemo)((()=>{const e="string"===typeof m?{name:m,icon:"-"}:(0,U.A)((0,U.A)({},m),{},{name:"".concat(m.icon," ").concat(m.name)}
1);return a.createElement(P.D_,{content:e.name},a.createElement("div",null,p?a.createElement(Sr,null,e.icon):a.createElement(kr,null,e.icon)))}),[m,p]);return a.createElement(Cr,{"data-external-id":"recurring-transaction-message-block"},a.createElement(wr,{$width:274,style:{maxWidth:"274px",width:"274px"}},a.createElement(Hl,{id:n,name:null!==l&&void 0!==l?l:"",frequency:(0,yr.Bp)(o),logoUrl:r,isMerchant:!!t})),!h&&a.createElement(wr,{$width:180},u?a.createElement(Sr,null,s):a.createElement(Ar,null,a.createElement(Gl.v,{logoUrl:c,icon:d,size:20}),a.createElement(Ir,null,s))),!h&&a.createElement(wr,{$width:62,$align:"center"},v),a.createElement(wr,{$width:100,$align:"right"},a.createElement("div",{className:"flex flex-col"},a.createElement(Yl.t,{className:"font-medium",value:g,type:"expense",emphasis:g>0,showSign:g>0}),a.createElement(Nr,{color:"content.secondary",size:"small"},xr(i)))))},xr=e=>{try{const t=N.c9.fromISO(e),n=N.c9.now().startOf("day"),a=t.startOf("day");if(a.equals(n))return"Today";const l=Math.ceil(a.diff(n,"days").days);return l>0?"in ".concat(l," day").concat(l>1?"s":""):t.toFormat("MMM d")}catch(t){return e}},wr=(0,u.default)(sr).withConfig({displayName:"RecurringTransactionMessageBlock__AssistantRecurringListCell",componentId:"sc-1oiete4-0"})(["padding:"," 0;overflow:hidden;"],vt.YK.xsmall),Cr=(0,u.default)(cr).withConfig({displayName:"RecurringTransactionMessageBlock__AssistantRecurringListRow",componentId:"sc-1oiete4-1"})(["align-items:center;min-height:60px;padding-top:",";padding-bottom:",";padding-left:",";width:100%;"],vt.YK.small,vt.YK.small,vt.YK.default),Ar=(0,u.default)(m.g).withConfig({displayName:"RecurringTransactionMessageBlock__AccountSection",componentId:"sc-1oiete4-2"})(["flex-direction:row;align-items:center;gap:",";min-width:0;overflow:hidden;"],vt.YK.xsmall),Ir=(0,u.default)(xt.v).withConfig({displayName:"RecurringTransactionMessageBlock__AccountText",componentId:"sc-1oiete4-3"})(["overflow:hidden;text-overflow:ellipsis;white-space:nowrap;flex:1;min-width:0;"]),kr=(0,u.default)(xt.v).withConfig({displayName:"RecurringTransactionMessageBlock__CategoryText",componentId:"sc-1oiete4-4"})(["overflow:hidden;text-overflow:ellipsis;white-space:nowrap;"]),Sr=(0,u.default)(xt.v).withConfig({displayName:"RecurringTransactionMessageBlock__NotSelectedText",componentId:"sc-1oiete4-5"})(["color:",";"],vt.Ee.color.content.secondary),Nr=(0,u.default)(xt.v).withConfig({displayName:"RecurringTransactionMessageBlock__DateText",componentId:"sc-1oiete4-6"})([""]);var Tr=n(13484),_r=n(5406),Dr=n.n(_r),Rr=n(29158);const Mr=e=>{let t=e.className;return a.createElement(Gr,{"data-external-id":"recurring-list-loading",className:t},a.createElement(Fr,null,a.createElement(Pr,null),Dr().range(6).map((e=>a.createElement(Or,{key:e})))))},Lr=()=>a.createElement(a.Fragment,null,a.createElement("rect",{x:"20%",y:"24",rx:"5",ry:"5",width:"15%",height:"20"}),a.createElement("rect",{x:"40%",y:"24",rx:"5",ry:"5",width:"15%",height:"20"}),a.createElement("rect",{x:"60%",y:"24",rx:"5",ry:"5",width:"15%",height:"20"}),a.createElement("rect",{x:"88%",y:"24",rx:"5",ry:"5",width:"20%",height:"20"})),Or=()=>a.createElement(Br,{"data-external-id":"row-loading"},a.createElement(Rr.s,null,a.createElement("circle",{cx:"50",cy:"34",r:"20"}),a.createElement("rect",{x:"80",y:"24",rx:"5",ry:"5",width:"10%",height:"20"}),a.createElement(Lr,null))),Pr=()=>a.createElement(zr,{"data-external-id":"header-loading"},a.createElement(Rr.s,null,a.createElement("rect",{x:"3%",y:"20",rx:"5",ry:"5",width:"10%",height:"28"}),a.createElement(Lr,null))),Br=u.default.div.withConfig({displayName:"RecurringListLoading__CategoryRowRoot",componentId:"sc-12lwljy-0"})(["height:68px;border-bottom:1px solid ",";"],vt.Ee.color.divider.primary),zr=u.default.div.withConfig({displayName:"RecurringListLoading__CategoryGroupHeaderRoot",componentId:"sc-12lwljy-1"})(["height:68px;border-bottom:1px solid ",";"],vt.Ee.color.divider.primary),Fr=(0,u.default)(Xl.AM).withConfig({displayName:"RecurringListLoading__CategoryGroupRoot",componentId:"sc-12lwljy-2"})([":not(:last-child){margin-bottom:",";}"],(e=>e.theme.spacing.gutter)),Gr=u.default.div.withConfig({displayName:"RecurringListLoading__Root",componentId:"sc-12lwljy-3"})(["margin-bottom:",";"],(e=>e.theme.spacing.gutter));var Yr=n(68734),Ur=n(61792);const Vr=(0,u.default)(m.g).withConfig({displayName:"RecurringTransactionsBlockRenderer__TransactionsList",componentId:"sc-1n38s3l-0"})(["flex:1;gap:0;"]),Wr=(0,u.default)(nr).withConfig({displayName:"RecurringTransactionsBlockRenderer__AssistantRecurringList",componentId:"sc-1n38s3l-1"})(["width:100%;margin-bottom:0;box-shadow:none;border:1px solid ",";overflow:hidden;"],vt.Ee.color.border.primary),jr=(0,u.default)(Mr).withConfig({displayName:"RecurringTransactionsBlockRenderer__AssistantRecurringListLoading",componentId:"sc-1n38s3l-2"})(["width:100%;"]),Hr=(0,u.default)(ur).withConfig({displayName:"RecurringTransactionsBlockRenderer__AssistantRecurringHeaderText",componentId:"sc-1n38s3l-3"})(["&:hover{color:",";cursor:default;}"],vt.Ee.color.content.secondary),Kr=ra(Bn)((e=>{let t=e.data,n=t.ids,l=t.rows,r=e.incomplete,i=e.renderContext;const s=(0,a.useState)(!1),c=(0,o.A)(s,2),u=c[0],m=c[1],p=(0,d.d4)(A._S)&&i===la.Assistant||i===la.Recap,g=(0,et.I)(Yr.dB,{variables:{filters:(0,Ur.fj)({ids:n}),includeLiabilities:!0,includePending:!0},skip:0===n.length||r}),h=g.data,v=g.isLoadingInitialData||r,f=(0,a.useMemo)((()=>l.map((e=>{const t=null===h||void 0===h?void 0:h.recurringTransactionStream
1s.find((t=>t.stream.id===e.ID));return t?{stream:t.stream,account:t.account,category:t.category,date:e.Date,amount:(0,rl.vu)(e.Amount)}:null})).filter(Tr.A)),[h,l]),E=u?f:f.slice(0,5),y=f.length>5;return v?a.createElement("div",{className:"flex w-full"},a.createElement(jr,null)):a.createElement(Wr,null,a.createElement(ar,null,a.createElement(sr,{$width:274,style:{maxWidth:274}},a.createElement(Hr,null,"Recurring Transaction")),p&&a.createElement(sr,{$width:180},a.createElement(Hr,null,"Payment Account")),p&&a.createElement(sr,{$width:62,$align:"center"},a.createElement(Hr,null,"Category")),a.createElement(sr,{$width:100,$align:"right"},a.createElement(Hr,null,"Amount"))),a.createElement(rr,{open:!0},a.createElement(Vr,{column:!0},E.map(((e,t)=>{var n,l,r,o,i;const s=e.stream,c=e.account,d=e.category,u=e.date,m=e.amount,g=null!==s&&void 0!==s?s:{},h=g.merchant,v=g.creditReportLiabilityAccount,f=!!v,E=f&&!c,y=f&&!d;return a.createElement(br,{key:"".concat(null===s||void 0===s?void 0:s.id,"-").concat(t),id:null!==(n=null!==(l=null===h||void 0===h?void 0:h.id)&&void 0!==l?l:null===v||void 0===v||null===(r=v.account)||void 0===r?void 0:r.id)&&void 0!==n?n:"stream-".concat(t),name:null===s||void 0===s?void 0:s.name,logoUrl:null===s||void 0===s?void 0:s.logoUrl,merchant:null===h||void 0===h?void 0:h.name,frequency:null===s||void 0===s?void 0:s.frequency,date:u,accountName:c?c.displayName:f?"Not selected":"Unknown account",accountLogoUrl:null!==(o=null===c||void 0===c?void 0:c.logoUrl)&&void 0!==o?o:void 0,accountIcon:null!==(i=null===c||void 0===c?void 0:c.icon)&&void 0!==i?i:void 0,isAccountNotSelected:E,category:d||(f?"Not selected":"Unknown category"),isCategoryNotSelected:y,amount:null!==m&&void 0!==m?m:0,compacted:!p})}))),y&&a.createElement("div",{className:"flex justify-center border-t border-divider-primary py-sm"},a.createElement(bn.v,{onClick:()=>m(!u)},u?"View less":"View all (".concat(f.length,")")))))})),qr=ra(Bn)((e=>{let t=e.data.rows;const n=(0,d.d4)(A._S);return a.createElement(Wr,null,a.createElement(ar,null,a.createElement(sr,{$width:180},a.createElement(ur,null,"Recurring Transaction")),n&&a.createElement(sr,{$width:180},a.createElement(ur,null,"Payment Account")),n&&a.createElement(sr,{$width:150},a.createElement(ur,null,"Category")),a.createElement(sr,{$width:100,$align:"right"},a.createElement(ur,null,"Amount"))),a.createElement(rr,{open:!0},t.map(((e,t)=>{let l=e.merchant,r=e.frequency,o=e.date,i=e.account,s=e.category,c=e.amount;return a.createElement(br,{key:"".concat(l,"-").concat(t),id:String(t),name:l,logoUrl:null,merchant:l,frequency:r,date:o,accountName:i,accountLogoUrl:void 0,accountIcon:void 0,category:s,amount:(0,rl.vu)(c),compacted:!n})}))))})),$r=e=>{e.id;let t=e.name,n=e.color,l=e.transactionCount;const r=(0,u.useTheme)();return t?a.createElement(Qr,{"data-external-id":"demo-tag-message-block"},a.createElement(eo,null,a.createElement(to,null,a.createElement(Ta.c,{color:n||r.color.grayLight}),a.createElement(no,null,t)),void 0!==l&&l>0&&a.createElement(Jr,null,l," ",1===l?"transaction":"transactions"))):null},Zr=(0,u.default)(m.g).withConfig({displayName:"DemoTagsBlockRenderer__Root",componentId:"sc-61uz54-0"})(["flex:1;gap:",";"],(e=>e.theme.spacing.xsmall)),Jr=(0,u.default)(xt.v).attrs({size:"small",weight:"medium"}).withConfig({displayName:"DemoTagsBlockRenderer__TransactionCount",componentId:"sc-61uz54-1"})(["color:",";padding:",";margin:-",";border-radius:",";&:hover{background-color:",";cursor:pointer;}"],(e=>e.theme.variables.color.content.primary),(e=>e.theme.spacing.xsmall),(e=>e.theme.spacing.xsmall),(e=>e.theme.radius.small),(e=>e.theme.variables.color.background.secondary)),Xr=ra(Gn)((e=>{let t=e.data.rows;return a.createElement(Zr,{column:!0},t.map((e=>{let t=e.ID,n=e.Name,l=e.Color,r=e.TransactionCount;return a.createElement($r,{key:t,id:t,name:n,color:l,transactionCount:r?parseInt(r,10):void 0})})))})),Qr=u.default.div.withConfig({displayName:"DemoTagsBlockRenderer__TagRoot",componentId:"sc-61uz54-2"})(["padding:",";border:1px solid ",";border-radius:",";background-color:",";transition:all 0.2s ease;width:fit-content;max-width:450px;min-width:300px;"],(e=>e.theme.spacing.medium),(e=>e.theme.variables.color.border.primary),(e=>e.theme.radius.medium),(e=>e.theme.color.white)),eo=(0,u.default)(m.g).attrs({alignCenter:!0,justifyBetween:!0}).withConfig({displayName:"DemoTagsBlockRenderer__TagRow",componentId:"sc-61uz54-3"})(["width:100%;"]),to=(0,u.default)(m.g).attrs({alignCenter:!0}).withConfig({displayName:"DemoTagsBlockRenderer__TagInfo",componentId:"sc-61uz54-4"})(["gap:",";"],(e=>e.theme.spacing.small)),no=(0,u.default)(xt.v).attrs({size:"base",weight:"medium"}).withConfig({displayName:"DemoTagsBlockRenderer__TagName",componentId:"sc-61uz54-5"})(["color:",";"],(e=>e.theme.variables.color.content.primary));var ao=n(88752);const lo=e=>{let t=e.name,n=e.categoryIcon,l=e.categoryName,r=e.amount,o=e.tags,i=void 0===o?[]:o,s=e.onClickChevron,c=e.loading,d=e.merchantLogoUrl,u=e.compacted;return a.createElement(ro,{"data-external-id":"transaction-message-block"},a.createElement(Ul.w,null,a.createElement(Ul.d,{when:!!c},a.createElement(p.i,{size:"sm"})),a.createElement(Ul.d,{default:!0},a.createElement(uo,{$compacted:u},a.createElement(Wl._,{url:d,size:32}),a.createElement(so,null,t)),a.createElement("div",{className:"ml-lg flex grow items-center justify-start gap-sm"},a.createElement(xt.v,null,n),u?null:a.createElement(co,null,l)),i.length>0&&a.createElement(io,null,a.createElement(ao.T,{tags:i})),a.createElement(Yl.t,{className:"text-right font-medium",value:r,type:"expense",emphasis:r>0,showSign:r>0}),a.createElement(oo,{onClick:s}))))},ro=(0,u.default)(m.g).attrs({alignCenter:!0}).withConfig({displayName:"TransactionMessageBlock__Root",componentId:"sc-1r0jr6e-0"})(["background:",";height:58px;width:100%;padding:"," ",";&:not(:first-child){border-top:1px solid ",";}"],vt.Ee.color.background.primary,vt.YK.small,vt.YK.xsmall,vt.Ee.color.border.primary),oo=(0,u.default)(B.L).attrs({icon:"chevron-right"}).withConfig({displayName:"TransactionMessageBlock__ChevronButton",componentId:"sc-1r0jr6e-1"})(["margin:-"," 0;margin-left:",";"],vt.YK.xsmall,vt.YK.xsmall),io=u.default.div.withConfig({displayName:"TransactionMessageBlock__IconsSection",componentId:"sc-1r0jr6e-2"})(["display:flex;align-items:center;width:24px;justify-content:center;margin-left:",";
1"],vt.YK.xsmall),so=(0,u.default)(xt.v).attrs({clampLines:1}).withConfig({displayName:"TransactionMessageBlock__TextGrow",componentId:"sc-1r0jr6e-3"})(["flex:1;:not(:first-child){margin-left:",";}",""],vt.YK.xsmall,(e=>e.$hiddenSmall&&(0,u.css)(["@media (max-width:","px){display:none;}"],vt.nm.lg))),co=(0,u.default)(xt.v).attrs({clampLines:1}).withConfig({displayName:"TransactionMessageBlock__CategoryName",componentId:"sc-1r0jr6e-4"})(["flex:1;@media (max-width:","px){display:none;}"],vt.nm.md),uo=(0,u.default)(m.g).attrs({alignCenter:!0,gap:"small"}).withConfig({displayName:"TransactionMessageBlock__Merchant",componentId:"sc-1r0jr6e-5"})(["width:45%;",""],(e=>e.$compacted&&(0,u.css)(["width:50%;"])));var mo=n(16049),po=n(217),go=n(62311);const ho=(0,u.default)(Cn).withConfig({displayName:"TransactionsBlockRenderer__TransactionsBlockMessageCard",componentId:"c0cy92-0"})(["flex:1;flex-direction:column;width:100%;padding:0;overflow:hidden;"]),vo=Ee.Gp$,fo=ra(Pn)((e=>{let t=e.data.ids,n=e.renderContext;const l=(0,a.useState)(!1),r=(0,o.A)(l,2),i=r[0],s=r[1],c=(0,et.I)(vo,{variables:{ids:t}}),u=c.data,m=c.isLoadingInitialData,p=!(0,d.d4)(A._S)&&n===la.Assistant,g=(null!==u&&void 0!==u?u:{}).allTransactions,h=(null!==g&&void 0!==g?g:{}).results,v=void 0===h?[]:h,f=(0,a.useMemo)((()=>(0,Xn.A)((0,mo.A)("id"),v)),[v]),E=(0,a.useState)(),y=(0,o.A)(E,2),b=y[0],x=y[1],w=i?t:t.slice(0,5),C=t.length>5;return a.createElement(ho,null,w.map((e=>{const t=f[e],n=null!==t&&void 0!==t?t:{},l=n.merchant,r=n.category,o=n.amount,i=n.tags;return t||m?a.createElement(lo,{key:e,id:e,name:null===l||void 0===l?void 0:l.name,merchantLogoUrl:null===l||void 0===l?void 0:l.logoUrl,categoryIcon:(null===r||void 0===r?void 0:r.icon)||"",categoryName:(null===r||void 0===r?void 0:r.name)||"",amount:o,tags:i,loading:!t,onClickChevron:()=>x(e),compacted:p}):null})),C&&a.createElement("div",{className:"flex justify-center border-t border-divider-primary py-sm"},a.createElement(bn.v,{onClick:()=>s(!i)},i?"View less":"View all (".concat(t.length,")"))),!!b&&a.createElement(po.K,null,a.createElement(go.TT,{id:b,previousTransactionId:null,nextTransactionId:null,setId:x,onClose:()=>x(void 0)})))})),Eo=ra(Pn)((e=>{let t=e.data.rows;const n=(0,d.d4)(A._S);return a.createElement(ho,null,t.map((e=>{let t=e.ID,l=e.Merchant,r=e.Category,o=e.Amount;const i=r.split(" "),s=(null===i||void 0===i?void 0:i.length)>1?i.slice(1).join(" "):i[0],c=(null===i||void 0===i?void 0:i.length)>1?i[0]:"";return a.createElement(lo,{key:t,id:t,name:l,categoryName:s,categoryIcon:c,amount:(0,rl.vu)(o),compacted:!n})})))}));var yo=n(75956);const bo=e=>{let t=e.goal,n=e.loading;const l=t?I.JZ.goals.savings.detail({id:t.id}):void 0;return a.createElement(xo,{"data-external-id":"savings-goal-message-block",linkTo:l},n||!t?a.createElement(Co,null,a.createElement(p.i,{size:"sm"})):a.createElement(wo,null,a.createElement(yo.p,{goal:t,variant:"modal"})))},xo=(0,u.default)(Cn).withConfig({displayName:"SavingsGoalMessageBlock__Root",componentId:"sc-1ezmpbg-0"})(["width:100%;padding:0;display:flex;flex-direction:column;"]),wo=u.default.div.withConfig({displayName:"SavingsGoalMessageBlock__CardWrapper",componentId:"sc-1ezmpbg-1"})(["width:100%;flex:1;"]),Co=(0,u.default)(m.g).attrs({center:!0}).withConfig({displayName:"SavingsGoalMessageBlock__LoadingContainer",componentId:"sc-1ezmpbg-2"})(["height:129px;flex:1;"]);var Ao=n(78877),Io=n(47056);const ko=e=>{var t;let n=e.ids;const l=(0,et.I)(_o,{variables:{ids:n},skip:0===n.length}),r=a.useMemo((()=>{var e,t;const n=null!==(e=null===(t=l.data)||void 0===t?void 0:t.goalsV2)&&void 0!==e?e:[];return(0,Xn.A)((0,mo.A)("id"),n)}),[null===(t=l.data)||void 0===t?void 0:t.goalsV2]);return a.createElement(a.Fragment,null,n.map((e=>{const t=r[e];return t||l.isLoadingInitialData?a.createElement(Sl,{key:e,goal:t,loading:!t}):null})))},So=e=>{var t;let n=e.ids;const l=(0,et.I)(Io.iO,{skip:0===n.length}),r=a.useMemo((()=>{var e,t;const a=null!==(e=null===(t=l.data)||void 0===t?void 0:t.savingsGoals)&&void 0!==e?e:[],r=(0,Xn.A)((0,mo.A)("id"),a),o={};return n.forEach((e=>{r[e]&&(o[e]=r[e])})),o}),[null===(t=l.data)||void 0===t?void 0:t.savingsGoals,n]);return a.createElement(a.Fragment,null,n.map((e=>{const t=r[e];return t||l.isLoadingInitialData?a.createElement(bo,{key:e,goal:t,loading:!t}):null})))},No=(0,u.default)(m.g).withConfig({displayName:"GoalsBlockRenderer__Root",componentId:"wfisef-0"})(["flex:1;gap:",";"],(e=>e.theme.spacing.xsmall)),To=ra(zn)((e=>{let t=e.data.ids;const n=(0,Ao.Q)(),l=n.hasMigrated;return n.loading?null:a.createElement(No,{column:!0},l?a.createElement(So,{ids:t}):a.createElement(ko,{ids:t}))})),_o=Ee.lTl;var Do=n(81882);const Ro=["label"],Mo=(e,t)=>n=>{const l=n.active,r=(0,_a.WS)(n),o=null!==r&&void 0!==r?r:{},i=o.label,s=(0,En.A)(o,Ro),c=t?t(i,!0):i;return a.createElement(Sa.II,{active:l,header:c},e.map(((e,t)=>{let n=e.dataKey,l=e.lineColor,r=e.label,o=e.valueFormatter;return a.createElement(Na.B,{key:t,dotFillColor:l,label:r,value:o?o(s[n]):s[n]})})))},Lo=(0,u.default)(m.g).attrs({center:!0,column:!0}).withConfig({displayName:"LineChartBlockRenderer__LoadingContainer",componentId:"sc-15rw7d6-0"}
1)(["height:","px;width:100%;"],Ga),Oo=ra(jn)((e=>{var t;let n=e.data,l=n.chartData,r=n.columns,o=e.incomplete,i=e.renderContext;const s=(0,u.useTheme)(),c=(0,d.d4)(A._S),m=c&&i===la.Assistant&&r.length>1,g=(0,ll.C)().categories,h=(0,a.useMemo)((()=>r.map(((e,t)=>{let n=e.label,a=e.valueType;return{dataKey:"".concat(n,"-").concat(t),lineColor:s.color[Ya[t%Ya.length]],label:n,legendName:m?n:void 0,valueFormatter:e=>"currency"===a?(0,rl.vv)(Math.abs(null!==e&&void 0!==e?e:0)):"".concat(e)}}))),[r,s,m]),v=(0,a.useMemo)((()=>l.map((e=>{let t=e.label,n=e.values;return(0,U.A)({label:t},h.reduce(((e,t,a)=>{var l;let r=t.dataKey;return(0,U.A)((0,U.A)({},e),{},{[r]:Math.abs(null!==(l=n[a])&&void 0!==l?l:0)})}),{}))}))),[l,h]),f=(0,a.useMemo)((()=>za(l,g)),[g,l]),E=(0,a.useCallback)(((e,t)=>Fa(e,f,g,!t)),[g,f]),y=(0,a.useMemo)((()=>{if(!(i===la.Assistant&&!c)||v.length<=3)return;const e=v.length-1,t=Math.floor(e/2);return[v[0].label,v[t].label,v[e].label]}),[i,c,v]);return a.createElement(In,null,o?a.createElement(Lo,null,a.createElement(p.i,null)):a.createElement(Do.rT,{height:Ga,data:v,yDataKeys:h.map((e=>e.dataKey)),lineOptions:h,xDataKey:"label",tooltipComponent:Mo(h,E),margin:{left:-14},formatYAxis:"currency"===(null===(t=r[0])||void 0===t?void 0:t.valueType)?rl.fw:e=>"".concat(e),formatXAxis:e=>E(e,!1),showAllTicks:f,isAnimationActive:!1,xAxisProps:(0,U.A)({},y&&{ticks:y}),legendProps:{iconSize:14},yAxisProps:{tick:{fontSize:Do.kM,fontWeight:Do.vQ,fill:s.variables.color.chart.label,textAnchor:"start"},tickMargin:34+parseInt(s.spacing.xxsmall,10)}}))})),Po=()=>a.createElement(Cn,{"data-external-id":"message-error"},a.createElement(xt.v,{color:"red"},a.createElement(sl.ZQ,{name:"alert-triangle"})," Error loading message"));var Bo=n(61047);const zo=ra(Hn)((e=>{let t=e.data,n=t.question,l=t.choices,r=e.nextGroup;const i=(0,d.d4)(A.MJ),s=(0,Bo.b)(),c=(0,o.A)(s,1)[0],u=!!r;return a.createElement(Ol,{question:n,choices:u?[]:l,onClickChoice:e=>{if(!i)throw new Error("Thread ID is not set");c({variables:{input:{fromRecommendedPrompt:void 0,threadId:i,content:e,triggerSource:Ee.y3I.ASSISTANT}}})}})}));var Fo=n(85151),Go=n(75893),Yo=n(62380),Uo=n(98251),Vo=n(21327),Wo=n(6515);const jo=(0,u.default)(Cn).withConfig({displayName:"PieChartBlockRenderer__ChartCard",componentId:"sc-1jtawsh-0"})(["width:100%;padding:",";"],vt.YK.default),Ho=(0,u.default)(m.g).attrs({center:!0,column:!0}).withConfig({displayName:"PieChartBlockRenderer__LoadingContainer",componentId:"sc-1jtawsh-1"})(["height:","px;width:100%;"],Ga),Ko=(0,u.default)(Uo.el).withConfig({displayName:"PieChartBlockRenderer__AssistantPieChartWithLegend",componentId:"sc-1jtawsh-2"})(["width:100%;padding:0;[data-sc-tw~='PieChartWithLegend__PieContainer']{align-self:flex-start;position:",";top:",";width:50%;max-width:480px;max-height:480px;}"," ","{[data-sc-tw~='PieChartWithLegend__PieContainer']{height:200px;width:200px;position:relative;top:auto;}}"],(e=>e.$allowSticky?"sticky":"relative"),(e=>{let t=e.$allowSticky,n=e.theme;return t?n.spacing.gutter:"auto"}),(e=>e.$compacted&&(0,u.css)(["[data-sc-tw~='PieChartWithLegend__PieContainer']{position:relative;width:100%;max-width:100%;max-height:none;height:auto;}"])),Wo.J.sm),qo=(0,u.default)(m.g).attrs({center:!0}).withConfig({displayName:"PieChartBlockRenderer__Footer",componentId:"sc-1jtawsh-3"})(["color:",";cursor:pointer;font-size:",";font-weight:",";margin-top:",";padding:",";transition:",";user-select:none;position:",";&:hover,&:active,&:focus{color:",";}"],vt.yW.blue,vt.J.small,vt.Wy.medium,vt.YK.default,vt.YK.default,vt.kY.fast,(e=>e.$allowSticky?"sticky":"relative"),vt.yW.blueDark),$o=(0,u.default)(Yo.r).attrs({size:14}).withConfig({displayName:"PieChartBlockRenderer__ChevronIcon",componentId:"sc-1jtawsh-4"})(["transform:translateY(1px);"]),Zo=ra(Vn)((e=>{var t;let n=e.data,l=n.chartData,r=n.columns,i=e.incomplete,s=e.renderContext;const c=(0,u.useTheme)(),m=(0,ll.C)().categories,g=!(0,d.d4)(A._S)&&s===la.Assistant,h=(0,a.useState)(!1),v=(0,o.A)(h,2),f=v[0],E=v[1],y=(0,a.useMemo)((()=>(0,Vo.uK)(c.color)),[c.color]),b="currency"===(null===(t=r[0])||void 0===t?void 0:t.valueType),x=(0,a.useMemo)((()=>za(l,m)),[m,l]),w=(0,a.useCallback)((e=>Fa(e,x,m)),[m,x]),C=(0,a.useMemo)((()=>{const e=(0,Fo.A)([(0,Go.A)((e=>{var t;let n=e.values;return Math.abs(null!==(t=n[0])&&void 0!==t?t:0)}))],l),t=(f?e:e.slice(0,10)).map(((e,t)=>{var n;let a=e.label,l=e.values;const r=Math.abs(null!==(n=l[0])&&void 0!==n?n:0);return{id:"".concat(a,"-").concat(t),label:w(a),value:r,color:y[t%y.length],formattedValue:b?(0,rl.vv)(r):(0,De.RZ)(r)}}));if(!f&&e.length>10){const n=e.slice(10).reduce(((e,t)=>{var n;let a=t.values;return e+Math.abs(null!==(n=a[0])&&void 0!==n?n:0)}),0),a={id:"everything_else",label:"Everything else",value:n,color:y[t.length%y.length],formattedValue:b?(0,rl.vv)(n):(0,De.RZ)(n),onClick:()=>E(!0)};return[...t,a]}return t}),[l,y,w,b,f]),I=(0,a.useMemo)((()=>C.reduce(((e,t)=>e+t.value),0)),[C]),k=(0,a.useMemo)((()=>b?(0,rl.vv)(I):"".concat((0,De.RZ)(I))),[I,b]),S=(0,a.useCallback)((()=>l.length<=10?null:a.createElement(qo,{onClick:()=>E(!f),$allowSticky:!!f},a.createElement("span",null,f?"Hide legend":"Expand legend"),a.createElement($o,{name:f?"chevron-up":"chevron-down"}
1))),[l.length,f]);return a.createElement(jo,null,i?a.createElement(Ho,null,a.createElement(p.i,null)):a.createElement(Ko,{$allowSticky:f,$compacted:g,data:C,pieChartTitle:k,pieChartSubtitle:"Total",pieChartSize:"100%",renderLegendFooter:S}))}));var Jo=n(51277),Xo=n(19340),Qo=n(68085),ei=n(14220);const ti=e=>{let t=e.entityType,n=e.entityId,l=e.fallbackText;switch(t){case"category":return a.createElement(ni,{"data-external-id":"entity-renderer",entityId:n,fallbackText:l});case"merchant":return a.createElement(ai,{"data-external-id":"entity-renderer",entityId:n,fallbackText:l});default:return a.createElement("span",{"data-external-id":"entity-renderer"},l)}},ni=e=>{let t=e.entityId,n=e.fallbackText;const l=(0,Xo.IT)(Qo.oS,{variables:{id:t}}),r=l.data,o=l.loading,i=l.error;if(o||i||null===r||void 0===r||!r.category)return a.createElement("span",{"data-external-id":"category-entity-renderer"},n);const s=r.category,c=s.name,d=s.icon;return a.createElement(li,{"data-external-id":"category-entity-renderer"},d&&a.createElement(fe.xa2,null,d),a.createElement("span",null,c))},ai=e=>{let t=e.entityId,n=e.fallbackText;const l=(0,Xo.IT)(ei.W5,{variables:{id:t}}),r=l.data,o=l.loading,i=l.error;if(o||i||null===r||void 0===r||!r.merchant)return a.createElement("span",{"data-external-id":"merchant-entity-renderer"},n);const s=r.merchant,c=s.name,d=s.logoUrl;return a.createElement(li,{"data-external-id":"merchant-entity-renderer"},d&&a.createElement(Wl._,{url:d,size:24}),a.createElement("span",null,c))},li=u.default.span.withConfig({displayName:"EntityRenderer__EntityContainer",componentId:"sc-14dl9xk-0"})(["display:flex;align-items:center;gap:",";"],(e=>e.theme.spacing.xxsmall));var ri=n(83668);const oi=ra(Jn)((e=>{let t=e.data,n=e.incomplete;const l=t.headers,r=t.rows,o=a.useRef(null),i=r.map(((e,t)=>{const n={id:"row-".concat(t)};return l.forEach(((t,a)=>{n[t]=e[a]||{type:"text",value:""}})),n})),s=a.useMemo((()=>l.map((e=>({id:e,header:e,accessorFn:t=>{const n=t[e];return"string"===typeof n?n:n.value},cell:t=>{const n=t.row.original[e];return"string"===typeof n?a.createElement("span",null,n):ii(n)}})))),[l]);if(n)return a.createElement(si,{"data-external-id":"table-block-renderer"},a.createElement(di,null,a.createElement(p.i,{label:"Loading table data..."})));if(0===l.length&&0===r.length)return a.createElement(si,{"data-external-id":"table-block-renderer"},a.createElement(ci,null,"No data available"));const c={scrollTo:(e,t)=>{var n;null===(n=o.current)||void 0===n||n.scrollTo({top:0,behavior:(null===t||void 0===t?void 0:t.behavior)||"smooth"})},scrollRef:o};return a.createElement(si,{"data-external-id":"table-block-renderer",ref:o},a.createElement(ri.z.Provider,{value:c},a.createElement(Jo.k1,{className:"mb-0",columns:s,data:i,showFooter:!1})))})),ii=e=>"entity"===e.type?a.createElement(ti,{entityType:e.entityType,entityId:e.entityId,fallbackText:(0,rl.Kv)(e.value)}):a.createElement("span",null,(0,rl.Kv)(e.value)),si=u.default.div.withConfig({displayName:"TableBlockRenderer__TableContainer",componentId:"cnlpbu-0"})(["max-height:60vh;overflow-y:auto;border:1px solid ",";border-radius:",";"],vt.Ee.color.border.primary,vt.r8.default),ci=u.default.div.withConfig({displayName:"TableBlockRenderer__EmptyState",componentId:"cnlpbu-1"})(["padding:",";text-align:center;color:",";font-style:italic;border:1px solid ",";border-radius:",";background:",";"],vt.YK.large,vt.Ee.color.content.secondary,vt.Ee.color.border.primary,vt.r8.default,vt.Ee.color.background.primary),di=u.default.div.withConfig({displayName:"TableBlockRenderer__LoadingContainer",componentId:"cnlpbu-2"})(["padding:",";display:flex;justify-content:center;align-items:center;border:1px solid ",";border-radius:",";background:",";"],vt.YK.large,vt.Ee.color.border.primary,vt.r8.default,vt.Ee.color.background.primary),ui=e=>{e.id;let t=e.name,n=e.color,l=e.transactionCount;const r=(0,d.d4)(A.MJ),i=(0,Bo.b)(),s=(0,o.A)(i,1)[0],c=(0,u.useTheme)();return t?a.createElement(mi,{"data-external-id":"tag-message-block"},a.createElement(pi,null,a.createElement(gi,null,a.createElement(Ta.c,{color:n||c.color.grayLight}),a.createElement(hi,null,t)),void 0!==l&&l>0&&a.createElement(vi,{onClick:()=>
1{if(!r)throw new Error("Thread ID is not set");l&&l>0&&t&&s({variables:{input:{fromRecommendedPrompt:void 0,threadId:r,content:"Show me transactions tagged with ".concat(t),triggerSource:Ee.y3I.ASSISTANT}}})}},(0,De.td)("transaction",l,{inclusive:!0})))):null},mi=u.default.div.withConfig({displayName:"TagMessageBlock__Root",componentId:"ckez73-0"})(["padding:",";border:1px solid ",";border-radius:",";background-color:",";transition:all 0.2s ease;width:fit-content;max-width:450px;min-width:300px;"],(e=>e.theme.spacing.medium),(e=>e.theme.variables.color.border.primary),(e=>e.theme.radius.medium),(e=>e.theme.color.white)),pi=(0,u.default)(m.g).attrs({alignCenter:!0,justifyBetween:!0}).withConfig({displayName:"TagMessageBlock__TagRow",componentId:"ckez73-1"})(["width:100%;"]),gi=(0,u.default)(m.g).attrs({alignCenter:!0}).withConfig({displayName:"TagMessageBlock__TagInfo",componentId:"ckez73-2"})(["gap:",";"],(e=>e.theme.spacing.small)),hi=(0,u.default)(xt.v).attrs({size:"medium",weight:"medium"}).withConfig({displayName:"TagMessageBlock__TagName",componentId:"ckez73-3"})(["color:",";"],(e=>e.theme.variables.color.content.primary)),vi=(0,u.default)(xt.v).attrs({size:"small",weight:"medium"}).withConfig({displayName:"TagMessageBlock__TransactionCount",componentId:"ckez73-4"})(["color:",";cursor:pointer;&:hover{color:",";text-decoration:underline;}"],(e=>e.theme.variables.color.content.secondary),(e=>e.theme.variables.color.content.primary)),fi=(0,u.default)(m.g).withConfig({displayName:"TagsBlockRenderer__Root",componentId:"sc-10vx0v-0"})(["flex:1;gap:",";"],(e=>e.theme.spacing.xsmall)),Ei=ra(Gn)((e=>{let t=e.data.rows;return a.createElement(fi,{column:!0},t.map((e=>{let t=e.ID,n=e.Name,l=e.Color,r=e["Transaction Count"];return a.createElement(ui,{key:t,id:t,name:n,color:l,transactionCount:r?parseInt(r,10):void 0})})))})),yi=["children"],bi=e=>{let t=e.children,n=(0,En.A)(e,yi);const l=(0,d.d4)(ft._S),r=(0,a.useMemo)((()=>l?"xxxxlarge":"xlarge"),[l]);return a.createElement(m.g,Object.assign({"data-external-id":"message-bubble",paddingVertical:"small",paddingHorizontal:"default",marginLeft:r,backgroundColor:"background.primary",borderRadius:"large"},n),t)};var xi=n(53786);const wi=e=>{let t=e.children,n=e.colors,l=e.animationDuration,r=e.direction,o=e.lineHeight;return a.createElement(Ci,{"data-external-id":"shimmer-text",$colors:n,$animationDuration:l,$direction:r,$lineHeight:o},t)},Ci=u.default.div.withConfig({displayName:"ShimmerText__StyledShimmerText",componentId:"igj33i-0"})([""," background-image:linear-gradient( to right,"," );background-size:200% 100%;background-position-x:0%;background-clip:text;-webkit-text-fill-color:transparent;animation:gradient-move "," linear infinite ",";@keyframes gradient-move{0%{background-position:0 50%;}100%{background-position:100% 50%;}}"],(e=>{let t=e.$lineHeight;return t&&"line-height: ".concat(t,";")}),(e=>{let t=e.theme,n=e.$colors;const a=null!==n&&void 0!==n?n:["content.primary","content.brand"],l=(0,o.A)(a,1)[0];return[...a,...a,l].map((e=>(0,xi.HE)(e,t))).join(", ")}),(e=>{let t=e.$animationDuration;return void 0===t?"2s":t}),(e=>{let t=e.$direction;return"ltr"===(void 0===t?"ltr":t)?"reverse":"normal"}));var Ai=n(79087);const Ii=["source","isStreaming","forceComplete"],ki=(0,a.createContext)({}),Si=e=>{let t=e.source,n=e.isStreaming,l=e.forceComplete,r=(0,En.A)(e,Ii);const i=(0,a.useState)(n?0:t.length),s=(0,o.A)(i,2),c=s[0],d=s[1],u=(0,a.useRef)(""),m=(0,a.useRef)(null),p=(0,a.useRef)(n?0:t.length),g=(0,a.useRef)(n),h=(0,a.useRef)(t.length),v=(0,a.useRef)(l),f=(0,a.useContext)(ki).onAnimationComplete;(0,a.useEffect)((()=>{p.current=c}),[c]),(0,a.useEffect)((()=>{h.current=t.length}),[t.length]),(0,a.useEffect)((()=>{v.current=l}),[l]),(0,a.useEffect)((()=>{n&&(g.current=!0)}),[n]),(0,a.useEffect)((()=>{var e;l&&(null===(e=m.current)||void 0===e||e.stop(),d(t.length))}),[l,t.length]),(0,a.useEffect)((()=>{var e;const a=u.current;if(l)return void(u.current=t);if(t===a)return;let r;null===(e=m.current)||void 0===e||e.stop();if(!t.startsWith(a)||0===a.length){if(g.current=n,!g.current)return d(t.length),void(u.current=t);r=0,d(0)}else r=p.current;if(u.current=t,t.length>r){const e=.015*(t.length-r);m.current=(0,Ai.i)(r,t.length,{duration:e,ease:"easeOut",onUpdate(e){d(Math.floor(e))}})}else d(t.length);return()=>{var e;null===(e=m.current)||void 0===e||e.stop()}}),[t]),(0,a.useEffect)((()=>{const e=()=>{var e;document.hidden||v.current||(null===(e=m.current)||void 0===e||e.stop(),d(h.current))};return document.addEventListener("visibilitychange",e),()=>{document.removeEventListener("visibilitychange",e)}}),[]),(0,a.useEffect)((()=>{n||c!==t.length||null===f||void 0===f||f()}),[n,c,t.length,f]);const E=t.slice(0,c);return a.createElement(Ll.o,Object.assign({"data-external-id":"streaming-markdown"},r),E)},Ni=(0,q.cn)("wrap-anywhere","[&_h1]:mt-0 [&_h1]:text-xl [&_h1]:leading-[inherit]","[&_h2]:mt-0 [&_h2]:text-lg [&_h2]:leading-[inherit]","[&_h3]:mt-0 [&_h3]:text-base [&_h3]:leading-[inherit]","[&_hr]:my-sm [&_hr]:h-px [&_hr]:border-0 [&_hr]:bg-border-primary [&_hr]:[font-size:0] [&_hr]:text-border-primary","[&_ul]:mt-0","[&_p:not(:last-child)]:mb-sm","[&_li>p:not(:last-child)]:m-0"),Ti=ra(Ln)((e=>{let t=e.messageType,n=e.data.content,l=e.assistantResponseState;const o="AssistantMessage"===t&&l===Ee.duP.LOADING,i="AssistantMessage"===t&&l===Ee.duP.CANCELLED,s="AssistantMessage"===t?a.createElement(Si,{source:n,isStreaming:o,forceComplete:i,className:Ni}
1):a.createElement(Ll.o,{className:Ni},n);return(0,r.YW)(t).with("UserMessage",(()=>a.createElement(bi,null,s))).with("AssistantStatusMessage",(()=>a.createElement(wi,null,s))).otherwise((()=>s))}));var _i=n(97405),Di=n.n(_i),Ri=n(75317);const Mi=e=>{try{return Di().parse(e)}catch(t){return}},Li=e=>{let t=e.messageId,n=e.content,a=e.messageType;const l=(e=>{let t=e.content,n=e.messageType,a=e.messageId;const l=t.trim().match(/^(\S+):(\S+)\s+([^]+)$/);if(l){const e=(0,o.A)(l,4),t=e[1],r=e[2],i=e[3],s="".concat(t,":").concat(r);if(Rn[s])return[{type:s,content:i.trim(),incomplete:!1,messageType:n,messageId:a}]}const r=new RegExp(/(```(\S+)([\s\S]*?)(```|$))|([\s\S]+?((?=```\S+)|$))/g),i=[...t.matchAll(r)],s=(0,Ri.A)(i.map((e=>{var t;const l=null===(t=e[2])||void 0===t?void 0:t.trim();let r=l?e[3]:e[5];r=null===r||void 0===r?void 0:r.trim();const o=!!l&&"```"!==e[4];return r?[{type:null!==l&&void 0!==l?l:"text",content:r,incomplete:o,messageType:n,messageId:a}]:[]})));return s})({content:n,messageType:a,messageId:t}),r=(e=>(0,Ri.A)(e.map((e=>{let t=e.type,n=e.content,a=e.incomplete,l=e.messageType,r=e.messageId;const o=Rn[t];if(!o)return[];try{return[{type:t,data:o.parse(n,a),incomplete:a,messageType:l,messageId:r}]}catch(i){return[]}}))))(l);return r.map((e=>(0,U.A)((0,U.A)({},e),{},{messageType:a,messageId:t})))},Oi=e=>(0,Ri.A)(e.map((e=>{let t=e.content,n=e.__typename,a=e.id;return Li({messageId:a,content:t,messageType:n})})));var Pi=n(86140);const Bi=oa([Ti,fo,Kr,Zo,il,To,sa,Ei,Oo,zo,va,oi]),zi=oa([Eo,qr,gl,Ml,Xr,Fl]),Fi=e=>{let t=e.messages,n=e.nextGroup,l=e.demo;const r=(0,a.useMemo)((()=>Oi(t)),[t]),i=(0,a.useMemo)((()=>(0,U.A)((0,U.A)({},Bi),l?zi:{})),[l]),s=(0,o.A)(t,1)[0],c=s.assistantResponseState,d=s.__typename,u=c===Ee.duP.CANCELLED,m=(0,a.useMemo)((()=>
1u?r.filter((e=>"text"===e.type||!e.incomplete)):r),[r,u]);return a.createElement("div",{"data-external-id":"message-blocks-renderer"},m.map(((e,t)=>a.createElement(Gi,Object.assign({key:t},"UserMessage"===d&&{justifyEnd:!0}),a.createElement(yn.t,{errorComponent:a.createElement(Po,null),onError:Pi.jC},a.createElement(ia,{messageType:d,block:e,blockRenderers:i,previousBlockInGroup:m[t-1],nextBlockInGroup:m[t+1],nextGroup:n,renderContext:la.Assistant,assistantResponseState:c}))))),u&&a.createElement(dl,{canContinue:!(null!==n&&void 0!==n&&n.length)}))},Gi=(0,u.default)(m.g).withConfig({displayName:"MessageBlocksRenderer__BlockContainer",componentId:"vataov-0"})([":not(:first-child):not(:empty){margin-top:",";}"],vt.YK.default);var Yi=n(29734),Ui=n(4045),Vi=n(65887),Wi=n(7983);const ji=e=>{var t;let n=e.actions,l=e.className,r=e.feedbackOptions;return a.createElement("div",{"data-external-id":"feedback-actions",className:(0,q.cn)("flex gap-xs rounded-default",l)},a.createElement("div",{className:"flex"},n.map(((e,t)=>{let n=e.icon,l=e.label,r=e.onClick,o=e.tooltip;const i=a.createElement(Yi.S,{"aria-label":l,size:"sm",onClick:r,className:"text-content-secondary"},a.createElement(Ui.je,{name:n}));return o?a.createElement(Wi.Y,{key:t,content:o},i):a.createElement(a.Fragment,{key:t},i)}))),(null!==(t=null===r||void 0===r?void 0:r.length)&&void 0!==t?t:0)>0&&a.createElement("div",{className:"flex items-center gap-xs"},null===r||void 0===r?void 0:r.map(((e,t)=>a.createElement(Vi.H7,{key:t,size:"xs",rounded:"pill",pressed:!!e.isActive,onPressedChange:e.onClick,className:"data-pressed:border-border-brand data-pressed:bg-background-brand-subtle data-pressed:not-disabled:hover:border-border-brand-hover"},e.label)))))},Hi=["messages","nextGroup","actions","feedbackOptions","demo","className","children"],Ki=e=>{let t=e.messages,n=e.nextGroup,l=e.actions,r=e.feedbackOptions,o=e.demo,i=e.className,s=e.children,c=(0,En.A)(e,Hi);return a.createElement(m.g,Object.assign({"data-external-id":"message-list-group-base",role:"group",position:"relative",flex:1,paddingHorizontal:"xlarge",paddingVertical:"xxsmall",className:i,gap:"small",column:!0},c),a.createElement(qi,null,!!t&&a.createElement(Fi,{messages:t,nextGroup:n,demo:o}),s),!(!l||!l.length)&&a.createElement(ji,{actions:l,feedbackOptions:r}))},qi=u.default.div.withConfig({displayName:"MessageListGroupBase__Content",componentId:"sc-49q86v-0"})(["white-space:pre-wrap;width:100%;:not(:first-child){margin-top:6px;}"]),$i=()=>a.createElement(a.Fragment,null,a.createElement("div",{className:"mt-sm flex flex-1 justify-center"},a.createElement(M.Al,{$width:"175px",$height:"20px",$borderRadius:"small"})),a.createElement(Zi,null,a.createElement("div",{className:"flex flex-1 justify-end"},a.createElement(M.Al,{$width:"20%",$height:"48px",$borderRadius:"large"}))),a.createElement(Zi,null,a.createElement("div",{className:"flex flex-1 flex-col gap-sm"},a.createElement(M.Al,{$width:"70%",$height:"20px",$borderRadius:"small"}),a.createElement(M.Al,{$width:"66%",$height:"20px",$borderRadius:"small"}),a.createElement(M.Al,{$width:"30%",$height:"20px",$borderRadius:"small"})))),Zi=(0,u.default)(Ki).withConfig({displayName:"AssistantLoadingMessage__StyledMessageListGroupBase",componentId:"sc-153qb5i-0"})(["padding-top:",";"],vt.YK.small);var Ji=n(38224),Xi=n(74469),Qi=n(29617),es=n(51716);const ts=e=>(0,i.n)(ns,(0,U.A)((0,U.A)({awaitRefetchQueries:!0},e),{},{refetchQueries:t=>{var n;return[..."function"===typeof(null===e||void 0===e?void 0:e.refetchQueries)?e.refetchQueries(t):null!==(n=null===e||void 0===e?void 0:e.refetchQueries)&&void 0!==n?n:[],es.YV]}})),ns=(0,Qt.J)("\n  mutation Common_DeleteMessageThread($id: ID!) {\n    deleteMessageThread(id: $id) {\n      success\n    }\n  }\n"),as=(0,u.css)(["padding:"," ",";color:",";"],vt.YK.xxsmall,vt.YK.xsmall,vt.Ee.color.content.primary),ls=e=>{let t=e.messageThreads,n=e.activeThreadId;const l=t.find((e=>e.id===n)),r=(null===l||void 0===l?void 0:l.subject)||"New chat",i=(0,z.h)().setActiveThread,s=ts({refetchQueries:[Qe.ps]}),c=(0,o.A)(s,1)[0],d=(0,ht.S)().isAiFeaturesEnabled,u=t.slice(0,7);return 0!==t.length&&d?a.createElement(Qi.Az,{"data-external-id":"assistant-messages-list-dropdown",overlay:a.createElement(ds,null,u.map((e=>a.createElement(ss,{key:e.id,onClick:()=>{e.id!==n&&(0,Ge.u4)(Ye.xb.AssistantChatRevisited,{thread_id:e.id}),i(e.id)},selected:e.id===n},e.subject||"Untitled conversation"))),n&&a.createElement(a.Fragment,null,a.createElement(Ji.NM,null),a.createElement(cs,{icon:"trash",onClick:async()=>{n&&((0,Ge.u4)(Ye.xb.AssistantChatDeletedClicked,{thread_id:n}),await c({variables:{id:n}}),i(null))}},"Delete this chat"))),placement:"bottom-start"},(e=>{let t=e.toggleOpen,n=e.isOpen;return a.createElement(os,{onClick:t,isActive:n},a.createElement(is,null,r),a.createElement(rs,null))})):null},rs=(0,u.default)(sl.ZQ).attrs({name:"chevron-down",size:16}).withConfig({displayName:"AssistantMessagesListDropdown__ChevronDownIcon",componentId:"ysy73y-0"})(["margin-left:",";transform:translateY(1px);"],(e=>e.theme.spacing.xxsmall)),os=(0,u.default)(Xi.G).withConfig({displayName:"AssistantMessagesListDropdown__MenuButton",componentId:"ysy73y-1"})([""," justify-content:space-between;text-overflow:ellipsis;overflow:hidden;white-space:nowrap;border-radius:",";background:",";"],as,vt.r8.default,(e=>{let t=e.isActive,n=e.theme;return t?n.variables.color.background.tertiary:"transparent"})),is=(0,u.default)(xt.v).attrs({weight:"medium"}).withConfig({displayName:"AssistantMessagesListDropdown__ThreadTitle",componentId:"ysy73y-2"})(["text-overflow:ellipsis;overflow:hidden;white-space:nowrap;"]),ss=(0,u.default)(Ji.xm).withConfig({displayName:"AssistantMessagesListDropdown__StyledDropdownMenuItem",componentId:"ysy73y-3"})(["display:block;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;"]),cs=(0,u.default)(Ji.xm).withConfig({displayName:"AssistantMessagesListDropdown__DeleteMenuItem",componentId:"ysy73y-4"})(["color:",";&:hover{color:",";}"],vt.Ee.color.content.danger,vt.Ee.color.content.dangerHover),ds=(0,u.default)(Ji.SP).withConfig({displayName:"AssistantMessagesListDropdown__StyledDropdownMenu",componentId:"ysy73y-5"})(["max-width:276px;"]),us=new Set(["high_yield_savings_account","uninvested_cash"]),ms=e=>us.has(e)?"Earn ":"Save ",ps={mo:"/mo",yr:"/yr"}
1,gs={high_yield_savings_account:"Tell me more about moving my idle cash",high_interest_credit_card_sweep:"Tell me more about paying down this card",investment_fees:"Tell me more about these investment fees",mortgage_refinance:"Tell me more about refinancing my mortgage",avoidable_overdraft_fees:"Tell me more about these overdraft fees",avoidable_account_fees:"Tell me more about these account fees",credit_utilization:"Tell me more about my credit utilization",rewards_card_mismatch:"Tell me more about which card to use",single_stock_concentration:"Tell me more about this holding",spending_creep:"Tell me more about this spending increase",investment_movement:"Tell me more about this investment move",spending_comparison:"Tell me more about how my spending compares",networth_comparison:"Tell me more about how my net worth compares",late_fee_autopay:"How do I set up autopay to stop late fees?",milestone_celebration:"Tell me more about the progress I've made",uninvested_cash:"What should I do with the cash in my investment accounts?",duplicate:"Tell me more about this duplicate subscription",annual_billing:"Tell me more about switching to annual billing",retention_deal:"Tell me more about this retention offer",competitor_switch:"Tell me more about switching providers"},hs=new Set([Ee.cKf.NEW,Ee.cKf.ACCEPTED,Ee.cKf.IN_PROGRESS,Ee.cKf.REOPENED]),vs={[Ee.HXC.LIKE]:"up",[Ee.HXC.DISLIKE]:"down"},fs={[Ee.Evb.MONTHLY]:"mo",[Ee.Evb.ANNUAL]:"yr",[Ee.Evb.ONE_OFF]:"one_time"},Es=e=>e.map((e=>Ht(e.text,e.entityType,{abbreviateThousands:!1}))).join(""),ys=e=>{var t,n,a,l,r,o,i;return{id:e.id,insightType:e.insightType,status:(i=e.status,hs.has(i)?"active":i===Ee.cKf.DENIED?"dismissed":"completed"),isSaved:Boolean(e.isBookmarked),title:Es(e.title),description:Es(e.body),sourceLine:(null===(t=e.contextLine)||void 0===t?void 0:t.length)?Es(e.contextLine):void 0,merchantLogoUrl:null!==(a=null===(n=e.merchant)||void 0===n?void 0:n.logoUrl)&&void 0!==a?a:void 0,value:e.value,valueCaptured:e.valueCaptured,valueBadge:Cs(e),primaryAction:e.ctaLabel?{label:e.ctaLabel,actionKey:null!==(l=e.ctaDeepLink)&&void 0!==l?l:e.insightType}:void 0,feedback:e.feedback?vs[e.feedback]:void 0,feedbackReason:null!==(r=e.feedbackReason)&&void 0!==r?r:void 0,seededPrompt:e.prompt.trim()||xs(e.insightType),updatedAt:null!==(o=e.refreshedAt)&&void 0!==o?o:e.updatedAt,messageThreadId:e.messageThreadId}},bs=e=>e.map(ys),xs=e=>{var t;return null!==(t=gs[e])&&void 0!==t?t:"Tell me more about this"},ws=e=>e.seededPrompt||xs(e.insightType),Cs=e=>{var t,n;const a=null!==(t=e.value)&&void 0!==t?t:0;if(a<=0)return;const l=e.valuePeriod?fs[e.valuePeriod]:void 0;return{label:"".concat(ms(e.insightType)).concat((0,jt.T3)(a)).concat(null!==(n=l&&ps[l])&&void 0!==n?n:""),amount:a,unit:l}},As=[{id:"needs_attention",label:Re.NEEDS_ATTENTION},{id:"recommendations",label:"Recommendations"},{id:"updates",label:"Updates"},{id:"in_the_background",label:Re.IN_THE_BACKGROUND}],Is={avoidable_overdraft_fees:"needs_attention",avoidable_account_fees:"needs_attention",credit_utilization:"needs_attention",late_fee_autopay:"needs_attention",reconnect_account:"needs_attention",high_yield_savings_account:"recommendations",high_interest_credit_card_sweep:"recommendations",investment_fees:"recommendations",mortgage_refinance:"recommendations",rewards_card_mismatch:"recommendations",uninvested_cash:"recommendations",single_stock_concentration:"updates",spending_creep:"updates",investment_movement:"updates",milestone_celebration:"updates",spending_comparison:"updates",networth_comparison:"updates",duplicate:"recommendations",new_subscription:"needs_attention",yearly_subscription:"recommendations",retention_deal:"recommendations",expired_promo:"needs_attention",annual_billing:"recommendations",tier_downgrade:"recommendations",plan_optimization:"recommendations",bundle:"recommendations",competitor_switch:"recommendations",vendor_switch:"recommendations",other:"recommendations",marketplace_review:"updates",transfer_review:"updates",product_review:"updates"},ks="recommendations",Ss=e=>{var t;return null!==(t=Is[e])&&void 0!==t?t:ks},Ns=[],Ts=e=>{var t,n;return _s(null!==(n=null===(t=Ns[Ns.length-1])||void 0===t?void 0:t.lists)&&void 0!==n?n:[],e)},_s=(e,t)=>{for(const n of e){const e=n.findIndex((e=>e.id===t));if(-1!==e)return e+1}return null},Ds=new Set(["saved","completed","archived","everything_else"]),Rs=e=>({insight_id:e.id,insight_type:e.insightType,section:Ss(e.insightType),value:"number"===typeof e.value?e.value:null,position:Ts(e.id)}),Ms=(e,t)=>{var n,a;return null!==(a=null===(n=e.find((e=>e.id===t)))||void 0===n?void 0:n.insights)&&void 0!==a?a:[]},Ls=e=>{var t;const n=e.value;if("number"!==typeof n)return;const a="mo"===(null===(t=e.valueBadge)||void 0===t?void 0:t.unit)?12*n:n;return(0,De.Ym)(a)},Os=(e,t)=>{const n=Ls(e),a=Ls(t);return"number"!==typeof n&&"number"!==typeof a?0:"number"!==typeof n?1:"number"!==typeof a?-1:a-n},Ps=(e,t)=>{return n=(e=>[...e].sort(Os))(t),a=e,Array.from({length:Math.max(n.length,a.length)},((e,t)=>[n[t],a[t]])).flat().filter((e=>void 0!==e));var n,a},Bs=function(e){return function(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return[Ms(e,"needs_attention").length>0,Ms(e,"recommendations").length>0||Ms(e,"updates").length>
10,t].filter(Boolean).length}(e,arguments.length>1&&void 0!==arguments[1]&&arguments[1])>1},zs={needs_attention:"alert-triangle",recommendations:"piggy-bank",updates:"trending-up",in_the_background:"info"},Fs={needs_attention:"red",recommendations:"blue",updates:"yellow",in_the_background:"gray-secondary"},Gs={avoidable_overdraft_fees:"red",avoidable_account_fees:"red",credit_utilization:"red",late_fee_autopay:"red",reconnect_account:"red",new_subscription:"yellow",expired_promo:"yellow",spending_creep:"yellow",duplicate:"yellow",single_stock_concentration:"yellow",spending_comparison:"gray-secondary",networth_comparison:"gray-secondary",marketplace_review:"gray-secondary",transfer_review:"gray-secondary",product_review:"gray-secondary",high_yield_savings_account:"blue",high_interest_credit_card_sweep:"blue",investment_fees:"blue",mortgage_refinance:"blue",rewards_card_mismatch:"blue",yearly_subscription:"blue",retention_deal:"blue",annual_billing:"blue",tier_downgrade:"blue",plan_optimization:"blue",bundle:"blue",competitor_switch:"blue",vendor_switch:"blue",other:"blue",uninvested_cash:"blue",investment_movement:"green",milestone_celebration:"green"},Ys={avoidable_overdraft_fees:"invoice",avoidable_account_fees:"fee",credit_utilization:"credit-card",late_fee_autopay:"fee",reconnect_account:"wifi-off",new_subscription:"invoice",spending_creep:"shopping-bag",duplicate:"copy",single_stock_concentration:"pie-chart",high_yield_savings_account:"pigg
1y-bank",high_interest_credit_card_sweep:"wallet",investment_fees:"invoice",mortgage_refinance:"home",rewards_card_mismatch:"shopping-bag",yearly_subscription:"calendar-check",annual_billing:"calendar-check",uninvested_cash:"wallet",networth_comparison:"dollar-note",spending_comparison:"dollar-note",milestone_celebration:"milestone-badge",investment_movement:"trending-up"},Us=/\bis down\b|had a rough\b/i,Vs=[{pattern:/dining out|restaurants|\bdining\b/i,icon:"dining"},{pattern:/\bgas\b|\bfuel\b/i,icon:"fuel"},{pattern:/clothing/i,icon:"hanger"},{pattern:/medical|dental|personal care/i,icon:"health-heart"},{pattern:/entertainment/i,icon:"tv"}],Ws=e=>Boolean(e&&Us.test(e)),js=e=>[e.title,e.description].filter(Boolean).join("\n"),Hs=new Set(["spending_comparison","spending_creep"]),Ks=(e,t)=>{if("investment_movement"===e&&Ws(t))return"trending-down";if(Hs.has(e)){const e=(e=>{var t;return e?null===(t=Vs.find((t=>t.pattern.test(e))))||void 0===t?void 0:t.icon:void 0})(t);if(e)return e}return Ys[e]},qs=(e,t)=>((e,t,n,a)=>{const l=t?n(t):void 0;if(l)return l;const r=Ks(e,a);return(r?n(r):void 0)||zs[Ss(e)]})(e.insightType,t,Ui.lS,js(e)),$s=e=>((e,t)=>{var n;return"investment_movement"===e&&Ws(t)?"yellow":null!==(n=Gs[e])&&void 0!==n?n:Fs[Ss(e)]})(e.insightType,js(e)),Zs=Ui.je,Js=new Set(["avoidable_account_fees","single_stock_concentration","spending_creep","investment_movement","milestone_celebration","spending_comparison","networth_comparison"]),Xs={networth_comparison:Re.NETWORTH_COMPARISON_SOURCE,spending_comparison:Re.SPENDING_COMPARISON_SOURCE},Qs=e=>Xs[e],ec=/(\$\d+(?:,\d{3})*(?:\.\d+)?|\d+(?:,\d{3})*(?:\.\d+)?%)/g,tc="pointer-events-none relative z-10 [&_a]:pointer-events-auto [&_button]:pointer-events-auto [&_textarea]:pointer-events-auto",nc=e=>{let t=e.insight,n=e.isSaved,l=e.onPrimaryAction,r=e.onOpenConversation,i=e.onSave,s=e.onComplete,c=e.onUndoComplete,d=e.onDismiss,u=e.onRestore,m=e.forceRestore,p=void 0!==m&&m,g=e.className;const h=t.valueBadge,v=t.primaryAction,f=(0,rl.T$)(t.title),E=(0,rl.T$)(t.description),y=Qs(t.insightType),b=(0,a.useState)(!1),x=(0,o.A)(b,2),w=x[0],C=x[1],A=null!==n&&void 0!==n?n:w,I="dismissed"===t.status,k="completed"===t.status,S=Boolean(u)&&(I||p),N=Boolean(d)&&!S&&!k,T=(_=t.insightType,!Js.has(_));var _;const D=T&&!I&&(k?Boolean(c):Boolean(s)),R=T&&"active"===t.status||A,M=A?Re.SAVED:Re.SAVE,L=k?Re.UNDO_COMPLETE:Re.COMPLETE;return a.createElement(fe.Qey.Root,{"data-external-id":"insight-card",variant:"shadow",className:(0,q.cn)("relative rounded-lg p-0",r&&"cursor-pointer hover:bg-background-primary",g),"aria-label":r?f:void 0,onClick:r?e=>r(t,e.currentTarget):void 0},N&&d&&a.createElement(fe.Yvj,{content:Re.DISMISS},a.createElement(fe.TU1,{variant:"minimal",size:"xs","aria-label":Re.DISMISS,className:"absolute top-2xs right-2xs z-10",onClick:e=>{e.stopPropagation(),d(t)}})),S&&u&&a.createElement(fe.Yvj,{content:Re.RESTORE},a.createElement(fe.SO$,{variant:"minimal",size:"xs","aria-label":Re.RESTORE,className:"absolute top-2xs right-2xs z-10",onClick:e=>{e.stopPropagation(),u(t)}},a.createElement(fe.Q1e,null))),a.createElement("div",{className:"flex w-full min-w-0 flex-col gap-sm p-default"},a.createElement("div",{className:"flex items-start gap-sm"},a.createElement(rc,{insight:t}),a.createElement("div",{className:(0,q.cn)("flex min-w-0 flex-1 flex-col gap-2xs",(N||S)&&"pr-xl")},h&&a.createElement(ac,{valueBadge:h,insightType:t.insightType}),a.createElement(fe.c8D,{size:"base",weight:"medium",render:a.createElement("h3",null),className:"m-0 w-fit"},f),a.createElement(fe.c8D,{size:"sm",color:"secondary"},a.createElement(lc,{text:E})),y&&a.createElement("span",{className:(0,q.cn)("w-fit",tc),onClick:e=>e.stopPropagation()},a.createElement(fe.cIj,{label:a.createElement(fe.c8D,{size:"sm",color:"secondary"},Re.COMPARISON_REFERENCE_LINE),content:y,iconSize:"sm",triggerClassName:"items-center text-content-secondary"})))),a.createElement("div",{className:"flex flex-col gap-default pl-3xl"},a.createElement("div",{className:(0,q.cn)("flex flex-wrap items-center gap-xs",tc),onClick:e=>e.stopPropagation()},v&&l&&a.createElement(fe.XZZ,{size:"xs",variant:"default",rounded:"pill",onClick:()=>l(t)},v.label),a.createElement("div",{className:"ml-auto flex items-center gap-3xs"},R&&a.createElement(fe.Yvj,{content:M},a.createElement(fe.SO$,{variant:"minimal",size:"xs","aria-label":M,className:(0,q.cn)(A&&"text-content-primary"),onClick:()=>{const e=!A;void 0===n&&C(e),null===i||void 0===i||i(t,e)}},A?a.createElement(fe.OSm,null):a.createElement(fe.Eve,null))),D&&a.createElement(fe.Yvj,{content:L},a.createElement(fe.SO$,{variant:"minimal",size:"xs","aria-label":L,"aria-pressed":k,className:(0,q.cn)(k&&"text-content-primary"),onClick:()=>k?null===c||void 0===c?void 0:c(t):null===s||void 0===s?void 0:s(t)},k?a.createElement(fe.cyv,null):a.createElement(fe.C14,null))))))))},ac=e=>{let t=e.valueBadge,n=e.insightType;const l=t.amount,r=t.label,o=t.unit,i=o?ps[o]:void 0;return void 0===l?a.createElement(fe.c8D,{"data-external-id":"insight-value-badge",size:"sm",className:"shrink-0"},r):a.createElement(fe.c8D,{"data-external-id":"insight-value-badge",size:"sm",className:"shrink-0"},a.createElement("span",{className:"font-book text-content-secondary"},ms(n)),a.createElement("span",{className:"font-medium text-content-success"},(0,rl.T3)(l)),i?a.createElement("span",{className:"text-xs font-book text-content-secondary"},i):null)},lc=e=>{let t=e.text;return a.createElement(a.Fragment,null,(e=>{var t;if(!e)return[];const n=[];let a=0;for(const l of e.matchAll(ec)){const r=null!==(t=l.index)&&void 0!==t?t:0;r>a&&n.push({text:e.slice(a,r),emphasize:!1}),n.push({text:l[0],emphasize:!0}),a=r+l[0].length}return a<e.length&&n.push({text:e.slice(a),emphasize:!1}),n})(t).map(((e,t)=>e.emphasize?a.createElement("span",{key:t,className:"font-medium text-content-secondary"},e.text):a.createElement(a.Fragment,{key:t},e.text))))},rc=e=>{let t=e.insight;return a.createElement(fe.Qey.IconTile,{"data-external-id":"card-tile",align:"start",color:$s(t),className:"size-9 rounded-[10px] [&_svg]:size-4.5",icon:a.createElement(Zs,{name:qs(t)})})},oc=e=>{let t,n=e.delayMs,a=void 0===n?400:n,l=e.schedule,r=e.cancel,o=e.show,i=[];const s=()=>{const e=i;var n;(i=[],t=void 0,0!==e.length)&&o((n=e.length)>1?Re.dismissedArchivedCount(n):Re.DISMISSED_ARCHIVED_TOAST,(()=>{for(const t of e)t()}))};return{push(e){i.push(e),void 0!==t&&r(t),t=l(s,a)},discard(){i=[],void 0!==t&&(r(t),t=void 0)}}},ic=new Set([...Re.FEEDBACK_REASONS,Re.FEEDBACK_REASON_OTHER]),sc=e=>e?[ic.has(e)?e:Re.FEEDBACK_REASON_OTHER]:[],cc=(e,t)=>e?{feedback_type:"up"===e?Ua.Positive:Ua.Negative,details:sc(t)}:null,dc="generic";var uc=n(91793);const mc={up:Ee.HXC.LIKE,down:Ee.HXC.DISLIKE},pc=5e3,gc=e=>{(0,C.W7)({message:e,duration:pc})},hc=(e,t)=>{(0,C.W7)({message:e,duration:pc,actions:[{text:Re.UNDO,onClick:t}]})},vc=()=>{const e=(0,C.RU)(),t=(0,l.Zp)(),n=(0,a.useRef)(oc({schedule:(e,t)=>
1window.setTimeout(e,t),cancel:e=>window.clearTimeout(e),show:hc})),r=(e=>{let t=e.showStatusToast,n=e.showUndoToast,l=e.showErrorToast,r=e.track,s=e.navigateTo;var c;const d=(0,V.m)(),u=(0,a.useSyncExternalStore)(uc.Vp,uc.RJ),m=u.hiddenInsightIds,p=u.dismissingInsightIds,g=u.completedStub,h=u.savedInsightIds,f=u.unsavedInsightIds,E=u.sessionCompletedInsights,y=u.sessionDismissedInsights,b=u.sessionUnhelpfulInsights,x=u.restoredInsightIds,w=u.feedbackByInsightId,C=u.completedDelta,A=(0,v.D)(t),I=(0,v.D)(n),k=(0,v.D)(l),S=(0,v.D)(r),N=uc.DA.completeInFlight,T=uc.DA.undoneCompleteIds,_=uc.DA.undoInFlightIds,D=uc.DA.dismissInFlight,R=(0,a.useRef)(s);R.current=s;const M=(0,a.useCallback)(((e,t,n)=>{S(e,(0,U.A)((0,U.A)({},Rs(t)),n))}),[S]),L=(0,i.n)(es.ct,{fetchPolicy:"no-cache"}),O=(0,o.A)(L,1)[0],P=(0,i.n)(es.kE),B=(0,o.A)(P,1)[0],z=(0,i.n)(es.Y$),F=(0,o.A)(z,1)[0],G=(0,i.n)(es.y,{fetchPolicy:"no-cache"}),Y=(0,o.A)(G,1)[0],W=(0,a.useCallback)((()=>{d.refetchQueries({include:["Common_GetTodayInsights"]})}),[d]);(0,a.useEffect)((()=>(0,uc.pu)(W)),[W]);const j=(0,a.useCallback)((async function(e,t){let n=(arguments.length>2&&void 0!==arguments[2]?arguments[2]:{}).denialReason;var a,l,r,o,i;try{const s=await O({variables:{input:(0,U.A)({id:e.id,status:t},n&&{denialReason:n})}}),c=s.data,d=s.errors;if((null===d||void 0===d?void 0:d.length)||(null===(l=null===(a=null===c||void 0===c?void 0:c.updateInsightStatus)||void 0===a?void 0:a.errors)||void 0===l?void 0:l.message))throw new Error(null!==(i=null===(o=null===(r=null===c||void 0===c?void 0:c.updateInsightStatus)||void 0===r?void 0:r.errors)||void 0===o?void 0:o.message)&&void 0!==i?i:"Update failed");return!0}catch(s){return k(),!1}}),[k,O]),H=(0,a.useCallback)((async e=>{if(N.has(e.id)||_.has(e.id))return!1;const t=(0,uc.TU)();M(Ye.CP.InsightCompleted,e,{completed:!0,source:"card"});const n=(0,uc.RJ)().completedStub;n&&n.id!==e.id&&(0,uc.Yt)(n.id,!0),(0,uc.uM)(e),(0,uc.BV)((t=>t.some((t=>t.id===e.id))?t:[...t,(0,U.A)((0,U.A)({},e),{},{status:"completed"})]));const a=j(e,Ee.cKf.COMPLETED);N.set(e.id,a);const l=await a;return N.delete(e.id),T.has(e.id)||!(0,uc.I_)(t)?l:l?((0,uc.e3)((e=>e+1)),!0):((0,uc.uM)((t=>(null===t||void 0===t?void 0:t.id)===e.id?n:t)),(0,uc.Yt)(e.id,!1),n&&n.id!==e.id&&(0,uc.Yt)(n.id,!1),(0,uc.BV)((t=>t.filter((t=>t.id!==e.id)))),!1)}),[N,_,T,j,M]),K=(0,a.useCallback)((async function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:e?"card":"completed_stub";var n;const a=null!==e&&void 0!==e?e:(0,uc.RJ)().completedStub;if(!a||_.has(a.id))return;const l=(0,uc.TU)(),r=(null===(n=(0,uc.RJ)().completedStub)||void 0===n?void 0:n.id)===a.id,o=!N.has(a.id);T.add(a.id),_.add(a.id),r&&(0,uc.uM)(null),(0,uc.Yt)(a.id,!1),o&&(0,uc.e3)((e=>e-1)),(0,uc.BV)((e=>e.filter((e=>e.id!==a.id))));const i=N.get(a.id);if(i&&!await i)return T.delete(a.id),void _.delete(a.id);const s=await j(a,Ee.cKf.REOPENED);if((0,uc.I_)(l)){if(!s)return T.delete(a.id),_.delete(a.id),r&&(0,uc.uM)(a),o&&(0,uc.e3)((e=>e+1)),void(0,uc.BV)((e=>e.some((e=>e.id===a.id))?e:[...e,(0,U.A)((0,U.A)({},a),{},{status:"completed"})]));T.delete(a.id),_.delete(a.id),M(Ye.CP.InsightCompleted,a,{completed:!1,source:t}),A(Re.RESTORED),W()}}),[N,_,T,j,W,A,M]),q=(0,a.useCallback)(((e,t)=>{(0,uc.vl)((n=>"down"===t?n.some((t=>t.id===e.id))?n:[...n,(0,U.A)((0,U.A)({},e),{},{feedback:"down"})]:n.filter((t=>t.id!==e.id))))}),[]),$=(0,a.useCallback)((async function(e,t,n){let a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},l=a.skipToast,r=void 0!==l&&l,i=a.skipErrorToast,s=void 0!==i&&i;var c,d,u,m,p,g;const h=(0,uc.TU)(),v=(0,uc.RJ)().feedbackByInsightId[e.id];(0,uc.i3)((n=>(0,U.A)((0,U.A)({},n),{},{[e.id]:t}))),q(e,t),r||("up"===t?A(Re.HELPFUL_TOAST):null===t&&A(Re.RATING_REMOVED_TOAST));try{const a=await F({variables:{input:{id:e.id,feedback:t&&mc[t],reason:n}}}),l=a.data,r=a.errors;if((null===r||void 0===r?void 0:r.length)||(null===(d=null===(c=null===l||void 0===l?void 0:l.setInsightFeedback)||void 0===c?void 0:c.errors)||void 0===d?void 0:d.message))throw new Error(null!==(p=null===(m=null===(u=null===l||void 0===l?void 0:l.setInsightFeedback)||void 0===u?void 0:u.errors)||void 0===m?void 0:m.message)&&void 0!==p?p:"Feedback failed")}catch(f){return(0,uc.I_)(h)&&((0,uc.i3)((t=>void 0===v?Object.fromEntries(Object.entries(t).filter((t=>(0,o.A)(t,1)[0]!==e.id))):(0,U.A)((0,U.A)({},t),{},{[e.id]:v}))),q(e,void 0===v?null!==(g=e.feedback)&&void 0!==g?g:null:v)),s||k(),!1}return!0}),[F,k,A,q]),Z=(0,a.useCallback)((async e=>{var t,n,a,l,r;try{const o=await Y({variables:{input:{id:e.id}}}),i=o.data,s=o.errors;if((null===s||void 0===s?void 0:s.length)||(null===(n=null===(t=null===i||void 0===i?void 0:i.undoInsightDenial)||void 0===t?void 0:t.errors)||void 0===n?void 0:n.message))throw new Error(null!==(r=null===(l=null===(a=null===i||void 0===i?void 0:i.undoInsightDenial)||void 0===a?void 0:a.errors)||void 0===l?void 0:l.message)&&void 0!==r?r:"Undo failed");return!0}catch(o){return k(),!1}}),[k,Y]),J=(0,a.useCallback)((async function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"restore_button";var n;const a=(0,uc.TU)();("dismissed"!==e.status||await Z(e))&&(0,uc.I_)(a)&&(M(Ye.CP.InsightRestored,e,{source:t}),(0,uc.tl)((t=>t.filter((t=>
1t.id!==e.id)))),(0,uc.vl)((t=>t.filter((t=>t.id!==e.id)))),(0,uc.Vf)((t=>new Set(t).add(e.id))),(0,uc.Yt)(e.id,!1),(!("down"===(null!==(n=(0,uc.RJ)().feedbackByInsightId[e.id])&&void 0!==n?n:e.feedback))||await $((0,U.A)((0,U.A)({},e),{},{status:"active"}),null,void 0,{skipToast:!0}))&&A(Re.RESTORED),W())}),[$,W,A,M,Z]),X=(0,a.useCallback)((async(e,t)=>{var n;if(D.has(e.id))return!1;D.add(e.id);const a=(0,uc.TU)();M(Ye.CP.InsightDismissed,e,{has_note:Boolean(null===t||void 0===t?void 0:t.trim())}),(null===(n=(0,uc.RJ)().completedStub)||void 0===n?void 0:n.id)===e.id&&(0,uc.uM)(null),(0,uc.JO)((t=>new Set(t).add(e.id)));const l=await j(e,Ee.cKf.DENIED,{denialReason:t});return(0,uc.I_)(a)?l?((0,uc.vl)((t=>t.map((t=>t.id===e.id?(0,U.A)((0,U.A)({},t),{},{status:"dismissed"}):t)))),t||((0,uc.Vf)((t=>{if(!t.has(e.id))return t;const n=new Set(t);return n.delete(e.id),n})),(0,uc.tl)((t=>t.some((t=>t.id===e.id))?t:[...t,(0,U.A)((0,U.A)({},e),{},{status:"dismissed"})])),I(Re.DISMISSED_TOAST,(()=>{J((0,U.A)((0,U.A)({},e),{},{status:"dismissed"}),"dismiss_toast")}))),!0):(D.delete(e.id),(0,uc.JO)((t=>{const n=new Set(t);return n.delete(e.id),n})),(0,uc.Yt)(e.id,!1),!1):(D.delete(e.id),l)}),[D,j,J,I,M]),Q=(0,a.useCallback)((e=>{(0,uc.RJ)().dismissingInsightIds.has(e)&&(D.delete(e),(0,uc.JO)((t=>{const n=new Set(t);return n.delete(e),n})),(0,uc.Yt)(e,!0),W())}),[D,W]),ee=(0,a.useCallback)(((e,t)=>{(0,uc.Wc)((n=>{const a=new Set(n);return t?a.add(e):a.delete(e),a})),(0,uc.vz)((n=>{const a=new Set(n);return t?a.delete(e):a.add(e),a}))}),[]),te=(0,a.useCallback)((async(e,t)=>{var n,a,l,r,o;const i=(0,uc.TU)();ee(e.id,t),M(Ye.CP.InsightSaveToggled,e,{saved:t}),A(t?Re.SAVED_TOAST:Re.UNSAVED_TOAST);try{const i=await B({variables:{input:{id:e.id,bookmarked:t}}}),s=i.data,c=i.errors;if((null===c||void 0===c?void 0:c.length)||(null===(a=null===(n=null===s||void 0===s?void 0:s.setInsightBookmarked)||void 0===n?void 0:n.errors)||void 0===a?void 0:a.message))throw new Error(null!==(o=null===(r=null===(l=null===s||void 0===s?void 0:s.setInsightBookmarked)||void 0===l?void 0:l.errors)||void 0===r?void 0:r.message)&&void 0!==o?o:"Bookmark failed")}catch(s){(0,uc.I_)(i)&&ee(e.id,!t),k()}}),[ee,B,k,A,M]),ne=(0,a.useCallback)((async(e,t,n)=>{if(null===t&&"dismissed"===e.status)return void await J(e,"feedback_removed");const a=cc(t,n);a&&("down"!==t||n)&&M(Ye.CP.InsightFeedbackSubmitted,e,(0,U.A)((0,U.A)({},a),{},{has_note:Boolean(null===n||void 0===n?void 0:n.trim())})),await $(e,t,n,{skipErrorToast:"down"===t&&!n})}),[$,J,M]),ae=(0,a.useCallback)((e=>{var t;M(Ye.CP.InsightPrimaryActionClicked,e);const n=(e=>{const t=null===e||void 0===e?void 0:e.replace(/[\t\n\r]/g,"");if((null===t||void 0===t?void 0:t.startsWith("/"))&&!/^\/[/\\]/.test(t))return t})(null===(t=e.primaryAction)||void 0===t?void 0:t.actionKey),a=R.current;n&&a?a(n):e.primaryAction&&A("".concat(e.primaryAction.label,"\u2026"))}),[A,M]),le=(0,a.useCallback)(((e,t)=>{const n=cc("down",t);n&&M(Ye.CP.InsightFeedbackSubmitted,e,(0,U.A)((0,U.A)({},n),{},{has_note:Boolean(t.trim())})),$(e,"down",t).then((async n=>{n&&await X(e,t)&&I(Re.FEEDBACK_THANKS_TOAST,(()=>{J((0,U.A)((0,U.A)({},e),{},{status:"dismissed"}),"feedback_toast")}))}))}),[$,X,J,I,M]),re=(0,a.useCallback)((async(e,t)=>{const n=t.trim();return!!n&&j(e,Ee.cKf.DENIED,{denialReason:n})}),[j]),oe=(0,a.useCallback)((()=>(0,uc.e3)(0)),[]);return{hiddenInsightIds:m,dismissingInsightIds:p,completedStubInsightId:null!==(c=null===g||void 0===g?void 0:g.id)&&void 0!==c?c:null,savedInsightIds:h,unsavedInsightIds:f,sessionCompletedInsights:E,sessionDismissedInsights:y,sessionUnhelpfulInsights:b,restoredInsightIds:x,feedbackByInsightId:w,completedDelta:C,onComplete:H,onUndoComplete:K,onFinalizeCompleteStub:uc.yE,onDismiss:X,onUndoDismiss:J,onDismissAnimationEnd:Q,onSave:te,onFeedback:ne,onFeedbackReason:le,submitDenialNote:re,onPrimaryAction:ae,resetCompletedDelta:oe,refetchInsights:W}})({showStatusToast:gc,showUndoToast:(e,t)=>{e!==Re.DISMISSED_TOAST?hc(e,t):n.current.push(t)},showErrorToast:e,track:Ge.u4,navigateTo:e=>{t(e)}});return(0,U.A)((0,U.A)({},r),{},{showDismissNoteToast:e=>{hc(Re.DISMISSED_NOTE_TOAST,e)}})},fc=[Ee.cKf.NEW,Ee.cKf.ACCEPTED,Ee.cKf.IN_PROGRESS,Ee.cKf.REOPENED],Ec=[Ee.cKf.COMPLETED],yc=e=>{let t=e.hiddenInsightIds,n=e.sessionSavedInsightIds,l=e.unsavedInsightIds,r=e.skip,o=void 0!==r&&r;var i,s,c,d;const u=(0,et.I)(es.YV,{skip:o,variables:{feedStatuses:fc,completedStatuses:Ec,limit:50}}),m=u.data,p=u.isLoadingInitialData,g=u.error,h=u.refetch,v=(0,a.useMemo)((()=>{var e,t;return[...null!==(e=null===m||void 0===m?void 0:m.insights)&&void 0!==e?e:[],...null!==(t=null===m||void 0===m?void 0:m.completedInsights)&&void 0!==t?t:[]]}),[null===m||void 0===m?void 0:m.completedInsights,null===m||void 0===m?void 0:m.insights]),f=(0,a.useMemo)((()=>bs(v)),[v]),E=(0,a.useMemo)((()=>{var e;return bs(null!==(e=null===m||void 0===m?void 0:m.dismissedInsights)&&void 0!==e?e:[])}),[null===m||void 0===m?void 0:m.dismissedInsights]),y=(0,a.useMemo)((()=>{var e;return bs(null!==(e=null===m||void 0===m?void 0:m.unhelpfulInsights)&&void 0!==e?e:[])}),[null===m||void 0===m?void 0:m.unhelpfulInsights]),b=(0,a.useMemo)((()=>(null===t||void 0===t?void 0:t.size)?f.filter((e=>!t.has(e.id))):f),[t,f]),x=(0,a.useMemo)((()=>b.filter((e=>!e.isSaved||(null===n||void 0===n?void 0:n.has(e.id))||(null===l||void 0===l?void 0:l.has(e.id))))),[n,l,b]),w=(0,a.useMemo)((()=>function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:As;var n;const a=(e=>((e,t)=>e.filter((e=>e.status===t)))(e,"active"))(e),l=new Map(t.map((e=>[e.id,[]])));for(const r of a){const e=Ss(r.insightType),t=null!==(n=l.get(e))&&void 0!==n?n:l.get(ks);null===t||void 0===t||t.push(r)}return t.map((e=>{var t;return{id:e.id,label:e.label,insights:null!==(t=l.get(e.id))&&void 0!==t?t:[]}})).filter((e=>e.insights.length>0))}(x)),[x]),C=null!==(s=null===(i=null===m||void 0===m?void 0:m.insightCounts)||void 0===i?void 0:i.completed)&&void 0!==s?s:0,A=null!==(d=null===(c=null===m||void 0===m?void 0:m.insightCounts)||void 0===c?void 0:c.unhelpful)&&void 0!==d?d:0;return{insights:b,allInsights:f,sections:w,dismissedInsights:E,unhelpfulInsights:y,isEmpty:0===w.length,completedCount:C,unhelpfulCount:A,isLoading:p,error:g,refetch:h}},bc=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.hiddenInsightIds,n=e.sessionSavedInsightIds,a=e.unsavedInsightIds,l=e.skip;return yc({hiddenInsightIds:t,sessionSavedInsightIds:n,unsavedInsightIds:a,skip:void 0!==l&&l})},xc=e=>{let t=e.insightId,n=e.threadId;const l=bc().allInsights,r=vc(),o=r.savedInsightIds,i=r.unsavedInsightIds,s=r.onSave,c=r.onComplete,d=r.onPrimaryAction,u=l.find((e=>e.id===t));
1if(!u||u.messageThreadId&&u.messageThreadId!==n)return null;const m=!i.has(u.id)&&(o.has(u.id)||u.isSaved);return a.createElement("div",{"data-external-id":"assistant-overlay-insight",className:"px-default"},a.createElement(nc,{insight:u,isSaved:m,onSave:s,onComplete:c,onPrimaryAction:d}))};var wc=n(63627),Cc=n(51765),Ac=n(2717),Ic=n(82910),kc=n.n(Ic),Sc=n(54147),Nc=n(99270),Tc=n(61501),_c=n(64378),Dc=n(30713),Rc=n(67237),Mc=n(85546),Lc=n(36803),Oc=n(97335),Pc=n(70931);const Bc=e=>{let t=e.title,n=e.subtitle,l=e.initiallyExpanded,r=void 0!==l&&l,i=e.children,s=e.className,c=e.showBorders,d=void 0===c||c;const u=(0,Pc.e)(r),m=(0,o.A)(u,2),p=m[0],g=m[1].toggle;return a.createElement(zc,{"data-external-id":"deprecated-collapsible-section"},a.createElement(Fc,{className:s,onClick:g,$showBorders:d},a.createElement(Gc,null,!!t&&a.createElement(xt.v,{weight:"medium"},t),!!n&&a.createElement(xt.v,{size:"small"},n)),a.createElement(Yc,{rotate:p})),a.createElement(Ql.$,{open:p,shouldAnimateOnMount:!1},i))},zc=u.default.div.withConfig({displayName:"CollapsibleSection__Root",componentId:"sc-13mbqyr-0"})(["width:100%;"]),Fc=(0,u.default)(m.g).withConfig({displayName:"CollapsibleSection__Header",componentId:"sc-13mbqyr-1"})(["cursor:pointer;transition:",";padding:"," 0;width:100%;",""],(e=>e.theme.transition.default),(e=>e.theme.spacing.xlarge),(e=>e.$showBorders&&(0,u.css)(["width:auto;padding:"," ",";border-top:1px solid ",";border-bottom:1px solid ",";:hover{background:",";}"],(e=>e.theme.spacing.xlarge),(e=>e.theme.spacing.xxlarge),(e=>e.theme.color.grayFocus),(e=>e.theme.color.grayFocus),(e=>e.theme.color.grayBackground)))),Gc=(0,u.default)(m.g).attrs({column:!0}).withConfig({displayName:"CollapsibleSection__TitleContainer",componentId:"sc-13mbqyr-2"})(["margin-right:",";flex:1;& > [data-sc-tw~='Text__Text']:not(:first-child){margin-top:",";}"],(e=>e.theme.spacing.xlarge),(e=>e.theme.spacing.xsmall)),Yc=(0,u.default)(sl.ZQ).attrs({name:"chevron-down"}).withConfig({displayName:"CollapsibleSection__ArrowIcon",componentId:"sc-13mbqyr-3"})(["width:24px;height:24px;transition:all 0.5s cubic-bezier(0.176,0.88,0.32,1.48);",""],(e=>e.rotate&&(0,u.css)(["transform:rotate(180deg);"]))),Uc=["System:","AI:","Human:"],Vc={llm_start:"LLM Request",llm_end:"LLM Response",llm_error:"LLM Error",tool_start:"Tool Request",tool_end:"Tool Response",tool_error:"Tool Error",agent_finish:"Agent Finish"},Wc=e=>{let t=e.logs;return a.createElement(a.Fragment,null,t.map(((e,t)=>a.createElement(qc,{key:t,title:jc(e),subtitle:N.c9.fromISO(e.timestamp).toLocaleString({hour:"numeric",minute:"numeric",second:"numeric"})},a.createElement($c,null,a.createElement(Kc,{log:e}))))))},jc=e=>{const t=e.event,n=e.data,l=e.agent_type,r=Vc[t]||t,o=[];if(l&&o.push(a.createElement(Oc.D,{key:"agent-type",color:"green"},l)),["tool_start","tool_end"].includes(t)&&n.name&&o.push(a.createElement(Oc.D,{key:"tool-name",color:"blue"},n.name)),"llm_end"===t){var i,s,c,d;const e=null===(i=n.generations)||void 0===i||null===(s=i[0])||void 0===s||null===(c=s[0])||void 0===c||null===(d=c.generation_info)||void 0===d?void 0:d.model_name;e&&o.push(a.createElement(Oc.D,{key:"model",color:"orange"},e))}return a.createElement("div",{className:"flex items-center gap-xs"},a.createElement("span",null,r),o)},Hc=e=>{let t=e.children;return a.createElement("div",{"data-external-id":"wrapper",className:"flex flex-col items-start gap-sm"},t)},Kc=e=>{let t=e.log,n=t.event,l=t.data;if("llm_start"===n){const e=l.prompts||[],t=(0,o.A)(e,1)[0];if(!t)return null;const n=(e=>{const t=Uc.join("|"),n=Uc.map((e=>"\n".concat(e))).join("|"),a=new RegExp("(".concat(t,") (.+?)(?=").concat(n,"|$)"),"gs");return[...e.matchAll(a)].map((e=>({role:e[1].trim(),content:e[2].trim()})))})(t);return a.createElement(Hc,{"data-external-id":"log-content"},a.createElement(Oc.D,{color:"grayFocus"},"Prompt Messages"),n.map(((e,t)=>{let n=e.role,l=e.content;return a.createElement("div",{key:t},a.createElement(Zc,null,a.createElement(Oc.D,{color:"grayFocus"},n.replace(":","")),a.createElement("div",null,l)))})))}if("llm_end"===n){const e=l.generations[0][0].text,t=Mi(e);return a.createElement(Hc,{"data-external-id":"log-content"},a.createElement(Oc.D,{color:"grayFocus"},"Response"),a.createElement(Zc,null,t?JSON.stringify(t,null,2):e))}if("tool_start"===n){const e=l.input_str,t=Mi(e);return a.createElement(Hc,{"data-external-id":"log-content"},a.createElement(Oc.D,{color:"grayFocus"},"Tool Input"),a.createElement(Zc,null,t?JSON.stringify(t,null,2):e))}if("tool_end"===n){const e=l.output;return a.createElement(Hc,{"data-external-id":"log-content"},a.createElement(Oc.D,{color:"grayFocus"},"Output"),a.createElement(Zc,null,(0,Lc.A)(e)?JSON.stringify(e,null,2):e))}if("agent_finish"===n){const e=l.output;return a.createElement(Hc,{"data-external-id":"log-content"},a.createElement(Oc.D,{color:"grayFocus"},"Output"),a.createElement(Zc,null,e))}return a.createElement("code",{"data-external-id":"log-content"},JSON.stringify(l,null,2))},qc=(0,u.default)(Bc).withConfig({displayName:"DebugPrettyLogs__StyledCollapsibleSection",componentId:"sc-173ltko-0"})(["padding:",";"],(e=>e.theme.spacing.xlarge)),$c=u.default.div.withConfig({displayName:"DebugPrettyLogs__SectionContent",componentId:"sc-173ltko-1"})(["padding:",";white-space:pre-wrap;"],(e=>e.theme.spacing.xlarge)),Zc=u.default.div.withConfig({displayName:"DebugPrettyLogs__Inset",componentId:"sc-173ltko-2"})(["padding:",";background:",";border:1px solid ",";border-radius:",";margin-bottom:",";"],(e=>e.theme.spacing.default),(e=>
1e.theme.color.grayBackground),(e=>e.theme.color.grayFocus),(e=>e.theme.radius.medium),(e=>e.theme.spacing.large)),Jc=e=>{let t=e.logs;return a.createElement(a.Fragment,null,t.map(((e,t)=>{let n=e.event,l=e.data,r=e.timestamp;return a.createElement(Xc,{key:t,title:n,subtitle:N.c9.fromISO(r).toLocaleString({hour:"numeric",minute:"numeric",second:"numeric"})},a.createElement(Qc,null,a.createElement("code",null,JSON.stringify(l,null,2))))})))},Xc=(0,u.default)(Bc).withConfig({displayName:"DebugRawLogs__StyledCollapsibleSection",componentId:"onrl1e-0"})(["padding:",";"],(e=>e.theme.spacing.xlarge)),Qc=u.default.div.withConfig({displayName:"DebugRawLogs__SectionContent",componentId:"onrl1e-1"})(["padding:",";white-space:pre-wrap;"],(e=>e.theme.spacing.xlarge)),ed=e=>{let t=e.debugInfo,n=e.threadId,l=e.messageId;if(!t)return a.createElement(Rc.L,{"data-external-id":"assistant-message-debug-modal",title:"No logs available"});const r=((0,Tc.A)(t)?JSON.parse(t):t).logs,o=n||l?"AssistantMessage.threadId: ".concat(null!==n&&void 0!==n?n:"N/A"," AssistantMessage.id: ").concat(null!==l&&void 0!==l?l:"N/A"):void 0;return a.createElement(Dc.t,{"data-external-id":"assistant-message-debug-modal"},a.createElement(td,{title:"AI Debug Info",description:o,tabs:a.createElement(a.Fragment,null,a.createElement(Mc.t,{index:0},"Pretty logs"),a.createElement(Mc.t,{index:1},"Raw logs"))},a.createElement(_c.K,{index:0},a.createElement(Wc,{logs:r})),a.createElement(_c.K,{index:1},a.createElement(Jc,{logs:r}))))},td=(0,u.default)(Rc.L).withConfig({displayName:"AssistantMessageDebugModal__StyledModalCard",componentId:"q35dwq-0"})(["overflow:hidden;"]),nd=e=>Wa.includes(e),ad=["open"],ld=e=>{let t=e.open,n=(0,En.A)(e,ad);return a.createElement(fe.hg1.Root,{"data-external-id":"share-feedback-modal",open:t,onOpenChange:n.onOpenChange,size:"xl"},a.createElement(fe.hg1.Content,null,a.createElement(fe.hg1.CloseTrigger,null),a.createElement(fe.hg1.Header,null,a.createElement(fe.hg1.Title,null,Ka)),a.createElement(rd,n)))},rd=e=>{let t=e.onOpenChange,n=e.onSubmit,l=e.initialDetails,r=e.initialComments;const i=(0,a.useId)(),s=(0,a.useState)((()=>(null!==l&&void 0!==l?l:[]).filter(nd))),c=(0,o.A)(s,2),d=c[0],u=c[1],m=(0,a.useState)(null!==r&&void 0!==r?r:""),p=(0,o.A)(m,2),g=p[0],h=p[1],v=g.trim(),f=((e,t)=>{const n=t.trim().length>0;return!(e.includes(Va)&&!n)&&(e.length>0||n)})(d,g);return a.createElement(a.Fragment,null,a.createElement(fe.hg1.Body,{className:"flex flex-col gap-lg"},a.createElement("div",{className:"flex flex-col gap-sm"},a.createElement(fe.c8D,{id:i,size:"sm",weight:"medium"},qa," ",a.createElement(fe.c8D,{size:"sm",color:"secondary"},$a)),a.createElement("div",{role:"group","aria-labelledby":i,className:"flex flex-wrap gap-xs"},Wa.map((e=>a.createElement(fe.H7j,{key:e,size:"sm",rounded:"pill",pressed:d.includes(e),onPressedCh
1ange:()=>(e=>u((t=>t.includes(e)?t.filter((t=>t!==e)):[...t,e])))(e)},e))))),a.createElement(fe.RVf.Root,null,a.createElement(fe.RVf.Label,null,Za),a.createElement(fe.LYY,{minRows:3,maxRows:8,value:g,onChange:e=>h(e.target.value)}))),a.createElement(fe.hg1.Footer,{className:"gap-sm"},a.createElement(fe.hg1.Close,{render:a.createElement(fe.XZZ,null,Ja)}),a.createElement(fe.XZZ,{variant:"primary",disabled:!f,onClick:()=>{f&&(n({details:d,comments:v||void 0}),t(!1))}},Xa)))},od=["M2 11C2.55228 11 3 11.4477 3 12C3 12.5523 2.55228 13 2 13H1C0.447715 13 0 12.5523 0 12C0 11.4477 0.447715 11 1 11H2Z","M3.20703 3.29297C3.59756 2.90249 4.23059 2.90246 4.62109 3.29297L5.32812 4C5.71863 4.39051 5.7186 5.02353 5.32812 5.41406C4.9376 5.80459 4.30459 5.80459 3.91406 5.41406L3.20703 4.70703C2.81651 4.31651 2.81651 3.68349 3.20703 3.29297Z","M12 0C12.5523 4.67289e-08 13 0.447715 13 1V2C13 2.55228 12.5523 3 12 3C11.4477 3 11 2.55228 11 2V1C11 0.447715 11.4477 2.4141e-08 12 0Z","M19.5 3.29297C19.8905 2.90246 20.5235 2.90249 20.9141 3.29297C21.3046 3.68349 21.3046 4.31651 20.9141 4.70703L20.207 5.41406C19.8165 5.80459 19.1835 5.80459 18.793 5.41406C18.4025 5.02353 18.4025 4.39051 18.793 4L19.5 3.29297Z","M23 11C23.5523 11 24 11.4477 24 12C24 12.5523 23.5523 13 23 13H22C21.4477 13 21 12.5523 21 12C21 11.4477 21.4477 11 22 11H23Z"],id=220*(od.length+1),sd=e=>(e>id?e-id:e)/id,cd=od.map(((e,t)=>(e=>{const t=220*e,n=t+660,a=n>id?1:0;return[{offset:0,opacity:a},...[{offset:sd(t),opacity:0},{offset:sd(t+140),opacity:1},{offset:sd(n-140),opacity:1},{offset:sd(n),opacity:0}].sort(((e,t)=>e.offset-t.offset)),{offset:1,opacity:a}].filter(((e,t,n)=>0===t||e.offset>n[t-1].offset))})(t))),dd="(prefers-reduced-motion: reduce)",ud=()=>{const e=(0,a.useState)((()=>{var e,t;return"undefined"!==typeof window&&Boolean(null===(e=(t=window).matchMedia)||void 0===e?void 0:e.call(t,dd).matches)})),t=(0,o.A)(e,2),n=t[0],l=t[1];return(0,a.useEffect)((()=>{if("undefined"===typeof window||!window.matchMedia)return;const e=window.matchMedia(dd),t=()=>l(e.matches);return t(),e.addEventListener("change",t),()=>e.removeEventListener("change",t)}),[]),n},md=e=>{let t=e.className;const n=ud();return a.createElement("svg",{"data-external-id":"thinking-lightbulb","aria-hidden":!0,"data-testid":"thinking-lightbulb",viewBox:"0 0 24 24",width:16,height:16,fill:"currentColor",className:(0,q.cn)("shrink-0 text-content-secondary",t)},a.createElement("path",{d:"M12 5C16.0807 5 19.3886 8.308 19.3887 12.3887C19.3887 15.2029 17.815 17.6488 15.5 18.8965V21C15.5 22.6569 14.1569 24 12.5 24H11.5C9.84315 24 8.5 22.6569 8.5 21V18.8965C6.18499 17.6488 4.61133 15.2029 4.61133 12.3887C4.61145 8.308 7.9193 5 12 5ZM10.5 20V21C10.5 21.5523 10.9477 22 11.5 22H12.5C13.0523 22 13.5 21.5523 13.5 21V20H10.5ZM12 7C9.02395 7 6.61144 9.41249 6.61133 12.3887C6.61133 14.438 7.75531 16.2228 9.44922 17.1357C9.81744 17.3342 10.1061 17.639 10.2871 18H13.7129C13.8939 17.639 14.1826 17.3342 14.5508 17.1357C16.2447 16.2228 17.3887 14.438 17.3887 12.3887C17.3886 9.41249 14.9761 7 12 7Z"}),od.map(((e,t)=>a.createElement("path",{key:e,d:e,opacity:n?1:0},!n&&a.createElement("animate",{attributeName:"opacity",values:cd[t].map((e=>e.opacity)).join(";"),keyTimes:cd[t].map((e=>e.offset)).join(";"),dur:"".concat(id,"ms"),repeatCount:"indefinite"})))))};var pd=n(31160);const gd=e=>{const t=(0,a.useCallback)((e=>((0,pd.H)(e),()=>(0,pd.H)(null))),[]);(e=>{let t=e.isLoading,n=e.hasAssistantMessages,l=e.stepCount,r=e.threadId,o=e.messageId,i=e.track,s=e.onReasoningStateChange;const c=(0,a.useRef)(t).current,d=(0,a.useRef)(!1),u=(0,a.useRef)(!1),m=(0,a.useRef)(c?Date.now():null),p=(0,a.useRef)(void 0);(0,a.useEffect)((()=>{c&&r&&!d.current&&(d.current=!0,i(Ye.xb.ReasoningSummaryViewed,{thread_id:r}))}),[c,r,i]),(0,a.useEffect)((()=>{if(c&&!t&&r&&!u.current){u.current=!0;const e=m.current?Date.now()-m.current:void 0;i(Ye.xb.ReasoningSummaryCompleted,{message_id:o,thread_id:r,step_count:l,duration_ms:e})}}),[t,o,r,l,c,i]),(0,a.useEffect)((()=>{var e;if(c)return n&&!p.current&&(p.current=Date.now()),s({reasoningComplete:n,reasoningStartedAt:null!==(e=m.current)&&void 0!==e?e:void 0,reasoningCompletedAt:p.current,answerComplete:!t,stepCount:l,messageId:o})}),[t,n,l,o,c,s])})((0,U.A)((0,U.A)({},e),{},{track:Ge.u4,onReasoningStateChange:t}))},hd={id:"status-done",content:Re.THINKING_DONE_STEP,contentSubtext:null},vd=["content.primary","content.secondary"],fd=e=>{let t=e.completedMessages,n=e.activeMessage,l=e.isLoading,r=e.hasAssistantMessages,i=e.threadId,s=e.messageId,c=e.defaultOpen,d=void 0!==c&&c,u=e.className;const m=(0,a.useState)(d),p=(0,o.A)(m,2),g=p[0],h=p[1],v=t.length+1,f=l?[...t.map((e=>({message:e,isActive:!1}))),{message:n,isActive:!0}]:[...[...t,n].map((e=>({message:e,isActive:!1}))),{message:hd,isActive:!1}];return gd({isLoading:l,hasAssistantMessages:null!==r&&void 0!==r&&r,stepCount:v,threadId:i,messageId:s}),a.createElement("div",{"data-external-id":"status-accordion",className:(0,q.cn)("my-xs flex px-xl",u)},a.createElement(fe.X0s,{open:g,onOpenChange:h,className:"w-full"},a.createElement(fe.X0s.Trigger,{className:"w-full justify-start gap-xs"},l?a.createElement(md,null):a.createElement(fe.nRr,{size:"md",className:"shrink-0 text-content-secondary"}),a.createElement("div",{className:"min-w-0 shrink text-left"},l?a.createElement(wi,{colors:vd},a.createElement(fe.c8D,{size:"sm"}
1,n.content)):a.createElement(fe.c8D,{size:"sm",weight:"medium",className:"truncate"},Re.THINKING_DONE_SUMMARY)),a.createElement(fe.D39,{size:"xs","data-testid":"status-accordion-chevron",className:(0,q.cn)("shrink-0 text-content-secondary transition-transform",g&&"rotate-180")})),a.createElement(fe.X0s.Content,null,a.createElement("div",{className:"mt-sm rounded-lg border border-border-primary p-sm"},a.createElement(fe.S5l.Root,{size:"md",variant:"plain",className:"[&_[data-mds=timeline-item]:last-child_[data-mds=timeline-content]]:pb-0"},f.map((e=>{let t=e.message,n=e.isActive;return a.createElement(fe.S5l.Item,{key:t.id},a.createElement(fe.S5l.Connector,{className:"w-4"},a.createElement(fe.S5l.Indicator,{className:(0,q.cn)("mt-xs size-1.5",n?"animate-thinking-pulse bg-content-primary motion-reduce:animate-none":"bg-content-secondary")}),a.createElement(fe.S5l.Separator,{className:"mt-0 -mb-xs"})),a.createElement(fe.S5l.Content,null,n?a.createElement(fe.S5l.Title,{className:"flex items-baseline"},a.createElement(wi,{colors:vd},t.content),a.createElement(Ed,null)):a.createElement(fe.S5l.Title,{color:"secondary"},t.content),t.contentSubtext?a.createElement(fe.S5l.Description,null,t.contentSubtext):null))})))))))},Ed=()=>a.createElement("span",{"data-external-id":"animated-ellipsis","aria-hidden":!0,className:"inline-block animate-thinking-ellipsis motion-reduce:animate-none"},"...");var yd=n(64065),bd=n(34960);const xd=e=>{const t=N.c9.local(),n=t.startOf("day"),a=t.minus({days:7}).startOf("day"),l=t.minus({days:30}).startOf("day"),r=e.reduce(((e,t)=>{var r;const o=N.c9.fromISO(null!==(r=t.lastMessageSentAt)&&void 0!==r?r:t.createdAt);return o>=n?(0,U.A)((0,U.A)({},e),{},{Today:e.Today.concat(t)}):o>=a?(0,U.A)((0,U.A)({},e),{},{"Past week":e["Past week"].concat(t)}):o>=l?(0,U.A)((0,U.A)({},e),{},{"Past month":e["Past month"].concat(t)}):(0,U.A)((0,U.A)({},e),{},{"Over a month ago":e["Over a month ago"].concat(t)})}),{Today:[],"Past week":[],"Past month":[],"Over a month ago":[]});return["Today","Past week","Past month","Over a month ago"].filter((e=>r[e].length>0)).map((e=>({category:e,threads:r[e]})))},wd=(e,t)=>{var n,a;if(!(null===e||void 0===e?void 0:e.length))return;const l=e.filter((e=>!!e&&e!==bd.u));if(1!==l.length)return;const r=t.find((e=>e.id===l[0]));return null!==(a=null!==(n=null===r||void 0===r?void 0:r.displayName)&&void 0!==n?n:null===r||void 0===r?void 0:r.name)&&void 0!==a?a:void 0},Cd=e=>"UserMessage"===(null===e||void 0===e?void 0:e.__typename),Ad=e=>"AssistantMessage"===(null===e||void 0===e?void 0:e.__typename),Id=e=>"AssistantStatusMessage"===(null===e||void 0===e?void 0:e.__typename),kd=e=>Ad(e[0])||Id(e[0]),Sd=e=>Cd(e[0]),Nd=e=>{const t=(0,yd.A)(Cd,e),n=(null===t||void 0===t?void 0:t.createdAt)?Date.now()-new Date(t.createdAt).getTime():void 0;return null!==n&&void 0!==n&&n>=0?n:void 0};var Td=n(74505),_d=n.n(Td);const Dd=[Vn.type,Wn.type,jn.type],Rd=e=>e.map((e=>e.map((e=>e.replace(/\s*[\t\r\n]+\s*/g," ").trim())).join("\t"))).join("\n"),Md=e=>{let t=e.chartData,n=e.columns;return t.length?Rd([["",...n.map((e=>e.label))],...t.map((e=>[e.label,...e.values.map(((e,t)=>{var a;return((e,t)=>void 0===e?"":"currency"===t?(0,jt.vv)(Math.abs(e)):"".concat(e))(e,null===(a=n[t])||void 0===a?void 0:a.valueType)}))]))]):""},Ld=e=>{let t=e.type,n=e.data;return t===Ln.type?(a=n.content,_d()(a,{stripListLeaders:!1,useImgAltText:!0})).trim():t===Jn.type?(e=>{let t=e.headers,n=e.rows;return t.length?Rd([t,...n.map((e=>e.map((e=>e.value))))]):""})(n):Dd.includes(t)?Md(n):"";var a};var Od=n(6179),Pd=n(81862),Bd=n(87187);const zd=e=>{var t,n;let l=e.messages,r=e.nextGroup,s=e.demo,c=e.className,u=e.children;const m=(0,d.d4)(ft.MJ),p=l.filter(Id),g=(0,Sc.A)(p),h=p.slice(0,-1),v=(e=>{const t=e.filter(Ad),n=(0,Sc.A)(t),l=!t.length||t.some((e=>e.assistantResponseState===Ee.duP.LOADING)),r=(null===n||void 0===n?void 0:n.assistantResponseState)===Ee.duP.CANCELLED,i=(0,a.useState)(!1),s=(0,o.A)(i,2),c=s[0],d=s[1];(0,a.useEffect)((()=>{t.some((e=>e.assistantResponseState===Ee.duP.LOADING))&&d(!0)}),[t]);const u=(0,a.useState)(!l),m=(0,o.A)(u,2),p=m[0],g=m[1];(0,a.useEffect)((()=>{l?g(!1):!r&&c||g(!0)}),[l,r,c]);const h=(0,a.useCallback)((()=>{g(!0)}),[]);return{isLoading:l||!p,onAnimationComplete:h,isGenerating:l,assistantMessages:t,lastAssistantMessage:n,isLastMessageCancelled:r}})(l),f=v.isLoading,E=v.onAnimationComplete,y=v.assistantMessages,b=v.lastAssistantMessage,x=v.isLastMessageCancelled,w=(0,et.I)(Qe.uG,{variables:{threadId:null!==(t=null===b||void 0===b?void 0:b.threadId)&&void 0!==t?t:""},skip:!(null!==b&&void 0!==b&&b.threadId)}).data,A=(0,a.useMemo)((()=>{var e,t;const n=null!==(e=null===w||void 0===w||null===(t=w.assistantFeedbackByThread)||void 0===t?void 0:t.filter((e=>(null===e||void 0===e?void 0:e.messageId)===(null===b||void 0===b?void 0:b.id)&&(null===e||void 0===e?void 0:e.createdAt))))&&void 0!==e?e:[],a=(0,Nc.A)((e=>
1new Date(e.createdAt).getTime()))(n);return(0,Sc.A)(a)}),[w,b]),I=(0,a.useMemo)((()=>{var e,t,n,a;return{feedbackType:null!==(e=null===A||void 0===A?void 0:A.feedbackType)&&void 0!==e?e:null,details:null!==(t=null===A||void 0===A||null===(n=A.details)||void 0===n?void 0:n.filter((e=>!!e)))&&void 0!==t?t:[],comments:null!==(a=null===A||void 0===A?void 0:A.comments)&&void 0!==a?a:void 0}}),[A]),k=(0,Pd.h)(),S=(0,o.A)(k,2),N=S[0],T=S[1].open,_=(0,a.useState)(!1),D=(0,o.A)(_,2),R=D[0],M=D[1],L=(0,d.d4)(Od.$Y),O=(0,C.RU)(),P=(0,i.n)(Qe.XH,{refetchQueries:[Qe.uG]}),B=(0,o.A)(P,1)[0],z=(0,a.useCallback)((async(e,t)=>{var n;let a=t.feedbackType,l=t.details,r=t.comments;if(!a)return!0;const o=(await B({variables:{input:{feedbackType:a,messageId:e,details:l,comments:r}}})).data;return!(null===o||void 0===o||null===(n=o.submitAssistantFeedback)||void 0===n||!n.success)}),[B]),F=(0,a.useCallback)((()=>O({description:Qa})),[O]),G=(e=>{let t=e.messageId,n=e.serverFeedback,l=e.persist,r=e.onError;const i=(0,a.useState)(null),s=(0,o.A)(i,2),c=s[0],d=s[1],u=(0,a.useRef)(0);(0,a.useEffect)((()=>{d(null),u.current+=1}),[t]);const m=null!==c&&void 0!==c?c:n,p=(0,a.useCallback)((async e=>{if(!t)return;const n=m;u.current+=1;const a=u.current;d(e);let o=!1;try{o=await l(t,e)}catch(i){o=!1}o||a!==u.current||(d(n),r())}),[m,t,r,l]);return{feedback:m,submit:p}})({messageId:null===b||void 0===b?void 0:b.id,serverFeedback:I,persist:z,onError:F}),Y=G.feedback,U=G.submit,V=Y.feedbackType,W=(0,a.useMemo)((()=>({onAnimationComplete:E})),[E]),j=(0,a.useMemo)((()=>Oi(l.filter(Ad)).map(Ld).filter(Boolean).join("\n\n")),[l]),H=(0,a.useState)(!1),K=(0,o.A)(H,2),q=K[0],$=K[1];(0,a.useEffect)((()=>{if(!q)return;const e=setTimeout((()=>$(!1)),2e3);return()=>clearTimeout(e)}),[q]);const Z=[...j?[{icon:q?"check":"copy",onClick:async()=>{try{await(0,Bd.l)(j),$(!0),(0,Ge.u4)(Ye.xb.AssistantResponseCopied)}catch(e){O({description:al})}},label:q?nl:tl,tooltip:q?nl:el}]:[],{icon:V===Ua.Positive?"thumbs-up-filled":"thumbs-up",onClick:()=>{V!==Ua.Positive&&U({feedbackType:Ua.Positive,details:[]})},label:V===Ua.Positive?"Positive feedback given":"Give positive feedback",tooltip:ja},{icon:V===Ua.Negative?"thumbs-down-filled":"thumbs-down",onClick:()=>{V!==Ua.Negative&&U({feedbackType:Ua.Negative,details:[]}),M(!0)},label:V===Ua.Negative?"Negative feedback given":"Give negative feedback",tooltip:Ha},...L?[{icon:"info",onClick:T,label:"View debug information"}]:[]],J=y.length>0&&!x,X=y.length>0,Q=g&&!x?a.createElement(fd,{completedMessages:h,activeMessage:g,isLoading:f,hasAssistantMessages:y.length>0,threadId:null!==m&&void 0!==m?m:void 0,messageId:null===b||void 0===b?void 0:b.id}):null,ee=X?a.createElement(ki.Provider,{value:W},a.createElement(Ki,{messages:y.map((e=>({content:e.content,__typename:e.__typename,id:e.id,assistantResponseState:e.assistantResponseState}))),nextGroup:r,demo:s,actions:J?Z:void 0,className:c},u)):null;return a.createElement(a.Fragment,null,Q,ee,a.createElement(ld,{open:R,onOpenChange:M,onSubmit:e=>{let t=e.details,n=e.comments;U({feedbackType:Ua.Negative,details:t,comments:n})},initialDetails:Y.details,initialComments:Y.comments}),a.createElement(N,{large:!0},b&&a.createElement(ed,{debugInfo:null!==(n=b.debugInfo)&&void 0!==n?n:null,threadId:b.threadId,messageId:b.id})))},Fd=e=>a.createElement(Ki,Object.assign({"data-external-id":"user-message-list-group"},e)),Gd=aa((e=>{let t=e.messages,n=e.nextGroup,l=e.demo,o=e.className,i=e.children;return(0,r.YW)(t).when(kd,(e=>a.createElement(zd,{messages:e,nextGroup:n,demo:l,className:o},i))).when(Sd,(e=>a.createElement(Fd,{messages:e,nextGroup:n,demo:l,className:o},i))).otherwise((()=>null))}),kc());var Yd=n(24258);var Ud=n(30987),Vd=n(57161),Wd=n(92191),jd=n(96725),Hd=n(69469);var Kd,qd=n(34527),$d=n(4424);const Zd=e=>{let t=e.messages,n=e.header,l=e.footer,r=e.demo,i=e.className,s=e.isAnimationComplete,c=e.overlayColor,u=e.hideLeadingTimestamp,m=void 0!==u&&u,p=e.scrollAnchor,h=void 0===p?"latest-turn":p;const v=(0,d.Pj)(),f=(0,a.useRef)(null),E=(0,a.useRef)(null),y=(0,qd.W)(),b=(0,o.A)(y,2),x=b[0],w=b[1],C=(0,a.useRef)(!1),A=(0,a.useState)(!1),I=(0,o.A)(A,2),k=I[0],S=I[1],T=(0,a.useState)(!1),_=(0,o.A)(T,2),D=_[0],R=_[1],M=(0,a.useState)(0),L=(0,o.A)(M,2),O=L[0],P=L[1],B=(0,a.useRef)(null),z=(0,a.useRef)(null),F=(0,a.useState)(!1),G=(0,o.A)(F,2),Y=G[0],U=G[1],V=(0,a.useCallback)((e=>{e instanceof HTMLElement&&(x(e),E.current=e)}),[x]),W=(e=>{let t=e.scrollerElementRef,n=e.isAnimationComplete;const l=(0,d.wA)(),r=(0,a.useRef)(null),i=(0,a.useRef)(new Set),s=(0,a.useRef)(new Map),c=(0,a.useRef)(null),u=(0,a.useRef)(null),m=(0,a.useState)(!1),p=(0,o.A)(m,2),h=p[0],v=p[1],f=(0,a.useMemo)((()=>(0,_r.debounce)((e=>l((0,g.Ce)({scrollIndex:e}))),150,{trailing:!0})),[l]);(0,a.useEffect)((()=>()=>f.cancel()),[f]),(0,a.useEffect)((()=>{const e=t.current;if(!e)return;r.current&&(r.current.disconnect(),i.current.clear());const n=new IntersectionObserver((e=>{e.forEach((e=>{const t=Number(e.target.getAttribute("data-index"));if(e.isIntersecting){var n,a;const l=e.intersectionRect.height/(null!==(n=null===(a=e.rootBounds)||void 0===a?void 0:a.height)&&void 0!==n?n:1);e.intersectionRatio>=.5||l>=.8?i.current.add(t):i.current.delete(t)}else i.current.delete(t)}));const t=Array.from(i.current).sort(((e,t)=>e-t)),n=(0,o.A)(t,1)[0],a=n!==c.current;h&&void 0!==n&&a&&(c.current=n,f(n))}),{root:e,threshold:[0,.5,.75,1]});return r.current=n,s.current.forEach((e=>{n.observe(e)})),()=>{n.disconnect()}}),[h,f,t]);const E=(0,a.useCallback)(((e,t)=>{const n=s.current.get(e);n&&r.current&&r.current.unobserve(n),t?(s.current.set(e,t),r.current&&r.current.observe(t)):(s.current.delete(e),i.current.delete(e))}),[]);return(0,a.useEffect)((()=>
1{if(n)return u.current=setTimeout((()=>{v(!0)}),300),()=>{u.current&&clearTimeout(u.current)}}),[n]),{registerElement:E}})({scrollerElementRef:E,isAnimationComplete:s}),j=W.registerElement,H=(0,a.useMemo)((()=>(e=>e.reduce(((e,t)=>{const n=(0,Sc.A)(e);return n&&((e,t)=>{var n,a;return"UserMessage"!==e.__typename&&"UserMessage"!==t.__typename||e.__typename===t.__typename&&(null===(n=e.user)||void 0===n?void 0:n.id)===(null===(a=t.user)||void 0===a?void 0:a.id)})(n[0],t)?(0,Ud.A)([...n,t],(0,Vd.A)(e)):[...e,[t]]}),[]))(t)),[t]),K="leading-header"===h,q=K&&($=(e=>e.filter((e=>{var t;return"UserMessage"===(null===(t=e[0])||void 0===t?void 0:t.__typename)})).length)(H),$<2);var $;const Z=K&&!q,J=(0,o.A)(t,1)[0],X=J&&!m?(e=>{const t=N.c9.fromISO(e),n=N.c9.local(),a=t.year===n.year?"cccc, LLL d, h:mm":"cccc, LLL d, yyyy, h:mm",l=t.toFormat("a").toLowerCase();return"".concat(t.toFormat(a)).concat(l)})(J.createdAt):null,Q=(0,a.useMemo)((()=>{const e=(0,Cc.A)(Sd,H);if(-1!==e){const t=H.slice(0,e),n=H.slice(e),a=!q&&D&&O>0?O:void 0,l=t.map(((e,a)=>{var l;return{type:"group",group:e,nextGroup:null!==(l=t[a+1])&&void 0!==l?l:n[0]}}));return l.push({type:"footer",groups:n,minHeight:a}),l}return H.map(((e,t)=>({type:"group",group:e,nextGroup:H[t+1]})))}),[O,H,q,D]),ee=(0,a.useMemo)((()=>{if(q)return;if(K)return{index:"LAST",align:"end"};const e=(0,ft.GK)(v.getState()),t=e===Q.length-1;return null===e||t?{index:"LAST",align:"end"}:e}),[q,K,v,Q.length]),te=(0,a.useMemo)((()=>(e,t)=>{const n=0===e&&X&&a.createElement(eu,null,X);return"footer"===t.type?a.createElement(iu,{$minHeight:t.minHeight,ref:t=>j(e,t),"data-index":e},n,t.groups.map(((e,n)=>a.createElement(nu,{key:"".concat(e[0].__typename,"-").concat(e[0].id),messages:e,nextGroup:t.groups[n+1],demo:r}))),l,a.createElement(tu,null)):a.createElement("div",{"data-index":e,ref:t=>j(e,t)},n,a.createElement(nu,{messages:t.group,nextGroup:t.nextGroup,demo:r,key:t.group[0].id}))}),[r,X,l,j]);(0,a.useEffect)((()=>{w.height&&P(w.height)}),[w.height]);const ne=(0,a.useMemo)((()=>Q.find((e=>"footer"===e.type))),[Q]);(0,a.useEffect)((()=>{if(q||!ne||"footer"!==ne.type)return;const e=(0,o.A)(ne.groups,1)[0];if(!e)return;const t=e.find((e=>Cd(e)&&(0,Hd.Z)(e.id)));t&&t.id!==B.current&&(R(!0),B.current=t.id)}),[ne,q]),(0,a.useEffect)((()=>{if(!ne||"footer"!==ne.type)return;const e=(0,o.A)(ne.groups,1)[0];if(!e)return;const t=e.find((e=>(0,Hd.Z)(e.id)));t&&ne.minHeight&&t.id!==z.current&&(z.current=t.id,requestAnimationFrame((()=>{var e;null===(e=f.current)||void 0===e||e.scrollToIndex({index:"LAST",align:"start",behavior:"smooth"})})))}),[ne]);const ae=(0,a.useCallback)((e=>{S(!e)}),[]),le=(0,a.useCallback)((()=>{var e;null===(e=f.current)||void 0===e||e.scrollToIndex({index:"LAST",align:"end",behavior:"smooth"})}),[]),re=(0,a.useMemo)((()=>(0,_r.debounce)((()=>requestAnimationFrame((()=>{if(f.current&&!C.current){if(q)return f.current.scrollTo({top:0}),0===Q.length||(C.current=!0),void U(!0);if(0!==Q.length){if(C.current=!0,K)f.current.scrollToIndex({index:"LAST",align:"end"});else{const e=(0,ft.GK)(v.getState()),t=e===Q.length-1;null===e||t?f.current.scrollToIndex({index:"LAST",align:"end"}):f.current.scrollToIndex({index:e,align:"start"})}U(!0)}}}))),50,{trailing:!0})),[q,f,K,v,Q.length]);(0,a.useEffect)((()=>()=>re.cancel()),[re]),(0,a.useEffect)((()=>{s&&re()}),[s,re]);const oe=t.length>0,ie=oe||void 0!==n,se=ie&&(Y||!oe),ce=(0,a.useMemo)((()=>({header:n})),[n]);return a.createElement(a.Fragment,null,!ie&&a.createElement(Qd,null,a.createElement($i,null)),a.createElement(Xd,Object.assign({$hideScrollbar:!s,$isVisible:se,ref:f,scrollerRef:V,followOutput:Z,atBottomThreshold:50,atBottomStateChange:ae,itemsRendered:Y?void 0:re,components:Jd,context:ce,itemContent:te,rangeChanged:Y?void 0:re,data:Q,increaseViewportBy:{bottom:1e3,top:0},className:i},void 0!==ee?{initialTopMostItemIndex:ee}:{})),a.createElement(au,null,a.createElement(lu,{$visible:k,$overlayColor:c}),a.createElement(ru,{$visible:k,onClick:le,"aria-label":"Scroll to bottom"},a.createElement(ou,null))))},Jd={Header:e=>{let t=e.context;return a.createElement(a.Fragment,null,null===t||void 0===t?void 0:t.header)}},Xd=(0,u.default)(Ac.aY).withConfig({displayName:"MessagesList__StyledVirtuoso",componentId:"sc-1t47xhe-0"})(["flex:1;
1opacity:",";transition:opacity 0.2s ease-in-out;"," &[data-virtuoso-scroller='true'] > * > *{max-width:","px;margin:0 auto;}"],(e=>e.$isVisible?1:0),(e=>e.$hideScrollbar&&"\n    &::-webkit-scrollbar {\n      width: 0;\n      background: transparent;\n    }\n  "),Yd.aA),Qd=u.default.div.withConfig({displayName:"MessagesList__LoadingContainer",componentId:"sc-1t47xhe-1"})(["max-width:","px;margin:0 auto;"],Yd.aA),eu=(0,u.default)(xt.v).attrs({size:"xsmall",color:"content.secondary"}).withConfig({displayName:"MessagesList__Timestamp",componentId:"sc-1t47xhe-2"})(["display:block;text-align:center;margin-top:",";"],vt.YK.default),tu=u.default.div.withConfig({displayName:"MessagesList__FooterSpacer",componentId:"sc-1t47xhe-3"})(["height:","px;"],16),nu=(0,u.default)(Gd).withConfig({displayName:"MessagesList__StyledMessageListGroup",componentId:"sc-1t47xhe-4"})(["padding-top:",";"],vt.YK.small),au=$d.s.div(Kd||(Kd=(0,wc.A)(["relative"]))),lu=u.default.div.withConfig({displayName:"MessagesList__FadeOverlay",componentId:"sc-1t47xhe-5"})(["position:absolute;bottom:0;left:0;right:0;height:","px;background:linear-gradient(to bottom,transparent,",");pointer-events:none;transition:",";opacity:",";"],60,(e=>e.$overlayColor),(e=>e.theme.transition.createFastTransitions(["opacity"])),(e=>e.$visible?1:0)),ru=u.default.button.withConfig({displayName:"MessagesList__FloatingScrollArrow",componentId:"sc-1t47xhe-6"})(["position:absolute;bottom:",";left:50%;transform:translateX(-50%);width:","px;height:","px;background-color:",";border:1px solid ",";border-radius:",";display:flex;align-items:center;justify-content:center;cursor:pointer;box-shadow:0 2px 8px ",";transition:opacity 0.2s ease-in-out,transform 0.2s ease-in-out;opacity:",";pointer-events:",";&:hover{background-color:",";}",""],vt.YK.default,36,36,vt.Ee.color.background.primary,vt.Ee.color.border.primary,vt.r8.round,vt.Ee.color.shadow.medium,(e=>e.$visible?1:0),(e=>e.$visible?"auto":"none"),vt.Ee.color.background.secondary,(e=>!e.$visible&&(0,u.css)(["transform:translateX(-50%) translateY(10px);"]))),ou=(0,u.default)(sl.ZQ).attrs({name:"arrow-down",size:16}).withConfig({displayName:"MessagesList__ScrollArrowIcon",componentId:"sc-1t47xhe-7"})(["color:",";"],vt.Ee.color.content.primary),iu=u.default.div.withConfig({displayName:"MessagesList__FooterRoot",componentId:"sc-1t47xhe-8"})(["min-height:",";"],(e=>{let t=e.$minHeight;return t?"".concat(t,"px"):void 0}));var su=n(43979),cu=n(59309),du=n(23670);const uu=e=>{let t=e.onConfirm;const n=(0,i.n)(du.Ii),l=(0,o.A)(n,2),r=l[0],s=l[1].loading,c=(0,d.d4)(A._S),u=(0,a.useCallback)((async()=>{await r({variables:{updateProfileInput:{aiAssistantOptedIn:!0},updateMeInput:{}}}),null===t||void 0===t||t()}),[r,t]);return a.createElement(mu,{"data-external-id":"persistent-assistant-opt-in-modal",column:!0,gap:"xxlarge",justifyCenter:!0,$isExpanded:c},!c&&a.createElement("div",{className:"flex items-center justify-center gap-xs"},a.createElement(fe.bQo,{size:"md",className:"text-content-brand"}),a.createElement(xt.v,{weight:"medium",color:"content.brand"},"AI Assistant")),a.createElement("div",{className:"flex flex-col justify-center gap-default"},_t.zA.PERSISTENT_OPT_IN.BULLET_POINTS.map(((e,t)=>a.createElement("div",{key:t,className:"flex flex-col gap-3xs"},a.createElement(xt.v,{weight:"medium",align:"center",size:c?"20":"base"},e.title),a.createElement(xt.v,{size:c?"base":"small",color:"content.secondary",align:"center"},a.createElement(Ll.o,{source:e.description,className:"[&_a]:text-inherit [&_a]:underline"})))))),a.createElement(pu,{$isExpanded:c},a.createElement(gu,{onClick:u,pending:s,size:"large"},_t.zA.PERSISTENT_OPT_IN.BUTTON_TEXT),a.createElement(xt.v,{size:"xsmall",color:"content.secondary",align:"center"},a.createElement(Ll.o,{source:_t.zA.PERSISTENT_OPT_IN.PRIVACY_DISCLAIMER,className:"[&_a]:text-inherit [&_a]:underline"}))))},mu=(0,u.default)(m.g).withConfig({displayName:"PersistentAssistantOptInModal__Card",componentId:"sc-1s5xunt-0"})(["background:transparent;max-width:",";margin:0 auto;min-height:min-content;padding:"," 0;"],(e=>e.$isExpanded?"385px":"354px"),vt.YK.default),pu=(0,u.default)(m.g).attrs({column:!0,gap:"default"}).withConfig({displayName:"PersistentAssistantOptInModal__ButtonSection",componentId:"sc-1s5xunt-1"})(["margin-top:",";padding-bottom:",";"],(e=>{let t=e.$isExpanded,n=e.theme;return t?"0":n.spacing.xxxxlarge}),(e=>{let t=e.$isExpanded,n=e.theme;return t?"0":n.spacing.xxlarge})),gu=(0,u.default)(su.U).withConfig({displayName:"PersistentAssistantOptInModal__ConfirmButton",componentId:"sc-1s5xunt-2"})(["width:100%;",";"],cu.vc);var hu=n(35654),vu=n(82194),fu=n(42584),Eu=n(60818),yu=n(28274),bu=n(43503);const xu=(0,u.default)(Eu.lV).withConfig({displayName:"PersistentAssistantPrompt__StyledForm",componentId:"sc-1jpud3w-0"})(["width:100%;"]),wu=(0,u.default)(vu.Q).withConfig({displayName:"PersistentAssistantPrompt__StyledTextAreaField",componentId:"sc-1jpud3w-1"})(["flex:1;width:100%;&:not(:last-child){margin-bottom:0;}textarea{box-sizing:border-box;min-height:",";line-height:26px;max-height:182px;padding-top:",";padding-right:",";padding-bottom:",";padding-left:",";background-color:",";border:1px solid ",";border-radius:",";resize:none;}"],(e=>{let t=e.$hasBanner;return"".concat(t?104:52,"px")}),(e=>{let t=e.$hasBanner,n=e.theme;return t?"".concat(62,"px"):n.spacing.small}),vt.YK.xxxlarge,vt.YK.small,vt.YK.default,vt.Ee.color.input.default.background,vt.Ee.color.input.default.border,vt.r8.large),Cu=(0,u.css)(["border-radius:",";padding:6px;flex-shrink:0;position:absolute;right:",";bottom:",";width:28px;height:28px;"],vt.r8.default,vt.YK.small,vt.YK.small),Au=(0,u.default)(B.L).withConfig({displayName:"PersistentAssistantPrompt__StyledIconButton",componentId:"sc-1jpud3w-2"})([""," background-color:",";color:",";&::before{display:none;}&:disabled{background-color:",";color:",";}&:hover:not(:disabled){background-color:",";color:",";}"],Cu,vt.Ee.color.background.brand,vt.Ee.color.content.white,vt.Ee.color.background.secondary,vt.Ee.color.content.secondary,vt.Ee.color.background.brandHover,vt.Ee.color.content.white),Iu=u.default.button.attrs({type:"button"}).withConfig({displayName:"PersistentAssistantPrompt__CancelButton",componentId:"sc-1jpud3w-3"})([""," background-color:",";border:none;cursor:pointer;display:flex;align-items:center;justify-content:center;"],Cu,vt.Ee.color.background.secondary),ku=(0,u.default)(fu.g).withConfig({displayName:"PersistentAssistantPrompt__InputBanner",componentId:"sc-1jpud3w-4"})(["position:absolute;top:0;left:0;right:0;border-radius:",";padding:",";margin:",";"],vt.r8.default,vt.YK.xsmall,vt.YK.small),Su=e=>{let t=e.sendMessage,n=e.hasOutstandingAssistantRequests,l=e.placeholder,i=void 0===l?"Ask anything about your money...":l,s=e.autoFocus,c=void 0!==s&&s,u=e.promptRef,m=e.promptValueRef,p=e.isLoading,g=e.isLastMessageStreaming,h=e.onCancelResponse,v=e.canCancelResponse,f=e.retryLastErroredMessage;const E=(0,C.RU)(),y=(0,yu.X)(t),b=(0,d.d4)(A.MJ),x=(0,F.K)(),w=(0,a.useState)(m.current),I=(0,o.A)(w,2),k=I[0],S=I[1],N=(0,a.useState)(!1),T=(0,o.A)(N,2),_=T[0],D=T[1],R=!!f,M=x||_||R,L=(0,a.useMemo)((()=>p||n||g),[p,n,g]),O=L&&!p&&v,P=(0,a.useRef)(x),B=(0,a.useCallback)((e=>{S(e),m.current=e}),[m]),z=(0,a.useCallback)((async(e,t)=>{let n=t.resetForm;if(!L&&!x){D(!1);try{var a;S(""),m.current="",n(),await y({content:e.prompt,fromRecommendedPrompt:!1,triggerSource:Ee.y3I.ASSISTANT}),null===u||void 0===u||null===(a=u.current)||void 0===a||a.focus()}catch(l){E({description:"Failed to send message"})}}}),[y,u,m,L,x,E]);return(0,a.useEffect)((()=>{const e=!1===P.current&&!0===x,t=!0===P.current&&!1===x;e&&(0,Ge.u4)(Ye.xb.AssistantRateLimitShown),R?D(!1):t&&D(!0),P.current=x}),[x,R]),(0,bu.w)((()=>{S(""),D(!1)}),[b]),a.createElement("div",{"data-external-id":"persistent-assistant-prompt",className:"flex flex-col items-center gap-sm"},a.createElement(xu,{key:null!==b&&void 0!==b?b:"new-thread",initialValues:{prompt:k},enableReinitialize:!0,onSubmit:p?()=>{}:z},a.createElement(hu.c.Consumer,null,(e=>{let t=e.values,n=e.isSubmitting,l=e.submitForm;return a.createElement("div",{className:"relative flex items-center gap-sm"},(0,r.YW)({isRateLimited:x,hasError:R,showSuccessBanner:_}).with({isRateLimited:!0},(()=>a.createElement(ku,{type:"error"},a.createElement("div",{className:"flex items-center gap-xs"},a.createElement(sl.ZQ,{name:"alert-triangle",size:16}),a.createElement(xt.v,{size:"small"},_t.zA.RATE_LIMIT_MESSAGE))))).with({hasError:!0},(()=>a.createElement(ku,{type:"warning"},a.createElement("div",{className:"flex items-center justify-between gap-xs"},a.createElement("div",{className:"flex items-center gap-xs"},a.createElement(sl.ZQ,{name:"alert-triangle",size:16}),a.createElement(xt.v,{size:"small",color:"content.warning"}
1,_t.zA.ERROR_MESSAGE)),a.createElement(bn.v,{onClick:f},a.createElement(xt.v,{size:"small",weight:"bold",color:"content.warning"},_t.zA.ERROR_RETRY)))))).with({showSuccessBanner:!0},(()=>a.createElement(ku,{type:"success"},a.createElement("div",{className:"flex items-center gap-xs"},a.createElement(sl.ZQ,{name:"check-circle",size:16}),a.createElement(xt.v,{size:"small"},_t.zA.RATE_LIMIT_SUCCESS_MESSAGE))))).otherwise((()=>null)),a.createElement(wu,{key:"textarea-".concat(M),autoFocus:c,hideLabel:!0,name:"prompt",placeholder:i,disabled:n,textAreaRef:u,onChange:B,submitOnEnter:!0,hideResizeHandle:!0,$hasBanner:M}),O?a.createElement(Iu,{onClick:h,"aria-label":"Cancel response"},a.createElement(fe.QlK,{size:"2xs",className:"text-content-secondary"})):a.createElement(Au,{icon:"arrow-up",iconSize:16,onClick:l,disabled:L||x||!t.prompt||n,"aria-label":"Send message"}))}))),a.createElement(xt.v,{size:"xsmall",color:"content.secondary"},a.createElement(Ll.o,{className:"[&_a]:text-content-secondary [&_a]:underline [&_a:hover]:text-content-primary [&_a:visited]:text-content-secondary [&_a:visited:hover]:text-content-primary"},_t.zA.PROMPT_DISCLAIMER)))},Nu=u.default.div.withConfig({displayName:"PersistentAssistantPrompt__ErrorContainer",componentId:"sc-1jpud3w-5"})(["padding:",";"],vt.YK.default),Tu=e=>a.createElement(yn.t,{"data-external-id":"assistant-with-error-boundary",onError:Pi.jC,errorComponent:a.createElement(Nu,null,a.createElement(fu.g,{type:"error"},"An unexpected error occurred. Try refreshing the page."))},a.createElement(Su,e)),_u=()=>a.createElement("div",{"data-external-id":"thinking-placeholder",role:"status",className:"my-xs flex items-center gap-xs px-xl"},a.createElement(md,null),a.createElement(wi,{colors:vd},a.createElement(fe.c8D,{size:"sm"},Re.THINKING_PLACEHOLDER)),a.createElement(fe.hPJ,{size:"xs",className:"shrink-0 text-content-secondary"}));var Du=n(41862),Ru=n(42618),Mu=n(58071);const Lu=Ee.Wk7,Ou=Ee.foQ,Pu=Ee.Wi1,Bu=e=>{let t=e.threadId,n=e.onCreateThreadSuccess,l=e.onCreateThreadError,r=e.insightId,s=e.onFirstMessageFailed,c=e.onThreadNotFound;const u=(0,d.wA)(),m=(0,C.RU)(),p=(0,a.useCallback)((e=>m({description:e})),[m]),h=(e=>{let t=e.threadId,n=e.onError;const l=(0,a.useState)(!1),r=(0,o.A)(l,2),s=r[0],c=r[1],d=Boolean(t&&!(0,Hd.Z)(t));(0,a.useEffect)((()=>{c(!1)}),[t]);const u=(0,i.n)(Qe.my),m=(0,o.A)(u,1)[0];return{isOptimisticallyCancelled:s,canCancelResponse:d,cancelResponse:(0,a.useCallback)((async()=>{var e,a;if(t&&!(0,Hd.Z)(t)){c(!0);try{if(!(null===(a=null===(e=(await m({variables:{threadId:t}})).data)||void 0===e?void 0:e.cancelMessageThread)||void 0===a?void 0:a.success))throw new Error}catch(l){c(!1),null===n||void 0===n||n("Failed to stop response")}}}),[t,m,n]),clearOptimisticCancellation:(0,a.useCallback)((()=>{c(!1)}),[])}})({threadId:t,onError:p}),v=h.isOptimisticallyCancelled,f=h.canCancelResponse,E=h.cancelResponse,y=h.clearOptimisticCancellation,b=(0,et.I)(Qe.ps),x=b.data,w=b.isLoadingInitialData,A=null!==x&&void 0!==x?x:{},I=A.messageThreads,k=void 0===I?[]:I,S=A.householdPreferences,N=A.me,T=(0,a.useCallback)((()=>{u((0,g.Ce)({rateLimitExpiresAt:Date.now()+1e3*At.ec}))}),[u]),_=(0,Hd.C)({threadId:t,currentUserId:null===N||void 0===N?void 0:N.id,onCreateThreadSuccess:(e,t)=>{let a=t.fromGlobalSearch;return null===n||void 0===n?void 0:n({threadId:e,optimistic:!1,fromGlobalSearch:a})},onCreateThreadError:l,insightId:r,onFirstMessageFailed:s,onOptimisticThreadCreated:(e,t)=>{let a=t.fromGlobalSearch;return null===n||void 0===n?void 0:n({threadId:e,optimistic:!0,fromGlobalSearch:a})},onSubmit:y,onNonRateLimitError:p,onRateLimitError:T}),D=(0,et.I)(Qe._Q,(0,U.A)({variables:{threadId:null!==t&&void 0!==t?t:""},skip:!t},t&&(0,Hd.Z)(t)&&{fetchPolicy:"cache-only"})),R=D.data,M=D.subscribeToMore,L=D.networkStatus,O=D.error,P=D.isNetworkRequestInFlight;(0,a.useEffect)((()=>{t&&!(0,Hd.Z)(t)&&!P&&(e=>{var t;return!!(null===(t=null===e||void 0===e?void 0:e.graphQLErrors)||void 0===t?void 0:t.some((e=>e.message.toLowerCase().includes("not found"))))})(O)&&(null===c||void 0===c||c())}),[t,P,O,c]);const B=(null!==R&&void 0!==R?R:{}).messageThread,z=null!==B&&void 0!==B?B:{},F=z.messages,G=void 0===F?[]:F,Y=z.hasOutstandingAssistantRequests,V=(e=>{let t=e.unfilteredMessages,n=e.threadId,a=e.isOptimisticallyCancelled,l=e.hasOutstandingAssistantRequestsFromBackend;const r=(0,yd.A)((e=>!Id(e)),t),o=Ad(r)&&r.assistantResponseState!==Ee.duP.LOADING,i=Boolean(n)&&null!==l&&void 0!==l&&l&&!a&&!o;return{messages:(0,Wd.A)((e=>e.filter((e=>{const t=n&&!(0,Hd.Z)(n)&&e.threadId&&(0,Hd.Z)(e.threadId);return e.threadId===n||t}))),(0,jd.A)((e=>a&&Ad(e)&&e.assistantResponseState===Ee.duP.LOADING?(0,U.A)((0,U.A)({},e),{},{assistantResponseState:Ee.duP.CANCELLED}):e)))(t),hasOutstandingAssistantRequests:i}})({unfilteredMessages:G,threadId:t,isOptimisticallyCancelled:v,hasOutstandingAssistantRequestsFromBackend:Y}),W=V.messages,j=V.hasOutstandingAssistantRequests,H=(0,Sc.A)(W),K=j&&Cd(H),q=(0,a.useMemo)((()=>Ad(H)&&H.assistantResponseState===Ee.duP.LOADING),[H]),$=(0,a.useCallback)((()=>{f&&(0,Ge.u4)(Ye.xb.AssistantGenerationStopped,{generation_duration_ms:Nd(W),stop_reason:"user_initiated"}),E()}),[W,E,f]);(0,Du.R)(Pu),(0,a.useEffect)((()=>{const e=M({document:Ou,updateQuery:(e,n)=>{const a=n.subscriptionData.data.onMessageCreated,l=null===a||void 0===a?void 0:a.message,r=e.messageThread;if(!l||l.threadId!==t||!r)return e;const o=(0,Ru.A)({messages:e=>{const t=e.filter((e=>!(0,Hd.Z)(e.id))),n=(0,Ud.A)(l,t);return(0,Mu.A)((0,mo.A)("id"),n)}},r);return{__typename:"Query",messageThread:o}}}),n=M({document:Lu,updateQuery:(e,n)=>{const a=n.subscriptionData.data.onMessageUpdated,l=null===a||void 0===a?void 0:a.message,r=(o=t,(e,t)=>{const n=e.messageThread;if(!o||!t||t.threadId!==o||!n)return e;const a=(0,Ru.A)({messages:e=>e.map((e=>e.id===t.id?t:e))},n);return(0,U.A)((0,U.A)({},e),{},{messageThread:a})})(e,l);var o;return(0,U.A)((0,U.A)({},r),{},{__typename:"Query"})}});return()=>{e(),n()}}),[M,t]);const Z=null===S||void 0===S?void 0:S.aiAssistantEnabled,J=(null!==N&&void 0!==N?N:{}).profile,X=(null!==J&&void 0!==J?J:{}).aiAssistantOptedInAt,Q=!w&&(!X||new Date(X)<At.$N),ee=!w&&Z&&Q,te=(0,a.useCallback)((()=>{(0,Ge.u4)(Ye.xb.AssistantErrorRetryClicked,{error_type:"generation_error"})}),[]),ne=(e=>{let t=e.messages,n=e.sendMessage,l=e.onRetry;const r=(0,Sc.A)(t),o=Ad(r)&&r.assistantResponseState===Ee.duP.ERROR,i=(0,a.useMemo)((()=>(0,yd.A)(Cd,t)),[t]);return(0,a.useMemo)((()=>
1{if(o&&i)return()=>{null===l||void 0===l||l(),n({content:i.content,fromRecommendedPrompt:!1,triggerSource:Ee.y3I.ASSISTANT})}}),[o,i,n,l])})({messages:W,sendMessage:_,onRetry:te});return{messageThreads:k,messageThread:B,messages:W,lastMessage:H,hasOutstandingAssistantRequests:j,isLoadingInitialData:w,isLastMessageFromUser:K,isLastMessageStreaming:q,canCancelResponse:f,isAssistantEnabled:Z,needsToOptIn:Q,shouldShowOptInModal:ee,networkStatus:L,sendMessage:_,cancelResponse:$,retryLastErroredMessage:ne}},zu=e=>{let t=e.threadId,n=e.sendMessage,l=e.pendingInitialMessage,r=e.clearPendingInitialMessage;const o=(0,C.RU)();(0,a.useEffect)((()=>{if(!l||t)return;const e=l;r(),n({content:e.content,fromRecommendedPrompt:!1,fromGlobalSearch:!!e.fromGlobalSearch,triggerSource:e.triggerSource}).catch((()=>{o({description:"Failed to start a new chat. Please try again."})}))}),[l,t,n,r,o])},Fu=(e,t)=>{if(!e)return t;const n=N.c9.fromISO(e);return n.isValid?n:t},Gu=e=>{let t=e.assistantName,n=e.assistantColor,l=e.avatarState,r=e.timestamp,o=e.children,i=e.identityRef;return a.createElement("div",{"data-external-id":"today-goldi-thread-header",className:"flex flex-col gap-sm pb-sm"},a.createElement("div",{ref:i,className:"flex flex-col items-center gap-xs pb-xs"},a.createElement("div",{className:"pt-2"},a.createElement(he,{color:n,label:t,size:60,state:l})),a.createElement("div",{className:"flex flex-col items-center gap-3xs"},a.createElement(fe.c8D,{size:"base",weight:"medium",className:"text-center"},t),a.createElement(fe.c8D,{size:"xs",color:"secondary",className:"text-center"},(e=>{const t=e.hasSame(N.c9.local(),"day")?"Today":e.toFormat("LLL d");return"".concat(t," \xb7 ").concat(e.toFormat("h:mm a"))})(r)))),o)},Yu=()=>a.createElement(fe.c8D,{"data-external-id":"today-composer-disclaimer",size:"xs",color:"secondary",className:"w-full text-center text-pretty"},Re.THREAD_COMPOSER_DISCLAIMER),Uu=e=>{let t=e.value,n=e.placeholder,l=e.disabled,r=void 0!==l&&l,o=e.isSubmitDisabled,i=void 0!==o&&o,s=e.action,c=e.size,d=void 0===c?"medium":c,u=e.inputRef,m=e.onChange,p=e.onSubmit;const g=Boolean(t.trim())&&!r&&!i,h="medium"===d;return a.createElement("div",{"data-external-id":"today-composer-field",className:(0,q.cn)("flex gap-xs rounded-lg border border-input-default-border bg-background-primary shadow-sm",h?"items-end py-sm pr-sm pl-default":"items-center py-1.5 pr-1.5 pl-default")},a.createElement(fe.LYY,{ref:u,value:t,onChange:e=>m(e.target.value),onKeyDown:e=>{"Enter"!==e.key||e.shiftKey||(e.preventDefault(),p())},disabled:r,"aria-label":n,placeholder:n,minRows:h?3:1,maxRows:6,style:{minBlockSize:h?"calc(3 * 1lh)":"1.5rem"},className:" min-w-0 flex-1 border-0 bg-transparent p-0 leading-6 text-content-primary hover:border-0 hover:bg-transparent focus:border-0 focus:bg-transparent "}),null!==s&&void 0!==s?s:a.createElement(fe.SO$,{variant:"minimal",size:"sm","aria-label":"Send",disabled:!g,onClick:p,className:(0,q.cn)("shrink-0 rounded-default disabled:opacity-100",g?"bg-background-brand text-content-white hover:bg-background-brand-hover":"bg-background-secondary text-content-secondary")},a.createElement(fe.UWG,{size:"md"})))},Vu=e=>{let t=e.value,n=e.placeholder,l=e.disabled,i=void 0!==l&&l,s=e.isSubmitDisabled,c=void 0!==s&&s,u=e.showCancelButton,m=void 0!==u&&u,p=e.inputRef,g=e.onChange,h=e.onSubmit,v=e.onCancel,f=e.onRetry;const E=(0,F.K)(),y=(0,d.d4)(A.MJ),b=(0,a.useState)(!1),x=(0,o.A)(b,2),w=x[0],C=x[1],I=(0,a.useRef)(E),k=i||E;(0,a.useEffect)((()=>{const e=!1===I.current&&!0===E,t=!0===I.current&&!1===E;e&&(0,Ge.u4)(Ye.xb.AssistantRateLimitShown),f?C(!1):t&&C(!0),I.current=E}),[E,f]),(0,bu.w)((()=>{C(!1)}),[y]);const S=(0,r.YW)({isRateLimited:E,hasError:Boolean(f),showSuccessBanner:w}).with({isRateLimited:!0},(()=>a.createElement(fe.hzW,{variant:"error"},_t.zA.RATE_LIMIT_MESSAGE))).with({hasError:!0},(()=>a.createElement(fe.hzW.Root,{variant:"warning"},a.createElement(fe.hzW.Description,null,_t.zA.ERROR_MESSAGE),a.createElement(fe.hzW.Actions,null,a.createElement(fe.XZZ,{variant:"text",size:"xs",onClick:f},_t.zA.ERROR_RETRY))))).with({showSuccessBanner:!0},(()=>a.createElement(fe.hzW,{variant:"success"},_t.zA.RATE_LIMIT_SUCCESS_MESSAGE))).otherwise((()=>null));return a.createElement("div",{"data-external-id":"today-reply-composer",className:"flex flex-col gap-sm"},S,a.createElement(Uu,{value:t,placeholder:n,disabled:k,isSubmitDisabled:c,action:m?a.createElement(fe.SO$,{variant:"minimal",size:"sm","aria-label":"Stop generating",onClick:v,className:"shrink-0 rounded-default bg-background-secondary"},a.createElement(fe.QlK,{size:"md"})):void 0,size:"compact",inputRef:p,onChange:g,onSubmit:()=>{C(!1),h()}}),a.createElement(Yu,null))},Wu=function(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return function(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return e===Ee.duP.ERROR?"error":e===Ee.duP.LOADING||t?"thinking":"default"}("AssistantMessage"===(null===e||void 0===e?void 0:e.__typename)?e.assistantResponseState:void 0,t)},ju=e=>{const t=(0,a.useRef)(null),n=(0,a.useRef)(new Map),l=(0,a.useCallback)(((e,a)=>{if(a)t.current=e;else{const a=t.current;a&&(n.current.set(e,a),t.current=null)}}),[]);return{stableKey:(0,a.useMemo)((()=>{var t;return e?null!==(t=n.current.get(e))&&void 0!==t?t:e:null}),[e]),handleThreadCreation:l}};var Hu=n(53307),Ku=n(42120),qu=n(28987);const $u=e=>{let t=e.isOpen,n=e.promptValueRef;return a.createElement(T.N,{"data-external-id":"floating-assistant"},t&&a.createElement(Zu,{promptValueRef:n}))},Zu=e=>{var t;let n=e.promptValueRef;const l=(0,u.useTheme)(),i=(0,_.E)(),s=(0,a.useRef)(!1),c=(0,a.useRef)(null),m=(0,a.useRef)(null),p=(0,z.h)(),g=p.closeAssistant,h=p.setA
1ctiveThread,v=p.setPendingInitialMessage,f=(0,ot.M)().isOn,E=(0,d.d4)(A.$Y)||(0,qu.P)(),y=(0,d.d4)(A.MJ),b=(0,d.d4)(A.jX),x=(0,d.d4)(A.x9),w=(0,d.d4)(A.GC),C=(0,d.d4)(A.lu),I=(0,a.useState)(!1),k=(0,o.A)(I,2),S=k[0],T=k[1],D=(0,ht.S)(),L=D.isAiFeaturesEnabled,P=D.isLoading,B=ju(y),G=B.stableKey,Y=B.handleThreadCreation,U=(0,a.useCallback)((()=>{v(null)}),[v]),V=!!(0,a.useRef)(b&&Date.now()-b<500).current,W=(0,a.useCallback)((e=>{let t=e.threadId,n=e.optimistic;Y(t,n),h(t,{persistUpgrade:!0})}),[Y,h]),j=(0,a.useCallback)((()=>{h(null)}),[h]),H=(0,a.useCallback)((()=>{h(null)}),[h]),K=Bu({threadId:null!==y&&void 0!==y?y:void 0,onCreateThreadSuccess:W,onCreateThreadError:j,onThreadNotFound:H}),q=K.isLoadingInitialData,$=K.messages,Z=K.lastMessage,J=K.messageThreads,X=K.isLastMessageFromUser,Q=K.isLastMessageStreaming,ee=K.sendMessage,te=K.cancelResponse,ne=K.canCancelResponse,ae=K.hasOutstandingAssistantRequests,le=K.shouldShowOptInModal,re=K.retryLastErroredMessage;zu({threadId:y,sendMessage:ee,pendingInitialMessage:x,clearPendingInitialMessage:U});const oe=(0,a.useState)((()=>"string"===typeof n.current?n.current:"")),ie=(0,o.A)(oe,2),se=ie[0],ce=ie[1],de=(0,a.useState)((()=>N.c9.local())),ue=(0,o.A)(de,1)[0],me=(0,F.K)(),pe=at({skip:!f}),he=pe.assistantName,ve=pe.assistantColor,fe=pe.isLoadingProfile,ye=(null===he||void 0===he?void 0:he.trim())||ge.Uk,be=null!==ve&&void 0!==ve?ve:ge.fB,xe=ae||Q,we=xe&&ne,Ce=xe||me,Ae=fe?null:a.createElement(Gu,{assistantName:ye,assistantColor:be,avatarState:Wu(Z,xe),timestamp:Fu(null===(t=$[0])||void 0===t?void 0:t.createdAt,ue)},C&&y?a.createElement(xc,{insightId:C,threadId:y}):null),Ie="light"===l.uiTheme?l.variables.color.background.primary:l.variables.color.background.page;(0,a.useEffect)((()=>{if(!V)return i.start("animate"),void i.set({boxShadow:void 0,borderColor:void 0});if(s.current)return;(async()=>{await i.start("animate"),await Promise.all([i.start({boxShadow:["0px 3px 16px ".concat(l.variables.color.shadow.large),"0px 3px 20px ".concat(l.variables.color.background.brand),"0px 3px 16px ".concat(l.variables.color.shadow.large)],transition:{duration:1.6,delay:.4,ease:"easeInOut"}}),i.start({borderColor:[Ie,l.variables.color.background.brand,Ie],transition:{duration:1.6,delay:.6,ease:"easeInOut"}})]),i.set({boxShadow:void 0,borderColor:void 0}),s.current=!0})()}),[V]),(0,a.useEffect)((()=>{s.current&&i.set({borderColor:Ie})}),[Ie,i]);const ke=(0,a.useCallback)((()=>{var e;null===(e=c.current)||void 0===e||e.focus()}),[c]),Se=(0,a.useCallback)((()=>{var e;h(null),null===(e=m.current)||void 0===e||e.focus()}),[h]),Ne=(0,a.useRef)(y);(0,a.useEffect)((()=>{var e;Ne.current!==y&&(Ne.current=y,n.current="",ce("")),null===(e=m.current)||void 0===e||e.focus()}),[n,y]),(0,Ku.D)("Escape",c.current,{onKeyDown:()=>{g()}});const Te=(0,a.useCallback)((()=>{var e;T(!0),null===(e=m.current)||void 0===e||e.focus()}),[]),_e=P||q,De=(0,a.useMemo)((()=>a.createElement(dn,{isLoadingInitialData:_e,sendMessage:ee,messageThreads:J})),[_e,ee,J]),Re=(0,a.useMemo)((()=>({sendMessage:ee})),[ee]);return(0,R.createPortal)(a.createElement(O,{value:Re},a.createElement(Ju,{tabIndex:-1,ref:c,onMouseDown:ke,initial:"initial",animate:i,exit:"exit",variants:Yd.A3,transition:Yd.V8,onAnimationComplete:Te,$withEmployeeMenu:E},a.createElement(Xu,null,!le&&a.createElement(M.Dp,{isLoading:q,placeholderComponent:a.createElement(M.Al,{$height:"32px",$width:"40%"})},a.createElement(ls,{messageThreads:J,activeThreadId:y})),a.createElement("div",{className:"flex",style:{marginLeft:"auto"}},a.createElement(Et,{handleCreateNewThread:Se}))),a.createElement(Qu,null,(0,r.YW)({isLoading:_e,shouldShowOptInModal:le,isAiFeaturesEnabled:L,threadId:y}).with({isLoading:!0,threadId:r.P.nullish},(()=>De)).with({isLoading:!0,threadId:r.P.not(r.P.nullish)},(()=>a.createElement($i,null))).with({shouldShowOptInModal:!0},(()=>a.createElement(uu,null))).with({isAiFeaturesEnabled:!1},(()=>a.createElement(Dt,{onClose:g,source:null!==w&&void 0!==w?w:void 0}))).with({threadId:r.P.not(r.P.nullish)},(()=>a.createElement(em,{key:G,messages:$,header:f?Ae:void 0,footer:X&&a.createElement(_u,null),isAnimationComplete:S,overlayColor:l.variables.color.background.secondary,hideLeadingTimestamp:f,scrollAnchor:f?"leading-header":"latest-turn"}))).otherwise((()=>De))),(_e||!le&&L)&&a.createElement(tm,null,f?a.createElement(Vu,{value:se,placeholder:Pe(ye),disabled:_e,isSubmitDisabled:Ce,showCancelButton:we,inputRef:m,onCh
1ange:e=>{n.current=e,ce(e)},onSubmit:()=>{const e=se.trim();e&&!Ce&&(ee({content:e,triggerSource:Ee.y3I.ASSISTANT}),n.current="",ce(""))},onCancel:te,onRetry:re}):a.createElement(Tu,{isLoading:_e,sendMessage:ee,hasOutstandingAssistantRequests:ae,promptRef:m,promptValueRef:n,isLastMessageStreaming:Q,onCancelResponse:te,canCancelResponse:ne,retryLastErroredMessage:re})))),document.body)},Ju=(0,u.default)(D.PY1.div).withConfig({displayName:"FloatingAssistant__AssistantBackground",componentId:"sswg1d-0"})(["border:1px solid ",";border-radius:",";box-shadow:0px 3px 16px ",";position:fixed;width:450px;max-width:calc(100vw - "," * 2);max-height:calc(100vh - "," * 2);height:684px;bottom:",";right:",";overflow:hidden;background:rgba( ",",0.85 );backdrop-filter:blur(10px);transform:translate3d(0,0,0);display:flex;flex-direction:column;&:focus-visible{outline:none;}"],(e=>{let t=e.theme;return"light"===t.uiTheme?t.variables.color.background.primary:t.variables.color.background.page}),vt.r8.large,vt.Ee.color.shadow.large,vt.YK.default,vt.YK.default,(e=>{let t=e.theme;return e.$withEmployeeMenu?t.spacing.xxxlarge:t.spacing.default}),vt.YK.default,(e=>{let t=e.theme;return(0,Hu.N)(t.variables.color.background.secondary)})),Xu=(0,u.default)(m.g).attrs({gap:"default",justifyBetween:!0,alignCenter:!0}).withConfig({displayName:"FloatingAssistant__Header",componentId:"sswg1d-1"})(["color:",";padding:"," "," "," ",";"],vt.Ee.color.content.primary,vt.YK.default,vt.YK.large,vt.YK.default,vt.YK.default),Qu=u.default.div.withConfig({displayName:"FloatingAssistant__ContentArea",componentId:"sswg1d-2"})(["display:flex;flex:1;min-height:0;flex-direction:column;overflow-y:auto;"]),em=(0,u.default)(Zd).withConfig({displayName:"FloatingAssistant__MessagesList",componentId:"sswg1d-3"})(["flex:1;min-height:0;"]),tm=u.default.div.withConfig({displayName:"FloatingAssistant__PromptContainer",componentId:"sswg1d-4"})(["padding:",";padding-top:0;flex-shrink:0;"],vt.YK.default),nm=e=>{let t=e.onClick;const n=(0,d.d4)(A.$Y),l=(0,d.d4)(A.Pl),r=n||(0,qu.P)(),o=at(),i=o.assistantName,s=o.assistantColor;return o.isLoadingProfile?null:(0,R.createPortal)(a.createElement("button",{type:"button","aria-label":"Open assistant",onClick:t,className:(0,q.cn)("\n          fixed right-xl z-floating flex size-12 cursor-pointer appearance-none items-center\n          justify-center border-0 bg-transparent p-0 outline-none\n        ",r?"bottom-3xl":"bottom-xl",l?"drop-shadow-[0px_2px_16px_var(--color-background-gradient-orange)]":"drop-shadow-[0px_3px_16px_var(--shadow-color-lg)]")},a.createElement(he,{color:null!==s&&void 0!==s?s:ge.fB,label:(null===i||void 0===i?void 0:i.trim())||ge.Uk,size:48})),document.body)};var am=n(2607),lm=n(63086);const rm="shadow-[0px_3px_16px_var(--shadow-color-lg)]",om='url("data:image/svg+xml,'.concat(encodeURIComponent('<svg xmlns="http://www.w3.org/2000/svg" viewBox="'.concat(am.L.viewBox,'">').concat(am.L.markup,"</svg>")),'")'),im={maskImage:om,WebkitMaskImage:om,maskSize:"contain",WebkitMaskSize:"contain",maskRepeat:"no-repeat",WebkitMaskRepeat:"no-repeat",maskPosition:"center",WebkitMaskPosition:"center"},sm=e=>{let t=e.surface,n=e.ariaLabel,l=e.onClick;const o=(0,d.d4)(A.$Y),i=(0,d.d4)(A.Pl),s=o||(0,qu.P)(),c="dark"===(0,lm.a)(),u=s?"bottom-3xl":"bottom-xl",m=(0,r.YW)(t).with("supportChat",(()=>({icon:a.createElement(fe.F6q,{size:24,className:"text-content-primary"}),buttonShadowClassName:rm}))).with("assistant",(()=>({icon:i?a.createElement("span",{"aria-hidden":!0,className:"block size-6 rotate-90 bg-[linear-gradient(178deg,var(--color-background-gradient-red)_20%,var(--color-background-gradient-orange)_80%)]",style:im}):a.createElement(fe.bQo,{size:24,className:"text-content-primary"}),buttonShadowClassName:i?"shadow-[0px_2px_16px_var(--color-background-gradient-orange)]":rm}))).exhaustive(),p=m.icon,g=m.buttonShadowClassName;return(0,R.createPortal)(a.createElement("button",{type:"button","aria-label":n,onClick:l,className:(0,q.cn)("\n  fixed right-xl flex size-12 cursor-pointer\n  items-center justify-center rounded-round bg-background-primary outline-none\n  hover:bg-background-primary-hover\n",c?"border border-border-primary":"border-none",u,g)},p),document.body)},cm=()=>{const e=(0,d.wA)(),t=(0,z.h)(),n=t.restoreAssistant,l=t.openAssistant,o=(0,ot.M)().isOn,i=(0,d.d4)(A.MJ),s=(0,d.d4)(A.XT),c=(0,d.d4)(A.Le);(0,Du.R)(dm,{skip:!i,onData:t=>{var n;let a=t.data.data;const l=null===a||void 0===a||null===(n=a.onMessageCreated)||void 0===n?void 0:n.message;l&&l.threadId===i&&"AssistantMessage"===l.__typename&&e((0,g.Ce)({hasUnreadWhileMinimized:!0}))}});const u=()=>
1{const e=(0,gt.zy)({isOpen:s,isMinimized:c,activeThreadId:i});(0,r.YW)(e).with({action:"restore"},(()=>{n()})).with({action:"open-thread"},(e=>{let t=e.threadId;l(t)})).with({action:"new-chat"},(()=>{l()})).exhaustive()};return o?a.createElement(nm,{"data-external-id":"minimized-assistant-button",onClick:u}):a.createElement(sm,{"data-external-id":"minimized-assistant-button",surface:"assistant",ariaLabel:"Restore AI Assistant",onClick:n})},dm=Ee.Bk7;var um=n(60371),mm=n(21501),pm=n(88297),gm=n(83896),hm=n(19443);const vm=e=>{let t=e.messageThread,n=t.id,l=t.subject,r=e.isSelected;const i=(0,z.h)().setActiveThread,s=(0,d.d4)(ft.MJ),c=ts({refetchQueries:[Qe.ps]}),u=(0,o.A)(c,1)[0],m=(0,hm.M)((async()=>{(0,Ge.u4)(Ye.xb.AssistantChatDeletedClicked,{thread_id:n}),await u({variables:{id:n}}),s===n&&i(null)})),p=(0,o.A)(m,2),g=p[0],h=p[1],v=null!==l&&void 0!==l?l:_t.zA.MESSAGE_THREAD_SUBJECT_PLACEHOLDER;return a.createElement(fm,{"data-external-id":"message-thread-list-item",selected:r},a.createElement(Em,null,a.createElement(xt.v,{title:v,clampLine
1s:1},v)),a.createElement(bm,null,a.createElement(Qi.Az,{overlay:a.createElement(Ji.SP,null,a.createElement(xm,{icon:"trash",onClick:h,disabled:g},"Delete this chat")),placement:"bottom-end"},(e=>{let t=e.toggleOpen;return a.createElement(B.L,{icon:"more-horizontal",size:"xxsmall",onClick:t})}))))},fm=(0,u.default)(pm.sR).attrs({"data-sc-tw":"Menu__MenuItem MessageThreadListItem__PersistentAssistantMenuItem"}).withConfig({displayName:"MessageThreadListItem__PersistentAssistantMenuItem",componentId:"sc-1818kgr-0"})(["overflow:hidden;width:100%;display:flex;align-items:center;justify-content:space-between;border-radius:",";gap:",";padding:"," ",";margin:0;",";"],vt.r8.default,vt.YK.xsmall,vt.YK.xsmall,vt.YK.small,(e=>{let t=e.selected,n=e.theme;return t&&(0,u.css)(["&&{background:",";color:",";}"],n.variables.color.background.secondaryHover,n.variables.color.content.primary)})),Em=(0,u.default)(m.g).withConfig({displayName:"MessageThreadListItem__ContentContainer",componentId:"sc-1818kgr-1"})(["flex:1;min-width:0;overflow:hidden;"]),ym=(0,u.default)(gm.n).attrs({onClick:!0}).withConfig({displayName:"MessageThreadListItem__MoreButtonBoundary",componentId:"sc-1818kgr-2"})(["flex:0;"]),bm=(0,u.default)(ym).withConfig({displayName:"MessageThreadListItem__MoreButtonContainer",componentId:"sc-1818kgr-3"})(["opacity:0;transition:opacity 120ms ease-in-out;&:focus-within{opacity:1;}[data-sc-tw~='MessageThreadListItem__PersistentAssistantMenuItem']:hover &{opacity:1;}"]),xm=(0,u.default)(Ji.xm).withConfig({displayName:"MessageThreadListItem__DeleteMenuItem",componentId:"sc-1818kgr-4"})(["color:",";&:hover{color:",";}"],vt.Ee.color.content.danger,vt.Ee.color.content.dangerHover);var wm=n(82822),Cm=n(43400);const Am=["as","className"],Im=["className","selected","disabled"],km=()=>(0,q.cn)(Cm.UG,"mx-0 w-full","not-data-selected:not-data-disabled:hover:bg-background-secondary-hover","focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-border-info focus-visible:outline-solid"),Sm=(0,a.forwardRef)(((e,t)=>{let n=e.as,l=void 0===n?"div":n,r=e.className,o=(0,En.A)(e,Am);const i=e=>{"function"===typeof t?t(e):t&&(t.current=e)},s=(0,U.A)((0,U.A)({},o),{},{className:(0,q.cn)("flex flex-col gap-2xs py-2xs",r)});return"nav"===l?a.createElement("nav",Object.assign({"data-external-id":"root",ref:i},s)):a.createElement("div",Object.assign({"data-external-id":"root",ref:i},s))})),Nm=(0,a.forwardRef)(((e,t)=>{let n=e.className,l=e.selected,r=e.disabled,o=(0,En.A)(e,Im);return a.createElement("button",Object.assign({"data-external-id":"item",ref:t},o,{type:"button",className:(0,q.cn)("appearance-none border-0 bg-transparent font-[inherit] text-inherit",km(),"text-left",n),"data-selected":l||void 0,"data-disabled":r||void 0,disabled:r}))})),Tm=Object.defineProperties(Sm,{Item:{value:Nm},ItemLink:{value:e=>{let t=e.to,n=e.className,r=e.children;const o=(0,l.RQ)(t);return a.createElement(l.k2,{"data-external-id":"item-link",to:t,className:(0,q.cn)("text-inherit",km(),n),"data-selected":(null===o||void 0===o?void 0:o.pathname)===t||void 0},r)}},Separator:{value:e=>{let t=e.className;return a.createElement(wm.A,{"data-external-id":"separator",className:(0,q.cn)("my-2xs",t)})}}});var _m=n(61198);const Dm=e=>{let t=e.messageThreads,n=e.className,l=e.activeThreadId,r=e.onSelectThread;const o=(0,z.h)().setActiveThread,i=(0,F.K)(),s=(0,a.useMemo)((()=>xd(t)),[t]);return a.createElement(_m.O,{"data-external-id":"message-threads-list",className:n},a.createElement(Tm,{className:"p-sm"},a.createElement(Rm,{onClick:()=>{i||o(null)},disabled:i},a.createElement(fm,{selected:!l,disabled:i},a.createElement(Em,{gap:"xsmall",alignCenter:!0},a.createElement(sl.ZQ,{name:"create-new",size:12}),a.createElement(xt.v,{clampLines:1},"New chat")))),s.map((e=>{let t=e.category,n=e.threads;return a.createElement(a.Fragment,{key:t},a.createElement(Mm,null,t),n.map((e=>a.createElement(Rm,{key:e.id,onClick:()=>null===r||void 0===r?void 0:r(e.id)},a.createElement(vm,{messageThread:e,isSelected:l===e.id})))))}))))},Rm=(0,u.default)(Xi.G).withConfig({displayName:"MessageThreadsList__SelectThreadButton",componentId:"sc-13dm9p4-0"})(["padding:0;max-width:100%;width:100%;"]),Mm=(0,u.default)(xt.v).attrs({size:"small",weight:"medium",color:"content.secondary"}).withConfig({displayName:"MessageThreadsList__CategoryHeader",componentId:"sc-13dm9p4-1"})(["padding:"," ",";margin-top:",";&:first-child{margin-top:0;}"],vt.YK.xxsmall,vt.YK.small,vt.YK.large);var Lm,Om=n(82584),Pm=n(23422);const Bm=e=>{let t=e.isOpen,n=e.promptValueRef;return a.createElement(T.N,{"data-external-id":"modal-assistant"},t&&a.createElement(zm,{promptValueRef:n}))},zm=e=>{let t=e.promptValueRef;const n=(0,a.useRef)(null),l=(0,z.h)(),i=l.setActiveThread,s=l.closeAssistant,c=l.setPendingInitialMessage,m=(0,d.d4)(A.MJ),p=(0,d.d4)(A.x9),g=(0,d.d4)(A.GC),h=(0,a.useState)(!1),v=(0,o.A)(h,2),f=v[0],E=v[1],y=(0,ht.S)(),b=y.isAiFeaturesEnabled,x=y.isLoading,w=(0,u.useTheme)(),C=ju(m),I=C.stableKey,k=C.handleThreadCreation,S=(0,a.useCallback)((()=>{c(null)}),[c]),N=(0,a.useCallback)((e=>{let t=e.threadId,n=e.optimistic;k(t,n),i(t,{persistUpgrade:!0})}),[k,i]),T=(0,a.useCallback)((()=>{i(null)}),[i]),_=(0,a.useCallback)((()=>{i(null)}),[i]),D=Bu({threadId:null!==m&&void 0!==m?m:void 0,onCreateThreadSuccess:N,onCreateThreadError:T,onThreadNotFound:_}),R=D.isLoadingInitialData,L=D.messages,P=D.messageThreads,B=D.isLastMessageFromUser,F=D.isLastMessageStreaming,G=D.sendMessage,Y=D.cancelResponse,U=D.canCancelResponse,V=D.hasOutstandingAssistantRequests,W=D.shouldShowOptInModal,j=D.retryLastErroredMessage;zu({threadId:m,sendMessage:G,pendingInitialMessage:p,clearPendingInitialMessage:S}
1);const H=(0,a.useCallback)((()=>{s()}),[s]),K=(0,a.useCallback)((()=>{var e;i(null),null===(e=n.current)||void 0===e||e.focus()}),[i]),q=(0,a.useCallback)((e=>{e!==m&&(0,Ge.u4)(Ye.xb.AssistantChatRevisited,{thread_id:e}),i(e)}),[i,m]);(0,a.useEffect)((()=>{var e;null===(e=n.current)||void 0===e||e.focus()}),[m]);const $=x||R,Z=null!==m||!$&&b&&!W&&P.length>0,J=(0,a.useCallback)((()=>{var e;E(!0),null===(e=n.current)||void 0===e||e.focus()}),[]),X=(0,a.useMemo)((()=>a.createElement(Wm,null,a.createElement(Km,null,a.createElement(dn,{isLoadingInitialData:$,sendMessage:G,messageThreads:P})))),[$,G,P]),Q=(0,a.useMemo)((()=>({sendMessage:G})),[G]);return a.createElement(O,{"data-external-id":"animated-modal-assistant",value:Q},a.createElement(Fm,{animate:!1,onClose:H,large:!0,full:!0,overlay:a.createElement(Gm,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:Yd.V8,onClick:H})},a.createElement(Ym,{initial:"initial",animate:"animate",exit:"exit",variants:Yd.A3,transition:Yd.V8,onAnimationComplete:J},a.createElement(jm,null,a.createElement(Hm,null,a.createElement("div",{className:"flex items-center gap-xs"},a.createElement(fe.bQo,{size:16,className:"text-content-brand"}),a.createElement(It,{$fontWeight:"medium"},"AI Assistant")),a.createElement(Et,{handleCreateNewThread:K})),a.createElement(qm,null,Z&&a.createElement(Um,null,a.createElement(M.Dp,{isLoading:R,placeholderComponent:a.createElement("div",{className:"flex flex-col gap-2xs rounded-default p-lg"},a.createElement(M.Al,{$height:"40px",$width:"100%",$borderRadius:"large"}),a.createElement(M.Al,{$height:"40px",$width:"100%",$borderRadius:"large"}),a.createElement(M.Al,{$height:"40px",$width:"100%",$borderRadius:"large"}))},a.createElement(Dm,{messageThreads:P,activeThreadId:m,onSelectThread:q}))),a.createElement(Vm,null,(0,r.YW)({isLoading:$,shouldShowOptInModal:W,isAiFeaturesEnabled:b,threadId:m}).with({isLoading:!0,threadId:r.P.nullish},(()=>X)).with({isLoading:!0,threadId:r.P.not(r.P.nullish)},(()=>a.createElement(Jm,null,a.createElement($i,null)))).with({shouldShowOptInModal:!0},(()=>a.createElement(Km,null,a.createElement(uu,null)))).with({isAiFeaturesEnabled:!1},(()=>a.createElement(Dt,{onClose:H,source:null!==g&&void 0!==g?g:void 0}))).with({threadId:r.P.nonNullable},(()=>a.createElement(Wm,null,a.createElement($m,{key:I,messages:L,footer:B&&a.createElement(_u,null),isAnimationComplete:f,overlayColor:w.variables.color.background.page})))).otherwise((()=>X)),($||!W&&b)&&a.createElement(Xm,null,a.createElement(Tu,{isLoading:$,sendMessage:G,promptRef:n,promptValueRef:t,hasOutstandingAssistantRequests:V,isLastMessageStreaming:F,onCancelResponse:Y,canCancelResponse:U,retryLastErroredMessage:j}))))))))},Fm=(0,u.default)(um.b).withConfig({displayName:"ModalAssistant__StyledModal",componentId:"sc-1g78y2w-0"})(["--modal-padding:",";"],vt.YK.xxxxlarge),Gm=(0,u.default)(D.PY1.create(mm.h)).withConfig({displayName:"ModalAssistant__AnimatedShield",componentId:"sc-1g78y2w-1"})(["background-color:",";"],(e=>{let t=e.theme;return"light"===t.uiTheme?t.variables.color.background.modalOverlay:(0,Pm.O1)(Om.$R,.7)({theme:t})})),Ym=(0,u.default)(D.PY1.div).withConfig({displayName:"ModalAssistant__ModalContent",componentId:"sc-1g78y2w-2"})(["border-radius:",";overflow:hidden;background:",";display:flex;flex-direction:row;height:calc(100vh - 2 * ",");margin:0 auto;border:1px solid ",";"],vt.r8.large,(e=>{let t=e.theme;return"light"===t.uiTheme?t.variables.color.background.secondary:t.variables.color.background.page}),vt.YK.xxxxlarge,vt.Ee.color.divider.primary),Um=u.default.div.withConfig({displayName:"ModalAssistant__Sidebar",componentId:"sc-1g78y2w-3"})(["width:340px;display:flex;flex-direction:column;overflow:hidden;@media (max-width:","px){width:280px;}@media (max-width:","px){width:250px;}"],vt.nm.lg,vt.nm.md),Vm=(0,u.default)(m.g).attrs({column:!0}).withConfig({displayName:"ModalAssistant__ChatColumn",componentId:"sc-1g78y2w-4"})(["flex:1;"]),Wm=u.default.div.withConfig({displayName:"ModalAssistant__ChatContent",componentId:"sc-1g78y2w-5"})(["flex:1;overflow-y:auto;"]),jm=u.default.div.withConfig({displayName:"ModalAssistant__MainContent",componentId:"sc-1g78y2w-6"})(["flex:1;display:flex;flex-direction:column;overflow:hidden;min-width:0;"]),Hm=(0,u.default)(m.g).attrs({gap:"default",justifyBetween:!0,alignCenter:!0}).withConfig({displayName:"ModalAssistant__Header",componentId:"sc-1g78y2w-7"})(["color:",";padding:"," ",";border-bottom:1px solid rgba(",",0.3);"],vt.Ee.color.content.primary,vt.YK.default,vt.YK.xlarge,(e=>{let t=e.theme;return(0,Hu.N)(t.variables.color.divider.secondary)})),Km=(0,u.default)(m.g).attrs({justifyCenter:!0}).withConfig({displayName:"ModalAssistant__EmptyStateContainer",componentId:"sc-1g78y2w-8"})(["height:100%;overflow-y:auto;"]),qm=u.default.div.withConfig({displayName:"ModalAssistant__ContentArea",componentId:"sc-1g78y2w-9"})(["display:flex;height:100%;overflow:hidden;"]),$m=(0,u.default)(Zd).withConfig({displayName:"ModalAssistant__MessagesList",componentId:"sc-1g78y2w-10"})(["flex:1;min-height:0;"]),Zm=u.default.div.withConfig({displayName:"ModalAssistant__MaxWidthContainer",componentId:"sc-1g78y2w-11"})(["max-width:","px;width:100%;align-self:center;"],Yd.aA),Jm=(0,$d.s)(Zm)(Lm||(Lm=(0,wc.A)(["flex-1"]))),Xm=(0,u.default)(Zm).withConfig({displayName:"ModalAssistant__PromptContainer",componentId:"sc-1g78y2w-12"})(["padding:",";padding-top:0;flex-shrink:0;align-self:center;"],vt.YK.xlarge);var Qm=n(6454);const ep=()=>{const e=(0,l.zy)().pathname,t=(0,ot.M)().isOn,n=(0,gt.KH)({pathname:e,isTodayEnabled:t}),r=(0,d.d4)(A.XT),o=(0,d.d4)(A._S),i=(0,d.d4)(A.Le),s=Y(),c=(0,d.d4)(A.MJ),u=(0,a.useRef)(""),m=(0,ht.S)().isAiFeaturesEnabled,p=(0,Qm.Eo)(),g=p.endSupportChat,h=p.isChatOpen;(0,a.useEffect)((()=>{u.current=""}),[c]);const v=!n&&r&&!i&&(t||!o||!s),f=!n&&!t&&s&&o&&r&&!i,E=!t&&!n&&r&&i,y=(0,gt.JM)({isTodayEnabled:t,isAiFeaturesEnabled:m,hideOverlay:n,showFloating:v,showModal:f,isSupportChatOpen:h});return(0,a.useEffect)((()=>{n||r&&!i&&g()}),[n,r,i,g]),a.createElement(a.Fragment,null,a.createElement(Bm,{isOpen:f,promptValueRef:u}),a.createElement($u,{isOpen:v,promptValueRef:u}),(E||y)&&a.createElement(cm,null))};var tp=n(68841),np=n(31955);const ap=()=>a.createElement("div",{"data-external-id":"detail-sidebar-skeleton",className:(0,q.cn)("flex h-full flex-col gap-md p-default"),"aria-busy":"true","aria-label":"Loading sidebar","data-testid":"detail-sidebar-skeleton"},a.createElement("div",{className:"flex items-center justify-between gap-sm"},a.createElement(M.Al,{$width:"160px",$height:"24px",$borderRadius:"small","aria-hidden":!0}),a.createElement(M.Al,{$width:"32px",$height:"32px",$borderRadius:"small","aria-hidden":!0})),a.createElement(M.Al,{$width:"100%",$height:"120px",$borderRadius:"medium","aria-hidden":!0}),a.createElement(M.Al,{$width:"100%",$height:"160px",$borderRadius:"medium","aria-hidden":!0})),lp=(e,t)=>{const n=new Map([[t,1]]),a=l=>{if(!Number.isFinite(l)||l<=t)return 1;const r=n.get(l);if(void 0!==r)return r;const o=a(l-1)*(1+e.getInflationRate(l-1)/100);return n.set(l,o),o};return a},rp=e=>({getGrowthRate:(e,t)=>
1e.getGrowthRate(t),getInflationRate:()=>e.inflationRate}),op=e=>{var t,n;return!1===(null===(t=e.taxTreatmentConfig)||void 0===t?void 0:t.enabled)?void 0:null!==(n=e.taxTreatmentConfig)&&void 0!==n?n:void 0},ip={numPaths:1e3,inflationVolatility:2,showFan:!1},sp=100,cp=e=>Number.isFinite(e)?Math.min(Math.max(e,0),100):0,dp=e=>{const t=new Map;for(const n of e){const e=n.year,a=n.rate;t.set(e,a)}return[...t.entries()].map((e=>{let t=(0,o.A)(e,2);return{year:t[0],rate:t[1]}})).sort(((e,t)=>e.year-t.year))},up=(e,t)=>{const n=dp(e),a=n.at(0);if(void 0===a)throw new Error("interpolateRate requires at least one anchor");if(t<=a.year)return a.rate;let l=a;for(const r of n){if(r.year===t)return r.rate;if(r.year>t){const e=(t-l.year)/(r.year-l.year);return l.rate+e*(r.rate-l.rate)}l=r}return l.rate},mp=["pretax","roth"],pp=e=>mp.includes(e),gp=e=>({forecastAccountId:e,serialized:e}),hp=(e,t)=>({forecastAccountId:e,mixedComponentKind:t,serialized:"".concat(e,":").concat(t)}),vp=e=>{const t=e.lastIndexOf(":");if(-1!==t){const n=e.slice(t+1);if(pp(n))return hp(e.slice(0,t),n)}return gp(e)},fp=(e,t)=>e.find((e=>{var n,a;return e.forecastAccountId===t.forecastAccountId&&(null!==(n=e.mixedComponentKind)&&void 0!==n?n:void 0)===(null!==(a=t.mixedComponentKind)&&void 0!==a?a:void 0)}));class Ep{constructor(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:rp(t);this.config=void 0,this.settings=void 0,this.rateProvider=void 0,this.balance=void 0,this.yearStartBalance=0,this.yearGrowth=0,this.yearInterest=0,this.yearDeposits=0,this.yearWithdrawals=0,this.yearWithdrawalTax=0,this.yearWithdrawalPenalty=0,this.yearPayments=0,this.yearExpenses=0,this.yearContributions=0,this.currentYear=void 0,this.activeStartYear=void 0,this.isBeforeActiveYear=!1,this.mixedComponentKind=void 0,this.config=e,this.settings=t,this.rateProvider=n,this.balance=e.balance,this.yearStartBalance=Math.abs(e.balance),this.currentYear=t.startYear}get rowKey(){return this.mixedComponentKind?hp(this.forecastAccountId,this.mixedComponentKind):gp(this.forecastAccountId)}get forecastAccountId(){return this.config.id}get name(){return this.config.name}get systemAccountType(){return this.config.systemAccountType}get ownerId(){return this.config.ownerId}get owner(){const e=this.ownerId;if(e)return this.settings.participants.find((t=>t.userId===e))}getCategory(){return this.constructor.CATEGORY}getGrowthRate(e){var t;const n=this.config,a=n.growthRateMethod,l=n.growthRateSchedule;return"noChange"===a?0:"schedule"===a&&l&&l.length>0?up(l,e):null!==(t=this.config.growthRate)&&void 0!==t?t:this.constructor.DEFAULT_GROWTH_RATE}getVolatility(){var e;return cp(null!==(e=this.config.volatility)&&void 0!==e?e:this.constructor.DEFAULT_VOLATILITY)}get isGrowthPinnedFlat(){return"noChange"===this.config.growthRateMethod}toSnapshot(){return{forecastAccountId:this.forecastAccountId,mixedComponentKind:this.mixedComponentKind,name:this.name,accountType:this.config.accountType,systemAccountType:this.config.systemAccountType,balance:this.balance,breakdown:this.isBeforeActiveYear?null:this.getBreakdown()}}isIncluded(){return this.config.isIncluded}resetYearTracking(e){void 0!==this.activeStartYear&&e<this.activeStartYear?this.balance=0:void 0!==this.activeStartYear&&e===this.activeStartYear&&(this.balance=this.config.balance),this.isBeforeActiveYear=void 0!==this.activeStartYear&&e<this.activeStartYear,this.currentYear=e,this.yearStartBalance=Math.abs(this.balance),this.yearGrowth=0,this.yearInterest=0,this.yearContributions=0,this.yearDeposits=0,this.yearWithdrawals=0,this.yearWithdrawalTax=0,this.yearWithdrawalPenalty=0,this.yearPayments=0,this.yearExpenses=0}recordDeposit(e){this.yearDeposits=this.yearDeposits+Math.abs(e)}recordContribution(e){this.yearContributions=this.yearContributions+Math.abs(e)}recordWithdrawal(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;this.yearWithdrawals=this.yearWithdrawals-Math.abs(e),this.yearWithdrawalTax=this.yearWithdrawalTax-Math.abs(t),this.yearWithdrawalPenalty=this.yearWithdrawalPenalty-Math.abs(n)}recordPayment(e){this.yearPayments=this.yearPayments+Math.abs(e)}recordExpenses(e){this.yearExpenses=this.yearExpenses-Math.abs(e)}recordGrowthOrInterest(e,t){t?this.yearInterest=this.yearInterest-Math.abs(e):this.yearGrowth=this.yearGrowth+e}getBreakdown(){return{startingBalance:this.yearStartBalance,growth:this.yearGrowth,interest:this.yearInterest,contributions:this.yearContributions,deposits:this.yearDeposits,withdrawals:this.yearWithdrawals,withdrawalTax:this.yearWithdrawalTax,withdrawalPenalty:this.yearWithdrawalPenalty,payments:this.yearPayments,expenses:this.yearExpenses,endingBalance:Math.abs(this.balance)}}}Ep.DEFAULT_GROWTH_RATE=0,Ep.DEFAULT_VOLATILITY=0,Ep.CATEGORY="other";const yp=e=>{let t=e.plannedPayment,n=e.minimumPayment;return void 0!==t&&null!==t&&t>0?t:null!==n&&void 0!==n?n:0};
1class bp extends Ep{getInterestRate(){var e;return null!==(e=this.config.interestRate)&&void 0!==e?e:this.constructor.DEFAULT_INTEREST_RATE}getMonthlyPayment(){return yp({plannedPayment:this.config.plannedPayment,minimumPayment:this.config.minimumPayment})}isPaidOff(){return this.balance>=0}recordInterest(e){this.recordGrowthOrInterest(e,!0)}processYear(){if(this.isBeforeActiveYear)return 0;let e=0;for(let t=0;t<12&&!this.isPaidOff();t+=1){const t=this.getInterestRate()/100,n=Math.abs(this.balance)*t/12;this.balance=this.balance-n,this.recordInterest(n);const a=this.getMonthlyPayment();if(a>0){const t=Math.abs(this.balance),n=a<t?a:t;this.balance=this.balance+n,this.recordPayment(n),e+=n}}return this.config.isSynthetic?0:-e}}bp.DEFAULT_INTEREST_RATE=0,bp.CATEGORY="other";class xp{constructor(e,t){this.config=void 0,this.settings=void 0,this.config=e,this.settings=t}get ownerId(){}get owner(){const e=this.ownerId;if(e)return this.settings.participants.find((t=>t.userId===e))}get hasMultipleActiveParticipants(){return this.settings.participants.filter((e=>!e.hiddenFromForecast)).length>1}get displayName(){var e;return this.hasMultipleActiveParticipants&&null!==(e=this.owner)&&void 0!==e&&e.displayName?"".concat(this.name," (").concat(this.owner.displayName,")"):this.name}get id(){return this.config.id}get name(){return this.config.name}get startYear(){var e;return null!==(e=this.config.startYear)&&void 0!==e?e:void 0}get isExcludedByOwner(){var e,t;return null!==(e=null===(t=this.owner)||void 0===t?void 0:t.hiddenFromForecast)&&void 0!==e&&e}get isIncluded(){return!this.isExcludedByOwner&&this.config.isIncluded}get icon(){return this.config.icon}get color(){return this.config.color}get foregroundColor(){var e;return null!==(e=this.config.foregroundColor)&&void 0!==e?e:this.config.color}get isHidden(){var e;return null!==(e=this.config.isHidden)&&void 0!==e&&e}get isVisibleInForecast(){return!this.isHidden&&!this.isExcludedByOwner}get isPrecomputable(){return!0}getEffectDefinitions(){return[]}isActiveInYear(e){return!0}getEffects(e){const t=this.getActiveYearRange(e.projectionEndYear,e.eventModels);return!t||e.year<t.start||e.year>=t.end?[]:this.isActiveInYear(e)?this.getEffectDefinitions().map((t=>{var n;return{id:t.id,name:null!==(n=t.name)&&void 0!==n?n:t.label,amount:t.computeAmount(e),target:t.target,targetEventId:t.targetEventId}})).filter((e=>0!==e.amount)):[]}getDirectIncomeEffectsTotal(e){return this.getEffects(e).reduce(((e,t)=>e+t.amount),0)}getActiveYearRange(e,t){if(void 0!==this.startYear)return{start:this.startYear,end:this.startYear+1}}getYearChangeAction(e){return this.startYear===e?null:{type:"updateEvent",eventId:this.id,startYear:e}}}const wp=(e,t,n)=>{const a=n.cumulativeInflationFactor;return a?Ap(e)*a(t):Ip(e,t,n.startYear,n.inflationRate)},Cp=(e,t)=>n=>Math.pow(1+t/100,Math.max(0,n-e)),Ap=e=>Number.isFinite(e)?e:0,Ip=(e,t,n,a)=>{const l=Ap(e),r=Ap(t),o=Ap(n),i=Ap(a);return l*Cp(o,i)(r)},kp=(e,t,n,a,l,r)=>{let o=0;const i=l?wp(e,l,a):e;if(l===t)return i;if("inflation"===n){if(a.cumulativeInflationFactor)return wp(e,Math.max(t,null!==l&&void 0!==l?l:a.startYear),a);o=a.inflationRate}else"increase"===n?o=Math.abs(null!==r&&void 0!==r?r:2):"decrease"===n&&(o=-Math.abs(null!==r&&void 0!==r?r:2));return Ip(i,t,null!==l&&void 0!==l?l:a.startYear,o)};var Sp=n(83558);const Np=e=>Math.abs(e)<Sp.Y;var Tp=n(50147);
1const _p=e=>"uncategorizedSavings"===e.systemAccountType,Dp=e=>"unfundedExpenses"===e.systemAccountType,Rp=e=>(0,Tp.n)(e.systemAccountType),Mp=e=>{var t;return null!==(t=null===e||void 0===e?void 0:e.snapshots.some((e=>e.accounts.some((e=>Dp(e)&&!Np(e.balance))))))&&void 0!==t&&t},Lp=e=>{if(Rp(e))return[];if("liability"!==e.accountType.group)return[];const t=[];return void 0===e.interestRate&&t.push("interestRate"),void 0===e.minimumPayment&&void 0===e.plannedPayment&&t.push("payment"),t},Op=e=>Lp(e).length>0;class Pp extends xp{get startYear(){var e;return null!==(e=this.config.startYear)&&void 0!==e?e:this.settings.startYear}getEffectDefinitions(){return[{id:"expense",label:this.name,target:"expense",computeAmount:e=>{let t=e.year;return kp(this.config.amount,t,this.growthType,this.settings,this.startYear,this.growthRate)}}]}getEffects(e){const t=this.getActiveYearRange(e.projectionEndYear);return!t||e.year<t.start||e.year>=t.end?[]:[...super.getEffects(e),...this.calculateDebtPaydownOffsets(e)]}getActiveYearRange(e){if(void 0!==this.startYear)return{start:this.startYear,end:e}}calculateDebtPaydownOffsets(e){return e.accountModels.filter((e=>e instanceof bp&&e.isIncluded()&&!1!==e.config.reduceExpensesForPaidOffDebt&&!Op(e.config))).map((t=>{const n=t.getMonthlyPayment(),a=kp(12*n,e.year,this.growthType,this.settings,this.startYear,this.growthRate);return{id:"debt-offset-".concat(t.forecastAccountId),name:"".concat(t.config.name," payment offset"),amount:-a,target:"expense"}})).filter((e=>0!==e.amount))}get growthType(){var e;return null!==(e=this.config.growthType)&&void 0!==e?e:"inflation"}get growthRate(){var e;return null!==(e=this.config.growthRate)&&void 0!==e?e:void 0}}class Bp extends Ep{processYear(){if(this.isBeforeActiveYear)return 0;const e=this.rateProvider.getGrowthRate(this,this.currentYear)/100,t=Math.max(0,Math.min(this.yearStartBalance,this.balance))*e;return this.balance=this.balance+t,this.recordGrowthOrInterest(t,!1),0}}class zp extends Bp{}zp.DEFAULT_GROWTH_RATE=3,zp.DEFAULT_VOLATILITY=10,zp.CATEGORY="real-estate";const Fp=(e,t,n)=>{const a=t/100/12,l=12*n;return a>0?e*(a*Math.pow(1+a,l))/(Math.pow(1+a,l)-1):e/l},Gp=(e,t)=>e*t/100/12,Yp=(e,t,n,a)=>{const l=.8*t;if(e<=l||0===e)return 0;const r=n/100/12,o=12*a;if(r<=0)return Math.ceil(o*(1-l/e));const i=Math.pow(1+r,o),s=i-l*(i-1)/e;return Math.ceil(Math.log(s)/Math.log(1+r))},Up=e=>{var t;const n=e.homeValue*(e.downPaymentPercent/100),a=e.homeValue-n,l="finance"===e.purchaseMethod?Fp(a,e.mortgageRate,e.mortgageTerm):0,r="finance"===e.purchaseMethod&&e.downPaymentPercent<20?Gp(a,null!==(t=e.pmiRate)&&void 0!==t?t:1):0,o=(i=e.homeValue,s=e.propertyTaxRate,i*s/100/12);var i,s;const c=((e,t)=>e*t/100/12)(e.homeValue,e.homeInsuranceRate);return{downPaymentAmount:n,principal:a,monthlyPI:l,monthlyTax:o,monthlyInsurance:c,totalMonthlyPayment:l+o+c+r,yearlyOwnershipCosts:e.homeValue*(e.yearlyOwnershipCostRate/100),monthlyPMI:r}},Vp={defaultName:"Buy a home",isIncluded:!0,icon:"home",color:"blue",foregroundColor:"blue",eventKind:"buyAHome",homeValue:4e5,purchaseMethod:"finance",downPaymentPercent:20,mortgageTerm:30,mortgageRate:6.5,propertyTaxRate:1,homeInsuranceRate:.5,yearlyOwnershipCostRate:1,replaceExistingHousing:!1,currentMonthlyHousingPayment:0,pmiRate:1,growthType:"inflation"};class Wp extends xp{getEffectDefinitions(){const e=[],t=this.startYear,n=wp(this.homeValue,null!==t&&void 0!==t?t:this.settings.startYear,this.settings),a="cash"===this.purchaseMethod;return e.push({id:"down-payment",label:a?"Home purchase":"Down payment",target:"expense",computeAmount:e=>e.year!==t||void 0===t?0:a?n:n*(this.downPaymentPercent/100)}),"finance"===this.purchaseMethod&&(e.push({id:"principal-and-interest",label:"Principal and interest",target:"expense",isFixedPayment:!0,computeAmount:e=>{if(void 0===t||e.year>=t+this.mortgageTerm)return 0;const a=n*(1-this.downPaymentPercent/100);return 12*Fp(a,this.mortgageRate,this.mortgageTerm)}}),this.downPaymentPercent<20&&this.pmiRate>0&&e.push({id:"private-mortgage-insurance",label:"Private mortgage insurance",target:"expense",isFixedPayment:!0,
1computeAmount:e=>{if(void 0===t||e.year>=t+this.mortgageTerm)return 0;const a=n*(1-this.downPaymentPercent/100),l=Gp(a,this.pmiRate),r=Yp(a,n,this.mortgageRate,this.mortgageTerm),o=12*(e.year-t);return l*Math.max(0,Math.min(12,r-o))}})),e.push({id:"property-tax",label:"Property tax",target:"expense",computeAmount:e=>{if(void 0===t)return 0;return n*this.getLinkedHomeAppreciationFactor(e,t)*(this.propertyTaxRate/100)}}),e.push({id:"home-insurance",label:"Home insurance",target:"expense",computeAmount:e=>{if(void 0===t)return 0;const a=e.year-t;return n*(this.homeInsuranceRate/100)*Math.pow(1.03,a)}}),e.push({id:"ownership-costs",label:"Home ownership costs",target:"expense",computeAmount:e=>void 0===t?0:kp(this.homeValue*(this.yearlyOwnershipCostRate/100),e.year,this.growthType,this.settings,this.startYear,this.growthRate)}),this.replaceExistingHousing&&this.currentMonthlyHousingPayment>0&&e.push({id:"housing-offset",label:"Housing cost offset",target:"expense",computeAmount:e=>void 0===t?0:-wp(12*this.currentMonthlyHousingPayment,e.year,this.settings)}),e}getLinkedHomeAppreciationFactor(e,t){const n=e.accountModels.find((e=>e.config.sourceEventExternalId===this.config.id&&"asset"===e.config.accountType.group));let a=1;for(let l=t;l<e.year;l+=1){a*=1+(n?n.rateProvider.getGrowthRate(n,l):zp.DEFAULT_GROWTH_RATE)/100}return a}getActiveYearRange(e){if(void 0!==this.startYear)return{start:this.startYear,end:e}}get homeValue(){return this.config.homeValue}get purchaseMethod(){return this.config.purchaseMethod}get downPaymentPercent(){return Math.min(Math.max(this.config.downPaymentPercent,0),100)}get mortgageTerm(){return this.config.mortgageTerm}get mortgageRate(){return this.config.mortgageRate}get propertyTaxRate(){return this.config.propertyTaxRate}get homeInsuranceRate(){return this.config.homeInsuranceRate}get yearlyOwnershipCostRate(){return this.config.yearlyOwnershipCostRate}get replaceExistingHousing(){return this.config.replaceExistingHousing}get currentMonthlyHousingPayment(){return this.config.currentMonthlyHousingPayment}get pmiRate(){var e;return null!==(e=this.config.pmiRate)&&void 0!==e?e:1}get growthType(){var e;return null!==(e=this.config.growthType)&&void 0!==e?e:"inflation"}get growthRate(){var e;return null!==(e=this.config.growthRate)&&void 0!==e?e:void 0}}const jp=["retirement","careerBreak","newJob"],Hp=e=>jp.includes(e),Kp=e=>"income"===e||"newJob"===e,qp=e=>Kp(e.eventKind),$p=(e,t)=>void 0===t||null===t?null===e||void 0===e:null===e||void 0===e||e===t,Zp=(e,t)=>{var n;if(!t.isIncluded)return!1;const a=e.ownerId;if(!$p(t.ownerId,null!==a&&void 0!==a?a:void 0))return!1;const l=null!==(n=e.startYear)&&void 0!==n?n:void 0;if((0,Tp.n)(l)){if("income"===t.eventKind&&"once"===t.frequency)return!1;if("income"===t.eventKind&&"yearly"===t.frequency&&(0,Tp.n)(t.endYear)&&t.endYear<=l)return!1;if("newJob"===t.eventKind&&(0,Tp.n)(t.startYear))if("newJob"===e.eventKind){if(t.startYear>l)return!1}else if("careerBreak"===e.eventKind){var r;const n=null!==(r=e.endYear)&&void 0!==r?r:void 0;if((0,Tp.n)(n)&&t.startYear>=n)return!1}}return!0},Jp=(e,t)=>e.isIncluded&&Zp(e,t),Xp=e=>{e.forEach((t=>{var n;if(!Hp(t.eventKind))return;if(!("incomeReductionTargets"in t)||!Array.isArray(t.incomeReductionTargets))return;const a=t,l=null!==(n=a.incomeReductionTargets)&&void 0!==n?n:[],r=l.filter((t=>((e,t,n)=>{const a=n.find((e=>e.id===t));return!(!a||!qp(a))&&Zp(e,a)})(a,t.targetEventId,e)));(l.length!==r.length||l.some(((e,t)=>{var n;return(null===(n=r[t])||void 0===n?void 0:n.targetEventId)!==e.targetEventId})))&&(a.incomeReductionTargets=r)}))},Qp=(e,t)=>{e.filter((e=>Hp(e.eventKind)&&e.id!==t.id&&((e,t)=>!!Jp(e,t)&&!("newJob"===t.eventKind&&"newJob"===e.eventKind&&(0,Tp.n)(t.startYear)&&(0,Tp.n)(e.startYear)&&e.startYear>t.startYear))(e,t))).forEach((e=>{var n;const a=e;a.incomeReductionTargets=tg(null!==(n=a.incomeReductionTargets)&&void 0!==n?n:[],t.id,100)}))},eg=(e,t)=>{var n;if(!Hp(t.eventKind))return;const a=null!==(n=t.incomeReductionTargets)&&void 0!==n?n:[];let l=a;e.forEach((e=>{if(qp(e)&&e.id!==t.id&&Jp(t,e)){const t=tg(l,e.id,100);t!==l&&(l=t)}})),l!==a&&(t.incomeReductionTargets=l)},tg=function(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:100;return e.some((e=>e.targetEventId===t))?e:[...e,{targetEventId:t,reductionPercent:n}]},ng=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:100;return e.length>0?{incomeReductionTargets:e.map((e=>({targetEventId:e.id,reductionPercent:t})))}:{incomeReductionTargets:[]}},ag=function(e,t,n){let a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:100;const l=e.find((e=>e.id===t)),r=l&&Hp(l.eventKind)?(()=>{const a=(0,U.A)((0,U.A)({},l),{},{ownerId:n,isIncluded:!0});return e.filter((e=>!(!qp(e)||e.id===t||!1===e.isIncluded)&&Jp(a,e)))})():e.filter((e=>qp(e)&&e.id!==t&&!1!==e.isIncluded&&$p(e.ownerId,n)));return(0,U.A)({ownerId:n},ng(r,a))},lg=e=>e.find((e=>(e=>"annualExpense"===e.config.eventKind&&e.isHidden)(e))),rg=(e,t,n)=>e.find((e=>!!((e,t)=>{const n=e.config;return"endOfPlan"===e.config.eventKind&&n.ownerId===t})(e,t)&&(!0!==(null===n||void 0===n?void 0:n.includedOnly)||e.isIncluded))),og={defaultName:"Career Break",ownerId:void 0,isIncluded:!0,icon:"umbrella",color:"indigo",foregroundColor:"indigo",eventKind:"careerBreak",incomeReductionTargets:[],expenseMultiplier:1};class ig extends xp{getEffectDefinitions(){var e;const t=[],n=null!==(e=this.config.incomeReductionTargets)&&void 0!==e?e:[];
1for(const a of n)a.reductionPercent<=0||t.push({id:"reduction-".concat(a.targetEventId),label:"Income reduction",target:"income",targetEventId:a.targetEventId,computeAmount:e=>{const t=this.findIncomeSourceModel(e.eventModels,a.targetEventId);if(!t)return 0;return-t.getDirectIncomeEffectsTotal(e)*Math.min(Math.max(a.reductionPercent,0),100)/100}});return 1!==this.expenseMultiplier&&t.push({id:"expense-adjustment",label:"Expense adjustment",target:"expense",computeAmount:e=>{const t=lg(e.eventModels);if(!t)return 0;const n=t.getEffects(e).reduce(((e,t)=>e+t.amount),0);return n<=0?0:n*(this.expenseMultiplier-1)}}),t}findIncomeSourceModel(e,t){return e.find((e=>Kp(e.config.eventKind)&&e.id===t&&e.isIncluded))}getActiveYearRange(){if(void 0!==this.startYear&&void 0!==this.endYear)return{start:this.startYear,end:this.endYear}}get ownerId(){return this.config.ownerId}get expenseMultiplier(){return this.config.expenseMultiplier}get endYear(){return this.config.endYear}}const sg=90,cg={defaultName:"End of plan",ownerId:void 0,isIncluded:!0,icon:"ghost",color:"gray",foregroundColor:"gray",eventKind:"endOfPlan",isRequired:!0};class dg extends xp{get startYear(){var e,t;if(null===(e=this.owner)||void 0===e||!e.birthday)return this.settings.startYear;return(0,Ba.NP)(this.owner.birthday)+(null!==(t=this.owner.lifeExpectancy)&&void 0!==t?t:sg)}get ownerId(){return this.config.ownerId}getYearChangeAction(e){var t;const n=this.settings.participants.find((e=>e.userId===this.config.ownerId));if(null===n||void 0===n||!n.birthday)return null;const a=e-(0,Ba.NP)(n.birthday),l=Math.max(50,Math.min(110,a));return(null!==(t=n.lifeExpectancy)&&void 0!==t?t:sg)===l?null:{type:"updateParticipant",userId:this.config.ownerId,lifeExpectancy:l}}}class ug extends xp{getEffectDefinitions(){const e=[];return this.config.upfrontChildCosts>0&&e.push({id:"upfront-cost",label:"Upfront costs",name:this.name,target:"expense",computeAmount:e=>{let t=e.year;return this.calculateUpfrontCost(t)}}),this.config.yearlyChildExpenses>0&&e.push({id:"child-expenses",label:"Child expenses",name:this.name,target:"expense",computeAmount:e=>{let t=e.year;return this.calculateChildExpenses(t)}}),e}calculateUpfrontCost(e){return e!==this.startYear?0:wp(this.config.upfrontChildCosts,e,this.settings)}calculateChildExpenses(e){if(void 0===this.startYear)return 0;const t=this.startYear+this.config.yearsOfChildcare;return e<this.startYear||e>=t?0:kp(this.config.yearlyChildExpenses,e,this.growthType,this.settings,this.startYear,this.growthRate)}getActiveYearRange(e){if(void 0===this.startYear)return;const t=this.startYear+this.config.yearsOfChildcare;return{start:this.startYear,end:Math.min(t,e)}}get yearlyChildExpenses(){return this.config.yearlyChildExpenses}get yearsOfChildcare(){return this.config.yearsOfChildcare}get upfrontChildCosts(){return this.config.upfrontChildCosts}get growthType(){var e;return null!==(e=this.config.growthType)&&void 0!==e?e:"inflation"}get growthRate(){var e;return null!==(e=this.config.growthRate)&&void 0!==e?e:void 0}}const mg=e=>{if(void 0===e||null===e)return 1;const t=Math.floor(Number(e));return!Number.isFinite(t)||t<1?1:t},pg=(e,t)=>
1"once"===e?{intervalYears:void 0}:{intervalYears:mg(t)},gg=(e,t,n,a)=>"yearly"!==t||void 0!==n&&((e,t,n)=>(e-t)%n===0)(e,n,a),hg={defaultName:"Income",ownerId:void 0,isIncluded:!0,isHidden:!1,isRequired:!1,icon:"trending-up",color:"green",foregroundColor:"green",eventKind:"income",frequency:"yearly",amount:0,intervalYears:1,growthType:"inflation"};class vg extends xp{getEffectiveIntervalYears(){return this.config.isHidden?1:mg(this.config.intervalYears)}get startYear(){var e;return null!==(e=this.config.startYear)&&void 0!==e?e:this.settings.startYear}get frequency(){return this.config.frequency}get amount(){return this.config.amount}get endYear(){return this.config.endYear}get ownerId(){return this.config.ownerId}get growthType(){var e;return null!==(e=this.config.growthType)&&void 0!==e?e:"inflation"}get growthRate(){var e;return null!==(e=this.config.growthRate)&&void 0!==e?e:void 0}get incomeEffectLabel(){return this.config.isHidden?_t.Et.ASSUMPTIONS.YEARLY_TAKE_HOME_INCOME_LABEL:"once"===this.config.frequency?"Income amount":"Yearly income amount"}getEffectDefinitions(){return[{id:"income",label:this.incomeEffectLabel,name:this.name,target:"income",computeAmount:e=>{let t=e.year;return this.resolveIncomeForYear(t)}}]}resolveIncomeForYear(e){return kp(this.config.amount,e,this.growthType,this.settings,this.startYear,this.growthRate)}isActiveInYear(e){return gg(e.year,this.config.frequency,this.startYear,this.getEffectiveIntervalYears())}getActiveYearRange(e){var t;if(void 0!==this.startYear)return"yearly"!==this.config.frequency?{start:this.startYear,end:this.startYear+1}:{start:this.startYear,end:null!==(t=this.config.endYear)&&void 0!==t?t:e}}}const fg=e=>{const t=e.filter((e=>"endOfPlan"===e.config.eventKind&&e.isIncluded)).map((e=>e.startYear)).filter((e=>void 0!==e));return t.length>0?Math.max(...t):null},Eg={defaultName:"New job",isIncluded:!0,icon:"briefcase",color:"lime",foregroundColor:"lime",eventKind:"newJob",incomeReductionTargets:[],yearlyTakeHomeIncome:0,signingBonus:0,ownerId:void 0,growthType:"inflation"};class yg extends xp{takeHomeAmountForYear(e){return void 0===this.startYear||this.config.yearlyTakeHomeIncome<=0?0:kp(this.config.yearlyTakeHomeIncome,e,this.growthType,this.settings,this.startYear,this.growthRate)}signingBonusAmountForYear(e){const t=this.startYear;return void 0===t||this.config.signingBonus<=0?0:e===t?wp(this.config.signingBonus,t,this.settings):0}getEffectDefinitions(){var e;const t=[],n=null!==(e=this.config.incomeReductionTargets)&&void 0!==e?e:[];for(const l of n)l.reductionPercent<=0||t.push({id:"reduction-".concat(l.targetEventId),label:"Income reduction",target:"income",targetEventId:l.targetEventId,computeAmount:e=>{const t=this.findIncomeSourceModel(e.eventModels,l.targetEventId);if(!t)return 0;return-t.getDirectIncomeEffectsTotal(e)*Math.min(Math.max(l.reductionPercent,0),100)/100}});const a=this.startYear;return void 0!==a&&this.config.yearlyTakeHomeIncome>0&&t.push({id:"new-job-take-home",label:_t.Et.ASSUMPTIONS.YEARLY_TAKE_HOME_INCOME_LABEL,target:"income",computeAmount:e=>{let t=e.year;return this.takeHomeAmountForYear(t)}}),void 0!==a&&this.config.signingBonus>0&&t.push({id:"signing-bonus",label:"Signing bonus",target:"income",computeAmount:e=>{let t=e.year;return this.signingBonusAmountForYear(t)}}),t}getDirectIncomeEffectsTotal(e){const t=this.getActiveYearRange(e.projectionEndYear,e.eventModels);return!t||e.year<t.start||e.year>=t.end?0:this.takeHomeAmountForYear(e.year)+this.signingBonusAmountForYear(e.year)}findIncomeSourceModel(e,t){return e.find((e=>Kp(e.config.eventKind)&&e.id===t&&e.config.isIncluded))}getActiveYearRange(e,t){if(void 0===this.startYear)return;const n=t?fg(t):null;return{start:this.startYear,end:n?n+1:e}}get ownerId(){return this.config.ownerId}get yearlyTakeHomeIncome(){return this.config.yearlyTakeHomeIncome}get signingBonus(){return this.config.signingBonus}get growthType(){var e;return null!==(e=this.config.growthType)&&void 0!==e?e:"inflation"}get growthRate(){var e;return null!==(e=this.config.growthRate)&&void 0!==e?e:void 0}}class bg extends xp{getEffectiveIntervalYears(){return mg(this.config.intervalYears)}getEffectDefinitions(){return[{id:"expense",label:"once"===this.config.frequency?"Expense amount":"Yearly expense amount",name:this.name,target:"expense",computeAmount:e=>{let t=e.year;
1return this.calculateAmount(t)}}]}calculateAmount(e){return kp(this.config.amount,e,this.growthType,this.settings,this.startYear,this.growthRate)}isActiveInYear(e){return gg(e.year,this.config.frequency,this.startYear,this.getEffectiveIntervalYears())}getActiveYearRange(e){var t;if(void 0!==this.startYear)return"yearly"!==this.config.frequency?{start:this.startYear,end:this.startYear+1}:{start:this.startYear,end:null!==(t=this.config.endYear)&&void 0!==t?t:e}}get frequency(){return this.config.frequency}get amount(){return this.config.amount}get endYear(){return this.config.endYear}get growthType(){var e;return null!==(e=this.config.growthType)&&void 0!==e?e:"inflation"}get growthRate(){var e;return null!==(e=this.config.growthRate)&&void 0!==e?e:void 0}}const xg={defaultName:"Retirement",ownerId:void 0,isIncluded:!0,icon:"sunset",color:"orange",foregroundColor:"orange",eventKind:"retirement",incomeReductionTargets:[],expenseMultiplier:1,additionalYearlyExpenses:6500,growthType:"inflation"};class wg extends xp{getEffectDefinitions(){var e;const t=[],n=null!==(e=this.config.incomeReductionTargets)&&void 0!==e?e:[];for(const a of n)a.reductionPercent<=0||t.push({id:"reduction-".concat(a.targetEventId),label:"Income reduction",target:"income",targetEventId:a.targetEventId,computeAmount:e=>{const t=this.findIncomeSourceModel(e.eventModels,a.targetEventId);if(!t)return 0;return-t.getDirectIncomeEffectsTotal(e)*Math.min(Math.max(a.reductionPercent,0),100)/100}});return 1!==this.expenseMultiplier&&t.push({id:"expense-adjustment",label:"Expense adjustment",target:"expense",computeAmount:e=>{const t=lg(e.eventModels);if(!t)return 0;const n=t.getEffects(e).reduce(((e,t)=>e+t.amount),0);return n<=0?0:n*(this.expenseMultiplier-1)}}),this.additionalYearlyExpenses>0&&t.push({id:"additional-expenses",label:"Additional yearly expenses",target:"expense",computeAmount:e=>{let t=e.year;return kp(this.additionalYearlyExpenses,t,this.growthType,this.settings,this.startYear,this.growthRate)}}),t}findIncomeSourceModel(e,t){return e.find((e=>Kp(e.config.eventKind)&&e.id===t&&e.isIncluded))}getActiveYearRange(e,t){if(void 0===this.startYear)return;const n=t?fg(t):null;return{start:this.startYear,end:n?n+1:e}}get ownerId(){return this.config.ownerId}get expenseMultiplier(){return this.config.expenseMultiplier}get additionalYearlyExpenses(){return this.config.additionalYearlyExpenses}get growthType(){var e;return null!==(e=this.config.growthType)&&void 0!==e?e:"inflation"}get growthRate(){var e;return null!==(e=this.config.growthRate)&&void 0!==e?e:void 0}}const Cg={defaultName:"Social Security",ownerId:void 0,isIncluded:!0,icon:"shield-user",color:"yellow",foregroundColor:"yellow",eventKind:"socialSecurity",monthlyBenefitAmount:2e3,growthType:"inflation"};class Ag extends xp{getEffectDefinitions(){return[{id:"social-security",label:"Yearly benefit",name:this.name,target:"income",computeAmount:e=>kp(12*this.monthlyBenefitAmount,e.year,this.growthType,this.settings,this.startYear,this.growthRate)}]}getActiveYearRange(e,t){var n;if(void 0===this.startYear)return;const a=this.ownerId&&t?null===(n=rg(t,this.ownerId))||void 0===n?void 0:n.startYear:void 0,l=a?a+1:e;return{start:this.startYear,end:l}}get ownerId(){return this.config.ownerId}get monthlyBenefitAmount(){var e;return null!==(e=this.config.monthlyBenefitAmount)&&void 0!==e?e:0}get growthType(){var e;return null!==(e=this.config.growthType)&&void 0!==e?e:"inflation"}get growthRate(){var e;return null!==(e=this.config.growthRate)&&void 0!==e?e:void 0}}class Ig extends xp{getEffectDefinitions(){return[{id:"windfall",label:"Income amount",name:this.name,target:"income",computeAmount:e=>wp(this.config.amount,e.year,this.settings)}]}get amount(){return this.config.amount}}var kg=n(94116);const Sg=new Set(["orange","yellow","green","red","gray","blue","sky","lime","purple","pink","indigo","teal","brown"]),Ng=e=>"string"===typeof e&&Sg.has(e),Tg=e=>"string"===typeof e&&Object.prototype.hasOwnProperty.call(kg,e),_g=(e,t)=>{var n,a;const l=null!==(n=e.startYear)&&void 0!==n?n:1/0,r=null!==(a=t.startYear)&&void 0!==a?a:1/0;return l===r?0:l-r},Dg=(e,t)=>
1{switch(e.eventKind){case"income":return new vg(e,t);case"annualExpense":return new Pp(e,t);case"buyAHome":return new Wp(e,t);case"retirement":return new wg(e,t);case"socialSecurity":return new Ag(e,t);case"careerBreak":return new ig(e,t);case"otherExpense":return new bg(e,t);case"windfall":return new Ig(e,t);case"haveAKid":return new ug(e,t);case"endOfPlan":return new dg(e,t);case"newJob":return new yg(e,t);default:throw new Error("Unknown eventKind: ".concat(e.eventKind))}},Rg={annualExpense:{defaultName:"Annual Expenses",isIncluded:!0,isHidden:!0,isRequired:!0,icon:"credit-card",color:"red",foregroundColor:"red",eventKind:"annualExpense",amount:0,growthType:"inflation"},income:hg,buyAHome:Vp,retirement:xg,socialSecurity:Cg,otherExpense:{defaultName:"New Expense",isIncluded:!0,icon:"credit-card",color:"red",foregroundColor:"red",eventKind:"otherExpense",frequency:"once",amount:0,growthType:"inflation"},haveAKid:{defaultName:"Have a kid",isIncluded:!0,icon:"stroller",color:"pink",foregroundColor:"pink",eventKind:"haveAKid",yearlyChildExpenses:18e3,yearsOfChildcare:13,upfrontChildCosts:4500,growthType:"inflation"},endOfPlan:cg,careerBreak:og,newJob:Eg,windfall:{defaultName:"Windfall",isIncluded:!0,isHidden:!1,isRequired:!1,icon:"treasure-chest",color:"green",foregroundColor:"green",eventKind:"windfall",amount:0}},Mg=(new Date).getFullYear()+15,Lg="Split extra savings",Og=["cash","taxable-investments","tax-deferred","tax-free-investments"],Pg=["cash","taxable-investments","tax-deferred","tax-free-investments"],Bg=308,zg=112,Fg=100,Gg=16,Yg=28,Ug={maximumFractionDigits:3,useGrouping:!1},Vg={orange:"bg-chart-event-background-orange",yellow:"bg-chart-event-background-yellow",green:"bg-chart-event-background-green",red:"bg-chart-event-background-red",gray:"bg-chart-event-background-gray",blue:"bg-chart-event-background-blue",sky:"bg-chart-event-background-sky",lime:"bg-chart-event-background-lime",purple:"bg-chart-event-background-purple",pink:"bg-chart-event-background-pink",indigo:"bg-chart-event-background-indigo",teal:"bg-chart-event-background-teal",brown:"bg-chart-event-background-brown"},Wg={orange:"text-chart-event-foreground-orange",yellow:"text-chart-event-foreground-yellow",green:"text-chart-event-foreground-green",red:"text-chart-event-foreground-red",gray:"text-chart-event-foreground-gray",blue:"text-chart-event-foreground-blue",sky:"text-chart-event-foreground-sky",lime:"text-chart-event-foreground-lime",purple:"text-chart-event-foreground-purple",pink:"text-chart-event-foreground-pink",indigo:"text-chart-event-foreground-indigo",teal:"text-chart-event-foreground-teal",brown:"text-chart-event-foreground-brown"},jg={orange:"text-scenario-icon-orange",yellow:"text-scenario-icon-yellow",green:"text-scenario-icon-green",red:"text-scenario-icon-red",gray:"text-scenario-icon-gray",blue:"text-scenario-icon-blue",sky:"text-scenario-icon-sky",lime:"text-scenario-icon-lime",purple:"text-scenario-icon-purple",pink:"text-scenario-icon-pink",indigo:"text-scenario-icon-indigo",teal:"text-scenario-icon-teal",brown:"text-scenario-icon-brown"},Hg={orange:"border-scenario-icon-orange",yellow:"border-scenario-icon-yellow",green:"border-scenario-icon-green",red:"border-scenario-icon-red",gray:"border-scenario-icon-gray",blue:"border-scenario-icon-blue",sky:"border-scenario-icon-sky",lime:"border-scenario-icon-lime",purple:"border-scenario-icon-purple",pink:"border-scenario-icon-pink",indigo:"border-scenario-icon-indigo",teal:"border-scenario-icon-teal",brown:"border-scenario-icon-brown"},Kg={orange:"bg-chart-event-border-orange",yellow:"bg-chart-event-border-yellow",green:"bg-chart-event-border-green",red:"bg-chart-event-border-red",gray:"bg-chart-event-border-gray",blue:"bg-chart-event-border-blue",sky:"bg-chart-event-border-sky",lime:"bg-chart-event-border-lime",purple:"bg-chart-event-border-purple",pink:"bg-chart-event-border-pink",indigo:"bg-chart-event-border-indigo",teal:"bg-chart-event-border-teal",brown:"bg-chart-event-border-brown"},qg={orange:"ring-chart-event-border-orange",yellow:"ring-chart-event-border-yellow",green:"ring-chart-event-border-green",red:"ring-chart-event-border-red",gray:"ring-chart-event-border-gray",blue:"ring-chart-event-border-blue",sky:"ring-chart-event-border-sky",lime:"ring-chart-event-border-lime",purple:"ring-chart-event-border-purple",pink:"ring-chart-event-border-pink",indigo:"ring-chart-event-border-indigo",teal:"ring-chart-event-border-teal",brown:"ring-chart-event-border-brown"},$g=["red","orange","yellow","lime","green","teal","sky","blue","indigo","purple","pink","brown"],Zg=["map","diamond","trending-up","treasure-chest","dollar-sign","credit-card","bar-chart","institution","calculator","percent","sunset","sun","moon","home","building","car","heart","gift","shield-user","briefcase","stroller","umbrella","graduation-cap","flame","ghost","calendar","user","target","award","star","compass","zap","mail","lock","camera","settings"],Jg=["gray",...$g],
1Xg=Zg,Qg={name:"",icon:"compass",color:"gray"},eh="https://www.monarch.com/blog/forecasting#general-assumptions-586ded21b012",th="https://help.monarch.com/hc/en-us/articles/48344305092244-Forecasting-in-Monarch#h_01KR1GBRC055KW48YMD1K8WRRN",nh="https://www.monarch.com/blog/forecasting#retirement-5d1bef560adc",ah="https://www.monarch.com/blog/forecasting#have-a-kid-3cb16588b58e",lh="https://www.monarch.com/blog/forecasting#expense-withdrawal-order-943c38a205ce",rh="https://www.monarch.com/blog/forecasting#extra-savings-6f8486c2b91f",oh="https://www.monarch.com/blog/forecasting#taxes-863e9e270cff",ih="https://www.monarch.com/blog/forecasting#paycheck-contributions-287c94014e4a",sh="https://www.monarch.com/blog/forecasting#buy-a-home-5486886df3fc";var ch=n(46848),dh=n.n(ch),uh=n(43595),mh=n(35875),ph=n(7558),gh=n(11505),hh=n(22306),vh=n(56909);const fh=(e,t)=>e.map((e=>Dg(e,t))),Eh=(e,t)=>e/t,yh=(e,t,n)=>({mode:e,inflationRate:t,planStartYear:n,toTodaysDollars:(a,l)=>"todaysDollars"===e?((e,t,n,a)=>e/Cp(n,a)(t))(a,l,n,t):a}),bh=(e,t)=>{let n=t.dollarMode;return e?e.snapshots.map((e=>({year:e.year,netWorth:"todaysDollars"===n?Eh(e.netWorth,e.cumulativeInflationFactor):e.netWorth}))):[]};var xh=n(16438),wh=n(88151),Ch=n.n(wh);const Ah=(e,t)=>{var n;const a=null!==(n=e.startYear)&&void 0!==n?n:t.startYear;return wp(e.homeValue,a,t)},Ih=e=>{let t=e.accounts;return e.events.forEach((n=>{"buyAHome"===n.eventKind&&(t=((e,t,n)=>(0,xh.jM)(e,(e=>{const a=e.find((e=>e.sourceEventExternalId===t.id&&"asset"===e.accountType.group)),l=e.find((e=>e.sourceEventExternalId===t.id&&"liability"===e.accountType.group)),r=Ah(t,n);if(a&&(a.name=t.name,a.balance=r,a.isIncluded=t.isIncluded),"finance"===t.purchaseMethod){const n=r*(1-t.downPaymentPercent/100),a=Fp(n,t.mortgageRate,t.mortgageTerm);l?(l.name="".concat(t.name," (Mortgage)"),l.balance=-n,l.interestRate=t.mortgageRate,l.minimumPayment=a,l.isIncluded=t.isIncluded):e.push({id:(o=t.id,Ch()(o,"a2039ae4-33ac-4c49-80b9-ba956415de25")),name:"".concat(t.name," (Mortgage)"),accountType:{type:"loan",group:"liability",subtype:"mortgage"},balance:-n,interestRate:t.mortgageRate,minimumPayment:a,isIncluded:t.isIncluded,isSynthetic:!0,sourceEventExternalId:t.id,reduceExpensesForPaidOffDebt:!1})}else if(l){const t=e.findIndex((e=>e.id===l.id));t>=0&&e.splice(t,1)}var o})))(t,n,e.settings))})),(0,U.A)((0,U.A)({},e),{},{accounts:t})};class kh extends Bp{}kh.DEFAULT_GROWTH_RATE=2,kh.DEFAULT_VOLATILITY=0,kh.CATEGORY="cash";class Sh extends bp{}Sh.DEFAULT_INTEREST_RATE=5,Sh.DEFAULT_VOLATILITY=0,Sh.CATEGORY="other";class Nh extends Bp{}Nh.DEFAULT_GROWTH_RATE=0,Nh.DEFAULT_VOLATILITY=0,Nh.CATEGORY="other";class Th extends Bp{}Th.DEFAULT_GROWTH_RATE=7,Th.DEFAULT_VOLATILITY=16,Th.CATEGORY="tax-deferred";class _h extends Bp{}_h.DEFAULT_GROWTH_RATE=7,_h.DEFAULT_VOLATILITY=16,_h.CATEGORY="tax-free-investments";class Dh extends Bp{}Dh.DEFAULT_GROWTH_RATE=7,Dh.DEFAULT_VOLATILITY=16,Dh.CATEGORY="taxable-investments";class Rh extends Bp{}Rh.DEFAULT_GROWTH_RATE=-15,Rh.DEFAULT_VOLATILITY=0,Rh.CATEGORY="other";new Set(["st_401k","st_403b","st_457b"]);const Mh=new Set(["roth","roth_401k","tfsa","fhsa","health_savings_account","health_reimbursement_arrangement","st_529","education_savings_account","resp","rdsp","isa","cash_isa","non_taxable_brokerage_account","qualifying_share_account"]),Lh=e=>"health_savings_account"===e.toLowerCase(),Oh=new Set(["ira","sep_ira","simple_ira","st_401a","st_401k","st_403b","st_457b","thrift_savings_plan","sarsep_pension","keogh_plan","profit_sharing_plan","fixed_annuity","variable_annuity","retirement","pension","sipp","rrsp","rrif","prif","lif","lrif","lira","lrsp","rlif"]),Ph=["sep_ira","simple_ira","pension","sarsep_pension","health_reimbursement_arrangement","profit_sharing_plan"],Bh=e=>Lh(e)||"rrsp"===e.toLowerCase(),zh=e=>(e=>{const t=e.toLowerCase();return t.includes("401")||t.includes("403b")||t.includes("457")||"thrift_savings_plan"===t||Lh(e)})(e)||Ph.includes(e.toLowerCase())||Bh(e),Fh=["rrif","lif","lrif","rlif","prif"],Gh=e=>{return"depository"===e.type||"brokerage"===e.type&&(t=e.subtype,!Fh.includes(t.toLowerCase())&&!(e=>zh(e)&&!Bh(e))(e.subtype));var t},Yh=e=>"brokerage"===e.type&&zh(e.subtype),Uh=e=>!Rp(e)&&e.isIncluded&&Yh(e.accountType),Vh=e=>"brokerage"===e.accountType.type&&zh(e.accountType.subtype)&&void 0===e.yearlyPaycheckContribution,Wh=e=>{if("depository"===e.type)return"cash";if("brokerage"===e.type){const t=e.subtype.toLowerCase();return Mh.has(t)?"tax-free-investments":Oh.has(t)?"tax-deferred":"taxable-investments"}return"real_estate"===e.type?"real-estate":"vehicle"===e.type?"other":"credit"===e.type?"credit-cards":"loan"===e.type?"loans":"other_liability"===e.type?"other-liability":"other"},jh=e=>{let t=e.accountType,n=e.componentKind;return"pretax"===n?"tax-deferred":"roth"===n?"tax-free-investments":Wh(t)},Hh={pretax:"Traditional",roth:"Roth"},Kh=(e,t)=>"".concat(e," (").concat(Hh[t],")"),qh={cash:kh,"tax-free-investments":_h,"tax-deferred":Th,"taxable-investments":Dh,"real-estate":zp,other:Nh,"credit-cards":Sh,loans:Sh,"other-liability":Sh};class $h{static classFor(e){const t=e.accountType;return"liability"===t.group?Sh:"vehicle"===t.type?Rh:qh[Wh(t)]}
1static create(e,t,n){return new($h.classFor(e))(e,t,n)}static defaultGrowthRate(e){return $h.classFor(e).DEFAULT_GROWTH_RATE}static defaultVolatility(e){return $h.classFor(e).DEFAULT_VOLATILITY}static createAll(e,t,n){const a=op(e);return a&&0!==a.components.length?a.components.map((a=>$h.createMixedComponent(e,t,a,n))):[$h.create(e,t,n)]}static createMixedComponent(e,t,n,a){const l="roth"===n.kind,r=(0,U.A)((0,U.A)({},e),{},{name:Kh(e.name,n.kind),balance:n.balance,yearlyPaycheckContribution:n.annualContribution,taxTreatmentConfig:null,penaltyRate:e.penaltyRate,penaltyFreeAge:e.penaltyFreeAge,withdrawalTiming:e.withdrawalTiming,withdrawalStartingYear:e.withdrawalStartingYear,ownerId:e.ownerId},l?{withdrawalTaxRate:0,taxableWithdrawalPercent:0}:{}),o=new(l?_h:Th)(r,t,a);return o.mixedComponentKind=n.kind,o}}const Zh=(e,t,n)=>e.reduce(((e,t)=>{var a,l;if(e.remaining<=0)return(0,U.A)((0,U.A)({},e),{},{allocations:(0,U.A)((0,U.A)({},e.allocations),{},{[t.accountId]:null!==(l=e.allocations[t.accountId])&&void 0!==l?l:0})});const o=(0,r.YW)(t).with({type:"percent"},(t=>e.remaining*(t.amount/100))).with({type:"dollarAmount"},(t=>{const a=null===n||void 0===n?void 0:n.inflateDollarAmountsToYear;if(void 0===a)return Math.min(t.amount,e.remaining);const l=wp(t.amount,a.year,a.settings);return Math.min(l,e.remaining)})).exhaustive();return{allocations:(0,U.A)((0,U.A)({},e.allocations),{},{[t.accountId]:(null!==(a=e.allocations[t.accountId])&&void 0!==a?a:0)+o}),remaining:e.remaining-o}}),{allocations:{},remaining:Math.max(0,t)}),Jh={st_401k:{penaltyRate:10,penaltyFreeAge:59.5},st_403b:{penaltyRate:10,penaltyFreeAge:59.5},st_457b:{penaltyRate:10,penaltyFreeAge:59.5},roth_401k:{penaltyRate:10,penaltyFreeAge:59.5},ira:{penaltyRate:10,penaltyFreeAge:59.5},roth:{penaltyRate:10,penaltyFreeAge:59.5},sep_ira:{penaltyRate:10,penaltyFreeAge:59.5},simple_ira:{penaltyRate:10,penaltyFreeAge:59.5},health_savings_account:{penaltyRate:20,penaltyFreeAge:65}},Xh=e=>{if(e)return Jh[e]},Qh=e=>{var t,n;if(!e)return;const a=Xh(e.accountType.subtype);if(!a)return;const l=null!==(t=e.penaltyRate)&&void 0!==t?t:a.penaltyRate;return l<=0?void 0:{penaltyRate:l,penaltyFreeAge:null!==(n=e.penaltyFreeAge)&&void 0!==n?n:a.penaltyFreeAge}},ev=(e,t)=>{const n=N.c9.fromISO(e,{zone:"utc"});if(!n.isValid)return;const a=Math.floor(t),l=Math.round(12*(t-a));return n.plus({years:a,months:l})},tv=(e,t)=>{var n;return null===(n=ev(e,t))||void 0===n?void 0:n.year},nv=(e,t)=>e.ownerId?e.ownerId:1===t.length?t[0]:void 0,av=(e,t,n)=>{var a;const l=nv(e,t);if(void 0!==l)return null===(a=n.find((e=>e.userId===l)))||void 0===a?void 0:a.birthday},lv=e=>void 0!==Xh(e),rv=Array.from({length:16},((e,t)=>55+t)).flatMap((e=>59===e?[59,59.5]:[e])),ov=(e,t,n)=>Math.max(t,Math.min(n,e)),iv=e=>{const t=Math.floor(e),n=e-t;return Math.abs(n-.5)<1e-9?"".concat(t,"\xbd"):String(e)},sv=rv.map((e=>({value:String(e),label:iv(e)}))),cv=e=>{let t=e.year,n=e.birthday,a=e.penaltyFreeAge;if(void 0===n)return;if(void 0!==a){if(tv(n,a)===t)return iv(a)}const l=(0,Ba.GB)(t,n);return void 0!==l?String(l):void 0},dv=e=>{let t=e.birthday,n=e.penaltyFreeAge,a=e.fallbackYear,l=e.maxYear;if(void 0!==t&&void 0!==n){const e=tv(t,n);if(void 0!==e)return ov(e,a,l)}return a},uv=e=>{let t=e.isPenaltyEligible,n=e.timing,a=e.ownerId,l=e.householdUserIds,r=e.ownerBirthday;if(!t||n===Ee.TXV.NEVER)return;return nv({ownerId:a},l)?r?void 0:"missing-birthday":l.length>1?"shared-ownership":void 0},mv=e=>{let t=e.account,n=e.settings,a=e.householdUserIds;const l=av(t,a,n.participants),r=(e=>{var t,n;return null!==(t=e.penaltyFreeAge)&&void 0!==t?t:null===(n=Xh(e.accountType.subtype))||void 0===n?void 0:n.penaltyFreeAge})(t);if(void 0!==l&&void 0!==r)return dv({birthday:l,penaltyFreeAge:r,fallbackYear:n.startYear,maxYear:n.startYear+n.projectionYears})},pv=e=>{const t=e.account;var n;return void 0!==t.withdrawalTiming?{timing:t.withdrawalTiming,startingYear:t.withdrawalTiming===Ee.TXV.STARTING_YEAR?null!==(n=t.withdrawalStartingYear)&&void 0!==n?n:mv(e):void 0}:lv(t.accountType.subtype)?{timing:Ee.TXV.STARTING_YEAR,startingYear:mv(e)}:{timing:Ee.TXV.ALWAYS}},gv=e=>{let t=e.account,n=e.settings,a=e.householdUserIds;const l=lv(t.accountType.subtype);if(!l)return{canCalculate:!0,alertKind:void 0};const r=pv({account:t,settings:n,householdUserIds:a}).timing;if(r===Ee.TXV.NEVER)return{canCalculate:!0,alertKind:void 0};const o=av(t,a,n.participants);return{canCalculate:void 0!==o,alertKind:uv({isPenaltyEligible:l,timing:r,ownerId:t.ownerId,householdUserIds:a,ownerBirthday:o})}},hv=e=>
1gv(e).canCalculate,vv=(e,t,n)=>jh({accountType:t(e),componentKind:null===n||void 0===n?void 0:n(e)}),fv=(e,t,n)=>!Rp(e)&&Og.includes(vv(e,t,n)),Ev=e=>e.withdrawalTiming!==Ee.TXV.NEVER,yv=(e,t,n,a,l,r)=>{const o=e.filter((e=>fv(e,t,l))).sort(((e,n)=>((e,t,n,a)=>Og.indexOf(vv(e,n,a))-Og.indexOf(vv(t,n,a)))(e,n,t,l)));return((e,t,n)=>{if(null===t||void 0===t||!t.length)return e;const a=new Map(t.map(((e,t)=>[e,t]))),l=new Map(e.map(((e,t)=>[e.rowKey.serialized,t]))),r=e=>{var t,l;return null!==(t=null!==(l=a.get(e.rowKey.serialized))&&void 0!==l?l:n?a.get(n(e)):void 0)&&void 0!==t?t:1/0};return[...e].sort(((e,t)=>{var n,a;const o=r(e),i=r(t);return o!==i?o-i:(null!==(n=l.get(e.rowKey.serialized))&&void 0!==n?n:0)-(null!==(a=l.get(t.rowKey.serialized))&&void 0!==a?a:0)}))})(n?[n,...o]:o,a,r)},bv=e=>{const t=op(e);return t?t.components.map((t=>(0,U.A)((0,U.A)({},e),{},{rowKey:hp(e.id,t.kind),forecastAccountId:e.id,mixedComponentKind:t.kind,name:Kh(e.name,t.kind)}))):[(0,U.A)((0,U.A)({},e),{},{rowKey:gp(e.id),forecastAccountId:e.id})]},xv=(e,t)=>{const n=e.find(_p),a=n&&n.isIncluded&&Ev(n)?n:void 0,l=e.filter((e=>e.isIncluded&&!_p(e))).filter((e=>Ev(e))).flatMap(bv);return yv(l,(e=>e.accountType),a?bv(a)[0]:void 0,t,(e=>e.mixedComponentKind),(e=>e.forecastAccountId))},wv=(e,t)=>null===e||void 0===e?void 0:e.filter((e=>vp(e).forecastAccountId!==t)),Cv=e=>{let t=e.account,n=e.year,a=e.settings,l=e.householdUserIds;return t.isIncluded()&&t.balance>0&&!Op(t.config)&&hv({account:t.config,settings:a,householdUserIds:l})&&(e=>{let t=e.account,n=e.year,a=e.settings,l=e.householdUserIds;const o=pv({account:t.config,settings:a,householdUserIds:l}),i=o.timing,s=o.startingYear;return(0,r.YW)(i).with(Ee.TXV.NEVER,(()=>!1)).with(Ee.TXV.STARTING_YEAR,(()=>void 0!==s&&n>=s)).with(Ee.TXV.ALWAYS,r.P.nullish,(()=>!0)).exhaustive()})({account:t,year:n,settings:a,householdUserIds:l})},Av=(e,t,n,a)=>{var l;const r=Qh(e.config);if(!r)return null;const o=nv({ownerId:e.ownerId},a);if(!o)return null;const i=null===(l=n.participants.find((e=>e.userId===o)))||void 0===l?void 0:l.birthday;if(!i)return null;const s=((e,t,n)=>{const a=ev(t,n);if(!a)return 1;const l=N.c9.utc(e,1,1),r=N.c9.utc(e+1,1,1),o=a.startOf("day");if(o<=l)return 0;if(o>=r)return 1;const i=r.diff(l,"days").days;return o.diff(l,"days").days/i})(t,i,r.penaltyFreeAge);return s<=0?null:{fraction:s,penaltyRate:r.penaltyRate}},Iv=(e,t,n,a)=>{const l=e.balance,r=Av(e,t,n,a);if(!r)return[{account:e,maxWithdrawalAmount:l,penaltyRate:0}];if(r.fraction>=1)return[{account:e,maxWithdrawalAmount:l,penaltyRate:r.penaltyRate}];const o=pv({account:e.config,settings:n,householdUserIds:a});if(o.timing===Ee.TXV.STARTING_YEAR&&o.startingYear===t)return[{account:e,maxWithdrawalAmount:l,penaltyRate:0}];return[{account:e,maxWithdrawalAmount:l*(1-r.fraction),penaltyRate:0},{account:e,maxWithdrawalAmount:l*r.fraction,penaltyRate:r.penaltyRate}]},kv=e=>{let t=e.account,n=e.settings,a=e.householdUserIds;return!Op(t)&&hv({account:t,settings:n,householdUserIds:a})},Sv=(e,t)=>{const n=e.config,a=n.yearlyPaycheckContribution,l=n.accountType,r=n.ownerId;if(!a||a<=0)return;const o="brokerage"===l.type?l.subtype:"";if(!zh(o))return;const i=((e,t)=>{const n=t.filter((e=>e instanceof wg&&e.isIncluded&&"number"===typeof e.startYear));if(0!==n.length){if(e){const t=n.find((t=>t.config.ownerId===e));if(t)return t.startYear}return Math.min(...n.map((e=>e.startYear)))}})(r,t);if(void 0!==i&&e.currentYear>=i)return;if(((e,t,n)=>{const a=n.filter((e=>e instanceof ig&&e.isIncluded&&"number"===typeof e.startYear)),l=t=>{const n=t.getActiveYearRange();return!!n&&e>=n.start&&e<n.end};return t?a.some((e=>e.config.ownerId===t&&l(e))):a.some(l)})(e.currentYear,r,t))return;const s=wp(a,e.currentYear,e.settings);e.balance=e.balance+s,e.recordContribution(s)},Nv={householdUserIds:[]};class Tv{constructor(e,t,n){var a,l;let r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};this.settings=void 0,this.uncategorizedSavingsSettings=void 0,this.cumulativeCashFlow=void 0,this.accounts=void 0,this.accountsByForecastId=void 0,this.events=void 0,this.includedLiabilities=void 0,this.includedAssets=void 0,this.allIncludedAccounts=void 0,this.activeAccounts=void 0,this.uncategorizedSavingsAccount=null,this.unfundedExpensesAccount=null,this.customWithdrawalOrderIds=void 0,this.options=void 0,this.rateProvider=void 0;const o=r.customWithdrawalOrderIds,i=r.uncategorizedSavingsSettings,s=r.options,c=void 0===s?Nv:s,d=r.asOfDate,u=r.rateProvider;this.rateProvider=null!==u&&void 0!==u?u:rp(e),this.options=c,this.settings=(0,U.A)((0,U.A)({},e),{},{inflationRate:this.rateProvider.getInflationRate(e.startYear),cumulativeInflationFactor:this.rateProvider.variesInflationByYear?lp(this.rateProvider,e.startYear):void 0}),this.uncategorizedSavingsSettings=i,this.cumulativeCashFlow=0,this.customWithdrawalOrderIds=o,this.accounts=t.flatMap((e=>$h.createAll(e,this.settings,this.rateProvider))),this.accountsByForecastId=new Map(this.accounts.map((e=>[e.forecastAccountId,e]))),this.events=n.map((e=>Dg(e,this.settings)));const m=(null!==d&&void 0!==d?d:new Date).getMonth(),p=new Map;
1this.accounts.forEach((e=>{if(e.mixedComponentKind){var t;const n=null!==(t=p.get(e.forecastAccountId))&&void 0!==t?t:[];n.push(e),p.set(e.forecastAccountId,n)}})),this.accounts.forEach((e=>{if(e.config.isSynthetic&&e.config.sourceEventExternalId){const n=this.events.find((t=>t.config.id===e.config.sourceEventExternalId));var t;if(n)e.activeStartYear=null!==(t=n.config.startYear)&&void 0!==t?t:void 0}e.config.isSynthetic||e.config.isSystemAccount||!this.canProject(e.config)||(e.balance=e.mixedComponentKind?this.computeMixedStartingBalance(e,p.get(e.forecastAccountId),m):this.computeStartingBalance(e,m))})),this.includedLiabilities=this.accounts.filter((e=>e.isIncluded()&&e instanceof bp&&this.canProject(e.config))),this.includedAssets=this.accounts.filter((e=>e.isIncluded()&&!(e instanceof bp)&&this.canProject(e.config))),this.allIncludedAccounts=this.accounts.filter((e=>e.isIncluded())),this.activeAccounts=this.accounts.filter((e=>e.isIncluded()&&this.canProject(e.config))),this.uncategorizedSavingsAccount=null!==(a=this.accounts.find((e=>_p(e.config))))&&void 0!==a?a:null,this.unfundedExpensesAccount=null!==(l=this.accounts.find((e=>Dp(e.config))))&&void 0!==l?l:null}canProject(e){var t;return kv({account:e,settings:this.settings,householdUserIds:null!==(t=this.options.householdUserIds)&&void 0!==t?t:[]})}computeStartingBalance(e,t){const n=e.config,a=e.getGrowthRate(this.settings.startYear),l=n.balance;if("liability"===n.accountType.group&&e instanceof bp){if(Np(l))return 0;const a=e.getInterestRate(),r=yp({plannedPayment:n.plannedPayment,minimumPayment:n.minimumPayment}),o=a/100/12;let i=l;for(let e=0;e<t;e+=1)i-=r,o>0&&(i/=1+o);return Math.min(0,i)}if("asset"===n.accountType.group){if(e.mixedComponentKind)throw new Error("Mixed Account legs must use computeMixedStartingBalance");return Tv.backCalcAssetStartingBalance(l,this.assetYearlyContribution(e),a,t)}return l}assetYearlyContribution(e){var t,n,a,l,r,o,i;const s=e.config,c="brokerage"===s.accountType.type?s.accountType.subtype:"",d=null!==(t=null===(n=this.uncategorizedSavingsSettings)||void 0===n?void 0:n.splitUncategorizedSavings)&&void 0!==t&&t&&Gh(s.accountType)&&!e.mixedComponentKind&&null!==(a=null===(l=(null!==(r=null===(o=this.uncategorizedSavingsSettings)||void 0===o?void 0:o.uncategorizedSavingsAllocation)&&void 0!==r?r:[]).find((e=>e.accountId===s.id&&"dollarAmount"===e.type)))||void 0===l?void 0:l.amount)&&void 0!==a?a:0;return(zh(c)&&null!==(i=s.yearlyPaycheckContribution)&&void 0!==i?i:0)+d}static backCalcAssetStartingBalance(e,t,n,a){let l=e-t/12*a;const r=n/100;if(r){const e=1+r*(a/12);e&&(l/=e)}return Math.max(0,l)}computeMixedStartingBalance(e,t,n){const a=(0,De.Eb)(t.map((e=>e.config.balance))),l=(0,De.Eb)(t.map((e=>this.assetYearlyContribution(e)))),r=Tv.backCalcAssetStartingBalance(a,l,e.getGrowthRate(this.settings.startYear),n);return Np(a)?r/t.length:r*(e.config.balance/a)}run(){var e;const t=[],n=this.buildEffectTable(),a=null!==(e=this.settings.cumulativeInflationFactor)&&void 0!==e?e:Cp(this.settings.startYear,this.settings.inflationRate);for(let l=0;l<=this.settings.projectionYears;l+=1){const e=this.settings.startYear+l,r=n.get(e),o=[];r&&r.forEach((e=>{o.push(...e)}));const i=this.sumEffects(o),s=i.totalIncome,c=i.totalExpenses,d=s-c;let u=d;this.includedLiabilities.forEach((t=>{t.resetYearTracking(e),u+=t.processYear()})),this.includedAssets.forEach((t=>{t.resetYearTracking(e),Sv(t,this.events)})),u>0?this.handleSurplus(u,e):u<0&&this.handleDeficit(Math.abs(u),e),this.includedAssets.forEach((e=>{e.processYear()}));const m=c+(d-u),p=this.allIncludedAccounts.map((e=>e.toSnapshot())),g=(0,De.Eb)(p.map((e=>e.breakdown?Math.abs(e.breakdown.withdrawals):0))),h=s-m+g;this.cumulativeCashFlow=this.cumulativeCashFlow+h;let v=0;this.activeAccounts.forEach((e=>{v+=e.balance})),t.push({year:e,accounts:p,netWorth:v,totalIncome:s,totalExpenses:m,netWithdrawals:g,netCashFlow:h,cumulativeCashFlow:this.cumulativeCashFlow,cumulativeInflationFactor:a(e)})}return{snapshots:t,effectTable:n,annotations:this.buildAnnotations(t)}}buildAnnotations(e){const t=[];return this.accounts.filter((e=>e instanceof bp&&e.isIncluded()&&!Rp(e)&&this.canProject(e.config))).forEac
1h((n=>{const a=gp(n.forecastAccountId),l=e.findIndex((e=>{if(void 0!==n.activeStartYear&&e.year<n.activeStartYear)return!1;const t=fp(e.accounts,a);return void 0!==t&&t.balance>=0}));if(-1===l)return;const r=e[l],o=e.slice(0,l+1).reduce(((e,t)=>{var n,l;const r=fp(t.accounts,a),o=null!==(n=null===r||void 0===r||null===(l=r.breakdown)||void 0===l?void 0:l.payments)&&void 0!==n?n:0;return{totalPayments:e.totalPayments+o,totalPaymentsTodaysDollars:e.totalPaymentsTodaysDollars+Eh(o,t.cumulativeInflationFactor)}}),{totalPayments:0,totalPaymentsTodaysDollars:0}),i=o.totalPayments,s=o.totalPaymentsTodaysDollars,c=n.getMonthlyPayment(),d=!1!==n.config.reduceExpensesForPaidOffDebt?12*c:0;t.push({id:"payoff-".concat(n.forecastAccountId),year:r.year,kind:"payoff",accountId:n.forecastAccountId,accountName:n.config.name,totalPayments:i,totalPaymentsTodaysDollars:s,yearlyExpenseReduction:d,yearlyExpenseReductionTodaysDollars:Eh(d,r.cumulativeInflationFactor),metadata:n.config.metadata})})),t}buildEffectTable(){const e=new Map,t=this.events.filter((e=>e.isIncluded&&e.isPrecomputable)),n=this.settings.startYear+this.settings.projectionYears+1;for(let a=0;a<=this.settings.projectionYears;a+=1){const l=this.settings.startYear+a,r={year:l,projectionEndYear:n,accountModels:this.accounts,eventModels:this.events},o=new Map;t.forEach((e=>{const t=e.getEffects(r);t.length>0&&o.set(e.id,t)})),o.size>0&&(this.capReductionsPerSource(o),this.capExpenseReductions(o),e.set(l,o))}return e}capReductionsPerSource(e){const t=new Map;e.forEach(((e,n)=>{let a=0;e.forEach((e=>{"income"===e.target&&void 0===e.targetEventId&&(a+=e.amount)})),a>0&&t.set(n,a)}));const n=[...this.events].sort(_g),a=new Map;n.forEach((t=>{const n=e.get(t.id);n&&n.forEach((e=>{if("income"===e.target&&void 0!==e.targetEventId&&e.amount<0){var t;const n=null!==(t=a.get(e.targetEventId))&&void 0!==t?t:[];n.push(e),a.set(e.targetEventId,n)}}))})),a.forEach(((e,n)=>{var a;let l=null!==(a=t.get(n))&&void 0!==a?a:0;e.forEach((e=>{const t=-e.amount,n=t<l?t:l;e.amount=0===n?0:-n,l-=n}))}))}capExpenseReductions(e){let t=0;e.forEach((e=>{e.forEach((e=>{"expense"===e.target&&e.amount>0&&(t+=e.amount)}))}));[...this.events].sort(_g).forEach((n=>{const a=e.get(n.id);a&&a.forEach((e=>{if("expense"===e.target&&e.amount<0){const n=-e.amount,a=n<t?n:t;e.amount=0===a?0:-a,t-=a}}))}))}sumEffects(e){let t=0,n=0;return e.forEach((e=>{"income"===e.target?t+=e.amount:n+=e.amount})),{totalIncome:t,totalExpenses:n}}handleSurplus(e,t){var n,a,l,r;let o=e;if(this.unfundedExpensesAccount&&this.unfundedExpensesAccount.balance<0){const e=Math.abs(this.unfundedExpensesAccount.balance),t=e<o?e:o;this.unfundedExpensesAccount.balance=this.unfundedExpensesAccount.balance+t,this.unfundedExpensesAccount.recordPayment(t),o-=t}const i=null!==(n=null===(a=this.uncategorizedSavingsSettings)||void 0===a?void 0:a.splitUncategorizedSavings)&&void 0!==n&&n,s=null!==(l=null===(r=this.uncategorizedSavingsSettings)||void 0===r?void 0:r.uncategorizedSavingsAllocation)&&void 0!==l?l:[];if(o>0&&i&&s.length>0){const e=s.filter((e=>{const t=this.accountsByForecastId.get(e.accountId);return t&&!_p(t.config)&&t.isIncluded()&&this.canProject(t.config)&&Gh(t.config.accountType)})),n=Zh(e,o,{inflateDollarAmountsToYear:{year:t,settings:this.settings}}),a=n.allocations,l=n.remaining;e.forEach((e=>{var t;const n=this.accountsByForecastId.get(e.accountId),l=null!==(t=a[e.accountId])&&void 0!==t?t:0;n&&l>0&&(n.balance=n.balance+l,n.recordDeposit(l))})),o=l}o>0&&this.uncategorizedSavingsAccount&&(this.uncategorizedSavingsAccount.balance=this.uncategorizedSavingsAccount.balance+o,this.uncategorizedSavingsAccount.recordDeposit(o))}handleDeficit(e,t){var n,a;let l=e;const r=((e,t,n,a)=>yv(e,(e=>e.config.accountType),a.uncategorizedSavings,a.customWithdrawalOrderIds,(e=>e.mixedComponentKind),(e=>e.forecastAccountId)).filter((e=>Cv({account:e,year:t,settings:n,householdUserIds:a.householdUserIds}))).flatMap((e=>Iv(e,t,n,a.householdUserIds))))(this.accounts,t,this.settings,{householdUserIds:null!==(n=this.options.householdUserIds)&&void 0!==n?n:[],uncategorizedSavings:null!==(a=this.uncategorizedSavingsAccount)&&void 0!==a?a:void 0,customWithdrawalOrderIds:this.customWithdrawalOrderIds});r.forEach((e=>{var t,n;if(l<=0)return;const a=e.account,r=e.maxWithdrawalAmount,o=e.penaltyRate;if(a.balance<=0||r<=0)return;const i=(null!==(t=a.config.withdrawalTaxRate)&&void 0!==t?t:0)/100*((null!==(n=a.config.taxableWithdrawalPercent)&&void 0!==n?n:100)/100),s=o/100,c=((e,t,n)=>{const a=t+n;return a<1?e/(1-a):e})(l,i,s),d=Math.min(r,a.balance),u=Math.min(c,d);if(u<=0)return;const m=((e,t,n)=>{const a=e*t,l=e*n;return{net:e-a-l,tax:a,penalty:l}})(u,i,s),p=m.net,g=m.tax,h=m.penalty;a.balance=a.balance-u,a.recordWithdrawal(p,g,h),l-=p})),this.recordUnfundedExpenses(l)}recordUnfundedExpenses(e){e>0&&this.unfundedExpensesAccount&&(this.unfundedExpensesAccount.balance=this.unfundedExpensesAccount.balance-e,this.unfundedExpensesAccount.re
1cordExpenses(e))}}const _v=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Nv;const n=Ih(e),a=new Date,l=function(e,t){return new Tv(e,t,arguments.length>2&&void 0!==arguments[2]?arguments[2]:[],arguments.length>3&&void 0!==arguments[3]?arguments[3]:{}).run()}(n.settings,n.accounts,n.events,{customWithdrawalOrderIds:n.customWithdrawalOrderIds,uncategorizedSavingsSettings:n.uncategorizedSavingsSettings,options:t,asOfDate:a});return{projection:l,preparedInput:n,asOfDate:a}};var Dv=n(90972);const Rv=["id","eventKind","name","startYear","isIncluded","icon","color","foregroundColor","isHidden","isRequired"],Mv=e=>"scenario"===e?"settings":"withdrawalRules"===e||"allocationRules"===e?"priorityRules":e,Lv={todaysDollars:Ee.L$s.TODAYSDOLLARS,futureDollars:Ee.L$s.FUTUREDOLLARS},Ov={fixed:Ee.svW.FIXED,schedule:Ee.svW.SCHEDULE,noChange:Ee.svW.NOCHANGE},Pv={[Ee.svW.FIXED]:"fixed",[Ee.svW.SCHEDULE]:"schedule",[Ee.svW.NOCHANGE]:"noChange"},Bv=e=>Ov[null!==e&&void 0!==e?e:"fixed"],zv=new Set(["ownerId"]),Fv=e=>{e.id,e.eventKind,e.name,e.startYear,e.isIncluded,e.icon,e.color,e.foregroundColor,e.isHidden,e.isRequired;return(0,En.A)(e,Rv)},Gv=e=>{var t;return(null!==(t=e.customWithdrawalOrderIds)&&void 0!==t?t:[]).map((e=>{var t;const n=vp(e);return{accountExternalId:n.forecastAccountId,componentKind:null!==(t=n.mixedComponentKind)&&void 0!==t?t:null,config:{}}}))},Yv=e=>{var t,n;return(null!==(t=null===(n=e.uncategorizedSavingsSettings)||void 0===n?void 0:n.uncategorizedSavingsAllocation)&&void 0!==t?t:[]).map((e=>({accountExternalId:e.accountId,config:{method:e.type,value:e.amount}})))},Uv=(e,t)=>{var n,a;const l=t.scenarioExternalId,i=Mv(e),s=null!==(n=null===(a=t.categoryVersions)||void 0===a?void 0:a[i])&&void 0!==n?n:0;return(0,r.YW)(e).with("scenario",(()=>{var e,n;return{mutation:Dv.VR,variables:{input:{scenarioExternalId:l,expectedVersion:s,inflationRate:t.settings.inflationRate,projectionYears:t.settings.projectionYears,useActualsAsBaseline:t.useActualsAsBaseline,splitUncategorizedSavings:null===(e=null===(n=t.uncategorizedSavingsSettings)||void 0===n?void 0:n.splitUncategorizedSavings)||void 0===e||e,dollarMode:t.dollarMode&&Lv[t.dollarMode],mcNumPaths:t.monteCarloSettings.numPaths,mcInflationVolatility:t.monteCarloSettings.inflationVolatility,mcShowFan:t.monteCarloSettings.showFan}}}})).with("events",(()=>{var e;return{mutation:Dv.FH,variables:{input:{scenarioExternalId:l,expectedVersion:s,events:(null!==(e=t.events)&&void 0!==e?e:[]).map((e=>{var t;return{externalId:e.id,eventKind:e.eventKind,name:e.name,startYear:e.startYear,isIncluded:e.isIncluded,isHidden:null!==(t=e.isHidden)&&void 0!==t&&t,icon:e.icon,color:e.color,config:Fv(e)}}))}}}})).with("accounts",(()=>({mutation:Dv.B_,variables:{input:{scenarioExternalId:l,expectedVersion:s,accounts:t.accounts.map((e=>{var t,n,a,l,r,i,s,c,d,u,m,p;const g=(h=e.growthRateSchedule)&&0!==h.length?dp(h):null;var h;const v=(f=null!==(t=e.growthRateMethod)&&void 0!==t?t:"fixed",E=g,"schedule"===f&&null===E?"fixed":f);var f,E;const y=(e=>{var t,n,a,l;return{withdrawalTiming:null!==(t=e.withdrawalTiming)&&void 0!==t?t:null,withdrawalStartingYear:null!==(n=e.withdrawalStartingYear)&&void 0!==n?n:null,penaltyRate:null!==(a=e.penaltyRate)&&void 0!==a?a:null,penaltyFreeAge:null!==(l=e.penaltyFreeAge)&&void 0!==l?l:null}})(e);return function(){const e={},t=new Set;for(var n=arguments.length,a=new Array(n),l=0;l<n;l++)a[l]=arguments[l];for(const i of a)for(const n of Object.entries(i)){var r=(0,o.A)(n,2);const a=r[0],l=r[1];"fieldsToReset"===a?l.forEach((e=>t.add(e))):e[a]=l}return t.size>0&&(e.fieldsToReset=[...t]),e}((0,U.A)((0,U.A)({externalId:e.id,isIncluded:e.isIncluded,growthRate:null!==(n=e.growthRate)&&void 0!==n?n:null,growthRateMethod:Bv(v),growthRateSchedule:g,volatility:null!==(a=e.volatility)&&void 0!==a?a:null,interestRate:null!==(l=e.interestRate)&&void 0!==l?l:null,minimumPayment:null!==(r=e.minimumPayment)&&void 0!==r?r:null,plannedPayment:null!==(i=e.plannedPayment)&&void 0!==i?i:null,withdrawalTaxRate:null!==(s=e.withdrawalTaxRate)&&void 0!==s?s:null,taxableWithdrawalPercent:null!==(c=e.taxableWithdrawalPercent)&&void 0!==c?c:null},y),{},{reduceExpensesForPaidOffDebt:null!==(d=e.reduceExpensesForPaidOffDebt)&&void 0!==d?d:null,yearlyPaycheckContribution:null!==(u=e.yearlyPaycheckContribution)&&void 0!==u?u:null}),(e=>{var t;return e.taxTreatmentConfig?{taxTreatmentConfig:{enabled:null===(t=e.taxTreatmentConfig.enabled)||void 0===t||t,components:e.taxTreatmentConfig.components.map((e=>({kind:e.kind,balance:e.balance,annualContribution:e.annualContribution})))}}:{}})(e),e.isSynthetic?(0,U.A)((0,U.A)({},e.sourceEventExternalId?{name:e.name,accountType:null===(m=e.accountType)||void 0===m?void 0:m.type,initialBalance:void 0!==e.balance?String(e.balance):null,sourceEventExternalId:e.sourceEventExternalId}:{}),{},{accountSubtype:null===(p=e.accountType)||void 0===p?void 0:p.subtype}):{})}))}}}))).with("participants",(()=>({mutation:Dv.oJ,variables:{input:{scenarioExternalId:l,expectedVersion:s,participants:t.settings.participants.map((e=>{var t;return{userId:e.userId,lifeExpectancy:null!==(t=e.lifeExpectancy)&&void 0!==t?t:null,isIncluded:!e.hiddenFromForecast}}))}}}))).with("withdrawalRules",(()=>({mutation:Dv.lY,variables:{input:{scenarioExternalId:l,expectedVersion:s,ruleType:"withdrawal",rules:Gv(t)}}}))).with("allocationRules",(()=>({mutation:Dv.lY,variables:{input:{scenarioExternalId:l,expectedVersion:s,ruleType:"allocation",rules:Yv(t)}}}))).exhaustive()}
1,Vv={scenario:"updateForecastScenario",events:"replaceForecastEvents",accounts:"saveForecastAccounts",participants:"saveForecastParticipantOverrides",withdrawalRules:"saveForecastPriorityRules",allocationRules:"saveForecastPriorityRules"},Wv="VERSION_CONFLICT",jv=(e,t)=>{var n;const a=null===e||void 0===e?void 0:e[Vv[t]];return null!==(n=null===a||void 0===a?void 0:a.newVersion)&&void 0!==n?n:null},Hv=(e,t)=>{var n;const a=null===e||void 0===e?void 0:e[Vv[t]];return(null===a||void 0===a||null===(n=a.errors)||void 0===n?void 0:n.message)===Wv},Kv=(e,t)=>{var n;const a=null===e||void 0===e?void 0:e[Vv[t]],l=null===a||void 0===a||null===(n=a.errors)||void 0===n?void 0:n.message;return l&&l!==Wv?l:null},qv=(e,t)=>{const n=e.filter((e=>e.birthday&&!e.hiddenFromForecast));if(0===n.length)return 50;const a=n.map((e=>{var t;return(0,Ba.NP)(e.birthday)+(null!==(t=e.lifeExpectancy)&&void 0!==t?t:sg)}));return Math.max(...a)-t},$v={brokerage:"asset",depository:"asset",real_estate:"asset",valuables:"asset",vehicle:"asset",other_asset:"asset",asset:"asset",credit:"liability",loan:"liability",other_liability:"liability",liability:"liability",other:"other"},Zv=e=>{var t,n,a,l,r,o,i,s,c,d,u,m,p,g,h,v,f,E,y,b,x,w,C,A,I,k,S;const N=null!==(t=$v[null!==(n=e.accountType)&&void 0!==n?n:""])&&void 0!==t?t:"other",T={type:e.accountType,group:N,subtype:e.accountSubtype},_=Wh(T),D=null!==(a=e.systemAccountType)&&void 0!==a?a:void 0,R=((e,t)=>"uncategorizedSavings"===t||"taxable-investments"===e?{defaultTaxRate:15,defaultTaxablePercent:80}:"tax-deferred"===e?{defaultTaxRate:20}:{})(_,D);return{id:e.externalId,monarchAccountId:null!==(l=e.monarchAccountId)&&void 0!==l?l:void 0,name:null!==(r=e.name)&&void 0!==r?r:"",balance:null!==(o=e.signedBalance)&&void 0!==o?o:0,accountType:T,isIncluded:e.isIncluded,metadata:{logoUrl:null!==(i=e.logoUrl)&&void 0!==i?i:void 0,subtypeDisplay:null!==(s=e.accountSubtypeDisplay)&&void 0!==s?s:void 0,icon:null!==(c=e.icon)&&void 0!==c?c:void 0},isSystemAccount:null!==e.systemAccountType&&void 0!==e.systemAccountType,systemAccountType:D,sourceEventExternalId:null!==(d=e.sourceEventExternalId)&&void 0!==d?d:void 0,isSynthetic:e.isSynthetic,isNew:e.isNew,isDeleted:e.isDeleted,growthRate:null!==(u=e.growthRate)&&void 0!==u?u:void 0,growthRateMethod:(M=e.growthRateMethod,null!==M&&void 0!==M?Pv[M]:"fixed"),growthRateSchedule:e.growthRateSchedule&&e.growthRateSchedule.length>0?dp(e.growthRateSchedule.map((e=>({year:e.year,rate:e.rate})))):void 0,volatility:null!==(m=e.volatility)&&void 0!==m?m:void 0,interestRate:null!==(p=e.interestRate)&&void 0!==p?p:void 0,plannedPayment:null!==(g=e.plannedPayment)&&void 0!==g?g:void 0,minimumPayment:null!==(h=e.minimumPayment)&&void 0!==h?h:void 0,reduceExpensesForPaidOffDebt:e.reduceExpensesForPaidOffDebt,yearlyPaycheckContribution:null!==(v=e.yearlyPaycheckContribution)&&void 0!==v?v:void 0,ownerId:null!==(f=e.ownerUserId)&&void 0!==f?f:void 0,withdrawalTaxRate:null!==(E=e.withdrawalTaxRate)&&void 0!==E?E:R.defaultTaxRate,taxableWithdrawalPercent:null!==(y=e.taxableWithdrawalPercent)&&void 0!==y?y:R.defaultTaxablePercent,withdrawalTiming:null!==(b=e.withdrawalTiming)&&void 0!==b?b:void 0,withdrawalStartingYear:null!==(x=e.withdrawalStartingYear)&&void 0!==x?x:void 0,penaltyRate:null!==(w=e.penaltyRate)&&void 0!==w?w:void 0,penaltyFreeAge:null!==(C=e.penaltyFreeAge)&&void 0!==C?C:void 0,linkedGrowthRate:null!==(A=e.linkedGrowthRate)&&void 0!==A?A:void 0,linkedInterestRate:null!==(I=e.linkedInterestRate)&&void 0!==I?I:void 0,linkedPlannedPayment:null!==(k=e.linkedPlannedPayment)&&void 0!==k?k:void 0,linkedMinimumPayment:null!==(S=e.linkedMinimumPayment)&&void 0!==S?S:void 0,isTaxTreatmentEligible:e.isTaxTreatmentEligible,taxTreatmentConfig:e.taxTreatmentConfig?{kind:"tax_treatment",enabled:e.taxTreatmentConfig.enabled,components:e.taxTreatmentConfig.components.map((e=>({kind:e.kind,balance:e.balance,annualContribution:e.annualContribution})))}:void 0};var M},Jv=e=>{var t,n,a,l,r,o,i,s;return{userId:null!==(t=null===(n=e.user)||void 0===n?void 0:n.id)&&void 0!==t?t:"",displayName:(null===(a=e.user)||void 0===a?void 0:a.displayName)||"Member",birthday:null!==(l=null===(r=e.user)||void 0===r?void 0:r.birthday)&&void 0!==l?l:void 0,profilePictureUrl:null!==(o=null===(i=e.user)||void 0===i?void 0:i.profilePictureUrl)&&void 0!==o?o:void 0,lifeExpectancy:null!==(s=e.lifeExpectancy)&&void 0!==s?s:sg,hiddenFromForecast:!e.isIncluded}},Xv=e=>{var t,n,a,l,r,i,s,c;const d=Rg[e.eventKind],u=null!==(t=null!==(n=e.color)&&void 0!==n?n:null===d||void 0===d?void 0:d.color)&&void 0!==t?t:"gray",m={id:e.externalId,eventKind:e.eventKind,name:null!==(a=e.name)&&void 0!==a?a:"Event",startYear:e.startYear,isIncluded:null===(l=e.isIncluded)||void 0===l||l,icon:null!==(r=null!==(i=e.icon)&&void 0!==i?i:null===d||void 0===d?void 0:d.icon)&&void 0!==r?r:"calendar",color:u,foregroundColor:u,isHidden:null!==(s=e.isHidden)&&void 0!==s&&s,isRequired:null!==(c=e.isRequired)&&void 0!==c&&c};return(0,U.A)((0,U.A)({},m),((e,t)=>{if(!t)return{};const n=Rg[e];return Object.fromEntries(Object.entries(t).map((e=>{let t=(0,o.A)(e,2),a=t[0],l=t[1];if("string"!==typeof l)return[a,l];const r=null===n||void 0===n?void 0:n[a];if(void 0!==r){if("number"===typeof r){const e=Number(l);return[a,Number.isNaN(e)?l:e]}return[a,l]}if(zv.has(a))return[a,l];const i=l.trim();if(""===i)return[a,l];const s=Number(i);return Number.isNaN(s)||!Number.isSafeInteger(s)?[a,l]:[a,s]})))})(e.eventKind,e.config))},Qv=e=>{var t;const n=(null!==(t=e.priorityRules)&&void 0!==t?t:[]).filter((e=>"withdrawal"===e.ruleType)).sort(((e,t)=>e.order-t.order));return n.length>0?n.filter((e=>e.accountExternalId)).map((e=>(e=>{const t=e.accountExternalId;return e.componentKind&&pp(e.componentKind)?hp(t,e.componentKind):gp(t)})({accountExternalId:e.accountExternalId,componentKind:e.componentKind}).serialized)):void 0},ef=e=>{var t,n;const a=(null!==(t=e.priorityRules)&&void 0!==t?t:[]).filter((e=>"allocation"===e.ruleType)).sort(((e,t)=>e.order-t.order));if(0!==a.length)return{splitUncategorizedSavings:null===(n=e.splitUncategorizedSavings)||void 0===n||n,uncategorizedSavingsAllocation:a.map((e=>{var t,n;return{accountId:e.accountExternalId,type:"dollarAmount"===(null===(t=e.config)||void 0===t?void 0:t.method)?"dollarAmount":"percent",amount:Number(null===(n=e.config)||void 0===n?void 0:n.value)||0}})).filter((e=>Boolean(e.accountId)))}},tf=e=>{var t,n,a,l,r,o,i,s;const c=(null!==(t=e.participants)&&void 0!==t?t:[]).map(Jv),d=(null!==(n=e.accounts)&&void 0!==n?n:[]).map(Zv),u=(null!==(a=e.events)&&void 0!==a?a:[]).map(Xv),m=(new Date).getFullYear();return{accounts:d,events:u,settings:{startYear:m,projectionYears:qv(c,m),participants:c,inflationRate:null!==(l=e.inflationRate)&&void 0!==l?l:3},customWithdrawalOrderIds:Qv(e),uncategorizedSavingsSettings:ef(e),presetAmounts:{annualIncome:null!==(r=e.baselineIncome)&&void 0!==r?r:0,annualExpenses:null!==(o=e.baselineExpenses)&&void 0!==o?o:0},useActualsAsBaseline:null===(i=e.useActualsAsBaseline)||void 0===i||i,dollarMode:null!==(s=e.dollarMode)&&void 0!==s?s:"futureDollars",monteCarlo:{numPaths:e.mcNumPaths,inflationVolatility:e.mcInflationVolatility,showFan:e.mcShowFan}}};var nf=n(99593);const af=(e,t)=>
1[t,...e.filter((e=>e!==t))],lf=(e,t,n)=>{const a=e.filter((e=>e!==t)),l=null===n?-1:a.indexOf(n);return-1===l?[t,...a]:[...a.slice(0,l+1),t,...a.slice(l+1)]},rf=(e,t)=>{var n;return null!==(n=e.byScenarioId[t])&&void 0!==n?n:{status:"idle"}},of=(0,mh.v)((e=>({byScenarioId:{},recentScenarioIds:[],startRun:t=>e((e=>{var n;return{byScenarioId:(0,U.A)((0,U.A)({},e.byScenarioId),{},{[t]:(0,U.A)((0,U.A)({},rf(e,t)),{},{status:"running",progress:void 0})}),recentScenarioIds:null!==(n=e.byScenarioId[t])&&void 0!==n&&n.result?af(e.recentScenarioIds,t):e.recentScenarioIds}})),setRunProgress:(t,n)=>e((e=>{var a;return"running"!==(null===(a=e.byScenarioId[t])||void 0===a?void 0:a.status)?e:{byScenarioId:(0,U.A)((0,U.A)({},e.byScenarioId),{},{[t]:(0,U.A)((0,U.A)({},rf(e,t)),{},{progress:n})})}})),cancelRun:t=>e((e=>({byScenarioId:(0,U.A)((0,U.A)({},e.byScenarioId),{},{[t]:(0,U.A)((0,U.A)({},rf(e,t)),{},{status:"idle",progress:void 0})})}))),failRun:t=>e((e=>({byScenarioId:(0,U.A)((0,U.A)({},e.byScenarioId),{},{[t]:(0,U.A)((0,U.A)({},rf(e,t)),{},{status:"failed",progress:void 0})})}))),setResultForScenario:(t,n,a)=>e((e=>(e=>{if(e.recentScenarioIds.length<=2)return e;const t=e.recentScenarioIds.slice(0,2),n=new Set(e.recentScenarioIds.slice(2));return{byScenarioId:Object.fromEntries(Object.entries(e.byScenarioId).flatMap((e=>{let t=(0,o.A)(e,2),a=t[0],l=t[1];return n.has(a)?"idle"===l.status?[]:[[a,{status:l.status}]]:[[a,l]]}))),recentScenarioIds:t}})({byScenarioId:(0,U.A)((0,U.A)({},e.byScenarioId),{},{[t]:{status:"idle",result:n}}),recentScenarioIds:t===a?af(e.recentScenarioIds,t):lf(e.recentScenarioIds,t,a)}))),markScenarioUsed:t=>e((e=>{var n;return null!==(n=e.byScenarioId[t])&&void 0!==n&&n.result?e.recentScenarioIds[0]===t?e:{recentScenarioIds:af(e.recentScenarioIds,t)}:e})),clearResultForScenario:t=>e((e=>{if(!(t in e.byScenarioId))return e;const n=e.byScenarioId;n[t];return{byScenarioId:(0,En.A)(n,[t].map(nf.A)),recentScenarioIds:e.recentScenarioIds.filter((e=>e!==t))}})),reset:()=>e({byScenarioId:{},recentScenarioIds:[]})}))),sf=e=>Gh(e.accountType),cf=40,df=60,uf=5,mf=95,pf=(e,t)=>
1{const n=e.length;if(0===n)throw new Error("percentileOf: no values to take a percentile of");if(1===n)return e[0];const a=t/100*(n-1),l=Math.floor(a),r=Math.ceil(a);return e[l]+(e[r]-e[l])*(a-l)},gf=(e,t)=>{if(e.some((e=>!Number.isFinite(e))))throw new Error("".concat(t," contains a non-finite value"))},hf=(e,t)=>{if(0===e.length)return[];const n=e[0].length;if(e.some((e=>e.length!==n)))throw new Error("aggregateBands: every path must cover the same number of years");const a=[];for(let l=0;l<n;l+=1){const n=e.map((e=>e[l]));gf(n,"aggregateBands: net worth series"),n.sort(((e,t)=>e-t)),a.push({year:t+l,p5:pf(n,uf),p40:pf(n,cf),p50:pf(n,50),p60:pf(n,df),p95:pf(n,mf)})}return a},vf=(e,t)=>hf(e.map((e=>e.netWorthByYear)),t),ff=(e,t)=>hf(e.map((e=>e.netWorthByYear.map(((t,n)=>Eh(t,e.cumulativeInflationFactorByYear[n]))))),t),Ef=(e,t)=>{const n=t/100/(1+e/100);return Math.sqrt(Math.log((1+Math.sqrt(1+4*n*n))/2))},yf=e=>Np(e)||e<0,bf=e=>{let t=e.outOfMoneyYear,n=e.endingNetWorth;return null===t&&!yf(n)},xf=(e,t)=>{const n=e.cumulativeInflationFactorByYear[e.cumulativeInflationFactorByYear.length-1];return t&&void 0!==n?Eh(e.endingNetWorth,n):e.endingNetWorth},wf=(e,t)=>t?Eh(e.netWorth,e.cumulativeInflationFactor):e.netWorth,Cf={success:"text-content-success",warning:"text-content-warning",danger:"text-content-danger",neutral:"text-content-secondary"},Af=[{color:"red",upToFraction:.25},{color:"orange",upToFraction:.5},{color:"yellow",upToFraction:.8},{color:"green",upToFraction:1}],If=e=>{if(e<=0)return[];const t=[];return Af.forEach(((n,a)=>{let l=n.color,r=n.upToFraction;const o=a===Af.length-1?e:Math.floor(r*e),i=0===a?0:t[a-1].max+1;t.push({color:l,min:i,max:o})})),t},kf={red:{arc:"stroke-chart-fill-red",dot:"bg-chart-fill-red",fill:"fill-chart-fill-red"},orange:{arc:"stroke-chart-fill-orange",dot:"bg-chart-fill-orange",fill:"fill-chart-fill-orange"},yellow:{arc:"stroke-chart-fill-yellow",dot:"bg-chart-fill-yellow",fill:"fill-chart-fill-yellow"},green:{arc:"stroke-chart-fill-green",dot:"bg-chart-fill-green",fill:"fill-chart-fill-green"}},Sf=Af.map(((e,t)=>{let n=e.color,a=e.upToFraction;return{color:n,range:"".concat(0===t?0:Math.round(100*Af[t-1].upToFraction)+1,"\u2013").concat(Math.round(100*a),"%")}})),Nf=e=>{if(e>=1||e<=0)return(0,De.gj)(e);const t=Math.min(Math.max((e=>Math.round(100*e))(e),1),99);return(0,De.gj)(t/100)},Tf=["onTrack","offTrack"],_f=e=>e>0,Df=(e,t)=>{let n=t.successFloor,a=t.isTodaysDollars;return bf(e)?((e,t)=>
1e-t>=-Sp.Y?"onTrack":"offTrack")(xf(e,a),n):"offTrack"},Rf={onTrack:{color:"forecast-path-on-track",bgClass:"bg-forecast-path-on-track"},offTrack:{color:"forecast-path-off-track",bgClass:"bg-forecast-path-off-track"}},Mf={onTrack:{status:"success",qualifier:{word:"On track",icon:fe.C14}},offTrack:{status:"danger",qualifier:{word:"Off track",icon:fe.QqB}}},Lf=(e,t)=>0===e.length?null:e.filter((e=>"onTrack"===Df(e,t))).length/e.length,Of=e=>5*Math.round(20*e),Pf=["num_paths"],Bf=["failure_kind","success_rate","num_paths","completed_paths","duration_ms"],zf=()=>({scenario_id:wE.getState().scenarioExternalId}),Ff=(e,t)=>{if("income"===e)return t?"income_source":"forecast_event"},Gf=e=>{let t=e.scenarioId,n=e.source;(0,Ge.u4)(Ye.yq.ScenarioCreated,(0,U.A)((0,U.A)({source:n},zf()),t?{scenario_id:t}:{}))},Yf=e=>{(0,Ge.u4)(Ye.yq.OnboardingCarouselViewed,(0,U.A)({page:e},zf()))},Uf=e=>Math.max(500*Math.round(e/500),sp),Vf=e=>{let t=e.failure_kind,n=e.success_rate,a=e.num_paths,l=e.completed_paths,r=e.duration_ms,o=(0,En.A)(e,Bf);return(0,Ge.u4)(Ye.yq.MonteCarloRunFinished,(0,U.A)((0,U.A)((0,U.A)({},o),{},{num_paths:Uf(a),completed_pct:Of(l/a),duration_ms:(i=r,i<5e3?250*Math.round(i/250):i<3e4?1e3*Math.round(i/1e3):Math.min(5e3*Math.round(i/5e3),12e4))},void 0===t?{}:{failure_kind:t}),void 0===n||null===n?{}:{success_rate:Of(n)}));var i},Wf=e=>{(0,Ge.u4)(Ye.yq.ScenarioCompareEntryPointClicked,(0,U.A)((0,U.A)({},e),zf()))},jf=e=>{(0,Ge.u4)(Ye.yq.ScenarioCompareTargetSelected,(0,U.A)((0,U.A)({},e),zf()))},Hf=new Set(["scenario","participants","withdrawalRules","allocationRules"]),Kf=e=>({id:dh()(),name:cg.defaultName,isIncluded:cg.isIncluded,icon:cg.icon,color:cg.color,eventKind:cg.eventKind,isRequired:cg.isRequired,ownerId:e.userId}),qf=e=>e.filter((e=>{var t;return"income"===e.eventKind&&null!==(t=e.isHidden)&&void 0!==t&&t})),$f=e=>e.find((e=>"annualExpense"===e.eventKind&&!0===e.isHidden)),Zf=(e,t)=>e.find((e=>"endOfPlan"===e.eventKind&&e.ownerId===t)),Jf=(e,t)=>{if(!t)return{amount:0,hasDrift:!1};const n=(0,De.hj)(e-eE(t))||0;return{amount:n,hasDrift:!Np(n)}},Xf=(e,t)=>e.components.find((e=>e.kind===t)),Qf=(e,t,n)=>(0,U.A)((0,U.A)({},e),{},{components:e.components.map((e=>e.kind===t?(0,U.A)((0,U.A)({},e),n):e))}),eE=e=>(0,De.Eb)(e.components.map((e=>e.balance))),tE=e=>(0,De.Eb)(e.components.map((e=>e.annualContribution))),nE=e=>e?Jf(e.balance,op(e)):{amount:0,hasDrift:!1},aE=e=>{let t=e.snapshots,n=e.accounts,a=e.settings,l=e.householdUserIds;const r=new Map(n.map((e=>[e.id,e]))),o=new Map;return t.forEach((e=>{e.accounts.forEach((e=>{var t,n;const i=(s=e).mixedComponentKind?hp(s.forecastAccountId,s.mixedComponentKind):gp(s.forecastAccountId);var s;const c=i.serialized;if(o.has(c))return;const d=r.get(e.forecastAccountId),u=d?gv({account:d,settings:a,householdUserIds:l}):{canCalculate:!0,alertKind:void 0},m=u.canCalculate,p=u.alertKind;o.set(c,{rowKey:i,forecastAccountId:e.forecastAccountId,account:d,mixedComponentKind:e.mixedComponentKind,name:e.name,accountType:e.accountType,systemAccountType:e.systemAccountType,group:e.accountType.group,taxBucket:jh({accountType:e.accountType,componentKind:e.mixedComponentKind}),logoUrl:null===d||void 0===d||null===(t=d.metadata)||void 0===t?void 0:t.logoUrl,icon:null===d||void 0===d||null===(n=d.metadata)||void 0===n?void 0:n.icon,isEditable:!!d,hasMissingDetails:!!d&&Op(d),canCalculateWithdrawalPenalty:m,earlyWithdrawalAlertKind:p,needsContributionSetup:!!d&&Vh(d),growthRate:null===d||void 0===d?void 0:d.growthRate,interestRate:null===d||void 0===d?void 0:d.interestRate,isSynthetic:null===d||void 0===d?void 0:d.isSynthetic,isSystemAccount:null===d||void 0===d?void 0:d.isSystemAccount,isLinkedAccountDeleted:!(null===d||void 0===d||!d.isDeleted),drift:nE(d)})}))})),[...o.values()]},lE=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:65;return N.c9.fromISO(e).year+t},rE=(e,t)=>{var n;return null!==(n=t.find((t=>(0,r.W9)({eventKind:"retirement",isIncluded:!0,ownerId:e.userId,startYear:r.P.number},t))))&&void 0!==n?n:null},oE=(e,t)=>{var n;if(!e.birthday)return null;const a=rE(e,t);return a&&null!==(n=(0,Ba.GB)(a.startYear,e.birthday))&&void 0!==n?n:null},iE=()=>{const e=vy().openEvent,t=QE().startYear;return(0,a.useCallback)((n=>
1{const a=wE.getState().events,l=n.birthday?lE(n.birthday):t,r={ownerId:n.userId,startYear:l,eventKind:"retirement",isIncluded:!0},o=(null!==a&&void 0!==a?a:[]).filter((e=>qp(e)&&Jp(r,e))),i=((e,t,n)=>{const a=wE.getState().createEventOfType,l=e.birthday?lE(e.birthday):t;return a("retirement",(0,U.A)({startYear:l,ownerId:e.userId},n))})(n,t,(0,U.A)({},ng(o)));e(i)}),[e,t])};var sE=n(70729);const cE=["startYear"],dE=["defaultName"],uE=(0,mh.v)((e=>({tableHoveredYear:null,chartHoveredYear:null,setTableHoveredYear:t=>e({tableHoveredYear:t}),setChartHoveredYear:t=>e({chartHoveredYear:t})})));let mE=!1;const pE=e=>{mE||uE.getState().setTableHoveredYear(e)},gE=e=>uE.subscribe(((t,n)=>{t.tableHoveredYear===n.tableHoveredYear&&t.chartHoveredYear===n.chartHoveredYear||e((()=>{const e=uE.getState(),t=e.tableHoveredYear,n=e.chartHoveredYear;return[...new Set([t,n].filter((e=>null!==e)))]})())})),hE=()=>{const e=uE((e=>e.setTableHoveredYear));return(0,a.useCallback)((t=>{mE||e(t)}),[e])},vE=e=>uE((t=>t.tableHoveredYear===e||t.chartHoveredYear===e)),fE={accounts:[],events:[],settings:{startYear:(new Date).getFullYear(),projectionYears:50,participants:[],inflationRate:3},monteCarloSettings:(0,U.A)({},ip),scenarioExternalId:void 0,categoryVersions:void 0,scenarioMetadata:void 0,dirtyCategories:{},savingCategories:{},saveErrors:{},isConflicted:!1,lastSavedAt:null,useActualsAsBaseline:void 0,dollarMode:void 0,customWithdrawalOrderIds:void 0,uncategorizedSavingsSettings:void 0,presetAmounts:void 0,currentUserId:void 0,householdUserIds:[],projection:null,projectionAsOfDate:null,error:null,needsInitialization:!0,isCompletingOnboarding:!1,isScenarioMetadataEditorOpen:!1,pendingScenarioMetadataEditorAutoOpen:!1,forecastOperation:null,rawScenarioSnapshot:void 0},EE=e=>{try{var t;const n=_v({settings:e.settings,accounts:e.accounts,events:null!==(t=e.events)&&void 0!==t?t:[],customWithdrawalOrderIds:e.customWithdrawalOrderIds,uncategorizedSavingsSettings:e.uncategorizedSavingsSettings},{householdUserIds:e.householdUserIds}),a=n.projection,l=n.preparedInput,r=n.asOfDate;e.accounts=l.accounts,e.projection=a,e.projectionAsOfDate=r,e.error=null}catch(n){e.projection=null,e.projectionAsOfDate=null,e.error="Unable to calculate forecast. Your data may be corrupted."}},yE=function(e,t,n){var a;let l=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},r=l.startYear,o=(0,En.A)(l,cE);const i=Rg[t],s=i.defaultName,c=(0,En.A)(i,dE),d="ownerId"in c?e.settings.participants.find((t=>t.userId===e.currentUserId)):void 0,u=d?{ownerId:d.userId}:{},m=(0,U.A)((0,U.A)((0,U.A)({},c),u),{},{id:n,name:s,startYear:void 0!==r?r:e.settings.startYear},o),p="careerBreak"===(g=m).eventKind?(0,U.A)((0,U.A)({},g),{},{endYear:g.startYear&&!g.endYear?g.startYear+1:g.endYear}):g;var g;e.events=[...null!==(a=e.events)&&void 0!==a?a:[],p],"buyAHome"===t&&bE(e,p)},bE=(e,t)=>{const n=Ah(t,e.settings),a={id:dh()(),name:t.name,accountType:{type:"real_estate",group:"asset",subtype:"primary_home"},balance:n,growthRate:zp.DEFAULT_GROWTH_RATE,isIncluded:t.isIncluded,isSynthetic:!0,sourceEventExternalId:t.id};if(e.accounts.push(a),"finance"===t.purchaseMethod){const a=n*(1-t.downPaymentPercent/100),l={id:dh()(),name:"".concat(t.name," (Mortgage)"),accountType:{type:"loan",group:"liability",subtype:"mortgage"},balance:-a,interestRate:t.mortgageRate,minimumPayment:Fp(a,t.mortgageRate,t.mortgageTerm),isIncluded:t.isIncluded,isSynthetic:!0,sourceEventExternalId:t.id,reduceExpensesForPaidOffDebt:!1};e.accounts.push(l)}},xE=(e,t,n)=>{var a,l,r,o;const i=(new Date).getFullYear(),s=t.birthday?N.c9.fromISO(t.birthday).year:void 0;var c,d,u;(qf(null!==(a=e.events)&&void 0!==a?a:[]).some((e=>e.ownerId===t.userId))||yE(e,"income",dh()(),{name:"Income (".concat(t.displayName,")"),amount:n,frequency:"yearly",ownerId:t.userId,startYear:null,isHidden:!0,isRequired:!1,isIncluded:!0}),s&&s+65>i&&(c=null!==(l=e.events)&&void 0!==l?l:[],d=t.userId,!c.find((e=>"socialSecurity"===e.eventKind&&e.ownerId===d)))&&yE(e,"socialSecurity",dh()(),{ownerId:t.userId,startYear:s+65,monthlyBenefitAmount:2e3,isIncluded:!0}),t.birthday&&!((e,t)=>e.find((e=>"retirement"===e.eventKind&&e.ownerId===t)))(null!==(r=e.events)&&void 0!==r?r:[],t.userId)&&yE(e,"retirement",dh()(),{ownerId:t.userId,startYear:lE(t.birthday),isIncluded:!0}),t.birthday&&!Zf(null!==(o=e.events)&&void 0!==o?o:[],t.userId)
1)&&(e.events=[...null!==(u=e.events)&&void 0!==u?u:[],Kf(t)])},wE=(0,mh.v)()((0,ph.lt)((0,uh.P)((0,gh.D)(((e,t)=>(0,U.A)((0,U.A)({},fE),{},{updateAccount:(t,n)=>e((e=>{const a=e.accounts.find((e=>e.id===t));if(a){Object.assign(a,n);(!1===n.isIncluded||n.withdrawalTiming===Ee.TXV.NEVER)&&(e.customWithdrawalOrderIds=wv(e.customWithdrawalOrderIds,t)),EE(e)}})),removeDeletedAccount:(t,n)=>{const a=wE.temporal.getState(),l=a.isTracking;kE=!0,l&&a.pause();try{e((e=>{e.accounts=e.accounts.filter((e=>e.id!==t)),e.customWithdrawalOrderIds=wv(e.customWithdrawalOrderIds,t),e.uncategorizedSavingsSettings&&(e.uncategorizedSavingsSettings.uncategorizedSavingsAllocation=e.uncategorizedSavingsSettings.uncategorizedSavingsAllocation.filter((e=>e.accountId!==t))),e.categoryVersions&&(e.categoryVersions.accounts=n.accountsVersion,e.categoryVersions.priorityRules=n.priorityRulesVersion),EE(e)}))}finally{l&&(a.clear(),a.resume()),kE=!1}},setCustomWithdrawalOrder:t=>e((e=>{e.customWithdrawalOrderIds=t,EE(e)})),enableMixedAccount:t=>e((e=>{const n=e.accounts.find((e=>e.id===t));if(n){var a;if(n.taxTreatmentConfig)n.taxTreatmentConfig=(0,U.A)((0,U.A)({},((e,t)=>{var n,a;const l=tE(e),r=null!==(n=null===(a=Xf(e,"pretax"))||void 0===a?void 0:a.annualContribution)&&void 0!==n?n:0,o=0===l?Math.round(t/2):Math.round(t*(r/l));return Qf(Qf(e,"pretax",{annualContribution:o}),"roth",{annualContribution:t-o})})(n.taxTreatmentConfig,null!==(a=n.yearlyPaycheckContribution)&&void 0!==a?a:0)),{},{enabled:!0});else n.taxTreatmentConfig=((e,t)=>{const n=e/2,a=(null!==t&&void 0!==t?t:0)/2;return{kind:"tax_treatment",components:[{kind:"pretax",balance:n,annualContribution:a},{kind:"roth",balance:n,annualContribution:a}]}})(n.balance,n.yearlyPaycheckContribution);e.customWithdrawalOrderIds=((e,t)=>{if(!e)return e;const n=e.indexOf(t);return-1===n?e:[...e.slice(0,n),...mp.map((e=>hp(t,e).serialized)),...e.slice(n+1)]})(e.customWithdrawalOrderIds,t),EE(e)}})),disableMixedAccount:t=>e((e=>{const n=e.accounts.find((e=>e.id===t));null!==n&&void 0!==n&&n.taxTreatmentConfig&&(n.taxTreatmentConfig=(0,U.A)((0,U.A)({},n.taxTreatmentConfig),{},{enabled:!1}),e.customWithdrawalOrderIds=((e,t)=>{if(!e)return e;const n=new Set(mp.map((e=>hp(t,e).serialized))),a=e.findIndex((e=>n.has(e)));return-1===a?e:e.flatMap(((e,l)=>l===a?[t]:n.has(e)?[]:[e]))})(e.customWithdrawalOrderIds,t),EE(e))})),updateMixedComponent:(t,n,a)=>e((e=>{const l=e.accounts.find((e=>e.id===t));null!==l&&void 0!==l&&l.taxTreatmentConfig&&(l.taxTreatmentConfig=Qf(l.taxTreatmentConfig,n,a),void 0!==a.annualContribution&&(l.yearlyPaycheckContribution=tE(l.taxTreatmentConfig)),EE(e))})),updateEvent:(t,n)=>e((e=>{var a;const l=(null!==(a=e.events)&&void 0!==a?a:[]).find((e=>e.id===t));if(l){const a="ownerId"in l?l.ownerId:void 0;var r,o,i;if(Object.assign(l,n),qp(l)&&"isIncluded"in n&&!1===n.isIncluded)(null!==(r=e.events)&&void 0!==r?r:[]).forEach((e=>{Hp(e.eventKind)&&"incomeReductionTargets"in e&&Array.isArray(e.incomeReductionTargets)&&(e.incomeReductionTargets=e.incomeReductionTargets.filter((e=>e.targetEventId!==t)))}));if(qp(l)&&"ownerId"in n&&n.ownerId!==a)(null!==(o=e.events)&&void 0!==o?o:[]).forEach((e=>{Hp(e.eventKind)&&e.ownerId===a&&"incomeReductionTargets"in e&&Array.isArray(e.incomeReductionTargets)&&(e.incomeReductionTargets=e.incomeReductionTargets.filter((e=>e.targetEventId!==t)))}));if(("startYear"in n||"endYear"in n)&&(qp(l)||Hp(l.eventKind)))s=null!==(i=e.events)&&void 0!==i?i:[],c=l,Xp(s),qp(c)&&Qp(s,c),Hp(c.eventKind)&&eg(s,c);EE(e)}var s,c})),removeEvent:n=>{var a;const l=null!==(a=t().events)&&void 0!==a?a:[],r=l.find((e=>e.id===n));null!==r&&void 0!==r&&r.isRequired||"income"===(null===r||void 0===r?void 0:r.eventKind)&&r.isHidden&&l.filter((e=>"income"===e.eventKind&&e.isHidden)).length<=1||(e((e=>{var t;const a=(null!==(t=e.events)&&void 0!==t?t:[]).filter((e=>e.id!==n));e.events=a.map((e=>Hp(e.eventKind)&&"incomeReductionTargets"in e&&Array.isArray(e.incomeReductionTargets)?(0,U.A)((0,U.A)({},e),{},{incomeReductionTargets:e.incomeReductionTargets.filter((e=>e.targetEventId!==n))}):e)),e.accounts.some((e=>e.sourceEventExternalId===n))&&(e.accounts=e.accounts.filter((e=>e.sourceEventExternalId!==n))),EE(e)})),r&&(e=>{const t=Ff(e.eventKind,e.isHidden);(0,Ge.u4)(Ye.yq.EventDeleted,(0,U.A)((0,U.A)({type:e.eventKind,event_id:e.id},t&&{income_origin:t}),zf()))})(r))},createEventOfType:function(n){var a;let l=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const r=dh()();e((e=>{var t;yE(e,n,r,l);const a=(null!==(t=e.events)&&void 0!==t?t:[]).find((e=>e.id===r));var o,i,s;a&&qp(a)&&(i=null!==(o=e.events)&&void 0!==o?o:[],Qp(i,s=a),Hp(s.eventKind)&&eg(i,s));EE(e)}));const o=(null!==(a=t().events)&&void 0!==a?a:[]).find((e=>e.id===r));return o&&(e=>{const t=Ff(e.eventKind,e.isHidden);(0,Ge.u4)(Ye.yq.EventAdded,(0,U.A)((0,U.A)({type:e.eventKind,event_id:e.id},t&&{income_origin:t}),zf()))})(o),r},initializeOnboardingEvents:()=>e((e=>{var t,n,a,l;const r=null!==(t=e.events)&&void 0!==t?t:[],o=e.settings.participants.filter((e=>!e.hiddenFromForecast)),i=qf(r).length>0,s=null!==(n=null===(a=e.presetAmounts)||void 0===a?void 0:a.annualIncome)&&void 0!==n?n:0,c=o.length>0?Math.round(s/o.length*100)/100:0;o.forEach((t=>{xE(e,t,i?0:c)}));const d=null!==(l=e.events)&&void 0!==l?l:[];d.forEach((e=>{"incomeReductionTargets"in e&&eg(d,e)})),EE(e)})),updateSettings:t=>e((e=>{Object.assign(e.settings,t),EE(e)})),updateMonteCarloSettings:t=>e((e=>{Object.assign(e.monteCarloSettings,t)})),updateParticipant:(t,n)=>e((e=>{const a=e.settings.participants.find((e=>e.userId===t));
1if(a){const o=Boolean(a.birthday),i=a.hiddenFromForecast;Object.assign(a,n);const s=Boolean(a.birthday);if(!o&&s){var l;const n=null!==(l=e.events)&&void 0!==l?l:[];Zf(n,t)||(e.events=[...n,Kf(a)])}if(i&&!a.hiddenFromForecast){var r;xE(e,a,0);const t=null!==(r=e.events)&&void 0!==r?r:[];t.forEach((e=>{"incomeReductionTargets"in e&&eg(t,e)}))}("lifeExpectancy"in n||"hiddenFromForecast"in n)&&(e.settings.projectionYears=qv(e.settings.participants,e.settings.startYear)),EE(e)}})),setUseActualsAsBaseline:t=>e((e=>{if(e.useActualsAsBaseline=t,t&&e.presetAmounts){var n;const t=null!==(n=e.events)&&void 0!==n?n:[],a=$f(t);a&&(a.amount=e.presetAmounts.annualExpenses)}EE(e)})),setDollarMode:t=>e((e=>{e.dollarMode=t})),setSplitUncategorizedSavings:t=>e((e=>{var n;const a=e.uncategorizedSavingsSettings;e.uncategorizedSavingsSettings={splitUncategorizedSavings:t,uncategorizedSavingsAllocation:null!==(n=null===a||void 0===a?void 0:a.uncategorizedSavingsAllocation)&&void 0!==n?n:[]},EE(e)})),setUncategorizedSavingsAllocation:t=>e((e=>{var n;const a=t.map((e=>"percent"===e.type?(0,U.A)((0,U.A)({},e),{},{amount:Math.max(0,Math.min(100,e.amount))}):(0,U.A)((0,U.A)({},e),{},{amount:Math.max(0,e.amount)}))),l=e.uncategorizedSavingsSettings;e.uncategorizedSavingsSettings={splitUncategorizedSavings:null!==(n=null===l||void 0===l?void 0:l.splitUncategorizedSavings)&&void 0!==n&&n,uncategorizedSavingsAllocation:a},EE(e)})),hydrateFromScenario:n=>{const a=t();if(a.needsInitialization||a.scenarioExternalId!==n.externalId||!a.categoryVersions||!((e,t)=>{if(!e.categoryVersions)return!1;const n=e.categoryVersions.settingsVersion,a=e.categoryVersions.eventsVersion,l=e.categoryVersions.accountsVersion,r=e.categoryVersions.participantsVersion,o=e.categoryVersions.priorityRulesVersion;return n<t.settings||a<t.events||l<t.accounts||r<t.participants||o<t.priorityRules})(n,a.categoryVersions)){kE=!0,PE();try{e((e=>{e.isCompletingOnboarding=!1,e.scenarioExternalId=n.externalId,e.scenarioMetadata={name:n.name,icon:Tg(n.icon)?n.icon:Qg.icon,
1color:Ng(n.color)?n.color:Qg.color},e.categoryVersions=n.categoryVersions?{settings:n.categoryVersions.settingsVersion,events:n.categoryVersions.eventsVersion,accounts:n.categoryVersions.accountsVersion,participants:n.categoryVersions.participantsVersion,priorityRules:n.categoryVersions.priorityRulesVersion}:void 0;const t=tf(n);e.accounts=t.accounts,e.events=t.events,e.settings=t.settings,e.monteCarloSettings=t.monteCarlo,e.customWithdrawalOrderIds=t.customWithdrawalOrderIds,e.uncategorizedSavingsSettings=t.uncategorizedSavingsSettings,e.presetAmounts=t.presetAmounts,e.useActualsAsBaseline=t.useActualsAsBaseline,e.dollarMode=t.dollarMode,e.dirtyCategories={},e.savingCategories={},e.saveErrors={},e.isConflicted=!1,e.lastSavedAt=null,e.needsInitialization=!1,e.rawScenarioSnapshot=n,EE(e)}))}finally{kE=!1}}},setCurrentUserId:t=>e((e=>{e.currentUserId=t})),setHouseholdUserIds:n=>{const a=t().householdUserIds;if(a.length===n.length&&a.every(((e,t)=>e===n[t])))return;const l=wE.temporal.getState(),r=l.isTracking;kE=!0,r&&l.pause();try{e((e=>{e.householdUserIds=[...n],e.needsInitialization||EE(e)}))}finally{r&&l.resume(),kE=!1}},setScenarioMetadata:t=>e((e=>{var n;const a=null!==(n=e.scenarioMetadata)&&void 0!==n?n:Qg;e.scenarioMetadata=(0,U.A)((0,U.A)({},a),t)})),setIsCompletingOnboarding:t=>e({isCompletingOnboarding:t}),openScenarioMetadataEditor:()=>e((e=>{e.isScenarioMetadataEditorOpen=!0})),closeScenarioMetadataEditor:()=>e((e=>{e.isScenarioMetadataEditorOpen=!1})),queueScenarioMetadataEditorAutoOpen:()=>e((e=>{e.pendingScenarioMetadataEditorAutoOpen=!0})),clearScenarioMetadataEditorAutoOpen:()=>e((e=>{e.pendingScenarioMetadataEditorAutoOpen=!1})),setForecastOperation:t=>e((e=>{e.forecastOperation=t})),clearForecastOperation:()=>e((e=>{e.forecastOperation=null})),reset:()=>e(fE)}))),{limit:100,equality:vh.x,partialize:e=>({accounts:e.accounts,events:e.events,settings:e.settings,useActualsAsBaseline:e.useActualsAsBaseline,dollarMode:e.dollarMode,monteCarloSettings:e.monteCarloSettings,customWithdrawalOrderIds:e.customWithdrawalOrderIds,uncategorizedSavingsSettings:e.uncategorizedSavingsSettings}),handleSet:e=>Dr().debounce((t=>{e(t)}),500,{leading:!0,trailing:!1}),wrapTemporal:e=>(t,n,a)=>{const l=e(t,n,a);return(0,U.A)((0,U.A)({},l),{},{undo:e=>TE("undo",(()=>l.undo(e))),redo:e=>TE("redo",(()=>l.redo(e)))})}}),{name:"ForecastStore"}));wE.temporal.getState().pause(),(0,sE.m0)(wE,(()=>wE.temporal.getState().clear()));const CE=Dr().debounce((()=>{const e=wE.getState();if(e.needsInitialization||0===e.accounts.length)return;const t=wE.temporal.getState(),n=t.isTracking;n&&t.pause();try{var a;const t=_v({settings:e.settings,accounts:e.accounts,events:null!==(a=e.events)&&void 0!==a?a:[],customWithdrawalOrderIds:e.customWithdrawalOrderIds,uncategorizedSavingsSettings:e.uncategorizedSavingsSettings},{householdUserIds:e.householdUserIds}),n=t.projection,l=t.preparedInput,r=t.asOfDate;wE.setState({accounts:l.accounts,projection:n,projectionAsOfDate:r,error:null})}catch(l){wE.setState({projection:null,projectionAsOfDate:null,error:"Unable to calculate forecast. Your data may be corrupted."})}finally{n&&t.resume()}}),30,{leading:!1,trailing:!0});let AE;wE.subscribe(((e,t)=>{if(e.needsInitialization||t.needsInitialization)return;const n=e.accounts!==t.accounts||e.events!==t.events||e.settings!==t.settings||e.customWithdrawalOrderIds!==t.customWithdrawalOrderIds||e.uncategorizedSavingsSettings!==t.uncategorizedSavingsSettings,a=e.projection===t.projection;n&&a&&CE()})),wE.subscribe(((e,t)=>{e.scenarioExternalId!==t.scenarioExternalId&&e.scenarioExternalId&&of.getState().markScenarioUsed(e.scenarioExternalId)}));let IE,kE=!1;const SE=e=>{IE=e};let NE="forecast";const TE=(e,t)=>{const n=NE;NE=e;try{t()}finally{NE=n}},_E={current:new Map},DE={current:new Map},RE={current:new Map},ME=(e,t)=>{const n=e.current.get(t);n?n.add(NE):e.current.set(t,new Set([NE]))},LE=e=>{const t=e.current;return e.current=new Map,t},OE=(e,t)=>{for(const a of t){var n=(0,o.A)(a,2);const t=n[0],l=n[1],r=e.current.get(t);if(r)for(const e of l)r.add(e);else e.current.set(t,new Set(l))}},PE=()=>
1{_E.current=new Map,DE.current=new Map,RE.current=new Map};wE.subscribe(((e,t)=>{if(kE)return;if(e.needsInitialization||t.needsInitialization)return;if(0===e.accounts.length)return;const n=[];if(e.events!==t.events){var a,l;n.push("events");const r=new Map((null!==(a=t.events)&&void 0!==a?a:[]).map((e=>[e.id,e])));(null!==(l=e.events)&&void 0!==l?l:[]).forEach((e=>{const t=r.get(e.id);t&&e!==t&&ME(_E,e.id)}))}if(e.accounts!==t.accounts){var r,o;n.push("accounts");const a=new Map((null!==(r=t.accounts)&&void 0!==r?r:[]).map((e=>[e.id,e])));(null!==(o=e.accounts)&&void 0!==o?o:[]).forEach((e=>{const t=a.get(e.id);t&&e!==t&&ME(DE,e.id)}))}var i,s;(e.settings.participants!==t.settings.participants&&n.push("participants"),e.customWithdrawalOrderIds!==t.customWithdrawalOrderIds&&n.push("withdrawalRules"),e.uncategorizedSavingsSettings!==t.uncategorizedSavingsSettings)&&(n.push("allocationRules"),(null===(i=t.uncategorizedSavingsSettings)||void 0===i?void 0:i.splitUncategorizedSavings)!==(null===(s=e.uncategorizedSavingsSettings)||void 0===s?void 0:s.splitUncategorizedSavings)&&n.push("scenario"));if(e.settings.inflationRate===t.settings.inflationRate&&e.settings.projectionYears===t.settings.projectionYears&&e.useActualsAsBaseline===t.useActualsAsBaseline&&e.dollarMode===t.dollarMode&&e.monteCarloSettings===t.monteCarloSettings||n.push("scenario"),0===n.length)return;for(const c of n)ME(RE,c);clearTimeout(AE),AE=setTimeout((()=>{var e;return null===(e=IE)||void 0===e?void 0:e()}),500);n.every((t=>e.dirtyCategories[t]))||wE.setState((e=>{for(const t of n)e.dirtyCategories[t]=!0,delete e.saveErrors[t]}))}));const BE=()=>wE((e=>{var t;return null!==(t=e.scenarioMetadata)&&void 0!==t?t:Qg})),FE=()=>{const e=wE((e=>e.isScenarioMetadataEditorOpen)),t=wE((e=>e.openScenarioMetadataEditor)),n=wE((e=>e.closeScenarioMetadataEditor));return(0,a.useMemo)((()=>({isOpen:e,open:t,close:n,toggle:()=>{wE.getState().isScenarioMetadataEditorOpen?n():t()}})),[e,t,n])},GE=(e,t)=>wE((n=>{var a;return(null===(a=n.forecastOperation)||void 0===a?void 0:a.kind)===e&&n.forecastOperation.phase===t})),YE=()=>wE((e=>e.setForecastOperation)),UE=()=>wE((e=>e.clearForecastOperation)),VE=()=>wE((e=>e.queueScenarioMetadataEditorAutoOpen)),WE=()=>wE((e=>e.projection)),jE=[],HE=[],KE=()=>wE((e=>e.accounts)),qE=()=>wE((e=>{var t;return null!==(t=e.events)&&void 0!==t?t:jE})),$E=()=>wE((e=>{var t;return $f(null!==(t=e.events)&&void 0!==t?t:jE)})),ZE=()=>wE((0,hh.k)((e=>{var t;const n=new Set(e.settings.participants.filter((e=>e.hiddenFromForecast)).map((e=>e.userId)));return qf(null!==(t=e.events)&&void 0!==t?t:jE).filter((e=>!e.ownerId||!n.has(e.ownerId)))})));function JE(e,t){return wE((n=>{var a;return(null!==(a=n.events)&&void 0!==a?a:jE).find((n=>n.id===e&&(void 0===t||n.eventKind===t)))}))}const XE=()=>{const e=wE((e=>{var t;return null!==(t=e.events)&&void 0!==t?t:jE})),t=wE((e=>e.settings));return(0,a.useMemo)((()=>{try{return fh(e,t)}catch(n){return s.Cp(n,{level:"warning"}),[]}}),[e,t])},QE=()=>wE((e=>e.settings)),ey=()=>wE((e=>e.monteCarloSettings.showFan)),ty=()=>wE((e=>e.settings.participants.find((t=>t.userId===e.currentUserId)))),ny=()=>wE((e=>e.settings.participants.filter((e=>!e.hiddenFromForecast)).length>1)),ay=()=>wE((e=>{var t;return null===(t=e.useActualsAsBaseline)||void 0===t||t})),ly=[],ry=()=>wE((e=>{var t,n;return null!==(t=null===(n=e.uncategorizedSavingsSettings)||void 0===n?void 0:n.splitUncategorizedSavings)&&void 0!==t&&t})),oy=()=>wE((e=>{var t,n;return null!==(t=null===(n=e.uncategorizedSavingsSettings)||void 0===n?void 0:n.uncategorizedSavingsAllocation)&&void 0!==t?t:ly})),iy=()=>wE((e=>e.presetAmounts)),sy=()=>{const e=wE((e=>e.projection)),t=wE((e=>{var t;return null!==(t=e.dollarMode)&&void 0!==t?t:"futureDollars"}));return(0,a.useMemo)((()=>bh(e,{dollarMode:t})),[e,t])},cy=()=>{const e=wE((e=>e.accounts)),t=wE((e=>e.customWithdrawalOrderIds));return(0,a.useMemo)((()=>xv(e,t)),[e,t])},dy=()=>{const e=wE((e=>e.accounts)),t=wE((e=>{var t,n;return null!==(t=null===(n=e.uncategorizedSavingsSettings)||void 0===n?void 0:n.uncategorizedSavingsAllocation)&&void 0!==t?t:ly}));return(0,a.useMemo)((()=>{const n=e.find(_p);return((e,t,n)=>{if(0===e.length&&!n)return[];const a=Object.fromEntries(e.map((e=>[e.id,e]))),l=new Set(t.map((e=>e.accountId)));return[...t.map((e=>a[e.accountId])).filter((e=>void 0!==e&&sf(e))),...e.filter((e=>!l.has(e.id))).filter(sf).sort(((e,t)=>Pg.indexOf(Wh(e.accountType))-Pg.indexOf(Wh(t.accountType)))),...n?[
1n]:[]]})(e.filter((e=>e.isIncluded&&!_p(e))),t,null!==n&&void 0!==n?n:void 0)}),[e,t])},uy=e=>{const t=wE((e=>{var t;return null===(t=e.projection)||void 0===t?void 0:t.annotations})),n=XE();return(0,a.useMemo)((()=>{var a;if(!t||!e)return null;const l=t.find((t=>"payoff"===t.kind&&t.accountId===e)),r=null!==(a=null===l||void 0===l?void 0:l.year)&&void 0!==a?a:null,o=(e=>{const t=e.filter((e=>"endOfPlan"===e.config.eventKind&&e.isIncluded)).map((e=>e.startYear)).filter((e=>void 0!==e));return t.length>0?Math.min(...t):null})(n);let i;return i=null===r?"never":o&&r>o?"late":"success",{payoffYear:r,endOfPlanYear:o,status:i}}),[t,n,e])},my=()=>{const e=(()=>{const e=(0,mh.P)(wE.temporal,(e=>e)),t=e.undo,n=e.redo,a=e.clear,l=e.pastStates,r=e.futureStates;return{undo:t,redo:n,clear:a,canUndo:l.length>0,canRedo:r.length>0}})(),t=e.undo,n=e.redo,l=e.canUndo,r=e.canRedo;(0,a.useEffect)((()=>{const e=e=>{(e.metaKey||e.ctrlKey)&&("z"===e.key&&!e.shiftKey&&l?(e.preventDefault(),t()):"z"===e.key&&e.shiftKey&&r&&(e.preventDefault(),n()))};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)}),[t,n,l,r])},py=()=>{var e;const t=(0,lt.L7)(),n=t.householdPreferences,a=t.isLoadingInitialData;return{isEnabled:null!==(e=null===n||void 0===n?void 0:n.forecastMonteCarloExperimentEnabled)&&void 0!==e&&e,isResolved:!a}},gy=["event","account","assumptions","chance-of-success","withdrawal-order","new-event","uncategorized-savings"],hy=()=>{const e=QE();return(0,a.useMemo)((()=>e.participants.filter((e=>!e.hiddenFromForecast)).map((e=>({value:e.userId,label:e.displayName})))),[e.participants])},vy=()=>{const e=(0,b.ii)(),t=(0,o.A)(e,2),n=t[0],l=t[1],r=py().isEnabled,i=(0,a.useMemo)((()=>{const e="string"===typeof n.sidebar?n.sidebar:null,t="string"===typeof n.id?n.id:null,a="string"===typeof n.year?n.year:null,l="string"===typeof n.focusAccountId?n.focusAccountId:null;return fy(e,t,a,l,r)}),[n,r]),s=(0,a.useCallback)((e=>{const t={sidebar:null===e||void 0===e?void 0:e.type,id:e&&"id"in e&&null!==e.id?e.id:void 0,year:e&&"new-event"===e.type&&void 0!==e.year?String(e.year):void 0,focusAccountId:e&&"uncategorized-savings"===e.type&&"string"===typeof e.accountId?e.accountId:void 0};l(t,!1,{preserveState:!0})}),[l]),c=(0,a.useCallback)((()=>{s(null)}),[s]),d=(0,a.useCallback)((e=>{s({type:"event",id:e})}),[s]),u=(0,a.useCallback)((()=>{s({type:"assumptions"})}),[s]),m=(0,a.useCallback)((()=>{"assumptions"===(null===i||void 0===i?void 0:i.type)?c():s({type:"assumptions"})}),[i,c,s]),p=(0,a.useCallback)((()=>{s({type:"chance-of-success"})}),[s]),g=(0,a.useCallback)((()=>{"chance-of-success"===(null===i||void 0===i?void 0:i.type)?c():s({type:"chance-of-success"})}),[i,c,s]),h=(0,a.useCallback)((e=>{s({type:"account",id:null!==e&&void 0!==e?e:null})}),[s]),v=(0,a.useCallback)((()=>{s({type:"withdrawal-order"})}),[s]),f=(0,a.useCallback)((e=>{s({type:"uncategorized-savings",accountId:"string"===typeof e?e:void 0})}),[s]),E=(0,a.useCallback)((function(){s({type:"new-event",year:arguments.length>0&&void 0!==arguments[0]?arguments[0]:Mg})}),[s]),y=i&&"id"in i?i.id:null;return{closeSidebar:c,openEvent:d,openAssumptions:u,toggleAssumptions:m,openChanceOfSuccess:p,toggleChanceOfSuccess:g,openAccount:h,openWithdrawalOrder:v,openUncategorizedSavings:f,openNewEvent:E,openedSidebarDetails:i,id:y}},fy=(e,t,n,a,l)=>{return null!==(o=e)&&gy.includes(o)?(0,r.YW)(e).with("event",(()=>t?{type:"event",id:t}:null)).with("account",(()=>({type:"account",id:t}))).with("assumptions",(()=>({type:"assumptions"}))).with("chance-of-success",(()=>l?{type:"chance-of-success"}:null)).with("withdrawal-order",(()=>({type:"withdrawal-order"}))).with("uncategorized-savings",(()=>({type:"uncategorized-savings",accountId:null!==a&&void 0!==a?a:void 0}))).with("new-event",(()=>{if(!n)return{type:"new-event",year:void 0};const e=Number(n);return Number.isFinite(e)?{type:"new-event",year:e}:null})).exhaustive():null;var o};var Ey=n(14152);const yy=a.createContext(null),by=()=>{const e=(0,a.useContext)(yy);if(!e)throw new Error("SliderInput compound components must be used within a <SliderInput> provider");return e};var xy=n(73064);const wy=e=>
1{let t=e.value,n=e.onChange,l=e.min,r=e.max,i=e.step,s=void 0===i?1:i,c=e.debounceMs,d=e.children;const u=(0,a.useState)(t),m=(0,o.A)(u,2),p=m[0],g=m[1],h=(0,xy.d)(p,null!==c&&void 0!==c?c:0),v=(0,a.useRef)(h);(0,a.useEffect)((()=>{g(t)}),[t]),(0,a.useEffect)((()=>{h!==v.current&&(v.current=h,Math.abs(h-t)>1e-9&&n(h))}),[h,t,n]);const f=(0,a.useMemo)((()=>({localValue:p,min:l,max:r,step:s,setLocalValue:g})),[p,l,r,s]);return a.createElement(yy.Provider,{"data-external-id":"deprecated-slider-input-root",value:f},d)},Cy=u.default.div.withConfig({displayName:"SliderInputGrid__DEPRECATEDSliderInputGrid",componentId:"mb4m6u-0"})(["display:grid;grid-template-columns:1fr ","px;align-items:center;gap:0 ",";"],(e=>e.$rightColumnWidth),vt.YK.small),Ay=24,Iy=e=>{let t=e.colorVariant,n=void 0===t?"primary":t,l=e.ariaLabel;const r=by(),o=r.localValue,i=r.min,s=r.max,c=r.step,d=r.setLocalValue,u=(0,a.useCallback)((e=>Math.round(e/c)*c),[c]),m=(0,a.useCallback)((e=>{d(u(Number(e.target.value)))}),[u,d]),p=Math.max(0,Math.min(100,(o-i)/(s-i)*100)),g=(0,a.useMemo)((()=>o<i?"left":o>s?"right":null),[o,i,s]);return a.createElement(ky,{"data-external-id":"deprecated-slider-input-track"},a.createElement(Sy,null),a.createElement(Ny,{$colorVariant:n,style:{width:"".concat(p,"%")}}),a.createElement(_y,{type:"range","aria-label":l,min:i,max:s,step:c,value:Math.max(i,Math.min(s,o)),onChange:m}),a.createElement(Ty,{style:{left:"calc(".concat(p,"% - ").concat(p/100*Ay,"px)")}},g?a.createElement(sl.ZQ,{name:"arrow-".concat(g),size:14}):a.createElement(Dy,{$colorVariant:n})))},ky=u.default.div.withConfig({displayName:"SliderInputTrack__SliderContainer",componentId:"nv2vky-0"})(["position:relative;width:100%;height:","px;display:flex;align-items:center;"],Ay),Sy=u.default.div.withConfig({displayName:"SliderInputTrack__Track",componentId:"nv2vky-1"})(["position:absolute;top:50%;left:0;right:0;height:","px;background:",";border-radius:","px;transform:translateY(-50%);"],6,vt.Ee.color.progress.background,3),Ny=u.default.div.withConfig({displayName:"SliderInputTrack__TrackFill",componentId:"nv2vky-2"})(["position:absolute;top:50%;left:0;height:","px;background:linear-gradient( 90deg,"," 0%,"," 198.65% );border-radius:","px;transform:translateY(-50%);pointer-events:none;"],6,(e=>{let t=e.$colorVariant;return n=t,(0,r.YW)(n).with("primary",(()=>vt.Ee.color.background.gradientOrange)).with("blue",(()=>vt.Ee.color.background.gradientIndigo)).exhaustive();var n}),(e=>{let t=e.$colorVariant;return n=t,(0,r.YW)(n).with("primary",(()=>vt.Ee.color.background.gradientYellow)).with("blue",(()=>vt.Ee.color.background.gradientLightBlue)).exhaustive();var n}),3),Ty=u.default.div.attrs({"data-sc-tw":"SliderInputTrack__Thumb"}).withConfig({displayName:"SliderInputTrack__Thumb",componentId:"nv2vky-3"})(["position:absolute;top:50%;width:","px;height:","px;background:",";border:1px solid ",";border-radius:50%;transform:translateY(-50%);pointer-events:none;color:",";display:flex;align-items:center;justify-content:center;box-shadow:0 2px 4px rgba(0,0,0,0.1);transition:box-shadow 0.15s ease;"],Ay,Ay,vt.Ee.color.background.primary,vt.Ee.color.border.primary,vt.Ee.color.content.secondary),_y=u.default.input.withConfig({displayName:"SliderInputTrack__RangeInput",componentId:"nv2vky-4"})(["position:absolute;top:0;left:0;right:0;bottom:0;width:100%;height:100%;opacity:0;cursor:pointer;margin:0;&:active{cursor:grabbing;}&:focus-visible + [data-sc-tw~='SliderInputTrack__Thumb']{box-shadow:0 0 0 2px ",";}"],vt.Ee.color.input.focus.border),Dy=u.default.div.withConfig({displayName:"SliderInputTrack__ThumbInner",componentId:"nv2vky-5"})(["width:","px;height:","px;background:",";border-radius:50%;"],16,16,(e=>{let t=e.$colorVariant;return n=t,(0,r.YW)(n).with("primary",(()=>vt.Ee.color.background.brand)).with("blue",(()=>vt.Ee.color.background.gradientIndigo)).exhaustive();var n}));var Ry=n(18771);const My=84,Ly=e=>{let t=e.name,n=e.formatValue,l=void 0===n?String:n,r=e.parseValue,i=void 0===r?parseFloat:r,s=e.min,c=e.max,d=e.step,u=e.textAlign,m=void 0===u?"left":u;const p=by(),g=p.localValue,h=p.min,v=p.max,f=p.setLocalValue,E=(0,a.useState)(l(g)),y=(0,o.A)(E,2),b=y[0],x=y[1],w=(0,a.useState)(!1),C=(0,o.A)(w,2),A=C[0],I=C[1];(0,a.useEffect)((()=>{A||x(l(g))}),[g,l]);return a.createElement(Oy,{"data-external-id":"deprecated-slider-input-value-input",small:!0,name:t,$textAlign:m,value:A?b:l(g),onChange:e=>x(e.target.value),onFocus:()=>{I(!0)},onBlur:()=>{I(!1);const e=i(b);if(isNaN(e))x(l(g));else{const t=Math.max(null!==s&&void 0!==s?s:h,Math.min(null!==c&&void 0!==c?c:v,e)),n=void 0!==d?Math.round(t/d)*d:t;f(n),x(l(n))}},onKeyDown:e=>{"Enter"===e.key&&e.currentTarget.blur()}})},Oy=(0,u.default)(Ry.X).withConfig({displayName:"SliderInputValueInput__StyledTextInput",componentId:"sc-4az7ah-0"})(["width:","px;flex-shrink:0;text-align:",";"],My,(e=>e.$textAlign)),Py=e=>{let t=e.value;const n=by(),l=n.min,r=n.max,o=(0,a.useMemo)((()=>{const e=Math.max(l,Math.min(r,t)),n=r-l,a=0===n?0:(e-l)/n;return"calc(".concat(100*a,"% - ").concat(a*Ay,"px + ").concat(10,"px)")}),[t,l,r]);return a.createElement(By,{"data-external-id":"deprecated-slider-input-default-value"},a.createElement(zy,{style:{left:o}}))},By=u.default.div.withConfig({displayName:"SliderInputDefaultValue__Container",componentId:"pz29aa-0"})(["position:relative;width:100%;height:","px;"],4),zy=u.default.div.withConfig({displayName:"SliderInputDefaultValue__Dot",componentId:"pz29aa-1"})(["position:absolute;width:","px;height:","px;border-radius:50%;background-color:",";"],4,4,vt.Ee.color.content.secondary);var Fy=n(99361),Gy=n(27869);const Yy=e=>{let t=e.x,n=e.y,l=e.markerSize,r=void 0===l?Yg:l,i=e.children;const s=(0,a.useRef)(null),c=(0,a.useState)({x:t,y:n,placement:"top"}),d=(0,o.A)(c,2),u=d[0],m=d[1];return(0,a.useLayoutEffect)((()=>
1{if(!s.current)return;const e=s.current.getBoundingClientRect(),a=Uy(t,n,e,r);m(a)}),[t,n,r]),(0,R.createPortal)(a.createElement(Vy,{ref:s,$x:u.x,$y:u.y,$placement:u.placement,initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.075}},i),document.body)},Uy=(e,t,n,a)=>{const l=window.innerWidth;if(t-n.height<8){const r=e-8,o=l-e-8,i=n.width,s=a/2+4;return o>=i?{x:e+s,y:t,placement:"right"}:r>=i?{x:e-s,y:t,placement:"left"}:{x:Math.max(8,Math.min(e,l-i-8)),y:Math.max(n.height+8,t),placement:"top"}}return{x:Math.max(n.width/2+8,Math.min(e,l-n.width/2-8)),y:t,placement:"top"}},Vy=(0,u.default)(D.PY1.div).withConfig({displayName:"ChartTooltipPortal__TooltipWrapper",componentId:"sc-19ufiy6-0"})(["position:fixed;pointer-events:none;",""],(e=>{let t=e.$placement,n=e.$x,a=e.$y;switch(t){case"top":return"\n          left: ".concat(n,"px;\n          top: ").concat(a,"px;\n          transform: translate(-50%, -100%);\n        ");case"left":return"\n          left: ".concat(n,"px;\n          top: ").concat(a,"px;\n          transform: translate(-100%, -50%);\n        ");case"right":return"\n          left: ".concat(n,"px;\n          top: ").concat(a,"px;\n          transform: translate(0, -50%);\n        ")}}));var Wy=n(98143);const jy=e=>{const t=e.querySelector("rect"),n=t?t.getBoundingClientRect():e.getBoundingClientRect();return{x:n.left+n.width/2,y:n.top-4}},Hy=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.hoverDelayMs,n=void 0===t?300:t,l=e.layoutRef,r=e.onDismiss;const i=(0,a.useState)(null),s=(0,o.A)(i,2),c=s[0],d=s[1],u=(0,a.useRef)(null),m=(0,a.useRef)(null),p=(0,a.useRef)(null),g=(0,a.useRef)(!1),h=(0,a.useRef)(null),v=(0,a.useCallback)((()=>{null!==u.current&&(clearTimeout(u.current),u.current=null)}),[]),f=(0,a.useCallback)((()=>{null!==m.current&&(cancelAnimationFrame(m.current),m.current=null),null!==p.current&&(clearTimeout(p.current),p.current=null)}),[]),E=(0,a.useCallback)((()=>{(g.current||null!==u.current)&&(v(),f(),h.current=null,g.current=!1,d(null),null===r||void 0===r||r())}),[v,f,r]);(0,a.useEffect)((()=>()=>{v(),f()}),[v,f]),(0,a.useEffect)((()=>{window.addEventListener("resize",E);const e=null===l||void 0===l?void 0:l.current,t=e?new Wy.A(E):null;return e&&t&&t.observe(e),()=>{window.removeEventListener("resize",E),null===t||void 0===t||t.disconnect()}}),[E,l]);return{tooltipPosition:c,scheduleShow:(0,a.useCallback)(((e,t)=>{f();const a=jy(e);if(g.current)return v(),d(a),void(null===t||void 0===t||t());var l,r;null!==u.current&&(l=h.current,r=a,null!==l&&null!==r&&Math.abs(l.x-r.x)<1&&Math.abs(l.y-r.y)<1)||(v(),h.current=a,u.current=setTimeout((()=>{g.current=!0,h.current=null,d(e.isConnected?jy(e):a),null===t||void 0===t||t()}),n))}),[v,f,n]),scheduleHide:(0,a.useCallback)((e=>{v(),f(),h.current=null,m.current=requestAnimationFrame((()=>{m.current=null,p.current=setTimeout((()=>{p.current=null,g.current=!1,d(null),null===e||void 0===e||e()}),50)}))}),[v,f]),cancelPendingShow:(0,a.useCallback)((()=>{h.current=null,v()}),[v]),cancelPendingLeave:f}};var Ky=n(14181),qy=n(5563);const $y={top:44,right:10,bottom:0,left:0},Zy=16,Jy={line:(0,qy.f)("content-brand"),axis:(0,qy.f)("content-secondary"),grid:(0,qy.f)("divider-secondary"),dotFill:(0,qy.f)("background-primary"),dotBorder:(0,qy.f)("border-primary")},Xy=e=>{let t=e.anchors;return a.createElement(a.Fragment,null,t.map((e=>a.createElement(Ky.r,{key:"anchor-outer-".concat(e.year),x:e.year,y:e.rate,r:6,fill:Jy.dotFill,stroke:Jy.dotBorder,strokeWidth:1.5}))),t.map((e=>a.createElement(Ky.r,{key:"anchor-inner-".concat(e.year),x:e.year,y:e.rate,r:3,fill:Jy.line,strokeWidth:0}))))};var Qy=n(15047),eb=n(2270);const tb=e=>{let t=e.startYear,n=e.endYear,l=e.xTicks,r=e.yTicks,o=e.yDomain;return a.createElement(a.Fragment,null,a.createElement(Qy.d,{horizontal:!0,vertical:!1,stroke:Jy.grid,strokeWidth:1}),a.createElement(eb.e_,{y:0,stroke:Jy.grid,strokeWidth:2}),a.createElement(xa.W,{dataKey:"year",type:"number",domain:[t,n],ticks:l,padding:{left:8,right:8},tick:{fontSize:12,fill:Jy.axis}
1,tickMargin:8,tickLine:!1,axisLine:!1,allowDecimals:!1,interval:0}),a.createElement(wa.h,{type:"number",width:38,domain:o,ticks:r,interval:0,allowDecimals:!1,tick:{fontSize:12,fill:Jy.axis},tickLine:!1,axisLine:!1,tickFormatter:e=>"".concat(e,"%")}))},nb=e=>"".concat(Number(Number(e).toFixed(3)),"%"),ab=e=>parseFloat(e.replace("%",""));var lb,rb=n(88986);const ob=()=>a.createElement(Aa.m,{"data-external-id":"rate-schedule-line-tooltip",isAnimationActive:!1,cursor:{stroke:Jy.grid,strokeWidth:1,strokeDasharray:"3 3"},content:e=>{var t;let n=e.active,l=e.payload;const r=null===l||void 0===l||null===(t=l[0])||void 0===t?void 0:t.payload;return n&&r?a.createElement(rb.J,null,a.createElement(ib,null,"".concat(r.year," \xb7 ").concat(nb(r.rate)))):null}}),ib=$d.s.div(lb||(lb=(0,wc.A)(["\n  rounded-xs bg-background-frosted px-xs py-2xs text-xs font-medium whitespace-nowrap\n  text-content-primary backdrop-blur-(--background-blur-frosted)\n"]))),sb=e=>{var t,n;let l=e.viewBox,r=e.markers,o=e.onMarkerEnter,i=e.onMarkerLeave;const s=null!==(t=null===l||void 0===l?void 0:l.x)&&void 0!==t?t:0,c=null!==(n=null===l||void 0===l?void 0:l.y)&&void 0!==n?n:0;return a.createElement("g",{"data-external-id":"retirement-marker-badges-label"},r.map(((e,t)=>{const n=c-6-Zy-19*t,l="".concat(e.year,"-").concat(t);return a.createElement("g",{key:l,transform:"translate(".concat(s-8,", ").concat(n,")"),pointerEvents:"all",style:{cursor:"default"},onMouseEnter:t=>o(l,e.label,t.currentTarget),onMouseLeave:i},a.createElement("rect",{width:Zy,height:Zy,rx:5,ry:5,fill:(0,qy.f)("chart-event-background-".concat(e.color)),stroke:Jy.dotFill,strokeWidth:1.5}),a.createElement("foreignObject",{width:Zy,height:Zy,pointerEvents:"none"},a.createElement("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",width:Zy,height:Zy}},a.createElement(sl.ZQ,{name:e.icon,size:11,style:{color:(0,qy.f)("chart-event-foreground-".concat(e.foregroundColor)),display:"flex"}}))))})))},cb=e=>{let t=e.markersByYear,n=e.onMarkerEnter,l=e.onMarkerLeave;return a.createElement(a.Fragment,null,t.map((e=>{let t=(0,o.A)(e,2),r=t[0],i=t[1];return a.createElement(eb.e_,{key:"retirement-".concat(r),x:r,stroke:Jy.grid,strokeWidth:1,label:e=>a.createElement(sb,{viewBox:e.viewBox,markers:i,onMarkerEnter:n,onMarkerLeave:l})})})))};var db=n(84074);const ub=e=>{let t=e.schedule,n=e.startYear,l=e.endYear,r=e.retirementMarkers;const o=(0,a.useMemo)((()=>dp(t)),[t]),i=(0,a.useMemo)((()=>(0,db.A)(n,l+1).map((e=>({year:e,rate:up(o,e)})))),[o,n,l]),s=(0,a.useMemo)((()=>{const e=l-n;if(e<=0)return[n];const t=(0,db.A)(0,5).map((t=>Math.round(n+t*e/4)));return[...new Set(t)]}),[n,l]),c=(0,a.useMemo)((()=>((e,t,n,a)=>{const l=e.map((e=>e.rate)),r=Math.min(...l),o=Math.max(...l),i=Math.max((o-r)*n,a),s=r-i,c=o+i,d=t-1;let u;u=s>=0?0:c<=0?d:Math.min(Math.max(Math.round(d*-s/(c-s)),1),d-1);const m=d-u,p=Math.max(1,u>0?Math.ceil(-s/u):0,m>0?Math.ceil(c/m):0);return(0,db.A)(0,t).map((e=>(e-u)*p))})(o,4,.08,1)),[o]),d=(0,a.useMemo)((()=>[c[0],c[c.length-1]]),[c]),u=(0,a.useMemo)((()=>{const e=new Map;return r.filter((e=>e.year>=n&&e.year<=l)).forEach((t=>{var n;e.set(t.year,[...null!==(n=e.get(t.year))&&void 0!==n?n:[],t])})),[...e.entries()]}),[r,n,l]);return{anchors:o,data:i,xTicks:s,yTicks:c,yDomain:d,markersByYear:u}},mb=e=>{let t=e.schedule,n=e.startYear,l=e.endYear;const r=(()=>{const e=XE();return(0,a.useMemo)((()=>e.filter((e=>"retirement"===e.config.eventKind&&e.isIncluded&&e.isVisibleInForecast&&void 0!==e.startYear)).map((e=>({year:e.startYear,label:e.displayName,icon:e.icon,color:e.color,foregroundColor:e.foregroundColor})))),[e])})(),i=ub({schedule:t,startYear:n,endYear:l,retirementMarkers:r}),s=(0,a.useState)(null),c=(0,o.A)(s,2),d=c[0],u=c[1],m=(0,a.useCallback)((()=>u(null)),[]),p=Hy({onDismiss:m}),g=p.tooltipPosition,h=p.scheduleShow,v=p.scheduleHide,f=p.cancelPendingLeave;return a.createElement(a.Fragment,null,a.createElement(ya.u,{width:"100%",height:150},a.createElement(Fy.b,{data:i.data,margin:$y},a.createElement(tb,{startYear:n,endYear:l,xTicks:i.xTicks,yTicks:i.yTicks,yDomain:i.yDomain}),a.createElement(cb,{markersByYear:i.markersByYear,onMarkerEnter:(e,t,n)=>{(null===d||void 0===d?void 0:d.id)!==e?h(n,(()=>u({id:e,label:t}))):f()},onMarkerLeave:()=>v((()=>u(null)))}),a.createElement(Gy.N1,{type:"linear",dataKey:"rate",stroke:Jy.line,strokeWidth:3,dot:!1,activeDot:!1,isAnimationActive:!1}),a.createElement(ob,null),a.createElement(Xy,{anchors:i.anchors}))),g&&null!==d&&a.createElement(Yy,{x:g.x,y:g.y,markerSize:Zy},a.createElement(rb.J,null,a.createElement(ib,null,d.label))))},pb=e=>{let t=e.canonicalValue,n=e.onCommit;const l=(0,a.useRef)(null),r=(0,a.useState)(t),i=(0,o.A)(r,2),s=i[0],c=i[1],d=(0,a.useRef)(!1),u=(0,a.useRef)(!1);(0,a.useEffect)((()=>{c(t)}),[t]);const m=(0,a.useCallback)((()=>
1{if(d.current)return d.current=!1,u.current=!1,void c(t);const e=s.trim();if(e&&e!==t){const t=u.current?"enter":"blur";u.current=!1,n(e,{reason:t})}else u.current=!1,c(t)}),[s,t,n]),p=(0,a.useCallback)((e=>{var n;if("Enter"===e.key)e.preventDefault(),u.current=!0,null===(n=l.current)||void 0===n||n.blur();else if("Escape"===e.key){var a;e.preventDefault(),u.current=!1,d.current=!0,c(t),null===(a=l.current)||void 0===a||a.blur()}}),[t]),g=(0,a.useCallback)((e=>{c(e.target.value)}),[]);return{inputProps:{ref:l,value:s,onChange:g,onBlur:m,onKeyDown:p},commit:m}};var gb;const hb=e=>{let t=e.value,n=e.onChange,l=e.name,r=e.autoFocus,i=e.formatValue,s=void 0===i?String:i,c=e.parseValue,d=void 0===c?parseFloat:c;const u=(0,a.useState)(Boolean(r)),m=(0,o.A)(u,2),p=m[0],g=m[1],h=(0,a.useCallback)((e=>{const t=d(e);Number.isNaN(t)||n(Math.max(-30,Math.min(30,t)))}),[d,n]),v=pb({canonicalValue:s(t),onCommit:h}).inputProps,f=p?v.value:s(t);return a.createElement(vb,Object.assign({"data-external-id":"rate-value-input",small:!0,name:l,autoFocus:r},v,{value:f,onFocus:e=>{g(!0),r&&e.currentTarget.select()},onChange:e=>{v.onChange(e)},onBlur:()=>{g(!1),v.onBlur()}}))},vb=(0,$d.s)(Ry.X)(gb||(gb=(0,wc.A)(["w-full text-right"])));var fb=n(71091),Eb=n(28873),yb=n(53443);const bb=e=>{let t=e.value,n=e.onChange,l=e.onClear,r=e.label,o=e.placeholder,i=e.birthday,s=e.getAgeLabel,c=e.minYear,d=e.maxYear,u=e.excludeYears,m=e.referenceYear,p=e.isDisabled,g=e.size;const h=QE(),v=(0,a.useMemo)((()=>{const e=(new Date).getFullYear(),t=h.startYear+h.projectionYears,n=null!==c&&void 0!==c?c:e,a=null!==d&&void 0!==d?d:t,l=new Set(null!==u&&void 0!==u?u:[]),r=a-n+1;return Array.from({length:r},((e,t)=>{const a=n+t;let l,r=String(a);if(void 0!==m){const e=a-m;l="(".concat(e," ").concat(1===e?"year":"years",")"),r="".concat(a," ").concat(l)}else{var o;const e=(0,Ba.GB)(a,i),t=null!==(o=null===s||void 0===s?void 0:s(a))&&void 0!==o?o:void 0!==e?String(e):void 0;void 0!==t&&(l="(age ".concat(t,")"),r="".concat(a," ").concat(l))}return{value:String(a),label:r,year:String(a),secondaryLabel:l}})).filter((e=>!l.has(Number(e.value))))}),[h.startYear,h.projectionYears,i,s,c,d,u,m]),f=void 0!==t?v.find((e=>e.value===String(t))):void 0,E=void 0!==l&&void 0!==f&&!p,y=a.createElement(fb.M,{render:a.createElement("button",{type:"button","aria-label":r,className:(0,Eb.X)({mode:"button",className:(0,q.cn)("group relative flex w-full min-w-0 items-center pl-sm text-left text-base/6","sm"===g?"h-9":"h-10",E?"pr-13.75":"pr-5.75")})})},f?a.createElement("span",{className:"flex min-w-0 flex-1 items-center gap-1"},a.createElement("span",{className:"shrink-0"},f.year),void 0!==f.secondaryLabel&&a.createElement("span",{className:"truncate text-sm text-content-secondary"},f.secondaryLabel)):a.createElement("span",{className:"min-w-0 flex-1 truncate text-input-placeholder"},null!==o&&void 0!==o?o:"Select year"),a.createElement(fe.ri_,{className:"absolute top-1/2 right-1.75 -translate-y-1/2"}));return a.createElement(fe.OR9.Root,{"data-external-id":"year-selector",items:v,value:null!==f&&void 0!==f?f:null,onValueChange:e=>{e?n(Number(e.value)):null===l||void 0===l||l()},isItemEqualToValue:(e,t)=>(null===e||void 0===e?void 0:e.value)===(null===t||void 0===t?void 0:t.value),disabled:p,size:g},E?a.createElement("div",{className:"relative flex w-full min-w-0"},y,a.createElement("button",{type:"button","aria-label":"Clear",className:(0,q.cn)(Eb.e,"absolute top-1/2 right-7.75 -translate-y-1/2"),onPointerDown:e=>e.preventDefault(),onMouseDown:e=>e.preventDefault(),onClick:l},a.createElement(yb.MdsXIcon,null))):y,a.createElement(fe.OR9.Content,null,a.createElement(fe.OR9.PopupInput,{placeholder:"Search"}),a.createElement(fe.OR9.Empty,null,"No options"),a.createElement(fe.OR9.List,null,(e=>a.createElement(fe.OR9.Option,{key:e.value,value:e},a.createElement("span",null,e.year,void 0!==e.secondaryLabel&&a.createElement("span",{className:"text-sm text-content-secondary"}," ",e.secondaryLabel)))))))};var xb=n(86432),wb=n(81766),Cb=n(16318);const Ab=["htmlFor"],Ib=["className","style"];var kb;const Sb=u.default.div.withConfig({displayName:"shared__SidebarContainer",componentId:"sc-1qtijv4-0"})(["display:flex;flex-direction:column;height:100%;border-radius:",";overflow:hidden;"],vt.r8.large),Nb=u.default.div.withConfig({displayName:"shared__EventSidebarContainer",componentId:"sc-1qtijv4-1"})(["display:flex;flex-direction:column;height:100%;background:",";overflow:hidden;"],(e=>{let t=e.theme,n=e.$color;const a=t.variables.color.chart.fill[n],l=t.variables.color.background.primary;return"linear-gradient(180deg, ".concat((0,xb.B3)(a,.2)," 0%, ").concat((0,xb.B3)(l,.2)," 180px), ").concat(l)})),Tb=u.default.div.withConfig({displayName:"shared__SidebarHeader",componentId:"sc-1qtijv4-2"})(["display:flex;justify-content:space-between;align-items:center;padding:"," ",";gap:",";flex-shrink:0;"],vt.YK.small,vt.YK.default,vt.YK.xsmall),_b=u.default.div.withConfig({displayName:"shared__SidebarScrollableContent",componentId:"sc-1qtijv4-3"})(["flex:1;padding:",";padding-bottom:100px;display:flex;flex-direction:column;gap:",";overflow-y:auto;overflow-x:hidden;scrollbar-width:none;-ms-overflow-style:none;&::-webkit-scrollbar{display:none;}"],vt.YK.default,vt.YK.xlarge),Db=$d.s.div(kb||(kb=(0,wc.A)(["flex flex-col gap-default rounded-lg border border-divider-secondary p-default"]))),Rb=u.default.h2.withConfig({displayName:"shared__SidebarTitle",componentId:"sc-1qtijv4-4"})(["font-size:18px;font-weight:",";line-height:26px;color:",";margin:0;flex:1;"],vt.Wy.medium,vt.Ee.color.content.primary),Mb=u.default.label.
1withConfig({displayName:"shared__StyledSidebarLabel",componentId:"sc-1qtijv4-5"})(["font-size:14px;font-weight:",";color:",";"],vt.Wy.medium,vt.Ee.color.content.primary),Lb=e=>{let t=e.htmlFor,n=(0,En.A)(e,Ab);return t?a.createElement(Mb,Object.assign({"data-external-id":"sidebar-label",htmlFor:t},n)):a.createElement(Mb,Object.assign({"data-external-id":"sidebar-label",as:"span"},n))},Ob=u.default.p.withConfig({displayName:"shared__SidebarDescription",componentId:"sc-1qtijv4-6"})(["font-size:14px;line-height:20px;color:",";margin:0;"],vt.Ee.color.content.secondary),Pb=Cb.p9,Bb=(0,u.default)(wb.gz).attrs({target:"_blank",rel:"noopener noreferrer"}).withConfig({displayName:"shared__LearnMoreLink",componentId:"sc-1qtijv4-7"})([""]),zb=a.forwardRef(((e,t)=>{let n=e.className,l=e.style,r=(0,En.A)(e,Ib);return a.createElement("input",Object.assign({"data-external-id":"text-input",ref:t,type:"text",className:(0,q.cn)("flex-1 rounded-sm border border-input-default-border bg-input-default-background px-sm py-1.5","text-base text-input-default-text","placeholder:text-content-secondary","focus:border-input-focus-border focus:ring-1 focus:ring-input-focus-border focus:outline-none","disabled:cursor-not-allowed disabled:opacity-60",n),style:(0,U.A)({height:36},l)},r))}));zb.displayName="TextInput";var Fb,Gb,Yb,Ub,Vb,Wb=n(99395);const jb=e=>{let t=e.schedule,n=e.startYear,l=e.projectionYears,r=e.onChange;const i=n+l,s=(0,a.useMemo)((()=>[...t].sort(Hb)),[t]),c=(0,a.useState)(null),d=(0,o.A)(c,2),u=d[0],m=d[1];(0,a.useEffect)((()=>{null!==u&&s.some((e=>e.year===u))&&m(null)}),[u,s]);const p=(0,a.useMemo)((()=>((e,t,n)=>{if(0===e.length)return{year:t,rate:0};const a=new Set(e.map((e=>e.year))),l=Math.max(...e.map((e=>e.year))),r=Math.max(l,t),o=Math.min(r+5,n);if(a.has(o))return null;const i=up(e,l);return{year:o,rate:Math.max(0,i-.5)}})(s,n,i)),[s,n,i]),g=e=>{const t=((e,t)=>{const n=t+1;return{year:n,rate:up(e,n)}})(s,e);r([...s,t].sort(Hb)),m(t.year)},h=s.length>1;return a.createElement("div",{"data-external-id":"growth-rate-schedule-editor",className:"flex flex-col gap-sm"},a.createElement(Kb,null,a.createElement(Lb,null,"Year"),a.createElement(Lb,null,"Rate")),a.createElement("div",{className:"flex flex-col"},s.map(((e,t)=>{const l=s[t+1],o=void 0!==l&&l.year-e.year>1;return a.createElement(a.Fragment,{key:e.year},a.createElement(qb,null,a.createElement(bb,{label:"Year for ".concat(e.year," anchor"),value:e.year,minYear:Math.min(n,e.year),maxYear:Math.max(i,e.year),excludeYears:s.filter((t=>t.year!==e.year)).map((e=>e.year)),size:"sm",onChange:t=>{return n=e.year,a=t,void r(s.map((e=>e.year===n?(0,U.A)((0,U.A)({},e),{},{year:a}):e)).sort(Hb));var n,a}}),a.createElement(hb,{name:"growth-rate-rate-".concat(e.year),value:e.rate,autoFocus:e.year===u,onChange:t=>{return n=e.year,a=t,void r(s.map((e=>e.year===n?(0,U.A)((0,U.A)({},e),{},{rate:a}):e)));var n,a},formatValue:nb,parseValue:ab}),a.createElement(Yi.S,{size:"sm",className:"disabled:bg-transparent disabled:opacity-50 disabled:outline-transparent","aria-label":"Remove ".concat(e.year," anchor"),disabled:!h,onClick:()=>{return t=e.year,void r(s.filter((e=>e.year!==t)));var t}},a.createElement(fe.Kfl,{className:"text-content-secondary"}))),void 0!==l&&a.createElement($b,null,o&&a.createElement(a.Fragment,null,a.createElement(Zb,null),a.createElement(Jb,{type:"button","aria-label":"Add point after ".concat(e.year),onClick:()=>g(e.year)},a.createElement(fe.Wa3,{size:"xs"})))))}))),a.createElement(P.D_,{maxWidth:240,content:null===p?a.createElement(P.fn,null,"You can't add points beyond end of plan, but you can add points between existing ones"):void 0},a.createElement("span",{className:"self-start"},a.createElement(Wb.X,{variant:"default",size:"xs",disabled:null===p,onClick:()=>{p&&(r([...s,p].sort(Hb)),m(p.year))},icon:a.createElement(fe.e8D,{size:"md"})},"Add point"))),a.createElement(mb,{schedule:s,startYear:n,endYear:i}))},Hb=(e,t)=>e.year-t.year,Kb=$d.s.div(Fb||(Fb=(0,wc.A)(["grid grid-cols-[1fr_88px_28px] items-center gap-xs"]))),qb=$d.s.div(Gb||(Gb=(0,wc.A)(["grid grid-cols-[1fr_88px_28px] items-center gap-xs"]))),$b=$d.s.div(Yb||(Yb=(0,wc.A)(["group relative grid h-xs grid-cols-[1fr_88px_28px] content-center items-center gap-xs"]))),Zb=$d.s.div(Ub||(Ub=(0,wc.A)(["\n  pointer-events-none col-start-1 col-end-3 row-start-1 h-0.5 w-full rounded-full\n  bg-chart-event-border-orange opacity-0 transition-opacity\n  group-hover:opacity-100\n"]))),Jb=$d.s.button(Vb||(Vb=(0,wc.A)(["\n  z-10 col-start-2 row-start-1 -ml-1 flex size-3.5 -translate-x-1/2 -translate-y-
1px\n  cursor-pointer items-center justify-center justify-self-start rounded-full border-0\n  bg-content-brand text-content-white opacity-0 transition-opacity\n  group-hover:opacity-100\n"])));var Xb;const Qb=[{value:"fixed",label:"Fixed rate",description:"default"},{value:"schedule",label:"Variable rate",description:"advanced"},{value:"noChange",label:"Doesn't change"}],ex=e=>{var t,n,l,r,o,i;let s=e.account,c=e.startYear,d=e.projectionYears,u=e.onChange;const m=null!==(t=s.growthRateMethod)&&void 0!==t?t:"fixed",p=null!==(n=s.growthRate)&&void 0!==n?n:0,g=null!==(l=s.growthRate)&&void 0!==l?l:$h.defaultGrowthRate(s),h=s.growthRateSchedule&&s.growthRateSchedule.length>0?s.growthRateSchedule:[{year:c,rate:g}],v=Math.min(0,null!==(r=s.linkedGrowthRate)&&void 0!==r?r:0),f=Math.max(10,null!==(o=s.linkedGrowthRate)&&void 0!==o?o:0),E=(0,Tr.A)(s.linkedGrowthRate)&&s.growthRate!==s.linkedGrowthRate;return a.createElement(Db,{"data-external-id":"asset-growth-rate"},a.createElement(nx,null,a.createElement(Lb,null,"Change over time"),a.createElement(fe.hGA.Root,{items:Qb,value:m,onValueChange:e=>{var t;(t=e)!==m&&("schedule"!==t||void 0!==s.growthRateSchedule&&0!==s.growthRateSchedule.length?u({growthRateMethod:t}):u({growthRateMethod:"schedule",growthRateSchedule:[{year:c,rate:g}]}))}},a.createElement(fe.hGA.Trigger,null,a.createElement(fe.hGA.Value,null,(e=>{const t=Qb.find((t=>t.value===e));return t?tx(t):null}))),a.createElement(fe.hGA.Content,null,Qb.map((e=>a.createElement(fe.hGA.Option,{key:e.value,value:e.value,label:e.label},tx(e))))))),"fixed"===m&&a.createElement(nx,null,a.createElement(wy,{key:s.id,value:p,onChange:e=>u({growthRate:e}),min:v,max:f,step:.5,debounceMs:150},a.createElement(Cy,{$rightColumnWidth:My},a.createElement(Iy,null),a.createElement(Ly,{name:"growthRate",formatValue:nb,parseValue:ab,min:-30,max:30,step:.001,textAlign:"right"}),(0,Tr.A)(s.linkedGrowthRate)&&a.createElement(Py,{value:s.linkedGrowthRate}))),E&&a.createElement(Ob,null,"Linked account value: ",nb(null!==(i=s.linkedGrowthRate)&&void 0!==i?i:0))),"schedule"===m&&a.createElement(jb,{schedule:h,startYear:c,projectionYears:d,onChange:e=>{u({growthRateSchedule:e})}}))},tx=e=>a.createElement("span",null,e.label,e.description?a.createElement("span",{className:"ml-2xs text-content-secondary"},"(",e.description,")"):null),nx=$d.s.div(Xb||(Xb=(0,wc.A)(["flex flex-col gap-xs"])));var ax;const lx=e=>{let t=e.icon,n=e.color,l=e.foregroundColor,r=e.name,o=e.onClick,i=e.rightSlot,s=e.renderIcon,c=e.borderless;const d=Boolean(o&&!i),u=(0,q.cn)("flex items-center gap-xs text-content-primary",c?"py-2xs":"h-12 rounded-sm border border-divider-secondary px-sm py-2xs",d&&"cursor-pointer bg-transparent hover:bg-background-secondary"),m=null!==s&&void 0!==s?s:a.createElement("div",{className:(0,q.cn)("flex size-7 shrink-0 items-center justify-center rounded-default",Vg[n],Wg[null!==l&&void 0!==l?l:n])},a.createElement(sl.ZQ,{name:t,size:16})),p=a.createElement(a.Fragment,null,m,a.createElement("span",{className:"min-w-0 flex-1 truncate",title:r},r));return d?a.createElement("button",{"data-external-id":"event-list-item",type:"button",className:(0,q.cn)(u,"w-full text-left"),onClick:o},p,a.createElement(sl.ZQ,{name:"arrow-right",size:16}
1)):o&&i?a.createElement("div",{"data-external-id":"event-list-item",className:u},m,a.createElement(rx,{type:"button",onClick:o,title:r},a.createElement("span",{className:"min-w-0 flex-1 truncate"},r)),i):a.createElement("div",{"data-external-id":"event-list-item",className:u},p,i)},rx=$d.s.button(ax||(ax=(0,wc.A)(["\n  -my-2xs -ml-2xs flex min-w-0 flex-1 cursor-pointer items-center rounded-sm\n  border-0 bg-transparent px-2xs py-xs text-left text-content-primary\n  hover:bg-background-secondary\n"])));var ox=n(68226),ix=n(69761);const sx=e=>{var t,n,l,r;let o=e.account,i=e.onEnable,s=e.onDisable,c=e.onUpdateComponent,d=e.paycheckContribution;const u=o.taxTreatmentConfig,m=!!op(o),p=u?Xf(u,"pretax"):null,g=u?Xf(u,"roth"):null,h=null!==(t=null===p||void 0===p?void 0:p.annualContribution)&&void 0!==t?t:0,v=null!==(n=null===g||void 0===g?void 0:g.annualContribution)&&void 0!==n?n:0,f=null!==(l=null===p||void 0===p?void 0:p.balance)&&void 0!==l?l:0,E=null!==(r=null===g||void 0===g?void 0:g.balance)&&void 0!==r?r:0,y=Jf(o.balance,u);return a.createElement("div",{"data-external-id":"mixed-account-section",className:"flex flex-col gap-xl rounded-sm border border-border-primary p-default"},d,a.createElement("div",{className:"flex w-full items-center gap-default"},a.createElement("div",{className:"flex min-w-0 flex-1 flex-col gap-2xs"},a.createElement(Lb,{htmlFor:"mixed-account-toggle"},"Account contains Roth contributions"),a.createElement(Ob,null,"Some institutions combine 401k and Roth 401k into a single account.")),a.createElement(ox.k,{id:"mixed-account-toggle",checked:m,onChange:e=>{e.target.checked?i():s()}})),m&&u&&a.createElement(a.Fragment,null,a.createElement(cx,{label:"Yearly paycheck contribution",tooltip:"Your total annual contribution from payroll deductions, split between Traditional (pretax) and Roth dollars.",ariaLabel:"Split of yearly paycheck contribution between Traditional and Roth",namePrefix:"Contribution",total:tE(u),traditional:h,roth:v,onChange:(e,t)=>
1c(e,{annualContribution:t})}),a.createElement("div",{className:"flex flex-col gap-xs"},a.createElement(Lb,null,"Current account balance"),a.createElement("div",{className:"\n                flex h-9 items-center rounded-sm border border-border-primary\n                bg-background-secondary px-sm text-base text-content-primary\n              "},(0,rl.T3)(o.balance))),a.createElement("div",{className:"flex flex-col gap-default"},a.createElement(cx,{label:"Account balance",tooltip:"How your current balance is split between Traditional (pretax) and Roth dollars.",ariaLabel:"Split of account balance between Traditional and Roth",namePrefix:"Balance",total:o.balance,traditional:f,roth:E,onChange:(e,t)=>c(e,{balance:t})}),y.hasDrift&&a.createElement("div",{className:"rounded-sm bg-background-warning px-default py-xs text-sm text-content-warning"},"Your Traditional and Roth balances are"," ",(0,rl.T3)(Math.abs(y.amount))," ",y.amount<0?"over":"under"," your ",(0,rl.T3)(o.balance)," ","account balance. Adjust them to match."))))},cx=e=>{let t=e.label,n=e.tooltip,l=e.ariaLabel,r=e.namePrefix,i=e.total,s=e.traditional,c=e.roth,d=e.onChange;const u=(0,De.hj)(i),m=u<=0,p=(0,a.useState)(null),g=(0,o.A)(p,2),h=g[0],v=g[1],f=null!==h&&void 0!==h?h:{traditional:s,roth:c},E=(0,a.useRef)(h);E.current=h;const y=(0,a.useRef)(d);y.current=d;const b=(0,a.useMemo)((()=>(0,_r.debounce)((()=>{const e=E.current;e&&(y.current("pretax",e.traditional),y.current("roth",e.roth))}),150)),[]);(0,a.useEffect)((()=>()=>b.cancel()),[b]);const x=f.traditional+f.roth,w=u>0?Math.max(0,Math.min(100,f.traditional/u*100)):50;return a.createElement("div",{"data-external-id":"split-section",className:"flex flex-col gap-default"},a.createElement("div",{className:"flex flex-col gap-default"},a.createElement(mx,{label:t,tooltip:n,total:x}),a.createElement(dx,{percent:w,disabled:m,ariaLabel:l,onScrub:e=>{const t=(0,De.hj)(e/100*u);v({traditional:t,roth:u-t}),b()},onScrubEnd:()=>{b.flush(),v(null)}})),a.createElement("div",{className:"flex flex-col gap-xs"},a.createElement(ux,{label:"Traditional",dotClassName:"bg-chart-fill-green",name:"pretax".concat(r),value:f.traditional,onChange:e=>d("pretax",e)}),a.createElement(ux,{label:"Roth",dotClassName:"bg-chart-fill-lime",name:"roth".concat(r),value:f.roth,onChange:e=>d("roth",e)})))},dx=e=>{let t=e.percent,n=e.disabled,l=e.ariaLabel,r=e.onScrub,o=e.onScrubEnd;return a.createElement("div",{"data-external-id":"proportion-bar",className:"relative flex h-3 w-full items-center gap-2xs"},a.createElement("div",{className:"h-full rounded-full bg-chart-fill-green",style:{flexGrow:t,flexBasis:0}}),a.createElement("div",{className:"h-full rounded-full bg-chart-fill-lime",style:{flexGrow:100-t,flexBasis:0}}),!n&&a.createElement(a.Fragment,null,a.createElement("input",{type:"range","aria-label":l,className:"peer absolute inset-0 m-0 size-full cursor-col-resize opacity-0",min:0,max:100,step:"any",value:t,onChange:e=>r(Math.max(0,Math.min(100,Number(e.target.value)))),onPointerUp:o,onPointerCancel:o,onKeyUp:o,onBlur:o}),a.createElement("div",{className:"\n            pointer-events-none absolute top-1/2 size-4 -translate-1/2 rounded-full border\n            border-border-primary bg-background-primary opacity-0 shadow-sm transition-opacity\n            peer-hover:opacity-100\n            peer-focus-visible:opacity-100 peer-focus-visible:ring-2\n            peer-focus-visible:ring-input-focus-border\n          ",style:{left:"".concat(t,"%")}})),n&&a.createElement("span",{className:"absolute inset-0 cursor-not-allowed"}))},ux=e=>{let t=e.label,n=e.dotClassName,l=e.name,r=e.value,o=e.onChange;return a.createElement("div",{"data-external-id":"split-row",className:"flex items-center gap-xs"},a.createElement("div",{className:"flex flex-1 items-center gap-xs"},a.createElement("div",{className:"size-2 shrink-0 rounded-full ".concat(n)}),a.createElement(Lb,null,t)),a.createElement("div",{className:(0,q.cn)("w-[110px]","shrink-0")},a.createElement(fe.K$5,{name:l,value:r,onValueChange:e=>o(null!==e&&void 0!==e?e:0),precision:0,onFocus:(0,ix.s)(r)})))},mx=e=>{let t=e.label,n=e.tooltip,l=e.total;return a.createElement("div",{"data-external-id":"split-header",className:"flex items-center gap-2xs"},a.createElement(fe.cIj,{size:"3xs",content:n,iconSize:"xs",label:a.createElement(Lb,null,t)}),a.createElement("span",{className:"ml-auto text-base text-content-secondary"},(0,rl.T3)(l)))},px=()=>{const e=vy().openUncategorizedSavings;return a.createElement(m.g,{"data-external-id":"uncategorized-savings",column:!0,gap:"default",padding:"default",border:"1px solid divider.secondary",borderRadius:"small",alignStart:!0},a.createElement(m.g,{column:!0,gap:"xxsmall"},a.createElement(xt.v,{size:"small",weight:"medium"},Lg),a.createElement(xt.v,{size:"small",color:"content.secondary"},"When you\u2019re forecasted to earn more than you spend, you can distribute savings across accounts. ",a.
1createElement(Bb,{href:rh},"Learn more"))),a.createElement(wt.Xb,{size:"small",type:"button",onClick:()=>e()},"Change savings splits"))},gx=()=>{const e=vy().openWithdrawalOrder;return a.createElement(m.g,{"data-external-id":"withdrawal-order",column:!0,gap:"default",padding:"default",border:"1px solid divider.secondary",borderRadius:"small",alignStart:!0},a.createElement(m.g,{column:!0,gap:"xxsmall"},a.createElement(xt.v,{size:"small",weight:"medium"},"Expense withdrawal order"),a.createElement(xt.v,{size:"small",color:"content.secondary"},"Choose the order in which to use your savings and investments to cover expenses in retirement and other events."," ",a.createElement(Bb,{href:lh},"Learn more"))),a.createElement(wt.Xb,{size:"small",type:"button",onClick:e},"Change withdrawal order"))},hx="Early withdrawal penalties cannot be calculated until you do so.",vx=e=>{let t=e.isPenaltyEligible,n=e.timing,l=e.ownerId,o=e.ownerBirthday,i=e.householdUserIds,s=e.monarchAccountId;const c=vy().openAssumptions,d=uv({isPenaltyEligible:t,timing:n,ownerId:l,householdUserIds:i,ownerBirthday:o});if(void 0===d)return null;const u=n===Ee.TXV.STARTING_YEAR?"to edit the starting year.":"to forecast taxes, penalties, and future value.";return(0,r.YW)(d).with("shared-ownership",(()=>a.createElement(fe.hzW.Root,{variant:"error",icon:null},a.createElement(fe.hzW.Description,{className:"flex flex-col gap-lg"},a.createElement("span",null,"You need to"," ",s?a.createElement(Vl.W,{size:"sm",to:I.JZ.accounts.accountDetails.edit({id:s})},"assign an owner"):"assign an owner"," ","to this account ",u),a.createElement("span",null,hx))))).with("missing-birthday",(()=>a.createElement(fe.hzW.Root,{variant:"error",icon:null},a.createElement(fe.hzW.Description,{className:"flex flex-col gap-lg"},a.createElement("span",null,"You need to"," ",a.createElement(fe.XZZ,{variant:"text",colorScheme:"link",size:"sm",className:"inline h-auto px-0",onClick:e=>{e.preventDefault(),c()}},"add a birthday")," ","for this account's owner ",u),a.createElement("span",null,hx))))).exhaustive()},fx=e=>{let t=e.account,n=e.startYear,l=e.maxYear,r=e.ownerBirthday,o=e.penaltyFreeAge,i=e.onUpdate;return a.createElement(fe.RVf.Root,{"data-external-id":"penalty-free-age-field",size:"md"},a.createElement(fe.RVf.Label,null,"Penalty-free age"),a.createElement(fe.hGA,{size:"md",options:[...sv],value:void 0!==o?String(o):null,onValueChange:e=>{null!==e&&i((e=>{let t=e.birthday,n=e.previousPenaltyFreeAge,a=e.nextPenaltyFreeAge,l=e.currentStartingYear,r=e.fallbackYear,o=e.maxYear;const i={penaltyFreeAge:a};if(void 0===t||void 0===n||void 0===l)return i;const s=tv(t,n);if(void 0===s||l!==s)return i;const c=tv(t,a);return void 0!==c&&(i.withdrawalStartingYear=ov(c,r,o)),i})({birthday:r,previousPenaltyFreeAge:o,nextPenaltyFreeAge:Number(e),currentStartingYear:t.withdrawalStartingYear,fallbackYear:n,maxYear:l}))}}))};var Ex=n(26481);const yx=e=>{let t=e.penaltyRate,n=e.onUpdate;const l=(0,a.useId)();return a.createElement(fe.RVf.Root,{"data-external-id":"penalty-rate-field",size:"md"},a.createElement(fe.RVf.Label,{htmlFor:l},"Early withdrawal penalty"),a.createElement(fe._CU.Root,{value:null!==t&&void 0!==t?t:null,min:0,step:"any",locale:"en-US",format:Ug,onValueChange:e=>n({penaltyRate:null!==e&&void 0!==e?e:0})},a.createElement(fe.i9A,null,a.createElement(fe._CU.Input,Object.assign({id:l,name:"penaltyRate"},(0,Ex.p)("numeric-input"))),a.createElement(fe.i9A.Addon,{align:"content-end"},a.createElement(fe.i9A.Text,null,"%")))))},bx="Funds will be taken from this account as needed.",xx=", early withdrawal penalties will apply.",wx="Funds will be taken from this account as needed, but no sooner than",Cx=e=>{let t=e.timing,n=e.isPenaltyEligible,l=e.penaltyFreeAge,o=e.ownerBirthday,i=e.startingYear;const s=iv(null!==l&&void 0!==l?l:59.5),c=void 0!==o&&void 0!==l?tv(o,l):void 0,d=void 0===i?void 0:cv({year:i,birthday:o,penaltyFreeAge:l}),u=a.createElement(fe.liZ,{size:"sm",href:"https://help.monarch.c
1om/hc/en-us/articles/48344305092244-Forecasting-in-Monarch#h_01KPGT13HBT56E5N13PJMQWG2K",external:!0},"Learn more"),m=(0,r.YW)({timing:t,isPenaltyEligible:n}).with({timing:Ee.TXV.NEVER},(()=>"Funds will never be taken from this account.")).with({isPenaltyEligible:!0},(()=>void 0!==c&&void 0!==l?a.createElement(a.Fragment,null,"If you take funds before"," ",a.createElement("span",{className:"font-medium"},c," (age ",iv(l),")"),xx," ",u):a.createElement(a.Fragment,null,"If you take funds before ",a.createElement("span",{className:"font-medium"},"age ",s),xx," ",u))).with({timing:Ee.TXV.STARTING_YEAR},(()=>void 0===i?bx:void 0!==d?a.createElement(a.Fragment,null,wx," ",a.createElement("span",{className:"font-medium"},i," (age ",d,")"),"."):a.createElement(a.Fragment,null,wx," ",a.createElement("span",{className:"font-medium"},i),"."))).otherwise((()=>bx));return a.createElement(fe.RVf.Description,{"data-external-id":"withdrawal-timing-description"},m)},Ax=[{value:Ee.TXV.ALWAYS,label:"Anytime"},{value:Ee.TXV.STARTING_YEAR,label:"Starting year"},{value:Ee.TXV.NEVER,label:"Never"}],Ix=e=>{var t;let n=e.account,l=e.startYear,r=e.maxYear,o=e.isWithdrawalDisabled,i=e.isPenaltyEligible,s=e.ownerBirthday,c=e.penaltyFreeAge,d=e.effectiveTiming,u=e.onUpdate;const m=!o&&d.timing===Ee.TXV.STARTING_YEAR,p=i&&void 0===s,g=p?void 0:null!==(t=n.withdrawalStartingYear)&&void 0!==t?t:d.startingYear;return a.createElement(fe.RVf.Root,{"data-external-id":"withdrawal-timing-field",size:"sm",disabled:o},a.createElement(fe.RVf.Label,null,"Withdrawal timing"),a.createElement("div",{className:m?"flex items-end gap-xs":void 0},a.createElement("div",{className:"min-w-0 flex-1"},a.createElement(fe.hGA,{size:"md",options:[...Ax],value:d.timing,onValueChange:e=>{o||null===e||u((e=>{let t=e.nextTiming,n=e.currentStartingYear,a=e.birthday,l=e.penaltyFreeAge,r=e.fallbackYear,o=e.maxYear,i=e.isPenaltyEligible;return t!==Ee.TXV.STARTING_YEAR||i&&void 0===a?{withdrawalTiming:t}:{withdrawalTiming:t,withdrawalStartingYear:null!==n&&void 0!==n?n:dv({birthday:a,penaltyFreeAge:l,fallbackYear:r,maxYear:o})}})({nextTiming:e,currentStartingYear:n.withdrawalStartingYear,birthday:s,penaltyFreeAge:c,fallbackYear:l,maxYear:r,isPenaltyEligible:i}))},disabled:o})),m&&a.createElement("div",{className:"min-w-0 flex-1"},a.createElement(Lb,{className:"sr-only"},"Starting year"),a.createElement(bb,{value:g,onChange:e=>u({withdrawalStartingYear:e}),birthday:s,getAgeLabel:e=>cv({year:e,birthday:s,penaltyFreeAge:c}),minYear:l,isDisabled:p,placeholder:p?"-":void 0}))),a.createElement(Cx,{timing:d.timing,isPenaltyEligible:i,penaltyFreeAge:c,ownerBirthday:s,startingYear:g}))},kx=e=>{let t=e.account,n=e.startYear,l=e.monarchAccountId,r=e.onUpdate,o=e.isWithdrawalDisabled,i=void 0!==o&&o;const s=wE((e=>e.householdUserIds)),c=QE(),d=n+c.projectionYears,u=lv(t.accountType.subtype),m=av(t,s,c.participants),p=(e=>{var t,n,a;const l=Xh(e.accountType.subtype);return{penaltyRate:null!==(t=null!==(n=e.penaltyRate)&&void 0!==n?n:null===l||void 0===l?void 0:l.penaltyRate)&&void 0!==t?t:0,penaltyFreeAge:null!==(a=e.penaltyFreeAge)&&void 0!==a?a:null===l||void 0===l?void 0:l.penaltyFreeAge}})(t),g=p.penaltyRate,h=p.penaltyFreeAge,v=i?{timing:Ee.TXV.NEVER,startingYear:void 0}:pv({account:t,settings:c,householdUserIds:s}),f=!i&&v.timing!==Ee.TXV.NEVER&&u;return a.createElement("div",{"data-external-id":"early-withdrawal-settings-section",className:"flex flex-col gap-xl"},a.createElement("div",{className:"flex flex-col gap-xs"},a.createElement(Ix,{account:t,startYear:n,maxYear:d,isWithdrawalDisabled:i,isPenaltyEligible:u,ownerBirthday:m,penaltyFreeAge:h,effectiveTiming:v,onUpdate:r}),f&&a.createElement(vx,{isPenaltyEligible:u,timing:v.timing,ownerId:t.ownerId,ownerBirthday:m,householdUserIds:s,monarchAccountId:l})),f&&a.createElement(a.Fragment,null,a.createElement(yx,{penaltyRate:g,onUpdate:r}),a.createElement(fx,{account:t,startYear:n,maxYear:d,ownerBirthday:m,penaltyFreeAge:h,onUpdate:r})))},Sx=e=>Object.keys(e.dirtyCategories).length>0,Nx=e=>Sx(e)||Object.keys(e.savingCategories).length>0,Tx=e=>!Nx(e)&&!e.isConflicted,_x=()=>wE(Tx),Dx=()=>{const e=(0,i.n)(Dv.ej),t=(0,o.A)(e,2),n=t[0],l=t[1],r=wE((e=>e.removeDeletedAccount));return{deleteAccount:(0,a.useCallback)((async e=>{var t,a;const l=wE.getState(),o=l.scenarioExternalId;if(!o)return{success:!1,error:"No scenario loaded."};if(!Tx(l))return{success:!1,error:"Please wait for your changes to finish saving."};const i=null!==(t=null===(a=l.categoryVersions)||void 0===a?void 0:a.accounts)&&void 0!==t?t:0;try{var s,c;const t=(await n({variables:{input:{scenarioExternalId:o,accountExternalId:e,expectedVersion:i}}})).data,a=null===t||void 0===t?void 0:t.deleteForecastAccount,l=null===a||void 0===a||null===(s=a.errors)||void 0===s?void 0:s.message;if("VERSION_CONFLICT"===l)return wE.setState((e=>{e.isConflicted=!0})),{success:!1,error:"VERSION_CONFLICT"};if(l)return{success:!1,error:l};const d=null===a||void 0===a||null===(c=a.scenario)||void 0===c?void 0:c.categoryVersions;return d?(r(e,{accountsVersion:d.accountsVersion,priorityRulesVersion:d.priorityRulesVersion}),{success:!0}):{success:!1,error:"Account was not deleted."}}catch(d){return{success:!1,error:d instanceof Error?d.message:"Delete failed."}}}),[n,r]),isDeleting:l.loading}};var Rx=n(32515);const Mx=e=>{let t=e.accountId,n=e.accountName;const l=Dx(),r=l.deleteAccount,o=l.isDeleting,i=_x(),s=BE().name,c=(0,C.RU)();return a.createElement("div",{"data-external-id":"delete-forecast-account-confirmation",className:"flex flex-col gap-sm"},a.createElement(fe.hzW,{variant:"error",icon:null},"This account has been deleted from Monarch and no longer receives updates. You can remove it from your forecast when you\u2019re ready."),a.createElement(fe.V0Z,{tone:"destructive",trigger:a.createElement(fe.XZZ,{variant:"danger",className:"w-full",disabled:!i||o},"Remove account"),title:"Remove ".concat(n," from ").concat(s,"?"),confirmLabel:"Remove account",onConfirm:async()=>{const e=await r(t);if(!e.success&&"VERSION_CONFLICT"!==e.error)throw c({title:"Couldn't remove account",description:e.error}),new Error(e.error)}},a.createElement("div",{className:"flex flex-col gap-default rounded-default bg-background-secondary p-xl"},a.createElement(fe.c8D,{weight:"medium"},"What will change:"),a.createElement("ul",{className:"m-0 flex list-none flex-col gap-default p-0"},a.createElement("li",{className:"flex items-start gap-default"},a.createElement(Rx.MdsXCircleIcon,{className:"mt-3xs",size:22}),a.createElement(fe.c8D,null,"The account will be removed from this scenario")),a.createElement("li",{className:"flex items-start gap-default"},a.createElement(Rx.MdsXCircleIcon,{className:"mt-3xs",size:22}),a.createElement(fe.c8D,null,"It will no longer affect your projections"))))))},Lx=(0,mh.v)((e=>
1({viewModeByScenarioId:{},setViewMode:(t,n)=>e((e=>({viewModeByScenarioId:(0,U.A)((0,U.A)({},e.viewModeByScenarioId),{},{[t]:n})}))),resetViewMode:t=>e((e=>({viewModeByScenarioId:(0,U.A)((0,U.A)({},e.viewModeByScenarioId),{},{[t]:"active"})})))}))),Ox=()=>(0,l.g)().scenarioId,Px=()=>{const e=Ox(),t=Lx((t=>{var n;return null!==(n=e?t.viewModeByScenarioId[e]:void 0)&&void 0!==n?n:"active"})),n=Lx((e=>e.setViewMode));return{viewMode:t,setViewMode:t=>{e&&n(e,t)}}},Bx=e=>{var t,n,a,l;let r=e.netWorthData,o=e.eventModels,i=e.currentParticipant,s=e.startYear;const c=o.map((e=>e.config)),d=r.find((e=>e.year===s)),u=null!==(t=null===d||void 0===d?void 0:d.netWorth)&&void 0!==t?t:null,m=i?rE(i,c):null,p=null!==(n=null===i||void 0===i?void 0:i.hiddenFromForecast)&&void 0!==n&&n,g=null!==m,h=m&&!p&&null!==(a=null===(l=r.find((e=>e.year===m.startYear)))||void 0===l?void 0:l.netWorth)&&void 0!==a?a:null,v=i&&!p?oE(i,c):null,f=i?rg(o,i.userId,{includedOnly:!0}):void 0,E=null===f||void 0===f?void 0:f.startYear;let y=null;var b,x;if(void 0!==E)y=null!==(b=null===(x=r.find((e=>e.year===E)))||void 0===x?void 0:x.netWorth)&&void 0!==b?b:null;else if(r.length>0){var w,C;y=null!==(w=null===(C=r[r.length-1])||void 0===C?void 0:C.netWorth)&&void 0!==w?w:null}const A=o.filter((e=>e.isIncluded&&!e.isHidden)).length;return{netWorthEOY:u,netWorthAtRetirement:h,retirementAge:v,netWorthAtEnd:y,endOfPlanYear:E,hasRetirementEvent:g,lifeEventsCount:A}},zx=e=>(0,Tp.n)(e.netWorthEOY)?{netWorthToday:e.netWorthEOY,netWorthAtRetirement:e.netWorthAtRetirement,retirementAge:e.retirementAge,netWorthAtEnd:e.netWorthAtEnd,lifeEventsCount:e.lifeEventsCount}:void 0,Fx=()=>{const e={startYear:(new Date).getFullYear(),projectionYears:50,participants:[],inflationRate:3};return{projection:null,events:[],eventModels:[],netWorthData:[],accounts:[],settings:e,dollarMode:yh("futureDollars",e.inflationRate,e.startYear),hasUnfundedExpenses:!1,splitUncategorizedSavings:!1,withdrawalOrderAccountIds:[],startYear:void 0,participants:[],engineError:void 0}},Gx=async e=>{try{await e.refetchQueries({include:["Web_ForecastScenario"]})}catch(t){}},Yx=()=>{const e=(0,V.m)(),t=(0,i.n)(Dv.Tx,{optimisticResponse:e=>{var t;return{__typename:"Mutation",updateForecastScenarioComparison:{__typename:"UpdateForecastScenarioComparison",errors:null,scenario:{__typename:"ForecastScenarioType",externalId:e.input.scenarioExternalId,compareToScenarioExternalId:null!==(t=e.input.compareToScenarioExternalId)&&void 0!==t?t:null}}}},update(e,t,n){var a;let l=t.data,r=n.variables;if(!r)return;const o=null===l||void 0===l?void 0:l.updateForecastScenarioComparison;null!==o&&void 0!==o&&o.errors||null===o||void 0===o||!o.scenario||((e,t,n)=>{const a=e.readQuery({query:Dv.Tu,variables:{externalId:t}});null!==a&&void 0!==a&&a.forecastScenario&&e.writeQuery({query:Dv.Tu,variables:{externalId:t},data:(0,U.A)((0,U.A)({},a),{},{forecastScenario:(0,U.A)((0,U.A)({},a.forecastScenario),{},{compareToScenarioExternalId:n})})})})(e,r.input.scenarioExternalId,null!==(a=o.scenario.compareToScenarioExternalId)&&void 0!==a?a:null)},onError:()=>{Gx(e)},onCompleted:t=>{const n=null===t||void 0===t?void 0:t.updateForecastScenarioComparison;(null!==n&&void 0!==n&&n.errors||null===n||void 0===n||!n.scenario)&&Gx(e)}}),n=(0,o.A)(t,1)[0];return{updateComparison:(0,a.useCallback)((async e=>{try{const t=(await n({variables:{input:e}})).data,a=null===t||void 0===t?void 0:t.updateForecastScenarioComparison;return Boolean((null===a||void 0===a?void 0:a.scenario)&&!a.errors)}catch(t){return!1}}),[n])}},Ux={byScenarioId:{},yearTableViewByScenarioId:{},modeByScenarioId:{},chanceOfSuccessViewByScenarioId:{}},Vx=(0,mh.v)(((e,t)=>(0,U.A)((0,U.A)({},Ux),{},{setYearTableViewForScenario:(t,n,a)=>{I.Q6.includes(a)&&e((e=>({yearTableViewByScenarioId:(0,U.A)((0,U.A)({},e.yearTableViewByScenarioId),{},{[t]:(0,U.A)((0,U.A)({},e.yearTableViewByScenarioId[t]),{},{[n]:a})})})))},getYearTableViewForScenario:(e,n)=>{var a;return null===(a=t().yearTableViewByScenarioId[e])||void 0===a?void 0:a[n]},setModeForScenario:(t,n)=>{I.vk.includes(n)&&e((e=>({modeByScenarioId:(0,U.A)((0,U.A)({},e.modeByScenarioId),{},{[t]:n})})))},getModeForScenario:e=>t().modeByScenarioId[e],setChanceOfSuccessViewForScenario:(t,n)=>{I.y3.includes(n)&&e((e=>({chanceOfSuccessViewByScenarioId:(0,U.A)((0,U.A)({},e.chanceOfSuccessViewByScenarioId),{},{[t]:n})})))},getChanceOfSuccessViewForScenario:e=>t().chanceOfSuccessViewByScenarioId[e],setSnapshotForScenario:(t,n)=>e((e=>{if(null===n){const n=e.byScenarioId;n[t];return{byScenarioId:(0,En.A)(n,[t].map(nf.A))}}return{byScenarioId:(0,U.A)((0,U.A)({},e.byScenarioId),{},{[t]:n})}})),clearSnapshotForScenario:t=>e((e=>{if(!(t in e.byScenarioId))return e;const n=e.byScenarioId;n[t];return{byScenarioId:(0,En.A)(n,[t].map(nf.A))}})),clearMemoryForScenario:t=>e((e=>{const n=e.byScenarioId,a=(n[t],(0,En.A)(n,[t].map(nf.A))),l=e.yearTableViewByScenarioId,r=(l[t],(0,En.A)(l,[t].map(nf.A))),o=e.modeByScenarioId,i=(o[t],(0,En.A)(o,[t].map(nf.A))),s=e.chanceOfSuccessViewByScenarioId;s[t];return{byScenarioId:a,yearTableViewByScenarioId:r,modeByScenarioId:i,chanceOfSuccessViewByScenarioId:(0,En.A)(s,[t].map(nf.A))}})),getSnapshotForScenario:e=>{var n;return null!==(n=t().byScenarioId[e])&&void 0!==n?n:null},reset:()=>e((0,U.A)({},Ux))}
1))),Wx=e=>void 0!==e&&I.Q6.includes(e),jx=e=>void 0!==e&&I.vk.includes(e),Hx=e=>void 0!==e&&I.y3.includes(e),Kx=e=>{const t=(null!==e&&void 0!==e?e:"").split("/").filter((e=>e.length>0)),n=(0,o.A)(t,2),a=n[0],l=n[1];if(Wx(a))return{mode:"plan",yearTableView:a,shouldRedirect:!0,path:"plan/".concat(a)};if(!jx(a))return(e=>({mode:"plan",yearTableView:"accounts",shouldRedirect:e,path:"plan/accounts"}))(!0);if("chance-of-success"===a){const e=Hx(l)?l:I.vc;return{mode:a,chanceOfSuccessView:e,shouldRedirect:l!==e||2!==t.length,path:"".concat(a,"/").concat(e)}}const r=Wx(l)?l:"accounts";return{mode:a,yearTableView:r,shouldRedirect:l!==r||2!==t.length,path:"".concat(a,"/").concat(r)}},qx=e=>{if("chance-of-success"===e.mode){const t=Hx(e.chanceOfSuccessView)?e.chanceOfSuccessView:I.vc;return"".concat(I.su,"/").concat(e.scenarioId,"/").concat(e.mode,"/").concat(t)}const t="plan"===(n=e.mode)||"compare"===n?e.mode:"plan";var n;const a=Wx(e.yearTableView)?e.yearTableView:"accounts";return"".concat(I.su,"/").concat(e.scenarioId,"/").concat(t,"/").concat(a)},$x=e=>{var t;const n=Vx.getState();return"chance-of-success"===e.mode?qx((0,U.A)((0,U.A)({},e),{},{chanceOfSuccessView:n.getChanceOfSuccessViewForScenario(e.scenarioId)})):qx((0,U.A)((0,U.A)({},e),{},{yearTableView:null!==(t=n.getYearTableViewForScenario(e.scenarioId,e.mode))&&void 0!==t?t:e.yearTableView}))},Zx=()=>{const e=(0,l.g)(),t=e.scenarioId,n=void 0===t?"":t,a=e["*"],r=Kx(a),o=Vx((e=>n?e.getYearTableViewForScenario(n,"plan"):void 0)),i=null!==o&&void 0!==o?o:"chance-of-success"===r.mode?"accounts":r.yearTableView;return(0,U.A)((0,U.A)({scenarioId:n},r),{},{planYearTableView:i,rememberedPlanYearTableView:o,pathname:n?"".concat(I.su,"/").concat(n,"/").concat(r.path):"".concat(I.su,"/").concat(r.path)})},Jx=e=>{let t=e.startYear,n=e.currentParticipant;const l=sy(),r=XE();return(0,a.useMemo)((()=>Bx({netWorthData:l,eventModels:r,currentParticipant:n,startYear:t})),[l,r,t,n])},Xx=e=>{const t=e.kpis;if(!t||"object"!==typeof t||Array.isArray(t))return;const n=t,a="number"===typeof n.netWorthToday?n.netWorthToday:null,l="number"===typeof n.lifeEventsCount?n.lifeEventsCount:null;return null!==a&&null!==l?{netWorthToday:a,lifeEventsCount:l,netWorthAtRetirement:"number"===typeof n.netWorthAtRetirement?n.netWorthAtRetirement:null,retirementAge:"number"===typeof n.retirementAge?n.retirementAge:null,netWorthAtEnd:"number"===typeof n.netWorthAtEnd?n.netWorthAtEnd:null}:void 0},Qx=()=>{const e=QE(),t=ty(),n=(0,l.g)().scenarioId,r=Jx({startYear:e.startYear,currentParticipant:t}),o=r.netWorthEOY,i=r.netWorthAtRetirement,s=r.retirementAge,c=r.netWorthAtEnd,d=r.lifeEventsCount,u=(0,et.I)(Dv.Tu,{variables:{externalId:null}}),m=u.data,p=u.isLoadingInitialData,g=u.error,h=(0,et.I)(Dv.EX),v=h.data,f=h.isLoadingInitialData,E=h.error,y=wE((e=>e.scenarioExternalId)),b=wE((e=>e.scenarioMetadata)),x=(0,a.useMemo)((()=>zx({netWorthEOY:o,netWorthAtRetirement:i,retirementAge:s,netWorthAtEnd:c,lifeEventsCount:d})),[d,c,i,o,s]);return{scenarios:(0,a.useMemo)((()=>{const e=null===m||void 0===m?void 0:m.forecastScenario;if(!e)return[];const t=t=>n?t===n:t===e.externalId,a=(e,t,n)=>t&&e===y&&null!==x&&void 0!==x?x:n,l=e=>
1void 0!==b&&e.externalId===y?{name:b.name,icon:b.icon,color:b.color}:{name:e.name,icon:Tg(e.icon)?e.icon:Qg.icon,color:Ng(e.color)?e.color:Qg.color},r=null===v||void 0===v?void 0:v.forecastScenarios;if(r&&r.length>0){return[...r].sort(((e,t)=>e.order-t.order)).map((e=>{const n=t(e.externalId);return(0,U.A)((0,U.A)({id:e.externalId},l(e)),{},{order:e.order,isActive:n,kpis:a(e.externalId,n,Xx(e))})}))}const o=t(e.externalId);return[(0,U.A)((0,U.A)({id:e.externalId},l(e)),{},{order:0,isActive:o,kpis:a(e.externalId,o,Xx(e))})]}),[y,x,n,null===m||void 0===m?void 0:m.forecastScenario,null===v||void 0===v?void 0:v.forecastScenarios,b]),isLoading:p||f,error:null!==g&&void 0!==g?g:E}},ew=()=>{const e=py().isEnabled,t=Zx(),n=t.scenarioId,a=t.mode,l=Qx(),r=l.scenarios,o=l.isLoading,i=r.some((e=>e.id!==n));return e&&"chance-of-success"===a?"chanceOfSuccess":e&&"compare"===a&&(i||o)?"compare":"plan"},tw=(0,a.createContext)(null),nw=e=>{let t=e.children;const n=(()=>{var e;const t=(0,l.g)().scenarioId,n=void 0===t?"":t,r=Yx().updateComparison,o=(0,et.I)(Dv.Tu,{variables:{externalId:n||null},skip:!n}),i=o.data,s=o.isLoadingInitialData,c=o.isDataAvailable,d=o.isNetworkRequestInFlight,u=o.error,m=null===i||void 0===i?void 0:i.forecastScenario,p=(null===m||void 0===m?void 0:m.externalId)===n,g=!s&&p&&c&&null!==(e=null===m||void 0===m?void 0:m.compareToScenarioExternalId)&&void 0!==e?e:void 0,h=(0,a.useMemo)((()=>n?s?"loading":u?"error":!m||p&&c?"ready":d?"loading":"idle":"idle"),[n,s,c,d,u,m,p]),v=(0,a.useCallback)((async e=>{n&&e!==n&&await r({scenarioExternalId:n,compareToScenarioExternalId:e})}),[n,r]),f=(0,a.useCallback)((async()=>{n&&await r({scenarioExternalId:n,compareToScenarioExternalId:null})&&Lx.getState().resetViewMode(n)}),[n,r]);return{compareToScenarioId:g,comparisonStatus:h,compareSelectionError:u,setCompareToScenarioId:v,clearCompareToScenarioId:f}})(),r=n.compareToScenarioId,o=n.comparisonStatus,i=n.compareSelectionError,s=n.setCompareToScenarioId,c=n.clearCompareToScenarioId,d=(e=>{const t=wE((e=>e.currentUserId)),n=(0,et.I)(Dv.Tu,{variables:{externalId:null!==e&&void 0!==e?e:null},skip:!e,fetchPolicy:"cache-first"}),l=n.data,r=n.isLoadingInitialData,o=n.isDataAvailable,i=n.isNetworkRequestInFlight,s=n.error,c=null===l||void 0===l?void 0:l.forecastScenario,d=(null===c||void 0===c?void 0:c.externalId)===e,u=(0,a.useMemo)((()=>e?r?"loading":s?"error":c?d&&o?"ready":i?"loading":"idle":"idle":"idle"),[e,r,o,i,s,c,d]),m=wE((e=>e.householdUserIds)),p=(0,a.useMemo)((()=>{if("ready"!==u||!c||!d)return Fx();try{var e,t,n;const a=tf(c),l=_v(a,{householdUserIds:m}),r=l.projection,o=l.preparedInput,i=fh(a.events,a.settings),s=null!==(e=a.dollarMode)&&void 0!==e?e:"futureDollars",d=bh(r,{dollarMode:s}),u=Mp(r);return{projection:r,events:a.events,eventModels:i,netWorthData:d,accounts:o.accounts,settings:a.settings,dollarMode:yh(s,a.settings.inflationRate,a.settings.startYear),hasUnfundedExpenses:u,splitUncategorizedSavings:null!==(t=null===(n=a.uncategorizedSavingsSettings)||void 0===n?void 0:n.splitUncategorizedSavings)&&void 0!==t&&t,withdrawalOrderAccountIds:xv(o.accounts,o.customWithdrawalOrderIds).map((e=>e.rowKey.serialized)),startYear:a.settings.startYear,participants:a.settings.participants,engineError:void 0}}catch(a){return(0,U.A)((0,U.A)({},Fx()),{},{engineError:a instanceof Error?a:new Error("Unable to calculate compare scenario projection.")})}}),[u,c,d,m]),g=(0,a.useMemo)((()=>{if(!p.projection||void 0===p.startYear)return;const e=void 0!==t?p.participants.find((e=>e.userId===t)):void 0,n=Bx({netWorthData:p.netWorthData,eventModels:p.eventModels,currentParticipant:e,startYear:p.startYear});return zx(n)}),[p.projection,p.netWorthData,p.eventModels,p.startYear,p.participants,t]),h=(0,a.useMemo)((()=>{if("ready"===u&&c&&d)return{name:c.name,icon:Tg(c.icon)?c.icon:Qg.icon,
1color:Ng(c.color)?c.color:Qg.color}}),[u,c,d]),v=p.engineError?"error":u,f=null!==s&&void 0!==s?s:p.engineError;return{projection:p.projection,kpis:g,events:p.events,eventModels:p.eventModels,netWorthData:p.netWorthData,accounts:p.accounts,settings:p.settings,dollarMode:p.dollarMode,hasUnfundedExpenses:p.hasUnfundedExpenses,splitUncategorizedSavings:p.splitUncategorizedSavings,withdrawalOrderAccountIds:p.withdrawalOrderAccountIds,projectionStatus:v,projectionError:f,compareScenarioMetadata:h}})(r),u=d.projection,m=d.kpis,p=d.events,g=d.eventModels,h=d.netWorthData,v=d.accounts,f=d.settings,E=d.dollarMode,y=d.hasUnfundedExpenses,b=d.splitUncategorizedSavings,x=d.withdrawalOrderAccountIds,w=d.projectionStatus,C=d.projectionError,A=d.compareScenarioMetadata,I=(e=>{let t=e.compareToScenarioId,n=e.comparisonStatus,a=e.projectionStatus;return!!t&&"ready"===n&&"ready"===a})({compareToScenarioId:r,comparisonStatus:o,projectionStatus:w}),k=py().isEnabled,S=ew(),N=Qx(),T=N.scenarios,_=N.isLoading,D=(e=>{let t=e.isMonteCarloEnabled,n=e.forecastingMode,a=e.hasValidCompareTarget;return!t||"compare"===n&&a})({isMonteCarloEnabled:k,forecastingMode:S,hasValidCompareTarget:!!r&&(_||T.some((e=>e.id===r)))}),R=(0,a.useMemo)((()=>I?{projection:u,kpis:m,events:p,eventModels:g,netWorthData:h,accounts:v,settings:f,dollarMode:E,hasUnfundedExpenses:y,splitUncategorizedSavings:b,withdrawalOrderAccountIds:x,compareScenarioMetadata:A}:lw()),[I,u,m,p,g,h,v,f,E,y,b,x,A]),M=(0,a.useMemo)((()=>(0,U.A)({isComparisonAvailable:I,isComparisonActive:D,compareToScenarioId:r,comparisonStatus:o,compareSelectionError:i,setCompareToScenarioId:s,clearCompareToScenarioId:c,projectionStatus:w,projectionError:C},R)),[I,D,r,o,i,s,c,w,C,R]);return a.createElement(tw.Provider,{"data-external-id":"compare-projection-provider",value:M},t)},aw=()=>{const e=(0,a.useContext)(tw);if(!e)throw new Error("useCompareProjectionContext must be used within a CompareProjectionProvider");return e},lw=()=>{const e={startYear:(new Date).getFullYear(),projectionYears:50,participants:[],inflationRate:3};return{projection:null,kpis:void 0,events:[],eventModels:[],netWorthData:[],accounts:[],settings:e,dollarMode:yh("futureDollars",e.inflationRate,e.startYear),hasUnfundedExpenses:!1,splitUncategorizedSavings:!1,withdrawalOrderAccountIds:[],compareScenarioMetadata:void 0}},rw=()=>{const e=aw(),t=Ox(),n=(e=>{let t=e.viewMode,n=e.isComparisonAvailable;return e.isComparisonActive&&n&&"compare"===t})({viewMode:Lx((e=>{var n;return null!==(n=t?e.viewModeByScenarioId[t]:void 0)&&void 0!==n?n:"active"})),isComparisonAvailable:e.isComparisonAvailable,isComparisonActive:e.isComparisonActive});return{isTableShowingCompareData:n,compare:e}},ow=()=>{const e=wE((e=>{var t;return null!==(t=e.dollarMode)&&void 0!==t?t:"futureDollars"})),t=wE((e=>e.settings.inflationRate)),n=wE((e=>e.settings.startYear));return(0,a.useMemo)((()=>yh(e,t,n)),[e,t,n])},iw=[],sw=(e,t,n,a)=>e?a(t):n,cw=e=>e.projection,dw=e=>e.accounts,uw=e=>e.eventModels,mw=e=>e.events,pw=e=>e.settings,gw=e=>e.dollarMode,hw=e=>e.hasUnfundedExpenses,vw=e=>e.splitUncategorizedSavings,fw=e=>e.withdrawalOrderAccountIds,Ew=(e,t)=>{const n=rw(),a=n.isTableShowingCompareData,l=n.compare;return sw(a,l,e,t)},yw=(e,t,n,l)=>(0,a.useMemo)((()=>e?aE({snapshots:e.snapshots,accounts:t,settings:n,householdUserIds:l}):iw),[e,t,n,l]),bw=()=>Ew(WE(),cw),xw=()=>Ew(qE(),mw),ww=()=>Ew(ow(),gw),Cw=()=>{const e=rw(),t=e.isTableShowingCompareData,n=e.compare,a=WE(),l=KE(),r=QE(),o=wE((e=>Mp(e.projection))),i=ow(),s=wE((e=>e.householdUserIds)),c=sw(t,n,a,cw),d=sw(t,n,l,dw),u=sw(t,n,o,hw),m=sw(t,n,i,gw),p=sw(t,n,r,pw);return{projection:c,accounts:d,rows:yw(c,d,p,s),hasUnfundedExpenses:u,dollarMode:m}},Aw=()=>{const e=Ox(),t=(()=>{const e=Ox(),t=wE((e=>e.scenarioExternalId));if(e)return t&&t!==e?t:e})(),n=rw(),a=n.isTableShowingCompareData,l=n.compare.compareToScenarioId;return a&&l&&e?{kind:"compare",activeScenarioId:e,compareTargetId:l}:t?{kind:"active",activeScenarioId:t}:{kind:"none"}},Iw=(e,t,n)=>{let a=e.sourceEventExternalId;if(!a&&e.accountId){const t=n.find((t=>t.id===e.accountId));a=null===t||void 0===t?void 0:t.sourceEventExternalId}if(!a)return null;const l=t.find((e=>e.id===a));return l?{eventIcon:l.icon,eventColor:l.color,eventForegroundColor:l.foregroundColor}:null},kw=e=>{const t=xw(),n=Ew(KE(),dw);return Iw(e,t,n)},Sw=["sourceEventExternalId","accountId"],Nw=["sourceEventExternalId","accountId"],Tw=["eventIcon","size","className"],_w=e=>{let t=e.sourceEventExternalId,n=e.accountId,l=(0,En.A)(e,Sw);const r=(e=>{const t=qE(),n=KE();return Iw(e,t,n)})({sourceEventExternalId:t,accountId:n}
1);return a.createElement(Rw,Object.assign({"data-external-id":"forecast-account-logo",eventIcon:r},l))},Dw=e=>{let t=e.sourceEventExternalId,n=e.accountId,l=(0,En.A)(e,Nw);const r=kw({sourceEventExternalId:t,accountId:n});return a.createElement(Rw,Object.assign({"data-external-id":"forecast-table-account-logo",eventIcon:r},l))},Rw=e=>{var t;let n=e.eventIcon,l=e.size,r=void 0===l?28:l,o=e.className,i=(0,En.A)(e,Tw);if(!n)return a.createElement(Gl.v,Object.assign({"data-external-id":"account-logo-or-event-icon",size:r,className:o},i));const s=Math.round(r*(16/28));return a.createElement("div",{"data-external-id":"account-logo-or-event-icon",className:(0,q.cn)("flex shrink-0 items-center justify-center rounded-default",Vg[n.eventColor],Wg[null!==(t=n.eventForegroundColor)&&void 0!==t?t:n.eventColor],o),style:{width:r,height:r}},a.createElement(sl.ZQ,{name:n.eventIcon,size:s}))},Mw=(e,t)=>{const n=Wh(e.accountType),a=_p(e)?"taxable-investments":n,l="taxable-investments"===(i=a)?{showWithdrawalTaxRate:!0,showTaxableWithdrawalPercent:!0}:"tax-deferred"===i?{showWithdrawalTaxRate:!0,showTaxableWithdrawalPercent:!1}:{showWithdrawalTaxRate:!1,showTaxableWithdrawalPercent:!1},r=l.showWithdrawalTaxRate,o=l.showTaxableWithdrawalPercent;var i;const s=Rp(e),c=!!e.sourceEventExternalId,d="liability"===e.accountType.group,u=d&&!s,m=!(s&&d),p=Og.includes(n)||_p(e),g=Yh(e.accountType)&&!e.isTaxTreatmentEligible,h=!!e.isTaxTreatmentEligible,v=!s&&Gh(e.accountType),f="brokerage"===(E=e.accountType).type&&Bh(E.subtype);var E;const y=_p(e),b=p,x=!d&&!p,w=t.hasLinkedEvent,C=!s&&!c,A=!(!e.monarchAccountId||!t.hasMultipleActiveParticipants),I=!!e.isDeleted,k=!!e.monarchAccountId;return{isSyntheticAccount:c,isAccountLiability:d,showRateField:m,showStandalonePaycheckContribution:g,showMixedAccount:h,showDirectContribution:v,showContributionLimitNote:f,showUncategorizedSavings:y,showLiabilityPayments:u,showEarlyWithdrawalControls:b,showWithdrawalDisabledTiming:x,showWithdrawalTaxRate:r,showTaxableWithdrawalPercent:o,showWithdrawalOrder:p,showLinkedEvent:w,showExcludeToggle:C,showOwnerField:A,showDeletedBanner:I,showOpenInAccounts:k,sectionHasGrowth:m||g||h||v||f||y||u,sectionHasWithdrawals:b||x||r||o||p,sectionHasMisc:w||C||A||I||k}},Lw=()=>(e=>e.filter((e=>!Dp(e))))(KE());var Ow,Pw=n(40729);const Bw=()=>{var e,t,n,l,o,i,s,c,d,u;const m=vy(),p=m.closeSidebar,g=m.openEvent,h=m.openAccount,v=m.openUncategorizedSavings,f=m.id,E=oy(),y=Lw(),b=QE(),x=wE((e=>e.updateAccount)),w=wE((e=>e.enableMixedAccount)),C=wE((e=>e.disableMixedAccount)),A=wE((e=>e.updateMixedComponent)),k=ny(),S=(0,a.useMemo)((()=>y.map((e=>{var t,n;return{value:e.id,label:e.name,leading:a.createElement(_w,{logoUrl:null===(t=e.metadata)||void 0===t?void 0:t.logoUrl,icon:null===(n=e.metadata)||void 0===n?void 0:n.icon,sourceEventExternalId:e.sourceEventExternalId,size:20}),account:e}}))),[y]),N=(0,a.useMemo)((()=>{var e;return null!==(e=S.find((e=>e.value===f)))&&void 0!==e?e:S[0]}),[S,f]),T=null===N||void 0===N?void 0:N.account,_=null!==T&&void 0!==T&&T.ownerId?b.participants.find((e=>e.userId===T.ownerId)):void 0,D=uy(null!==(e=null===T||void 0===T?void 0:T.id)&&void 0!==e?e:""),R=function(e,t){const n=wE((n=>{var a;return(null!==(a=n.events)&&void 0!==a?a:jE).find((n=>n.id===e&&(void 0===t||n.eventKind===t)))})),l=wE((e=>e.settings));return(0,a.useMemo)((()=>{if(n)return Dg(n,l)}),[n,l])}(null!==(t=null===T||void 0===T?void 0:T.sourceEventExternalId)&&void 0!==t?t:null),M=ow().toTodaysDollars;if(!T)return a.createElement(Sb,{"data-external-id":"account-sidebar"},a.createElement(Tb,null,a.createElement(Ww,null,"No accounts"),a.createElement(fe.TU1,{variant:"outline",onClick:p,"aria-label":"Close sidebar"})),a.createElement(_b,null,a.createElement(jw,null,"No accounts are included in this forecast.")));const L=Yw(T),O=(null!==T&&void 0!==T?T:{}).monarchAccountId,P=Wh(T.accountType),B=_p(T)?Gw("taxable-investments"):Gw(P),z=Mw(T,{hasMultipleActiveParticipants:k,hasLinkedEvent:!!R}),F=z.isSyntheticAccount,G=z.isAccountLiability,Y=z.showRateField,U=z.showStandalonePaycheckContribution,V=z.showMixedAccount,W=z.showDirectContribution,j=z.showContributionLimitNote,H=z.showUncategorizedSavings,K=z.showLiabilityPayments,q=z.showEarlyWithdrawalControls,$=z.
1showWithdrawalDisabledTiming,Z=z.showWithdrawalTaxRate,J=z.showTaxableWithdrawalPercent,X=z.showWithdrawalOrder,Q=z.showLinkedEvent,ee=z.showExcludeToggle,te=z.showOwnerField,ne=z.showDeletedBanner,ae=z.showOpenInAccounts,le=z.sectionHasGrowth,re=z.sectionHasWithdrawals,oe=z.sectionHasMisc,ie=K?Lp(T):[],se=ie.includes("interestRate"),ce=ie.includes("payment"),de=(0,Tr.A)(T.linkedInterestRate)&&T.interestRate!==T.linkedInterestRate,ue=(0,Tr.A)(T.linkedMinimumPayment)&&T.minimumPayment!==T.linkedMinimumPayment,me=(0,Tr.A)(T.linkedPlannedPayment)&&T.plannedPayment!==T.linkedPlannedPayment,pe=yp({plannedPayment:T.plannedPayment,minimumPayment:T.minimumPayment}),ge=12*pe,he=pe>0&&D&&T.isIncluded&&(null===(n=T.reduceExpensesForPaidOffDebt)||void 0===n||n);return a.createElement(Sb,{"data-external-id":"account-sidebar"},a.createElement(Tb,null,a.createElement(fe.hGA,{placeholder:fe.L2e,size:"sm",name:"accountId",value:null===N||void 0===N?void 0:N.value,options:S,onValueChange:e=>{h(e)},classNames:{trigger:"flex-1 min-w-0"}}),a.createElement(fe.TU1,{variant:"outline",onClick:p,"aria-label":"Close sidebar"})),a.createElement(_b,null,K&&!F&&a.createElement(Hw,null,"Auto-filled from ",a.createElement(Vl.W,{to:I.JZ.goals.debtPaydown()},"Debt pay down"),". Changes made here only affect your forecast and won\u2019t be applied to debt pay down."),a.createElement(Uw,{title:G?"Payments":"Growth",showHeader:le},Y&&(G?a.createElement("div",{className:"flex flex-col gap-xs"},a.createElement(Lb,null,L),a.createElement(Kw,{name:"interestRate",fieldId:"interestRate",hideLabel:!0,errors:se?["Required to calculate future balance"]:void 0,description:(0,r.YW)(!0).when((()=>F),(()=>"Calculated from the linked event")).when((()=>de),(()=>{var e;return"Linked account value: ".concat(nb(null!==(e=T.linkedInterestRate)&&void 0!==e?e:0))})).otherwise((()=>"If your loan has a variable rate, enter your current rate, and keep it up-to-date over time to ensure accurate calculations."))},a.createElement(fe._CU.Root,{value:null!==(l=T.interestRate)&&void 0!==l?l:null,disabled:F,min:0,step:"any",locale:"en-US",format:Ug,onValueChange:e=>x(T.id,{interestRate:null!==e&&void 0!==e?e:0})},a.createElement(fe.i9A,{invalid:se},a.createElement(fe._CU.Input,Object.assign({name:"interestRate"},(0,Ex.p)("numeric-input"))),a.createElement(fe.i9A.Addon,{align:"content-end"},a.createElement(fe.i9A.Text,null,"%")))))):a.createElement(ex,{key:T.id,account:T,startYear:b.startYear,projectionYears:b.projectionYears,onChange:e=>x(T.id,e)})),U&&a.createElement(zw,{yearlyPaycheckContribution:T.yearlyPaycheckContribution,onYearlyPaycheckContributionChange:e=>x(T.id,{yearlyPaycheckContribution:e})}),V&&a.createElement(sx,{account:T,onEnable:()=>w(T.id),onDisable:()=>C(T.id),onUpdateComponent:(e,t)=>A(T.id,e,t),paycheckContribution:Yh(T.accountType)?a.createElement(zw,{yearlyPaycheckContribution:T.yearlyPaycheckContribution,disabled:!!op(T),onYearlyPaycheckContributionChange:e=>x(T.id,{yearlyPaycheckContribution:e})}):void 0}),W&&a.createElement(Fw,{accountId:T.id,allocationEntries:E,onEdit:v}),j&&a.createElement("div",{className:"\n                rounded-sm bg-background-info px-default py-xs text-sm font-book text-content-info\n              "},"The combined total of these two fields should not exceed the yearly contribution limit."),H&&a.createElement(px,null),K&&a.createElement(a.Fragment,null,a.createElement("div",{className:"flex flex-col gap-xs"},a.createElement("div",{className:"flex items-center gap-2xs"},a.createElement(fe.cIj,{size:"3xs",content:"The minimum amount required by your lender each month",iconSize:"xs",label:a.createElement(Lb,null,"Minimum monthly payment")})),a.createElement(Kw,{name:"minimumPayment",fieldId:"minimumPayment",hideLabel:!0,errors:ce?["Required to calculate future balance"]:void 0,description:(0,r.YW)(!0).when((()=>F),(()=>"Calculated from the linked event")).when((()=>ue),(()=>{var e;return"Linked account value: ".concat((0,rl.vv)(null!==(e=T.linkedMinimumPayment)&&void 0!==e?e:0))})).otherwise((()=>_t.RU.MINIMUM_MONTHLY_PAYMENT_TOOLTIP))},a.createElement(fe.K$5,{name:"minimumPayment",disabled:F,invalid:ce,value:null!==(o=T.minimumPayment)&&void 0!==o?o:null,onValueChange:e=>x(T.id,{minimumPayment:null!==e&&void 0!==e?e:void 0}),precision:0,onFocus:(0,ix.s)(T.minimumPayment)}))),a.createElement("div",{className:"flex flex-col gap-xs"},a.createElement(Lb,null,"Planned monthly payment"),a.createElement(Kw,{name:"plannedPayment",fieldId:"plannedPayment",hideLabel:!0,description:me?"Linked account value: ".concat((0,rl.vv)(null!==(i=T.linkedPlannedPayment)&&void 0!==i?i:0)):"This is used if you're paying above the minimum required. If you plan to pay the minimum, you can leave this field blank."},a.createElement(fe.K$5,{name:"plannedPayment",value:null!==(s=T.plannedPayment)&&void 0!==s?s:null,onValueChange:e=>x(T.id,{plannedPayment:null!==e&&void 0!==e?e:void 0}),precision:0,onFocus:(0,ix.s)(T.plannedPayment)}))),he&&(0,r.YW)(D).with({status:"success",payoffYear:r.P.number},(e=>{let t=e.payoffYear;return a.createElement(qw,{$type:"info"},"This debt will be paid off in ",t," with a yearly expense reduction of"," ",(0,rl.vv)(M(ge,t)),".")})).with({status:"late",payoffYear:r.P.number},(e=>{let t=e.payoffYear;return a.createElement(qw,{$type:"warning"},"Based on the information provided, this debt will not be paid off until"," ",t,".")})).with({status:"never"},(()=>a.createElement(qw,{$type:"danger"},"Based on the information provided, this debt will never be paid off."))).otherwise((()=>null)),T.isIncluded&&!F&&a.createElement(Pb,{id:"reduce-forecasted-expenses-toggle",label:"Include in living expenses",subtext:"When enabled, we'll avoid counting this payment twice and automatically reduce your expenses once the debt is paid off.",checked:null===(c=T.reduceExpensesForPaidOffDebt)||void 0===c||c,onChange:e=>x(T.id,{reduceExpensesForPaidOffDebt:e.target.checked})}))),a.createElement(Uw,{title:"Withdrawals",showHeader:re},(q||$)&&a.createElement(kx,{account:T,startYear:b.startYear,monarchAccountId:O,onUpdate:e=>x(T.id,e),isWithdrawalDisabled:$}),Z&&B.taxRateLabel&&a.createElement("div",{className:"flex flex-col gap-xs"},a.createElement(Lb,null,B.taxRateLabel),a.createElement(fe._CU.Root,{value:null!==(d=T.withdrawalTaxRate)&&void 0!==d?d:0,min:0,step:"any",locale:"en-US",format:Ug,onValueChange:e=>x(T.id,{withdrawalTaxRate:null!==e&&void 0!==e?e:0})},a.createElement(fe.i9A,null,a.createElement(fe._CU.Input,Object.assign({name:"withdrawalTaxRate"},(0,Ex.p)("numeric-input"))),a.createElement(fe.i9A.Addon,{align:"content-end"},a.createElement(fe.i9A.Text,null,"%")))),B.taxRateDescription&&a.createElement(Ob,null,B.taxRateDescription)),J&&B.taxablePercentLabel&&a.createElement("div",{className:"flex flex-col gap-xs"},a.createElement(Lb,null,B.taxablePercentLabel),a.createElement(fe._CU.Root,{value:null!==(u=T.taxableWithdrawalPercent)&&void 0!==u?u:0,min:0,step:"any",locale:"en-US",format:Ug,onValueChange:e=>x(T.id,{taxableWithdrawalPercent:null!==e&&void 0!==e?e:0})},a.createElement(fe.i9A,null,a.createElement(fe._CU.Input,Object.assign({name:"taxableWithdrawalPercent"},(0,Ex.p)("numeric-input"))),a.createElement(fe.i9A.Addon,{align:"content-end"},a.createElement(fe.i9A.Text,null,"%")))),B.taxablePercentDescription&&a.createElement(Ob,null,B.taxablePercentDescription)),X&&a.createElement(gx,null)),a.createElement(Uw,{title:"Misc",showHeader:oe},Q&&R&&a.createElement("div",{className:"flex flex-col gap-xs"},a.createElement(Lb,null,"Linked event"),a.createElement(lx,{icon:R.icon,color:R.color,foregroundColor:R.foregroundColor,name:R.displayName,onClick:()=>g(R.id)}),a.createElement(Ob,null,"This account is managed by an event. To change its settings, edit the event.")),ee&&a.createElement(Pb,{label:"Exclude from forecast",subtext:"This will exclude the account from your Forecast c
1alculations",checked:!T.isIncluded,onChange:e=>x(T.id,{isIncluded:!e.target.checked})}),te&&a.createElement("div",{className:"flex flex-col gap-xs"},a.createElement(Lb,null,"Account owner"),a.createElement($w,null,a.createElement(Pw.n,{userId:T.ownerId,userName:null===_||void 0===_?void 0:_.displayName,userProfilePictureUrl:null===_||void 0===_?void 0:_.profilePictureUrl,avatarSize:24,showLabel:!0}))),ne?a.createElement(Mx,{accountId:T.id,accountName:T.name}):ae&&O&&a.createElement(Hw,null,"You can change more settings like name and account type on the"," ",a.createElement(Vl.W,{to:I.JZ.accounts.accountDetails.edit({id:O})},"Account Settings")," ","page"))))},zw=e=>{let t=e.yearlyPaycheckContribution,n=e.onYearlyPaycheckContributionChange,l=e.disabled,r=void 0!==l&&l;return a.createElement("div",{"data-external-id":"paycheck-contribution-section",className:"flex flex-col gap-xs"},a.createElement("div",{className:"flex items-center gap-2xs"},a.createElement(Lb,null,"Yearly paycheck contribution")),a.createElement(fe.K$5,{name:"yearlyPaycheckContribution",disabled:r,value:null!==t&&void 0!==t?t:0,onValueChange:e=>n(null!==e&&void 0!==e?e:0),precision:0,onFocus:(0,ix.s)(t)}),a.createElement(Ob,null,_t.Et.ASSUMPTIONS.YEARLY_PAYCHECK_CONTRIBUTION_DESCRIPTION," ",a.createElement(Bb,{href:ih},"Learn more")))},Fw=e=>{let t=e.accountId,n=e.allocationEntries,l=e.onEdit;const o=ry(),i=(0,a.useMemo)((()=>n.find((e=>e.accountId===t))),[n,t]),s=o?(0,r.YW)(i).with({type:"percent",amount:r.P.number},(e=>{let t=e.amount;return t>0?"".concat(t,"% of extra savings"):void 0})).with({type:"dollarAmount",amount:r.P.number},(e=>{let t=e.amount;return t>0?(0,rl.T3)(t):void 0})).otherwise((()=>{})):void 0;return a.createElement("div",{"data-external-id":"direct-contribution-section",className:"flex flex-col gap-xs"},a.createElement("div",{className:"flex items-center gap-2xs"},a.createElement(Lb,null,"Yearly direct contribution")),a.createElement("div",{className:"flex items-center gap-xs"},a.createElement("div",{className:"\n            flex h-9 flex-1 items-center rounded-sm border border-border-primary\n            bg-background-secondary px-sm text-base text-content-secondary\n          "},null!==s&&void 0!==s?s:(0,rl.T3)(0)),a.createElement(wt.Xb,{size:"small",type:"button",onClick:()=>l(t)},"Edit")),a.createElement(Ob,null,"How much you plan to deposit into this account each year from your bank account in today\u2019s dollars. This amount will grow with inflation automatically.",a.createElement("br",null),a.createElement("br",null),"Since this money comes from your take-home income, this amount will be moved out of Extra Savings and into this account."," ",a.createElement(Bb,{href:rh},"Learn more")))},Gw=e=>"taxable-investments"===e?{taxRateLabel:"Capital gains tax rate",taxRateDescription:"The tax rate applied to investment gains when you withdraw.",taxablePercentLabel:"Taxable portion of withdrawals",taxablePercentDescription:a.createElement(a.Fragment,null,"Approximate percentage of each withdrawal treated as taxable gains."," ",a.createElement(Bb,{href:oh},"Learn more"))}:"tax-deferred"===e?{taxRateLabel:"Income tax rate during retirement",taxRateDescription:a.createElement(a.Fragment,null,"Tax-deferred withdrawals are taxed as ordinary income during retirement."," ",a.createElement(Bb,{href:oh},"Learn more"))}:{},Yw=e=>(e=>"liability"===e.accountType.group)(e)||"depository"===e.accountType.type?"Interest rate":"Growth rate",Uw=e=>{let t=e.title,n=e.showHeader,l=e.children;return a.createElement(a.Fragment,null,n&&a.createElement(Vw,null,t),l)},Vw=e=>{let t=e.children;return a.createElement(fe.c8D,{"data-external-id":"account-sidebar-section-header",size:"lg",weight:"medium"},t)},Ww=(0,u.default)(xt.v).attrs({as:"h2",size:"20",weight:"bold"}).withConfig({displayName:"AccountSidebar__EmptyTitle",componentId:"ikfdwg-0"})(["margin:0;"]),jw=(0,u.default)(xt.v).attrs({as:"p",size:"small",color:"content.secondary"}).withConfig({displayName:"AccountSidebar__EmptyMessage",componentId:"ikfdwg-1"})(["margin:0;"]),Hw=u.default.div.withConfig({displayName:"AccountSidebar__InfoBanner",componentId:"ikfdwg-2"})(["background:",";padding:"," ",";border-radius:",";font-size:14px;line-height:20px;color:",";"],vt.Ee.color.background.secondary,vt.YK.xsmall,vt.YK.default,vt.r8.
1small,vt.Ee.color.content.primary),Kw=(0,u.default)(Ey.oP).withConfig({displayName:"AccountSidebar__SidebarFormItem",componentId:"ikfdwg-3"})(["&:not(:last-child){margin-bottom:0;}"]),qw=u.default.div.withConfig({displayName:"AccountSidebar__PayoffBanner",componentId:"ikfdwg-4"})(["background:",";padding:"," ",";border-radius:",";font-size:14px;line-height:20px;color:",";"],(e=>{let t=e.$type;return e.theme.variables.color.background[t]}),vt.YK.xsmall,vt.YK.default,vt.r8.small,(e=>{let t=e.$type;return e.theme.variables.color.content[t]})),$w=$d.s.div(Ow||(Ow=(0,wc.A)(["\n  flex items-center gap-xs rounded-lg bg-background-secondary px-default py-sm\n"])));var Zw;const Jw=e=>{let t=e.growthType,n=e.growthRate,l=e.inflationRate,r=e.onGrowthTypeChange,o=e.onGrowthRateChange;const i=(0,a.useMemo)((()=>[{value:"inflation",label:"Match inflation (".concat(nb(l),")")},{value:"increase",label:"Increase"},{value:"decrease",label:"Decrease"},{value:"none",label:"Doesn't change"}]),[l]);return a.createElement(a.Fragment,null,a.createElement(Xw,null,a.createElement(Lb,null,"Change over time"),a.createElement(fe.hGA,{placeholder:fe.L2e,options:i,value:null!==t&&void 0!==t?t:"inflation",onValueChange:e=>{const t=e;r(t),"increase"!==t&&"decrease"!==t||void 0!==n||o(2)}})),("increase"===t||"decrease"===t)&&a.createElement(Xw,null,a.createElement(Lb,null,"Yearly ","increase"===t?"increase":"decrease"),a.createElement(wy,{value:null!==n&&void 0!==n?n:2,onChange:o,min:0,max:5,step:.2,debounceMs:150},a.createElement(Cy,{$rightColumnWidth:My},a.createElement(Iy,null),a.createElement(Ly,{name:"growthRate",formatValue:nb,parseValue:ab,min:0,max:20,step:.001,textAlign:"right"}),a.createElement(Py,{value:2})))))},Xw=$d.s.div(Zw||(Zw=(0,wc.A)(["flex flex-col gap-xs"])));var Qw=n(47107),eC=n(10357),tC=n(95830),nC=n(5690);const aC="1920-01-01",lC=(new Date(aC),[{value:Ee.Xns.EMPLOYED_FULL_TIME,label:"Employed Full-Time"},{value:Ee.Xns.EMPLOYED_PART_TIME,label:"Employed Part-Time"},{value:Ee.Xns.SELF_EMPLOYED,label:"Self-Employed/Freelancer"},{value:Ee.Xns.BUSINESS_OWNER,label:"Business Owner"},{value:Ee.Xns.UNEMPLOYED,label:"Unemployed"},{value:Ee.Xns.STUDENT,label:"Student"},{value:Ee.Xns.RETIRED,label:"Retired"}]),rC=[{value:Ee.Xx6.SINGLE,label:"Single"},{value:Ee.Xx6.MARRIED_FILING_JOINTLY,label:"Married filing jointly"},{value:Ee.Xx6.MARRIED_FILING_SEPARATELY,label:"Married filing separately"},{value:Ee.Xx6.HEAD_OF_HOUSEHOLD,label:"Head of household"},{value:Ee.Xx6.QUALIFYING_SURVIVING_SPOUSE,label:"Qualifying surviving spouse"}],oC=[{value:Ee.bNR.PARTNER,label:"Partner"},{value:Ee.bNR.FAMILY_MEMBER,label:"Family member"},{value:Ee.bNR.OTHER,label:"Other"}];var iC=n(62292);const sC=e=>{var t,n,l;let r=e.participant;const i=(0,a.useState)(!1),s=(0,o.A)(i,2),c=s[0],d=s[1],u=wE((e=>e.updateParticipant)),p=(0,nC.xd)(),g=(0,o.A)(p,1)[0].currentUser,h=(null===g||void 0===g?void 0:g.id)===r.userId,v=(0,Dv.m9)(),f=(0,o.A)(v,1)[0],E=Boolean(r.birthday),y=E?(0,Ba.NP)(r.birthday):void 0,b=r.birthday?(0,Ba.X)(r.birthday):void 0,x=null!==(t=r.lifeExpectancy)&&void 0!==t?t:sg,w=y?y+x:void 0,C=(0,a.useMemo)((()=>Array.from({length:61},((e,t)=>({value:(50+t).toString(),label:"".concat(50+t," years")})))),[]),A={birthday:null!==(n=r.birthday)&&void 0!==n?n:null,lifeExpectancy:E?x.toString():"",endYear:w?w.toString():"",hiddenFromForecast:r.hiddenFromForecast},I=(0,a.useCallback)((async e=>{var t;let n=e.birthday,a=e.lifeExpectancy,l=e.hiddenFromForecast;const o={};(null!==n&&void 0!==n?n:void 0)!==r.birthday&&(o.birthday=null!==n&&void 0!==n?n:void 0,await f({variables:{input:(0,Dv.Ml)(r.userId,null!==n&&void 0!==n?n:null)}}));const i=null!==(t=r.lifeExpectancy)&&void 0!==t?t:sg,s=parseInt(a,10);s!==i&&(o.lifeExpectancy=s),l!==r.hiddenFromForecast&&(o.hiddenFromForecast=l),Object.keys(o).length>0&&u(r.userId,o)}),[r.birthday,r.lifeExpectancy,r.hiddenFromForecast,r.userId,u,f]);return a.createElement(dC,{"data-external-id":"participant-card"},a.createElement(uC,{$isOpen:c,onClick:()=>d(!c),type:"button"},a.createElement(mC,null,a.createElement(pC,null,a.createElement(sl.ZQ,{name:c?"chevron-down":"chevron-right",size:16})),a.createElement(gC,null,a.createElement(Pw.n,{userId:r.userId,userName:r.displayName,userProfilePictureUrl:r.profilePictureUrl,avatarSize:24,showLabel:!1}
1),a.createElement(hC,null,r.displayName))),void 0!==b&&a.createElement(vC,null,"Age ",b)),a.createElement(Ql.$,{open:c,shouldAnimateOnMount:!1},a.createElement(Eu.lV,{initialValues:A,onSubmit:I,submitOnChange:!0,submitOnChangeDebounceMs:350},a.createElement(m.g,{column:!0,gap:"large",padding:"default"},a.createElement(tC.zB.Date,{name:"birthday",label:"Birthday",dateFormat:iC.yP,description:a.createElement(a.Fragment,null,"This will also change ",h?"your":"their"," birthday in"," ",h?"your":"their"," profile and"," ",a.createElement(Vl.W,{to:(0,Ue.AI)("members","household-members")},"Household Members")," ","settings"),min:aC,max:null!==(l=N.c9.now().toISODate())&&void 0!==l?l:void 0}),a.createElement(cC,{birthYear:y,lifeExpectancyOptions:C,disabled:!E}),a.createElement(eC.J,{name:"hiddenFromForecast",label:"Exclude from forecast",subtext:"This will exclude the member from your Forecast page"})))))},cC=e=>{let t=e.birthYear,n=e.lifeExpectancyOptions,l=e.disabled,r=void 0!==l&&l;const o=(0,hu.x)(),i=o.values,s=o.setFieldValue,c=(0,a.useCallback)((e=>{if(void 0===t)return;const n=parseInt(e,10);s("endYear",(t+n).toString())}),[t,s]);return(0,a.useEffect)((()=>{if(void 0===t)return;const e=parseInt(i.endYear,10);if(!isNaN(e)){const n=e-t,a=Math.max(50,Math.min(110,n));a.toString()!==i.lifeExpectancy&&s("lifeExpectancy",a.toString())}}),[t,i.endYear,i.lifeExpectancy,s]),a.createElement(fC,{"data-external-id":"life-expectancy-row"},a.createElement(yC,null,"Life expectancy"),a.createElement(EC,null,a.createElement(tC.zB.Select,{name:"lifeExpectancy",label:null,options:n,disabled:r,onValueChanged:(e,t)=>{null!==t&&c(t)}}),a.createElement(Qw.X,{name:"endYear",hideLabel:!0,type:"number",disabled:r})),a.createElement(bC,null,r?"Set a birthday to configure life expectancy":"Set when your forecast should end"))},dC=u.default.div.withConfig({displayName:"ParticipantCard__Container",componentId:"jwtvl9-0"})(["background:",";border:1px solid ",";border-radius:",";"],vt.Ee.color.background.primary,vt.Ee.color.border.primary,vt.r8.small),uC=u.default.button.withConfig({displayName:"ParticipantCard__Header",componentId:"jwtvl9-1"})(["display:flex;align-items:center;justify-content:space-between;width:100%;height:56px;padding:0 "," 0 ",";background:",";border:none;border-bottom:1px solid ",";border-radius:",";cursor:pointer;&:hover{background:",";}"],vt.YK.default,vt.YK.xsmall,vt.Ee.color.background.primary,(e=>{let t=e.$isOpen,n=e.theme;return t?n.variables.color.divider.primary:"transparent"}),(e=>{let t=e.$isOpen,n=e.theme;const a="calc(".concat(n.radius.small," - 1px)");return t?"".concat(a," ").concat(a," 0 0"):a}),vt.Ee.color.background.secondary),mC=u.default.div.withConfig({displayName:"ParticipantCard__HeaderLeft",componentId:"jwtvl9-2"})(["display:flex;align-items:center;gap:",";"],vt.YK.xsmall),pC=u.default.div.withConfig({displayName:"ParticipantCard__ChevronButton",componentId:"jwtvl9-3"})(["width:32px;height:32px;display:flex;align-items:center;justify-content:center;border-radius:999px;color:",";"],vt.Ee.color.content.primary),gC=u.default.div.withConfig({displayName:"ParticipantCard__ParticipantInfo",componentId:"jwtvl9-4"})(["display:flex;align-items:center;gap:",";"],vt.YK.xsmall),hC=u.default.span.withConfig({displayName:"ParticipantCard__ParticipantName",componentId:"jwtvl9-5"})(["font-size:16px;font-weight:",";color:",";"],vt.Wy.medium,vt.Ee.color.content.primary),vC=u.default.span.withConfig({displayName:"ParticipantCard__AgeLabel",componentId:"jwtvl9-6"})(["font-size:16px;font-weight:",";color:",";"],vt.Wy.medium,vt.Ee.color.content.primary),fC=u.default.div.withConfig({displayName:"ParticipantCard__LifeExpectancySection",componentId:"jwtvl9-7"})(["display:flex;flex-direction:column;gap:",";"],vt.YK.xsmall),EC=u.default.div.withConfig({displayName:"ParticipantCard__InputsRow",componentId:"jwtvl9-8"})(["display:flex;gap:",";> *{flex:1;min-width:0;}"],vt.YK.xsmall),yC=u.default.span.withConfig({displayName:"ParticipantCard__Label",componentId:"jwtvl9-9"})(["font-size:14px;font-weight:",";line-height:20px;color:",";"],vt.Wy.medium,vt.Ee.color.content.primary),bC=u.default.span.withConfig({displayName:"ParticipantCard__Description",componentId:"jwtvl9-10"})(["font-size:14px;line-height:20px;color:",";"],vt.Ee.color.content.secondary);var xC=n(77017);const wC=e=>{let t=e.isLoading,n=e.onCancel,l=e.onConfirm;return a.createElement(xC.$,{"data-external-id":"scenario-delete-confirmation",title:"Are you sure you want to delete this scenario?",confirm:"Delete scenario",isLoading:t,onCancel:n,onConfirm:l,useDangerButton:!0},a.createElement("div",{className:"flex flex-col gap-default rounded-default bg-background-secondary p-xl"},a.createElement(xt.v,{weight:"medium"},"What will change:"),a.createElement("ul",{className:"m-0 flex list-none flex-col gap-default p-0"},a.createElement("li",{className:"flex items-start gap-default"},a.createElement(sl.ZQ,{className:"mt-3xs inline-block shrink-0",name:"x-circle",size:22}),a.createElement(xt.v,null,"All events will be deleted")),a.createElement("li",{className:"flex items-start gap-default"},a.createElement(sl.ZQ,{className:"mt-3xs inline-block shrink-0",name:"x-circle",size:22}),a.createElement(xt.v,null,"All assumptions will be deleted")),a.createElement("li",{className:"flex items-start gap-default"},a.createElement(sl.ZQ,{className:"mt-3xs inline-block shrink-0",name:"x-circle",size:22}),a.createElement(xt.v,null,"Scenario will no longer appear in the list")))))},CC=["sidebar","id","year","focusAccountId"],AC=["sidebar","id","year","focusAccountId"],IC=e=>{const t=tp.A.parse(e),n=(t.sidebar,t.id,t.year,t.focusAccountId,(0,En.A)(t,CC)),a=tp.A.stringify(n);return a?"?".concat(a):""},kC=(e,t)=>{const n=Vx.getState().getSnapshotForScenario(e);if(!n)return t;const a=t.startsWith("?")?t.slice(1):t,l=tp.A.parse(a),r=(l.sidebar,l.id,l.year,l.focusAccountId,(0,En.A)(l,AC)),o=(0,U.A)((0,U.A)((0,U.A)((0,U.A)({},r),{},{sidebar:n.sidebar},void 0!==n.id?{id:n.id}:{}),void 0!==n.year?{year:n.year}:{}),void 0!==n.focusAccountId?{focusAccountId:n.focusAccountId}:{}),i=tp.A.stringify(o);return i?"?".concat(i):""},SC=(e,t)=>{var n;if(t)return $x((0,U.A)({scenarioId:e},t));const a=null!==(n=Vx.getState().getModeForScenario(e))&&void 0!==n?n:"plan";return $x({scenarioId:e,mode:a})},NC=(e,t)=>{const n=IC(window.location.search);return{pathname:SC(e,t),search:kC(e,n)}},TC=(e,t)=>{const n=new Set(e);return n.has(t)?n.delete(t):n.add(t),n},_C=()=>({accounts:{collapsedGroupIds:new Set,expandedAccountIds:new Set,expandedHiddenCategoryIds:new Set},cashFlow:{collapsedSectionIds:new Set,expandedIncomeEventIds:new Set,expandedExpenseRowKeys:new Set,expandedWithdrawalCategoryIds:new Set,expandedWithdrawalAccountIds:new Set,isIncomeExcludedExpanded:!1,isExpenseExcludedExpanded:!1},events:{expandedEventIds:new Set,isExcludedExpanded:!1}}),DC=_C(),RC={active:_C(),compare:null},MC=(e,t)=>{var n,a;if("none"===t.kind)return DC;const l=null!==(n=e[t.activeScenarioId])&&void 0!==n?n:RC;return"active"===t.kind?l.active:(null===(a=l.compare)||void 0===a?void 0:a.targetId)!==t.compareTargetId?DC:l.compare.expansion},LC=(e,t)=>{var n,a;const l=e.currentScope;if("none"===l.kind)return null;const r=l.activeScenarioId,o=null!==(n=e.byScenarioId[r])&&void 0!==n?n:RC;if("active"===l.kind)return{byScenarioId:(0,U.A)((0,U.A)({},e.byScenarioId),{},{[r]:(0,U.A)((0,U.A)({},o),{},{active:t(o.active)})})};const i=(null===(a=o.compare)||void 0===a?void 0:a.targetId)===l.compareTargetId?o.compare.expansion:DC;return{byScenarioId:(0,U.A)((0,U.A)({},e.byScenarioId),{},{[r]:(0,U.A)((0,U.A)({},o),{},{compare:{targetId:l.compareTargetId,expansion:t(i)}})})}},OC=e=>"compare"===e.kind?"compare:".concat(e.activeScenarioId,":").concat(e.compareTargetId):"active"===e.kind?"active:".concat(e.activeScenarioId):"none",PC=(0,mh.v)()((e=>({byScenarioId:{},currentScope:{kind:"none"},setCurrentScope:t=>e((e=>OC(e.currentScope)===OC(t)?e:{currentScope:t})),toggleCollapsedGroup:t=>e((e=>{const n=LC(e,(e=>(0,U.A)((0,U.A)({},e),{},{accounts:(0,U.A)((0,U.A)({},e.accounts),{},{collapsedGroupIds:TC(e.accounts.collapsedGroupIds,t)})})));return n?(0,U.A)((0,U.A)({},e),n):e})),toggleExpandedAccount:t=>e((e=>{const n=LC(e,(e=>(0,U.A)((0,U.A)({},e),{},{accounts:(0,U.A)((0,U.A)({},e.accounts),{},{expandedAccountIds:TC(e.accounts.expandedAccountIds,t)})})));return n?(0,U.A)((0,U.A)({},e),n):e})),toggleExpandedHiddenCategory:t=>e((e=>{const n=LC(e,(e=>(0,U.A)((0,U.A)({},e),{},{accounts:(0,U.A)((0,U.A)({},e.accounts),{},{expandedHiddenCategoryIds:TC(e.accounts.expandedHiddenCategoryIds,t)})})));return n?(0,U.A)((0,U.A)({},e),n):e})),toggleCollapsedCashFlowSection:t=>e((e=>{const n=LC(e,(e=>(0,U.A)((0,U.A)({},e),{},{cashFlow:(0,U.A)((0,U.A)({},e.cashFlow),{},{collapsedSectionIds:TC(e.cashFlow.collapsedSectionIds,t)})})));return n?(0,U.A)((0,U.A)({},e),n):e})),toggleExpandedIncomeEvent:t=>e((e=>{const n=LC(e,(e=>(0,U.A)((0,U.A)({},e),{},{cashFlow:(0,U.A)((0,U.A)({},e.cashFlow),{},{expandedIncomeEventIds:TC(e.cashFlow.expandedIncomeEventIds,t)})})));return n?(0,U.A)((0,U.A)({},e),n):e})),toggleExpandedExpenseRow:t=>e((e=>{const n=LC(e,(e=>(0,U.A)((0,U.A)({},e),{},{cashFlow:(0,U.A)((0,U.A)({},e.cashFlow),{},{expandedExpenseRowKeys:TC(e.cashFlow.expandedExpenseRowKeys,t)})})));return n?(0,U.A)((0,U.A)({},e),n):e})),toggleExpandedWithdrawalCategory:t=>e((e=>{const n=LC(e,(e=>(0,U.A)((0,U.A)({},e),{},{cashFlow:(0,U.A)((0,U.A)({},e.cashFlow),{},{expandedWithdrawalCategoryIds:TC(e.cashFlow.expandedWithdrawalCategoryIds,t)})})));return n?(0,U.A)((0,U.A)({},e),n):e})),toggleExpandedWithdrawalAccount:t=>e((e=>{const n=LC(e,(e=>(0,U.A)((0,U.A)({},e),{},{cashFlow:(0,U.A)((0,U.A)({},e.cashFlow),{},{expandedWithdrawalAccountIds:TC(e.cashFlow.expandedWithdrawalAccountIds,t)})})));return n?(0,U.A)((0,U.A)({},e),n):e})),toggleIncomeExcludedExpanded:()=>e((e=>{const t=LC(e,(e=>(0,U.A)((0,U.A)({},e),{},{cashFlow:(0,U.A)((0,U.A)({},e.cashFlow),{},{isIncomeExcludedExpanded:!e.cashFlow.isIncomeExcludedExpanded})})));return t?(0,U.A)((0,U.A)({},e),t):e})),toggleExpenseExcludedExpanded:()=>e((e=>{const t=LC(e,(e=>(0,U.A)((0,U.A)({},e),{},{cashFlow:(0,U.A)((0,U.A)({},e.cashFlow),{},{isExpenseExcludedExpanded:!e.cashFlow.isExpenseExcludedExpanded})})));return t?(0,U.A)((0,U.A)({},e),t):e})),toggleExpandedEvent:t=>e((e=>{const n=LC(e,(e=>(0,U.A)((0,U.A)({},e),{},{events:(0,U.A)((0,U.A)({},e.events),{},{expandedEventIds:TC(e.events.expandedEventIds,t)})})));return n?(0,U.A)((0,U.A)({},e),n):e})),toggleExcludedExpanded:()=>e((e=>{const t=LC(e,(e=>(0,U.A)((0,U.A)({},e),{},{events:(0,U.A)((0,U.A)({},e.events),{},{isExcludedExpanded:!e.events.isExcludedExpanded})})));return t?(0,U.A)((0,U.A)({},e),t):e})),reset:()=>e({byScenarioId:{},currentScope:{kind:"none"}})}
1))),BC=e=>{(0,a.useEffect)((()=>{PC.getState().setCurrentScope(e)}),[e])};var zC=n(68e3);const FC="__forecastWorkerError",GC=function(e,t){return(e=>{const t=new Set;let n=!1;const a=e=>{n||(n=!0,(0,Pi.jC)(new Error("Forecast worker: ".concat(e))),t.forEach((t=>t(e))))};return e.onerror=e=>a(e.message||"unknown load error"),e.addEventListener("message",(e=>{e.data&&"object"===typeof e.data&&FC in e.data&&a(String(e.data[FC]))})),{worker:e,onFailure:e=>{t.add(e)}}})((e=>{const t=["self.onerror = function (msg, src, line, col, err) {","  self.postMessage({ ".concat(FC,": String((err && err.stack) || msg) });"),"};","self.addEventListener('unhandledrejection', function (e) {","  self.postMessage({ ".concat(FC,": 'unhandledrejection: ' + String((e.reason && e.reason.stack) || e.reason) });"),"});","importScripts(".concat(JSON.stringify(e),");")].join("\n"),n=new Blob([t],{type:"text/javascript"}),a=URL.createObjectURL(n);return new Worker(a)})(e.toString()))},YC=3e4,UC=e=>{let t,n=performance.now(),a=!1;const l=()=>{a=!0,clearTimeout(t),t=void 0,"undefined"!==typeof document&&document.removeEventListener("visibilitychange",i)},r=()=>{a||(l(),e())},o=e=>{clearTimeout(t),t=setTimeout(r,e)},i=()=>
1{if(a||"visible"!==document.visibilityState)return;const e=performance.now()-n;e>=YC?r():o(YC-e)};return o(YC),"undefined"!==typeof document&&document.addEventListener("visibilitychange",i),{noteProgress:()=>{a||(n=performance.now(),o(YC))},stop:l}},VC=()=>(e=>{const t="number"===typeof e&&e>0?e:2;return Math.max(1,Math.min(4,t-1))})("undefined"===typeof navigator?void 0:navigator.hardwareConcurrency);class WC extends Error{constructor(e,t,n,a){super(t,a),this.kind=void 0,this.detail=void 0,this.name="ForecastRunError",this.kind=e,this.detail=n}}class jC extends Error{constructor(){super("Forecast pool terminated"),this.name="ForecastPoolTerminatedError"}}const HC=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:VC(),t=null;const a=new Set,l=e=>{const t=[...a];a.clear(),t.forEach((t=>t(e)))},r=()=>{var e;l(new jC),null===(e=t)||void 0===e||e.forEach((e=>{let t=e.worker;e.proxy[zC.A2](),t.terminate()})),t=null},o=()=>{try{return(()=>{const e=new GC(new URL(n.p+n.u(5292),n.b),{name:"forecast.worker"}),t=e.worker,a=e.onFailure;return{worker:t,proxy:(0,zC.LV)(t),onFailure:a}})()}catch(e){throw new WC("spawn-failed","Forecast worker could not be spawned",e instanceof Error?e.message:String(e),{cause:e})}};return{get size(){return e},runPaths:async(n,i,s)=>{if(!n.asOfDate)throw new Error("Forecast pool run requires input.asOfDate");const c=((e,t)=>{const n=[];if(e<=0||t<=0)return n;const a=Math.floor(e/t),l=e%t;let r=0;for(let o=0;o<t;o+=1){const e=a+(o<l?1:0);e>0&&(n.push({firstPathIndex:r,count:e}),r+=e)}return n})(i,e);if(0===c.length)return[];let d;(e=>{const t=[...e].sort(((e,t)=>e.firstPathIndex-t.firstPathIndex));t.forEach(((e,n)=>{const a=t[n-1];if(a&&e.firstPathIndex<a.firstPathIndex+a.count)throw new Error("Forecast pool path ranges overlap: [".concat(a.firstPathIndex,", ").concat(a.firstPathIndex+a.count,") and [").concat(e.firstPathIndex,", ").concat(e.firstPathIndex+e.count,")"))}))})(c);const u=new Promise(((e,t)=>{d=t})),m=UC((()=>d(new WC("stall","Forecast pool run stopped responding: no progress for ".concat(YC," ms"))))),p=c.map((()=>0)),g=()=>{var e;m.noteProgress(),null===(e=s.onProgress)||void 0===e||e.call(s,p.reduce(((e,t)=>e+t),0),i)};try{g();const e=(e=>{for(t||(t=[]);t.length<e;){const e=o();e.onFailure((e=>{l(new WC("worker-died","Forecast worker failed",e)),r()})),t.push(e)}return t})(c.length),i=((e,t,n)=>{const a=t.map(((t,a)=>{const l=e[a].worker,r=e=>{const t=(e=>{if("object"!==typeof e||null===e||!("forecastBatchProgress"in e))return null;const t=e.forecastBatchProgress;return"number"===typeof t?t:null})(e.data);null!==t&&n(a,t)};return l.addEventListener("message",r),{worker:l,listener:r}}));return()=>{a.forEach((e=>{let t=e.worker,n=e.listener;return t.removeEventListener("message",n)}))}})(e,c,((e,t)=>{p[e]=t,g()})),d=Promise.all(c.map(((t,a)=>e[a].proxy.runBatch(n,t,s.runSeed).then((e=>(p[a]=t.count,g(),e))))));let m;const h=new Promise(((e,t)=>{m=t}));a.add(m);try{return(await Promise.race([d,h,u])).flatMap((e=>e.summaries))}finally{i(),a.delete(m)}}catch(h){throw r(),h instanceof Error?h:new Error(String(h))}finally{m.stop()}},terminate:r}};let KC=null;const qC=()=>{var e;null===(e=KC)||void 0===e||e.terminate(),KC=null},$C=2147483647,ZC=()=>Math.floor(2147483648*Math.random()),JC=(0,mh.v)((e=>({useFixedSeed:!1,fixedSeed:null,setUseFixedSeed:t=>e({useFixedSeed:t}),setFixedSeed:t=>e({fixedSeed:t})}))),XC=e=>{let t=e.useFixedSeed,n=e.fixedSeed;return t&&null!==n?n:null},QC=()=>{var e;return null!==(e=XC(JC.getState()))&&void 0!==e?e:ZC()},eA=e=>{var t,n;const a=Ih({settings:e.settings,accounts:e.accounts,events:null!==(t=e.events)&&void 0!==t?t:[],customWithdrawalOrderIds:e.customWithdrawalOrderIds,uncategorizedSavingsSettings:e.uncategorizedSavingsSettings});return{input:{settings:a.settings,accounts:a.accounts,events:a.events,customWithdrawalOrderIds:null!==(n=a.customWithdrawalOrderIds)&&void 0!==n?n:[],uncategorizedSavingsSettings:a.uncategorizedSavingsSettings,asOfDate:new Date,retirementYears:(r=a.settings.participants,o=a.events,r.flatMap((e=>{if(e.hiddenFromForecast)return[];const t=rE(e,o);return t?[{participantId:e.userId,year:t.startYear}]:[]}))),options:{householdUserIds:e.householdUserIds},monteCarlo:{inflationVolatility:e.monteCarloSettings.inflationVolatility}},paths:(l=e.monteCarloSettings.numPaths,Number.isFinite(l)?Math.min(Math.max(Math.floor(l),sp),5e3):sp),startYear:e.settings.startYear,runSeed:QC()};var l,r,o},tA=new Set(["name","metadata","color","foregroundColor","icon","isNew","linkedGrowthRate","linkedInterestRate","linkedPlannedPayment","linkedMinimumPayment","asOfDate","runSeed"]),nA=e=>JSON.stringify(e,((e,t)=>
1{if(!tA.has(e))return"householdUserIds"===e&&Array.isArray(t)?[...t].sort():t})),aA=(0,mh.v)((e=>({successFloor:0,setSuccessFloor:t=>e({successFloor:t})})));let lA=null,rA=0;const oA=e=>Date.now()-e,iA=e=>{var t,n,a;return Vf({scenario_id:e.scenarioId,outcome:"cancelled",num_paths:e.paths,completed_paths:null!==(t=null===(n=of.getState().byScenarioId[e.scenarioId])||void 0===n||null===(a=n.progress)||void 0===a?void 0:a.completed)&&void 0!==t?t:0,duration_ms:oA(e.startedAt),chart_mode:e.chartMode})},sA=async(e,t)=>{const n=e.scenarioId,a=(KC||(KC=HC()),KC);let l=0;try{var r,o;const i=await a.runPaths(e.input,e.paths,{runSeed:e.runSeed,onProgress:(e,a)=>{var r;l=e,(null===(r=lA)||void 0===r?void 0:r.id)===t&&of.getState().setRunProgress(n,{completed:e,total:a})}});if((null===(r=lA)||void 0===r?void 0:r.id)!==t)return;const s=lA,c=s.startedAt,d=s.paths,u=s.chartMode;lA=null;const m=(e=>{let t=e.summaries,n=e.startYear,a=e.runSeed,l=e.asOfDate,r=e.signature,o=void 0===r?"":r;return{unadjustedBands:vf(t,n),todaysDollarsBands:ff(t,n),summaries:t,runSeed:a,asOfDate:l,signature:o}})({summaries:i,startYear:e.startYear,runSeed:e.runSeed,asOfDate:e.input.asOfDate,signature:e.signature});of.getState().setResultForScenario(n,m,null!==(o=wE.getState().scenarioExternalId)&&void 0!==o?o:null),Vf({scenario_id:n,outcome:"completed",num_paths:d,completed_paths:i.length,duration_ms:oA(c),success_rate:Lf(i,{successFloor:aA.getState().successFloor,isTodaysDollars:"todaysDollars"===wE.getState().dollarMode}),chart_mode:u})}catch(m){var i,c,d,u;if((null===(i=lA)||void 0===i?void 0:i.id)!==t)return;const r=lA,o=r.startedAt,p=r.paths,g=r.chartMode,h=of.getState();if((e=>e instanceof jC)(m))return iA(lA),lA=null,void h.cancelRun(n);const v=(e=>e instanceof WC?{kind:e.kind,detail:e.detail}:{kind:"unknown"})(m),f=null!==(c=null===(d=h.byScenarioId[n])||void 0===d||null===(u=d.progress)||void 0===u?void 0:u.completed)&&void 0!==c?c:0;Vf((0,U.A)({scenario_id:n,outcome:"failed",num_paths:p,completed_paths:f,duration_ms:oA(o),chart_mode:g},"unknown"===v.kind?{}:{failure_kind:v.kind})),lA=null,s.Cp(m,{level:"error",tags:{monteCarloRunFailure:v.kind},extra:{paths:e.paths,poolSize:a.size,completedPaths:l,detail:v.detail}}),h.failRun(n)}},cA=()=>{var e;const t=wE.getState(),n=t.scenarioExternalId;if(!n)return;const a=eA(t),l=(0,U.A)((0,U.A)({},a),{},{scenarioId:n,signature:nA(a)}),r=of.getState();lA&&(iA(lA),r.cancelRun(lA.scenarioId),qC()),rA+=1;const o=null===(e=r.byScenarioId[l.scenarioId])||void 0===e?void 0:e.result;let i="plan_edited";void 0===o?i="first_run":o.signature===l.signature&&(i="same_plan"),lA={id:rA,scenarioId:l.scenarioId,startedAt:Date.now(),paths:a.paths,chartMode:t.monteCarloSettings.showFan?"range":"paths"},r.startRun(l.scenarioId),(e=>{let t=e.num_paths,n=(0,En.A)(e,Pf);(0,Ge.u4)(Ye.yq.MonteCarloRunStarted,(0,U.A)((0,U.A)({},n),{},{num_paths:Uf(t)}))})({scenario_id:l.scenarioId,num_paths:a.paths,rerun_kind:i,chart_mode:lA.chartMode}),sA(l,rA)},dA=e=>{var t;if((null===(t=lA)||void 0===t?void 0:t.scenarioId)!==e)return;const n=lA,a=of.getState();iA(n),lA=null,a.cancelRun(e),qC()};(0,sE.zB)((()=>{lA=null,qC(),of.getState().reset()}));const uA=e=>{dA(e),of.getState().clearResultForScenario(e),Vx.getState().clearMemoryForScenario(e),(e=>{PC.setState((t=>{if(!(e in t.byScenarioId))return t;const n=t.byScenarioId;return n[e],{byScenarioId:(0,En.A)(n,[e].map(nf.A))}}))})(e),(e=>{Lx.setState((t=>{if(!(e in t.viewModeByScenarioId))return t;const n=t.viewModeByScenarioId;return n[e],{viewModeByScenarioId:(0,En.A)(n,[e].map(nf.A))}}))})(e)},mA=()=>{const e=(0,i.n)(Dv.HB,{refetchQueries:[Dv.EX],awaitRefetchQueries:!0}),t=(0,o.A)(e,2),n=t[0],r=t[1],s=(0,l.Zp)(),c=(0,l.g)().scenarioId,d=void 0===c?"":c,u=wE((e=>e.scenarioExternalId)),m=YE(),p=UE(),g=(0,a.useCallback)((async e=>{const t=e.scenarioExternalId,a=e.deletedScenarioOrder,l=e.scenarioCountBeforeDelete,r=e.onSuccess,o=e.silent,i=void 0!==o&&o,c=e.skipNavigation,g=void 0!==c&&c,h=e=>{i||m(e)},v=e=>(h({kind:"deleteScenario",phase:"error",title:"Could not delete scenario",description:e}),{success:!1,error:e});if(l<=1)return v("You must keep at least one scenario.");try{var f;h({kind:"deleteScenario",phase:"loading",title:"Deleting scenario\u2026"});const e=(await n({variables:{input:{scenarioExternalId:t}}})).data,l=null===e||void 0===e?void 0:e.deleteForecastScenario,o=null===l||void 0===l||null===(f=l.errors)||void 0===f?void 0:f.message;if(o)return v(o);if(null===l||void 0===l||!l.deleted)return v("Scenario was not deleted.");uA(t),(e=>{let t=e.scenario_id,n=e.source;(0,Ge.u4)(Ye.yq.ScenarioDeleted,{scenario_id:t,source:n})})({scenario_id:t,source:i?"cancel_new_scenario":"menu_delete"});let c=null;if(t===(d||u||"")){var E;c=((e,t)=>{var n,a;const l=[...e].sort(((e,t)=>e.order-t.order)),r=l.filter((e=>e.order<t));return r.length>0?r[r.length-1].externalId:null!==(n=null===(a=l[0])||void 0===a?void 0:a.externalId)&&void 0!==n?n:null})(null!==(E=l.scenarios)&&void 0!==E?E:[],a),g||s((e=>e?NC(e):{pathname:I.su,search:IC(window.location.search)})(c))}return null===r||void 0===r||r(),h({kind:"deleteScenario",phase:"success",title:"Scenario deleted"}),{success:!0,nextScenarioId:c}}catch(y){return v(y instanceof Error?y.message:"Delete failed")}finally{const e=wE.getState().forecastOperation;"deleteScenario"===(null===e||void 0===e?void 0:e.kind)&&"loading"===e.phase&&(i||p())}}),[n,s,d,u,m,p]);return(0,U.A)({deleteScenario:g},r)},pA=()=>{const e=(0,i.n)(Dv.jr,{refetchQueries:[Dv.EX],awaitRefetchQueries:!0}),t=(0,o.A)(e,2),n=t[0],r=t[1],s=(0,l.Zp)(),c=YE(),d=UE(),u=VE(),m=(0,a.useCallback)((async e=>{c({kind:"duplicateScenario",phase:"loading",title:"Duplicating scenario\u2026"});const t=e=>(c({kind:"duplicateScenario",phase:"error",title:"Could not duplicate scenario",description:"Please try again."}),{success:!1,error:e});try{var a,l;
1const r=(await n({variables:{input:{sourceScenarioExternalId:e}}})).data,o=null===r||void 0===r?void 0:r.duplicateForecastScenario,i=null===o||void 0===o||null===(a=o.errors)||void 0===a?void 0:a.message;if(i)return t(i);const d=null===o||void 0===o||null===(l=o.scenario)||void 0===l?void 0:l.externalId;return d?(c({kind:"duplicateScenario",phase:"success",title:"Scenario duplicated"}),u(),s(NC(d)),Gf({scenarioId:d,source:"duplicate"}),{success:!0,newScenarioId:d}):t("Unexpected empty response")}catch(r){return t(r instanceof Error?r.message:"Duplicate failed")}finally{const e=wE.getState().forecastOperation;"duplicateScenario"===(null===e||void 0===e?void 0:e.kind)&&"loading"===e.phase&&d()}}),[n,s,c,d,u]);return(0,U.A)({duplicate:m},r)},gA=e=>{let t=e.scenarioId,n=e.surface,r=e.isActive,i=void 0!==r&&r,s=e.onAfterNavigate,c=e.onCompare;const d=(0,l.Zp)(),u=FE(),m=VE(),p=wE((e=>e.scenarioExternalId)),g=GE("duplicateScenario","loading"),h=Qx(),v=h.scenarios,f=h.isLoading,E=pA().duplicate,y=mA(),b=y.deleteScenario,x=y.loading,w=(0,Pd.h)(),C=(0,o.A)(w,2),A=C[0],I=C[1],k=I.open,S=I.close,N=!x&&!f&&v.length>1,T="scenarioList"===n,_=T||"pillContextMenu"===n,D=t===p,R=(0,a.useCallback)((()=>{t&&(_&&!D?(m(),d(NC(t))):u.open(),null===s||void 0===s||s())}),[t,_,D,m,d,u,s]),M=(0,a.useCallback)((()=>{t&&E(t).then((e=>{e.success&&(null===s||void 0===s||s())}))}),[t,E,s]),L=(0,a.useCallback)((()=>{const e=v.find((e=>e.id===t));e&&b({scenarioExternalId:t,deletedScenarioOrder:e.order,scenarioCountBeforeDelete:v.length,onSuccess:()=>{S(),T&&i&&(null===s||void 0===s||s())}})}),[t,v,b,S,T,i,s]);return{entries:(0,a.useMemo)((()=>{const e=[];return"assumptionsHeader"!==n&&(e.push({label:"Edit name and icon",onClick:R}),c&&e.push({label:"Compare",onClick:c})),e.push({label:"Duplicate",disabled:g,onClick:M},{label:"Delete scenario",variant:"destructive",disabled:!N,onClick:()=>k()}),e}),[n,R,c,M,g,N,k]),deleteModal:a.createElement(A,null,a.createElement(wC,{isLoading:x,onCancel:S,onConfirm:L}))}};var hA=n(86551);const vA=e=>{let t=e.scenarioId,n=e.variant,l=void 0===n?"cardHeader":n,r=e.size,o=void 0===r?"sm":r,i=e.isActive,s=void 0!==i&&i,c=e.onAfterNavigate,d=e.onCompare;const u=gA({scenarioId:t,surface:l,isActive:s,onAfterNavigate:c,onCompare:d}),m=u.entries,p=u.deleteModal,g=a.createElement(Yi.S,{size:o,variant:"assumptionsHeader"===l?"outline":void 0,"aria-label":"Scenario actions",className:"shrink-0"},a.createElement(fe.V_g,null));return a.createElement(a.Fragment,null,a.createElement(hA.u,{trigger:g,items:m,align:"start",side:"bottom"}),p)};var fA=n(93474),EA=n(76788);const yA=e=>{let t=e.icon,n=e.color,l=e.availableColors,o=e.availableIcons,i=e.onColorChange,s=e.onIconChange,c=e.swatchBgClassMap,d=e.pickerGlyphColor,u=e.ariaNoun,m=e.close;const p=(0,a.useMemo)((()=>{const e=new Set(o);return t&&!e.has(t)?[t,...o]:[...o]}),[o,t]),g=(0,r.YW)({hasColor:!!i,hasIcon:!!s}).with({hasColor:!0,hasIcon:!0},(()=>({popoverAriaLabel:"".concat((0,EA.ZH)(u)," color and icon")}))).with({hasColor:!0,hasIcon:!1},(()=>({popoverAriaLabel:"Icon color"}))).otherwise((()=>({popoverAriaLabel:"".concat((0,EA.ZH)(u)," icon")}))).popoverAriaLabel,h=i&&l.map((e=>a.createElement("button",{key:e,type:"button",role:"radio","aria-label":"".concat(e," icon color"),"aria-checked":e===n,"data-event-color-swatch":e,className:(0,q.cn)("\n            mx-auto size-6 cursor-pointer rounded-round border-0 p-0\n            aria-checked:ring-2 aria-checked:ring-input-focus-border aria-checked:ring-offset-1\n          ",c[e],"\n            focus-visible:outline-2 focus-visible:outline-offset-2\n            focus-visible:outline-input-focus-border\n          "),onClick:()=>{i(e)}}))),v=(0,r.YW)({hasSwatches:Boolean(h),hasIcons:!!s}).with({hasSwatches:!0,hasIcons:!0},(()=>a.createElement("div",{role:"radiogroup","aria-label":"Icon color",className:"grid grid-cols-6 gap-xs"},h))).with({hasSwatches:!0,hasIcons:!1},(()=>h)).otherwise((()=>null));return a.createElement(Qi.j7,{"data-external-id":"appearance-popover-content",role:s?"dialog":"radiogroup","aria-label":g,className:(0,q.cn)(s?"flex w-72 max-w-full min-w-0 flex-col gap-default overflow-x-hidden p-default":"inline-grid w-54 grid-cols-6 grid-rows-2 gap-xs p-default")},v,i&&s?a.createElement("div",{className:"w-full shrink-0 border-t border-divider-primary",role:"presentation"}):null,s?a.createElement("div",{className:(0,q.cn)("\n              max-h-52 min-h-0 w-full min-w-0 overflow-x-hidden overflow-y-auto\n              [scrollbar-color:var(--border-primary)_transparent] [scrollbar-width:thin]\n              [&::-webkit-scrollbar]:size-1\n              [&::-webkit-scrollbar-thumb]:rounded-full\n              [&::-webkit-scrollbar-thumb]:bg-border-primary\n            ")},a.createElement("div",{role:"radiogroup","aria-label":"".concat((0,EA.ZH)(u)," icon"),className:"grid w-full min-w-0 grid-cols-6 gap-x-xs gap-y-sm"},p.map((e=>{const n=e===t;return a.createElement("button",{key:e,type:"button",role:"radio","aria-label":"".concat(e," ").concat(u," icon"),"aria-checked":n,className:(0,q.cn)("\n                      mx-auto flex size-9 cursor-pointer items-center justify-center rounded-full\n                      border-0 bg-transparent p-0\n                      focus-visible:outline-2 focus-visible:outline-offset-2\n                      focus-visible:outline-input-focus-border\n                    "),onClick:()=>{s(e),m()}},a.createElement("span",{className:(0,q.cn)("\n                        flex size-8 items-center justify-center rounded-full bg-transparent\n                        transition-colors\n                      ",!n&&"hover:bg-background-secondary")},a.createElement(sl.ZQ,{name:e,size:20,style:{color:d}})))})))):null)},bA=e=>{let t=e.icon,n=e.color,l=e.onColorChange,r=e.onIconChange,o=e.overlayPortalContainer;const i="var(--scenario-icon-".concat(n,")");return a.createElement(fA.A,{"data-external-id":"scenario-appearance-picker",placement:"bottom",offsetDistance:8,portalContainer:null!==o&&void 0!==o?o:void 0,overlay:e=>{let o=e.close;return a.createElement(yA,{icon:t,color:n,availableColors:Jg,availableIcons:Xg,onColorChange:l,onIconChange:r,swatchBgClassMap:Kg,pickerGlyphColor:i,ariaNoun:"scenario",close:o})}},(e=>{let l=e.toggleOpen,r=e.isOpen;return a.createElement("button",{type:"button",onClick:l,"aria-label":"Select scenario color and icon","aria-haspopup":"dialog","aria-expanded":r,className:(0,q.cn)("\n              flex size-9 shrink-0 cursor-pointer items-center justify-center rounded-default\n              border-0 bg-transparent p-0 leading-none transition-colors\n              hover:bg-background-secondary\n              focus-visible:bg-background-secondary focus-visible:outline-2\n              focus-visible:outline-offset-2 focus-visible:outline-input-focus-border\n            ",r&&"bg-background-secondary",jg[n])},a.createElement(sl.ZQ,{name:t,size:20}))}))};var xA=n(17585);const wA=e=>{let t=e.autoFocus,n=e.overlayPortalContainer,l=e.onNameSaved;const r=BE(),s=(()=>{const e=(0,V.m)(),t=(0,i.n)(Dv.VR),n=(0,o.A)(t,2),l=n[0],r=n[1],s=(0,a.useCallback)((async t=>{var n;
1const a=wE.getState(),r=a.scenarioExternalId;if(!r)return{success:!1,error:"No active scenario"};const o=null!==(n=a.scenarioMetadata)&&void 0!==n?n:Qg,i=(0,U.A)((0,U.A)({},o),t);a.setScenarioMetadata(i);const s=()=>{const e=wE.getState().scenarioMetadata;if(!e)return;const n={};for(const a of Object.keys(t))e[a]===i[a]&&(n[a]=o[a]);Object.keys(n).length>0&&wE.getState().setScenarioMetadata(n)};try{var c,d;const t=null!==(c=null===(d=a.categoryVersions)||void 0===d?void 0:d.settings)&&void 0!==c?c:0,n=(await l({variables:{input:(0,U.A)({scenarioExternalId:r,expectedVersion:t},i)}})).data,o=null!==n&&void 0!==n?n:void 0,m=Kv(o,"scenario");if(m)return s(),{success:!1,error:m};if(Hv(o,"scenario"))return s(),wE.setState((e=>{e.isConflicted=!0})),{success:!1,error:"VERSION_CONFLICT"};const p=jv(o,"scenario");if(null===p||void 0===p)return s(),{success:!1,error:"Unexpected empty response"};wE.setState((e=>{e.categoryVersions&&(e.categoryVersions.settings=p),e.lastSavedAt=new Date}));try{await e.refetchQueries({include:["Web_ForecastScenario","Web_ForecastScenarios"]})}catch(u){}return{success:!0}}catch(m){return s(),{success:!1,error:m instanceof Error?m.message:"Save failed"}}}),[e,l]);return(0,U.A)({update:s},r)})(),c=s.update,d=(0,a.useCallback)((async(e,t)=>{(await c({name:e})).success&&(null===l||void 0===l||l(t))}),[c,l]),u=(0,a.useCallback)((e=>{c({color:e})}),[c]),m=(0,a.useCallback)((e=>{c({icon:e})}),[c]),p=pb({canonicalValue:r.name,onCommit:d}).inputProps;return a.createElement("div",{"data-external-id":"scenario-name-and-icon-fields",className:"flex min-w-0 items-center gap-xs"},a.createElement(bA,{icon:r.icon,color:r.color,onColorChange:u,onIconChange:m,overlayPortalContainer:n}),a.createElement(xA.D,Object.assign({"aria-label":"Scenario name",placeholder:"Scenario name",autoFocus:t,className:"min-w-0 flex-1"},p)))};var CA,AA,IA;const kA=[{value:"todaysDollars",label:_t.Et.ASSUMPTIONS.DOLLAR_MODE_OPTION_TODAYS},{value:"futureDollars",label:_t.Et.ASSUMPTIONS.DOLLAR_MODE_OPTION_FUTURE}],SA=()=>{var e,t,n,r,o;const i=vy(),s=i.closeSidebar,c=i.openEvent,d=(0,l.g)().scenarioId,u=py().isEnabled,m=QE(),p=wE((e=>e.updateSettings)),g=wE((e=>e.updateEvent)),h=wE((e=>e.setUseActualsAsBaseline)),v=wE((e=>e.createEventOfType)),f=wE((e=>{var t;return null!==(t=e.dollarMode)&&void 0!==t?t:"futureDollars"})),E=wE((e=>e.setDollarMode)),y=ay(),b=iy(),x=$E(),w=ZE(),C=(0,De.Eb)(w.map((e=>e.amount))),A=e=>{var t,n;e!==f&&(E(e),t=f,n=e,(0,Ge.u4)(Ye.yq.DollarModeChanged,(0,U.A)({from:t,to:n},zf())))},I=w.length>0,k=NA();return a.createElement(Sb,{"data-external-id":"assumptions-sidebar"},a.createElement(TA,null,a.createElement(Rb,null,"Edit assumptions"),a.createElement("div",{className:"flex items-center gap-xs"},u&&d&&a.createElement(vA,{scenarioId:d,variant:"assumptionsHeader"}),a.createElement(Yi.S,{variant:"outline",onClick:s,"aria-label":"Close"},a.createElement(yb.MdsXIcon,null)))),a.createElement(_b,null,u&&a.createElement("div",{className:"flex flex-col gap-xs"},a.createElement(Lb,null,"Scenario name and icon"),a.createElement(wA,null)),a.createElement("div",{className:"flex flex-col gap-xs"},u&&a.createElement(Lb,null,"Participants"),a.createElement("div",{className:"flex flex-col gap-lg"},m.participants.map((e=>a.createElement(sC,{key:e.userId,participant:e}))))),w.length>0&&a.createElement("div",{className:"flex flex-col gap-xs"},a.createElement(Lb,null,"Current income sources"),w.map((e=>a.createElement(lx,{key:e.id,icon:e.icon,color:e.color,foregroundColor:e.foregroundColor,name:e.name,renderIcon:a.createElement(Wl._,{url:null,size:24}),onClick:()=>c(e.id)}))),a.createElement(wt.Xb,{className:"self-start",size:"xsmall",onClick:()=>{const e=v("income",{startYear:null,isHidden:!0,frequency:"yearly"});c(e)}},a.createElement(Yo.r,{name:"plus-circle"}),a.createElement("span",null,"Add new"))),a.createElement(Pb,{label:I?"Use actual expenses as baseline":"Use actuals as baseline",subtext:I?a.createElement(a.Fragment,null,"Monarch will use the last 12 months of expenses to determine your starting cash flow."," ",a.createElement(Bb,{href:eh},"Learn more")):a.createElement(a.Fragment,null,"Monarch will use the last 12 months of income and expenses to determine your starting cash flow."," ",a.createElement(Bb,{href:eh},"Learn more")),checked:y,onChange:()=>h(!y)},y?a.createElement("div",{className:"-mx-default -mb-default flex flex-col gap-default p-default"},!I&&a.createElement("div",{className:"flex flex-col gap-xs"},a.createElement(Lb,null,_t.Et.ASSUMPTIONS.YEARLY_TAKE_HOME_INCOME_LABEL),a.createElement(xt.v,{color:"content.secondary"},"~",(0,rl._L)(null!==(e=null===b||void 0===b?void 0:b.annualIncome)&&void 0!==e?e:0)," ",k),a.createElement(xt.v,{size:"small",color:"content.secondary"},_t.Et.ASSUMPTIONS.YEARLY_TAKE_HOME_INCOME_HELPER_TEXT)),a.createElement("div",{className:"flex flex-col gap-xs"},a.createElement(Lb,null,"Yearly living expenses"),a.createElement(Ry.X,{className:"w-full",disabled:!0,name:"annualExpenses",value:"".concat((0,rl._L)(Math.abs(null!==(t=null===b||void 0===b?void 0:b.annualExpenses)&&void 0!==t?t:0))," ").concat(k)})),x&&a.createElement(Jw,{growthType:x.growthType,growthRate:null!==(n=x.growthRate)&&void 0!==n?n:void 0,inflationRate:m.inflationRate,onGrowthTypeChange:e=>g(x.id,{growthType:e}),onGrowthRateChange:e=>g(x.id,{growthRate:e})})):a.createElement("div",{className:"-mx-default -mb-default flex flex-col gap-default p-default"},!I&&a.createElement("div",{className:"flex flex-col gap-xs"},a.createElement(Lb,null,_t.Et.ASSUMPTIONS.YEARLY_TAKE_HOME_INCOME_LABEL),a.createElement(fe.K$5,{name:"annualIncome",value:C,disabled:!0,precision:0,onFocus:(0,ix.s)(C)}),a.createElement(xt.v,{size:"small",color:"content.secondary"},_t.Et.ASSUMPTIONS.YEARLY_TAKE_HOME_INCOME_HELPER_TEXT)),a.createElement("div",{className:"flex flex-col gap-xs"},a.createElement(Lb,null,"Yearly living expenses"),a.createElement(fe.K$5,{name:"annualExpenses",value:null!==(r=null===x||void 0===x?void 0:x.amount)&&void 0!==r?r:0,onValueChange:e=>x&&g(x.id,{amount:null!==e&&void 0!==e?e:0}),precision:0,onFocus:(0,ix.s)(null===x||void 0===x?void 0:x.amount)})),x&&a.createElement(Jw,{growthType:x.growthType,growthRate:null!==(o=x.growthRate)&&void 0!==o?o:void 0,inflationRate:m.inflationRate,onGrowthTypeChange:e=>g(x.id,{growthType:e}),onGrowthRateChange:e=>g(x.id,{growthRate:e})}))),a.createElement(_A,null,a.createElement("div",{className:"flex flex-col gap-xs"},a.createElement(Lb,null,"Yearly inflation rate"),a.createElement(xt.v,{size:"small",color:"content.secondary"},"Most financial plans use 2\u20133%. The long-term U.S. average is around 3%."," ",a.createElement(Bb,{href:"https://www.monarch.c
1om/blog/forecasting#yearly-inflation-and-investment-growth-rates-351ae5fbd512"},"Learn more")),a.createElement(wy,{value:m.inflationRate,onChange:e=>{p({inflationRate:e})},min:0,max:5,step:.2,debounceMs:150},a.createElement(Cy,{$rightColumnWidth:My},a.createElement(Iy,null),a.createElement(Ly,{name:"inflationRate",formatValue:nb,parseValue:ab,min:-5,max:20,step:.001,textAlign:"right"}),a.createElement(Py,{value:3})))),a.createElement("div",{className:"flex flex-col gap-xs"},a.createElement(Lb,{htmlFor:"dollarMode"},_t.Et.ASSUMPTIONS.DOLLAR_MODE_LABEL),a.createElement(fe.hGA.Root,{items:kA,value:f,onValueChange:e=>{A(e)}},a.createElement(fe.hGA.Trigger,{id:"dollarMode"},a.createElement(fe.hGA.Value,null,(e=>"todaysDollars"===e?a.createElement("span",null,_t.Et.ASSUMPTIONS.DOLLAR_MODE_OPTION_TODAYS," ",a.createElement("span",{className:"text-content-secondary"},_t.Et.ASSUMPTIONS.DOLLAR_MODE_OPTION_TODAYS_RECOMMENDED_SUFFIX)):_t.Et.ASSUMPTIONS.DOLLAR_MODE_OPTION_FUTURE))),a.createElement(fe.hGA.Content,null,kA.map((e=>a.createElement(fe.hGA.Option,{key:e.value,value:e.value,label:e.label},a.createElement("span",null,e.label,"todaysDollars"===e.value&&a.createElement("span",{className:"text-content-secondary"}," ",_t.Et.ASSUMPTIONS.DOLLAR_MODE_OPTION_TODAYS_RECOMMENDED_SUFFIX))))))),a.createElement(Ob,null,_t.Et.ASSUMPTIONS.DOLLAR_MODE_HELPER_LEAD," ",a.createElement(Bb,{href:th},"Learn more")),a.createElement(DA,null,a.createElement("li",null,a.createElement("strong",null,_t.Et.ASSUMPTIONS.DOLLAR_MODE_OPTION_TODAYS)," ",_t.Et.ASSUMPTIONS.DOLLAR_MODE_BULLET_TODAYS),a.createElement("li",null,a.createElement("strong",null,_t.Et.ASSUMPTIONS.DOLLAR_MODE_OPTION_FUTURE)," ",_t.Et.ASSUMPTIONS.DOLLAR_MODE_BULLET_FUTURE)))),a.createElement(gx,null),a.createElement(px,null)))},NA=()=>{const e=N.c9.now().minus({months:1}).endOf("month"),t=(0,Ba.AO)(e.toISODate());return"in ".concat(e.year,", as of ").concat(t)},TA=(0,$d.s)(Tb)(CA||(CA=(0,wc.A)(["border-b border-divider-primary"]))),_A=$d.s.div(AA||(AA=(0,wc.A)(["flex flex-col gap-default rounded-sm border border-divider-secondary p-default"]))),DA=$d.s.ul(IA||(IA=(0,wc.A)(["\n  m-0 flex list-disc flex-col gap-xs pl-md text-sm/5 text-content-secondary\n  marker:text-content-secondary\n"])));var RA=n(36825),MA=n(59109);const LA=e=>{let t=e.icon,n=e.color,l=e.foregroundColor,o=e.renderIcon,i=e.onColorChange,s=e.onIconChange,c=e.availableColors,d=e.availableIcons;const u=null!==l&&void 0!==l?l:n,m="var(--chart-event-foreground-".concat(n,")"),p=!o&&(!!i||!!s),g=(0,r.YW)({hasColor:!!i,hasIcon:!!s}).with({hasColor:!0,hasIcon:!0},(()=>"Select event color and icon")).with({hasColor:!0,hasIcon:!1},(()=>"Select icon color")).otherwise((()=>"Select event icon"));return(0,r.YW)({renderIcon:o,canPickAppearance:p}).with({renderIcon:r.P.nonNullable},(e=>{let t=e.renderIcon;return a.createElement(a.Fragment,null,t)})).with({canPickAppearance:!0},(()=>a.createElement(fA.A,{placement:"bottom",offsetDistance:8,overlay:e=>{let l=e.close;return a.createElement(yA,{icon:t,color:n,availableColors:c,availableIcons:d,onColorChange:i,onIconChange:s,swatchBgClassMap:Kg,pickerGlyphColor:m,ariaNoun:"event",close:l})}},(e=>{let l=e.toggleOpen,r=e.isOpen;return a.createElement("button",{type:"button",onClick:l,"aria-label":g,"aria-haspopup":"dialog","aria-expanded":r,className:(0,q.cn)("\n                group cursor-pointer rounded-default border-0 bg-transparent p-0 leading-none\n                focus-visible:outline-none\n              ")},a.createElement(OA,{color:n,foregroundColor:u,className:(0,q.cn)("ring-inset group-hover:ring-2 group-focus-visible:ring-2",qg[n],r&&"ring-2")},a.createElement(sl.ZQ,{name:t,size:24})))})))).otherwise((()=>a.createElement(OA,{color:n,foregroundColor:u},a.createElement(sl.ZQ,{name:t,size:24}))))},OA=e=>{let t=e.color,n=e.foregroundColor,l=e.className,r=e.children;return a.createElement("div",{"data-external-id":"icon-circle",className:(0,q.cn)("flex size-9 shrink-0 items-center justify-center rounded-default",Vg[t],Wg[n],l)},r)};var PA,BA;const zA=e=>{let t=e.icon,n=e.color,l=e.foregroundColor,r=e.name,o=e.onNameChange,i=e.renderIcon,s=e.onColorChange,c=e.onIconChange,d=e.availableColors,u=void 0===d?$g:d,m=e.availableIcons,p=void 0===m?Zg:m;
1const g=(0,a.useId)(),h=pb({canonicalValue:r,onCommit:e=>o(e)}).inputProps;return a.createElement(FA,{"data-external-id":"event-name-and-appearance"},a.createElement(Lb,{htmlFor:g},"Name and icon"),a.createElement(GA,null,a.createElement(LA,{icon:t,color:n,foregroundColor:l,renderIcon:i,onColorChange:s,onIconChange:c,availableColors:u,availableIcons:p}),a.createElement(zb,Object.assign({id:g,placeholder:"Event name"},h))))},FA=$d.s.div(PA||(PA=(0,wc.A)(["flex flex-col gap-xs"]))),GA=$d.s.div(BA||(BA=(0,wc.A)(["flex items-center gap-xs"]))),YA=e=>{let t=e.isIncluded,n=e.isRequired,l=e.onIsIncludedChange,r=e.onDelete;const o=vy().closeSidebar,i=(0,a.useCallback)((()=>{l(!t)}),[t,l]),s=t?"Exclude from forecast":"Include in forecast",c=(0,a.useCallback)((()=>a.createElement(Ji.SP,null,a.createElement(HA,{icon:"trash",onClick:r},"Delete event"))),[r]);return a.createElement(UA,{"data-external-id":"event-sidebar-header"},a.createElement(VA,null,!n&&a.createElement(P.D_,{content:s},a.createElement(fe.SO$,{variant:"overlay",onClick:i,"aria-label":s},t?a.createElement(fe.N9s,null):a.createElement(fe.yhH,null)))),a.createElement(WA,null),a.createElement(jA,null,!n&&r&&a.createElement(Qi.Az,{placement:"bottom-end",overlay:c},(e=>{let t=e.toggleOpen,n=e.isOpen;return a.createElement(fe.SO$,{variant:"overlay",onClick:t,"aria-label":"More options","data-pressed":n||void 0},a.createElement(fe.V_g,null))})),a.createElement(fe.TU1,{variant:"overlay",onClick:o,"aria-label":"Close sidebar"})))},UA=u.default.div.withConfig({displayName:"EventSidebarHeader__HeaderContainer",componentId:"sc-1au34zi-0"})(["display:flex;align-items:center;padding:"," ",";gap:",";"],vt.YK.small,vt.YK.default,vt.YK.xsmall),VA=u.default.div.withConfig({displayName:"EventSidebarHeader__LeftActions",componentId:"sc-1au34zi-1"})(["display:flex;align-items:center;gap:",";"],vt.YK.xsmall),WA=u.default.div.withConfig({displayName:"EventSidebarHeader__Spacer",componentId:"sc-1au34zi-2"})(["flex:1;"]),jA=u.default.div.withConfig({displayName:"EventSidebarHeader__RightActions",componentId:"sc-1au34zi-3"})(["display:flex;align-items:center;gap:",";"],vt.YK.xsmall),HA=(0,u.default)(Ji.xm).withConfig({displayName:"EventSidebarHeader__DeleteMenuItem",componentId:"sc-1au34zi-4"})(["color:",";"],vt.Ee.color.content.danger),KA=e=>{let t=e.todaysDollarsValue,n=e.effectiveYear,l=e.verb,r=e.perMonth;const o=QE();if("todaysDollars"===ow().mode)return a.createElement(Ob,{"data-external-id":"inflation-adjusted-helper-text"},_t.Et.EVENTS.INFLATION_HELPER_TODAYS_DOLLARS);const i=wp(t,n,o);return a.createElement(Ob,{"data-external-id":"inflation-adjusted-helper-text"},_t.Et.EVENTS.INFLATION_HELPER_FUTURE_DOLLARS_LEAD(l)," ",a.createElement("strong",null,(0,rl.Ig)(i)),_t.Et.EVENTS.INFLATION_HELPER_FUTURE_DOLLARS_TRAIL({year:n,perMonth:r}))};var qA,$A,ZA;const JA=["finance","cash"],XA=[{value:"15",label:"15 year"},{value:"30",label:"30 year"}],QA=()=>{var e,t,n,l,r;const o=vy(),i=o.closeSidebar,s=o.id,c=QE(),d=ow().toTodaysDollars,u=wE((e=>e.updateEvent)),m=wE((e=>e.removeEvent)),p=JE(s,"buyAHome"),g=JA.indexOf(null!==(e=null===p||void 0===p?void 0:p.purchaseMethod)&&void 0!==e?e:"finance"),h=(0,a.useMemo)((()=>!!p&&p.downPaymentPercent<20),[p]),v=(0,a.useCallback)((e=>{s&&u(s,e)}),[s,u]),f=(0,a.useCallback)((e=>{v({growthRate:e})}),[v]),E=(0,a.useCallback)((e=>{v({purchaseMethod:JA[e]})}),[v]),y=(0,a.useCallback)((()=>{s&&(m(s),i())}),[s,m,i]),b=(0,a.useMemo)((()=>{var e;if(!p)return null;const t=null!==(e=p.startYear)&&void 0!==e?e:c.startYear;return wp(p.homeValue,t,c)}),[p,c]),x=(0,a.useMemo)((()=>p&&null!==b?Up((0,U.A)((0,U.A)({},p),{},{homeValue:b})):null),[p,b]),w=(0,a.useMemo)((()=>{var e;if(!p||!x)return null;const t=null!==(e=p.startYear)&&void 0!==e?e:c.startYear;return(0,U.A)((0,U.A)({},x),{},{monthlyPI:d(x.monthlyPI,t),monthlyPMI:d(x.monthlyPMI,t),monthlyTax:d(x.monthlyTax,t),monthlyInsurance:d(x.monthlyInsurance,t),totalMonthlyPayment:d(x.totalMonthlyPayment,t)})}),[p,c.startYear,x,d]),C=(0,a.useMemo)((()=>{if(!h||!x||null===b||!p)return null;const e=Yp(x.principal,b,p.mortgageRate,p.mortgageTerm);return e<12?(0,De.td)("month",e,{inclusive:!0}):(0,De.td)("year",Math.floor(e/12),{inclusive:!0})}),[h,x,b,p]);if(!p||!x||!w||null===b)return null;const A=null!==(t=p.startYear)&&void 0!==t?t:c.startYear,I=p.homeValue*p.downPaymentPercent/100,k=p.homeValue*p.yearlyOwnershipCostRate/100,S="finance"===p.purchaseMethod;return a.createElement(Nb,{"data-external-id":"buy-a-home-sidebar",$color:p.color},a.createElement(YA,{isIncluded:p.isIncluded,isRequired:p.isRequired,onIsIncludedChange:e=>v({isIncluded:e}),onDelete:y}),a.createElement(_b,null,a.createElement(zA,{icon:p.icon,color:p.color,foregroundColor:p.foregroundColor,name:p.name,onNameChange:e=>v({name:e}),onColorChange:e=>v({color:e,foregroundColor:e}),onIconChange:e=>v({icon:e})}),a.createElement(aI,null,a.createElement(Lb,null,"Year"),a.createElement(bb,{value:null!==(n=p.startYear)&&void 0!==n?n:c.startYear,onChange:e=>v({startYear:e})})),a.createElement(aI,null,a.createElement(Lb,null,"Home value"),a.createElement(fe.K$5,{name:"homeValue",value:p.homeValue,onValueChange:e=>v({homeValue:null!==e&&void 0!==e?e:0}),precision:0,onFocus:(0,ix.s)(p.homeValue)}),a.createElement(KA,{todaysDollarsValue:p.homeValue,effectiveYear:A,verb:"equal"})),a.createElement("div",{className:"rounded-md border border-border-primary bg-background-primary"},a.createElement("div",{className:"flex flex-col gap-xl p-default pb-xl"},a.createElement(Dc.t,{index:g,onChangeIndex:E},a.createElement(MA.c,null,a.createElement(RA.Q,{index:0,$background:"card"},"Finance"),a.createElement(RA.Q,{index:1,$background:"card"},"Pay Cash"))),S&&a.createElement(a.Fragment,null,a.createElement(aI,null,a.createElement(Lb,null,"Down payment"),a.createElement(lI,null,a.createElement("div",{className:"min-w-0"},a.createElement(fe.K$5,{name:"downPaymentAmount",value:I,onValueChange:e=>{const t=p.homeValue>
10?Math.min(Math.max((null!==e&&void 0!==e?e:0)/p.homeValue*100,0),100):0;v({downPaymentPercent:t})},precision:0,onFocus:(0,ix.s)(I)})),a.createElement(eI,{name:"downPaymentPercent",value:p.downPaymentPercent,onValueChange:e=>v({downPaymentPercent:Math.min(Math.max(null!==e&&void 0!==e?e:0,0),100)})})),a.createElement(KA,{todaysDollarsValue:I,effectiveYear:A,verb:"equal"}),a.createElement(Ob,null,"20% is recommended to avoid private mortgage insurance. Higher down payments mean lower monthly payments."," ",a.createElement(Bb,{href:sh},"Learn more"))),h&&a.createElement(aI,null,a.createElement(Lb,null,"Private mortgage insurance (PMI)"),a.createElement(eI,{name:"pmiRate",value:null!==(l=p.pmiRate)&&void 0!==l?l:1,onValueChange:e=>v({pmiRate:null!==e&&void 0!==e?e:0})}),a.createElement(Ob,null,x.monthlyPMI>0?"Will be added to your monthly payment for ".concat(C," until 20% equity is reached"):"Will not be added to your monthly payment.")),a.createElement(aI,null,a.createElement(Lb,null,"Mortgage"),a.createElement(lI,null,a.createElement(fe.hGA,{placeholder:fe.L2e,options:XA,value:String(p.mortgageTerm),onValueChange:e=>v({mortgageTerm:Number(e)||30})}),a.createElement(eI,{name:"mortgageRate",value:p.mortgageRate,onValueChange:e=>v({mortgageRate:null!==e&&void 0!==e?e:0})})))),a.createElement(aI,null,a.createElement(lI,null,a.createElement("div",{className:"flex flex-1 flex-col gap-xs"},a.createElement(Lb,null,"Property tax"),a.createElement(eI,{name:"propertyTaxRate",value:p.propertyTaxRate,onValueChange:e=>v({propertyTaxRate:null!==e&&void 0!==e?e:0})})),a.createElement("div",{className:"flex flex-1 flex-col gap-xs"},a.createElement(Lb,null,"Home insurance"),a.createElement(eI,{name:"homeInsuranceRate",value:p.homeInsuranceRate,onValueChange:e=>v({homeInsuranceRate:null!==e&&void 0!==e?e:0})}))))),a.createElement(tI,{calculations:w,isFinance:S,shouldShowPMI:h})),a.createElement("div",{className:"flex flex-col rounded-md border border-border-primary"},a.createElement("div",{className:"flex flex-col gap-xl p-default"},a.createElement(aI,null,a.createElement(Lb,null,"Yearly home ownership costs"),a.createElement(lI,null,a.createElement("div",{className:"min-w-0"},a.createElement(fe.K$5,{name:"yearlyOwnershipCosts",value:k,onValueChange:e=>{const t=p.homeValue>0?Math.min(Math.max((null!==e&&void 0!==e?e:0)/p.homeValue*100,0),100):0;v({yearlyOwnershipCostRate:t})},precision:0,onFocus:(0,ix.s)(k)})),a.createElement(eI,{name:"yearlyOwnershipCostRate",value:p.yearlyOwnershipCostRate,onValueChange:e=>v({yearlyOwnershipCostRate:Math.min(Math.max(null!==e&&void 0!==e?e:0,0),100)})})),a.createElement(KA,{todaysDollarsValue:k,effectiveYear:A,verb:"startAt"}),a.createElement(Ob,null,"1% is a good rule-of-thumb."," ",a.createElement(Bb,{href:sh},"Learn more"))),a.createElement(Jw,{growthType:p.growthType,growthRate:null!==(r=p.growthRate)&&void 0!==r?r:void 0,inflationRate:c.inflationRate,onGrowthTypeChange:e=>v({growthType:e}),onGrowthRateChange:f}))),a.createElement("div",{className:"flex flex-col rounded-md border border-border-primary"},a.createElement("div",{className:"flex items-center justify-between p-default"},a.createElement(Lb,null,"Replace existing Housing expenses"),a.createElement(ox.k,{checked:p.replaceExistingHousing,onChange:e=>v({replaceExistingHousing:e.target.checked})})),a.createElement(nI,{open:p.replaceExistingHousing},a.createElement("div",{className:"border-t border-divider-primary"}),a.createElement("div",{className:"flex flex-col gap-xl p-default"},a.createElement(aI,null,a.createElement(Lb,null,"Current monthly payment"),a.createElement(fe.K$5,{name:"currentMonthlyHousingPayment",value:p.currentMonthlyHousingPayment,onValueChange:e=>v({currentMonthlyHousingPayment:null!==e&&void 0!==e?e:0}),precision:0,onFocus:(0,ix.s)(p.currentMonthlyHousingPayment)}),a.createElement(Ob,null,"In today's dollars.")),a.createElement(rI,null,"This amount will be replaced by your estimated monthly payment of"," ",a.createElement("strong",null,(0,rl.vv)(w.totalMonthlyPayment)),"."))))))},eI=e=>{let t=e.name,n=e.value,l=e.onValueChange;return a.createElement(fe._CU.Root,{"data-external-id":"percent-input",value:n,min:0,step:"any",locale:"en-US",format:Ug,onValueChange:l},a.createElement(fe.i9A,{className:"w-full min-w-0 flex-1"},a.createElement(fe._CU.Input,Object.assign({name:t},(0,Ex.p)("numeric-input"))),a.createElement(fe.i9A.Addon,{align:"content-end"},a.createElement(fe.i9A.Text,null,"%"))))},tI=e=>{let t=e.calculations,n=e.isFinance,l=e.shouldShowPMI;const r=t.monthlyPI,o=t.monthlyPMI,i=t.monthlyTax,s=t.monthlyInsurance,c=t.totalMonthlyPayment,d=n?[{label:"Principal and interest",amount:r,color:"bg-chart-fill-indigo"},...l&&o>0?[{label:"PMI",amount:o,color:"bg-chart-fill-purple"}]:[],{label:"Property tax",amount:i,color:"bg-chart-fill-blue"},{label:"Home insurance",amount:s,color:"bg-chart-fill-teal"}]:[{label:"Property tax",amount:i,color:"bg-chart-fill-blue"},{label:"Home insurance",amount:s,color:"bg-chart-fill-teal"}];return a.createElement("div",{"data-external-id":"monthly-payment-section",className:"flex flex-col gap-xl border-t border-border-primary p-default"},a.createElement("div",{className:"flex flex-col gap-default"},a.createElement("div",{className:"flex items-center justify-between"},a.createElement("span",{className:"text-base font-medium text-content-primary"},"Monthly payment"),a.createElement("span",{className:"text-base font-medium text-content-secondary"},(0,rl.vv)(c))),a.createElement("div",{className:"flex w-full gap-2xs"},d.map(((e,t)=>{const n=c>0?e.amount/c*100:0;return a.createElement("div",{key:e.label,className:(0,q.cn)(e.color,t>0&&"ml-px","h-sm rounded-xs"),style:{width:"".concat(n,"%")}})})))),a.createElement("div",{className:"flex flex-col gap-xs"},d.map((e=>a.createElement("div",{key:e.label,className:"flex items-center justify-between"},a.createElement("div",{className:"flex items-center gap-xs"},a.createElement("div",{className:(0,q.cn)("size-xs rounded-round",e.color)}),a.createElement("span",{className:"text-base text-content-primary"},e.label)),a.createElement("span",{className:"text-right text-base text-content-primary"},(0,rl.vv)(e.amount)))))))},nI=e=>{let t=e.open,n=e.children;return a.createElement("div",{"data-external-id":"tailwind-drawer",className:(0,q.cn)("grid transition-[grid-template-rows] duration-250 ease-[
1cubic-bezier(0.22,1,0.36,1)]",t?"grid-rows-[1fr]":"grid-rows-[0fr]")},a.createElement("div",{className:"overflow-hidden"},n))},aI=$d.s.div(qA||(qA=(0,wc.A)(["flex flex-col gap-xs"]))),lI=$d.s.div($A||($A=(0,wc.A)(["grid grid-cols-2 gap-xs"]))),rI=$d.s.div(ZA||(ZA=(0,wc.A)(["rounded-md bg-background-info p-default text-sm text-content-info"])));var oI,iI;const sI=e=>{let t=e.ownerId,n=e.targets,l=e.onChange,r=e.eventId,o=e.eventStartYear,i=e.eventEndYear,s=e.learnMoreUrl,c=e.eventKind;const d=XE(),u=vy().openEvent,m=(0,a.useMemo)((()=>{const e={ownerId:null!==t&&void 0!==t?t:null,startYear:null!==o&&void 0!==o?o:null,endYear:null!==i&&void 0!==i?i:null,eventKind:c,isIncluded:!0};return d.map((e=>e.config)).filter((t=>t.id!==r&&(!!qp(t)&&Zp(e,t))))}),[d,r,t,o,i,c]),p=e=>{var t;const a=n.find((t=>t.targetEventId===e));return null!==(t=null===a||void 0===a?void 0:a.reductionPercent)&&void 0!==t?t:0};return 0===m.length?null:a.createElement(cI,{"data-external-id":"income-reduction-list"},a.createElement(Lb,null,"Income reduction"),a.createElement(Ob,null,"Choose income sources that will be reduced for the duration of this event."," ",s&&a.createElement(Bb,{href:s},"Learn more")),m.map((e=>{const t=(s=e.id,o?d.flatMap((e=>{if(e.id===r)return[];const t=e.config;if(!Hp(t.eventKind))return[];if(!e.isIncluded||!e.startYear)return[];if("careerBreak"===t.eventKind&&(0,Tp.n)(t.endYear)&&t.endYear<=o)return[];if((0,Tp.n)(i)&&e.startYear>=i)return[];if(!("incomeReductionTargets"in t)||!Array.isArray(t.incomeReductionTargets))return[];const n=t.incomeReductionTargets.find((e=>e.targetEventId===s&&e.reductionPercent>0));return n?[{id:e.id,name:e.name,percent:n.reductionPercent}]:[]})):[]);var s;return a.createElement("div",{key:e.id},a.createElement(lx,{icon:e.icon,color:e.color,foregroundColor:e.foregroundColor,name:e.name,borderless:!0,onClick:()=>u(e.id),renderIcon:e.isHidden?a.createElement(Wl._,{url:null,size:28}):void 0,rightSlot:a.createElement(fe._CU.Root,{value:p(e.id),min:0,step:"any",locale:"en-US",format:Ug,onValueChange:t=>((e,t)=>{const a=Math.min(Math.max(t,0),100),r=n.find((t=>t.targetEventId===e));l(r?n.map((t=>t.targetEventId===e?(0,U.A)((0,U.A)({},t),{},{reductionPercent:a}):t)):[...n,{targetEventId:e,reductionPercent:a}])})(e.id,null!==t&&void 0!==t?t:0)},a.createElement(fe.i9A,{className:"w-18 shrink-0"},a.createElement(fe._CU.Input,Object.assign({name:"reduction-".concat(e.id),className:"text-right"},(0,Ex.p)("numeric-input"))),a.createElement(fe.i9A.Addon,{align:"content-end"},a.createElement(fe.i9A.Text,null,"%"))))}),t.length>0&&a.createElement("div",{className:"mt-3xs pl-9"},a.createElement(xt.v,{size:"xsmall",color:"content.secondary"},"Also reduced by"," ",t.map(((e,t)=>a.createElement(a.Fragment,{key:e.id},t>0&&", ",a.createElement(dI,{type:"button",onClick:()=>u(e.id)},e.name)," (".concat(e.percent,"%)")))))))})))},cI=$d.s.div(oI||(oI=(0,wc.A)(["flex flex-col gap-xs"]))),dI=$d.s.button(iI||(iI=(0,wc.A)(["cursor-pointer border-0 bg-transparent p-0 text-content-link hover:underline"]))),uI="Same",mI=e=>{const t=Number((100*(e-1)).toFixed(2));return 0===t?uI:"".concat(t>0?"+":"").concat(t,"%")},pI=e=>e.trim().toLowerCase()===uI.toLowerCase()?1:parseFloat(e.replace("%",""))/100+1;var gI,hI;const vI=()=>{var e,t,n,l,r,o;const i=vy(),s=i.closeSidebar,c=i.id,d=hy(),u=QE(),m=ny(),p=wE((e=>e.updateEvent)),g=wE((e=>e.removeEvent)),h=JE(c,"careerBreak"),v=(0,a.useCallback)((e=>{c&&p(c,e)}),[c,p]),f=(0,a.useCallback)((()=>{c&&(g(c),s())}),[c,g,s]);if(!h)return null;const E=u.participants.find((e=>e.userId===h.ownerId));return a.createElement(Nb,{"data-external-id":"career-break-sidebar",$color:h.color},a.createElement(YA,{isIncluded:h.isIncluded,isRequired:h.isRequired,onIsIncludedChange:e=>v({isIncluded:e}),onDelete:f}),a.createElement(_b,null,a.createElement(zA,{icon:h.icon,color:h.color,foregroundColor:h.foregroundColor,name:h.name,onNameChange:e=>v({name:e}),onColorChange:e=>v({color:e,foregroundColor:e}),onIconChange:e=>v({icon:e})}),m&&a.createElement(fI,null,a.createElement(Lb,null,"Event owner"),a.createElement(fe.hGA,{name:"ownerId",value:h.ownerId,options:d,onValueChange:e=>{var t;const n=null!==(t=wE.getState().events)&&void 0!==t?t:[];v(ag(n,h.id,e))},placeholder:"Select owner"})),a.createElement(fI,null,a.createElement(Lb,null,"Start year"),a.createElement(bb,{value:null!==(e=h.startYear)&&void 0!==e?e:void 0,onChange:e=>v({startYear:e}),birthday:null===E||void 0===E?void 0:E.birthday,maxYear:(0,Tr.A)(h.endYear)?h.endYear-1:void 0})),a.createElement(fI,null,a.createElement(Lb,null,"End year"),a.createElement(bb,{value:null!==(t=h.endYear)&&void 0!==t?t:void 0,onChange:e=>v({endYear:e}),minYear:(0,Tr.A)(h.startYear)?h.startYear+1:void 0,referenceYear:null!==(n=h.startYear)&&void 0!==n?n:void 0})),a.createElement(fI,null,a.createElement(Lb,null,"Living expenses"),a.createElement(Ob,null,"How much you expect your yearly spending to change during your break."),a.createElement(wy,{value:h.expenseMultiplier,onCh
1ange:e=>v({expenseMultiplier:null!==e&&void 0!==e?e:0}),min:.5,max:1.5,step:.05},a.createElement(Cy,{$rightColumnWidth:My},a.createElement(Iy,{colorVariant:"blue"}),a.createElement(Ly,{name:"expenseMultiplier",formatValue:mI,parseValue:pI,min:0,max:3,step:1e-4,textAlign:"right"}),a.createElement(EI,null,a.createElement("span",null,"Spend less"),a.createElement("span",null,"\u2022"),a.createElement("span",null,"Spend more"))))),a.createElement(sI,{ownerId:h.ownerId,targets:null!==(l=h.incomeReductionTargets)&&void 0!==l?l:[],onChange:e=>v({incomeReductionTargets:e}),eventId:h.id,eventStartYear:null!==(r=h.startYear)&&void 0!==r?r:void 0,eventEndYear:null!==(o=h.endYear)&&void 0!==o?o:void 0,eventKind:"careerBreak"})))},fI=$d.s.div(gI||(gI=(0,wc.A)(["flex flex-col gap-xs"]))),EI=$d.s.div(hI||(hI=(0,wc.A)(["\n  col-start-1 -mt-xs grid grid-cols-[1fr_auto_1fr] items-center text-xs text-content-secondary\n  [&>span:first-child]:text-left\n  [&>span:last-child]:text-right\n  [&>span:nth-child(2)]:text-center\n"]))),yI=e=>{let t=e.value,n=e.onChange,l=e.min,r=e.max,o=e.step,i=e.name,s=e.ariaLabel,c=e.defaultValue;return a.createElement(wy,{"data-external-id":"forecasting-slider-input",value:t,onChange:n,min:l,max:r,step:o,debounceMs:150},a.createElement(Cy,{$rightColumnWidth:My},a.createElement(Iy,{ariaLabel:s}),a.createElement(Ly,{name:i,formatValue:nb,parseValue:ab,min:l,max:r,step:.001,textAlign:"right"}),void 0!==c&&a.createElement(Py,{value:c})))},bI=()=>{const e=wE((e=>{var t;return null!==(t=e.scenarioExternalId)&&void 0!==t?t:null})),t=of((t=>{var n,a;return e&&null!==(n=null===(a=t.byScenarioId[e])||void 0===a?void 0:a.status)&&void 0!==n?n:"idle"})),n=of((t=>{var n;return!!e&&void 0!==(null===(n=t.byScenarioId[e])||void 0===n?void 0:n.result)})),l=(0,a.useCallback)((()=>{e&&dA(e)}),[e]);return{run:cA,cancel:l,isRunning:"running"===t,hasFinishedRun:n,hasRunFailed:"failed"===t}},xI=e=>{let t=e.isFullWidth,n=void 0!==t&&t;const l=bI(),r=l.run,i=l.cancel,s=l.isRunning,c=l.hasFinishedRun,d=l.hasRunFailed,u=(0,a.useState)(!1),m=(0,o.A)(u,2),p=m[0],g=m[1],h=(0,a.useState)(!1),v=(0,o.A)(h,2),f=v[0],E=v[1],y=(0,a.useRef)(!1),b=(0,a.useRef)(null),x=s&&(p||f),w=(0,a.useCallback)((e=>{const t=b.current;if(b.current=null,!(e.detail>=2))return s?void((null!==t&&void 0!==t?t:x)&&i()):(g(!1),E(!1),void r())}),[i,x,s,r]);return a.createElement(fe.XZZ,{"data-external-id":"monte-carlo-run-button",variant:"primary","aria-busy":s||void 0,className:n?"w-full":void 0,icon:wI(s,x),onClick:w,onPointerEnter:()=>g(!0),onPointerMove:()=>g(!0),onPointerLeave:()=>{y.current=!1,g(!1)},onPointerDown:()=>{y.current=!0,b.current=x},onPointerUp:()=>{y.current=!1},onPointerCancel:()=>{y.current=!1},onFocus:()=>E(!y.current),onKeyDown:()=>{b.current=x},onKeyUp:()=>E(!0),onBlur:()=>E(!1)},(e=>{let t=e.isRunning,n=e.isOfferingCancel,a=e.hasFinishedRun,l=e.hasRunFailed;return n?"Cancel":t?"Simulating":l?"Try again":a?"Run again":"Run simulation"})({isRunning:s,isOfferingCancel:x,hasFinishedRun:c,hasRunFailed:d}))},wI=(e,t)=>t?a.createElement(fe.oRA,null):e?a.createElement(fe.ix7,{size:"xs",className:"text-current","aria-hidden":!0}):a.createElement(fe.C3S,null),CI=()=>{const e=bI().hasRunFailed;return a.createElement("div",{"data-external-id":"monte-carlo-run-control",className:"flex flex-col gap-xs"},a.createElement(xI,{isFullWidth:!0}),e&&a.createElement(fe.c8D,{size:"sm",color:"danger"},"The last run could not finish. Anything already on screen is from an earlier run."))},AI=[],II=[],kI=()=>{const e=wE((e=>{var t;return null!==(t=e.scenarioExternalId)&&void 0!==t?t:null}));return of((t=>{var n;return e?null===(n=t.byScenarioId[e])||void 0===n?void 0:n.result:void 0}))},SI=()=>{var e,t;return null!==(e=null===(t=kI())||void 0===t?void 0:t.summaries)&&void 0!==e?e:II},NI=()=>{const e=kI(),t=TI();return e?t?e.todaysDollarsBands:e.unadjustedBands:AI},TI=()=>wE((e=>"todaysDollars"===e.dollarMode)),_I=()=>{const e=kI(),t=(()=>{const e=wE((e=>e.accounts)),t=wE((e=>e.events)),n=wE((e=>e.settings)),l=wE((e=>e.customWithdrawalOrderIds)),r=wE((e=>e.uncategorizedSavingsSettings)),o=wE((e=>e.monteCarloSettings.numPaths)),i=wE((e=>e.monteCarloSettings.inflationVolatility)),s=wE((e=>e.householdUserIds));return a.useMemo((()=>nA(eA({accounts:e,events:t,settings:n,customWithdrawalOrderIds:l,uncategorizedSavingsSettings:r,monteCarloSettings:{numPaths:o,inflationVolatility:i},householdUserIds:s}))),[e,t,n,l,r,o,i,s])})(),n=JC(XC);return void 0!==e&&(e.signature!==t||null!==n&&n!==e.runSeed)};var DI,RI,MI;const LI={onTrack:"money lasted the whole plan",offTrack:"ran out of money"},OI={useGrouping:!1},PI={schedule:"Growth follows this account\u2019s variable rate, set on the account.",noChange:"This account doesn\u2019t change, so a path draws no growth for it."},BI=()=>{var e;const t=vy().closeSidebar,n=QE(),l=KE(),r=wE((e=>e.updateSettings)),i=wE((e=>e.updateAccount)),s=wE((e=>e.monteCarloSettings)),c=s.numPaths,d=s.inflationVolatility,u=GI(n.inflationRate,cp(d)),m=wE((e=>e.updateMonteCarloSettings)),p=null===(e=kI())||void 0===e?void 0:e.runSeed,g=JC((e=>e.useFixedSeed)),h=JC((e=>e.fixedSeed)),v=JC((e=>e.setUseFixedSeed)),f=JC((e=>e.setFixedSeed)),E=aA((e=>e.successFloor)),y=aA((e=>e.setSuccessFloor)),b=a.useState(E),x=(0,o.A)(b,2),w=x[0],C=x[1],A=a.useMemo((()=>(0,_r.debounce)(y,150,{maxWait:2e3})),[y]);a.useEffect((()=>()=>A.cancel()),[A]);const I=l.filter((e=>"asset"===e.accountType.group&&e.isIncluded&&!e.isSystemAccount));return a.createElement(Sb,{"data-external-id":"chance-of-success-sidebar"},a.createElement(UI,null,a.createElement(Rb,null,"Chance of success"),a.createElement(fe.TU1,{variant:"outline",onClick:t,"aria-label":"Close sidebar"})),a.createElement(_b,null,a.createElement(CI,null),a.createElement(zI,{title:"Success criteria",defaultOpen:!0},a.createElement(Db,null,a.createElement("div",{className:"flex flex-col gap-sm"},a.createElement(fe.cIj,{size:"3xs",iconSize:"xs",triggerClassName:"text-content-secondary",content:"Where each path lands at the end of the plan. A path is on track at or above the figure and off track below it or if it ever ran out of money.",label:a.createElement(Ob,null,"Ending net worth threshold")}),a.createElement(fe.w18,{value:w,min:0,max:2e6,"aria-label":"Ending net worth threshold",step:5e4,onValueChange:e=>{"number"===typeof e&&(C(e),A(e))},onValueCommitted:e=>{"number"===typeof e&&(A.cancel(),y(e))}}),a.createElement("div",{className:"flex flex-col gap-2xs"},Tf.map((e=>{const t=Mf[e],n=t.qualifier.icon;return a.createElement("div",{key:e,className:"flex items-center gap-xs"},a.createElement(n,{size:"xs",className:Cf[t.status]}),a.createElement(fe.c8D,{size:"sm"},a.createElement("span",{className:"text-content-primary"}
1,t.qualifier.word)," ",a.createElement("span",{className:"text-content-secondary"},_f(w)?((e,t)=>_f(t)?"onTrack"===e?"at or above ".concat((0,rl.fw)(t)):"under ".concat((0,rl.fw)(t),", or ran out of money"):null)(e,w):LI[e])))})))))),a.createElement(zI,{title:"Inflation Settings",defaultOpen:!0},a.createElement(Db,null,a.createElement(VI,null,a.createElement("div",{className:"flex items-center gap-2xs"},a.createElement(fe.cIj,{size:"3xs",iconSize:"xs",triggerClassName:"text-content-secondary",content:"How much prices rise in a typical year. Each path varies inflation around this number.",label:a.createElement(Ob,null,"Inflation rate")})),a.createElement(yI,{name:"inflationRate",ariaLabel:"Inflation rate",value:n.inflationRate,onChange:e=>{TE("chance_of_success",(()=>r({inflationRate:e})))},min:0,max:10,step:.1,defaultValue:3})),a.createElement(VI,null,a.createElement("div",{className:"flex items-center gap-2xs"},a.createElement(fe.cIj,{size:"3xs",iconSize:"xs",triggerClassName:"text-content-secondary",content:"How much inflation jumps around from year to year. A bigger number means less predictable prices.",label:a.createElement(Ob,null,"Volatility (Standard Deviation)")})),a.createElement(yI,{name:"inflationVolatility",ariaLabel:"Inflation volatility",value:d,onChange:e=>TE("chance_of_success",(()=>m({inflationVolatility:e}))),min:0,max:10,step:.1,defaultValue:ip.inflationVolatility}),u&&a.createElement("div",{className:"flex items-center gap-2xs"},a.createElement(fe.cIj,{size:"3xs",iconSize:"xs",triggerClassName:"text-content-secondary",content:"What prices rise by in an average year. The typical year above is lower, because a stretch of high-inflation years compounds further than a stretch of low ones pulls back.",label:a.createElement(WI,null,"Yearly inflation averages ",u)}))))),I.length>0&&a.createElement(zI,{title:"Account Settings"},I.map((e=>{var t,n,l,r,o,s,c;const d=YI(e),u=$h.defaultVolatility(e),m=null!==(t=e.growthRate)&&void 0!==t?t:d,p=cp(null!==(n=e.volatility)&&void 0!==n?n:u),g=GI(m,p),h=null!==(l=e.growthRateMethod)&&void 0!==l?l:"fixed",v=PI[h];return a.createElement(Db,{key:e.id},a.createElement("div",{className:"flex items-center gap-xs"},a.createElement(_w,{logoUrl:null!==(r=null===(o=e.metadata)||void 0===o?void 0:o.logoUrl)&&void 0!==r?r:void 0,icon:null!==(s=null===(c=e.metadata)||void 0===c?void 0:c.icon)&&void 0!==s?s:void 0,sourceEventExternalId:e.sourceEventExternalId,accountId:e.id,size:24}),a.createElement(Lb,null,e.name)),a.createElement("div",{className:"flex flex-col gap-sm"},v&&a.createElement(Ob,null,v),"fixed"===h&&a.createElement(VI,null,a.createElement("div",{className:"flex items-center gap-2xs"},a.createElement(fe.cIj,{size:"3xs",iconSize:"xs",triggerClassName:"text-content-secondary",content:"The rate this account grows at over the long run. Any one year can land far above or far below it.",label:a.createElement(Ob,null,"Growth rate")})),a.createElement(yI,{name:"".concat(e.id,"-growthRate"),ariaLabel:"".concat(e.name," growth rate"),value:m,onChange:t=>((e,t)=>{TE("chance_of_success",(()=>i(e.id,{growthRate:t})))})(e,t),min:Math.min(-30,d),max:Math.max(30,d),step:.5,defaultValue:d}),g&&a.createElement("div",{className:"flex items-center gap-2xs"},a.createElement(fe.cIj,{size:"3xs",iconSize:"xs",triggerClassName:"text-content-secondary",content:"What a single year earns on average. You keep less than that over the long run, because losing value costs more than gaining it back. That\u2019s why the growth rate above is lower.",label:a.createElement(WI,null,"Yearly returns average ",g)}))),"noChange"!==h&&a.createElement(VI,null,a.createElement("div",{className:"flex items-center gap-2xs"},a.createElement(fe.cIj,{size:"3xs",iconSize:"xs",triggerClassName:"text-content-secondary",content:"How much this account's return jumps around from year to year. A bigger number means bigger swings. The bigger the swings, the more a bad year undoes the good ones. Zero means the return never changes.",label:a.createElement(Ob,null,"Volatility (Standard Deviation)")})),a.createElement(yI,{name:"".concat(e.id,"-volatility"),ariaLabel:"".concat(e.name," volatility"),value:p,onChange:t=>((e,t)=>{TE("chance_of_success",(()=>i(e.id,{volatility:t})))})(e,t),min:0,max:50,step:.5,defaultValue:u}))))}))),a.createElement(zI,{title:"Advanced Settings"},a.createElement(Db,null,a.createElement("div",{className:"flex flex-col gap-xs"},a.createElement("div",{className:"flex items-center gap-2xs"},a.createElement(Lb,{htmlFor:"numPaths"},"Number of paths"),a.createElement(fe.cIj,{size:"3xs",iconSize:"xs","aria-label":"About the number of paths",content:"How many separate paths we simulate. More paths steady the result and take longer to finish."})),a.createElement(fe._CU,{size:"sm",id:"numPaths",name:"numPaths",value:c,onValueChange:e=>null!==e&&TE("chance_of_success",(()=>m({numPaths:e}))),min:sp,max:5e3,step:100}
1),a.createElement(WI,null,"Default is ",ip.numPaths.toLocaleString())),a.createElement("div",{className:"flex flex-col gap-xs"},a.createElement("div",{className:"flex items-center gap-2xs"},a.createElement(fe.Ko1,{size:"sm",label:"Use fixed seed",checked:g,onCheckedChange:e=>{e&&f(null!==p&&void 0!==p?p:ZC()),v(e)}}),a.createElement(fe.cIj,{size:"3xs",iconSize:"xs",triggerClassName:"text-content-secondary","aria-label":"About the fixed seed",content:"Reuses the same set of paths instead of drawing a new set. The number names the set."})),g&&null!==h&&a.createElement(a.Fragment,null,a.createElement(Lb,{htmlFor:"fixedSeed"},"Seed"),a.createElement(fe._CU,{size:"sm",id:"fixedSeed",name:"fixedSeed",value:h,onValueChange:e=>null!==e&&f(e),min:0,max:$C,step:1,format:OI})))))))},zI=e=>{let t=e.title,n=e.defaultOpen,l=void 0!==n&&n,r=e.children;return a.createElement(fe.X0s,{"data-external-id":"collapsible-section",defaultOpen:l},a.createElement(fe.X0s.Trigger,{className:"group/section flex w-full items-center justify-between gap-sm"},a.createElement(Lb,null,t),a.createElement(fe.D39,{className:"size-4 shrink-0 text-content-secondary transition-transform duration-200 group-data-panel-open/section:rotate-180"})),a.createElement(fe.X0s.Content,null,a.createElement("div",{className:"flex flex-col gap-default pt-default"},r)))},FI=e=>"".concat(e.toFixed(2),"%"),GI=(e,t)=>{const n=FI(((e,t)=>{if(e<=-100)return e;const n=Ef(e,t);return 100*((1+e/100)*Math.exp(n*n/2)-1)})(e,t));return n===FI(e)?null:n},YI=e=>{var t;return null!==(t=e.linkedGrowthRate)&&void 0!==t?t:$h.defaultGrowthRate(e)},UI=(0,$d.s)(Tb)(DI||(DI=(0,wc.A)(["border-b border-divider-primary"]))),VI=$d.s.div(RI||(RI=(0,wc.A)(["flex flex-col gap-xs"]))),WI=(0,$d.s)(Ob)(MI||(MI=(0,wc.A)(["text-xs"]))),jI=()=>{var e;const t=vy(),n=t.closeSidebar,l=t.id,r=QE(),o=ny(),i=wE((e=>e.updateEvent)),s=wE((e=>e.removeEvent)),c=wE((e=>e.updateParticipant)),d=JE(l,"endOfPlan"),u=r.participants.find((e=>e.userId===(null===d||void 0===d?void 0:d.ownerId))),m=null!==u&&void 0!==u&&u.birthday?(0,Ba.NP)(u.birthday):void 0,p=null!==(e=null===u||void 0===u?void 0:u.lifeExpectancy)&&void 0!==e?e:sg,g=m?m+p:void 0,h=m?m+50:void 0,v=m?m+110:void 0,f=(0,a.useCallback)((e=>{l&&i(l,e)}),[l,i]),E=(0,a.useCallback)((()=>{l&&(s(l),n())}),[l,s,n]),y=(0,a.useCallback)((e=>{if(null===d||void 0===d||!d.ownerId||void 0===m)return;const t=e-m,n=Math.max(50,Math.min(110,t));c(d.ownerId,{lifeExpectancy:n})}),[null===d||void 0===d?void 0:d.ownerId,m,c]);return d&&u?a.createElement(Nb,{"data-external-id":"end-of-plan-sidebar",$color:d.color},a.createElement(YA,{isIncluded:d.isIncluded,isRequired:d.isRequired,onIsIncludedChange:e=>f({isIncluded:e}),onDelete:E}),a.createElement(_b,null,a.createElement(zA,{icon:d.icon,color:d.color,foregroundColor:d.foregroundColor,name:d.name,onNameChange:e=>f({name:e})}),o&&a.createElement(HI,null,a.createElement(Lb,null,"Event owner"),a.createElement(KI,null,a.createElement(Pw.n,{userId:u.userId,userName:u.displayName,userProfilePictureUrl:u.profilePictureUrl,avatarSize:24,showLabel:!1}),a.createElement(qI,null,u.displayName))),a.createElement(HI,null,a.createElement(Lb,null,"Year"),a.createElement(bb,{value:g,onChange:y,birthday:u.birthday,minYear:h,maxYear:v})))):null},HI=u.default.div.withConfig({displayName:"EndOfPlanSidebar__Section",componentId:"sc-1r0wcje-0"})(["display:flex;flex-direction:column;gap:",";"],vt.YK.xsmall),KI=u.default.div.withConfig({displayName:"EndOfPlanSidebar__OwnerCard",componentId:"sc-1r0wcje-1"})(["display:flex;align-items:center;gap:",";padding:"," ",";background:",";border-radius:8px;"],vt.YK.xsmall,vt.YK.small,vt.YK.default,vt.Ee.color.background.secondary),qI=u.default.span.withConfig({displayName:"EndOfPlanSidebar__OwnerName",componentId:"sc-1r0wcje-2"})(["font-size:14px;font-weight:",";color:",";"],vt.Wy.medium,vt.Ee.color.content.primary),$I=[{kind:"income",title:"Income",description:"Inheritance, bonus, stock sales, and more",icon:"trending-up",color:"green",foregroundColor:"green"},{kind:"otherExpense",title:"Expense",description:"Buy a car, start a business, home repairs, and more",icon:"credit-card",color:"red",foregroundColor:"red"},{kind:"retirement",title:"Retire",description:"Transition to retirement income sources",icon:"sunset",color:"orange",foregroundColor:"orange"},{kind:"buyAHome",title:"Buy a home",description:"Plan for home ownership and related costs",icon:"home",color:"blue",foregroundColor:"blue"},{kind:"otherExpense",title:"Get married",description:"Plan for wedding and related expenses",icon:"heart",color:"pink",foregroundColor:"pink",comingSoon:!0},{kind:"socialSecurity",title:"Social Security",description:"Begin collecting Social Security payments",icon:"shield-user",color:"yellow",foregroundColor:"yellow"},{kind:"newJob",title:"New job",description:"Model income changes from a new position",icon:"briefcase",color:"lime",foregroundColor:"lime"},{kind:"haveAKid",title:"Have a kid",description:"Model the financial impact of raising children",icon:"stroller",color:"pink",foregroundColor:"pink"},{kind:"careerBreak",title:"Career break",description:"Plan for time away from work",icon:"umbrella",color:"indigo",foregroundColor:"indigo"},{kind:"windfall",title:"Windfall",description:"One-time financial gains or windfalls",icon:"treasure-chest",color:"green",foregroundColor:"green"},{kind:"otherExpense",title:"Education",description:"Plan for tuition and education costs",icon:"graduation-cap",color:"teal",foregroundColor:"teal",comingSoon:!0}
1,{kind:"otherExpense",title:"Emergency",description:"Prepare for unexpected expenses",icon:"flame",color:"brown",foregroundColor:"brown",comingSoon:!0}],ZI=$I.filter((e=>!e.comingSoon)),JI=$I.filter((e=>e.comingSoon)),XI=()=>{const e=vy(),t=e.closeSidebar,n=e.openEvent,l=e.openedSidebarDetails,r=wE((e=>e.createEventOfType));return a.createElement(Sb,{"data-external-id":"event-type-picker"},a.createElement(Tb,null,a.createElement(Rb,null,"New event"),a.createElement(fe.TU1,{variant:"outline",onClick:t,"aria-label":"Close sidebar"})),a.createElement(_b,null,a.createElement("div",null,a.createElement(QI,null,ZI.map((e=>a.createElement(ek,{key:e.title,onClick:()=>(e=>{const t="new-event"===(null===l||void 0===l?void 0:l.type)&&void 0!==l.year?l.year:void 0,a=r(e.kind,{startYear:t,name:e.title,icon:e.icon,color:e.color,foregroundColor:e.foregroundColor});n(a)})(e)},a.createElement(ak,{$color:e.color,$foregroundColor:e.foregroundColor},a.createElement(sl.ZQ,{name:e.icon,size:24})),a.createElement(m.g,{column:!0,minWidth:0,flex:1},a.createElement(xt.v,{size:"base",weight:"medium",lineHeight:"24px",color:"content.primary"},e.title),a.createElement(xt.v,{size:"small",lineHeight:"20px",color:"content.secondary"},e.description))))))),a.createElement("div",null,a.createElement(Lb,null,"Coming soon"),a.createElement(tk,null,JI.map((e=>a.createElement(nk,{key:e.title},a.createElement(ak,{$color:e.color,$foregroundColor:e.foregroundColor},a.createElement(sl.ZQ,{name:e.icon,size:24})),a.createElement(m.g,{column:!0,minWidth:0,flex:1},a.createElement(xt.v,{size:"base",weight:"medium",lineHeight:"24px",color:"content.primary"},e.title),a.createElement(xt.v,{size:"small",lineHeight:"20px",color:"content.secondary"},e.description)))))))))},QI=u.default.div.withConfig({displayName:"EventTypePicker__OptionsList",componentId:"sc-1rcwq9q-0"})(["display:flex;flex-direction:column;border:1px solid ",";border-radius:",";overflow:hidden;"],vt.Ee.color.border.primary,vt.r8.small),ek=u.default.button.withConfig({displayName:"EventTypePicker__OptionRow",componentId:"sc-1rcwq9q-1"})(["display:flex;align-items:center;gap:",";padding:"," ",";background:",";border:none;border-bottom:1px solid ",";cursor:pointer;text-align:left;transition:",";&:last-child{border-bottom:none;}&:hover{background:",";}"],vt.YK.default,vt.YK.small,vt.YK.default,vt.Ee.color.background.primary,vt.Ee.color.border.primary,vt.kY.fast,vt.Ee.color.background.secondary),tk=(0,u.default)(QI).withConfig({displayName:"EventTypePicker__ComingSoonList",componentId:"sc-1rcwq9q-2"})(["margin-top:",";"],vt.YK.xsmall),nk=(0,u.default)(ek).withConfig({displayName:"EventTypePicker__DisabledOptionRow",componentId:"sc-1rcwq9q-3"})(["opacity:0.5;cursor:not-allowed;"]),ak=u.default.div.withConfig({displayName:"EventTypePicker__IconSquare",componentId:"sc-1rcwq9q-4"})(["width:","px;height:","px;border-radius:",";background:",";display:flex;align-items:center;justify-content:center;color:",";flex-shrink:0;"],36,36,vt.r8.default,(e=>{let t=e.theme,n=e.$color;return t.variables.color.chart.event.background[n]}),(e=>{let t=e.theme,n=e.$foregroundColor;return t.variables.color.chart.event.foreground[n]}));var lk;const rk=()=>{var e,t,n,l;const r=vy(),o=r.closeSidebar,i=r.id,s=QE(),c=wE((e=>e.updateEvent)),d=wE((e=>e.removeEvent)),u=JE(i,"haveAKid"),m=(0,a.useCallback)((e=>{i&&c(i,e)}),[i,c]),p=(0,a.useCallback)((()=>{i&&(d(i),o())}),[i,d,o]);if(!u)return null;const g=null!==(e=u.startYear)&&void 0!==e?e:s.startYear;return a.createElement(Nb,{"data-external-id":"have-a-kid-sidebar",$color:u.color},a.createElement(YA,{isIncluded:u.isIncluded,isRequired:u.isRequired,onIsIncludedChange:e=>m({isIncluded:e}),onDelete:p}),a.createElement(_b,null,a.createElement(zA,{icon:u.icon,color:u.color,foregroundColor:u.foregroundColor,name:u.name,onNameChange:e=>m({name:e}),onColorChange:e=>m({color:e,foregroundColor:e}),onIconChange:e=>m({icon:e})}),a.createElement(ik,null,a.createElement(Lb,null,"Year"),a.createElement(bb,{value:null!==(t=u.startYear)&&void 0!==t?t:s.startYear,onChange:e=>m({startYear:e})})),a.createElement(ik,null,a.createElement(Lb,null,"Years of child expenses"),a.createElement(fe._CU,Object.assign({name:"yearsOfChildcare",value:null!==(n=u.yearsOfChildcare)&&void 0!==n?n:null,min:0,locale:"en-US",format:{maximumFractionDigits:0,useGrouping:!1},onValueChange:e=>m({yearsOfChildcare:ok(null!==e&&void 0!==e?e:void 0)})},(0,Ex.p)("numeric-input"))),a.createElement(Ob,null,"An existing child? Enter remaining years of child expenses. Remove it from your living expenses to avoid double-counting."," ",a.createElement(Bb,{href:"https://help.monarch.c
1om/hc/en-us/articles/48344305092244-Forecasting-in-Monarch#:~:text=How%20do%20I%20model%20expenses%20for%20a%20child%20I%20already%20have%3F"},"Learn more"))),a.createElement("div",{className:"flex flex-col rounded-md border border-border-primary"},a.createElement("div",{className:"flex flex-col gap-xl p-default"},a.createElement(ik,null,a.createElement(Lb,null,"Yearly child expenses"),a.createElement(fe.K$5,{name:"yearlyChildExpenses",value:u.yearlyChildExpenses,onValueChange:e=>m({yearlyChildExpenses:null!==e&&void 0!==e?e:0}),precision:0,onFocus:(0,ix.s)(u.yearlyChildExpenses)}),a.createElement(KA,{todaysDollarsValue:u.yearlyChildExpenses,effectiveYear:g,verb:"startAt"}),a.createElement(Ob,null,"Includes childcare, food, clothing, healthcare, education, and other expenses."," ",a.createElement(Bb,{href:ah},"Learn more"))),a.createElement(Jw,{growthType:u.growthType,growthRate:null!==(l=u.growthRate)&&void 0!==l?l:void 0,inflationRate:s.inflationRate,onGrowthTypeChange:e=>m({growthType:e}),onGrowthRateChange:e=>m({growthRate:e})}))),a.createElement(ik,null,a.createElement(Lb,null,"Upfront child costs"),a.createElement(fe.K$5,{name:"upfrontChildCosts",value:u.upfrontChildCosts,onValueChange:e=>m({upfrontChildCosts:null!==e&&void 0!==e?e:0}),precision:0,onFocus:(0,ix.s)(u.upfrontChildCosts)}),a.createElement(KA,{todaysDollarsValue:u.upfrontChildCosts,effectiveYear:g,verb:"equal"}),a.createElement(Ob,null,"One-time costs for child birth, adoption, family leave, and other setup expenses."," ",a.createElement(Bb,{href:ah},"Learn more")))))},ok=e=>Math.min(50,Math.max(1,Math.round(null!==e&&void 0!==e?e:0))),ik=$d.s.div(lk||(lk=(0,wc.A)(["flex flex-col gap-xs"])));var sk;const ck=e=>{let t=e.incomeEventId;const n=qE(),l=vy().openEvent,r=(null!==n&&void 0!==n?n:[]).filter((e=>dk(e,t)));return 0===r.length?null:a.createElement(uk,{"data-external-id":"events-affecting-income"},a.createElement(Lb,null,"Events that affect income"),a.createElement(Ob,null,"Events that increase or reduce income from this source are listed below."," ",a.createElement(Bb,{href:nh},"Learn more")),r.map((e=>{var t;const n=Rg[e.eventKind];return a.createElement(lx,{key:e.id,icon:e.icon,color:e.color,foregroundColor:null!==(t=e.foregroundColor)&&void 0!==t?t:null===n||void 0===n?void 0:n.foregroundColor,name:e.name,onClick:()=>l(e.id)})})))},dk=(e,t)=>!!Hp(e.eventKind)&&(!(!("incomeReductionTargets"in e)||!Array.isArray(e.incomeReductionTargets))&&e.incomeReductionTargets.some((e=>e.targetEventId===t&&e.reductionPercent>0))),uk=$d.s.div(sk||(sk=(0,wc.A)(["flex flex-col gap-xs"]))),mk={maximumFractionDigits:0,useGrouping:!1},pk=e=>{let t=e.value,n=e.onChange;return a.createElement("div",{"data-external-id":"interval-years-section",className:"flex flex-col gap-xs"},a.createElement(Lb,null,"Repeat every (years)"),a.createElement(fe._CU,Object.assign({name:"intervalYears",value:mg(t),min:0,locale:"en-US",format:mk,onValueChange:e=>n(mg(e))},(0,Ex.p)("numeric-input"))))},gk=u.default.div.withConfig({displayName:"SidebarSectionCard",componentId:"sc-1p4tvg1-0"})(["display:flex;flex-direction:column;gap:",";padding:",";border:1px solid ",";border-radius:",";background:",";"],vt.YK.default,vt.YK.default,vt.Ee.color.border.primary,vt.r8.medium,vt.Ee.color.background.primary);var hk;const vk=()=>{var e;const t=vy(),n=t.closeSidebar,l=t.toggleAssumptions,r=t.openEvent,o=t.id,i=hy(),s=QE(),c=ny(),d=wE((e=>e.updateEvent)),u=wE((e=>e.removeEvent)),m=ZE(),p=JE(o,"income"),g=(0,a.useMemo)((()=>m.map((e=>({value:e.id,label:e.name})))),[m]),h=(0,a.useMemo)((()=>{var e;return null!==(e=g.find((e=>e.value===o)))&&void 0!==e?e:g[0]}),[g,o]),v=(0,a.useCallback)((e=>{r(e)}),[r]),f=(0,a.useCallback)((e=>{o&&d(o,e)}),[o,d]),E=(0,a.useCallback)((()=>{o&&(u(o),n())}),[o,u,n]),y=(0,a.useCallback)((e=>f({growthRate:e})),[f]),b=(0,a.useCallback)((()=>a.createElement(Ji.SP,null,a.createElement(Ji.xm,{className:"text-content-danger",icon:"trash",onClick:E},"Delete income source"))),[E]);if(!p)return null;const x=m.length<=1;return a.createElement(Sb,{"data-external-id":"current-income-sidebar"},a.createElement(Tb,null,a.createElement(fe.SO$,{variant:"outline",onClick:l,"aria-label":"Back"},a.createElement(fe.qzE,null)),a.createElement(fe.hGA,{placeholder:fe.L2e,size:"sm",name:"incomeSource",value:null===h||void 0===h?void 0:h.value,options:g,onValueChange:v,classNames:{trigger:"min-w-0 flex-1"}}),!x&&a.createElement(Qi.Az,{placement:"bottom-end",overlay:b},(e=>{let t=e.toggleOpen,n=e.isOpen;return a.createElement(fe.SO$,{variant:"outline",onClick:t,"aria-label":"More options","data-
1pressed":n||void 0},a.createElement(fe.V_g,null))})),a.createElement(fe.TU1,{variant:"outline",onClick:n,"aria-label":"Close sidebar"})),a.createElement(_b,null,a.createElement(zA,{icon:p.icon,color:p.color,foregroundColor:p.foregroundColor,name:p.name,onNameChange:e=>f({name:e}),renderIcon:a.createElement(Wl._,{url:null,size:36})}),c&&a.createElement(fk,null,a.createElement(Lb,null,"Owner"),a.createElement(fe.hGA,{name:"ownerId",value:p.ownerId,options:i,onValueChange:e=>{f({ownerId:e})},placeholder:"Select owner"})),a.createElement(fk,null,a.createElement(Lb,null,_t.Et.ASSUMPTIONS.YEARLY_TAKE_HOME_INCOME_LABEL),a.createElement(fe.K$5,{name:"amount",value:p.amount,onValueChange:e=>f({amount:null!==e&&void 0!==e?e:0}),precision:0,onFocus:(0,ix.s)(p.amount)}),a.createElement(xt.v,{size:"small",color:"content.secondary"},_t.Et.ASSUMPTIONS.YEARLY_TAKE_HOME_INCOME_HELPER_TEXT)),a.createElement(Jw,{growthType:p.growthType,growthRate:null!==(e=p.growthRate)&&void 0!==e?e:void 0,inflationRate:s.inflationRate,onGrowthTypeChange:e=>f({growthType:e}),onGrowthRateChange:y}),a.createElement(ck,{incomeEventId:p.id}),a.createElement(Pb,{label:"Exclude from forecast",subtext:"This will exclude the income source from your Forecast calculations",checked:!p.isIncluded,onChange:()=>f({isIncluded:!p.isIncluded})})))},fk=$d.s.div(hk||(hk=(0,wc.A)(["flex flex-col gap-xs"])));var Ek;const yk=["once","yearly"],bk=()=>{var e,t,n,l;const r=vy(),i=r.closeSidebar,s=r.id,c=hy(),d=QE(),u=ny(),m=wE((e=>e.updateEvent)),p=wE((e=>e.removeEvent)),g=JE(s,"income"),h=(0,a.useState)(null!==(e=null===g||void 0===g?void 0:g.frequency)&&void 0!==e?e:"yearly"),v=(0,o.A)(h,2),f=v[0],E=v[1];(0,a.useEffect)((()=>{var e;g&&E(null!==(e=g.frequency)&&void 0!==e?e:"yearly")}),[g]);const y=(0,a.useCallback)((e=>{s&&m(s,e)}),[s,m]),b=(0,a.useCallback)((e=>{const t=yk[e];E(t),y((0,U.A)((0,U.A)({frequency:t,endYear:void 0},pg(t,null===g||void 0===g?void 0:g.intervalYears)),"once"===t&&{growthType:"inflation",growthRate:void 0}))}),[null===g||void 0===g?void 0:g.intervalYears,y]),x=yk.indexOf(f),w=(0,a.useCallback)((()=>{s&&(p(s),i())}),[s,p,i]);if(null!==g&&void 0!==g&&g.isHidden)return a.createElement(vk,{"data-external-id":"income-sidebar"});if(!g)return null;const C="once"===f?"Income amount":"Yearly income amount",A=null!==(t=g.startYear)&&void 0!==t?t:d.startYear;return a.createElement(Nb,{"data-external-id":"income-sidebar",$color:g.color},a.createElement(YA,{isIncluded:g.isIncluded,isRequired:g.isRequired,onIsIncludedChange:e=>y({isIncluded:e}),onDelete:w}),a.createElement(_b,null,a.createElement(zA,{icon:g.icon,color:g.color,foregroundColor:g.foregroundColor,name:g.name,onNameChange:e=>y({name:e}),onColorChange:e=>y({color:e,foregroundColor:e}),onIconChange:e=>y({icon:e})}),u&&a.createElement(xk,null,a.createElement(Lb,null,"Owner"),a.createElement(fe.hGA,{name:"ownerId",value:g.ownerId,options:c,onValueChange:e=>{y({ownerId:e})},placeholder:"Select owner"})),a.createElement(xk,null,a.createElement(Lb,null,"Year"),a.createElement(bb,{value:A,onChange:e=>y({startYear:e})})),a.createElement(gk,null,a.createElement(Dc.t,{index:x,onChangeIndex:b},a.createElement(MA.c,null,a.createElement(RA.Q,{index:0,$background:"card"},"One-time"),a.createElement(RA.Q,{index:1,$background:"card"},"Recurring"))),a.createElement(xk,null,a.createElement(Lb,null,C),a.createElement(fe.K$5,{name:"amount",value:g.amount,onValueChange:e=>y({amount:null!==e&&void 0!==e?e:0}),precision:0,onFocus:(0,ix.s)(g.amount)}),a.createElement(KA,{todaysDollarsValue:g.amount,effectiveYear:A,verb:"once"===f?"equal":"startAt"})),"yearly"===f&&a.createElement(a.Fragment,null,a.createElement(pk,{value:g.intervalYears,onChange:e=>y({intervalYears:e})}),a.createElement(xk,null,a.createElement(Lb,null,"End year ",a.createElement("span",{className:"font-book text-content-secondary"},"(optional)")),a.createElement(bb,{value:null!==(n=g.endYear)&&void 0!==n?n:0,onChange:e=>y({endYear:e}),onClear:()=>y({endYear:void 0}),placeholder:"Select end year",minYear:A+1,referenceYear:A})),a.createElement(Jw,{growthType:g.growthType,growthRate:null!==(l=g.growthRate)&&void 0!==l?l:void 0,inflationRate:d.inflationRate,onGrowthTypeChange:e=>y({growthType:e}),onGrowthRateChange:e=>y({growthRate:e})}))),a.createElement(ck,{incomeEventId:g.id})))},xk=$d.s.div(Ek||(Ek=(0,wc.A)(["flex flex-col gap-xs"])));var wk;const Ck=()=>{var e,t,n,l,r;const o=vy(),i=o.closeSidebar,s=o.id,c=hy(),d=QE(),u=ny(),m=wE((e=>e.updateEvent)),p=wE((e=>e.removeEvent)),g=JE(s,"newJob"),h=(0,a.useCallback)((e=>{s&&m(s,e)}),[s,m]),v=(0,a.useCallback)((()=>{s&&(p(s),i())}),[s,p,i]);if(!g)return null;const f=d.participants.find((e=>e.userId===g.ownerId)),E=null!==(e=g.startYear)&&void 0!==e?e:d.startYear;return a.createElement(Nb,{"data-external-id":"new-job-sidebar",$color:g.color},a.createElement(YA,{isIncluded:g.isIncluded,isRequired:g.isRequired,onIsIncludedChange:e=>h({isIncluded:e}),onDelete:v}),a.createElement(_b,null,a.createElement(zA,{icon:g.icon,color:g.color,foregroundColor:g.foregroundColor,name:g.name,onNameChange:e=>h({name:e}),onColorChange:e=>h({color:e,foregroundColor:e}),onIconChange:e=>h({icon:e})}),u&&a.createElement(Ak,null,a.createElement(Lb,null,"Event owner"),a.createElement(fe.hGA,{name:"ownerId",value:g.ownerId,options:c,onValueChange:e=>{var t;const n=null!==(t=wE.getState().events)&&void 0!==t?t:[];h(ag(n,g.id,e))},placeholder:"Select owner"})),a.createElement(Ak,null,a.createElement(Lb,null,"Year"),a.createElement(bb,{value:null!==(t=g.startYear)&&void 0!==t?t:void 0,onChange:e=>h({startYear:e}),birthday:null===f||void 0===f?void 0:f.birthday})),a.createElement("div",{className:"flex flex-col rounded-md border border-border-primary"},a.createElement("div",{className:"flex flex-col gap-xl p-default"},a.createElement(Ak,null,a.createElement(Lb,null,"Yearly take-home income"),a.createElement(fe.K$5,{name:"yearlyTakeHomeIncome",value:g.yearlyTakeHomeIncome,onValueChange:e=>h({yearlyTakeHomeIncome:null!==e&&void 0!==e?e:0}),precision:0,onFocus:(0,ix.s)(g.yearlyTakeHomeIncome)}),a.createElement(KA,{todaysDollarsValue:g.yearlyTakeHomeIncome,effectiveYear:E,verb:"startAt"})),a.createElement(Jw,{growthType:g.growthType,growthRate:null!==(n=g.growthRate)&&void 0!==n?n:void 0,inflationRate:d.inflationRate,onGrowthTypeChange:e=>h({growthType:e}),onGrowthRateChange:e=>h({growthRate:e})}))),a.createElement(Ak,null,a.createElement(Lb,null,"Signing bonus"),a.createElement(fe.K$5,{name:"signingBonus",value:g.signingBonus,onValueChange:e=>h({signingBonus:null!==e&&void 0!==e?e:0}),precision:0,onFocus:(0,ix.s)(g.signingBonus)}),a.createElement(Ob,null,"One-time income from signing bonuses, etc."),a.createElement(KA,{todaysDollarsValue:g.signingBonus,effectiveYear:E,verb:"equal"})),a.createElement(sI,{ownerId:g.ownerId,targets:null!==(l=g.incomeReductionTargets)&&void 0!==l?l:[],onChange:e=>h({incomeReductionTargets:e}),eventId:g.id,eventStartYear:null!==(r=g.startYear)&&void 0!==r?r:void 0,eventKind:"newJob"})))},Ak=$d.s.div(wk||(wk=(0,wc.A)(["flex flex-col gap-xs"])));var Ik;const kk=["once","yearly"],Sk=()=>{var e,t,n,l;const r=vy(),i=r.closeSidebar,s=r.id,c=QE(),d=wE((e=>e.updateEvent)),u=wE((e=>e.removeEvent)),m=JE(s,"otherExpense"),p=(0,a.useState)(null!==(e=null===m||void 0===m?void 0:m.frequency)&&void 0!==e?e:"once"),g=(0,o.A)(p,2),h=g[0],v=g[1];(0,a.useEffect)((()=>{var e;m&&v(null!==(e=m.frequency)&&void 0!==e?e:"once")}),[m]);const f=(0,a.useCallback)((e=>{s&&d(s,e)}),[s,d]),E=(0,a.useCallback)((e=>{const t=kk[e];v(t),f((0,U.A)((0,U.A)({frequency:t,endYear:void 0},pg(t,null===m||void 0===m?void 0:m.intervalYears)),"once"===t&&{growthType:"inflation",growthRate:void 0}))}),[null===m||void 0===m?void 0:m.intervalYears,f]),y=kk.indexOf(h),b=(0,a.useCallback)((()=>{s&&(u(s),i())}),[s,u,i]);if(!m)return null;const x="once"===h?"Expense amount":"Yearly expense amount",w=null!==(t=m.startYear)&&void 0!==t?t:c.startYear;return a.createElement(Nb,{"data-external-id":"other-expense-sidebar",$color:m.color},a.createElement(YA,{isIncluded:m.isIncluded,isRequired:m.isRequired,onIsIncludedChange:e=>f({isIncluded:e}),onDelete:b}),a.createElement(_b,null,a.createElement(zA,{icon:m.icon,color:m.color,foregroundColor:m.foregroundColor,name:m.name,onNameChange:e=>f({name:e}),onColorChange:e=>f({color:e,foregroundColor:e}),onIconChange:e=>f({icon:e})}),a.createElement(Nk,null,a.createElement(Lb,null,"Year"),a.createElement(bb,{value:w,onChange:e=>f({startYear:e})})),a.createElement(gk,null,a.createElement(Dc.t,{index:y,onChangeIndex:E},a.createElement(MA.c,null,a.createElement(RA.Q,{index:0,$background:"card"},"One-time"),a.createElement(RA.Q,{index:1,$background:"card"},"Recurring"))),a.createElement(Nk,null,a.createElement(Lb,null,x),a.createElement(fe.K$5,{name:"amount",value:m.amount,onValueChange:e=>f({amount:null!==e&&void 0!==e?e:0}),precision:0,onFocus:(0,ix.s)(m.amount)}),a.createElement(KA,{todaysDollarsValue:m.amount,effectiveYear:w,verb:"once"===h?"equal":"startAt"})),"yearly"===h&&a.createElement(a.Fragment,null,a.createElement(pk,{value:m.intervalYears,onChange:e=>f({intervalYears:e})}),a.createElement(Nk,null,a.createElement(Lb,null,"End year ",a.createElement("span",{className:"font-book text-content-secondary"},"(optional)")),a.createElement(bb,{value:null!==(n=m.endYear)&&void 0!==n?n:0,onChange:e=>f({endYear:e}),onClear:()=>f({endYear:void 0}),placeholder:"Select end year",minYear:w+1,referenceYear:w})),a.createElement(Jw,{growthType:m.growthType,growthRate:null!==(l=m.growthRate)&&void 0!==l?l:void 0,inflationRate:c.inflationRate,onGrowthTypeChange:e=>f({growthType:e}),onGrowthRateChange:e=>f({growthRate:e})})))))},Nk=$d.s.div(Ik||(Ik=(0,wc.A)(["flex flex-col gap-xs"])));var Tk,_k;const Dk=()=>{var e,t,n,l,r;const o=vy(),i=o.closeSidebar,s=o.id,c=hy(),d=QE(),u=ny(),m=wE((e=>e.updateEvent)),p=wE((e=>e.removeEvent)),g=JE(s,"retirement"),h=(0,a.useCallback)((e=>{s&&m(s,e)}),[s,m]),v=(0,a.useCallback)((()=>{s&&(p(s),i())}),[s,p,i]);if(!g)return null;const f=null!==(e=g.startYear)&&void 0!==e?e:d.startYear,E=d.participants.find((e=>e.userId===g.ownerId));return a.createElement(Nb,{"data-external-id":"retire-sidebar",$color:g.color},a.createElement(YA,{isIncluded:g.isIncluded,isRequired:g.isRequired,onIsIncludedChange:e=>h({isIncluded:e}),onDelete:v}),a.createElement(_b,null,a.createElement(zA,{icon:g.icon,color:g.color,foregroundColor:g.foregroundColor,name:g.name,onNameChange:e=>h({name:e}),onColorChange:e=>h({color:e,foregroundColor:e}),onIconChange:e=>h({icon:e})}),u&&a.createElement(Rk,null,a.createElement(Lb,null,"Event owner"),a.createElement(fe.hGA,{name:"ownerId",value:g.ownerId,options:c,onValueChange:e=>{var t;const n=null!==(t=wE.getState().events)&&void 0!==t?t:[];h(ag(n,g.id,e))},placeholder:"Select owner"})),a.createElement(Rk,null,a.createElement(Lb,null,"Year"),a.createElement(bb,{value:null!==(t=g.startYear)&&void 0!==t?t:void 0,onChange:e=>h({startYear:e}),birthday:null===E||void 0===E?void 0:E.birthday})),a.createElement(Rk,null,a.createElement(Lb,null,"Living expenses"),a.createElement(Ob,null,"How much you expect your yearly spending to change after you retire."," ",a.createElement(Bb,{href:nh},"Learn more")),a.createElement(wy,{value:g.expenseMultiplier,onCh
1ange:e=>h({expenseMultiplier:null!==e&&void 0!==e?e:0}),min:.5,max:1.5,step:.05},a.createElement(Cy,{$rightColumnWidth:My},a.createElement(Iy,null),a.createElement(Ly,{name:"expenseMultiplier",formatValue:mI,parseValue:pI,min:0,max:3,step:1e-4,textAlign:"right"}),a.createElement(Mk,null,a.createElement("span",null,"Spend less"),a.createElement("span",null,"\u2022"),a.createElement("span",null,"Spend more"))))),a.createElement(gk,null,a.createElement(Rk,null,a.createElement(Lb,null,"Additional yearly expenses"),a.createElement(fe.K$5,{name:"additionalYearlyExpenses",value:g.additionalYearlyExpenses,onValueChange:e=>h({additionalYearlyExpenses:null!==e&&void 0!==e?e:0}),precision:0,onFocus:(0,ix.s)(g.additionalYearlyExpenses)}),a.createElement(KA,{todaysDollarsValue:g.additionalYearlyExpenses,effectiveYear:f,verb:"startAt"}),a.createElement(Ob,null,"Allowance for out-of-pocket expenses like healthcare."," ",a.createElement(Bb,{href:nh},"Learn more"))),a.createElement(Jw,{growthType:g.growthType,growthRate:null!==(n=g.growthRate)&&void 0!==n?n:void 0,inflationRate:d.inflationRate,onGrowthTypeChange:e=>h({growthType:e}),onGrowthRateChange:e=>h({growthRate:e})})),a.createElement(sI,{ownerId:g.ownerId,targets:null!==(l=g.incomeReductionTargets)&&void 0!==l?l:[],onChange:e=>h({incomeReductionTargets:e}),eventId:g.id,eventStartYear:null!==(r=g.startYear)&&void 0!==r?r:void 0,learnMoreUrl:nh,eventKind:"retirement"})))},Rk=$d.s.div(Tk||(Tk=(0,wc.A)(["flex flex-col gap-xs"]))),Mk=$d.s.div(_k||(_k=(0,wc.A)(["\n  col-start-1 -mt-xs grid grid-cols-[1fr_auto_1fr] items-center text-xs text-content-secondary\n  [&>span:first-child]:text-left\n  [&>span:last-child]:text-right\n  [&>span:nth-child(2)]:text-center\n"])));var Lk;const Ok=()=>{var e,t,n,l,r;const o=vy(),i=o.closeSidebar,s=o.id,c=hy(),d=QE(),u=ny(),m=wE((e=>e.updateEvent)),p=wE((e=>e.removeEvent)),g=JE(s,"socialSecurity"),h=(0,a.useCallback)((e=>{s&&m(s,e)}),[s,m]),v=(0,a.useCallback)((()=>{s&&(p(s),i())}),[s,p,i]);if(!g)return null;const f=null!==(e=g.startYear)&&void 0!==e?e:d.startYear,E=d.participants.find((e=>e.userId===g.ownerId));return a.createElement(Nb,{"data-external-id":"social-security-sidebar",$color:g.color},a.createElement(YA,{isIncluded:g.isIncluded,isRequired:g.isRequired,onIsIncludedChange:e=>h({isIncluded:e}),onDelete:v}),a.createElement(_b,null,a.createElement(zA,{icon:g.icon,color:g.color,foregroundColor:g.foregroundColor,name:g.name,onNameChange:e=>h({name:e}),onColorChange:e=>h({color:e,foregroundColor:e}),onIconChange:e=>h({icon:e})}),u&&a.createElement(Pk,null,a.createElement(Lb,null,"Event owner"),a.createElement(fe.hGA,{name:"ownerId",value:g.ownerId,options:c,onValueChange:e=>{h({ownerId:e})},placeholder:"Select owner"})),a.createElement(Pk,null,a.createElement(Lb,null,"Year"),a.createElement(bb,{value:null!==(t=g.startYear)&&void 0!==t?t:void 0,onChange:e=>h({startYear:e}),birthday:null===E||void 0===E?void 0:E.birthday})),a.createElement(Pk,null,a.createElement(Lb,null,"Monthly benefit amount"),a.createElement(fe.K$5,{name:"monthlyBenefitAmount",value:null!==(n=g.monthlyBenefitAmount)&&void 0!==n?n:0,onValueChange:e=>h({monthlyBenefitAmount:null!==e&&void 0!==e?e:0}),precision:0,onFocus:(0,ix.s)(g.monthlyBenefitAmount)}),a.createElement(KA,{todaysDollarsValue:null!==(l=g.monthlyBenefitAmount)&&void 0!==l?l:0,effectiveYear:f,verb:"startAt",perMonth:!0}),a.createElement(Ob,null,"The Social Security Administration has a"," ",a.createElement(Bb,{href:"https://www.ssa.gov/OACT/quickcalc/"},"calculator")," you can use to calculate your benefit amount.")),a.createElement(Jw,{growthType:g.growthType,growthRate:null!==(r=g.growthRate)&&void 0!==r?r:void 0,inflationRate:d.inflationRate,onGrowthTypeChange:e=>h({growthType:e}),onGrowthRateChange:e=>h({growthRate:e})})))},Pk=$d.s.div(Lk||(Lk=(0,wc.A)(["flex flex-col gap-xs"])));var Bk=n(66454),zk=n(49642),Fk=n(35337);const Gk=(0,u.default)(m.g).withConfig({displayName:"ButtonGroup__DEPRECATEDButtonGroup",componentId:"sc-169sdj3-0"})(["[data-sc-tw~='DefaultButton__DefaultButton']{&:not(:first-child){border-top-left-radius:0;border-bottom-left-radius:0;}&:not(:last-child){border-top-right-radius:0;border-bottom-right-radius:0;}:first-child:not(:only-child){border-top-right-radius:0;border-bottom-right-radius:0;}:last-child:not(:only-child){border-top-left-radius:0;border-bottom-left-radius:0;}:not(:first-child):not(:only-child){margin-left:-1px;}}"]),Yk=[{title:"%",value:"percent"},{title:"$",value:"dollarAmount"}],Uk=e=>{var t,n,l,r,o,i;let s=e.account,c=e.entry,d=e.onAllocationChange,u=e.onClick,p=e.isFirst,g=e.simulationValue;return a.createElement(m.g,{"data-external-id":"account-split-item",flex:1,role:"button",column:!0,gap:"xsmall",minWidth:0,onClick:u},a.createElement(m.g,{alignCenter:!0,gap:"xsmall"},a.createElement(_w,{logoUrl:null===(t=s.metadata)||void 0===t?void 0:t.logoUrl,icon:null===(n=s.metadata)||void 0===n?void 0:n.icon,sourceEventExternalId:s.sourceEventExternalId,size:32}),a.createElement(m.g,{column:!0,justifyCenter:!0,flex:1,minWidth:0}
1,a.createElement(xt.v,{clampLines:1,title:s.name},s.name),a.createElement(xt.v,{size:"small",color:"content.secondary",clampLines:1,title:(null===(l=s.metadata)||void 0===l?void 0:l.subtypeDisplay)||void 0},null!==(r=null===(o=s.metadata)||void 0===o?void 0:o.subtypeDisplay)&&void 0!==r?r:""))),a.createElement(m.g,{alignCenter:!0,gap:"xsmall",onClick:e=>e.stopPropagation()},"percent"===c.type?a.createElement(fe._CU.Root,{value:null!==(i=c.amount)&&void 0!==i?i:null,min:0,step:"any",locale:"en-US",format:Ug,onValueChange:e=>d((0,U.A)((0,U.A)({},c),{},{type:"percent",amount:Math.max(0,null!==e&&void 0!==e?e:0)}))},a.createElement(fe.i9A,{className:"h-8 w-25"},a.createElement(fe._CU.Input,Object.assign({name:"allocation-percent-".concat(s.id),placeholder:"0"},(0,Ex.p)("numeric-input"))),a.createElement(fe.i9A.Addon,{align:"content-end"},a.createElement(fe.i9A.Text,null,"%")))):a.createElement(fe.K$5.Root,{value:c.amount,min:0,format:{maximumFractionDigits:0},onValueChange:e=>d((0,U.A)((0,U.A)({},c),{},{type:"dollarAmount",amount:Math.max(0,null!==e&&void 0!==e?e:0)}))},a.createElement(fe.i9A,{className:"h-8 w-25"},a.createElement(fe.K$5.Input,{name:"allocation-".concat(s.id),placeholder:"$",onFocus:(0,ix.s)(c.amount)}))),a.createElement(Gk,null,Yk.map((e=>a.createElement(wt.Xb,{key:e.value,onClick:()=>d((0,U.A)((0,U.A)({},c),{},{type:e.value})),active:c.type===e.value,size:"xsmall"},e.title)))),"percent"===c.type&&!p&&void 0===g&&a.createElement(xt.v,{size:"xsmall",color:"content.secondary"},"of remainder"),void 0!==g&&a.createElement(Oc.D,{color:"blue",variant:"subtle"},"= ",(0,rl.T3)(g))))},Vk=e=>{let t=e.accountName,n=e.onClick,l=e.simulationValue;return a.createElement(Wk,{"data-external-id":"uncategorized-savings-row",role:"button",onClick:n},a.createElement(xt.v,{italic:!0,color:"content.secondary"},t),a.createElement(m.g,{alignCenter:!0,gap:"xsmall"},a.createElement(m.g,{alignCenter:!0,backgroundColor:"input.disabled.background",border:"1px solid input.disabled.border",paddingVertical:"xxsmall",paddingHorizontal:"small",borderRadius:"small",maxWidth:150},a.createElement(xt.v,{color:"input.disabled.text"},"Remainder")),void 0!==l&&a.createElement(Oc.D,{color:"blue",variant:"subtle"},"= ",(0,rl.T3)(l))))},Wk=(0,u.default)(m.g).attrs({column:!0,paddingHorizontal:"default",paddingVertical:"xsmall",gap:"xsmall",border:"1px solid border.primary",borderRadius:"default",backgroundColor:"background.primary"}).withConfig({displayName:"UncategorizedSavingsRow__StyledUncategorizedSavingsRow",componentId:"sc-19c98eg-0"})(["",";cursor:pointer;&:hover{background-color:",";}"],wn.M.medium,vt.Ee.color.background.primaryHover),jk=(e,t)=>{const n=e.getBoundingClientRect(),a=t.getBoundingClientRect(),l=t.scrollTop+n.top-a.top+n.height/2-t.clientHeight/2,r=Math.max(0,t.scrollHeight-t.clientHeight),o=Math.min(Math.max(0,l),r);t.scrollTo({top:o,behavior:"smooth"})};var Hk=n(61884),Kk=n(20587);const qk=e=>{let t=e.scrollContainerRef,n=e.highlightedAccountId;const l=vy().openAccount,r=QE(),i=wE((e=>e.householdUserIds)),s=dy(),c=(0,a.useMemo)((()=>s.filter((e=>!_p(e)))),[s]),d=(0,a.useMemo)((()=>s.find(_p)),[s]),u=oy(),m=(0,a.useMemo)((()=>Object.fromEntries(u.map((e=>[e.accountId,e])))),[u]),p=wE((e=>e.setUncategorizedSavingsAllocation)),g=(0,a.useState)(!1),h=(0,o.A)(g,2),v=h[0],f=h[1],E=(0,a.useState)(1e4),y=(0,o.A)(E,2),b=y[0],x=y[1],w=(0,a.useRef)(null),C=(0,Bk.FR)((0,Bk.MS)(Bk.AN),(0,Bk.MS)(Bk.uN,{coordinateGetter:Fk.JR})),A=(0,a.useMemo)((()=>c.map((e=>e.id))),[c]);(e=>{let t=e.highlightedAccountId,n=e.scrollContainerRef,l=e.accountIds;const r=(0,a.useRef)(void 0);(0,a.useEffect)((()=>{var e,a;if(!t)return void(r.current=void 0);if(r.current===t)return;if(!l.includes(t))return;const o=(null!==(e=null===n||void 0===n?void 0:n.current)&&void 0!==e?e:document).querySelector('[data-account-id="'.concat(CSS.escape(t),'"]'));if(!o)return;const i=null!==(a=null===n||void 0===n?void 0:n.current)&&void 0!==a?a:null;i&&jk(o,i);const s=o.querySelector('input[name^="allocation-"]');(null!==s&&void 0!==s?s:o).focus({preventScroll:!0}),r.current=t}),[t,n,l])})({highlightedAccountId:n,scrollContainerRef:t,accountIds:A});const I=(0,a.useCallback)((e=>{const t=e.active,n=e.over;
1if(t&&n&&t.id!==n.id){const e=c.findIndex((e=>e.id===t.id)),a=c.findIndex((e=>e.id===n.id));if(-1===e||-1===a)return;const l=(0,Fk.be)(c,e,a).map((e=>{var t;return null!==(t=m[e.id])&&void 0!==t?t:$k(e.id)}));p(l)}}),[c,m,p]),k=(0,a.useCallback)(((e,t)=>{const n=(0,U.A)((0,U.A)({},t),{},{accountId:e}),a=m[e]?u.map((t=>t.accountId===e?n:t)):[...u,n];p(a)}),[u,m,p]),S=(0,a.useMemo)((()=>{if(!v)return{};const e=c.filter((e=>e.isIncluded&&kv({account:e,settings:r,householdUserIds:i}))).map((e=>{var t;return null!==(t=m[e.id])&&void 0!==t?t:$k(e.id)})),t=Zh(e,b,{inflateDollarAmountsToYear:{year:r.startYear,settings:r}}),n=t.allocations,a=t.remaining;return d?(0,U.A)((0,U.A)({},n),{},{[d.id]:Math.max(0,a)}):n}),[v,b,c,m,d,r,i]);return a.createElement("div",{"data-external-id":"account-split-list",className:"flex flex-col gap-default"},a.createElement("div",{className:"flex flex-col gap-xs"},a.createElement(fe.c8D,{size:"sm",color:"secondary"},"Amounts shown are in today\u2019s dollars and grow with inflation over time. Savings are allocated top to bottom. Each account draws from what remains."," ",a.createElement(fe.XZZ,{type:"button",variant:"text",colorScheme:"link",size:"sm",className:"inline h-auto p-0 align-baseline text-[length:inherit]",onClick:()=>f((e=>!e))},v?"Hide":"Show"," example")),v&&a.createElement(fe.K$5,{ref:w,className:"w-full",size:"sm",name:"simulation-amount",value:b,onValueChange:e=>x(Math.max(0,null!==e&&void 0!==e?e:0)),onFocus:()=>{var e;0===b&&(null===(e=w.current)||void 0===e||e.selectAll())}})),a.createElement(Bk.Mp,{sensors:C,collisionDetection:Bk.fp,onDragEnd:I,modifiers:[zk.FN],autoScroll:t?{order:Bk.HC.ReversedTreeOrder,canScroll:e=>e===t.current}:void 0},a.createElement(Fk.gB,{items:A,strategy:Fk._G},c.map(((e,t)=>{var n;return a.createElement(Hk.U,{key:e.id,id:e.id,"data-account-id":e.id,tabIndex:-1,className:(0,q.cn)("\n                  flex cursor-pointer scroll-mt-2 scroll-mb-20 flex-row items-center rounded-default\n                  border border-border-primary bg-background-primary py-sm pr-default pl-0 text-left\n                  shadow-card\n                  hover:bg-background-primary-hover\n                  focus-visible:border-input-focus-border\n                  focus-visible:shadow-[0_0_0_2px_var(--color-input-focus-border)]\n                  focus-visible:outline-none\n                "),handle:a.createElement("div",{role:"button","data-sortable-item-handle":!0,"aria-label":"Drag to reorder",className:"flex shrink-0 cursor-grab items-center justify-center p-default"},a.createElement(Kk.P,null))},a.createElement(Uk,{account:e,entry:null!==(n=m[e.id])&&void 0!==n?n:$k(e.id),onAllocationChange:t=>k(e.id,t),onClick:()=>l(e.id),isFirst:0===t,simulationValue:S[e.id]}))})))),d&&a.createElement(Vk,{accountName:d.name,onClick:()=>l(d.id),simulationValue:S[d.id]}))},$k=e=>({accountId:e,type:"percent",amount:0}),Zk={cash:{label:"Cash",icon:"dollar-sign"},"taxable-investments":{label:"Taxable Investments",icon:"trending-up"},"tax-deferred":{label:"Tax-deferred Investments",icon:"trending-up"},"tax-free-investments":{label:"Tax-free Investments",icon:"trending-up"},"real-estate":{label:"Real Estate",icon:"home"},"uncategorized-savings":{label:"Extra Savings",icon:"grid"},other:{label:"Other",icon:"dollar-sign"},"credit-cards":{label:"Credit Cards",icon:"credit-card"},loans:{label:"Loans",icon:"trending-down"},"unfunded-expenses":{label:"Shortfall",icon:"alert-circle"},"other-liability":{label:"Other",icon:"dollar-sign"}},Jk=["cash","taxable-investments","tax-deferred","tax-free-investments","real-estate","uncategorized-savings","other"],Xk=new Set(["uncategorized-savings","unfunded-expenses"]),Qk=["credit-cards","loans","unfunded-expenses","other-liability"],eS=()=>{const e=vy(),t=e.closeSidebar,n=e.openedSidebarDetails,r=(0,l.Zp)(),o=ry(),i=wE((e=>e.setSplitUncategorizedSavings)),s=(0,a.useRef)(null),c="uncategorized-savings"===(null===n||void 0===n?void 0:n.type)?n.accountId:void 0;return a.createElement(Sb,{"data-external-id":"uncategorized-savings-sidebar"},a.createElement(Tb,null,a.createElement(fe.SO$,{variant:"outline",onClick:()=>r(-1),"aria-label":"Back"},a.createElement(fe.qzE,null)),a.createElement(nS,null,Zk["uncategorized-savings"].label),a.createElement(fe.TU1,{variant:"outline",onClick:t,"aria-label":"Close sidebar"})),a.createElement(_b,{ref:s},a.createElement(tS,{label:Lg,subtext:a.createElement(a.Fragment,null,"When you're forecasted to earn more than you spend, you can distribute savings across accounts."," ",a.createElement(Bb,{href:rh},"Learn more")),checked:o,onChange:()=>i(!o)}),o&&a.createElement(qk,{scrollContainerRef:s,highlightedAccountId:c})))},tS=(0,u.default)(Pb).withConfig({displayName:"UncategorizedSavingsSidebar__StyledSidebarToggleWithText",componentId:"sc-1aaf2ls-0"})(["padding:0;border:none;"]),nS=(0,u.default)(Rb).withConfig({displayName:"UncategorizedSavingsSidebar__CenteredTitle",componentId:"sc-1aaf2ls-1"})(["text-align:center;"]);var aS;const lS=()=>{var e;const t=vy(),n=t.closeSidebar,l=t.id,r=QE(),o=wE((e=>e.updateEvent)),i=wE((e=>e.removeEvent)),s=JE(l,"windfall"),c=(0,a.useCallback)((e=>{l&&o(l,e)}),[l,o]),d=(0,a.useCallback)((()=>{l&&(i(l),n())}),[l,i,n]);if(!s)return null;const u=null!==(e=s.startYear)&&void 0!==e?e:r.startYear;return a.createElement(Nb,{"data-external-id":"windfall-sidebar",$color:s.color},a.createElement(YA,{isIncluded:s.isIncluded,isRequired:s.isRequired,onIsIncludedChange:e=>c({isIncluded:e}),onDelete:d}),a.createElement(_b,null,a.createElement(zA,{icon:s.icon,color:s.color,foregroundColor:s.foregroundColor,name:s.name,onNameChange:e=>c({name:e}),onColorChange:e=>c({color:e,foregroundColor:e}),onIconChange:e=>c({icon:e})}),a.createElement(rS,null,a.createElement(Lb,null,"Year"),a.createElement(bb,{value:u,onChange:e=>c({startYear:e})})),a.createElement(rS,null,a.createElement(Lb,null,"Income amount"),a.createElement(fe.K$5,{name:"amount",value:s.amount,onValueChange:e=>c({amount:null!==e&&void 0!==e?e:0}),precision:0,onFocus:(0,ix.s)(s.amount)}),a.createElement(KA,{todaysDollarsValue:s.amount,effectiveYear:u,verb:"equal"}))))}
1,rS=$d.s.div(aS||(aS=(0,wc.A)(["flex flex-col gap-xs"]))),oS=e=>{let t=e.account,n=e.onClick;const l=_p(t),r=!1===t.isIncluded,o=!r&&!Ev(t),i=!r&&!o,s=(0,a.useCallback)((e=>{"Enter"!==e.key&&" "!==e.key||(e.preventDefault(),n())}),[n]);return i?a.createElement(Hk.U,{"data-external-id":"withdrawal-list-item",id:t.rowKey.serialized,className:" flex flex-row items-center rounded-default border border-border-primary bg-background-primary py-sm pr-default pl-0 text-left shadow-md transition hover:bg-background-primary-hover ",handle:a.createElement("div",{role:"button","data-sortable-item-handle":!0,"aria-label":"Drag to reorder",className:"flex shrink-0 cursor-grab items-center justify-center p-default"},a.createElement(Kk.P,null))},a.createElement("div",{role:"button",tabIndex:0,onClick:n,onKeyDown:s,className:"flex min-h-0 min-w-0 flex-1 cursor-pointer items-center gap-xs rounded-sm"},a.createElement(iS,{account:t,isUncategorized:l,isForecastExcluded:!1,isWithdrawalDisabled:!1,onOpenAccountSettings:n}))):a.createElement("div",{"data-external-id":"withdrawal-list-item",role:"button",tabIndex:0,onClick:n,onKeyDown:s,className:" flex w-full cursor-pointer items-center gap-xs rounded-default border border-border-primary bg-background-secondary px-default py-sm text-left shadow-md transition hover:bg-background-secondary-hover "},a.createElement(iS,{account:t,isUncategorized:l,isForecastExcluded:r,isWithdrawalDisabled:o,onOpenAccountSettings:n}))},iS=e=>{var t,n;let l=e.account,r=e.isUncategorized,o=e.isForecastExcluded,i=e.isWithdrawalDisabled,s=e.onOpenAccountSettings;const c=r||o||i?"secondary":"primary";return a.createElement(a.Fragment,null,!r&&a.createElement(_w,{logoUrl:null===(t=l.metadata)||void 0===t?void 0:t.logoUrl,icon:null===(n=l.metadata)||void 0===n?void 0:n.icon,sourceEventExternalId:l.sourceEventExternalId,size:32}),a.createElement("div",{className:"flex min-w-0 flex-1 flex-col justify-center"},a.createElement(fe.c8D,{color:c,className:r?"line-clamp-1 italic":"line-clamp-1",title:l.name},l.name),a.createElement(sS,{account:l,isForecastExcluded:o,isWithdrawalDisabled:i,onOpenAccountSettings:s})))},sS=e=>{var t,n;let l=e.account,r=e.isForecastExcluded,o=e.isWithdrawalDisabled,i=e.onOpenAccountSettings;if(r)return a.createElement(cS,{"data-external-id":"account-subtitle",icon:a.createElement(fe.yhH,{size:"sm",className:"shrink-0 text-content-secondary"}),label:"Excluded from forecast"});if(o)return a.createElement(cS,{"data-external-id":"account-subtitle",icon:a.createElement(fe.sOb,{size:"sm",className:"shrink-0 text-content-secondary"}),label:"Withdrawals disabled",trailing:a.createElement("div",{className:"flex shrink-0 items-center",onClick:e=>e.stopPropagation(),onKeyDown:e=>e.stopPropagation()},a.createElement(fe.cIj,{"aria-label":"Withdrawal timing set to Never",icon:a.createElement(fe.ucZ,{size:"sm",className:"shrink-0 text-content-secondary"}),content:a.createElement(fe.c8D,{size:"sm"},"Funds will never be taken from this account. Change withdrawal timing in"," ",a.createElement("span",{className:"whitespace-nowrap"},a.createElement(fe.XZZ,{variant:"text",colorScheme:"link",size:"xs",className:"inline h-auto px-0",onClick:e=>{e.preventDefault(),e.stopPropagation(),i()}},"account settings"),"."))}))});const s=_p(l)?"Other":null!==(t=null===(n=l.metadata)||void 0===n?void 0:n.subtypeDisplay)&&void 0!==t?t:"";return a.createElement(fe.c8D,{"data-external-id":"account-subtitle",size:"sm",color:"secondary",className:"line-clamp-1",title:s||void 0},s)},cS=e=>{let t=e.icon,n=e.label,l=e.trailing;return a.createElement("div",{"data-external-id":"ineligible-subtitle",className:"flex min-w-0 items-center gap-2xs"},t,a.createElement(fe.c8D,{size:"sm",color:"secondary",className:"line-clamp-1",title:n},n),l)},dS=()=>{const e=(0,l.Zp)(),t=vy(),n=t.closeSidebar,r=t.openAccount,i=cy(),s=wE((e=>e.setCustomWithdrawalOrder)),c=KE(),d=(0,a.useRef)(null),u=(0,Bk.FR)((0,Bk.MS)(Bk.AN),(0,Bk.MS)(Bk.uN,{coordinateGetter:Fk.JR})),m=(0,a.useMemo)((()=>i.map((e=>e.rowKey.serialized))),[i]),p=(0,a.useCallback)((e=>{const t=e.active,n=e.over;
1if(t&&n&&t.id!==n.id){const e=m.indexOf(t.id),a=m.indexOf(n.id);-1!==e&&-1!==a&&s((0,Fk.be)(m,e,a))}}),[m,s]),g=(0,a.useState)(!1),h=(0,o.A)(g,2),v=h[0],f=h[1],E=(0,a.useMemo)((()=>(e=>e.filter((e=>fv(e,(e=>e.accountType))||_p(e))).filter((e=>!e.isIncluded||!Ev(e))).flatMap(bv))(c)),[c]),y=E.length;return a.createElement(Sb,{"data-external-id":"withdrawal-order-sidebar"},a.createElement(Tb,null,a.createElement(fe.SO$,{variant:"outline",onClick:()=>e(-1),"aria-label":"Back"},a.createElement(fe.qzE,null)),a.createElement(Rb,null,"Withdrawal order"),a.createElement(fe.TU1,{variant:"outline",onClick:n,"aria-label":"Close sidebar"})),a.createElement(_b,{ref:d,className:"min-h-0"},a.createElement(fe.c8D,{size:"sm",color:"primary"},"Choose the order in which to use your cash and investments to cover expenses in retirement and other events."," ",a.createElement(Bb,{href:lh},"Learn more")),a.createElement("div",{className:"flex flex-col gap-default"},a.createElement(Bk.Mp,{sensors:u,collisionDetection:Bk.fp,onDragEnd:p,modifiers:[zk.FN],autoScroll:{order:Bk.HC.ReversedTreeOrder,canScroll:e=>e===d.current}},a.createElement(Fk.gB,{items:m,strategy:Fk._G},i.map((e=>a.createElement(oS,{key:e.rowKey.serialized,account:e,onClick:()=>r(e.forecastAccountId)})))))),y>0&&a.createElement(fe.X0s,{open:v,onOpenChange:f,className:"flex shrink-0 flex-col gap-default"},a.createElement(fe.X0s.Trigger,{render:a.createElement(fe.XZZ,{variant:"text",colorScheme:"secondary",size:"sm",className:"justify-start px-2xs py-sm",icon:v?a.createElement(fe.D39,{size:"md"}):a.createElement(fe.hPJ,{size:"md"})},v?"Collapse ".concat(y," ineligible ").concat((0,De.td)("account",y)):"Show ".concat(y," ineligible ").concat((0,De.td)("account",y)))}),a.createElement(fe.X0s.Content,null,a.createElement("div",{className:"flex flex-col gap-default"},E.map((e=>a.createElement(oS,{key:e.rowKey.serialized,account:e,onClick:()=>r(e.forecastAccountId)}))))))))};var uS=n(74298);const mS=e=>{var t,n;let r=e.initState,i=e.isScenarioSwitching,s=void 0!==i&&i;const c=(0,l.g)().scenarioId,d=void 0===c?"":c,u=vy(),p=u.openedSidebarDetails,g=u.closeSidebar,h=wE((e=>e.isCompletingOnboarding)),v=wE((e=>e.settings.participants)),f=null!==(t=null===p||void 0===p?void 0:p.type)&&void 0!==t?t:null,E=JE(p&&"id"in p?p.id:null),y=E&&"ownerId"in E?E.ownerId:void 0,b="event"===f&&y?v.find((e=>e.userId===y&&e.hiddenFromForecast)):void 0,x=(0,a.useRef)(!1);h&&(x.current=!0);const w=x.current&&!f?new URLSearchParams(window.location.search).get("sidebar"):null,C=null!==f&&void 0!==f?f:w,A=(0,a.useRef)(void 0),I=(0,a.useRef)(!1),k=(0,a.useState)(!1),S=(0,o.A)(k,2),N=S[0],T=S[1];if((0,a.useLayoutEffect)((()=>{const e=A.current;void 0!==e&&e!==d&&""!==d&&I.current&&T(!0),A.current=d,I.current=!!C}),[d,C]),(0,a.useEffect)((()=>{N&&(s||T(!1))}),[N,s]),h)return null;const _=!!C||N;x.current&&f&&(x.current=!1);let D=null;if(b)D=a.createElement(pS,{ownerName:b.displayName,onClose:g});else if(C){var R;D=gS(C,null!==(R=null===E||void 0===E?void 0:E.eventKind)&&void 0!==R?R:null)}else N&&(D=a.createElement(ap,null));return a.createElement(hS,{"data-external-id":"detail-sidebar",$isOpen:_,$initState:r},a.createElement(m.g,{column:!0,height:"100%",paddingTop:"zero",paddingRight:"gutter",paddingBottom:"ready"===r?"gutter":"zero",paddingLeft:"zero"},a.createElement(m.g,{column:!0,width:"362px",height:"100%",backgroundColor:"background.primary",borderRadius:"large",overflow:"hidden",border:"1px solid border.primary"},null!==(n=D)&&void 0!==n?n:a.createElement("div",null))))},pS=e=>{let t=e.ownerName,n=e.onClose;const l=vy().openAssumptions;return a.createElement("div",{"data-external-id":"excluded-by-owner-message",className:"flex h-full flex-col"},a.createElement("div",{className:"flex items-center justify-end px-default py-sm"},a.createElement(fe.TU1,{variant:"overlay",onClick:n,"aria-label":"Close sidebar"})),a.createElement("div",{className:"px-xl text-center text-sm text-content-secondary"},t," is excluded from the forecast.",a.createElement("br",null),a.createElement(bn.v,{className:"inline min-h-[unset] p-0 text-[length:inherit]",onClick:l},"Include them")," ","to manage their events."))},gS=(e,t)=>(0,r.YW)(e).with("new-event",(()=>a.createElement(XI,null))).with("event",(()=>{return e=t,(0,r.YW)(e).with(null,"annualExpense",(()=>null)).with("buyAHome",(()=>a.createElement(QA,null))).with("retirement",(()=>a.createElement(Dk,null))).with("socialSecurity",(()=>a.createElement(Ok,null))).with("income",(()=>a.createElement(bk,null))).with("otherExpense",(()=>a.createElement(Sk,null))).with("haveAKid",(()=>a.createElement(rk,null))).with("endOfPlan",(()=>a.createElement(jI,null))).with("careerBreak",(()=>a.createElement(vI,null))).with("newJob",(()=>a.createElement(Ck,null))).with("windfall",(()=>a.createElement(lS,null))).exhaustive();var e})).with("account",(()=>a.createElement(Bw,null))).with("assumptions",(()=>a.createElement(SA,null))).with("chance-of-success",(()=>a.createElement(BI,null))).with("withdrawal-order",(()=>a.createElement(dS,null))).with("uncategorized-savings",(()=>a.createElement(eS,null))).otherwise((()=>null)),hS=u.default.div.withConfig({displayName:"DetailSidebar__SidebarContainer",componentId:"sc-17kabro-0"})(["width:",";height:",";flex-shrink:0;overflow:hidden;transition:",";position:sticky;top:",";"],(e=>e.$isOpen?"378px":"0"),(e=>{let t=e.$initState,n=e.theme;return"needs-onboarding"!==t?"calc(100vh - ".concat(uS.uF,")"):"calc(100vh - 2 * ".concat(n.spacing.gutter,")")}),vt.kY.fast,(e=>{let t=e.$initState,n=e.theme;return"needs-onboarding"!==t?"0":n.spacing.gutter})),vS=e=>{let t=e.refetchScenario;const n=wE(Sx),l=(0,a.useState)(!1),r=(0,o.A)(l,2),i=r[0],s=r[1],c=(0,a.useState)(null),d=(0,o.A)(c,2),u=d[0],p=d[1],g=(0,a.useCallback)((async()=>{s(!0),p(null);try{const e=await t();if(e){const t=wE.temporal.getState();t.pause();try{wE.getState().hydrateFromScenario(e)}finally{t.clear(),t.resume()}}else p("Unable to load scenario. Please reload the page.")}catch(e){p("Failed to refresh. Please try again.")}finally{s(!1)}}),[t]),h=n?"This forecast was updated elsewhere. Refresh to see the latest changes. Your unsaved changes will be lost.":"This forecast was updated elsewhere. Refresh to see the latest changes.";return a.createElement(fu.g,{"data-external-id":"forecast-conflict-banner",type:"warning"},a.createElement(m.g,{alignCenter:!0,justifyBetween:!0},a.createElement("span",null,null!==u&&void 0!==u?u:h),a.createElement(wt.Xb,{onClick:g,disabled:i},i?"Refreshing\u2026":"Refresh")))};var fS=n(49751);const ES=["children"],yS=e=>{let t=e.children,n=(0,En.A)(e,ES);const l=aw().compareToScenarioId;return a.createElement(fS.k,Object.assign({"data-external-id":"compare-read-only-tooltip",variant:"tooltip",contentClassName:"max-w-60",description:"View-only in comparison mode. Switch scenario to edit."}
1,n,{content:a.createElement(a.Fragment,null,"View-only in comparison mode.",l?a.createElement(a.Fragment,null,a.createElement("br",null),a.createElement(Vl.W,{to:NC(l,{mode:"plan"}),onClick:e=>{e.stopPropagation(),Lx.getState().resetViewMode(l)}},"Switch scenario to edit")):null)}),t)},bS=e=>{let t=e.breakdownKey,n=e.growthRateMethod,l=e.growthRate,r=e.interestRate,o=e.onClick,i=e.readOnly;if("growth"===t&&"schedule"===n)return a.createElement(xS,{"data-external-id":"growth-rate-indicator",label:"Variable",onClick:o,readOnly:i});if("growth"===t&&"noChange"===n)return a.createElement(xS,{"data-external-id":"growth-rate-indicator",label:nb(0),onClick:o,readOnly:i});const s=CS(t,l,r);return wS(s)?a.createElement(xS,{"data-external-id":"growth-rate-indicator",label:nb(s),onClick:o,readOnly:i}):null},xS=e=>{let t=e.label,n=e.onClick,l=e.readOnly;const r=!l&&(0,Tr.A)(n),o=a.createElement(bn.v,{onClick:l?void 0:n,tabIndex:r?void 0:-1,"aria-disabled":!r,className:(0,q.cn)("gap-xs p-0",!r&&"pointer-events-none cursor-default text-content-secondary")},a.createElement(sl.ZQ,{name:"trending-up",size:14}),a.createElement(xt.v,{size:"small",lineHeight:"20px",weight:"medium",className:"text-inherit"},t));return l?a.createElement(yS,{"data-external-id":"badge"},a.createElement("span",{className:"inline-flex"},o)):o},wS=e=>(0,Tr.A)(e)&&0!==e,CS=(e,t,n)=>"growth"===e?t:"interest"===e?n:void 0,AS=()=>{const e=ww(),t=e.mode,n=e.inflationRate;return"todaysDollars"!==t||n<=0?null:a.createElement(P.D_,{"data-external-id":"fixed-payment-info-icon",maxWidth:280,interactive:!0,content:a.createElement(P.fn,null,_t.Et.EVENTS.SHRINKAGE_TOOLTIP_BODY," ",a.createElement(Bb,{href:th},"Learn more"))},a.createElement("span",{role:"img","aria-label":"Fixed payment information",className:"inline-flex shrink-0 cursor-default items-center text-content-secondary"},a.createElement(sl.ZQ,{name:"info",size:12})))},IS=e=>{let t=e.value,n=e.pathname,r=e.children;const o=(0,l.Zp)(),i=(0,l.zy)().search;return a.createElement(fe.T36.Tab,{"data-external-id":"forecast-route-tab",value:t,nativeButton:!1,render:a.createElement(l.k2,{to:{pathname:n,search:i},onClick:e=>{if(e.defaultPrevented||0!==e.button||e.metaKey||e.ctrlKey||e.shiftKey||e.altKey)return;const t=window.location.search;t!==i&&(e.preventDefault(),o({pathname:n,search:t}))}})},r)},kS=(0,a.createContext)(null),SS=e=>{let t=e.years,n=e.scrollContainerRef,l=e.children;const r=(0,a.useCallback)((e=>{const a=n.current;if(!a)return;const l=e-(0,o.A)(t,1)[0];l<0||a.scrollTo({left:l*zg,behavior:"smooth"})}),[n,t]),i=(0,a.useMemo)((()=>({years:t,scrollContainerRef:n,scrollToYear:r})),[t,n,r]);return a.createElement(kS.Provider,{"data-external-id":"forecast-year-table-provider",value:i},l)},NS=()=>{const e=(0,a.useContext)(kS);if(!e)throw new Error("useForecastTableContext must be used within a ForecastYearTableProvider");return e},TS=e=>{let t=e.icon,n=e.size,l=e.color,r=e.className;return a.createElement(sl.ZQ,{"data-external-id":"scenario-icon",name:t,size:n,className:(0,q.cn)(r,l&&jg[l])})},_S=()=>{const e=(()=>{const e=Px(),t=e.viewMode,n=e.setViewMode,a=aw(),l=a.compareToScenarioId,r=a.compareScenarioMetadata,o=BE();return{viewMode:t,setViewMode:n,isToggleVisible:!!l,activeMetadata:{name:o.name,icon:o.icon,color:o.color},compareMetadata:r}})(),t=e.viewMode,n=e.setViewMode,l=e.isToggleVisible,r=e.activeMetadata,o=e.compareMetadata;if(!l||!o)return null;const i=[{value:"active",metadata:r},{value:"compare",metadata:o}];return a.createElement(Vi.Md,{"data-external-id":"scenario-view-toggle",attached:!0,rounded:"pill",size:"xs",value:[t],onValueChange:e=>{const a=e[0];var l;a&&a!==t&&(l=a,(0,Ge.u4)(Ye.yq.ScenarioCompareTableViewToggled,(0,U.A)({view_mode:l},zf())),n(a))},"aria-label":"Scenario view toggle","data-testid":"scenario-view-toggle"},i.map((e=>{let t=e.value,n=e.metadata;return a.createElement(Vi.H7,{key:t,value:t,icon:a.createElement(TS,{icon:n.icon,size:12,color:n.color,className:"shrink-0"}),className:"gap-2xs text-xs"},a.createElement("span",{className:"block max-w-40 truncate"},n.name))})))},DS=e=>{const t=(0,a.useRef)(null),n=(0,a.useState)(null),l=(0,o.A)(n,2),r=l[0],i=l[1],s=(0,a.useCallback)((e=>{i(e)}),[]),c=(0,a.useState)(!1),d=(0,o.A)(c,2),u=d[0],m=d[1],p=(0,a.useRef)(null),g=(0,a.useRef)(0),h=(0,a.useRef)(null),v=(0,a.useRef)(null),f=(0,a.useCallback)((()=>{const n=e,a=t.current;if(!n||!a)return;const l=((e,t,n)=>{if(e<=0||t<=0)return null;const a=t-e;if(a<=0)return{width:e,left:0};const l=Math.max(e/t*e,36),r=Math.max(e-l,0);return{width:l,left:0===r?0:Math.min(Math.max(n/a*r,0),r)}})(n.clientWidth,n.scrollWidth,n.scrollLeft);if(!l)return g.current=0,a.style.width="0px",void(a.style.transform="translateX(0px)");g.current=l.width,a.style.width="".concat(l.width,"px"),a.style.transform="translateX(".concat(l.left,"px)")}),[e]),E=(0,a.useCallback)((()=>{h.current&&cancelAnimationFrame(h.current),h.current=requestAnimationFrame((()=>{h.current=null,f()}))}),[f]),y=(0,a.useCallback)((()=>{const t=e;if(!t)return;const n=t.getBoundingClientRect(),a=t.scrollWidth>t.clientWidth,l=n.top<window.innerHeight&&n.bottom>0;m(a&&l),E()}),[e,E]);(0,a.useEffect)((()=>
1{if(!r)return;y();const e=()=>y(),t=(e=>{var t;let n=null!==(t=null===e||void 0===e?void 0:e.parentElement)&&void 0!==t?t:null;for(;n;){const e=window.getComputedStyle(n).overflowY;if(("auto"===e||"scroll"===e)&&n.scrollHeight>n.clientHeight)return n;n=n.parentElement}return null})(r);return window.addEventListener("scroll",e,{passive:!0}),window.addEventListener("resize",e),null===t||void 0===t||t.addEventListener("scroll",e,{passive:!0}),()=>{window.removeEventListener("scroll",e),window.removeEventListener("resize",e),null===t||void 0===t||t.removeEventListener("scroll",e)}}),[r,y]),(0,a.useEffect)((()=>{const t=e;if(!t)return;y();const n=new ResizeObserver((()=>y()));n.observe(t);const a=t.firstElementChild;return a&&n.observe(a),()=>n.disconnect()}),[y,e]),(0,a.useEffect)((()=>{const t=e;if(!t)return;const n=()=>E();return t.addEventListener("scroll",n,{passive:!0}),()=>t.removeEventListener("scroll",n)}),[e,E]),(0,a.useEffect)((()=>()=>{var e;h.current&&cancelAnimationFrame(h.current),null===(e=v.current)||void 0===e||e.call(v)}),[]);const b=(0,a.useCallback)(((t,n)=>{var a;p.current={startClientX:t,startScrollLeft:n};const l=t=>{const n=p.current,a=e;if(!n||!a)return;const l=a.scrollWidth-a.clientWidth,r=a.clientWidth-g.current;if(l<=0||r<=0)return;const o=(t.clientX-n.startClientX)/r*l,i=Math.min(Math.max(n.startScrollLeft+o,0),l);a.scrollLeft=i,f()},r=()=>{p.current=null,v.current=null,window.removeEventListener("mousemove",l),window.removeEventListener("mouseup",o)},o=()=>r();null===(a=v.current)||void 0===a||a.call(v),v.current=r,window.addEventListener("mousemove",l),window.addEventListener("mouseup",o)}),[e,f]),x=(0,a.useCallback)((t=>{const n=e;n&&(t.preventDefault(),t.stopPropagation(),f(),b(t.clientX,n.scrollLeft))}),[e,f,b]),w=(0,a.useCallback)((t=>{const n=e;if(!n)return;t.preventDefault();const a=t.currentTarget.getBoundingClientRect(),l=t.clientX-a.left,r=n.scrollWidth-n.clientWidth,o=g.current,i=Math.max(a.width-o,1),s=Math.min(Math.max(l-o/2,0),i),c=Math.min(Math.max(s/i*r,0),r);n.scrollLeft=c,f(),b(t.clientX,c)}),[e,f,b]);return{thumbRef:t,sentinelRef:s,shouldShowProxy:u,handleThumbMouseDown:x,handleTrackMouseDown:w}},RS=()=>{const e=aw().isComparisonActive,t=ew(),n=Zx(),a=n.scenarioId,r=n.mode,o=n.planYearTableView,i=Px().setViewMode,s=(0,l.Zp)(),c=(0,l.zy)().search,d=(0,v.D)((e=>{if(!a||e===t)return;var l;l={from:t,to:e},(0,Ge.u4)(Ye.yq.ForecastingModeChanged,(0,U.A)((0,U.A)({},l),zf()));const d=window.location.search||c;"chanceOfSuccess"!==e?("compare"===e&&void 0===Lx.getState().viewModeByScenarioId[a]&&i("compare"),s({pathname:$x({scenarioId:a,mode:e,yearTableView:"chance-of-success"===r?o:n.yearTableView}),search:d})):s({pathname:$x({scenarioId:a,mode:"chance-of-success"}),search:d})}));return{forecastingMode:t,setForecastingMode:d,isComparisonActive:e}},MS="data-year-highlighted";var LS,OS,PS,BS,zS,FS,GS,YS,US,VS,WS,jS,HS;const KS=["isHeader","isTotal","className"],qS=["background","indentPx","className","style"],$S={accounts:"Accounts",cashflow:"Cash Flow",events:"Events"},ZS={primary:"bg-background-primary",secondary:"bg-background-secondary"},JS=e=>{let t=e.children;const n=Zx(),l=RS(),r=l.forecastingMode,i=l.isComparisonActive,s="chanceOfSuccess"===r,c=!s&&"chance-of-success"!==n.mode,d=!s&&i,u=bw(),m=(null!==u&&void 0!==u?u:{}).snapshots,p=a.useMemo((()=>{var e;return null!==(e=null===m||void 0===m?void 0:m.map((e=>e.year)))&&void 0!==e?e:[]}),[m]),g=a.useRef(null),h=(0,a.useState)(null),v=(0,o.A)(h,2),f=v[0],E=v[1],y=(0,a.useCallback)((e=>{g.current=e,E(e)}),[]),b=a.useRef(null),x=a.useRef(null);var w;w=x,(0,a.useEffect)((()=>gE((e=>{const t=w.current;t&&(t.querySelectorAll("[".concat(MS,"]")).forEach((e=>e.removeAttribute(MS))),e.forEach((e=>{t.querySelectorAll('[data-year="'.concat(e,'"]')).forEach((e=>e.setAttribute(MS,"")))})))}))),[w]);const C=!!m&&m.length>0,A=DS(f),k=A.thumbRef,S=A.sentinelRef,N=A.shouldShowProxy,T=A.handleThumbMouseDown,_=A.handleTrackMouseDown;if((0,a.useEffect)((()=>{const e=f;if(!e)return;let t;const n=()=>{t&&cancelAnimationFrame(t),t=requestAnimationFrame((()=>{b.current&&(b.current.style.transform="translateX(-".concat(e.scrollLeft,"px)"))}))},a=()=>{(()=>{mE=!0;const e=uE.getState();null!==e.tableHoveredYear&&e.setTableHoveredYear(null)})(),n()},l=e=>{return t=XS(e),void(mE&&(mE=!1,pE(t)));var t};return e.addEventListener("scroll",a,{passive:!0}),e.addEventListener("pointermove",l,{passive:!0}),n(),()=>{e.removeEventListener("scroll",a),e.removeEventListener("pointermove",l),t&&cancelAnimationFrame(t)}}),[f]),!C)return a.createElement(uN,{"data-external-id":"forecast-year-table"},a.createElement(xt.v,{color:"textLight"},"No projection data available"));const D="".concat(Bg,"px repeat(").concat(p.length,", ").concat(zg,"px)");return a.createElement(SS,{"data-external-id":"forecast-year-table",years:p,scrollContainerRef:g},a.createElement(aN,{ref:x},c&&a.createElement("div",{className:"flex items-center justify-between px-xl py-default"},a.createElement(fe.T36.Root,{variant:"pill",value:n.yearTableView},a.createElement(fe.T36.List,{activateOnFocus:!1},I.Q6.map((e=>{const t=$S[e],l=qx({scenarioId:n.scenarioId,mode:n.mode,yearTableView:e});return a.createElement(IS,{key:e,value:e,pathname:l},t)})),a.createElement(fe.T36.Indicator,null))),d&&a.createElement(_S,null)),s?t:a.createElement(a.Fragment,null,a.createElement(lN,null,a.createElement(rN,{ref:b,style:{gridTemplateColumns:D}},a.createElement(oN,null),p.map((e=>a.createElement(QS,{key:e,year:e}))))),a.createElement(iN,{ref:y},a.createElement(sN,{style:{gridTemplateColumns:D}},t),a.createElement(mN,{ref:S})),a.createElement(pN,{$visible:N,onMouseDown:_},a.createElement(gN,null,a.createElement(hN,null),a.createElement(vN,{ref:k,onMouseDown:T}))))))},XS=e=>{var t;const n=null===(t=e.target)||void 0===t?void 0:t.closest("[data-year]"),a=Number(null===n||void 0===n?void 0:n.getAttribute("data-year"));return Number.isFinite(a)?a:null},QS=e=>{let t=e.year;const n=vE(t),l=hE(),r=a.useCallback((()=>
1{l(t)}),[l,t]),o=a.useCallback((()=>{l(null)}),[l]);return a.createElement("div",{"data-external-id":"year-header-pill",className:"flex cursor-default justify-end bg-background-page pr-sm",onMouseEnter:r,onMouseLeave:o},a.createElement(xt.v,{weight:"medium",size:"small",color:n?"content.primary":"content.secondary"},t))},eN=e=>{let t=e.isHeader,n=e.isTotal,l=e.className,r=(0,En.A)(e,KS);return a.createElement("div",Object.assign({"data-external-id":"grid-row",className:(0,q.cn)("contents","*:flex *:min-h-14 *:items-center *:border-b *:border-b-divider-primary","last:*:border-b-0","[&>*:first-child]:justify-start [&>*:not(:first-child)]:justify-end",t||n?"*:font-medium":"*:font-book",l)},r))},tN=e=>{let t=e.background,n=void 0===t?"primary":t,l=e.indentPx,r=e.className,o=e.style,i=(0,En.A)(e,qS);return a.createElement("div",Object.assign({"data-external-id":"sticky-cell",className:(0,q.cn)("sticky left-0 z-2 flex items-center border-r border-divider-secondary px-xl",ZS[n],void 0!==l&&"pl-(--forecast-sticky-cell-pl)",r),style:void 0!==l?(0,U.A)((0,U.A)({},o),{},{"--forecast-sticky-cell-pl":"".concat(l,"px")}):o},i))},nN=e=>a.createElement("div",Object.assign({"data-external-id":"spacer-sticky-cell",className:"sticky left-0 z-2 h-full border-r border-divider-secondary bg-inherit",style:{width:Bg}},e)),aN=$d.s.div(LS||(LS=(0,wc.A)(["isolate flex flex-col overflow-clip rounded-lg border border-border-primary bg-background-primary"]))),lN=$d.s.div(OS||(OS=(0,wc.A)(["\n  pointer-events-none sticky top-0 z-3 overflow-hidden border-y\n  border-divider-secondary bg-background-page\n"]))),rN=$d.s.div(PS||(PS=(0,wc.A)(["grid min-w-full will-change-transform *:flex *:h-9 *:items-center"]))),oN=$d.s.div(BS||(BS=(0,wc.A)(["bg-background-page pl-sm"]))),iN=$d.s.div(zS||(zS=(0,wc.A)(["\n  isolate -mt-9 flex-1 overflow-x-auto pt-9 [-ms-overflow-style:none] [scrollbar-width:none]\n  [&::-webkit-scrollbar]:hidden [&::-webkit-scrollbar]:h-0\n"]))),sN=$d.s.div(FS||(FS=(0,wc.A)(["inline-grid min-w-full"]))),cN=$d.s.div(GS||(GS=(0,wc.A)(["\n  col-span-full flex h-2 border-y border-divider-secondary bg-background-page\n"]))),dN=(0,$d.s)(cN)(YS||(YS=(0,wc.A)(["relative z-3 -mt-px"]))),uN=$d.s.div(US||(US=(0,wc.A)(["p-2xl text-center"]))),mN=$d.s.div(VS||(VS=(0,wc.A)(["h-0 w-full"]))),pN=$d.s.div((e=>["sticky bottom-0 -mt-px bg-background-page","z-4",e.$visible?"pointer-events-auto h-5 border-t border-border-primary":"pointer-events-none h-0 overflow-hidden"])),gN=$d.s.div(WS||(WS=(0,wc.A)(["relative h-full overflow-hidden"]))),hN=$d.s.div(jS||(jS=(0,wc.A)(["absolute inset-0 bg-background-secondary"]))),vN=$d.s.div(HS||(HS=(0,wc.A)(["\n  absolute inset-y-0 left-0 cursor-grab will-change-transform\n  before:absolute before:-inset-x-3 before:inset-y-0 before:content-['']\n  after:pointer-events-none after:absolute after:inset-x-0 after:top-1/2 after:h-1.5\n  after:-translate-y-1/2 after:rounded-md after:bg-border-primary\n  after:transition-[height,background-color] after:duration-120 after:ease-in-out after:content-['']\n  hover:after:h-[calc(100%-10px)] hover:after:bg-border-primary-hover\n  active:cursor-grabbing\n  active:after:h-[calc(100%-10px)] active:after:bg-border-secondary\n"]))),fN=e=>{let t=e.penaltyRate,n=e.onClick,l=e.readOnly;if(!EN(t))return null;const r=!l&&(0,Tr.A)(n),o=a.createElement(fe.XZZ,{variant:"text",colorScheme:r?"link":"secondary",size:"sm",icon:a.createElement(fe.Ul6,null),onClick:l?void 0:n,tabIndex:r?void 0:-1,"aria-disabled":!r,"aria-label":"Withdrawal penalty ".concat(nb(t),", open account settings"),className:(0,q.cn)(!r&&"pointer-events-none cursor-default")},nb(t));return l?a.createElement(yS,{"data-external-id":"withdrawal-penalty-rate-indicator"},a.createElement("span",{className:"inline-flex"},o)):o},EN=e=>(0,Tr.A)(e)&&0!==e,yN=(e,t)=>{if(e===t)return!0;if(Array.isArray(e)||Array.isArray(t))return Array.isArray(e)&&Array.isArray(t)&&e.length===t.length&&e.every(((e,n)=>yN(e,t[n])));if(a.isValidElement(e)&&a.isValidElement(t)){if(e.type!==t.type||e.key!==t.key)return!1;const n=e.props,a=t.props,l=Object.keys(n);return l.length===Object.keys(a).length&&l.every((e=>{if(!(e in a))return!1;const t=n[e],l=a[e];return t===l||yN(t,l)}))}return!1},bN=(e,t)=>e.year===t.year&&e.align===t.align&&e.background===t.background&&e.dashedBorder===t.dashedBorder&&yN(e.children,t.children),xN={primary:"bg-background-primary",secondary:"bg-background-secondary",page:"bg-background-page"},wN=a.memo((e=>{let t=e.year,n=e.align,l=void 0===n?"right":n,r=e.background,o=void 0===r?"primary":r,i=e.dashedBorder,s=e.children;return a.createElement("div",{"data-external-id":"year-cell","data-year":t,className:(0,q.cn)("\n          flex cursor-default items-center pr-sm whitespace-nowrap transition-colors duration-100\n          ease-
1out\n          data-year-highlighted:bg-background-primary-hover\n        ",xN[o],"right"===l?"justify-end":"justify-start",{"border-r [border-right-style:dashed] border-r-divider-secondary":i}),onMouseEnter:()=>pE(t),onMouseLeave:()=>pE(null)},s)}),bN);var CN,AN,IN,kN,SN;const NN=["minHeight","divider","background","className","style"],TN=["minHeight","divider"],_N=(e,t)=>"".concat(e,"-").concat(t),DN={primary:"[&>*]:border-b [&>*]:border-b-divider-primary",secondary:"[&>*]:border-b [&>*]:border-b-divider-secondary",none:""},RN={primary:"[&>*]:bg-background-primary",secondary:"[&>*]:bg-background-secondary"},MN=e=>{let t=e.minHeight,n=void 0===t?56:t,l=e.divider,r=void 0===l?"primary":l,o=e.background,i=e.className,s=e.style,c=(0,En.A)(e,NN);return a.createElement("div",Object.assign({"data-external-id":"table-row",className:(0,q.cn)("contents *:flex *:min-h-(--forecast-table-row-min-height) *:items-center","[&>*:not(:first-child)]:justify-end",DN[r],o&&RN[o],i),style:(0,U.A)((0,U.A)({},s),{},{"--forecast-table-row-min-height":"".concat(n,"px")})},c))},LN=e=>{let t=e.minHeight,n=void 0===t?44:t,l=e.divider,r=void 0===l?"secondary":l,o=(0,En.A)(e,TN);return a.createElement(MN,Object.assign({"data-external-id":"compact-sub-row",minHeight:n,divider:r},o))},ON=e=>{let t=e.open,n=e.children;const l=(0,a.useState)(t),r=(0,o.A)(l,2),i=r[0],s=r[1];return t&&!i&&s(!0),(0,a.useEffect)((()=>{if(t)return;const e=setTimeout((()=>s(!1)),200);return()=>clearTimeout(e)}),[t]),a.createElement("div",{"data-external-id":"collapsible-section","data-open":t||void 0,className:" col-span-full grid grid-cols-subgrid grid-rows-[0fr] overflow-clip transition-[grid-template-rows] duration-200 ease-in-out data-open:grid-rows-[1fr] motion-reduce:transition-none "},a.createElement("div",{className:"col-span-full grid min-h-0 grid-cols-subgrid self-start overflow-clip"},i?n:null))},PN=$d.s.div(CN||(CN=(0,wc.A)(["\n  flex min-w-0 items-center gap-xs\n  [&>button:first-child]:shrink-0 [&>div:first-of-type]:shrink-0\n"]))),BN=$d.s.div.attrs({"data-forecast-hover-reveal":"true"})(AN||(AN=(0,wc.A)(["\n  opacity-0 transition-all duration-150 ease-in-out\n  focus-within:opacity-100 has-data-popup-open:opacity-100\n"]))),zN=$d.s.div(IN||(IN=(0,wc.A)(["\n  shrink-0 opacity-0 transition-opacity duration-150 ease-out\n  group-hover:opacity-100 focus-within:opacity-100 has-data-popup-open:opacity-100\n"]))),FN=$d.s.div.attrs({"data-forecast-hover-default":"true"})(kN||(kN=(0,wc.A)(["pointer-events-none flex transition-all duration-150 ease-in-out"]))),GN=$d.s.div(SN||(SN=(0,wc.A)(["\n  grid *:col-start-1 *:row-start-1\n  [&:focus-within_[data-forecast-hover-default]]:opacity-0\n  [&:has([data-popup-open])_[data-forecast-hover-default]]:opacity-0\n"]))),YN=a.createElement(a.Fragment,null,"Adjusts starting balance for inflation to reflect its purchasing power in today's dollars."," ",a.createElement(Bb,{href:th},"Learn more")),UN={startingBalance:"Starting balance",inflationAdjustment:"Inflation adjustment",growth:"Growth",interest:"Interest",contributions:"Yearly paycheck contribution",deposits:"Deposits",withdrawals:"Withdrawals",withdrawalTax:"Tax on withdrawals",withdrawalPenalty:"Withdrawal penalty",payments:"Payments",expenses:"Expenses",endingBalance:"Ending balance"},VN=["startingBalance","inflationAdjustment","growth","contributions","deposits","withdrawals","withdrawalTax","withdrawalPenalty"].map((e=>({key:e,label:UN[e],isSigned:"startingBalance"!==e,labelTooltip:"inflationAdjustment"===e?YN:void 0}))),WN=["startingBalance","inflationAdjustment","interest","payments","expenses"].map((e=>({key:e,label:UN[e],isSigned:"startingBalance"!==e,labelTooltip:"inflationAdjustment"===e?YN:void 0}))),jN={primary:"text-content-primary",secondary:"text-content-secondary",positive:"text-content-success",negative:"text-content-danger"},HN=e=>{let t=e.accountId,n=e.years,l=e.breakdowns,o=e.isLiability,i=e.isSynthetic,s=e.isSystemAccount,c=e.growthRate,d=e.growthRateMethod,u=e.growthRateSchedule,m=e.interestRate,p=e.penaltyRate,g=e.hasMissingDetails,h=e.onOpenAccount;const v=rw().isTableShowingCompareData,f=null!==d&&void 0!==d?d:"fixed",E=KN(o,l,f),y=h&&!v?()=>h(t):void 0;return a.createElement(a.Fragment,null,E.map((e=>a.createElement(LN,{key:ZN(t,e.key)},a.createElement(tN,{className:"justify-between gap-xs pr-sm",indentPx:Fg},a.createElement("span",{className:"flex items-center gap-2xs"},a.createElement(xt.v,{size:"small",color:"content.primary",lineHeight:"20px"},e.label),e.labelTooltip?a.createElement(P.D_,{maxWidth:298,interactive:!0,content:a.createElement(P.fn,null,e.labelTooltip)},a.createElement("span",{className:"inline-flex shrink-0 cursor-default items-center text-content-secondary"},a.createElement(sl.ZQ,{name:"info",size:12}))):null,"payments"===e.key&&o&&!s?a.createElement(AS,null):null),"withdrawalPenalty"===e.key?a.createElement(fN,{penaltyRate:p,onClick:y,readOnly:v}):a.createElement(bS,{breakdownKey:e.key,growthRateMethod:f,growthRate:c,interestRate:m,onClick:y,readOnly:v})),l.map(((l,c)=>{var d;const m=null===l?void 0:l[e.key],p=void 0===m?{text:"-",color:"secondary"}:qN(m,e.isSigned,e.key),h=p.text,v=p.color,E=a.createElement(xt.v,{size:"small",lineHeight:"20px",className:jN[v]},h),y="growth"===e.key&&null!==l?$N(f,u,n[c]):void 0,b=void 0===y?E:a.createElement("span",{className:"flex flex-col items-end"},E,a.createElement("span",{className:"flex items-center gap-2xs text-content-link"},a.createElement(sl.ZQ,{name:"trending-up",size:12}),a.createElement(xt.v,{size:"xsmall",lineHeight:"18px",className:"text-content-link"},nb(y)))),x="startingBalance"===e.key&&0===c;return a.createElement(wN,{key:JN(t,e.key,n[c]),year:n[c],align:"right",background:"primary"},!x||i||s||g||o&&0===(null!==(d=null===l||void 0===l?void 0:l.endingBalance)&&void 0!==d?d:0)?b:a.createElement(P.D_,{maxWidth:298,content:a.createElement(P.fn,null,(0,r.YW)(o).with(!0,(()=>"Estimated Jan 1 balance: We back up from your balance today using your planned payments and interest rate for the months already passed this calendar year (not your actual transactions).")).with(!1,(()=>"Estimated Jan 1 balance: We back up from your balance today using your planned contributions and growth rate for the months already passed this calendar year (not your actual transactions).")).exhaustive())},a.createElement("span",{className:"flex items-center gap-2xs"},a.createElement(sl.ZQ,{name:"info",size:12,className:"text-content-secondary"}),E)))}))))))},KN=(e,t,n)=>{const a=e?WN:VN,l=t.filter((e=>null!==e)),r=!e&&("noChange"===n||"schedule"===n);return a.filter((e=>"startingBalance"===e.key||"growth"===e.key&&r||l.some((t=>{const n=t[e.key];return void 0!==n&&Math.abs(n)>Sp.Y}))))},qN=(e,t,n)=>{if("startingBalance"!==n&&Math.abs(e)<Sp.Y)return{text:"-",color:"secondary"};const a=(0,rl.fw)(Math.abs(e));return t?e>Sp.Y?{text:"+".concat(a),color:"positive"}:e<-Sp.Y?{text:"-".concat(a),color:"negative"}:{text:a,color:"primary"}:{text:a,color:"primary"}},$N=(e,t,n)=>"schedule"===e&&t&&t.length>0?up(t,n):void 0,ZN=(e,t)=>"breakdown-".concat(e,"-").concat(t),JN=(e,t,n)=>"breakdown-".concat(e,"-").concat(t,"-").concat(n),XN={danger:"text-content-danger",warning:"text-content-warning"},QN=e=>{let t=e.label,n=e.variant,l=e.leadingIcon,o=e.content,i=e.compareReadOnly,s=e.contentClassName;const c=(0,r.YW)(l).with("alert-triangle",(()=>a.createElement(fe.WU2,{size:"sm",className:XN[n]}))).with("info",(()=>a.createElement(fe.ucZ,{size:"sm",className:XN[n]}))).exhaustive(),d=a.createElement(fe.c8D,{size:"sm",color:n,className:"truncate"},t);return i?a.createElement(yS,{"data-external-id":"account-row-alert"},a.createElement("span",{className:(0,q.cn)("inline-flex min-w-0 items-center gap-2xs",XN[n])},c,d)):a.createElement(fe.cIj,{"data-external-id":"account-row-alert","aria-label":t,label:d,labelPosition:"after",icon:c,triggerClassName:(0,q.cn)("max-w-full min-w-0 justify-start self-start",XN[n]),contentClassName:(0,q.cn)("max-w-70",s),content:a.createElement("div",{className:"text-left"},o)})},eT=e=>{let t=e.kind,n=e.forecastAccountId;const l=vy(),o=l.openAssumptions,i=l.openAccount;return(0,r.YW)(t).with("missing-birthday",(()=>a.createElement(a.Fragment,null,"You need to"," ",a.createElement(fe.XZZ,{variant:"text",colorScheme:"link",size:"xs",className:"inline h-auto px-0",onClick:e=>{e.preventDefault(),e.stopPropagation(),o()}},"add a birthday")," ","for this account's owner to forecast taxes, penalties, and future value."))).with("shared-ownership",(()=>a.createElement(a.Fragment,null,"You need to"," ",a.createElement(fe.XZZ,{variant:"text",colorScheme:"link",size:"xs",className:"inline h-auto px-0",onClick:e=>{e.preventDefault(),e.stopPropagation(),i(n)}},"assign an owner")," ","to this account to forecast taxes, penalties, and future value."))).exhaustive()},tT=e=>(0,r.YW)(e).with("missing-birthday",(()=>"Add a birthday")).with("shared-ownership",(()=>"Assign an owner")).exhaustive(),nT=e=>{let t=e.kind,n=e.forecastAccountId,l=e.compareReadOnly;const r=tT(t),o=a.createElement(fe.WU2,{size:"sm",className:"text-content-danger"});return l?a.createElement(yS,{"data-external-id":"year-alert-triangle"},a.createElement("span",{className:"inline-flex","aria-label":r},o)):a.createElement(fe.cIj,{"data-external-id":"year-alert-triangle","aria-label":r,icon:o,contentClassName:"max-w-70",content:a.createElement("span",null,a.createElement(eT,{kind:t,forecastAccountId:n}
1))})},aT=["minHeight"],lT=["minHeight","divider","background"],rT=["className"];var oT,iT,sT,cT,dT;const uT=(e,t)=>_N("account-".concat(e),t),mT=(0,$d.s)(xt.v).attrs({clampLines:1})(oT||(oT=(0,wc.A)(["min-w-0"]))),pT=(0,$d.s)(xt.v).attrs({size:"small",clampLines:1})(iT||(iT=(0,wc.A)(["min-w-0"]))),gT=(0,$d.s)(xt.v).attrs({size:"small",color:"content.secondary",clampLines:1})(sT||(sT=(0,wc.A)(["min-w-0"]))),hT=(0,$d.s)(xt.v).attrs({lineHeight:"20px"})(cT||(cT=(0,wc.A)([""]))),vT=((0,$d.s)(xt.v).attrs({size:"small",lineHeight:"20px"})(dT||(dT=(0,wc.A)([""]))),e=>{let t=e.minHeight,n=void 0===t?44:t,l=(0,En.A)(e,aT);return a.createElement(MN,Object.assign({"data-external-id":"account-row",minHeight:n},l))}),fT=e=>{let t=e.minHeight,n=void 0===t?44:t,l=e.divider,r=void 0===l?"secondary":l,o=e.background,i=void 0===o?"secondary":o,s=(0,En.A)(e,lT);return a.createElement(MN,Object.assign({"data-external-id":"hidden-account-row",minHeight:n,divider:r,background:i},s))},ET=e=>{let t=e.className,n=(0,En.A)(e,rT);return a.createElement(tN,Object.assign({"data-external-id":"account-sticky-cell",className:(0,q.cn)("justify-between pr-sm pl-2xl","[&:hover_[data-forecast-hover-default]]:opacity-0","[&:hover_[data-forecast-hover-reveal]]:opacity-100",t)},n))},yT=e=>{let t=e.row,n=e.rowId,l=e.years,r=e.compareReadOnly;return!t.hasMissingDetails&&t.canCalculateWithdrawalPenalty?a.createElement(a.Fragment,null,t.balances.map(((e,r)=>a.createElement(wN,{key:uT(n,l[r]),year:l[r],align:"right"},a.createElement(fe.c8D,{size:"sm"},null===t.breakdowns[r]?"-":(0,rl.fw)(e)))))):a.createElement(a.Fragment,null,l.map((e=>a.createElement(wN,{key:uT(n,e),year:e,align:"right"},t.earlyWithdrawalAlertKind?a.createElement(nT,{kind:t.earlyWithdrawalAlertKind,forecastAccountId:t.forecastAccountId,compareReadOnly:r}):a.createElement("div",{className:"flex text-content-danger"},a.createElement(fe.WU2,{size:"sm"}))))))},bT={danger:0,warning:1};var xT=n(46271);const wT=e=>{let t=e.isTableShowingCompareData,n=e.onClick,l=e.ariaLabel,r=void 0===l?"Settings":l;return t?a.createElement(yS,{"data-external-id":"compare-aware-settings-button"},a.createElement("span",{className:"inline-flex"},a.createElement(Yi.S,{"aria-label":"".concat(r," (view-only in comparison mode)"),size:"xs",disabled:!0,className:"pointer-events-none"},a.createElement(xT.MdsSettingsIcon,null)))):a.createElement(Yi.S,{"data-external-id":"compare-aware-settings-button","aria-label":r,size:"xs",onClick:n},a.createElement(xT.MdsSettingsIcon,null))},CT={danger:"text-content-danger",warning:"text-content-warning"},AT=e=>{let t=e.alerts,n=e.forecastAccountId,l=e.isTableShowingCompareData,i=e.onOpenAccount;if(0===t.length)return null;const s=()=>i(n);if(t.length>1){const e=(e=>{const t=e.some((e=>"danger"===e.variant));return{variant:t?"danger":"warning",icon:t?"alert-triangle":"info",label:"".concat(e.length," issues detected")}})(t);return a.createElement(QN,{"data-external-id":"account-row-alerts",variant:e.variant,leadingIcon:e.icon,label:e.label,compareReadOnly:l,contentClassName:"max-w-73",content:a.createElement("div",{className:"flex flex-col gap-default text-left"},t.map((e=>a.createElement("div",{key:e.id,className:"flex flex-col"},a.createElement("div",{className:(0,q.cn)("flex items-center gap-2xs",CT[e.variant])},(0,r.YW)(e.icon).with("alert-triangle",(()=>a.createElement(fe.WU2,null))).with("info",(()=>a.createElement(fe.ucZ,null))).exhaustive(),a.createElement(fe.c8D,{size:"sm",color:e.variant},e.label)),a.createElement(fe.c8D,{size:"sm"},ST(e.id,n,s))))))})}const c=(0,o.A)(t,1)[0];return a.createElement(QN,{"data-external-id":"account-row-alerts",variant:c.variant,leadingIcon:c.icon,label:c.label,compareReadOnly:l,content:ST(c.id,n,s)})},IT=a.memo((e=>{let t=e.row,n=e.years,l=e.onOpenAccount,r=e.isTableShowingCompareData;const o=t.rowKey.serialized,i=(e=>{const t=Aw();return PC((n=>MC(n.byScenarioId,t).accounts.expandedAccountIds.has(e)))})(o),s=PC((e=>e.toggleExpandedAccount)),c=t.canCalculateWithdrawalPenalty&&i,d=(e=>{const t=[];return!e.canCalculateWithdrawalPenalty&&e.earlyWithdrawalAlertKind&&t.push({id:e.earlyWithdrawalAlertKind,variant:"danger",icon:"alert-triangle",label:tT(e.earlyWithdrawalAlertKind)}
1),e.hasMissingDetails&&t.push({id:"missingDetails",variant:"danger",icon:"alert-triangle",label:"Missing details"}),e.needsContributionSetup&&t.push({id:"contributions",variant:"warning",icon:"info",label:"Set up contributions"}),e.drift.hasDrift&&t.push({id:"drift",variant:"warning",icon:"info",label:"Update split balances"}),e.isLinkedAccountDeleted&&t.push({id:"deleted",variant:"danger",icon:"alert-triangle",label:"Account deleted"}),t.toSorted(((e,t)=>bT[e.variant]-bT[t.variant]))})(t);return a.createElement(a.Fragment,{key:o},a.createElement(vT,{minHeight:d.length>0?68:void 0},a.createElement(ET,null,a.createElement(PN,null,a.createElement(fe.SO$,{"aria-label":c?"Collapse account":"Expand account",size:"xs",disabled:!t.canCalculateWithdrawalPenalty,onClick:t.canCalculateWithdrawalPenalty?()=>s(o):void 0,variant:"minimal"},c?a.createElement(fe.D39,null):a.createElement(fe.hPJ,null)),a.createElement(Dw,{logoUrl:t.logoUrl,icon:t.icon,accountId:t.forecastAccountId,size:24}),a.createElement("div",{className:"flex min-w-0 flex-col"},a.createElement(pT,{title:t.name},t.name),a.createElement(AT,{alerts:d,forecastAccountId:t.forecastAccountId,isTableShowingCompareData:r,onOpenAccount:l}))),t.isEditable&&a.createElement(BN,null,a.createElement(wT,{isTableShowingCompareData:r,onClick:()=>l(t.forecastAccountId)}))),a.createElement(yT,{row:t,rowId:o,years:n,compareReadOnly:r})),t.canCalculateWithdrawalPenalty&&a.createElement(ON,{open:c},a.createElement(HN,{accountId:o,years:n,breakdowns:t.breakdowns,isLiability:t.isLiability,isSynthetic:t.isSynthetic,isSystemAccount:t.isSystemAccount,growthRate:t.growthRate,growthRateMethod:t.growthRateMethod,growthRateSchedule:t.growthRateSchedule,interestRate:t.interestRate,penaltyRate:t.penaltyRate,hasMissingDetails:t.hasMissingDetails,onOpenAccount:()=>l(t.forecastAccountId)})))})),kT=a.memo((e=>{let t=e.accounts,n=e.years,l=e.onOpenAccount,r=e.isTableShowingCompareData;return a.createElement(a.Fragment,null,t.map((e=>a.createElement(IT,{key:e.rowKey.serialized,row:e,years:n,onOpenAccount:l,isTableShowingCompareData:r}))))})),ST=(e,t,n)=>(0,r.YW)(e).with("shared-ownership","missing-birthday",(e=>a.createElement(eT,{kind:e,forecastAccountId:t}))).with("missingDetails",(()=>a.createElement(a.Fragment,null,"This account is missing important details that affect your forecast."," ",a.createElement(fe.XZZ,{variant:"text",colorScheme:"link",size:"xs",className:"inline h-auto px-0",onClick:e=>{e.preventDefault(),e.stopPropagation(),n()}},"Fix issue")))).with("contributions",(()=>a.createElement(a.Fragment,null,"You can enter how much you plan to deposit into this account each year from payroll deductions in"," ",a.createElement("span",{className:"whitespace-nowrap"},a.createElement(fe.XZZ,{variant:"text",colorScheme:"link",size:"xs",className:"inline h-auto px-0",onClick:e=>{e.preventDefault(),e.stopPropagation(),n()}},"account settings"),".")))).with("drift",(()=>a.createElement(a.Fragment,null,"Your Traditional and Roth balances don't add up to this account's current balance."," ",a.createElement("span",{className:"whitespace-nowrap"},a.createElement(fe.XZZ,{variant:"text",colorScheme:"link",size:"xs",className:"inline h-auto px-0",onClick:e=>{e.preventDefault(),e.stopPropagation(),n()}},"Adjust them to match"),".")))).with("deleted",(()=>a.createElement(a.Fragment,null,"This account has been deleted from Monarch and no longer receives updates.",a.createElement("br",null),a.createElement(fe.XZZ,{variant:"text",colorScheme:"link",size:"xs",className:"inline h-auto px-0",onClick:e=>{e.preventDefault(),e.stopPropagation(),n()}},"Remove it from your forecast")," ","when you're ready."))).exhaustive(),NT=e=>{let t=e.hiddenAccounts,n=e.isExpanded,l=e.categoryId,r=e.onToggle,o=e.years,i=e.keyPrefix,s=e.onOpenAccount;const c=rw().isTableShowingCompareData;return 0===t.length?null:a.createElement(a.Fragment,null,a.createElement(ON,{open:n},t.map((e=>{var t,n;return a.createElement(fT,{key:e.id},a.createElement(ET,{background:"secondary"},a.createElement(PN,null,a.createElement("div",{style:{width:24}})," ",a.createElement(Dw,{logoUrl:null===(t=e.metadata)||void 0===t?void 0:t.logoUrl,icon:null===(n=e.metadata)||void 0===n?void 0:n.icon,sourceEventExternalId:e.sourceEventExternalId,size:24}),a.createElement(gT,{title:e.name},e.name)),a.createElement(GN,null,a.createElement(FN,null,a.createElement("div",{className:"flex size-8 items-center justify-center text-content-secondary"},a.createElement(fe.yhH,{size:"md"}))),a.createElement(BN,null,a.createElement(wT,{isTableShowingCompareData:c,onClick:()=>s(e.id),ariaLabel:"Settings for ".concat(e.name)}
1)))),o.map((t=>a.createElement(wN,{key:uT("".concat(i).concat(e.id),t),year:t,background:"secondary"},a.createElement(xt.v,{size:"small",color:"content.secondary"},"-")))))}))),a.createElement(LN,null,a.createElement(tN,{className:"pr-sm pl-2xl",onClick:()=>r(l),style:{cursor:"pointer"}},a.createElement(PN,null,a.createElement(fe.SO$,{"aria-label":n?"Collapse excluded accounts":"Show excluded accounts",size:"3xs",variant:"minimal","aria-expanded":n,className:"text-content-secondary"},n?a.createElement(fe.yhH,{size:"sm"}):a.createElement(fe.N9s,{size:"sm"})),a.createElement(xt.v,{size:"small",color:"content.secondary"},n?"Collapse ".concat(t.length," excluded ").concat((0,De.td)("account",t.length)):"Show ".concat(t.length," excluded ").concat((0,De.td)("account",t.length))))),o.map((e=>a.createElement(wN,{key:_N("".concat(i,"toggle"),e),year:e})))))};var TT;const _T=["divider"],DT=["withSettingsIcon","className"],RT=a.memo((e=>{const t=e.category,n=e.categoryConfig,l=e.accounts,r=e.totals,o=e.years,i=e.isCollapsed,s=e.isStandalone,c=e.collapseId,d=e.onToggleCollapse,u=e.onOpenAccount,m=e.onOpenUncategorizedSavings,p=a.useCallback((()=>d(c)),[d,c]),g=Ew(ry(),vw),h=rw().isTableShowingCompareData,v="uncategorized-savings"===t,f="unfunded-expenses"===t,E=l&&l.length>0,y=s&&!f,b=y&&null!==l&&void 0!==l&&l[0]?l[0].rowKey.serialized:void 0,x=v&&!g;return a.createElement(a.Fragment,null,a.createElement(PT,{minHeight:x||f?68:void 0},a.createElement(BT,{className:"px-sm",withSettingsIcon:y},a.createElement(PN,null,a.createElement(fe.SO$,{"aria-label":i?"Expand category":"Collapse category",size:"xs",variant:"minimal",className:"text-content-primary",onClick:p},i?a.createElement(fe.hPJ,null):a.createElement(fe.D39,null)),a.createElement(zT,null,a.createElement(sl.ZQ,{name:n.icon,size:16})),a.createElement(MT,{category:t,label:n.label,showExtraSavingsCallout:x,isSplitConfigured:g,onOpenUncategorizedSavings:m,isTableShowingCompareData:h})),b&&a.createElement(BN,null,a.createElement(wT,{isTableShowingCompareData:h,onClick:()=>u(b)}))),o.map(((e,n)=>a.createElement(wN,{key:_N("".concat(t,"-total"),e),year:e,align:"right"},a.createElement(hT,null,E?(0,rl.fw)(r[n]):"-"))))),a.createElement(ON,{open:!i},e.isStandalone?(null===l||void 0===l?void 0:l[0])&&a.createElement(HN,{accountId:l[0].rowKey.serialized,years:o,breakdowns:l[0].breakdowns,isLiability:l[0].isLiability,isSynthetic:l[0].isSynthetic,isSystemAccount:l[0].isSystemAccount,growthRate:l[0].growthRate,growthRateMethod:l[0].growthRateMethod,growthRateSchedule:l[0].growthRateSchedule,interestRate:l[0].interestRate,penaltyRate:l[0].penaltyRate,hasMissingDetails:l[0].hasMissingDetails,onOpenAccount:u}):a.createElement(a.Fragment,null,E&&a.createElement(kT,{accounts:l,years:o,onOpenAccount:e.onOpenAccount,isTableShowingCompareData:h}),e.hiddenAccounts.length>0&&a.createElement(NT,{hiddenAccounts:e.hiddenAccounts,isExpanded:e.isHiddenExpanded,categoryId:e.hiddenCategoryId,onToggle:e.onToggleHidden,years:o,keyPrefix:e.hiddenKeyPrefix,onOpenAccount:e.onOpenAccount}))))})),MT=e=>{let t=e.category,n=e.label,l=e.showExtraSavingsCallout,r=e.isSplitConfigured,o=e.onOpenUncategorizedSavings,i=e.isTableShowingCompareData;return"uncategorized-savings"===t?a.createElement("div",{"data-external-id":"category-label-content",className:"flex min-w-0 flex-col"},a.createElement("div",{className:"flex min-w-0 items-center gap-2xs"},a.createElement(mT,{italic:l,color:l?"content.secondary":void 0},n),r&&a.createElement(OT,{onSetupSplits:o,showLink:!i},a.createElement("span",{className:"shrink-0 text-content-secondary"},a.createElement(sl.ZQ,{name:"info",size:14})))),l&&a.createElement(OT,{onSetupSplits:o,showLink:!i},a.createElement("div",{className:"flex items-center gap-2xs text-content-warning"},a.createElement(sl.ZQ,{name:"info",size:14}),a.createElement(xt.v,{size:"small"},"Set up Savings Splits")))):"unfunded-expenses"===t?a.createElement("div",{"data-external-id":"category-label-content",className:"flex min-w-0 flex-col"},a.createElement(mT,{color:"content.secondary"},n),a.createElement(P.D_,{interactive:!0,maxWidth:200,content:a.createElement(P.fn,null,a.createElement("p",null,"Your forecasted expenses exceed the cash and investable assets in all of your accounts."),a.createElement("p",null,"You may need to increase income or reduce expenses to remove the shortfall."))},a.createElement("div",{className:"flex items-center gap-2xs text-content-warning"},a.createElement(sl.ZQ,{name:"info",size:14}),a.createElement(xt.v,{size:"small"},"You have unfunded expenses")))):a.createElement(mT,{"data-external-id":"category-label-content"},n)},LT=e=>{let t=e.onSetupSplits,n=e.showLink,l=void 0===n||n;return a.createElement(P.fn,{"data-external-id":"savings-split-tooltip-content"},"When you earn more than you spend, the extra shows up here. You can split these funds across your other accounts from"," ",l?a.createElement(a.Fragment,null,a.createElement(wb.gz,{onClick:t},"savings splits"),"."):"savings splits.")},OT=e=>{let t=e.children,n=e.onSetupSplits,l=e.showLink,r=void 0===l||l;return a.createElement(P.D_,{"data-external-id":"savings-split-tooltip",interactive:!0,maxWidth:200,content:a.createElement(LT,{onSetupSplits:n,showLink:r})},t)},PT=e=>{let t=e.divider,n=void 0===t?"secondary":t,l=(0,En.A)(e,_T);return a.createElement(MN,Object.assign({"data-external-id":"category-row",divider:n},l))},BT=e=>{let t=e.withSettingsIcon,n=e.className,l=(0,En.A)(e,DT);
1return a.createElement(tN,Object.assign({"data-external-id":"category-header-cell",className:(0,q.cn)(t&&"justify-between [&:hover_[data-forecast-hover-reveal]]:opacity-100",n)},l))},zT=$d.s.div(TT||(TT=(0,wc.A)(["flex size-6 items-center justify-center"]))),FT=e=>!e.hasMissingDetails&&e.canCalculateWithdrawalPenalty,GT=e=>{let t=e.systemAccountType,n=e.baseCategory;return _p({systemAccountType:t})?"uncategorized-savings":Dp({systemAccountType:t})?"unfunded-expenses":n},YT=(e,t,n,a,l)=>{if(!e||0===e.snapshots.length)return null;const r=n.map((t=>{var n,a,r;const o="liability"===t.group,i=[],s=[];return e.snapshots.forEach((e=>{var n,a;const r=fp(e.accounts,t.rowKey);i.push(l.toTodaysDollars(null!==(n=null===r||void 0===r?void 0:r.balance)&&void 0!==n?n:0,e.year));const c=null!==(a=null===r||void 0===r?void 0:r.breakdown)&&void 0!==a?a:null;s.push(c&&"todaysDollars"===l.mode?((e,t,n,a,l)=>{if(0===a||t-n<=0)return e;const r=Cp(n,a),o=r(t),i=r(t-1),s=e.startingBalance/i,c=l.isLiability?1:-1;return{startingBalance:s,endingBalance:e.endingBalance/o,growth:e.growth/o,interest:e.interest/o,contributions:e.contributions/o,deposits:e.deposits/o,withdrawals:e.withdrawals/o,withdrawalTax:e.withdrawalTax/o,withdrawalPenalty:e.withdrawalPenalty/o,payments:e.payments/o,expenses:e.expenses/o,inflationAdjustment:c*s*(1-1/(1+a/100))}})(c,e.year,l.planStartYear,l.inflationRate,{isLiability:o}):c)})),{rowKey:t.rowKey,forecastAccountId:t.forecastAccountId,name:t.name,balances:i,breakdowns:s,logoUrl:t.logoUrl,icon:t.icon,group:t.group,systemAccountType:t.systemAccountType,category:GT({systemAccountType:t.systemAccountType,baseCategory:t.taxBucket}),isEditable:t.isEditable,isLiability:o,hasMissingDetails:t.hasMissingDetails,canCalculateWithdrawalPenalty:t.canCalculateWithdrawalPenalty,earlyWithdrawalAlertKind:t.earlyWithdrawalAlertKind,needsContributionSetup:t.needsContributionSetup,growthRate:t.growthRate,growthRateMethod:null===(n=t.account)||void 0===n?void 0:n.growthRateMethod,growthRateSchedule:null===(a=t.account)||void 0===a?void 0:a.growthRateSchedule,interestRate:t.interestRate,penaltyRate:null===(r=Qh(t.account))||void 0===r?void 0:r.penaltyRate,isSynthetic:t.isSynthetic,isSystemAccount:t.isSystemAccount,isLinkedAccountDeleted:t.isLinkedAccountDeleted,drift:t.drift}})),o=r.filter((e=>"asset"===e.group)),i=r.filter((e=>"liability"===e.group&&!(Dp(e)&&!a))).map((e=>(0,U.A)((0,U.A)({},e),{},{balances:e.balances.map((e=>Math.abs(e)))}))),s=new Map;o.forEach((e=>{if(e.category){const t=s.get(e.category)||[];s.set(e.category,[...t,e])}}));const c=new Map;s.forEach(((t,n)=>{const a=t.filter(FT),l=e.snapshots.map(((e,t)=>a.reduce(((e,n)=>e+n.balances[t]),0)));c.set(n,l)}));const d=new Map;i.forEach((e=>{if(e.category){const t=d.get(e.category)||[];d.set(e.category,[...t,e])}}));const u=new Map;d.forEach(((t,n)=>{const a=t.filter(FT),l=e.snapshots.map(((e,t)=>a.reduce(((e,n)=>e+n.balances[t]),0)));
1u.set(n,l)}));const m=o.filter(FT),p=e.snapshots.map(((e,t)=>m.reduce(((e,n)=>e+n.balances[t]),0))),g=i.filter(FT),h=e.snapshots.map(((e,t)=>g.reduce(((e,n)=>e+n.balances[t]),0))),v=e.snapshots.map((e=>l.toTodaysDollars(e.netWorth,e.year))),f=new Map,E=new Map;return t.forEach((e=>{if(e.isIncluded)return;const t=GT({systemAccountType:e.systemAccountType,baseCategory:Wh(e.accountType)});if("liability"===e.accountType.group){const n=E.get(t)||[];E.set(t,[...n,e])}else{const n=f.get(t)||[];f.set(t,[...n,e])}})),{assetRows:o,liabilityRows:i,assetsByCategory:s,categoryTotals:c,liabilitiesByCategory:d,liabilityCategoryTotals:u,hiddenAssetsByCategory:f,hiddenLiabilitiesByCategory:E,assetsTotal:p,liabilitiesTotal:h,netWorth:v}},UT=[],VT=[],WT=()=>{const e=Cw(),t=e.projection,n=e.accounts,l=e.rows,r=e.hasUnfundedExpenses,o=e.dollarMode,i=vy(),s=i.openAccount,c=i.openUncategorizedSavings,d=NS().years,u=(()=>{const e=Aw();return BC(e),PC((0,hh.k)((t=>{const n=MC(t.byScenarioId,e);return{collapsedGroupIds:n.accounts.collapsedGroupIds,expandedHiddenCategoryIds:n.accounts.expandedHiddenCategoryIds,toggleCollapsedGroup:t.toggleCollapsedGroup,toggleExpandedAccount:t.toggleExpandedAccount,toggleExpandedHiddenCategory:t.toggleExpandedHiddenCategory}})))})(),m=u.collapsedGroupIds,p=u.expandedHiddenCategoryIds,g=u.toggleCollapsedGroup,h=u.toggleExpandedHiddenCategory,v=(0,a.useMemo)((()=>YT(t,n,l,r,o)),[t,n,l,r,o]);if(!v)return null;const f=v.assetsByCategory,E=v.categoryTotals,y=v.liabilitiesByCategory,b=v.liabilityCategoryTotals,x=v.hiddenAssetsByCategory,w=v.hiddenLiabilitiesByCategory,C=v.assetsTotal,A=v.liabilitiesTotal,I=v.netWorth;return a.createElement(a.Fragment,null,a.createElement(eN,{isTotal:!0},a.createElement(tN,null,a.createElement(jT,null,"Net Worth")),I.map(((e,t)=>a.createElement(wN,{key:_N("total",d[t]),year:d[t],align:"right"},a.createElement(jT,{isNegative:e<0},(0,rl.fw)(e)))))),a.createElement(dN,null,a.createElement(nN,null)),a.createElement(HT,{collapsed:m.has("assets")},a.createElement(tN,{className:"px-sm"},a.createElement(PN,null,a.createElement(fe.SO$,{"aria-label":m.has("assets")?"Expand assets":"Collapse assets",size:"xs",variant:"minimal",className:"text-content-primary",onClick:()=>g("assets")},m.has("assets")?a.createElement(fe.hPJ,null):a.createElement(fe.D39,null)),a.createElement(jT,null,"Assets"))),C.map(((e,t)=>a.createElement(wN,{key:_N("assets-total",d[t]),year:d[t],align:"right"},a.createElement(jT,null,(0,rl.fw)(e)))))),a.createElement(ON,{open:!m.has("assets")},Jk.map((e=>{var t,n;const l=f.get(e),r=null!==(t=x.get(e))&&void 0!==t?t:VT,o=l&&l.length>0,i=r.length>0;if(!o&&!i)return null;const u="assets-".concat(e);var v;if(Xk.has(e))return a.createElement(RT,{key:e,isStandalone:!0,category:e,categoryConfig:Zk[e],accounts:l,totals:null!==(v=E.get(e))&&void 0!==v?v:UT,years:d,isCollapsed:m.has(u),collapseId:u,onToggleCollapse:g,onOpenAccount:s,onOpenUncategorizedSavings:c});const y="hidden-assets-".concat(e);return a.createElement(RT,{key:e,category:e,categoryConfig:Zk[e],accounts:l,hiddenAccounts:r,totals:null!==(n=E.get(e))&&void 0!==n?n:UT,years:d,isCollapsed:m.has(u),collapseId:u,onToggleCollapse:g,isHiddenExpanded:p.has(y),hiddenCategoryId:y,onToggleHidden:h,hiddenKeyPrefix:"hidden-".concat(e,"-"),onOpenAccount:s,onOpenUncategorizedSavings:c})}))),a.createElement(dN,null,a.createElement(nN,null)),a.createElement(HT,{collapsed:m.has("liabilities")},a.createElement(tN,{className:"px-sm"},a.createElement(PN,null,a.createElement(fe.SO$,{"aria-label":m.has("liabilities")?"Expand liabilities":"Collapse liabilities",size:"xs",variant:"minimal",className:"text-content-primary",onClick:()=>g("liabilities")},m.has("liabilities")?a.createElement(fe.hPJ,null):a.createElement(fe.D39,null)),a.createElement(jT,null,"Liabilities"))),A.map(((e,t)=>a.createElement(wN,{key:_N("liabilities-total",d[t]),year:d[t],align:"right"},a.createElement(jT,null,(0,rl.fw)(e)))))),a.createElement(ON,{open:!m.has("liabilities")},Qk.map((e=>{var t,n;const l=y.get(e),r=null!==(t=w.get(e))&&void 0!==t?t:VT,o=l&&l.length>0,i=r.length>0;if(!o&&!i)return null;const u="liabilities-".concat(e);var v;if(Xk.has(e))return a.createElement(RT,{key:e,isStandalone:!0,category:e,categoryConfig:Zk[e],accounts:l,totals:null!==(v=b.get(e))&&void 0!==v?v:UT,years:d,isCollapsed:m.has(u),collapseId:u,onToggleCollapse:g,onOpenAccount:s,onOpenUncategorizedSavings:c});const f="hidden-liabilities-".concat(e);return a.createElement(RT,{key:e,category:e,categoryConfig:Zk[e],accounts:l,hiddenAccounts:r,totals:null!==(n=b.get(e))&&void 0!==n?n:UT,years:d,isCollapsed:m.has(u),collapseId:u,onToggleCollapse:g,isHiddenExpanded:p.has(f),hiddenCategoryId:f,onToggleHidden:h,hiddenKeyPrefix:"hidden-".concat(e,"-"),onOpenAccount:s,onOpenUncategorizedSavings:c})}))))},jT=e=>{let t=e.isNegative,n=e.children;return a.createElement(fe.c8D,{"data-external-id":"main-row-text",size:"lg",weight:"medium",color:t?"danger":"primary",className:"leading-6.5"},n)},HT=e=>{let t=e.collapsed,n=e.children;return a.createElement(MN,{"data-external-id":"group-header-row",divider:t?"none":"secondary"},n)},KT=(e,t)=>{if(Np(e))return{text:(0,rl.fw)(0),color:"content.primary"};const n=(0,rl.fw)(Math.abs(e));return e<0?{text:"-".concat(n),color:t}:{text:n,color:"content.primary"}},qT=e=>KT(e,"content.danger"),$T=e=>KT(e,"content.success"),ZT=(e,t)=>"income"===e?qT(t):$T(t),JT=e=>Np(e)?{text:(0,rl.fw)(0),color:"content.primary"}:{text:(0,rl.fw)(Math.abs(e)),color:"content.primary"},XT=(e,t)=>{const n=(0,rl.fw)(Math.abs(e));if(e<0){if("income"===t)return{text:"-".concat(n),color:"content.danger"};if("expense"===t)return{text:"-".concat(n),color:"content.success"}}return{text:n,color:"content.primary"}},QT=(e,t)=>void 0===e||null===e?{text:"-",color:"content.secondary"}:Np(e)?{text:(0,rl.fw)(0),color:"content.primary"}:XT(e,t),e_=new Map,t_=e=>{const t=xw();return(0,a.useMemo)((()=>e.map((e=>((e,t)=>{if(!e.targetEventId)return e;const n=(null!==t&&void 0!==t?t:[]).find((t=>t.id===e.targetEventId));return n?(0,U.A)((0,U.A)({},e),{},{label:"".concat(e.label," - ").concat(n.name)}):e})(e,t)))),[e,t])},n_={parentRow:"h-9 w-9 rounded-default",subRow:"size-6 rounded-default",cashFlowSubRow:"size-3.5 rounded-sm"},a_=(e,t,n)=>({containerClassName:(0,q.cn)("flex shrink-0 items-center justify-center",Vg[e],n_[n]),iconClassName:Wg[t]}),l_=e=>{var t;let n=e.eventId,l=e.subItems,r=e.years,o=e.onOpenSubRow;const i=bw(),s=null!==(t=null===i||void 0===i?void 0:i.effectTable)&&void 0!==t?t:e_,c=t_(l),d=ww().toTodaysDollars,u=rw().isTableShowingCompareData;return a.createElement(a.Fragment,null,c.map((e=>a.createElement(r_,{key:c_(n,s_(e.effectEmitterId,e.id)),eventId:n,subItem:e,years:r,effectTable:s,onOpenSubRow:o,isTableShowingCompareData:u,toTodaysDollars:d}))))},r_=e=>{let t=e.eventId,n=e.subItem,l=e.years,r=e.effectTable,o=e.onOpenSubRow,i=e.isTableShowingCompareData,s=e.toTodaysDollars;const c=n.effectEmitterId,d=n.id,u=n.subRowIcon,m=n.label,p=n.isFixedPayment,g=s_(c,d);return a.createElement(LN,{"data-external-id":"cash-flow-sub-item-row"},a.createElement(o_,{label:m,subRowIcon:u,effectEmitterId:c,onOpenSubRow:o,isTableShowingCompareData:i,isFixedPayment:p}),a.createElement(i_,{eventId:t,rowKeySuffix:g,effectEmitterId:c,effectId:d,years:l,effectTable:r,toTodaysDollars:s}))},o_=e=>{let t=e.label,n=e.subRowIcon,l=e.effectEmitterId,r=e.onOpenSubRow,o=e.isTableShowingCompareData,i=e.isFixedPayment;const s=n?a_(n.color,n.foregroundColor,"cashFlowSubRow"):null;return a.createElement(tN,{"data-external-id":"cash-flow-sub-item-sticky-label",indentPx:Fg,className:"group justify-between gap-xs pr-sm"},a.createElement("div",{className:"flex min-w-0 flex-1 items-center gap-xs"},n&&s?a.createElement("div",{className:s.containerClassName}
1,a.createElement(sl.ZQ,{name:n.icon,size:10,className:s.iconClassName})):null,a.createElement(xt.v,{className:"min-w-0",size:"small",weight:"book",color:"content.primary",lineHeight:"20px",clampLines:1,title:t},t),i?a.createElement(AS,null):null),r?a.createElement(zN,null,a.createElement(wT,{isTableShowingCompareData:o,onClick:()=>r(l),ariaLabel:"Settings for ".concat(t)})):null)},i_=e=>{let t=e.eventId,n=e.rowKeySuffix,l=e.effectEmitterId,r=e.effectId,o=e.years,i=e.effectTable,s=e.toTodaysDollars;return a.createElement(a.Fragment,null,o.map((e=>{var o;const c=null===(o=i.get(e))||void 0===o?void 0:o.get(l),d=null===c||void 0===c?void 0:c.find((e=>e.id===r)),u=void 0===(null===d||void 0===d?void 0:d.amount)?void 0:s(d.amount,e),m=QT(u,null===d||void 0===d?void 0:d.target),p=m.text,g=m.color;return a.createElement(wN,{key:d_(t,n,e),year:e,align:"right",background:"primary",dashedBorder:!1},a.createElement(xt.v,{size:"small",weight:"book",lineHeight:"20px",color:g},p))})))},s_=(e,t)=>"".concat(e,"__").concat(t),c_=(e,t)=>"subitem-".concat(e,"-").concat(t),d_=(e,t,n)=>"subitem-".concat(e,"-").concat(t,"-").concat(n),u_=e=>{const t=e.rowIdPrefix,n=e.model,l=e.years,r=e.amounts,o=e.variant,i=e.isExpandable,s=e.isExpanded,c=e.expandKey,d=e.isExcluded,u=e.labelOverride,m=e.onToggleExpand,p=e.onOpenEvent,g=rw().isTableShowingCompareData,h=null!==u&&void 0!==u?u:n.displayName,v=d?"secondary":"primary",f="income"===o&&"income"===n.config.eventKind&&n.isHidden,E=a_(n.color,n.foregroundColor,"subRow");return a.createElement(a.Fragment,null,a.createElement(MN,{divider:"primary",background:d?"secondary":void 0},a.createElement(tN,{background:d?"secondary":"primary",className:(0,q.cn)("group justify-between pr-sm",d&&"text-content-secondary")},a.createElement(PN,null,i&&!d&&c?a.createElement(B.L,{icon:s?"chevron-down":"chevron-right",size:"xxsmall",onClick:()=>m(c)}):a.createElement("div",{className:"size-6 shrink-0","aria-hidden":!0}),f?a.createElement("div",{className:(0,q.cn)("flex size-6 shrink-0 items-center justify-center",d&&"opacity-60")},a.createElement(Wl._,{url:null,size:24})):a.createElement("div",{className:(0,q.cn)(E.containerClassName,d&&"opacity-60")},a.createElement(sl.ZQ,{name:n.icon,size:16,className:E.iconClassName})),a.createElement(xt.v,{className:"min-w-0",size:"base",weight:"book",lineHeight:"24px",color:d?"content.secondary":void 0,clampLines:1},h)),d&&a.createElement("div",{className:"group/gear relative grid *:col-start-1 *:row-start-1"},a.createElement("div",{className:" pointer-events-none flex opacity-100 transition-opacity duration-150 ease-out group-focus-within:opacity-0 group-hover:opacity-0 group-has-data-popup-open/gear:opacity-0 "},a.createElement("div",{className:"flex size-8 items-center justify-center text-content-secondary"},a.createElement(fe.yhH,{size:"md"}))),a.createElement(zN,null,a.createElement(wT,{isTableShowingCompareData:g,onClick:()=>p(n.id),ariaLabel:"Settings for ".concat(h)}))),!d&&a.createElement(zN,null,a.createElement(wT,{isTableShowingCompareData:g,onClick:()=>p(n.id),ariaLabel:"Settings for ".concat(h)}))),l.map(((e,l)=>{var i;const s=d?{text:"-",color:"content.secondary"}:ZT(o,null!==(i=null===r||void 0===r?void 0:r[l])&&void 0!==i?i:0),c=s.text,u=s.color;return a.createElement(wN,{key:_N("".concat(t,"-").concat(n.id),e),year:e,align:"right",background:v},a.createElement(xt.v,{size:"base",weight:"book",lineHeight:"24px",color:u},c))}))),m_(e))},m_=e=>{if(!e.isExpandable||e.isExcluded)return null;if("income"===e.variant){const t=e.sectionSubItems,n=e.onOpenSubRow,l=e.isExpanded,r=e.model,o=e.years;return t&&0!==t.length?a.createElement(ON,{open:l},a.createElement(l_,{eventId:r.id,subItems:t,years:o,onOpenSubRow:n})):null}if("expense"===e.variant){const t=e.sectionSubItems,n=e.isExpanded,l=e.model,r=e.years;if(!t||0===t.length)return null;const o=t.map((e=>({id:e.id,label:e.label,targetEventId:e.targetEventId,isFixedPayment:e.isFixedPayment,effectEmitterId:l.id})));return a.createElement(ON,{open:n},a.createElement(l_,{eventId:l.id,subItems:o,years:r}))}return null},p_=e=>
1{let t=e.rows,n=e.variant,l=e.isExpanded,r=e.onToggle,o=e.keyPrefix,i=e.years,s=e.onOpenEvent,c=e.onToggleExpand;return 0===t.length?null:a.createElement(a.Fragment,null,a.createElement(ON,{open:l},t.map((e=>{let t=e.model;return a.createElement(u_,{key:"".concat(o,"-").concat(t.id),rowIdPrefix:o,model:t,years:i,variant:n,isExpandable:!1,isExpanded:!1,isExcluded:!0,onToggleExpand:c,onOpenEvent:s})}))),a.createElement(LN,null,a.createElement(tN,{className:"pr-sm pl-2xl",onClick:r,style:{cursor:"pointer"}},a.createElement(PN,null,a.createElement(B.L,{icon:l?"eye-off":"eye",size:"xxsmall",color:"content.secondary","aria-expanded":l,"aria-label":l?"Collapse ".concat(t.length," excluded ").concat((0,De.td)("event",t.length)):"Show ".concat(t.length," excluded ").concat((0,De.td)("event",t.length))}),a.createElement(xt.v,{size:"small",weight:"book",lineHeight:"20px",color:"content.secondary"},l?"Collapse ".concat(t.length," excluded ").concat((0,De.td)("event",t.length)):"Show ".concat(t.length," excluded ").concat((0,De.td)("event",t.length))))),i.map((e=>a.createElement(wN,{key:_N("".concat(o,"-toggle"),e),year:e})))))},g_=e=>(0,De.Eb)(e.filter((e=>"expense"===e.target)).map((e=>e.amount))),h_=(e,t,n)=>{var a,l;return null!==(a=null===(l=e.get(t))||void 0===l?void 0:l.get(n))&&void 0!==a?a:[]},v_=(e,t,n)=>g_(h_(e,t,n)),f_=(e,t,n)=>n.some((n=>!Np(v_(e,n,t)))),E_=(e,t)=>"cf-row-".concat(e,"-").concat(t),y_=(e,t)=>e.getEffectDefinitions().filter((e=>e.target===t)),b_=(e,t)=>y_(e,t).length>0,x_=(e,t)=>y_(e,"expense").length>0||t.length>0,w_="Payments",C_=e=>{const t=e.years,n=e.rows,l=e.accounts,r=e.onOpenAccount,o=e.variant,i=rw().isTableShowingCompareData;if("yearlyLivingNested"===o)return a.createElement(a.Fragment,null,n.map((e=>a.createElement(LN,{key:"cf-yl-loan-".concat(e.forecastAccountId)},a.createElement(tN,{background:"primary",className:"group justify-between pr-sm",indentPx:Fg},a.createElement(PN,null,a.createElement(Dw,A_(l,e.forecastAccountId)),a.createElement(xt.v,{className:"min-w-0",size:"small",weight:"book",color:"content.primary",lineHeight:"20px",clampLines:1,title:e.name},e.name),a.createElement(AS,null)),a.createElement(zN,null,a.createElement(wT,{isTableShowingCompareData:i,onClick:()=>r(e.forecastAccountId),ariaLabel:"Account settings for ".concat(e.name)}))),t.map(((t,n)=>{var l;const r=null!==(l=e.paymentsByYearIndex[n])&&void 0!==l?l:0,o=$T(r),i=o.text,s=o.color;return a.createElement(wN,{key:_N("cf-yl-loan-".concat(e.forecastAccountId),t),year:t,align:"right",background:"primary"},a.createElement(xt.v,{size:"small",weight:"book",lineHeight:"20px",color:s},i))}))))));const s=e.rowIdPrefix,c=e.expandedEventKeys,d=e.onToggleExpand;return a.createElement(a.Fragment,null,n.map((e=>{const n=(o=e.forecastAccountId,E_("expense","debt-".concat(o)));var o;const u=c.has(n);return a.createElement(a.Fragment,{key:"".concat(s,"-").concat(e.forecastAccountId)},a.createElement(MN,{divider:"primary"},a.createElement(tN,{background:"primary",className:"group justify-between pr-sm"},a.createElement(PN,null,a.createElement(B.L,{icon:u?"chevron-down":"chevron-right",size:"xxsmall",onClick:()=>d(n),"aria-expanded":u,"aria-label":u?"Collapse":"Expand"}),a.createElement(Dw,A_(l,e.forecastAccountId)),a.createElement(xt.v,{className:"min-w-0",size:"base",weight:"book",lineHeight:"24px",clampLines:1,title:e.name},e.name)),a.createElement(zN,null,a.createElement(wT,{isTableShowingCompareData:i,onClick:()=>r(e.forecastAccountId),ariaLabel:"Account settings for ".concat(e.name)}))),t.map(((t,n)=>{var l;const r=null!==(l=e.paymentsByYearIndex[n])&&void 0!==l?l:0,o=$T(r),i=o.text,c=o.color;return a.createElement(wN,{key:_N("".concat(s,"-").concat(e.forecastAccountId),t),year:t,align:"right",background:"primary"},a.createElement(xt.v,{size:"base",weight:"book",lineHeight:"24px",color:c},i))}))),a.createElement(ON,{open:u},a.createElement(LN,null,a.createElement(tN,{background:"primary",className:"gap-2xs pr-sm",indentPx:Fg},a.createElement(xt.v,{className:"min-w-0",size:"small",weight:"book",color:"content.primary",lineHeight:"20px",clampLine
1s:1,title:w_},w_),a.createElement(AS,null)),t.map(((t,n)=>{var l;const r=null!==(l=e.paymentsByYearIndex[n])&&void 0!==l?l:0,o=$T(r),i=o.text,c=o.color;return a.createElement(wN,{key:_N("".concat(s,"-payments-").concat(e.forecastAccountId),t),year:t,align:"right",background:"primary"},a.createElement(xt.v,{size:"small",weight:"book",lineHeight:"20px",color:c},i))})))))})))},A_=(e,t)=>{var n,a,l,r;const o=e.find((e=>e.id===t));return{logoUrl:null!==(n=null===o||void 0===o||null===(a=o.metadata)||void 0===a?void 0:a.logoUrl)&&void 0!==n?n:void 0,icon:null!==(l=null===o||void 0===o||null===(r=o.metadata)||void 0===r?void 0:r.icon)&&void 0!==l?l:void 0,sourceEventExternalId:null===o||void 0===o?void 0:o.sourceEventExternalId,accountId:t,size:24}},I_="Other annual expenses",k_=e=>{let t=e.annualExpenseModel,n=e.years,l=e.amounts,r=e.otherAnnualExpenseAmounts,o=e.debtRowsInYearlyLiving,i=e.accounts,s=e.isExpandable,c=e.hasAnnualExpenseSubItem,d=e.expandKey,u=e.isExpanded,m=e.onToggleExpand,p=e.onOpenAssumptions,g=e.onOpenAccount;const h=rw().isTableShowingCompareData;return a.createElement(a.Fragment,null,a.createElement(MN,{divider:"primary"},a.createElement(tN,{background:"primary",className:"group justify-between pr-sm"},a.createElement(PN,null,s?a.createElement(B.L,{icon:u?"chevron-down":"chevron-right",size:"xxsmall",onClick:()=>m(d)}):a.createElement("div",{className:"size-6 shrink-0","aria-hidden":!0}),a.createElement(xt.v,{className:"min-w-0",size:"base",weight:"book",lineHeight:"24px",clampLines:1},"Yearly living expenses")),a.createElement(zN,null,a.createElement(wT,{isTableShowingCompareData:h,onClick:p,ariaLabel:"Edit assumptions"}))),n.map(((e,n)=>{var r;const o=null!==(r=l[n])&&void 0!==r?r:0,i=ZT("expense",o),s=i.text,c=i.color;return a.createElement(wN,{key:_N("cf-yearly-living-".concat(t.id),e),year:e,align:"right",background:"primary"},a.createElement(xt.v,{size:"base",weight:"book",lineHeight:"24px",color:c},s))}))),s?a.createElement(ON,{open:u},c?a.createElement(LN,null,a.createElement(tN,{indentPx:Fg,className:"pr-sm"},a.createElement("div",{className:"flex min-w-0 items-center gap-xs"},a.createElement(xt.v,{className:"min-w-0",size:"small",weight:"book",color:"content.primary",lineHeight:"20px",clampLines:1,title:I_},I_),a.createElement(fe.cIj,{size:"3xs",content:"Your Yearly living expenses minus the payments shown below. Expenses drop automatically once a debt is paid off.",iconSize:"xs"}))),n.map(((e,n)=>{var l;const o=null!==(l=r[n])&&void 0!==l?l:0,i=QT(o,"expense"),s=i.text,c=i.color;return a.createElement(wN,{key:_N("cf-yl-annual-".concat(t.id),e),year:e,align:"right",background:"primary"},a.createElement(xt.v,{size:"small",weight:"book",lineHeight:"20px",color:c},s))}))):null,a.createElement(C_,{variant:"yearlyLivingNested",years:n,rows:o,accounts:i,onOpenAccount:g})):null)},S_=e=>{let t=e.years,n=e.expenses,l=e.expenseCollapsed,r=e.onToggleExpenseSection,o=e.yearlyLiving,i=e.debtPaymentRowsNotInYearlyLiving,s=e.expenseRows,c=e.expenseExcludedRows,d=e.isExpenseExcludedExpanded,u=e.onToggleExpenseExcludedExpanded,m=e.accounts,p=e.expandedExpenseRowKeys,g=e.onToggleExpand,h=e.onOpenEvent,v=e.onOpenAccount,f=e.onOpenAssumptions;return a.createElement(a.Fragment,null,a.createElement(MN,{divider:"secondary"},a.createElement(tN,{className:"px-sm"},a.createElement(PN,null,a.createElement(B.L,{icon:l?"chevron-right":"chevron-down",size:"xsmall",onClick:r,"aria-expanded":!l,"aria-label":l?"Expand expenses":"Collapse expenses"}),a.createElement(xt.v,{size:"large",weight:"medium",lineHeight:"26px"},"Expenses"))),n.map(((e,n)=>{const l=$T(e),r=l.text,o=l.color;return a.createElement(wN,{key:_N("cf-expense-total",t[n]),year:t[n],align:"right"},a.createElement(xt.v,{size:"large",weight:"medium",lineHeight:"26px",color:o},r))}))),a.createElement(ON,{open:!l},o?a.createElement(k_,{annualExpenseModel:o.model,years:t,amounts:o.amounts,otherAnnualExpenseAmounts:o.otherAnnualExpenseAmounts,debtRowsInYearlyLiving:o.debtRowsInYearlyLiving,accounts:m,isExpandable:o.isExpandable,hasAnnualExpenseSubItem:o.hasAnnualExpenseSubItem,expandKey:E_("expense",o.model.id),isExpanded:p.has(E_("expense",o.model.id)),onToggleExpand:g,onOpenAssumptions:f,onOpenAccount:v}):null,a.createElement(C_,{variant:"expenseSectionPeer",rowIdPrefix:"cf-debt",years:t,rows:i,accounts:m,expandedEventKeys:p,onToggleExpand:g,onOpenAccount:v}),s.map((e=>{const n=E_("expense",e.model.id);return a.createElement(u_,{key:"cf-exp-".concat(e.model.id),rowIdPrefix:"cf-exp",model:e.model,years:t,amounts:e.amounts,variant:"expense",isExpandable:e.isExpandable,expandKey:n,sectionSubItems:e.sectionSubItems,isExpanded:p.has(n),onToggleExpand:g,onOpenEvent:h})})),a.createElement(p_,{rows:c,variant:"expense",isExpanded:d,onToggle:u,keyPrefix:"cf-exp-excl",years:t,onOpenEvent:h,onToggleExpand:g})))},N_=e=>{let t=e.row,n=e.years,l=e.accounts,r=e.isExpanded,o=e.onToggleExpand,i=e.onOpenAccount;const s=rw().isTableShowingCompareData,c=t.name,d=t.rowKey.serialized,u=D_(l,t.forecastAccountId);return a.createElement(a.Fragment,null,a.createElement(LN,null,a.createElement(tN,{background:"primary",className:"group justify-between pr-sm",indentPx:68},a.createElement(PN,null,t.hasTaxBreakdown?a.createElement(B.L,{icon:r?"chevron-down":"chevron-right",size:"xxsmall",onClick:()=>o(d),"aria-expanded":r,"aria-label":r?"Collapse ".concat(t.name," withdrawal breakdown"):"Expand ".concat(t.name," withdrawal breakdown")}):a.createElement("div",{className:"size-6 shrink-0","aria-hidden":!0}),a.createElement(Dw,u),a.createElement(xt.v,{className:"min-w-0",size:"small",weight:"book",color:"content.primary",lineHeight:"20px",clampLine
1s:1,title:c},c)),t.isEditable&&a.createElement(zN,null,a.createElement(wT,{isTableShowingCompareData:s,onClick:()=>i(t.forecastAccountId),ariaLabel:"Account settings for ".concat(t.name)}))),n.map(((e,n)=>{var l;const r=JT(null!==(l=t.grossByYearIndex[n])&&void 0!==l?l:0),o=r.text,i=r.color;return a.createElement(wN,{key:_N("cf-wd-acct-".concat(d),e),year:e,align:"right",background:"primary"},a.createElement(xt.v,{size:"small",weight:"book",lineHeight:"20px",color:i},o))}))),t.hasTaxBreakdown?a.createElement(ON,{open:r},a.createElement(T_,{row:t,years:n,indent:132,onOpenAccount:i})):null)},T_=e=>{let t=e.row,n=e.years,l=e.indent,r=e.onOpenAccount;const o=rw().isTableShowingCompareData,i=t.rowKey.serialized,s=t.taxByYearIndex.some((e=>!Np(e))),c=t.penaltyByYearIndex.some((e=>!Np(e))),d=r&&!o?()=>r(t.forecastAccountId):void 0;return a.createElement(a.Fragment,null,a.createElement(__,{label:"Discretionary",keyPrefix:"cf-wd-acct-".concat(i,"-discretionary"),valuesByYearIndex:t.discretionaryByYearIndex,years:n,kind:"amount",indent:l}),s?a.createElement(__,{label:"Tax",keyPrefix:"cf-wd-acct-".concat(i,"-tax"),valuesByYearIndex:t.taxByYearIndex,years:n,kind:"tax",indent:l}):null,c?a.createElement(__,{label:"Withdrawal penalty",keyPrefix:"cf-wd-acct-".concat(i,"-penalty"),valuesByYearIndex:t.penaltyByYearIndex,years:n,kind:"tax",indent:l,trailing:a.createElement(fN,{penaltyRate:t.penaltyRate,onClick:d,readOnly:o})}):null)},__=e=>{let t=e.label,n=e.keyPrefix,l=e.valuesByYearIndex,r=e.years,o=e.kind,i=e.indent,s=e.trailing;return a.createElement(LN,{"data-external-id":"sub-row"},a.createElement(tN,{background:"primary",className:"justify-between gap-xs pr-sm",indentPx:i},a.createElement(xt.v,{className:"min-w-0",size:"small",weight:"book",color:"content.primary",lineHeight:"20px",clampLines:1,title:t},t),s),r.map(((e,t)=>{var r;const i=null!==(r=l[t])&&void 0!==r?r:0,s="tax"===o?JT(i):JT(i),c=s.text,d=s.color;return a.createElement(wN,{key:_N(n,e),year:e,align:"right",background:"primary"},a.createElement(xt.v,{size:"small",weight:"book",lineHeight:"20px",color:d},c))})))},D_=(e,t)=>{var n,a,l,r;const o=e.find((e=>e.id===t));return{logoUrl:null!==(n=null===o||void 0===o||null===(a=o.metadata)||void 0===a?void 0:a.logoUrl)&&void 0!==n?n:void 0,icon:null!==(l=null===o||void 0===o||null===(r=o.metadata)||void 0===r?void 0:r.icon)&&void 0!==l?l:void 0,sourceEventExternalId:null===o||void 0===o?void 0:o.sourceEventExternalId,accountId:t,size:24}},R_=e=>{let t=e.category,n=e.years,l=e.accounts,r=e.isExpanded,o=e.onToggleExpand,i=e.expandedAccountIds,s=e.onToggleExpandAccount,c=e.onOpenAccount;const d=rw().isTableShowingCompareData,u="uncategorized-savings"===t.category&&1===t.accounts.length?t.accounts[0]:void 0,m=!u||u.hasTaxBreakdown;return a.createElement(a.Fragment,null,a.createElement(MN,{divider:"primary"},a.createElement(tN,{background:"primary",className:u?"group justify-between pr-sm":"pr-sm"},a.createElement(PN,null,m?a.createElement(B.L,{icon:r?"chevron-down":"chevron-right",size:"xxsmall",onClick:()=>o(t.category),"aria-expanded":r,"aria-label":r?"Collapse ".concat(t.label):"Expand ".concat(t.label)}):a.createElement("div",{className:"size-6 shrink-0","aria-hidden":!0}),a.createElement(xt.v,{className:"min-w-0",size:"base",weight:"book",lineHeight:"24px",clampLines:1},t.label)),(null===u||void 0===u?void 0:u.isEditable)&&a.createElement(zN,null,a.createElement(wT,{isTableShowingCompareData:d,onClick:()=>c(u.forecastAccountId),ariaLabel:"Account settings for ".concat(t.label)}))),n.map(((e,n)=>{var l;const r=JT(null!==(l=t.totalByYearIndex[n])&&void 0!==l?l:0),o=r.text,i=r.color;return a.createElement(wN,{key:_N("cf-wd-cat-".concat(t.category),e),year:e,align:"right",background:"primary"},a.createElement(xt.v,{size:"base",weight:"book",lineHeight:"24px",color:i},o))}))),a.createElement(ON,{open:m&&r},u?a.createElement(T_,{row:u,years:n,indent:Fg,onOpenAccount:c}):t.accounts.map((e=>{const t=e.rowKey.serialized;return a.createElement(N_,{key:"cf-wd-acct-".concat(t),row:e,years:n,accounts:l,isExpanded:i.has(t),onToggleExpand:s,onOpenAccount:c})}))))},M_=e=>{let t=e.data,n=e.years,l=e.accounts,r=e.isCollapsed,o=e.onToggleSection,i=e.expandedCategoryIds,s=e.onToggleExpandCategory,c=e.expandedAccountIds,d=e.onToggleExpandAccount,u=e.onOpenAccount;return a.createElement(a.Fragment,null,a.createElement(MN,{divider:"secondary"},a.createElement(tN,{className:"px-sm"},a.createElement(PN,null,a.createElement(B.L,{icon:r?"chevron-right":"chevron-down",size:"xsmall",onClick:o,"aria-expanded":!r,"aria-label":r?"Expand withdrawals":"Collapse withdrawals"}),a.createElement(xt.v,{size:"large",weight:"medium",lineHeight:"26px"},"Withdrawals"))),t.totalByYearIndex.map(((e,t)=>{const l=JT(e),r=l.text,o=l.color;return a.createElement(wN,{key:_N("cf-wd-total",n[t]),year:n[t],align:"right"},a.createElement(xt.v,{size:"large",weight:"medium",lineHeight:"26px",color:o},r))}))),a.createElement(ON,{open:!r},t.categories.map((e=>a.createElement(R_,{key:"cf-wd-cat-".concat(e.category),category:e,years:n,accounts:l,isExpanded:i.has(e.category),onToggleExpand:s,expandedAccountIds:c,onToggleExpandAccount:d,onOpenAccount:u})))))}
1,L_=["income","newJob","socialSecurity","windfall"],O_=(e,t,n)=>(0,De.Eb)(((e,t,n)=>{const a=e.get(t);if(!a)return[];const l=[];for(const i of a){var r=(0,o.A)(i,2);const e=r[0],t=r[1];for(const a of t)"income"===a.target&&(e!==n?a.targetEventId===n&&l.push(a):a.targetEventId||l.push(a))}return l})(e,t,n).map((e=>e.amount))),P_=e=>{let t=e.settings,n=e.eventModels,a=e.effectTable,l=e.years;const r=n.filter((e=>e.isIncluded)),o=((e,t)=>{const n=new Set(e.participants.filter((e=>e.hiddenFromForecast)).map((e=>e.userId))),a=e=>{const t=e.ownerId;return void 0===t||null===t||!n.has(t)},l=new Map;for(const o of t)o.isIncluded&&a(o)&&(o.isHidden||(r=o.config.eventKind,!L_.includes(r))?o.isHidden&&"income"===o.config.eventKind&&l.set(o.id,o):l.set(o.id,o));var r;return[...l.values()].sort(_g)})(t,n);return o.map((e=>{const t=((e,t)=>{const n=e.id,a=e.getEffectDefinitions().filter((e=>"income"===e.target&&!e.targetEventId)).map((e=>({id:e.id,label:e.label,effectEmitterId:n}))),l=[];for(const r of t)if(r.id!==n)for(const e of r.getEffectDefinitions())"income"===e.target&&e.targetEventId===n&&l.push({model:r,defId:e.id,label:r.displayName});return[...a,...[...l].sort(((e,t)=>_g(e.model,t.model))).map((e=>({id:e.defId,label:e.label,effectEmitterId:e.model.id,subRowIcon:{icon:e.model.icon,color:e.model.color,foregroundColor:e.model.foregroundColor}})))]})(e,r);return{model:e,amounts:l.map((t=>O_(a,t,e.id))),sectionSubItems:t,isExpandable:t.length>=1}}))},B_={cash:"Cash withdrawals","tax-deferred":"Tax-deferred investments","taxable-investments":"Taxable investments","tax-free-investments":"Tax-free investments","uncategorized-savings":"Extra savings"},z_=["cash","tax-deferred","taxable-investments","tax-free-investments","uncategorized-savings"],F_=(e,t,n,a)=>{const l=new Map(t.map((e=>[e.year,e]))),i=new Map;e.forEach((e=>{var t;if(!e.account)return;const n=(e=>_p(e)?"uncategorized-savings":Rp(e)?null:(0,r.YW)(e.taxBucket).with("cash",(()=>"cash")).with("tax-deferred",(()=>"tax-deferred")).with("taxable-investments",(()=>"taxable-investments")).with("tax-free-investments",(()=>"tax-free-investments")).otherwise((()=>null)))(e);n&&i.set(e.rowKey.serialized,{displayCategory:n,name:e.name,forecastAccountId:e.forecastAccountId,isEditable:e.isEditable,rowKey:e.rowKey,penaltyRate:null===(t=Qh(e.account))||void 0===t?void 0:t.penaltyRate})}));const s=new Map;for(const r of i){var c=(0,o.A)(r,2);const e=c[0],t=c[1],a=[],i=[],d=[],u=[];n.forEach((e=>{var n,r;const o=fp(null!==(n=null===(r=l.get(e))||void 0===r?void 0:r.accounts)&&void 0!==n?n:[],t.rowKey),s=null===o||void 0===o?void 0:o.breakdown,c=s?Math.abs(s.withdrawals):0,m=s?Math.abs(s.withdrawalTax):0,p=s?Math.abs(s.withdrawalPenalty):0;a.push((0,De.Eb)([c,m,p])),i.push(c),d.push(m),u.push(p)})),a.every(Np)||s.set(e,{forecastAccountId:t.forecastAccountId,rowKey:t.rowKey,name:t.name,isEditable:t.isEditable,grossByYearIndex:a,hasTaxBreakdown:d.some((e=>!Np(e)))||u.some((e=>!Np(e))),discretionaryByYearIndex:i,taxByYearIndex:d,penaltyByYearIndex:u,penaltyRate:t.penaltyRate})}const d=new Map(z_.map((e=>[e,[]])));for(const r of i){var u=(0,o.A)(r,2);const e=u[0],t=u[1],n=s.get(e);n&&d.get(t.displayCategory).push(n)}const m=new Map(a.map(((e,t)=>[e,t]))),p=[];if(z_.forEach((e=>{const t=[...d.get(e)].sort(((e,t)=>{var n,a;const l=null!==(n=m.get(e.rowKey.serialized))&&void 0!==n?n:1/0,r=null!==(a=m.get(t.rowKey.serialized))&&void 0!==a?a:1/0;return l!==r?l-r:e.name.localeCompare(t.name)}));if(0===t.length)return;const a=n.map(((e,n)=>(0,De.Eb)(t.map((e=>{var t;return null!==(t=e.grossByYearIndex[n])&&void 0!==t?t:0})))));p.push({category:e,label:B_[e],totalByYearIndex:a,accounts:t})})),0===p.length)return null;return{totalByYearIndex:n.map(((e,t)=>(0,De.Eb)(p.map((e=>{var n;return null!==(n=e.totalByYearIndex[t])&&void 0!==n?n:0}))))),categories:p}},G_=e=>{let t=e.projection,n=e.eventModels,a=e.years,l=e.settings,r=e.accounts,o=e.rows,i=e.dollarMode,s=e.withdrawalOrderAccountIds,c=void 0===s?[]:s;if(!t||0===t.snapshots.length)return null;const d=t.effectTable,u=t.snapshots,m=e=>e.map(((e,t)=>i.toTodaysDollars(e,a[t]))),p=e=>m(a.map((t=>v_(d,t,e)))),g=((e,t,n)=>{const a=new Map(e.map((e=>[e.year,e]))),l=new Map;e.forEach((e=>
1{e.accounts.forEach((e=>{"liability"!==e.accountType.group||l.has(e.forecastAccountId)||l.set(e.forecastAccountId,e.name)}))}));const r=new Set;return t.forEach((e=>{const t=a.get(e);t&&t.accounts.forEach((e=>{var t,a;if("liability"!==e.accountType.group)return;if(!((e,t)=>{var n;return!0!==(null===(n=t.find((t=>t.id===e)))||void 0===n?void 0:n.isSynthetic)})(e.forecastAccountId,n))return;const l=null!==(t=null===(a=e.breakdown)||void 0===a?void 0:a.payments)&&void 0!==t?t:0;Np(l)||r.add(e.forecastAccountId)}))})),[...r].sort(((e,t)=>{var n,a;return(null!==(n=l.get(e))&&void 0!==n?n:"").localeCompare(null!==(a=l.get(t))&&void 0!==a?a:"")})).map((e=>{var n;return{forecastAccountId:e,name:null!==(n=l.get(e))&&void 0!==n?n:"Debt",paymentsByYearIndex:t.map((t=>{var n,l;const r=a.get(t),o=null===r||void 0===r?void 0:r.accounts.find((t=>t.forecastAccountId===e));return null!==(n=null===o||void 0===o||null===(l=o.breakdown)||void 0===l?void 0:l.payments)&&void 0!==n?n:0}))}}))})(u,a,r).map((e=>(0,U.A)((0,U.A)({},e),{},{paymentsByYearIndex:m(e.paymentsByYearIndex)}))),h=((e,t)=>{const n=[],a=[];for(const r of e){!1!==(null===(l=t.find((e=>e.id===r.forecastAccountId)))||void 0===l?void 0:l.reduceExpensesForPaidOffDebt)?n.push(r):a.push(r)}var l;return{inYearlyLiving:n,notInYearlyLiving:a}})(g,r),v=h.inYearlyLiving,f=h.notInYearlyLiving,E=(e=>{const t=e.filter((e=>e.isVisibleInForecast));return{included:t.filter((e=>e.isIncluded)).sort(_g),excluded:t.filter((e=>!e.isIncluded)).sort(_g)}})(n),y=E.included,b=E.excluded,x=P_({settings:l,eventModels:n,effectTable:d,years:a}).map((e=>(0,U.A)((0,U.A)({},e),{},{amounts:m(e.amounts)}))),w=y.filter((e=>f_(d,e.id,a))),C=n.find((e=>"annualExpense"===e.config.eventKind&&Boolean(e.isHidden)));const A=null!==C&&void 0!==C&&C.isIncluded&&f_(d,C.id,a)?(e=>{let t=e.annualExpenseModel,n=e.otherAnnualExpenseAmounts,a=e.debtRowsInYearlyLiving;return{model:t,amounts:n.map(((e,t)=>(0,De.Eb)([e,...a.map((e=>{var n;return null!==(n=e.paymentsByYearIndex[t])&&void 0!==n?n:0}))]))),isExpandable:x_(t,a),hasAnnualExpenseSubItem:y_(t,"expense").length>0,otherAnnualExpenseAmounts:n,debtRowsInYearlyLiving:a}})({annualExpenseModel:C,otherAnnualExpenseAmounts:p(C.id),debtRowsInYearlyLiving:v}):null,I=w.map((e=>({model:e,amounts:p(e.id),sectionSubItems:y_(e,"expense"),isExpandable:b_(e,"expense")}))),k=(e=>{const t=e=>e.getEffectDefinitions().some((e=>"income"===e.target));return{incomeExcluded:e.filter(t),expenseExcluded:e.filter((e=>!t(e)))}})(b),S=k.incomeExcluded,N=k.expenseExcluded,T=Y_(F_(o,u,a,c),m),_=a.map(((e,t)=>(0,De.Eb)(x.map((e=>{var n;return null!==(n=e.amounts[t])&&void 0!==n?n:0}))))),D=a.map(((e,t)=>{var n;return(0,De.Eb)([...I.map((e=>{var n;return null!==(n=e.amounts[t])&&void 0!==n?n:0})),null!==(n=null===A||void 0===A?void 0:A.amounts[t])&&void 0!==n?n:0,...f.map((e=>{var n;return null!==(n=e.paymentsByYearIndex[t])&&void 0!==n?n:0}))])})),R=a.map(((e,t)=>{var n,l,r,o;return(0,De.Eb)([null!==(n=_[t])&&void 0!==n?n:0,-(null!==(l=D[t])&&void 0!==l?l:0),i.toTodaysDollars(null!==(r=null===(o=u[t])||void 0===o?void 0:o.netWithdrawals)&&void 0!==r?r:0,a[t])])}));return{income:_,expenses:D,netCashFlow:R,snapshots:u,incomeStreamRows:x,expenseRows:I,incomeExcludedRows:S.map((e=>({model:e}))),expenseExcludedRows:N.map((e=>({model:e}))),yearlyLiving:A,debtPaymentRowsNotInYearlyLiving:f,withdrawalsSection:T}},Y_=(e,t)=>e?{totalByYearIndex:t(e.totalByYearIndex),categories:e.categories.map((e=>(0,U.A)((0,U.A)({},e),{},{totalByYearIndex:t(e.totalByYearIndex),accounts:e.accounts.map((e=>(0,U.A)((0,U.A)({},e),{},{grossByYearIndex:t(e.grossByYearIndex),discretionaryByYearIndex:t(e.discretionaryByYearIndex),taxByYearIndex:t(e.taxByYearIndex),penaltyByYearIndex:t(e.penaltyByYearIndex)})))})))}:null,U_="cf-income",V_="cf-expense",W_="cf-withdrawals",j_=()=>{const e=(()=>{const e=rw(),t=e.isTableShowingCompareData,n=e.compare,l=WE(),r=XE(),o=KE(),i=QE(),s=ow(),c=wE((e=>e.householdUserIds)),d=cy(),u=(0,a.useMemo)((()=>d.map((e=>e.rowKey.serialized))),[d]),m=sw(t,n,l,cw),p=sw(t,n,r,uw),g=sw(t,n,o,dw),h=sw(t,n,i,pw),v=sw(t,n,s,gw),f=sw(t,n,u,fw);return{projection:m,eventModels:p,accounts:g,rows:yw(m,g,h,c),settings:h,dollarMode:v,withdrawalOrderAccountIds:f}})(),t=e.projection,n=e.eventModels,l=e.accounts,r=e.rows,o=e.settings,i=e.dollarMode,s=e.withdrawalOrderAccountIds,c=NS().years,d=vy(),u=d.openEvent,m=d.openAccount,p=d.openAssumptions,g=(()=>{const e=Aw();return BC(e),PC((0,hh.k)((t=>{const n=MC(t.byScenarioId,e);return{collapsedSectionIds:n.cashFlow.collapsedSectionIds,expandedIncomeEventIds:n.cashFlow.expandedIncomeEventIds,expandedExpenseRowKeys:n.cashFlow.expandedExpenseRowKeys,expandedWithdrawalCategoryIds:n.cashFlow.expandedWithdrawalCategoryIds,expandedWithdrawalAccountIds:n.cashFlow.expandedWithdrawalAccountIds,isIncomeExcludedExpanded:n.cashFlow.isIncomeExcludedExpanded,isExpenseExcludedExpanded:n.cashFlow.isExpenseExcludedExpanded,toggleCollapsedCashFlowSection:t.toggleCollapsedCashFlowSection,toggleExpandedIncomeEvent:t.toggleExpandedIncomeEvent,toggleExpandedExpenseRow:t.toggleExpandedExpenseRow,toggleExpandedWithdrawalCategory:t.toggleExpandedWithdrawalCategory,toggleExpandedWithdrawalAccount:t.toggleExpandedWithdrawalAccount,toggleIncomeExcludedExpanded:t.toggleIncomeExcludedExpanded,toggleExpenseExcludedExpanded:t.toggleExpenseExcludedExpanded}})))})(),h=g.collapsedSectionIds,v=g.expandedIncomeEventIds,f=g.expandedExpenseRowKeys,E=g.expandedWithdrawalCategoryIds,y=g.expandedWithdrawalAccountIds,b=g.isIncomeExcludedExpanded,x=g.isExpenseExcludedExpanded,w=g.toggleCollapsedCashFlowSection,C=g.toggleExpandedIncomeEvent,A=g.toggleExpandedExpenseRow,I=g.toggleExpandedWithdrawalCategory,k=g.toggleExpandedWithdrawalAccount,S=g.toggleIncomeExcludedExpanded,N=g.toggleExpenseExcludedExpanded,T=h.has(U_),_=h.has(V_),D=h.has(W_),R=(0,a.useMemo)((()=>G_({projection:t,eventModels:n,years:c,settings:o,accounts:l,rows:r,dollarMode:i,withdrawalOrderAccountIds:s})),[t,n,c,o,l,r,i,s]);if(!R)return null;const M=R.income,L=R.expenses,O=R.netCashFlow,P=R.incomeStreamRows,z=R.expenseRows,F=R.incomeExcludedRows,G=R.expenseExcludedRows,Y=R.yearlyLiving,U=R.debtPaymentRowsNotInYearlyLiving,V=R.withdrawalsSection;return a.createElement(a.Fragment,null,a.createElement(MN,{divider:"secondary"},a.createElement(tN,{className:"px-sm"},a.createElement(PN,null,a.createElement(B.L,{icon:T?"chevron-right":"chevron-down",size:"xsmall",onClick:()=>w(U_),"aria-expanded":!T,"aria-label":T?"Expand income":"Collapse income"}),a.createElement(xt.v,{size:"large",weight:"medium",lineHeight:"26px"},"Income"))),M.map(((e,t)=>{const n=qT(e),l=n.text,r=n.color;return a.createElement(wN,{key:_N("cf-income-total",c[t]),year:c[t],align:"right"},a.createElement(xt.v,{size:"large",weight:"medium",lineHeight:"26px",color:r},l))}))),a.createElement(ON,{open:!T},P.map((e=>a.createElement(u_,{key:"cf-inc-".concat(e.model.id),rowIdPrefix:"cf-inc",model:e.model,years:c,amounts:e.amounts,variant:"income",isExpandable:e.isExpandable,expandKey:e.model.id,sectionSubItems:e.sectionSubItems,isExpanded:v.has(e.model.id),onToggleExpand:C,onOpenEvent:u,onOpenSubRow:u}))),a.createElement(p_,{rows:F,variant:"income",isExpanded:b,onToggle:S,keyPrefix:"cf-inc-excl",years:c,onOpenEvent:u,onToggleExpand:C})),a.createElement(dN,null,a.createElement(nN,null)),a.createElement(S_,{years:c,expenses:L,expenseCollapsed:_,onToggleExpenseSection:()=>w(V_),yearlyLiving:Y,debtPaymentRowsNotInYearlyLiving:U,expenseRows:z,expenseExcludedRows:G,isExpenseExcludedExpanded:x,onToggleExpenseExcludedExpanded:N,accounts:l,expandedExpenseRowKeys:f,onToggleExpand:A,onOpenEvent:u,onOpenAccount:m,onOpenAssumptions:p}),V?a.createElement(a.Fragment,null,a.createElement(dN,null,a.createElement(nN,null)),a.createElement(M_,{data:V,years:c,accounts:l,isCollapsed:D,onToggleSection:()=>w(W_),expandedCategoryIds:E,onToggleExpandCategory:I,expandedAccountIds:y,onToggleExpandAccount:k,onOpenAccount:m})):null,a.createElement(dN,null,a.createElement(nN,null)),a.createElement(eN,{isTotal:!0},a.createElement(tN,null,a.createElement(xt.v,{size:"large",weight:"medium",lineHeight:"26px"},"Net Cash Flow")),O.map(((e,t)=>{const n=(e=>KT(e,"content.danger"))(e),l=n.text,r=n.color;return a.createElement(wN,{key:_N("cf-net",c[t]),year:c[t],align:"right"},a.createElement(xt.v,{size:"large",weight:"medium",lineHeight:"26px",color:r},l))}))))};var H_=n(22453),K_=n(24708),q_=n(26232);const $_=(e,t)=>
1e.x<t.x+t.width&&t.x<e.x+e.width&&e.y<t.y+t.height&&t.y<e.y+e.height,Z_=(e,t)=>({x:e.x-t,y:e.y-t,width:e.width+2*t,height:e.height+2*t}),J_=e=>{var t;const n=e.slots,a=e.label,l=e.obstacles,r=e.softObstacles,o=void 0===r?[]:r,i=e.plot,s=e.padding,c=e.previousX,d=e.previousPreferEdge,u=Z_({x:i.left,y:i.top,width:i.right-i.left,height:i.bottom-i.top},-s),m=i.left+.6*(i.right-i.left);let p=null,g=null,h=null,v=null;for(const M of n){const e=M.bottom-M.top;if(e<a.height+2*s)continue;const t=a.height/2,n=Math.max(M.top+t,u.y+t),r=Math.min(M.bottom-t,u.y+u.height-t),f=e=>({x:M.x-a.width/2,y:e-t,width:a.width,height:a.height}),E=e=>{return t=f(e),n=u,t.x>=n.x&&t.y>=n.y&&t.x+t.width<=n.x+n.width&&t.y+t.height<=n.y+n.height&&!l.some((t=>$_(Z_(t,s),f(e))));var t,n};let y,b=0;if(void 0===M.preferEdge){const e=(M.top+M.bottom)/2;E(e)&&(y=e)}else{const e="top"===M.preferEdge?n:r,t="top"===M.preferEdge?1:-1;for(let a=e;a>=n&&a<=r;a+=t)if(E(a)){y=a;break}void 0!==y&&(b=Math.abs(y-e))}if(void 0===y)continue;const x=f(y),w=e-.5*Math.max(0,80-Math.min(x.x-i.left,i.right-(x.x+x.width)))-.3*Math.abs(M.x-m)-1*b,C=o.reduce(((e,t)=>{const n=Z_(t,s);return e+($_(n,x)?X_(x,n):0)}),0),A={slot:M,score:w,overlap:C,seatY:y},I=M.x===c&&M.preferEdge===d;0===C?((null===p||w>p.score)&&(p=A),I&&(g=A)):((null===h||C<h.overlap||C===h.overlap&&w>h.score)&&(h=A),I&&(v=A))}const f=null!==(t=p)&&void 0!==t?t:h,E=null!==p?g:v,y=null!==E&&null!==f&&E.score>=f.score-24?E:f;if(null===y)return null;if(void 0!==y.slot.preferEdge||0===y.overlap)return{centerX:y.slot.x,centerY:y.seatY,preferEdge:y.slot.preferEdge};const b=y.seatY,x=a.height/2,w=Math.max(y.slot.top+x,u.y+x),C=Math.min(y.slot.bottom-x,u.y+u.height-x),A=y.slot.x-a.width/2,I=A+a.width,k=o.map((e=>Z_(e,s))).filter((e=>e.x<I&&A<e.x+e.width));if(0===k.length)return{centerX:y.slot.x,centerY:b,preferEdge:y.slot.preferEdge};const S=Math.min(...k.map((e=>e.y))),N=Math.max(...k.map((e=>e.y+e.height))),T=e=>e<S?S-e:e>N?e-N:0,_=T(w),D=T(C);let R=b;return(_>0||D>0)&&(R=_>=D?w:C),{centerX:y.slot.x,centerY:R,preferEdge:y.slot.preferEdge}},X_=(e,t)=>Math.max(0,Math.min(e.y+e.height,t.y+t.height)-Math.max(e.y,t.y)),Q_=e=>null!==e&&Tf.includes(e),eD=(0,mh.v)()((e=>({highlighted:null,setHighlighted:t=>e({highlighted:t})}))),tD=()=>eD((e=>e.highlighted)),nD=(e,t)=>null===t||t===e?1:.25,aD=(0,mh.v)()((e=>({hidden:[],toggle:t=>e((e=>{let n=e.hidden;return{hidden:n.includes(t)?n.filter((e=>e!==t)):[...n,t]}})),reset:()=>e((e=>0===e.hidden.length?e:{hidden:[]}))}))),lD=()=>aD((e=>e.hidden)),rD=[];var oD=n(28960);const iD=oD.I.area,sD=oD.I.area+1,cD=oD.I.area+2,dD=oD.I.line-1,uD=oD.I.line,mD=oD.I.line+3,pD=mD+1,gD=oD.I.area+3,hD=oD.I.line+1,vD=oD.I.line+2,fD=oD.I.scatter,ED=fD+1;var yD=n(12202);const bD=K_.g,xD="9 in 10 paths in here",wD="1 in 5 paths in here",CD={stroke:(0,qy.f)("background-primary"),strokeWidth:3,paintOrder:"stroke"},AD=e=>{let t=e.chartData,n=e.isAnimationActive;const l=(0,q_.oM)(),r=(0,q_.Ph)(),i=(0,q_.AD)(),s=lD(),c=tD(),d=(0,a.useState)(null),u=(0,o.A)(d,2),m=u[0],p=u[1],g=(0,a.useState)(null),h=(0,o.A)(g,2),v=h[0],f=h[1],E=(0,a.useCallback)((e=>{if(null!==e){const t=e.getBBox();p({width:t.width,height:t.height})}}),[]),y=(0,a.useCallback)((e=>{if(null!==e){const t=e.getBBox();f({width:t.width,height:t.height})}}),[]),b=(0,a.useRef)(),x=(0,a.useRef)(),w=(0,a.useMemo)((()=>{var e,n,a,o;if(!l||!r||!i||!m||!v)return{inner:null,outer:null};const c={left:l.x,right:l.x+l.width,top:l.y,bottom:l.y+l.height},d=e=>{const n=e.height;return t.map(((a,l)=>{if(void 0===a.netWorth)return null;const o=Number(r(a.year)),s=t[l+1],c=t[l-1],d=(void 0!==s?Number(r(s.year))-o:0)||(void 0!==c?o-Number(r(c.year)):e.width);return{x:o-d/2,y:Number(i(a.netWorth))-n/2,width:d,height:n}})).filter((e=>null!==e))},u=(e,t)=>void 0===e.mcOuterBand||void 0===e.mcInnerBand?null:{x:Number(r(e.year)),top:Number(i(t?e.mcOuterBand[1]:e.mcInnerBand[0])),bottom:Number(i(t?e.mcInnerBand[1]:e.mcOuterBand[0]))},p=t.map((e=>u(e,!0))).filter((e=>null!==e)),g=t.map((e=>u(e,!1))).filter((e=>null!==e)),h=[...ID(p.map((e=>(0,U.A)((0,U.A)({},e),{},{preferEdge:"bottom"}))),m.width),...ID(g.map((e=>(0,U.A)((0,U.A)({},e),{},{preferEdge:"top"}))),m.width)],f=s.includes("innerBand")?null:J_({slots:h,label:m,obstacles:d(m),plot:c,padding:2,previousX:null===(e=b.current)||void 0===e?void 0:e.x,previousPreferEdge:null===(n=b.current)||void 0===n?void 0:n.preferEdge});if(s.includes("outerBand"))return{inner:f,outer:null};const E=null===f?[]:[{x:f.centerX-m.width/2,y:f.centerY-m.height/2,width:m.width,height:m.height}],y=ID(p.map((e=>(0,U.A)((0,U.A)({},e),{},{preferEdge:"top"}))),v.width),w=ID(g.map((e=>(0,U.A)((0,U.A)({},e),{},{preferEdge:"bottom"}))),v.width);return{inner:f,outer:J_({slots:[...y,...w],label:v,obstacles:[...d(v),...E],plot:c,padding:2,previousX:null===(a=x.current)||void 0===a?void 0:a.x,previousPreferEdge:null===(o=x.current)||void 0===o?void 0:o.preferEdge})}}),[t,l,r,i,m,v,s]);if((0,a.useLayoutEffect)((()=>{b.current=null===w.inner?void 0:{x:w.inner.centerX,preferEdge:w.inner.preferEdge},x.current=null===w.outer?void 0:{x:w.outer.centerX,preferEdge:w.outer.preferEdge}}),[w]),n)return null;const C={textAnchor:"middle",dominantBaseline:"central",fontSize:yD.w.fontSize.xsmall,fontWeight:yD.w.fontWeight.medium,fill:(0,qy.f)("content-secondary")},A=nD("innerBand",c),I=nD("outerBand",c);return a.createElement(bD,{"data-external-id":"forecast-band-labels",zIndex:hD},a.createElement("g",{pointerEvents:"none"},a.createElement("text",Object.assign({ref:E,x:-9999,y:-9999,visibility:"hidden"},C),wD),a.createElement("text",Object.assign({ref:y,x:-9999,y:-9999,visibility:"hidden"},C),xD),null!==w.inner&&a.createElement("text",Object.assign({x:w.inner.centerX,y:w.inner.centerY,fillOpacity:A,strokeOpacity:A},C,CD),wD),null!==w.outer&&a.createElement("text",Object.assign({x:w.outer.centerX,y:w.outer.centerY,fillOpacity:I,strokeOpacity:I},C,CD),xD)))},ID=(e,t)=>e.map((n=>{const a=e.filter((e=>e.x>=n.x-t/2&&e.x<=n.x+t/2));return(0,U.A)((0,U.A)({},n),{},{top:Math.max(...a.map((e=>e.top))),bottom:Math.min(...a.map((e=>e.bottom)))})}));var kD=n(94267);const SD="Projected plan",ND=e=>{let t=e.entries;const n=eD((e=>e.setHighlighted)),l=lD(),r=aD((e=>e.toggle));return(0,a.useEffect)((()=>()=>n(null)),[n]),0===t.length?null:a.createElement("div",{"data-external-id":"forecast-legend",className:"flex flex-wrap justify-center gap-x-md gap-y-2xs pt-3"},t.map(((e,t)=>void 0===e.highlight?a.createElement("div",{key:t,className:"flex items-center gap-xs"},a.createElement(DD,{entry:e}),a.createElement(_D,null,e.name)):a.createElement(TD,{key:t,entry:e,part:e.highlight,isHidden:l.includes(e.highlight),setHighlighted:n,toggle:r}
1))))},TD=e=>{let t=e.entry,n=e.part,l=e.isHidden,r=e.setHighlighted,o=e.toggle;return a.createElement("button",{"data-external-id":"series-toggle",type:"button","aria-pressed":!l,className:(0,q.cn)("\n        flex cursor-pointer items-center gap-xs rounded-2xs border-0 bg-transparent p-0\n        focus-visible:outline-2 focus-visible:outline-border-info\n      ",l&&"opacity-40"),onClick:()=>{o(n),r(l?n:null)},onMouseEnter:()=>r(l?null:n),onMouseLeave:()=>r(null),onFocus:()=>r(l?null:n),onBlur:()=>r(null)},a.createElement(DD,{entry:t}),a.createElement(_D,null,t.name))},_D=e=>{let t=e.children;return a.createElement(kD.c,{"data-external-id":"name",size:"sm",color:"secondary"},t)},DD=e=>{let t=e.entry;if("band"===t.swatch)return a.createElement("svg",{"data-external-id":"swatch",xmlns:"http://www.w3.org/2000/svg",width:24,height:10,viewBox:"0 0 ".concat(24," ").concat(10)},a.createElement("rect",{width:24,height:10,rx:"2",fill:t.color,fillOpacity:t.opacity}));const n="dashed"===t.swatch;return a.createElement("svg",{"data-external-id":"swatch",xmlns:"http://www.w3.org/2000/svg",width:24,height:3,viewBox:"0 0 ".concat(24," ").concat(3),fill:"none"},a.createElement("path",{d:"M1.5 1.5H22.5",stroke:t.color,strokeWidth:n?"2":"3",strokeLinecap:"round",strokeLinejoin:"round",strokeDasharray:n?"2 6.5 4 6.5 2":void 0}))},RD=e=>{var t;let n=e.active,l=e.payload;const r=null===l||void 0===l||null===(t=l[0])||void 0===t?void 0:t.payload;if(!n||!r)return null;const o=MD(r);return o?a.createElement(Sa.II,{"data-external-id":"forecast-band-tooltip",active:!0,header:String(r.year)},a.createElement("div",{className:"flex flex-col gap-2xs"},(0,Tp.n)(r.netWorth)&&a.createElement("div",{className:"flex items-center justify-between gap-lg border-b border-divider-primary pb-2xs"},a.createElement(kD.c,{size:"xs",weight:"medium"},SD),a.createElement(kD.c,{size:"xs",weight:"medium"},(0,rl.fw)(r.netWorth))),o.map((e=>a.createElement("div",{key:e.label,className:"flex items-center justify-between gap-lg"},a.createElement(kD.c,{size:"xs",color:"secondary"},e.label),a.createElement(kD.c,{size:"xs",weight:"medium"},(0,rl.fw)(e.value))))))):null},MD=e=>{const t=e.mcInnerBand,n=e.mcOuterBand;if(!t)return null;const a=(0,o.A)(t,2),l=a[0],r=a[1],i=[];return n&&i.push({label:"Top of 9 in 10",value:n[1]}),i.push({label:"Top of 1 in 5",value:r},{label:"Bottom of 1 in 5",value:l}),n&&i.push({label:"Bottom of 9 in 10",value:n[0]}),i};var LD=n(92621);const OD=(e,t)=>{const n=t?2:3;return{baseY:t?-16:4,visibleCount:Math.min(e,n),shouldConsolidate:e>n}},PD=e=>e.isIncluded&&e.isVisibleInForecast&&void 0!==e.startYear,BD=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;const n=new Set(Object.keys(e).map(Number));return null!==t&&n.add(t),n},zD=e=>new Set(Object.entries(e).filter((e=>{let t=(0,o.A)(e,2)[1];return t.compareEvents.length>0&&0===t.activeEvents.length})).map((e=>{let t=(0,o.A)(e,1)[0];return Number(t)}))),FD=(e,t,n)=>e.activeEvents.length+e.compareEvents.length>0||n===t,GD=e=>(0,qy.f)("chart-event-border-".concat(e)),YD=e=>{let t=e.activeCount,n=e.compareCount,a=e.isExpanded;const l=t>2&&n>3||t<=2&&n>4;return{isCollapsible:l,visibleCompareCount:l&&!a?1:n}},UD=e=>{let t=e.annotation,n=e.yOffset,l=e.onMouseEnter,r=e.onMouseLeave;const o=(0,u.useTheme)(),i=VD(t.kind);return a.createElement(WD,{"data-external-id":"annotation-marker","data-annotation-marker":!0,"data-testid":"forecast-annotation-marker",transform:"translate(0, ".concat(n,")"),pointerEvents:"all",onMouseEnter:l,onMouseLeave:r},a.createElement("rect",{x:-8,y:0,width:Gg,height:Gg,rx:8,ry:8,fill:o.variables.color.background.primary}),a.createElement("foreignObject",{x:-8,y:0,width:Gg,height:Gg,pointerEvents:"none"},a.createElement(sl.ZQ,{name:i,size:10,style:{color:o.variables.color.content.secondary,display:"flex",alignItems:"center",justifyContent:"center",width:Gg,height:Gg}})))},VD=e=>(0,r.YW)(e).with("payoff",(()=>"info")).with("goalCompletion",(()=>"target")).exhaustive(),WD=u.default.g.withConfig({displayName:"AnnotationMarker__MarkerGroup",componentId:"kn20s4-0"})(["cursor:default;opacity:0.8;transition:",";&:hover{opacity:1;}"],(e=>e.theme.transition.createDefaultTransition(["opacity"]))),jD=24,HD=(0,qy.f)("background-primary"),KD=e=>{let t=e.marker,n=e.showSelectedRing,l=void 0!==n&&n;const r=qD(t),o=r.fill,i=r.stroke,s=r.strokeWidth,c=r.iconColor,d=r.selectedRingStroke,u=r.useInnerBorder;return a.createElement(a.Fragment,null,a.createElement("rect",{x:-12,y:0,width:jD,height:jD,rx:6,ry:6,fill:"transparent"}),l&&d&&a.createElement("rect",{x:-14,y:-2,width:28,height:28,rx:8,ry:8,fill:HD,stroke:d,strokeWidth:2}),u?a.createElement(a.Fragment,null,a.createElement("rect",{x:-12,y:0,width:jD,height:jD,rx:6,ry:6,fill:o}),a.createElement("rect",{x:-11,y:1,width:22,height:22,rx:5,ry:5,fill:"none",stroke:i,strokeWidth:s})):a.createElement("rect",{x:-12,y:0,width:jD,height:jD,rx:6,ry:6,fill:o,stroke:i,strokeWidth:s}),a.createElement("foreignObject",{x:-12,y:0,width:jD,height:jD,pointerEvents:"none"},a.createElement("div",{className:"flex size-6 items-center justify-center",style:{color:c}},a.createElement(fe.jeH,{name:t.icon,size:"md"}))))},qD=e=>(0,r.YW)(e).with({variant:"active"},(e=>({fill:$D(e.color),stroke:HD,strokeWidth:2,iconColor:JD(e.foregroundColor),selectedRingStroke:ZD(e.color)}))).with({variant:"compare"},(()=>({fill:HD,stroke:(0,qy.f)("border-primary"),strokeWidth:1,iconColor:(0,qy.f)("content-secondary"),useInnerBorder:!0}
1))).exhaustive(),$D=e=>(0,qy.f)("chart-event-background-".concat(e)),ZD=e=>(0,qy.f)("chart-event-border-".concat(e)),JD=e=>(0,qy.f)("chart-event-foreground-".concat(e)),XD=e=>{let t=e.marker,n=e.yOffset,l=e.onMouseEnter,r=e.onMouseLeave;return a.createElement("g",{"data-external-id":"compare-event-marker","data-event-marker":!0,"data-testid":"forecast-event-marker",transform:"translate(0, ".concat(n,")"),style:{cursor:"default",outline:"none"},pointerEvents:"all",onMouseEnter:l,onMouseLeave:r},a.createElement(KD,{marker:t}))},QD=e=>{let t=e.marker,n=e.yOffset,l=e.onMouseEnter,r=e.onMouseLeave,o=e.onPointerDown,i=e.onClick,s=e.isActive,c=void 0!==s&&s;const d=(0,Bk.PM)({id:t.id}),u=d.attributes,m=d.listeners,p=d.setNodeRef,g=d.isDragging,h=(0,a.useCallback)((e=>{var t;null===o||void 0===o||o(),null===m||void 0===m||null===(t=m.onPointerDown)||void 0===t||t.call(m,e)}),[o,m]),v=(0,a.useCallback)((e=>{0!==e.button||g||null===i||void 0===i||i(t.event.id)}),[g,i,t.event.id]);return a.createElement("g",Object.assign({"data-external-id":"draggable-event-marker",ref:p,"data-event-marker":!0,"data-testid":"forecast-event-marker",transform:"translate(0, ".concat(n,")"),style:{cursor:g?"grabbing":"pointer",outline:"none"},pointerEvents:"all"},u,m,{onPointerDown:h,onPointerUp:v,onMouseEnter:l,onMouseLeave:r}),a.createElement(KD,{marker:t,showSelectedRing:c}))},eR=()=>a.createElement("div",{"data-external-id":"event-drag-overlay",style:{width:Yg,height:Yg,cursor:"grabbing"}});var tR=n(84615);const nR=16,aR=e=>{let t=e.isExpanded,n=e.yOffset,l=e.onToggle;const r=t?tR.CY1:tR.D39;return a.createElement("g",{"data-external-id":"event-stack-toggle","data-event-stack-toggle":!0,transform:"translate(0, ".concat(n,")"),role:"button","aria-label":t?"Collapse events":"Expand events","aria-expanded":t,style:{cursor:"pointer",outline:"none"},pointerEvents:"all",onClick:l},a.createElement("rect",{x:-8,y:0,width:nR,height:20,rx:8,ry:8,fill:(0,qy.f)("background-primary"),stroke:(0,qy.f)("border-primary"),strokeWidth:1}),a.createElement("foreignObject",{x:-8,y:0,width:nR,height:20,pointerEvents:"none"},a.createElement("div",{className:"flex size-full items-center justify-center"},a.createElement(r,{size:12,className:"text-content-secondary"}))))},lR=e=>{let t=e.count,n=e.yOffset,l=e.onMouseEnter,r=e.onMouseLeave;const o=(0,u.useTheme)();return a.createElement(WD,{"data-external-id":"grouped-annotation-marker","data-annotation-marker":!0,"data-testid":"forecast-annotation-marker",transform:"translate(0, ".concat(n,")"),pointerEvents:"all",onMouseEnter:l,onMouseLeave:r},a.createElement("rect",{x:-8,y:0,width:16,height:16,rx:8,ry:8,fill:o.variables.color.background.primary}),a.createElement("text",{x:0,y:8,textAnchor:"middle",dominantBaseline:"central",fontSize:9,fontWeight:600,fill:o.variables.color.content.secondary,style:{userSelect:"none"}},"+",t))},rR=e=>{let t=e.viewBox,n=e.year,l=e.previewEventYear,r=e.annotations,o=e.activeEvents,i=e.compareEvents,s=e.openedEventId,c=e.isExpanded,d=e.onToggleExpanded,u=e.hideMarkerTooltip,m=e.handleAnnotationMouseEnter,p=e.handleGroupedAnnotationMouseEnter,g=e.handleEventPointerDown,h=e.handleEventClick,v=e.handleEventMouseEnter;const f=t.y-12,E=FD({annotations:r,activeEvents:o,compareEvents:i},n,l),y=YD({activeCount:o.length,compareCount:i.length,isExpanded:c}),b=y.isCollapsible,x=y.visibleCompareCount,w=i.slice(0,x),C=OD(r.length,E),A=C.baseY,I=C.visibleCount,k=C.shouldConsolidate,S=k?r.slice(0,I-1):r,N=k?r.slice(I-1):[];return a.createElement("g",{"data-external-id":"year-marker-label",transform:"translate(".concat(t.x,", ").concat(f,")")},S.map(((e,t)=>{const n=A-20*t;return a.createElement(UD,{key:e.id,annotation:e.annotation,yOffset:n,onMouseEnter:t=>{m(e.annotation.id,t.currentTarget)},onMouseLeave:u})})),k&&a.createElement(lR,{count:N.length,yOffset:A-20*S.length,onMouseEnter:e=>{p(N.map((e=>e.annotation.id)),e.currentTarget)},onMouseLeave:u}),o.map(((e,t)=>{const n=28*t,l=null!==s&&s===e.event.id;return a.createElement(QD,{key:e.id,marker:e,yOffset:n,isActive:l,onPointerDown:g,onClick:h,onMouseEnter:t=>
1{v({variant:e.variant,id:e.event.id},t.currentTarget)},onMouseLeave:u})})),w.map(((e,t)=>{const n=28*(o.length+t);return a.createElement(XD,{key:e.id,marker:e,yOffset:n,onMouseEnter:t=>{v({variant:e.variant,id:e.event.id},t.currentTarget)},onMouseLeave:u})})),b&&a.createElement(aR,{isExpanded:c,yOffset:28*(o.length+w.length),onToggle:d}))},oR=e=>{let t=e.markersByYear,n=e.compareOnlyEventMarkerYears,l=e.previewEventYear,r=e.selectedEvent,i=e.openedEventId,s=e.expandedYears,c=e.onToggleYearExpanded,d=e.hideMarkerTooltip,u=e.handleAnnotationMouseEnter,m=e.handleGroupedAnnotationMouseEnter,p=e.handleEventPointerDown,g=e.handleEventClick,h=e.handleEventMouseEnter;return a.createElement(a.Fragment,null,Object.entries(t).map((e=>{let t=(0,o.A)(e,2),v=t[0],f=t[1];const E=parseInt(v,10),y=((e,t,n)=>null===n||e!==n.startYear&&e!==n.endYear||null===n?t.has(e)?(0,qy.f)("divider-primary"):(0,qy.f)("divider-secondary"):GD(n.color))(E,n,r),b=f.annotations,x=f.activeEvents,w=f.compareEvents;return a.createElement(eb.e_,{key:_N("marker",E),zIndex:mD,x:E,stroke:y,strokeWidth:1,strokeOpacity:1,label:e=>a.createElement(rR,{viewBox:e.viewBox,year:E,previewEventYear:l,annotations:b,activeEvents:x,compareEvents:w,openedEventId:i,isExpanded:s.has(E),onToggleExpanded:()=>c(E),hideMarkerTooltip:d,handleAnnotationMouseEnter:u,handleGroupedAnnotationMouseEnter:m,handleEventPointerDown:p,handleEventClick:g,handleEventMouseEnter:h})})})))},iR=()=>{const e=ey()?"range":"paths";return a.createElement(Vi.Md,{"data-external-id":"forecast-chart-mode-toggle",attached:!0,rounded:"pill",size:"xs",value:[e],onValueChange:t=>sR(t,e),"aria-label":"Chart view","data-testid":"forecast-chart-view-toggle"},a.createElement(Vi.H7,{value:"paths"},"Paths"),a.createElement(Vi.H7,{value:"range"},"Range"))},sR=(e,t)=>{const n=((e,t)=>"paths"===e[0]||"range"===e[0]?e[0]:t)(e,t);var a;n!==t&&(a={from:t,to:n},(0,Ge.u4)(Ye.yq.ChartViewModeChanged,(0,U.A)((0,U.A)({},a),zf())),TE("chance_of_success",(()=>{wE.getState().updateMonteCarloSettings({showFan:"range"===n})})))},cR="new-event-preview",dR=e=>{let t=e.xAxisYearRange,n=e.activeNetWorthData,l=e.onPreviewEventYearChange;const r=XE(),i=(()=>{const e=wE((e=>e.updateEvent)),t=wE((e=>e.updateParticipant));return(0,a.useCallback)(((n,a)=>{const l=n.getYearChangeAction(a);l&&("updateEvent"===l.type?e(l.eventId,{startYear:l.startYear}):"updateParticipant"===l.type&&t(l.userId,{lifeExpectancy:l.lifeExpectancy}))}),[e,t])})(),s=vy().openedSidebarDetails,c=(0,a.useRef)(null),d=(0,a.useMemo)((()=>0===n.length?null:{minYear:n[0].year,maxYear:n[n.length-1].year}),[n]),u=(0,a.useCallback)((e=>{if(!d)return null;return r.find((t=>t.id===e))instanceof dg?d.maxYear+1:d.maxYear}),[d,r]),m=(0,a.useState)(null),p=(0,o.A)(m,2),g=p[0],h=p[1],v=(0,a.useState)(null),f=(0,o.A)(v,2),E=f[0],y=f[1],b=(0,a.useState)(null),x=(0,o.A)(b,2),w=x[0],C=x[1],A=(0,a.useState)(null),I=(0,o.A)(A,2),k=I[0],S=I[1],N=(0,a.useRef)(null),T=(0,a.useRef)(l),_=(0,a.useRef)(null),D=(0,a.useRef)(null);(0,a.useEffect)((()=>{T.current=l}),[l]);const R=(0,a.useCallback)((()=>{h(null),y(null),C(null),S(null),_.current=null,D.current=null}),[]);(0,a.useEffect)((()=>()=>{N.current&&clearTimeout(N.current)}),[]);const M=(0,a.useCallback)((e=>null===_.current?null:Math.round(e/_.current)),[]),L=(0,a.useCallback)((e=>{var t;if(!e.active||!e.delta||!E||!d)return;const n=e.active.id.toString(),a=M(e.delta.x);if(null===a)return;const l=E+a,o=Math.max(d.minYear,Math.min(null!==(t=u(n))&&void 0!==t?t:d.maxYear,l));if(C(o),n===cR)return S(o),N.current&&clearTimeout(N.current),void(T.current&&(N.current=setTimeout((()=>{var e;null===(e=T.current)||void 0===e||e.call(T,o)}),100)));if(o===D.current)return;const s=r.find((e=>e.id===n));s&&(D.current=o,i(s,o))}),[E,r,M,d,u,i]),O=(0,a.useCallback)((e=>{if(!e.active||!E)return void R();const t=e.active.id.toString();if(t===cR)return N.current&&(clearTimeout(N.current),N.current=null),T.current&&null!==k&&T.current(k),void R();if(e.delta&&d){const a=M(e.delta.x);if(null!==a){var n;const e=E+a,l=Math.max(d.minYear,Math.min(null!==(n=u(t))&&void 0!==n?n:d.maxYear,e)),o=r.find((e=>e.id===t));o&&i(o,l)}}R()}),[E,r,M,d,u,i,R,k]),P=(0,a.useCallback)((e=>{if(t<=0)return;const n=e.active.id;if(_.current=c.current?((e,t)=>{if(0===t)return null;const n=e.querySelector(".recharts-reference-area");if(!n)return null;const a=n.getBoundingClientRect().width;return a<=0?null:a/t})(c.current,t):null,n===cR){const e="new-event"===(null===s||void 0===s?void 0:s.type)&&void 0!==s.year?s.year:null;return void(null!==e&&(h(cR),y(e),S(e)))}const a=r.find((e=>e.id===n));a&&void 0!==a.startYear&&(h(n),y(a.startYear),C(a.startYear),D.current=a.startYear)}),[r,s,t]),B=(0,a.useMemo)((()=>{var e;if(!g||!w)return null;const t=r.find((e=>e.id===g));if(!t)return null;const a=null===(e=n.find((e=>e.year===w)))||void 0===e?void 0:e.netWorth;if(void 0===a)return null;const l=(0,qy.f)("chart-fill-".concat(t.color));return{year:w,netWorth:a,color:l}}),[g,w,r,n]);return{chartContainerRef:c,draggingEventId:g,draggedYear:w,draggedEventDot:B,draggedPreviewEventYear:k,handleDragStart:P,handleDragMove:L,handleDragEnd:O}},uR=(0,qy.f)("divider-secondary"),mR=(0,qy.f)("background-primary"),pR=e=>{let t=e.yOffset;const n=(0,Bk.PM)({id:cR}),l=n.attributes,r=n.listeners,o=n.setNodeRef,i=n.isDragging;return a.createElement("g",Object.assign({"data-external-id":"draggable-preview-event-marker",ref:o,transform:"translate(0, ".concat(t,")"),style:{cursor:i?"grabbing":"pointer",outline:"none"},pointerEvents:"all"},l,r),a.createElement("rect",{x:-12,y:0,width:24,height:24,rx:6,ry:6,fill:uR,stroke:mR,strokeWidth:2}))},gR=()=>a.createElement("div",{"data-external-id":"preview-event-drag-overlay",style:{width:Yg,height:Yg,cursor:"grabbing"}}),hR=e=>{let t=e.year,n=e.markersAtYear,l=e.isExpanded;return a.createElement(eb.e_,{"data-external-id":"preview-event-marker",x:t,zIndex:pD,stroke:"transparent",strokeWidth:0,label:e=>{const t=e.viewBox.y-12,r=function(e){var t,n;let a=arguments.length>1&&void 0!==arguments[1]&&arguments[1];const l=null!==(t=null===e||void 0===e?void 0:e.activeEvents.length)&&void 0!==t?t:0,r=null!==(n=null===e||void 0===e?void 0:e.compareEvents.length)&&void 0!==n?n:0,o=YD({activeCount:l,compareCount:r,isExpanded:a}),i=o.isCollapsible;return 28*(l+o.visibleCompareCount+(i?1:0))}(n,l);return a.createElement("g",{transform:"translate(".concat(e.viewBox.x,", ").concat(t,")")},a.createElement(pR,{yOffset:r}))}})},vR={primaryWidth:0,secondaryWidth:0,separatorWidth:0,height:0},fR=e=>
1{let t=e.text,n=e.secondaryText,l=e.showSecondaryDivider,r=void 0===l||l,i=e.viewBox,s=e.textColor,c=e.minX,d=e.maxX;const u=i.y+(i.height||0)+14,m=(0,qy.f)("shadow-color-md"),p=(0,a.useMemo)((()=>"year-label-shadow-".concat(dh()())),[]),g=(e=>{let t=e.text,n=e.secondaryText,l=e.showSecondaryDivider;const r=(0,a.useRef)(null),i=(0,a.useRef)(null),s=(0,a.useRef)(null),c=(0,a.useState)(vR),d=(0,o.A)(c,2),u=d[0],m=d[1];return(0,a.useLayoutEffect)((()=>{var e,t,n,a,l,o,c,d;const u=null===(e=r.current)||void 0===e?void 0:e.getBBox(),p=null===(t=i.current)||void 0===t?void 0:t.getBBox(),g=null===(n=s.current)||void 0===n?void 0:n.getBBox();m({primaryWidth:null!==(a=null===u||void 0===u?void 0:u.width)&&void 0!==a?a:0,secondaryWidth:null!==(l=null===p||void 0===p?void 0:p.width)&&void 0!==l?l:0,separatorWidth:null!==(o=null===g||void 0===g?void 0:g.width)&&void 0!==o?o:0,height:Math.max(null!==(c=null===u||void 0===u?void 0:u.height)&&void 0!==c?c:0,null!==(d=null===p||void 0===p?void 0:p.height)&&void 0!==d?d:0)})}),[t,n,l]),{primaryRef:r,secondaryRef:i,separatorRef:s,bounds:u}})({text:t,secondaryText:n,showSecondaryDivider:r}),h=g.primaryRef,v=g.secondaryRef,f=g.separatorRef,E=g.bounds,y=void 0!==n,b=y&&r,x=y&&!r,w=yR({bounds:E,hasSecondary:y,showDividerLine:b,showSeparator:x,horizontalPadding:parseInt(yD.w.spacing.xsmall,10),verticalPadding:parseInt(yD.w.spacing.xxsmall,10),dividerSidePadding:parseInt(yD.w.spacing.xxsmall,10),viewBoxX:i.x,minX:c,maxX:d}),C=null!==s&&void 0!==s?s:(0,qy.f)("content-primary");return a.createElement("g",{"data-external-id":"year-label",transform:"translate(".concat(w.clampedX,", ").concat(u,")")},a.createElement("defs",null,a.createElement("filter",{id:p,x:"-50%",y:"-50%",width:"200%",height:"200%"},a.createElement("feDropShadow",{dx:"0",dy:"2",stdDeviation:"2",floodColor:m,floodOpacity:"1"}))),a.createElement("rect",{x:w.rect.x,y:w.rect.y,width:w.rect.width,height:w.rect.height,rx:yD.w.radius.default,fill:(0,qy.f)("background-primary"),stroke:(0,qy.f)("border-primary"),strokeWidth:1,filter:"url(#".concat(p,")")}),a.createElement(ER,{ref:h,x:w.primaryX,textAnchor:"start",fill:C},t),y&&a.createElement(a.Fragment,null,b&&a.createElement("line",{x1:w.dividerCenterX,x2:w.dividerCenterX,y1:-w.dividerLineHalfHeight,y2:w.dividerLineHalfHeight,stroke:(0,qy.f)("chart-compare-divider"),strokeWidth:1.5}),x&&a.createElement(ER,{ref:f,x:w.dividerCenterX,textAnchor:"middle",fill:C},"\xb7"),a.createElement(ER,{ref:v,x:w.secondaryX,textAnchor:"start",fill:(0,qy.f)("content-secondary")},n)))},ER=(0,a.forwardRef)(((e,t)=>{let n=e.x,l=e.textAnchor,r=e.fill,o=e.children;return a.createElement("text",{"data-external-id":"label-segment",ref:t,x:n,y:0,textAnchor:l,dominantBaseline:"central",fontSize:yD.w.fontSize.xsmall,fontWeight:yD.w.fontWeight.medium,fill:r},o)})),yR=e=>{let t=e.bounds,n=e.hasSecondary,a=e.showDividerLine,l=e.showSeparator,r=e.horizontalPadding,o=e.verticalPadding,i=e.dividerSidePadding,s=e.viewBoxX,c=e.minX,d=e.maxX;const u=a?1.5:l?t.separatorWidth:0,m=n?2*i+u:0,p=t.primaryWidth+m+(n?t.secondaryWidth:0),g=p+2*r,h=t.height+2*o,v=-p/2,f=v+t.primaryWidth+m,E=v+t.primaryWidth+i+u/2;let y=s;return void 0!==c&&(y=Math.max(y,c+g/2)),void 0!==d&&(y=Math.min(y,d-g/2)),{rect:{x:-g/2,y:-h/2,width:g,height:h},primaryX:v,secondaryX:f,dividerCenterX:E,dividerLineHalfHeight:.75*t.height/2,clampedX:y}},bR=e=>{let t=e.year,n=e.netWorth,l=e.markersAtYear,r=e.isExpanded;return null===t?null:a.createElement(a.Fragment,null,a.createElement(eb.e_,{x:t,stroke:(0,qy.f)("divider-secondary"),strokeWidth:1,label:e=>a.createElement(fR,{text:String(t),viewBox:e.viewBox})}),null!==n&&a.createElement(Ky.r,{x:t,y:n,zIndex:ED,r:6.5,fill:(0,qy.f)("divider-secondary"),stroke:(0,qy.f)("background-primary"),strokeWidth:2}),a.createElement(hR,{year:t,markersAtYear:l,isExpanded:r}))};var xR=n(28774);const wR={fresh:{outer:.16,inner:.38},stale:{outer:.08,inner:.19}},CR=(0,qy.f)("forecast-band"),AR=e=>{let t=e.isAnimationActive,n=e.animationDuration;const l=_I(),r=ey(),o=tD(),i=lD(),s=l?wR.stale:wR.fresh;return a.createElement(a.Fragment,null,r&&!i.includes("outerBand")&&a.createElement(xR.Gk,{dataKey:"mcOuterBand",fill:CR,fillOpacity:s.outer*nD("outerBand",o),stroke:"none",connectNulls:!1,activeDot:!1,legendT
1ype:"none",isAnimationActive:t,animationDuration:n,zIndex:sD}),!i.includes("innerBand")&&a.createElement(xR.Gk,{dataKey:"mcInnerBand",fill:CR,fillOpacity:s.inner*nD("innerBand",o),stroke:"none",connectNulls:!1,activeDot:!1,legendType:"none",isAnimationActive:t,animationDuration:n,zIndex:cD}))},IR=e=>{var t,n;let l=e.points,r=e.payload,i=e.height,s=e.top,c=e.visible,d=e.stroke,u=e.strokeWidth,m=e.strokeOpacity,p=e.strokeDasharray,g=e.eventMarkerYears,h=e.left,v=e.width;const f=ty(),E=aw(),y=E.isComparisonAvailable,b=E.netWorthData;if(!c||null===l||void 0===l||!l[0]||null===r||void 0===r||!r[0])return null;const x=(0,o.A)(l,1)[0].x,w=(0,o.A)(r,1)[0].payload,C=w.year,A=w.netWorth,I=(0,Ba.GB)(C,null===f||void 0===f?void 0:f.birthday),k=[String(C),void 0!==I?"Age ".concat(I):void 0,(0,Tp.n)(A)?(0,rl.fw)(A):void 0].filter(Tp.n).join(" ".concat("\xb7"," ")),S=y?null===(t=b.find((e=>e.year===C)))||void 0===t?void 0:t.netWorth:void 0,N=null!==(n=null===g||void 0===g?void 0:g.has(C))&&void 0!==n&&n;return a.createElement("g",{"data-external-id":"forecast-cursor"},!N&&a.createElement("line",{x1:x,y1:null!==s&&void 0!==s?s:0,x2:x,y2:(null!==s&&void 0!==s?s:0)+(null!==i&&void 0!==i?i:0),stroke:d,strokeWidth:u,strokeOpacity:m,strokeDasharray:p}),a.createElement(fR,{text:k,secondaryText:void 0!==S?(0,rl.fw)(S):void 0,showSecondaryDivider:(0,Tp.n)(A),viewBox:{x:x,y:null!==s&&void 0!==s?s:0,height:null!==i&&void 0!==i?i:0},minX:h,maxX:void 0!==h&&void 0!==v?h+v:void 0}))};var kR=n(54026);const SR=e=>{let t=e.id,n=e.positiveColor,l=e.negativeColor,r=e.yAxisId,o=e.domain;const i=(0,a.useMemo)((()=>[{minValue:-1/0,color:l},{minValue:0,color:n}]),[n,l]);return a.createElement(kR.f,{"data-external-id":"forecast-line-gradient",id:t,yAxisId:r,domain:o,bands:i})},NR={"data-forecast-outcome-strip":""},TR="[data-forecast-outcome-strip]",_R=[],DR=(e,t)=>null===e||null===t?e===t:"path"===e.kind&&"path"===t.kind?e.pathNumber===t.pathNumber:"bucket"===e.kind&&"bucket"===t.kind?e.row===t.row&&e.index===t.index&&e.pathNumbers===t.pathNumbers:"offScale"===e.kind&&"offScale"===t.kind&&(e.row===t.row&&e.end===t.end&&e.pathNumbers===t.pathNumbers),RR=(0,mh.v)()((e=>({hovered:null,setHoveredPathNumber:t=>e((e=>{var n;if(null===t)return"path"===(null===(n=e.hovered)||void 0===n?void 0:n.kind)?{hovered:null}:e;const a={kind:"path",pathNumber:t};return DR(e.hovered,a)?e:{hovered:a}})),setHoveredBucket:(t,n)=>e((e=>{var a;if(null===n)return"bucket"===(null===(a=e.hovered)||void 0===a?void 0:a.kind)&&e.hovered.row===t?{hovered:null}:e;const l=(0,U.A)({kind:"bucket",row:t},n);return DR(e.hovered,l)?e:{hovered:l}})),setHoveredOffScale:(t,n,a)=>e((e=>{var l;if(null===a)return"offScale"===(null===(l=e.hovered)||void 0===l?void 0:l.kind)&&e.hovered.row===t&&e.hovered.end===n?{hovered:null}:e;const r={kind:"offScale",row:t,end:n,pathNumbers:a};return DR(e.hovered,r)?e:{hovered:r}})),clearRowHover:t=>e((e=>{const n=e.hovered;return"bucket"!==(null===n||void 0===n?void 0:n.kind)&&"offScale"!==(null===n||void 0===n?void 0:n.kind)?e:n.row===t?{hovered:null}:e}))}))),MR=()=>RR((e=>{var t;return"path"===(null===(t=e.hovered)||void 0===t?void 0:t.kind)?e.hovered.pathNumber:null})),LR=()=>RR((e=>e.hovered)),OR=()=>RR((e=>e.setHoveredPathNumber)),PR=()=>RR((e=>e.setHoveredBucket)),BR=()=>RR((e=>e.setHoveredOffScale)),zR=()=>RR((e=>e.clearRowHover)),FR=(e,t,n)=>{return"bucket"===(null===t||void 0===t?void 0:t.kind)?t.row===n?t.index:null:"path"===(null===t||void 0===t?void 0:t.kind)&&null!==(a=e.bucketIndexByPathNumber.get(t.pathNumber))&&void 0!==a?a:null;var a},GR=(e,t,n)=>{return"offScale"===(null===t||void 0===t?void 0:t.kind)?t.row===n?t.end:null:"path"===(null===t||void 0===t?void 0:t.kind)&&null!==(a=e.offScaleEndByPathNumber.get(t.pathNumber))&&void 0!==a?a:null;var a},YR=e=>{let t=e.summary,n=e.endOfPlanYear,l=e.isTodaysDollars,r=e.participants;const o=t.outOfMoneyYear,i=aA((e=>e.successFloor)),s=Df(t,{successFloor:i,isTodaysDollars:l}),c=Mf[s],d=null===o?null:n-o,u=xf(t,l),m=VR(bf(t),s,o,u),p=t.netWorthAtRetirement.flatMap((e=>{const t=r.find((t=>t.userId===e.participantId));if(void 0===t)return[];const n=wf(e,l);return[{key:e.participantId,name:t.displayName,year:e.year,amount:n}]}));return a.createElement(Sa.II,{"data-external-id":"path-hover-card",active:!0,header:"Path ".concat(t.pathNumber)},a.createElement("div",{className:"flex flex-col gap-2xs"},a.createElement(WR,{label:"Outcome"},a.createElement(fe.c8D,{size:"xs",weight:"medium",className:Cf[c.status]}
1,c.qualifier.word)),null!==o&&a.createElement(WR,{label:"Ran out in"},a.createElement(fe.c8D,{size:"xs",weight:"medium"},o,UR(d))),p.map((e=>{let t=e.key,n=e.name,l=e.year,r=e.amount;return a.createElement(WR,{key:t,label:"".concat(n," retires ").concat(l)},a.createElement(fe.c8D,{size:"xs",weight:"medium"},(0,rl.fw)(r)))})),a.createElement(WR,{label:"Ending net worth"},a.createElement(fe.c8D,{size:"xs",weight:"medium"},(0,rl.fw)(u))),null!==m&&a.createElement(fe.c8D,{size:"xs",color:"secondary"},m)))},UR=e=>null===e||e<=0?"":1===e?", 1 year early":", ".concat(e," years early"),VR=(e,t,n,a)=>e?"onTrack"===t?null:"This path lasted the whole plan but finished under your success criteria, so it counts against your chance of success.":((e,t)=>null===e?"This path never rose above zero. It counts against your chance of success.":"This path ran out in ".concat(e,t>0?", but later income built the balance back up. It still counts against your chance of success, because the path ran out.":", so it counts against your chance of success."))(n,a),WR=e=>{let t=e.label,n=e.children;return a.createElement("div",{"data-external-id":"row",className:"flex items-center justify-between gap-lg"},a.createElement(fe.c8D,{size:"xs",color:"secondary"},t),n)};let jR=null;const HR=()=>{var e;const t=MR(),n=SI(),l=NI(),r=TI(),i=QE().participants,s=(0,a.useState)(null),c=(0,o.A)(s,2),d=c[0],u=c[1],m=(0,a.useRef)({clientX:0,clientY:0});(0,a.useEffect)((()=>{const e=e=>{let t=e.clientX,n=e.clientY;m.current={clientX:t,clientY:n}};return window.addEventListener("pointermove",e,{passive:!0}),()=>window.removeEventListener("pointermove",e)}),[]),(0,a.useEffect)((()=>{if(u((e=>(null===e||void 0===e?void 0:e.pathNumber)===t?e:null)),null===t)return;const e=setTimeout((()=>{u({pathNumber:t,screenX:m.current.clientX,screenY:m.current.clientY})}),500);return()=>clearTimeout(e)}),[t]);const p=null===(e=l[l.length-1])||void 0===e?void 0:e.year,g=null===d?void 0:n.find((e=>e.pathNumber===d.pathNumber));return KR(g),null===d||void 0===g||void 0===p?null:a.createElement(Yy,{"data-external-id":"forecast-path-hover-card",x:d.screenX,y:d.screenY,markerSize:0},a.createElement("div",{"data-testid":"forecast-path-hover-card",className:"w-64 drop-shadow-md"},a.createElement(YR,{summary:g,endOfPlanYear:p,isTodaysDollars:r,participants:i})))},KR=e=>{const t=ey(),n=kI(),l=aA((e=>e.successFloor)),r=TI(),o=n?"".concat(n.runSeed,":").concat(n.asOfDate.getTime()):null;(0,a.useEffect)((()=>{var n;void 0!==e&&null!==o&&(jR!==o&&(jR=o,n={chart_mode:t?"range":"paths",path_outcome:"onTrack"===Df(e,{successFloor:l,isTodaysDollars:r})?"success":"failure"},(0,Ge.u4)(Ye.yq.PathDetailsViewed,(0,U.A)((0,U.A)({},n),zf()))))}),[e,o,t,l,r])},qR={minReadableShare:.55,maxClippedShare:.05},$R={onTrack:{baseline:.2,falloff:.35,min:.12,max:.5},offTrack:{baseline:.1,falloff:.5,min:.04,max:.3}},ZR=(e,t)=>{const n=e[1]-e[0];if(Math.abs(n)<1e-6||![...e,...t].every(Number.isFinite))return null;const a=(t[1]-t[0])/n;return{scale:a,translate:t[0]-a*e[0]}},JR=(e,t)=>{const n=ZR(e.x,t.x),a=ZR(e.y,t.y);return n&&a?{scaleX:n.scale,scaleY:a.scale,translateX:n.translate,translateY:a.translate}:null},XR=(e,t,n,a)=>{if(!Number.isFinite(e)||0===e)return!1;const l=-t/e,r=(n-t)/e;return Math.min(l,r)>=-.5&&Math.max(l,r)<=a+.5},QR=(e,t,n)=>{const a=e-n.left,l=t-n.top;return a>=0&&a<=n.width&&l>=0&&l<=n.height},eM={onTrack:{base:"forecast-path-on-track",hover:"forecast-path-on-track-hover"},offTrack:{base:"forecast-path-off-track",hover:"forecast-path-off-track-hover"}},tM=(e,t)=>{const n=e.style.color;e.style.color=(0,qy.f)(t);const a=window.getComputedStyle(e).color;return e.style.color=n,a},nM=K_.g,aM={x:0,y:0},lM=e=>{let t=e.runs,n=e.startYear,l=e.hiddenGroups,r=e.yDomain,i=e.yTargetDomain;const s=(0,a.useRef)({}),c=(0,a.useRef)(null),d=(0,a.useRef)(null),u=(0,a.useRef)(null),m=(0,a.useState)(null),p=(0,o.A)(m,2),g=p[0],h=p[1],v=(0,a.useCallback)((e=>{d.current=e,h(e)}),[]),f=(0,a.useRef)(null),E=(0,a.useRef)(null),y=(0,q_.oM)(),b=(0,q_.Ph)(),x=(0,q_.AD)(),w=_I(),C=tD(),A=(e=>{const t=(0,lm.a)(),n=(0,a.useState)(null),l=(0,o.A)(n,2),r=l[0],i=l[1];return(0,a.useEffect)((()=>{null!==e&&i(Object.fromEntries(Tf.map((t=>[t,{base:tM(e,eM[t].base),hover:tM(e,eM[t].hover)}]))))}),[t,e]),r})(g),I=MR(),k=LR(),S=OR(),N=(0,a.useMemo)((()=>new Set(l)),[l]),T=(0,a.useMemo)((()=>0===N.size?void 0:e=>{var n;return!N.has(null===(n=t[e])||void 0===n?void 0:n.group)}),[t,N]),_=(0,a.useMemo)((()=>new Map(t.map(((e,t)=>[e.pathNumber,t])))),[t]),D=(0,a.useMemo)((()=>
1{if("path"===(null===k||void 0===k?void 0:k.kind)){const e=_.get(k.pathNumber);return void 0===e||N.has(t[e].group)?[]:[e]}return"bucket"===(null===k||void 0===k?void 0:k.kind)||"offScale"===(null===k||void 0===k?void 0:k.kind)?k.pathNumbers.map((e=>_.get(e))).filter((e=>void 0!==e&&!N.has(t[e].group))):[]}),[k,_,t,N]),R="bucket"===(null===k||void 0===k?void 0:k.kind)||"offScale"===(null===k||void 0===k?void 0:k.kind);(0,a.useEffect)((()=>{null!==I&&0===D.length&&S(null)}),[I,D,S]);const M=(0,a.useRef)(null),L=(0,a.useRef)(null),O=(0,a.useRef)(null),P=(0,a.useRef)(!1),B=(0,a.useState)(0),z=(0,o.A)(B,2),F=z[0],G=z[1],Y=(0,a.useCallback)((()=>{null!==L.current&&(cancelAnimationFrame(L.current),L.current=null)}),[]),U=(0,a.useCallback)((()=>{M.current=null,Y()}),[Y]),V=(0,a.useCallback)((()=>{var e,n,a;L.current=null;const l=M.current,r=c.current,o=f.current,i=E.current,s=u.current;if(!l||!r||!o||!i||!s)return;const d=r.getBoundingClientRect(),m=l.clientX-d.left,p=l.clientY-d.top;if(!QR(l.clientX,l.clientY,s.getBoundingClientRect())||Boolean(null===(e=document.elementFromPoint(l.clientX,l.clientY))||void 0===e?void 0:e.closest(TR)))return M.current=null,void S(null);const g=function(e,t,n){let a=e.xByYear,l=e.yByRun,r=e.yearCount,o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},i=o.radiusPx,s=void 0===i?12:i,c=o.isEligible;if(0===r||0===l.length)return null;let d=0;for(;d<r-2&&a[d+1]<t;)d+=1;const u=Math.min(d+1,r-1),m=a[u]-a[d],p=0===m?0:Math.min(1,Math.max(0,(t-a[d])/m));let g=null,h=s;const v=l.length/r;for(let f=0;f<v;f+=1){if(void 0!==c&&!c(f))continue;const e=l[f*r+d],t=e+(l[f*r+u]-e)*p,a=Math.abs(t-n);a<h&&(h=a,g=f)}return g}(o,m,p,void 0===T?void 0:{isEligible:T}),h=null===g?null:null!==(n=null===(a=t[g])||void 0===a?void 0:a.pathNumber)&&void 0!==n?n:null;S(h)}),[t,T,S]),W=(0,a.useCallback)((()=>{null!==O.current&&clearTimeout(O.current),O.current=window.setTimeout((()=>{O.current=null,P.current=!0,G((e=>e+1))}),90)}),[]);(0,a.useLayoutEffect)((()=>{if(!A)return;const e=d.current;if(!y||!b||!x||null===n||0===t.length)return f.current=null,E.current=null,void(e&&(e.style.transform="none"));const a=y.x,l=y.y,o=y.width,c=y.height,u=t[0].values.length,m=[n,n+u-1],p=(e,t)=>({x:[Number(b(m[0]))-a+t.x,Number(b(m[1]))-a+t.x],y:[Number(x(e[0]))-l+t.y,Number(x(e[1]))-l+t.y]}),g=(t,n)=>{e&&(e.style.width="".concat(t.width,"px"),e.style.height="".concat(t.height,"px"),e.style.transformOrigin="0 0",e.style.transform="translate(".concat(n.translateX,"px, ").concat(n.translateY,"px) scale(").concat(n.scaleX,", ").concat(n.scaleY,")"))},h=e=>g(e,(e=>({scaleX:1,scaleY:1,translateX:-e.margin.x,translateY:-e.margin.y}))(e)),v=()=>{f.current=null,Y(),S(null),W()},w=E.current;if(!(P.current||null===w||w.runs!==t||w.startYear!==n||w.colors!==A)&&null!==w){const t=p(w.probeValues,w.margin);if(o===w.plotWidth&&c===w.plotHeight&&t.x[0]===w.probe.x[0]&&t.x[1]===w.probe.x[1]&&t.y[0]===w.probe.y[0]&&t.y[1]===w.probe.y[1])return void h(w);const n=JR(w.probe,p(w.probeValues,aM));if(null!==n&&oM(w,n))return void h(w);if(null!==n&&e&&((e,t,n)=>XR(e.scaleX,e.translateX,n.width,t.width)&&XR(e.scaleY,e.translateY,n.height,t.height))(n,{width:w.width,height:w.height},{width:o,height:c}))return g(w,n),void v()}P.current=!1,(()=>{const e=(d={width:o,height:c},{x:Math.min(Math.max(0,.15*d.width),180),y:Math.min(Math.max(0,.15*d.height),120)});var d;const y=o+2*e.x,w=c+2*e.y,C=[];for(let t=0;t<u;t+=1)C.push(Number(b(n+t))-a+e.x);const I=[Math.min(r[0],i[0]),Math.max(r[1],i[1])],k=Number(x(r[0]))-l+e.y,S=Number(x(r[1]))-l+e.y,N=((e,t,n)=>{const a=e[1]-e[0];return 0===a?()=>NaN:l=>t+(l-e[0])/a*(n-t)})(I,k,S),T=new Float32Array(t.length*u);t.forEach(((e,t)=>{e.values.forEach(((e,n)=>{T[t*u+n]=N(e)}))})),f.current={xByYear:C,yByRun:T,yearCount:u},E.current={runs:t,startYear:n,colors:A,width:y,height:w,plotWidth:o,plotHeight:c,margin:e,probeYears:m,probeValues:I,probe:{x:p(I,e).x,y:[k,S]}};const _=E.current;h(_),Tf.forEach((e=>{const n=((e,t)=>{const n=$R[t],a=n.baseline,l=n.falloff,r=n.min,o=n.max;if(e<=0)return o;const i=a*(1e3/e)**l;return Math.min(Math.max(i,r),o)})(t.length,e),a=s.current[e],l=a&&rM(a,y,w);a&&l&&(l.lineWidth=1.25,l.globalAlpha=n,l.strokeStyle=A[e].base,t.forEach(((t,n)=>{t.group===e&&iM(l,C,T,n,u)})))})),null!==M.current&&null===L.current&&(L.current=requestAnimationFrame(V));const D=E.current,R=null===D?null:JR(D.probe,p(I,aM));null===R||null===D||oM(D,R)||(g(D,R),v())})()}),[t,n,y,b,x,r,i,A,F,W,Y,V,S]);const j=(0,a.useRef)([]);(0,a.useEffect)((()=>{const e=c.current,n=f.current,a=E.current;if(!e||!y||!a)return;if(0===D.length)return rM(e,a.width,a.height),void(j.current=[]);if(!n){const t=j.current;return void(t.length===D.length&&t.every(((e,t)=>e===D[t]))||(rM(e,a.width,a.height),j.current=[]))}const l=rM(e,a.width,a.height);l&&(l.lineWidth=2.5,D.forEach((e=>{const r=t[e];r&&(l.strokeStyle=a.colors[r.group].hover,iM(l,n.xByYear,n.yByRun,e,n.yearCount))})),j.current=D)}),[D,t,y,n,b,x,A,F]);const H=(0,a.useCallback)((e=>{var t;const n=u.current;if(!n)return;if(null!==(t=e.target)&&void 0!==t&&t.closest(TR))return void U();return E.current&&QR(e.clientX,e.clientY,n.getBoundingClientRect())?(M.current={clientX:e.clientX,clientY:e.clientY},void(null===L.current&&(L.current=requestAnimationFrame(V)))):(U(),void S(null))}),[V,S,U]);if((0,a.useEffect)((()=>()=>{U(),S(null),null!==O.current&&clearTimeout(O.current)}
1),[U,S]),(0,a.useEffect)((()=>{var e;const t=null===(e=c.current)||void 0===e?void 0:e.closest("svg");if(!t)return;const n=()=>{U(),S(null)};return t.addEventListener("pointermove",H),t.addEventListener("pointerleave",n),()=>{t.removeEventListener("pointermove",H),t.removeEventListener("pointerleave",n)}}),[H,S,U,y]),!y||0===t.length)return null;const K=w?.4:1,q=e=>{if(N.has(e))return 0;if(R)return.25*K;if(null===C||"runLines"===C)return K;const t=Q_(C)?e:"runLines";return K*nD(t,C)};return a.createElement(nM,{"data-external-id":"forecast-run-lines",zIndex:iD},a.createElement("foreignObject",{x:y.x,y:y.y,width:y.width,height:y.height,pointerEvents:"none"},a.createElement("div",{ref:u,className:"pointer-events-none size-full overflow-hidden"},a.createElement("div",{ref:v,className:"relative"},Tf.map((e=>a.createElement("canvas",{key:e,ref:t=>{s.current[e]=t},"data-testid":"forecast-run-lines-".concat(e),className:"pointer-events-none absolute inset-0 block size-full",style:{opacity:q(e)}}))),a.createElement("canvas",{ref:c,"data-testid":"forecast-run-lines-highlight",className:"pointer-events-none absolute inset-0 block size-full",style:{opacity:K}})))),a.createElement(HR,null))},rM=(e,t,n)=>{const a=window.devicePixelRatio||1;e.width=Math.max(1,Math.round(t*a)),e.height=Math.max(1,Math.round(n*a));const l=e.getContext("2d");return l?(l.setTransform(a,0,0,a,0,0),l.clearRect(0,0,t,n),l.lineJoin="round",l.lineCap="round",l):null},oM=(e,t)=>Math.abs(t.scaleX-1)<.001&&Math.abs(t.scaleY-1)<.001&&Math.abs(t.translateX+e.margin.x)<.01&&Math.abs(t.translateY+e.margin.y)<.01,iM=(e,t,n,a,l)=>{e.beginPath();let r=!1;for(let o=0;o<l;o+=1){const i=t[o],s=n[a*l+o];Number.isFinite(i)&&Number.isFinite(s)&&(r?e.lineTo(i,s):(e.moveTo(i,s),r=!0))}e.stroke()},sM={buckets:[],peakCount:0,bucketIndexByPathNumber:new Map,offScale:{low:[],high:[]},offScaleEndByPathNumber:new Map,aboveCount:0,belowCount:0},cM=.001,dM=e=>{var t,n;return null!==(t=null!==(n=null===e||void 0===e?void 0:e.ownerSVGElement)&&void 0!==n?n:null===e||void 0===e?void 0:e.closest("svg"))&&void 0!==t?t:null},uM=e=>{const t=(0,a.useState)(1),n=(0,o.A)(t,2),l=n[0],r=n[1],i=(0,a.useRef)(null),s=(0,a.useRef)(null),c=(0,a.useCallback)((()=>{const t=(e=>{const t=dM(e);if(!t)return 1;const n=t.getBoundingClientRect().width,a=t.viewBox.baseVal.width||t.width.baseVal.value;return n&&a?n/a:1})(e.current);return r((e=>Math.abs(t-e)>cM?t:e)),t}),[e]),d=(0,a.useRef)(null),u=(0,a.useRef)(null);return(0,a.useEffect)((()=>()=>{var e;return null===(e=d.current)||void 0===e?void 0:e.disconnect()}),[]),(0,a.useLayoutEffect)((()=>{const t=dM(e.current);if(t!==u.current){var n;if(null===(n=d.current)||void 0===n||n.disconnect(),d.current=null,null!==t){const e=new ResizeObserver(c);e.observe(t),d.current=e}u.current=t}const a=()=>{i.current=requestAnimationFrame((()=>{const e=c(),t=s.current;s.current=e;(null===t||Math.abs(e-t)>cM)&&Math.abs(e-1)>cM?a():i.current=null}))},l=c();return s.current=l,Math.abs(l-1)>cM&&null===i.current&&a(),()=>{null!==i.current&&(cancelAnimationFrame(i.current),i.current=null)}})),l},mM=K_.g,pM=108,gM=e=>{let t=e.runs,n=e.axis,l=e.targetAxis,r=e.formatValue;const i=(0,q_.oM)(),s=_I(),c=tD(),d=LR(),u=PR(),m=OR(),p=BR(),g=zR(),h=(0,o.A)(l,2),v=h[0],f=h[1],E=(0,a.useMemo)((()=>((e,t)=>{let n=t.bucketCount,a=t.domain;const l=(0,o.A)(a,2),r=l[0],i=l[1];if(!Number.isFinite(r)||!Number.isFinite(i)||i<=r||n<1)return sM;const s=(i-r)/n,c=Array.from({length:n},((e,t)=>({start:r+t*s,end:r+(t+1)*s,pathCount:0,succeededCount:0,pathNumbers:[]}))),d={low:[],high:[]},u=new Map,m=new Map;return e.forEach((e=>{let t=e.pathNumber,a=e.group,l=e.values;const o=l[l.length-1];if(void 0===o||!Number.isFinite(o))return;if(o<r)return d.low.push(t),void u.set(t,"low");if(o>i)return d.high.push(t),void u.set(t,"high");const p=Math.min(n-1,Math.floor((o-r)/s)),g=c[p];g.pathCount+=1,g.pathNumbers.push(t),m.set(t,p),"onTrack"===a&&(g.succeededCount+=1)})),{buckets:c,peakCount:Math.max(0,...c.map((e=>e.pathCount))),bucketIndexByPathNumber:m,offScale:d,offScaleEndByPathNumber:u,aboveCount:d.high.length,belowCount:d.low.length}})(t,{bucketCount:64,domain:[v,f]})),[t,v,f]),y=void 0===i?0:i.height,b=(0,a.useMemo)((()=>((e,t)=>{let n=t.axis,a=t.plotHeightPx;const l=(0,o.A)(n,2),r=l[0],i=l[1],s=i-r,c=[];if(!Number.isFinite(s)||s<=0||a<=0)return{placed:c};const d=e=>(i-e)/s*a;
1return e.buckets.forEach(((e,t)=>{const n=Math.max(0,d(e.end)),l=Math.min(a,d(e.start));l>n&&c.push({bucket:e,index:t,topPx:n,heightPx:l-n})})),{placed:c}})(E,{axis:n,plotHeightPx:y})),[E,n,y]),x=b.placed,w=(0,a.useRef)(E),C=("bucket"===(null===d||void 0===d?void 0:d.kind)||"offScale"===(null===d||void 0===d?void 0:d.kind))&&"endingValues"===d.row;(0,a.useEffect)((()=>{C&&w.current!==E&&g("endingValues")}),[E,C,g]),(0,a.useEffect)((()=>()=>g("endingValues")),[g]);const A=(0,a.useRef)(null),I=uM(A);if(!i||0===t.length||0===E.buckets.length)return null;const k=i.x+i.width-pM,S=i.x+i.width,N=Math.abs(I-1)>.001?"translate(".concat(S,",0) scale(").concat(1/I,",1) translate(").concat(-S,",0)"):void 0,T=s?.4:1,_=FR(E,d,"endingValues"),D=null===_?void 0:x.find((e=>e.index===_)),R=hM("onTrack",c),M=hM("offTrack",c),L=e=>{w.current=E,p("endingValues",e,E.offScale[e])};return a.createElement(a.Fragment,null,a.createElement(mM,{zIndex:gD},a.createElement("g",{transform:N},a.createElement("rect",{ref:A,x:k+4,y:i.y-12,width:104,height:i.height+24,rx:12,fill:(0,qy.f)("background-secondary"),fillOpacity:.6}))),a.createElement(mM,{zIndex:vD},a.createElement("g",{transform:N},a.createElement("foreignObject",{x:k,y:Math.max(0,i.y-16),width:pM,height:16},a.createElement(EM,{histogram:E,end:"high",count:E.aboveCount,arrow:"\u2191",edge:"above",onHoverStart:L})),a.createElement("foreignObject",{x:k,y:i.y,width:pM,height:i.height},a.createElement("div",Object.assign({},NR,{"data-testid":"forecast-outcome-strip",className:"pointer-events-auto relative box-border size-full",style:{paddingLeft:16},onMouseMove:e=>e.stopPropagation(),onMouseEnter:e=>{var t;null===(t=e.currentTarget.parentElement)||void 0===t||t.dispatchEvent(new MouseEvent("mouseout",{bubbles:!0}))},onMouseOver:e=>{var t,n;const a=e.target.closest("[data-bucket]");w.current=E;const l=null===a?null:Number(a.dataset.bucketIndex);u("endingValues",null===l?null:{index:l,pathNumbers:null!==(t=null===(n=E.buckets[l])||void 0===n?void 0:n.pathNumbers)&&void 0!==t?t:_R}),null===l&&m(null)},onMouseLeave:()=>u("endingValues",null)}),x.filter((e=>e.bucket.pathCount>0)).map((e=>{let t=e.bucket,n=e.index,l=e.topPx,o=e.heightPx;return a.createElement(vM,{key:n,bucket:t,bucketIndex:n,peakCount:E.peakCount,range:"".concat(r(t.start)," \u2013 ").concat(r(t.end)),topPx:l,heightPx:o,opacity:T,onTrackOpacity:R,offTrackOpacity:M})})),void 0!==D&&a.createElement("div",{"data-hovered":!0,"aria-hidden":!0,className:"pointer-events-none absolute rounded-xs",style:{to
1p:D.topPx,height:D.heightPx,width:80,boxShadow:"0 0 0 1px ".concat((0,qy.f)("content-primary")),backgroundColor:"color-mix(in oklab, ".concat((0,qy.f)("content-primary")," 12%, transparent)")}}))),a.createElement("foreignObject",{x:k,y:i.y+i.height,width:pM,height:16},a.createElement(EM,{histogram:E,end:"low",count:E.belowCount,arrow:"\u2193",edge:"below",onHoverStart:L})))))},hM=(e,t)=>{if(null===t||"runLines"===t)return 1;const n=Q_(t)?e:"runLines";return nD(n,t)},vM=a.memo((e=>{let t=e.bucket,n=e.bucketIndex,l=e.peakCount,r=e.range,o=e.topPx,i=e.heightPx,s=e.opacity,c=e.onTrackOpacity,d=e.offTrackOpacity;const u=t.pathCount-t.succeededCount,m=Math.min(Math.max(i-1,2),6),p=l>0?Math.max(m,t.pathCount/l*80):0;return a.createElement(fe.Yvj,{"data-external-id":"bar",content:a.createElement("div",{className:"flex flex-col gap-2xs text-left"},a.createElement(fe.c8D,{size:"xs",weight:"medium"},r),a.createElement(fM,{label:"Paths",value:t.pathCount}),t.succeededCount>0&&a.createElement(fM,{label:Mf.onTrack.qualifier.word,value:t.succeededCount}),u>0&&a.createElement(fM,{label:Mf.offTrack.qualifier.word,value:u})),description:"".concat(r,": ").concat(t.pathCount," paths, ").concat(t.succeededCount," on track, ").concat(u," off track")},a.createElement("div",{"data-bucket":!0,"data-bucket-index":n,className:"absolute flex items-center",style:{top:o,height:i,width:80,opacity:s}},a.createElement("div",{className:"flex overflow-hidden rounded-full",style:{width:p,height:m}},a.createElement("span",{className:(0,q.cn)("h-full",Rf.onTrack.bgClass),style:{width:"".concat(t.succeededCount/t.pathCount*100,"%"),opacity:c}}),a.createElement("span",{className:(0,q.cn)("h-full flex-1",Rf.offTrack.bgClass),style:{opacity:d}}))))})),fM=e=>{let t=e.label,n=e.value;return a.createElement("div",{"data-external-id":"tooltip-row",className:"flex items-center justify-between gap-lg"},a.createElement(fe.c8D,{size:"xs",color:"secondary"},t),a.createElement(fe.c8D,{size:"xs",weight:"medium"},n))},EM=e=>{let t=e.histogram,n=e.end,l=e.count,r=e.arrow,o=e.edge,i=e.onHoverStart;const s=LR(),c=BR(),d=GR(t,s,"endingValues")===n;return 0===l?null:a.createElement("div",Object.assign({"data-external-id":"edge-count"},NR,{className:"pointer-events-auto flex size-full cursor-default items-center justify-end whitespace-nowrap",onMouseEnter:()=>i(n),onMouseLeave:()=>c("endingValues",n,null)}),a.createElement(fe.c8D,{size:"xs",color:d?"primary":"secondary",weight:d?"medium":void 0,className:d?"underline":void 0},"".concat(r," ").concat(l," end ").concat(o)))},yM={text:"No change",iconName:"arrow-right",color:"content.secondary"},bM=(e,t,n,a,l)=>e?{kind:n,activeValue:a,compareValue:l,loading:t}:void 0,xM=(e,t)=>{if(null===e||null===t)return;const n=e-t;if(Np(n))return yM;const a=(0,rl.fw)(Math.abs(n)),l=Np(e)||e<0?a:"".concat(a," (").concat((0,De.gj)(Math.abs(n)/e),")");return n>0?{text:l,iconName:"arrow-up-right",color:"content.success"}:{text:l,iconName:"arrow-down-right",color:"content.danger"}},wM=(e,t)=>{if(null===e||null===t)return;const n=e-t;if(0===n)return yM;const a=(0,De.td)("year",Math.abs(n),{inclusive:!0});return n<0?{text:a,iconName:"arrow-down-right",color:"content.success"}:{text:a,iconName:"arrow-up-right",color:"content.danger"}},CM={"content.success":"text-content-success","content.danger":"text-content-danger","content.secondary":"text-content-secondary"},AM=e=>{let t=e.kind,n=e.activeValue,l=e.compareValue;if(e.loading)return a.createElement(kM,{"data-external-id":"forecast-kpi-delta"});const r=((e,t,n)=>"netWorth"===e?xM(t,n):wM(t,n))(t,n,null!==l&&void 0!==l?l:null);return r?a.createElement(IM,{"data-external-id":"forecast-kpi-delta",delta:r}):a.createElement(SM,{"data-external-id":"forecast-kpi-delta"})},IM=e=>{let t=e.delta;return a.createElement("div",{"data-external-id":"kpi-delta-item",className:(0,q.cn)("flex h-4 items-center gap-3xs",CM[t.color])},a.createElement(sl.ZQ,{name:t.iconName,size:12}),a.createElement(xt.v,{size:"xsmall",weight:"medium",color:t.color},t.text))},kM=()=>a.createElement(M.Al,{"data-external-id":"compare-delta-skeleton",$width:"80px",$height:"16px",$borderRadius:"small","aria-hidden":!0,"data-testid":"forecast-kpi-delta-skeleton"}),SM=()=>a.createElement("div",{"data-external-id":"delta-spacer",className:"h-4","aria-hidden":!0,"data-testid":"forecast-kpi-delta-spacer"});var NM,TM;const _M=e=>{let t=e.activeContent,n=e.kind,l=e.activeValue,r=e.compareValue,o=e.loading;return a.createElement(a.Fragment,null,a.createElement("div",{className:" flex items-center gap-sm text-xl @max-[1000px]/statbar:text-20 @max-[880px]/statbar:text-lg @max-[780px]/statbar:gap-xs @max-[780px]/statbar:text-base @max-[640px]/statbar:text-sm "},t,a.createElement(LM,null),a.createElement(DM,{kind:n,loading:o,value:r})),a.createElement(AM,{kind:n,activeValue:l,compareValue:r,loading:o}))},DM=e=>{let t=e.kind,n=e.loading,l=e.value;return n?a.createElement(RM,{"data-external-id":"compare-stat-value"}):a.createElement(MM,{"data-external-id":"compare-stat-value"},((e,t)=>null===t||void 0===t?"\u2014":"netWorth"===e?(0,rl.fw)(t):String(t))(t,l))},RM=()=>a.createElement(M.Al,{"data-external-id":"compare-value-skeleton",$width:"64px",$height:"24px",$borderRadius:"small","aria-hidden":!0,"data-testid":"forecast-kpi-value-skeleton"}),MM=$d.s.span(NM||(NM=(0,wc.A)(["flex h-9 items-center font-medium text-content-secondary"]))),LM=$d.s.div(TM||(TM=(0,wc.A)(["h-6 w-0.5 bg-divider-secondary"])));var OM;const PM=$d.s.div(OM||(OM=(0,wc.A)(["\n  flex flex-1 flex-col items-start justify-start gap-2xs px-xl py-default\n  not-last:border-r not-last:border-divider-primary\n  @max-[880px]/statbar:px-lg\n  @max-[780px]/statbar:px-md\n  @max-[640px]/statbar:px-sm\n  @max-[580px]/statbar:px-xs\n"]))),BM=e=>{let t=e.label,n=e.tooltip;const l=a.createElement(fe.c8D,{size:"xs",weight:"medium",color:"secondary",className:"whitespace-nowrap @max-[580px]/statbar:text-2xs"},t);return a.createElement("div",{"data-external-id":"stat-cell-label",className:"flex items-center gap-2xs text-content-secondary"},n?a.createElement(fe.cIj,{size:"3xs",content:n,label:l,iconSize:"xs"}):l)},zM={low:2,high:90},FM=e=>{var t;if(0===e)return 0;const n=Math.abs(e),a=10**Math.floor(Math.log10(n/2)),l=null!==(t=[5,2,1].map((e=>e*a)).find((e=>e<=n/2)))&&void 0!==t?t:1;return Math.sign(e)*Math.ceil(n/l)*l},GM=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(0===e.length)return null;const n=e.map((e=>e.value));gf(n,"buildOutcomeDistribution: path values");const a=[...n].sort(((e,t)=>e-t)),l=((e,t)=>{let n=t.includeInDomain,a=t.clipToPercentiles;const l=void 0===n?[]:[n];return void 0===a?{min:Math.min(...e,...l),max:Math.max(...e,...l)}:{min:Math.min(0,FM(pf(e,a.low)),...l),max:Math.max(0,FM(pf(e,a.high)),...l)}})(a,t),r=l.min,o=l.max,i=((e,t)=>{let n=t.bucketCount,a=void 0===n?24:n,l=t.minBucketWidth;const r=e/a;return void 0===l?r>0?r:1:Math.max(l,Math.ceil(r/l)*l)})(o-r,t),s=((e,t,n)=>void 0===n?e:Math.floor(e/t)*t)(r,i,t.minBucketWidth),c=void 0===t.minBucketWidth?Math.max(1,Math.ceil((o-s)/i-1e-9)):Math.floor((o-s)/i+1e-9)+1,d=Array.from({length:c},((e,t)=>({start:s+t*i,end:s+(t+1)*i,pathCount:0,succeededCount:0,pathNumbers:[]}))),u={min:s,max:s+c*i},m=VM(u),p={low:[],high:[]},g=new Map,h=new Map;return e.forEach((e=>{let t=e.value,n=e.succeeded,a=e.pathNumber;if(t<u.min-m)return p.low.push(a),void h.set(a,"low");if(t>u.max+m)return p.high.push(a),void h.set(a,"high");const l=YM(Math.floor((t-s)/i),c-1),r=d[l];r.pathCount+=1,r.pathNumbers.push(a),g.set(a,l),n&&(r.succeededCount+=1)})),{buckets:d,domain:u,offScale:p,innerRange:{low:pf(a,cf),high:pf(a,df)},pathCount:e.length,peakCount:Math.max(1,...d.map((e=>e.pathCount))),bucketIndexByPathNumber:g,offScaleEndByPathNumber:h}},YM=(e,t)=>Math.min(Math.max(e,0),t),UM=(e,t)=>{let n=e.domain;const a=VM(n);if(t<n.min-a||t>n.max+a)return null;const l=n.max-n.min;return 0===l?0:WM((t-n.min)/l)},VM=e=>{let t=e.min,n=e.max;return 1e-9*Math.max(Math.abs(n-t),1)},WM=e=>Math.min(Math.max(e,0),1),jM=.04,HM=e=>{let t=e.distribution,n=e.row,l=e.planValue,r=e.formatValue,o=e.formatBucketValue,i=void 0===o?r:o,s=e.formatPlanLabel,c=e.fill,d=e.emptyMessage,u=e.isStale;const m=zR();return(0,a.useEffect)((()=>(null===t&&m(n),()=>m(n))),[t,n,m]),a.createElement("div",{"data-external-id":"outcome-histogram",className:(0,q.cn)("w-full",u&&"opacity-60")},null===t?a.createElement("div",{className:"flex w-full flex-col gap-3xs"},a.createElement("div",{className:"h-8 w-full"}),a.createElement("div",{className:"flex h-14 w-full items-center"},a.createElement(fe.c8D,{size:"xs",color:"secondary"},d)),a.createElement("div",{className:"h-4 w-full"})):a.createElement(KM,{row:n,distribution:t,planValue:l,formatValue:r,formatBucketValue:i,formatPlanLabel:s,fill:c}))},KM=e=>{var t,n;let l=e.row,r=e.distribution,o=e.planValue,i=e.formatValue,s=e.formatBucketValue,c=e.formatPlanLabel,d=e.fill;const u=PR(),m=(0,a.useRef)(null),p=null!==(t=UM(r,r.innerRange.low))&&void 0!==t?t:0,g=null!==(n=UM(r,r.innerRange.high))&&void 0!==n?n:1,h=null===o?null:UM(r,o),v=UM(r,0),f=XM(r,{bandCenter:(p+g)/2,zeroFraction:v,formatValue:i}),E=JM(r,i),y=null===o?null:c(o);return a.createElement("div",{"data-external-id":"drawn-histogram",className:"flex w-full flex-col gap-3xs"},a.createElement("div",{className:"relative h-8 w-full"},null!==h&&null!==y&&a.createElement(eL,{fraction:h,isEmphasized:!0,line:"lower"},y),E.map((e=>a.createElement(QM,{key:e.key,row:l,distribution:r,caption:e})))),a.createElement("div",{className:"relative h-14 w-full border-b border-divider-primary"},a.createElement("div",{className:"absolute inset-0 flex items-end",onMouseOver:e=>{var t,n;const a=e.target.closest("[data-bucket]");m.current=r;const o=null===a?null:Number(a.dataset.bucketIndex);
1u(l,null===o?null:{index:o,pathNumbers:null!==(t=null===(n=r.buckets[o])||void 0===n?void 0:n.pathNumbers)&&void 0!==t?t:_R})},onMouseLeave:()=>u(l,null)},r.buckets.map(((e,t)=>a.createElement(iL,{key:e.start,bucket:e,bucketIndex:t,peakCount:r.peakCount,range:"".concat(s(e.start)," \u2013 ").concat(s(e.end)),fill:d})))),a.createElement("div",{"aria-hidden":!0,className:"pointer-events-none absolute inset-y-0 rounded-t-xs",style:{left:oL(p),width:oL(g-p),minWidth:12,backgroundColor:rL(CR,wR.fresh.inner)}}),null!==h&&a.createElement("div",{"aria-hidden":!0,className:"absolute inset-y-0 w-px bg-content-primary",style:{left:oL(h)}}),a.createElement(qM,{row:l,distribution:r,hoveredDistributionRef:m}),a.createElement($M,{row:l,distribution:r,hoveredDistributionRef:m,formatBucketValue:s})),a.createElement("div",{className:"relative h-4 w-full"},f.map((e=>{let t=e.key,n=e.fraction,l=e.text;return a.createElement(eL,{key:t,fraction:n},l)}))))},qM=e=>{let t=e.row,n=e.distribution,l=e.hoveredDistributionRef;const r=LR(),o=PR();(0,a.useEffect)((()=>{"bucket"===(null===r||void 0===r?void 0:r.kind)&&r.row===t&&l.current!==n&&o(t,null)}),[r,t,n,l,o]);const i=FR(n,r,t);return null===i?null:a.createElement("div",{"data-external-id":"hovered-bucket","data-hovered":!0,"aria-hidden":!0,className:"pointer-events-none absolute inset-y-0 rounded-xs bg-content-primary/12 ring-1 ring-content-primary ring-inset",style:{left:oL(i/n.buckets.length),width:oL(1/n.buckets.length)}})},$M=e=>{let t=e.row,n=e.distribution,l=e.hoveredDistributionRef,r=e.formatBucketValue;const i=LR(),s=(0,a.useState)(!1),c=(0,o.A)(s,2),d=c[0],u=c[1],m=l.current===n&&"bucket"===(null===i||void 0===i?void 0:i.kind)&&i.row===t?i.index:null;if((0,a.useEffect)((()=>{if(null===m)return void u(!1);if(d)return;const e=setTimeout((()=>u(!0)),200);return()=>clearTimeout(e)}),[m,d]),null===m)return null;const p=n.buckets[m];if(void 0===p)return null;const g=p.pathCount-p.succeededCount,h="".concat(r(p.start)," \u2013 ").concat(r(p.end));return a.createElement(fe.Yvj,{"data-external-id":"row-bucket-tooltip",open:d,onOpenChange:u,content:a.createElement("div",{className:"flex flex-col gap-2xs text-left"},a.createElement(fe.c8D,{size:"xs",weight:"medium"},h),a.createElement(tL,{label:"Paths",value:p.pathCount}),p.succeededCount>0&&a.createElement(tL,{label:Mf.onTrack.qualifier.word,value:p.succeededCount}),g>0&&a.createElement(tL,{label:Mf.offTrack.qualifier.word,value:g})),description:ZM(h,p)},a.createElement("div",{"aria-hidden":!0,className:"pointer-events-none absolute inset-y-0",style:{left:oL(m/n.buckets.length),width:oL(1/n.buckets.length)}}))},ZM=(e,t)=>"".concat(e,": ").concat(t.pathCount," paths, ").concat(t.succeededCount," on track, ").concat(t.pathCount-t.succeededCount," off track"),JM=(e,t)=>{let n=e.offScale,a=e.domain;return[{key:"offScaleLow",fraction:0,end:"low",count:n.low.length,text:"\u2193 ".concat(n.low.length," below")},{key:"offScaleHigh",fraction:1,end:"high",count:n.high.length,text:"\u2191 ".concat(n.high.length," above")}].filter((e=>e.count>0)).map((e=>{let n=e.key,l=e.fraction,r=e.end,o=e.text;return{key:n,fraction:l,end:r,text:"".concat(o," ").concat(t(0===l?a.min:a.max))}}))},XM=(e,t)=>{let n=e.domain,a=e.innerRange,l=t.bandCenter,r=t.zeroFraction,o=t.formatValue;const i=null!==r&&r>jM&&r<.96;return[{key:"low",fraction:0,text:o(n.min)},{key:"high",fraction:1,text:o(n.max)},{key:"band",fraction:nL(l,.18),text:"".concat(o(a.low),"\u2013").concat(o(a.high))},...i&&null!==r?[{key:"zero",fraction:r,text:o(0)}]:[]].reduce(((e,t)=>e.some((e=>{let n=e.fraction;return Math.abs(n-t.fraction)<.18}))?e:[...e,t]),[])},QM=e=>{let t=e.row,n=e.distribution,l=e.caption;const r=LR(),o=BR(),i=l.end,s=l.fraction,c=l.text,d=GR(n,r,t)===i;return a.createElement(eL,{"data-external-id":"off-scale-caption",fraction:s,isLit:d,className:"cursor-default",onMouseEnter:()=>o(t,i,n.offScale[i]),onMouseLeave:()=>o(t,i,null)},c)},eL=e=>{let t=e.fraction,n=e.isEmphasized,l=void 0!==n&&n,r=e.isLit,o=void 0!==r&&r,i=e.className,s=e.line,c=void 0===s?"upper":s,d=e.onMouseEnter,u=e.onMouseLeave,m=e.children;return a.createElement("div",{"data-external-id":"scale-label",className:(0,q.cn)("absolute whitespace-nowrap","lower"===c?"top-4":"top-0",i),style:aL(t),onMouseEnter:d,onMouseLeave:u},a.createElement(fe.c8D,{size:"2xs",color:l||o?"primary":"secondary",weight:l||o?"medium":"book",className:o?"underline":void 0},m))},tL=e=>{let t=e.label,n=e.value;return a.createElement("div",{"data-external-id":"tooltip-row",className:"flex items-center justify-between gap-lg"},a.createElement(fe.c8D,{size:"xs",color:"secondary"},t),a.createElement(fe.c8D,{size:"xs",weight:"medium"},n))},nL=(e,t)=>Math.min(Math.max(e,t),1-t),aL=e=>
1e<=jM?{left:0}:e>=.96?{right:0}:{left:oL(e),transform:"translateX(-50%)"},lL=(e,t)=>{var n;return"danger"===t?0:null!==(n=(e=>{let t=e.pathCount,n=e.succeededCount;return 0===t?null:n/t})(e))&&void 0!==n?n:0},rL=(e,t)=>"color-mix(in oklab, ".concat(e," ").concat(oL(t),", transparent)"),oL=e=>"".concat(100*e,"%"),iL=a.memo((e=>{let t=e.bucket,n=e.bucketIndex,l=e.peakCount,r=e.range,o=e.fill;return 0===t.pathCount?a.createElement("div",{"data-external-id":"histogram-bar","aria-hidden":!0,className:"flex-1"}):a.createElement("div",{"data-external-id":"histogram-bar",className:"flex h-full flex-1 items-end justify-center","data-testid":"outcome-histogram-bar","data-bucket":!0,"data-bucket-index":n,role:"img","aria-label":ZM(r,t)},a.createElement("div",{className:"flex flex-col-reverse overflow-hidden rounded-full",style:{width:6,height:oL(t.pathCount/l),minHeight:6}},a.createElement("span",{className:(0,q.cn)("w-full",Rf.onTrack.bgClass),style:{height:oL(lL(t,o))}}),a.createElement("span",{className:(0,q.cn)("w-full flex-1",Rf.offTrack.bgClass)})))})),sL=e=>{var t;let n=e.bucketCount;const l=SI(),r=ty(),o=TI(),i=aA((e=>e.successFloor)),s=sy(),c=XE(),d=QE(),u=Jx({startYear:d.startYear,currentParticipant:r}),m=u.netWorthAtRetirement,p=u.retirementAge,g=u.hasRetirementEvent,h=null===r||void 0===r?void 0:r.userId,v=null!==(t=null===r||void 0===r?void 0:r.birthday)&&void 0!==t?t:void 0,f=(0,a.useMemo)((()=>void 0===n?null:GM(((e,t)=>{let n=t.participantId,a=t.isTodaysDollars,l=t.successFloor;return void 0===n?[]:e.flatMap((e=>{const t=e.netWorthAtRetirement.find((e=>e.participantId===n));return void 0===t?[]:[{value:wf(t,a),succeeded:"onTrack"===Df(e,{successFloor:l,isTodaysDollars:a}),pathNumber:e.pathNumber}]}))})(l,{participantId:h,isTodaysDollars:o,successFloor:i}),{bucketCount:n,clipToPercentiles:zM,includeInDomain:null!==m&&void 0!==m?m:void 0})),[l,h,o,i,n,m]),E=(0,a.useMemo)((()=>{var e,t,n;const a=fg(c),l=null!==(e=null===a?void 0:s.find((e=>e.year===a)))&&void 0!==e?e:s[s.length-1];return{planEndNetWorth:null!==(t=null===l||void 0===l?void 0:l.netWorth)&&void 0!==t?t:null,planEndAge:null!==(n=(0,Ba.GB)(null===l||void 0===l?void 0:l.year,v))&&void 0!==n?n:null}}),[c,s,v]),y=E.planEndNetWorth,b=E.planEndAge,x=(0,a.useMemo)((()=>void 0===n?null:GM(((e,t)=>{let n=t.isTodaysDollars,a=t.successFloor;return e.map((e=>({value:xf(e,n),succeeded:"onTrack"===Df(e,{successFloor:a,isTodaysDollars:n}),pathNumber:e.pathNumber})))})(l,{isTodaysDollars:o,successFloor:i}),{bucketCount:n,clipToPercentiles:zM,includeInDomain:null!==y&&void 0!==y?y:void 0})),[l,o,i,n,y]),w=(0,a.useMemo)((()=>{const e=((e,t)=>{let n=t.birthday;const a=[];let l=0;return e.forEach((e=>{if(bf(e))return;if(null===e.outOfMoneyYear)return void(l+=1);const t=(0,Ba.GB)(e.outOfMoneyYear,n);void 0!==t&&a.push({value:t,succeeded:!1,pathNumber:e.pathNumber})})),{values:a,neverAboveZeroCount:l}})(l,{birthday:v}),t=e.values,a=e.neverAboveZeroCount;return{shortfallDistribution:void 0===n?null:GM(t,{bucketCount:n,minBucketWidth:1,includeInDomain:null!==b&&void 0!==b?b:void 0}),neverAboveZeroCount:a}}),[l,v,b,n]),C=w.shortfallDistribution,A=w.neverAboveZeroCount;return{retirementNetWorth:{distribution:f,planValue:m},endingNetWorth:{distribution:x,planValue:y},shortfallAge:{distribution:C,planValue:b},neverAboveZeroCount:A,hasRetirementEvent:g,hasRun:l.length>0,hasBirthday:void 0!==v,retirementAge:p,planEndAge:b}};var cL,dL;const uL="Run the simulation to see this",mL=()=>{const e=(0,qd.W)(),t=(0,o.A)(e,2),n=t[0],l=t[1].width,r=pL(void 0===l?0:l),i=sL({bucketCount:r}),s=i.retirementNetWorth,c=i.endingNetWorth,d=i.shortfallAge,u=i.neverAboveZeroCount,m=i.hasRetirementEvent,p=i.hasRun,g=i.hasBirthday,h=i.retirementAge,v=i.planEndAge,f=_I(),E=(0,a.useCallback)((e=>fL(e)),[]),y=(0,a.useCallback)((e=>(0,rl.fw)(e)),[]),b=(0,a.useCallback)((e=>"plan ".concat(fL(e))),[]);return a.createElement(bL,{"data-external-id":"forecast-outcome-distributions"},a.createElement(xL,null,a.createElement(BM,{label:vL("Net worth at retirement",h),tooltip:"Where every path lands in the year you retire. The line marks your projected plan, and the shaded band covers the middle 1 in 5 paths."}),a.createElement("div",{ref:n,className:"w-full"},a.createElement(HM,Object.assign({},s,{row:"retirementNetWorth",formatValue:E,formatBucketValue:y,formatPlanLabel:b,fill:"outcomeSplit",emptyMessage:hL({hasRetirementEvent:m,hasRun:p}),isStale:f})))),a.createElement(xL,null,a.createElement(BM,{label:vL("Net worth at plan end",v),tooltip:"Where every path lands at the end of your plan. The line marks your projected plan, and the shaded band covers the middle 1 in 5 paths."}),a.createElement(HM,Object.assign({},c,{row:"endingNetWorth",formatValue:E,formatBucketValue:y,formatPlanLabel:b,fill:"outcomeSplit",emptyMessage:uL,isStale:f}))),a.createElement(xL,null,a.createElement(BM,{label:"Shortfall age",tooltip:"Your age when a path runs out of money, across the paths that do. The line marks your age at the end of your plan."}),a.createElement(HM,Object.assign({},d,{row:"shortfallAge",formatValue:EL,formatPlanLabel:yL,fill:"danger",emptyMessage:gL({hasBirthday:g,hasRun:p,neverAboveZeroCount:u}),isStale:f})),u>0&&a.createElement(fe.c8D,{size:"2xs",color:"secondary",className:(0,q.cn)(f&&"opacity-60")},"".concat((0,De.td)("path",u,{inclusive:!0})," never got above zero"))))}
1,pL=e=>{const t=(0,a.useRef)(void 0),n=(e=>0===e?void 0:Math.max(8,Math.floor(e/8)))(e);return void 0!==n&&(t.current=n),null!==n&&void 0!==n?n:t.current},gL=e=>{let t=e.hasBirthday,n=e.hasRun,a=e.neverAboveZeroCount;return t?n?a>0?"No paths ran out of money mid-plan":"No paths ran out of money":uL:"Add your birthday to see this"},hL=e=>{let t=e.hasRetirementEvent,n=e.hasRun;return t?n?"No paths include your retirement year":uL:"Add a retirement event to see this"},vL=(e,t)=>null===t?e:"".concat(e," (age ").concat(Math.round(t),")"),fL=e=>0===Math.round(e)?"$0":(0,rl.Ig)(e),EL=e=>"".concat(Math.round(e)),yL=e=>"end of plan \xb7 ".concat(Math.round(e)),bL=$d.s.div(cL||(cL=(0,wc.A)(["flex flex-2 flex-col"]))),xL=$d.s.div(dL||(dL=(0,wc.A)(["\n  flex flex-col items-start gap-3xs px-xl py-xs\n  not-last:border-b not-last:border-divider-primary\n  @max-[880px]/statbar:px-lg\n  @max-[780px]/statbar:px-md\n  @max-[640px]/statbar:px-sm\n  @max-[580px]/statbar:px-xs\n"]))),wL=220,CL=110,AL=99,IL=11,kL=157,SL=226,NL=1-.8,TL=CL+AL*Math.sin(kL*Math.PI/180)+5.5,_L=(()=>{const e=e=>{const t=e*Math.PI/180;return{x:CL+AL*Math.cos(t),y:CL+AL*Math.sin(t)}},t=e(kL),n=e(383);return"M ".concat(t.x," ").concat(t.y," A ").concat(AL," ").concat(AL," 0 ").concat(1," 1 ").concat(n.x," ").concat(n.y)})(),DL=(()=>{const e=kL*Math.PI/180;return{x:CL+AL*Math.cos(e),y:CL+AL*Math.sin(e)}})(),RL=e=>Math.round(e*TL/wL),ML=e=>{let t=e.target,n=e.animate,l=void 0===n||n,r=e.durationMs,i=void 0===r?1200:r,s=e.restartKey;const c=ud(),d=l&&!c,u=(0,a.useState)(d?0:t),m=(0,o.A)(u,2),p=m[0],g=m[1],h=(0,a.useState)(s),v=(0,o.A)(h,2),f=v[0],E=v[1];s!==f&&(E(s),g(d?0:t));const y=(0,a.useRef)(p);return y.current=p,(0,a.useEffect)((()=>{if(!d)return void g(t);const e=y.current;let n=0,a=0;const l=r=>{a||(a=r);const o=Math.min(1,(r-a)/i);g(e+(t-e)*(1-(1-o)**3)),o<1&&(n=requestAnimationFrame(l))};return n=requestAnimationFrame(l),()=>cancelAnimationFrame(n)}),[t,d,i,s]),d?p:t},LL=50/220,OL=e=>{let t=e.successRate,n=e.successfulPathCount,l=e.totalPathCount,r=e.isStale,i=e.runKey,s=e.className;const c=(0,qd.W)(),d=(0,o.A)(c,2),u=d[0],m=d[1],p=m.width,g=void 0===p?0:p,h=m.height,v=void 0===h?0:h,f=null!==t&&l>0,E=0===v?1/0:(v-(f?24:0))*wL/TL,y=0===g?104:PL(Math.min(g,E),104,260),b=g>0&&g<104,x=ML({target:f?t:0,restartKey:i}),w=f?((e,t)=>{var n,a;if(t<=0)return null;const l=Math.min(Math.max(e,0),t);return null!==(n=null===(a=If(t).find((e=>{let t=e.max;return l<=t})))||void 0===a?void 0:a.color)&&void 0!==n?n:Af[Af.length-1].color})(n,l):null,C=w?kf[w]:void 0,A=r?"stroke-chart-fill-gray":null===C||void 0===C?void 0:C.arc,I=r?"text-content-secondary":"text-content-primary",k=r?"fill-chart-fill-gray":null===C||void 0===C?void 0:C.fill,S="forecast-success-gauge-reveal-".concat((0,a.useId)().replace(/:/g,"")),N=x*SL,T=f?Nf(x):"\u2014",_=f?"".concat((0,De.LN)(n)," of ").concat((0,De.LN)(l)," paths"):null;return a.createElement("div",{"data-external-id":"forecast-success-gauge",ref:u,className:(0,q.cn)("relative w-full min-w-0",s)},b?a.createElement("div",{className:"flex flex-col items-start gap-3xs"},a.createElement("span",{className:(0,q.cn)("leading-none font-medium tabular-nums",I)},T),null!==_&&a.createElement(fe.c8D,{size:"xs",color:"secondary"},_)):a.createElement("div",{className:(0,q.cn)("absolute inset-x-0 flex flex-col items-center gap-2xs",v>0?"inset-y-0 justify-center":"top-0")},a.createElement("div",{className:"relative shrink-0 overflow-visible select-none",style:{width:y,height:RL(y)}},a.createElement("div",{className:"absolute top-0 left-0 overflow-visible",style:{width:y,height:y}},a.createElement("svg",{"aria-hidden":!0,className:"absolute inset-0 overflow-visible",width:y,height:y,viewBox:"0 0 ".concat(wL," ").concat(wL),fill:"none"},a.createElement("defs",null,a.createElement("mask",{id:S},a.createElement("path",{d:_L,stroke:"white",strokeWidth:13,strokeLinecap:"round",pathLength:1,strokeDasharray:"".concat(x," 2")}))),a.createElement("path",{d:_L,className:"stroke-chart-event-background-gray",strokeWidth:IL,strokeLinecap:"round",pathLength:1}),a.createElement("path",{"data-testid":"forecast-success-gauge-arc",d:_L,className:A,strokeWidth:IL,strokeLinecap:"round",pathLength:1,mask:"url(#".concat(S,")")}),null!==w&&a.createElement("g",{transform:"rotate(".concat(N," ").concat(CL," ").concat(CL,")")},a.createElement("circle",{cx:DL.x,cy:DL.y,r:9,className:"fill-background-primary"}),a.createElement("circle",{"data-testid":"forecast-success-gauge-dot",cx:DL.x,cy:DL.y,r:6,className:k}))),a.createElement("div",{className:"absolute inset-0 flex flex-col items-center justify-center"},a.createElement("span",{className:(0,q.cn)("leading-none font-medium tabular-nums",I),style:{fontSize:y*LL}},T)))),null!==_&&a.createElement(fe.c8D,{size:"xs",color:"secondary"},_)))},PL=(e,t,n)=>Math.min(n,Math.max(t,e)),BL={successRate:null,successfulPathCount:0,totalPathCount:0},zL={red:"Red",orange:"Orange",yellow:"Yellow",green:"Green"}
1,FL=e=>{let t=e.totalPaths;const n=aA((e=>e.successFloor)),l=void 0!==t&&t>0?If(t).map((e=>{let n=e.color,a=e.min,l=e.max;return{color:n,text:"".concat((0,De.LN)(a),"\u2013").concat((0,De.LN)(l)," of ").concat((0,De.LN)(t)," paths on track")}})):Sf.map((e=>{let t=e.color,n=e.range;return{color:t,text:"".concat(n," of paths on track")}}));return a.createElement("div",{"data-external-id":"success-infotip-content",className:"flex flex-col gap-sm text-left"},a.createElement(fe.c8D,{size:"xs",weight:"medium"},n>0?"The percentage of paths that reach the end of your plan without running out of money and finish with at least ".concat((0,rl.fw)(n),". Each path is your plan played out in one simulated market."):"The percentage of paths that reach the end of your plan without running out of money. Each path is your plan played out in one simulated market."),a.createElement("dl",{className:"m-0 flex flex-col gap-2xs"},l.map((e=>{let t=e.color,n=e.text;return a.createElement("div",{key:t,className:"flex items-center gap-2xs"},a.createElement("dt",{className:"flex items-center gap-2xs"},a.createElement("span",{role:"img","aria-label":zL[t],className:(0,q.cn)("size-xs rounded-full",kf[t].dot)})),a.createElement("dd",{className:"m-0"},a.createElement(fe.c8D,{size:"xs",weight:"medium",color:"secondary"},n)))}))))};var GL,YL;const UL=()=>{const e=QE(),t=ty(),n=Jx({startYear:e.startYear,currentParticipant:t}),l=n.netWorthEOY,r=n.netWorthAtRetirement,o=n.retirementAge,i=n.netWorthAtEnd,s=n.endOfPlanYear,c=n.hasRetirementEvent,d=iE(),u=py().isEnabled,m=RS(),p=m.forecastingMode,g=m.isComparisonActive,h=aw(),v=h.compareToScenarioId,f=h.kpis,E=h.projectionStatus,y=(0,Tp.n)(v)&&g,b="loading"===E,x=(0,a.useCallback)((()=>{t&&d(t)}),[d,t]);return u&&"chanceOfSuccess"===p?a.createElement(VL,{"data-external-id":"forecast-stat-bar"}):a.createElement(KL,{"data-external-id":"forecast-stat-bar",isFullBleed:u},a.createElement(HL,{label:"Net worth (EOY)",tooltip:"The total value of the assets and debts included in your forecast at the end of the year.",kpiComparisonConfig:bM(y,b,"netWorth",l,null===f||void 0===f?void 0:f.netWorthToday)},null!==l?a.createElement(qL,{className:WL(l)},(0,rl.fw)(l)):void 0),a.createElement(HL,{label:"Net worth at retirement",tooltip:"Your projected investable net worth when you retire.",kpiComparisonConfig:bM(y,b,"netWorth",r,null===f||void 0===f?void 0:f.netWorthAtRetirement)},null!==r?a.createElement(qL,{className:WL(r)},(0,rl.fw)(r)):void 0),a.createElement(HL,{label:"Retirement age",value:y||c?o:void 0,kpiComparisonConfig:bM(y,b,"retirementAge",o,null===f||void 0===f?void 0:f.retirementAge)},y||c?null:a.createElement(Wb.X,{variant:"default",icon:a.createElement(fe.E2F,null),onClick:x},"Add retirement")),a.createElement(HL,{label:"Net worth at end",tooltip:void 0!==s?"What\u2019s left at the end of your plan in ".concat(s):"What\u2019s left at the end of your plan",kpiComparisonConfig:bM(y,b,"netWorth",i,null===f||void 0===f?void 0:f.netWorthAtEnd)},null!==i?a.createElement(qL,{className:WL(i)},(0,rl.fw)(i)):void 0))},VL=()=>{const e=(e=>{let t=e.summaries,n=e.successFloor,l=e.isTodaysDollars;return(0,a.useMemo)((()=>{if(0===t.length)return BL;const e=t.filter((e=>"onTrack"===Df(e,{successFloor:n,isTodaysDollars:l}))).length;return{successRate:e/t.length,successfulPathCount:e,totalPathCount:t.length}}),[t,n,l])})({summaries:SI(),successFloor:aA((e=>e.successFloor)),isTodaysDollars:TI()}),t=e.successRate,n=e.successfulPathCount,l=e.totalPathCount;return a.createElement(KL,{"data-external-id":"chance-of-success-stat-row",isFullBleed:!0},a.createElement(jL,{successRate:t,successfulPathCount:n,totalPathCount:l}),a.createElement(mL,null))},WL=e=>!Np(e)&&e<0?"text-content-danger":"text-content-primary",jL=e=>{let t=e.successRate,n=e.successfulPathCount,l=e.totalPathCount;const r=_I(),o=kI(),i=o?"".concat(o.runSeed,":").concat(o.asOfDate.getTime()):null;return a.createElement(PM,{"data-external-id":"success-stat-item",className:"min-w-0 py-xs"},a.createElement(BM,{label:"Chance of success",tooltip:a.createElement(FL,{totalPaths:l})}),a.createElement(OL,{className:"flex-1",successRate:t,successfulPathCount:n,totalPathCount:l,isStale:r,runKey:i}))},HL=e=>{let t=e.label,n=e.value,l=e.tooltip,r=e.children,o=e.kpiComparisonConfig;const i=null!==r&&void 0!==r?r:(0,Tp.n)(n)?a.createElement(qL,null,n):a.createElement($L,null,"\u2014");return a.createElement(PM,{"data-external-id":"stat-item"},a.createElement(BM,{label:t,tooltip:l}),o?a.createElement(_M,Object.assign({activeContent:i},o)):a.createElement("div",{className:"flex items-center gap-sm text-xl @max-[520px]/statbar:text-20 @max-[420px]/statbar:text-lg"},i))},KL=e=>{let t=e.isFullBleed,n=e.children;return a.createElement("div",{"data-external-id":"root","data-testid":"forecast-stat-bar",className:(0,q.cn)("@container/statbar flex items-stretch border-divider-primary",t?"border-y":"mx-default rounded-sm border")},n)},qL=$d.s.span(GL||(GL=(0,wc.A)(["flex h-9 items-center font-medium text-content-primary"]))),$L=$d.s.span(YL||(YL=(0,wc.A)(["flex h-9 items-center font-medium text-content-secondary"])));var ZL,JL,XL,QL,eO,tO;const nO=$d.s.div(ZL||(ZL=(0,wc.A)(["flex flex-col gap-xs"]))),aO=$d.s.dl(JL||(JL=(0,wc.A)(["m-0 flex flex-col gap-2xs"]))),lO=(0,$d.s)(xt.v)(XL||(XL=(0,wc.A)([""]))),rO=$d.s.div(QL||(QL=(0,wc.A)(["flex items-center justify-between gap-default"]))),oO=(0,$d.s)(xt.v).attrs({color:"content.secondary",as:"dt"})(eO||(eO=(0,wc.A)(["shrink-0"]))),iO=(0,$d.s)(xt.v).attrs({as:"dd"})(tO||(tO=(0,wc.A)(["m-0 flex items-center justify-end gap-2xs"]))),sO=e=>{let t=e.label,n=e.value,l=e.labelId;return a.createElement(rO,{"data-external-id":"tooltip-label-value-row"},a.createElement(oO,{id:l},t),a.createElement(iO,{"aria-labelledby":l},"string"===typeof n||"number"===typeof n?a.createElement(xt.v,{size:"small",weight:"medium"},n):n))};var cO,dO;const uO=e=>{let t=e.scenarioMetadata,n=e.children;return a.createElement(hO,{"data-external-id":"event-tooltip-base",active:!0},a.createElement(gO,null,null!==t&&void 0!==t&&t.name?a.createElement("div",{className:"flex items-center gap-2xs px-xs"},a.createElement(TS,{icon:t.icon,size:12,color:t.color,className:"shrink-0"}),a.createElement(lO,{size:"xsmall",color:"content.secondary",className:"wrap-break-word whitespace-normal"},t.name)):null,a.createElement("div",{className:"flex flex-col gap-default"},n)))},mO=e=>{let t=e.title,n=e.children;return a.createElement(nO,{"data-external-id":"event-tooltip-section",className:"px-xs"},a.createElement(lO,{size:"small",weight:"medium"},t),a.createElement(aO,null,n))},pO=e=>{let t=e.label,n=e.value;return a.createElement(sO,{"data-external-id":"event-tooltip-row",label:t,value:n})},gO=$d.s.div(cO||(cO=(0,wc.A)(["flex flex-col px-sm py-default text-sm font-medium"]))),hO=(0,$d.s)(Sa.II)(dO||(dO=(0,wc.A)(["max-w-90 min-w-75 p-0 **:data-chart-tooltip-value:p-0"]))),vO=e=>{let t=e.annotation;const n=t.targetDate?N.c9.fromISO(t.targetDate).toFormat("MMMM yyyy"):void 0;return a.createElement(uO,{"data-external-id":"goal-completion-annotation-tooltip"},a.createElement(mO,{title:"Save up goal"},a.createElement(pO,{label:"Goal",value:t.goalName}),!!t.targetAmount&&a.createElement(pO,{label:"Target amount",value:(0,rl.fw)(t.targetAmount)}),void 0!==n&&a.createElement(pO,{label:"Target date",value:n})))},fO=e=>{var t,n;let l=e.annotation;const o=(0,r.YW)(l.dollarMode).with("todaysDollars",(()=>
1({yearlyExpenseReduction:l.yearlyExpenseReductionTodaysDollars,totalPaid:l.totalPaymentsTodaysDollars}))).otherwise((()=>({yearlyExpenseReduction:l.yearlyExpenseReduction,totalPaid:l.totalPayments}))),i=o.yearlyExpenseReduction,s=o.totalPaid;return a.createElement(uO,{"data-external-id":"payoff-annotation-tooltip",scenarioMetadata:l.scenarioMetadata},a.createElement(mO,{title:"Debt paid off!"},a.createElement(pO,{label:"Account",value:a.createElement("div",{className:"flex items-center gap-2xs"},a.createElement(_w,{logoUrl:null===(t=l.metadata)||void 0===t?void 0:t.logoUrl,icon:null===(n=l.metadata)||void 0===n?void 0:n.icon,accountId:l.accountId,size:20}),a.createElement(fe.c8D,{size:"sm",weight:"medium"},l.accountName))}),i>0&&a.createElement(pO,{label:"Yearly expense reduction",value:(0,rl.fw)(i)}),a.createElement(pO,{label:"Total paid",value:(0,rl.fw)(s)}),a.createElement(pO,{label:"Year",value:l.year.toString()})))},EO=e=>{let t=e.annotation;return(0,r.YW)(t).with({kind:"payoff"},(e=>a.createElement(fO,{annotation:e}))).with({kind:"goalCompletion"},(e=>a.createElement(vO,{annotation:e}))).exhaustive()},yO=e=>{let t=e.annotations;return a.createElement(uO,{"data-external-id":"grouped-annotation-tooltip"},a.createElement(mO,{title:"".concat(t.length," milestone").concat(1===t.length?"":"s")},a.createElement("div",{className:"flex flex-col gap-xs"},t.map((e=>(0,r.YW)(e).with({kind:"payoff"},(e=>a.createElement(bO,{key:e.id,annotation:e}))).with({kind:"goalCompletion"},(e=>a.createElement(xO,{key:e.id,annotation:e}))).exhaustive())))))},bO=e=>{var t,n;let l=e.annotation;const r="todaysDollars"===l.dollarMode?l.totalPaymentsTodaysDollars:l.totalPayments,o=l.scenarioMetadata;return a.createElement("div",{"data-external-id":"payoff-row",className:"flex items-center gap-xs"},a.createElement(_w,{logoUrl:null===(t=l.metadata)||void 0===t?void 0:t.logoUrl,icon:null===(n=l.metadata)||void 0===n?void 0:n.icon,accountId:l.accountId,size:20}),a.createElement("div",{className:"flex min-w-0 flex-1 flex-col"},a.createElement(fe.c8D,{size:"sm",weight:"medium",className:"line-clamp-1"},l.accountName),a.createElement("div",{className:"flex items-center gap-2xs"},a.createElement(fe.c8D,{size:"xs",color:"secondary"},"Paid off \xb7 ",(0,rl.fw)(r)),null!==o&&void 0!==o&&o.name?a.createElement(a.Fragment,null,a.createElement(fe.c8D,{size:"xs",color:"secondary"},"\xb7"),a.createElement(TS,{icon:o.icon,size:12,color:o.color,className:"shrink-0"}),a.createElement(fe.c8D,{size:"xs",color:"secondary",className:"line-clamp-1"},o.name)):null)))},xO=e=>{let t=e.annotation;const n=t.targetDate?N.c9.fromISO(t.targetDate).toFormat("MMM yyyy"):void 0;return a.createElement("div",{"data-external-id":"goal-row",className:"flex items-center gap-xs"},a.createElement(fe.lGO,{size:"lg",className:"shrink-0"}),a.createElement("div",{className:"flex min-w-0 flex-1 flex-col"},a.createElement(fe.c8D,{size:"sm",weight:"medium",className:"line-clamp-1"},t.goalName),a.createElement(fe.c8D,{size:"xs",color:"secondary"},"Goal",t.targetAmount?" \xb7 ".concat((0,rl.fw)(t.targetAmount)):"",n?" \xb7 ".concat(n):"")))},wO=e=>{var t,n,l;let r=e.event,o=e.dollarMode;const i="finance"===r.purchaseMethod,s=null!==(t=r.startYear)&&void 0!==t?t:r.settings.startYear,c=wp(r.homeValue,s,r.settings),d=e=>o.toTodaysDollars(e,s),u=Up((0,U.A)((0,U.A)({},r.config),{},{homeValue:c})),m=u.downPaymentAmount,p=u.totalMonthlyPayment,g=u.monthlyPMI,h=u.principal,v=u.yearlyOwnershipCosts,f=r.replaceExistingHousing&&r.currentMonthlyHousingPayment>0,E=f?wp(12*r.currentMonthlyHousingPayment,s,r.settings):0,y=r.downPaymentPercent<20&&g>0,b=y?(()=>{const e=Yp(h,c,r.mortgageRate,r.mortgageTerm);return e<12?(0,De.td)("month",e,{inclusive:!0}):(0,De.td)("year",Math.floor(e/12),{inclusive:!0})})():null;return a.createElement(a.Fragment,null,a.createElement(mO,{title:r.displayName},a.createElement(pO,{label:"Year",value:null!==(n=null===(l=r.startYear)||void 0===l?void 0:l.toString())&&void 0!==n?n:""}),a.createElement(pO,{label:"Home value",value:(0,rl.T3)(d(c))})),i&&a.createElement(mO,{title:"Finance"},a.createElement(pO,{label:"".concat(r.downPaymentPercent,"% down payment"),value:(0,rl.T3)(d(m))}),a.createElement(pO,{label:"Mortgage term",value:"".concat(r.mortgageTerm," year")}),a.createElement(pO,{label:"Interest rate",value:"".concat(r.mortgageRate,"%")})),a.createElement(mO,{title:"Yearly expenses"},a.createElement(pO,{label:"Monthly payments",value:(0,rl.T3)(d(12*p
1))}),y&&b&&a.createElement(pO,{label:"".concat(r.pmiRate,"% PMI"),value:"".concat(b,", ").concat((0,rl.T3)(d(12*g)))}),a.createElement(pO,{label:"Cost of ownership",value:(0,rl.T3)(d(v))}),f&&a.createElement(pO,{label:"Replace housing expenses",value:(0,rl.T3)(d(-E))})))},CO=e=>{var t,n;let l=e.event;const r=l.owner;return a.createElement(a.Fragment,null,a.createElement(mO,{title:l.displayName},a.createElement(pO,{label:"Start year",value:null!==(t=null===(n=l.startYear)||void 0===n?void 0:n.toString())&&void 0!==t?t:""}),"number"===typeof l.endYear&&a.createElement(pO,{label:"End year",value:l.endYear.toString()}),l.hasMultipleActiveParticipants&&r&&a.createElement(pO,{label:"Owner",value:r.displayName})),a.createElement(mO,{title:"Impact"},a.createElement(pO,{label:"Living expenses",value:mI(l.expenseMultiplier)}),a.createElement(pO,{label:"Income reduction",value:AO(l)})))},AO=e=>{var t;const n=(null!==(t=e.config.incomeReductionTargets)&&void 0!==t?t:[]).filter((e=>e.reductionPercent>0));return 0===n.length?"None":n.map((e=>"".concat(e.reductionPercent,"%"))).join(", ")},IO=e=>"(age ".concat(e,")"),kO=e=>{let t=e.event;const n=t.settings.participants.find((e=>e.userId===t.ownerId)),l=(0,Ba.GB)(t.startYear,null===n||void 0===n?void 0:n.birthday);return a.createElement(mO,{"data-external-id":"end-of-plan-event-tooltip",title:t.displayName},a.createElement(pO,{label:"Year",value:a.createElement(a.Fragment,null,a.createElement(xt.v,{size:"small",weight:"medium"},t.startYear),void 0!==l&&a.createElement(xt.v,{size:"small",weight:"medium",color:"content.secondary"},IO(l)))}),t.hasMultipleActiveParticipants&&n&&a.createElement(pO,{label:"Owner",value:n.displayName}))},SO=(e,t,n,a)=>"todaysDollars"===a.mode?e:wp(e,t,n),NO=e=>{var t,n,l;let r=e.event,o=e.dollarMode;const i=null!==(t=r.startYear)&&void 0!==t?t:r.settings.startYear,s=SO(r.yearlyChildExpenses,i,r.settings,o),c=SO(r.upfrontChildCosts,i,r.settings,o);return a.createElement(a.Fragment,null,a.createElement(mO,{title:r.displayName},a.createElement(pO,{label:"Year",value:null!==(n=null===(l=r.startYear)||void 0===l?void 0:l.toString())&&void 0!==n?n:""}),a.createElement(pO,{label:"Years of child expenses",value:"".concat(r.yearsOfChildcare," years")})),a.createElement(mO,{title:"Expenses"},a.createElement(pO,{label:"Yearly child expenses",value:(0,rl.T3)(s)}),a.createElement(pO,{label:"Upfront child costs",value:(0,rl.T3)(c)})))},TO=e=>{var t,n,l,r,o;let i=e.event,s=e.dollarMode;const c=null!==(t=i.startYear)&&void 0!==t?t:i.settings.startYear,d=SO(i.amount,c,i.settings,s);return a.createElement(mO,{"data-external-id":"income-event-tooltip",title:i.displayName},"yearly"!==i.frequency?a.createElement(a.Fragment,null,a.createElement(pO,{label:"Year",value:null!==(n=null===(l=i.startYear)||void 0===l?void 0:l.toString())&&void 0!==n?n:""}),a.createElement(pO,{label:"Income amount",value:(0,rl.T3)(d)})):a.createElement(a.Fragment,null,a.createElement(pO,{label:"number"===typeof i.endYear?"Start year":"Starting year",value:null!==(r=null===(o=i.startYear)||void 0===o?void 0:o.toString())&&void 0!==r?r:""}),!i.isHidden&&a.createElement(pO,{label:"Repeat every",value:1===i.getEffectiveIntervalYears()?"1 year":"".concat(i.getEffectiveIntervalYears()," years")}),"number"===typeof i.endYear&&a.createElement(pO,{label:"End year",value:i.endYear.toString()}),a.createElement(pO,{label:"Yearly income amount",value:(0,rl.T3)(d)})))},_O=e=>{var t;let n=e.event,l=e.dollarMode;const r=n.ownerId?n.settings.participants.find((e=>e.userId===n.ownerId)):void 0,o=(0,Ba.GB)(n.startYear,null===r||void 0===r?void 0:r.birthday),i=null!==(t=n.startYear)&&void 0!==t?t:n.settings.startYear,s=SO(n.yearlyTakeHomeIncome,i,n.settings,l),c=SO(n.signingBonus,i,n.settings,l);return a.createElement(a.Fragment,null,a.createElement(mO,{title:n.displayName},a.createElement(pO,{label:"Year",value:a.createElement(a.Fragment,null,a.createElement(xt.v,{size:"small",weight:"medium"},n.startYear),void 0!==o&&a.createElement(xt.v,{size:"small",weight:"medium",color:"content.secondary"},IO(o)))}),n.hasMultipleActiveParticipants&&r&&a.createElement(pO,{label:"Owner",value:r.displayName})),a.createElement(mO,{title:"Income"},a.createElement(pO,{label:"Yearly take-home",value:(0,rl.T3)(s)}),n.signingBonus>0&&a.createElement(pO,{label:"Signing bonus",value:(0,rl.T3)(c)})))},DO=e=>{var t,n,l,r,o;let i=e.event,s=e.dollarMode;const c=null!==(t=i.startYear)&&void 0!==t?t:i.settings.startYear,d=SO(i.amount,c,i.settings,s);return a.createElement(mO,{"data-external-id":"other-expense-event-tooltip",title:i.displayName},"yearly"!==i.frequency?a.createElement(a.Fragment,null,a.createElement(pO,{label:"Year",value:null!==(n=null===(l=i.startYear)||void 0===l?void 0:l.toString())&&void 0!==n?n:""}),a.createElement(pO,{label:"Expense amount",value:(0,rl.T3)(d)})):a.createElement(a.Fragment,null,a.createElement(pO,{label:"number"===typeof i.endYear?"Start year":"Starting year",value:null!==(r=null===(o=i.startYear)||void 0===o?void 0:o.toString())&&void 0!==r?r:""}),a.createElement(pO,{label:"Repeat every",value:1===i.getEffectiveIntervalYears()?"1 year":"".concat(i.getEffectiveIntervalYears()," years")}),"number"===typeof i.endYear&&a.createElement(pO,{label:"End year",value:i.endYear.toString()}),a.createElement(pO,{label:"Yearly expense amount",value:(0,rl.T3)(d)})))},RO=e=>{var t;let n=e.event,l=e.dollarMode;const r=qE(),o=n.ownerId?n.settings.participants.find((e=>e.userId===n.ownerId)):void 0,i=mI(n.expenseMultiplier),s=(0,Ba.GB)(n.startYear,null===o||void 0===o?void 0:o.birthday),c=null!==(t=n.startYear)&&void 0!==t?t:n.settings.startYear,d=SO(n.additionalYearlyExpenses,c,n.settings,l),u=(0,a.useMemo)((()=>{var e;const t=null!==(e=n.config.incomeReductionTargets)&&void 0!==e?e:[];return 0===t.length?[]:t.map((e=>MO(e,r))).filter((e=>null!==e))}),[n.config.incomeReductionTargets,r]);return a.createElement(a.Fragment,null,a.createElement(mO,{title:n.displayName},a.createElement(pO,{label:"Year",value:a.createElement(a.Fragment,null,a.createElement(xt.v,{size:"small",weight:"medium"},n.startYear),void 0!==s&&a.createElement(xt.v,{size:"small",weight:"medium",color:"content.secondary"},IO(s)))}),n.hasMultipleActiveParticipants&&o&&a.createElement(pO,{label:"Owner",value:o.displayName})),a.createElement(mO,{title:"Expenses"},a.createElement(pO,{label:"Expenses in retirement",value:i}),a.createElement(pO,{label:"Additional yearly expenses",value:(0,rl.T3)(d)})),u.length>0&&a.createElement(mO,{title:"Income reduction"},u.map((e=>a.createElement(pO,{key:e.targetEventId,label:e.name,value:"".concat(e.reductionPercent,"%")})))))},MO=(e,t)=>
1{if(e.reductionPercent<=0)return null;const n=(null!==t&&void 0!==t?t:[]).find((t=>t.id===e.targetEventId&&qp(t)&&t.isIncluded));return n?{targetEventId:e.targetEventId,name:n.name,reductionPercent:e.reductionPercent}:null},LO=e=>{var t;let n=e.event,l=e.dollarMode;const r=n.ownerId?n.settings.participants.find((e=>e.userId===n.ownerId)):void 0,o=(0,Ba.GB)(n.startYear,null===r||void 0===r?void 0:r.birthday),i=null!==(t=n.startYear)&&void 0!==t?t:n.settings.startYear,s=SO(12*n.monthlyBenefitAmount,i,n.settings,l);return a.createElement(a.Fragment,null,a.createElement(mO,{title:n.displayName},a.createElement(pO,{label:"Year",value:a.createElement(a.Fragment,null,a.createElement(xt.v,{size:"small",weight:"medium"},n.startYear),void 0!==o&&a.createElement(xt.v,{size:"small",weight:"medium",color:"content.secondary"},IO(o)))}),n.hasMultipleActiveParticipants&&r&&a.createElement(pO,{label:"Owner",value:r.displayName})),a.createElement(mO,{title:"Income"},a.createElement(pO,{label:"Yearly benefit amount",value:(0,rl.T3)(s)})))},OO=e=>{var t,n,l;let r=e.event,o=e.dollarMode;const i=null!==(t=r.startYear)&&void 0!==t?t:r.settings.startYear,s=SO(r.amount,i,r.settings,o);return a.createElement(mO,{"data-external-id":"windfall-event-tooltip",title:r.displayName},a.createElement(pO,{label:"Year",value:null!==(n=null===(l=r.startYear)||void 0===l?void 0:l.toString())&&void 0!==n?n:""}),a.createElement(pO,{label:"Income amount",value:(0,rl.T3)(s)}))},PO=e=>{let t=e.event,n=e.scenarioMetadata,l=e.dollarMode;const o=ow(),i=((e,t)=>(0,r.YW)(e).with(r.P.instanceOf(wg),(e=>a.createElement(RO,{event:e,dollarMode:t}))).with(r.P.instanceOf(yg),(e=>a.createElement(_O,{event:e,dollarMode:t}))).with(r.P.instanceOf(Ag),(e=>a.createElement(LO,{event:e,dollarMode:t}))).with(r.P.instanceOf(vg),(e=>a.createElement(TO,{event:e,dollarMode:t}))).with(r.P.instanceOf(bg),(e=>a.createElement(DO,{event:e,dollarMode:t}))).with(r.P.instanceOf(ug),(e=>a.createElement(NO,{event:e,dollarMode:t}))).with(r.P.instanceOf(Wp),(e=>a.createElement(wO,{event:e,dollarMode:t}))).with(r.P.instanceOf(ig),(e=>a.createElement(CO,{event:e}))).with(r.P.instanceOf(dg),(e=>a.createElement(kO,{event:e}))).with(r.P.instanceOf(Ig),(e=>a.createElement(OO,{event:e,dollarMode:t}))).otherwise((()=>null)))(t,null!==l&&void 0!==l?l:o);return i?a.createElement(uO,{"data-external-id":"event-tooltip",scenarioMetadata:n},i):null},BO=e=>{let t=e.target,n=e.hoveredEvent,l=e.hoveredAnnotations,r=e.eventTooltipScenarioMetadata,o=e.eventTooltipDollarMode;return"event"===t.kind?n?a.createElement(PO,{"data-external-id":"marker-tooltip-content",event:n,scenarioMetadata:r,dollarMode:o}):null:0===l.length?null:1===l.length?a.createElement(EO,{"data-external-id":"marker-tooltip-content",annotation:l[0]}):a.createElement(yO,{"data-external-id":"marker-tooltip-content",annotations:l})},zO=()=>a.createElement(FO,{"data-external-id":"new-event-tooltip",active:!0},a.createElement("div",{className:"flex px-default py-sm"},a.createElement(xt.v,{size:"xsmall",weight:"medium",color:"content.white"},"New event"))),FO=(0,u.default)(Sa.II).withConfig({displayName:"NewEventTooltip__StyledChartTooltip",componentId:"eci3c8-0"})(["[data-sc-tw~='ChartTooltip__TooltipValue']{padding:0;}"]),GO=["mcOuterBand","mcInnerBand"],YO=e=>{let t=1/0,n=-1/0;for(const a of e)for(const e of GO){const l=a[e];l&&(t=Math.min(t,l[0]),n=Math.max(n,l[1]))}return t<=n?[t,n]:[]},UO=e=>{const t=(0,a.useMemo)((()=>function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:5;if(0===e.length)return{ticks:[0],domain:[0,0]};if(t<1)return{ticks:[],domain:[Math.min(...e),Math.max(...e)]};let n=Math.min(...e),a=Math.max(...e);if(n===a){const e=.1*Math.abs(n)||1;n-=e,a+=e}const l=(a-n)/t,r=Math.pow(10,Math.floor(Math.log10(l))),o=l/r;let i;i=o<=1.5?r:o<=3?2*r:o<=7?5*r:10*r;const s=Math.floor(n/i)*i,c=Math.ceil(a/i)*i,d=[];for(let u=s;u<=c+.01*i;u+=i)d.push(Math.round(1e6*u)/1e6);return{ticks:d,domain:[d[0],d[d.length-1]]}}(e)),[e]),n=t.ticks,l=t.domain,r=(0,o.A)(l,2),i=r[0],s=r[1],c=(0,a.useState)(l),d=(0,o.A)(c,2),u=d[0],m=d[1],p=(0,a.useRef)(null),g=(0,a.useRef)(0),h=(0,a.useRef)(l),v=(0,a.useRef)(l),f=(0,a.useCallback)((()=>{null!==p.current&&(cancelAnimationFrame(p.current),p.current=null)}),[]);return(0,a.useLayoutEffect)((()=>{const e=(0,o.A)(v.current,2),t=e[0],n=e[1];if(i===t&&s===n)return;f(),h.current=v.current,g.current=performance.now();const a=e=>{const t=e-g.current,n=Math.min(t/300,1),l=(r=n,1-Math.pow(1-r,3));var r;const o=1===n?[i,s]:[h.current[0]+(i-h.current[0])*l,h.current[1]+(s-h.current[1])*l];v.current=o,m(o),p.current=n<1?requestAnimationFrame(a):null};return p.current=requestAnimationFrame(a),f}),[i,s,f]),{domain:u,ticks:n,targetDomain:l}},VO=e=>"payoff"===e.kind,WO=()=>{const e=QE(),t=BE(),n=wE((e=>{var t,n;return null!==(t=null===(n=e.projection)||void 0===n?void 0:n.annotations)&&void 0!==t?t:HE})),l=((e,t)=>{const n=(0,et.I)(Io.iO).data;return(0,a.useMemo)((()=>{const a=null===n||void 0===n?void 0:n.savingsGoals;if(!a)return[];const l=e+t;return a.reduce(((t,n)=>{if(null!==n.archivedAt&&void 0!==n.archivedAt)return t;if(!n.targetDate)return t;
1const a=N.c9.fromISO(n.targetDate).year;return a<e||a>l||t.push({id:"goalCompletion-".concat(n.id),kind:"goalCompletion",year:a,goalId:n.id,goalName:n.name,targetAmount:n.targetAmount,targetDate:n.targetDate}),t}),[])}),[n,e,t])})(e.startYear,e.projectionYears),r=aw(),o=RS().isComparisonActive,i=ow().mode,s=r.dollarMode.mode;return(0,a.useMemo)((()=>{var e,a;return(e=>{let t=e.activePayoffs,n=e.comparePayoffs,a=e.goalAnnotations,l=e.activeScenarioMetadata,r=e.compareScenarioMetadata,o=e.activeDollarMode,i=e.compareDollarMode;if(!e.isComparisonAvailable)return[...t.map((e=>(0,U.A)((0,U.A)({},e),{},{dollarMode:o}))),...a];return[...t.map((e=>(0,U.A)((0,U.A)({},e),{},{scenarioMetadata:l,dollarMode:o}))),...n.map((e=>(0,U.A)((0,U.A)({},e),{},{id:"compare-".concat(e.id),scenarioMetadata:r,dollarMode:null!==i&&void 0!==i?i:o}))),...a]})({activePayoffs:n.filter(VO),comparePayoffs:(null!==(e=null===(a=r.projection)||void 0===a?void 0:a.annotations)&&void 0!==e?e:[]).filter(VO),goalAnnotations:l,activeScenarioMetadata:t,compareScenarioMetadata:r.compareScenarioMetadata,activeDollarMode:i,compareDollarMode:s,isComparisonAvailable:r.isComparisonAvailable&&o})}),[n,l,t,r.projection,r.compareScenarioMetadata,i,s,r.isComparisonAvailable,o])},jO=e=>{let t=e.cx,n=e.cy,l=e.payload;if(!(0,Tp.n)(null===l||void 0===l?void 0:l.compareNetWorth))return a.createElement("g",{"data-external-id":"compare-line-active-dot"});const r=l.compareNetWorth>=0?qO:$O;return a.createElement("circle",{"data-external-id":"compare-line-active-dot",cx:t,cy:n,r:3.5,fill:r,stroke:(0,qy.f)("background-primary"),strokeWidth:2})},HO="forecast-line-gradient",KO="compare-forecast-line-gradient",qO=(0,qy.f)("chart-compare-line-positive"),$O=(0,qy.f)("chart-compare-line-negative"),ZO=(e,t,n
1)=>{const a=new Map;return e.forEach((e=>{let t=e.year,n=e.netWorth;a.set(t,{year:t,netWorth:n})})),n&&t.forEach((e=>{let t=e.year,n=e.netWorth;const l=a.get(t);l?l.compareNetWorth=n:a.set(t,{year:t,compareNetWorth:n})})),Array.from(a.values()).sort(((e,t)=>e.year-t.year))},JO=e=>{let t=e.activeName,n=e.compareName,a=e.activeColor,l=e.compareColor;return[{name:t,color:a},n?{name:n,color:l,swatch:"dashed"}:null].filter(Tp.n)},XO=e=>{let t=e.showCompareLine,n=e.activeName,a=e.compareName,l=e.customActiveDot,r=e.activeLineOpacity;const o={lineColor:"url(#".concat(HO,")"),strokeOpacity:r,hideActiveDot:0===r,areaColor:"transparent",showDots:!1,strokeWidth:3,isDashed:!1,customActiveDot:l,legendName:n,zIndex:uD};if(!t)return{yDataKeys:["netWorth"],lineOptions:[o]};return{yDataKeys:["compareNetWorth","netWorth"],lineOptions:[{lineColor:"url(#".concat(KO,")"),areaColor:"transparent",showDots:!1,strokeWidth:2,isDashed:!0,hideUntilAnimationStart:!0,customActiveDot:jO,legendName:a,zIndex:dD},o]}},QO=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;const n=XE(),l=aw(),r=RS().isComparisonActive;return(0,a.useMemo)((()=>{const a=(e=>e.filter(PD).map((e=>({variant:"active",id:e.id,event:e,name:e.name,icon:e.icon,color:e.color,foregroundColor:e.foregroundColor}))))(n),o=r?(e=>e.filter(PD).map((e=>({variant:"compare",id:e.id,event:e,name:e.name,icon:e.icon}))))(l.eventModels):[],i=(e=>{let t=e.annotations,n=e.activeEvents,a=e.compareEvents;const l=(e=>e.map((e=>({type:"annotation",id:e.id,annotation:e}))))(t),r=(0,LD.A)((e=>String(e.annotation.year)),l),o=(0,LD.A)((e=>String(e.event.startYear)),n),i=(0,LD.A)((e=>String(e.event.startYear)),a),s=new Set([...Object.keys(r),...Object.keys(o),...Object.keys(i)]);return Object.fromEntries([...s].map((e=>{var t,n,a;return[e,{annotations:null!==(t=r[e])&&void 0!==t?t:[],activeEvents:null!==(n=o[e])&&void 0!==n?n:[],compareEvents:null!==(a=i[e])&&void 0!==a?a:[]}]})))})({annotations:e,activeEvents:a,compareEvents:o});return{markersByYear:i,eventMarkerYears:BD(i,t),compareOnlyEventMarkerYears:zD(i)}}),[n,e,l.eventModels,t,r])},eP=e=>{let t=e.cx,n=e.cy,l=e.fill,r=e.stroke,i=e.strokeWidth,s=e.onClick,c=e.onMouseEnter,d=e.onMouseLeave,u=e.onPointerDown;const m=(0,a.useState)(!1),p=(0,o.A)(m,2),g=p[0],h=p[1],v=g?7.5:5.5,f=(0,a.useCallback)((e=>{h(!0),null===c||void 0===c||c(e.currentTarget)}),[c]),E=(0,a.useCallback)((()=>{h(!1),null===d||void 0===d||d()}),[d]),y=(0,a.useCallback)((e=>{e.stopPropagation(),null===s||void 0===s||s()}),[s]),b=(0,a.useCallback)((e=>null===u||void 0===u?void 0:u()),[u]);return a.createElement("g",{"data-external-id":"interactive-active-dot"},a.createElement("circle",{cx:t,cy:n,r:v,fill:l,stroke:r,strokeWidth:i,style:{cursor:"crosshair",pointerEvents:"auto"},onMouseEnter:f,onMouseLeave:E,onPointerDown:b,onClick:y}))},tP={r:5.5,fill:(0,qy.f)("content-primary"),stroke:(0,qy.f)("background-primary"),strokeWidth:2},nP=e=>{let t=e.year,n=e.eventMarkerYears,a=e.hideActiveDotYears;return null!==a&&void 0!==a&&a.has(t)?"hidden":null!==n&&void 0!==n&&n.has(t)?"static":"interactive"},aP=e=>{let t=e.annotations,n=e.chartData,l=e.draggingEventId,r=e.draggedPreviewEventYear,o=e.isMarkerTooltipVisible,i=e.hideActiveDotYears,s=e.onActiveDotMouseEnter,c=e.onActiveDotMouseLeave,d=e.onActiveDotPointerDown;const u=vy().openedSidebarDetails,m=(0,a.useMemo)((()=>(e=>{let t=e.draggingEventId,n=e.draggedPreviewEventYear,a=e.openedSidebarDetails;return t===cR&&null!==n&&void 0!==n?n:"new-event"===(null===a||void 0===a?void 0:a.type)&&void 0!==a.year?a.year:null})({draggingEventId:l,draggedPreviewEventYear:r,openedSidebarDetails:u})),[l,r,u]),p=QO(t,m),g=p.markersByYear,h=p.eventMarkerYears,v=p.compareOnlyEventMarkerYears,f=(e=>{let t=e.chartData,n=e.newEventYear,l=e.draggingEventId,r=e.isMarkerTooltipVisible,o=e.eventMarkerYears,i=e.hideActiveDotYears,s=e.onActiveDotMouseEnter,c=e.onActiveDotMouseLeave,d=e.onActiveDotPointerDown;const u=vy().openNewEvent,m=(0,a.useMemo)((()=>{var e;if(null===n)return null;const a=t.find((e=>e.year===n));return null!==(e=null===a||void 0===a?void 0:a.netWorth)&&void 0!==e?e:null}),[t,n]),p=(0,a.useCallback)((e=>{null!==l||r||u(e.year)}),[l,r,u]),g=(0,a.useCallback)((e=>{const t=e.payload;if(!(0,Tp.n)(null===t||void 0===t?void 0:t.netWorth))return a.createElement("g",null);const n=t.netWorth>=0?tP.fill:(0,qy.f)("content-danger"),l=tP.stroke,r=tP.strokeWidth,u=nP({year:t.year,eventMarkerYears:o,hideActiveDotYears:i});return"hidden"===u?a.createElement("g",null):"static"===u?a.createElement("circle",{cx:e.cx,cy:e.cy,r:tP.r,fill:n,stroke:l,strokeWidth:r}):a.createElement(eP,{cx:e.cx,cy:e.cy,fill:n,stroke:l,strokeWidth:r,onClick:()=>p(t),onMouseEnter:s,onMouseLeave:c,onPointerDown:d})}),[p,o,i,s,c,d]);return{newEventNetWorth:m,activeDotProps:tP,customActiveDot:g}})({chartData:n,newEventYear:m,draggingEventId:l,isMarkerTooltipVisible:o,eventMarkerYears:h,hideActiveDotYears:i,onActiveDotMouseEnter:s,onActiveDotMouseLeave:c,onActiveDotPointerDown:d});return{markersByYear:g,eventMarkerYears:h,compareOnlyEventMarkerYears:v,newEventYear:m,newEventNetWorth:f.newEventNetWorth,activeDotProps:f.activeDotProps,customActiveDot:f.customActiveDot}},lP=e=>{let t=e.chartData,n=e.enabled,l=e.includeOuterBand;const r=NI(),o=n?r:rP,i=(0,a.useMemo)((()=>
1n?((e,t,n)=>{const a=new Map(t.map((e=>[e.year,e])));return e.map((e=>{const t=a.get(e.year);if(!t)return e;const l=(0,U.A)((0,U.A)({},e),{},{mcInnerBand:[t.p40,t.p60]});return n&&(l.mcOuterBand=[t.p5,t.p95]),l}))})(t,o,l):t),[t,o,n,l]);return{chartData:i,hasBands:o.length>0}},rP=[],oP=[],iP=e=>{var t,n,l;let r=e.chartData,o=e.enabled;const i=SI(),s=NI(),c=TI(),d=aA((e=>e.successFloor)),u=null!==(t=null===(n=s[0])||void 0===n?void 0:n.year)&&void 0!==t?t:null,m=null===(l=r[r.length-1])||void 0===l?void 0:l.year,p=(0,a.useMemo)((()=>{if(!o||0===s.length||null===u)return oP;const e=(null!==m&&void 0!==m?m:u)-u+1;return e<=0?oP:((e,t)=>{let n=t.drawnYearCount,a=t.isTodaysDollars,l=t.successFloor;return e.map((e=>{const t=e.netWorthByYear.slice(0,n);return{pathNumber:e.pathNumber,group:Df(e,{successFloor:l,isTodaysDollars:a}),values:a?t.map(((t,n)=>Eh(t,e.cumulativeInflationFactorByYear[n]))):t}}))})(i,{drawnYearCount:e,isTodaysDollars:c,successFloor:d})}),[o,i,s,u,m,c,d]),g=(0,a.useMemo)((()=>{if(0===p.length)return[];const e=s.slice(0,p[0].values.length),t={top:e.reduce(((e,t)=>Math.max(e,t.p60)),-1/0),bottom:e.reduce(((e,t)=>Math.min(e,t.p40)),1/0)};return function(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:qR;const a=[],l=[];if(e.forEach((e=>{let t=e.values,n=-1/0,r=1/0;t.forEach((e=>{e>n&&(n=e),e<r&&(r=e)})),n>-1/0&&(a.push(n),l.push(r))})),0===a.length)return[];a.sort(((e,t)=>e-t)),l.sort(((e,t)=>e-t));const r=a[a.length-1],o=l[0],i=[o,r],s=t.top-t.bottom,c=r-o;if(!Number.isFinite(s)||s<=0||c<=0||s/c>=n.minReadableShare)return i;const d=Math.floor(a.length*n.maxClippedShare);if(0===d)return i;const u=s/n.minReadableShare-s,m=Math.max(0,r-t.top),p=Math.max(0,t.bottom-o),g=Math.min(m,Math.max(u/2,u-p)),h=Math.min(p,Math.max(u/2,u-m)),v=Math.min(r,Math.max(t.top+g,a[a.length-1-d])),f=Math.max(o,Math.min(t.bottom-h,l[d]));return v>=r&&f<=o?i:[f,v]}(p,t)}),[p,s]);return{runs:p,startYear:u,extentValues:g}};var sP,cP;const dP="\u2014",uP=()=>{const e=a.useId(),t=QE(),n=qE(),l=iE(),o=ZE(),i=$E(),s=wE((e=>{var t;return null!==(t=e.dollarMode)&&void 0!==t?t:"futureDollars"})),c=o.filter((e=>!1!==e.isIncluded)),d=c.length>0?(0,De.Eb)(c.map((e=>e.amount))):null,u=(0,Tp.n)(t.inflationRate)?Number(t.inflationRate.toFixed(3)):null,m="".concat(e,"-assumptions");return a.createElement(mP,{"data-external-id":"edit-assumptions-tooltip-content",role:"region","aria-label":"Forecast assumptions"},a.createElement("div",{className:"flex flex-col gap-default"},t.participants.filter((e=>!e.hiddenFromForecast)).map(((t,o)=>{const i="".concat(e,"-participant-").concat(o),s=oE(t,n),c=t.birthday;return a.createElement(nO,{key:t.userId,role:"group","aria-labelledby":i},a.createElement(lO,{id:i},t.displayName||dP),a.createElement(aO,null,a.createElement(rO,null,a.createElement(oO,{id:"".concat(i,"-current-age")},"Current age"),a.createElement(iO,{"aria-labelledby":"".concat(i,"-current-age")},t.birthday?String((0,Ba.X)(t.birthday)):dP)),a.createElement(rO,null,a.createElement(oO,{id:"".concat(i,"-retirement-age")},"Retirement age"),a.createElement(iO,{"aria-labelledby":"".concat(i,"-retirement-age")},(0,r.YW)({retirementAge:s,birthday:c}).with({retirementAge:r.P.number},(e=>{let t=e.retirementAge;return String(t)})).with({birthday:r.P.string},(()=>a.createElement(pP,{onClick:()=>l(t),"aria-label":"Add retirement event for ".concat(t.displayName||"participant")},"Add"))).otherwise((()=>dP)))),a.createElement(rO,null,a.createElement(oO,{id:"".concat(i,"-life-expectancy")},"Life expectancy"),a.createElement(iO,{"aria-labelledby":"".concat(i,"-life-expectancy")},(0,Tp.n)(t.lifeExpectancy)?String(t.lifeExpectancy):dP))))})),a.createElement(nO,{role:"group","aria-labelledby":m},a.createElement(lO,{id:m},"Assumptions"),a.createElement(aO,null,a.createElement(rO,null,a.createElement(oO,{id:"".concat(m,"-take-home-income")},"Yearly take-home income"),a.createElement(iO,{"aria-labelledby":"".concat(m,"-take-home-income")},(0,Tp.n)(d)?(0,rl._L)(d):dP)),a.createElement(rO,null,a.createElement(oO,{id:"".concat(m,"-living-expenses")},"Yearly living expenses"),a.createElement(iO,{"aria-labelledby":"".concat(m,"-living-expenses")},(0,Tp.n)(null===i||void 0===i?void 0:i.amount)?(0,rl._L)(Math.abs(i.amount)):dP)),a.createElement(rO,null,a.createElement(oO,{id:"".concat(m,"-yearly-inflation-rate")},"Yearly inflation rate"),a.createElement(iO,{"aria-labelledby":"".concat(m,"-yearly-inflation-rate")},(0,Tp.n)(u)?"".concat(u,"%"):dP)),a.createElement(rO,null,a.createElement(oO,{id:"".concat(m,"-future-values")},"Future values"),a.createElement(iO,{"aria-labelledby":"".concat(m,"-future-values")},"todaysDollars"===s?_t.Et.ASSUMPTIONS.DOLLAR_MODE_OPTION_TODAYS:_t.Et.ASSUMPTIONS.DOLLAR_MODE_OPTION_FUTURE))))))},mP=$d.s.div(sP||(sP=(0,wc.A)(["\n  max-h-[60vh] w-66 overflow-y-auto px-sm py-default text-left text-sm font-medium\n"]))
1),pP=(0,$d.s)(bn.v)(cP||(cP=(0,wc.A)(["min-h-[unset] p-0 text-[length:inherit]"]))),gP=()=>a.createElement(Wb.X,{"data-external-id":"forecast-walkthrough-button",variant:"default",icon:a.createElement(fe.C3S,null),onClick:()=>window.open("https://youtu.be/nTuJdfQMpU8","_blank","noopener,noreferrer")},"Watch walkthrough");var hP=n(38759);const vP="none",fP=()=>{const e=RS(),t=e.forecastingMode,n=e.setForecastingMode,r=(0,l.g)().scenarioId,o=Qx(),i=o.scenarios,s=o.isLoading,c=aw().compareToScenarioId,d=(0,a.useRef)(!1),u=(0,a.useMemo)((()=>i.filter((e=>e.id!==r))),[r,i]),m=(0,a.useMemo)((()=>i.find((e=>e.id===c))),[c,i]),p=!s&&0===u.length;return a.createElement(hP.T.Root,{"data-external-id":"forecasting-mode-tabs",variant:"pill",fitContent:!0,value:t,onValueChange:e=>{"plan"!==e&&"compare"!==e&&"chanceOfSuccess"!==e||(d.current="compare"===e&&"compare"!==t&&void 0===m,n(e))},"aria-label":"Forecasting mode"},a.createElement(hP.T.List,{activateOnFocus:!1},a.createElement(hP.T.Tab,{value:"plan"},"Plan"),p?a.createElement(Wi.Y,{content:"Add another scenario to compare against this one."},a.createElement(hP.T.Tab,{value:"compare",disabled:!0},"Compare")):a.createElement(hP.T.Tab,{value:"compare",popup:e=>a.createElement(EP,Object.assign({},e,{scenarios:u,autoOpenRef:d}))},a.createElement("span",{className:"flex min-w-0 items-center gap-xs"},m?a.createElement(a.Fragment,null,a.createElement("span",{className:"shrink-0"},"Compare to"),a.createElement(TS,{icon:m.icon,size:12,color:m.color,className:"shrink-0"}),a.createElement("span",{className:"max-w-40 min-w-0 truncate"},m.name)):"Compare")),a.createElement(hP.T.Tab,{value:"chanceOfSuccess"},"Chance of success"),a.createElement(hP.T.Indicator,null)))},EP=e=>{let t=e.open,n=e.onOpenChange,l=e.anchor,r=e.scenarios,o=e.autoOpenRef;const i=aw(),s=i.compareToScenarioId,c=i.setCompareToScenarioId,d=i.clearCompareToScenarioId,u=(0,v.D)((e=>{e&&Wf({source:"mode_tab"}),n(e)}));return(0,a.useEffect)((()=>{o.current&&(o.current=!1,u(!0))}),[o,u]),a.createElement(hA.u.Root,{"data-external-id":"compare-scenario-picker",open:t,onOpenChange:u},a.createElement(hA.u.Content,{anchor:l,align:"start",side:"bottom"},a.createElement(hA.u.Group,null,a.createElement(hA.u.GroupLabel,null,"Compare to:"),a.createElement(hA.u.RadioGroup,{value:null!==s&&void 0!==s?s:vP,onValueChange:e=>{const t=String(e);t===vP?d():(jf({source:"compare_menu"}),c(t)),n(!1)}},a.createElement(hA.u.RadioItem,{value:vP},"None"),r.map((e=>a.createElement(hA.u.RadioItem,{key:e.id,value:e.id,leading:a.createElement(TS,{icon:e.icon,size:12,color:e.color})},e.name)))))))};var yP=n(4939);const bP=e=>{var t,n,l;let r=e.scenarioId;const o=Qx().scenarios,i=aw(),s=i.compareToScenarioId,c=i.setCompareToScenarioId,d=i.clearCompareToScenarioId,u=(0,a.useMemo)((()=>o.filter((e=>e.id!==r))),[r,o]),m=(0,a.useMemo)((()=>s?o.find((e=>e.id===s)):void 0),[s,o]),p=(0,a.useCallback)((e=>{jf({source:"compare_menu"}),c(e)}),[c]),g=(0,a.useCallback)((()=>{d()}),[d]);if(0===u.length)return null;const h=null!==(t=null===m||void 0===m?void 0:m.name)&&void 0!==t?t:"Unknown scenario",v=null!==(n=null===m||void 0===m?void 0:m.icon)&&void 0!==n?n:Qg.icon,f=null!==(l=null===m||void 0===m?void 0:m.color)&&void 0!==l?l:Qg.color;return a.createElement(fe.hGA.Root,{"data-external-id":"scenario-compare-menu",key:s?"compare-active":"compare-empty",value:null!==s&&void 0!==s?s:null,onValueChange:p},s?a.createElement("div",{className:"flex max-w-56 min-w-0 shrink items-center gap-xs","data-testid":"scenario-compare-chip-".concat(r)},a.createElement(fe.c8D,{size:"xs"},"vs."),a.createElement(fe.oxS,{attached:!0,rounded:"pill",className:"flex min-w-0 flex-1 items-stretch"},a.createElement(yP.b,{render:a.createElement(fe.XZZ,{variant:"default",size:"sm",icon:a.createElement(TS,{icon:v,size:12,color:f}),className:"min-w-0 flex-1 shrink justify-start gap-1 border-r-0 px-2"},a.createElement(fe.XZZ.Label,{className:"min-w-0"},a.createElement(fe.c8D,{size:"xs",weight:"medium",color:"secondary",className:"block truncate"},h)))}),a.createElement(fe.SO$,{"aria-label":"Dismiss comparison",onClick:g},a.createElement(fe.sOb,{className:"text-content-secondary"})))):a.createElement(yP.b,{render:a.createElement(fe.SO$,{"aria-label":"Compare scenario","data-testid":"scenario-compare-menu-trigger-".concat(r),className:"shrink-0",onClick:()=>{Wf({source:"card_header_icon"})}},a.createElement(fe.wYT,null))}),a.createElement(fe.hGA.Content,{className:"w-80",side:"bottom",align:"start"},a.createElement(xP,{scenarios:u,selectedCompareToScenarioId:s,onDeselect:g})))},xP=e=>{let t=e.scenarios,n=e.selectedCompareToScenarioId,l=e.onDeselect;return a.createElement(fe.hGA.Group,{"data-external-id":"compare-scenario-options"},a.createElement(fe.hGA.GroupLabel,null,"Compare to:"),t.map((e=>{const t=e.id===n;return a.createElement(fe.hGA.Option,{key:e.id,value:e.id,"data-testid":"scenario-compare-menu-item-".concat(e.id),onClick:t?e=>{e.preventBaseUIHandler(),l()}:void 0,leading:a.createElement("span",{className:"inline-flex min-w-4 items-center justify-center"},a.createElement(TS,{icon:e.icon,color:t?void 0:e.color,size:12}))},e.name)})))},wP=()=>{const e=FE(),t=(0,a.useState)(null),n=(0,o.A)(t,2),l=n[0],r=n[1];return a.createElement("div",{"data-external-id":"scenario-edit-popover",ref:r,role:"dialog","aria-label":"Edit name and icon","data-testid":"scenario-edit-popover",className:"flex flex-col gap-default"},a.createElement(wA,{autoFocus:!0,overlayPortalContainer:l,onNameSaved:t=>{"enter"===t.reason&&e.close()}}))};
1var CP;const AP=["isOpen","className"],IP=a.forwardRef(((e,t)=>{let n=e.isOpen,l=e.className,r=(0,En.A)(e,AP);const o=BE(),i=o.name,s=o.icon,c=o.color;return a.createElement(NP,Object.assign({"data-external-id":"scenario-name-and-icon-trigger",ref:t,type:"button","aria-label":"Edit scenario name and icon","data-testid":"scenario-name-icon-trigger",className:(0,q.cn)(n&&"bg-background-secondary",l)},r),a.createElement(kP,{icon:s,color:c}),a.createElement(SP,{name:i}))}));IP.displayName="ScenarioNameAndIconTrigger";const kP=e=>{let t=e.icon,n=e.color;return a.createElement(TS,{"data-external-id":"scenario-glyph",icon:t,size:16,color:n,className:"shrink-0"})},SP=e=>{let t=e.name;return a.createElement(fe.c8D,{"data-external-id":"scenario-name",size:"lg",weight:"medium",color:"primary",className:"min-w-0 truncate"},t||"Untitled scenario")},NP=$d.s.button(CP||(CP=(0,wc.A)(["\n  inline-flex max-w-full min-w-0 cursor-pointer items-center gap-xs rounded-default border-0\n  bg-transparent px-xs py-2xs leading-none transition-colors\n  hover:bg-background-secondary\n  focus-visible:bg-background-secondary focus-visible:outline-2 focus-visible:outline-offset-2\n  focus-visible:outline-input-focus-border\n"]))),TP=parseInt(yD.w.spacing.default,10),_P=e=>{let t=e.portalContainer;const n=vy(),r=n.toggleAssumptions,o=n.openNewEvent,i=n.toggleChanceOfSuccess,s=RS().forecastingMode,c=FE(),d=(0,l.g)().scenarioId,u=py().isEnabled,m=u&&"chanceOfSuccess"===s;(()=>{const e=wE((e=>e.pendingScenarioMetadataEditorAutoOpen)),t=wE((e=>e.clearScenarioMetadataEditorAutoOpen)),n=wE((e=>e.openScenarioMetadataEditor)),l=wE((e=>e.scenarioExternalId));(0,a.useEffect)((()=>{e&&(t(),l&&n())}),[e,t,l,n])})();const p=a.createElement("div",{className:"flex shrink-0 items-center gap-xs"},!u&&a.createElement("div",{className:"flex items-center gap-xs @max-[860px]/forecastheader:hidden"},a.createElement(gP,null),a.createElement("span",{"aria-hidden":"true",className:"h-lg w-px self-center bg-divider-secondary"})),m?a.createElement(a.Fragment,null,a.createElement(Wb.X,{variant:"default",icon:a.createElement(fe.z79,null),onClick:i},"Settings"),a.createElement(xI,null)):a.createElement(a.Fragment,null,a.createElement(P.D_,{content:a.createElement(uP,null),place:"bottom",interactive:!0,collisionPadding:TP,delayShow:500},a.createElement(Wb.X,{variant:"default",icon:u?a.createElement(fe.z79,null):a.createElement(fe.yIO,null),onClick:r},u?"Assumptions":"Edit assumptions")),a.createElement(Wb.X,{variant:"primary",icon:a.createElement(fe.Wa3,null),onClick:()=>o()},"Add event")));return a.createElement("div",{"data-external-id":"scenario-card-header",className:"@container/forecastheader flex items-center justify-between gap-2xl px-default pt-sm pb-0","data-testid":"scenario-card-header"},a.createElement("div",{className:"flex min-w-0 items-center gap-2xs"},u?a.createElement(fP,null):a.createElement(a.Fragment,null,a.createElement(fS.k.Root,{open:c.isOpen,onOpenChange:e=>e?c.open():c.close()},a.createElement(fS.k.Trigger,{render:a.createElement(IP,{isOpen:c.isOpen})}),a.createElement(fS.k.Content,{side:"bottom",align:"start",sideOffset:8,container:null!==t&&void 0!==t?t:void 0,className:"w-80 max-w-[calc(100vw-32px)] p-default"},a.createElement(wP,null))),d&&a.createElement(bP,{scenarioId:d}),d&&a.createElement(vA,{scenarioId:d,variant:"cardHeader"}))),p)};var DP=n(97798),RP=n(49467),MP=n(6559);const LP={left:24,right:Math.ceil(14)+2},OP={activationConstraint:{distance:5}},PP=e=>{var t,n,l,r,i;let s=e.className;const c=(0,a.useState)(null),d=(0,o.A)(c,2),u=d[0],m=d[1],p=sy(),g=XE(),h=(e=>{let t=e.netWorthData;const n=BE(),l=aw(),r=l.isComparisonAvailable,o=l.compareToScenarioId,i=l.netWorthData,s=l.compareScenarioMetadata,c=RS().isComparisonActive,d=r&&c,u=(0,Tp.n)(o)&&c,m=(0,a.useMemo)((()=>ZO(t,i,d)),[t,i,d]),p=(0,a.useCallback)(((e,t)=>XO({activeName:n.name,compareName:null===s||void 0===s?void 0:s.name,customActiveDot:e,activeLineOpacity:t,showCompareLine:d})),[d,n.name,null===s||void 0===s?void 0:s.name]),g=(0,a.useMemo)((()=>u?JO({activeName:n.name,compareName:null===s||void 0===s?void 0:s.name,activeColor:(0,qy.f)("content-primary"),compareColor:qO}):[]),[u,n.name,null===s||void 0===s?void 0:s.name]);return{chartData:m,isComparisonAvailable:d,legendEntries:g,showLegend:u,getLineConfig:p}})({netWorthData:p}),v=h.chartData,f=h.isComparisonAvailable,E=h.legendEntries,y=h.showLegend,b=h.getLineConfig,x=py().isEnabled,w=RS().forecastingMode,C=x&&"chanceOfSuccess"===w,A=ey(),I=C&&A,k=C&&!A,S=tD(),N=lD(),_=aD((e=>e.reset)),R=C?N:rD;(0,a.useEffect)((()=>(_(),()=>_())),[I,_]);const M=(0,a.useMemo)((()=>C?[{name:SD,color:(0,qy.f)("content-primary"),highlight:"projectedPlan"},...I?[{name:"9 in 10 paths each year",color:CR,swatch:"band",opacity:wR.fresh.outer,highlight:"outerBand"}]:[],{name:"1 in 5 paths each year",color:CR,swatch:"band",opacity:wR.fresh.inner,highlight:"innerBand"},...(I?[]:Tf).map((e=>
1({name:Mf[e].qualifier.word,color:(0,qy.f)(Rf[e].color),highlight:e})))]:E),[E,C,I]),L=lP({chartData:v,enabled:C,includeOuterBand:I}).chartData,O=iP({chartData:v,enabled:k}),P=O.runs,B=O.startYear,z=O.extentValues,F=(0,a.useMemo)((()=>R.filter(Q_)),[R]),G=(0,a.useMemo)((()=>0===R.length?P:P.filter((e=>{let t=e.group;return!R.includes(t)}))),[P,R]),Y=WO(),V=uE((e=>e.tableHoveredYear)),W=uE((e=>e.setChartHoveredYear)),j=(0,a.useMemo)((()=>(new Date).getFullYear()),[]),H=null!==(t=null===(n=v[0])||void 0===n?void 0:n.year)&&void 0!==t?t:j,K=null!==(l=null===(r=v[v.length-1])||void 0===r?void 0:r.year)&&void 0!==l?l:j,$=(0,a.useMemo)((()=>[H,K]),[H,K]),Z=(0,a.useMemo)((()=>(0,db.A)(H,K+1)),[H,K]),J=(0,a.useMemo)((()=>[...v.flatMap((e=>[e.netWorth,e.compareNetWorth].filter(Tp.n))),...I?YO(L):z]),[v,L,I,z]),X=UO(J),Q=X.domain,ee=X.ticks,te=X.targetDomain,ne=(()=>{const e=(0,a.useState)(!0),t=(0,o.A)(e,2),n=t[0],l=t[1];return(0,a.useEffect)((()=>{const e=setTimeout((()=>l(!1)),1500);return()=>clearTimeout(e)}),[]),{isAnimationActive:n,animationDuration:1500}})(),ae=ne.isAnimationActive,le=ne.animationDuration,re=vy(),oe=re.openEvent,ie=re.openNewEvent,se=re.openedSidebarDetails,ce=dR({xAxisYearRange:$[1]-$[0],activeNetWorthData:p,onPreviewEventYearChange:e=>{ie(e)}}),de=ce.chartContainerRef,ue=ce.draggingEventId,me=ce.draggedEventDot,pe=ce.draggedPreviewEventYear,ge=ce.handleDragStart,he=ce.handleDragMove,ve=ce.handleDragEnd,fe=(()=>{const e=vy().openedSidebarDetails,t=XE(),n=QE(),l=(0,a.useMemo)((()=>"event"===(null===e||void 0===e?void 0:e.type)?e.id:null),[e]),r=(0,a.useMemo)((()=>{if(!l)return null;const e=t.find((e=>e.id===l));if(!e||!e.startYear||!e.isVisibleInForecast)return null;const a=n.startYear+n.projectionYears+1,r=e.getActiveYearRange(a,t),o=void 0!==r&&r.end-r.start>1;return{id:e.id,startYear:e.startYear,endYear:o?r.end-1:void 0,color:e.color,hasRange:o}}),[l,t,n]);return{selectedEvent:r}})(),Ee=fe.selectedEvent,ye=(0,a.useState)((()=>new Set)),be=(0,o.A)(ye,2),xe=be[0],we=be[1],Ce=(0,a.useCallback)((e=>{we((t=>{const n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}))}),[]),Ae=(0,a.useRef)(null),Ie=(e=>{let t=e.annotations,n=e.draggingEventId,l=e.layoutRef;const r=XE(),i=aw(),s=BE(),c=ow(),d=RS().isComparisonActive,u=(0,a.useState)(null),m=(0,o.A)(u,2),p=m[0],g=m[1],h=(0,a.useCallback)((()=>g(null)),[]),v=Hy({layoutRef:l,onDismiss:h}),f=v.tooltipPosition,E=v.scheduleShow,y=v.scheduleHide,b=v.cancelPendingShow,x=v.cancelPendingLeave,w=(0,a.useMemo)((()=>{if("event"===(null===p||void 0===p?void 0:p.kind))return("active"===p.markerKey.variant?r:i.eventModels).find((e=>e.id===p.markerKey.id))}),[p,r,i.eventModels]),C=(0,a.useMemo)((()=>"annotation"!==(null===p||void 0===p?void 0:p.kind)?[]:p.annotationIds.map((e=>t.find((t=>t.id===e)))).filter((e=>void 0!==e))),[p,t]),A=(0,a.useMemo)((()=>{if("event"===(null===p||void 0===p?void 0:p.kind)&&i.isComparisonAvailable&&d)return"active"===p.markerKey.variant?s:i.compareScenarioMetadata}),[p,i,s,d]),I=(0,a.useMemo)((()=>{if("event"===(null===p||void 0===p?void 0:p.kind)&&i.isComparisonAvailable&&d)return"active"===p.markerKey.variant?c:i.dollarMode}),[p,i,c,d]),k=null!==p&&null!==f&&("event"===p.kind?null===n&&void 0!==w:C.length>0),S=(0,a.useCallback)(((e,t)=>{var n,a;a=e,null!==(n=p)&&n.kind===a.kind&&("event"===n.kind&&"event"===a.kind?((e,t)=>null!==e&&e.variant===t.variant&&e.id===t.id)(n.markerKey,a.markerKey):"annotation"===n.kind&&"annotation"===a.kind&&((e,t)=>e.length===t.length&&e.every(((e,n)=>e===t[n])))(n.annotationIds,a.annotationIds))?x():(null===f&&g(null),E(t,(()=>g(e))))}),[p,f,E,x]),N=(0,a.useCallback)(((e,t)=>{n!==e.id&&S({kind:"event",markerKey:e},t)}),[n,S]),T=(0,a.useCallback)(((e,t)=>{S({kind:"annotation",annotationIds:e},t)}),[S]),_=(0,a.useCallback)(((e,t)=>T([e],t)),[T]),D=T,R=(0,a.useCallback)((()=>{y((()=>g(null)))}),[y]),M=(0,a.useCallback)((()=>{b()}),[b]);return{target:p,tooltipPosition:f,hoveredEvent:w,hoveredAnnotations:C,eventTooltipScenarioMetadata:A,eventTooltipDollarMode:I,isMarkerTooltipVisible:k,handleEventMouseEnter:N,handleAnnotationMouseEnter:_,handleGroupedAnnotationMouseEnter:D,handleEventPointerDown:M,hideMarkerTooltip:R}})({annotations:Y,draggingEventId:ue,layoutRef:de}),ke=Ie.target,Se=Ie.hoveredEvent,Ne=Ie.hoveredAnnotations,Te=Ie.eventTooltipScenarioMetadata,_e=Ie.eventTooltipDollarMode,De=Ie.isMarkerTooltipVisible,Re=Ie.tooltipPosition,Me=Ie.handleEventMouseEnter,Le=Ie.handleAnnotationMouseEnter,Oe=Ie.handleGroupedAnnotationMouseEnter,Pe=Ie.handleEventPointerDown,Be=Ie.hideMarkerTooltip,ze=(0,a.useCallback)((e=>{Be(),oe(e)}),[Be,oe]),Fe=Hy({hoverDelayMs:1e3,layoutRef:de}),Ge=Fe.tooltipPosition,Ye=Fe.scheduleShow,Ue=Fe.scheduleHide,Ve=(0,a.useMemo)((()=>{const e=new Set;return Ee&&e.add(Ee.startYear),e}),[Ee]),We=aP({annotations:Y,chartData:v,draggingEventId:ue,draggedPreviewEventYear:pe,isMarkerTooltipVisible:De,hideActiveDotYears:Ve,onActiveDotMouseEnter:Ye,onActiveDotMouseLeave:Ue,onActiveDotPointerDown:Ue}),je=We.markersByYear,He=We.eventMarkerYears,Ke=We.compareOnlyEventMarkerYears,qe=We.newEventYear,$e=We.newEventNetWorth,Ze=We.activeDotProps,Je=We.customActiveDot,Xe=(0,a.useMemo)((()=>function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;const n=Object.entries(e).reduce(((e,n)=>{let a=(0,o.A)(n,2),l=a[0],r=a[1];const i=Number(l),s=r.annotations.length,c=FD(r,i,t),d=OD(s,c).visibleCount,u=c&&s>0?d+1:d;return Math.max(e,u)}),0);return 40+Math.max(0,n-2)*Gg}(je,qe)),[je,qe]),Qe=(0,a.useMemo)((()=>({top:Xe})),[Xe]),et=k&&P.length>0,tt=(0,a.useMemo)((()=>(0,U.A)((0,U.A)({},LP),{},{right:et?pM:LP.right})),[et]),nt=R.includes("projectedPlan")?0:C&&null!==S?nD("projectedPlan",S
1):void 0,at=(0,a.useMemo)((()=>b(Je,nt)),[b,Je,nt]),lt=at.yDataKeys,rt=at.lineOptions,ot=(0,a.useCallback)(((e,t)=>{const n="number"===typeof e.activeLabel?e.activeLabel:void 0;if(void 0!==n){W(n);const e=null===t||void 0===t?void 0:t.nativeEvent;if(e&&"clientX"in e){var a;const t=document.elementFromPoint(e.clientX,e.clientY);!(null!==(a=null===t||void 0===t?void 0:t.closest("[data-event-marker]"))&&void 0!==a?a:null===t||void 0===t?void 0:t.closest("[data-annotation-marker]"))&&De&&Be()}}else Ue()}),[W,Be,De,Ue]),it=(0,a.useCallback)((()=>{W(null),Be(),Ue()}),[W,Be,Ue]),st=(0,a.useCallback)((e=>{ge(e),Be()}),[ge,Be]),ct=(0,a.useMemo)((()=>{var e;const t=v.find((e=>e.year===j));return null!==(e=null===t||void 0===t?void 0:t.netWorth)&&void 0!==e?e:null}),[v,j]),dt=(0,a.useMemo)((()=>null!==V?v.find((e=>e.year===V)):void 0),[v,V]),ut=(0,a.useMemo)((()=>{var e,t;return Ee&&null!==(e=null===(t=v.find((e=>e.year===Ee.startYear)))||void 0===t?void 0:t.netWorth)&&void 0!==e?e:null}),[v,Ee]),mt=(0,a.useMemo)((()=>{if("event"===(null===se||void 0===se?void 0:se.type)){const t=g.find((e=>e.id===se.id));if(t&&void 0!==t.startYear){var e;const n=v.find((e=>e.year===t.startYear));return{eventId:t.id,year:t.startYear,color:t.color,icon:t.icon,netWorth:null!==(e=null===n||void 0===n?void 0:n.netWorth)&&void 0!==e?e:null}}}return null}),[se,g,v]),pt=(0,a.useMemo)((()=>!De&&null===ue),[De,ue]);return a.createElement("div",{"data-external-id":"forecast-chart-card",ref:m,className:(0,q.cn)("relative shrink-0",s)},a.createElement(RP.x,{className:"gap-sm rounded-lg border border-border-primary shadow-none"},a.createElement(_P,{portalContainer:u}),a.createElement(UL,null),a.createElement("div",{className:"flex min-h-100 flex-col p-lg pt-0",ref:de},v.length>0?a.createElement(a.Fragment,null,C&&a.createElement("div",{className:"flex justify-end pb-xs"},a.createElement(iR,null)),a.createElement(DP.G,{onDragStart:st,onDragMove:he,onDragEnd:ve,pointerSensorOptions:OP,dragOverlay:e=>e===cR?a.createElement(gR,null):a.createElement(eR,null),modifiers:[zk.dU]},a.createElement(Do.rT,{isAnimationActive:ae,animationDuration:le,height:C?560:400,data:L,yDataKeys:lt,lineOptions:rt,xDataKey:"year",domain:Q,formatYAxis:FP,formatXAxis:GP,xAxisProps:{tickMargin:24,type:"number",domain:$,ticks:Z,allowDecimals:!1,padding:tt},yAxisProps:{ticks:ee,width:"auto"},hideLegend:!0,hideActiveDot:!pt,tooltipComponent:C?RD:YP,tooltipProps:{cursor:a.createElement(IR,{visible:pt,stroke:(0,qy.f)("content-secondary"),strokeWidth:1,strokeOpacity:pt?.4:0,strokeDasharray:"4 4",eventMarkerYears:He})},margin:Qe,onMouseMove:ot,onMouseLeave:it},a.createElement(H_.T,{y1:-1e9,y2:0,fill:"url(#negativeAreaPattern)",ifOverflow:"hidden",pointerEvents:"none"}),a.createElement("defs",null,a.createElement("pattern",{id:"negativeAreaPattern",patternUnits:"userSpaceOnUse",patternTransform:"matrix(9 0 0 13.14 357 27.5)",preserveAspectRatio:"none",viewBox:"0 0 9 13.14",width:"1",height:"1"},a.createElement("use",{xlinkHref:"#negativeAreaPatternInner",transform:"translate(0 -13.14)"}),a.createElement("g",{id:"negativeAreaPatternInner"},a.createElement("g",{clipPath:"url(#clip-negative-area)"},a.createElement("path",{d:"M10.6107 -0.753474L-0.998474 16.0944",stroke:(0,qy.f)("chart-negative-area"),strokeWidth:1.5})))),a.createElement("clipPath",{id:"clip-negative-area"},a.createElement("rect",{width:"9",height:"18",fill:"white"}))),C&&a.createElement(AR,{isAnimationActive:ae,animationDuration:le}),I&&a.createElement(AD,{chartData:L,isAnimationActive:ae}),k&&a.createElement(lM,{runs:P,startYear:B,hiddenGroups:F,yDomain:Q,yTargetDomain:te}),k&&a.createElement(gM,{runs:G,axis:Q,targetAxis:te,formatValue:FP}),Q[0]<0&&Q[1]>0&&a.createElement(eb.e_,{y:0,stroke:(0,qy.f)("chart-label"),strokeWidth:1,ifOverflow:"hidden"}),a.createElement(SR,{id:HO,positiveColor:(0,qy.f)("content-primary"),negativeColor:(0,qy.f)("content-danger"),yAxisId:0,domain:Q}),f&&a.createElement(SR,{id:KO,positiveColor:qO,negativeColor:$O,yAxisId:0,domain:Q}),null!==ct&&a.createElement(Ky.r,{x:j,y:ct,zIndex:fD,r:5.5,fill:(0,qy.f)("content-brand"),stroke:(0,qy.f)("background-primary"),strokeWidth:2,pointerEvents:"none"}),null!==V&&a.createElement(eb.e_,{x:V,stroke:(0,qy.f)("content-primary"),strokeWidth:1,strokeOpacity:.5,strokeDasharray:"6 6"}),null!==V&&f&&(0,Tp.n)(null===dt||void 0===dt?void 0:dt.compareNetWorth)&&a.createElement(Ky.r,{x:V,y:dt.compareNetWorth,r:3.5,fill:dt.compareNetWorth>=0?qO:$O,stroke:(0,qy.f)("background-primary"),strokeWidth:2}),null!==V&&(0,Tp.n)(null===dt||void 0===dt?void 0:dt.netWorth)&&a.createElement(Ky.r,{x:V,y:dt.netWorth,r:Ze.r,fill:dt.netWorth>
1=0?Ze.fill:(0,qy.f)("content-danger"),stroke:Ze.stroke,strokeWidth:Ze.strokeWidth}),a.createElement(bR,{year:qe,netWorth:$e,markersAtYear:null!==qe?je[String(qe)]:void 0,isExpanded:null!==qe&&xe.has(qe)}),me&&a.createElement(Ky.r,{x:me.year,y:me.netWorth,r:5.5,fill:me.color,stroke:(0,qy.f)("background-primary"),strokeWidth:2}),me&&ue!==(null===Ee||void 0===Ee?void 0:Ee.id)&&a.createElement(eb.e_,{x:me.year,stroke:"transparent",strokeWidth:0,label:e=>a.createElement(fR,{text:String(me.year),viewBox:e.viewBox,textColor:me.color})}),Ee&&Ee.hasRange&&void 0!==Ee.endYear&&a.createElement(H_.T,{key:"range-area",x1:Ee.startYear,x2:Ee.endYear,fill:BP(Ee.color),fillOpacity:.1,ifOverflow:"hidden",pointerEvents:"none"}),Ee&&a.createElement(eb.e_,{key:"range-start-line",x:Ee.startYear,stroke:BP(Ee.color),strokeWidth:1,label:e=>{const t=e.viewBox;Ae.current=t.x;const n=Ee.id===ue,l=n||!Ee.hasRange?String(Ee.startYear):"Year 1";return a.createElement(fR,{text:l,viewBox:e.viewBox,textColor:n?BP(Ee.color):void 0})}}),Ee&&null!==ut&&a.createElement(Ky.r,{x:Ee.startYear,y:ut,r:5.5,fill:zP(Ee.color),stroke:(0,qy.f)("background-primary"),strokeWidth:2,pointerEvents:"none"}),Ee&&Ee.hasRange&&void 0!==Ee.endYear&&a.createElement(eb.e_,{key:"range-end-line",x:Ee.endYear,stroke:BP(Ee.color),strokeWidth:1,label:e=>{const t=e.viewBox,n=Ee.endYear-Ee.startYear,l=Ae.current,r=BP(Ee.color);return a.createElement("g",null,a.createElement(fR,{text:"Year ".concat(n+1),viewBox:t}),null!==l&&a.createElement("line",{x1:l,y1:t.y,x2:t.x,y2:t.y,stroke:r,strokeWidth:2}))}}),a.createElement(oR,{markersByYear:je,compareOnlyEventMarkerYears:Ke,previewEventYear:qe,selectedEvent:Ee,openedEventId:null!==(i=null===mt||void 0===mt?void 0:mt.eventId)&&void 0!==i?i:null,expandedYears:xe,onToggleYearExpanded:Ce,hideMarkerTooltip:Be,handleAnnotationMouseEnter:Le,handleGroupedAnnotationMouseEnter:Oe,handleEventPointerDown:Pe,handleEventClick:ze,handleEventMouseEnter:Me})),a.createElement(T.N,null,De&&ke&&Re&&a.createElement(Yy,{x:Re.x,y:Re.y,markerSize:"annotation"===ke.kind?Gg:Yg},a.createElement(BO,{target:ke,hoveredEvent:Se,hoveredAnnotations:Ne,eventTooltipScenarioMetadata:Te,eventTooltipDollarMode:_e}))),pt&&Ge&&a.createElement(Yy,{x:Ge.x,y:Ge.y,markerSize:15},a.createElement(zO,null))),a.createElement("div",{className:"flex justify-center"},a.createElement(T.N,{initial:!1},(y||C)&&a.createElement(D.PY1.div,{key:"forecast-legend",initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:{duration:.2,ease:"easeInOut"},className:"overflow-hidden"},a.createElement(ND,{entries:M}))))):a.createElement(MP.e,{title:"No projection data available"}))))},BP=e=>(0,qy.f)("chart-event-border-".concat(e)),zP=e=>(0,qy.f)("chart-event-dot-".concat(e)),FP=e=>(0,rl.fw)(e),GP=e=>e.toString(),YP=()=>null,UP=e=>{var t;let n=e.eventId,l=e.subItems,r=e.years;const o=bw(),i=null!==(t=null===o||void 0===o?void 0:o.effectTable)&&void 0!==t?t:e_,s=t_(l),c=ww();return a.createElement(a.Fragment,null,s.map((e=>a.createElement(LN,{key:VP(n,e.id)},a.createElement(tN,{indentPx:Fg,className:"gap-2xs pr-sm"},a.createElement(xt.v,{className:"min-w-0",size:"small",color:"content.primary",lineHeight:"20px",clampLines:1,title:e.label},e.label),e.isFixedPayment?a.createElement(AS,null):null),r.map((t=>{var l;const r=null===(l=i.get(t))||void 0===l?void 0:l.get(n),o=null===r||void 0===r?void 0:r.find((t=>t.id===e.id)),s=void 0===(null===o||void 0===o?void 0:o.amount)?void 0:c.toTodaysDollars(o.amount,t),d=(p=s,g=null===o||void 0===o?void 0:o.target,void 0===p?{text:"",color:"content.secondary"}:Np(p)?{text:(0,rl.fw)(0),color:"content.secondary"}:XT(p,g)),u=d.text,m=d.color;var p,g;return a.createElement(wN,{key:WP(n,e.id,t),year:t,align:"right",background:"primary",dashedBorder:!0},a.createElement(xt.v,{size:"small",lineHeight:"20px",color:m},u))}))))))},VP=(e,t)=>"subitem-".concat(e,"-").concat(t),WP=(e,t,n)=>"subitem-".concat(e,"-").concat(t,"-").concat(n),jP=a.memo((e=>{let t=e.year,n=e.background,l=void 0===n?"primary":n,r=e.children;const o=vE(t),i=hE(),s=a.useCallback((()=>{i(t)}),[i,t]),c=a.useCallback((()=>{i(null)}),[i]),d=o?"background.primaryHover":"background.".concat(l);return a.createElement(HP,{"data-external-id":"chip-anchor-cell",alignCenter:!0,backgroundColor:d,cursor:"default",onMouseEnter:s,onMouseLeave:c},r)})),HP=(0,u.default)(m.g).attrs({position:"relative",overflow:"visible",zIndex:1}).withConfig({displayName:"chipComponents__ChipAnchorFlexContainer",componentId:"s4grn2-0"})(["white-space:nowrap;transition:",";border-right:1px dashed ",";"],vt.kY.default,vt.Ee.color.divider.secondary),KP=u.default.div.withConfig({displayName:"chipComponents__ChipContainer",componentId:"s4grn2-1"})(["position:absolute;
1left:0;top:50%;transform:translateY(-50%);width:","px;height:","px;border-radius:",";background:",";border:1px solid ",";"," pointer-events:auto;cursor:",";overflow:clip;display:flex;align-items:center;padding-top:",";padding-bottom:",";",""],(e=>e.$width),32,vt.r8.default,(e=>{let t=e.theme,n=e.$color;return t.variables.color.chart.event.background[n]}),vt.Ee.color.avatar.border,wn.M.medium,(e=>!1===e.$clickable?"default":"pointer"),vt.YK.xxsmall,vt.YK.xxsmall,(e=>{let t=e.$opacity;return void 0!==t&&"opacity: ".concat(t,";")})),qP=u.default.div.withConfig({displayName:"chipComponents__ChipContent",componentId:"s4grn2-2"})(["position:sticky;left:","px;display:flex;align-items:center;gap:",";padding-left:",";padding-right:",";max-width:100%;min-width:0;color:",";"],Bg,vt.YK.xsmall,vt.YK.small,vt.YK.small,(e=>{let t=e.theme,n=e.$foregroundColor;return t.variables.color.chart.event.foreground[n]})),$P=(0,u.default)(xt.v).attrs({size:"small",clampLines:1,lineHeight:"20px"}).withConfig({displayName:"chipComponents__ChipLabel",componentId:"s4grn2-3"})(["font-weight:350;min-width:0;"]),ZP=["excluded","className"],JP=["background"],XP=e=>{let t=e.model,n=e.years,l=e.chip,r=e.arrowDirection,o=e.containerWidth,i=e.isExpandable,s=e.isExpanded,c=e.isExcluded,d=e.onToggleExpand,u=e.onOpenEvent,p=e.onScrollToYear,g=e.setTableHoveredYear;const h=rw().isTableShowingCompareData,v=t.startYear,f=c?eB:tB,E=c?"secondary":"primary",y=l?n[l.startIndex]:v,b=void 0!==r&&void 0!==v?a.createElement(rB,{"data-arrow-circle-button":!0,onClick:()=>{void 0!==y&&p(y)},title:"Scroll to ".concat(t.name," (").concat(y,")")},a.createElement(sl.ZQ,{name:"arrow-".concat(r),size:16})):null;return a.createElement(a.Fragment,null,a.createElement(f,{divider:s?"secondary":"none"},a.createElement(QP,{excluded:c,background:c?"secondary":void 0},a.createElement(PN,null,i&&!c?a.createElement(B.L,{icon:s?"chevron-down":"chevron-right",size:"xxsmall",onClick:()=>d(t.id)}):a.createElement(m.g,{width:24,flexShrink:0}),a.createElement(aB,{$color:t.color,$foregroundColor:t.foregroundColor,$opacity:c?.6:void 0},a.createElement(sl.ZQ,{name:t.icon,size:20})),a.createElement(nB,{weight:c?void 0:"medium",color:c?"content.secondary":void 0},t.displayName)),c&&a.createElement(GN,null,a.createElement(FN,null,a.createElement(m.g,{center:!0,width:32,height:32,color:"content.secondary"},a.createElement(sl.ZQ,{name:"eye-off",size:16}))),a.createElement(BN,null,a.createElement(wT,{isTableShowingCompareData:h,onClick:()=>u(t.id),ariaLabel:"Settings for ".concat(t.displayName)}))),!c&&a.createElement(BN,null,a.createElement(wT,{isTableShowingCompareData:h,onClick:()=>u(t.id),ariaLabel:"Settings for ".concat(t.displayName)})),void 0!==r&&void 0!==v&&a.createElement(lB,{$direction:r,style:{left:"right"===r?o-8:316}},"left"===r&&b,a.createElement(oB,null,v),"right"===r&&b)),n.map(((e,r)=>l&&r===l.startIndex?a.createElement(jP,{key:_N("event-".concat(t.id),e),year:e,background:E},a.createElement(KP,{$width:l.columnCount*zg,$color:t.color,$opacity:c?.6:void 0,$clickable:!h,title:t.displayName,onClick:h?void 0:()=>u(t.id),onMouseMove:e=>{const t=e.currentTarget.getBoundingClientRect(),a=Math.floor((e.clientX-t.left)/zg),r=n[l.startIndex+a];void 0!==r&&g(r)},onMouseLeave:()=>g(null)},a.createElement(qP,{$foregroundColor:t.foregroundColor},a.createElement(sl.ZQ,{name:t.icon,size:20}),a.createElement($P,null,t.displayName)))):a.createElement(wN,{key:_N("event-".concat(t.id),e),year:e,background:E,dashedBorder:!0})))),i&&!c&&a.createElement(ON,{open:s},a.createElement(UP,{eventId:t.id,subItems:t.getEffectDefinitions(),years:n})))},QP=e=>{let t=e.excluded,n=e.className,l=(0,En.A)(e,ZP);return a.createElement(tN,Object.assign({"data-external-id":"event-sticky-cell",className:(0,q.cn)("justify-between border-b border-divider-secondary pr-sm",t&&"text-content-secondary","[&:hover:not(:has([data-arrow-circle-button]:hover))_[data-forecast-hover-reveal]]:opacity-100","[&:hover:not(:has([data-arrow-circle-button]:hover))_[data-forecast-hover-default]]:opacity-0",n)},l))},eB=e=>{let t=e.background,n=void 0===t?"secondary":t,l=(0,En.A)(e,JP);return a.createElement(MN,Object.assign({"data-external-id":"excluded-event-row",background:n},l))},tB=(0,u.default)(MN).withConfig({displayName:"EventRowContent__EventRow",componentId:"sc-6i3jj5-0"})(["> *:not(:first-child){border-bottom:1px solid ",";transition:",",border-color 0s linear 10ms;}"],(e=>{let t=e.divider,n=e.theme;return"none"===t?"transparent":n.variables.color.divider[null!==t&&void 0!==t?t:"primary"]}
1),vt.kY.default),nB=(0,u.default)(xt.v).attrs({clampLines:1}).withConfig({displayName:"EventRowContent__EventName",componentId:"sc-6i3jj5-1"})(["min-width:0;"]),aB=u.default.div.withConfig({displayName:"EventRowContent__IconSquare",componentId:"sc-6i3jj5-2"})(["width:","px;height:","px;border-radius:",";background:",";display:flex;align-items:center;justify-content:center;flex-shrink:0;color:",";",""],36,36,vt.r8.default,(e=>{let t=e.theme,n=e.$color;return t.variables.color.chart.event.background[n]}),(e=>{let t=e.theme,n=e.$foregroundColor;return t.variables.color.chart.event.foreground[n]}),(e=>{let t=e.$opacity;return void 0!==t&&"opacity: ".concat(t,";")})),lB=u.default.div.withConfig({displayName:"EventRowContent__ArrowIndicator",componentId:"sc-6i3jj5-3"})(["position:absolute;top:50%;transform:translateY(-50%) ",";display:flex;align-items:center;gap:",";pointer-events:none;z-index:3;"],(e=>"right"===e.$direction?"translateX(-100%)":""),vt.YK.xsmall),rB=u.default.button.withConfig({displayName:"EventRowContent__ArrowCircleButton",componentId:"sc-6i3jj5-4"})(["width:","px;height:","px;border-radius:",";background:",";border:1px solid ",";"," display:flex;align-items:center;justify-content:center;flex-shrink:0;padding:0;cursor:pointer;pointer-events:auto;color:",";&:hover{color:",";}"],28,28,vt.r8.round,vt.Ee.color.background.primary,vt.Ee.color.border.primary,wn.M.medium,vt.Ee.color.content.secondary,vt.Ee.color.content.primary),oB=(0,u.default)(xt.v).attrs({size:"small",color:"content.secondary",lineHeight:"20px"}).withConfig({displayName:"EventRowContent__ArrowLabel",componentId:"sc-6i3jj5-5"})(["font-weight:350;"]),iB=["className"],sB=["className"],cB=e=>{let t=e.className,n=(0,En.A)(e,iB);return a.createElement(MN,Object.assign({"data-external-id":"empty-state-row",minHeight:80,className:(0,q.cn)("last:*:border-b-0",t)},n))},dB=e=>{let t=e.className,n=(0,En.A)(e,sB);return a.createElement(tN,Object.assign({"data-external-id":"empty-state-sticky-cell",background:"secondary",className:(0,q.cn)("text-center",t)},n))},uB=()=>{const e=Ew(XE(),uw),t=NS(),n=t.years,l=t.scrollToYear,r=vy().openEvent,i=(()=>{const e=Aw();return BC(e),PC((0,hh.k)((t=>{const n=MC(t.byScenarioId,e);return{expandedEventIds:n.events.expandedEventIds,isExcludedExpanded:n.events.isExcludedExpanded,toggleExpandedEvent:t.toggleExpandedEvent,toggleExcludedExpanded:t.toggleExcludedExpanded}})))})(),s=i.expandedEventIds,c=i.isExcludedExpanded,d=i.toggleExpandedEvent,u=i.toggleExcludedExpanded,m=hE(),p=(()=>{const e=NS(),t=e.years,n=e.scrollContainerRef,l=(0,a.useState)({first:0,lastLeftEdgeVisible:t.length-1,containerWidth:0}),r=(0,o.A)(l,2),i=r[0],s=r[1];return(0,a.useEffect)((()=>{const e=n.current;if(!e)return;const a=()=>{const n=e.clientWidth,a=Math.floor(e.scrollLeft/zg),l=Math.max(0,n-Bg),r=Math.min(t.length-1,Math.ceil((e.scrollLeft+l)/zg)-1);s((e=>e.first===a&&e.lastLeftEdgeVisible===r&&e.containerWidth===n?e:{first:a,lastLeftEdgeVisible:r,containerWidth:n}))};a(),e.addEventListener("scroll",a,{passive:!0});const l=new ResizeObserver(a);return l.observe(e),()=>{e.removeEventListener("scroll",a),l.disconnect()}}),[n,t.length]),i})(),g=p.first,h=p.lastLeftEdgeVisible,v=p.containerWidth,f=(0,a.useMemo)((()=>{const t=e.filter((e=>e.isVisibleInForecast));return{included:[...t.filter((e=>e.isIncluded))].sort(_g),excluded:[...t.filter((e=>!e.isIncluded))].sort(_g)}}),[e]),E=f.included,y=f.excluded;return 0===E.length&&0===y.length?a.createElement(cB,{"data-external-id":"events-tab"},a.createElement(dB,null,a.createElement(xt.v,{color:"content.secondary"},"No events added yet. Add income or expense events to see cash flow projections.")),n.map((e=>a.createElement(wN,{key:_N("empty",e),year:e,dashedBorder:!0})))):a.createElement(a.Fragment,null,E.map((t=>a.createElement(mB,{key:t.id,model:t,allModels:e,years:n,firstVisible:g,lastLeftEdgeVisible:h,containerWidth:v,expandedEvents:s,onToggleExpand:d,onOpenEvent:r,onScrollToYear:l,setTableHoveredYear:m}))),y.length>0&&a.createElement(a.Fragment,null,a.createElement(ON,{open:c},y.map((t=>a.createElement(mB,{key:t.id,model:t,allModels:e,years:n,firstVisible:g,lastLeftEdgeVisible:h,containerWidth:v,isExcluded:!0,onToggleExpand:d,onOpenEvent:r,onScrollToYear:l,setTableHoveredYear:m})))),a.createElement(MN,{divider:"secondary"},a.createElement(tN,{className:"pr-sm pl-xl",onClick:u,style:{cursor:"pointer"}},a.createElement(PN,null,a.createElement(B.L,{icon:c?"eye-off":"eye",size:"xxsmall",color:"content.secondary","aria-expanded":c}),a.createElement(xt.v,{size:"small",color:"content.secondary"},c?"Collapse ".concat(y.length," excluded ").concat((0,De.td)("event",y.length)):"Show ".concat(y.length," excluded ").concat((0,De.td)("event",y.length))))),n.map((e=>a.createElement(wN,{key:_N("excluded-toggle",e),year:e,dashedBorder:!0}))))))},mB=e=>{var t;let n=e.model,l=e.allModels,r=e.years,i=e.firstVisible,s=e.lastLeftEdgeVisible,c=e.containerWidth,d=e.expandedEvents,u=e.isExcluded,m=e.onToggleExpand,p=e.onOpenEvent,g=e.onScrollToYear,h=e.setTableHoveredYear;const v=!u&&(e=>e.getEffectDefinitions().length>0)(n),f=v&&null!==(t=null===d||void 0===d?void 0:d.has(n.id))&&void 0!==t&&t,E=((e,t,n)=>{if(0===t.length)return;const a=e.getActiveYearRange(t[t.length-1]+1,n);if(!a)return;const l=(0,o.A)(t,1)[0],r=t[t.length-1],i=Math.max(a.start,l),s=Math.min(a.end,r+1);if(i>=s)return;return{startIndex:i-l,columnCount:s-i}})(n,r,l),y=((e,t,n,a,l)=>{const r=e.startYear;if(void 0===r)return;const o=void 0!==t&&t.startIndex>l,i=void 0!==t&&t.startIndex+t.columnCount-1<a,s=void 0===t;return o||s&&r>n[n.length-1]?"right":i||s&&r<n[0]?"left":void 0})(n,E,r,i,s);return a.createElement(XP,{"data-external-id":"event-row",model:n,years:r,chip:E,arrowDirection:y,containerWidth:c,isExpandable:v,isExpanded:f,isExcluded:u,onToggleExpand:m,onOpenEvent:p,onScrollToYear:g,setTableHoveredYear:h})},pB=()=>a.createElement("div",{"data-external-id":"forecast-legal-disclaimer"},a.createElement("p",{className:"m-0 text-xs leading-[150%] text-content-secondary"},_t.Pb)),gB="".concat(Bg,"px repeat(").concat(6,", ").concat(zg,"px)"),hB=()=>a.createElement("div",{"data-external-id":"forecast-main-skeleton",className:"flex flex-col gap-gutter","aria-busy":"true","aria-label":"Loading forecast","data-testid":"forecast-main-skeleton"},a.createElement(vB,null),a.createElement("div",{className:(0,q.cn)("flex min-h-[min(520px,55vh)] min-w-0 flex-col overflow-hidden rounded-lg border","border-border-primary bg-background-primary")},a.createElement("div",{className:"flex shrink-0 items-center px-6 py-4"},a.createElement("div",{className:"flex items-center gap-2xs"},a.createElement(M.Al,{$width:"96px",$height:"32px",$borderRadius:"pill","aria-hidden":!0}),a.createElement(M.Al,{$width:"108px",$height:"32px",$borderRadius:"pill","aria-hidden":!0}),a.createElement(M.Al,{$width:"84px",$height:"32px",$borderRadius:"pill","aria-hidden":!0}))),a.createElement("div",{className:"min-h-0 min-w-0 flex-1 overflow-x-auto"},a.createElement("div",{className:"flex min-w-full flex-col",style:{minWidth:980}},a.createElement(fB,{className:"shrink-0 border-y border-border-secondary bg-background-page",style:{minHeight:36}},a.createElement("div",{className:"flex items-center border-r border-border-secondary pl-2"},a.createElement(M.Al,{$width:"72px",$height:"18px",$borderRadius:"small","aria-hidden":!0})),Array.from({length:6},((e,t)=>a.createElement("div",{key:t,className:"flex items-center justify-end pr-2"},a.createElement(M.Al,{$width:"40px",$height:"16px",$borderRadius:"small","aria-hidden":!0}))))),Array.from({length:6},((e,t)=>a.createElement(fB,{key:t,className:"shrink-0 border-b border-border-primary last:border-b-0",style:{minHeight:56}},a.createElement("div",{className:"flex items-center border-r border-border-secondary px-6"},a.createElement(M.Al,{$width:"65%",$height:"20px",$borderRadius:"small","aria-hidden":!0})),Array.from({length:6},((e,t)=>a.createElement("div",{key:t,className:"flex items-center justify-end px-2"},a.createElement(M.Al,{$width:"64px",$height:"18px",$borderRadius:"small","aria-hidden":!0}))))))))))),vB=()=>a.createElement(RP.x,{"data-external-id":"forecast-chart-card-skeleton",className:(0,q.cn)("shrink-0 gap-default rounded-lg border border-border-primary shadow-none"),"aria-busy":"true","aria-label":"Loading forecast chart","data-testid":"forecast-chart-card-skeleton"},a.createElement("div",{className:"flex items-center justify-between gap-sm px-6 pt-6 pb-2"},a.createElement(M.Al,{$width:"220px",$height:"32px",$borderRadius:"small","aria-hidden":!0}),a.createElement(M.Al,{$width:"140px",$height:"32px",$borderRadius:"small","aria-hidden":!0})),a.createElement("div",{className:"px-6 py-3"},a.createElement(M.Al,{$width:"100%",$height:"52px",$borderRadius:"small","aria-hidden":!0})),a.createElement("div",{className:"px-6 pb-6",style:{minHeight:400}},a.createElement(M.Al,{$width:"100%",$height:"360px",$borderRadius:"medium","aria-hidden":!0}
1))),fB=e=>{let t=e.children,n=e.className,l=e.style;return a.createElement("div",{"data-external-id":"table-skeleton-grid-row",className:(0,q.cn)("grid w-full",n),style:(0,U.A)({gridTemplateColumns:gB},l)},t)},EB="forecast-upsell-mini-curve-gradient",yB=String(65),bB=[{title:"Buy a home",subtitle:"Plan for home ownership",color:"blue",icon:"home"},{title:"Have a kid",subtitle:"Model the impact of raising children",color:"pink",icon:"stroller"},{title:"Expense",subtitle:"Large purchases, one-time costs, and more",color:"red",icon:"credit-card"},{title:"Income",subtitle:"Inheritance, stock sales, and more",color:"green",icon:"trending-up"},{title:"Retire",subtitle:"Transition to retirement income",color:"orange",icon:"sunset"}],xB=[{centerX:70,topPx:63,color:"blue",icon:"home"},{centerX:167,topPx:39,color:"green",icon:"trending-up"},{centerX:251,topPx:15,color:"orange",icon:"sunset"}],wB=(0,u.default)(m.g).attrs({gap:"default"}).withConfig({displayName:"ForecastFeatureCardsstyles__FeatureCardsRow",componentId:"sc-14fxp1g-0"})(["@media (max-width:","px){flex-direction:column;}"],vt.nm.md),CB=(0,u.default)(m.g).attrs({column:!0,alignCenter:!0,gap:"xlarge",padding:"xlarge",minWidth:0,overflow:"hidden",backgroundColor:"background.primary",borderRadius:"large",flex:"1 0 0"}).withConfig({displayName:"ForecastFeatureCardsstyles__FeatureCard",componentId:"sc-14fxp1g-1"})(["border:1px solid ",";@media (max-width:","px){flex:none;}"],vt.Ee.color.border.primary,vt.nm.md),AB=u.default.div.withConfig({displayName:"ForecastFeatureCardsstyles__IllustrationArea",componentId:"sc-14fxp1g-2"})(["width:100%;flex-shrink:0;aspect-ratio:",";max-height:","px;border-radius:",";background-color:",";overflow:hidden;position:relative;"],"320 / 126",140,vt.r8.large,(e=>vt.yW[e.$bgColor](e))),IB=(0,u.default)(m.g).attrs({column:!0,gap:"xsmall",padding:"default",position:"absolute",minWidth:0,backgroundColor:"background.primary",borderRadius:"medium"}).withConfig({displayName:"ForecastFeatureCardsstyles__RetirementSliderCard",componentId:"sc-14fxp1g-3"})(["left:50%;transform:translateX(-50%);top:","%;height:","%;width:","%;border:1px solid ",";box-shadow:0 2px 4px 0 ",";"],21/126*100,114/126*100,85,vt.Ee.color.border.primary,vt.Ee.color.shadow.medium),kB=u.default.div.withConfig({displayName:"ForecastFeatureCardsstyles__SliderTrack",componentId:"sc-14fxp1g-4"})(["position:relative;height:12px;background-color:",";border-radius:",";"],vt.Ee.color.background.secondary,vt.r8.pill),SB=u.default.div.withConfig({displayName:"ForecastFeatureCardsstyles__SliderFill",componentId:"sc-14fxp1g-5"})(["position:absolute;left:0;top:0;height:100%;width:","%;background-color:",";border-radius:",";"],(e=>e.$percent),vt.yW.blue7,vt.r8.pill),NB=u.default.div.withConfig({displayName:"ForecastFeatureCardsstyles__SliderThumb",componentId:"sc-14fxp1g-6"})(["position:absolute;top:50%;left:","%;transform:translate(-50%,-50%);width:22px;height:22px;border-radius:",";background-color:",";border:2px solid ",";box-shadow:0 1px 3px ",";"],(e=>e.$percent),vt.r8.round,vt.Ee.color.background.primary,vt.yW.blue7,vt.Ee.color.shadow.medium),TB=(0,u.default)(m.g).attrs({column:!0,overflow:"hidden",position:"absolute",borderRadius:"large"}).withConfig({displayName:"ForecastFeatureCardsstyles__LifeEventsList",componentId:"sc-14fxp1g-7"})(["left:50%;transform:translateX(-50%);top:10%;width:87%;border:1px solid ",";"],vt.Ee.color.border.primary),_B=(0,u.default)(m.g).attrs({alignCenter:!0,gap:"small",paddingVertical:"xsmall",paddingHorizontal:"small",backgroundColor:"background.primary"}).withConfig({displayName:"ForecastFeatureCardsstyles__LifeEventRow",componentId:"sc-14fxp1g-8"})(["border-bottom:1px solid ",";&:last-child{border-bottom:none;}"],vt.Ee.color.border.primary),DB=u.default.div.withConfig({displayName:"ForecastFeatureCardsstyles__MiniChartContainer",componentId:"sc-14fxp1g-9"})(["position:absolute;inset:0;"]),RB=u.default.svg.withConfig({displayName:"ForecastFeatureCardsstyles__MiniChartSvg",componentId:"sc-14fxp1g-10"})(["position:absolute;inset:0;width:100%;height:100%;"]),MB=u.default.div.withConfig({displayName:"ForecastFeatureCardsstyles__MiniChartMarkerWrapper",componentId:"sc-14fxp1g-11"})(["position:absolute;top:","%;left:","%;transform:translateX(-50%);"],(e=>e.$topPx/126*100),(e=>e.$centerX/320*100)),LB=(0,u.default)(m.g).attrs({center:!0}).withConfig({displayName:"ForecastFeatureCardsstyles__MiniChartMarkerSquare",componentId:"sc-14fxp1g-12"})(["width:","px;height:","px;border-radius:",";background:",";color:",";
1"],24,24,vt.r8.small,(e=>vt.Ee.color.chart.event.background[e.$color](e)),(e=>vt.Ee.color.chart.event.foreground[e.$color](e))),OB=(0,u.default)(m.g).attrs({center:!0,flexShrink:0}).withConfig({displayName:"shared__EventIconSquare",componentId:"sc-1n8w2dn-0"})(["width:","px;height:","px;border-radius:",";background:",";color:",";"],(e=>e.$size),(e=>e.$size),vt.r8.small,(e=>vt.Ee.color.chart.event.background[e.$color](e)),(e=>vt.Ee.color.chart.event.foreground[e.$color](e))),PB=u.default.line.withConfig({displayName:"shared__ChartEventLine",componentId:"sc-1n8w2dn-1"})(["stroke:",";stroke-width:2;"," @media (max-width:","px){"," ","}"],(e=>vt.Ee.color.chart.event.background[e.$color](e)),(e=>e.$showOnlyOnMobile&&"display: none;"),vt.nm.md,(e=>e.$hideOnMobile&&"display: none;"),(e=>e.$showOnlyOnMobile&&"display: block;")),BB=u.default.path.withConfig({displayName:"shared__ForecastCurvePath",componentId:"sc-1n8w2dn-2"})(["fill:none;stroke-width:2.5;stroke-linecap:round;"]),zB=u.default.stop.withConfig({displayName:"shared__GradientStopOrange",componentId:"sc-1n8w2dn-3"})(["stop-color:",";"],vt.Ee.color.background.gradientOrange),FB=u.default.stop.withConfig({displayName:"shared__GradientStopYellow",componentId:"sc-1n8w2dn-4"})(["stop-color:",";"],vt.Ee.color.background.gradientYellow),GB=()=>a.createElement(wB,{"data-external-id":"forecast-feature-cards"},a.createElement(CB,null,a.createElement(UB,null),a.createElement(m.g,{column:!0,gap:"xxsmall",flex:1},a.createElement(xt.v,{size:"large",weight:"medium",color:"content.primary",align:"center"},"When can I retire?"),a.createElement(xt.v,{size:"small",color:"content.secondary",align:"center"},"Test different assumptions to land on a plan you understand and trust that is grounded in your real numbers."))),a.createElement(CB,null,a.createElement(VB,null),a.createElement(m.g,{column:!0,gap:"xxsmall",flex:1},a.createElement(xt.v,{size:"large",weight:"medium",color:"content.primary",align:"center"},"Can I afford this house?"),a.createElement(xt.v,{size:"small",color:"content.secondary",align:"center"},"Understand how big decisions affect your long-term picture. Weigh the trade-offs and choose what fits the future you want."))),a.createElement(CB,null,a.createElement(WB,null),a.createElement(m.g,{column:!0,gap:"xxsmall",flex:1},a.createElement(xt.v,{size:"large",weight:"medium",color:"content.primary",align:"center"},"How does my future look?"),a.createElement(xt.v,{size:"small",color:"content.secondary",align:"center"},"See where your money is headed based on your actual habits and life plans.")))),YB=e=>{let t=e.centerX,n=e.topPx,l=e.color,r=e.icon;return a.createElement(MB,{"data-external-id":"mini-chart-marker",$centerX:t,$topPx:n},a.createElement(LB,{$color:l},a.createElement(sl.ZQ,{name:r,size:12})))},UB=()=>a.createElement(AB,{"data-external-id":"retirement-illustration",$bgColor:"blue2"},a.createElement(IB,null,a.createElement(m.g,{justifyBetween:!0,alignCenter:!0,gap:"small",minWidth:0},a.createElement(xt.v,{size:"small",weight:"medium",color:"content.primary",clampLines:1},"Choose a retirement age"),a.createElement(xt.v,{size:"large",weight:"medium",color:"content.primary"},yB)),a.createElement(kB,null,a.createElement(SB,{$percent:47}),a.createElement(NB,{$percent:47})))),VB=()=>a.createElement(AB,{"data-external-id":"life-events-illustration",$bgColor:"orange2"},a.createElement(TB,null,bB.slice(0,2).map((e=>{let t=e.title,n=e.subtitle,l=e.color,r=e.icon;return a.createElement(_B,{key:t},a.createElement(OB,{$color:l,$size:26},a.createElement(sl.ZQ,{name:r,size:14})),a.createElement(m.g,{column:!0,gap:"xxxsmall",minWidth:0},a.createElement(xt.v,{size:"xsmall",weight:"medium",color:"content.primary",clampLines:1},t),a.createElement(xt.v,{size:"xsmall",color:"content.secondary",clampLines:1},n)))})))),WB=()=>a.createElement(AB,{"data-external-id":"future-look-illustration",$bgColor:"pink2"},a.createElement(DB,null,a.createElement(RB,{viewBox:"0 0 ".concat(320," ").concat(126),preserveAspectRatio:"none","aria-hidden":"true"},a.createElement("defs",null,a.createElement("linearGradient",{id:EB,x1:"31",y1:"63",x2:"320",y2:"63",gradientUnits:"userSpaceOnUse"},a.createElement(zB,null),a.createElement(FB,{offset:"1"}))),xB.map((e=>{let t=e.centerX,n=e.topPx,l=e.color;return a.createElement(PB,{key:t,$color:l,x1:t,y1:n,x2:t,y2:126,strokeWidth:"1.5"})})),a.createElement(BB,{d:"M 1,111 C 1,111 192,95 250,30 C 278,24 318,50 320,53",stroke:"url
1(#".concat(EB,")"),strokeDasharray:"4 4",strokeLinecap:"round",strokeLinejoin:"round",strokeOpacity:.75})),xB.map((e=>{let t=e.centerX,n=e.topPx,l=e.color,r=e.icon;return a.createElement(YB,{key:t,centerX:t,topPx:n,color:l,icon:r})})))),jB=[{label:"$2.5M",topPercent:12.1},{label:"$2M",topPercent:27.9},{label:"$1.5M",topPercent:44},{label:"$1M",topPercent:60},{label:"$500k",topPercent:76.1}],HB=(new Date).getFullYear(),KB=[6.3,21.4,36.4,51.4,66.4,81.4,96.4].map(((e,t)=>({label:String(HB+4*t),leftPercent:e}))),qB="forecast-upsell-curve-gradient",$B=[{label:"Buy a home",color:"blue",icon:"home",leftPercent:16.9,topPercent:70,mobileTopPercent:72,svgX:161,mobileVisible:!0},{label:"Have a kid",color:"pink",icon:"stroller",leftPercent:28.4,topPercent:58,mobileTopPercent:52,svgX:270,mobileVisible:!0},{label:"Expense",color:"red",icon:"credit-card",leftPercent:46.2,topPercent:55,mobileTopPercent:28,svgX:439,mobileVisible:!0},{label:"Income",color:"green",icon:"trending-up",leftPercent:68,topPercent:42,svgX:647},{label:"Retire",color:"orange",icon:"sunset",leftPercent:92.5,topPercent:-3,svgX:880}],ZB=(0,u.default)(m.g).attrs({column:!0,width:"full",overflow:"hidden",backgroundColor:"background.primary",borderRadius:"large"}).withConfig({displayName:"ForecastHeroSectionstyles__HeroCard",componentId:"sc-11lf8ve-0"})(["border:1px solid ",";@media (max-width:","px){background-color:transparent;border:none;border-radius:0;overflow:visible;}"],vt.Ee.color.border.primary,vt.nm.md),JB=(0,u.default)(m.g).attrs({column:!0,alignCenter:!0}).withConfig({displayName:"ForecastHeroSectionstyles__HeroTitleSection",componentId:"sc-11lf8ve-1"})(["padding:"," "," 0;text-align:center;@media (max-width:","px){padding:"," "," 0;gap:",";}"],vt.YK.xxxxlarge,vt.YK.xxxlarge,vt.nm.md,vt.YK.xlarge,vt.YK.default,vt.YK.default),XB=u.default.div.withConfig({displayName:"ForecastHeroSectionstyles__HeroChartSection",componentId:"sc-11lf8ve-2"})(["position:relative;min-height:","px;@media (max-width:","px){min-height:220px;overflow:hidden;}"],460,vt.nm.md),QB=(0,u.default)(m.g).attrs({column:!0,alignCenter:!0,gap:"default",position:"relative"}).withConfig({displayName:"ForecastHeroSectionstyles__HeroSubContent",componentId:"sc-11lf8ve-3"})(["padding:"," "," ",";text-align:center;@media (max-width:","px){display:none;}"],vt.YK.small,vt.YK.xxxlarge,vt.YK.xxxxlarge,vt.nm.md),ez=(0,u.default)(xt.v).attrs({as:"h2",weight:"book",color:"content.primary",lineHeight:1.3,letterSpacing:"-0.05em"}).withConfig({displayName:"ForecastHeroSectionstyles__HeroHeading",componentId:"sc-11lf8ve-4"})(["font-family:Copernicus,serif;font-size:48px;margin:0;@media (max-width:","px){font-size:32px;}"],vt.nm.md),tz=(0,u.default)(m.g).attrs({column:!0,alignCenter:!0,gap:"default",width:"full"}).withConfig({displayName:"ForecastHeroSectionstyles__MobileHeroContent",componentId:"sc-11lf8ve-5"})(["display:none;@media (max-width:","px){display:flex;}"],vt.nm.md),nz=u.default.div.withConfig({displayName:"ForecastHeroSectionstyles__HeroDescriptionWrapper",componentId:"sc-11lf8ve-6"})(["max-width:","px;text-wrap:pretty;"],540),az=u.default.div.withConfig({displayName:"ForecastHeroSectionstyles__HeroChartArea",componentId:"sc-11lf8ve-7"})(["position:absolute;inset:",";@media (max-width:","px){inset:0;width:200%;left:-15%;}"],vt.YK.xxxlarge,vt.nm.md),lz=u.default.span.withConfig({displayName:"ForecastHeroSectionstyles__ChartYLabel",componentId:"sc-11lf8ve-8"})(["position:absolute;left:0;width:36px;top:","%;transform:translateY(-50%);font-size:12px;color:",";text-align:right;pointer-events:none;white-space:nowrap;@media (max-width:","px){display:none;}"],(e=>e.$topPercent),vt.Ee.color.chart.label,vt.nm.md),rz=u.default.span.withConfig({displayName:"ForecastHeroSectionstyles__ChartXLabel",componentId:"sc-11lf8ve-9"})(["position:absolute;bottom:-5px;left:","%;transform:translateX(-50%);font-size:12px;color:",";pointer-events:none;white-space:nowrap;@media (max-width:","px){display:none;}"],(e=>e.$leftPercent),vt.Ee.color.chart.label,vt.nm.md),oz=(0,u.default)(m.g).attrs({alignCenter:!0,gap:"xsmall",position:"absolute",backgroundColor:"background.primary",borderRadius:"medium"}).withConfig({displayName:"ForecastHeroSectionstyles__EventChip",componentId:"sc-11lf8ve-10"})(["left:","%;top:","%;transform:translate(-50%,-50%);padding:"," "," "," ",";box-shadow:0 3px 6px 0 ",";white-space:nowrap;@media (max-width:","px){"," ","}"],(e=>e.$leftPercent),(e=>e.$topPercent),vt.YK.xxsmall,vt.YK.xsmall,vt.YK.xxsmall,vt.YK.xxsmall,vt.Ee.color.shadow.medium,vt.nm.md,(e=>e.$hideOnMobile&&"display: none;"),(e=>{let t=e.$mobileTopPercent;return void 0!==t&&"top: ".concat(t,"%;")})),iz=u.default.line.withConfig({displayName:"ForecastHeroSectionstyles__ChartAxisLine",componentId:"sc-11lf8ve-11"})(["stroke:",";stroke-width:1;@media (max-width:","px){display:none;}"],vt.Ee.color.chart.axis,vt.nm.md),sz=e=>{let t=e.onCtaClick,n=e.ctaLabel;return a.createElement(a.Fragment,null,a.createElement(JB,null,a.createElement(ez,null,"See how your",a.createElement("br",null),a.createElement("em",null,"future")," plays out"),t&&a.createElement(tz,null,a.createElement(cz,{onCtaClick:t,ctaLabel:n}))),a.createElement(XB,null,a.createElement(az,null,a.createElement(dz,null),jB.map((e=>{let t=e.label,n=e.topPercent;return a.createElement(lz,{key:t,$topPercent:n},t)}
1)),KB.map((e=>{let t=e.label,n=e.leftPercent;return a.createElement(rz,{key:t,$leftPercent:n},t)})),$B.map((e=>{let t=e.label,n=e.color,l=e.icon,r=e.leftPercent,o=e.topPercent,i=e.mobileTopPercent,s=e.mobileVisible;return a.createElement(oz,{key:t,$leftPercent:r,$topPercent:o,$mobileTopPercent:i,$hideOnMobile:!s},a.createElement(OB,{$color:n,$size:20},a.createElement(sl.ZQ,{name:l,size:12})),a.createElement(xt.v,{size:"small",color:"content.secondary"},t))}))),t&&a.createElement(QB,null,a.createElement(cz,{onCtaClick:t,ctaLabel:n}))))},cz=e=>{let t=e.onCtaClick,n=e.ctaLabel;return a.createElement(a.Fragment,null,a.createElement(nz,null,a.createElement(xt.v,{size:"base",color:"content.secondary",align:"center"},"Use your real Monarch data to model life events, then drag and play with scenarios to see exactly how each decision shapes your future.")),a.createElement(cu.WT,{size:"medium",onClick:t},n))},dz=()=>a.createElement("svg",{"data-external-id":"forecast-hero-chart",viewBox:"0 0 951 380",width:"100%",height:"100%",preserveAspectRatio:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true"},a.createElement("defs",null,a.createElement("linearGradient",{id:qB,x1:"52",y1:"180",x2:"951",y2:"180",gradientUnits:"userSpaceOnUse"},a.createElement(zB,null),a.createElement(FB,{offset:"1"}))),a.createElement(iz,{x1:46,y1:350,x2:951,y2:350}),$B.map((e=>{let t=e.svgX,n=e.color,l=e.mobileVisible,r=e.topPercent,o=e.mobileTopPercent;return a.createElement(PB,{key:t,$color:n,$hideOnMobile:!l||void 0!==o,x1:t,y1:r/100*380,x2:t,y2:350})})),$B.filter((e=>{let t=e.mobileTopPercent,n=e.mobileVisible;return void 0!==t&&n})).map((e=>{let t=e.svgX,n=e.color,l=e.mobileTopPercent;return a.createElement(PB,{key:"mobile-".concat(t),$color:n,$showOnlyOnMobile:!0,x1:t,y1:l/100*380,x2:t,y2:350})})),a.createElement(BB,{d:"M 46,335 C 92,330 148,312 225,280 C 302,247 372,237 461,241 C 540,241 600,241 649,233 C 711,223 769,177 769,177 C 769,177 856,102 879,15 C 917,-3 943,22 951,22",stroke:"url(#".concat(qB,")"),strokeDasharray:"6 6",strokeLinecap:"round",strokeLinejoin:"round",strokeOpacity:.75})),uz=e=>{let t=e.onCtaClick,n=e.ctaLabel,l=void 0===n?"Try Forecasting":n;return a.createElement(m.g,{"data-external-id":"forecast-landing-screen",column:!0,gap:"gutter"},a.createElement(ZB,null,a.createElement(sz,{onCtaClick:t,ctaLabel:l})),a.createElement(GB,null))},mz=e=>{let t=e.onBack,n=e.onNext,l=e.isNextDisabled,r=e.isBackDisabled,o=e.backLabel;return a.createElement("div",{"data-external-id":"onboarding-navigation",className:"flex w-full justify-between"},a.createElement(wt.Xb,{size:"small",onClick:t,disabled:r},null!==o&&void 0!==o?o:"Go back"),a.createElement(cu.WT,{size:"small",onClick:n,disabled:l},"Continue"))},pz=new Set(["loans","other-liability"]),gz=[{categories:["cash"],label:Zk.cash.label},{categories:["taxable-investments","tax-deferred","tax-free-investments"],label:"Investments"},{categories:["loans","other-liability"],label:Zk.loans.label},{categories:["credit-cards"],label:Zk["credit-cards"].label,hint:"Only include credit cards that aren't paid in full every month."},{categories:["real-estate","other"],label:"Real Estate & Other",hint:"Only include items you'd sell to pay for living expenses in retirement."}],hz=e=>{var t;let n=e.account,l=e.onToggle;const r=Wh(n.accountType),o=Math.abs(n.balance),i=pz.has(r)?"Loan balance":"Account balance",s=(0,rl.Ig)(o);return a.createElement(fe.xz6.Content,{"data-external-id":"account-row",className:"flex-row items-center justify-between gap-default px-xl py-lg"},a.createElement("div",{className:"flex min-w-0 flex-row items-center gap-sm"},a.createElement(Gl.v,{logoUrl:null===(t=n.metadata)||void 0===t?void 0:t.logoUrl,size:40}),a.createElement("div",{className:"flex min-w-0 flex-col gap-0.5"},a.createElement(xt.v,{size:"large",className:"truncate",title:n.name},n.name),a.createElement(xt.v,{color:"content.secondary",size:"small"},i,": ",s))),a.createElement(ox.k,{checked:n.isIncluded,onChange:l}))},vz=e=>{let t=e.emoji,n=e.value,l=e.description;return a.createElement(m.g,{"data-external-id":"assumption-item",gap:"xsmall",alignStart:!0},a.createElement(xt.v,null,t),a.createElement(m.g,{column:!0,gap:"xxsmall",flex:1},a.createElement(xt.v,{color:"content.primary"},n),a.createElement(xt.v,{color:"content.secondary",size:"small"},l)))};var fz=n(16009);const Ez=e=>{var t,n;let l=e.participant,r=e.index,o=e.totalCount,i=e.onHiddenFromForecastChange,s=e.onBirthdaySubmit;
1const c=l.displayName||"Member",d=l.birthday?(0,Ba.X)(l.birthday):null,u=0===r,m=r===o-1,p=1===o;return a.createElement("div",{"data-external-id":"participant-row",className:(0,q.cn)("flex flex-col overflow-hidden",u&&"rounded-t-default",m&&"rounded-b-default")},a.createElement("div",{className:"flex items-center justify-between gap-xs bg-background-primary p-default"},a.createElement("div",{className:"flex flex-1 items-center gap-default"},!p&&i&&a.createElement("div",{className:"flex items-center"},a.createElement(fz.hm,{size:16,className:"[&_svg]:size-3",checked:!l.hiddenFromForecast,onChange:e=>i(l.userId,!e.target.checked),"aria-label":"".concat(c," ").concat(l.hiddenFromForecast?"excluded from":"included in"," forecast")})),a.createElement("div",{className:(0,q.cn)("flex items-center gap-xs transition-opacity",l.hiddenFromForecast?"opacity-50":void 0)},a.createElement(Pw.n,{userId:l.userId,userName:c,userProfilePictureUrl:l.profilePictureUrl,avatarSize:24,showLabel:!1}),a.createElement(xt.v,{weight:"medium"},c))),a.createElement("div",{className:(0,q.cn)("flex items-center transition-opacity",l.hiddenFromForecast?"invisible opacity-0":"visible opacity-100")},null!==d?a.createElement(xt.v,{weight:"medium"},"Age ",d):a.createElement("div",{className:"flex items-center gap-2xs"},a.createElement(xt.v,{color:"content.warning"},a.createElement(sl.ZQ,{name:"alert-triangle"})),a.createElement(xt.v,{color:"content.warning",weight:"medium"},"Birthday required")))),a.createElement(Ql.$,{open:!l.hiddenFromForecast,shouldAnimateOnMount:!1},a.createElement("div",{className:"flex w-full pr-default pb-default pl-3xl"},a.createElement(Eu.lV,{initialValues:{birthday:null!==(t=l.birthday)&&void 0!==t?t:null},onSubmit:s,submitOnChange:!0,submitOnChangeDebounceMs:350,className:"w-full"},a.createElement(tC.zB.Date,{name:"birthday",label:"Birthday",dateFormat:iC.yP,allowPlainLanguage:!0,min:aC,max:null!==(n=N.c9.now().toISODate())&&void 0!==n?n:void 0})))))},yz=()=>a.createElement(fe.xz6,{"data-external-id":"scenario-name-and-icon-card",className:"z-1 w-full overflow-visible border border-border-primary"},a.createElement(fe.xz6.Content,{className:"gap-sm p-default pt-sm"},a.createElement(fe.c8D,{weight:"medium"},"Scenario name and icon"),a.createElement(wA,{autoFocus:!0}))),bz=()=>{const e=KE(),t=wE((e=>e.presetAmounts)),n=wE((e=>e.settings.participants));return{accounts:(0,a.useMemo)((()=>e.map((e=>({balance:e.balance})))),[e]),participants:n,baselineAmounts:t}},xz=e=>{const t=Math.abs(e);return(0,rl.Ig)(t)},wz=e=>"".concat(hg.defaultName," (").concat(e,")"),Cz=e=>{var t;let n=e.source,l=e.participants,r=e.onChange,i=e.onRemove;const s=(0,a.useMemo)((()=>l.map((e=>{var t;return{value:e.userId,label:null!==(t=e.displayName)&&void 0!==t?t:"Member"}}))),[l]),c=(0,a.useMemo)((()=>{var e;return null!==(e=s.find((e=>e.value===n.ownerId)))&&void 0!==e?e:null}),[s,n.ownerId]),d=(0,a.useState)(n.amount),u=(0,o.A)(d,2),m=u[0],p=u[1];(0,bu.w)((()=>p(n.amount)),[n.amount]);const g=(0,a.useCallback)((()=>{null===m&&p(n.amount)}),[m,n.amount]);return a.createElement(fe.xz6,{"data-external-id":"income-source-card",className:"rounded-sm border border-border-primary"},a.createElement(fe.xz6.Content,{className:"flex-col gap-xl p-default"},a.createElement("div",{className:"flex flex-col gap-xs"},a.createElement(xt.v,{size:"small",weight:"medium",color:"content.primary"},"Name and icon"),a.createElement("div",{className:"flex items-center gap-sm"},a.createElement(Wl._,{url:null,size:36}),a.createElement("div",{className:"flex-1"},a.createElement(Ry.X,{className:"w-full",name:"income-source-name",value:n.name,onChange:e=>r({name:e.target.value}),placeholder:c?wz(c.label):"Income source name"})))),l.length>1&&a.createElement("div",{className:"flex flex-col gap-xs"},a.createElement(xt.v,{size:"small",weight:"medium",color:"content.primary"},"Owner"),a.createElement(fe.hGA,{size:"sm",value:null!==(t=null===c||void 0===c?void 0:c.value)&&void 0!==t?t:null,options:s,placeholder:"Select owner",onValueChange:e=>{r({ownerId:e})}})),a.createElement("div",{className:"flex flex-col gap-xs"},a.createElement(xt.v,{size:"small",weight:"medium",color:"content.primary"},_t.Et.ASSUMPTIONS.YEARLY_TAKE_HOME_INCOME_LABEL),a.createElement(fe.K$5,{name:"income-amount-".concat(n.id),value:m,onValueChange:e=>{p(e),null!==e&&r({amount:e})},onBlur:g,precision:0,onFocus:(0,ix.s)(n.amount)}),a.createElement(xt.v,{size:"small",color:"content.secondary"},_t.Et.ASSUMPTIONS.YEARLY_TAKE_HOME_INCOME_HELPER_TEXT)),i&&a.createElement("div",{className:"flex justify-end"},a.createElement(bn.v,{className:"text-content-danger",onClick:i},"Remove"))))},Az=e=>{var t,n;let l=e.account,r=e.onContributionChange;const i=null!==(t=l.yearlyPaycheckContribution)&&void 0!==t?t:0,s=(0,a.useState)(i),c=(0,o.A)(s,2),d=c[0],u=c[1];(0,bu.w)((()=>u(i)),[i]);const m=(0,a.useCallback)((()=>{null===d&&u(i)}),[d,i]),p=Math.abs(l.balance),g=(0,rl.Ig)(p);return a.createElement(fe.xz6,{"data-external-id":"paycheck-contribution-card",className:"border border-border-primary"},a.createElement(fe.xz6.Content,{className:"flex-col gap-default px-xl py-lg"},a.createElement("div",{className:"flex flex-row items-start gap-sm"},a.createElement(Gl.v,{logoUrl:null===(n=l.metadata)||void 0===n?void 0:n.logoUrl,
1size:40}),a.createElement("div",{className:"flex min-w-0 flex-1 flex-col gap-0.5"},a.createElement(xt.v,{size:"large",className:"truncate",title:l.name},l.name),a.createElement(xt.v,{color:"content.secondary",size:"small"},"Account balance: ",g))),a.createElement("div",{className:"flex flex-col gap-xs"},a.createElement(xt.v,{as:"label",htmlFor:"yearly-contribution-".concat(l.id),size:"small",weight:"medium"},"Yearly paycheck contribution"),a.createElement(fe.K$5,{value:d,min:0,format:{maximumFractionDigits:0},onValueChange:e=>{u(e),null!==e&&r(e)},onBlur:m,id:"yearly-contribution-".concat(l.id),name:"yearlyPaycheckContribution-".concat(l.id),onFocus:(0,ix.s)(l.yearlyPaycheckContribution)}),a.createElement(xt.v,{color:"content.secondary",size:"small"},_t.Et.ASSUMPTIONS.YEARLY_PAYCHECK_CONTRIBUTION_DESCRIPTION," ",a.createElement(Bb,{href:ih},"Learn more")))))},Iz=e=>{let t=e.className,n=e.onNext,l=e.onBack;const r=KE(),o=wE((e=>e.updateAccount)),i=(0,a.useMemo)((()=>r.filter(Uh)),[r]);return 0===i.length?a.createElement("div",{"data-external-id":"paycheck-contributions",className:(0,q.cn)("mx-auto flex max-w-125 flex-col gap-xl",t)},a.createElement(mz,{onBack:l,onNext:n})):a.createElement("div",{"data-external-id":"paycheck-contributions",className:(0,q.cn)("mx-auto flex max-w-125 flex-col gap-xl",t)},a.createElement("div",{className:"flex flex-col items-center gap-default"},a.createElement(xt.v,{as:"h1",color:"content.primary",size:"xlarge",weight:"medium",className:"m-0"},"Set up account contributions"),a.createElement(xt.v,{color:"content.secondary",size:"small",weight:"book",align:"center",className:"max-w-100"},"If you make contributions to these accounts via payroll deductions, enter the yearly totals in today's dollars here."," ",a.createElement(Bb,{href:ih},"Learn more"))),a.createElement("div",{className:"flex w-full flex-col gap-default"},i.map((e=>a.createElement(Az,{key:e.id,account:e,onContributionChange:t=>o(e.id,{yearlyPaycheckContribution:null!==t&&void 0!==t?t:0})})))),a.createElement(fu.g,{type:"info"},a.createElement(xt.v,{size:"small"},"After initial setup, you can add contributions made from take-home dollars in the"," ",a.createElement(Bb,{stealthy:!0,className:"font-medium hover:text-content-info-hover",href:rh},"Savings Splits")," ","panel.")),a.createElement(mz,{onBack:l,onNext:n}))},kz=e=>{let t=e.participant,n=e.event,l=e.minYear,r=e.maxYear,o=e.onYearChange;const i=t.displayName||"Member";return a.createElement(fe.xz6,{"data-external-id":"participant-retirement-card",className:"border border-border-primary"},a.createElement(fe.xz6.Content,{className:"flex-col gap-sm p-default"},a.createElement("div",{className:"flex items-center gap-default"},a.createElement("div",{className:"flex min-w-0 flex-1 items-center gap-sm"},a.createElement(Pw.n,{userId:t.userId,userName:i,userProfilePictureUrl:t.profilePictureUrl,avatarSize:24,showLabel:!1}),a.createElement(xt.v,{weight:"medium",className:"truncate"},i)),a.createElement("div",{className:"w-40"},a.createElement(bb,{value:n.startYear,onChange:o,birthday:t.birthday,minYear:l,maxYear:r}))),a.createElement(wy,{value:n.startYear,onChange:e=>{null!==e&&o(e)},min:l,max:r,step:1},a.createElement(Iy,null))))};var Sz,Nz,Tz,_z,Dz,Rz,Mz,Lz=n(28672);const Oz=70,Pz=15,Bz=35,zz=()=>a.createElement(Hz,{"data-external-id":"life-events-illustration",className:"bg-(--orange-2)"},a.createElement(Kz,null,bB.slice(0,2).map((e=>{let t=e.title,n=e.subtitle,l=e.color,r=e.icon;return a.createElement(qz,{key:t},a.createElement(Yz,{color:l,size:30},a.createElement(sl.ZQ,{name:r,size:20})),a.createElement("div",{className:"flex min-w-0 flex-col"},a.createElement(xt.v,{size:"small",weight:"medium",color:"content.primary",clampLines:1},t),a.createElement(xt.v,{size:"xsmall",color:"content.secondary",clampLines:1},n)))})))),Fz=()=>a.createElement(Hz,{"data-external-id":"chart-illustration",className:"bg-(--pink-2)"},a.createElement("div",{className:"absolute inset-0"},a.createElement("svg",{viewBox:"0 0 ".concat(320," ").concat(126),preserveAspectRatio:"none","aria-hidden":"true",className:"absolute inset-0 size-full"},a.createElement("defs",null,a.createElement("linearGradient",{id:"wrapup-label-gradient",x1:69.59,y1:"0",x2:184.59,y2:"0",gradientUnits:"userSpaceOnUse"},a.createElement("stop",{stopColor:"var(--blue-3)",stopOpacity:.8,offset:"0"}),a.createElement("stop",{stopColor:"var(--blue-3)",stopOpacity:0,offset:"1"})),a.createElement("linearGradient",{id:"wrapup-separator-gradient",x1:81.59,y1:"0",x2:183.59,y2:"0",gradientUnits:"userSpaceOnUse"},a.createElement("stop",{stopColor:"var(--color-background-primary)",stopOpacity:.8,offset:"0"}),a.createElement("stop",{stopColor:"var(--color-background-primary)",stopOpacity:0,offset:"1"})),a.createElement("linearGradient",{id:"wrapup-separator-border-gradient",x1:81.59,y1:"0",x2:183.59,y2:"0",gradientUnits:"userSpaceOnUse"},a.createElement("stop",{stopColor:"rgba(0,0,0,0.1)",offset:"0"}),a.createElement("stop",{stopColor:"rgba(0,0,0,0)",offset:"0.6"}))),a.createElement("g",{transform:"translate(-6.24, 45.5)"},a.createElement("path",{d:"M328.336 0C164.836 0 174.836 61.5 6.24444 67.5C-7.80554 68 6.24444 103.5 6.24444 103.5H352.745L328.336 0Z",fill:"var(--color-background-primary)",fillOpacity:.6})),a.createElement("line",{stroke:"var(--color-chart-event-background-blue)",strokeWidth:"1",x1:Oz,y1:Bz,x2:Oz,y2:126}),a.createElement("rect",{x:69.59,y:15,width:115,height:14,rx:5,fill:"url(#wrapup-label-gradient)"}),a.createElement("line",{x1:81.59,y1:29,x2:183.59,y2:29,stroke:"url
1(#wrapup-separator-border-gradient)",strokeWidth:"1"}),a.createElement("line",{x1:81.59,y1:39.5,x2:183.59,y2:39.5,stroke:"url(#wrapup-separator-border-gradient)",strokeWidth:"1"}),a.createElement("rect",{x:81.59,y:29,width:102,height:10.5,fill:"url(#wrapup-separator-gradient)"}),a.createElement("g",{transform:"translate(-1.05, 44.5)"},a.createElement("path",{d:"M1.50002 69.5C178.637 63.5 145.637 7.50002 324.638 1.50002",fill:"none",stroke:"var(--orange-7)",strokeWidth:"3",strokeDasharray:"6 6",strokeLinecap:"round"}))),a.createElement("div",{style:{position:"absolute",top:"".concat(Pz/126*100,"%"),left:"".concat(Oz/320*100,"%"),transform:"translateX(-50%)"}},a.createElement(Yz,{color:"blue",size:24},a.createElement(sl.ZQ,{name:"home",size:16}))),a.createElement("div",{style:{position:"absolute",top:17,left:"".concat(22.059375,"%"),width:24,height:24}},a.createElement("div",{style:{position:"absolute",top:"25%",bottom:"22.55%",left:"20.83%",right:"22.97%",filter:"drop-shadow(-0.2px 1px 1.5px rgba(0,0,0,0.5))"}},a.createElement("svg",{viewBox:"0 0 13.4863 12.588",width:"100%",height:"100%","aria-hidden":"true",preserveAspectRatio:"none"},a.createElement("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M12.9691 2.144C12.6171 1.887 12.2251 1.787 11.7921 1.846C11.5841 1.874 11.4121 1.935 11.2691 2.02C11.2741 1.861 11.2621 1.71 11.2261 1.568C11.1511 1.271 11.0111 1.027 10.8061 0.835C10.6011 0.643 10.3551 0.505 10.0681 0.42C9.80814 0.342 9.54314 0.319 9.27314 0.352C9.00214 0.385 8.76015 0.477 8.54515 0.63C8.47515 0.68 8.42314 0.744 8.36714 0.805C8.32814 0.736 8.29214 0.665 8.23714 0.601C8.07114 0.409 7.86014 0.261001 7.60314 0.157001C7.34614 0.0530005 7.07314 0 6.78714 0C6.49414 0 6.21814 0.0530005 5.96214 0.157001C5.70514 0.261001 5.49314 0.409 5.32714 0.601C5.27314 0.663 5.23914 0.733001 5.19914 0.801001C5.16214 0.759001 5.13114 0.711001 5.08814 0.674001C4.91214 0.524001 4.70514 0.422 4.46714 0.366C4.23014 0.311 3.99114 0.303 3.75014 0.342C3.44414 0.387 3.16914 0.502 2.92414 0.684C2.68014 0.866 2.50014 1.112 2.38214 1.421C2.27314 1.71 2.26014 2.052 2.32714 2.435C1.75714 2.365 1.22714 2.531 0.742144 2.944C0.241144 3.371 -0.00685588 4.043 0.000144123 4.961C0.00614412 6.445 0.288144 7.763 0.844144 8.916C1.40114 10.068 2.18414 10.969 3.19314 11.616C4.20214 12.264 5.37114 12.588 6.69914 12.588C7.91014 12.588 8.94514 12.375 9.80514 11.948C10.6641 11.522 11.3601 10.905 11.8901 10.097C12.4201 9.291 12.8061 8.291 13.0471 7.099C13.1771 6.469 13.2791 5.849 13.3551 5.244C13.4301 4.638 13.4741 3.998 13.4861 3.32C13.4931 2.793 13.3201 2.401 12.9691 2.144Z",fill:"black"}),a.createElement("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M2.51344 3.5051L2.75944 4.7751C2.80544 5.0161 2.92544 5.1701 3.12044 5.2341C3.31644 5.3001 3.49344 5.2681 3.65344 5.1411C3.81244 5.0141 3.86644 4.8341 3.81444 4.5991L3.30644 2.1681C3.24744 1.9141 3.32144 1.7091 3.52644 1.5531C3.73144 1.3971 3.95844 1.3381 4.20944 1.3771C4.46044 1.4161 4.62144 1.5631 4.69344 1.8171L4.83944 2.3441C4.89144 2.5461 5.01344 2.6731 5.20544 2.7251C5.39844 2.7771 5.58144 2.7541 5.75744 2.6571C5.93344 2.5591 6.02144 2.4161 6.02144 2.2271V1.5531C6.02144 1.3771 6.09444 1.2361 6.24144 1.1281C6.38744 1.0211 6.56544 0.9671 6.77344 0.9671C6.97544 0.9671 7.14944 1.0211 7.29644 1.1281C7.44244 1.2361 7.51544 1.3771 7.51544 1.5531V2.2271C7.51544 2.4091 7.60344 2.5511 7.77944 2.6521C7.95544 2.7531 8.13844 2.7771 8.33144 2.7251C8.52344 2.6731 8.64544 2.5461 8.69744 2.3441L8.85345 1.7971C8.91945 1.5561 9.07544 1.4161 9.32244 1.3771C9.56944 1.3381 9.79644 1.3971 10.0014 1.5531C10.2064 1.7091 10.2824 1.9141 10.2304 2.1681L10.0744 3.0471C10.0284 3.2811 10.0744 3.4641 10.2114 3.5941C10.3474 3.7241 10.5134 3.7861 10.7094 3.7791C10.9044 3.7731 11.0514 3.7011 11.1484 3.5641L11.4024 3.1541C11.4934 3.0171 11.6294 2.9381 11.8074 2.9151C11.9864 2.8921 12.1474 2.9291 12.2914 3.0271C12.4344 3.1251 12.5064 3.2651 12.5064 3.4471C12.5064 3.9881 12.4674 4.5061 12.3884 5.0001C12.3104 5.4951 12.1964 6.0641 12.0474 6.7091L11.9884 6.9821C11.7614 7.9981 11.4344 8.8351 11.0124 9.4921C10.5894 10.1501 10.0274 10.6461 9.32744 10.9811C8.62744 11.3171 7.76244 11.4841 6.73444 11.4841C5.59444 11.4841 4.59544 11.2051 3.73644 10.6441C2.87644 10.0851 2.21544 9.3051 1.75344 8.3051C1.29144 7.3061 1.06044 6.1691 1.06044 4.8921C1.06044 4.4371 1.15944 4.0871 1.35844 3.8431C1.55644 3.5981 1.79444 3.4661 2.07144 3.4421C2.23444 3.4291 2.37844 3.4561 2.51344 3.5051Z",fill:"white"})))))),Gz=()=>a.createElement(Hz,{"data-external-id":"assumptions-illustration",className:"bg-(--blue-2)"},a.createElement("div",{className:" absolute top-1/2 left-1/2 flex -translate-1/2 flex-col gap-2xs rounded-lg border border-border-primary bg-background-primary px-default py-2xs shadow-md ",style:{width:"".concat(85,"%")}},a.createElement("div",{className:"flex items-center gap-sm"},a.createElement(xt.v,{size:"small",weight:"medium",color:"content.primary",className:"flex-1"},"Inflation rate"),a.createElement($z,null,a.createElement("div",{className:" absolute inset-y-0 left-0 rounded-full bg-linear-to-r from-background-gradient-orange to-(--yellow-6) to-[198.65%] ",style:{width:"".concat(32.5,"%")}})),a.createElement(xt.v,{size:"20",weight:"medium",color:"content.primary"},"3%")),a.createElement("div",{className:"flex items-center gap-sm"},a.createElement(xt.v,{size:"small",weight:"medium",color:"content.primary",className:"flex-1"},"Growth rate"),a.createElement($z,null,a.createElement("div",{className:" absolute inset-y-0 left-0 rounded-full bg-linear-to-r from-(--indigo-11) to-(--indigo-6) to-[198.65%] ",style:{width:"".concat(72.5,"%")}})),a.createElement(xt.v,{size:"20",weight:"medium",color:"content.primary"},"7%")),a.createElement("div",{className:"flex h-7.5 items-center gap-sm"},a.createElement(xt.v,{size:"small",weight:"medium",color:"content.primary",className:"flex-1"},"Withdraw during retirement"),a.createElement("div",{className:" flex size-4 shrink-0 items-center justify-center rounded-sm bg-(--green-8) text-content-white "},a.createElement(sl.ZQ,{name:"check",size:12}))))),Yz=e=>{let t=e.color,n=e.size,l=e.children;return a.createElement("div",{"data-external-id":"event-icon",className:Uz({color:t}),style:{width:n,height:n}},l)},Uz=(0,Lz.tv)({base:"flex shrink-0 items-center justify-center rounded-md",variants:{color:Object.fromEntries(Object.keys(Vg).map((e=>[e,"".concat(Vg[e]," ").concat(Wg[e])])))}}),Vz=(0,$d.s)(fe.xz6)(Sz||(Sz=(0,wc.A)(["rounded-lg border border-border-primary"]))),Wz=(0,$d.s)(fe.xz6.Content)(Nz||(Nz=(0,wc.A)(["flex-row items-center gap-default p-default"]))),jz=$d.s.div(Tz||(Tz=(0,wc.A)(["flex flex-1 flex-col gap-default"]))),Hz=$d.s.div(_z||(_z=(0,wc.A)(["relative h-31.5 flex-1 overflow-hidden rounded-lg"]))),Kz=$d.s.div(Dz||(Dz=(0,wc.A)(["\n  absolute bottom-0 left-1/2 w-[87%] -translate-x-1/2 overflow-hidden rounded-t-lg\n"]))),qz=$d.s.div(Rz||(Rz=(0,wc.A)(["\n  flex items-center gap-sm border border-b-0 border-border-primary bg-background-primary px-sm\n  py-xs\n  first:rounded-t-lg\n"]))),$z=$d.s.div(Mz||(Mz=(0,wc.A)(["relative h-1.5 w-20 shrink-0 rounded-full bg-background-secondary"]))),Zz=e=>{const t=(0,i.n)(Dv.cg),n=(0,o.A)(t,1)[0],l=(0,a.useState)(!1),r=(0,o.A)(l,2),s=r[0],c=r[1],d=(0,a.useState)(null),u=(0,o.A)(d,2),m=u[0],p=u[1],g=wE((e=>e.setIsCompletingOnboarding)),h=(0,a.useCallback)((async t=>{g(!0),c(!0),p(null);try{var a,l;const o=null===(a=(await n({variables:{completedAt:(new Date).toISOString()}})).data)||void 0===a||null===(l=a.updateUserProfile)||void 0===l?void 0:l.errors;var r;if(o)throw new Error(null!==(r=o.message)&&void 0!==r?r:"Failed to complete onboarding");t(),e(),(0,Ge.u4)(Ye.yq.OnboardingCompleted,(0,U.A)({},zf()))}catch(o){p(o instanceof Error?o:new Error("Unknown error"))}finally{g(!1),c(!1)}}),[n,e,g]);return{completeOnboarding:h,loading:s,error:m}},Jz=300,Xz=300,Qz=30,eF=200;var tF;!function(e){e[e.Forward=1]="Forward",e[e.Backward=-1]="Backward"}(tF||(tF={}));const nF={enter:e=>({x:e===tF.Forward?Jz:-Jz,opacity:0}
1),center:{x:0,opacity:1},exit:e=>({x:e===tF.Forward?-Jz:Jz,opacity:0})},aF={x:{type:"spring",stiffness:Xz,damping:Qz},opacity:{duration:eF/1e3}},lF="data-slide-content-key",rF=e=>{let t=e.itemKey,n=e.direction,l=e.children,r=e.onAnimationStart,o=e.className;return a.createElement(oF,{"data-external-id":"slide",className:o},a.createElement(T.N,{initial:!1,custom:n},a.createElement(iF,{key:t,custom:n,variants:nF,initial:"enter",animate:"center",exit:"exit",transition:aF,onAnimationStart:r},a.createElement(sF,{[lF]:t},l))))},oF=u.default.div.withConfig({displayName:"Slide__AnimationWrapper",componentId:"tsh58z-0"})(["display:grid;width:100%;"]),iF=(0,u.default)(D.PY1.div).withConfig({displayName:"Slide__AnimatedContent",componentId:"tsh58z-1"})(["grid-area:1 / 1;width:100%;"]),sF=u.default.div.withConfig({displayName:"Slide__ContentWrapper",componentId:"tsh58z-2"})(["width:100%;"]);var cF,dF,uF;const mF=["height","style","className"],pF=[{step:e=>{let t=e.className,n=e.onNext,r=e.onBack;const i=(e=>(0,a.useMemo)((()=>({isCreating:"review"!==e,isCreateFromScratch:"create-from-scratch"===e})),[e]))(e.mode),s=i.isCreating,c=i.isCreateFromScratch,d=bz(),u=d.accounts,p=d.participants,g=d.baselineAmounts,h=BE(),v=vy().toggleAssumptions,f=(e=>{let t=e.isCreateFromScratch,n=e.onBack;const r=(0,l.Zp)(),o=(0,l.zy)(),i=(0,l.g)().scenarioId,s=void 0===i?"":i,c=mA(),d=c.deleteScenario,u=c.loading,m=Qx().scenarios,p=o.state,g=null===p||void 0===p?void 0:p.returnTo,h=(0,a.useCallback)((()=>{const e=IC(o.search);null!==g&&void 0!==g&&g.scenarioId?r({pathname:qx(g),search:e},{replace:!0}):r({pathname:"".concat(I.su,"/accounts"),search:e},{replace:!0})}),[r,o.search,g]);return{handleBack:(0,a.useCallback)((async()=>{if(t){if(s){var e;const t=m.find((e=>e.id===s));await d({scenarioExternalId:s,deletedScenarioOrder:null!==(e=null===t||void 0===t?void 0:t.order)&&void 0!==e?e:0,scenarioCountBeforeDelete:m.length,silent:!0,skipNavigation:!0})}h()}else n()}),[s,d,t,h,n,m]),isDeletingScenario:u,backLabel:t?"Cancel":void 0}})({isCreateFromScratch:c,onBack:r}),E=f.handleBack,y=f.isDeletingScenario,b=f.backLabel,x=(e=>{let t=e.onNext;const n=wE((e=>e.updateParticipant)),l=wE((e=>e.initializeOnboardingEvents)),r=(0,Dv.m9)(),i=(0,o.A)(r,1)[0],s=(0,a.useCallback)(((e,t)=>{n(e,{hiddenFromForecast:t})}),[n]),c=(0,a.useCallback)((e=>async t=>{var a,l;await i({variables:{input:(0,Dv.Ml)(e.userId,null!==(a=t.birthday)&&void 0!==a?a:null)}}),n(e.userId,{birthday:null!==(l=t.birthday)&&void 0!==l?l:void 0})}),[n,i]);return{handleHiddenFromForecastChange:s,handleBirthdaySubmit:c,handleNext:(0,a.useCallback)((()=>{l(),t()}),[l,t])}})({onNext:n}),w=x.handleHiddenFromForecastChange,C=x.handleBirthdaySubmit,A=x.handleNext,k=(e=>(0,a.useMemo)((()=>({totalAssets:e.filter((e=>e.balance>0)).reduce(((e,t)=>e+t.balance),0),totalLiabilities:e.filter((e=>e.balance<0)).reduce(((e,t)=>e+Math.abs(t.balance)),0)})),[e]))(u),S=k.totalAssets,N=k.totalLiabilities,T=(e=>{let t=e.isCreateFromScratch,n=e.scenarioName,l=e.participants,r=e.isDeletingScenario;return(0,a.useMemo)((()=>(e=>{let t=e.isDeletingScenario,n=e.isCreateFromScratch,a=e.scenarioName,l=e.participants;const r=n&&0===a.trim().length,o=l.some((e=>!e.hiddenFromForecast&&!e.birthday)),i=l.length>=1&&l.every((e=>e.hiddenFromForecast));return t||r||o||i})({isDeletingScenario:r,isCreateFromScratch:t,scenarioName:n,participants:l})),[t,n,l,r])})({isCreateFromScratch:c,scenarioName:h.name,participants:p,isDeletingScenario:y});return a.createElement("div",{"data-external-id":"baseline-info",className:(0,q.cn)("mx-auto flex max-w-125 flex-1 flex-col items-center",t)},a.createElement(m.g,{column:!0,gap:"xlarge",flex:1,alignCenter:!0},a.createElement(m.g,{column:!0,gap:"xsmall",alignCenter:!0},a.createElement(xt.v,{as:"h1",color:"content.primary",size:"xlarge",weight:"medium",className:"m-0"},s?"Confirm your information":"Review your household's forecast"),a.createElement(xt.v,{color:"content.secondary",size:"small",weight:"book",align:"center",className:"max-w-100"},s?a.createElement(a.Fragment,null,"Your age data will be used to forecast important milestones around retirement, Social Security, and end of life."):a.createElement(a.Fragment,null,"Your household already has a forecast set up. Review the settings below and make any adjustments.")," ",a.createElement(Bb,{href:"https://www.monarch.c
1om/blog/forecasting#general-inputs-586ded21b012"},"Learn more"))),c&&a.createElement(yz,null),a.createElement(fe.xz6,{className:"z-1 w-full overflow-visible border border-border-primary"},a.createElement(fe.xz6.Content,{className:"p-0"},a.createElement("div",{className:"flex flex-col [&>*:not(:last-child)]:border-b [&>*:not(:last-child)]:border-divider-primary"},p.map(((e,t)=>a.createElement(Ez,{key:e.userId,participant:e,index:t,totalCount:p.length,onHiddenFromForecastChange:w,onBirthdaySubmit:C(e)})))))),a.createElement(fe.xz6,{className:"w-full border border-border-primary"},a.createElement(fe.xz6.Content,{className:"gap-sm p-default"},a.createElement(xt.v,{weight:"medium"},"Assumptions"),void 0!==g&&a.createElement(a.Fragment,null,a.createElement(vz,{emoji:"\ud83e\udd11",value:"".concat(xz(g.annualIncome)," take-home income per year"),description:"Based on your combined average income from the last 12 months."}),a.createElement(vz,{emoji:"\ud83d\udcb3",value:"".concat(xz(g.annualExpenses)," living expenses per year"),description:"Based on your average expenses from the last 12 months."})),a.createElement(vz,{emoji:"\ud83d\udcc8",value:"".concat(xz(S)," in assets"),description:a.createElement(a.Fragment,null,"In your linked accounts. If this seems off, you can"," ",a.createElement(Vl.W,{to:I.JZ.accounts.addAccount()},"add accounts"),".")}),a.createElement(vz,{emoji:"\ud83d\udcc9",value:"".concat(xz(N)," in liabilities"),description:a.createElement(a.Fragment,null,"In your linked accounts. If this seems off, you can"," ",a.createElement(Vl.W,{to:I.JZ.accounts.addAccount()},"add accounts"),".")}),a.createElement(fu.g,{type:"info"},a.createElement(xt.v,{size:"small",className:"flex flex-col"},"Your forecast uses rounded numbers to avoid false precision."," ",a.createElement(Bb,{stealthy:!0,className:"font-medium hover:text-content-info-hover",href:"https://www.monarch.c
1om/blog/forecasting#what-is-false-precision-vs-directionally-correct-3e81d81891c2"},"Learn more"))),a.createElement(m.g,{center:!0},a.createElement(bn.v,{className:"font-book text-content-secondary hover:text-content-primary",onClick:v},"Edit assumptions")))),a.createElement(mz,{onBack:E,onNext:A,backLabel:b,isBackDisabled:y,isNextDisabled:T})))},page:"confirm_info"},{step:e=>{let t=e.className,n=e.onNext,l=e.onBack;const r=bz(),o=r.participants,i=r.baselineAmounts,s=(0,a.useMemo)((()=>o.filter((e=>!e.hiddenFromForecast))),[o]),c=ZE(),d=wE((e=>e.updateEvent)),u=wE((e=>e.removeEvent)),m=wE((e=>e.createEventOfType)),p=(0,a.useCallback)(((e,t)=>d(e,t)),[d]),g=(0,a.useCallback)((()=>m("income",{isHidden:!0,startYear:null,name:"",amount:0})),[m]),h=(0,a.useCallback)((e=>u(e)),[u]),v=qE(),f=(0,a.useCallback)((()=>{c.forEach((e=>{if(!e.name){const t=s.find((t=>t.userId===e.ownerId)),n=t?wz(t.displayName):hg.defaultName;d(e.id,{name:n})}})),s.forEach((e=>{const t=v.find((t=>"retirement"===t.eventKind&&t.ownerId===e.userId));if(!t)return;const n=c.filter((t=>!1!==t.isIncluded&&(t.ownerId===e.userId||null===t.ownerId||void 0===t.ownerId)));d(t.id,{incomeReductionTargets:n.map((e=>({targetEventId:e.id,reductionPercent:100})))})})),n()}),[c,s,d,n,v]);return a.createElement("div",{"data-external-id":"income-sources",className:(0,q.cn)("mx-auto flex max-w-125 flex-col gap-xl",t)},a.createElement("div",{className:"flex flex-col items-center gap-default"},a.createElement(xt.v,{as:"h1",color:"content.primary",size:"xlarge",weight:"medium",className:"m-0"},"Add take-home income"),a.createElement(xt.v,{color:"content.secondary",size:"small",weight:"book",align:"center"},"Your forecast will project how your income, expenses, and savings change over time. If your income is variable, a rough estimate is fine."," ",a.createElement(Bb,{href:"https://www.monarch.c
1om/blog/forecasting#current-income-sources-7d4c9a614ae7"},"Learn more"))),a.createElement("div",{className:"flex flex-col gap-default"},void 0!==i&&a.createElement(fu.g,{type:"info"},a.createElement(xt.v,{size:"small"},"In the last 12 months, your household take-home income was"," ",a.createElement("strong",null,"~",(0,rl.Ig)(Math.abs(i.annualIncome))),".")),a.createElement("div",{className:"flex w-full flex-col gap-default"},c.map((e=>a.createElement(Cz,{key:e.id,source:e,participants:s,onChange:t=>p(e.id,t),onRemove:c.length>1?()=>h(e.id):void 0})))),a.createElement(bn.v,{className:"self-start",onClick:g},"Add another income source")),a.createElement(mz,{onBack:l,onNext:f}))},page:"income_sources"},{step:e=>{let t=e.className,n=e.onNext,l=e.onBack;const r=KE(),o=wE((e=>e.updateAccount)),i=(0,a.useMemo)((()=>gz.map((e=>{const t=r.filter((t=>!t.isSystemAccount&&e.categories.includes(Wh(t.accountType))));return(0,U.A)((0,U.A)({},e),{},{accounts:t})})).filter((e=>e.accounts.length>0))),[r]);return a.createElement("div",{"data-external-id":"account-selection",className:(0,q.cn)("mx-auto flex max-w-125 flex-col gap-xl",t)},a.createElement("div",{className:"flex flex-col items-center gap-default"},a.createElement(xt.v,{as:"h1",color:"content.primary",size:"xlarge",weight:"medium",className:"m-0"},"Choose your forecast accounts"),a.createElement(xt.v,{color:"content.secondary",size:"small",weight:"book",align:"center",className:"max-w-100"},"Select accounts you'll save into, pay down, and draw from during retirement and career breaks. ",a.createElement(Bb,{href:"https://www.monarch.c
1om/blog/forecasting#accounts-65f90c6b8a69"},"Learn more"))),a.createElement("div",{className:"flex w-full flex-col gap-default"},i.map((e=>a.createElement("div",{key:e.label,className:"flex flex-col gap-default"},a.createElement(xt.v,{weight:"medium",size:"large",color:"content.primary"},e.label),e.hint&&a.createElement(fu.g,{type:"info"},a.createElement(xt.v,{size:"small"},e.hint)),a.createElement("div",{className:"flex flex-col gap-default"},e.accounts.map((e=>a.createElement(fe.xz6,{key:e.id,className:"border border-border-primary"},a.createElement(hz,{account:e,onToggle:()=>o(e.id,{isIncluded:!e.isIncluded})}))))))))),a.createElement(mz,{onBack:l,onNext:n}))},page:"account_selection"},{step:Iz,page:"paycheck_contributions"},{step:e=>{let t=e.className,n=e.onNext,l=e.onBack;const r=qE(),o=QE(),i=wE((e=>e.updateEvent)),s=(0,a.useMemo)((()=>o.participants.filter((e=>!e.hiddenFromForecast))),[o.participants]),c=(new Date).getFullYear(),d=o.startYear+o.projectionYears;return a.createElement("div",{"data-external-id":"retirement-settings",className:(0,q.cn)("mx-auto flex max-w-125 flex-col gap-xl",t)},a.createElement("div",{className:"flex flex-col items-center gap-default"},a.createElement(xt.v,{as:"h1",color:"content.primary",size:"xlarge",weight:"medium",className:"m-0"},"Choose a retirement age"),a.createElement(xt.v,{color:"content.secondary",size:"small",weight:"book",align:"center",className:"max-w-100"},"It's okay if you don't know exactly when you plan to retire\u2014your best guess is fine for now, and it's easy to adjust later.")),a.createElement("div",{className:"flex w-full flex-col gap-default"},s.map((e=>{const t=rE(e,r);return t?a.createElement(kz,{key:e.userId,participant:e,event:t,minYear:c,maxYear:d,onYearChange:e=>i(t.id,{startYear:e})}):null}))),a.createElement(mz,{onBack:l,onNext:n}))},page:"retirement_settings"},{step:e=>{let t=e.className,n=e.onNext,l=e.isCompleteOnboardingLoading;return a.createElement("div",{"data-external-id":"wrap-up",className:(0,q.cn)("mx-auto flex flex-1 flex-col items-center",t)},a.createElement("div",{className:"flex flex-col items-center gap-xl"},a.createElement("div",{className:"flex max-w-100 flex-col items-center gap-xs"},a.createElement(xt.v,{color:"content.primary",size:"xlarge",weight:"medium",align:"center"},"You're good to go"),a.createElement("div",{className:"flex flex-col"},a.createElement(xt.v,{color:"content.secondary",size:"small",weight:"book",align:"center"},"Go ahead and explore your baseline forecast."),a.createElement(xt.v,{color:"content.secondary",size:"small",weight:"book",align:"center"},"Add events, play with the timing, and lock in your plan."))),a.createElement("div",{className:"flex max-w-175 min-w-0 flex-col items-stretch gap-default"},a.createElement(Vz,null,a.createElement(Wz,null,a.createElement(jz,null,a.createElement(xt.v,{weight:"medium"},"Add some life events"),a.createElement(xt.v,{size:"small",color:"content.secondary"},"Understand how big decisions affect your long-term picture. Weigh the trade-offs and choose what fits the future you want.")),a.createElement(zz,null))),a.createElement(Vz,null,a.createElement(Wz,null,a.createElement(Fz,null),a.createElement(jz,null,a.createElement(xt.v,{weight:"medium"},"Play with the chart"),a.createElement(xt.v,{size:"small",color:"content.secondary"},"The fastest way to build understanding is through play. You can drag life events around to see how timing affects your plan.")))),a.createElement(Vz,null,a.createElement(Wz,null,a.createElement(jz,null,a.createElement(xt.v,{weight:"medium"},"Edit assumptions"),a.createElement(xt.v,{size:"small",color:"content.secondary"},"Our defaults for growth and interest rates should work for most people\u2014but you can edit the settings for any account.")),a.createElement(Gz,null)))),a.createElement("div",{className:"flex items-center justify-center"},a.createElement(cu.gs,{className:"w-50",size:"small",onClick:n,pending:l},"Go to forecast"))))},page:"ready"}],gF=pF.length,hF=pF.findIndex((e=>e.step===Iz)),vF=e=>{let t=e.mode,n=e.onComplete;const l="create-from-scratch"===t,r=(0,a.useState)((()=>!l)),i=(0,o.A)(r,2),s=i[0],c=i[1];(0,a.useEffect)((()=>{l&&Yf(pF[0].page)}),[l]);const d=(0,a.useState)(0),u=(0,o.A)(d,2),m=u[0],p=u[1],g=(0,a.useRef)(m);g.current=m;const h=(0,a.useRef)(null),v=(0,a.useState)(tF.Forward),f=(0,o.A)(v,2),E=f[0],y=f[1],b=Zz(n),x=b.completeOnboarding,w=b.loading,C=b.error,A=(0,qd.W)(),I=(0,o.A)(A,2),k=I[0],S=I[1].height,N=vy(),T=N.closeSidebar,_=N.openAssumptions,D=N.openedSidebarDetails,R=(0,a.useCallback)((e=>{null!==h.current&&(clearTimeout(h.current),h.current=null),D?(T(),h.current=setTimeout((()=>{h.current=null,e()}),300)):e()}),[D,T]),M=()=>
1{Yf(pF[0].page),c(!1)};if(s)return a.createElement(uz,{"data-external-id":"forecast-onboarding",onCtaClick:M,ctaLabel:"Build my forecast"});const L=pF[m].step;return a.createElement("div",{"data-external-id":"forecast-onboarding",className:"flex h-full min-h-0 flex-1"},a.createElement("div",{className:" flex min-h-0 flex-1 flex-col overflow-hidden rounded-lg border border-border-primary bg-background-primary "},C&&a.createElement(xF,{type:"error"},"Something went wrong. Please try again."),a.createElement(CF,null,pF.map(((e,t)=>a.createElement("div",{key:e.page,className:"p-xs"},a.createElement(AF,{$active:t===m}))))),a.createElement(wF,{ref:k},a.createElement(rF,{itemKey:m,direction:E},a.createElement(bF,{height:S},a.createElement("div",{className:"px-4xl"},a.createElement(L,{className:"pb-4xl",onNext:()=>R((async()=>{if(w)return;const e=g.current;if(e>=gF-1)return void await x(_);const t=fF(e,yF()),n=(0,o.A)(t,2),a=n[0],l=n[1];l&&Yf(l),y(tF.Forward),p(a)})),onBack:()=>R((()=>{const e=g.current;0!==e?(y(tF.Backward),p(EF(e,yF()))):c(!0)})),mode:t,isCompleteOnboardingLoading:w})))))))},fF=(e,t)=>{var n,a;const l=e+1,r=null!==(n=null===(a=pF[l])||void 0===a?void 0:a.page)&&void 0!==n?n:null;if(t||l!==hF)return[l,r];if(hF<0||hF>=gF-1)return[l,r];const o=pF[hF+1];return o?[hF+1,o.page]:[l,r]},EF=(e,t)=>t||hF<=0||hF>=gF-1||e!==hF+1?e-1:hF-1,yF=()=>wE.getState().accounts.some(Uh),bF=e=>{let t=e.height,n=e.style,l=e.className,r=(0,En.A)(e,mF);return a.createElement("div",Object.assign({"data-external-id":"scrollable-content-wrapper",style:(0,U.A)({maxHeight:t||void 0,minHeight:t||void 0},n),className:(0,q.cn)("relative overflow-y-auto scroll-smooth","[-ms-overflow-style:none] [scrollbar-width:none] [&::-webkit-scrollbar]:hidden",l)},r))},xF=(0,$d.s)(fu.g)(cF||(cF=(0,wc.A)(["m-default"]))),wF=$d.s.div(dF||(dF=(0,wc.A)(["relative min-h-0 flex-1 overflow-hidden"]))),CF=$d.s.div(uF||(uF=(0,wc.A)(["flex justify-center gap-xs pt-3xl pb-default"]))),AF=$d.s.div((e=>["size-2 rounded-full transition-colors",e.$active?"bg-content-brand":"bg-border-primary"])),IF={accounts:a.createElement(WT,null),cashflow:a.createElement(j_,null),events:a.createElement(uB,null)},kF=e=>{let t=e.initState,n=e.mode,o=e.markOnboardingComplete;const i=(()=>{const e=Qx().isLoading,t=(0,a.useRef)(!1);return e||(t.current=!0),!t.current})(),s=py().isResolved,c=Zx();return(0,r.YW)(t).with("loading",(()=>a.createElement(hB,null))).with("needs-onboarding",(()=>a.createElement(vF,{mode:n,onComplete:o}))).with("ready",(()=>s?a.createElement(a.Fragment,null,i?a.createElement(vB,null):a.createElement(PP,null),"chance-of-success"!==c.mode&&a.createElement(JS,null,a.createElement(l.BV,null,I.Q6.map((e=>a.createElement(a.Fragment,{key:e},a.createElement(l.qh,{path:"plan/".concat(e),element:IF[e]}),a.createElement(l.qh,{path:"compare/".concat(e),element:IF[e]})))))),a.createElement(pB,null)):a.createElement(hB,null))).exhaustive()};var SF=n(63162),NF=n(63491),TF=n(443),_F=n(15589),DF=n(19678);const RF=e=>{let t=e.title,n=e.children,l=e.className;return a.createElement("div",{"data-external-id":"page-empty-overlay-card",className:(0,q.cn)("\n        absolute inset-x-0 top-0 mx-auto mt-36.25 flex w-104.75 flex-col\n        items-center rounded-default bg-background-primary p-xl\n        shadow-[0px_8px_16px_rgba(0,40,100,0.08)]\n      ",l)},!!t&&a.createElement(kD.c,{weight:"medium",className:"w-full text-center"},t),n)},MF=[{icon:"institution",title:"Find your institution"},{icon:"lock",title:"Connect it securely to Monarch"},{icon:"pie-chart",title:"Monarch syncs your transactions and analyzes your balances, cash flow, and investments."}],LF=u.default.div.withConfig({displayName:"OnboardingConnectAccountSidebar__Root",componentId:"sc-97xbra-0"})([""]),OF=(0,u.default)(m.g).attrs({column:!0}).withConfig({displayName:"OnboardingConnectAccountSidebar__Section",componentId:"sc-97xbra-1"})(["padding:19px ",";:not(:last-child){border-bottom:1px solid ",";}"],(e=>e.theme.spacing.large),(e=>e.theme.color.grayFocus)),PF=(0,u.default)(xt.v).attrs({size:"large",weight:"medium"}).withConfig({displayName:"OnboardingConnectAccountSidebar__Title",componentId:"sc-97xbra-2"})([""]),BF=(0,u.default)(xt.v).attrs({size:"small",color:"textLight"}).withConfig({displayName:"OnboardingConnectAccountSidebar__Subtitle",componentId:"sc-97xbra-3"})(["margin-top:",";"],(e=>{let t=e.$topMargin,n=e.theme;return t?n.spacing[t]:"0"})),zF=(0,u.default)(m.g).attrs({center:!0}).withConfig({displayName:"OnboardingConnectAccountSidebar__IconCircle",componentId:"sc-97xbra-4"})(["width:32px;height:32px;border-radius:",";background-color:",";flex-shrink:0;margin-right:",";"],(e=>e.theme.radius.round),(e=>
1e.theme.color.grayBackground),(e=>e.theme.spacing.small)),FF=(0,u.default)(m.g).attrs({alignCenter:!0}).withConfig({displayName:"OnboardingConnectAccountSidebar__Step",componentId:"sc-97xbra-5"})(["margin-top:",";"],(e=>e.theme.spacing.default)),GF=(0,u.default)(m.g).attrs({center:!0}).withConfig({displayName:"OnboardingConnectAccountSidebar__LogosContainer",componentId:"sc-97xbra-6"})(["margin:"," 0;"],(e=>e.theme.spacing.xxlarge));var YF=n(48705),UF=n(17158),VF=n(41820);const WF=e=>{let t=e.onSelectInstitution;const n=(0,a.useRef)(null),l=(0,a.useState)(""),r=(0,o.A)(l,2),i=r[0],s=r[1],c=(0,a.useState)(!1),d=(0,o.A)(c,2),u=d[0],g=d[1],h=(0,UF._)(),v=(0,et.I)(eG,{variables:{dataProviders:h}}),f=v.data,E=v.isLoadingInitialData,y=null!==f&&void 0!==f?f:{},b=y.topInstitutionGroups,x=void 0===b?[]:b,w=y.credentials,C=(void 0===w?[]:w).length,A=(0,a.useMemo)((()=>(0,Wd.A)((0,jd.A)((0,mo.A)("institutions")),Ri.A,(0,NF.A)(9))(x)),[x]),I=(0,YF.J)(i),k=I.debouncedSearch,S=I.searchInstitutions,N=I.isNetworkRequestInFlight;return a.createElement(RF,{"data-external-id":"new-onboarding-connect-account-card",className:" top-0 bottom-auto mx-auto mt-(--top) max-h-[calc(100%-var(--top)-var(--spacing-xl))] w-[calc(100%-2*var(--spacing-2xl))] max-w-230 items-stretch overflow-hidden p-0 [--top:calc(var(--app-header-height)+var(--spacing-xl))] lg:flex-row lg:[--top:219px] "},a.createElement(jF,null,a.createElement(HF,null,a.createElement(xt.v,{size:"large",weight:"medium"},"Connect an account"),a.createElement(qF,null,"Connect your ",a.createElement("b",null,"banks"),", ",a.createElement("b",null,"credit cards"),", and ",a.createElement("b",null,"investments")," all in one place."),a.createElement($F,{name:"search-institutions",placeholder:"Search 13,000+ institutions",autoComplete:"off",value:i,onChange:s,onFocus:()=>g(!0),onBlur:()=>g(!1),ref:n})),a.createElement(ZF,null,a.createElement(Ul.w,null,a.createElement(Ul.d,{when:E||N&&!S.length},a.createElement(m.g,{center:!0},a.createElement(p.i,null))),a.createElement(Ul.d,{when:!!k},a.createElement(_F.i,{institutions:S,search:k,credentialCount:C,onSelectInstitution:t})),a.createElement(Ul.d,{default:!0},a.createElement(JF,null,a.createElement(DF.f,{institutions:A,credentialCount:C,onSelectInstitution:t}),!u&&a.createElement(XF,{onClick:()=>{var e;return null===(e=n.current)||void 0===e?void 0:e.focus()}},"Search for more institutions"),a.createElement(QF,{onClick:()=>window.open(VF.q5,"_blank")},a.createElement(Yo.r,{name:"lock",size:16}),"Your data is private & secure")))))),a.createElement(KF,null))},jF=(0,u.default)(m.g).attrs({column:!0}).withConfig({displayName:"NewOnboardingConnectAccountCard__Left",componentId:"sc-12vjksf-0"})(["flex:1;overflow:hidden;"]),HF=(0,u.default)(m.g).attrs({column:!0}).withConfig({displayName:"NewOnboardingConnectAccountCard__Header",componentId:"sc-12vjksf-1"})(["padding:19px ",";padding-bottom:0;"],(e=>e.theme.spacing.large)),KF=(0,u.default)((e=>{let t=e.className;return a.createElement(LF,{"data-external-id":"onboarding-connect-account-sidebar",className:t},a.createElement(OF,null,a.createElement(PF,null,"Get started in under 5 minutes"),MF.map(((e,t)=>{let n=e.icon,l=e.title;return a.createElement(FF,{key:t},a.createElement(zF,null,a.createElement(sl.ZQ,{name:n,size:16})),a.createElement(BF,null,l))}))),a.createElement(OF,null,a.createElement(PF,null,"Trusted by thousands"),a.createElement(BF,{$topMargin:"default"},"\u201cI tried YNAB, I tried Mint, I use Monarch. Soooo much more intuitive and the UI/UX is delightful.\u201d"),a.createElement(BF,{align:"right",$topMargin:"small"},"- Joshua C."),a.createElement(GF,null,a.createElement("img",{src:"https://monarch-static-assets-us-east-2.s3.amazonaws.com/onboarding/featured-in-logos.svg",alt:"Business Insider, Fast Company, Product Hunt"}))))})).withConfig({displayName:"NewOnboardingConnectAccountCard__StyledSidebar",componentId:"sc-12vjksf-2"})(["width:100%;border-top:1px solid ",";flex-shrink:0;display:none;@media (min-width:","px){width:360px;border-top:none;border-left:1px solid ",";display:flex;flex-direction:column;}"],(e=>e.theme.color.grayFocus),(e=>
1e.theme.breakPoints.lg),(e=>e.theme.color.grayFocus)),qF=(0,u.default)(xt.v).withConfig({displayName:"NewOnboardingConnectAccountCard__Subtitle",componentId:"sc-12vjksf-3"})(["margin-top:",";b{font-weight:",";}"],(e=>e.theme.spacing.xsmall),(e=>e.theme.fontWeight.medium)),$F=(0,u.default)(TF.J).withConfig({displayName:"NewOnboardingConnectAccountCard__StyledSearchBar",componentId:"sc-12vjksf-4"})(["margin:"," 0;"],(e=>e.theme.spacing.xlarge)),ZF=(0,u.default)(_m.O).attrs({hideScrollBar:!0}).withConfig({displayName:"NewOnboardingConnectAccountCard__StyledScroll",componentId:"sc-12vjksf-5"})(["display:flex;flex-direction:column;"]),JF=u.default.div.withConfig({displayName:"NewOnboardingConnectAccountCard__TopInstitutionsContainer",componentId:"sc-12vjksf-6"})(["display:flex;flex-direction:column;align-items:center;flex:1;justify-content:space-between;padding:19px ",";padding-top:0;"],(e=>e.theme.spacing.large)),XF=(0,u.default)(wt.Xb).attrs({size:"small"}).withConfig({displayName:"NewOnboardingConnectAccountCard__SearchButton",componentId:"sc-12vjksf-7"})(["margin-top:",";"],(e=>e.theme.spacing.xlarge)),QF=(0,u.default)(bn.v).withConfig({displayName:"NewOnboardingConnectAccountCard__FooterButton",componentId:"sc-12vjksf-8"})(["margin-top:",";margin-bottom:",";"],(e=>e.theme.spacing.xlarge),(e=>e.theme.spacing.small)),eG=Ee.Ej8;var tG=n(12536),nG=n(38082);const aG=Ee.xEf.BANKS_CREDIT_CARDS,lG=e=>{var t;let n=e.emptyTitle,l=e.emptyIcon,r=e.emptyButtonText,i=e.onAccountAdded;const s=(0,Pd.h)(),c=(0,o.A)(s,2),d=c[0],u=c[1],m=u.open,p=u.close,g=u.context,h=(0,nG.p)("new-onboarding-connect-account","off",{trackImpression:!0}),v=(null!==(t=(0,tG.F)(aG))&&void 0!==t?t:{}).topInstitutionGroupByType;return a.createElement(a.Fragment,null,h?a.createElement(WF,{onSelectInstitution:e=>m({institution:e})}):a.createElement("div",{className:" absolute inset-x-2xl bottom-default mx-auto flex flex-col items-start rounded-default bg-background-primary px-default py-lg shadow-lg sm:top-0 sm:bottom-auto sm:mt-54.75 sm:w-125 sm:p-xl "},a.createElement(Ui.je,{name:l,size:"xl",className:"mb-6.75 hidden text-content-brand sm:block"}),a.createElement(kD.c,{weight:"medium",size:"sm",className:"sm:text-xl"},n),a.createElement("div",{className:"mt-4.75 flex w-full items-center sm:mt-2xl sm:w-auto"},a.createElement(Wb.X,{variant:"primary",size:"md",className:"flex-1 sm:flex-none",onClick:()=>m({selectedTopGroup:null!==v&&void 0!==v?v:void 0})},r))),a.createElement(d,{onClose:i},a.createElement(SF.E,{allowManualAccount:!0,selectedTopGroup:null===g||void 0===g?void 0:g.selectedTopGroup,institution:null===g||void 0===g?void 0:g.institution,onClose:p,onComplete:p})))};var rG=n(54056),oG=n(12896),iG=n(24013),sG=n(43958);const cG=e=>e.accounts,dG=(0,sG.Mz)(cG,(e=>e.hasAddedAccounts)),uG=(0,sG.Mz)(cG,(e=>{let t=e.collapsedAccountGroups;return null!==t&&void 0!==t?t:{}})),mG=()=>{var e;const t=(0,d.wA)(),n=(0,d.d4)(dG),a=(0,et.I)(iG.N0,{skip:n,onCompleted(e){let n=e.hasAccounts;n&&t((0,oG.R4)(n))}}),l=a.data,r=a.refetch,o=a.error,i=a.isLoadingInitialData;return{hasAccounts:null!==(e=(0,c.A)(n)?n:null===l||void 0===l?void 0:l.hasAccounts)&&void 0!==e?e:void 0,refetch:r,error:o,isLoadingInitialData:i}};var pG=n(91413),gG=n(51090);const hG=e=>{let t=e.children;const n=mG(),l=n.hasAccounts,r=n.refetch,o=n.isLoadingInitialData,i=(0,pG.w)();(0,a.useEffect)((()=>{i((0,g.B8)(l))}),[i,l]);const s=(0,d.d4)(gG.pk);return o?null:s?a.createElement(rG.Y,{"data-external-id":"forecast-no-accounts-empty-state",name:"Forecasting",parentRoute:null,showHeader:!1,shouldScroll:!0,overlayEmptyComponent:a.createElement(lG,{emptyTitle:_t.mZ,emptyIcon:"trending-up",emptyButtonText:_t.cW,onAccountAdded:r})},a.createElement("div",{className:"p-4"},a.createElement(uz,null))):a.createElement(a.Fragment,null,t)};var vG=n(93867);const fG={role:"status","aria-live":"polite"},EG=()=>{const e=wE((e=>e.forecastOperation)),t=wE((e=>e.clearForecastOperation));if((0,a.useEffect)((()=>{if("success"!==(null===e||void 0===e?void 0:e.phase))return;const n=window.setTimeout((()=>{t()}),2500);return()=>clearTimeout(n)}),[null===e||void 0===e?void 0:e.phase,null===e||void 0===e?void 0:e.kind,t]),!e)return null;const n=e.phase,l=e.title,o=e.description,i=(0,r.YW)(n).with("loading",(()=>({liveProps:fG,iconColumnClassName:"",icon:a.createElement(vG.W,null,a.createElement(sl.ZQ,{name:"refresh"})),showDismiss:!1}))).with("success",(()=>({liveProps:fG,iconColumnClassName:"text-content-success",icon:a.createElement(sl.ZQ,{name:"check-circle-filled"}),showDismiss:!1}))).with("error",(()=>({liveProps:{role:"alert"},iconColumnClassName:"text-content-danger",icon:a.createElement(sl.ZQ,{name:"x-circle"}),showDismiss:!0}))).exhaustive(),s=i.liveProps,c=i.iconColumnClassName,d=i.icon,u=i.showDismiss;return(0,R.createPortal)(a.createElement(rb.J,null,a.createElement("div",{className:"fixed right-0 bottom-4 z-toast flex justify-end"},a.createElement("div",Object.assign({className:(0,q.cn)("w-95 overflow-hidden transition-opacity duration-400 ease-in-out","bg-background-frosted backdrop-blur-(--background-blur-frosted)","rounded-md border border-divider-secondary text-content-white","mr-0 2xs:mr-default"),"data-testid":"forecast-operation-panel"},s),a.createElement("div",{className:"flex items-stretch text-xs leading-[150%] text-content-white"},a.createElement("div",{className:(0,q.cn)("mr-xl flex max-w-8 shrink-0 items-center pl-xl",c)},d),a.createElement("div",{className:"flex min-w-0 flex-1 items-center"},a.createElement("div",{className:"min-w-0 flex-1 p-default"},a.createElement("span",{className:"mb-2xs block text-sm font-medium"},l),o?a.createElement("span",null,o):null)),u?a.createElement("div",{className:"flex min-w-29.5 shrink-0 flex-col border-l border-divider-secondary"},a.createElement("button",{type:"button",className:(0,q.cn)("min-h-11 w-full flex-1 cursor-pointer border-none bg-transparent","text-xs font-medium tracking-[0.08em] text-content-white uppercase","hover:bg-content-white/3","active:bg-content-black/30"),onClick:()=>t()},"Dismiss")):null)))),document.body)},yG=()=>{const e=bG(),t=e.status,n=e.lastSavedAt,l=(0,a.useState)(0),r=(0,o.A)(l,2)[1];switch((0,a.useEffect)((()=>
1{if("saved"!==t)return;const e=setInterval((()=>r((e=>e+1))),1e4);return()=>clearInterval(e)}),[t]),t){case"idle":return null;case"saving":return a.createElement(wG,{"data-external-id":"forecast-save-status"},"Saving\u2026");case"saved":return a.createElement(wG,{"data-external-id":"forecast-save-status"},n?xG(n):null);case"error":return a.createElement(wG,{"data-external-id":"forecast-save-status",$isError:!0},"Save failed")}},bG=()=>{const e=wE((e=>e.isConflicted)),t=wE((e=>Object.keys(e.savingCategories).length)),n=wE((e=>Object.keys(e.saveErrors).length)),a=wE((e=>e.lastSavedAt));if(e)return{status:"idle",lastSavedAt:a};let l="idle";return t>0?l="saving":n>0?l="error":null!==a&&(l="saved"),{status:l,lastSavedAt:a}},xG=e=>{const t=Math.floor((Date.now()-e.getTime())/1e3);if(t<10)return"Saved just now";if(t<60)return"Saved ".concat(t,"s ago");const n=Math.floor(t/60);return n<60?"Saved ".concat(n,"m ago"):"Saved ".concat(Math.floor(n/60),"h ago")},wG=u.default.span.withConfig({displayName:"ForecastSaveStatus__StatusText",componentId:"sc-1vrybr6-0"})(["font-size:12px;color:",";white-space:nowrap;"],(e=>{let t=e.$isError,n=e.theme;return t?n.variables.color.content.danger:n.variables.color.content.secondary}));var CG=n(9889);const AG=()=>{const e=(0,l.Zp)(),t=Zx(),n=t.scenarioId,r=t.mode,s="chance-of-success"===t.mode?t.chanceOfSuccessView:void 0,c="chance-of-success"===t.mode?void 0:t.yearTableView,d=(0,i.n)(Dv.y1,{refetchQueries:[Dv.EX],awaitRefetchQueries:!0}),u=(0,o.A)(d,2),m=u[0],p=u[1],g=(0,a.useCallback)((async function(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},a=t.name,l=void 0===a?"New scenario":a,o=t.icon,i=t.color,d=t.onSuccess;const u={icon:Xg[Math.floor(Math.random()*Xg.length)],color:Jg[Math.floor(Math.random()*Jg.length)]},p=null!==o&&void 0!==o?o:u.icon,g=null!==i&&void 0!==i?i:u.color;let h;n&&(h="chance-of-success"===r?{scenarioId:n,mode:r,chanceOfSuccessView:s}:{scenarioId:n,mode:r,yearTableView:c});const v=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"Please try again.";return C.oR.error({title:"Couldn't create scenario",description:t}),{success:!1,error:e}};try{var f;const t=(await m({variables:{input:{name:l,icon:p,color:g}},update:(e,t)=>{var a;let l=t.data;const r=null===l||void 0===l||null===(a=l.createForecastScenario)||void 0===a?void 0:a.scenario;r&&IG(e,r,n)}})).data,a=null===t||void 0===t?void 0:t.createForecastScenario,r=null===a||void 0===a||null===(f=a.errors)||void 0===f?void 0:f.message;if(r)return v(r,r);const o=null===a||void 0===a?void 0:a.scenario;return o?(e({pathname:qx({scenarioId:o.externalId,mode:"plan"}),search:IC(window.location.search)},{state:(0,U.A)({isNewScenario:!0},h?{returnTo:h}:{})}),null===d||void 0===d||d(),Gf({scenarioId:o.externalId,source:"start_from_scratch"}),{success:!0,newScenarioId:o.externalId}):v("Failed to create scenario")}catch(E){return v(E instanceof Error?E.message:"Could not create scenario")}}),[m,e,n,r,s,c]);return(0,U.A)({create:g},p)},IG=(e,t,n)=>{const a=kG(e,n);a&&e.writeQuery({query:Dv.Tu,variables:{externalId:t.externalId},data:{__typename:"Query",forecastScenario:t,me:a}})},kG=(e,t)=>{const n=t=>{try{var n,a;return null!==(n=null===(a=e.readQuery({query:Dv.Tu,variables:{externalId:t}}))||void 0===a?void 0:a.me)&&void 0!==n?n:null}catch(l){return null}},a=n(t);return a||null===t?a:n(null)},SG=e=>{let t=e.close;const n=GE("duplicateScenario","loading"),l=AG(),r=l.create,o=l.loading,i=Qx().scenarios,s=pA().duplicate,c=o||n;return a.createElement(hA.u.Content,{"data-external-id":"add-scenario-menu",className:"min-w-64"},a.createElement(hA.u.Item,{"data-testid":"add-scenario-start-from-scratch",closeOnClick:!1,disabled:c,trailing:o?a.createElement(p.i,{size:"xs"}):void 0,onClick:()=>{r({onSuccess:t})}},"Start from scratch"),1===i.length?a.createElement(hA.u.Item,{closeOnClick:!1,disabled:c,onClick:async()=>{(await s(i[0].id)).success&&t()}},"Duplicate existing scenario"):a.createElement(hA.u.SubmenuRoot,null,a.createElement(hA.u.SubmenuTrigger,{disabled:c},"Duplicate existing scenario"),a.createElement(hA.u.Content,{side:"right",align:"start",sideOffset:0,className:"w-80"},i.map((e=>a.createElement(hA.u.Item,{key:e.id,closeOnClick:!1,disabled:c,leading:a.createElement(TS,{icon:e.icon,size:12,color:e.color}),onClick:async()=>{(await s(e.id)).success&&t()}},e.name))))))},NG=e=>{let t=e.icon,n=e.name,l=e.color;return a.createElement(a.Fragment,null,a.createElement(TS,{icon:t,size:12,color:l,className:"shrink-0"}),a.createElement(fe.c8D,{className:"block min-w-0 truncate"},n))},TG=e=>{let t=e.scenario,n=e.onNavigate;const r=t.isActive,o=aw().setCompareToScenarioId,i=RS().setForecastingMode,s=py().isEnabled,c=(0,a.useCallback)((()=>{jf({source:"scenario_list"}),o(t.id),s&&i("compare"),null===n||void 0===n||n()}),[o,i,s,t.id,n]),d=!r;return a.createElement(Hk.U,{"data-external-id":"scenario-list-row",id:t.id,role:"listitem",className:(0,q.cn)("group relative flex w-full items-center gap-xs rounded-sm px-sm py-xs transition-colors",r?"bg-background-secondary":"hover:bg-background-primary-hover"),handle:a.createElement("div",{"data-sortable-item-handle":!0,"aria-label":"Drag to reorder",className:(0,q.cn)("shrink-0 cursor-grab touch-none px-2xs py-3xs opacity-0 transition-opacity","group-hover:opacity-100 group-focus-visible:opacity-100","group-aria-pressed:opacity-100")},a.createElement(Kk.P,null))},a.createElement(l.k2,{to:NC(t.id),onClick:()=>null===n||void 0===n?void 0:n(),"data-testid":"scenario-list-row-link-".concat(t.id),className:"flex min-w-0 flex-1 items-center gap-xs pr-2xl text-content-primary no-underline"},a.createElement(NG,{icon:t.icon,name:t.name,color:t.color})),a.createElement("div",{className:"absolute inset-y-0 right-2xs flex items-center"},a.createElement(vA,{scenarioId:t.id,variant:"scenarioList",isActive:r,onAfterNavigate:n,onCompare:d?c:void 0})))},_G=(e,t)=>{const n=(0,V.m)(),l=YE(),r=(0,a.useMemo)((()=>e.map((e=>e.id))),[e]),s=null===t||void 0===t?void 0:t.visibleIds,c=(0,Bk.FR)((0,Bk.MS)(Bk.AN,{activationConstraint:null===t||void 0===t?void 0:t.activationConstraint})),d=(0,i.n)(Dv.gj,{optimisticResponse:e=>{var t;const a=((e,t)=>{if(null===t||void 0===t||!t.length)return null;const n=Object.fromEntries(t.map((e=>[e.externalId,e]))),a=[];for(let l=0;l<e.length;l+=1){const t=n[e[l]];if(!t)return null;a.push((0,U.A)((0,U.A)({},t),{},{order:l}))}return a})(e.input.orderedScenarioExternalIds,null===(t=n.readQuery({query:Dv.EX}))||void 0===t?void 0:t.forecastScenarios);return a?{__typename:"Mutation",updateForecastScenarioOrder:{__typename:"UpdateForecastScenarioOrderMutation",errors:null,scenarios:a}}:{__typename:"Mutation"}},update(e,t){var n;let a=t.data;const l=null===a||void 0===a?void 0:a.updateForecastScenarioOrder;if(null!==l&&void 0!==l&&null!==(n=l.errors)&&void 0!==n&&n.message)return;const r=null===l||void 0===l?void 0:l.scenarios;null!==r&&void 0!==r&&r.length&&e.modify({fields:{forecastScenarios:()=>r}})}}
1),u=(0,o.A)(d,1)[0],m=(0,a.useCallback)((async e=>{const t=e.active,a=e.over;if(null===t||void 0===t||!t.id||null===a||void 0===a||!a.id||t.id===a.id)return;const o=DG(r,t.id,a.id,s);if(o)try{var i,c;const e=await u({variables:{input:{orderedScenarioExternalIds:o}}}),t=e.data,a=e.errors;if(null!==a&&void 0!==a&&a.length)throw new Error(a.map((e=>e.message)).join("; "));const r=null===t||void 0===t||null===(i=t.updateForecastScenarioOrder)||void 0===i||null===(c=i.errors)||void 0===c?void 0:c.message;r&&(await n.refetchQueries({include:[Dv.EX]}),l({kind:"reorderScenarios",phase:"error",title:"Could not reorder scenarios",description:r}))}catch(d){await n.refetchQueries({include:[Dv.EX]}),l({kind:"reorderScenarios",phase:"error",title:"Could not reorder scenarios",description:"Please try again."})}}),[r,s,u,n,l]);return{handleDragEnd:m,sensors:c}},DG=(e,t,n,a)=>{if(!a){const a=e.indexOf(t),l=e.indexOf(n);return-1===a||-1===l?null:(0,Fk.be)(e,a,l)}const l=a.indexOf(t),r=a.indexOf(n);if(-1===l||-1===r)return null;const o=(0,Fk.be)(a,l,r),i=new Set(a);return[...o,...e.filter((e=>!i.has(e)))]},RG=e=>{let t=e.scenarios,n=e.close;const l=(0,a.useRef)(null),r=(0,a.useMemo)((()=>t.map((e=>e.id))),[t]),o=_G(t),i=o.handleDragEnd,s=o.sensors;return a.createElement("div",{"data-external-id":"scenario-list-popover","data-testid":"scenario-list-popover"},a.createElement("header",{className:"flex items-center justify-between gap-sm border-b border-divider-secondary pb-xs pl-sm"},a.createElement(fe.c8D,{size:"sm",weight:"medium"}
1,t.length," ",1===t.length?"scenario":"scenarios"),a.createElement(MG,{close:n})),a.createElement(Bk.Mp,{sensors:s,collisionDetection:Bk.fp,onDragEnd:i,modifiers:[zk.FN],autoScroll:{order:Bk.HC.ReversedTreeOrder,canScroll:e=>e===l.current}},a.createElement(Fk.gB,{items:r,strategy:Fk._G},a.createElement("div",{ref:l,className:(0,q.cn)("m-0 flex max-h-90 list-none flex-col gap-3xs overflow-y-auto p-2xs","[-ms-overflow-style:none] [scrollbar-width:none] [&::-webkit-scrollbar]:hidden"),role:"list"},t.map((e=>a.createElement(TG,{key:e.id,scenario:e,onNavigate:n})))))))},MG=e=>{let t=e.close;const n=(0,a.useState)(!1),l=(0,o.A)(n,2),r=l[0],i=l[1];return a.createElement(hA.u.Root,{"data-external-id":"new-scenario-menu-button",open:r,onOpenChange:i},a.createElement(hA.u.Trigger,{render:a.createElement(Wb.X,{variant:"default",size:"xs",icon:a.createElement(fe.Wa3,{size:"md"}),"data-testid":"scenario-list-new-scenario-button"},"New scenario")}),a.createElement(SG,{close:()=>{i(!1),t()}}))},LG=e=>{let t=e.count,n=e.scenarios;const l=(0,a.useState)(!1),r=(0,o.A)(l,2),i=r[0],s=r[1];return a.createElement(fS.k.Root,{"data-external-id":"scenario-overflow-chip",open:i,onOpenChange:s},a.createElement(fS.k.Trigger,{render:a.createElement("button",{type:"button","aria-haspopup":"menu","data-testid":"scenario-overflow-chip",className:(0,q.cn)("\n                inline-flex h-8 shrink-0 cursor-pointer items-center justify-center gap-2xs\n                rounded-pill border border-border-primary bg-background-page px-2.5\n                text-content-secondary transition-colors\n              ",i&&"bg-background-tertiary")},a.createElement(fe.c8D,{size:"xs",weight:"medium",className:"block whitespace-nowrap",color:"secondary"},t," more"),a.createElement(sl.ZQ,{name:"chevron-down",size:12}))}),a.createElement(fS.k.Content,{side:"bottom",align:"start",className:"w-80 overflow-hidden p-xs"},a.createElement(RG,{scenarios:n,close:()=>s(!1)})))},OG=()=>a.createElement("nav",{"data-external-id":"scenario-pill-bar-skeleton",className:"flex items-center gap-xs","aria-label":"Forecast scenarios","aria-busy":"true","data-testid":"scenario-pill-bar-skeleton"},["5.5rem","11rem","7.5rem"].map(((e,t)=>a.createElement("div",{key:t,className:" inline-flex h-8 min-w-[7.25rem] items-center justify-center gap-2xs rounded-pill border border-border-primary px-2.5 ","data-testid":"scenario-pill-skeleton"},a.createElement(M.Xu,{$size:12,"aria-hidden":!0}),a.createElement(M.Al,{$width:e,$height:"12px",$borderRadius:"small","aria-hidden":!0})))));var PG=n(15069);const BG=e=>{let t=e.scenarioId,n=e.isActive,l=void 0!==n&&n,r=e.onOpen,o=e.children;const i=gA({scenarioId:t,surface:"pillContextMenu",isActive:l}),s=i.entries,c=i.deleteModal;return a.createElement(a.Fragment,null,a.createElement(PG.D,{items:s,classNames:{content:"min-w-44"},onOpenChange:e=>{e&&(null===r||void 0===r||r())}},o),c)},zG=e=>{var t,n;let l=e.scenario,r=e.shortcutNumber;const o=l.kpis;return a.createElement("div",{"data-external-id":"scenario-pill-tooltip-content",className:" flex w-fit min-w-66 flex-col items-start gap-default px-sm py-default text-left whitespace-normal "},a.createElement(nO,{className:"self-stretch px-xs"},a.createElement("div",{className:"flex items-start justify-between gap-default"},a.createElement(lO,{size:"small",weight:"medium",className:"wrap-break-word whitespace-normal"},l.name),(0,Tp.n)(r)?a.createElement("div",{"aria-hidden":!0,"data-testid":"scenario-shortcut-keycap",className:" flex w-6 shrink-0 items-center justify-center gap-2xs rounded-2xs border border-border-primary bg-background-primary px-xs py-3xs text-xs font-medium text-content-primary shadow-sm "},r):null)),a.createElement(aO,{className:"self-stretch px-xs"},a.createElement(sO,{label:"Net worth today",value:(0,Tp.n)(null===o||void 0===o?void 0:o.netWorthToday)?(0,rl.Ig)(o.netWorthToday):"\u2014"}),a.createElement(sO,{label:"Net worth at retirement",value:(0,Tp.n)(null===o||void 0===o?void 0:o.netWorthAtRetirement)?(0,rl.Ig)(o.netWorthAtRetirement):"\u2014"}),a.createElement(sO,{label:"Retirement age",value:null!==(t=null===o||void 0===o?void 0:o.retirementAge)&&void 0!==t?t:"\u2014"}),a.createElement(sO,{label:"Net worth at end",value:(0,Tp.n)(null===o||void 0===o?void 0:o.netWorthAtEnd)?(0,rl.Ig)(o.netWorthAtEnd):"\u2014"}),a.createElement(sO,{label:"Life events",value:null!==(n=null===o||void 0===o?void 0:o.lifeEventsCount)&&void 0!==n?n:"\u2014"})))};var FG=n(97373),GG=n(66605);const YG=["1","2","3","4","5","6","7","8","9"],UG=(e,t)=>
1({maxVisible:(0,a.useMemo)((()=>{if(0===t)return 5;return((e,t)=>{if(170*t+8*Math.max(0,t-1)<=e)return 5;const n=e-110-8,a=Math.floor((n+8)/178);return Math.max(1,Math.min(a,5))})(Math.max(0,t-32-8),e)}),[t,e])});var VG=n(96818);const WG=e=>{let t=e.regionWidth,n=void 0===t?0:t;const r=Qx(),i=r.scenarios,s=r.isLoading,c=r.error,d=UG(i.length,n).maxVisible,u=(0,a.useMemo)((()=>function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:5;const n=Math.max(1,t);if(e.length<=n)return{visible:e,overflow:[]};const a=e.slice(0,n),l=e.slice(n);if(a.some((e=>e.isActive)))return{visible:a,overflow:l};const r=l.findIndex((e=>e.isActive));if(-1===r)return{visible:a,overflow:l};const o=a[n-1],i=l[r];return{visible:[...a.slice(0,n-1),i],overflow:[o,...l.slice(0,r),...l.slice(r+1)]}}(i,d)),[i,d]),m=u.visible,p=u.overflow;!function(e){let t=(arguments.length>1&&void 0!==arguments[1]?arguments[1]:{}).enabled,n=void 0===t||t;const a=(0,l.Zp)(),r=(0,FG.N)().isAnyModalOpen,o=(0,v.D)(((t,l)=>{if(!n||r)return;const o=e[Number(l)-1];o&&!o.isActive&&(t.preventDefault(),a(NC(o.id)))}));(0,GG.O)(YG,o)}(m,{enabled:!s&&!c});const g=(0,a.useMemo)((()=>m.map((e=>e.id))),[m]),h=_G(i,{activationConstraint:{distance:8},visibleIds:g}),f=h.handleDragEnd,E=h.sensors,y=((e,t)=>{const n=(0,a.useState)(null),l=(0,o.A)(n,2),r=l[0],i=l[1];return{draggingItem:(0,a.useMemo)((()=>r?e.find((e=>e.id===r)):void 0),[r,e]),handleDragStart:(0,a.useCallback)((e=>{i(e.active.id)}),[]),handleDragEnd:(0,a.useCallback)((e=>{i(null),t(e)}),[t]),handleDragCancel:(0,a.useCallback)((()=>i(null)),[])}})(m,f),b=y.draggingItem,x=y.handleDragStart,w=y.handleDragEnd,C=y.handleDragCancel;if(s)return a.createElement(OG,{"data-external-id":"scenario-pill-bar"});if(c){const e=VG.U.FORECAST_SCENARIOS;return a.createElement("div",{"data-external-id":"scenario-pill-bar",className:"flex items-center","data-testid":"scenario-pill-bar-error"},a.createElement(P.D_,{content:e,place:"bottom",maxWidth:280,interactive:!1},a.createElement("span",{role:"alert","aria-label":e,className:"inline-flex cursor-default items-center text-content-danger"},a.createElement(fe.WU2,{size:18}))))}return a.createElement(Bk.Mp,{"data-external-id":"scenario-pill-bar",sensors:E,collisionDetection:Bk.fp,onDragStart:x,onDragEnd:w,onDragCancel:C,modifiers:[zk.dU]},a.createElement(Fk.gB,{items:g,strategy:Fk.m$},a.createElement("nav",{className:"flex min-w-0 items-center gap-xs overflow-x-clip","aria-label":"Forecast scenarios"},m.map(((e,t)=>a.createElement(jG,{key:e.id,scenario:e,shortcutNumber:t+1}))),p.length>0&&a.createElement(LG,{count:p.length,scenarios:i}))),a.createElement(Bk.Hd,{dropAnimation:null},b?a.createElement(HG,{scenario:b,isDragging:!0}):null))},jG=e=>{let t=e.scenario,n=e.shortcutNumber;const l=(0,Fk.gl)({id:t.id}),r=l.listeners,o=l.setNodeRef,i=l.transform,s=l.transition,c=l.isDragging,d={transform:CG.Ks.Translate.toString(i),transition:null!==s&&void 0!==s?s:void 0,opacity:c?.4:void 0};return a.createElement("div",{"data-external-id":"sortable-scenario-pill",ref:o,style:d},a.createElement(HG,{scenario:t,isDragging:c,dragListeners:r,shortcutNumber:n}))},HG=e=>{let t=e.scenario,n=e.isDragging,r=void 0!==n&&n,i=e.dragListeners,s=e.shortcutNumber;const c=t.id,d=t.name,u=t.icon,m=t.color,p=t.isActive,g=(0,a.useState)(!1),h=(0,o.A)(g,2),v=h[0],f=h[1],E=(0,a.useState)(null),y=(0,o.A)(E,2),b=y[0],x=y[1],w=FE(),C=py().isEnabled&&p&&!r,A=C&&w.isOpen,I=NC(c),k=Hg[null!==m&&void 0!==m?m:Qg.color],S=(0,q.cn)("\n      inline-flex h-8 items-center justify-center gap-2xs rounded-pill border border-border-primary\n      transition-colors\n    ",p?(0,q.cn)(k,"border-2 bg-background-primary shadow-sm"):"bg-background-page hover:border-border-secondary"),N=a.createElement(fS.k.Root,{variant:"tooltip",open:v&&!A,onOpenChange:f},a.createElement(fS.k.Trigger,{hoverOnly:!0,nativeButton:!1,delay:500,description:d,render:a.createElement("div",{ref:x,className:S,"data-testid":"scenario-pill-root-".concat(c)},a.createElement(l.k2,Object.assign({to:I,"data-testid":"scenario-pill-".concat(c),className:(0,q.cn)("\n                  inline-flex size-full min-w-0 items-center gap-2xs px-2.5 no-underline\n                  focus-visible:outline-2 focus-visible:-outline-offset-2\n                  focus-visible:outline-input-focus-border\n                ",r?"cursor-grabbing":"cursor-pointer")},i,{onClick:e=>{p&&e.preventDefault()}}),a.createElement(TS,{icon:u,size:12,color:m}),a.createElement(fe.c8D,{size:"xs",weight:"medium",color:p?"primary":"secondary",className:"block max-w-32 truncate"},d)))}),a.createElement(fS.k.Content,{side:"bottom",className:"p-0"},a.createElement(zG,{scenario:t,shortcutNumber:s}),a.createElement(fS.k.Arrow,null)));return a.createElement(a.Fragment,null,r?N:a.createElement(BG,{scenarioId:c,isActive:p,onOpen:()=>f(!1)},N),C&&a.createElement(fS.k.Root,{open:w.isOpen,onOpenChange:e=>
1e?w.open():w.close()},a.createElement(fS.k.Content,{anchor:b,side:"bottom",align:"start",sideOffset:12,className:"w-80 max-w-[calc(100vw-32px)] p-default"},a.createElement(wP,null))))},KG=()=>{const e=(0,a.useState)(!1),t=(0,o.A)(e,2),n=t[0],l=t[1];return a.createElement(hA.u.Root,{"data-external-id":"add-scenario-button",open:n,onOpenChange:l},a.createElement(hA.u.Trigger,{render:a.createElement(Yi.S,{"aria-label":"Add scenario",size:"xs"},a.createElement(fe.Wa3,null))}),a.createElement(SG,{close:()=>l(!1)}))};var qG=n(6411);const $G=()=>(0,qG.e)().isPaidPlusMember?null:a.createElement(ZG,{"data-external-id":"plus-badge",color:"orange",variant:"subtle"},a.createElement(sl.ZQ,{name:"monarch",size:10}),"Plus"),ZG=(0,u.default)(Oc.D).withConfig({displayName:"PlusBadge__StyledBadge",componentId:"x4zat2-0"})(["border-radius:",";gap:",";"],vt.r8.pill,vt.YK.xxxsmall),JG=e=>{let t=e.showControls;const n=(0,qd.W)(),l=(0,o.A)(n,2),r=l[0],i=l[1].width,s=void 0===i?0:i,c=py().isEnabled;return a.createElement(uS.Y9,{"data-external-id":"forecast-scenario-header"},a.createElement("div",{className:"flex w-full items-center gap-default"},a.createElement(XG,null),t&&a.createElement(a.Fragment,null,a.createElement("div",{ref:r,className:"flex min-w-0 flex-1 items-center gap-xs"},a.createElement(WG,{regionWidth:s}),a.createElement("div",{className:"shrink-0"},a.createElement(KG,null))),a.createElement("div",{className:"flex shrink-0 items-center gap-xs"},a.createElement(yG,null),c&&a.createElement(gP,null)))))},XG=()=>a.createElement("span",{"data-external-id":"forecast-page-title",className:"inline-flex shrink-0 items-center gap-sm"},"Forecasting",a.createElement($G,null));var QG=n(62643),eY=n(21291);const tY="ForecastUpsellPaywall",nY=a.memo((()=>{const e=(0,a.useState)(!1),t=(0,o.A)(e,2),n=t[0],l=t[1],r=(0,b.cn)("upgradeSuccess"),i=(0,eY.z)();return a.createElement(a.Fragment,null,a.createElement(rG.Y,{name:"Forecasting",parentRoute:null,showHeader:!1,shouldScroll:!0},a.createElement(m.g,{padding:"gutter"},a.createElement(uz,{onCtaClick:()=>{i(tY),l(!0)}}))),n&&a.createElement(QG.N,{type:"Forecasting",analyticsName:tY,onClose:()=>l(!1),onCheckoutSuccess:()=>r("true")}))}));let aY=null,lY=!1,rY=0;const oY=()=>{rY++},iY=async e=>{if(aY)lY=!0;else do{lY=!1;try{aY=sY(e),await aY}finally{aY=null}}while(lY)},sY=async e=>{const t=rY,n=wE.getState(),a=Object.keys(n.dirtyCategories);if(0===a.length||!n.scenarioExternalId||n.isConflicted)return;const l=n.scenarioExternalId;wE.setState((e=>{for(const t of a)delete e.dirtyCategories[t],e.savingCategories[t]=!0}));const i=LE(_E),s=LE(DE),c=LE(RE),d=wE.getState(),u=async(t,n)=>{try{const o=Uv(t,n),i=o.mutation,s=o.variables,c=(await e.mutate({mutation:i,variables:s})).data,d=Kv(c,t);if(d)return{category:t,outcome:"error",errorMessage:d};if(Hv(c,t))return{category:t,outcome:"conflict"};const u=jv(c,t);if(null!==u&&void 0!==u){var a,l,r;return{category:t,outcome:"success",newVersion:u,priorityRulesNewVersion:"accounts"===t?null===c||void 0===c||null===(a=c.saveForecastAccounts)||void 0===a||null===(l=a.scenario)||void 0===l||null===(r=l.categoryVersions)||void 0===r?void 0:r.priorityRulesVersion:void 0}}return{category:t,outcome:"error",errorMessage:"Unexpected empty response"}}catch(o){return{category:t,outcome:"error",errorMessage:o instanceof Error?o.message:"Save failed"}}},m=["withdrawalRules","allocationRules"],p=a.filter((e=>!m.includes(e))),g=a.filter((e=>m.includes(e))),h=p.includes("events"),v=p.includes("accounts"),f=h&&v,E=[];f&&E.push(await u("events",d));let y=f?p.filter((e=>"events"!==e)):p;f&&"success"!==E[0].outcome&&y.includes("accounts")&&(y=y.filter((e=>"accounts"!==e)),t===rY&&wE.setState((e=>{delete e.savingCategories.accounts,e.dirtyCategories.accounts=!0})));const b=await Promise.all(y.map((e=>u(e,d)))),x=[...E,...b],w=x.find((e=>void 0!==e.priorityRulesNewVersion));w&&t===rY&&wE.setState((e=>{e.categoryVersions&&(e.categoryVersions.priorityRules=w.priorityRulesNewVersion)}));const C=x.find((e=>"accounts"===e.category)),A="success"===(null===C||void 0===C?void 0:C.outcome),I=v&&!A&&g.length>0;I&&t===rY&&wE.setState((e=>{g.forEach((t=>{delete e.savingCategories[t],e.dirtyCategories[t]=!0}))}
1));const k=[];for(const r of I?[]:g){const e=wE.getState(),n=await u(r,e);if(t===rY&&"success"===n.outcome&&void 0!==n.newVersion&&wE.setState((e=>{e.categoryVersions&&(e.categoryVersions[Mv(n.category)]=n.newVersion)})),k.push(n),"conflict"===n.outcome){const e=new Set(k.map((e=>e.category)));t===rY&&wE.setState((t=>{g.filter((t=>!e.has(t))).forEach((e=>{delete t.savingCategories[e],t.dirtyCategories[e]=!0}))}));break}}const S=[...x,...k];if(t!==rY)return;wE.setState((e=>{let t=!1;for(const n of S)delete e.savingCategories[n.category],(0,r.YW)(n.outcome).with("success",(()=>{if(e.categoryVersions){const t=Mv(n.category);e.categoryVersions[t]=n.newVersion,void 0!==n.priorityRulesNewVersion&&(e.categoryVersions.priorityRules=n.priorityRulesNewVersion)}delete e.saveErrors[n.category],t=!0})).with("conflict",(()=>{e.isConflicted=!0})).with("error",(()=>{var t,a;e.dirtyCategories[n.category]=!0;const l=e.saveErrors[n.category];e.saveErrors[n.category]={message:null!==(t=n.errorMessage)&&void 0!==t?t:"Save failed",failureCount:(null!==(a=null===l||void 0===l?void 0:l.failureCount)&&void 0!==a?a:0)+1}})).exhaustive();t&&(e.lastSavedAt=new Date)}));const N=wE.getState();for(const r of Object.values(N.saveErrors))if(5===r.failureCount){cY();break}const T=S.filter((e=>"success"===e.outcome)).map((e=>e.category));T.includes("events")||OE(_E,i),T.includes("accounts")||(e=>{OE(DE,e)})(s),((e,t)=>{const n=new Set(t);OE(RE,new Map([...e].filter((e=>{let t=(0,o.A)(e,1)[0];return!n.has(t)}))))})(c,T),T.length>0&&(((e,t,n,a)=>{const l=zf();for(const p of e)if("events"===p&&t.size>0){var r;const e=new Map((null!==(r=wE.getState().events)&&void 0!==r?r:[]).map((e=>[e.id,e])));for(const n of t){var i=(0,o.A)(n,2);const t=i[0],a=i[1],r=e.get(t),c=r?Ff(r.eventKind,r.isHidden):void 0;for(const e of a){var s;(0,Ge.u4)(Ye.yq.EventUpdated,(0,U.A)((0,U.A)({event_id:t,type:null!==(s=null===r||void 0===r?void 0:r.eventKind)&&void 0!==s?s:"unknown",source:e},c&&{income_origin:c}),l))}}}else if("accounts"===p&&n.size>0){const e=new Map(wE.getState().accounts.map((e=>[e.id,e])));for(const t of n){var c,d,u=(0,o.A)(t,2);const n=u[0],a=u[1],r=null!==(c=null===(d=e.get(n))||void 0===d?void 0:d.accountType.group)&&void 0!==c?c:"other";for(const e of a)(0,Ge.u4)(Ye.yq.AccountUpdated,(0,U.A)({account_id:n,account_group:r,source:e},l))}}else if(Hf.has(p)){var m;const e=null!==(m=a.get(p))&&void 0!==m?m:new Set(["unknown"]);for(const t of e)(0,Ge.u4)(Ye.yq.ScenarioAssumptionsUpdated,(0,U.A)({category:p,source:t},l))}})(T,T.includes("events")?i:new Map,T.includes("accounts")?s:new Map,c),(async(e,t)=>{try{await e.query({query:Dv.Tu,variables:{externalId:t},fetchPolicy:"network-only"})}catch(n){}})(e,l))},cY=()=>{(0,C.oR)({title:"Couldn't save forecast changes",description:"Check your connection and try again."})};let dY;const uY=e=>{const t=(0,V.m)();(0,a.useEffect)((()=>{oY(),wE.setState((e=>{e.dirtyCategories={},e.savingCategories={},e.saveErrors={}})),PE();const e=()=>iY(t);return dY=e,SE(e),()=>{clearTimeout(AE),iY(t),dY=void 0,SE(void 0)}}),[t]),(e=>{(0,a.useEffect)((()=>{const t=()=>{const t=wE.getState();if(t.scenarioExternalId)if(Tx(t))e().then((e=>{if(!e)return;const t=wE.getState();if(Nx(t))return;const n=wE.temporal.getState();n.pause();try{t.hydrateFromScenario(e)}finally{n.clear(),n.resume()}})).catch((()=>{}));else if(Sx(t)){var n;null===(n=dY)||void 0===n||n()}},n=()=>{"visible"===document.visibilityState&&t()};return document.addEventListener("visibilitychange",n),window.addEventListener("online",t),()=>{document.removeEventListener("visibilitychange",n),window.removeEventListener("online",t)}}),[e])})(e)};class mY extends Error{constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"Open a forecast scenario before calling dump()"),this.name="ForecastNotReadyError"}}var pY=n(52694);const gY=(e,t,n)=>{const a=e.scenarioExternalId,l=void 0===a?void 0:t.byScenarioId[a];if(void 0===l)return;const r=l.result;return{settings:e.monteCarloSettings,status:l.status,progress:l.progress,run:void 0===r?void 0:{pathCount:r.summaries.length,runSeed:r.runSeed,asOfDate:r.asOfDate.toISOString(),signature:r.signature,unadjustedBands:r.unadjustedBands,todaysDollarsBands:r.todaysDollarsBands,summaries:!0===n.chanceOfSuccessPaths?r.summaries:void 0}}},hY=e=>{const t={};for(const l of e){var n=(0,o.A)(l,2);const e=n[0],r=n[1],i={};for(const t of r){var a=(0,o.A)(t,2);const e=a[0],n=a[1];i[e]=n}t[e]=i}return t},vY=function(){var e,t;let n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};window.monarch=null!==(e=window.monarch)&&void 0!==e?e:{},window.monarch.debug=null!==(t=window.monarch.debug)&&void 0!==t?t:{};const a={dump:e=>{console.warn("Dump contains personal and financial data. Only share with Monarch support.");const t=!0===(null===e||void 0===e?void 0:e.download);var a;a={download_requested:t},(0,Ge.u4)(Ye.yq.DebugDumpTriggered,(0,U.A)((0,U.A)({},a),zf()));const l=function(){var e,t,n,a,l,r;let o=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const s=(null!==(e=o.getForecastState)&&void 0!==e?e:wE.getState)(),c=(null!==(t=o.getMonteCarloResultsState)&&void 0!==t?t:of.getState)();if(s.needsInitialization||null===s.projection)throw new mY;return{dumpVersion:2,engineVersion:1,exportedAt:(new Date).toISOString(),webVersion:null!==(n=(0,pY.s)())&&void 0!==n?n:"unknown",userAgent:"undefined"===typeof navigator?"":navigator.userAgent,currentUserId:s.currentUserId,scenarioExternalId:s.scenarioExternalId,inputs:{settings:s.settings,accounts:s.accounts,events:null!==(a=s.events)&&void 0!==a?a:[],customWithdrawalOrderIds:s.customWithdrawalOrderIds,uncategorizedSavingsSettings:s.uncategorizedSavingsSettings,householdUserIds:s.householdUserIds,dollarMode:s.dollarMode},monteCarlo:gY(s,c,i),projection:{asOfDate:null!==(l=null===(r=s.projectionAsOfDate)||void 0===r?void 0:r.toISOString())&&void 0!==l?l:null,snapshots:s.projection.snapshots,effectTable:s.projection.effectTable,annotations:s.projection.annotations}
1,scenario:s.rawScenarioSnapshot,runtime:{lastSavedAt:s.lastSavedAt?s.lastSavedAt.toISOString():null,dirtyCategories:s.dirtyCategories,savingCategories:s.savingCategories,saveErrors:s.saveErrors,isConflicted:s.isConflicted,error:s.error,needsInitialization:s.needsInitialization}}}({getForecastState:n.getForecastState,getMonteCarloResultsState:n.getMonteCarloResultsState},{chanceOfSuccessPaths:null===e||void 0===e?void 0:e.chanceOfSuccessPaths}),r=(e=>(0,U.A)((0,U.A)({},e),{},{projection:(0,U.A)((0,U.A)({},e.projection),{},{effectTable:hY(e.projection.effectTable)})}))(l);return t&&(e=>{const t=new Blob([JSON.stringify(e,null,2)],{type:"application/json"}),n=URL.createObjectURL(t),a=document.createElement("a");a.href=n,a.download="monarch-forecast-dump-".concat(e.exportedAt.replace(/:/g,"-"),".json"),a.click(),URL.revokeObjectURL(n)})(r),r}};return window.monarch.debug.forecast=a,()=>{var e,t;(null===(e=window.monarch)||void 0===e||null===(t=e.debug)||void 0===t?void 0:t.forecast)===a&&(window.monarch.debug.forecast=void 0)}},fY=["isNewScenario","returnTo"],EY=()=>{var e,t,n,r;const i=(0,l.g)().scenarioId,s=void 0===i?"":i,c=(0,l.Zp)(),d=(0,l.zy)().state,u=Boolean(null===d||void 0===d?void 0:d.isNewScenario),m=Boolean(null===d||void 0===d||null===(e=d.returnTo)||void 0===e?void 0:e.scenarioId),p=((e,t)=>e?t?"create-from-scratch":"initialization":"review")(u,m),g=wE((e=>e.hydrateFromScenario)),h=(0,a.useRef)(null),v=(0,a.useState)(null),f=(0,o.A)(v,2),E=f[0],y=f[1],b=(0,a.useRef)(null),x=(0,et.I)(Dv.Tu,{variables:{externalId:s||null}}),w=x.data,C=x.isLoadingInitialData,A=x.error,I=x.refetch;(0,et.I)(Io.iO);const k=null===w||void 0===w?void 0:w.forecastScenario,S=null!==(t=null===k||void 0===k?void 0:k.externalId)&&void 0!==t?t:null;h.current=k;const N=(0,a.useMemo)((()=>{const e=null===k||void 0===k?void 0:k.categoryVersions;return e?"".concat(e.settingsVersion,".").concat(e.eventsVersion,".").concat(e.accountsVersion,".").concat(e.participantsVersion,".").concat(e.priorityRulesVersion):null}),[null===k||void 0===k?void 0:k.categoryVersions]),T=null===w||void 0===w||null===(n=w.me)||void 0===n||null===(r=n.profile)||void 0===r?void 0:r.completedForecastOnboardingAt,_=Boolean(T);(()=>{const e=(0,nC.xd)(),t=(0,o.A)(e,1)[0],n=t.users,l=t.currentUser,r=wE((e=>e.setCurrentUserId)),i=wE((e=>e.setHouseholdUserIds));(0,a.useLayoutEffect)((()=>{r(null===l||void 0===l?void 0:l.id),i((null!==n&&void 0!==n?n:[]).map((e=>e.id)))}),[null===l||void 0===l?void 0:l.id,n,r,i])})(),(0,a.useEffect)((()=>vY()),[]);const D=(0,a.useState)("loading"),R=(0,o.A)(D,2),M=R[0],L=R[1],O=(0,a.useRef)(null);(0,a.useEffect)((()=>{if(s!==S)return;const e=h.current;if(!e||!S)return;S===E?null!==N&&N!==b.current&&((e,t)=>{const n=wE.getState();if(a=n.categoryVersions,l=e.categoryVersions,!(a&&l&&(l.settingsVersion>a.settings||l.eventsVersion>a.events||l.accountsVersion>a.accounts||l.participantsVersion>a.participants||l.priorityRulesVersion>a.priorityRules)))return void(b.current=t);var a,l;if(!Tx(n))return;const r=wE.temporal.getState();r.pause();try{g(e),b.current=t}finally{r.resume()}})(e,N):((e,t)=>{const n=wE.temporal.getState();n.pause();try{g(e),y(S),b.current=t}finally{n.clear(),n.resume()}})(e,N)}),[E,g,S,s,N]),((e,t,n)=>{(0,a.useEffect)((()=>{var a,l;if(!e||!t||n!==t)return;const r=null!==(a=e.baselineIncome)&&void 0!==a?a:0,o=null!==(l=e.baselineExpenses)&&void 0!==l?l:0,i=wE.getState(),s=i.presetAmounts;if(s&&s.annualIncome===r&&s.annualExpenses===o)return;if(!Tx(i))return;const c=wE.temporal.getState();c.pause();try{wE.setState((e=>{e.presetAmounts={annualIncome:r,annualExpenses:o}}))}finally{c.resume()}}),[e,t,n])})(k,S,E),((e,t)=>{const n=$E(),l=ay(),r=iy(),o=wE((e=>e.updateEvent));(0,a.useEffect)((()=>{if(!e||t!==e||!l||!n||!r)return;const a=r.annualExpenses;if((0,De.Ym)(a)!==(0,De.Ym)(n.amount)){const e=wE.temporal.getState();e.pause();try{o(n.id,{amount:a})}finally{e.resume()}}}),[e,t,l,n,r,o])})(S,E),(0,a.useEffect)((()=>{if(C||A)return;if(!k||!S||E!==S)return;if(O.current===S)return;O.current=S;L(u||!_?"needs-onboarding":"ready")}),[C,A,k,S,E,_,u]);const P=(0,a.useMemo)((()=>C?"loading":A?"error":k?s!==S?"route-mismatch":S&&E!==S?"hydrating":"ready":"not-found"),[C,A,k,s,S,E]),B="not-found"===P,z=(0,a.useMemo)((()=>"ready"===P?M:null===E||u?"loading":M),[P,M,E,u]),F=(0,a.useMemo)((()=>null!==E&&""!==s&&E!==s),[E,s]),G=(0,a.useCallback)((async()=>{var e,t;return null!==(e=null===(t=(await I()).data)||void 0===t?void 0:t.forecastScenario)&&void 0!==e?e:null}),[I]),Y=(0,a.useCallback)((()=>
1{if(L("ready"),null===d||void 0===d||!d.isNewScenario)return;d.isNewScenario,d.returnTo;const e=(0,En.A)(d,fY);c("".concat(window.location.pathname).concat(window.location.search),{replace:!0,state:Object.keys(e).length>0?e:null})}),[c,d]);return{initState:z,scenarioId:S,hydratedScenarioId:E,isNewScenario:u,mode:p,hasOnboarded:_,isLoading:C,isScenarioSwitching:F,error:A,shouldRedirectToScenarioRoot:B,refetch:I,refetchScenario:G,markOnboardingComplete:Y}},yY=()=>{const e=(0,l.g)(),t=e.scenarioId,n=void 0===t?"":t,r=e["*"],o=(0,l.zy)(),i=o.pathname,s=o.search,c=py(),d=c.isEnabled,u=c.isResolved;(0,a.useEffect)((()=>{if(!n||!i.includes("/forecast/"))return;const e=(e=>{const t=e.startsWith("?")?e.slice(1):e,n=tp.A.parse(t),a="string"===typeof n.sidebar?n.sidebar:null;return a?(0,U.A)((0,U.A)((0,U.A)({sidebar:a},"string"===typeof n.id&&""!==n.id?{id:n.id}:{}),"string"===typeof n.year&&""!==n.year?{year:n.year}:{}),"string"===typeof n.focusAccountId&&""!==n.focusAccountId?{focusAccountId:n.focusAccountId}:{}):null})(s),t=Vx.getState();t.setSnapshotForScenario(n,e);const a=Kx(r);!a.shouldRedirect&&("plan"===a.mode||u&&d)&&(t.setModeForScenario(n,a.mode),"chance-of-success"!==a.mode?t.setYearTableViewForScenario(n,a.mode,a.yearTableView):t.setChanceOfSuccessViewForScenario(n,a.chanceOfSuccessView))}),[n,i,s,r,d,u])},bY=e=>{let t=e.initState,n=e.isScenarioSwitching;const o=(0,l.g)().scenarioId,i=void 0===o?"":o,s=wE((e=>e.scenarioExternalId)),c=wE((e=>e.events)),d=wE((e=>e.accounts)),u=vy(),m=u.openedSidebarDetails,p=u.closeSidebar;(0,a.useEffect)((()=>{i&&s===i&&(n||"loading"===t||m&&(((e,t,n)=>{if(!e)return!0;const a=null!==t&&void 0!==t?t:[],l=null!==n&&void 0!==n?n:[];return(0,r.YW)(e).with({type:"event"},(e=>{let t=e.id;return a.some((e=>e.id===t))})).with({type:"account"},(e=>{let t=e.id;return null===t||l.some((e=>e.id===t))})).with({type:"uncategorized-savings"},(e=>{let t=e.accountId;return!t||l.some((e=>e.id===t))})).with({type:"assumptions"},{type:"chance-of-success"},{type:"withdrawal-order"},{type:"new-event"},(()=>!0)).exhaustive()})(m,c,d)||(p(),Vx.getState().clearSnapshotForScenario(i))))}),[i,s,t,n,m,c,d,p])},xY=e=>{const t=QE(),n=ty(),l=wE((e=>e.scenarioExternalId)),r=(0,i.n)(Dv.nW,{update:(e,t,n)=>{let a=t.data,l=n.variables;if(!l)return;if(null===a||void 0===a||!a.saveForecastScenarioKpis)return;if(a.saveForecastScenarioKpis.errors)return;const r=l.input,o=r.scenarioExternalId,i=r.kpis;e.modify({fields:{forecastScenarios:function(){return(arguments.length>0&&void 0!==arguments[0]?arguments[0]:[]).map((e=>"externalId"in e&&e.externalId===o?(0,U.A)((0,U.A)({},e),{},{kpis:i}):e))}}})}}),s=(0,o.A)(r,1)[0],c=(0,a.useRef)(null),d=Jx({startYear:t.startYear,currentParticipant:n}),u=(0,a.useMemo)((()=>(e=>(0,Tp.n)(e.netWorthEOY)?{netWorthToday:e.netWorthEOY,netWorthAtRetirement:e.netWorthAtRetirement,retirementAge:e.retirementAge,netWorthAtEnd:e.netWorthAtEnd,lifeEventsCount:e.lifeEventsCount}:null)(d)),[d]),m=(0,a.useMemo)((()=>u&&l?{scenarioId:l,kpis:u}:null),[l,u]),p=(0,xy.d)(m,500);(0,a.useEffect)((()=>{var t;if(!p)return;if(p.scenarioId!==l)return;if(!l||l!==e)return;const n=JSON.stringify(p.kpis);(null===(t=c.current)||void 0===t?void 0:t.scenarioId)===l&&c.current.hash===n||(c.current={scenarioId:l,hash:n},(async()=>{try{var e;const t=await s({variables:{input:{scenarioExternalId:l,kpis:p.kpis}}}),n=t.data,a=t.errors;(null!==a&&void 0!==a&&a.length||null!==n&&void 0!==n&&null!==(e=n.saveForecastScenarioKpis)&&void 0!==e&&e.errors)&&(c.current=null)}catch(t){c.current=null}})())}),[l,e,s,p])};var wY,CY=n(11606),AY=n(38893);const IY=a.memo((()=>{const e=(0,l.zy)(),t=(0,l.g)(),n=t.scenarioId,r=void 0===n?"":n,i=t["*"],s=tp.A.parse(e.search).upgradeSuccess,c=(0,b.cn)("upgradeSuccess"),d=(0,Pd.h)("true"===s),u=(0,o.A)(d,2),m=u[0],p=u[1],g=p.open,h=p.close;(0,a.useEffect)((()=>{"true"===s&&g()}),[s,g]),(0,a.useEffect)((()=>()=>(()=>{const e=lA;lA=null,e&&of.getState().cancelRun(e.scenarioId),qC()})()),[]);const v=()=>{c(void 0),h()};if(jx(r)||Wx(r)){const t=Kx([r,i].filter(Boolean).join("/")).path;return a.createElement(l.C5,{"data-external-id":"forecast",to:{pathname:"".concat(I.su,"/").concat(t),search:e.search},replace:!0})}return a.createElement(a.Fragment,null,a.createElement(np.m,null,a.createElement(hG,null,a.createElement(kY,null))),a.createElement(np.m,{showWhenNoAccess:!0},a.createElement(nY,null)),a.createElement(m,{maxWidth:"440px",onClose:v},a.createElement(CY.R,{continueCopy:"Continue to forecast",onClose:v,onContinue:v,renderContentOnly:!0})))})),kY=a.memo((()=>{var e;const t=(0,l.g)()["*"],n=Zx(),r=(0,a.useMemo)((()=>({forecast_mode:n.mode,forecast_view:"chance-of-success"===n.mode?n.chanceOfSuccessView:n.yearTableView})),[n]),o=EY(),i=o.initState,s=o.hasOnboarded,c=o.mode,d=o.isLoading,u=o.isScenarioSwitching,m=o.hydratedScenarioId,p=o.error,g=o.refetchScenario,h=o.shouldRedirectToScenarioRoot,v=o.markOnboardingComplete;yY(),bY({initState:i,isScenarioSwitching:u});const f=wE((e=>e.error)),E=NY(),y=null!==(e=null===p||void 0===p?void 0:p.message)&&void 0!==e?e:"ready"===i?f:null,b=!!y||E;my(),uY(g),xY(m);const x=wE(Nx),w=SY(),C="needs-onboarding"!==i,A="ready"===i||s,k=d&&!s;if(h){const e=Kx(t).path;return a.createElement(l.C5,{"data-external-id":"plus-tier-forecast",to:{pathname:"".concat(I.su,"/").concat(e),search:window.location.search},replace:!0})}if(w)return a.createElement(l.C5,{"data-external-id":"plus-tier-forecast",to:w,replace:!0});const S="needs-onboarding"===i;return a.createElement(nw,{"data-external-id":"plus-tier-forecast"},a.createElement("div",{className:(0,q.cn)("flex w-full max-w-full overflow-hidden",S&&"py-gutter")},a.createElement(EG,null),a.createElement(AY.I,{when:x,message:"You have unsaved forecast changes."}),a.createElement("div",{className:"flex min-w-0 flex-1 flex-col"},a.createElement(rG.Y,{name:"Forecasting",pageProperties:r,overrideTitle:a.createElement(XG,null),overrideHtmlTitle:"Forecasting",parentRoute:null,isLoading:k,showHeader:C,header:a.createElement(JG,{showControls:A}),shouldScroll:!0},b&&a.createElement("div",{className:"flex flex-col gap-sm px-gutter pb-gutter"},E&&a.createElement(vS,{refetchScenario:g}),y&&a.createElement(TY,{type:"error"},y)),a.createElement("div",{className:(0,q.cn)("flex flex-1",S&&"h-full min-h-0")},a.createElement("div",{className:(0,q.cn)("flex min-w-0 flex-1 flex-col gap-gutter px-gutter","ready"===i&&"pb-gutter",S&&"min-h-0")},a.createElement(kF,{initState:i,mode:c,markOnboardingComplete:v})),a.createElement(mS,{initState:i,isScenarioSwitching:u}))))))})),SY=()=>{const e=py(),t=e.isEnabled,n=e.isResolved,a=Qx(),l=a.scenarios,r=a.isLoading,o=Zx(),i=(e=>{let t=e.route,n=e.isMonteCarloEnabled,a=e.isExperimentResolved,l=e.hasOtherScenarios,r=e.isScenariosLoading;if(!t.scenarioId)return null;const o=qx({scenarioId:t.scenarioId,mode:"plan",yearTableView:t.rememberedPlanYearTableView});return a&&!n&&"plan"!==t.mode||a&&n&&"compare"===t.mode&&!r&&!l?o:t.shouldRedirect?t.pathname:null})({route:o,isMonteCarloEnabled:t,isExperimentResolved:n,hasOtherScenarios:l.some((e=>e.id!==o.scenarioId)),isScenariosLoading:r});return i?{pathname:i,search:window.location.search}:null},NY=()=>wE((e=>e.isConflicted)),TY=(0,$d.s)(fu.g)(wY||(wY=(0,wc.A)(["flex items-center justify-between"]))),_Y=()=>{const e=(0,l.zy)(),t=Kx((e=>{const t=e.split("/").filter((e=>e.length>0));return"forecast"!==t[0]?"":t.slice(1).join("/")})(e.pathname)),n=Qx(),r=n.scenarios,s=n.isLoading,c=n.error,d=(0,i.n)(Dv.hs),u=(0,o.A)(d,1
1)[0],m=(0,a.useRef)(!1),p=(0,a.useState)(!1),g=(0,o.A)(p,2),h=g[0],v=g[1],f=(0,a.useState)(null),E=(0,o.A)(f,2),y=E[0],b=E[1],x=(0,a.useState)(0),w=(0,o.A)(x,2),C=w[0],A=w[1],I=(0,a.useState)(null),k=(0,o.A)(I,2),S=k[0],N=k[1];(0,a.useEffect)((()=>{s||c||r.length>0||m.current||h||(m.current=!0,v(!0),b(null),u({update:(e,t)=>{var n;let a=t.data;const l=null===a||void 0===a||null===(n=a.initializeForecast)||void 0===n?void 0:n.scenario;if(!l)return;const r=e.readQuery({query:Dv.Tu,variables:{externalId:null}}),o=e.readQuery({query:Dv.Tu,variables:{externalId:l.externalId}});if(r){const t=(0,U.A)((0,U.A)({},r),{},{forecastScenario:l});e.writeQuery({query:Dv.Tu,variables:{externalId:null},data:t}),e.writeQuery({query:Dv.Tu,variables:{externalId:l.externalId},data:t})}else o&&e.writeQuery({query:Dv.Tu,variables:{externalId:l.externalId},data:(0,U.A)((0,U.A)({},o),{},{forecastScenario:l})})},onQueryUpdated:()=>!1}).then((e=>{var t,n,a,l;const r=null!==(t=null===(n=e.data)||void 0===n||null===(a=n.initializeForecast)||void 0===a||null===(l=a.scenario)||void 0===l?void 0:l.externalId)&&void 0!==t?t:null;if(r)return N(r),void Gf({scenarioId:r,source:"initialize_forecast"});b(new Error("Something went wrong setting up your forecast. Please try again."))})).catch((e=>{b(e instanceof Error?e:new Error("Failed to initialize forecast"))})).finally((()=>v(!1))))}),[u,h,s,C,c,r.length]);const T=(0,a.useCallback)((()=>{m.current=!1,b(null),N(null),A((e=>e+1))}),[]),_=(0,a.useMemo)((()=>{var e,t;return S||(0===r.length?null:null!==(e=null===(t=[...r].sort(((e,t)=>e.order-t.order))[0])||void 0===t?void 0:t.id)&&void 0!==e?e:null)}),[S,r]);return y?a.createElement(rG.Y,{"data-external-id":"redirect-to-first-scenario",name:"Forecasting",parentRoute:null},a.createElement("div",{className:"p-gutter"},a.createElement(fu.g,{type:"error"},a.createElement("div",{className:"flex items-center justify-between gap-sm"},a.createElement("span",null,y.message),a.createElement(wt.Xb,{onClick:T},"Retry"))))):c?a.createElement(rG.Y,{"data-external-id":"redirect-to-first-scenario",name:"Forecasting",parentRoute:null},a.createElement("div",{className:"p-gutter"},a.createElement(fu.g,{type:"error"},a.createElement("div",{className:"flex items-center justify-between gap-sm"},a.createElement("span",null,"We couldn't load your forecast scenarios. Please try again."),a.createElement(wt.Xb,{onClick:()=>window.location.reload()},"Retry"))))):s||h?a.createElement(rG.Y,{"data-external-id":"redirect-to-first-scenario",name:"Forecasting",isLoading:!0,parentRoute:null},a.createElement(a.Fragment,null)):_?a.createElement(l.C5,{"data-external-id":"redirect-to-first-scenario",to:{pathname:qx((0,U.A)({scenarioId:_},t)),search:window.location.search},state:{isNewScenario:S===_},replace:!0}):a.createElement(rG.Y,{"data-external-id":"redirect-to-first-scenario",name:"Forecasting",parentRoute:null},a.createElement("div",{className:"p-gutter"},a.createElement(fu.g,{type:"warning"},a.createElement("div",{className:"flex items-center justify-between gap-sm"},a.createElement("span",null,"We couldn't find any forecast scenarios yet."),a.createElement(wt.Xb,{onClick:T},"Try again")))))},DY=()=>a.createElement(a.Fragment,null,a.createElement(np.m,null,a.createElement(_Y,null)),a.createElement(np.m,{showWhenNoAccess:!0},a.createElement(nY,null)));var RY=n(96083),MY=n(35190),LY=n(96987);const OY=e=>{let t=e.name,n=e.defaultOnTimeout,r=e.onValue,o=void 0===r?"on":r,i=e.redirectTo,s=void 0===i?I.JZ.dashboard.path:i,c=e.children;return a.createElement(MY.T,{"data-external-id":"feature-flag-route",name:t,defaultOnTimeout:n},(e=>e===LY.eu||(0,Tc.A)(o)&&e===o||(0,RY.A)(o)&&o.includes(e)?c:a.createElement(l.C5,{to:s,replace:!0})))};var PY=n(39069),BY=n(66808),zY=n(19822),FY=n(81043);const GY=e=>{let t=e.children;const n=(0,l.Zp)(),r=(0,l.zy)(),o=(0,d.d4)(FY.T2),i=(0,d.d4)(FY.$Y),s=(0,zY.r)(),c=s.subscription,u=s.isLoadingInitialData,m=null!==c&&void 0!==c?c:{},p=m.entitlements,g=m.paymentMethod;return(0,a.useEffect)((()=>{const e=r.pathname.startsWith(I.JZ.advisorPortal.path),t=r.pathname===I.JZ.advisors.signup.payment.path;if(!u){const a=!(0,PY.A)(p);a||!e||t||n(I.JZ.advisors.signup.payment());const l=(0,BY.A)(g);a&&l&&e&&r.pathname!==I.JZ.advisorPortal.billing.path&&n(I.JZ.advisorPortal.billing())}}),[r.pathname,u,p,g,n]),o||i?a.createElement(a.Fragment,null,t):a.createElement(l.C5,{"data-external-id":"advisor-route",to:"/",replace:!0})};var YY=n(70687);const UY=e=>{let t=e.children,n=e.allowLocal,r=void 0!==n&&n;
1const o=(0,d.d4)(FY.$Y);return(r?(0,YY.z)(o):o)?a.createElement(a.Fragment,null,t):a.createElement(l.C5,{"data-external-id":"employee-route",to:"/",replace:!0})};var VY=n(81831),WY=n(83506),jY=n(81577);const HY=e=>{let t=e.children;const n=(0,jY.mB)(),r=n.isCashFlowSunsetOn;return n.isResolved?r?a.createElement(l.C5,{"data-external-id":"sunset-cash-flow-route",to:I.JZ.reports.cashFlow(),replace:!0}):t:a.createElement("div",{"data-external-id":"sunset-cash-flow-route",className:"flex h-full flex-1 flex-col items-center justify-center"},a.createElement(p.i,null))};var KY=n(24789),qY=n(88808),$Y=n(65791),ZY=n(4211),JY=n(82429),XY=n(18075),QY=n(64680),eU=n(45808),tU=n(65548),nU=n(34141),aU=n(34992),lU=n(57271),rU=n(96903),oU=n(99242);const iU=e=>{let t=e.accountId,n=e.companyName,l=e.isPublic;return a.createElement(oU.B,{"data-external-id":"equity-feedback-modal",formName:"equity_account",accountId:t,metadata:{companyName:n,isPublic:l},title:"Share your feedback",description:"Want to share more details about your experience?",analyticsEventName:Ye.Sd.EquityAccountFeedbackSubmitted})};var sU=n(33063),cU=n(37423),dU=n(30377),uU=n(6229);const mU=e=>{var t,n,l,r,i;let s=e.accountId,c=e.onAddGrantButtonClick,d=e.onEditGrantsClick;const u=(0,a.useState)("security"),m=(0,o.A)(u,2),g=m[0],h=m[1],v=(0,a.useState)("asc"),f=(0,o.A)(v,2),E=f[0],y=f[1],b=(0,a.useState)("security"),x=(0,o.A)(b,2),w=x[0],C=x[1],A=(0,a.useState)("asc"),I=(0,o.A)(A,2),k=I[0],S=I[1],N=(0,et.I)(LU,{variables:{accountId:s}}),T=N.data,_=N.isNetworkRequestInFlight,D=null!==(t=null===T||void 0===T||null===(n=T.account)||void 0===n?void 0:n.equityGrants)&&void 0!==t?t:[],R=(null===T||void 0===T||null===(l=T.account)||void 0===l||null===(r=l.company)||void 0===r?void 0:r.name)||"Company",M=(0,a.useMemo)((()=>{var e;if(null===T||void 0===T||null===(e=T.account)||void 0===e||!e.company)return"409a (FMV)";const t=T.account.company.valuationMethod;return"fmv_409a"===t?"409a (FMV)":"preferred_price"===t?"Preferred price":"Custom price"}),[null===T||void 0===T||null===(i=T.account)||void 0===i?void 0:i.company]),L=(0,a.useCallback)(((e,t)=>{var n,a;const l=null===(n=e.vestingTimeline)||void 0===n?void 0:n.find((e=>(null===e||void 0===e?void 0:e.date)&&(0,dU.wn)(e.date))),r=(null===l||void 0===l?void 0:l.earlyExercised)||0,o=e.exercisedQuantity||0,i=e.vestedQuantity||0,s=Math.max(0,o-r),c=Math.max(0,i-s);switch(t){case"security":return(e.grantNickname||R).toLowerCase();case"exercisePrice":return e.strikePrice||0;case"quantity":return e.quantityGranted||0;case"vested":return c;case"exercised":return s;case"earlyExercised":return r;case"value":return null!==(a=e.currentValue)&&void 0!==a?a:0;default:return 0}}),[R]),O=(0,a.useCallback)(((e,t,n)=>{if(!t)return e;return(0,sU.A)(((e,a)=>{const l=L(e,t),r=L(a,t);let o=0;return l<r?o=-1:l>r&&(o=1),"asc"===n?o:-o}),e)}),[L]),P=(e,t,n,a,l)=>{t===e?"asc"===n?l("desc"):(a(null),l("asc")):(a(e),l("asc"))},B=(0,a.useMemo)((()=>{const e=D.filter((e=>{var t;const n=null===(t=e.grantType)||void 0===t?void 0:t.toLowerCase();return"iso"===n||"nso"===n})),t=D.filter((e=>{var t;const n=null===(t=e.grantType)||void 0===t?void 0:t.toLowerCase();return"rsu"===n||"rsa"===n||"espp"===n}));return{optionGrants:O(e,g,E),shareGrants:O(t,w,k)}}),[D,g,E,w,k,O]),z=B.optionGrants,F=B.shareGrants;if(_)return a.createElement(Xl.AM,{"data-external-id":"equity-grants-list-container"},a.createElement(pU,null,a.createElement(p.i,null)));if(0===D.length)return a.createElement(Xl.AM,{"data-external-id":"equity-grants-list-container"},a.createElement(qY.S,null,a.createElement(cU.vx,{emptyTheme:cU.dO.NEW,title:"No equity grants",subtitle:"Add your first equity grant to start tracking your compensation",button:c?{title:"Save grant",onClick:c}:void 0})));const G=(e,t,n,l,r,o,i)=>a.createElement(IU,{onClick:()=>P(e,n,l,r,o)},t," ",i&&a.createElement(JY.d,{content:i,place:"top",hyphens:!1},a.createElement(sl.ZQ,{name:"info",size:12})));return a.createElement(Xl.AM,{"data-external-id":"equity-grants-list-container"},a.createElement($Y.H8,{title:"Grants",controls:a.createElement(uU.f,null,d&&a.createElement(wt.Xb,{onClick:d},"Manage grants"))}),a.createElement(yU,null,a.createElement(gU,null,z.length>0&&a.createElement(hU,null,a.createElement(vU,null,a.createElement(fU,null,"ISO and NSO")),a.createElement(bU,null,a.createElement(kU,{onClick:()=>P("security",g,E,h,y)},"Security"),G("exercisePrice","Exercise price",g,E,h,y,"The price per share you must pay to exercise these options (also called strike price)."),G("quantity","Quantity",g,E,h,y),G("vested","Vested",g,E,h,y,"Options that have vested and unexercised."),G("exercised","Exercised",g,E,h,y,"Options that have been exercised and converted to shares."),G("earlyExercised","Early exercised",g,E,h,y,"Options that have been exercised and have not vested. These shares are subject to repurchase until they vest."),G("value","Value",g,E,h,y,"Vested unexercised options valued at (".concat(M," \u2013 strike) plus exercised shares you still hold at full ").concat(M," value. Sold shares are excluded."))),a.createElement(EU,null,z.map((e=>{var t;const n=e.currentValue,l=e.quantityGranted||0,r=e.vestedQuantity||0,o=e.exercisedQuantity||0,i=null===(t=e.vestingTimeline)||void 0===t?void 0:t.find((e=>(null===e||void 0===e?void 0:e.date)&&(0,dU.wn)(e.date))),s=(null===i||void 0===i?void 0:i.earlyExercised)||0,c=Math.max(0,o-s),d=Math.max(0,r-c);return a.createElement(xU,{key:e.id},a.createElement(SU,null,a.createElement(NU,null,e.grantNickname||R),a.createElement(TU,null,e.grantType)),a.createElement(_U,null,e.strikePrice?"$".concat((0,dU.$g)(e.strikePrice)):"--"),a.createElement(_U,null,l.toLocaleStr
1ing()),a.createElement(DU,null,d.toLocaleString()),a.createElement(RU,null,c.toLocaleString()),a.createElement(MU,{$hasValue:s>0},s>0?s.toLocaleString():"--"),a.createElement(_U,null,null!==n&&void 0!==n?"$".concat(n.toLocaleString(void 0,{minimumFractionDigits:2,maximumFractionDigits:2})):"--"))})))),F.length>0&&a.createElement(hU,null,a.createElement(vU,null,a.createElement(fU,null,"RSU and RSA")),a.createElement(wU,null,a.createElement(kU,{onClick:()=>P("security",w,k,C,S)},"Security"),a.createElement(AU,null),G("quantity","Quantity",w,k,C,S),G("vested","Vested",w,k,C,S,"Shares that have vested."),a.createElement(AU,null),a.createElement(AU,null),G("value","Value",w,k,C,S,"Current value of vested shares based on ".concat(M,"."))),a.createElement(EU,null,F.map((e=>{const t=e.currentValue,n=e.quantityGranted||0,l=e.vestedQuantity||0;return a.createElement(CU,{key:e.id},a.createElement(SU,null,a.createElement(NU,null,e.grantNickname||R),a.createElement(TU,null,e.grantType)),a.createElement(_U,null),a.createElement(_U,null,n.toLocaleString()),a.createElement(DU,null,l.toLocaleString()),a.createElement(_U,null),a.createElement(_U,null),a.createElement(_U,null,null!==t&&void 0!==t?"$".concat(t.toLocaleString(void 0,{minimumFractionDigits:2,maximumFractionDigits:2})):"--"))})))))))},pU=u.default.div.withConfig({displayName:"EquityGrantsListContainer__LoadingContainer",componentId:"sc-1xisdin-0"})(["padding:",";display:flex;justify-content:center;"],vt.YK.xlarge),gU=u.default.div.withConfig({displayName:"EquityGrantsListContainer__TableContainer",componentId:"sc-1xisdin-1"})(["width:100%;min-width:980px;"]),hU=u.default.div.withConfig({displayName:"EquityGrantsListContainer__Section",componentId:"sc-1xisdin-2"})(["&:not(:last-child){margin-bottom:",";}"],vt.YK.xxxsmall),vU=u.default.div.withConfig({displayName:"EquityGrantsListContainer__SectionTitle",componentId:"sc-1xisdin-3"})(["background:",";padding:"," ",";margin:0;"],vt.Ee.color.background.secondary,vt.YK.xsmall,vt.YK.default),fU=(0,u.default)(xt.v).attrs({size:"small",color:"content.secondary"}).withConfig({displayName:"EquityGrantsListContainer__SectionTitleText",componentId:"sc-1xisdin-4"})(["letter-spacing:0.5px;font-weight:500;"]),EU=u.default.div.withConfig({displayName:"EquityGrantsListContainer__Table",componentId:"sc-1xisdin-5"})(["width:100%;"]),yU=(0,u.default)(qY.S).withConfig({displayName:"EquityGrantsListContainer__StyledCardBody",componentId:"sc-1xisdin-6"})(["padding:0;"]),bU=u.default.div.withConfig({displayName:"EquityGrantsListContainer__OptionsTableHeader",componentId:"sc-1xisdin-7"})(["display:grid;grid-template-columns:2fr 1fr 1fr 1fr 1fr 1fr 1.5fr;gap:",";padding:"," ",";"],vt.YK.default,vt.YK.small,vt.YK.default),xU=u.default.div.withConfig({displayName:"EquityGrantsListContainer__OptionsTableRow",componentId:"sc-1xisdin-8"})(["display:grid;grid-template-columns:2fr 1fr 1fr 1fr 1fr 1fr 1.5fr;gap:",";padding:",";align-items:center;"],vt.YK.default,vt.YK.default),wU=u.default.div.withConfig({displayName:"EquityGrantsListContainer__SharesTableHeader",componentId:"sc-1xisdin-9"})(["display:grid;grid-template-columns:2fr 1fr 1fr 1fr 1fr 1fr 1.5fr;gap:",";padding:"," ",";"],vt.YK.default,vt.YK.small,vt.YK.default),CU=u.default.div.withConfig({displayName:"EquityGrantsListContainer__SharesTableRow",componentId:"sc-1xisdin-10"})(["display:grid;grid-template-columns:2fr 1fr 1fr 1fr 1fr 1fr 1.5fr;gap:",";padding:",";align-items:center;"],vt.YK.default,vt.YK.default),AU=(0,u.default)(xt.v).attrs({size:"small",color:"content.secondary"}).withConfig({displayName:"EquityGrantsListContainer__TableHeaderCell",componentId:"sc-1xisdin-11"})(["display:flex;align-items:center;justify-content:flex-end;gap:",";font-size:14px;font-style:normal;font-weight:500;line-height:20px;color:",";white-space:nowrap;"],vt.YK.xxsmall,vt.Ee.color.content.primary),IU=(0,u.default)(AU).withConfig({displayName:"EquityGrantsListContainer__SortableHeaderCell",componentId:"sc-1xisdin-12"})(["cursor:pointer;user-select:none;transition:color 0.2s;&:hover{color:",";}"],vt.Ee.color.content.brand),kU=(0,u.default)(IU).withConfig({displayName:"EquityGrantsListContainer__SecuritySortableHeaderCell",componentId:"sc-1xisdin-13"})(["justify-content:flex-start;"]),SU=u.default.div.withConfig({displayName:"EquityGrantsListContainer__SecurityCell",componentId:"sc-1xisdin-14"})(["display:flex;flex-direction:column;gap:",";min-width:0;overflow:hidden;"],vt.YK.xxsmall),NU=(0,u.default)(xt.v).attrs({size:"medium",weight:"medium"}).withConfig({displayName:"EquityGrantsListContainer__SecurityName",componentId:"sc-1xisdin-15"})(["overflow:hidden;text-overflow:ellipsis;white-space:nowrap;"]),TU=(0,u.default)(xt.v).attrs({size:"xsmall",weight:"small",color:"content.secondary"}).withConfig({displayName:"EquityGrantsListContainer__SecurityType",componentId:"sc-1xisdin-16"})(["text-transform:uppercase;"]),_U=(0,u.default)(xt.v).attrs({size:"small"}).withConfig({displayName:"EquityGrantsListContainer__CellValue",componentId:"sc-1xisdin-17"})(["text-align:right;min-width:0;overflow:hidden;white-space:nowrap;font-size:",";"],vt.J.base),DU=(0,u.default)(_U).withConfig({displayName:"EquityGrantsListContainer__VestedValue",componentId:"sc-1xisdin-18"})(["color:",";"],vt.Ee.color.equity.table.unexercisedVested),RU=(0,u.default)(_U).withConfig({displayName:"EquityGrantsListContainer__ExercisedValue",componentId:"sc-1xisdin-19"})(["color:",";"],vt.Ee.color.equity.table.owned),MU=(0,u.default)(_U).withConfig({displayName:"EquityGrantsListContainer__EarlyExercisedValue",componentId:"sc-1xisdin-20"})(["color:",";"],(e=>e.$hasValue?vt.Ee.color.equity.table.earlyExercisedUnvested:vt.Ee.color.content.primary)),LU=Ee.lj3;var OU=n(42670),PU=n(90565);const BU=[{label:"Shares",value:"shares"},{label:"Value",value:"value"}],zU=e=>{let t=e.grants;const n=(0,u.useTheme)(),l=(0,a.useState)("shares"),r=(0,o.A)(l,2),i=r[0],s=r[1],c=(0,qd.W)(),d=(0,o.A)(c,2),m=d[0],p=d[1].width,g=void 0===p?0:p,h=(0,a.useMemo)((()=>({exercised:n.variables.color.equity.chart.owned,earlyExercised:n.variables.color.equity.chart.earlyExercisedUnvested,vested:n.variables.color.equity.chart.unexercisedVested,unvested:n.variables.color.equity.chart.unvested,sold:n.variables.color.content.secondary})),[n]),v=(0,a.useMemo)((()=>{const e=new Set;t.forEach((t=>
1{(t.vestingTimeline||[]).forEach((t=>{e.add(t.date)}))}));const n=(0,Nc.A)((e=>new Date(e).getTime()),[...e]),a=t.map((e=>{const t=e.vestingTimeline||[],a=new Map;t.forEach((e=>{a.set(e.date,e)}));const l=(0,Nc.A)((e=>new Date(e).getTime()),t.map((e=>e.date))),r=l[l.length-1],o=r?a.get(r):null;return o&&n.forEach((e=>{new Date(e).getTime()>new Date(r).getTime()&&a.set(e,(0,U.A)((0,U.A)({},o),{},{date:e}))})),a})),l=new Map;a.forEach((e=>{e.forEach((e=>{if(!e)return;const t=(0,dU.Wj)(e.date),n=l.get(t);var a,r,o,i,s,c,d,u,m,p,g,h,v,f,E,y;n?(n.exercised+=e.exercised,n.earlyExercised+=e.earlyExercised,n.vested+=e.vested,n.unvested+=e.unvested,n.forfeited+=e.forfeited,n.sold+=null!==(a=e.sold)&&void 0!==a?a:0,n.total+=e.total,n.isCurrentMonth=n.isCurrentMonth||(0,dU.wn)(e.date),n.exercisedValue+=null!==(r=e.exercisedValue)&&void 0!==r?r:0,n.earlyExercisedValue+=null!==(o=e.earlyExercisedValue)&&void 0!==o?o:0,n.vestedValue+=null!==(i=e.vestedValue)&&void 0!==i?i:0,n.unvestedValue+=null!==(s=e.unvestedValue)&&void 0!==s?s:0,n.forfeitedValue+=null!==(c=e.forfeitedValue)&&void 0!==c?c:0,n.soldValue+=null!==(d=e.soldValue)&&void 0!==d?d:0,n.totalValue+=null!==(u=e.totalValue)&&void 0!==u?u:0):l.set(t,{month:t,date:e.date,exercised:e.exercised,earlyExercised:e.earlyExercised,vested:e.vested,unvested:e.unvested,forfeited:e.forfeited,sold:null!==(m=e.sold)&&void 0!==m?m:0,total:e.total,isCurrentMonth:(0,dU.wn)(e.date),exercisedValue:null!==(p=e.exercisedValue)&&void 0!==p?p:0,earlyExercisedValue:null!==(g=e.earlyExercisedValue)&&void 0!==g?g:0,vestedValue:null!==(h=e.vestedValue)&&void 0!==h?h:0,unvestedValue:null!==(v=e.unvestedValue)&&void 0!==v?v:0,forfeitedValue:null!==(f=e.forfeitedValue)&&void 0!==f?f:0,soldValue:null!==(E=e.soldValue)&&void 0!==E?E:0,totalValue:null!==(y=e.totalValue)&&void 0!==y?y:0})}))}));const r=(0,Nc.A)((e=>
1new Date(e.date).getTime()),[...l.values()]),o=r.find((e=>e.isCurrentMonth)),i=o?o.exercised+o.earlyExercised+o.vested:0,s=o?o.exercisedValue+o.earlyExercisedValue+o.vestedValue:0,c=Math.max(...r.map((e=>e.total)),0),d=Math.max(...r.map((e=>e.totalValue)),0);return{months:r,vestedSharesTotal:i,vestedValueTotal:s,maxTotalShares:c,maxTotalValue:d}}),[t]),f="value"===i,E=f?v.vestedValueTotal:v.vestedSharesTotal,y=f?v.maxTotalValue:v.maxTotalShares,b=e=>f?(0,rl.Ig)(e):e.toLocaleString(),x=(0,a.useMemo)((()=>{const e=v.months.length;let t;return t=e<=12?1:e<=24?3:e<=36?5:e<=48?7:e<=60?9:11,v.months.map(((e,n)=>{var a;const l=f?e.exercisedValue:e.exercised,r=f?e.earlyExercisedValue:e.earlyExercised,o=f?e.vestedValue:e.vested,i=f?e.unvestedValue:e.unvested,s=f?0:null!==(a=e.sold)&&void 0!==a?a:0;return{month:0===n||n%t===0?e.month:"",fullMonth:e.month,exercised:l,earlyExercised:r,vested:o,unvested:i,sold:s,isCurrentMonth:e.isCurrentMonth,rawData:e}}))}),[v.months,f]),w=(0,a.useMemo)((()=>{const e=v.months.some((e=>e.exercised>0)),t=v.months.some((e=>e.earlyExercised>0)),n=v.months.some((e=>e.vested>0)),a=v.months.some((e=>e.unvested>0)),l=!f&&v.months.some((e=>{var t;return(null!==(t=e.sold)&&void 0!==t?t:0)>0}));return[{name:"exercised",label:"Exercised",color:h.exercised,hasData:e},{name:"earlyExercised",label:"Early Exercised",color:h.earlyExercised,hasData:t},{name:"vested",label:"Vested",color:h.vested,hasData:n},{name:"unvested",label:"Unvested",color:h.unvested,hasData:a},{name:"sold",label:"Sold",color:h.sold,hasData:l}].filter((e=>e.hasData)).map((e=>({name:e.name,label:e.label,color:e.color})))}),[v.months,h,f]),C=u.default.span.withConfig({displayName:"VestingScheduleChart__TooltipLabel",componentId:"sc-1pzn17a-0"})(["flex-grow:1;text-align:left;margin-right:40px;"]),A=(0,a.useMemo)((()=>x.findIndex((e=>e.isCurrentMonth))),[x]);return 0===v.months.length?null:a.createElement(FU,{"data-external-id":"vesting-schedule-chart"},a.createElement(GU,null,a.createElement(YU,null,a.createElement(UU,null,a.createElement(VU,null,"Vesting Schedule"),a.createElement(WU,null,a.createElement(jU,null,b(E)," securities"),a.createElement(HU,null,"of ",b(y)))),a.createElement(KU,null,a.createElement(qU,null,a.createElement(fe.hGA,{placeholder:fe.L2e,size:"sm",value:i,onValueChange:e=>s(e||"shares"),options:BU})))),a.createElement($U,{ref:m},a.createElement(PU.vD,{heightPx:360,widthPx:g-32,data:x,barDataKeys:w,xAxisDataKey:"month",formatXAxis:e=>e,formatYAxis:e=>f?(0,rl.Ig)(e):e.toLocaleString(),tooltipComponent:e=>{const t=e.active,n=(0,_a.WS)(e);if(!t||!n)return null;const l=n.rawData,r=f?(null===l||void 0===l?void 0:l.exercised)>0:n.exercised>0,o=f?(null===l||void 0===l?void 0:l.earlyExercised)>0:n.earlyExercised>0,i=f?(null===l||void 0===l?void 0:l.vested)>0:n.vested>0,s=f?(null===l||void 0===l?void 0:l.unvested)>0:n.unvested>0,c=!f&&n.sold>0;return a.createElement(Sa.II,{active:t,header:n.fullMonth||n.month},r&&a.createElement(Na.B,{label:a.createElement(C,null,"Exercised"),value:b(n.exercised),dotFillColor:h.exercised}),o&&a.createElement(Na.B,{label:a.createElement(C,null,"Early Exercised"),value:b(n.earlyExercised),dotFillColor:h.earlyExercised}),i&&a.createElement(Na.B,{label:a.createElement(C,null,"Vested"),value:b(n.vested),dotFillColor:h.vested}),s&&a.createElement(Na.B,{label:a.createElement(C,null,"Unvested"),value:b(n.unvested),dotFillColor:h.unvested}),c&&a.createElement(Na.B,{label:a.createElement(C,null,"Sold"),value:b(n.sold),dotFillColor:h.sold}))},initialPanPosition:"start",minBarWidthPx:6,verticalLineAtIndex:A>=0?A:void 0,margin:{top:20,right:10,bottom:20,left:10},withLegend:!0}))))},FU=(0,u.default)(Xl.AM).withConfig({displayName:"VestingScheduleChart__Root",componentId:"sc-1pzn17a-1"})(["margin-bottom:",";"],vt.YK.gutter),GU=(0,u.default)(qY.S).withConfig({displayName:"VestingScheduleChart__StyledCardBody",componentId:"sc-1pzn17a-2"})(["gap:",";padding-bottom:0;"],vt.YK.xxxsmall),YU=u.default.div.withConfig({displayName:"VestingScheduleChart__Header",componentId:"sc-1pzn17a-3"})(["display:flex;justify-content:space-between;align-items:flex-start;margin-bottom:",";"],vt.YK.xxsmall),UU=u.default.div.withConfig({displayName:"VestingScheduleChart__HeaderLeft",componentId:"sc-1pzn17a-4"})([""]),VU=(0,u.default)(xt.v).attrs({size:"small",color:"content.secondary"}).withConfig({displayName:"VestingScheduleChart__HeaderTitle",componentId:"sc-1pzn17a-5"})(["text-transform:uppercase;letter-spacing:0.5px;margin-bottom:",";"],vt.YK.xsmall),WU=u.default.div.withConfig({displayName:"VestingScheduleChart__VestedAmount",componentId:"sc-1pzn17a-6"})(["display:flex;align-items:baseline;gap:",";"],vt.YK.xsmall),jU=(0,u.default)(xt.v).attrs({size:"xlarge",weight:"medium"}).withConfig({displayName:"VestingScheduleChart__VestedNumber",componentId:"sc-1pzn17a-7"})(["color:",";"],vt.Ee.color.equity.content.value),HU=(0,u.default)(xt.v).attrs({size:"default",color:"content.secondary"}).withConfig({displayName:"VestingScheduleChart__TotalText",componentId:"sc-1pzn17a-8"})([""]),KU=u.default.div.withConfig({displayName:"VestingScheduleChart__Filters",componentId:"sc-1pzn17a-9"})(["display:flex;gap:",";"],vt.YK.small),qU=u.default.div.withConfig({displayName:"VestingScheduleChart__FilterSelectWrapper",componentId:"sc-1pzn17a-10"})(["min-width:120px;"]),$U=u.default.div.withConfig({displayName:"VestingScheduleChart__
1ChartContainer",componentId:"sc-1pzn17a-11"})(["padding:0;"]);var ZU,JU=n(97239),XU=n(2113),QU=n(25185),eV=n(27236),tV=n(86730),nV=n(29379),aV=n(97521),lV=n(17800),rV=n(45564),oV=n(12985);const iV="Account Details",sV="Accounts",cV=(0,u.keyframes)(["0%{transform:scale(1);}25%{transform:scale(1.3);}50%{transform:scale(1);}75%{transform:scale(1.15);}100%{transform:scale(1);}"]),dV=(0,Qt.J)("\n  query Web_EquityAccountDetails_getAccount($id: UUID!) {\n    account(id: $id) {\n      id\n      ...AccountFields\n      ...EditAccountFormFields\n      ...AccountNotesInlineEditCardFields\n      isLiability\n      name\n      ownedByUser {\n        id\n        name\n      }\n      company {\n        id\n        name\n        isPublic\n        employmentStatus\n        ownerStartDate\n        ownerEndDate\n        fullyDilutedShares\n        latestFundingRound\n        latestPreferredPrice\n        fmv409aPrice\n        sharePrice\n        valuationMethod\n        priceHistory {\n          date\n          price\n          priceType\n        }\n        linkedAccountId\n        securityId\n        security {\n          id\n          name\n          ticker\n          currentPrice\n          closingPrice\n        }\n      }\n      credential {\n        id\n        hasSyncOrRecentRefreshRequest\n        canBeForceRefreshed\n        disconnectedFromDataProviderAt\n        syncDisabledAt\n        syncDisabledReason\n        dataProvider\n        institution {\n          id\n          plaidInstitutionId\n          url\n          ...InstitutionStatusFields\n        }\n      }\n      connectionStatus {\n        connectionStatusCode\n        copyTitle\n        inAppSmallCopy\n        inAppCopy\n        helpCenterUrl\n      }\n      institution {\n        id\n        plaidInstitutionId\n        url\n        ...InstitutionStatusFields\n      }\n      equityGrants {\n        id\n        grantType\n        grantNickname\n        grantDate\n        quantityGranted\n        vestingSchedule\n        vestingEndDate\n        exerciseEvents\n        strikePrice\n        postTerminationExerciseWindow\n        vestedQuantity\n        unvestedQuantity\n        exercisedQuantity\n        forfeitedQuantity\n        currentValue\n        vestingTimeline {\n          date\n          exercised\n          earlyExercised\n          vested\n          unvested\n          forfeited\n          sold\n          total\n          exercisedValue\n          earlyExercisedValue\n          vestedValue\n          unvestedValue\n          forfeitedValue\n          soldValue\n          totalValue\n        }\n      }\n    }\n  }\n"),uV=(0,Qt.J)("\n  query Web_EquityAccountDetails_getLinkedAccount($id: UUID!) {\n    account(id: $id) {\n      id\n      displayName\n      logoUrl\n      icon\n    }\n  }\n"),mV=()=>{var e,t,n,r,i,c,d,u,m,g,h,v,f,E,y,b;const x=(0,lV.L)().id,w=(0,l.Zp)(),A=(0,et.I)(dV,{variables:{id:x}}),k=A.data,S=A.refetch,N=null===k||void 0===k||null===(e=k.account)||void 0===e||null===(t=e.company)||void 0===t?void 0:t.linkedAccountId,T=(null===N||void 0===N?void 0:N.split(" ")[0])||N,_=(0,et.I)(uV,{variables:{id:T||""},skip:!T}).data,D=(0,tV.j)(),R=(0,o.A)(D,1)[0],M=(0,a.useState)(null),L=(0,o.A)(M,2),O=L[0],P=L[1],B=(0,a.useState)(!1),z=(0,o.A)(B,2),F=z[0],G=z[1],Y=(0,a.useRef)(null),U=(0,a.useRef)(!1),V=(0,Pd.h)(),W=(0,o.A)(V,2),j=W[0],H=W[1].open;(0,a.useEffect)((()=>()=>{Y.current&&(clearTimeout(Y.current),Y.current=null)}),[]);const K=(0,a.useCallback)((async e=>{if(!O&&!U.current)if("positive"===e){U.current=!0,Y.current&&(clearTimeout(Y.current),Y.current=null),G(!0);try{var t,n,a,l,r;const o=await R({formName:"equity_account",formVersion:"v1",accountId:x,answers:{rating:"positive"},metadata:{companyName:(null===k||void 0===k||null===(t=k.account)||void 0===t||null===(n=t.company)||void 0===n?void 0:n.name)||"Unknown",isPublic:null!==(a=null===k||void 0===k||null===(l=k.account)||void 0===l||null===(r=l.company)||void 0===r?void 0:r.isPublic)&&void 0!==a&&a}});if(!o.success)throw new Error(o.error||"Failed to submit feedback");P(e),(0,Ge.u4)(Ye.Sd.EquityAccountFeedbackSubmitted,{rating:"positive"}),Y.current=window.setTimeout((()=>{G(!1),Y.current=null}),1200)}catch(o){U.current=!1,G(!1),Y.current&&(clearTimeout(Y.current),Y.current=null),s.Cp(o,{fingerprint:["equity-feedback-positive-error"],tags:{formName:"equity_account",accountId:x}}),(0,C.oR)({title:"Failed to submit feedback",description:"Please try again later."})}}else P(e),H()}),[O,R,x,null===k||void 0===k||null===(n=k.account)||void 0===n||null===(r=n.company)||void 0===r?void 0:r.name,null===k||void 0===k||null===(i=k.account)||void 0===i||null===(c=i.company)||void 0===c?void 0:c.isPublic,H]),q=(0,nV.J)().downloadBalances,$=(0,aV.M)({accountId:x,accountName:(null===k||void 0===k||null===(d=k.account)||void 0===d?void 0:d.displayName)||""}),Z=(0,o.A)($,2),J=Z[0],X=Z[1].open,Q=()=>q([x]),ee=(0,a.useMemo)((()=>{var e;if(null===k||void 0===k||null===(e=k.account)||void 0===e||!e.company)return null;const t=k.account.company.valuationMethod;return"fmv_409a"===t?"409a (FMV)":"preferred_price"===t?"Preferred price":"Custom price"}),[null===k||void 0===k||null===(u=k.account)||void 0===u?void 0:u.company]),te=(null===k||void 0===k||null===(m=k.account)||void 0===m?void 0:m.id)===x;if(!k||!te)return a.createElement(rG.Y,{"data-external-id":"equity-account-details",name:iV,parentRoute:sV},a.createElement(vV,{center:!0,column:!0},a.createElement(p.i,{className:"mb-default"}),"Loading account details..."));if(null===k||void 0===k||!k.account)return a.createElement(eV.M,{"data-external-id":"equity-account-details"});const ne=k.account,ae=ne.isManual;
1return ne.type.name===oV.fC.EQUITY?a.createElement(rG.Y,{"data-external-id":"equity-account-details",icon:a.createElement(hV,{logoUrl:ne.logoUrl,icon:ne.icon}),name:iV,parentRoute:sV,overrideTitle:a.createElement("div",{className:"flex items-center gap-2xs"},ne.displayName),overrideHtmlTitle:ne.displayName,titleIsSensitive:!0,scrollClassName:"scroll-pb-24",controls:a.createElement(uU.f,null,a.createElement(Qi.Az,{placement:"bottom-end",overlay:()=>a.createElement(Ji.SP,null,a.createElement(Ji.xm,{onClick:()=>w(I.JZ.accounts.accountDetails.edit({id:x}))},"Edit account"),a.createElement(Ji.xm,{onClick:()=>w(I.JZ.accounts.accountDetails.editCompany({id:x}))},"Manage company"),a.createElement(Ji.xm,{onClick:()=>w(I.JZ.accounts.accountDetails.manageEquityHoldings({id:x}))},"Manage grants"),a.createElement(Ji.xm,{onClick:Q},"Download balance history"),a.createElement(Ji.xm,{onClick:()=>w(I.JZ.accounts.importBalanceHistory({queryParams:{accountId:x}}))},"Import balance history"),a.createElement(Ji.xm,{onClick:X},"Edit balance history"))},(e=>{let t=e.toggleOpen,n=e.isOpen;return a.createElement(EV,{onClick:t,active:n},"Edit ",a.createElement(fV,null))})))},a.createElement(rV.T,{screenName:"Account Details"}),a.createElement(gV,{template:'"chart chart" "rec sum" / 1fr minmax(0, 30%)',xl:'"chart" "sum" "rec" / 1fr'},a.createElement(QU.E,{area:"chart"},k.account.equityGrants&&k.account.equityGrants.length>0&&a.createElement(zU,{grants:k.account.equityGrants.map((e=>{var t;return{grantType:e.grantType,quantityGranted:e.quantityGranted||0,strikePrice:e.strikePrice||0,vestingTimeline:null===(t=e.vestingTimeline)||void 0===t?void 0:t.map((e=>({date:(null===e||void 0===e?void 0:e.date)||"",exercised:(null===e||void 0===e?void 0:e.exercised)||0,earlyExercised:(null===e||void 0===e?void 0:e.earlyExercised)||0,vested:(null===e||void 0===e?void 0:e.vested)||0,unvested:(null===e||void 0===e?void 0:e.unvested)||0,forfeited:(null===e||void 0===e?void 0:e.forfeited)||0,sold:(null===e||void 0===e?void 0:e.sold)||0,total:(null===e||void 0===e?void 0:e.total)||0,exercisedValue:(null===e||void 0===e?void 0:e.exercisedValue)||0,earlyExercisedValue:(null===e||void 0===e?void 0:e.earlyExercisedValue)||0,vestedValue:(null===e||void 0===e?void 0:e.vestedValue)||0,unvestedValue:(null===e||void 0===e?void 0:e.unvestedValue)||0,forfeitedValue:(null===e||void 0===e?void 0:e.forfeitedValue)||0,soldValue:(null===e||void 0===e?void 0:e.soldValue)||0,totalValue:(null===e||void 0===e?void 0:e.totalValue)||0})))}})),sharePrice:(()=>{const e=k.account.company;if(null!==e&&void 0!==e&&e.security){var t;const n=null!==(t=e.security.currentPrice)&&void 0!==t?t:e.security.closingPrice;if(null!==n&&void 0!==n)return n}return(null===e||void 0===e?void 0:e.sharePrice)||0})()})),a.createElement(QU.E,{area:"rec"},a.createElement("div",{className:"flex flex-col"},a.createElement(yV,null,a.createElement(mU,{accountId:x,onAddGrantButtonClick:()=>w(I.JZ.accounts.accountDetails.addEquityGrant({id:x})),onEditGrantsClick:()=>w(I.JZ.accounts.accountDetails.manageEquityHoldings({id:x}))})))),a.createElement(QU.E,{area:"sum"},a.createElement(lU.b,{className:"xl:pb-24"},a.createElement(eU.W,{account:ne,isManual:ae,isVehicle:!1,isRealEstate:!1,isInvestments:!1,isEquity:!0,isTrackingManualHoldings:!1,isTrackingManualBalances:!1,transactionCount:0,holdingCount:0}),ne.company&&a.createElement(Xl.AM,null,a.createElement($Y.H8,{title:"Company",controls:a.createElement(xt.v,{size:"base",color:"content.link",style:{cursor:"pointer"},onClick:()=>w(I.JZ.accounts.accountDetails.editCompany({id:x}))},"Edit")}),a.createElement(qY.S,null,a.createElement("div",{className:"flex flex-col gap-sm"},a.createElement("div",{className:"flex justify-between"},a.createElement(xt.v,{size:"base",color:"content.secondary"},"Company"),a.createElement(xt.v,{size:"base"},ne.company.name)),a.createElement("div",{className:"flex justify-between"},a.createElement(xt.v,{size:"base",color:"content.secondary"},"Status"),a.createElement(xt.v,{size:"base"},ne.company.isPublic?"Public":"Private")),(null===_||void 0===_?void 0:_.account)&&a.createElement("div",{className:"flex justify-between"},a.createElement("div",{className:"flex items-center gap-2xs"},a.createElement(xt.v,{size:"base",color:"content.secondary"},"Associated with"),a.createElement(JY.d,{content:JU.w,place:"right",hyphens:!1},a.createElement(bV,{name:"info",size:12}))),a.createElement("div",{className:"flex items-center gap-xs",style:{cursor:"pointer"},onClick:()=>_.account&&w(I.JZ.accounts.accountDetails({id:_.account.id}))},a.createElement(hV,{logoUrl:null===(g=_.account)||void 0===g?void 0:g.logoUrl,icon:null===(h=_.account)||void 0===h?void 0:h.icon}),a.createElement(xt.v,{size:"base",color:"content.link"},null===(v=_.account)||void 0===v?void 0:v.displayName))),(()=>{const e=ne.company;let t=e.sharePrice,n="manual";if(e.security){var l;const a=null!==(l=e.security.currentPrice)&&void 0!==l?l:e.security.closingPrice;null!==a&&void 0!==a&&(t=a,n="security")}return!t||t<=0?null:a.createElement("div",{className:"flex justify-between"},a.createElement("div",{className:"flex items-center gap-2xs"},a.createElement(xt.v,{size:"base",color:"content.secondary"},"Share Price"),"manual"===n&&ee&&a.createElement(JY.d,{content:'You chose "'.concat(ee,'" as your valuation method at the time of company setup. It cannot be changed.'),place:"right",hyphens:!1},a.createElement(bV,{name:"info",size:12})),"security"===n&&a.createElement(JY.d,{content:"Current market price",place:"right",hyphens:!1},a.createElement(bV,{name:"info",size:12}))),a.createElement(xt.v,{size:"base"},"$",(0,dU.$g)(t)))})(),ne.ownedByUser&&a.createElement("div",{className:"flex justify-between"},a.createElement(xt.v,{size:"base",color:"content.secondary"},"Owner"),a.createElement(xt.v,{size:"base"},ne.ownedByUser.name)),ne.company.employmentStatus&&a.createElement("div",{className:"flex justify-between"},a.createElement(xt.v,{size:"base",color:"content.secondary"},"Employment Status"),a.createElement(xt.v,{size:"base"},ne.company.employmentStatus.replace(/_/g," ").split(" ").map((e=>e.charAt(0).toUpperCase()+e.slice(1).toLowerCase())).join(" "))),ne.company.ownerStartDate&&a.createElement("div",{className:"flex justify-between"},a.createElement(xt.v,{size:"base",color:"content.secondary"},"Start Date"),a.createElement(xt.v,{size:"base"},pV(ne.company.ownerStartDate))),ne.company.ownerEndDate&&a.createElement("div",{className:"flex justify-between"},a.createElement(xt.v,{size:"base",color:"content.secondary"},"End Date"),a.createElement(xt.v,{size:"base"},pV(ne.company.ownerEndDate))),a.createElement(xV,null,a.createElement(wV,null,a.createElement(xt.v,{size:"base",color:"content.secondary"},"Review this feature"),a.createElement(CV,null,"negative"!==O&&a.createElement(IV,{icon:"thumbs-up",size:"small","aria-label":"Good experience",onClick:()=>K("positive"),$isAnimating:F,disabled:"positive"===O}),"positive"!==O&&a.createElement(AV,{icon:"thumbs-down",size:"small","aria-label":"Poor experience",onClick:()=>K("negative"),disabled:"negative"===O}))))))),!ae&&!ne.deactivatedAt&&ne.credential&&a.createElement(nU.b,{account:ne,refetch:S}
1),a.createElement(QY.o,{key:ne.id,accountId:ne.id,notes:ne.notes}),!!ne.deactivatedAt&&a.createElement(tU.K,{deactivatedAt:ne.deactivatedAt})))),a.createElement(XU.l,{path:I.JZ.accounts.accountDetails.edit.relativePath},(e=>{let t=e.close;return a.createElement(XY.r,{account:ne,onDone:()=>{t(),S()},onClose:t})})),a.createElement(XU.l,{path:I.JZ.accounts.accountDetails.addEquityGrant.relativePath},(e=>{let t=e.close;return a.createElement(rU.c,{accountId:x,onDone:()=>{t(),S()},goBack:t})})),a.createElement(XU.l,{path:I.JZ.accounts.accountDetails.manageEquityHoldings.relativePath},(e=>{let t=e.close;return a.createElement(OU.i,{accountId:x,companyName:ne.name||"Unknown Company",goBack:t,onDone:()=>{t(),S()},onAddHoldingClick:()=>{w(I.JZ.accounts.accountDetails.addEquityGrant({id:x}))},onEditHoldingClick:()=>{},refetchAccount:S})})),a.createElement(XU.l,{path:null===(f=I.JZ.accounts.accountDetails.editCompany)||void 0===f?void 0:f.relativePath},(e=>{var t,n,l,r,o,i,s,c,d,u,m,p,g,h,v,f;let E=e.close;return a.createElement(aU.o,{mode:"edit",accountId:x,initialValues:{companyName:(null===(t=ne.company)||void 0===t?void 0:t.name)||"",isPublic:(null===(n=ne.company)||void 0===n?void 0:n.isPublic)||!1,ownerUserId:(null===(l=ne.ownedByUser)||void 0===l?void 0:l.id)||"ownership_shared",employmentStatus:(null===(r=ne.company)||void 0===r?void 0:r.employmentStatus)||void 0,ownerStartDate:(null===(o=ne.company)||void 0===o?void 0:o.ownerStartDate)||void 0,ownerEndDate:(null===(i=ne.company)||void 0===i?void 0:i.ownerEndDate)||void 0,fullyDilutedShares:null!==(s=ne.company)&&void 0!==s&&s.fullyDilutedShares?Number(ne.company.fullyDilutedShares):void 0,latestFundingRound:(null===(c=ne.company)||void 0===c?void 0:c.latestFundingRound)||void 0,latestPreferredPrice:(null===(d=ne.company)||void 0===d?void 0:d.latestPreferredPrice)||void 0,fmv409aPrice:(null===(u=ne.company)||void 0===u?void 0:u.fmv409aPrice)||void 0,linkedAccountId:T||"",valuationMethod:(null===ne||void 0===ne||null===(m=ne.company)||void 0===m?void 0:m.valuationMethod)||void 0,sharePrice:(null===(p=ne.company)||void 0===p?void 0:p.sharePrice)||void 0,securityId:null!==(g=ne.company)&&void 0!==g&&g.securityId?String(ne.company.securityId):void 0,fmv409aHistory:[],preferredPriceHistory:[],customHistory:[]},initialSecurity:(null===(h=ne.company)||void 0===h?void 0:h.security)||null,currentPriceHistory:null!==(v=null===(f=ne.company)||void 0===f?void 0:f.priceHistory)&&void 0!==v?v:void 0,onDone:()=>{E(),S()},goBack:E})})),a.createElement(J,null),a.createElement(j,null,a.createElement(iU,{accountId:x,companyName:(null===(E=ne.company)||void 0===E?void 0:E.name)||"Unknown",isPublic:null!==(y=null===(b=ne.company)||void 0===b?void 0:b.isPublic)&&void 0!==y&&y}))):a.createElement(eV.M,{"data-external-id":"equity-account-details"})},pV=e=>{const t=e.split("-").map(Number),n=(0,o.A)(t,3),a=n[0],l=n[1],r=n[2];return new Date(a,l-1,r).toLocaleDateString()},gV=(0,$d.s)(QU.a)(ZU||(ZU=(0,wc.A)(["pt-0"]))),hV=(0,u.default)(Gl.v).withConfig({displayName:"EquityAccountDetails__StyledAccountLogo",componentId:"sc-1vm9f6l-0"})(["width:24px;height:24px;"]),vV=(0,u.default)(ZY.B).withConfig({displayName:"EquityAccountDetails__LoadingContainer",componentId:"sc-1vm9f6l-1"})(["flex:1;height:100%;"]),fV=(0,u.default)(sl.ZQ).attrs({name:"chevron-down",size:12}).withConfig({displayName:"EquityAccountDetails__ChevronDownIcon",componentId:"sc-1vm9f6l-2"})(["transform:translateY(1px);"]),EV=(0,u.default)(wt.Xb).withConfig({displayName:"EquityAccountDetails__ManageButton",componentId:"sc-1vm9f6l-3"})(["position:relative;align-items:center;gap:",";"],vt.YK.xsmall),yV=u.default.div.withConfig({displayName:"EquityAccountDetails__StyledEquityGrantsListWrapper",componentId:"sc-1vm9f6l-4"})([":empty{height:0;margin:0;}:not(:empty){margin-bottom:72px;}"]),bV=(0,u.default)(sl.ZQ).withConfig({displayName:"EquityAccountDetails__InfoIcon",componentId:"sc-1vm9f6l-5"})(["color:",";cursor:pointer;"],vt.Ee.color.content.secondary),xV=u.default.div.withConfig({displayName:"EquityAccountDetails__FeedbackSection",componentId:"sc-1vm9f6l-6"})(["margin-top:",";padding-top:",";border-top:1px solid ",";"],vt.YK.default,vt.YK.default,vt.Ee.color.border.primary),wV=u.default.div.withConfig({displayName:"EquityAccountDetails__FeedbackHeader",componentId:"sc-1vm9f6l-7"})(["display:flex;align-items:center;justify-content:space-between;"]),CV=u.default.div.withConfig({displayName:"EquityAccountDetails__FeedbackButtonsContainer",componentId:"sc-1vm9f6l-8"})(["display:flex;gap:",";"],vt.YK.xsmall),AV=(0,u.default)(B.L).withConfig({displayName:"EquityAccountDetails__FeedbackIconButton",componentId:"sc-1vm9f6l-9"})(["color:",";&:disabled{opacity:0.5;}&:hover:not(:disabled){color:",";}"],vt.Ee.color.content.secondary,vt.Ee.color.content.primary),IV=(0,u.default)(AV).withConfig({displayName:"EquityAccountDetails__AnimatedThumbsUpButton",componentId:"sc-1vm9f6l-10"})([""," &:disabled{opacity:1;color:",";}"],(e=>e.$isAnimating&&(0,u.css)(["animation:"," 0.6s ease-in-out;color:",";
1"],cV,vt.Ee.color.content.success)),vt.Ee.color.content.success),kV=(0,Qt.J)("\n  query Web_AccountDetailsRouter_getAccountType($id: UUID!) {\n    account(id: $id) {\n      id\n      type {\n        name\n      }\n    }\n  }\n"),SV=()=>{const e=(0,lV.L)().id,t=(0,et.I)(kV,{variables:{id:e}}),n=t.data;return t.isNetworkRequestInFlight||!n?a.createElement(rG.Y,{"data-external-id":"account-details-container",name:"Account Details",parentRoute:"Accounts"},a.createElement("div",{className:"flex h-full flex-1 flex-col items-center justify-center"},a.createElement(p.i,null))):null!==n&&void 0!==n&&n.account?n.account.type.name===oV.fC.EQUITY?a.createElement(mV,{"data-external-id":"account-details-container"}):a.createElement(KY.c,{"data-external-id":"account-details-container"}):a.createElement(eV.M,{"data-external-id":"account-details-container"})};var NV=n(41766),TV=n(22130),_V=n(37830),DV=n(34914),RV=n(6316),MV=n(87995),LV=n(35151),OV=n(24767);const PV={green:"bg-chart-fill-green",sky9:"bg-chart-fill-sky",teal9:"bg-chart-fill-teal",purple:"bg-chart-fill-purple",red:"bg-chart-fill-red",yellow:"bg-chart-fill-yellow",orange:"bg-chart-fill-orange",gray:"bg-chart-fill-gray",lime:"bg-chart-fill-lime",pink:"bg-chart-fill-pink"},BV=(0,oV.se)({}),zV=e=>{var t;let n=e.type,l=e.name,r=e.balance,o=e.className,i=e.onClick,s=e.inverted,c=void 0!==s&&s,d=e.hideDot,u=void 0!==d&&d,m=e.isAsset,p=e.percentage;if((0,BY.A)(n)&&(0,BY.A)(l))throw new Error("AccountBalanceIndicator must have either a type or a name");const g=(0,OV.T)().typeOptions,h=(0,a.useMemo)((()=>g.find((e=>{let t=e.value,a=e.label;return n?t.toLowerCase()===n:a===l}))),[g,l,n]),v=null===h||void 0===h?void 0:h.value.toLowerCase(),f=null!==(t=null===h||void 0===h?void 0:h.label)&&void 0!==t?t:"",E=v&&["other_asset","other_liability"].includes(v)?(0,MV.A)(/_/g," ",v):f,y=(0,a.useMemo)((()=>(0,LV.A)(m)?BV[v]:"Other"===E?BV[m?"other_asset":"other_liability"]:BV[v]),[E,v,m]),b=(0,rl.vv)(r);return a.createElement("div",{"data-external-id":"account-balance-indicator",className:(0,q.cn)("mb-xs flex items-center justify-between last:mb-0",c?"text-content-white":"text-content-primary",(0,Tr.A)(i)?"cursor-pointer":"cursor-auto",o),onClick:i},a.createElement("div",{className:"flex items-center"},!u&&v&&a.createElement("div",{className:(0,q.cn)("mr-xs inline-block size-2 rounded-full",PV[y])}),a.createElement(fe.c8D,{color:"inherit",className:"text-[length:inherit] capitalize"},E)),a.createElement(fe.Yvj,{content:p?b:void 0},a.createElement("span",fl.TN,p?(0,De.gj)(p):b)))};var FV=n(41516),GV=n(13974);const YV=["month","net"],UV=e=>{let t=e.title,n=e.currentMonthData,l=e.previousMonthData;const r=(0,OV.T)().accountTypes,i=(0,a.useCallback)((e=>{const t=r.find((t=>t.name===e));return(null===t||void 0===t?void 0:t.group)===Ee.n8S.LIABILITY}),[r]),s=null!==n&&void 0!==n?n:{},c=(s.month,s.net),d=(0,En.A)(s,YV),u=n?(0,GV.mu)(n):{},m=l?(0,GV.mu)(l):{};return a.createElement(VV,{"data-external-id":"account-net-worth-chart-tooltip",header:a.createElement(jV,null,t),footer:a.createElement("div",{className:"flex flex-col"},a.createElement("div",{className:"flex items-center justify-between"},a.createElement(xt.v,null,"Net Worth"),a.createElement(xt.v,null,(0,rl.vv)(c))),a.createElement(KV,{balance:c,previousBalance:null===l||void 0===l?void 0:l.net})),active:!0},a.createElement("div",{className:"flex flex-col gap-2xs"},Object.entries(d).filter((e=>"currentMonthNet"!==(0,o.A)(e,1)[0])).map((e=>{let t=(0,o.A)(e,1)[0];const n=t,l=m[t];return a.createElement(HV,{key:"".concat(t,"-").concat(l)},a.createElement(WV,{key:t,type:n,balance:u[t],inverted:!0}),a.createElement(KV,{balance:u[t],previousBalance:l,isLiability:i(n)}))}))))},VV=(0,u.default)(Sa.II).withConfig({displayName:"AccountNetWorthChartTooltip__Tooltip",componentId:"sc-13urnaa-0"})(["min-width:280px;border-radius:",";"],vt.r8.medium),WV=(0,u.default)(zV).withConfig({displayName:"AccountNetWorthChartTooltip__StyledBalanceIndicator",componentId:"sc-13urnaa-1"})(["font-size:",";&:not(:last-child){margin-bottom:-",";}"],vt.J.small,(e=>e.theme.spacing.xxsmall)),jV=(0,u.default)(xt.v).withConfig({displayName:"AccountNetWorthChartTooltip__TooltipHeader",componentId:"sc-13urnaa-2"})(["display:block;padding:"," 0;font-size:",";"],vt.YK.xxsmall,vt.J.base),HV=u.default.div.withConfig({displayName:"AccountNetWorthChartTooltip__Row",componentId:"sc-13urnaa-3"})(["border-bottom:1px solid ",";&:last-of-type{border-bottom:none;margin-bottom:",";}"],vt.Ee.color.divider.primary,vt.YK["-small"]),KV=(0,u.default)(FV.F).withConfig({displayName:"AccountNetWorthChartTooltip__StyledBalanceDiffIndicator",componentId:"sc-13urnaa-4"})(["justify-content:flex-end;"]);var qV=n(92267);const $V=n.p+"static/media/net-worth-breakdown-dark.868d3763.svg";
1const ZV=n.p+"static/media/net-worth-breakdown-light.eefafe89.svg";const JV=n.p+"static/media/net-worth-performance-dark.446315af.svg";const XV=n.p+"static/media/net-worth-performance-light.7fd3e615.svg";const QV=n.p+"static/media/pie-dark.bc28be10.svg";const eW=n.p+"static/media/pie-light.df202a4e.svg";const tW=n.p+"static/media/pnl-dark.2ae553e0.svg";const nW=n.p+"static/media/pnl-light.7e4abe4e.svg";const aW=n.p+"static/media/ranked-bars-dark.d36d8199.svg";const lW=n.p+"static/media/ranked-bars-light.b5da1ef4.svg";const rW=n.p+"static/media/sankey-dark.31cdb34a.svg";const oW=n.p+"static/media/sankey-light.ee3a1074.svg";const iW=n.p+"static/media/transactions-dark.05b29c8d.svg";const sW=n.p+"static/media/transactions-light.eba53eb3.svg";const cW=n.p+"static/media/treemap-dark.5bf9e4e5.svg";const dW=n.p+"static/media/treemap-light.79180939.svg";const uW=n.p+"static/media/trend-bars-dark.050220d5.svg";const mW={sankey:{light:oW,dark:rW},trendBars:{light:n.p+"static/media/trend-bars-light.7216e00c.svg",dark:uW},pie:{light:eW,dark:QV},profitLoss:{light:nW,dark:tW},rankedBars:{light:lW,dark:aW},treemap:{light:dW,dark:cW},transactions:{light:sW,dark:iW},netWorthPerformance:{light:XV,dark:JV},netWorthBreakdown:{light:ZV,dark:$V}},pW=e=>{var t;let n=e.options,l=e.value,r=e.onValueChange,o=e["aria-label"];const i=gW(),s=(0,a.useMemo)((()=>n.map((e=>{let t=e.value,n=e.label,a=e.description,l=e.thumbnail;return{value:t,label:n,description:a,leading:i(l)}}))),[n,i]);return a.createElement(qV.h,{"data-external-id":"chart-type-select",size:"sm",options:s,value:null!==l&&void 0!==l?l:null===(t=n[0])||void 0===t?void 0:t.value,onValueChange:r,"aria-label":o,classNames:{trigger:"w-auto font-medium",content:"\n  p-xs\n  [&>div]:pb-0\n  [&>div]:before:h-0\n\n  [&_[data-mds=select-option]]:mx-0\n  [&_[data-mds=select-option]]:gap-default\n  [&_[data-mds=select-option]]:px-md\n  [&_[data-mds=select-option]]:py-sm\n  [&_[data-mds=select-option]]:font-medium\n  [&_[data-mds=select-option]_.text-content-secondary]:font-book\n  [&_[data-mds=select-option]+[data-mds=select-option]]:mt-xs\n\n  [&_[data-mds=select-option]]:transition-shadow\n  [&_[data-mds=select-option]]:duration-150\n  [&_[data-mds=select-option]]:data-highlighted:bg-transparent\n  [&_[data-mds=select-option]]:data-highlighted:ring-1\n  [&_[data-mds=select-option]]:data-highlighted:ring-inset\n  [&_[data-mds=select-option]]:data-highlighted:ring-border-primary\n  [&_[data-mds=select-option]]:active:shadow-none\n\n  [&_[data-mds=select-option]]:data-selected:bg-transparent\n  [&_[data-mds=select-option]]:data-selected:text-content-primary\n  [&_[data-mds=select-option]]:data-selected:ring-2\n  [&_[data-mds=select-option]]:data-selected:ring-inset\n  [&_[data-mds=select-option]]:data-selected:ring-border-info\n"}})},gW=()=>{const e="dark"===(0,lm.a)();return(0,a.useMemo)((()=>t=>a.createElement("span",{"aria-hidden":!0,"data-testid":"chart-type-thumbnail",className:" block h-10.75 w-18 shrink-0 bg-contain bg-center bg-no-repeat in-data-[mds=select-trigger]:h-6 in-data-[mds=select-trigger]:w-10.25 ",style:{backgroundImage:'url("'.concat(e?mW[t].dark:mW[t].light,'")')}})),[e])};var hW=n(73698),vW=n(68310);const fW=[{value:"performance",label:"Performance",description:"Your net worth over time",thumbnail:"netWorthPerformance"},{value:"breakdown",label:"Breakdown",description:"Assets & debts, month by month",thumbnail:"netWorthBreakdown"}],EW=[{value:"month",label:"Monthly"},{value:"quarter",label:"Quarterly"},{value:"year",label:"Yearly"}],yW=e=>{let t=e.chartType,n=e.activeTimeframeIndex,l=e.selectedDateRange,r=e.onChangeTimeframe,o=e.onChangeChartType,i=e.setSelectedDateRange;const s="performance"===t,c=(0,a.useMemo)((()=>(0,hW.fD)()),[]),d=(0,a.useMemo)((()=>s?c.map((e=>({value:e.display,label:e.longDisplay}))):EW),[s,c]),u=s?null===l||void 0===l?void 0:l.display:EW[n].value,m=(0,a.useCallback)((e=>{if(!s)return void((0,vW.k3)(e)&&r(e));const t=c.find((t=>t.display===e));t&&i(t)}),[s,c,r,i]);return a.createElement("div",{"data-external-id":"net-worth-chart-controls",className:"flex gap-default"},a.createElement(pW,{"aria-label":"Chart type",options:fW,value:t,onValueChange:o}),a.createElement(qV.h,{size:"sm",options:d,value:u,onValueChange:m,"aria-label":"Timeframe",classNames:{trigger:"w-auto font-medium"}}))},bW=e=>{let t=e.x,n=e.y;
1const l=(0,u.useTheme)(),r=parseInt(l.radius.small,10);return a.createElement("g",{"data-external-id":"net-worth-chart-label-content-loader",transform:"translate(".concat(t-19,",").concat(n-1,")")},a.createElement(Rr.s,{width:38,height:12,viewBox:"0 0 ".concat(38," ").concat(12)},a.createElement("rect",{x:"0",y:"0",rx:r,ry:r,width:38,height:12})))};var xW=n(86586),wW=n(29108);const CW=parseInt(yD.w.spacing.default,10),AW=e=>{let t=e.snapShotsDataByAccountType,n=e.isSnapshotsNetworkRequestInFlight,l=e.activeTimeframeIndex,r=void 0===l?0:l,i=e.width;const s=(0,u.useTheme)(),c=(0,a.useMemo)((()=>EW[r].value),[r]),d=(0,a.useMemo)((()=>(0,GV.o)(t,c,!0)),[t]),m=(0,a.useState)(new Set([c])),p=(0,o.A)(m,2),g=p[0],h=p[1],v=n&&!g.has(c),f=(0,a.useCallback)((e=>{var t;const n=N.c9.fromISO(e),a=n.startOf(c).toISODate(),l=n.endOf(c).toISODate();return null!==(t=(0,wW.yP)({startDate:a,endDate:l}))&&void 0!==t?t:e}),[c]),E=(0,a.useMemo)((()=>IW(s)),[s]);return a.createElement(PU.vD,{"data-external-id":"net-worth-breakdown-chart",data:d,barDataKeys:E,onAnimationEnd:()=>h((e=>e.add(c))),xAxisDataKey:"month",totalDataKey:"net",dashedLineDataKey:"currentMonthNet",heightPx:275,widthPx:i-CW,barWidthPx:40,formatXAxis:(0,xW.B)(c,{showFirstQuarterWithYear:!0}),xAxisProps:v?{tick:a.createElement(bW,null)}:{height:"quarter"===c?38:26},formatYAxis:rl.fw,activeBarIndex:d.length-1,tooltipComponent:e=>{var n,l;let r=e.active,o=e.payload;if(null===o||void 0===o||!o.length)return null;const i=null===(n=o[0])||void 0===n||null===(l=n.payload)||void 0===l?void 0:l.month,s=i?N.c9.fromISO(i):void 0,d=i?f(i):"",u=r&&s?(0,GV.$q)(t,s,c):null;return u?a.createElement(UV,{title:d,currentMonthData:u.current,previousMonthData:u.previous}):null}})},IW=e=>Object.entries((0,oV.se)(e)).map((t=>{let n=(0,o.A)(t,2),a=n[0],l=n[1];return{name:a,color:e.color[l]}})),kW=["size","colorVariant"],SW=(0,u.default)((e=>{let t=e.size,n=void 0===t?20:t,l=(e.colorVariant,(0,En.A)(e,kW));return a.createElement(fe.bQo,Object.assign({"data-external-id":"sparkle-icon-base",size:n},l))})).attrs({"data-sc-tw":"AssistantSparkleIcon__AssistantSparkleIcon"}).withConfig({displayName:"AssistantSparkleIcon",componentId:"sc-1kf1jo9-0"})(["color:",";display:inline-flex;",";&:hover{color:",";",";}"],(e=>{let t=e.colorVariant,n=void 0===t?"secondary":t,a=e.theme;return"brand"===n?a.variables.color.background.brand:a.variables.color.content.secondary}),St,vt.Ee.color.background.brandHover,Nt);var NW=n(42712);const TW=e=>{let t=e.content,n=e.label,l=e.source,r=e.onDismiss;const o=(0,ht.S)().isAiFeaturesEnabled,i=(0,NW.N)(),s=(0,d.d4)(A._S),c=(0,F.K)();if(!o)return null;return a.createElement(fe.XZZ,{"data-external-id":"tooltip-insights-button",variant:"unstyled",type:"button",onClick:async e=>{e.preventDefault(),e.stopPropagation(),c||(s&&(null===r||void 0===r||r()),(0,Ge.u4)(Ye.g8.Clicked,{source:l}),await i(t,{fromGlobalSearch:!0,source:l}))},disabled:c,className:" group w-full rounded-default bg-background-brand-subtle p-xs hover:not-disabled:brightness-105 focus-visible:outline-offset-2 active:not-disabled:brightness-[0.97] disabled:pointer-events-none "},a.createElement("div",{className:"flex w-full items-center justify-between gap-2xs"},a.createElement("span",{className:"inline-flex items-center justify-center text-chart-fill-yellow"},a.createElement(SW,{size:12,colorVariant:"brand",className:"group-hover:transform-sparkle group-hover:text-background-brand-hover"})),a.createElement(Tt,{className:"flex-1 text-left text-xs/normal font-medium whitespace-nowrap"},n),a.createElement("span",{className:"inline-flex items-center justify-center text-chart-fill-yellow"},a.createElement(fe.hPJ,{size:"xs"}))))},_W=e=>0===e.length?"":1===e.length?e[0]:2===e.length?"".concat(e[0]," and ").concat(e[1]):"".concat(e.slice(0,-1).join(", "),", and ").concat(e[e.length-1]),DW=e=>{let t=e.accountTypeDisplayNames,n=e.accountDisplayNames,a=e.householdMemberName,l=e.businessEntityDisplayNames;const r=[];return t&&t.length>0&&r.push("\u2022 Account Types: ".concat(_W(t))),n&&n.length>0&&r.push("\u2022 Accounts: ".concat(n.join(", "))),a&&r.push("\u2022 Owners: ".concat(a)),l&&l.length>0&&r.push("\u2022 Businesses: ".concat(l.join(", "))),r.length>0?"\n".concat(r.join("\n")):""},RW=(0,u.default)(Sa.II).withConfig({displayName:"BigDateValueTooltip__StyledChartTooltip",componentId:"sc-8b7skt-0"})(["min-width:280px;position:relative;[data-sc-tw~='ChartTooltip__TooltipHeader']{font-size:",";}"],vt.J.xsmall),MW=(0,u.default)(FV.F).withConfig({displayName:"BigDateValueTooltip__Diff",componentId:"sc-8b7skt-1"})(["font-size:",";"],vt.J.xsmall),LW=(0,u.default)(xt.v).withConfig({displayName:"BigDateValueTooltip__PercentageText",componentId:"sc-8b7skt-2"})(["margin-left:",";"],vt.YK.xsmall),OW=u.default.div.withConfig({displayName:"BigDateValueTooltip__TooltipBuffer",componentId:"sc-8b7skt-3"})(["padding:",";margin:-",";"],vt.YK.xlarge,vt.YK.xlarge),PW=a.forwardRef(((e,t)=>{let n=e.date,l=e.value,r=e.label,i=e.active,s=e.isAsset,c=e.comparisonData,d=e.selectedHouseholdMemberName,u=e.selectedAccountTypeDisplayNames,p=e.selectedAccountDisplayNames,g=e.businessEntityDisplayNames;const h=(0,ht.S)().isAiFeaturesEnabled,v=a.useState(!1),f=(0,o.A)(v,2),E=f[0],y=f[1];a.useEffect((()=>{y(!1)}),[n]);const b=(0,Ba.AO)(c.initialDate),x=(0,Ba.AO)(n),w=r.toLowerCase(),C=d?" for accounts owned by ".concat(d):"",A="Analyze changes to ".concat(d?"":"my ").concat(w).c
1oncat(C," from ").concat(b," to ").concat(x),I=DW({accountTypeDisplayNames:u,accountDisplayNames:p,businessEntityDisplayNames:g}),k="".concat(A).concat(I),S=a.useCallback((e=>{e.stopPropagation()}),[]),N=a.useCallback((()=>{y(!0)}),[]),T="".concat(b," - ").concat(x),_=a.createElement(m.g,{justifyBetween:!0,alignCenter:!0,gap:"xsmall"},a.createElement(xt.v,{size:"small"},(0,rl.vv)(l)),a.createElement(MW,{balance:l,previousBalance:l-c.diff,isLiability:!s},a.createElement(LW,{size:"xsmall"},c.percentageChange?"(".concat(c.percentageChange.toFixed(2),"%)"):"")));return h?a.createElement(OW,{"data-external-id":"big-date-value-tooltip",onMouseEnter:S,onMouseMove:S,onMouseDown:S},a.createElement("div",{ref:t},a.createElement(RW,{header:T,active:i&&!E},a.createElement(m.g,{column:!0,gap:"small"},_,a.createElement(m.g,{justifyStart:!0,paddingBottom:"xxsmall"},a.createElement(TW,{content:k,label:"Explain this change",source:Ye.rP.NetWorthChartTooltip,onDismiss:N})))))):a.createElement("div",{"data-external-id":"big-date-value-tooltip",ref:t},a.createElement(RW,{header:T,active:i},_))}));PW.displayName="BigDateValueTooltip";var BW=n(41464),zW=n(95279),FW=n(66588),GW=n.n(FW);const YW=e=>{let t=e.points,n=e.tooltipY,l=e.activeDataPointY,r=e.tooltipHeight,i=void 0===r?0:r;const s=(0,u.useTheme)(),c=a.useState((()=>"cursor-gradient-".concat((0,FW.v4)()))),d=(0,o.A)(c,1)[0];if(!t||t.length<2||void 0===l)return null;const m=(0,o.A)(t,2),p=m[0],g=m[1],h=p.x,v=g.y-l;return a.createElement(a.Fragment,null,a.createElement("defs",null,a.createElement("linearGradient",{id:d,x1:"0",y1:"0",x2:"0",y2:"1"},a.createElement("stop",{offset:"5.3%",stopColor:s.variables.color.border.info,stopOpacity:1}),a.createElement("stop",{offset:"107.88%",stopColor:s.variables.color.border.info,stopOpacity:0}))),void 0!==n&&i>0&&a.createElement("line",{x1:h,y1:n+i,x2:h,y2:l,stroke:s.variables.color.divider.secondary,strokeWidth:2,strokeDasharray:"6 6",strokeLinecap:"round"}),a.createElement(zW.M,{x:h-2,y:l,fill:"url(#".concat(d,")"),width:4,height:v}))};var UW=n(27198),VW=n(80994),WW=n(61627),jW=n(73616),HW=n(23326);const KW=(e,t,n,a)=>{var l;const r=((e,t)=>{const n=(0,Wd.A)((0,UW.A)(t),(0,VW.A)((0,WW.A)(Number)))(e);return 0===n.length?{min:0,max:0}:{min:Math.min(...n),max:Math.max(...n)}})(e,t),o=r.min,i=r.max;if(0===i&&0===o)return{ticks:[0],domain:[0,0]};const s=(0,HW.dG)([o,i],n,!0),c=s.length>1?s[1]-s[0]:i-o,d=s.filter((e=>e>i)).length,u=null!==(l=(0,yd.A)((e=>e<=i),s))&&void 0!==l?l:s[0],m=i-u<.5*c?d+1:d,p=Math.max(0,a-m),g=s[s.length-1],h=Array.from({length:p},((e,t)=>g+c*(t+1))),v=[...s,...h];return{ticks:v,domain:[Math.min(...v),Math.max(...v)]}},qW=e=>{var t;let n=e.aggregateSnapshotsData,a=e.activeDataIndex,l=e.activeDataPointX,r=e.mouseY,i=e.yDataKey,s=e.tooltipWidth,c=e.tooltipHeight,d=e.chartAreaWidth,u=e.chartAreaHeight,m=e.yDomain;if(void 0===a||!n.length||void 0===l||!s||!c)return;const p=null===(t=n[a])||void 0===t?void 0:t[i];if("number"!==typeof p)return;const g=((e,t,n,a,l,r)=>{const o=r/(e.length-1||1),i=Math.ceil(l/2/o),s=Math.max(1,i),c=Math.max(0,t-s),d=Math.min(e.length-1,t+s),u=(0,Wd.A)((0,UW.A)(a),(0,VW.A)((0,WW.A)(Number)))(e.slice(c,d+1));return 0===u.length?n:Math.max(...u)})(n,a,p,i,s,d),h=(0,o.A)(m,2),v=h[0],f=h[1],E=(f-g)*(u/(f-v));let y=180;if(void 0!==r&&void 0!==c&&c>0){const e=E-180,t=20;if(r>=e-t&&r<=e+c+t){y=E-r+30+c}}const b=E-y,x=Math.max(-75,b),w=l-s/2;return{x:(0,jW.A)(0,d-s,w),y:x}},$W=["active","yDataKey","lineChartData","title","isAsset","selectedHouseholdMemberName","selectedAccountTypeDisplayNames","selectedAccountDisplayNames","businessEntityDisplayNames","tooltipRef","setActiveDate"],ZW=e=>{let t=e.title,n=e.aggregateSnapshotsData,l=e.isAggreateSnapShotsNet
1workRequestInFlight,r=e.isAsset,i=e.selectedDateRange,s=e.yDataKey,c=e.width,d=e.selectedHouseholdMemberName,m=e.selectedAccountTypeDisplayNames,p=e.selectedAccountDisplayNames,g=e.businessEntityDisplayNames;const h=(0,u.useTheme)(),v=(0,ht.S)().isAiFeaturesEnabled,f=(0,a.useState)(void 0),E=(0,o.A)(f,2),y=E[0],b=E[1],x=(0,a.useState)(void 0),w=(0,o.A)(x,2),C=w[0],A=w[1],I=(0,a.useState)(void 0),k=(0,o.A)(I,2),S=k[0],N=k[1],T=(0,a.useState)(void 0),_=(0,o.A)(T,2),D=_[0],R=_[1],M=(0,a.useRef)(!1),L=(0,qd.W)(),O=(0,o.A)(L,2),P=O[0],B=O[1],z=B.width,F=void 0===z?0:z,G=B.height,Y=void 0===G?0:G;(0,a.useEffect)((()=>{b(void 0),A(void 0),N(void 0),R(void 0),M.current=!1}),[n,i.display]);const V=(0,a.useMemo)((()=>{if(S)return n.findIndex((e=>e.date===S))}),[S,n]),W=(0,a.useMemo)((()=>KW(n,s,5,v?3:2)),[n,s,v]),j=W.ticks,H=W.domain,K=(0,a.useMemo)((()=>qW({aggregateSnapshotsData:n,activeDataIndex:V,activeDataPointX:y,mouseY:D,yDataKey:s,tooltipWidth:F,tooltipHeight:Y,chartAreaWidth:c,chartAreaHeight:249-Do.kM,yDomain:H})),[V,n,s,c,y,F,Y,H,D]);(0,a.useEffect)((()=>{K||(R(void 0),M.current=!1)}),[K]);const q=(0,a.useState)(i.display),$=(0,o.A)(q,2),Z=$[0],J=$[1];(0,a.useEffect)((()=>{l||J(i.display)}),[l,i.display]);const X=l?Z:i.display,Q=l&&Z!==i.display,ee="1Y"===X||"ALL"===X,te=(0,a.useMemo)((()=>ee?Ba.Ex:Ba.SR),[ee]),ne=(0,a.useMemo)((()=>(0,_a.Bb)(n,"date",te)),[n,te]),ae=(0,a.useMemo)((()=>e=>a.createElement(JW,Object.assign({},e,{yDataKey:s,lineChartData:n,title:t,isAsset:r,selectedHouseholdMemberName:d,selectedAccountTypeDisplayNames:m,selectedAccountDisplayNames:p,businessEntityDisplayNames:g,tooltipRef:P,setActiveDate:N}))),[s,n,t,r,d,m,p,g]),le=(0,a.useCallback)((e=>{var t;!M.current&&e.isTooltipActive&&void 0!==(null===(t=e.activeCoordinate)||void 0===t?void 0:t.y)&&(M.current=!0,R(e.activeCoordinate.y))}),[]);return a.createElement(QW,{"data-external-id":"net-worth-performance-chart"},a.createElement(BW.f,{height:275,margin:{left:10},lineColor:h.color.blue9,customActiveDot:e=>a.createElement(XW,{cx:e.cx,cy:e.cy,fill:e.fill,setActiveDataPointX:b,setActiveDataPointY:A}),data:n,xAxisProps:Q?(0,U.A)((0,U.A)({},ne),{},{height:26,tick:a.createElement(bW,null)}):(0,U.A)((0,U.A)({},ne),{},{height:26}),tooltipComponent:ae,onMouseMove:le,onMouseLeave:()=>{b(void 0),A(void 0),N(void 0),R(void 0),M.current=!1},tooltipProps:{position:K,isAnimationActive:!1,wrapperStyle:{pointerEvents:"auto",opacity:F>0&&Y>0&&K?1:0},cursor:void 0!==C&&void 0!==K&&a.createElement(YW,{activeDataPointY:C,tooltipY:K.y,tooltipHeight:Y}),allowEscapeViewBox:{x:!1,y:!0}},yDataKey:s,xDataKey:"date",domain:H,yAxisProps:{ticks:j,interval:0},formatYAxis:rl.fw,formatXAxis:te,smoothGradient:!0}))},JW=e=>{let t=e.active,n=e.yDataKey,l=e.lineChartData,r=e.title,o=e.isAsset,i=e.selectedHouseholdMemberName,s=e.selectedAccountTypeDisplayNames,c=e.selectedAccountDisplayNames,d=e.businessEntityDisplayNames,u=e.tooltipRef,m=e.setActiveDate,p=(0,En.A)(e,$W);const g=(0,_a.WS)((0,U.A)({active:t},p)),h=null===g||void 0===g?void 0:g.date,v=null===g||void 0===g?void 0:g[n];(0,a.useEffect)((()=>{m(h)}),[h,m]);const f=(0,a.useMemo)((()=>h?(0,GV.bJ)(l,h,n):null),[h,l,n]);return(0,Tr.A)(h)&&(0,Tr.A)(v)&&(0,Tr.A)(f)?a.createElement(PW,{"data-external-id":"tooltip-component",ref:u,active:t,value:v,date:h,label:r,isAsset:o,comparisonData:f,selectedHouseholdMemberName:i,selectedAccountTypeDisplayNames:s,selectedAccountDisplayNames:c,businessEntityDisplayNames:d}):null},XW=e=>{let t=e.cx,n=e.cy,l=e.fill,r=e.setActiveDataPointX,o=e.setActiveDataPointY;const i=(0,u.useTheme)();return(0,a.useEffect)((()=>{r(t),o(n)}),[t,n,r,o]),a.createElement("circle",{"data-external-id":"active-dot",cx:t,cy:n,r:6,fill:l,strokeWidth:4,stroke:i.variables.color.content.white})},QW=u.default.div.withConfig({displayName:"NetWorthPerformanceChart__LineChartContainer",componentId:"rtk038-0"})(["margin-top:",";"],vt.YK.default),ej=e=>{let t=e.className,n=e.startAmount,l=e.currentAmount,r=e.timeframeText,o=e.isAsset,i=e.hideCurrentAmount,s=e.amountSize,c=void 0===s?"20":s;return a.createElement("div",{"data-external-id":"dashboard-widget-amount-header",className:(0,q.cn)("mt-xs flex w-fit flex-col items-start sm:flex-row sm:items-baseline",t)},!i&&a.createElement(kD.c,{className:(0,q.cn)(fl.zs.className,"translate-y-
1px"),color:"inherit",size:c,weight:"medium"},(0,rl.vv)(l)),a.createElement(El.H,{className:"text-base sm:mt-0 sm:ml-xs",startAmount:n,endAmount:l,timeframeDisplay:r,isAsset:o}))};var tj=n(82904),nj=n(36520);const aj=e=>e.reduce(((e,t)=>{const n=(0,o.A)(t.path,2),a=n[0];n[1];return a?"accounts"===a?(0,U.A)((0,U.A)({},e),{},{ids:[...e.ids||[],t.id]}):"ownership"===a?(0,U.A)((0,U.A)({},e),(0,tj.Bg)(t,null!==(l=e.ownershipSet)&&void 0!==l?l:void 0)):(console.warn("Unhandled filter section:",a),e):(console.warn("No type found for filter option",t),e);var l}),{}),lj=e=>{if(Array.isArray(e))return e.length>0;if("boolean"===typeof e)return e;if("object"===typeof e&&null!==e){const t=e;if(t.includeJointlyOwned||t.userIds&&t.userIds.length>0)return!0}return!1};var rj=n(27724),oj=n(76914),ij=n(22862),sj=n(57242);const cj=(e,t)=>{if(!t||!0!==t.needsReview)return!1;const n=t.needsReviewByUser,a=t.needsReviewUnassigned;return e===nC.V6?!0===a&&!n:n===e},dj=(e,t)=>({id:"needsReview",name:"Needs Review by",type:"radio",options:[{id:nC.V6,name:"Anyone",isSelected:cj(nC.V6,t),formatLabel:()=>"Needs review by anyone"},...(e||[]).map((e=>{let n=e.displayName,a=e.id;return{id:a,name:n,isSelected:cj(a,t),formatLabel:()=>"Needs review by ".concat(n)}}))]}),uj=e=>({id:"transactionVisibility",name:"Hidden",type:"radio",options:[{id:Ee.h1.HIDDEN_TRANSACTIONS_ONLY,name:"Hidden only",isSelected:(null===e||void 0===e?void 0:e.transactionVisibility)===Ee.h1.HIDDEN_TRANSACTIONS_ONLY},{id:Ee.h1.ALL_TRANSACTIONS,name:"Hidden and not hidden",isSelected:(null===e||void 0===e?void 0:e.transactionVisibility)===Ee.h1.ALL_TRANSACTIONS}]}),mj=function(e){return arguments.length>1&&void 0!==arguments[1]&&arguments[1]?{id:"deletedTransactionVisibility",name:"Deleted",type:"radio",options:[{id:Ee.SrA.DELETED_ONLY,name:"Deleted only",isSelected:(null===e||void 0===e?void 0:e.deletedTransactionVisibility)===Ee.
1SrA.DELETED_ONLY},{id:Ee.SrA.ALL_INCLUDING_DELETED,name:"Deleted and not deleted",isSelected:(null===e||void 0===e?void 0:e.deletedTransactionVisibility)===Ee.SrA.ALL_INCLUDING_DELETED}]}:void 0},pj=e=>e.reduce(((e,t)=>{const n=(0,o.A)(t.path,2),a=n[0],l=n[1];if("other"===a){const n=(0,tj.W5)(t);e.other||(e.other={}),e.other[l]=n}else"amount"===a?(e.amount||(e.amount={}),e.amount[t.id]=t.inputValues):"ownership"===a?(e.owners||(e.owners=[]),e.owners=e.owners.concat(t.id)):"businessEntities"===a?(e.businessEntities||(e.businessEntities=[]),e.businessEntities=e.businessEntities.concat(t.id)):e[a]=(e[a]||0)+1;return e}),{}),gj=(e,t)=>ij.Ay.filtersApplied({page:e,sections:pj(t)}),hj=(e,t)=>({id:sj.Lp.categories,name:"Categories",options:(0,tj.I5)(e).map((e=>({id:e.id,name:e.name,options:(0,tj.I5)(e.categories).map((e=>(0,tj.dN)(e,(0,tj.co)(null===t||void 0===t?void 0:t.categories))))}))).filter((e=>e.options.length>0))});var vj=n(72088);const fj=(e,t)=>{var n;if(0===e.length)return bj(t);const a=(0,Sn.A)(e),l=a[0],r=(0,kn.A)(a).slice(1),o=t.find((e=>e.id===l));return o?fj(r,null!==(n=o.options)&&void 0!==n?n:[o]):[]},Ej=e=>fj([],e).every((e=>e.isSelected)),yj=e=>e.options?bj(e.options):[e],bj=e=>e.reduce(((e,t)=>[...e,...yj(t)]),[]),xj=function(e){var t;const n=[...arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],e.id];return(0,U.A)((0,U.A)({},e),{},{path:n,options:null===(t=e.options)||void 0===t?void 0:t.map((e=>xj(e,n)))})},wj=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];return e.map((e=>xj(e,t)))},Cj=(e,t)=>{const n=(0,vj.A)((e=>e.name.toLowerCase().includes(t.toLowerCase())),e),a=(0,o.A)(n,2),l=a[0],r=a[1];return[...(0,Ri.A)(r.map((e=>{let n=e.options;return Cj(null!==n&&void 0!==n?n:[],t)}))),...l]},Aj=["data","onApplyFilters","filters","getFilterSectionsFromQuery","adaptSelectedOptionsToFilters","sectionsResetKey"],Ij=e=>{const t=e.data,n=e.onApplyFilters,l=e.filters,r=e.getFilterSectionsFromQuery,i=e.adaptSelectedOptionsToFilters,s=e.sectionsResetKey,c=(0,En.A)(e,Aj),d=(0,a.useState)((()=>r(t,l,c))),u=(0,o.A)(d,2),m=u[0],p=u[1],g=(0,a.useCallback)((function(){const e=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}).keepSelectedAsyncOptions,n=void 0===e||e,a=wj(m,[]).flatMap((e=>bj(e.options).filter((e=>e.isSelected)))),o=r(t,l,c),i=wj(o,[]),s=e=>e.map((e=>(a.find((t=>t.id===e.id&&JSON.stringify(t.path)===JSON.stringify(e.path)))&&(e.isSelected=!0),e.options&&e.options.length>0&&(e.options=s(e.options)),e)));i.forEach((e=>{n&&(e.options=s(e.options))})),p(i)}),[t,l,m,r,c]),h=(0,a.useCallback)((()=>{g({keepSelectedAsyncOptions:!1})}),[g]);(0,a.useEffect)((()=>{g()}),[t,l,s]);const v=(0,a.useCallback)((e=>{if((null!==e&&void 0!==e?e:{}).reset)return h(),void n({});const t=wj(m,[]).flatMap((e=>bj(e.options).filter((e=>e.isSelected)))),a=i(t);n(a,t)}),[n,i,h,m]);return{sections:m,onChangeSections:p,resetUnappliedChanges:h,handleApply:v}},kj=e=>{var t,n;const l=e.page,i=e.onApplyFilters,s=e.filters,c=e.renderAccountLogo,d=e.renderOwnership,u=(0,a.useState)(void 0),m=(0,o.A)(u,2),p=(m[0],m[1]),g=(0,et.I)(Sj),h=g.data,v=g.isLoadingInitialData,f=null!==(t=null===h||void 0===h||null===(n=h.myHousehold)||void 0===n?void 0:n.users)&&void 0!==t?t:[],E=(0,a.useCallback)((e=>{p(e)}),[]),y=Ij({data:h,filters:s,getFilterSectionsFromQuery:(e,t,n)=>((e,t,n)=>{var a,l;if(!e)return[];const o=n||{},i=o.renderAccountLogo,s=o.renderOwnership,c=o.householdUsers,d=void 0===c?[]:c,u=e.accounts,m=void 0===u?[]:u,p=e.householdPreferences||{},g=p.collaborationToolsEnabled,h=p.accountGroupOrder,v=!!g,f=(0,LD.A)((0,nj.A)("",["type","display"]),m),E=Object.keys(f),y=h&&h.length>0?[...h.filter((e=>f[e])),...E.filter((e=>!h.includes(e)))]:E,b=(0,LD.A)((e=>{var t;return(0,nj.A)("other",["type","group"],null===(t=f[e])||void 0===t?void 0:t[0])}),y),x=e=>(0,r.YW)(e).with("asset",(()=>"Assets")).with("liability",(()=>"Liabilities")).otherwise((()=>"Other"));return[{id:"accounts",name:"Accounts",options:["asset","liability","other"].filter((e=>{var t;return null===(t=b[e])||void 0===t?void 0:t.length})).map((e=>{var n;return{id:e,name:x(e),options:(null!==(n=b[e])&&void 0!==n?n:[]).map((e=>({id:e,name:e,options:f[e].map((e=>({id:e.id,name:(0,nj.A)("",["displayName"],e),isSelected:(0,tj.co)((null===t||void 0===t?void 0:t.ids)||void 0)(e.id),icon:null===i||void 0===i?void 0:i(e)})))}
1)))}}))},...v?[{id:"ownership",name:"Owners",options:[{id:bd.u,name:bd.H,isSelected:null!==(a=null===t||void 0===t||null===(l=t.ownershipSet)||void 0===l?void 0:l.includeJointlyOwned)&&void 0!==a&&a,icon:null===s||void 0===s?void 0:s()},...d.map((e=>{var n,a;return{id:e.id,name:null!==(n=e.displayName)&&void 0!==n?n:e.name,isSelected:(0,tj.co)(null===t||void 0===t||null===(a=t.ownershipSet)||void 0===a?void 0:a.userIds)(e.id),icon:null===s||void 0===s?void 0:s(e)}}))]}]:[]]})(e,t,(0,U.A)((0,U.A)({},n),{},{householdUsers:f,renderAccountLogo:c,renderOwnership:d})),onApplyFilters:(e,t)=>{i(e),t&&gj(l,t)},adaptSelectedOptionsToFilters:aj});return{sections:y.sections,isLoading:v,onChangeSections:y.onChangeSections,onSearchChange:E,resetUnappliedChanges:y.resetUnappliedChanges,handleApply:y.handleApply}},Sj=Ee.khq,Nj=(e,t)=>{const n=(0,et.I)(Sj).data,l=(0,a.useMemo)((()=>{var e,t;const a=new Map,l=new Map,r=new Map,o=new Map;return(null!==(e=null===n||void 0===n?void 0:n.accounts)&&void 0!==e?e:[]).forEach((e=>{var t,n;l.set(e.id,e.displayName);const a=null===(t=e.type)||void 0===t?void 0:t.name,i=null===(n=e.type)||void 0===n?void 0:n.group;a&&(r.has(a)||r.set(a,new Set),r.get(a).add(e.id)),i&&(o.has(i)||o.set(i,new Set),o.get(i).add(e.id))})),(0,tj.Xh)(null!==(t=null===n||void 0===n?void 0:n.accounts)&&void 0!==t?t:[]).forEach((e=>{e.subtypes.forEach(((e,t)=>a.set(t,e)))})),{subtypeKeyToDisplay:a,accountIdToDisplay:l,accountIdsByType:r,accountIdsByGroup:o}}),[n]),r=l.subtypeKeyToDisplay,i=l.accountIdToDisplay,s=l.accountIdsByType,c=l.accountIdsByGroup;return{selectedAccountTypeDisplayNames:(0,a.useMemo)((()=>{var t;return null!==(t=null===e||void 0===e?void 0:e.map((e=>{var t;return null!==(t=r.get(e))&&void 0!==t?t:e})))&&void 0!==t?t:[]}),[e,r]),selectedAccountDisplayNames:(0,a.useMemo)((()=>{var e;return null!==(e=null===t||void 0===t?void 0:t.map((e=>{var t;return null!==(t=i.get(e))&&void 0!==t?t:e})))&&void 0!==e?e:[]}),[t,i]),allAccountsOfTypeSelected:(0,a.useMemo)((()=>{if(null===t||void 0===t||!t.length)return!1;const e=new Set(t);for(const t of s){const n=(0,o.A)(t,2)[1];if(n.size===e.size&&[...n].every((t=>e.has(t))))return!0}return!1}),[t,s]),allAccountsOfGroupSelected:(0,a.useMemo)((()=>{if(null===t||void 0===t||!t.length)return!1;const e=new Set(t);for(const t of c){const n=(0,o.A)(t,2)[1];if(n.size===e.size&&[...n].every((t=>e.has(t))))return!0}return!1}),[t,c])}};var Tj=n(10227),_j=n(14708);const Dj=e=>{const t=(0,Tj.Rq)().businessEntities;return(0,a.useMemo)((()=>{var n;if(!e)return[];return(e.includeUnassigned?[_j.qq]:[]).concat((null!==(n=e.businessEntityIds)&&void 0!==n?n:[]).map((e=>{var n;return null===(n=t.find((t=>t.id===e)))||void 0===n?void 0:n.name})).filter(Boolean))}),[e,t])},Rj=parseInt(yD.w.spacing.default,10),Mj=e=>{let t=e.snapShotsDataByAccountType,n=e.aggregateSnapshotsData,l=e.availableAccountTypes,r=e.hideTitle,i=e.className,s=e.isLoadingSnapshotsByAccountType,d=e.isSnapshotsNetworkRequestInFlight,u=e.isLoadingAggregateSnapshots,m=e.isAggreateSnapShotsNet
1workRequestInFlight,g=e.chartType,h=e.setChartType,v=e.selectedDateRange,f=e.activeTimeframeIndex,E=void 0===f?0:f,y=e.onChangeTimeframe,b=e.setSelectedDateRange,x=e.selectedOwnerIds,w=e.selectedAccountTypes,C=e.selectedAccountIds,A=e.businessEntitySet,I=e.amountHeaderProps;const k=(0,qd.W)(),S=(0,o.A)(k,2),N=S[0],T=S[1].width,_=void 0===T?0:T,D=(0,nC.xd)(),R=(0,o.A)(D,1)[0].users,M=Nj(w,C),L=M.selectedAccountTypeDisplayNames,O=M.selectedAccountDisplayNames,P=M.allAccountsOfTypeSelected,B=M.allAccountsOfGroupSelected,z=Dj(A),F=(0,a.useMemo)((()=>EW[E].value),[E]),G=(0,a.useMemo)((()=>(0,GV.o)(t,F)),[t,F]),Y=(0,a.useMemo)((()=>{var e;return!(null===x||void 0===x||!x.length)||!(null===w||void 0===w||!w.length)||!(null===C||void 0===C||!C.length)||!(null===A||void 0===A||null===(e=A.businessEntityIds)||void 0===e||!e.length)||!(null===A||void 0===A||!A.includeUnassigned)}),[x,w,C,A]),U=(0,a.useMemo)((()=>Y&&l.length>0&&l.every((e=>"liability"===e.group))),[Y,l]),V=(0,a.useMemo)((()=>Y&&l.length>0&&l.every((e=>"asset"===e.group))),[Y,l]),W=U,j=!W,H=(0,a.useMemo)((()=>(0,hW.Q8)(n,null!==j&&void 0!==j&&j)),[j,n]).snapshots,K="balance",q=(0,a.useMemo)((()=>{const e="breakdown"===g?(0,GV.Fb)(G):(0,GV.e0)(H,K),t=(0,o.A)(e,2),n=t[0],a=t[1],l="breakdown"===g&&W?-1:1;return[n*l,a*l]}),[g,G,H,K,W]),$=(0,o.A)(q,2),Z=$[0],J=$[1],X=(0,a.useMemo)((()=>{if(1===z.length)return{title:z[0],isFiltered:!1};if(P&&1===l.length)return{title:l[0].display,isFiltered:!1};if(O.length>0&&O.length<=2)return{title:O.join(" + "),isFiltered:!1};if(U){if(1===l.length)return{title:"".concat(l[0].display," (filtered)"),isFiltered:!0};const e=!B;return{title:e?"Liabilities (filtered)":"Liabilities",isFiltered:e}}if(V){if(1===l.length)return{title:"".concat(l[0].display," (filtered)"),isFiltered:!0};const e=!B;return{title:e?"Assets (filtered)":"Assets",isFiltered:e}}return O.length>=3?{title:"Net worth (filtered)",isFiltered:!0}:{title:"Net worth",isFiltered:!1}}),[U,V,P,B,l,O,z]),Q=X.title,ee=X.isFiltered?_t.Dx.NET_WORTH_FILTERED_TOOLTIP:_t.Dx.NET_WORTH_TITLE_TOOLTIP,te=(0,a.useMemo)((()=>(0,GV.x_)(F,v.display,g)),[F,g,v]),ne=(0,a.useMemo)((()=>_-Rj),[_]),ae=(0,a.useMemo)((()=>wd(x,R)),[x,R]);return a.createElement(Lj,{"data-external-id":"account-net-worth-charts",ref:N,className:i},!r&&a.createElement("div",{className:"flex items-start justify-between"},a.createElement(Oj,null,a.createElement(fe.cIj,{size:"3xs",side:"right",content:ee,triggerClassName:"text-content-secondary",iconSize:"xs",label:a.createElement(RV.W,null,Q)})),y&&a.createElement(yW,{activeTimeframeIndex:E,selectedDateRange:v,setSelectedDateRange:b,onChangeTimeframe:y,onChangeChartType:h,chartType:g})),s||u?a.createElement(Pj,null,a.createElement(p.i,null)):a.createElement(Bj,null,a.createElement(ej,Object.assign({startAmount:Z,currentAmount:J,timeframeText:te,isAsset:j},I)),(0,c.A)(G)&&"breakdown"===g&&a.createElement(AW,{width:ne,snapShotsDataByAccountType:t,isSnapshotsNetworkRequestInFlight:d,activeTimeframeIndex:E,isLoadingSnapshotsByAccountType:s}),(0,c.A)(H)&&"performance"===g&&a.createElement(ZW,{title:Q,yDataKey:K,aggregateSnapshotsData:H,selectedDateRange:v,width:ne,isAggreateSnapShotsNet
1workRequestInFlight:m,isAsset:j,selectedHouseholdMemberName:ae,selectedAccountTypeDisplayNames:L,selectedAccountDisplayNames:O,businessEntityDisplayNames:z})))},Lj=u.default.div.attrs((0,Ex.p)("account-net-worth-charts")).withConfig({displayName:"AccountNetWorthCharts__Root",componentId:"sc-14tj3z2-0"})(["padding:",";"],(e=>e.theme.spacing.large)),Oj=(0,u.default)(m.g).attrs({alignCenter:!0}).withConfig({displayName:"AccountNetWorthCharts__TitleContainer",componentId:"sc-14tj3z2-1"})(["gap:",";"],(e=>e.theme.spacing.xsmall)),Pj=(0,u.default)(m.g).attrs({alignCenter:!0,justifyCenter:!0}).withConfig({displayName:"AccountNetWorthCharts__LoadingContainer",componentId:"sc-14tj3z2-2"})(["height:","px;"],275),Bj=(0,u.default)(m.g).attrs({column:!0}).withConfig({displayName:"AccountNetWorthCharts__ChartContainer",componentId:"sc-14tj3z2-3"})(["margin-top:-",";"],(e=>e.theme.spacing.xsmall));var zj=n(94391),Fj=n(18684),Gj=n(64962);const Yj=e=>{let t=e.header,n=e.width,l=e.className,r=e.children;return a.createElement(Uj,{"data-external-id":"filter-menu-column",$width:n,className:l},a.createElement(Vj,null,"string"===typeof t?a.createElement(Wj,null,t):t),a.createElement(jj,null,r))},Uj=(0,u.default)(m.g).withConfig({displayName:"FilterMenuColumn__Root",componentId:"sc-114402i-0"})(["flex-direction:column;overflow:hidden;",":not(:last-child){border-right:1px solid ",";}"],(e=>{let t=e.$width;return t?(0,u.css)(["width:","px;"],t):(0,u.css)(["flex:1;"])}),vt.Ee.color.divider.primary),Vj=(0,u.default)(m.g).attrs({alignCenter:!0,justifyBetween:!0}).withConfig({displayName:"FilterMenuColumn__Header",componentId:"sc-114402i-1"})(["height:","px;border-bottom:1px solid ",";font-size:",";font-weight:",";flex-shrink:0;"],50,vt.Ee.color.divider.primary,vt.J.small,vt.Wy.medium),Wj=u.default.div.withConfig({displayName:"FilterMenuColumn__HeaderText",componentId:"sc-114402i-2"})(["padding:"," calc("," + ",");"],vt.YK.xsmall,vt.YK.small,vt.YK.xxsmall),jj=u.default.div.withConfig({displayName:"FilterMenuColumn__Content",componentId:"sc-114402i-3"})(["flex:1;overflow-y:auto;"]),Hj=e=>{let t=e.subtitle,n=void 0===t?"Try searching for something else.":t;return a.createElement(Kj,{"data-external-id":"filter-menu-empty"},a.createElement(qj,null),a.createElement(xt.v,{size:"small",weight:"medium"},"No results found"),a.createElement(xt.v,{size:"small"},n))},Kj=(0,u.default)(m.g).attrs({gap:"xsmall",column:!0,center:!0}).withConfig({displayName:"FilterMenuEmpty__Root",componentId:"sc-1ylk9eh-0"})(["text-align:center;margin-top:",";"],vt.YK.default),qj=(0,u.default)(sl.ZQ).attrs({name:"search",size:24}).withConfig({displayName:"FilterMenuEmpty__SearchIcon",componentId:"sc-1ylk9eh-1"})(["color:",";margin-bottom:",";"],vt.yW.gray,vt.YK.xxsmall);var $j=n(30680);const Zj=e=>{let t=e.name,n=e.indent,l=e.isSelected,r=e.isGroup,o=e.onChangeSelected,i=e.accessory,s=e.icon;return a.createElement(Jj,{"data-external-id":"filter-menu-option-row",$indent:n},a.createElement(Xj,{size:16,checked:l,onChange:e=>null===o||void 0===o?void 0:o(e.target.checked)},a.createElement(Qj,null,s,a.createElement(xt.v,Object.assign({title:t,clampLines:1},r?{size:"xsmall",weight:"medium",color:"textLight"}:{size:"small",weight:"book"}),a.createElement($j.M,null,t))),i))},Jj=(0,u.default)(m.g).attrs({alignCenter:!0}).withConfig({displayName:"FilterMenuOptionRow__Root",componentId:"cjje0q-0"})(["padding:"," 0;padding-left:",";"],vt.YK.xxsmall,(e=>{let t=e.$indent;return"".concat(10*(null!==t&&void 0!==t?t:0),"px")})),Xj=(0,u.default)(fz.hm).withConfig({displayName:"FilterMenuOptionRow__StyledCheckbox",componentId:"cjje0q-1"})(["width:100%;[data-sc-tw~='Checkbox__Text']{overflow:hidden;display:flex;align-items:center;width:100%;justify-content:space-between;}"]),Qj=(0,u.default)(m.g).attrs({alignCenter:!0}).withConfig({displayName:"FilterMenuOptionRow__NameIconContainer",componentId:"cjje0q-2"})(["overflow:hidden;[data-sc-tw~='Text__Text']{line-height:150%;}"]);var eH=n(34357);const tH=e=>{var t;let n=e.option,l=e.onInputChange;return(0,LV.A)(n.inputs)?null:a.createElement(nH,{"data-external-id":"filter-menu
1-option-accessory"},null===(t=n.inputs)||void 0===t?void 0:t.map((e=>{var t,r;return"currency"!==e.type?null:a.createElement("div",{key:"".concat(n.id,"-").concat(e.name),className:"min-w-0 flex-1"},a.createElement(fe.K$5,{id:n.id,placeholder:e.placeholder,name:e.name,size:"sm",value:null!==(t=null===(r=n.inputValues)||void 0===r?void 0:r[e.name])&&void 0!==t?t:null,onValueChange:t=>l(n.path,n.id,e,t)}))})))},nH=(0,u.default)(m.g).attrs({gap:"xsmall"}).withConfig({displayName:"FilterMenuOptionAccessory__InputContainer",componentId:"r0kocu-0"})(["margin-top:",";"],vt.YK.xxxsmall),aH=e=>{let t=e.options,n=e.onChangeSelected,l=e.flat,r=e.onInputChange;const o=(0,a.useMemo)((()=>bj(t).filter((e=>e.isSelected)).reduce(((e,t)=>(0,U.A)((0,U.A)({},e),{},{[t.id]:!0})),{})),[t]);return a.createElement(a.Fragment,null,t.map((e=>{var t,i;let s=e.id,c=e.name,d=e.path,u=e.options,m=e.isSelected,p=e.icon,g=e.accessory,h=e.type;return a.createElement(a.Fragment,{key:s},"radio"===h?a.createElement(a.Fragment,null,a.createElement(lH,null,a.createElement(xt.v,{size:"xsmall",weight:"medium",color:"textLight"},c)),a.createElement(eH.FD,{RowComponent:rH,options:null!==(t=null===u||void 0===u?void 0:u.map((e=>({value:e.id,label:e.name,accessory:o[e.id]&&a.createElement(tH,{option:e,onInputChange:r})}))))&&void 0!==t?t:[],value:{value:null===u||void 0===u||null===(i=u.find((e=>e.isSelected)))||void 0===i?void 0:i.id},onChange:e=>{n(d,!1),setTimeout((()=>{var t;const a=(0,RY.A)(e)?null===(t=e[0])||void 0===t?void 0:t.value:e.value;a&&n([...d,a],!0)}),0)}})):a.createElement(a.Fragment,null,a.createElement(Zj,{name:c,indent:l?0:d.length-1,isGroup:!(null===u||void 0===u||!u.length),isSelected:m||!(!u||!Ej(u)),onChangeSelected:e=>n(d,e),accessory:g,icon:p}),u&&a.createElement(aH,{options:u,onChangeSelected:n,onInputChange:r})))})))},lH=(0,u.default)(m.g).withConfig({displayName:"FilterMenuOptionsList__Row",componentId:"sc-1k8blm0-0"})(["align-items:center;padding:"," 0;"],vt.YK.xxsmall),rH=(0,u.default)(lH).withConfig({displayName:"FilterMenuOptionsList__RadioRow",componentId:"sc-1k8blm0-1"})(["cursor:pointer;font-size:",";[data-sc-tw~='Radio__CircleIndicator']{margin-right:",";}"],vt.J.small,vt.YK.xsmall),oH=e=>{let t=e.sections,n=e.onChangeSelected,l=e.onInputChange;return a.createElement(a.Fragment,null,t.map((e=>{let t=e.id,r=e.name,o=e.options;return a.createElement(a.Fragment,{key:t},a.createElement(iH,null,a.createElement(xt.v,{clampLines:1,size:"xsmall",weight:"medium",color:"textLight"},r)),a.createElement(aH,{options:o,onChangeSelected:n,onInputChange:l,flat:!0}))})))},iH=(0,u.default)(m.g).withConfig({displayName:"FilterMenuSearchResults__Row",componentId:"aqo1j8-0"})(["align-items:center;padding:"," 0;"],vt.YK.xxsmall);var sH=n(77524);const cH=e=>{let t=e.isLoading,n=e.search,l=e.isSearchLoading,r=e.onSearchChange,o=e.searchResults,i=e.searchRef,s=e.validationErrors,c=e.activeSection,d=e.changeSelected,u=e.handleInputChange,m=e.hasActiveSearch;const p=c.options,g=t||(0,PY.A)(n)&&(0,PY.A)(o),h=t||l&&n.length>0&&(0,PY.A)(c.options)&&(0,PY.A)(o),v=(0,a.useMemo)((()=>c.options.some((e=>e.options))),[c]),f=(0,a.useMemo)((()=>c.options.some((e=>"radio"===e.type))),[c]),E=(0,PY.A)(n)&&(0,Gj.A)(p)&&!f&&!c.hideSelectAll;return a.createElement(a.Fragment,null,a.createElement(Yj,{header:a.createElement(uH,{name:"search",value:n,onChange:r,placeholder:"Search...",disabled:g,ref:i,autoFocus:!0,small:!0})},a.createElement(dH,null,h?a.createElement(pH,null,(0,db.A)(0,6).map((e=>a.createElement(gH,{key:e,$indent:e>0&&e%2===0})))):a.createElement(a.Fragment,null,E&&a.createElement(Zj,{name:"Select all",isGroup:!0,isSelected:Ej(c.options),onChangeSelected:e=>d([c.id],e)}),(0,PY.A)(o)?a.createElement(Hj,null):a.createElement(a.Fragment,null,s.length>0&&a.createElement(vH,{type:"error"},s.join("\n")),a.createElement(sH.j.Provider,{value:{searchWords:n.split(" ")}},m?a.createElement(oH,{sections:o,onChangeSelected:d,onInputChange:u}):a.createElement(aH,{flat:!!n||!v,onChangeSelected:d,onInputChange:u,options:p})))),c.footer&&a.createElement(hH,null,c.footer))))},dH=(0,u.default)(m.g).attrs({column:!0}).withConfig({displayName:"FilterMenuSearch__OptionsListContainer",componentId:"sc-9cci93-0"})(["padding:"," ",";gap:",";"],vt.YK.xsmall,vt.YK.small,vt.YK.xxxsmall),uH=(0,u.default)(TF.J).withConfig({displayName:"FilterMenuSearch__StyledSearchBar",componentId:"sc-9cci93-1"})(["width:100%;[data-sc-tw~='SearchBar__Input']{border:none !important;box-shadow:none !important;font-size:",";outline:none;:disabled{background-color:",";}}"],vt.J.small,vt.yW.white),mH=u.default.div.withConfig({displayName:"FilterMenuSearch__SkeletonContainer",componentId:"sc-9cci93-2"})(["flex:1;display:flex;flex-flow:column;padding:"," ",";padding-top:",";"],vt.YK.xsmall,vt.YK.small,vt.YK.small),pH=(0,u.default)(mH).withConfig({displayName:"FilterMenuSearch__OptionListSkeletonContainer",componentId:"sc-9cci93-3"})(["padding-left:0;padding-top:0;padding-right:",";"],vt.YK.small),gH=(0,u.default)(M.Al).withConfig({displayName:"FilterMenuSearch__BaseSkeleton",componentId:"sc-9cci93-4"})(["height:",";&:not(:last-child){margin-bottom:",";}",""],vt.J.small,vt.YK.small,(e=>e.$indent&&(0,u.css)(["margin-left:",";"],vt.YK.default))),hH=u.default.div.withConfig({displayName:"FilterMenuSearch__FooterContainer",componentId:"sc-9cci93-5"})(["padding-top:",";"],vt.YK.xsmall),vH=(0,u.default)(fu.g).withConfig({displayName:"FilterMenuSearch__SmallBanner",componentId:"sc-9cci93-6"})(["padding:"," ",";font-size:",";"],vt.YK.xxsmall,vt.YK.xsmall,vt.J.small),fH=e=>
1{let t=e.activeSections,n=e.onChangeSelected;return a.createElement("div",{"data-external-id":"filter-menu-selected-list",className:"flex flex-col gap-3xs px-sm"},t.map((e=>{let t=e.id,l=e.path,r=e.name,o=e.selectedOptions;return a.createElement(a.Fragment,{key:t},a.createElement("div",{className:"flex h-8 items-center justify-between gap-xs text-sm"},a.createElement(kD.c,{size:"xs",weight:"medium",color:"secondary",className:"line-clamp-1"},r),a.createElement(Wb.X,{variant:"text",colorScheme:"link",size:"xs",className:"text-xs",onClick:()=>n(l,!1)},"Clear")),o.map((e=>{let t=e.id,l=e.name,r=e.path,o=e.icon,i=e.inputs,s=e.inputValues,c=e.formatLabel;const d=EH(i,s),u=(null===c||void 0===c?void 0:c(d))||l;return a.createElement("div",{key:t,className:"flex h-8 items-center justify-between gap-xs text-sm"},a.createElement("div",{className:"flex items-center gap-px truncate"},o,a.createElement(kD.c,{size:"sm",title:u,className:"line-clamp-1 leading-normal"},u)),a.createElement(Yi.S,{size:"xs",variant:"minimal","aria-label":"Remove filter",onClick:()=>n(r,!1)},a.createElement(fe.QqB,null)))})))})))},EH=(e,t)=>(null!==e&&void 0!==e?e:[]).reduce(((e,n)=>{let a=n.name;return(0,U.A)((0,U.A)({},e),{},{[a]:null===t||void 0===t?void 0:t[a]})}),{}),yH={id:"",name:"",options:[]},bH=["other","amount"],xH=e=>{let t=e.sections,n=e.isLoading,l=e.isSearchLoading,r=e.onSearchChange,i=e.onChange,s=e.onClickApply,c=e.onClickCancel,d=e.options;const u=(null!==d&&void 0!==d?d:{}).filtersColumnWidth,m=(0,a.useMemo)((()=>wj(t)),[t]),p=(0,a.useState)(0),g=(0,o.A)(p,2),h=g[0],f=g[1],E=(0,a.useMemo)((()=>{var e;return null!==(e=m[h])&&void 0!==e?e:yH}),[m,h]),y=(0,a.useState)(""),b=(0,o.A)(y,2),x=b[0],w=b[1],C=(0,xy.d)(x,200),A=(0,a.useRef)(null);(0,a.useEffect)((()=>{null===r||void 0===r||r(C)}),[C,r]);const I=(0,a.useMemo)((()=>m.flatMap((e=>{const t=bj(e.options).filter((e=>e.isSelected));return t.length?[(0,U.A)((0,U.A)({},e),{},{selectedOptions:t})]:[]}))),[m]),k=(0,a.useMemo)((()=>I.reduce(((e,t)=>e+t.selectedOptions.length),0)),[I]),S=(0,a.useMemo)((()=>m.filter((e=>!bH.includes(e.id))).flatMap((e=>{const t=Cj(e.options,x);return t.length?[(0,U.A)((0,U.A)({},e),{},{options:t})]:[]}))),[m,x]),N=(0,v.D)(((e,t)=>{const n=(0,zj.A)(m);fj(e,n).forEach((e=>{e.isSelected=t})),i(n),R([])})),T=(0,a.useState)([]),_=(0,o.A)(T,2),D=_[0],R=_[1],M=(0,v.D)(((e,t,n,a)=>{const l=(0,zj.A)(m);fj(e,l).forEach((e=>{e.id===t&&(e.inputValues=(0,Fj.A)([n.name],a,e.inputValues))})),i(l)})),L=(0,v.D)((()=>{let e=[];return m.forEach((t=>{const n=bj(t.options).filter((e=>e.isSelected));if(t.validate){const a=n.reduce(((e,t)=>{let n=t.inputValues;return(0,U.A)((0,U.A)({},e),n)}),{}),l=t.validate(a);l&&(e=e.concat(l))}})),e})),O=(0,v.D)((()=>{R([]);const e=L();(0,Gj.A)(e)?R(e):s()})),P=(0,v.D)((()=>{const e=(0,zj.A)(m);e.forEach((e=>{e.options.forEach((e=>{e.isSelected=!1}))})),i(e),s({reset:!0})})),B=(0,Gj.A)(x);return a.createElement(wH,{"data-external-id":"filter-menu"},a.createElement(CH,null,a.createElement(Yj,{header:"Filters",width:null!==u&&void 0!==u?u:140},a.createElement(Tm,{role:"menu",className:"gap-3xs px-xs"},m.map(((e,t)=>{let n=e.name;const l=!B&&t===h;return a.createElement(Tm.Item,{key:t,selected:l,role:"menuitemradio","aria-checked":l,onClick:()=>{var e;f(t),w(""),null===(e=A.current)||void 0===e||e.focus()},className:"text-sm"},n)})))),a.createElement(cH,{search:x,searchRef:A,onSearchChange:w,isSearchLoading:l,hasActiveSearch:B,activeSection:E,changeSelected:N,handleInputChange:M,searchResults:S,validationErrors:D}),a.createElement(Yj,{header:a.createElement(a.Fragment,null,n?a.createElement(SH,null,a.createElement(NH,{$width:"50%"})):a.createElement(kH,null,"".concat((0,De.td)("filter",k,{inclusive:!0})," selected")))},n?a.createElement(SH,null,(0,db.A)(0,4).map((e=>a.createElement(NH,{key:e})))):a.createElement(fH,{activeSections:I,onChangeSelected:N}))),a.createElement(AH,null,a.createElement(IH,null,a.createElement(wt.Xb,{size:"xsmall",disabled:k<=0,onClick:P},"Clear"),a.createElement(wt.Xb,{size:"xsmall",onClick:c},"Cancel"),a.createElement(cu.WT,{size:"xsmall",onClick:O},"Apply"))))},wH=(0,u.default)(m.g).attrs({column:!0}).withConfig({displayName:"FilterMenu__Root",componentId:"sc-6pewcm-0"})(["width:660px;height:440px;overflow:hidden;"]),CH=(0,u.default)(m.g).withConfig({displayName:"FilterMenu__ColumnsContainer",componentId:"sc-6pewcm-1"})(["flex:1;overflow:hidden;"]),AH=(0,u.default)(m.g).attrs({justifyEnd:!0}).withConfig({displayName:"FilterMenu__Footer",componentId:"sc-6pewcm-2"})(["padding:",";border-top:1px solid ",";flex-shrink:0;"],vt.YK.small,vt.Ee.color.divider.primary),IH=(0,u.default)(m.g).withConfig({displayName:"FilterMenu__ButtonGroup",componentId:"sc-6pewcm-3"})(["gap:",";flex:1;[data-sc-tw~='DefaultButton__DefaultButton']:first-child{margin-right:auto;}"],vt.YK.xsmall),kH=u.default.div.withConfig({displayName:"FilterMenu__GrayHeaderText",componentId:"sc-6pewcm-4"})(["padding:"," ",";color:",";"],vt.YK.xsmall,vt.YK.small,vt.yW.textLight),SH=u.default.div.withConfig({displayName:"FilterMenu__SkeletonContainer",componentId:"sc-6pewcm-5"})(["flex:1;display:flex;flex-flow:column;padding:"," ",";padding-top:",";"],vt.YK.xsmall,vt.YK.small,vt.YK.small),NH=(0,u.default)(M.Al).withConfig({displayName:"FilterMenu__BaseSkeleton",componentId:"sc-6pewcm-6"}
1)(["height:",";&:not(:last-child){margin-bottom:",";}",""],vt.J.small,vt.YK.small,(e=>e.$indent&&(0,u.css)(["margin-left:",";"],vt.YK.default))),TH=e=>{let t=e.filters,n=e.onChangeFilters;const l=(0,a.useState)(!1),r=(0,o.A)(l,2),i=r[0],s=r[1],d=(0,a.useMemo)((()=>(0,c.A)((0,VW.A)(lj,t))),[t]),u=kj({page:"accounts",filters:t,renderAccountLogo:e=>a.createElement(Gl.v,{logoUrl:e.logoUrl,icon:e.icon,size:14,className:"mr-2xs"}),renderOwnership:e=>a.createElement(Pw.n,{userId:null===e||void 0===e?void 0:e.id,userName:null===e||void 0===e?void 0:e.name,userProfilePictureUrl:null===e||void 0===e?void 0:e.profilePictureUrl,avatarSize:14,showLabel:!1,className:"mr-2xs"}),onApplyFilters:e=>{n(e),v()}}),m=u.sections,p=u.isLoading,g=u.onSearchChange,h=u.onChangeSections,v=u.resetUnappliedChanges,f=u.handleApply;return a.createElement(fe.k_P.Root,{"data-external-id":"account-filter-button",open:i,onOpenChange:e=>{s(e),v()},size:"2xl"},a.createElement(fe.qN2,{show:d},a.createElement(fe.k_P.Trigger,{render:a.createElement(fe.XZZ,{icon:a.createElement(fe.evG,null),variant:"default"},"Filters")})),a.createElement(fe.k_P.Content,{side:"bottom",align:"end",className:"p-0"},a.createElement(xH,{sections:m,isLoading:p,onClickCancel:()=>{v(),s(!1)},onChange:h,onSearchChange:g,onClickApply:e=>{f(e),s(!1)}})))},_H=[Ee.DUA.CUSTOM,Ee.DUA.BALANCE_DESC,Ee.DUA.BALANCE_ASC],DH=Ee.DUA.CUSTOM,RH={custom:"Custom order",balance_desc:"Amount (high to low)",balance_asc:"Amount (low to high)"},MH=e=>e===Ee.DUA.CUSTOM||e===Ee.DUA.BALANCE_DESC||e===Ee.DUA.BALANCE_ASC,LH=e=>{let t=e.sortMode,n=e.onChangeSortMode;return a.createElement(fe.qN2,{"data-external-id":"accounts-sort-menu",show:t!==DH},a.createElement(hA.u.Root,{modal:!0},a.createElement(hA.u.Trigger,{render:a.createElement(Wb.X,{variant:"default",size:"sm",endIcon:a.createElement(fe.D39,{size:"sm"}),"data-testid":"accounts-sort-menu"},"Sort")}),a.createElement(hA.u.Backdrop,null),a.createElement(hA.u.Content,{align:"end",className:"min-w-48"},a.createElement(hA.u.RadioGroup,{value:t,onValueChange:e=>{MH(e)&&n(e)}},_H.map((e=>a.createElement(hA.u.RadioItem,{key:e,value:e,closeOnClick:!0},RH[e])))))))};var OH=n(10323),PH=n(75782);const BH=20*iC.K5,zH=5*iC.EM,FH=(0,Qt.J)("\n  query Common_ForceRefreshAccountsQuery {\n    hasAccountsSyncing\n  }\n"),GH=10*iC.EM,YH=e=>{let t=e.source,n=e.onOperationStarted,l=e.onBeforeStartRefresh,r=e.isRefreshInProgress;const s=(0,V.m)(),c=(0,a.useState)(!1),d=(0,o.A)(c,2),u=d[0],m=d[1],p=(0,a.useState)(),g=(0,o.A)(p,2),h=g[0],v=g[1],f=u||!!r,E=!!n,y=(e=>{const t=e.onDidStartRefresh,n=e.onDidFinishRefresh,l=e.beforeStartRefresh,r=e.onError,s=e.source,c=e.skipGlobalRateLimitHandler,d=(0,PH.p)(FH,{pollUntil:e=>!(null===e||void 0===e?void 0:e.hasAccountsSyncing),onComplete:n,skipWhenNotPolling:!1,pollIntervalMs:BH,pollTimeoutMs:zH}),u=(0,o.A)(d,2),m=u[0],p=u[1],g=p.data,h=p.refetch,v=(0,a.useState)(),f=(0,o.A)(v,2),E=f[0],y=f[1];(0,a.useEffect)((()=>{(null===g||void 0===g?void 0:g.hasAccountsSyncing)&&m()}),[g,m]);const b=(0,i.n)(iG.Xx,{variables:{input:{source:s}},errorPolicy:"all",context:{skipGlobalRateLimitHandler:null!==c&&void 0!==c&&c},optimisticResponse:{__typename:"Mutation",forceRefreshAllAccounts:{__typename:"ForceRefreshAllAccountsMutation",success:!0,forceRefreshOperationId:null,errors:{__typename:"PayloadError",fieldErrors:[],message:null,code:null}}},update:e=>{const t=e.readQuery({query:FH});e.writeQuery({query:FH,data:(0,U.A)((0,U.A)({},t),{},{hasAccountsSyncing:!0})})}}),x=(0,o.A)(b,1)[0],w=(0,a.useCallback)((async()=>{var e,n,a,o,i,s;null===l||void 0===l||l();const c=await x(),d=c.data,u=c.errors,m=null===d||void 0===d?void 0:d.forceRefreshAllAccounts,p=null!==(i=null!==(n=null===(e=null===m||void 0===m?void 0:m.errors)||void 0===e?void 0:e.code)&&void 0!==n?n:null===(o=null===(a=null===u||void 0===u?void 0:u[0])||void 0===a?void 0:a.extensions)||void 0===o?void 0:o.code)&&void 0!==i?i:null;if(p||!m)return y(p),void(null===r||void 0===r||r(p));const g=null!==(s=m.forceRefreshOperationId)&&void 0!==s?s:null;null===t||void 0===t||t(g),await h()}),[x,h,l,t,r]);return[w,{error:E}]})({source:t,beforeStartRefresh:()=>{m(!0),ij.Ay.credentialRefreshAllRequested({source:t}),E&&(null===l||void 0===l||l())},onError:e=>{m(!1),(0,Ge.u4)(Ye.z.CredentialRefreshAllErrored,{error_code:e})},onDidStartRefresh:e=>{if(E&&null!==e)n(e);else{const e=(0,C.oR)({title:_t.tf,description:_t.Hw,duration:GH,accessory:a.createElement(vG.W,null,a.createElement(sl.ZQ,{name:"refresh"})),onDismiss:()=>{(0,Ge.u4)(Ye.z.SyncTransparencyLegacyToastDismissed,{source:"web"})}});v(e)}},onDidFinishRefresh:()=>{m(!1),E||(C.oR.dismiss(h),(0,C.oR)({title:_t.Dx.REFRESHED_ALL_ACCOUNTS_TOAST_TITLE,description:_t.Dx.REFRESHED_ALL_ACCOUNTS_TOAST_SUBTITLE,duration:3e4,actions:[{text:"Update View",onClick:()=>{s.reFetchObservableQueries()}}]}))}}),b=(0,o.A)(y,1)[0];return a.createElement(UH,{"data-external-id":"refresh-all-button",onClick:b,disabled:f},a.createElement(vG.W,{enabled:f},a.createElement(Yo.r,{name:"refresh"})),a.createElement("span",null,f?"Refreshing":"Refresh all"))},UH=(0,u.default)(wt.Xb).withConfig({displayName:"RefreshAllButton__ButtonContainer",componentId:"sc-1v13cqp-0"})(["padding-left:",";"],vt.YK.xxsmall),VH=function(){let e=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}).skip,t=void 0!==e&&e;var n;const l=(0,et.I)(WH,{skip:t}),r=l.data,s=l.refetch,c=null===r||void 0===r?void 0:r.householdPreferences,d=t?DH:(u=null===c||void 0===c?void 0:c.accountSortMode,MH(u)?u:DH);var u;const m=null!==(n=null===c||void 0===c?void 0:c.id)&&void 0!==n?n:null,p=(0,i.n)(jH),g=(0,o.A)(p,1)[0];return{sortMode:d,setSortMode:(0,a.useCallback)((e=>{g({variables:{input:{accountSortMode:e}},optimisticResponse:m?{__typename:"Mutation",updateHouseholdPreferences:{__typename:"UpdateHouseholdPreferences",householdPreferences:{__typename:"HouseholdPreferences",id:m,accountSortMode:e}}}:void 0})}),[m,g]),refetch:(0,a.useCallback)((()=>t?Promise.resolve():s()),[s,t])}},WH=(0,Qt.J)("\n  query Common_GetHouseholdAccountSortMode {\n    householdPreferences {\n      id\n      accountSortMode\n    }\n  }\n"),jH=(0,Qt.J)("\n  mutation Common_UpdateHouseholdAccountSortMode($input: UpdateHouseholdPreferencesInput!) {\n    updateHouseholdPreferences(input: $input) {\n      householdPreferences {\n        id\n        accountSortMode\n      }\n    }\n  }\n"),HH=e=>{var t;
1let n=e.accountFilters,o=e.onChangeFilters,i=e.onChangeBusinessEntityFilter,s=e.onClearFilters,c=e.hasMultipleOwners,d=e.onEditOwners,u=e.onEditBusinessEntities,m=e.onOperationStarted,p=e.onBeforeStartRefresh,g=e.isRefreshInProgress;const h=(0,l.Zp)(),v=(0,qG.e)().hasAccess,f=(0,Tj.Rq)().businessEntities,E=v&&f.length>0,y=(0,nG.p)("feat-accounts-sort-by-balance-web_mobile","off"),b=VH({skip:!y}),x=b.sortMode,w=b.setSortMode,C=(0,a.useMemo)((()=>(e=>Object.values(e).some((e=>!(0,LV.A)(e))))(n)),[n]),A=(0,a.useCallback)((()=>{(0,Ge.u4)(Ye.QQ.EditOwnersClicked),d()}),[d]),k=(0,a.useCallback)((()=>{(0,Ge.u4)(Ye.cz.EditBusinessEntitiesClicked),u()}),[u]);return a.createElement("div",{"data-external-id":"accounts-header-controls",className:"flex items-center gap-xs"},a.createElement(a.Fragment,null,C&&a.createElement(Wb.X,{variant:"text",colorScheme:"link",size:"sm",onClick:s,className:"mr-2xs"},"Clear"),y&&a.createElement(LH,{sortMode:x,onChangeSortMode:w}),v&&a.createElement(OH.O,{businessEntitySet:null!==(t=n.businessEntitySet)&&void 0!==t?t:void 0,onChangeBusinessEntitySet:i,source:Ye.rP.Accounts}),a.createElement(TH,{filters:n,onChangeFilters:o})),(0,r.YW)({hasMultipleOwners:c,hasBusinessEntities:E}).with({hasMultipleOwners:!0,hasBusinessEntities:!0},(()=>a.createElement(a.Fragment,null,a.createElement(wm.A,{orientation:"vertical",color:"tertiary",className:"mx-2xs h-default"}),a.createElement(hA.u,{align:"end",trigger:a.createElement(Wb.X,{variant:"default",size:"sm",endIcon:a.createElement(fe.D39,{size:"sm"})},"Edit assignments"),items:[{label:"Edit owners",onClick:A},{label:"Edit businesses",onClick:k}]})))).with({hasMultipleOwners:!0},(()=>a.createElement(a.Fragment,null,a.createElement(wm.A,{orientation:"vertical",color:"tertiary",className:"mx-2xs h-default"}),a.createElement(Wb.X,{variant:"default",size:"sm",icon:a.createElement(fe.yIO,{size:"sm"}),onClick:A},"Edit owners")))).with({hasBusinessEntities:!0},(()=>a.createElement(a.Fragment,null,a.createElement(wm.A,{orientation:"vertical",color:"tertiary",className:"mx-2xs h-default"}),a.createElement(Wb.X,{variant:"default",size:"sm",icon:a.createElement(fe.yIO,{size:"sm"}),onClick:k},"Edit businesses")))).otherwise((()=>null)),a.createElement(YH,{source:oV.MS.WebAccountsPage,onOperationStarted:m,onBeforeStartRefresh:p,isRefreshInProgress:g}),a.createElement(Wb.X,{variant:"primary",size:"sm",icon:a.createElement(fe.Wa3,{size:"sm"}),onClick:()=>h(I.JZ.accounts.addAccount())},"Add account"))};var KH=n(9807),qH=n(92757),$H=n(10293),ZH=n(76444);const JH=e=>{let t=e.children,n=e.draggable,l=e.isAsset,r=e.title,o=e.currentAmount,i=e.startAmount,s=e.isDraggingThis,c=e.isDragActive,d=e.onToggleCollapsed,u=e.isCollapsed;const m=(0,ZH.D)("accounts").activeFilters,p=m.timeframe,g=m.dateRange,h=m.chartType,v=(0,GV.x_)(p,g,h);return a.createElement(XH,{"data-external-id":"account-group-card"},a.createElement(QH,{$isDragActive:c,$isDraggingThis:s},a.createElement(eK,{$bottomBorder:!u},n&&a.createElement(qH.v,{className:"mr-3xs ml-0",revealOnHover:!0,revealScope:"group"}),a.createElement($H.V,{expanded:!u,onClick:d}),a.createElement(tK,null,a.createElement(nK,null,a.createElement(RV.W,{$large:!0},r),a.createElement(El.H,{className:"flex-1 text-base",startAmount:i,endAmount:o,timeframeDisplay:v,isAsset:l})),a.createElement(aK,{value:o}))),a.createElement(Ql.$,{open:!u,shouldAnimateOnMount:!1},t)))},XH=u.default.div.withConfig({displayName:"AccountGroupCard__Root",componentId:"sc-1f2oxtr-0"})(["padding-bottom:",";"],(e=>e.theme.spacing.gutter)),QH=(0,u.default)(Xl.AM).attrs({hideHeader:!0}).withConfig({displayName:"AccountGroupCard__CustomCard",componentId:"sc-1f2oxtr-1"})(["--shadow-color:",";transition:",";opacity:",";",";"],vt.Ee.color.shadow.card,(e=>e.theme.transition.createDefaultTransition(["opacity"])),(e=>{let t=e.$isDraggingThis;return e.$isDragActive&&!t?.7:1}),(e=>e.$isDraggingThis&&(0,u.css)(["box-shadow:0px 0px 0px 2px ",";"],vt.yW.blue))),eK=$d.s.div((e=>["group/account-group flex items-center justify-start gap-2xs",{"border-b border-divider-primary":e.$bottomBorder}])),tK=(0,u.default)(m.g).attrs({column:!0}).withConfig({displayName:"AccountGroupCard__Content",componentId:"sc-1f2oxtr-2"})(["flex-grow:1;padding:"," "," "," 0;
1display:flex;gap:",";flex-direction:row;align-items:center;"],vt.YK.default,vt.YK.large,vt.YK.default,vt.YK.xsmall),nK=u.default.div.withConfig({displayName:"AccountGroupCard__ColumnWhenSmall",componentId:"sc-1f2oxtr-3"})(["flex:1;display:flex;gap:",";flex-direction:column;align-items:stretch;@media (min-width:","px){flex-direction:row;align-items:center;gap:",";}"],vt.YK.xxxsmall,(e=>e.theme.breakPoints.lg),vt.YK.xsmall),aK=(0,u.default)(hl.t).withConfig({displayName:"AccountGroupCard__StyledCurrency",componentId:"sc-1f2oxtr-4"})(["font-size:",";font-weight:",";"],vt.J.large,vt.Wy.medium);var lK=n(46437),rK=n(17128);const oK=e=>{let t=e.showText,n=void 0===t?"Show":t,l=e.hideText,r=void 0===l?"Hide":l,i=e.initiallyOpen,s=void 0!==i&&i,c=e.showIcon,d=void 0===c?"eye":c,u=e.hideIcon,m=void 0===u?"eye-off":u,p=e.drawerBackgroundColor,g=void 0===p?"grayBackground":p,h=e.showArrow,v=void 0===h||h,f=e.children,E=e.className;const y=(0,Pc.e)(s),b=(0,o.A)(y,2),x=b[0],w=b[1].toggle;return a.createElement("div",{"data-external-id":"deprecated-show-hide-toggle-drawer"},a.createElement(dK,{open:x,shouldAnimateOnMount:!1,backgroundColor:g},f),a.createElement(sK,{className:E,onClick:w},v&&a.createElement(D.PY1.div,{className:"absolute -top-1.5 left-1 size-3 border-r border-b border-divider-secondary bg-background-secondary",variants:iK,initial:!1,animate:x?"shown":"hidden"}),a.createElement(cK,{name:x?m:d,size:16}),a.createElement(xt.v,{size:"small"},x?r:n)))},iK={shown:{opacity:1,y:0,rotate:45,transition:{duration:.15,ease:"easeOut",delay:.5}},hidden:{opacity:0,y:-6,rotate:45,transition:{duration:0}}},sK=(0,u.default)(m.g).attrs({alignCenter:!0}).withConfig({displayName:"ShowHideToggleDrawer__Button",componentId:"x9ng2x-0"})(["padding:"," 0;margin:0 ",";cursor:pointer;transition:",";color:",";position:relative;:hover{color:",";}"],(e=>e.theme.spacing.large),(e=>e.theme.spacing.large),(e=>e.theme.transition.default),vt.Ee.color.content.secondary,vt.Ee.color.content.primary),cK=(0,u.default)(sl.ZQ).withConfig({displayName:"ShowHideToggleDrawer__StyledIcon",componentId:"x9ng2x-1"})(["margin-right:",";"],(e=>e.theme.spacing.small)),dK=(0,u.default)(Ql.$).withConfig({displayName:"ShowHideToggleDrawer__StyledDrawer",componentId:"x9ng2x-2"})(["background:",";"],(e=>{let t=e.theme,n=e.backgroundColor;return t.color[n]}));var uK,mK,pK=n(95415),gK=n(99143),hK=n(261),vK=n(42159),fK=n(81771);const EK=(0,vK.J1)(mK||(mK=(0,wc.A)(["\n  mutation Web_UpdateAccountOrder($input: UpdateAccountOrderInput!) {\n    updateAccountOrder(input: $input) {\n      account {\n        id\n        order\n      }\n    }\n  }\n"]))),yK=e=>{const t=(()=>{const e=(0,V.m)(),t=(0,i.n)(EK,{refetchQueries:["Web_GetAccountsPage"],fetchPolicy:"no-cache"}),n=(0,o.A)(t,2),a=n[0],l=n[1];return(0,fK.r)((async(t,n,l)=>(e.writeFragment({id:"Account:".concat(t),fragment:(0,vK.J1)(uK||(uK=(0,wc.A)(["\n        fragment AccountOrderFields on Account {\n          id\n          order\n        }\n      "]))),data:{__typename:"Account",id:t,order:n}}),await a({variables:{input:{id:t,destinationPosition:l}}}))),l)})(),n=(0,o.A)(t,1)[0];return{handleOnDragEnd:t=>{let a=t.active,l=t.over;if(!l||a.id===l.id)return;const r=e.findIndex((e=>e.id===a.id)),o=e.findIndex((e=>e.id===l.id));if(-1===r||-1===o)return;const i=e[o].order,s=o>r?i+.5:i-.5;n(String(a.id),s,o)}}},bK=(0,Nc.A)((0,mo.A)("order")),xK=e=>{let t=e.accounts,n=e.recentBalancesByAccount,l=e.sparklinesTimeframeKey,r=e.institutionsMetrics,i=e.sortMode,s=void 0===i?Ee.DUA.CUSTOM:i;const c=(0,a.useState)(null),d=(0,o.A)(c,2),u=d[0],m=d[1],p=(0,hK.T)(),g=(0,a.useMemo)((()=>(0,vj.A)((0,lK.A)([(0,rK.A)("isHidden",!1)]),t)),[t]),h=(0,o.A)(g,2),v=h[0],f=h[1],E=(0,De.td)("account",f.length),y=(0,a.useMemo)((()=>s===Ee.DUA.CUSTOM?bK(v):((e,t)=>t===Ee.DUA.CUSTOM?[...e].sort(((e,t)=>{var n,a;return(null!==(n=e.order)&&void 0!==n?n:0)-(null!==(a=t.order)&&void 0!==a?a:0)})):function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"highest";return[...e].sort(((e,n)=>((e,t,n)=>{const a=e.displayBalance,l=t.displayBalance,r=void 0===a||null===a,o=void 0===l||null===l;
1return r&&o?0:r?1:o?-1:"highest"===n?l-a:a-l})(e,n,t)))}(e,t===Ee.DUA.BALANCE_DESC?"highest":"lowest"))(v,s)),[s,v]),b=yK(y).handleOnDragEnd,x=(0,a.useMemo)((()=>y.map((0,mo.A)("id"))),[y]),w=s===Ee.DUA.CUSTOM&&v.length>1,C=(0,a.useMemo)((()=>null===r||void 0===r?void 0:r.reduce(((e,t)=>(e[t.id]=t,e)),{})),[r]);return a.createElement("div",{"data-external-id":"account-group-list"},a.createElement(Bk.Mp,{sensors:p,collisionDetection:Bk.fp,modifiers:[zk.FN],onDragStart:e=>{let t=e.active;return m(String(t.id))},onDragEnd:e=>{b(e),m(null)},onDragCancel:()=>m(null),accessibility:{announcements:gK.n}},a.createElement(pK.Z,null),a.createElement(Fk.gB,{items:x,strategy:Fk._G},a.createElement("div",{className:(0,q.cn)("transition-colors",u?"bg-background-secondary":"bg-inherit",(0,PY.A)(f)&&"rounded-b-md")},y.map(((e,t)=>{var r,o;return a.createElement(Hk.U,{key:e.id,id:e.id,disabled:!w,customDragHandle:!0},a.createElement(xn.Z,{account:e,recentBalances:null===n||void 0===n?void 0:n[e.id],sparklinesTimeframeKey:l,isLast:(0,PY.A)(f)&&t===v.length-1,dragHandle:w?"draggable":"reserved",isDragging:u===e.id,institutionMetrics:null===C||void 0===C?void 0:C[null!==(r=null===e||void 0===e||null===(o=e.institution)||void 0===o?void 0:o.id)&&void 0!==r?r:""]}))}))))),f.length>0&&a.createElement(oK,{showText:"Show ".concat(f.length," hidden ").concat(E),hideText:"Collapse ".concat(f.length," hidden ").concat(E)},f.map((e=>a.createElement(wK,{key:e.id,account:e,recentBalances:null===n||void 0===n?void 0:n[e.id],sparklinesTimeframeKey:l})))))},wK=(0,u.default)(xn.Z).withConfig({displayName:"AccountGroupList__HiddenAccountListItem",componentId:"sc-1sfegfw-0"})(["background:",";&:hover{background:inherit;}&&{border-bottom:1px solid ",";border-radius:0;}"],vt.Ee.color.background.secondary,vt.Ee.color.divider.secondary);var CK,AK=n(87627),IK=n(10022);const kK=(0,vK.J1)(CK||(CK=(0,wc.A)(["\n  mutation Common_UpdateAccountGroupOrder($input: UpdateAccountGroupOrderInput!) {\n    updateAccountGroupOrder(input: $input) {\n      household {\n        preferences {\n          id\n          accountGroupOrder\n        }\n      }\n      errors {\n        ...PayloadErrorFields\n      }\n    }\n  }\n  ","\n"])),IK.K),SK=(e,t)=>{const n=e.map((e=>e.type.display)),l=(e=>{const t=null===e||void 0===e?void 0:e.accountGroupOrder,n=(null===e||void 0===e?void 0:e.id)||null,a=(0,i.n)(kK),l=(0,o.A)(a,1)[0];return[t,async e=>{await l({variables:{input:{accountGroupOrder:e}},optimisticResponse:{updateAccountGroupOrder:{__typename:"UpdateAccountGroupOrderMutation",household:{__typename:"Household",preferences:{id:n,__typename:"HouseholdPreferences",accountGroupOrder:e}},errors:null}}})}]})(t),r=(0,o.A)(l,2),s=r[0],c=r[1],d=((e,t)=>{if(!t||(0,PY.A)(t))return e;const n=(0,VW.A)((e=>!t.includes(e)),e),a=(0,VW.A)((t=>!e.includes(t)),t);return(0,AK.A)((0,VW.A)((e=>!a.includes(e)),t),n)})(n,s);return{handleOnDragEnd:e=>{let t=e.active,n=e.over;if(!n||t.id===n.id)return;const a=d.indexOf(String(t.id)),l=d.indexOf(String(n.id));-1!==a&&-1!==l&&c((0,Fk.be)(d,a,l))},sortedAccountsGroup:(0,a.useMemo)((()=>(0,PY.A)(s)?e:(0,sU.A)(((e,t)=>d.indexOf(e.type.display)-d.indexOf(t.type.display)),e)),[e,d,s])}};var NK=n(45393);const TK=(0,u.default)(cU.vx).withConfig({displayName:"AccountsList__AccountsEmpty",componentId:"sc-1ryb6lo-0"})(["padding:",";"],(e=>e.theme.spacing.xxxlarge)),_K=(e,t)=>{let n=e.householdPreferences,l=e.recentBalancesByAccount,r=e.sparklinesTimeframeKey,i=e.accountSummaries,s=e.snapshots,c=e.previousBalancesByAccountType;const u=(0,a.useContext)(ri.z).scrollTo,m=(0,nG.p)("feat-accounts-sort-by-balance-web_mobile","off"),p=VH({skip:!m}).sortMode,h=SK(i,n),v=h.handleOnDragEnd,f=h.sortedAccountsGroup,E=(0,hK.T)(),y=(0,a.useState)(null),b=(0,o.A)(y,2),x=b[0],w=b[1],C=(0,a.useState)([]),A=(0,o.A)(C,2),I=A[0],k=A[1];(0,a.useEffect)((()=>{let e=!1;return(async()=>{try{if(i.length>0){const t=i.map((e=>e.accounts.map((e=>{var t;return null===e||void 0===e||null===(t=e.institution)||void 0===t?void 0:t.id})))),n=[...new Set(t.flat())].filter((e=>void 0!==e&&null!==e));if(n.length>0){const t=await(0,NK.g)(n);t&&!e&&k(t)}else e||k([])}else e||k([])}catch(t){e||k([])}})(),()=>{e=!0}}),[i]);const S=(0,d.wA)(),T=(0,d.d4)(uG);(0,a.useImperativeHandle)(t,(()=>({scrollToAccountType:e=>{u(e,{offset:-32})}})));const _=(0,ZH.D)("accounts").activeFilters,D=_.timeframe,R=_.chartType,M=(0,vW.k3)(D)?D:vW.xh,L=(0,a.useMemo)((()=>f.map((e=>e.type.display))),[f]),O=(0,a.useMemo)((()=>"performance"===R&&c?c:(0,GV.Fe)(s,N.c9.local(),M)),[s,M,R,c]);return f.length?a.createElement(Bk.Mp,{"data-external-id":"accounts-list",sensors:E,collisionDetection:Bk.fp,modifiers:[zk.FN],onDragStart:e=>{let t=e.active;return w(String(t.id))},onDragEnd:e=>{v(e),w(null)},onDragCancel:()=>w(null),accessibility:{announcements:gK.n}},a.createElement(pK.Z,null),a.createElement(Fk.gB,{items:L,strategy:Fk._G},f.map((e=>{let t=e.type,n=t.display,o=t.group,i=t.name,s=e.totalDisplayBalance,c=e.accounts;return a.createElement(KH.Hg,{name:n,key:i},a.createElement(Hk.U,{id:n,customDragHandle:!0,revealScope:"group"},a.createElement(JH,{isAsset:o===Ee.n8S.ASSET,title:n,currentAmount:s,startAmount:O[i],isDraggingThis:x===n,isDragActive:!!x,draggable:!0,isCollapsed:T[i],onToggleCollapsed:()=>S((0,g.sn)(i))},a.createElement(xK,{accounts:c,recentBalancesByAccount:l,sparklinesTimeframeKey:r,institutionsMetrics:I,sortMode:p}))))}
1)))):a.createElement(Xl.AM,{"data-external-id":"accounts-list"},a.createElement(TK,{title:"No accounts yet",subtitle:"Add an account to get started."}))},DK=(Ee.GNd,(0,a.forwardRef)(_K));var RK=n(95290),MK=n(55588);const LK=["className","children","isLoading"],OK=e=>{let t=e.className,n=e.children,l=e.isLoading,r=void 0!==l&&l,o=(0,En.A)(e,LK);return a.createElement("div",{"data-external-id":"deprecated-async-text-button",className:t},r?a.createElement(p.i,{size:"sm",className:"flex items-center"}):a.createElement(PK,o,n))},PK=(0,u.default)(bn.v).withConfig({displayName:"AsyncTextButton__StyledTextButton",componentId:"qp9ocq-0"})(["padding:0;"]),BK=e=>{let t=e.items;return a.createElement("div",{"data-external-id":"account-composition-bar",className:"flex h-3 w-full gap-0.75"},t.map((e=>{let t=e.percentage,n=e.color,l=e.type;return a.createElement("div",{key:l.name,className:"h-full rounded-[3px]",style:{width:"".concat(100*t,"%"),backgroundColor:n}})})))};var zK,FK,GK;const YK=e=>{let t=e.title,n=e.items,l=e.total,r=e.displayType,o=e.onClickType;return a.createElement(UK,{"data-external-id":"account-summary-card-group"},a.createElement(VK,null,a.createElement("span",null,t),a.createElement(fe.c8D,Object.assign({color:"secondary",weight:"medium"},fl.zs),(0,rl.vv)(l))),a.createElement(WK,null,a.createElement(BK,{items:n})),n.map((e=>{let t=e.type,n=e.amount,l=e.percentage;return a.createElement(zV,{key:t.name,onClick:()=>null===o||void 0===o?void 0:o(t.display),balance:n,percentage:"percentage"===r?l:void 0,name:t.display,isAsset:!0})})))},UK=$d.s.div.attrs((0,Ex.p)("account-summary-card-group"))(zK||(zK=(0,wc.A)(["\n  not-last:border-b not-last:border-divider-primary not-last:p-xl last:p-0\n"]))),VK=$d.s.div(FK||(FK=(0,wc.A)(["\n  flex justify-between font-medium text-content-primary not-last:mb-default\n"]))),WK=$d.s.div(GK||(GK=(0,wc.A)(["mb-default"]))),jK={TRANSACTIONS:"transactions",CASH_FLOW:"spending",ACCOUNTS:"accounts",RECURRING:"recurring transactions",BUDGET:"budget",GOALS:"goals"},HK=e=>{let t=e.insightTheme,n=e.content,l=e.className,r=e.tooltipPlacement,i=e.tooltipThemeOverride,s=e.tooltipDescription,c=e.source,d=e.widgetState,u=e.isLoading,m=void 0!==u&&u,p=e.animationDelayMs,g=void 0===p?900:p;const h=(0,ht.S)().isAiFeaturesEnabled,v=(0,NW.N)(),f=(0,F.K)(),E=(0,a.useRef)(!1),y=(0,a.useState)(!1),b=(0,o.A)(y,2),x=b[0],w=b[1];if((0,a.useEffect)((()=>{m||E.current||(E.current=!0,f||w(!0))}),[m,f]),!h)return null;const C=null!==s&&void 0!==s?s:"Understand insights about your ".concat(null!==i&&void 0!==i?i:jK[t]),A=a.createElement(fe.SO$,{"aria-label":"Ask AI Assistant",variant:"minimal",size:"3xs",className:(0,q.cn)("group disabled:pointer-events-none",l),disabled:f,onClick:e=>{e.preventDefault(),e.stopPropagation(),(async()=>{f||((0,Ge.u4)(Ye.g8.Clicked,{source:c,widget_state:d}),await v(n,{fromGlobalSearch:!0,source:c}))})()},onMouseDown:e=>{e.preventDefault(),e.stopPropagation()}},a.createElement(SW,{size:16,className:(0,q.cn)("group-hover:transform-sparkle group-hover:text-background-brand-hover",x&&!f&&"animate-sparkle-entrance motion-reduce:animate-none"),style:{"--sparkle-entrance-delay":"".concat(g,"ms")}}));return a.createElement(fe.Yvj,{"data-external-id":"insights-button",side:null!==r&&void 0!==r?r:"top",disabled:f,description:C,contentClassName:"max-w-71.5 p-0 text-left",content:a.createElement("div",{className:"min-w-65 text-left"},a.createElement("div",{className:"flex items-center gap-2xs border-b border-divider-primary px-default pt-sm pb-xs"},a.createElement(SW,{size:16,colorVariant:"brand"}),a.createElement(Tt,{className:"text-sm/5"},"AI Insights")),a.createElement(fe.c8D,{render:a.createElement("div",null),size:"sm",weight:"book",className:"px-default pt-xs pb-default leading-5"},C))},A)};var KK=n(52814);const qK=[{label:"Totals",value:"balance"},{label:"Percent",value:"percentage"}],$K=e=>{let t=e.onClickAccountType,n=e.onClickDownloadCsv,l=e.isDownloadingCsv,r=e.accountSummaries,i=e.selectedOwnerIds,s=e.selectedAccountTypes,c=e.selectedAccountIds,d=e.businessEntitySet,m=e.isLoading;const p=(0,u.useTheme)(),g=(0,nC.xd)(),h=(0,o.A)(g,1)[0].users,v=Nj(s,c),f=v.selectedAccountTypeDisplayNames,E=v.selectedAccountDisplayNames,y=Dj(d),b=(0,vj.A)((0,RK.A)(["type","group"],"asset"))(r),x=(0,o.A)(b,2),w=x[0],C=x[1],A=(0,KK.u)(w,p),I=(0,KK.u)(C,p),k=(0,MK.A)((0,jd.A)((0,mo.A)("amount"),A)),S=(0,MK.A)((0,jd.A)((0,mo.A)("amount"),I)),N=(0,a.useState)(0),T=(0,o.A)(N,2),_=T[0],D=T[1],R=qK[_].value,M=(0,a.useMemo)((()=>wd(i,h)),[i,h]),L=(0,a.useMemo)((()=>f.length>0?_W(f):"assets & liabilities"),[f]),O=(0,a.useMemo)((()=>{const e=DW({accountTypeDisplayNames:f,accountDisplayNames:E,householdMemberName:M,businessEntityDisplayNames:y});return e?"Provide insights about these accounts:".concat(e):"Provide insights about my ".concat(L)}),[E,f,M,y,L]);return a.createElement(Xl.AM,{"data-external-id":"accounts-summary-card",title:a.createElement(XK,null,"Summary",a.createElement(HK,{insightTheme:"ACCOUNTS",content:O,tooltipThemeOverride:L,source:Ye.rP.AccountsPage,isLoading:m,animationDelayMs:PU.q2})),controls:a.createElement(Dc.t,{onChangeIndex:D,index:_},a.createElement(JK,null,qK.map(((e,t)=>{let n=e.label;return a.createElement(RA.Q,{key:t,index:t,$background:"card"},n)}))))},a.createElement(YK,{title:"Assets",items:A,total:k,displayType:R,onClickType:t}),a.createElement(YK,{title:"Liabilities",items:I,total:S,displayType:R,onClickType:t}),a.createElement("div",{className:"flex"},a.createElement(ZK,{isLoading:l,onClick:n},"Download CSV")))},ZK=(0,u.default)(OK).withConfig({displayName:"AccountsSummaryCard__StyledAsyncTextButton",componentId:"sc-14hvw7h-0"})(["padding:",";margin:0 auto;"],(e=>e.theme.spacing.default)),JK=(0,u.default)(MA.c).withConfig({displayName:"AccountsSummaryCard__StyledTabGroup",componentId:"sc-14hvw7h-1"})(["margin:-5px 0;"]),XK=u.default.span.withConfig({displayName:"AccountsSummaryCard__TitleRow",componentId:"sc-14hvw7h-2"})(["display:inline-flex;align-items:center;gap:",";"],(e=>e.theme.spacing.xxsmall));var QK=n(97923),eq=n(88770),tq=n(7310);const nq=e=>{var t;return e.length<2?null!==(t=e[0])&&void 0!==t?t:"":2===e.length?e.join(" and "):"".concat(e.slice(0,-1).join(", "),", and ").concat(e.at(-1))};var aq=n(42513),lq=n(3945),rq=n(79664),oq=n(40218),iq=n(91790);const sq=["recommendation","media","title","description","className","descriptionClassName","onDismiss","onSwitchComplete","accountsByCredentialId"],cq="mr-xs",dq="gap-2xs",uq=e=>{let t=e.recommendations,n=e.onDismiss,l=e.onSwitchComplete,r=e.accountsByCredentialId;return 0===t.length?null:a.createElement(fe.xz6,{"data-external-id":"dp-switch-recommendation-card",elevation:"card",sitsOnColor:"background-page",className:"mb-default w-full"},1===t.length?a.createElement(gq,{recommendation:t[0],onDismiss:n,onSwitchComplete:l,accountsByCredentialId:r}):a.createElement(hq,{recommendations:t,onDismiss:n,onSwitchComplete:l,accountsByCredentialId:r}))},mq=()=>a.createElement(fe.Qey.IconTile,{"data-external-id":"recommendation-badge",color:"blue",icon:a.createElement(fe.ElM,null),
1className:"size-9"}),pq=e=>{let t=e.recommendation,n=e.media,l=e.title,r=e.description,i=e.className,s=e.descriptionClassName,c=e.onDismiss,d=e.onSwitchComplete,u=e.accountsByCredentialId,m=(0,En.A)(e,sq);const p=(0,rq.b)({credential:{id:t.credentialId,dataProvider:t.currentProvider,institution:t.institution},accounts:null===u||void 0===u?void 0:u.get(t.credentialId),refetch:d,recommendedProvider:t.targetProvider,entryPoint:"accounts_page_card",accountCount:t.accountCount}),g=(0,o.A)(p,2),h=g[0],v=g[1].open,f=(e=>(0,iq.$)((0,a.useCallback)((()=>(0,lq.N9)((0,U.A)((0,U.A)({},(0,lq.wY)(e)),{},{entry_point:"accounts_page_card"}))),[e])))(t);return a.createElement(a.Fragment,null,a.createElement(fe.Qey.Root,Object.assign({ref:f,className:i},m),a.createElement(fe.Qey.Media,{className:cq},n),a.createElement(fe.Qey.Content,{className:dq},a.createElement(fe.Qey.Title,{weight:"medium",className:"truncate"},l),a.createElement(fe.Qey.Description,{size:"sm",className:s},r)),a.createElement(fe.Qey.Actions,{className:"gap-sm"},a.createElement(fe.XZZ,{variant:"text",colorScheme:"secondary",size:"sm",onClick:()=>{(0,lq.oB)((0,lq.wY)(t)),c(t.credentialId)}},"Not now"),a.createElement(fe.XZZ,{variant:"default",size:"sm",onClick:v},"Switch provider"))),h)},gq=e=>{let t=e.recommendation,n=e.onDismiss,l=e.onSwitchComplete,r=e.accountsByCredentialId;const o=t.institution,i=t.currentProvider,s=t.targetProvider;return a.createElement(pq,{"data-external-id":"single-recommendation",recommendation:t,media:a.createElement(mq,null),title:"A better connection is available for ".concat(o.name),description:"".concat(o.name," currently syncs through ").concat((0,oq.M)(i),". ").concat((0,oq.M)(s)," has been more reliable for ").concat(o.name," accounts lately."),className:"px-lg py-default",descriptionClassName:"line-clamp-2",onDismiss:n,onSwitchComplete:l,accountsByCredentialId:r})},hq=e=>{let t=e.recommendations,n=e.onDismiss,l=e.onSwitchComplete,r=e.accountsByCredentialId;const i=(0,a.useState)(!1),s=(0,o.A)(i,2),c=s[0],d=s[1],u=t.length,m=u-3,p=c?t:t.slice(0,3),g=(0,a.useMemo)((()=>({institutionNames:nq(t.map((e=>e.institution.name))),currentProviders:nq([...new Set(t.map((e=>{let t=e.currentProvider;return(0,oq.M)(t)})))])})),[t]);return a.createElement(fe.X0s,{"data-external-id":"multi-recommendation-content",defaultOpen:!1},a.createElement(fe.X0s.Trigger,{className:"group/recommendations w-full"},a.createElement(fe.Qey.Root,{className:"w-full px-lg py-default"},a.createElement(fe.Qey.Media,{className:cq},a.createElement(mq,null)),a.createElement(fe.Qey.Content,{className:dq},a.createElement(fe.Qey.Title,{weight:"medium"},"Better connections are available for"," ",(0,De.td)("institution",u,{inclusive:!0})),a.createElement(fe.Qey.Description,{size:"sm",className:"line-clamp-2"},g.institutionNames," currently sync through ",g.currentProviders,". More reliable providers are available for each.")),a.createElement(fe.Qey.Actions,null,a.createElement(fe.D39,{size:"md",className:"text-content-secondary transition-transform group-data-panel-open/recommendations:rotate-180"})))),a.createElement(fe.X0s.Content,null,a.createElement("div",{className:"px-lg pb-lg"},a.createElement(fe.Qey.Group,{rounded:"none",className:"border-t border-divider-primary"},p.map((e=>{var t;return a.createElement(pq,{key:e.credentialId,recommendation:e,media:a.createElement(aq.i,{logo:null!==(t=e.institution.logo)&&void 0!==t?t:null,size:36,alt:""}),title:e.institution.name,description:"".concat((0,oq.M)(e.currentProvider)," \u2192 ").concat((0,oq.M)(e.targetProvider)," recommended \xb7 ").concat((0,De.td)("account",e.accountCount,{inclusive:!0})),className:"px-0 py-sm",descriptionClassName:"line-clamp-none",onDismiss:n,onSwitchComplete:l,accountsByCredentialId:r})}))),!c&&m>0&&a.createElement(fe.XZZ,{variant:"text",colorScheme:"link",size:"sm",className:"mt-sm",onClick:()=>d(!0)},"Show ",m," more"))))};var vq=n(74274);const fq=[],Eq=[],yq=new Map,bq=e=>{var t;let n=e.skip;const a=(0,et.I)(vq.bN,{skip:n}),l=a.data,r=a.error,o=a.isLoadingInitialData,i=a.refetch;return{recommendations:null!==(t=null===l||void 0===l?void 0:l.dataProviderSwitchRecommendations)&&void 0!==t?t:fq,error:r,isLoadingInitialData:o,refetch:i}};var xq=n(86185);const wq=e=>{let t=e.onSwitchComplete;const n=(0,nG.p)("feat-dp-switch-recommendations-web","off"),l=bq({skip:!n}),r=l.recommendations,i=l.error,s=l.isLoadingInitialData,c=l.refetch,d=(0,xq.bO)("dismissedSwitchRecommendationCredentialIds"),u=(0,o.A)(d,3),m=u[0],p=u[1],g=u[2],h=(0,a.useMemo)((()=>(null!==m&&void 0!==m?m:[]).filter(Tp.n)),[m]),v=(0,a.useMemo)((()=>(e=>[...e].sort(((e,t)=>
1t.accountCount-e.accountCount||e.institution.name.localeCompare(t.institution.name))))(((e,t)=>{const n=new Set(t);return e.filter((e=>{let t=e.credentialId;return!n.has(t)}))})((e=>e.filter((e=>{let t=e.institution,n=e.currentProvider,a=e.targetProvider;return(0,tq.lQ)(t,n,a)})))(r),h))),[r,h]),f=(e=>{let t=e.skip;const n=(0,et.I)(vq.cK,{skip:t}),l=n.data,r=n.isLoadingInitialData,o=(0,a.useMemo)((()=>null!==l&&void 0!==l&&l.credentials?new Map(l.credentials.map((e=>{var t;let n=e.id,a=e.accounts;return[n,null!==(t=null===a||void 0===a?void 0:a.map((e=>{let t=e.id,n=e.displayName,a=e.mask,l=e.subtype;return{id:t,displayName:n,subtypeDisplay:null===l||void 0===l?void 0:l.display,mask:a}})))&&void 0!==t?t:Eq]}))):yq),[null===l||void 0===l?void 0:l.credentials]);return{accountsByCredentialId:o,isLoadingInitialData:r}})({skip:!n}),E=f.accountsByCredentialId,y=f.isLoadingInitialData,b=(0,a.useCallback)((e=>{p(((e,t)=>(0,eq.A)([...e,t]))(h,e))}),[h,p]),x=(0,a.useCallback)((()=>{c(),null===t||void 0===t||t()}),[c,t]);return!n||s||y||g||i||0===v.length?null:a.createElement(uq,{"data-external-id":"dp-switch-recommendation-card-connected",recommendations:v,onDismiss:b,onSwitchComplete:x,accountsByCredentialId:E})};var Cq=n(74461);const Aq=e=>{let t=e.title,n=e.description,l=e.onCancel,r=e.onSave,o=e.isSaving,i=void 0!==o&&o,s=e.saveLabel,c=void 0===s?"Save":s,d=e.scrollable,u=void 0!==d&&d,m=e.children;return a.createElement(Rc.L,{"data-external-id":"bulk-account-edit-modal",title:t,description:u?void 0:n,fullHeight:u},u?a.createElement(_m.O,null,a.createElement("div",{className:"flex flex-col gap-xl p-xl"},a.createElement(xt.v,null,n),m)):a.createElement(qY.S,null,m),a.createElement(Cq.R,null,a.createElement(wt.Xb,{onClick:l},"Cancel"),a.createElement(cu.WT,{onClick:r,disabled:i},c)))};var Iq=n(81922),kq=n(79516),Sq=n(518);const Nq=e=>{let t=e.onSuccess,n=e.preserveEdits,l=void 0!==n&&n,r=e.scrollable,o=void 0!==r&&r;const i=(0,kq.M)(),s=i.accountTypeSummaries,c=i.businessEntities,d=i.initialValues,u=i.isLoadingInitialData,m=i.isLoadingAccountUpdates,p=i.updateAccountBusinessEntities;return a.createElement(Eu.Op,{"data-external-id":"account-business-entity-edit-modal",initialValues:d,onSubmit:()=>{},enableReinitialize:!l},a.createElement(Tq,{accountTypeSummaries:s,businessEntities:c,isLoadingInitialData:u,isLoadingAccountUpdates:m,updateAccountBusinessEntities:p,onSuccess:t,initialValues:l?d:void 0,scrollable:o}))},Tq=e=>{let t=e.accountTypeSummaries,n=e.businessEntities,l=e.isLoadingInitialData,r=e.isLoadingAccountUpdates,i=e.updateAccountBusinessEntities,s=e.onSuccess,c=e.initialValues,d=e.scrollable;const u=(0,Sq.k)().close,m=(0,C.RU)(),p=(0,hu.x)(),g=p.values,h=p.setValues;(0,a.useEffect)((()=>{c&&h((e=>{const t=Object.entries(c).filter((t=>!((0,o.A)(t,1)[0]in e)));return 0===t.length?e:(0,U.A)((0,U.A)({},e),Object.fromEntries(t))}))}),[c,h]);return a.createElement(Aq,{"data-external-id":"account-business-entity-edit-modal-content",title:"Bulk edit businesses for accounts",description:"Assign your accounts to the businesses they belong to. This lets you filter views by your business lines or everything together. Note: transactions inherit the account's business but can be edited individually.",onCancel:u,onSave:async()=>{try{await i(g),null===s||void 0===s||s(),u()}catch(e){m({description:"Failed to update businesses. Please try again."})}},isSaving:r||l,scrollable:d},a.createElement(Iq.A,{accountTypeSummaries:t,businessEntities:n,isLoadingInitialData:l}))};var _q=n(11755),Dq=n(25715);const Rq=e=>{var t;let n=e.onComplete,r=e.onClose;const o=(0,l.Zp)(),i=null!==(t=(0,d.d4)(A.fg))&&void 0!==t?t:{},s=i.token,c=i.reconnectCredentialId,u=window.location.href,m=(0,d.d4)(A.pd),p=()=>{n(),m&&m.parserName===Dq.cA.MultiAccountStatement&&o(I.JZ.accounts.importTransactions())};return(0,a.useEffect)((()=>{s||r()}),[]),s?c?a.createElement(_q.T,{"data-external-id":"plaid-link-oauth",token:s,receivedRedirectUri:u,credentialId:c,onClose:r,onSuccess:n}):a.createElement(SF.R,{"data-external-id":"plaid-link-oauth",cachedPlaidLinkToken:s,plaidReceivedRedirectUri:u,next:p,goBack:close}):null};var Mq=n(14533);const Lq=()=>a.createElement(m.g,{"data-external-id":"error-card",column:!0,full:!0,center:!0},a.createElement(Mq.M,{buttonText:"Refresh the page",onButtonClick:()=>location.reload()})),Oq=["onError"],Pq=e=>{let t=e.onError,n=(0,En.A)(e,Oq);const r=(0,E.wA)(),o=(0,l.zy)();return a.createElement(yn.t,Object.assign({"data-external-id":"logged-error-boundary"},n,{onError:e=>{r((0,g.Ex)({error:e,fromRoute:o.pathname})),t(e)}}))},Bq=e=>t=>a.createElement(Pq,{errorComponent:a.createElement(Lq,null),onError:Pi.S5},a.createElement(e,t)),zq=(0,a.createContext)(void 0),Fq=e=>{let t=e.error,n=e.retryFn,l=e.message,r=e.description,i=e.buttonText;const s=(0,a.useCallback)((async()=>{try{await(null===n||void 0===n?void 0:n())}catch(e){}}),[n]),c=(0,hm.M)(s),d=(0,o.A)(c,2),u=d[0],m=d[1];return{isRetrying:u,pageError:(0,a.useMemo)((()=>t?{message:l,description:r,buttonText:i,onRetry:m}:void 0),[t,l,r,i,m])}},Gq=["children","controls","onAccountAdded","emptyIcon","emptyTitle","emptyButtonText","overlayEmptyComponent","pageError","isLoading","childErrorRoutePrefix"],Yq=Bq((e=>{var t;
1let n=e.children,r=e.controls,i=e.onAccountAdded,s=e.emptyIcon,c=e.emptyTitle,u=e.emptyButtonText,m=void 0===u?_t.cW:u,p=e.overlayEmptyComponent,h=e.pageError,v=e.isLoading,f=void 0!==v&&v,E=e.childErrorRoutePrefix,y=(0,En.A)(e,Gq);const b=(0,l.zy)(),x=mG(),w=x.hasAccounts,C=x.refetch,A=x.error,I=(0,a.useState)([]),k=(0,o.A)(I,2),S=k[0],N=k[1],T=(0,a.useState)(),_=(0,o.A)(T,2),D=_[0],R=_[1],M=(0,a.useRef)(null===D||void 0===D?void 0:D.retryFn);M.current=null===D||void 0===D?void 0:D.retryFn;const L=(0,a.useCallback)((e=>{N([...S,e])}),[S,N]),O=(0,a.useCallback)((e=>{R(e)}),[]),P=(0,a.useMemo)((()=>({addAccountAddedListener:L,reportChildQueryError:O})),[L,O]),B=(0,pG.w)();a.useEffect((()=>{B((0,g.B8)(w))}),[B,w]);const z=!E||b.pathname.includes(E);(0,a.useEffect)((()=>{z||R(void 0)}),[z]);const F=(0,a.useCallback)((async()=>{try{var e;const t=await(null===(e=M.current)||void 0===e?void 0:e.call(M));null!==t&&void 0!==t&&t.error||R(void 0)}catch(t){}}),[]),G=Fq({error:z?null===D||void 0===D?void 0:D.error:void 0,retryFn:F,message:null===D||void 0===D?void 0:D.message,description:null===D||void 0===D?void 0:D.description,buttonText:null===D||void 0===D?void 0:D.buttonText}),Y=G.isRetrying,U=G.pageError,V=Fq({error:A,retryFn:C}),W=V.isRetrying,j=V.pageError,H=(0,d.d4)(gG.pk);return a.createElement(zq.Provider,{"data-external-id":"page-with-no-accounts-empty-state",value:P},a.createElement(rG.Y,Object.assign({},y,{pageError:null!==(t=null!==h&&void 0!==h?h:U)&&void 0!==t?t:j,isLoading:f||z&&Y||W,overlayEmptyComponent:H?a.createElement(lG,{emptyTitle:c,emptyIcon:s,emptyButtonText:m,onAccountAdded:()=>{C(),null===i||void 0===i||i(),S.forEach((e=>e()))}}):p,controls:H?null:r}),n))}));var Uq=n(39484),Vq=n(48472);const Wq=e=>{let t=e.onSuccess;const n=(0,Sq.k)().close,l=(0,Vq.y)(),r=l.accountTypeSummaries,i=l.initialValues,s=l.isLoadingInitialData,c=l.isLoadingAccountUpdates,d=l.updateAccountOwnership,u=(0,a.useState)(i),m=(0,o.A)(u,2),p=m[0],g=m[1];return a.createElement(Aq,{"data-external-id":"account-ownership-edit-modal",title:"Bulk edit account ownership",description:"Adjust ownership as you see fit. This lets you filter views by your accounts, shared ones, or everything together. Note: transactions inherit the account owner but can be edited individually.",onCancel:n,onSave:async()=>{await d(p),null===t||void 0===t||t(),n()},isSaving:c||s},a.createElement(Uq.u,{accountTypeSummaries:r,initialValues:i,isLoadingInitialData:s,onChange:g}))},jq=_t.n3.BANNER,Hq=e=>{let t=e.onDismiss,n=e.onGetStarted,l=e.shown;return a.createElement(T.N,{"data-external-id":"shared-views-banner",initial:!1},l?a.createElement(Kq,{key:"shared-views-banner",initial:{height:"auto"},exit:{height:0},transition:{duration:.5,ease:"easeInOut"}},a.createElement(qq,{hideHeader:!0},a.createElement(ZY.B,{row:!0,alignCenter:!0,justifyBetween:!0},a.createElement($q,{column:!0},a.createElement(Zq,null,a.createElement(sl.ZQ,{name:"shared"})," ",jq.TITLE),a.createElement(Jq,null,jq.SUBTITLE)),a.createElement(Xq,{row:!0},a.createElement(wt.Xb,{onClick:t},"Dismiss"),a.createElement(cu.WT,{onClick:n},jq.GET_STARTED_BUTTON))))):null)},Kq=(0,u.default)(D.PY1.div).withConfig({displayName:"SharedViewsBanner__StyledMotionDiv",componentId:"sc-1fggc6-0"})(["display:flex;flex-direction:column;overflow:hidden;"]),qq=(0,u.default)(Xl.AM).withConfig({displayName:"SharedViewsBanner__BannerCard",componentId:"sc-1fggc6-1"})(["padding:"," ",";margin-bottom:",";"],vt.YK.default,vt.YK.large,vt.YK.default),$q=(0,u.default)(ZY.B).withConfig({displayName:"SharedViewsBanner__ContentContainer",componentId:"sc-1fggc6-2"})(["flex:1;"]),Zq=u.default.div.withConfig({displayName:"SharedViewsBanner__Title",componentId:"sc-1fggc6-3"})(["font-size:",";font-weight:",";color:",";"],vt.J.small,vt.Wy.medium,vt.Ee.color.content.info),Jq=u.default.div.withConfig({displayName:"SharedViewsBanner__Subtitle",componentId:"sc-1fggc6-4"})(["font-size:",";font-weight:",";"],vt.J.large,vt.Wy.medium),Xq=(0,u.default)(ZY.B).withConfig({displayName:"SharedViewsBanner__ButtonContainer",componentId:"sc-1fggc6-5"})(["gap:",";"],vt.YK.small);var Qq=n(72844),e$=n(11418),t$=n(87366),n$=n(22584);const a$=e=>{let t=e.onComplete;const n=(0,lV.L)(),r=n.dataProvider,o=n.institutionId,i=(0,l.Zp)(),s=(0,e$.L)(),c=(0,nG.p)("switch-domain-migration-coinbase-redirect-web","on");(0,a.useEffect)((()=>
1{if(c&&"coinbase"===r.toLowerCase()&&"app.monarchmoney.com"===window.location.hostname){const e="https://app.monarch.com".concat(window.location.pathname).concat(window.location.search);window.location.replace(e)}}),[c,r]);const d=(0,Qq.L)(n$.ln,r.toUpperCase(),t$.xU);return a.createElement(um.b,{"data-external-id":"direct-link-account-for-data-provider",onClose:s},a.createElement(SF.R,{institution:{preferredDataProvider:d,finicityInstitutionId:d===n$.ln.FINICITY&&null!==o&&void 0!==o?o:null,plaidInstitutionId:d===n$.ln.PLAID&&null!==o&&void 0!==o?o:null,mxInstitutionId:d===n$.ln.MX&&null!==o&&void 0!==o?o:null},next:()=>{t(),i(I.JZ.accounts())},goBack:()=>i(I.JZ.accounts()),key:d}))};var l$=n(95186),r$=n(47705),o$=n(15408),i$=n(10106);const s$=e=>{let t=e.institution,n=e.hideBackButton;const l=t.newConnectionsDisabled,r=t.name,o=(0,r$.j)(),i=o.pop,s=o.push,c=o.onComplete,d=(0,(0,o$.j)().getNoticeForInstitution)(t.id,t.preferredDataProvider),u=null===d||void 0===d?void 0:d.publicMessage,m=(0,i$.O)(t),p=_t.Dx.SELECT_DATA_PROVIDER.ISSUES_REPORTED_DEFAULT_TITLE(r);return a.createElement(Rc.L,{"data-external-id":"link-account-select-data-provider-modal",onClickBackButton:n?void 0:i,hideBottomBorder:!0,title:u?p:_t.Dx.SELECT_DATA_PROVIDER.TITLE,description:a.createElement(Ll.o,{source:u||_t.Dx.SELECT_DATA_PROVIDER.DESCRIPTION})},a.createElement(c$,null,l?a.createElement(a.Fragment,null,a.createElement(u$,null,"Other Options")):a.createElement(a.Fragment,null,a.createElement(Oc.D,{color:"blue"},"Best Choice"),m.map(((e,n)=>a.createElement(a.Fragment,{key:e.dataProvider},a.createElement(d$,{key:e.dataProvider,onClick:()=>s(l$.a,{institution:t,dataProvider:e.dataProvider})},"Connect with ",(0,oq.M)(e.dataProvider)),0===n&&a.createElement(u$,null,"Other Options"))))),a.createElement(d$,{onClick:()=>s(QK.b,{onBack:i,onComplete:c})},"Add manual account")))},c$=u.default.div.withConfig({displayName:"LinkAccountSelectDataProviderModal__Container",componentId:"sc-93lu7l-0"})(["padding:0 ",";padding-bottom:",";"],(e=>e.theme.spacing.large),(e=>e.theme.spacing.xxlarge)),d$=(0,u.default)(wt.Xb).withConfig({displayName:"LinkAccountSelectDataProviderModal__Button",componentId:"sc-93lu7l-1"})(["margin-top:",";width:100%;"],(e=>e.theme.spacing.default)),u$=u.default.div.withConfig({displayName:"LinkAccountSelectDataProviderModal__Header",componentId:"sc-93lu7l-2"})(["font-size:11px;font-weight:",";letter-spacing:0.1em;text-transform:uppercase;margin-top:",";color:",";"],(e=>e.theme.fontWeight.bold),(e=>e.theme.spacing.default),(e=>e.theme.color.textLight));var m$,p$=n(8458);const g$=e=>{let t=e.onComplete;const n=(0,l.Zp)(),r=(0,lV.L)().institutionId,o=(0,et.I)(v$,{variables:{institutionId:r}}),i=o.data,s=o.isLoadingInitialData,c=(null!==i&&void 0!==i?i:{}).institution;return a.createElement(um.b,{"data-external-id":"direct-link-account-select-data-provider",onClose:()=>n(I.JZ.accounts())},(e=>{let n=e.close;return c?a.createElement(p$.B,{initial:{component:s$,props:{institution:c,hideBackButton:!0}},onPopTop:n,onComplete:t}):a.createElement(Rc.L,{hideBottomBorder:!0},a.createElement(h$,null,s?a.createElement(p.i,null):a.createElement(fu.g,{type:"error"},_t.Rb)))}))},h$=(0,u.default)(m.g).attrs({center:!0}).withConfig({displayName:"DirectLinkAccountSelectDataProvider__Container",componentId:"fqqcsk-0"})(["padding:",";padding-top:0;"],(e=>e.theme.spacing.xlarge)),v$=(0,vK.J1)(m$||(m$=(0,wc.A)(["\n  query Web_DirectLinkAccountSelectDataProvider($institutionId: String!) {\n    institution(id: $institutionId) {\n      id\n      ...LinkInstitutionFields\n    }\n  }\n"]))),f$=new Set([Ee.$0r.COMPLETED,Ee.$0r.ERRORED,Ee.$0r.SKIPPED]),E$=e=>f$.has(e),y$=e=>{const t=N.c9.fromISO(e);return Math.abs(t.diffNow().milliseconds)<iC.EM?"Just now":"".concat((0,Ba.fw)(t)," ago")},b$=e=>(0,r.YW)(e.state).with(Ee.$0r.WAITING,(()=>"Waiting...")).with(Ee.$0r.REQUESTING_DATA,(()=>"Checking for updates...")).with(Ee.$0r.CONNECTING,(()=>"Connecting...")).with(Ee.$0r.DOWNLOADING,(()=>"Downloading updates...")).with(Ee.$0r.COMPLETED,(()=>e.completedAt?y$(e.completedAt):"Just now")).with(Ee.$0r.SKIPPED,(()=>e.completedAt?y$(e.completedAt):"Up to date")).with(Ee.$0r.ERRORED,(()=>{var t;return null!==(t=e.errorMessage)&&void 0!==t?t:"Error syncing"})).exhaustive(),x$=2.5,w$=11.75,C$=2*Math.PI*w$,A$=(0,u.keyframes)(["from{stroke-dashoffset:0;}to{stroke-dashoffset:-",";}"],45),I$=e=>{let t=e.state,n=e.percent;const l=(0,u.useTheme)(),o=(0,a.useId)().replace(/:/g,"_"),i="mask".concat(o),s="glow".concat(o),c=vt.Ee.color.content.success({theme:l}),d=null!==n&&void 0!==n?n:(e=>(0,r.YW)(e).with(Ee.$0r.REQUESTING_DATA,(()=>.25)).with(Ee.$0r.CONNECTING,(()=>.5)).with(Ee.$0r.DOWNLOADING,(()=>.75)).otherwise((()=>0)))(t),m=C$*d,p=C$-m;return a.createElement("svg",{"data-external-id":"rotating-arc-ring",width:26,height:26,style:{flexShrink:0}},a.createElement("defs",null,a.createElement("filter",{id:s},a.createElement("feGaussianBlur",{stdDeviation:"2",result:"blur"}),a.createElement("feMerge",null,a.createElement("feMergeNode",{in:"blur"}),a.createElement("feMergeNode",{in:"SourceGraphic"}))),a.createElement("mask",{id:i},a.createElement("circle",{cx:13,cy:13,r:w$,fill:"none",stroke:"white",strokeWidth:4.5,strokeDasharray:"".concat(p," ").concat(m),strokeDashoffset:-m,transform:"rotate(-90 ".concat(13," ").concat(13,")"),style:{transition:"stroke-dasharray 0.8s ease-in-out, stroke-dashoffset 0.8s ease-in-out"}}))),a.createElement("g",{mask:"url(#".concat(i,")")},a.createElement(k$,{cx:13,cy:13,r:w$,fill:"none",stroke:"rgba(255,255,255,0.4)",strokeWidth:x$,strokeDasharray:"".concat(2," ").concat(2.5),strokeLinecap:"round"})),a.createElement("circle",{cx:13,cy:13,r:w$,fill:"none",stroke:c,strokeWidth:x$,strokeDasharray:"".concat(m," ").concat(p),strokeLinecap:d>0?"round":"butt",transform:"rotate(-90 ".concat(13," ").concat(13,")"),style:{transition:"stroke-dasharray 0.8s ease-in-out"}
1,filter:"url(#".concat(s,")")}))},k$=u.default.circle.withConfig({displayName:"RotatingArcRing__MarchingDashes",componentId:"sc-1yoh3qn-0"})(["animation:"," 6s linear infinite;"],A$),S$=10*iC.K5,N$=[{percent:.25,text:"Checking for updates..."},{percent:.35,text:"Connecting to your bank..."},{percent:.45,text:"Requesting account data..."},{percent:.55,text:"Retrieving transactions..."},{percent:.65,text:"Syncing balances..."},{percent:.75,text:"Reviewing account details..."},{percent:.85,text:"Verifying data..."},{percent:.9,text:"Finalizing sync..."},{percent:.95,text:"Almost done..."}],T$=e=>{let t=e.account;const n=(e=>{let t=e.state,n=e.startedAt;const l="PLAID"===e.dataProvider&&(t===Ee.$0r.REQUESTING_DATA||t===Ee.$0r.CONNECTING),r=(0,a.useState)(0),i=(0,o.A)(r,2),s=i[0],c=i[1];if((0,a.useEffect)((()=>{if(!l)return void c(0);const e=n?new Date(n).getTime():Date.now(),t=()=>Math.max(0,Math.min(Math.floor((Date.now()-e)/S$),N$.length-1));c(t());const a=setInterval((()=>c(t())),S$);return()=>clearInterval(a)}),[l,n]),!l)return{percent:void 0,statusText:void 0};const d=N$[s];return{percent:d.percent,statusText:d.text}})({state:t.state,startedAt:t.startedAt,dataProvider:t.dataProvider}),l=n.percent,r=n.statusText,i=t.state===Ee.$0r.ERRORED;return a.createElement(R$,{"data-external-id":"refresh-account-card",$errored:i},a.createElement(_$,{src:t.institutionLogoUrl}),a.createElement(O$,null,a.createElement(P$,null,t.accountName),a.createElement(B$,{$error:i},i&&t.errorDetail?"".concat(b$(t),": ").concat(t.errorDetail):null!==r&&void 0!==r?r:b$(t))),E$(t.state)&&a.createElement(D$,{state:t.state,newTransactionCount:t.newTransactionCount,timedOut:t.timedOut}),!E$(t.state)&&a.createElement(I$,{state:t.state,percent:l}))},_$=e=>{let t=e.src;return a.createElement(M$,{"data-external-id":"institution-logo"},t?a.createElement(L$,{src:t,alt:""}):a.createElement(sl.ZQ,{name:"building",size:14}))},D$=e=>{let t=e.state,n=e.newTransactionCount,l=e.timedOut;return(0,r.YW)(t).with(Ee.$0r.COMPLETED,(()=>(0,r.YW)({newTransactionCount:n,timedOut:l}).when((e=>e.newTransactionCount>0),(()=>a.createElement(F$,{$variant:"success"},n," new"))).otherwise((()=>a.createElement(F$,{$variant:"neutral"},"Up to date"))))).with(Ee.$0r.SKIPPED,(()=>a.createElement(F$,{$variant:"neutral"},"Up to date"))).with(Ee.$0r.ERRORED,(()=>a.createElement(z$,null,a.createElement(sl.ZQ,{name:"alert-triangle",size:16})))).otherwise((()=>null))},R$=(0,u.default)(m.g).attrs({alignCenter:!0}).withConfig({displayName:"RefreshAccountCard__Card",componentId:"sc-1kjhrc0-0"})(["gap:",";padding:"," ",";border-radius:",";border:1px solid ",";overflow:hidden;"],vt.YK.xsmall,vt.YK.xsmall,vt.YK.small,vt.r8.default,(e=>e.$errored?vt.Ee.color.content.danger:vt.Ee.color.divider.secondary)),M$=u.default.div.withConfig({displayName:"RefreshAccountCard__LogoCircle",componentId:"sc-1kjhrc0-1"})(["width:24px;height:24px;border-radius:50%;overflow:hidden;flex-shrink:0;display:flex;align-items:center;justify-content:center;"]),L$=u.default.img.withConfig({displayName:"RefreshAccountCard__LogoImg",componentId:"sc-1kjhrc0-2"})(["width:100%;height:100%;object-fit:cover;"]),O$=u.default.div.withConfig({displayName:"RefreshAccountCard__AccountInfo",componentId:"sc-1kjhrc0-3"})(["flex:1;display:flex;flex-direction:column;min-width:0;"]),P$=u.default.span.withConfig({displayName:"RefreshAccountCard__AccountName",componentId:"sc-1kjhrc0-4"})(["font-size:",";font-weight:",";white-space:nowrap;overflow:hidden;text-overflow:ellipsis;"],vt.J.small,vt.Wy.medium),B$=u.default.span.withConfig({displayName:"RefreshAccountCard__AccountStatusText",componentId:"sc-1kjhrc0-5"})(["font-size:",";white-space:",";overflow:",";text-overflow:",";font-weight:",";line-height:normal;color:",";"],vt.J.xsmall,(e=>e.$error?"normal":"nowrap"),(e=>e.$error?"visible":"hidden"),(e=>e.$error?"unset":"ellipsis"),vt.Wy.book,(e=>e.$error?vt.Ee.color.content.danger:"inherit")),z$=u.default.div.withConfig({displayName:"RefreshAccountCard__ErrorIconContainer",componentId:"sc-1kjhrc0-6"})(["color:",";display:flex;align-items:center;flex-shrink:0;"],vt.Ee.color.content.danger),F$=u.default.span.withConfig({displayName:"RefreshAccountCard__Badge",componentId:"sc-1kjhrc0-7"})(["font-size:",";line-height:",";font-weight:",";padding:"," ",";border-radius:",";white-space:nowrap;flex-shrink:0;background:",";color:",";"],vt.J.xxsmall,vt.J.base,vt.Wy.medium,vt.YK.xxsmall,vt.YK.xsmall,vt.r8.small,(e=>{let t=e.$variant;return(0,r.YW)(t).with("success",(()=>vt.Ee.color.background.success)).with("neutral",(()=>vt.Ee.color.background.info)).with("error",(()=>vt.Ee.color.background.danger)).exhaustive()}),(e=>{let t=e.$variant;return(0,r.YW)(t).with("success",(()=>vt.Ee.color.content.success)).with("neutral",(()=>vt.Ee.color.content.info)).with("error",(()=>vt.Ee.color.content.danger)).exhaustive()}
1)),G$=4*iC.K5,Y$=5*iC.EM,U$=function(e){var t;const n=(arguments.length>1&&void 0!==arguments[1]?arguments[1]:{}).onAccountCompleted,l=(0,a.useRef)(!1),r=(0,a.useRef)(new Map),i=(0,PH.p)(iG.L1,{variables:{id:null!==e&&void 0!==e?e:""},pollUntil:e=>{var t;return l.current||(null===(t=null===e||void 0===e?void 0:e.forceRefreshOperation)||void 0===t?void 0:t.state)===Ee.p2z.COMPLETED},pollIntervalMs:G$,pollTimeoutMs:Y$,skip:!e,skipWhenNotPolling:!1}),s=(0,o.A)(i,2),c=s[0],d=s[1].data;(0,a.useEffect)((()=>{e&&(l.current=!1,r.current=new Map,c())}),[e,c]);const u=null!==(t=null===d||void 0===d?void 0:d.forceRefreshOperation)&&void 0!==t?t:null;(0,a.useEffect)((()=>{u&&n&&(u.accounts.forEach((e=>{var t;const a=r.current.get(e.accountId);e.state===Ee.$0r.COMPLETED&&a!==Ee.$0r.COMPLETED&&n({accountId:e.accountId,completedAt:null!==(t=e.completedAt)&&void 0!==t?t:(new Date).toISOString()})})),r.current=new Map(u.accounts.map((e=>[e.accountId,e.state]))))}),[u,n]);const m=(0,a.useMemo)((()=>u?{id:u.id,state:u.state,completedAccountCount:u.completedAccountCount,totalAccountCount:u.totalAccountCount,accounts:u.accounts.map((e=>{var t,n,a,l;return{accountId:e.accountId,state:e.state,newTransactionCount:e.newTransactionCount,updatedTransactionCount:e.updatedTransactionCount,completedAt:null!==(t=e.completedAt)&&void 0!==t?t:null,startedAt:null!==(n=e.startedAt)&&void 0!==n?n:null,timedOut:e.timedOut,errorMessage:null!==(a=e.errorMessage)&&void 0!==a?a:null,errorDetail:null!==(l=e.errorDetail)&&void 0!==l?l:null}}))}:null),[u]);return{operation:m,stopPolling:(0,a.useCallback)((()=>{l.current=!0}),[])}};var V$,W$;const j$=e=>{var t,n;let l=e.operationId,r=e.orderedAccounts,i=e.onDismiss,s=e.onComplete;const c=(0,V.m)(),d=(0,a.useCallback)((e=>{let t=e.accountId,n=e.completedAt;c.cache.modify({id:c.cache.identify({__typename:"Account",id:t}),fields:{displayLastUpdatedAt:()=>n}})}),[c]),u=U$(l,{onAccountCompleted:d}),m=u.operation,p=u.stopPolling,g=(0,a.useState)(!1),h=(0,o.A)(g,2),v=h[0],f=h[1],E=(null===m||void 0===m?void 0:m.state)===Ee.p2z.COMPLETED;(0,a.useEffect)((()=>{E&&(p(),c.reFetchObservableQueries(),null===s||void 0===s||s())}),[E,p,c,s]);const y=(0,a.useMemo)((()=>((e,t)=>{const n=new Map((null!==t&&void 0!==t?t:[]).map((e=>[e.accountId,e])));return e.filter((e=>n.has(e.id))).map((e=>{const t=n.get(e.id);return(0,U.A)((0,U.A)({},t),{},{accountName:e.displayName,institutionLogoUrl:e.institutionLogoUrl,dataProvider:e.dataProvider})}))})(r,null===m||void 0===m?void 0:m.accounts)),[r,null===m||void 0===m?void 0:m.accounts]),b=null!==(t=null===m||void 0===m?void 0:m.totalAccountCount)&&void 0!==t?t:y.length,x=null!==(n=null===m||void 0===m?void 0:m.completedAccountCount)&&void 0!==n?n:0,w=b>0?x/b*100:0,C=E?(e=>{const t=e.reduce(((e,t)=>e+t.newTransactionCount),0),n=e.reduce(((e,t)=>e+t.updatedTransactionCount),0),a=[];return t>0&&a.push((0,De.td)("transaction",t,{inclusive:!0,modifier:"new"})),n>0&&a.push((0,De.td)("transaction",n,{inclusive:!0,modifier:"updated"})),0===a.length?"All accounts are up to date":"Monarch found ".concat(a.join(" and "))})(y):null,A=v&&y.length>0;return R.createPortal(a.createElement(rb.J,null,a.createElement(H$,null,a.createElement(K$,null,a.createElement(fe.X0s,{open:A,onOpenChange:e=>
1{(0,Ge.u4)(e?Ye.z.SyncTransparencyToastShowDetails:Ye.z.SyncTransparencyToastHideDetails,{source:"web"}),f(e)}},a.createElement(tZ,null,a.createElement(aZ,null,a.createElement(lZ,null,E?"Sync complete":"Syncing ".concat(x," of ").concat(b||"...","...")),a.createElement(fe.cqk,{value:w,color:"progress-success",size:"sm",className:"flex-1"}))),a.createElement(fe.X0s.Content,null,a.createElement(eZ,null),a.createElement(nZ,null,a.createElement(rZ,null,y.map((e=>a.createElement(T$,{key:e.accountId,account:e})))))),a.createElement(q$,null,a.createElement(Z$,{$success:E},E?a.createElement(sl.ZQ,{name:"check-circle-filled"}):a.createElement(vG.W,null,a.createElement(sl.ZQ,{name:"refresh"}))),a.createElement("div",{className:"flex min-w-0 flex-1 content-stretch items-center"},a.createElement($$,null,a.createElement(Q$,null,E?"Your accounts are up to date":"Syncing your accounts..."),a.createElement("span",null,E?C:"This may take a few minutes."))),a.createElement(J$,null,a.createElement(fe.X0s.Trigger,{render:a.createElement(X$,null)},A?"Hide Details":"Show Details"),a.createElement(X$,{onClick:()=>{(0,Ge.u4)(Ye.z.SyncTransparencyToastDismissed,{source:"web"}),p(),i()}},"Dismiss"))))))),document.body)},H$=$d.s.div(V$||(V$=(0,wc.A)(["fixed right-0 bottom-default z-toast"]))),K$=u.default.div.withConfig({displayName:"RefreshProgressToast__Root",componentId:"sc-1bzflsd-0"})(["margin:0 auto;width:","px;overflow:hidden;transition:opacity 0.4s ease-in-out;background:",";backdrop-filter:blur(6px);border:1px solid ",";border-radius:",";color:",";@media (min-width:","px){margin:0 "," 0 0;}"],380,vt.Ee.color.background.frosted,vt.Ee.color.divider.secondary,vt.r8.medium,vt.Ee.color.content.white,(e=>e.theme.breakPoints.xxs-1),vt.YK.default),q$=u.default.div.withConfig({displayName:"RefreshProgressToast__ToastContent",componentId:"sc-1bzflsd-1"})(["display:flex;align-items:stretch;border-top:1px solid ",";color:",";font-size:",";line-height:150%;"],vt.Ee.color.divider.secondary,vt.Ee.color.content.white,vt.J.xsmall),$$=$d.s.div(W$||(W$=(0,wc.A)(["p-0"]))),Z$=(0,u.default)(m.g).attrs({alignCenter:!0}).withConfig({displayName:"RefreshProgressToast__Accessory",componentId:"sc-1bzflsd-2"})(["padding-left:",";margin-right:",";max-width:32px;color:",";"],vt.YK.xlarge,vt.YK.xlarge,(e=>{let t=e.$success,n=e.theme;return t?n.variables.color.content.success:"inherit"})),J$=u.default.div.withConfig({displayName:"RefreshProgressToast__ButtonsContainer",componentId:"sc-1bzflsd-3"})(["display:flex;flex-direction:column;flex-shrink:0;min-width:","px;"],118),X$=u.default.button.withConfig({displayName:"RefreshProgressToast__Button",componentId:"sc-1bzflsd-4"})(["flex:1;width:100%;min-height:44px;color:",";font-size:",";font-weight:",";letter-spacing:0.08em;text-transform:uppercase;background:transparent;border:unset;cursor:pointer;&:hover{background-color:",";}&:active{background-color:",";}border-left:1px solid ",";&:not(:last-child){border-bottom:1px solid ",";}"],vt.Ee.color.content.white,vt.J.xsmall,vt.Wy.medium,(e=>{let t=e.theme;return(0,xb.No)(.97,t.color.white)}),(e=>{let t=e.theme;return"dark"===t.uiTheme?(0,xb.No)(.3,t.color.trueBlack):(0,xb.e$)(.02,t.color.black)}),vt.Ee.color.divider.secondary,vt.Ee.color.divider.secondary),Q$=u.default.span.withConfig({displayName:"RefreshProgressToast__Title",componentId:"sc-1bzflsd-5"})(["display:block;font-size:",";font-weight:",";margin-bottom:",";"],vt.J.small,vt.Wy.medium,vt.YK.xxsmall),eZ=u.default.div.withConfig({displayName:"RefreshProgressToast__Divider",componentId:"sc-1bzflsd-6"})(["height:1px;background:",";"],vt.Ee.color.divider.secondary),tZ=u.default.div.withConfig({displayName:"RefreshProgressToast__ProgressSection",componentId:"sc-1bzflsd-7"})(["padding:",";"],vt.YK.small),nZ=(0,u.default)(tZ).withConfig({displayName:"RefreshProgressToast__ScrollableSection",componentId:"sc-1bzflsd-8"})(["max-height:360px;overflow-y:auto;"]),aZ=(0,u.default)(m.g).attrs({alignCenter:!0,justifyBetween:!0}).withConfig({displayName:"RefreshProgressToast__ProgressHeader",componentId:"sc-1bzflsd-9"})(["gap:",";"],vt.YK.small),lZ=u.default.span.withConfig({displayName:"RefreshProgressToast__ProgressLabel",componentId:"sc-1bzflsd-10"})(["white-space:nowrap;font-size:",";color:",";font-weight:",";"],vt.J.xsmall,vt.Ee.color.content.white,vt.Wy.medium),rZ=u.default.div.withConfig({displayName:"RefreshProgressToast__AccountList",componentId:"sc-1bzflsd-11"})(["display:flex;flex-direction:column;gap:",";"],vt.YK.xsmall);var oZ=n(55061),iZ=n(49663);const sZ=(0,Qt.J)("\n  query Common_GetSnapshotsByAccountType(\n    $startDate: Date!\n    $timeframe: Timeframe!\n    $filters: AccountFilters\n  ) {\n    snapshotsByAccountType(startDate: $
1startDate, timeframe: $timeframe, filters: $filters) {\n      accountType\n      month\n      balance\n    }\n\n    accountTypes {\n      name\n      group\n    }\n  }\n"),cZ=(0,Qt.J)("\n  query Common_GetDisplayBalanceAtDate($date: Date!, $filters: AccountFilters) {\n    accounts(filters: $filters) {\n      id\n      displayBalance(date: $date)\n      includeInNetWorth\n      type {\n        name\n      }\n    }\n  }\n"),dZ=(0,Qt.J)("\n  mutation Common_DeleteSyncedSnapshotsMutation($input: DeleteSyncedSnapshotsInput!) {\n    deleteSyncedSnapshots(input: $input) {\n      success\n      errors {\n        message\n        code\n      }\n    }\n  }\n");var uZ=n(28853),mZ=n.n(uZ),pZ=n(76951),gZ=n(71585);const hZ=["accountType"],vZ=(0,gZ.J)("\n  query Common_GetAggregateSnapshots($filters: AggregateSnapshotFilters) {\n    aggregateSnapshots(filters: $filters) {\n      date\n      balance\n      assetsBalance\n      liabilitiesBalance\n    }\n  }\n");var fZ,EZ=n(35434),yZ=n(322),bZ=n(77508),xZ=n(73657);const wZ=(0,xZ.Z)((()=>n.e(5379).then(n.bind(n,95379)).then((e=>({default:e.SharedViewsWalkthrough})))),"LazyLoadedSharedViewsWalkthrough"),CZ="768px",AZ=["businessEntitySet"],IZ=()=>{const e=(0,d.wA)(),t=(0,d.d4)(gG.pk),n=(0,d.d4)(ft.oy),r=(0,nV.J)().downloadBalances,i=(0,yZ.B)(),s=i.shouldShowWalkthrough,c=i.dismissWalkthrough,u=i.getRouteToRedirectTo,m=i.shouldShowBanners,h=i.onDismissBanners,v=(0,Pd.h)(),f=(0,o.A)(v,2),E=f[0],y=f[1].open,b=(0,Pd.h)(),x=(0,o.A)(b,2),w=x[0],C=x[1].open,A=(0,ZH.D)("accounts"),k=A.activeFilters,S=k.timeframe,T=k.dateRange,_=k.chartType,D=void 0===_?"performance":_,R=A.updateFilter,M=(0,l.zy)(),L=(0,a.useState)((()=>{var e,t;const n=null!==(e=null===(t=M.state)||void 0===t?void 0:t.businessEntityIds)&&void 0!==e?e:[];return n.length>0?{businessEntitySet:{businessEntityIds:n,includeUnassigned:!1}}:{}})),O=(0,o.A)(L,2),P=O[0],B=O[1],z=(0,a.useMemo)((()=>(0,EZ.T)(P.ownershipSet)),[P.ownershipSet]),F=(0,a.useCallback)((e=>B((0,TV.A)((0,_V.A)(AZ,P),e))),[P]),G=(0,a.useCallback)((e=>{B((t=>(0,U.A)((0,U.A)({},t),{},{businessEntitySet:e})))}),[]),Y=(0,a.useCallback)((()=>B({})),[]),V=D,W="breakdown"===V,j="performance"===V,H=(0,vW.k3)(S)?S:vW.xh,K=(0,DV.A)(H,(0,jd.A)((0,mo.A)("value"),EW)),q=(0,a.useMemo)((()=>{const e=(0,hW.sF)(V);return e.find((e=>e.display===T))||e[0]}),[T,V]),$=N.c9.local().minus(q.duration).toISODate(),Z=(0,a.useMemo)((()=>W?N.c9.local().startOf(H).minus({day:1}).toISODate():"ALL"===q.display?void 0:$),[H,q,$,W]),J=(0,bZ.D)(TZ,{variables:{filters:(0,iZ.V)(P)}}),X=J.data,Q=J.refetch,ee=J.isLoadingInitialData,te=J.error,ne=Fq({error:te,retryFn:Q}),ae=ne.isRetrying,le=ne.pageError,re=(0,et.I)(_Z,{skip:(0,BY.A)(X),variables:{startDate:Z}}).data,oe=null!==X&&void 0!==X?X:{},ie=oe.householdPreferences,se=oe.accountTypeSummaries,ce=void 0===se?[]:se,de=oe.hasAccounts,ue=!(null===ie||void 0===ie||!ie.collaborationToolsEnabled),me=(0,a.useState)(null),pe=(0,o.A)(me,2),ge=pe[0],he=pe[1],ve=(0,a.useState)(!1),fe=(0,o.A)(ve,2),ye=fe[0],be=fe[1],xe=(0,a.useState)(!1),we=(0,o.A)(xe,2),Ce=we[0],Ae=we[1],Ie=(0,NV._)(iG.D_,{fetchPolicy:"network-only"}),ke=(0,o.A)(Ie,1)[0];(0,a.useEffect)((()=>{ke().then((e=>{let t=e.data;const a=null===t||void 0===t?void 0:t.latestForceRefreshOperation;a&&a.state!==Ee.p2z.COMPLETED&&a.id!==n&&(he(a.id),be(!0),Ae(!0))}))}),[]);const Se=(0,a.useCallback)((e=>{he(e),be(!0),Ae(!0)}),[]),Ne=(0,a.useCallback)((()=>{be(!1),he(null),Ae(!1)}),[]),Te=(0,a.useCallback)((()=>{Ae(!1)}),[]),_e=(0,a.useCallback)((()=>{ge&&e((0,g.aR)(ge)),be(!1),he(null)}),[ge,e]),De=SK(ce,null!==ie&&void 0!==ie?ie:null).sortedAccountsGroup,Re=(0,a.useMemo)((()=>De.flatMap((e=>e.accounts.filter((e=>!e.isHidden)).sort(((e,t)=>e.order-t.order)).map((e=>{var t,n,a;return{id:e.id,displayName:e.displayName,institutionLogoUrl:null!==(t=e.logoUrl)&&void 0!==t?t:null,dataProvider:null!==(a=null===(n=e.credential)||void 0===n?void 0:n.dataProvider)&&void 0!==a?a:null}}))))),[De]),Me=(0,bZ.D)(sZ,{skip:(0,BY.A)(X)||!W,variables:{startDate:(0,GV.in)({timeframe:H,value:kZ(H)}),timeframe:(0,Qq.L)(Ee.VE7,H,Ee.VE7.MONTH),filters:(0,iZ.V)(P)}}
1),Le=Me.data,Oe=Me.isLoadingInitialData,Pe=Me.isNetworkRequestInFlight,Be=(null!==Le&&void 0!==Le?Le:{}).snapshotsByAccountType,ze=void 0===Be?[]:Be,Fe=(e=>{var t,n;const l=e||{},r=l.accountFilters,o=l.snapshotStartDate,i=l.shouldUseMockData,s=void 0!==i&&i,c=l.skip;mZ()(o,"snapshotStartDate is required");const d=(0,pZ._)(vZ,s,{variables:{filters:{accountType:void 0,startDate:o,endDate:null,useAdaptiveGranularity:!0,accountFilters:(0,iZ.V)(null!==r&&void 0!==r?r:{})}},skip:c}),u=d.data,m=d.refetch,p=d.isLoadingInitialData,g=d.isNetworkRequestInFlight,h=null===(t=null===u||void 0===u?void 0:u.aggregateSnapshots)||void 0===t?void 0:t[0],v=(null===h||void 0===h?void 0:h.date)&&(null===h||void 0===h?void 0:h.date)!==o,f=null!==r&&void 0!==r?r:{},E=(f.accountType,(0,En.A)(f,hZ)),y=(0,pZ._)(cZ,s,{variables:{date:v?null===h||void 0===h?void 0:h.date:o,filters:(0,iZ.V)(E)}}),b=y.data,x=y.isLoadingInitialData,w=y.refetch,C=(0,a.useMemo)((()=>{var e;return(null!==(e=null===b||void 0===b?void 0:b.accounts)&&void 0!==e?e:[]).reduce(((e,t)=>{var n,a;if(!t.includeInNetWorth)return e;const l=null!==(n=e[t.type.name])&&void 0!==n?n:0;return(0,U.A)((0,U.A)({},e),{},{[t.type.name]:l+(null!==(a=t.displayBalance)&&void 0!==a?a:0)})}),{})}),[b]);return{aggregateSnapshots:null!==(n=null===u||void 0===u?void 0:u.aggregateSnapshots)&&void 0!==n?n:[],previousAmountsByAccountType:C,isLoadingAggregateSnapshots:p,isLoadingBalanceAtDate:x,isAggregateSnapshotsNetworkRequestInFlight:g,refetchAggregateSnapshots:m,refetchBalanceAtDate:w}})({snapshotStartDate:$,skip:(0,BY.A)(X)||!j,shouldUseMockData:t,accountFilters:P}),Ue=Fe.previousAmountsByAccountType,Ve=Fe.aggregateSnapshots,We=Fe.isLoadingAggregateSnapshots,je=Fe.isAggregateSnapshotsNetworkRequestInFlight,He=!Oe&&!Pe&&!We&&!je,Ke=(0,a.useMemo)((()=>{const e=(null!==re&&void 0!==re?re:{}).accounts;return(void 0===e?[]:e).reduce(((e,t)=>{const n=t.recentBalances.filter(Tr.A);return(0,U.A)((0,U.A)({},e),{},{[t.id]:n})}),{})}),[re]),qe=null!==Z&&void 0!==Z?Z:"ALL",$e=(0,l.Zp)(),Ze=(0,a.useRef)(null),Je=(0,hm.M)((()=>((0,Ge.u4)(Ye.Jr),r()))),Xe=(0,o.A)(Je,2),Qe=Xe[0],tt=Xe[1],nt=(e,t)=>{var n;Q(),e.dataProvider||1!==(null===(n=e.accountIds)||void 0===n?void 0:n.length)?t():$e(I.JZ.accounts.accountDetails({id:e.accountIds[0]}))},at=(0,a.useMemo)((()=>ce.map((e=>e.type))),[ce]),lt=(0,a.useCallback)((()=>{const e=u(oZ.Gd.SHARED_VIEWS_WALKTHROUGH);(0,Ge.u4)(Ye.QQ.WalkthroughGetStartedClicked,{destination:e}),$e(e)}),[u,$e]);return a.createElement(Yq,{"data-external-id":"accounts",name:"Accounts",emptyIcon:"layers",emptyTitle:_t.f_,pageError:le,isLoading:ae,onAccountAdded:Q,controls:a.createElement(HH,{accountFilters:P,onChangeFilters:F,onChangeBusinessEntityFilter:G,onClearFilters:Y,hasMultipleOwners:ue,onEditOwners:y,onEditBusinessEntities:C,onOperationStarted:Se,onBeforeStartRefresh:Ne,isRefreshInProgress:Ce})},a.createElement(rV.T,{screenName:"Accounts"}),ee?a.createElement(p.i,{label:"Loading account data..."}):a.createElement(a.Fragment,null,a.createElement(SZ,{template:'"chart chart" "rec sum" / minmax(0,1fr) 30%',md:'"chart" "sum" "rec"'},a.createElement(QU.E,{area:"chart"},a.createElement(Hq,{onDismiss:()=>h(),onGetStarted:()=>$e(u(oZ.Gd.SHARED_VIEWS_BANNER)),shown:!!m}),a.createElement(wq,{onSwitchComplete:Q}),a.createElement(Xl.AM,null,a.createElement(Mj,{chartType:V,setChartType:e=>{R({chartType:e})},snapShotsDataByAccountType:ze,availableAccountTypes:at,aggregateSnapshotsData:Ve,isLoadingSnapshotsByAccountType:Oe,isLoadingAggregateSnapshots:We,isAggreateSnapShotsNet
1workRequestInFlight:je,activeTimeframeIndex:K,onChangeTimeframe:e=>R({timeframe:e}),isSnapshotsNetworkRequestInFlight:Pe,selectedDateRange:q,setSelectedDateRange:e=>R({dateRange:e.display}),selectedOwnerIds:z,selectedAccountTypes:P.accountSubtypes,selectedAccountIds:P.ids,businessEntitySet:P.businessEntitySet,amountHeaderProps:{className:"-mt-xs",amountSize:"xl"}}))),a.createElement(QU.E,{area:"rec"},a.createElement(DK,{ref:Ze,accountSummaries:ce,householdPreferences:ie||null,recentBalancesByAccount:Ke,sparklinesTimeframeKey:qe,previousBalancesByAccountType:Ue,snapshots:ze})),a.createElement(QU.E,{area:"sum",sticky:!0},a.createElement(NZ,null,a.createElement($K,{accountSummaries:ce,onClickAccountType:e=>{null!==Ze&&void 0!==Ze&&Ze.current&&Ze.current.scrollToAccountType(e)},isDownloadingCsv:Qe,onClickDownloadCsv:tt,selectedOwnerIds:z,selectedAccountTypes:P.accountSubtypes,selectedAccountIds:P.ids,businessEntitySet:P.businessEntitySet,isLoading:!He}))))),a.createElement(XU.l,{path:I.JZ.accounts.addAccount.relativePath,onClose:Q},(e=>{let t=e.close;return a.createElement(SF.E,{onComplete:e=>{nt(e,t)},onClose:t,allowManualAccount:!0})})),a.createElement(XU.l,{path:I.JZ.accounts.addManualAccount.relativePath,onClose:Q},(e=>{let t=e.close;return a.createElement(QK.b,{onBack:t,onComplete:e=>{nt(e,t)}})})),a.createElement(XU.l,{path:I.JZ.accounts.plaidLinkOauth.relativePath,onClose:Q},(e=>{let t=e.close;return a.createElement(Rq,{onComplete:t,onClose:t})})),a.createElement(l.BV,null,a.createElement(l.qh,{path:"/add-account/:dataProvider/:institutionId?",element:a.createElement(a$,{onComplete:Q})}),a.createElement(l.qh,{path:"/choose-provider/:institutionId",element:a.createElement(g$,{onComplete:e=>nt(e,(()=>$e(I.JZ.accounts())))})})),a.createElement(E,{maxWidth:CZ},a.createElement(Wq,{onSuccess:()=>Q()})),a.createElement(w,{maxWidth:CZ},a.createElement(Nq,{onSuccess:()=>Q()})),ye&&a.createElement(j$,{operationId:ge,orderedAccounts:Re,onDismiss:_e,onComplete:Te}),s&&de&&!1===t?a.createElement(a.Suspense,{fallback:null},a.createElement(wZ,{onFinish:lt,onClose:c})):null)},kZ=e=>{const t=N.c9.local().minus({years:2});return(0,r.YW)(e).with(Ee.VE7.MONTH,(()=>t.diffNow().negate().as("months"))).with(Ee.VE7.YEAR,Ee.VE7.QUARTER,(()=>4)).otherwise((()=>{throw new Error("Unhandled timeframe: ".concat(e))}))},SZ=(0,$d.s)(QU.a)(fZ||(fZ=(0,wc.A)(["pt-0"]))),NZ=u.default.div.attrs((0,Ex.p)("accounts-summary-card")).withConfig({displayName:"Accounts__SummaryCardPositioner",componentId:"c0plss-0"})(["position:sticky;top:0;"]),TZ=Ee.qkX,_Z=Ee.bcC,DZ=()=>{const e=(0,l.Zp)(),t=(0,l.g)().threadId,n=(0,z.h)().openAssistant,r=(0,ot.M)(),o=r.isOn,i=r.isReady;return(0,a.useEffect)((()=>{const a=(0,gt.SY)({isSplitReady:i,threadId:t,isTodayEnabled:o});a&&(a.openOverlay&&n(t,Ye.rP.Url),e(a.href,{replace:!0}))}),[i,o,e,n,t]),null};var RZ=n(74165);const MZ=e=>{let t=e.value,n=e.label,l=e.subtitle,r=e.tooltipText,o=e.className,i=e.isLoading,s=e["data-sc-tw"];return a.createElement(LZ,{"data-external-id":"deprecated-statistic-card",className:o,rootProps:{"data-sc-tw":s}},i?a.createElement(M.Al,{$width:"138px",$height:"24px"}):a.createElement(OZ,null,t),a.createElement(BZ,null,i?a.createElement(M.Al,{$width:"98px",$height:"16px"}):a.createElement(a.Fragment,null,"string"===typeof n?a.createElement(RV.W,null,n):n,null!==r&&void 0!==r&&a.createElement(JY.d,{maxWidth:250,content:r},a.createElement(zZ,null)))),!i&&l&&a.createElement(PZ,null,l))},LZ=(0,u.default)(Xl.AM).withConfig({displayName:"StatisticCard__Root",componentId:"sc-12gcegu-0"})(["padding:",";text-align:center;gap:",";justify-content:center;align-items:center;"],vt.YK.xlarge,vt.YK.xsmall),OZ=u.default.span.withConfig({displayName:"StatisticCard__Value",componentId:"sc-12gcegu-1"})(["font-size:20px;font-weight:",";"],vt.Wy.medium),PZ=u.default.div.withConfig({displayName:"StatisticCard__Subtitle",componentId:"sc-12gcegu-2"})(["font-size:",";font-weight:",";color:",";"],vt.J.small,vt.Wy.medium,vt.Ee.color.content.success),BZ=u.default.div.withConfig({displayName:"StatisticCard__LabelContainer",componentId:"sc-12gcegu-3"})(["display:flex;align-items:center;justify-content:center;gap:",";"],vt.YK.xxsmall),zZ=(0,u.default)(sl.ZQ).attrs({name:"info",size:12}).withConfig({displayName:"StatisticCard__InfoIcon",componentId:"sc-12gcegu-4"})(["cursor:default;color:",";"],vt.Ee.color.content.secondary);var FZ=n(65986);const GZ={income:"green",expense:"red"},YZ=function(e){return GZ[arguments.length>1&&void 0!==arguments[1]&&arguments[1]?(e=>{if("income"===e)return"expense";if("expense"===e)return"income";throw new Error("Invalid transaction type: ".concat(e))})(e):e]},UZ=e=>
1{let t=e.className,n=e.max,r=e.total,o=e.color,i=e.entry,s=e.hideAmounts;const c=(0,l.Zp)(),d=i.icon,u=i.logoUrl,m=i.name,p=i.value,g=i.type,h=i.link,v=p>0&&"expense"===g||p<0&&"income"===g,f=Math.min(1,Math.abs(p/n)),E=p/r,y=(0,a.useMemo)((()=>null!==o&&void 0!==o?o:YZ(g,v)),[o,g,v]);return a.createElement(HZ,{"data-external-id":"breakdown-item",className:t,onClick:()=>h&&c(h),$hasLink:!!h},a.createElement(WZ,{size:f,color:y}),a.createElement(KZ,null,a.createElement(jZ,{gap:"xxsmall",alignCenter:!0,justifyStart:!0},d&&a.createElement(fe.xa2,null,d),u?a.createElement("div",{className:"flex"},a.createElement(qZ,{url:u,size:24}),a.createElement($Z,null,m)):a.createElement($Z,null,m)),a.createElement(ZZ,null,s?(0,De.l9)(E):a.createElement(a.Fragment,null,a.createElement(Yl.t,{emphasis:VZ(i)<0,type:g,value:p})," (",(0,De.l9)(E),")"))))},VZ=e=>{let t=e.type,n=e.value;return"expense"===t?-n:n},WZ=u.default.div.attrs({"data-sc-tw":"BreakdownItem__Bar"}).withConfig({displayName:"BreakdownItem__Bar",componentId:"vslkwd-0"})(["position:absolute;left:0;top:0;bottom:0;width:","%;opacity:0.3;transition:",",width 600ms ease-out;background-color:",";border-radius:",";border-top-left-radius:0;border-bottom-left-radius:0;"],(e=>100*e.size),(e=>e.theme.transition.default),(e=>{let t=e.theme,n=e.color;return t.color[n]}),(e=>e.theme.radius.medium)),jZ=(0,u.default)(m.g).withConfig({displayName:"BreakdownItem__StyledFlexContainer",componentId:"vslkwd-1"})(["overflow:hidden;max-width:calc(100vw - 500px);"]),HZ=u.default.div.withConfig({displayName:"BreakdownItem__Container",componentId:"vslkwd-2"})(["position:relative;",""],(e=>e.$hasLink?(0,u.css)(["&:hover{cursor:pointer;[data-sc-tw~='BreakdownItem__Bar']{opacity:0.4;}}"]):null)),KZ=u.default.div.withConfig({displayName:"BreakdownItem__Info",componentId:"vslkwd-3"})(["position:relative;display:flex;align-items:center;justify-content:space-between;min-height:40px;padding-left:24px;padding-right:16px;box-sizing:border-box;"]),qZ=(0,u.default)(Wl._).withConfig({displayName:"BreakdownItem__StyledMerchantLogo",componentId:"vslkwd-4"})(["margin-right:",";"],(e=>e.theme.spacing.small)),$Z=u.default.span.withConfig({displayName:"BreakdownItem__CategoryName",componentId:"vslkwd-5"})(["white-space:nowrap;overflow:hidden;text-overflow:ellipsis;"]),ZZ=(0,u.default)(xt.v).withConfig({displayName:"BreakdownItem__Price",componentId:"vslkwd-6"})(["white-space:nowrap;"]),JZ=e=>{var t,n;let l=e.className,r=e.items,o=e.total,i=e.color,s=e.empty,c=e.hideAmounts;const d=(0,Nc.A)((e=>-VZ(e)),r),u=null!==(t=null===(n=d[0])||void 0===n?void 0:n.value)&&void 0!==t?t:0;return a.createElement(XZ,{"data-external-id":"breakdown",className:l},d.length>0?d.map(((e,t)=>a.createElement(UZ,{key:t,entry:e,max:u,total:o,color:i,hideAmounts:c}))):s)},XZ=u.default.div.withConfig({displayName:"Breakdown__Root",componentId:"sr4sc3-0"})(["display:grid;gap:",";padding:",";padding-left:0;position:relative;"],(e=>e.theme.spacing.xsmall),(e=>e.theme.spacing.default)),QZ=e=>{let t=e.hideAmounts,n=e.toggleHideAmounts,l=e.onClickShare;const r=(0,a.useState)(!1),i=(0,o.A)(r,2),s=i[0],c=i[1],d=(0,a.useState)(!1),u=(0,o.A)(d,2),m=u[0],p=u[1];return a.createElement(eJ,{"data-external-id":"share-popover-content"},a.createElement(xt.v,null,_t.b0.SHARE_POPOVER_CONTENT),a.createElement(tJ,{onClick:e=>{e.stopPropagation(),n()}},a.createElement(xt.v,{weight:"medium"},_t.b0.SHARE_POPOVER_HIDE_AMOUNTS),a.createElement(ox.k,{checked:t,onChange:n})),a.createElement(tJ,{onClick:()=>c(!s)},a.createElement(xt.v,{weight:"medium"},_t.b0.SHARE_POPOVER_TRANSPARENT_BACKGROUND),a.createElement(ox.k,{checked:s})),a.createElement(nJ,{onClick:async()=>{p(!0),await l(s),p(!1)},pending:m},_t.b0.GENERATE_IMAGE_BUTTON))},eJ=(0,u.default)(m.g).attrs({column:!0,gap:"default"}).withConfig({displayName:"SharePopoverContent__PopoverContent",componentId:"sc-1astnzm-0"})(["width:240px;padding:",";font-size:",";"],(e=>e.theme.spacing.default),(e=>e.theme.fontSize.small)),tJ=(0,u.default)(m.g).attrs({alignCenter:!0,justifyBetween:!0}).withConfig({displayName:"SharePopoverContent__Row",componentId:"sc-1astnzm-1"})(["cursor:pointer;user-select:none;"]),nJ=(0,u.default)(su.U).withConfig({displayName:"SharePopoverContent__Button",componentId:"sc-1astnzm-2"})(["",""],cu.vc);var aJ=n(26260);const lJ=(0,a.createContext)({hideAmounts:!1,shareDisabled:!1,toggleHideAmounts:aJ.A,unhideAmounts:aJ.A}),rJ=["onSelectElement"],oJ=(0,u.default)(sl.ZQ).attrs({name:"chevron-down",size:12}).withConfig({displayName:"ShareChartButton__ChevronDownIcon",componentId:"sc-1huctm9-0"})(["transform:translateY(0);"]),iJ=(0,u.default)(wt.Xb).withConfig({displayName:"ShareChartButton__Button",componentId:"sc-1huctm9-1"})(["gap:",";"],(e=>e.theme.spacing.xsmall)),sJ=e=>{let t=e.onSelectElement,n=(0,En.A)(e,rJ);const l=(0,u.useTheme)(),r=(0,a.useContext)(lJ),o=r.shareDisabled,i=r.hideAmounts,s=r.toggleHideAmounts,c=r.unhideAmounts,d=(0,a.useCallback)((async e=>
1{const a=t(),r=await(0,_a.ov)((0,U.A)({element:a,backgroundColor:e?"transparent":l.color.white},n));r&&n.chartType&&await(0,_a.Xs)(r,n.fileName,{chart:n.chartType,view:n.view}).then(c)}),[t,c,l.color.white,n]);return a.createElement(Qi.Az,{"data-external-id":"share-chart-button",placement:"bottom-end",overlay:e=>{let t=e.close;return a.createElement(Qi.j7,null,a.createElement(QZ,{hideAmounts:i,toggleHideAmounts:s,onClickShare:e=>d(e).then(t)}))}},(e=>{let t=e.toggleOpen;return a.createElement(iJ,{onClick:o?void 0:t,disabled:o},_t.b0.SHARE_BUTTON," ",a.createElement(oJ,null))}))},cJ=a.memo(sJ),dJ=["category","group","merchant"],uJ=["Category","Group","Merchant"],mJ=e=>{let t=e.byCategory,n=e.byMerchant,l=e.byCategoryGroup,r=e.total,o=e.title;const i=a.useRef(null),s=(0,a.useMemo)((()=>"Monarch - Cash Flow - ".concat(o)),[o]),c=(0,a.useMemo)((()=>a.createElement("div",{className:"flex items-center gap-xs"},a.createElement(MA.c,null,uJ.map(((e,t)=>a.createElement(RA.Q,{index:t,key:e,$background:"card"},e)))),a.createElement(wm.A,{orientation:"vertical",color:"secondary",className:"mx-2xs h-default"}),a.createElement(cJ,{fileName:s,chartType:_a.NB.CashFlowBreakdown,onSelectElement:()=>i.current}))),[]);return a.createElement(Xl.AM,{"data-external-id":"breakdown-card",title:o,controls:c},a.createElement(gJ,{ref:i},a.createElement(pJ,{byCategory:t,byMerchant:n,byCategoryGroup:l,total:r,title:o})))},pJ=e=>{let t=e.byCategory,n=e.byMerchant,l=e.byCategoryGroup,r=e.total,i=e.title;const s=(0,a.useContext)(lJ).hideAmounts,c=(0,FZ.uc)(),d=(0,o.A)(c,1)[0],u=(0,a.useMemo)((()=>{switch(d){case 0:return t;case 1:return l;case 2:return n;default:return[]}}),[d,l,t,n]);return a.createElement(JZ,{"data-external-id":"breakdown-list",items:u,total:r,hideAmounts:s,empty:a.createElement(qY.S,null,a.createElement(cU.vx,{title:"No ".concat(i.toLowerCase()),subtitle:"No matching ".concat(i.toLowerCase()," for the selected range.")}))})},gJ=(0,u.default)(m.g).attrs({column:!0}).withConfig({displayName:"BreakdownCard__Content",componentId:"sc-1v2f0z7-0"})([""]),hJ=e=>{let t=e.children,n=e.onChangeIndex;const l=(0,FZ.uc)(),r=(0,o.A)(l,1)[0];return(0,bu.w)((()=>{n(r)}),[r]),a.createElement(a.Fragment,null,t)},vJ=e=>{let t=e.income,n=e.expenses,l=e.savings,r=e.title,o=e.savingsRate,i=e.active;const s=(0,u.useTheme)(),c=Math.max(0,o);return a.createElement(Sa.II,{"data-external-id":"cash-flow-bar-chart-tooltip",active:i,header:a.createElement(fJ,null,r)},a.createElement(Na.B,{label:"Income",value:a.createElement(Yl.t,{value:t,type:"income",round:!0}),dotFillColor:s.color.green}),a.createElement(Na.B,{label:"Expenses",value:a.createElement(Yl.t,{value:n,type:"expense",round:!0}),dotFillColor:s.color.red}),a.createElement(Na.B,{label:"Savings",value:a.createElement(Yl.t,{value:l,type:"income",round:!0}),strokeColor:s.color.gray}),a.createElement(Na.B,{label:"Savings Rate",value:(0,De.l9)(c),strokeColor:s.color.gray}))},fJ=u.default.div.withConfig({displayName:"CashFlowBarChartTooltip__Header",componentId:"eccgyr-0"})(["font-weight:",";font-size:",";text-align:left;"],(e=>e.theme.fontWeight.medium),(e=>e.theme.fontSize.xsmall));var EJ=n(87743);const yJ=parseInt(yD.w.spacing.default,10),bJ=e=>{let t=e.data,n=e.activeDate,l=e.timeframe,r=e.onBarClick;const i=(0,qd.W)(),s=(0,o.A)(i,2),c=s[0],d=s[1].width,m=void 0===d?0:d,p=(0,xy.d)(m,150)||m,g=(0,u.useTheme)(),h=(0,a.useCallback)((e=>{let t=e.startDate;return r(t)}),[r]),v=(0,EJ.Rt)(t,n),f=(0,a.useMemo)((()=>"year"!==l?(0,EJ.uu)(t):[]),[t,l]),E=(0,a.useCallback)((e=>{var t;return null!==(t=(0,wW.yP)({startDate:e,endDate:N.c9.fromISO(e).endOf(l).toISODate()}))&&void 0!==t?t:e}),[l]),y=(0,a.useMemo)((()=>a.createElement(PU.vD,{activeBarIndex:v,barColorInteractive:!0,data:t,barDataKeys:[{name:"income",color:g.color.green},{name:"expense",color:g.color.red}],totalDataKey:"savings",dashedLineDataKey:"currentMonthSavings",xAxisDataKey:"startDate",heightPx:275,widthPx:p-yJ,formatXAxis:(0,xW.B)(l),formatYAxis:rl.fw,onBarAreaClick:h,xAxisReferenceLines:f,tooltipComponent:e=>{var t;const n=e.active,l=(0,_a.WS)(e);if(!l)return null;const r=l.income,o=l.expense,i=l.savings,s=l.savingsRate,c=l.startDate,d=l.currentMonthSavings;return a.createElement(vJ,{active:n,income:r,expenses:o,savings:null!==(t=null!==i&&void 0!==i?i:d)&&void 0!==t?t:0,title:E(c),savingsRate:s})}})),[v,t,p,E,h,g,l,f]);return a.createElement(xJ,{"data-external-id":"cash-flow-bar-chart",ref:c},y)}
1,xJ=(0,u.default)(Xl.AM).withConfig({displayName:"CashFlowBarChart__Root",componentId:"sc-38tebx-0"})(["contain:size layout;min-height:","px;padding:0px ","px ","px;"],275+yJ,yJ,yJ);var wJ=n(22069),CJ=n(61492),AJ=n(20505),IJ=n(57174),kJ=n(4135),SJ=n(89185);const NJ=e=>{let t=e.activeFilters,n=e.onClickApply,l=e.onClickReset;const r=(0,kJ.X)(),i=(0,o.A)(r,2),s=i[0],c=i[1],d=(0,lt.L7)().householdPreferences,u=null===d||void 0===d?void 0:d.collaborationToolsEnabled;return a.createElement(Eu.lV,{"data-external-id":"cash-flow-filter-card",initialValues:t,onSubmit:e=>n(e)},a.createElement("div",{className:"w-82 pb-xs"},a.createElement("div",{className:"flex items-center justify-between border-b border-divider-primary px-xl py-default"},a.createElement(fe.XZZ,{variant:"default",onClick:()=>l()},"Reset"),a.createElement(CJ.I,{size:"small",className:"mt-0 w-fit"},"Apply")),a.createElement("div",{className:"px-xl py-default"},u&&a.createElement(TJ,{title:"Owners"},a.createElement(AJ.E,{name:"ownershipSet",label:null,placeholder:"All owners..."})),a.createElement(TJ,{title:"Accounts"},a.createElement(tC.zB.Combobox,{multiple:!0,clearable:!0,name:"accounts",placeholder:"All accounts...",options:c,loading:s,label:null})),a.createElement(TJ,{title:"Tags"},a.createElement(tC.zB,{name:"tags",label:null},(e=>a.createElement(IJ.F,{value:e.value,onChange:t=>e.onChange(t.map((e=>e.value))),isCreatable:!1,placeholder:"All tags..."})))),a.createElement(TJ,{title:"Hidden"},a.createElement(tC.zB.Combobox,{name:"transactionVisibility",placeholder:"Not hidden only",options:SJ.$F,clearable:!0,label:null})))))},TJ=e=>{let t=e.title,n=e.children;return a.createElement("div",{"data-external-id":"filter-section",className:"not-last:mb-default"},a.createElement(fe.c8D,{weight:"medium",size:"sm"},t),a.createElement("div",{className:"mt-xs flex *:min-w-0 *:flex-1"},n))};var _J=n(28506),DJ=n(70696);const RJ=(e,t)=>N.c9.fromISO(t).startOf(e).toISODate(),MJ=(e,t)=>{let n=t.groupBy,a=t.summary;var l,r,o,i,s;return{startDate:null!==(l=(0,DJ.A)([e],n))&&void 0!==l?l:"",expense:{amount:-(null!==(r=null===a||void 0===a?void 0:a.sumExpense)&&void 0!==r?r:0)},income:{amount:null!==(o=null===a||void 0===a?void 0:a.sumIncome)&&void 0!==o?o:0},savings:{amount:null!==(i=null===a||void 0===a?void 0:a.savings)&&void 0!==i?i:0},savingsRate:{amount:null!==(s=null===a||void 0===a?void 0:a.savingsRate)&&void 0!==s?s:0}}},LJ=(e,t,n)=>{if(!e)return[];const a=null!==n&&void 0!==n?n:MJ,l=((e,t)=>{var n;return null!==(n={day:e.byDay,year:e.byYear,month:e.byMonth,quarter:e.byQuarter,week:e.byWeek}[t])&&void 0!==n?n:[]})(e,t);return(0,Nc.A)((e=>{var n;return null!==(n=(0,DJ.A)(["groupBy",t],e))&&void 0!==n?n:""}),l).map((e=>a(t,e)))},OJ=e=>{if(e)return Array.isArray(e)?e:"string"===typeof e&&e.includes(",")?e.split(",").map((e=>e.trim())).filter(Boolean):"string"===typeof e?[e]:void 0},PJ=(e,t)=>{if(!e.find((e=>e.startDate===t))&&e.length>0){return e[e.length-1].startDate}return t};var BJ=n(31189);const zJ="cashFlow",FJ=e=>{var t;let n=e.controls,l=e.analyticsPage,r=e.options,i=void 0===r?vW.Un:r;const s=i.findIndex((e=>e.value===BJ.xm[zJ].timeframe)),d=(0,FZ.uc)(),u=(0,o.A)(d,2),m=u[0],p=u[1],g=null!==(t=i[m])&&void 0!==t?t:i[s],h=(0,qG.e)().hasAccess,v=(0,Tj.Rq)(),f=v.businessEntities,E=v.isLoadingInitialData,y=h&&(E||f.length>0),b=(0,ZH.D)(zJ,{useParams:!1}),x=b.activeFilters,w=b.updateFilter,C=b.resetFilter,A=(0,a.useMemo)((()=>(0,_J.h)(OJ(x.businessEntitySet))),[x.businessEntitySet]),I=(0,a.useCallback)((e=>{var t;return w({businessEntitySet:null!==(t=(0,_J.V)(e))&&void 0!==t?t:[]})}),[w]),k=(0,rj.A)(c.A,(0,wJ.A)((0,_V.A)(["accounts","tags","ownershipSet","transactionVisibility"],x)));return(0,bu.w)((()=>{w((0,U.A)({timeframe:g.value},x.date?{date:RJ(g.value,x.date)}:{}))}),[g.value]),a.createElement("div",{"data-external-id":"cash-flow-controls",className:"flex items-center justify-end"},a.createElement("div",{className:"flex items-center"},a.createElement(MA.c,null,i.map(((e,t)=>{let n=e.value,l=e.label;return a.createElement(RA.Q,{key:n,index:t,$background:"base"},l)}))),(0,Tr.A)(n)&&a.createElement(GJ,null,n),y&&a.createElement(YJ,null,a.createElement(OH.O,{businessEntitySet:A,onCh
1angeBusinessEntitySet:I,source:Ye.rP.CashFlow})),a.createElement(YJ,null,a.createElement(Qi.Az,{placement:"bottom-end",closeOnEscape:!1,overlay:e=>{let t=e.close;return a.createElement(Qi.j7,null,a.createElement(NJ,{activeFilters:x,onClickReset:()=>{C(),p(s),t()},onClickApply:e=>{w(e),ij.Ay.filtersApplied({page:l,sections:(0,U.A)((0,U.A)({},(0,_V.A)(["accounts","tags","transactionVisibility"],e)),{},{owners:e.ownershipSet})}),t()}}))}},(e=>{let t=e.toggleOpen,n=e.isOpen;return a.createElement(fe.qN2,{show:k},a.createElement(VJ,{onClick:t,active:n},"Filters ",a.createElement(UJ,null)))})))))},GJ=(0,u.default)(m.g).attrs({alignCenter:!0,gap:"default",marginLeft:"default"}).withConfig({displayName:"CashFlowControls__ControlsContainer",componentId:"goyhbh-0"})([""]),YJ=(0,u.default)(m.g).attrs({alignCenter:!0,marginLeft:"default"}).withConfig({displayName:"CashFlowControls__FilterContainer",componentId:"goyhbh-1"})([""]),UJ=(0,u.default)(sl.ZQ).attrs({name:"chevron-down",size:12}).withConfig({displayName:"CashFlowControls__ChevronDownIcon",componentId:"goyhbh-2"})(["transform:translateY(1px);"]),VJ=(0,u.default)(wt.Xb).withConfig({displayName:"CashFlowControls__FilterButton",componentId:"goyhbh-3"})(["position:relative;align-items:center;gap:",";"],vt.YK.xsmall);var WJ=n(99045),jJ=n(83562);const HJ={category:"Category",group:"Group",both:"Both"},KJ="monarch-cash-flow-sankey",qJ=e=>a.createElement($J,{"data-external-id":"cash-flow-sankey-card-controls"},a.createElement(MA.c,null,Object.values(HJ).map(((e,t)=>a.createElement(RA.Q,{key:"".concat(e,"-").concat(t),index:t,$background:"card"},e)))),a.createElement(wm.A,{orientation:"vertical",color:"secondary",className:"mx-2xs h-default"}),a.createElement(cJ,Object.assign({onSelectElement:()=>document.getElementById(KJ),chartType:_a.NB.CashFlowSankey},e))),$J=(0,u.default)(m.g).attrs({alignCenter:!0,gap:"xsmall"}).withConfig({displayName:"CashFlowSankeyCardControls__Root",componentId:"pnn3ns-0"})(["margin:-",";margin-right:-10px;"],(e=>e.theme.spacing.xxsmall));var ZJ=n(72880);const JJ={breakdown:"Bar Chart",sankey:"Sankey Diagram"},XJ=e=>{let t=e.selectedView,n=e.onChangeView;return a.createElement(QJ,{"data-external-id":"cash-flow-view-select"},a.createElement(xt.v,{color:"textLight",weight:"medium",size:"small"},"View"),a.createElement(Qi.Az,{placement:"bottom-end",overlay:a.createElement(nX,null,Object.entries(JJ).map((e=>{let l=(0,o.A)(e,2),r=l[0],i=l[1];return a.createElement(Ji.xm,{key:r,onClick:()=>n(r),selected:r===t},i)})))},(e=>{let n=e.open;return a.createElement(tX,{onClick:n},JJ[t]," ",a.createElement(eX,null))})))},QJ=(0,u.default)(m.g).attrs({alignCenter:!0}).withConfig({displayName:"CashFlowViewSelect__Root",componentId:"sc-1ub3t5f-0"})(["gap:",";"],(e=>e.theme.spacing.small)),eX=(0,u.default)(sl.ZQ).attrs({name:"chevron-down",size:12}).withConfig({displayName:"CashFlowViewSelect__ChevronDownIcon",componentId:"sc-1ub3t5f-1"})(["transform:translateY(0px);"]),tX=(0,u.default)(wt.Xb).withConfig({displayName:"CashFlowViewSelect__Button",componentId:"sc-1ub3t5f-2"})(["gap:",";"],(e=>e.theme.spacing.xsmall)),nX=(0,u.default)(Ji.SP).withConfig({displayName:"CashFlowViewSelect__Menu",componentId:"sc-1ub3t5f-3"})(["width:180px;min-width:unset;"]);var aX=n(20456),lX=n(1506),rX=n(72846),oX=n(12874);const iX=e=>{let t=e.data,n=e.isLoading,r=e.date,i=e.timeframe,s=e.hideHeader,c=e.disableOnClick,d=e.hideCategoryIfZero;const u=(0,qd.W)(),m=(0,o.A)(u,2),g=m[0],h=m[1].width,v=(0,xy.d)(h,150),f=(0,a.useContext)(lJ).hideAmounts,E=(0,l.Zp)(),y=(0,ZH.D)("cashFlow",{useParams:!1}),b=y.activeFilters.sankey,x=y.updateFilter,w=(0,FZ.uc)(),C=(0,o.A)(w,1)[0],A=(0,a.useMemo)((()=>Object.keys(HJ)[C]),[C]);(0,a.useEffect)((()=>{A&&A!==b&&x({sankey:A})}),[A,b,x]);const k=(0,a.useMemo)((()=>{const e=N.c9.fromISO(r),t=e.endOf(i);let n="Monarch - Cash Flow Sankey - ".concat(e.toFormat("yyyy-MM"));return"month"!==i&&(n+=" to ".concat(t.toFormat("yyyy-MM"))),n}),[r,i]),S=(0,rX.eB)(t,A),T=(0,a.useCallback)(((e,t)=>{var n;return e.id===lX.ns?null!==(n=e.depth)&&void 0!==n?n:0:WJ.pD(e,t)}),[]),_=(0,a.useCallback)(((e,t)=>((0,rX.c$)(e.target),(0,rX.c$)(t.target),e.target.id===lX.ns?-1:t.value-e.value)),[]),D=(0,a.useCallback)((e=>{if(e.type===lX.Z6.Generic)return;const t=e.id,n=e.type,a=(0,oX.WF)({date:r,timeframe:i});n===lX.Z6.Category?E(I.JZ.categories({id:t,queryParams:a})):n===lX.Z6.CategoryGroup&&E(I.JZ.categoryGroups({id:t,queryParams:a}))}),[r,i,E]),R=(0,a.useCallback)((e=>{let t=e.value,n=e.percent,a=e.categoryGroupType,l=e.rawValue,r=e.id;if(0===l&&d||!a&&r!==lX.ns)return"";if(f&&n)return(0,De.l9)(n);const o=a===Ee.wNk.EXPENSE&&l>0?"-":"";return"".concat(o).concat((0,rl.vv)(t)).concat(n?" (".concat((0,De.l9)(n),")"):"")}),[f,d]),M=(0,a.useMemo)((()=>n?a.createElement(cX,null,a.createElement(p.i,null)):S.nodes.length<=0?a.createElement(ZJ.$,{width:v}):a.createElement(aX.uq,{width:v,data:S,formatValue:R,onClickNode:c?void 0:D,onAlignNode:T,onSortLinks:_,customNodesColorDeterminer:(e,t,n)=>(0,rX.WQ)(e,t,n,A),highlightOnHover:!0})),[A,S,v,c,n,D,R,T,_]);return a.createElement(Xl.AM,{"data-external-id":"cash-flow-sankey-card",title:JJ.sankey,hideHeader:s,controls:a.createElement(qJ,{fileName:k})},a.createElement(jJ.P,{mouseScroll:{rubberBand:!1}},a.createElement(sX,{ref:g,id:KJ},M)))}
1,sX=(0,u.default)(qY.S).withConfig({displayName:"CashFlowSankeyCard__Content",componentId:"sc-1601ivh-0"})(["padding:0;"]),cX=(0,u.default)(m.g).attrs({center:!0,column:!0}).withConfig({displayName:"CashFlowSankeyCard__LoadingContainer",componentId:"sc-1601ivh-1"})(["padding:",";"],vt.YK.xxxxlarge),dX=["value","children"],uX=e=>{let t=e.value,n=void 0===t?"on":t,l=e.children,r=(0,En.A)(e,dX);return a.createElement(MY.T,Object.assign({"data-external-id":"feature-flag-gate"},r),(e=>(0,Tc.A)(n)?e===n?l:null:(0,RY.A)(n)&&n.includes(e)?l:null))};var mX=n(92747),pX=n(25309);const gX=(0,Qt.J)('\n  query Common_GetCashFlowDashboard($filters: TransactionFilterInput) {\n    byDay: aggregates(filters: $filters, fillEmptyValues: true, groupBy: ["day"]) {\n      summary {\n        sumExpense\n      }\n      groupBy {\n        day\n      }\n    }\n  }\n'),hX=(0,Qt.J)('\n  query Common_GetCashFlowTimeframeAggregates($filters: TransactionFilterInput) {\n    byYear: aggregates(groupBy: ["year"], fillEmptyValues: true, filters: $filters) {\n      groupBy {\n        year\n      }\n\n      summary {\n        savings\n        savingsRate\n        sumIncome\n        sumExpense\n      }\n    }\n\n    byMonth: aggregates(groupBy: ["month"], fillEmptyValues: true, filters: $filters) {\n      groupBy {\n        month\n      }\n\n      summary {\n        savings\n        savingsRate\n        sumIncome\n        sumExpense\n      }\n    }\n\n    byQuarter: aggregates(groupBy: ["quarter"], fillEmptyValues: true, filters: $filters) {\n      groupBy {\n        quarter\n      }\n\n      summary {\n        savings\n        savingsRate\n        sumIncome\n        sumExpense\n      }\n    }\n  }\n'),vX=(0,Qt.J)('\n  query Common_GetCashFlowEntityAggregates(\n    $filters: TransactionFilterInput\n    $includeCategory: Boolean = true\n    $includeCategoryGroup: Boolean = true\n    $includeMerchant: Boolean = true\n  ) {\n    byCategory: aggregates(filters: $filters, groupBy: ["category"])\n      @include(if: $includeCategory) {\n      groupBy {\n        category {\n          id\n          name\n          icon\n\n          group {\n            id\n            type\n          }\n        }\n      }\n\n      summary {\n        sum\n      }\n    }\n\n    byCategoryGroup: aggregates(filters: $filters, groupBy: ["categoryGroup"])\n      @include(if: $includeCategoryGroup) {\n      groupBy {\n        categoryGroup {\n          id\n          name\n          type\n        }\n      }\n\n      summary {\n        sum\n      }\n    }\n\n    byMerchant: aggregates(filters: $filters, groupBy: ["merchant"])\n      @include(if: $includeMerchant) {\n      groupBy {\n        merchant {\n          id\n          name\n          logoUrl\n        }\n      }\n\n      summary {\n        sumIncome\n        sumExpense\n      }\n    }\n\n    summary: aggregates(filters: $filters, fillEmptyValues: true) {\n      summary {\n        sumIncome\n        sumExpense\n        savings\n        savingsRate\n      }\n    }\n  }\n'),fX=e=>!!e&&0!==e.value,EX=(e,t,n,a)=>e.filter((e=>t=>{var n;let a=t.groupBy;return(null===a||void 0===a||null===(n=a.category)||void 0===n?void 0:n.group.type)===e})(n)).map(((e,t)=>n=>{let a=n.groupBy,l=n.summary;if(null===a||void 0===a||!a.category)return null;const r=a.category,o=r.icon,i=r.name,s=r.group,c=r.id,d=l.sum;return{icon:o,name:i,type:s.type===Ee.wNk.INCOME?"income":"expense",value:d,link:I.JZ.categories({id:c,queryParams:(0,oX.WF)({date:e.startDate,timeframe:t})})}})(t,a)).filter(fX),yX=(e,t,n,a)=>e.filter((e=>t=>{var n;let a=t.groupBy;return(null===a||void 0===a||null===(n=a.categoryGroup)||void 0===n?void 0:n.type)===e})(t)).map(((e,t,n)=>a=>{let l=a.groupBy,r=a.summary;if(null===l||void 0===l||!l.categoryGroup)return null;const o=l.categoryGroup,i=o.name,s=o.id,c=r.sum;return{name:i,type:e===Ee.wNk.EXPENSE?"expense":"income",value:c,link:I.JZ.categoryGroups({id:s,queryParams:(0,oX.WF)({date:t.startDate,timeframe:n})})}})(t,n,a)).filter(fX),bX=(e,t,n,a)=>e.map(((e,t,n)=>a=>{let l=a.groupBy,r=a.summary;if(null===l||void 0===l||!l.merchant)return null;const o=t===Ee.wNk.INCOME,i=l.merchant,s=i.name,c=i.id,d=i.logoUrl,u=r.sumExpense,m=r.sumIncome;return{name:s,logoUrl:d,type:o?"income":"expense",value:o?m:u,link:I.JZ.merchants({id:c,queryParams:(0,oX.WF)({date:e.startDate,timeframe:n})})}})(t,n,a)).filter(fX),xX=(e,t)=>
1{const n=(0,Tj.Rq)(),l=n.businessEntities,r=n.isLoadingInitialData,o=n.error,i=(0,a.useRef)(e),s=(0,a.useRef)(t);i.current=e,s.current=t,(0,a.useEffect)((()=>{const e=i.current;if(r||o||null===e||void 0===e||!e.length)return;const t=Array.isArray(e)?e:[e],n=new Set([...l.map((e=>e.id)),_j.CG]),a=t.filter((e=>n.has(e)));a.length===t.length&&Array.isArray(e)||s.current(a)}),[r,o,l])};var wX,CX=n(42790);const AX=["timeframe","date","view","sankey","breakdown"],IX=()=>{var e;const t=(0,ZH.D)("cashFlow"),n=t.activeFilters,l=t.updateFilter,r=n.timeframe,i=n.date,s=n.view,c=n.sankey,d=n.breakdown,u=(0,En.A)(n,AX),m=vW.Un.some((e=>e.value===r))?r:vW.xh;xX(u.businessEntitySet,(e=>l({businessEntitySet:e})));const g=(0,Pc.e)(!1),h=(0,o.A)(g,2),v=h[0],f=h[1],E=f.toggle,y=f.setOff,b=(0,a.useMemo)((()=>vW.Un.findIndex((e=>e.value===m))),[]),x=(0,a.useMemo)((()=>Object.keys(HJ).findIndex((e=>e===c))),[c]),w=i||(C=m,N.c9.local().startOf(C).toISODate());var C;const A=e=>l({date:e}),I=(0,U.A)((0,U.A)({},(e=>({tags:OJ(e.tags),accounts:OJ(e.accounts),ownershipSet:(0,EZ.H)(OJ(e.ownershipSet)),businessEntitySet:(0,_J.h)(OJ(e.businessEntitySet)),transactionVisibility:e.transactionVisibility}))(u)),{},{transactionVisibility:null!==(e=u.transactionVisibility)&&void 0!==e?e:Ee.h1.NON_HIDDEN_TRANSACTIONS_ONLY}),k=(0,bZ.D)(hX,{variables:{filters:(0,RZ.A)(CX.q9,I)}}).data,S=(0,a.useMemo)((()=>LJ(k,m,EJ.xD)),[k,m]),T=(0,a.useMemo)((()=>((e,t,n)=>{const a=t.find((e=>e.startDate===n)),l=a?N.c9.fromISO(a.startDate):N.c9.local().startOf(e),r=l.endOf(e);return{startDate:l.toISODate(),endDate:r.toISODate()}})(m,S,w)),[w,m,S]),_=(0,bZ.D)(vX,{variables:{filters:(0,RZ.A)(CX.q9,(0,U.A)((0,U.A)({},I),T))}}),D=_.data,R=_.refetch,M=_.isDataAvailable,L=_.isNetworkRequestInFlight,O=!M&&L,P=(0,a.useMemo)((()=>{const e=null!==D&&void 0!==D?D:{},t=e.byCategory,n=void 0===t?[]:t,a=e.byCategoryGroup,l=void 0===a?[]:a,r=e.byMerchant,o=void 0===r?[]:r;return{incomesByCategory:EX(n,T,Ee.wNk.INCOME,m),expensesByCategory:EX(n,T,Ee.wNk.EXPENSE,m),expensesByMerchant:bX(o,T,Ee.wNk.EXPENSE,m),incomesByMerchant:bX(o,T,Ee.wNk.INCOME,m),incomesByCategoryGroup:yX(l,Ee.wNk.INCOME,T,m),expensesByCategoryGroup:yX(l,Ee.wNk.EXPENSE,T,m)}}),[D,T,m]),B=(0,a.useMemo)((()=>(0,wW.yP)(T)),[T]),z=(0,a.useMemo)((()=>({hideAmounts:v,shareDisabled:!D,toggleHideAmounts:E,unhideAmounts:y})),[v,D,E,y]);return(0,a.useEffect)((()=>{const e=PJ(S,w);e!==w&&l({date:e})}),[S,w,l]),a.createElement(Dc.t,{"data-external-id":"cash-flow",initialIndex:b},a.createElement(Yq,{name:"Cash Flow",emptyIcon:"bar-chart-filled",emptyTitle:_t.VW,controls:a.createElement(FJ,{analyticsPage:"cash-flow"}),onAccountAdded:R},a.createElement(rV.T,{screenName:"Cash Flow",tab:m}),(()=>{if(D&&void 0!==k){const e=(0,o.A)(D.summary,1)[0].summary,t=e.sumIncome,n=e.sumExpense,r=e.savings,i=e.savingsRate;return a.createElement(TX,{template:'"chart" "date" "summary" "income" "expense"'},a.createElement(QU.E,{area:"chart"},a.createElement(bJ,{onBarClick:A,data:S,timeframe:m,activeDate:w})),a.createElement(QU.E,{area:"date"},a.createElement(DX,null,a.createElement(SX,null,B||(0,wW.KC)(T)),a.createElement(uX,{name:"sankey-diagram",defaultOnTimeout:"on"},a.createElement(XJ,{selectedView:s,onChangeView:e=>l({view:e})})))),a.createElement(QU.E,{area:"summary"},a.createElement(_X,null,a.createElement(NX,{value:a.createElement(Yl.t,{type:"income",value:t,round:!0,emphasis:!0}),label:"Income",isLoading:O}),a.createElement(NX,{value:a.createElement(Yl.t,{type:"expense",value:n,round:!0,emphasis:!0}),label:"Expenses",isLoading:O}),a.createElement(NX,{value:a.createElement(Yl.t,{type:"savings",value:r,round:!0}),label:"Total savings",isLoading:O}),a.createElement(NX,{value:(0,De.l9)(Math.max(0,i)),label:"Savings rate",isLoading:O}))),a.createElement(lJ.Provider,{value:z},s===_a.NB.CashFlowBreakdown?a.createElement(Dc.t,{initialIndex:d?dJ.indexOf(d):void 0},a.createElement(hJ,{onChangeIndex:e=>l({breakdown:dJ[e]})},a.createElement(QU.E,{area:"income"},a.createElement(mJ,{title:"Income",byCategory:P.incomesByCategory,byMerchant:P.incomesByMerchant,byCategoryGroup:P.incomesByCategoryGroup,total:t})),a.createElement(QU.E,{area:"expense"},a.createElement(mJ,{title:"Expenses",byCategory:P.expensesByCategory,b
1yMerchant:P.expensesByMerchant,byCategoryGroup:P.expensesByCategoryGroup,total:n})))):a.createElement(pX.f,{padding:0},a.createElement(mX.V,{md:12},a.createElement(Dc.t,{initialIndex:x},a.createElement(iX,{data:D,date:w,timeframe:m,isLoading:O}))))))}return a.createElement(kX,{center:!0,column:!0},a.createElement(p.i,null),"Loading cash flow...")})()))},kX=(0,u.default)(ZY.B).withConfig({displayName:"CashFlow__LoadingContainer",componentId:"sc-14j2gue-0"})(["flex:1;height:100%;gap:",";"],vt.YK.default),SX=u.default.div.withConfig({displayName:"CashFlow__DateLabel",componentId:"sc-14j2gue-1"})(["font-size:",";font-weight:",";"],vt.J.xlarge,vt.Wy.medium),NX=(0,u.default)(MZ).attrs({"data-sc-tw":"CashFlow__StatisticCardGrow"}).withConfig({displayName:"CashFlow__StatisticCardGrow",componentId:"sc-14j2gue-2"})(["flex:1;"]),TX=(0,$d.s)(QU.a)(wX||(wX=(0,wc.A)(["pt-0"]))),_X=(0,u.default)(m.g).attrs({justifyBetween:!0,alignCenter:!0,gap:"gutter"}).withConfig({displayName:"CashFlow__SummaryCardsContainer",componentId:"sc-14j2gue-3"})(["@media (max-width:","px){flex-flow:row wrap;gap:",";margin:"," 0 ",";> [data-sc-tw~='CashFlow__StatisticCardGrow']{flex-basis:33%;}}@media (max-width:","px){> [data-sc-tw~='CashFlow__StatisticCardGrow']{flex-basis:50%;}}"],vt.nm.md,vt.YK.small,vt.YK.gutter,vt.YK.small,vt.nm.xs),DX=(0,u.default)(m.g).attrs({justifyBetween:!0,alignCenter:!0}).withConfig({displayName:"CashFlow__DateViewContainer",componentId:"sc-14j2gue-4"})(["@media (max-width:","px){margin-top:",";margin-bottom:-",";}"],vt.nm.md,vt.YK.small,vt.YK.small),RX=e=>{let t=e.categoryId,n=e.startMonth,l=e.onCancel,r=e.onCompleted;const s=(0,i.n)(LX,{variables:{input:{categoryId:t,startMonth:n}},onCompleted:r}),c=(0,o.A)(s,2),d=c[0],u=c[1].loading;return a.createElement(xC.$,{"data-external-id":"reset-rollover-confirmation",title:"Are you sure?",confirm:"Yes, I'm sure",onConfirm:d,onCancel:l,isLoading:u},a.createElement(MX,null,"Resetting the rollover for a category will change the rollover balance to $0 for"," ",(0,Ba.Rc)(n),"."))},MX=u.default.div.withConfig({displayName:"ResetRolloverConfirmation__ConfirmationBody",componentId:"au2x14-0"})([""]),LX=Ee.CbT;var OX=n(8743),PX=n(18629),BX=n(10967);const zX=(e,t)=>(null!==e&&void 0!==e?e:0)+(null!==t&&void 0!==t?t:0),FX=(e,t)=>{const n=null!==e&&void 0!==e?e:0,a=Math.round(n);return t===Ee.wNk.INCOME||"savings"===t||"debt_paydown"===t?Math.max(0,a):a},GX=(e,t)=>(0,r.YW)(e).with(0,r.P.nullish,(()=>t.color.grayDark)).when((e=>e>0),(()=>t.color.green)).otherwise((()=>t.color.red)),YX=(e,t)=>0!==t?e*t<0?t>0?0:1:e/t:0,UX=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};var t,n;const a=WX(e)?e.remaining:e.available;return(0,Tr.A)(a)?a:(null!==(t=e.budgeted)&&void 0!==t?t:0)-(null!==(n=e.actual)&&void 0!==n?n:0)},VX=(e,t)=>((e,t)=>e<0&&t===Ee.wNk.EXPENSE?"red":"green")(Math.round(UX(e)),"savings"===t||"debt_paydown"===t?Ee.wNk.INCOME:t),WX=e=>!!e&&"remaining"in e,jX=e=>{let t=e.budgeted,n=e.actual,a=e.rollover;const l=null!==a&&void 0!==a?a:0,r=(null!==n&&void 0!==n?n:0)-Math.min(l,0),o=(null!==t&&void 0!==t?t:0)+Math.max(l,0);return r<=0?0:o<=0?1:Math.min(1,r/o)},HX=(e,t)=>e===Ee.wNk.INCOME&&Math.round(t)<0,KX=(e,t)=>e?"Over plan":t?"Remaining to rollover":"Remaining",qX=e=>{let t=e.categoryId,n=e.categoryType,l=e.data,r=e.onResetRollover,i=e.loading,s=e.isCategoryGroup,c=e.className,d=e.rolloverStartingBalance,u=e.groupLevelBudgetingEnabled,m=e.rootProps;const g=null!==l&&void 0!==l?l:{},h=g.month,v=g.previousMonthRolloverAmount,f=g.plannedAmount,E=g.actualAmount,y=g.remainingAmount,b=g.rolloverType,x=(0,Tr.A)(b),w=HX(n,null!==y&&void 0!==y?y:0),C=(0,Pd.h)(),A=(0,o.A)(C,2),I=A[0],k=A[1],S=k.open,T=k.close;return a.createElement(RP.x,Object.assign({"data-external-id":"category-plan-summary-card",className:c},m),a.createElement(RP.x.Header,null,a.createElement("div",{className:"flex flex-col"},a.createElement(RP.x.Title,null,"Budget"),h&&!i&&a.createElement(RP.x.Description,null,N.c9.fromISO(h).toFormat("MMMM y")))),i?a.createElement(RP.x.Content,null,a.createElement("div",{className:"flex items-center justify-center p-xl"},a.createElement(p.i,null))):a.createElement(RP.x.Content,null,a.createElement(OX.L.Root,{orientation:"horizontal"},x&&(!s||u)&&a.createElement(a.Fragment,null,a.createElement($X,{label:"Starting balance",value:a.createElement(Yl.t,{roun
1d:!0,emphasis:!0,type:"income",value:null!==d&&void 0!==d?d:0})}),a.createElement($X,{label:"Rolled over last month",value:a.createElement(Yl.t,{round:!0,emphasis:!0,type:"income",value:null!==v&&void 0!==v?v:0})})),a.createElement($X,{label:"Planned",sensitive:!0,value:(0,BY.A)(f)?"-":a.createElement(PX.P,{style:"currency",value:f,precision:0})}),a.createElement($X,{label:"Actual",sensitive:!0,value:(0,BY.A)(E)?"-":a.createElement(PX.P,{style:"currency",value:E,precision:0})}),a.createElement($X,{label:KX(w,x),value:a.createElement(Yl.t,{round:!0,emphasis:!0,type:"income",value:w?Math.abs(null!==y&&void 0!==y?y:0):null!==y&&void 0!==y?y:0})}))),!i&&!s&&x&&!!h&&a.createElement(a.Fragment,null,a.createElement(RP.x.Footer,{className:"justify-center"},a.createElement(Wb.X,{variant:"text",colorScheme:"link",onClick:S,disabled:!v},"Reset Rollover")),a.createElement(I,null,a.createElement(RX,{categoryId:t,startMonth:h,onCancel:T,onCompleted:()=>{T(),null===r||void 0===r||r()}}))))},$X=e=>{let t=e.label,n=e.value,l=e.sensitive;return a.createElement(OX.L.Item,{"data-external-id":"summary-row"},a.createElement(OX.L.ItemLabel,null,t),a.createElement(OX.L.ItemValue,{className:l?fl.TN.className:void 0},n))};qX.fragments={CategoryPlanSummaryFields:Ee.nsk};var ZX=n(58387),JX=n(4858),XX=n(18850);const QX=parseInt(yD.w.spacing.default,10),eQ=e=>{let t=e.data,n=e.onBarClick,l=e.dataLabel,r=e.displayAsExpense,i=e.showLoader,s=e.timeframe,c=e.activeDate;const d=(0,qd.W)(),m=(0,o.A)(d,2),g=m[0],h=m[1].width,v=void 0===h?0:h,f=(0,xy.d)(v,150)||v,E=(0,u.useTheme)(),y=(0,a.useCallback)((e=>{let t=e.startDate;return n(t)}),[n]),b=(0,a.useMemo)((()=>"year"!==s?(0,EJ.uu)(t):[]),[t,s]),x=(0,EJ.Rt)(t,c),w=(0,a.useCallback)((e=>{var t;return null!==(t=(0,wW.yP)({startDate:e,endDate:N.c9.fromISO(e).endOf(s).toISODate()}))&&void 0!==t?t:e}),[s]),C=(0,a.useMemo)((()=>{const e=e=>r?e>0:e<0;return a.createElement(PU.vD,{activeBarIndex:x,barColorInteractive:!0,data:t,barDataKeys:[{name:"sum",color:t=>{let n=t.amount;return e(n)?E.color.red:E.color.green}}],xAxisDataKey:"startDate",heightPx:275,widthPx:f,formatXAxis:(0,xW.B)(s),formatYAxis:rl._L,onBarAreaClick:y,xAxisReferenceLines:b,tooltipComponent:t=>{const n=t.active,o=(0,_a.WS)(t);if(!o)return null;const i=o.startDate,s=o.sum;return a.createElement(Sa.II,{active:n,header:w(i)},a.createElement(Na.B,{label:l,value:a.createElement(Yl.t,{value:r?-1*s:s,type:r?"expense":"income",round:!0}),dotFillColor:(c=s,0===c?E.color.gray:e(c)?E.color.red:E.color.green)}));var c}})}),[x,t,l,f,r,w,y,E,s,b]);if(i)return a.createElement(tQ,{"data-external-id":"transaction-attribute-bar-chart",ref:g},a.createElement(nQ,{center:!0},a.createElement(p.i,null)));return t.every((e=>0===e.count))?a.createElement(tQ,{"data-external-id":"transaction-attribute-bar-chart",ref:g},a.createElement(nQ,{center:!0},a.createElement(cU.vx,{emptyTheme:cU.dO.OLD,title:"No data for ".concat(l,".")}))):a.createElement(tQ,{"data-external-id":"transaction-attribute-bar-chart",ref:g},C)},tQ=(0,u.default)(Xl.AM).withConfig({displayName:"TransactionAttributeBarChart__Root",componentId:"beiw82-0"})(["contain:size layout;min-height:","px;padding:0px ","px ","px;"],275+QX,QX,QX),nQ=(0,u.default)(ZY.B).withConfig({displayName:"TransactionAttributeBarChart__StyledEmpty",componentId:"beiw82-1"})(["margin:0px ",";height:","px;"],vt.YK.default,275),aQ=e=>{let t=e.goal;return a.createElement(lQ,{"data-external-id":"goal-filter-image"},a.createElement(rQ,{imageStorageProvider:null===t||void 0===t?void 0:t.imageStorageProvider,imageStorageProviderId:null===t||void 0===t?void 0:t.imageStorageProviderId,showGradient:!1}))},lQ=u.default.div.withConfig({displayName:"GoalFilterImage__GoalImageContainer",componentId:"sc-1t7kxmp-0"})(["position:relative;width:","px;height:","px;border-radius:",";margin-right:",";"],16,16,(e=>e.theme.radius.xxsmall),vt.YK.xxsmall),rQ=(0,u.default)(vl.b).attrs({size:"small"}).withConfig({displayName:"GoalFilterImage__StyledGoalImage",componentId:"sc-1t7kxmp-1"})(["border-radius:",";"],(e=>e.theme.radius.xxsmall));var oQ=n(56573);const iQ=e=>{let t=e.savingsGoal;return a.createElement(sQ,{"data-external-id":"savings-goal-filter-image"},a.createElement(cQ,{imageStorageProvider:null===t||void 0===t?void 0:t.imageStorageProvider,imageStorageProviderId:null===t||void 0===t?void 0:t.imageStorageProviderId}))},sQ=u.default.div.withConfig({displayName:"SavingsGoalFilterImage__SavingsGoalImageContainer",componentId:"nopwg-0"})(["position:relative;width:","px;height:","px;margin-right:",";"],16,16,vt.YK.xxsmall),cQ=(0,u.default)(oQ.s).attrs({size:"small"}).withConfig({displayName:"SavingsGoalFilterImage__StyledSavingsGoalImage",componentId:"nopwg-1"})(["border-radius:",";"],vt.r8.xxsmall);var dQ=n(85307),uQ=n(93356),mQ=n(52729),pQ=n(35364);const gQ=(e,t,n)=>{var a,l;if(!e)return[];const r=n||{},o=r.renderAccountLogo,i=r.renderMerchantAccessory,s=r.renderTag,c=r.renderMerchantLogo,d=r.renderGoalImage,u=r.render
1SavingsGoalImage,m=r.renderOwnership,p=r.householdUsers,g=void 0===p?[]:p,h=e.categoryGroups,v=void 0===h?[]:h,f=e.merchants,E=void 0===f?[]:f,y=e.accounts,b=void 0===y?[]:y,x=e.householdTransactionTags,w=void 0===x?[]:x,C=e.householdPreferences,A=e.goalsV2,I=void 0===A?[]:A,k=e.savingsGoals,S=void 0===k?[]:k,N=(0,LD.A)((0,nj.A)("",["type","display"]),b),T=Object.keys(N),_=C||{},D=_.accountGroupOrder,R=!!_.collaborationToolsEnabled,M=D&&D.length>0?[...D.filter((e=>N[e])),...T.filter((e=>!D.includes(e)))]:T,L=(0,tj._E)(t);return[hj(v,t),{id:sj.Lp.merchants,name:"Merchants",hideSelectAll:!0,options:E.map((e=>({id:e.id,name:e.name,isSelected:(0,tj.co)(null===t||void 0===t?void 0:t.merchants)(e.id),accessory:null===i||void 0===i?void 0:i(e),icon:null===c||void 0===c?void 0:c(e)})))},{id:sj.Lp.accounts,name:"Accounts",options:M.map((e=>({id:e,name:e,options:N[e].map((e=>({id:e.id,name:(0,nj.A)("",["displayName"],e),isSelected:(0,tj.co)(null===t||void 0===t?void 0:t.accounts)(e.id),icon:null===o||void 0===o?void 0:o(e)})))})))},{id:sj.Lp.tags,name:"Tags",options:[{id:sj.TM,name:"Untagged",isSelected:null===t||void 0===t?void 0:t.isUntagged},...(0,tj.I5)(w).map((e=>({id:e.id,name:e.name,color:e.color,isSelected:(0,tj.co)(null===t||void 0===t?void 0:t.tags)(e.id),icon:null===s||void 0===s?void 0:s(e)})))]},..."v3"===(null===n||void 0===n?void 0:n.preferredGoalsVersion)?[{id:sj.Lp.savingsGoals,name:"Goals",options:(0,pQ.U4)(S).map((e=>({id:e.id,name:e.name,icon:null===u||void 0===u?void 0:u(e),isSelected:(0,tj.co)(null===t||void 0===t?void 0:t.savingsGoals)(e.id)})))}]:[{id:sj.Lp.goals,name:"Goals",options:(0,yl.Zk)(I).map((e=>({id:e.id,name:e.name,icon:null===d||void 0===d?void 0:d(e),isSelected:(0,tj.co)(null===t||void 0===t?void 0:t.goals)(e.id)})))}],...R?[{id:sj.Lp.ownership,name:"Owners",options:[{id:bd.u,name:bd.H,isSelected:null!==(a=null===t||void 0===t||null===(l=t.ownershipSet)||void 0===l?void 0:l.includeJointlyOwned)&&void 0!==a&&a,icon:null===m||void 0===m?void 0:m()},...(g||[]).map((e=>{var n;return{id:e.id,name:e.displayName,isSelected:(0,tj.co)(null===t||void 0===t||null===(n=t.ownershipSet)||void 0===n?void 0:n.userIds)(e.id),icon:null===m||void 0===m?void 0:m(e)}}))]}]:[]].concat((e=>({id:sj.Lp.amount,name:"Amount",validate:e=>{let t=[];return e.between&&((0,rj.A)(oj.A,[e.between.min,e.between.max])&&(t=t.concat("Please enter a minimum and maximum amount")),e.between.min&&e.between.max&&e.between.min>e.between.max&&(t=t.concat("Minimum amount must be less than maximum amount"))),t},options:[{id:"amount",name:"Amount",type:"radio",options:(0,tj.rs)(e)},{id:"type",name:"Type",type:"radio",options:[{id:"debitsOnly",name:"Debits only",isSelected:null===e||void 0===e?void 0:e.debitsOnly},{id:"creditsOnly",name:"Credits only",isSelected:null===e||void 0===e?void 0:e.creditsOnly}]}]}))(t)).concat(((e,t,n)=>{const a=null===n||void 0===n?void 0:n.isDeletedTransactionsFilterEnabled;return{id:sj.Lp.other,name:"Other",options:[dj(null===n||void 0===n?void 0:n.householdUsers,t),e({label:"Recurring",filterPath:["isRecurring"]}),e({label:"Has Attachments",negativeOptionLabel:"No attachments",filterPath:["hasAttachments"]}),e({label:"Split",negativeOptionLabel:"Not split",filterPath:["isSplit"]}),e({label:"Notes",optionLabel:"Has notes",negativeOptionLabel:"No notes",filterPath:["hasNotes"]}),e({label:"Syncing",optionLabel:"Synced from institution",filterPath:["syncedFromInstitution"]}),e({label:"Investments",optionLabel:"In an investment account",filterPath:["isInvestmentAccount"]}),e({label:"Imported from CSV",filterPath:["importedFromMint"],hide:!(null!==n&&void 0!==n&&n.hasTransactionsImportedFromMint),optionLabel:"Imported from CSV"}),e({label:"Pending",filterPath:["isPending"]}),uj(t),mj(t,a)].filter(Boolean)}})(L,t,n))},hQ=e=>e.reduce(((e,t)=>{const n=(0,DJ.A)(["path",0],t);if(!n)return console.warn("No type found for filter option",t),e;if("amount"===n)return(0,U.A)((0,U.A)({},e),(0,tj.d)(t));if("tags"===n){const a=(0,nj.A)([],[n],e);return(0,U.A)((0,U.A)({},e),(0,tj.OX)(t,a))}if("ownership"===n){const n=e.ownershipSet||{includeJointlyOwned:!1,userIds:[]};if(t.id===bd.u)return(0,U.A)((0,U.A)({},e),{},{ownershipSet:(0,U.A)((0,U.A)({},n),{},{includeJointlyOwned:!0})});
1{const a=n.userIds||[];return(0,U.A)((0,U.A)({},e),{},{ownershipSet:(0,U.A)((0,U.A)({},n),{},{userIds:[...a,t.id]})})}}if("other"===n)return(0,U.A)((0,U.A)({},e),(0,tj.jV)(t));const a=(0,nj.A)([],[n],e);return(0,Fj.A)([n],[...a,t.id],e)}),{});var vQ=n(93534);const fQ=e=>{var t,n;const l=e.page,r=e.onApplyFilters,i=e.filters,s=e.hiddenSectionIds,c=e.renderAccountLogo,d=e.renderGoalImage,u=e.renderSavingsGoalImage,m=e.renderMerchantAccessory,p=e.renderTag,g=e.renderMerchantLogo,h=e.renderOwnership,v=(0,a.useState)(!1),f=(0,o.A)(v,2),E=f[0],y=f[1],b=(0,et.I)(EQ,{variables:{search:void 0,includeIds:i.merchants}}),x=b.data,w=b.isLoadingInitialData,C=b.fetchMore,A=(0,vQ.N)().preferredVersion,I=(0,a.useCallback)((e=>{if(!(0,LV.A)(e))return y(!0),C({variables:{search:e},updateQuery:(e,t)=>{let n=t.fetchMoreResult;return(0,Ru.A)({merchants:(0,mQ.BI)(n.merchants)},e)}}).then((()=>y(!1)))}),[C]),k=(0,uQ.p)(yQ,{cacheExpiration:N.dw.fromObject({minutes:5})}).data,S=(0,dQ.A)((function(){return(arguments.length>0&&void 0!==arguments[0]?arguments[0]:0)>0}),["allMintTransactions","totalCount"],k),T=null!==(t=null===x||void 0===x||null===(n=x.myHousehold)||void 0===n?void 0:n.users)&&void 0!==t?t:[],_=(0,nG.p)("feat-deleted-transactions-filter","off"),D=Ij({data:x,filters:i,getFilterSectionsFromQuery:(e,t,n)=>gQ(e,t,(0,U.A)((0,U.A)({},n),{},{hasTransactionsImportedFromMint:S,householdUsers:T,renderAccountLogo:c,renderMerchantAccessory:m,renderMerchantLogo:g,renderTag:p,renderGoalImage:d,renderSavingsGoalImage:u,renderOwnership:h,isDeletedTransactionsFilterEnabled:_,preferredGoalsVersion:A})).filter((e=>{let t=e.id;return!(null!==s&&void 0!==s&&s.some((e=>e===t)))})),onApplyFilters:(e,t)=>{r(e),t&&gj(l,t)},adaptSelectedOptionsToFilters:hQ});return{sections:D.sections,isLoading:w,isFetchingMoreData:E,onChangeSections:D.onChangeSections,onSearchChange:I,resetUnappliedChanges:D.resetUnappliedChanges,handleApply:D.handleApply}},EQ=Ee.qLv,yQ=Ee.fk_,bQ=e=>{let t=e.page,n=e.filters,l=e.hiddenSectionIds,r=e.onApplyFilters,o=e.onClickCancel;const i=fQ({page:t,filters:n,hiddenSectionIds:l,onApplyFilters:r,renderAccountLogo:e=>a.createElement(Gl.v,{logoUrl:e.logoUrl,icon:e.icon,size:14,className:"mr-2xs"}),renderMerchantLogo:e=>a.createElement(Wl._,{url:e.logoUrl,size:14,className:"mr-2xs"}),renderMerchantAccessory:e=>e.transactionCount&&a.createElement("span",{className:"flex items-center gap-2xs text-sm font-book text-content-secondary"},a.createElement(fe.$OE,{size:12}),(0,De.LN)(e.transactionCount)),renderTag:e=>a.createElement(Ta.c,{color:e.color,size:10,className:"mr-2xs"}),renderGoalImage:e=>a.createElement(aQ,{goal:e}),renderSavingsGoalImage:e=>a.createElement(iQ,{savingsGoal:e}),renderOwnership:e=>a.createElement(Pw.n,{userId:null===e||void 0===e?void 0:e.id,userName:null===e||void 0===e?void 0:e.displayName,userProfilePictureUrl:null===e||void 0===e?void 0:e.profilePictureUrl,avatarSize:14,showLabel:!1,className:"mr-2xs"})}),s=i.sections,c=i.isLoading,d=i.isFetchingMoreData,u=i.onChangeSections,m=i.handleApply,p=i.onSearchChange;return a.createElement(xH,{"data-external-id":"transaction-filter-menu",isLoading:c,onClickApply:m,onClickCancel:o,sections:s,onChange:u,onSearchChange:p,isSearchLoading:d})},xQ=e=>{let t=e.page,n=e.filters,l=e.hiddenSectionIds,r=e.showIndicator,i=e.onApplyFilters;const s=(0,a.useState)(!1),c=(0,o.A)(s,2),d=c[0],u=c[1];return a.createElement(fe.k_P.Root,{"data-external-id":"transaction-filter-menu-button",open:d,onOpenChange:u,size:"2xl"},a.createElement(fe.qN2,{show:r},a.createElement(fe.k_P.Trigger,{render:a.createElement(fe.XZZ,{icon:a.createElement(fe.evG,null),variant:"default"},"Filters")})),a.createElement(fe.k_P.Content,{side:"bottom",align:"end",className:"p-0"},a.createElement(bQ,{page:t,filters:n,hiddenSectionIds:l,onClickCancel:()=>u(!1),onApplyFilters:e=>{i(e),u(!1)}})))},wQ="1970-01-01",CQ=[{value:"day",label:"Daily"},{value:"week",label:"Weekly"},{value:"month",label:"Monthly"},{value:"quarter",label:"Quarterly"},{value:"year",label:"Yearly"}],AQ=e=>{var t;let n=e.analyticsPage,l=e.filters,r=e.timeframe,o=e.onChangeTimeframe,i=e.onApplyFilters,s=e.onCh
1angeBusinessEntitySet,c=e.showBusinessEntityFilter,d=e.hiddenFilterKeys,u=void 0===d?[]:d,m=e.extraControls;const p=(0,a.useMemo)((()=>(0,oX.MX)(u)),[u]),g=(0,a.useMemo)((()=>(0,oX.iy)(u)),[u]),h=(0,a.useMemo)((()=>{const e=(0,tj.p8)(l.absAmountLte,l.absAmountGte);return e?(0,U.A)((0,U.A)({},l),{},{amountFilter:e}):l}),[l]),v=(0,CX.UN)((0,XX.A)(["businessEntitySet",...g],h));return a.createElement("div",{"data-external-id":"transaction-attribute-detail-controls",className:"flex items-center justify-end"},a.createElement("div",{className:"flex items-center"},a.createElement(hP.T,{variant:"pill",fitContent:!0,value:r,onValueChange:e=>o(e),items:CQ}),(0,Tr.A)(m)&&a.createElement("div",{className:"ml-default flex items-center gap-default"},m),c&&a.createElement("div",{className:"ml-default flex items-center"},a.createElement(OH.O,{businessEntitySet:null!==(t=l.businessEntitySet)&&void 0!==t?t:void 0,onChangeBusinessEntitySet:s,source:Ye.rP.CashFlow})),a.createElement("div",{className:"ml-default flex items-center"},a.createElement(xQ,{page:n,filters:h,hiddenSectionIds:p,showIndicator:v,onApplyFilters:i}))))};var IQ=n(41708),kQ=n(10070),SQ=n(71525),NQ=n(25635);const TQ=e=>{let t=e.title,n=void 0===t?"Summary":t,l=e.controls,r=e.footer,o=e.footerClassName,i=e.children;return a.createElement(RP.x,{"data-external-id":"summary-card"},a.createElement(RP.x.Header,null,a.createElement(RP.x.Title,null,n),l&&a.createElement(RP.x.Action,null,l)),a.createElement(RP.x.Content,{className:"gap-default"},i),r&&a.createElement(RP.x.Footer,{className:o},r))};TQ.Rows=e=>{let t=e.children;return a.createElement(OX.L.Root,{"data-external-id":"summary-card-rows",orientation:"horizontal",className:"gap-default"},t)},TQ.Row=e=>{let t=e.label,n=e.children;return a.createElement(OX.L.Item,{"data-external-id":"summary-card-row",className:"items-center gap-default"},a.createElement(OX.L.ItemLabel,{className:"text-sm"},t),a.createElement(OX.L.ItemValue,null,n))},TQ.SkeletonRow=e=>{let t=e.className;return a.createElement(OX.L.Item,{"data-external-id":"summary-card-skeleton-row",className:(0,q.cn)("items-center gap-default",t)},a.createElement(NQ.w,{className:"h-6 w-3/4"}),a.createElement(NQ.w,{className:"h-6 w-1/4"}))};var _Q=n(75164),DQ=n(2751),RQ=n(82813);const MQ=e=>{const t=(0,Xo.IT)(LQ,{variables:{input:e}}).data;return{transactionFiltersMetadata:null===t||void 0===t?void 0:t.transactionFiltersMetadata}},LQ=Ee.xsq,OQ=e=>{var t;if(!e)return null;const n=null!==(t=e.businessEntities)&&void 0!==t?t:[];return 0!==n.length||e.includeUnassigned?"Business entities: ".concat(YQ(n,(e=>e.name),e.includeUnassigned?[_j.qq]:void 0)):null},PQ=function(e,t,n,a){let l=!(arguments.length>4&&void 0!==arguments[4])||arguments[4];return e&&0!==e.length?l&&t&&t===e.length?null:"".concat(n,": ").concat(YQ(e,a)):null},BQ=(e,t,n)=>{var a;const l=null!==(a=null===e||void 0===e?void 0:e.length)&&void 0!==a?a:0;return l===t&&l>0&&n||0===l?null:"Tags: ".concat(YQ(null!==e&&void 0!==e?e:[],(e=>e.name)))},zQ=(e,t)=>{var n,a,l;if(!e)return null;const r=null!==(n=null===(a=e.users)||void 0===a?void 0:a.length)&&void 0!==n?n:0;return r===t&&r>0&&e.includeJointlyOwned?null:0!==r||e.includeJointlyOwned?"Owners: ".concat(YQ(null!==(l=e.users)&&void 0!==l?l:[],(e=>e.displayName),e.includeJointlyOwned?["Shared"]:void 0)):null},FQ=(e,t)=>(0,BY.A)(e)&&(0,BY.A)(t)?null:(0,BY.A)(e)||(0,BY.A)(t)?(0,BY.A)(e)?"Amount: < ".concat((0,jt.is)(t)):"Amount: > ".concat((0,jt.is)(e)):e===t?"Amount: ".concat((0,jt.is)(e)):"Amount: ".concat((0,jt.is)(e)," to ").concat((0,jt.is)(t)),GQ=(e,t,n)=>(0,BY.A)(e)?null:e?t:n,YQ=(e,t,n)=>{var a;const l=5-(null!==(a=null===n||void 0===n?void 0:n.length)&&void 0!==a?a:0),r=e.slice(0,l),o=[...null!==n&&void 0!==n?n:[],...r.map(t)],i=e.length-r.length,s=i>0?" (and ".concat(i," more)"):"";return o.join(", ")+s},UQ="Understand how your money is moving (trends, recurring activity, and outliers) without reviewing every transaction",VQ=e=>{let t=e.filters,n=e.dateRangeText;const l=(0,a.useMemo)((()=>(0,CX.WD)((0,TV.A)(t,CX.q9))),[t]),r=MQ(l).transactionFiltersMetadata,o=(0,et.I)(EQ,{variables:{search:void 0,includeIds:l.merchants}}).data,i=(0,a.useMemo)((()=>((e,t,n)=>{var a,l,r,o,i,s,c,d,u,m,p,g,h,v,f,E;const y=(null!==(a=null===n||void 0===n?void 0:n.categoryGroups)&&void 0!==a?a:[]).reduce(((e,t)=>{var n,a;return e+(null!==(n=null===(a=t.categories)||void 0===a?void 0:a.length)&&void 0!==n?n:0)}),0),b=PQ(null===t||void 0===t?void 0:t.categories,y,"Categories",(e=>"".concat(e.icon," ").concat(e.name))),x=PQ(null===t||void 0===t?void 0:t.categoryGroups,null===n||void 0===n||null===(l=n.categoryGroups)||void 0===l?void 0:l.length,"Category groups",(e=>e.name)),w=PQ(null===t||void 0===t?void 0:t.merchants,null===n||void 0===n||null===(r=n.merchants)||void 0===r?void 0:r.length,"Merchants",(e=>e.name),!1),C=PQ(null===t||void 0===t?void 0:t.accounts,null===n||void 0===n||null===(o=n.accounts)||void 0===o?void 0:o.length,"Accounts",(e=>e.displayName)),A=null!==(i=null===n||void 0===n||null===(s=n.householdTransactionTags)||void 0===s?void 0:s.length)&&void 0!==i?i:0,I=null!==(c=null===t||void 0===t||null===(d=t.tags)||void 0===d?void 0:d.length)&&void 0!==c?c:0,k=!0===e.isUntagged&&I===A&&A>0,S=BQ(null===t||void 0===t?void 0:t.tags,A,null!==(u=e.isUntagged)&&void 0!==u&&u),N=PQ(null===t||void 0===t?void 0:t.goals,null!==(m=null===t||void 0===t||null===(p=t.goals)||void 0===p?void 0:p.length)&&void 0!==m?m:0,"Goals",(e=>e.name),!1),T=PQ(null===t||void 0===t?void 0:t.savingsGoals,null!==(g=null===t||void 0===t||null===(h=t.savingsGoals)||void 0===h?void 0:h.length)&&void 0!==g?g:0,"Goals",(e=>e.name),!1),_=zQ(null===t||void 0===t?void 0:t.ownershipSet,null!==(v=null===n||void 0===n||null===(f=n.myHousehold)||void 0===f||null===(E=f.users)||void 0===E?void 0:E.length)&&void 0!==v?v:0),D=OQ(null===t||void 0===t?void 0:t.businessEntitySet),R=FQ(e.absAmountGte,e.absAmountLte),M=[e.creditsOnly&&"credits only",e.debitsOnly&&"debits only",e.isUncategorized&&"uncategorized",e.needsReview&&(null!==t&&void 0!==t&&t.needsReviewByUser?"needs review by ".concat(t.needsReviewByUser.name):"needs review"),GQ(e.isRecurring,"recurring","not recurring"),GQ(e.hasAttachments,"has attachments","no attachments"),GQ(e.isSplit,"split transactions","non-split transactions"),GQ(e.hasNotes,"has notes","no notes"),GQ(e.syncedFromInstitution,"synced from institution","not synced from institution"),GQ(e.isInvestmentAccount,"in an investment account","not in an investment account"),GQ(e.importedFromMint,"imported from CSV","not imported from CSV"),GQ(e.isPending,"pending","not pe
1nding"),e.isUntagged&&!k&&"untagged",e.transactionVisibility===Ee.h1.HIDDEN_TRANSACTIONS_ONLY&&"hidden transactions only",e.transactionVisibility===Ee.h1.ALL_TRANSACTIONS&&"hidden and not hidden transactions",e.deletedTransactionVisibility===Ee.SrA.DELETED_ONLY&&"deleted transactions only",e.deletedTransactionVisibility===Ee.SrA.ALL_INCLUDING_DELETED&&"deleted and not deleted transactions"].filter(Boolean),L=[x,b,w,C,S,R,N,T,_,D,M.length>0?"Other: ".concat(M.join(", ")):null].filter(Boolean);return L.length>0?"\n\u2022 ".concat(L.join("\n\u2022 ")):""})(l,r,o)),[l,r,o]),s=n||(e=>{const t=null!==e&&void 0!==e?e:{},n=t.startDate,a=t.endDate,l=t.timeframePeriod;if(n&&a)return"from ".concat((0,Ba.AO)(n)," to ").concat((0,Ba.AO)(a));if(n)return"since ".concat((0,Ba.AO)(n));if(a)return"up to ".concat((0,Ba.AO)(a));if(null!==l&&void 0!==l&&l.unit&&null!==(null===l||void 0===l?void 0:l.value)&&void 0!==(null===l||void 0===l?void 0:l.value)){const e=String(l.unit).toLowerCase(),t=l.value;return 1===t?"over the last ".concat(e):"over the last ".concat(t," ").concat(e,"s")}return""})(t);return i?"Provide insights about my transactions:".concat(s?"\n\u2022 Dates: ".concat(s):"").concat(i):"Provide insights about my transactions".concat(s?" ".concat(s):"")};var WQ=n(17837),jQ=n(79223),HQ=n(7156);const KQ=e=>{var t;let n=e.empty,l=e.errorMessage,r=e.filters,o=e.insightsDateRangeSource,i=void 0===o?"transactions":o,s=e.insightsSource,c=void 0===s?Ye.rP.TransactionsPage:s,d=e.isDownloadingCsv,u=e.showFirstAndLast,m=void 0===u||u,p=e.transactionsSummary,g=e.isLoading,h=e.onClickDownloadCsv,v=e.onChangeFilters;const f=(0,a.useMemo)((()=>(0,CX.WD)((0,TV.A)(r,CX.q9))),[r]),E=(0,et.I)(JQ,{variables:{filters:f}}),y=E.data,b=E.isLoadingInitialData,x=E.error,w=g||b,C=null!==(t=null===y||void 0===y?void 0:y.allTransactions.totalCount)&&void 0!==t?t:0,A=null!==p&&void 0!==p?p:{},I=A.max,k=A.maxExpense,S=A.avg,N=A.sumIncome,T=void 0===N?0:N,_=A.sumExpense,D=void 0===_?0:_,R=A.first,M=A.last,L=VQ({filters:r,dateRangeText:"transactions"===i?(()=>{const e=R?(0,Ba.AO)(R):void 0,t=M?(0,Ba.AO)(M):void 0;return e&&t?"from ".concat(e," to ").concat(t):e?"since ".concat(e):t?"up to ".concat(t):""})():void 0}),O=C>0,P=e=>{v((0,U.A)((0,U.A)({},r),{},{absAmountGte:e,absAmountLte:e,amountFilter:CX.iz}))},B=a.createElement(HK,{insightTheme:"TRANSACTIONS",content:L,tooltipPlacement:"bottom",tooltipDescription:UQ,source:c,isLoading:w});return w?a.createElement(TQ,{"data-external-id":"transactions-summary-card",controls:B,footer:a.createElement(NQ.w,{className:"h-5 w-full"})},a.createElement(TQ.Rows,null,(0,db.A)(0,5).map((e=>a.createElement(TQ.SkeletonRow,{key:e}))))):x?a.createElement(TQ,{"data-external-id":"transactions-summary-card",controls:B},a.createElement(SQ.W,{message:VG.U.TRANSACTION_SUMMARY})):O?a.createElement(TQ,{"data-external-id":"transactions-summary-card",controls:B,footerClassName:"justify-center",footer:h&&a.createElement(DQ.s,{feature:HQ.W1.DOWNLOAD_CSV,side:"left",align:"end"},(e=>{let t=e.hasAccess;return a.createElement("div",{className:"flex flex-col items-center"},l&&a.createElement(fu.g,{type:"error",className:"my-sm block"},l),a.createElement(OK,{isLoading:d,onClick:t?h:RQ.l},"Download CSV"),!t&&a.createElement(_Q.J,null))}))},a.createElement(TQ.Rows,null,a.createElement(ZQ,{text:"Total transactions",value:(0,De.LN)(C)}),!!I&&a.createElement($Q,{text:"Largest transaction",value:I,onClick:()=>P(I)}),!!k&&a.createElement($Q,{text:"Largest expense",value:k,onClick:()=>P(k)}),!!S&&a.createElement($Q,{text:"Average transaction",value:S}),T>0&&a.createElement($Q,{text:"Total income",value:T}),a.createElement($Q,{text:"Total spending",value:D}),m&&!!R&&a.createElement(ZQ,{text:"First transaction",value:(0,Ba.AO)(R)}),m&&!!M&&a.createElement(ZQ,{text:"Last transaction",value:(0,Ba.AO)(M)}))):a.createElement(TQ,{"data-external-id":"transactions-summary-card",controls:B},n)},qQ=e=>{let t=e.value,n=e.onClick;const l=t>0&&!(0,WQ.K)(),r=(0,jQ.s_)(t);return a.createElement(kD.c,{"data-external-id":"amount-value",color:l?"success":"primary",weight:l?"medium":"book",className:fl.zs.className},n?a.createElement(cl.M,{stealthy:!0,onClick:n},r):r)},$Q=e=>{let t=e.text,n=e.value,l=e.onClick;return a.createElement(TQ.Row,{"data-external-id":"transactions-summary-card-amount-row",label:t},a.createElement(qQ,{value:n,onClick:l}))},ZQ=e=>{let t=e.text,n=e.value;return a.createElement(TQ.Row,{"data-external-id":"transactions-summary-card-row",label:t},a.createElement(kD.c,null,n))},JQ=Ee.Mqv;KQ.fragments={TransactionsSummaryFields:Ee.vZi};var XQ,QQ=n(93021),e0=n(31808),t0=n(38958);const n0=["title","attributeFilter","attributeType","displayAsExpense","extraControls","additionalSummaryElement"],a0={day:"byDay",week:"byWeek",month:"byMonth",quarter:"byQuarter",year:"byYear"},l0=e=>{var t,n,r,i,s;let c=e.title,d=e.attributeFilter,u=e.attributeType,m=e.displayAsExpense,p=e.extraControls,g=e.additionalSummaryElement,h=(0,En.A)(e,n0);const v=c.substring(0,80)===c?c:"".concat(c.substring(0,80),"..."),f=(0,l.zy)().pathname,E=(0,b.ii)(),y=(0,o.A)(E,2),x=y[0],w=y[1],C="string"===typeof x.timeframe?x.timeframe:void 0,A="string"===typeof x.date?x.date:void 0,I=(0,t0.Tl)(),k=I.orderBy,S=I.setOrderBy,T=CQ.some((e=>e.value===C))?C:vW.xh,_=A?N.c9.fromISO(A).startOf(T).toISODate():void 0,D=(0,a.useCallback)((e=>{let t=e.queryParams;return tp.A.stringifyUrl({url:f,query:(0,JX.A)(BY.A,(0,U.A)({date:A,timeframe:C},t))})}),[f,A,C]),R=(0,e0.R7)({includeFalsyValues:!0,getRoute:D}),M=(0,o.A)(R,2),L=M[0],O=M[1],P=(0,a.useMemo)((()=>Object.keys(d).filter((e=>!(0,BY.A)(d[e])))),[d]),B=(0,a.useMemo)((()=>[...oX.wb,...(0,oX.iy)(P)]),[P]),z=(0,a.useMemo)((()=>(0,XX.A)(B,L)),[B,L]);xX((0,_J.V)(null!==(t=z.businessEntitySet)&&void 0!==t?t:void 0),(e=>w({businessEntitySet:e})));const F=(0,qG.e)().hasAccess,G=(0,Tj.Rq)(),Y=G.businessEntities,V=G.isLoadingInitialData,W=F&&(V||Y.length>0),j=(0,a.useMemo)((()=>_?{startDate:_,endDate:N.c9.fromISO(_).endOf(T).toISODate()}:{}),[_,T]),H=(0,a.useMemo)((()=>(0,wW.yP)(j)),[j]),K=(0,a.useMemo)((()=>(0,oX.fE)(z,d)),[z,d]),q=(0,a.useMemo)((()=>(0,CX.WD)(K)),[K]),$=(0,a.useMemo)((()=>(0,U.A)((0,U.A)({},K),j)),[K,j]),Z=(0,a.useMemo)((()=>(0,CX.WD)($)),[$]),J=(0,QQ.j)({filters:$}),X=J.currentSession,Q=J.downloadTransactions,ee=J.isLoading,te=(0,et.I)(o0,{variables:{summaryFilters:Z,timeframeGroupedFilters:q,includeDay:"day"===T,includeWeek:"week"===T,includeMonth:"month"===T,includeQuarter:"quarter"===T,includeYear:"year"===T}}
1),ne=te.data,ae=te.isLoadingInitialData,le=te.isNetworkRequestInFlight,re=te.refetch,oe=null!==(n=null===ne||void 0===ne?void 0:ne[a0[T]])&&void 0!==n?n:[],ie=le&&0===oe.length,se=null===ne||void 0===ne||null===(r=ne.summary[0])||void 0===r?void 0:r.summary,ce=(0,a.useCallback)((e=>O((0,XX.A)(B,e))),[B,O]),de=(e=>e.reduce(((e,t)=>e+t.summary.sum),0)>0?"income":"expense")(oe),ue="expense"===de,me=LJ({[a0[T]]:oe},T,((e,t)=>((e,t,n)=>{var a;const l=(0,DJ.A)([e],t.groupBy);if(!l)throw new Error("Missing start date");const r=null!==(a=t.summary)&&void 0!==a?a:{},o=r.sum;return{startDate:l,sum:n?-(null!==o&&void 0!==o?o:0):null!==o&&void 0!==o?o:0,count:r.count||0,avg:r.avg||0}})(e,t,!!m||ue))),pe=_?PJ(me,_):void 0,ge=pe?N.c9.fromISO(pe).startOf(T).toISODate():void 0,he="No transactions in this period for ".concat(c);return(0,a.useEffect)((()=>{_&&ge&&_!==ge&&w({date:ge})}),[_,ge,w]),a.createElement(rG.Y,Object.assign({"data-external-id":"transaction-attribute-detail-page",name:"Transaction Attribute Detail",parentRoute:"Cash Flow",overrideTitle:c,pageProperties:{attribute_type:u},controls:a.createElement(AQ,{analyticsPage:c,filters:z,timeframe:T,onChangeTimeframe:e=>w((0,U.A)({timeframe:e},A?{date:RJ(e,A)}:{})),onApplyFilters:e=>O((0,U.A)((0,U.A)({},e),{},{businessEntitySet:z.businessEntitySet})),onChangeBusinessEntitySet:e=>O((0,U.A)((0,U.A)({},z),{},{businessEntitySet:e})),showBusinessEntityFilter:W,hiddenFilterKeys:P,extraControls:p})},h),a.createElement(rV.T,{screenName:"Transaction Attribute Detail",tab:T,isInfiniteScroll:!0}),a.createElement(r0,{template:'"chart chart" "date date" "transactions summary" / 1fr 30%',md:'"chart" "date" "transactions" "summary"'},a.createElement(QU.E,{area:"chart"},a.createElement(eQ,{activeDateRange:j,data:me,onBarClick:e=>{w({date:pe===e?void 0:e})},dataLabel:v,showLoader:ie,displayAsExpense:!!m||ue,timeframe:T,activeDate:pe})),a.createElement(QU.E,{area:"date"},a.createElement("div",{className:"text-xl font-medium"},H||(pe?(0,wW.KC)(j):"All time"))),a.createElement(QU.E,{area:"transactions",sticky:!0},a.createElement(fe.xz6,{className:"overflow-visible"},a.createElement(kQ.j,{refetchSummary:re,transactionFilters:Z,emptyComponent:a.createElement(fe.erR,{icon:null,title:he,className:"p-3xl"}),overrideTitle:a.createElement(fe.c8D,{size:"lg",weight:"medium"},"Transactions"),allowBulkUpdate:!0,sortBy:k,onChangeSortBy:S,headerShouldHaveSortControls:!0}))),a.createElement(QU.E,{area:"summary",className:"flex flex-col gap-gutter"},pe&&g,a.createElement(KQ,{empty:a.createElement(fe.erR,{icon:null,title:he,className:"p-3xl"}),errorMessage:null!==(i=null===X||void 0===X?void 0:X.errorMessage)&&void 0!==i?i:void 0,filters:$,insightsDateRangeSource:"filters",insightsSource:Ye.rP.TransactionAttributeDetailPage,isDownloadingCsv:ee,isLoading:ae,onChangeFilters:ce,onClickDownloadCsv:Q,transactionsSummary:se}),a.createElement(IQ.T,{downloadUrl:null!==(s=null===X||void 0===X?void 0:X.url)&&void 0!==s?s:void 0}))))},r0=(0,$d.s)(QU.a)(XQ||(XQ=(0,wc.A)(["pt-0"]))),o0=Ee.bnu,i0=()=>{var e,t,n,l,r;const i=(0,lV.L)().id,s=(0,E.pE)("date"),c="month"===(null!==(e=(0,E.pE)("timeframe"))&&void 0!==e?e:"month")&&!!s,d={categories:[i]},u=(0,et.I)(s0,{variables:{id:i,month:null!==s&&void 0!==s?s:wQ,includeBudgetAmounts:c}}),m=u.data,p=u.refetch,g=u.error,h=null===m||void 0===m?void 0:m.category,v=(null===h||void 0===h||null===(t=h.group)||void 0===t?void 0:t.type)===Ee.wNk.EXPENSE,f=null!==h&&void 0!==h?h:{},y=f.budgetAmountsForMonth,b=f.rolloverPeriod,x=(0,Pd.h)(),w=(0,o.A)(x,2),C=w[0],A=w[1],I=A.open,k=A.close,S=!(null!==h&&void 0!==h&&h.excludeFromBudget)&&c;return a.createElement(a.Fragment,null,a.createElement(l0,{title:"".concat((null===m||void 0===m||null===(n=m.category)||void 0===n?void 0:n.icon)||""," ").concat((null===m||void 0===m||null===(l=m.category)||void 0===l?void 0:l.name)||""),attributeFilter:d,attributeType:"category",displayAsExpense:v,extraControls:a.createElement(fe.XZZ,{variant:"default",onClick:I},"Edit category"),overlayEmptyComponent:g?a.createElement(RF,{title:"Category does not exist"},a.createElement(fe.c8D,{color:"secondary",className:"mt-xs text-center"},"This category may have been disabled or deleted.")):void 0,additionalSummaryElement:S&&a.createElement(qX,{categoryId:i,categoryType:null===h||void 0===h||null===(r=h.group)||void 0===r?void 0:r.type,data:y,onResetRollover:p,loading:!y||y.month!==s,rolloverStartingBalance:null===b||void 0===b?void 0:b.startingBalance,rootProps:(0,Ex.p)("cashflow-budget-card")})}),h&&a.createElement(C,null,a.createElement(ZX.K,{categoryId:h.id,onDone:()=>{k(),p()}})))},s0=Ee.B_r;var c0=n(72994);const d0=()=>{var e;const t=(0,lV.L)().id,n=(0,E.pE)("date"),l=null!==(e=(0,E.pE)("timeframe"))&&void 0!==e?e:"month",r=(0,Pd.h)(),i=(0,o.A)(r,2),s=i[0],c=i[1],d=c.open,u=c.close,m="month"===l&&!!n,p={categoryGroups:[t]},g=(0,et.I)(u0,{variables:{id:t,month:null!==n&&void 0!==n?n:wQ,includeBudgetAmounts:m}}),h=g.data,v=g.refetch,f=g.error,y=null===h||void 0===h?void 0:h.categoryGroup,b=null!==y&&void 0!==y?y:{},x=b.budgetAmountsForMonth,w=b.rolloverPeriod,C=b.groupLevelBudgetingEnabled,A=(null===y||void 0===y?void 0:y.type)===Ee.wNk.EXPENSE;return a.createElement(a.Fragment,null,a.createElement(l0,{title:(null===y||void 0===y?void 0:y.name)||"",attributeFilter:p,attributeType:"category_group",displayAsExpense:A,extraControls:a.createElement(fe.XZZ,{variant:"default",onClick:d},"Edit group"),overlayEmptyComponent:f?a.createElement(RF,{title:"Group does not exist"},a.createElement(fe.c8D,{color:"secondary",className:"mt-xs text-center"},"This group may have been disabled or deleted.")):void 0,additionalSummaryElement:m&&a.createElement(qX,{categoryId:t,categoryType:null===y||void 0===y?void 0:y.type,data:x,onResetRollover:v,loading:!x||x.month!==n,isCategoryGroup:!0,rolloverStartingBalance:null===w||void 0===w?void 0:w.startingBalance,groupLevelBudgetingEnabled:C})}),y&&a.createElement(s,null,a.createElement(c0.x,{categoryGroupId:y.id,onDone:()=>{u(),v()}})))},u0=Ee.m_K;var m0=n(1884);const p0=e=>{let t=e.feature,n=e.children,l=e.showWhenNoAccess;const r=(0,m0.t)(t).hasAccess;return(l?!r:r)?a.createElement(a.Fragment,null,n):null};var g0=n(21568);const h0=["className"],v0=e=>{let t=e.className,n=(0,En.A)(e,h0);return a.createElement(qH.v,Object.assign({"data-external-id":"dashboard-widget-drag-handle",revealOnHover:!0},n,{className:(0,q.cn)("absolute left-0 z-docked group-hover/dashboard-widget:opacity-100",t)}))},f0=e=>"dashboard_widget_".concat(e);
1var E0,y0=n(79281);const b0=e=>{let t=e.title,n=e.description,o=e.headerRight,i=e.headerLeftAddon,s=e.children,c=e.loading,d=void 0!==c&&c,u=e.minHeightPx,g=e.headerLink,h=e.showHeaderBorder,v=void 0===h||h,f=e.hideHeader,E=void 0!==f&&f,y=e.tooltip,b=e.className,x=e.widgetError,w=e.widgetType,C=e.analyticsData,A=e.headerRightFlexGrow,I=e.headerSubRow,k=e.stackHeader,S=void 0!==k&&k;const N=f0(w);return a.createElement(x0,{"data-external-id":"deprecated-dashboard-widget",className:b,rootProps:u?{style:{minHeight:u}}:void 0},!E&&a.createElement(T0,{$showBorder:v},a.createElement(m.g,Object.assign({padding:"small",paddingLeft:"large"},!!I&&{paddingBottom:"xxsmall"},{minHeight:"".concat(56,"px")}),a.createElement(l.N_,{to:g,className:w0({hasTooltip:Boolean(y),stacked:Boolean(S),hasLeftAddon:Boolean(i)}),onClick:()=>{(0,Ge.u4)(Ye.H8.DashboardWidgetClicked,(0,U.A)({type:w,destination:g},C))},state:{referrerSource:N}},a.createElement("div",{className:"flex items-center gap-2xs"},a.createElement(S0,null,a.createElement(v0,null),a.createElement(N0,null,t)),!!i&&a.createElement(D0,null,i)),!!n&&a.createElement(R0,null,n)),y,!!i&&a.createElement(A0,null,i),!!i&&a.createElement(I0,null),!!o&&a.createElement(C0,{justifyEnd:!0,$flexGrow:A},o)),!!I&&a.createElement(_0,null,I)),(0,r.YW)({loading:d,widgetError:x}).with({loading:!0},(()=>a.createElement(m.g,{center:!0,margin:"xlarge"},a.createElement(p.i,null)))).with({loading:!1,widgetError:r.P.nonNullable},(e=>{let t=e.widgetError;return a.createElement(SQ.W,t)})).otherwise((()=>s)))},x0=(0,$d.s)(Xl.AM).attrs({role:"group"})(E0||(E0=(0,wc.A)(["group/dashboard-widget relative"]))),w0=(0,y0.tv)({base:"flex flex-col items-stretch gap-px text-inherit",variants:{hasTooltip:{false:"min-w-0 flex-1"},stacked:{true:"justify-center",false:"xl:flex-row xl:items-center xl:gap-xs xl:whitespace-nowrap"},hasLeftAddon:{true:""}},compoundVariants:[{stacked:!1,hasLeftAddon:!0,class:"xl:flex-[0_0_auto]"}]}),C0=(0,u.default)(ZY.B).withConfig({displayName:"DashboardWidget__HeaderRight",componentId:"sc-1g2c0g6-0"})(["margin-left:",";align-items:center;",";"],vt.YK.default,(e=>{let t=e.$flexGrow;return void 0!==t&&(0,u.css)(["flex-grow:",";"],t)})),A0=(0,u.default)(ZY.B).withConfig({displayName:"DashboardWidget__HeaderLeftAddon",componentId:"sc-1g2c0g6-1"})(["align-items:center;display:none;margin-left:",";@media (min-width:","px){display:flex;}"],vt.YK.xxsmall,(e=>e.theme.breakPoints.xl)),I0=u.default.div.withConfig({displayName:"DashboardWidget__SpacerAfterLeftAddon",componentId:"sc-1g2c0g6-2"})(["display:none;flex:1 1 auto;@media (min-width:","px){display:block;}"],(e=>e.theme.breakPoints.xl)),k0=(0,u.default)(RV.W).attrs({$large:!0}).withConfig({displayName:"DashboardWidget__Title",componentId:"sc-1g2c0g6-3"})(["display:flex;align-items:center;"]),S0=u.default.div.attrs({"data-sc-tw":"DashboardWidget__HoverRegion"}).withConfig({displayName:"DashboardWidget__HoverRegion",componentId:"sc-1g2c0g6-4"})(["display:flex;align-items:center;gap:",";min-width:0;overflow:hidden;"],vt.YK.xsmall),N0=(0,u.default)(k0).withConfig({displayName:"DashboardWidget__HoverRegionTitle",componentId:"sc-1g2c0g6-5"})(["display:block;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;[data-sc-tw~='DashboardWidget__HoverRegion']:hover &{color:",";}"],vt.Ee.color.content.link),T0=u.default.div.withConfig({displayName:"DashboardWidget__HeaderArea",componentId:"sc-1g2c0g6-6"})(["",""],(e=>e.$showBorder&&(0,u.css)(["border-bottom:1px solid ",";"],vt.Ee.color.divider.primary))),_0=u.default.div.withConfig({displayName:"DashboardWidget__SubHeaderRow",componentId:"sc-1g2c0g6-7"})(["display:flex;align-items:center;justify-content:space-between;padding:0 "," "," ",";"],vt.YK.small,vt.YK.small,vt.YK.large),D0=(0,u.default)(ZY.B).withConfig({displayName:"DashboardWidget__HeaderLeftAddonInline",componentId:"sc-1g2c0g6-8"})(["align-items:center;@media (min-width:","px){display:none;}"],(e=>e.theme.breakPoints.xl)),R0=u.default.div.withConfig({displayName:"DashboardWidget__DEPRECATEDDescription",componentId:"sc-1g2c0g6-9"})(["font-weight:",";line-height:150%;margin-top:1px;font-size:",";color:",";white-space:nowrap;"],(e=>e.theme.fontWeight.medium),vt.J.base,vt.Ee.color.content.secondary),M0=[{timeRange:"1m",display:"1M"},{timeRange:"3m",display:"3M"},{timeRange:"6m",display:"6M"},{timeRange:"ytd",display:"YTD"},{timeRange:"1y",display:"1Y"},{timeRange:"all",display:"ALL"}],L0=e=>{var t;return null===(t=M0.find((t=>
1t.display===e.display)))||void 0===t?void 0:t.timeRange};var O0=n(57571);const P0=(0,sG.Mz)((e=>e.dashboard),(e=>e.config));var B0,z0,F0,G0;const Y0=(0,n(42518).sU)(["__typename"]),U0=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};var n,l;const r=(0,d.wA)(),s=(0,d.d4)(P0),c=t.onUpdateConfig,u=(0,Xo.IT)(j0,{onCompleted:e=>{var t;const n=null===(t=e.myHousehold.preferences)||void 0===t?void 0:t.dashboardConfig;if(n){const e=Y0(n);r((0,oG.Nj)(e))}}}),m=u.data,p=(null!==(n=null===m||void 0===m?void 0:m.myHousehold.preferences)&&void 0!==n?n:{}).dashboardConfig,g=(0,a.useMemo)((()=>{if(p)return Y0(p)}),[p]),h=null!==g&&void 0!==g?g:s,v=h[e],f=null===(l=null===m||void 0===m?void 0:m.myHousehold.preferences)||void 0===l?void 0:l.dashboardConfigCustomizedAt,E=void 0!==m,y=void 0!==m&&(null===f||void 0===f),b=(0,i.n)(H0),x=(0,o.A)(b,1)[0],w=(0,a.useCallback)((async function(t){let n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];const a=(0,U.A)((0,U.A)({},Y0(h)),{},{[e]:t});await x({variables:{input:JSON.stringify(a)},optimisticResponse:m&&n?{updateDashboardConfig:{__typename:"UpdateDashboardConfigMutation",household:(0,O0.A)(m.myHousehold,{preferences:{dashboardConfig:a}})}}:void 0}),null===c||void 0===c||c(t),r((0,oG.Nj)(a))}),[h,e,x,m,r,c]);return[v,w,{isDefaultConfig:y,loaded:E}]},V0=(0,vK.J1)(B0||(B0=(0,wc.A)(["\n  fragment DashboardConfigFields on PlatformDashboardConfig {\n    layout\n    widgets\n  }\n"]))),W0=(0,vK.J1)(z0||(z0=(0,wc.A)(["\n  fragment HouseholdDashboardFields on Household {\n    id\n    preferences {\n      dashboardConfigCustomizedAt\n      dashboardConfig {\n        web {\n          ...DashboardConfigFields\n        }\n        mobile {\n          ...DashboardConfigFields\n        }\n      }\n    }\n  }\n  ","\n"])),V0),j0=(0,vK.J1)(F0||(F0=(0,wc.A)(["\n  query Common_GetDashboardConfig {\n    myHousehold {\n      id\n      ...HouseholdDashboardFields\n    }\n  }\n  ","\n"])),W0),H0=(0,vK.J1)(G0||(G0=(0,wc.A)(["\n  mutation Common_UpdateDashboardConfig($input: JSONString!) {\n    updateDashboardConfig(input: $input) {\n      household {\n        id\n        ...HouseholdDashboardFields\n      }\n      errors {\n        ...PayloadErrorFields\n      }\n    }\n  }\n  ","\n  ","\n"])),W0,IK.K);var K0=n(75783);const q0=u.default.div.withConfig({displayName:"AccountsDashboardWidget__Body",componentId:"xbx8sn-0"})(["padding:0 0 ",";"],(e=>e.theme.spacing.xlarge)),$0=u.default.div.withConfig({displayName:"AccountsDashboardWidget__NetWorthPerformanceChartWrapper",componentId:"xbx8sn-1"})(["padding-left:",";padding-right:",";"],(e=>{let t=e.theme;return"".concat(t.spacing.default)}),(e=>{let t=e.theme;return"".concat(t.spacing.default)})),Z0=["className"],J0=["className","children"],X0=["className","children"],Q0=["className"],e1=["className"],t1=["error","children","className"],n1=(0,a.forwardRef)(((e,t)=>{let n=e.className,l=(0,En.A)(e,Z0);return a.createElement(fe.xz6,Object.assign({"data-external-id":"dashboard-widget-card",ref:t,className:(0,q.cn)("group/dashboard-widget relative w-full",n)},l))}));n1.displayName="DashboardWidgetCard";const a1=(0,a.forwardRef)(((e,t)=>{let n=e.className,l=e.children,r=(0,En.A)(e,J0);return a.createElement(fe.xz6.Header,Object.assign({"data-external-id":"dashboard-widget-card-header",ref:t,className:(0,q.cn)("relative min-h-14 gap-xs pl-lg",n)},r),a.createElement(v0,null),l)}));a1.displayName="DashboardWidgetCard.Header";const l1=(0,a.forwardRef)(((e,t)=>{let n=e.className,l=e.children,r=(0,En.A)(e,X0);return a.createElement(fe.xz6.Title,Object.assign({"data-external-id":"dashboard-widget-card-title",ref:t,className:(0,q.cn)("flex min-w-0 items-center gap-xs",n)},r),"string"===typeof l?a.createElement("span",{className:"truncate"},l):l)}));l1.displayName="DashboardWidgetCard.Title";const r1=(0,a.forwardRef)(((e,t)=>{let n=e.className,l=(0,En.A)(e,Q0);return a.createElement("div",Object.assign({"data-external-id":"dashboard-widget-card-title-group",ref:t,className:(0,q.cn)("flex min-w-0 flex-1 flex-col gap-px xl:flex-row xl:items-center xl:gap-xs",n)},l))}));r1.displayName="DashboardWidgetCard.TitleGroup";const o1=(0,a.forwardRef)(((e,t)=>
1{let n=e.className,l=(0,En.A)(e,e1);return a.createElement(fe.xz6.Description,Object.assign({"data-external-id":"dashboard-widget-card-description",ref:t,className:(0,q.cn)("whitespace-nowrap",n)},l))}));o1.displayName="DashboardWidgetCard.Description";const i1=e=>a.createElement(fe.xz6.Action,Object.assign({"data-external-id":"dashboard-widget-card-action"},e));i1.displayName="DashboardWidgetCard.Action";const s1=e=>{let t=e.error,n=e.children,l=e.className,r=(0,En.A)(e,t1);return a.createElement(fe.xz6.Content,Object.assign({"data-external-id":"dashboard-widget-card-body",className:(0,q.cn)("p-lg",l)},r),t?a.createElement(SQ.W,t):n)};s1.displayName="DashboardWidgetCard.Body";const c1=Object.assign(n1,{Root:n1,Header:a1,Title:l1,TitleGroup:r1,Description:o1,Action:i1,Body:s1}),d1={save:fe.c3d,spend:fe.uel,invest:fe.bPG,pay_down:fe.BkL,protect:fe.DMT,wellness:fe.TYT},u1=e=>{let t=e.adviceCategory,n=t.displayName,l=t.name,r=t.color,o=e.completed,i=e.showName,s=void 0===i||i,c=e.sizePx,d=void 0===c?48:c,u=e.className;const m=d1[l];return a.createElement("div",{"data-external-id":"advice-category-icon",className:(0,q.cn)("flex flex-col items-center",u)},o?a.createElement("div",{className:" flex shrink-0 items-center justify-center rounded-round bg-transparent ring-1 ring-progress-success ring-inset ",style:{width:d,height:d}},a.createElement("div",{className:"flex items-center justify-center rounded-round border-0 bg-progress-success",style:{width:d-10,height:d-10}},a.createElement(fe.GdR,{size:d/2,className:"text-content-white"}))):a.createElement("div",{className:"flex shrink-0 items-center justify-center rounded-round ring-1 ring-avatar-border ring-inset",style:{width:d,height:d,backgroundColor:r}},m&&a.createElement(m,{size:d/2,className:"text-content-white"})),s&&a.createElement(fe.c8D,{size:"2xs",weight:"bold",color:"secondary",className:"mt-xs tracking-[0.08em] uppercase"},n))};u1.fragments={AdviceCategoryIconFields:Ee.TpX};const m1=e=>{let t=e.item,n=t.title,r=t.category,o=t.numTasksCompleted,i=t.numTasks,s=t.completedAt,c=e.onClick,d=e.to,u=e.className,m=e.__segment;return a.createElement(fe.Qey,{"data-external-id":"condensed-advice-item-row",media:a.createElement(u1,{adviceCategory:r,showName:!1,sizePx:36,completed:!!s}),title:n,actions:a.createElement(a.Fragment,null,a.createElement(fe.cqk,{value:Math.max(o,.08*(i||1)),max:i||1,color:"progress-success",className:"w-25"}),a.createElement(fe.hPJ,{size:"xl",className:"text-content-secondary transition-colors group-hover:text-content-primary"})),onClick:c,render:d?a.createElement(l.k2,{to:d}):void 0,className:(0,q.cn)("group",u),__segment:m})};m1.fragments={CondensedAdviceItemRowFields:Ee.Cml};var p1=n(47642);const g1=e=>{let t=e.cta,n=e.variant,l=void 0===n?"default":n;return t.href?a.createElement(p1.E,{"data-external-id":"widget-empty-state-cta-button",to:t.href,variant:l,onClick:t.onClick,endIcon:a.createElement(fe.Fug,{size:"xs"})},t.label):a.createElement(fe.XZZ,{"data-external-id":"widget-empty-state-cta-button",variant:l,type:"button",onClick:t.onClick,isLoading:t.isLoading,endIcon:a.createElement(fe.Fug,{size:"xs"})},t.label)},h1={blue:"bg-chart-event-background-blue",green:"bg-chart-event-background-green",purple:"bg-chart-event-background-purple",teal:"bg-chart-event-background-teal",indigo:"bg-chart-event-background-indigo",orange:"bg-chart-event-background-orange",pink:"bg-chart-event-background-pink",sky:"bg-chart-event-background-sky",lime:"bg-chart-event-background-lime",brown:"bg-chart-event-background-brown"},v1={blue:"text-chart-fill-blue",green:"text-chart-fill-green",purple:"text-chart-fill-purple",teal:"text-chart-fill-teal",indigo:"text-chart-fill-indigo",orange:"text-chart-fill-orange",pink:"text-chart-fill-pink",sky:"text-chart-fill-sky",lime:"text-chart-fill-lime",brown:"text-chart-fill-brown"},f1=e=>{let t=e.icon,n=e.title,l=e.description,r=e.cta,o=e.color,i=void 0===o?"blue":o;return a.createElement(fe.erR.Root,{"data-external-id":"widget-empty-state"},a.createElement(fe.erR.Icon,{variant:"unstyled"},a.createElement(E1,{icon:t,color:i})),a.createElement(fe.erR.Title,{className:"text-pretty"},n),a.createElement(fe.erR.Description,{className:"text-pretty"},l),a.createElement(fe.erR.Actions,null,a.createElement(g1,{cta:r})))},E1=e=>{let t=e.icon,n=e.color,l=void 0===n?"blue":n;return a.createElement("div",{"data-external-id":"widget-empty-state-icon-tile",className:(0,q.cn)("flex size-10 items-center justify-center rounded-full [&_svg]:size-5",h1[l],v1[l])},t)},y1=new Set,b1=e=>{let t=e.isVisible,n=e.trackImpression;const l=(0,a.useRef)(!1);(0,a.useEffect)((()=>{!l.current&&t&&(l.current=!0,n())}),[t,n])},x1=e=>({trackImpression:(0,a.useCallback)((()=>{y1.has(e)||(y1.add(e),(0,Ge.u4)(Ye.H8.DashboardWidgetEmptyStateImpression,{type:e}))}),[e]),trackCtaClicked:(0,a.useCallback)((t=>{(0,Ge.u4)(Ye.H8.DashboardWidgetEmptyStateCtaClicked,{type:e,cta:t})}),[e])});var w1=n(7589);const C1=Ee.vE8;var A1=n(43393),I1=n(57347),k1=n(37052),S1=n(13119);const N1=e=>{let t=e.name,n=e.entity,l=e.checked,r=e.disabled,o=e.onCheckedChange;return a.createElement(S1.L.Root,{"data-external-id":"business-entity-switch-card",name:t,checked:l,disabled:r,onCheckedChange:o},a.createElement(S1.L.Header,null,a.createElement(S1.L.Switch,null),a.createElement(S1.L.HeaderText,{className:"flex-row items-center gap-sm"},a.createElement(k1.L,{logoUrl:n.logoUrl,color:n.color,size:32,iconSize:_j._T.medium.icon}),a.createElement(S1.L.Label,{className:"line-clamp-1"},n.name))))},T1=[{title:"Net income",value:"income"},{title:"Net assets",value:"assets"}],_1={"1m":"1 month","3m":"3 months","6m":"6 months","1y":"1 year",ytd:"Year to date",all:"All time"},D1=["1m","3m","6m","1y","ytd","all"].map((e=>({value:e,label:_1[e]})));var R1;const M1=e=>{let t=e.businessEntities,n=e.visibleEntityIds,l=e.onSave;const r=(0,Sq.k)().close,o=(0,a.useMemo)((()=>{let e=0;return{entityOptions:t.map((t=>{const a=(void 0===n||n.includes(t.id))&&e<5;return a&&(e+=1),{id:t.id,enabled:a}}))}}),[t,n]),i=(0,a.useMemo)((()=>(0,I1.Ik)().shape({entityOptions:(0,I1.YO)().of((0,I1.Ik)().shape({id:(0,I1.Yj)().required(),enabled:(0,I1.zM)().required()})).required()})),[]);return a.createElement(Rc.L,{"data-external-id":"business-entity-widget-display-modal",title:"Business tracking widget",fullHeight:!0},a.createElement(L1,{initialValues:o,onSubmit:e=>(e=>{const n=e.entityOptions.filter((e=>e.enabled)).map((e=>e.id)),a=n.length===t.length?void 0:n;l(a),r()})(e),overrideValidationSchema:i},a.createElement(_m.O,null,a.createElement("div",{className:"flex flex-col gap-xl p-xl"},a.createElement(hu.c.Consumer,null,(e=>{let n=e.values,l=e.setFieldValue,r=e.setFieldTouched;const o=n.entityOptions.filter((e=>e.enabled)).length>=5;return a.createElement("div",{className:"flex flex-col gap-xl"},a.createElement("div",{className:"flex flex-col gap-xs"},a.createElement(kD.c,null,"Select up to 5 businesses you'd like to appear in your widget."),o&&a.createElement(kD.c,{size:"sm",color:"secondary"},"Maximum of ",5," entities can be displayed at once.")),a.createElement("div",{className:"flex flex-col gap-sm"},t.map(((e,t)=>{var i;const s="entityOptions.".concat(t,".enabled"),c=Boolean(null===(i=n.entityOptions[t])||void 0===i?void 0:i.enabled);return a.createElement(N1,{key:e.id,name:s,entity:e,checked:c,disabled:o&&!c,onCheckedChange:e=>{l(s,e),r(s,!0,!1)}})}))))}
1)))),a.createElement(Cq.R,null,a.createElement("div",{className:"flex justify-end"},a.createElement(Wb.X,{variant:"default",onClick:r},"Cancel"),a.createElement(Wb.X,{variant:"primary",type:"submit"},"Save")))))},L1=(0,$d.s)(Eu.lV)(R1||(R1=(0,wc.A)(["flex h-full flex-1 flex-col overflow-hidden"]))),O1=e=>{let t=e.onEditDisplay,n=e.disabled;return a.createElement(fe.u$N,{"data-external-id":"business-entity-widget-menu",align:"end",trigger:a.createElement(fe.SO$,{"aria-label":"Business tracking options",disabled:n},a.createElement(fe.V_g,null)),items:[{label:"Edit widget",onClick:()=>{(0,Ge.u4)(Ye.H8.DashboardWidgetUpdated,{type:K0.y.BUSINESS_ENTITIES,action:"edit_display"}),t()}},{label:"Watch walkthrough",onClick:()=>window.open(VF.e3,"_blank","noopener,noreferrer")},{type:"link",label:"Go to full settings",render:a.createElement(l.N_,{to:I.JZ.settings.businesses()}),closeOnClick:!0,onClick:()=>(0,Ge.u4)(Ye.H8.DashboardWidgetUpdated,{type:K0.y.BUSINESS_ENTITIES,action:"go_to_settings"})}]})};var P1,B1=n(39783),z1=n(67242),F1=n(39569);const G1=e=>{let t=e.data;const n=(0,u.useTheme)(),l=(0,Pc.e)(!1),r=(0,o.A)(l,2),i=r[0],s=r[1],c=s.setOff,d=s.setOn,m=(0,a.useMemo)((()=>{const e=(e=>{if(e.length<=3)return e;const t=Math.ceil(e.length/3),n=Math.ceil(e.length/t);return Array.from({length:n},((n,a)=>{const l=e.slice(a*t,(a+1)*t);return{month:l[l.length-1].month,sumIncome:l.reduce(((e,t)=>e+t.sumIncome),0),sumExpense:l.reduce(((e,t)=>e+t.sumExpense),0)}})).filter((t=>0!==t.sumIncome||0!==t.sumExpense||e.length>0))})(t);return e.map((e=>{let t=e.month,n=e.sumIncome,a=e.sumExpense;return{month:t,income:n,expense:Math.abs(a),net:n+a}}))}),[t]);if(0===t.length)return null;const p=i?n.variables.color.chart.fill.green:n.variables.color.chart.event.background.green,g=i?n.variables.color.chart.fill.red:n.variables.color.chart.event.background.red;return a.createElement(U1,{"data-external-id":"business-entity-income-sparkline","data-testid":"business-entity-income-sparkline",onMouseEnter:d,onMouseLeave:c},a.createElement(B1.X,{width:97,height:50,data:m,barCategoryGap:"8%",barGap:1,style:{cursor:"pointer"}},a.createElement(wa.h,{domain:["dataMin","dataMax"],hide:!0}),a.createElement(Ca.yP,{dataKey:"income",radius:[2,2,0,0],isAnimationActive:!1},m.map(((e,t)=>a.createElement(z1.f,{key:t,fill:p})))),a.createElement(Ca.yP,{dataKey:"expense",radius:[2,2,0,0],isAnimationActive:!1},m.map(((e,t)=>a.createElement(z1.f,{key:t,fill:g})))),a.createElement(Gy.N1,{dataKey:"net",dot:!1,activeDot:!1,strokeWidth:1.5,stroke:n.color.gray8,type:"linear",isAnimationActive:!1})))},Y1=e=>{var t,n,l,r;let i=e.data,s=e.timePeriodLabel;const c=(0,u.useTheme)(),d=(0,Pc.e)(!1),m=(0,o.A)(d,2),p=m[0],g=m[1],h=g.setOff,v=g.setOn;if(0===i.length)return null;const f=i.map((e=>({netAssets:e.netAssets}))),E=null!==(t=null===(n=f[0])||void 0===n?void 0:n.netAssets)&&void 0!==t?t:0,y=null!==(l=null===(r=f[f.length-1])||void 0===r?void 0:r.netAssets)&&void 0!==l?l:E,b=p?(0,hW.wn)({isAsset:!0,balance:y-E,theme:c}):c.color.gray8;return a.createElement(Wi.Y,{"data-external-id":"business-entity-assets-sparkline",open:p,content:a.createElement(El.H,{className:"flex-col gap-0",startAmount:E,endAmount:y,timeframeDisplay:s,isAsset:!0}),description:"Net assets trend"},a.createElement("div",{className:"align-middle","data-testid":"business-entity-assets-sparkline",onMouseEnter:v,onMouseLeave:h},a.createElement(F1.E,{data:f,dataKey:"netAssets",widthPx:97,heightPx:50,lineColor:b,referenceLineY:E})))},U1=$d.s.div(P1||(P1=(0,wc.A)(["\n  [&_.recharts-bar-rectangle_:is(path,rect)]:transition-[fill]\n  [&_.recharts-bar-rectangle_:is(path,rect)]:duration-100\n  [&_.recharts-bar-rectangle_:is(path,rect)]:ease-out\n"])));var V1=n(69416);const W1="text-content-danger",j1="text-content-success",H1=e=>{let t=e.businessEntity,n=e.amount,r=e.timePeriodLabel,o=e.viewMode,i=e.monthlyBreakdown,s=void 0===i?[]:i,c=e.monthlyNetAssets,d=void 0===c?[]:c,u=e.hideSparkline,m=void 0!==u&&u;const p=(0,l.Zp)(),g=t.id,h=t.name,v=t.logoUrl,f=t.color,E=t.structure,y=t.accountsCount,b=E?_j.xy[E]:null,x="income"===o,w=n>=0,C=x?I.JZ.reports.cashFlow({queryParams:{businessEntitySet:g}}):I.JZ.accounts(),A=x?I.JZ.reports.cashFlow():I.JZ.accounts(),k=(0,a.useMemo)((()=>x?{initialView:{tab:"cashFlow",chartType:V1.Gi.CashFlowChart}}:{businessEntityIds:[g]}),[x,g]),S=(0,a.useCallback)((e=>{e.preventDefault(),e.stopPropagation(),(0,Ge.u4)(Ye.H8.DashboardWidgetClicked,{type:K0.y.BUSINESS_ENTITIES,destination:I.JZ.reports.cashFlow(),source:"p_and_l"}),p(I.JZ.reports.cashFlow({queryParams:{businessEntitySet:g}}),{state:{initialView:{tab:"cashFlow",chartType:V1.Gi.ProfitLossTable}}})}),[p,g]),N=(0,a.useCallback)((e=>{e.preventDefault(),e.stopPropagation(),(0,Ge.u4)(Ye.H8.DashboardWidgetClicked,{type:K0.y.BUSINESS_ENTITIES,destination:A,source:"chart"}),p(C,{state:k})}),[p,A,C,k]),T=(0,a.useCallback)((()=>{(0,Ge.u4)(Ye.H8.DashboardWidgetClicked,{type:K0.y.BUSINESS_ENTITIES,destination:A,source:"row"})}),[A]),_=x?void 0:(0,De.td)("account",y,{inclusive:!0});return a.createElement(l.k2,{"data-external-id":"business-entity-widget-row",to:C,state:k,key:g,className:" group flex cursor-pointer items-center px-default py-sm text-inherit no-underline hover:bg-background-primary-hover [&+&]:border-t [&+&]:border-divider-primary ",onClick:T},a.createElement(k1.L,{logoUrl:v,color:f,size:_j._T.medium.logo,iconSize:_j._T.medium.icon,borderRadius:8}),a.createElement("div",{className:"ml-default flex min-w-0 flex-1 flex-col"},a.createElement(kD.c,{weight:"medium",className:"truncate"},h),b&&a.createElement(kD.c,{size:"sm",color:"secondary",className:"truncate"},b)),!m&&a.createElement("div",{className:"mx-sm shrink-0",onClick:N}
1,x?a.createElement(G1,{data:s}):a.createElement(Y1,{data:d,timePeriodLabel:r})),a.createElement("div",{className:"flex min-w-20 shrink-0 flex-col items-end text-right"},a.createElement(kD.c,{weight:"medium",className:(0,q.cn)(fl.zs.className,w?j1:W1)},(0,rl.vv)(n)),x?a.createElement(kD.c,{className:"cursor-pointer text-sm font-medium text-content-link hover:text-content-link-hover",role:"link",tabIndex:0,onClick:S},"View P&L"):a.createElement(kD.c,{size:"sm",color:"secondary"},_)))},K1=e=>{let t=e.value,n=e.onChange,l=e.disabled;return a.createElement(fe.hGA,{"data-external-id":"business-entity-widget-time-range-select",size:"sm",options:D1,value:t,onValueChange:n,disabled:l})};var q1;const $1=(0,vK.J1)(q1||(q1=(0,wc.A)(["\n  query Common_GetBusinessEntityFinancials($entityIds: [ID!]!, $startDate: Date!, $endDate: Date!) {\n    businessEntityFinancials(entityIds: $entityIds, startDate: $startDate, endDate: $endDate) {\n      entityId\n      sumIncome\n      sumExpense\n      netAssets\n      monthlyBreakdown {\n        month\n        sumIncome\n        sumExpense\n      }\n      monthlyNetAssets {\n        month\n        netAssets\n      }\n    }\n  }\n"]))),Z1=e=>{let t=e.entityIds,n=e.viewMode,l=e.timeRange;const o=(0,a.useMemo)((()=>(e=>{var t;const n=N.c9.local(),a=null!==(t=n.toISODate())&&void 0!==t?t:"";return(0,r.YW)(e).with("1m",(()=>{var e;return{startDate:null!==(e=n.minus({months:1}).toISODate())&&void 0!==e?e:"",endDate:a}})).with("3m",(()=>{var e;return{startDate:null!==(e=n.minus({months:3}).toISODate())&&void 0!==e?e:"",endDate:a}})).with("6m",(()=>{var e;return{startDate:null!==(e=n.minus({months:6}).toISODate())&&void 0!==e?e:"",endDate:a}})).with("1y",(()=>{var e;return{startDate:null!==(e=n.minus({years:1}).toISODate())&&void 0!==e?e:"",endDate:a}})).with("ytd",(()=>{var e;return{startDate:null!==(e=n.startOf("year").toISODate())&&void 0!==e?e:"",endDate:a}})).with("all",(()=>({startDate:"2000-01-01",endDate:a}))).otherwise((()=>{var e;return{startDate:null!==(e=n.minus({months:1}).toISODate())&&void 0!==e?e:"",endDate:a}}))})(l)),[l]),i=o.startDate,s=o.endDate,c="income"===n,d=t.length>0,u=(0,et.I)($1,{variables:{entityIds:t,startDate:i,endDate:s},skip:!d}),m=u.data,p=u.isLoadingInitialData,g=u.error,h=u.refetch;return{financialData:(0,a.useMemo)((()=>{var e;return(null!==(e=null===m||void 0===m?void 0:m.businessEntityFinancials)&&void 0!==e?e:[]).map((e=>{var t,n,a,l,r;return{entityId:e.entityId,amount:c?(null!==(t=e.sumIncome)&&void 0!==t?t:0)+(null!==(n=e.sumExpense)&&void 0!==n?n:0):null!==(a=e.netAssets)&&void 0!==a?a:0,monthlyBreakdown:null!==(l=e.monthlyBreakdown)&&void 0!==l?l:[],monthlyNetAssets:null!==(r=e.monthlyNetAssets)&&void 0!==r?r:[]}}))}),[m,c]),isLoading:p,refetch:h,error:g}};var J1,X1,Q1,e2,t2,n2,a2,l2,r2,o2,i2=n(65443);const s2=$d.s.div(J1||(J1=(0,wc.A)(["w-35"]))),c2=(0,$d.s)(A1.V)(X1||(X1=(0,wc.A)(["ml-xs w-fit gap-2xs *:h-9"]))),d2=(0,$d.s)(c2)(Q1||(Q1=(0,wc.A)(["ml-0"]))),u2=$d.s.div(e2||(e2=(0,wc.A)(["flex min-h-50 flex-col items-center gap-0 xs:flex-row"]))),m2=$d.s.div(t2||(t2=(0,wc.A)(["\n  flex min-w-0 flex-1 flex-col items-center justify-center rounded-none px-xl\n  pt-default pb-0\n  xs:rounded-bl-md xs:pt-sm xs:pr-xl xs:pb-lg xs:pl-default\n"]))),p2=$d.s.img(n2||(n2=(0,wc.A)(["h-auto w-full rounded-sm object-contain"]))),g2=$d.s.div(a2||(a2=(0,wc.A)(["\n  flex min-w-0 flex-1 flex-col items-stretch justify-center gap-0 bg-background-primary\n  p-xl\n  xs:items-start xs:pr-default xs:pl-0\n"]))),h2=(0,$d.s)(cu.WT)(l2||(l2=(0,wc.A)(["mt-default w-full xs:w-auto"]))),v2=$d.s.div(r2||(r2=(0,wc.A)(["flex justify-center border-t border-divider-primary p-default"]))),f2=(0,$d.s)(l.k2)(o2||(o2=(0,wc.A)(["\n  flex items-center gap-3xs text-sm font-medium text-content-link no-underline\n  hover:text-content-link-hover\n"])));var E2=n(3586),y2=n(17058),b2=n(36828);var x2;!function(e){e.ThisWeekVersusLastWeek="This week vs. last week",e.ThisMonthVersusLastMonth="This month vs. last month",e.ThisMonthVersusLastYear="This month vs. last year",e.ThisMonthVersusAverageMonth="This month vs. average month",e.ThisYearVersusLastYear="This year vs. last year"}(x2||(x2={}));const w2=Object.keys(x2).map((e=>({label:x2[e],value:x2[e]}))),C2={[x2.ThisWeekVersusLastWeek]:{previousPeriodLegend:"Last week",currentPeriodLegend:"This week",tooltipCurrentPeriodLabel:"This week",tooltipPreviousPeriodLabel:"Last week"},[x2.ThisMonthVersusLastMonth]:{previousPeriodLegend:"Last month",currentPeriodLegend:"This month",tooltipCurrentPeriodLabel:"This month",tooltipPreviousPeriodLabel:"Last month"},[x2.ThisMonthVersusLastYear]:{previousPeriodLegend:"This month last year",currentPeriodLegend:"This month",tooltipCurrentPeriodLabel:"This month",tooltipPreviousPeriodLabel:"This month last year"},[x2.ThisMonthVersusAverageMonth]:{previousPeriodLegend:"Average month (last 12 months)",currentPeriodLegend:"This month",tooltipCurrentPeriodLabel:"This month",tooltipPreviousPeriodLabel:"Average month (last 12 months)"},[x2.ThisYearVersusLastYear]:{previousPeriodLegend:"Last year",currentPeriodLegend:"This year",tooltipCurrentPeriodLabel:"This year",tooltipPreviousPeriodLabel:"Last year"}},A2=(0,Nc.A)((e=>{var t;return null===(t=e.groupBy)||void 0===t?void 0:t.day})),I2=(e,t)=>
1(0,LD.A)((e=>{var n;return N.c9.fromISO((null===(n=e.groupBy)||void 0===n?void 0:n.day)||"").startOf(t).toISODate()}),e),k2=e=>{const t=I2(e,"month"),n=(0,b2.d)(Object.keys(t)),a=(0,jd.A)((e=>t[e]),n);return(0,jd.A)(A2,a)},S2=e=>{const t=I2(e,"year"),n=(0,b2.d)(Object.keys(t)),a=(0,jd.A)((e=>t[e]),n);return(0,jd.A)(A2,a)},N2=e=>{const t=(0,jd.A)((e=>{var t,n;return{day:N.c9.fromISO((null===(t=e.groupBy)||void 0===t?void 0:t.day)||"").day,balance:-e.summary.sumExpense,date:(null===(n=e.groupBy)||void 0===n?void 0:n.day)||""}}),e);return(0,y2.A)(((e,t)=>[{balance:e.balance+t.balance},(0,U.A)((0,U.A)({},t),{},{balance:e.balance+t.balance})]),{balance:0},t)[1]},T2=(e,t)=>{switch(t){case x2.ThisMonthVersusLastMonth:return k2(e);case x2.ThisWeekVersusLastWeek:return(e=>{const t=I2(e,"week"),n=(0,b2.d)(Object.keys(t)),a=(0,jd.A)((e=>t[e]),n);return(0,jd.A)(A2,a)})(e);case x2.ThisMonthVersusLastYear:case x2.ThisYearVersusLastYear:return S2(e);case x2.ThisMonthVersusAverageMonth:return k2(e);default:return[]}},_2=e=>{if(0===e.length)return[];const t=(0,LD.A)((e=>{var t;const n=N.c9.fromISO((null===(t=e.groupBy)||void 0===t?void 0:t.day)||"");if(!n.isValid)return"invalid";const a=n.ordinal,l=10*(Math.ceil(a/10)-1)+1;return N.c9.fromObject({year:n.year,ordinal:l}).toISODate()||"invalid"}),e),n=Object.entries(t).filter((e=>"invalid"!==(0,o.A)(e,1)[0])).map((e=>{let t=(0,o.A)(e,2),n=t[0];const a=t[1];return{__typename:"AggregateData",summary:{__typename:"TransactionsSummary",sumExpense:(0,MK.A)(a.map((e=>e.summary.sumExpense)))},groupBy:{__typename:"AggregateGroupBy",day:n}}}));return(0,Nc.A)((e=>{var t;return(null===(t=e.groupBy)||void 0===t?void 0:t.day)||""}),n)},D2=e=>{let t=e.previousAggregateData,n=e.currentAggregateData,a=e.timeRangeType,l=e.averageMonthData,r=void 0===l?void 0:l,i=e.shouldReduceDatapoints,s=void 0!==i&&i,c=(null===t||void 0===t?void 0:t.byDay)||[],d=(null===n||void 0===n?void 0:n.byDay)||[];const u=(null===r||void 0===r?void 0:r.byDay)||[],m=a===x2.ThisMonthVersusLastYear,p=a===x2.ThisYearVersusLastYear,g=a===x2.ThisMonthVersusAverageMonth;let h;s&&(c=_2(c),d=_2(d)),h=m||p?[...c,...d]:[...d];const v=T2(h,a);if(!v||0===v.length)return[];let f,E;if(g){const e=(e=>{const t=I2(e,"month"),n=Object.fromEntries(Object.entries(t).filter((e=>{let t=(0,o.A)(e,2)[1];return 0!==(0,MK.A)(t.map((e=>e.summary.sumExpense)))})));if(0===Object.keys(n).length)return[];const a=new Set;Object.values(n).forEach((e=>{e.forEach((e=>{let t=e.groupBy;const n=N.c9.fromISO((null===t||void 0===t?void 0:t.day)||"").day;a.add(n)}))}));const l=Math.max(...a);return[...Array(l).keys()].map((e=>e+1)).map((e=>{let t=0,a=0;return Object.values(n).forEach((n=>{const l=n.find((t=>{let n=t.groupBy;return N.c9.fromISO((null===n||void 0===n?void 0:n.day)||"").day===e}));l&&(t+=l.summary.sumExpense,a+=1)})),{__typename:"AggregateData",summary:{__typename:"TransactionsSummary",sumExpense:a>0?t/a:0},groupBy:{__typename:"AggregateGroupBy",day:N.c9.local().set({day:e}).toISODate()||""}}}))})(u),t=v[v.length-1]||[];f=N2(e),E=N2(t)}else{var y=v.map(N2),b=(0,o.A)(y,2);f=b[0],E=b[1]}return function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];const n=Math.max(e.length,t.length);return(0,jd.A)((n=>{var a,l,r,o;return{day:n+1,balance:null===(a=e[n])||void 0===a?void 0:a.balance,previousBalance:null===(l=t[n])||void 0===l?void 0:l.balance,date:null===(r=e[n])||void 0===r?void 0:r.date,previousDate:null===(o=t[n])||void 0===o?void 0:o.date}}),[...Array(n).keys()])}(E,f)},R2=["currentPeriodDataKey","previousPeriodDataKey","forecastDataKey","selectedTimeRange"],M2=e=>{let t=e.currentPeriodDataKey,n=e.previousPeriodDataKey,l=e.forecastDataKey,r=e.selectedTimeRange,o=(0,En.A)(e,R2);const i=(0,u.useTheme)(),s=(0,JX.A)(BY.A,[n,t,l]);return a.createElement(Do.rT,Object.assign({"data-external-id":"compare-previous-period-line-chart",yDataKeys:s,lineOptions:[{lineColor:"dark"===i.uiTheme?i.color.textLight:i.color.gray,legendName:C2[r].previousPeriodLegend},{lineColor:i.color.orange,hasArea:!0,legendName:C2[r].currentPeriodLegend},{lineColor:i.color.orange,isDashed:!0}]},o,{tooltipComponent:e=>{const l=e.active,s=(0,_a.WS)(e);return a.createElement(Sa.II,{active:l,header:"Total Spending by Day ".concat(null===s||void 0===s?void 0:s[o.xDataKey])},a.createElement(Na.B,{label:C2[r].tooltipCurrentPeriodLabel,value:null!==s&&void 0!==s&&s[t]?(0,rl.vv)(s[t]):"-",dotFillColor:i.color.orange}),a.createElement(Na.B,{label:C2[r].tooltipPreviousPeriodLabel,value:null!==s&&void 0!==s&&s[n]?(0,rl.vv)(s[n]):"-",dotFillColor:i.color.grayLight}))}}))},L2=e=>{let t=e.mergedData,n=e.lastBalance,r=e.selectedTimeRange;const o=(0,u.useTheme)(),i=(0,l.Zp)(),s=(e,n)=>{var a;const l=null===(a=t[e])||void 0===a?void 0:a[n?"previousDate":"date"];i(I.JZ.transactions({queryParams:{startDate:l,endDate:l}}))},c=N.R2.weekdays("short");return a.createElement(P2,{"data-external-id":"cash-flow-dashboard-widget-graph"},a.createElement(M2,{height:232,xDataKey:"day",yAxisProps:{width:"auto"},currentPeriodDataKey:"balance",previousPeriodDataKey:"previousBalance",data:t,formatYAxis:rl.fw,formatXAxis:e=>
1r===x2.ThisWeekVersusLastWeek?c[e-1]:"Day ".concat(e),selectedTimeRange:r,onClickDot:e=>s(e.index,"previousBalance"===e.dataKey)},a.createElement(Ky.r,{x:null===n||void 0===n?void 0:n.day,y:null===n||void 0===n?void 0:n.balance,r:3,stroke:o.color.orange,cursor:"pointer",onClick:()=>s(n?n.day-1:0,!1)},a.createElement(E2.JU,{position:O2(t),content:()=>(0,rl.vv)((null===n||void 0===n?void 0:n.balance)||0),offset:10,style:{fontSize:o.fontSize.xsmall,fontWeight:o.fontWeight.medium,fill:o.color.orange}}))))},O2=e=>{const t=(0,yd.A)((e=>!!e.balance),e);if(!t)return"top";const n=t.day,a=t.balance,l=e.reduce(((e,t)=>{let n=t.balance;return void 0!==n&&n>e?n:e}),0),r=e.length>35?300:25;return a===l?n>r?"left":"right":n>r?"insideBottomRight":a&&a<l?"insideBottomLeft":"top"},P2=u.default.div.withConfig({displayName:"CashFlowDashboardWidgetGraph__Root",componentId:"q7dzzn-0"})(["padding:0 ",";"],vt.YK.default);var B2=n(87173);const z2={search:void 0,categories:void 0,accounts:void 0,absAmountGte:void 0,absAmountLte:void 0,tags:void 0,isUntagged:void 0,startDate:void 0,endDate:void 0,timeframePeriod:void 0,categoryGroups:void 0,goalId:void 0,goals:void 0,savingsGoals:void 0,hasAttachments:void 0,hasNotes:void 0,hideFromReports:void 0,householdMerchants:void 0,ids:void 0,importedFromMint:void 0,isRecurring:void 0,isSplit:void 0,isUncategorized:void 0,merchants:void 0,needsReview:void 0,uploadedStatement:void 0,needsReviewByUser:void 0,needsReviewUnassigned:void 0,isFlexSpending:void 0,syncedFromInstitution:void 0,categoryType:void 0,isInvestmentAccount:void 0,creditsOnly:void 0,debitsOnly:void 0,isPending:void 0,excludeIds:void 0,transactionVisibility:void 0,deletedTransactionVisibility:void 0,ownershipSet:void 0,hasGoalReconciliationRecord:void 0,hasGoalReconciliationAvailable:void 0,businessEntitySet:void 0},F2=u.default.div.withConfig({displayName:"CashFlowDashboardWidget__Container",componentId:"sc-1s8vvx-0"})(["padding-top:",";padding-bottom:",";"],vt.YK.xlarge,vt.YK.default),G2=u.default.div.withConfig({displayName:"CashFlowDashboardWidget__StyledSelectContainer",componentId:"sc-1s8vvx-1"})(["width:100%;min-width:100px;max-width:260px;"]);var Y2=n(38816),U2=n(93243),V2=n(41087),W2=n(17780);const j2="".concat(I.JZ.recurring.mapLiabilities.path,"?flow=").concat("credit_score"),H2=e=>{var t,n,i,s,c;let d=e.data,u=e.toggleCreditScoreTracking,m=e.isToggling;const p=(e=>{const t=(0,l.ok)(),n=(0,o.A)(t,1)[0];return(0,a.useMemo)((()=>e?(0,W2.v)(e,n):void 0),[e,n])})(j2),g=x1(K0.y.CREDIT_SCORE),h=g.trackImpression,v=g.trackCtaClicked,f=(0,V2.H3)(d),E=f.householdMap,y=f.householdEntries,b=f.myHistory,x=(null!==(t=null===b||void 0===b?void 0:b.length)&&void 0!==t?t:0)>=3,w=null===(null===(n=d.spinwheelUser)||void 0===n?void 0:n.creditScoreTrackingStatus)||void 0===(null===(i=d.spinwheelUser)||void 0===i?void 0:i.creditScoreTrackingStatus)||(null===(s=d.spinwheelUser)||void 0===s?void 0:s.creditScoreTrackingStatus)===Ee.HT2.DISABLED;b1({isVisible:w,trackImpression:h});const C={label:_t.ZC.DASHBOARD_CARD.WIDGET_EMPTY.BUTTON_TITLE,href:p,onClick:()=>v(_t.ZC.DASHBOARD_CARD.WIDGET_EMPTY.BUTTON_TITLE)};return a.createElement(a.Fragment,null,(0,r.YW)({trackingStatus:null===(c=d.spinwheelUser)||void 0===c?void 0:c.creditScoreTrackingStatus,myHistory:b}).with({trackingStatus:r.P.union(r.P.nullish,Ee.HT2.DISABLED)},(()=>a.createElement(f1,{color:"teal",icon:a.createElement(fe.S99,null),title:_t.ZC.DASHBOARD_CARD.WIDGET_EMPTY.TITLE,description:_t.ZC.DASHBOARD_CARD.WIDGET_EMPTY.SUBTITLE,cta:C}))).with({trackingStatus:Ee.HT2.PAUSED},(()=>a.createElement(fe.erR,{title:"Credit score tracking paused",description:"Your credit score is not currently being tracked within Monarch.",icon:null,actions:a.createElement(fe.XZZ,{isLoading:m,onClick:()=>u(!0)},"Resume credit score tracking")}))).with({myHistory:r.P.union(r.P.nullish,[])},(()=>a.createElement(fe.erR,{variant:"unstyled",title:"We're preparing your credit data",description:"Your credit score tracking will begin shortly.",icon:a.createElement(fe.ix7,null)}))).with({myHistory:r.P.nonNullable},(()=>a.createElement("div",{className:"-mx-lg flex flex-col gap-sm"},a.createElement("div",{className:"px-lg"},a.createElement(U2.t,{creditScoreSnapshots:b,isCurrentUser:!0,user:E[d.me.id]})),x?a.createElement(a.Fragment,null,a.createElement(fe.AVK,null),a.createElement("div",{className:"px-lg"},a.createElement(Y2.i,{creditScoreSnapshots:b}))):null))).otherwise((()=>null)),y.length>0&&a.createElement(fe.X0s,{className:(0,q.cn)("-mx-lg flex flex-col",!x&&"mt-sm")},a.createElement(fe.X0s.Trigger,{className:(0,q.cn)("\n                flex flex-1 cursor-pointer items-center justify-between border-0\n                bg-background-secondary px-default py-xs text-content-secondary -outline-offset-1\n                not-aria-expanded:-mb-lg\n                not-aria-expanded:focus-visible:rounded-b-md\n              ")},a.createElement(fe.c8D,{weight:"medium",size:"sm",color:"inherit"},"Other household members"),a.createElement(fe.hPJ,{className:"transition-transform in-aria-expanded:rotate-90"})),a.createElement(fe.X0s.Content,null,a.createElement("div",{className:"flex w-full flex-col gap-default divide-y divide-divider-primary pt-default"},y.map((e=>{let t=(0,o.A)(e,2),n=t[0],l=t[1];return a.createElement("div",{className:"px-lg pb-default last:pb-0",key:n},a.createElement(U2.t,{user:E[n],creditScoreSnapshots:l}))}))))))},K2=e=>{let t=e.disabled,n=e.onPauseTracking,r=e.creditScoreTrackingStatus;
1return r&&r!==Ee.HT2.DISABLED?a.createElement(fe.u$N,{"data-external-id":"credit-score-dashboard-widget-menu",align:"end",trigger:a.createElement(fe.SO$,{"aria-label":"Credit score options",disabled:t},a.createElement(fe.V_g,null)),items:[...r===Ee.HT2.ENABLED?[{label:"Pause credit score tracking",onClick:n}]:[],{type:"link",label:"Edit credit data settings",render:a.createElement(l.N_,{to:(0,Ue.AI)("data","remove-credit-data-access")}),closeOnClick:!0,onClick:()=>(0,Ge.u4)(Ye.Kf.EditCreditDataSettingsClicked,{source:Ee.mEJ.DASHBOARD_WIDGET})}]}):null};var q2=n(29066);const $2=N.c9.fromISO("2025-07-07"),Z2=1*iC.EM,J2=2*iC.K5,X2=[Ee.HT2.ENABLED,Ee.HT2.PAUSED];var Q2=n(92618);const e4=e=>{let t=e.column,n=e.widgetNames,l=e.rootProps,r=e.children;const o=(0,Bk.zM)({id:"".concat(t)}).setNodeRef;return a.createElement(Fk.gB,{"data-external-id":"dashboard-widget-column",id:"".concat(t),items:n,strategy:Fk._G},a.createElement("div",Object.assign({ref:o,className:"h-full *:mb-gutter"},l),r))},t4=(e,t)=>{const n=t.filter((e=>{var t;return!(null===(t=e.data.current)||void 0===t||!t.sortable)})),a=t.filter((e=>{var t;return!(null!==(t=e.data.current)&&void 0!==t&&t.sortable)}));if(0===a.length)return(0,Bk.fp)((0,U.A)((0,U.A)({},e),{},{droppableContainers:n}));const l=(e.pointerCoordinates?Bk.TT:Bk.Qo)((0,U.A)((0,U.A)({},e),{},{droppableContainers:a})),r=(0,o.A)(l,1)[0];if(!r)return e.pointerCoordinates?[]:(0,Bk.fp)((0,U.A)((0,U.A)({},e),{},{droppableContainers:n}));const i=n.filter((e=>{var t;return(null===(t=e.data.current)||void 0===t?void 0:t.sortable.containerId)===r.id}));return i.length>0?(0,Bk.fp)((0,U.A)((0,U.A)({},e),{},{droppableContainers:i})):[r]},n4=e=>t4(e,e.droppableContainers),a4=e=>{var t;const n=(null!==(t=e.active.data.current)&&void 0!==t?t:{}).dragType;return t4(e,e.droppableContainers.filter((e=>{var t;return(null===(t=e.data.current)||void 0===t?void 0:t.dragType)===n})))};var l4=n(49868),r4=n(1840),o4=n(75787),i4=n(88858),s4=n(51402);const c4=()=>{const e=U0("web"),t=(0,o.A)(e,2),n=t[0],l=t[1];return{onDragEnd:(0,a.useCallback)((e=>{var t,a,r;const o=(0,s4.k)(e);if(!o)return;const i=n.layout,s=Number(o.source.containerId),c=Number(o.destination.containerId),d=o.id,u=null!==(t=null===(a=i[s])||void 0===a?void 0:a.indexOf(d))&&void 0!==t?t:-1;if(-1===u)return;const m=o.overId?null===(r=i[c])||void 0===r?void 0:r.indexOf(o.overId):0;if(void 0===m||-1===m)return;const p=o.insertAfter?m+1:m,g=s===c?(0,r4.A)(s,(e=>(0,Fk.be)(e,u,p)),i):(0,Wd.A)((0,r4.A)(s,(0,o4.A)(u,1)),(0,r4.A)(c,(0,i4.A)(p,d)))(i);l((0,U.A)((0,U.A)({},n),{},{layout:g}),!0)}),[l,n])}};var d4=n(66767);const u4=()=>{const e=(0,d4.u)("exp-financial-agents","off",{trackImpression:!0}).treatment;return"on"===e||"VA"===e};var m4=n(30433),p4=n(3824),g4=n(74756);const h4=()=>{(0,p4.n)(Ye.H8.CustomizeDashboardOpened);const e=U0("web"),t=(0,o.A)(e,2),n=t[0],l=t[1],i=c4().onDragEnd,s=(0,hK.T)(),c=n.layout,d=n.widgets,m=(0,m4.W)(),p=(0,vQ.N)().preferredVersion,g=(0,ht.S)().isAiFeaturesEnabled,h=u4(),v=(0,l4.E)().isAdviceSunsetOn,f=c.length,E=(0,u.useTheme)();return a.createElement(Rc.L,{"data-external-id":"customize-dashboard-modal",title:g4.$Q.CUSTOMIZE_DASHBOARD.TITLE,description:g4.$Q.CUSTOMIZE_DASHBOARD.DESCRIPTION},a.createElement(Bk.Mp,{sensors:s,collisionDetection:n4,onDragEnd:i,accessibility:{announcements:gK.n}},a.createElement(pK.Z,null),a.createElement(pX.f,{rowGutterPx:0,padding:E.spacing.xlarge},c.map(((e,t)=>{const o=e.filter((e=>(0,r.YW)(e).with(K0.y.CREDIT_SCORE,(()=>m)).with(K0.y.SAVINGS_GOALS,(()=>"v3"===p)).with(K0.y.GOALS,(()=>"v2"===p)).with(K0.y.RECAP,(()=>g)).with(K0.y.BUSINESS_ENTITIES,(()=>!0)).with(K0.y.ADVICE,(()=>!v&&!h)).with(K0.y.FOUND_MONEY,(()=>!v&&h&&g)).otherwise((()=>!0))));return a.createElement(mX.V,{key:t,md:pX.Z/f},a.createElement(e4,{column:t,widgetNames:o},o.map((e=>a.createElement(Hk.U,{key:e,id:e,customDragHandle:!0},a.createElement(DQ.s,{feature:HQ.gC[e]},(t=>{let r=t.hasAccess;return a.createElement("div",{className:" flex items-center justify-between rounded-default bg-background-secondary px-default py-sm text-sm font-medium "},a.createElement("div",{className:"flex items-center"},r&&a.createElement(qH.v,null),a.createElement("span",{className:(0,q.cn)("shrink",r&&"ml-default")},_t.eW[e])),r?a.createElement(ox.k,{checked:d[e].enabled,onChange:t=>{const a=t.target.checked?Ye.H8.WidgetAdded:Ye.H8.WidgetRemoved;(0,Ge.u4)(a,{type:e}),l((0,g0.A)({widgets:{[e]:{enabled:t.target.checked}}},n),!0)}}):a.createElement(_Q.J,null))})))))))})))))};var v4,f4=n(29467),E4=n(8669);!function(e){e.Error="error",e.RunFailed="runFailed",e.Generating="generating",e.HasOpportunities="hasOpportunities",e.AllCompleted="allCompleted",e.NoOpportunities="noOpportunities",e.Onboarding="onboarding"}(v4||(v4={}));const y4=e=>{let t=e.isOptedIn,n=e.isOptingIn,a=e.isGenerating,l=e.latestRunStatus,o=e.hasError,i=e.insights,s=e.completedInsightCount;const c=i.filter((e=>E4.az.includes(e.status))).length,d=i.filter((e=>e.status===Ee.yWn.DENIED)).length;return(0,r.YW)({isOptedIn:t,isOptingIn:n,isGenerating:a,latestRunStatus:l,hasError:o,activeInsightCount:c,completedInsightCount:s,deniedInsightCount:d}).returnType().with({hasError:!0},(()=>v4.Error)).with({isOptingIn:!0},(()=>v4.Generating)).with({isGenerating:!0},(()=>v4.Generating)).with({isOptedIn:!1},(()=>v4.Onboarding)).with({latestRunStatus:Ee.pgv.FAILED,activeInsightCount:0,completedInsightCount:0,deniedInsightCount:0},(()=>v4.RunFailed)).with({activeInsightCount:0,completedInsightCount:0,deniedInsightCount:0,latestRunStatus:Ee.pgv.COMPLETED},(()=>v4.NoOpportunities)).with({activeInsightCount:0,completedInsightCount:r.P.number.gte(1)},(()=>v4.AllCompleted)).otherwise((()=>v4.HasOpportunities))},b4=e=>{var t;return e.status===Ee.yWn.COMPLETED&&null!==(t=e.capturedSavingsLow)&&void 0!==t?t:e.savingsEstimateLow},x4=e=>(0,De.Eb)(e.filter((e=>E4.az.includes(e.status))).map((e=>e.savingsEstimateLow))),w4=e=>{const t=N.c9.local().startOf("day");return[...e].sort(((e,n)=>{const a=e.nextChargeDate?N.c9.fromISO(e.nextChargeDate):null,l=n.nextChargeDate?N.c9.fromISO(n.nextChargeDate):null,r=!!((null===a||void 0===a?void 0:a.isValid)&&a>=t),o=!!((null===l||void 0===l?void 0:l.isValid)&&l>=t);return r&&o?a.toMillis()-l.toMillis():r?-1:o?1:0}))},C4=["rangeIdx"],A4=[{title:_t.V4.UPCOMING_CHARGES,subtitle:_t.V4.OVER_THE_NEXT_WEEK,days:7,section:Ye.WI.UpcomingCharges},{title:_t.V4.MORE_OPPORTUNITIES,subtitle:_t.V4.OVER_THE_NEXT_MONTH,days:30,section:Ye.WI.NextMonth},{title:_t.V4.MORE_OPPORTUNITIES,subtitle:_t.V4.BEYOND_THE_NEXT_MONTH,days:1/0,section:Ye.WI.MoreOpportunities}],I4=e=>{let t=e.insights,n=e.totalCapturedSavings,a=e.ranges,l=void 0===a?A4:a;const r=t.filter((e=>E4.az.includes(e.status))),o=t.filter((e=>e.status===Ee.yWn.COMPLETED)),i=t.filter((e=>e.status===Ee.yWn.DENIED)),s=((e,t)=>{const n=N.c9.local().startOf("day"),a=t.map((()=>[]));e.reduce(((e,a)=>{const l=a.nextChargeDate?N.c9.fromISO(a.nextChargeDate):null;if(!(null===l||void 0===l?void 0:l.isValid)||l<n)return e[t.length-1].push(a),e;const r=l.diff(n,"days").days,o=t.findIndex((e=>r<=e.days));return-1!==o&&e[o].push(a),e}),a);const l=t.map(((e,t)=>({rangeIdx:t,status:"active",label:e.title,subtitle:e.subtitle,section:e.section,total:(0,De.Eb)(a[t].map((e=>b4(e)))),insights:w4(a[t])}))).filter((e=>e.insights.length>0));return l.map(((e,n)=>{let a=e.rangeIdx,r=(0,En.A)(e,C4);const o=a===t.length-1;return 1===l.length&&o?(0,U.A)((0,U.A)({},r),{},{label:_t.V4.OPPORTUNITIES,subtitle:void 0}):0===n?(0,U.A)((0,U.A)({},r),{},{label:_t.V4.UPCOMING_CHARGES}):o?(0,U.A)((0,U.A)({},r),{},{label:_t.V4.ALL_OTHER_OPPORTUNITIES,subtitle:void 0}):r}))})(r,l);return o.length>
10&&s.push({status:"completed",label:_t.V4.COMPLETED_SECTION_TITLE,subtitle:_t.V4.COMPLETED_SECTION_TIME_LABEL,section:Ye.WI.MoreOpportunities,total:n,insights:o}),i.length>0&&s.push({status:"denied",label:_t.V4.NOT_INTERESTED_SECTION_TITLE,section:Ye.WI.MoreOpportunities,total:0,insights:i}),s},k4={icon:"dollar-sign",iconVariant:"secondary",title:_t.$y.LOADING_TITLE,description:_t.$y.LOADING_DESCRIPTION},S4={icon:"clock",iconVariant:"secondary",title:_t.vP.RUN_FAILED_TITLE,description:_t.vP.RUN_FAILED_DESCRIPTION},N4={icon:"lightbulb-filled",iconVariant:"success",title:_t.vP.NO_OPPORTUNITIES_EMPTY_TITLE,description:_t.vP.NO_OPPORTUNITIES_EMPTY_DESCRIPTION},T4=function(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return(0,r.YW)(e).with(v4.Generating,(()=>t?S4:k4)).with(v4.RunFailed,(()=>S4)).with(v4.NoOpportunities,(()=>N4)).otherwise((()=>null))};var _4=n(44777),D4=n(96103);const R4=e=>{let t=e.isOptedIn,n=e.statuses,l=void 0===n?E4.az:n,r=e.skip,s=void 0!==r&&r;var c;const d=(0,a.useState)(!1),u=(0,o.A)(d,2),m=u[0],p=u[1],g=(()=>{const e=(0,i.n)(D4.FD),t=(0,o.A)(e,2),n=t[0];return{isSettingFinancialInsightsEnabled:t[1].loading,setFinancialInsightsEnabled:(0,a.useCallback)((async e=>{var t;const a=(await n({variables:{input:{enabled:e}}})).data,l=null===a||void 0===a?void 0:a.setFinancialInsightsEnabled;if(null===(t=null===l||void 0===l?void 0:l.errors)||void 0===t?void 0:t.message)throw new Error(l.errors.message);return l}),[n])}})(),h=g.setFinancialInsightsEnabled,v=(0,_4.o)({statuses:l,skip:!t||s}),f=v.insights,E=v.summary,y=v.latestRunStatus,b=v.latestRunCreatedAt,x=v.expectedInsightsCount,w=v.isLoading,C=v.error,A=v.refetch,I=null!==y&&E4.Y3.includes(y),k=y===Ee.pgv.COMPLETED&&x>0&&0===f.length&&0===(null!==(c=null===E||void 0===E?void 0:E.completedCount)&&void 0!==c?c:0),S=m||t&&(I||k),N=w&&!m,T=(0,a.useState)((()=>!(!S||!b)&&Date.now()-new Date(b).getTime()>E4.xV)),_=(0,o.A)(T,2),D=_[0],R=_[1];(0,a.useEffect)((()=>{if(!S||!b||m)return void R(!1);const e=Date.now()-new Date(b).getTime();if(e>E4.xV)return void R(!0);const t=setTimeout((()=>R(!0)),E4.xV-e);return()=>clearTimeout(t)}),[S,m,b]);const M=m&&t&&(I||k)&&!w;(0,a.useEffect)((()=>{M&&p(!1)}),[M]);const L=(0,a.useCallback)((async()=>{p(!0);try{const e=await h(!0);return A(),e}catch(e){throw p(!1),e}}),[h,A]);return{insights:f,summary:E,latestRunStatus:y,isGenerating:S,isGeneratingOverdue:D,isOptingIn:m,isLoading:N,error:C,refetch:A,startGeneration:L}},M4=e=>{let t=e.icon,n=e.variant;return a.createElement("div",{"data-external-id":"state-icon-circle",className:L4({variant:n})},a.createElement(sl.ZQ,{name:t,size:32}))},L4=(0,y0.tv)({base:"flex size-4xl shrink-0 items-center justify-center rounded-round",variants:{variant:{secondary:"bg-background-secondary text-content-secondary",success:"bg-background-success text-content-success"}},defaultVariants:{variant:"secondary"}});var O4,P4,B4,z4,F4,G4,Y4,U4,V4,W4,j4,H4,K4,q4,$4;const Z4="https://monarch-static-assets-us-east-2.s3.us-east-2.amazonaws.com/found-money/web_dashboard_widget.png",J4="https://monarch-static-assets-us-east-2.s3.us-east-2.amazonaws.com/found-money/web_dashboard_widget_dark.png",X4=e=>{var t;let n=e.summary,r=e.opportunityCount,o=e.insights;const i=(0,l.Zp)(),s=x4(o);return a.createElement(c3,{"data-external-id":"summary-header",onClick:()=>i(I.JZ.advice({}))},a.createElement(d3,null,a.createElement(g3,null,a.createElement(xt.v,{size:"xxlarge",weight:"medium",color:"content.success"},(0,rl.T3)(null!==(t=null===n||void 0===n?void 0:n.totalCapturedSavings)&&void 0!==t?t:0)),a.createElement(xt.v,{size:"small",color:"content.secondary"},_t.vP.RECOUPED_LABEL)),a.createElement(g3,null,a.createElement(xt.v,{size:"xxlarge",weight:"medium"},r),a.createElement(xt.v,{size:"small",color:"content.secondary"},_t.vP.OPPORTUNITIES_LEFT_LABEL)),a.createElement(g3,null,a.createElement(xt.v,{size:"xxlarge",weight:"medium",color:"content.info"},(0,rl.T3)(s)),a.createElement(xt.v,{size:"small",color:"content.secondary"},_t.vP.POTENTIAL_LEFT_LABEL))))},Q4=e=>{let t=e.variant,n=e.wide,l=void 0!==n&&n,r=e.title,o=e.description,i=e.actions;const s=l?w3:x3;return a.createElement(s,{"data-external-id":"empty-state-content"},a.createElement(C3,{$variant:t},a.createElement(sl.ZQ,{name:"alert-triangle",size:32})),a.createElement("div",{className:"flex flex-col items-center justify-center gap-3xs"},a.createElement(xt.v,{weight:"medium",align:"center"},r),a.createElement(xt.v,{size:"small",align:"center"},o)),i)},e3=e=>{let t=e.insights,n=e.summary,l=e.onInsightClick;const r=I4({insights:t,totalCapturedSavings:0}).filter((e=>"active"===e.status)).flatMap((e=>e.insights)).slice(0,3);return a.createElement(a.Fragment,null,a.createElement(X4,{summary:n,opportunityCount:t.length,insights:t}),a.createElement("div",{className:"flex flex-col"},r.map((e=>{var t;const n=b4(e),r=Math.max(0,e.currentAnnualCost-n);return a.createElement(a.Fragment,{key:e.id},a.createElement(b3,null),a.createElement(u3,{onClick:()=>l(e.id,e)},a.createElement(m3,null,a.createElement(Wl._,{url:null!==(t=e.merchantLogoUrl)&&void 0!==t?t:null,size:40}),a.createElement("div",{className:"flex flex-col"},a.createElement(xt.v,{weight:"medium"},e.merchantNameDisplay),a.createElement(xt.v,{color:"content.secondary"},e.dashboardSubtitle))),a.createElement("div",{className:"flex items-baseline justify-end gap-2xs"},a.createElement(xt.v,{weight:"medium"},(0,rl.T3)(r)),a.createElement(f3,{color:"content.secondary"},(0,rl.T3)(e.currentAnnualCost),"/yr")),a.createElement(p3,null,a.createElement(v3,null,a.createElement(xt.v,{size:"xsmall",weight:"medium",color:"content.info"},_t.vP.SAVE_AMOUNT((0,rl.T3)(n)))))))}))))},t3=e=>{var t;let n=e.summary;const l=(0,rl.T3)(null!==(t=null===n||void 0===n?void 0:n.totalCapturedSavings)&&void 0!==t?t:0);return a.createElement(a.Fragment,null,a.createElement(X4,{summary:n,opportunityCount:0,insights:[]}),a.createElement(b3,null),a.createElement(x3,null,a.createElement(f4.R,{size:64}),a.createElement("div",{className:"flex flex-col items-center justify-center gap-3xs"},a.createElement(xt.v,{weight:"medium",align:"center"},_t.vP.ALL_COMPLETED_TITLE(l)),a.createElement(xt.v,{size:"small",align:"center"},_t.vP.ALL_COMPLETED_DESCRIPTION))))},n3=e=>{let t=e.opportunityCount,n=e.insights,l=e.onCheckThemOut;const r=x4(n);return a.createElement("div",{"data-external-id":"first-results-content",className:"flex flex-col items-center justify-center gap-default pb-2xl"},a.createElement("div",{className:"flex flex-col items-center justify-center"},a.createElement(y3,null,a.createElement(xt.v,{size:"20",weight:"medium",align:"center"},_t.vP.FIRST_RESULTS_TITLE),a.createElement(E3,{color:"content.secondary",align:"center"},_t.vP.FIRST_RESULTS_DESCRIPTION)),a.createElement("div",{className:"flex justify-center gap-2xs px-sm py-default"},a.createElement(h3,null,a.createElement(xt.v,{size:"xxlarge",weight:"medium",color:"content.info",align:"center"},(0,rl.T3)(r)),a.createElement(xt.v,{size:"small",color:"content.secondary",align:"center"},_t.vP.FIRST_RESULTS_POTENTIAL_LABEL)),a.createElement(h3,null,a.createElement(xt.v,{size:"xxlarge",weight:"medium",align:"center"},t),a.createElement(xt.v,{size:"small",color:"content.secondary",align:"center"},_t.vP.OPPORTUNITIES_LABEL)))),a.createElement(cu.WT,{size:"small",onClick:l},_t.vP.FIRST_RESULTS_CTA))},a3=e=>
1{let t=e.isOptingIn,n=e.onStartSaving,l=e.onLearnMore,r=e.widgetImageUrl;return a.createElement("div",{"data-external-id":"onboarding-content",className:"flex items-center justify-center gap-2xl px-xl py-lg"},a.createElement(i3,null,a.createElement(s3,{src:r,alt:"Found Money widget graphic"})),a.createElement(r3,null,a.createElement("div",{className:"flex flex-col gap-xs"},a.createElement(xt.v,{weight:"medium"},_t.vP.ONBOARDING_HEADLINE),a.createElement(xt.v,{size:"small",color:"content.secondary"},_t.vP.ONBOARDING_DESCRIPTION)),a.createElement(o3,null,a.createElement(cu.gs,{size:"small",onClick:n,pending:t},_t.vP.CTA_BUTTON),a.createElement(wt.Xb,{size:"small",onClick:l},_t.vP.LEARN_MORE_BUTTON))))},l3=e=>{let t=e.content;return a.createElement("div",{"data-external-id":"insights-state-card",className:"flex flex-col items-center justify-center gap-default px-xl py-4xl"},a.createElement(M4,{icon:t.icon,variant:t.iconVariant}),a.createElement("div",{className:"flex flex-col items-center justify-center gap-2xs"},a.createElement(xt.v,{size:"large",weight:"medium",align:"center"},t.title),a.createElement(A3,null,t.description)))},r3=$d.s.div(O4||(O4=(0,wc.A)(["flex flex-1 flex-col justify-center gap-default self-stretch"]))),o3=$d.s.div(P4||(P4=(0,wc.A)(["flex shrink-0 gap-xs self-start"]))),i3=$d.s.div(B4||(B4=(0,wc.A)(["flex min-w-0 flex-1 flex-col items-center"]))),s3=u.default.img.withConfig({displayName:"FoundMoneyDashboardWidget__WidgetGraphic",componentId:"lffszl-0"})(["width:100%;height:auto;max-height:","px;object-fit:contain;border-radius:",";"],375,vt.r8.default),c3=$d.s.div(z4||(z4=(0,wc.A)(["flex cursor-pointer px-sm py-3xs hover:bg-background-primary-hover"]))),d3=$d.s.div(F4||(F4=(0,wc.A)(["flex h-25 w-full items-center justify-center gap-2xs p-default"]))),u3=$d.s.div(G4||(G4=(0,wc.A)(["flex cursor-pointer items-center gap-xl px-lg py-default last:rounded-b-default hover:bg-background-primary-hover"]))),m3=$d.s.div(Y4||(Y4=(0,wc.A)(["flex min-w-0 flex-1 items-center gap-sm"]))),p3=$d.s.div(U4||(U4=(0,wc.A)(["flex w-22.5 shrink-0 items-center justify-end gap-xs"]))),g3=$d.s.div(V4||(V4=(0,wc.A)(["flex flex-1 flex-col items-center justify-center gap-2xs"]))),h3=$d.s.div(W4||(W4=(0,wc.A)(["flex w-43.25 flex-col items-center justify-center gap-2xs"]))),v3=$d.s.div(j4||(j4=(0,wc.A)(["flex items-center gap-2xs rounded-sm bg-background-info px-xs py-0.75"]))),f3=(0,u.default)(xt.v).withConfig({displayName:"FoundMoneyDashboardWidget__StrikethroughText",componentId:"lffszl-1"})(["text-decoration:line-through;"]),E3=(0,u.default)(xt.v).withConfig({displayName:"FoundMoneyDashboardWidget__ConstrainedDescription",componentId:"lffszl-2"})(["max-width:","px;"],321),y3=$d.s.div(H4||(H4=(0,wc.A)(["flex max-w-86.25 flex-col items-center justify-center gap-2xs pt-xl"]))),b3=$d.s.div(K4||(K4=(0,wc.A)(["h-px w-full bg-divider-primary"]))),x3=$d.s.div(q4||(q4=(0,wc.A)(["\n  flex max-w-75 flex-col items-center justify-center gap-default self-center px-default\n  py-2xl\n"]))),w3=$d.s.div($4||($4=(0,wc.A)(["\n  flex max-w-119 flex-col items-center justify-center gap-default self-center px-default\n  py-2xl\n"]))),C3=$d.s.div.transientProps(["$variant"])((e=>["flex shrink-0 items-center justify-center rounded-round size-[64px]","warning"===e.$variant?"bg-background-warning text-content-warning":"bg-background-danger text-content-danger"])),A3=(0,u.default)(xt.v).attrs({color:"content.secondary",align:"center"}).withConfig({displayName:"FoundMoneyDashboardWidget__StateCardDescription",componentId:"lffszl-3"})(["max-width:","px;"],456);var I3,k3,S3,N3,T3,_3,D3=n(55280),R3=n(90117),M3=n(2980);const L3=(0,$d.s)(b0)(I3||(I3=(0,wc.A)([""]))),O3=$d.s.div(k3||(k3=(0,wc.A)(["\n  flex max-w-150 flex-col items-center gap-xl self-center px-lg py-3xl\n  min-[2200px]:max-w-none min-[2200px]:flex-row min-[2200px]:justify-center min-[2200px]:gap-4xl\n"]))),P3=$d.s.div(S3||(S3=(0,wc.A)(["\n  contents\n  min-[2200px]:flex min-[2200px]:w-83 min-[2200px]:shrink-0 min-[2200px]:flex-col min-[2200px]:items-start min-[2200px]:gap-xl\n"]))),B3=$d.s.div(N3||(N3=(0,wc.A)(["order-1 flex w-full flex-col gap-2xs text-center min-[2200px]:text-left"]))),z3=$d.s.div(T3||(T3=(0,wc.A)(["\n  order-2 w-full overflow-hidden rounded-xs border border-divider-primary bg-background-secondary\n  min-[2200px]:h-71.25 min-[2200px]:w-132 min-[2200px]:shrink-0\n"]))),F3=$d.s.img(_3||(_3=(0,wc.A)(["block h-auto w-full"]))),G3=Ee.FUs;var Y3=n(26680),U3=n(51755);const V3=e=>{let t=e.returnPercent,n=e.className;return a.createElement(Y3.g,{"data-external-id":"return-percent-pill",className:n,value:t,formatter:e=>null!==e&&void 0!==e?(0,De.S7)(Math.abs(e)):"-",icon:(0,U3.UD)(null!==t&&void 0!==t?t:0,0,{equal:void 0,lessThan:a.createElement(fe.Per,null),greaterThan:a.createElement(fe.UWG,null)})})},W3=e=>{let t=e.ticker,n=e.securityName,l=e.currentPriceDollars,r=e.returnPercent;return a.createElement("div",{"data-external-id":"investments-dashboard-widget-top-mover-row",className:"flex items-center justify-between overflow-x-hidden border-t border-divider-primary px-lg py-default"},a.createElement("div",{className:"flex overflow-x-hidden"},a.createElement("span",{className:"mr-xs font-medium"},t),a.createElement("span",{className:"truncate text-sm text-content-secondary"},n)),a.createElement("div",{className:"flex items-center"},a.createElement("span",{className:"mr-default text-right font-medium"},(0,rl.vv)(l)),a.createElement(V3,{returnPercent:r})))},j3=Ee.RUh;var H3=n(97248);const K3=Ee.HoL;var q3=n(21105),$3=n(50223),Z3=n(5360);const J3=e=>{let t=e.onClose,n=e.refetch;const l=(0,i.n)(Z3.h),r=(0,o.A)(l,1)[0],s=(0,Pc.e)(!1),c=(0,o.A)(s,2),d=c[0],u=c[1].setOn,m=(0,Pc.e)(!1),p=(0,o.A)(m,2),g=p[0],h=p[1].setOn;return a.createElement(Eu.lV,{"data-external-id":"invite-member-modal-v2",mutation:r,transformValuesBeforeSubmit:e=>(0,U.A)((0,U.A)({},e),{},{relationshipToOwner:Ee.bNR.PARTNER}),onSubmitSuccess:()=>{(0,Ge.u4)(Ye.z.InvitePartnerSent,{action_source:"dashboard_widget"}),n(),u()},onError:e=>{e.errors.code===Ee.O4y.HOUSEHOLD_INVITE_USER_ALREADY_EXISTS&&h()}},d?a.createElement(Rc.L,null,a.createElement(hu.c.Consumer,null,(e=>{let t=e.values;return a.createElement("div",{className:"flex flex-col items-center justify-center"},a.createElement(t5,{center:!0},a.createElement(e5,null)),a.createElement("div",{className:"mx-lg flex flex-col items-center"},a.createElement(xt.v,{weight:"bold",size:"large"},"Invite sent"),a.createElement(xt.v,{color:"gray11",weight:"medium"},t.email),a.createElement(n5,{color:"gray11",align:"center"},_t.n3.MEMBER_SETTINGS.INVITE_MEMBER.POST_ACCEPTANCE_DESCRIPTION)),a.createElement("div",{className:"m-lg flex items-center rounded-sm bg-background-info p-sm"},a.createElement(a5,{color:"blue11",name:"info"}),a.createElement(xt.v,{color:"blue11",weight:"book"},"Once they accept, your partner will have full access to your household's data. Manage access in"," ",a.createElement(l5,{href:"/settings/members"},"Settings ",">"," Members"),".")))})),a.createElement(Cq.R,{justifyEnd:!0},a.createElement(cu.WT,{onClick:t},"Okay"))):a.createElement(Rc.L,{title:"Invite your partner"},a.createElement(r5,{column:!0},g&&a.createElement(Q3,null,a.createElement(xt.v,{size:"small"},"This user already has a Monarch account. They'll have to delete their existing household before they can join yours and collaborate.")),a.createElement("div",{className:"flex flex-col gap-default"},a.createElement(o5,{name:"email",placeholder:"Your partner's email",email:!0,required:!0}),a.createElement(xt.v,{color:"textLight",size:"small"},_t.n3.MEMBER_SETTINGS.INVITE_MEMBER.PARTNER_DESCRIPTION)),a.createElement(i5,null),a.createElement("div",{className:"flex flex-col gap-default"},a.createElement($3.u,{iconColor:"content.brand",headingFontSize:"base",subheadingFontSize:"small"}))),a.createElement(Cq.R,{justifyEnd:!0},a.createElement(wt.Xb,{onClick:()=>{(0,Ge.u4)(Ye.z.InvitePartnerSkipped,{action_source:"dashboard_widget"}),t()}},"Skip for now"),a.createElement(X3,null))))},X3=()=>{const e=(0,hu.x)().values.email,t=!e||""===e.trim();return a.createElement(cu.WT,{"data-external-id":"invite-button",type:"submit",disabled:t},"Invite")},Q3=(0,u.default)(fu.g).attrs({type:"error"}).withConfig({displayName:"InviteMemberModalV2__ErrorContainer",componentId:"qdcil6-0"})(["display:flex;align-items:center;"]),e5=(0,u.default)(sl.ZQ).attrs({name:"check"}).withConfig({displayName:"InviteMemberModalV2__CheckIcon",componentId:"qdcil6-1"})(["color:",";width:",";height:",";"],(e=>e.theme.color.textWhite),(e=>e.theme.spacing.xxlarge),(e=>e.theme.spacing.xxlarge)),t5=(0,u.default)(m.g).withConfig({displayName:"InviteMemberModalV2__CheckContainer",componentId:"qdcil6-2"})(["background-color:",";width:56px;height:56px;border-radius:100%;margin-top:",";margin-bottom:",";"],(e=>e.theme.color.green),(e=>e.theme.spacing.xxlarge),(e=>e.theme.spacing.xlarge)),n5=(0,u.default)(xt.v).withConfig({displayName:"InviteMemberModalV2__SecondaryText",componentId:"qdcil6-3"})(["text-wrap:balance;"]),a5=(0,u.default)(sl.ZQ).withConfig({displayName:"InviteMemberModalV2__InfoIcon",componentId:"qdcil6-4"})(["width:",";height:",";color:",";margin-right:",";flex-shrink:0;"],(e=>e.theme.spacing.default),(e=>e.theme.spacing.default),(e=>e.theme.color.blue),(e=>e.theme.spacing.small)),l5=u.default.a.withConfig({displayName:"InviteMemberModalV2__SettingsLink",componentId:"qdcil6-5"})(["color:",";font-weight:",";cursor:pointer;"],(e=>e.theme.color.blue11),(e=>e.theme.fontWeight.medium)),r5=(0,u.default)(m.g).withConfig({displayName:"InviteMemberModalV2__ModalContent",componentId:"qdcil6-6"})(["padding:",";"],(e=>e.theme.spacing.large)),o5=(0,u.default)(Qw.X).withConfig({displayName:"InviteMemberModalV2__EmailInput",componentId:"qdcil6-7"})([".input-field{border:2px solid ",";border-radius:8px;padding:12px 16px;font-size:16px;&:focus{border-color:",";outline:none;}}"],(e=>e.theme.color.blueLight),(e=>e.theme.color.blue)),i5=u.default.hr.withConfig({displayName:"InviteMemberModalV2__LineBreak",componentId:"qdcil6-8"})(["margin:"," 0;width:100%;height:1px;color:",";background-color:",";border:none;"],(e=>e.theme.spacing.xlarge),(e=>
1e.theme.color.grayBackground),(e=>e.theme.color.grayBackground));var s5,c5=n(51855),d5=n(50505),u5=n(40854);!function(e){e.AddAccount="add-account",e.ReviewSpending="review-spending",e.CustomizeCategories="customize-categories",e.TryDesktop="try-desktop",e.CreateGoal="create-goal",e.CreatePlan="create-plan",e.InvitePartner="invite-partner",e.ForecastFuture="forecast-future",e.TrackBusiness="track-business"}(s5||(s5={}));const m5=[{name:s5.AddAccount,icon:"\ud83c\udfe6",title:"Add an account",subheader:"Link your main spending account"},{name:s5.ReviewSpending,icon:"\ud83d\udcb3",title:"Review your spending",subheader:"Check out your recent transactions"},{name:s5.CustomizeCategories,icon:"\u2728",title:"Customize categories",subheader:"Automate your tracking"}],p5=[{name:s5.CreatePlan,icon:"\ud83d\udcc8",title:"Create a budget",subheader:"Pick categories to keep an eye on"},{name:s5.CreateGoal,icon:"\ud83c\udfaf",title:"Create a goal",subheader:"Set savings targets and track progress"}],g5={name:s5.TryDesktop,icon:"\ud83d\udcbb",title:"Go deeper on desktop",subheader:"Access web exclusive reports"},h5={name:s5.InvitePartner,icon:"\ud83e\udd1d",title:"Invite your partner",subheader:"Share a complete financial picture"},v5={name:s5.ForecastFuture,icon:"\ud83d\udd2e",title:"Forecast your future",subheader:"Model your financial future"},f5={name:s5.TrackBusiness,icon:"\ud83d\udcbc",title:"Track your business",subheader:"Manage income and expenses for your business"},E5=(0,Qt.J)("\n  query Common_OnboardingChecklist {\n    hasAccounts\n    goalsV2 {\n      id\n    }\n    savingsGoals {\n      id\n    }\n    budgetStatus {\n      hasBudget\n    }\n    me {\n      id\n      name\n      displayName\n      profile {\n        id\n        hasSeenCategoriesManagementTour\n        collaboratesOnFinancesDetailed\n        hasReviewedSpending\n        completedForecastOnboardingAt\n      }\n      userDevicesUsage {\n        hasSignedUpOnMobileApp\n        hasLoggedInOnDesktop\n      }\n    }\n    householdInvites(includeInactive: true) {\n      id\n      isRevoked\n    }\n  }\n");var y5=n(40796);const b5=52,x5=2*Math.PI*19.5,w5=e=>{let t=e.completed,n=e.total;const l=n>0?t/n:0,r=(0,a.useState)(0),i=(0,o.A)(r,2),s=i[0],c=i[1];return(0,a.useEffect)((()=>{let e;const t=requestAnimationFrame((()=>{e=requestAnimationFrame((()=>{c(l)}))}));return()=>{cancelAnimationFrame(t),void 0!==e&&cancelAnimationFrame(e)}}),[l]),a.createElement(T5,{"data-external-id":"onboarding-progress-circle"},a.createElement(_5,{width:b5,height:b5},a.createElement(D5,{cx:26,cy:26,r:19.5,strokeWidth:5}),a.createElement(R5,{cx:26,cy:26,r:19.5,strokeWidth:5,strokeLinecap:"round",$progress:s})),a.createElement(M5,null,t,"/",n))},C5=e=>{let t=e.completed,n=e.className;return a.createElement("span",{"data-external-id":"checklist-item-indicator","aria-hidden":!0,className:(0,q.cn)("flex size-4 shrink-0 items-center justify-center rounded-2xs border",t?"border-border-brand bg-background-brand":"border-border-secondary",n)},t&&a.createElement(fe.GdR,{size:11,className:"text-content-white"}))},A5=u.default.div.withConfig({displayName:"OnboardingDashboardWidget__RowsContainer",componentId:"sc-1u6gqio-0"})(["padding:"," "," 0;@media (max-width:500px){padding-left:",";padding-right:",";}"],vt.YK.default,vt.YK.default,vt.YK.xsmall,vt.YK.xsmall),I5=u.default.div.withConfig({displayName:"OnboardingDashboardWidget__RowContent",componentId:"sc-1u6gqio-1"})(["margin:0 ",";flex:1;min-width:0;"],vt.YK.xsmall),k5=u.default.span.withConfig({displayName:"OnboardingDashboardWidget__TitleRow",componentId:"sc-1u6gqio-2"})(["display:flex;align-items:center;gap:",";line-height:20px;"],vt.YK.xsmall),S5=u.default.span.withConfig({displayName:"OnboardingDashboardWidget__RowTitle",componentId:"sc-1u6gqio-3"})(["line-height:20px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;min-width:0;",""],(e=>{let t=e.$checked,n=e.theme;return t&&(0,u.css)(["text-decoration:line-through;color:",";"],n.variables.color.content.secondary)})),N5=u.default.span.withConfig({displayName:"OnboardingDashboardWidget__RowSubheader",componentId:"sc-1u6gqio-4"})(["display:block;margin-top:0;font-size:",";color:",";white-space:nowrap;overflow:hidden;text-overflow:ellipsis;"],vt.J.small,vt.Ee.color.content.secondary),T5=u.default.div.withConfig({displayName:"OnboardingDashboardWidget__
1CircleProgressRoot",componentId:"sc-1u6gqio-5"})(["display:flex;align-items:center;justify-content:center;position:relative;width:","px;height:","px;flex-shrink:0;min-width:","px;"],b5,b5,b5),_5=u.default.svg.withConfig({displayName:"OnboardingDashboardWidget__CircleProgressSvg",componentId:"sc-1u6gqio-6"})(["position:absolute;transform:rotate(-90deg);"]),D5=u.default.circle.withConfig({displayName:"OnboardingDashboardWidget__CircleProgressTrack",componentId:"sc-1u6gqio-7"})(["fill:none;stroke:",";"],vt.Ee.color.divider.primary),R5=u.default.circle.withConfig({displayName:"OnboardingDashboardWidget__CircleProgressArc",componentId:"sc-1u6gqio-8"})(["fill:none;stroke:",";stroke-dasharray:",";stroke-dashoffset:",";transition:stroke-dashoffset 0.5s cubic-bezier(0.4,0,0.2,1);"],vt.Ee.color.content.success,x5,(e=>{let t=e.$progress;return x5*(1-t)})),M5=u.default.span.withConfig({displayName:"OnboardingDashboardWidget__CircleProgressText",componentId:"sc-1u6gqio-9"})(["position:relative;z-index:1;font-size:11px;font-weight:",";color:",";"],vt.Wy.medium,vt.Ee.color.content.primary),L5=(0,u.default)(m.g).attrs({alignCenter:!0,justifyBetween:!0}).withConfig({displayName:"OnboardingDashboardWidget__Footer",componentId:"sc-1u6gqio-10"})(["padding:"," "," ",";animation:fadeInUp 0.4s ease-out 0.35s backwards;@keyframes fadeInUp{from{opacity:0;transform:translateY(12px);}to{opacity:1;transform:translateY(0);}}"],vt.YK.default,vt.YK.default,vt.YK.default),O5=u.default.span.withConfig({displayName:"OnboardingDashboardWidget__HideOnMobile",componentId:"sc-1u6gqio-11"})(["@media (max-width:500px){display:none;}"]),P5=u.default.button.withConfig({displayName:"OnboardingDashboardWidget__DismissLink",componentId:"sc-1u6gqio-12"})(["display:flex;align-items:center;gap:4px;background:none;border:none;padding:0;cursor:pointer;font-size:",";font-weight:",";color:",";:disabled{opacity:0.35;cursor:default;}:hover:not(:disabled){color:",";}"],vt.J.small,vt.Wy.medium,vt.Ee.color.content.secondary,vt.Ee.color.content.primary),B5=(0,u.default)(P5).withConfig({displayName:"OnboardingDashboardWidget__DismissWidgetLink",componentId:"sc-1u6gqio-13"})(["margin-left:auto;"]);var z5=n(45785),F5=n(52488);const G5=["value","mantissa"],Y5=e=>{let t=e.value,n=e.mantissa,l=void 0===n?0:n,r=(0,En.A)(e,G5);return a.createElement("span",Object.assign({"data-external-id":"animated-currency"},fl.zs),(0,WQ.K)()?a.createElement("span",{className:"inline-block h-[1.5em] leading-[1.5em]"},rl.y1):a.createElement(F5.Ay,Object.assign({value:t||0,format:{style:"currency",currency:"USD",minimumFractionDigits:l,maximumFractionDigits:l},locales:"en-US"},r)))};var U5=n(31036),V5=n(27184);const W5={negative:"text-content-danger bg-background-danger [&_number-flow-react::part(left)]:text-content-danger",zero:"text-content-secondary bg-background-secondary [&_number-flow-react::part(left)]:text-content-secondary",positive:"text-content-success bg-background-success [&_number-flow-react::part(left)]:text-content-success"},j5=e=>{let t=e.data,n=e.isLoading;const l=(0,a.useMemo)((()=>{const e=t.find((e=>e.type===V5.ZV));return(e=>{const t=Math.round(e);return 0===Math.abs(t)?0:t})((null===e||void 0===e?void 0:e.budgeted)||0)}),[t]);return a.createElement(fe.k_P.Root,{"data-external-id":"plan-summary-widget-header",variant:"tooltip",size:"xs"},a.createElement(fe.k_P.Trigger,{nativeButton:!1,openOnHover:!0,delay:500,render:a.createElement("div",{className:(0,q.cn)("flex w-full flex-col rounded-default p-gutter text-center font-medium gap-3xs",W5[K5(l)],"focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-border-info focus-visible:outline-solid","select-text")},a.createElement(kD.c,{color:"inherit",size:"2xl",weight:"medium"},n?"-":a.createElement(Y5,{value:l})),a.createElement(kD.c,{color:"inherit",weight:"medium",className:"inline-flex items-center justify-center gap-2xs"},"Left to budget",a.createElement(fe.ucZ,{size:"sm"})))}),a.createElement(fe.k_P.Content,{side:"bottom",className:"p-0"},a.createElement(U5.R,{rows:H5(t)}),a.createElement(fe.k_P.Arrow,null)))},H5=e=>{const t=e.find((e=>e.type===V5.ZV)),n=e.filter((e=>e.type!==V5.ZV)).map((e=>({title:e.name||"",value:e.budgeted||0})));return n.push({title:"Left to budget",value:(null===t||void 0===t?void 0:t.budgeted)||0,type:"income",emphasis:!0}),n},K5=e=>(0,r.YW)(e).when((e=>e<0),(()=>"negative")).with(0,(()=>"zero")).otherwise((()=>"positive"));var q5=n(31137);const $5={green:"progress-success",red:"progress-danger",yellow:"progress-warning",blue:"progress-info",orange:"progress-brand"},Z5=e=>{var t;return null!==(t=$5[e])&&void 0!==t?t:"content-brand"},J5=e=>{e.id;let t=e.title,n=e.actual,l=e.budgeted,i=(e.remaining,e.rollover),s=e.isLoading,c=e.type,d=e.ticks,u=e.titleSize,m=void 0===u?"small":u;const p=zX(l,i),g=(0,a.useMemo)((()=>c===Ee.Iaz.FLEXIBLE),[c]),h=c,v=FX(p-n,c),f=d||[],E=(0,o.A)(f,1)[0],y=g&&!!E,b=(0,De.hj)(n),x=(0,De.hj)(p),w=y?Math.min(b,E.percent*x):b,C=y?Math.max(0,b-w):0,A=YX(w,x),I=YX(C,x);return a.createElement("div",Object.assign({},(0,Ex.p)("plan-summary-widget-row"),{className:" m-[0_calc(var(--inner-padding)*-1)] flex flex-col gap-xs px-lg py-default not-last:border-b not-last:border-divider-primary last:pb-0 "}),s?a.createElement(X5,null):a.createElement(a.Fragment,null,a.createElement("div",{className:"flex justify-between"},a.createElement(fe.c8D,{size:"small"===m?"sm":"base"},t),a.createElement(fe.c8D,{size:"sm",color:"secondary"},a.createElement(fe.PED,Object.assign({value:l,style:"currency",precision:0,size:"sm",color:"secondary"},fl.zs))," ","planned")),a.createElement(fe.yDW,{value:A,max:1,color:Z5((0,q5.Yw)(v,h,!1))},a.createElement(fe.yDW.Track,null,I>0&&a.createElement(fe.yDW.Fill,{value:A+I,color:Z5((0,q5.Yw)(v,h,!0))}),a.createElement(fe.yDW.Fill,null)),null===d||void 0===d?void 0:d.map(((e,t)=>a.createElement(fe.Yvj,{key:t,content:e.name},a.createElement(fe.yDW.Tick,{value:e.percent}))))),a.createElement("div",{className:"flex justify-between"},a.createElement(fe.c8D,{weight:"medium",size:"sm"},a.createElement(fe.PED,Object.assign({value:n,style:"currency",precision:0,size:"sm",weight:"medium"},fl.zs))," ",(e=>(0,r.YW)(e).with(Ee.wNk.INCOME,(()=>"earned")).with(Ee.wNk.EXPENSE,Ee.Iaz.FLEXIBLE,Ee.Iaz.FIXED,Ee.Iaz.NON_MONTHLY,(()=>"spent")).with("debt_paydown",(()=>"paid down")).otherwise((()=>"contributed")))(c)),a.createElement(Q5,{remaining:v,rollover:i,type:h,exceedsMonthlyProgress:C>0}))))},X5=()=>a.createElement("div",{"data-external-id":"loading-skeleton",className:"flex flex-col"},a.createElement("div",{className:"my-xs flex justify-between"},a.createElement(fe.wME,{className:"h-[1.2em] w-[24%]"}),a.createElement(fe.wME,{className:"h-[1.2em] w-[15%]"})),a.createElement(fe.wME,{className:"h-[1em] w-full"}),a.createElement("div",{className:"my-xs flex justify-between"},a.createElement(fe.wME,{className:"h-[1.2em] w-[15%]"}),a.createElement(fe.wME,{className:"h-[1.2em] w-[15%]"}))),Q5=e=>{let t=e.remaining,n=e.rollover;const l=(e=>(0,r.YW)(e).with("blueText",(()=>"info")).with("greenText",(()=>"success")).with("redText",(()=>"danger")).with("yellowText",(()=>"warning")).otherwise((()=>"secondary")))(((e,t,n)=>"savings"===e||"debt_paydown"===e?"blueText":n?t&&t<0?"redText":"yellowText":(0,BX.A)(t)?"greenText":"textLight")(e.type,t,e.exceedsMonthlyProgress||t<0));return a.createElement(fe.c8D,{"data-external-id":"remaining-row",size:"sm",color:"secondary",weight:"medium",className:"inline-flex items-center gap-2xs"},a.createElement(fe.c8D,{size:"sm",color:l,weight:"medium",className:"inline-flex items-center gap-2xs"},0!==n&&a.createElement(fe.pyX,{size:"sm",className:"mt-px"}),a.createElement(fe.PED,Object.assign({value:t,style:"currency",precision:0,size:"sm",weight:"medium",color:l},fl.zs))),a.createElement("span",null,"remaining"))},e8=(u.default.span.withConfig({displayName:"PlanningTableCell",componentId:"efnxfm-0"})(["position:relative;display:flex;background-color:",";border:1px solid ",";justify-content:flex-end;font-weight:",";user-select:none;min-width:112px;height:60px;",";"],(e=>{let t=e.theme,n=e.isHeader,a=e.isHighlighted;return n||a?t.color.white:(0,xb.B3)(t.color.white,.5)}),(e=>{let t=e.theme,n=e.isHeader,a=e.isHighlighted;
1return n||a?t.color.grayBackground:t.color.grayFocus}),(e=>{let t=e.theme;return e.isHeader?t.fontWeight.medium:t.fontWeight.book}),(e=>{let t=e.isHighlighted,n=e.isFocused,a=e.theme,l=e.lastRow;return t&&!n&&(0,u.css)(["&::after{content:'';position:absolute;bottom:calc(-1 * "," - 1px);left:0;width:100%;height:",";background-color:",";border-radius:0 0 "," ",";}"],a.spacing[l?"large":"default"],a.spacing[l?"large":"default"],(e=>e.theme.color.white),l?a.radius.medium:0,l?a.radius.medium:0)})),()=>a.createElement("div",{"data-external-id":"cell-loading-spinner",className:"mr-default flex items-center"},a.createElement(p.i,{size:"md"}))),t8=((0,u.default)(hl.t).withConfig({displayName:"PlanningTableCell__ActualCell",componentId:"efnxfm-1"})(["",";padding:0px ",";display:flex;align-items:center;justify-content:flex-end;"],(e=>{let t=e.theme,n=e.isEmpty;return"\n  width: 100%;\n  text-align: right;\n  color: ".concat(n?t.color.textLight:t.color.text,";\n  background: none;\n")}),(e=>e.theme.spacing.default)),u.default.div.withConfig({displayName:"PlanningTableCell__NonInputItemContainer",componentId:"efnxfm-2"})(["padding:",";"],(e=>e.theme.spacing.default)),u.default.div.withConfig({displayName:"PlanningTableCell__Triangle",componentId:"efnxfm-3"})(["width:0;height:0;position:absolute;top:-1px;left:-7px;border-left:6px solid transparent;border-right:6px solid transparent;border-bottom:6px solid ",";transform:rotate(-45deg);transform-origin:top center;"],(e=>e.theme.color.blue)),e=>{let t=e.data,n=e.ticks,l=e.isLoading,r=e.titleSize;const i=(0,lt.L7)().isFlexBudgeting,s=(0,a.useMemo)((()=>(0,Xn.A)((0,mo.A)("type"),t)),[t]),c=s.income,d=s.expense,u=(0,a.useState)(0),m=(0,o.A)(u,2),p=m[0],g=m[1];return(0,a.useEffect)((()=>{g(i?2:0)}),[i]),a.createElement(r8,{"data-external-id":"plan-summary-widget"},a.createElement(Xl.AM,null,a.createElement(o8,null,a.createElement(j5,{data:t,isLoading:l}),a.createElement(Dc.t,{onChangeIndex:g,index:p},a.createElement(i8,null,a.createElement(RA.Q,{$background:"card",index:0},"Summary"),a.createElement(RA.Q,{$background:"card",index:1},"Income"),a.createElement(RA.Q,{$background:"card",index:2},"Expenses")),a.createElement(_c.K,{index:0},a.createElement(n8,{data:t,ticks:n,isLoading:l})),a.createElement(_c.K,{index:1},a.createElement(a8,{parentGroup:c,ticks:n,isLoading:l,titleSize:r,breakdownType:"categoryGroups"})),a.createElement(_c.K,{index:2},a.createElement(a8,{parentGroup:d,ticks:n,isLoading:l,titleSize:r,breakdownType:i?"budgetVariabilities":"categoryGroups"}))))))}),n8=e=>{let t=e.data,n=e.isLoading,l=e.ticks,r=e.titleSize;return a.createElement("div",{"data-external-id":"plan-summary-overview",className:"mb-lg flex flex-col"},Object.values(t).filter((e=>e.type!==V5.ZV)).map((e=>l8({item:e,isLoading:n,ticks:l,titleSize:r}))))},a8=e=>{var t,n;let l=e.parentGroup,r=e.isLoading,i=e.ticks,s=e.titleSize,c=e.breakdownType;const d=(0,a.useMemo)((()=>r||null===(null===l||void 0===l?void 0:l.actual)||null===(null===l||void 0===l?void 0:l.budgeted)||null===(null===l||void 0===l?void 0:l.remaining)),[r,l]),u=(null!==(t=null===l||void 0===l?void 0:l.budgeted)&&void 0!==t?t:0)>0,m=null===l||void 0===l||null===(n=l.type)||void 0===n?void 0:n.toLowerCase(),p=(0,a.useMemo)((()=>{var e;return l&&c&&null!==(e=l[c])&&void 0!==e?e:[]}),[l,c]);return a.createElement("div",{"data-external-id":"budget-type-category-breakdown",className:"mb-lg flex flex-col"},a.createElement(Ul.w,null,a.createElement(Ul.d,{when:u&&!d},Object.entries(p).map((e=>{let t=(0,o.A)(e,2),n=t[0],a=t[1];return(0,U.A)((0,U.A)({},a),{},{id:n})})).filter((e=>(e.budgeted||0)+(e.actual||0)!==0)).map((e=>l8({item:(0,U.A)((0,U.A)({},e),{},{name:e.name,type:e.type||(null===l||void 0===l?void 0:l.type)}),isLoading:r,ticks:i,titleSize:s})))),a.createElement(Ul.d,{when:!u&&!d&&!!m},a.createElement(s8,null,m?a.createElement(xt.v,{size:"small",color:"textLight"},"You haven't added any ",m," budgets. When you start budgeting your"," ",(0,De.td)(m,2),", a summary will appear here."):a.createElement(xt.v,{size:"small",color:"textLight"},"You haven't added any budgets yet."))),a.createElement(Ul.d,{default:!0},a.createElement("div",{className:"mt-default flex justify-center"},a.createElement(e8,null)))))},l8=e=>{var t,n,l,r;let o=e.item,i=e.isLoading,s=e.ticks,c=e.titleSize;return a.createElement(J5,{key:o.id||o.name,id:o.id,title:o.name||"",actual:null!==(t=o.actual)&&void 0!==t?t:0,budgeted:null!==(n=o.budgeted)&&void 0!==n?n:0,remaining:null!==(l=o.remaining)&&void 0!==l?l:0,rollover:null!==(r=o.rollover)&&void 0!==r?r:0,isLoading:i,type:o.type,ticks:s,titleSize:c})},r8=u.default.div.withConfig({displayName:"PlanSummaryWidget__Root",componentId:"tad3lg-0"})(["--inner-padding:",";margin-left:",";margin-bottom:",";"],vt.YK.default,vt.YK.gutter,vt.YK.xlarge),o8=(0,u.default)(m.g).attrs({column:!0}
1).withConfig({displayName:"PlanSummaryWidget__Content",componentId:"tad3lg-1"})(["padding:var(--inner-padding) var(--inner-padding) 0;"]),i8=(0,u.default)(m.g).attrs({justifyCenter:!0,alignCenter:!0}).withConfig({displayName:"PlanSummaryWidget__TabsContainer",componentId:"tad3lg-2"})(["gap:",";padding:"," 0 ",";border-bottom:1px solid ",";margin:0 calc(-1 * var(--inner-padding));[data-sc-tw~='PillTab__PillTab']{font-size:",";}"],vt.YK.xsmall,vt.YK.default,vt.YK.small,vt.Ee.color.divider.primary,vt.J.xsmall),s8=(0,u.default)(m.g).attrs({center:!0,marginTop:"default"}).withConfig({displayName:"PlanSummaryWidget__NoDataContainer",componentId:"tad3lg-3"})(["[data-sc-tw~='Text__Text']{max-width:20em;text-align:center;}"]),c8=e=>e.hasSame(N.c9.local(),"month"),d8=e=>{const t=e.startOf("month"),n=t.plus({months:1}),a=N.c9.local().diff(t).milliseconds,l=N.c9.local().diff(n).milliseconds,r=n.diff(t).milliseconds;return a<0?0:l>0?1:a/r},u8=e=>c8(e)?[{percent:d8(e)}]:void 0;var m8=n(32804),p8=n(87599),g8=n(35297);const h8=["data","error"],v8=(e,t)=>{const n=null!==t&&void 0!==t?t:{},l=n.forceGroupByVariability,r=n.isSavingsGoalsEnabled,o=void 0!==r&&r,i=n.isDebtPaydownInBudgetEnabled,s=void 0!==i&&i,c=n.shouldUseMockData,d=void 0!==c&&c,u=n.skip,m=void 0!==u&&u,p=e.toISODate(),g=e.endOf("month").toISODate(),h=(0,pZ._)(p8.wq,d,{variables:{startDate:p,endDate:g},skip:m}),v=h.data,f=h.error,E=(0,En.A)(h,h8),y=(null===v||void 0===v?void 0:v.budgetSystem)===Ee.Zmn.FIXED_AND_FLEX,b=(0,Tr.A)(l)?l:y,x=null===v||void 0===v?void 0:v.budgetStatus,w=(0,a.useMemo)((()=>v?(0,g8.zk)({data:v,date:e,isSavingsGoalsEnabled:o,isDebtPaydownInBudgetEnabled:s}):[]),[v,e,s,o]),C=(0,a.useMemo)((()=>(0,q5.Vi)(w)),[w]),A=(0,a.useMemo)((()=>v?(0,q5.ed)({data:v,date:e,isFlexBudgetingEnabled:b,isSavingsGoalsEnabled:o,isDebtPaydownInBudgetEnabled:s,summaryData:w}):void 0),[v,e,b,o,s,w]);return(0,U.A)((0,U.A)({},E),{},{budgetListData:A,budgetStatusData:x,budgetSummaryData:w,isFlexBudgetSystem:y,safeToSpend:C,shouldShowSafeToSpend:!!y,error:f})};var f8=n(74013);const E8="savings",y8="debt_paydown",b8="Monthly progress",x8=e=>"Compare your ".concat({income:"income",I:"income",expense:"expenses",E:"expenses",transfer:"transfers",T:"transfers",[E8]:"contributions",[y8]:"debt payments"}[e]," to where we are in the month"),w8=(e,t)=>{return"remaining"===t?UX({actual:null===e||void 0===e?void 0:e.actual,available:null===e||void 0===e?void 0:e.remaining,budgeted:null===e||void 0===e?void 0:e.budgeted}):null!==(n=null===e||void 0===e?void 0:e[t])&&void 0!==n?n:void 0;var n},C8=(e,t,n,a,l)=>e===f8.s.SingleMonth&&t<=0&&!n&&!a&&l>0,A8=(0,u.default)(m.g).attrs({justifyEnd:!0,alignCenter:!0}).withConfig({displayName:"PlanDashboardWidget__SelectContainer",componentId:"sc-18id8up-0"})([""]),I8=()=>{const e=(0,l.Zp)(),t=(0,pG.w)(),n=(0,C.RU)(),r=x1(K0.y.PLAN),s=r.trackImpression,c=r.trackCtaClicked,u=(0,d.d4)(A.nG),m=(0,z5.A)(u)?u:1,p=(0,R3.F)(),h=p.isOn,v=p.isDebtPaydownInBudgetEnabled,f=(0,a.useMemo)((()=>N.c9.local().startOf("month")),[]),E=v8(f,{isSavingsGoalsEnabled:h,isDebtPaydownInBudgetEnabled:v}),y=E.budgetStatusData,b=E.budgetSummaryData,x=E.isFlexBudgetSystem,w=E.isLoadingInitialData,k=E.error,S=(0,i.n)(p8.fG,{variables:{input:{startDate:f.toISODate(),timeframe:Ee.SPj.MONTH}},onCompleted:()=>{e(I.JZ.budget({queryParams:{introModal:!0}}))},onError:()=>n()}),T=(0,o.A)(S,2),_=T[0],D=T[1].loading,R=(0,a.useMemo)((()=>b.find((e=>"expense"===e.type))),[b]),M=["summary","expenses"],L=(0,a.useMemo)((()=>[{name:b8,percent:d8(f)}]),[f]),O=x?m:0,P=!(null===y||void 0===y||!y.hasBudget),B=(0,a.useMemo)((()=>b.filter((e=>e.type!==V5.ZV)).reduce(((e,t)=>{var n;return e+(null!==(n=t.budgeted)&&void 0!==n?n:0)}),0)),[b]),z=!w&&(!P||0===B);b1({isVisible:z,trackImpression:s});const F=(0,a.useMemo)((()=>({label:_t.o3.DASHBOARD_CARD.WIDGET_EMPTY.BUTTON_TITLE,onClick:()=>{c(_t.o3.DASHBOARD_CARD.WIDGET_EMPTY.BUTTON_TITLE),P?e(I.JZ.budget()):D||_()},isLoading:D})),[_,P,D,e,c]),G=!w&&k?{message:VG.U.BUDGET}:void 0,Y=(0,m8.Pw)(f.toISODate(),M[null!==O&&void 0!==O?O:1]);return a.createElement(b0,{"data-external-id":"plan-dashboard-widget",title:"Budget",loading:w,widgetError:G,description:(0,Ba.Rc)(f.toISODate()),headerLink:I.JZ.budget(),widgetType:K0.y.PLAN,headerLeftAddon:a.createElement(HK,Object.assign({insightTheme:"BUDGET"},Y,{tooltipDescription:"Understand your budget for ".concat((0,Ba.Rc)(f.toISODate())),source:Ye.rP.DashboardWidgetBudget,isLoading:w})),headerRight:x?a.createElement(A8,null,a.createElement(qV.h,{placeholder:qV.L,options:[{label:"Summary",value:"
10"},{label:"Expenses",value:"1"}],value:String(O),size:"sm",classNames:{trigger:"w-[150px]"},onValueChange:e=>(e=>{const n=null!==m&&void 0!==m?m:1;e!==n&&(0,Ge.u4)(Ye.H8.DashboardWidgetUpdated,{type:K0.y.PLAN,filter_name:"view",from:M[n],to:M[e]}),t((0,g.jS)(e))})(Number(e)),disabled:w})):null},a.createElement(Ul.w,null,a.createElement(Ul.d,{when:z},a.createElement(f1,{color:"pink",icon:a.createElement(fe.cdD,null),title:_t.o3.DASHBOARD_CARD.WIDGET_EMPTY.TITLE,description:_t.o3.DASHBOARD_CARD.WIDGET_EMPTY.SUBTITLE,cta:F})),a.createElement(Ul.d,{when:0===O},a.createElement(n8,{data:b,isLoading:w,ticks:L,titleSize:"base"})),a.createElement(Ul.d,{when:1===O},a.createElement(a8,{parentGroup:R,breakdownType:"budgetVariabilities",isLoading:w,ticks:L,titleSize:"base"}))))},k8=a.memo(I8);var S8,N8=n(35795),T8=n(38027);const _8=()=>a.createElement("div",{"data-external-id":"header-title",className:"flex items-center gap-xs"},a.createElement(fe.bQo,{className:"text-content-brand"}),a.createElement(It,{$fontWeight:"medium"},_t.wZ.WIDGET.TITLE)),D8=(0,$d.s)(fe.XZZ).attrs({variant:"unstyled"})(S8||(S8=(0,wc.A)(["\n  flex items-center gap-default rounded-b-md p-lg transition-colors hover:bg-background-primary-hover\n"]))),R8=e=>{let t=e.id,n=e.name,r=e.frequency,o=e.logoUrl,i=e.account,s=e.logoSize,c=void 0===s?40:s,d=e.className,u=e.startDate,m=e.isMerchant;const p=u?{date:u.startOf("month").toISODate()}:{},g=jl({id:t,isMerchant:m,queryParams:p});return a.createElement("div",{"data-external-id":"recurring-stream-dashboard-item",className:(0,q.cn)("flex items-center gap-default",d)},a.createElement(l.N_,{to:g},a.createElement("div",{className:"relative p-2xs"},a.createElement(Wl._,{url:o,size:c}),!!i&&a.createElement(Gl.v,{logoUrl:i.logoUrl,icon:i.icon,size:16,className:"absolute right-0 bottom-0 outline-4 outline-background-primary"}))),a.createElement("div",{className:"flex min-w-0 flex-col"},a.createElement(Vl.W,{to:g,tone:"inherit",weight:"medium",truncate:!0},n),a.createElement(Ul.w,null,a.createElement(Ul.d,{when:!m},a.createElement(kD.c,{color:"secondary"},"Account \u2022 ",r)),a.createElement(Ul.d,{when:m},a.createElement(kD.c,{color:"secondary"},"Merchant \u2022 ",r)))))},M8=(0,u.default)(b0).withConfig({displayName:"RecurringTransactionsDashboardWidget__StyledDashboardWidget",componentId:"sc-1tit2tm-0"})([""]),L8=(0,u.default)(m.g).attrs({alignCenter:!0,justifyBetween:!0}).withConfig({displayName:"RecurringTransactionsDashboardWidget__Item",componentId:"sc-1tit2tm-1"})(["padding:"," ",";border-top:1px solid ",";"],vt.YK.default,vt.YK.xlarge,vt.Ee.color.divider.primary),O8=(0,u.default)(m.g).attrs({center:!0}).withConfig({displayName:"RecurringTransactionsDashboardWidget__SpinnerContainer",componentId:"sc-1tit2tm-2"})(["margin:"," 0;"],vt.YK.xlarge),P8=(0,u.default)(xt.v).attrs((0,U.A)({weight:"medium"},fl.zs)).withConfig({displayName:"RecurringTransactionsDashboardWidget__Amount",componentId:"sc-1tit2tm-3"})(["color:",";"],(e=>{let t=e.$isIncome,n=e.theme;return t?vt.Ee.color.content.success({theme:n}):n.color.text})),B8=Ee.ezm,z8=e=>{let t=e.goals,n=e.enabledGoalIds,l=e.updateEnabledGoalIds,r=e.open,o=e.onOpenChange;const i=(0,a.useMemo)((()=>({goalOptions:t.map((e=>({id:e.id,enabled:n.includes(e.id)}
1)))})),[t,n]),s=(0,a.useMemo)((()=>(0,I1.Ik)().shape({goalOptions:(0,I1.YO)().of((0,I1.Ik)().shape({id:(0,I1.Yj)().required(),enabled:(0,I1.zM)().required()})).required()})),[]);return a.createElement(fe.hg1.Root,{"data-external-id":"savings-goals-dashboard-settings-dialog",open:r,onOpenChange:o,size:"lg"},a.createElement(fe.hg1.Content,null,a.createElement(Eu.lV,{key:String(r),className:"contents",initialValues:i,onSubmit:e=>(e=>{l(e.goalOptions.filter((e=>e.enabled)).map((e=>e.id)))})(e),overrideValidationSchema:s},a.createElement(fe.hg1.CloseTrigger,null),a.createElement(fe.hg1.Header,null,a.createElement(fe.hg1.Title,null,_t.$.DASHBOARD_CARD.WIDGET_SETTINGS.TITLE)),a.createElement(fe.hg1.Body,{className:"flex max-h-[70vh] flex-col gap-xl overflow-y-auto"},a.createElement(fe.c8D,{size:"base"},_t.$.DASHBOARD_CARD.WIDGET_SETTINGS.DESCRIPTION(5)),a.createElement(hu.c.Consumer,null,(e=>{let n=e.values;return a.createElement("div",{className:"flex flex-col gap-sm"},t.map(((e,t)=>a.createElement(tC.zB.SwitchCard,{key:e.id,name:"goalOptions.".concat(t,".enabled"),label:a.createElement("span",{className:"flex min-w-0 items-center gap-sm"},a.createElement(oQ.s,{imageStorageProvider:e.imageStorageProvider,imageStorageProviderId:e.imageStorageProviderId,size:"small",className:"relative size-8 shrink-0 rounded-sm"}),a.createElement("span",{className:"block truncate"},e.name)),disabled:n.goalOptions.filter((e=>e.enabled)).length>=5&&!n.goalOptions[t].enabled}))))}))),a.createElement(fe.hg1.Footer,{className:"gap-sm"},a.createElement(fe.hg1.Close,{render:a.createElement(fe.XZZ,null,"Cancel")}),a.createElement(fe.XZZ,{variant:"primary",type:"submit"},"Save")))))},F8=(e,t)=>{(0,Ge.u4)(Ye.H8.DashboardWidgetUpdated,{type:K0.y.SAVINGS_GOALS,goals_shown:e,goals_hidden:t})},G8=e=>{let t=e.onClickViewAll,n=e.className;return a.createElement(MP.e,{"data-external-id":"needs-review-empty",variant:"unstyled",icon:a.createElement(f4.R,{size:72}),title:_t.e6.NEEDS_REVIEW_EMPTY_TITLE,description:_t.e6.NEEDS_REVIEW_EMPTY_SUBTITLE,actions:a.createElement(Wb.X,{variant:"default",size:"md",onClick:t},"View all transactions"),className:n})};var Y8=n(48163),U8=n(47643);var V8=n(3548),W8=n(69131),j8=n(62776),H8=n(10495);const K8=e=>e===B2.Bt.All||e===B2.Bt.NeedsReview?e:"needs_review_by_user",q8=(0,u.default)(ZY.B).withConfig({displayName:"TransactionsDashboardWidget__CenteringContainer",componentId:"jxt58-0"})(["flex:1;height:100%;justify-content:center;align-items:center;flex-direction:column;padding:",";"],vt.YK.large),$8=(0,u.default)(U8.v).withConfig({displayName:"TransactionsDashboardWidget__StyledSelect",componentId:"jxt58-1"}
1)(["min-width:200px;"]);var Z8=n(6393),J8=n(11557),X8=n(93099),Q8=n(45204);const e6="https://monarch-static-assets-us-east-2.s3.amazonaws.com/plus/upsell-ipa-intro.mp4",t6="https://monarch-static-assets-us-east-2.s3.amazonaws.com/plus/ipa-intro-static-fallback.png",n6="InProductAnnouncement",a6=(0,u.keyframes)(["from{opacity:0;transform:translateY(24px);}to{opacity:1;transform:translateY(0);}"]),l6=e=>{let t=e.onClose,n=e.isExistingMember,l=void 0!==n&&n,i=e.hasPlusAccess,s=void 0!==i&&i,c=e.isSponsored,d=void 0!==c&&c,m=e.videoElement,p=e.fallbackImageSrc;const g=(0,a.useState)(0),h=(0,o.A)(g,2),v=h[0],f=h[1],E=(0,a.useState)(!0),y=(0,o.A)(E,2),b=y[0],x=y[1],w=(0,a.useState)(!1),C=(0,o.A)(w,2),A=C[0],I=C[1],k=(0,a.useState)({}),S=(0,o.A)(k,2),N=S[0],T=S[1],_=o6.length,D=(0,nC.xd)(),R=(0,o.A)(D,1)[0],M=R.isCurrentUserOwner,L=R.currentUser,O=Boolean(L&&!M),P=o6[v],B=O&&(null===P||void 0===P?void 0:P.memberCta)||(null===P||void 0===P?void 0:P.cta)||{label:"Continue"},z="undefined"!==typeof window&&window.innerWidth<=576?420:520,F=(0,a.useRef)(!1),G="dark"===(0,u.useTheme)().uiTheme;(0,a.useEffect)((()=>{o6.forEach(((e,t)=>{"lottie"===e.media.type&&e.media.load(G).then((e=>{T((n=>(0,U.A)((0,U.A)({},n),{},{[t]:e.default})))})).catch((()=>{}))}))}),[G]),(0,a.useEffect)((()=>{(0,Ge.u4)(Ye.L1.Opened,{identifier:n6,totalSteps:s6})}),[]),(0,a.useEffect)((()=>{(0,Ge.u4)(Ye.L1.Viewed,{identifier:n6,stepIndex:v,stepTitle:d6(v)})}),[v]);const Y=(0,a.useCallback)((()=>{F.current||(0,Ge.u4)(Ye.L1.Skipped,{identifier:n6,currentStepIndex:v}),t()}),[v,t]),V=(0,a.useCallback)((()=>{F.current=!0,x(!1),I(!0)}),[]),W=(0,a.useCallback)((()=>{I(!1),t()}),[t]);return a.createElement(X8.y,{"data-external-id":"in-product-announcement-modal"},A&&a.createElement(CY.R,{onClose:W,onContinue:W,continueCopy:"Done"}),b&&a.createElement(um.b,{onClose:Y,maxWidth:"620px",bottomSheetOnMobile:!0},a.createElement(Rc.L,{hideBottomBorder:!0,onClickBackButton:v>0?()=>{f(v===i6?_-1:v-1)}:void 0},a.createElement(v6,null,a.createElement(f6,{$slideHeight:z},a.createElement(E6,{$currentIndex:v,$slideHeight:z},o6.map(((e,t)=>a.createElement(y6,{key:e.label,$slideHeight:z,$isActive:t===v,$isVideoSlide:"video"===e.media.type},e.showBadge&&a.createElement(u6,null),a.createElement(C6,null,e.label),a.createElement(A6,{$narrow:e.narrowSubhead},e.description),a.createElement(I6,null,(0,r.YW)(e.media).with({type:"video"},(()=>p?a.createElement(T6,{src:p,alt:e.label}):m?a.createElement(h6,{videoElement:m}):a.createElement(S6,{autoPlay:!0,loop:!0,muted:!0,playsInline:!0,src:e6}))).with({type:"lottie"},(()=>t===v&&N[t]?a.createElement(k6,{key:v},a.createElement(Z8.A,{options:{loop:!0,autoplay:!0,animationData:N[t],rendererSettings:{preserveAspectRatio:"xMidYMid meet"}},height:"100%",width:"100%",isClickToPauseDisabled:!0})):null)).with({type:"image"},(n=>{let l=n.src;return t===v?a.createElement(T6,{src:l,alt:e.label}):null})).exhaustive())))),a.createElement(y6,{key:"final",$center:!0,$checkout:!0,$slideHeight:z,$isActive:v===i6},v===i6&&(0,r.YW)({hasPlusAccess:s,isSponsored:d}).with({hasPlusAccess:!0},(()=>a.createElement(p6,{onClose:Y}))).with({isSponsored:!0},(()=>a.createElement(g6,{onClose:Y}))).otherwise((()=>a.createElement(m6,{isExistingMember:l,onSuccess:V})))))),a.createElement(D6,{$hidden:v===i6},a.createElement(cu.WT,{size:"medium",onClick:()=>{B.href?window.open(B.href,"_blank","noopener,noreferrer"):f(v<_-1?v+1:i6)}},B.label))))))},r6=e=>({type:"lottie",load:t=>c6("".concat(e,t?"_dark.json":".json"))}),o6=[{label:"Introducing Monarch Plus",description:"Plan for retirement, track your business, and go deeper on your investments. More of what Monarch does best, for all the layers of your financial life.",media:{type:"video"},cta:{label:"Explore Plus"},showBadge:!0},{label:"Forecast your path into retirement",description:"With Forecasting, Monarch helps you plan for the future, using the accounts you've already connected.",media:r6("forecasting_upsell_animation"),cta:{label:"Continue"}},{label:"Business and personal, finally together",description:"Track income and expenses for your business alongside your household, with clean separation, P&L reporting, and tax-season readiness.",media:r6("business_tracking_upsell_animation"),cta:{label:"Continue"}},{label:"Clarity for your most complex assets",description:"Go deeper on your portfolio with Morningstar-powered allocation analysis and gains and losses tracking.",media:r6("investments_upsell_animation"),cta:{label:"Continue"}},{label:"Plan for the future.\nProtect it, too.",description:"Protect what you've built with a free will from Trust\xa0&\xa0Will.",media:r6("trust_and_will_upsell_animation"),cta:{label:"Continue"},memberCta:{label:"Explore Plus",href:"https://www.monarchmoney.com/pricing"},narrowSubhead:!0}],i6=o6.length,s6=i6+1,c6=e=>n(53544)("./".concat(e)),d6=e=>{var t,n;return e===i6?"Final":null!==(t=null===(n=o6[e])||void 0===n?void 0:n.label)&&void 0!==t?t:""},u6=()=>a.createElement(b6,{"data-external-id":"iam-plus-badge-content"},a.createElement(x6,{src:"/butterfly-logo.svg",alt:""}),a.createElement(w6,null,"Plus")),m6=e=>{var t,n,l,o,i,s,c,d;let u=e.isExistingMember,m=e.onSuccess;const p=(0,X8.Z)(),g=null!==(t=null===p||void 0===p?void 0:p.plans)&&void 0!==t?t:[],h=null!==(n=g.find((e=>e.period===Ee.YHE.YEARLY)))&&void 0!==n?n:g[0],v=(0,rl.vv)(null!==(l=null===h||void 0===h?void 0:h.discountedPricePerPeriodDollars)&&void 0!==l?l:null===h||void 0===h?void 0:h.pricePerPeriodDollars),f=(null!==(o=null===h||void 0===h?void 0:h.pricePerPeriodDollars)&&void 0!==o?o:0)-(null!==(i=null!==(s=null===h||void 0===h?void 0:h.discountedPricePerPeriodDollars)&&void 0!==s?s:null===h||void 0===h?void 0:h.pricePerPeriodDollars)&&void 0!==i?i:0),E=null!==(c=null===p||void 0===p?void 0:p.hasTrial)&&void 0!==c&&c,y=null!==(d=null===p||void 0===p?void 0:p.trialDays)&&void 0!==d?d:0,b=(0,Q8.uq)(E,y,u),x=(0,r.YW)({isExistingMember:u,savings:f,hasTrial:E}).when((e=>{let t=e.isExistingMember,n=e.savings;return t&&n>0}),(()=>"Plan for retirement, track your business, and go deeper on your investments \u2014 for ".concat(v,"/year. That's ").concat((0,rl.vv)(f)," off, exclusively for members."))).when((e=>e.hasTrial),(()=>"Plan for retirement, track your business, and go deeper on your investments \u2014 free for ".concat(y," days, then ").concat(v,"/year."))).otherwise((()=>"Plan for retirement, track your business, and go deeper on your investments. Everything you need to manage all the layers of your financial life, for ".concat(v,"/year.")));return a.createElement(a.Fragment,null,a.createElement(u6,null),a.createElement(C6,null,b),a.createElement(A6,{$narrow:!0},x),a.createElement(_6,null,a.createElement(J8.G,{onSuccess:m,analyticsName:"InProductAnnouncementMod
1al",hideHeader:!0})))},p6=e=>{let t=e.onClose;return a.createElement(a.Fragment,null,a.createElement(u6,null),a.createElement(C6,null,"You\u2019re already on Plus"),a.createElement(A6,{$narrow:!0},"All of these features are included in your plan. Dive in and start exploring \u2014 there\u2019s a lot to discover."),a.createElement(R6,{size:"medium",onClick:t},"Start exploring"))},g6=e=>{let t=e.onClose;return a.createElement(a.Fragment,null,a.createElement(u6,null),a.createElement(C6,null,"Interested in Plus?"),a.createElement(A6,{$narrow:!0},"Plus is coming soon for accounts managed by financial professionals. Stay tuned \u2014 your advisor will be able to unlock Plus for you in the near future."),a.createElement(R6,{size:"medium",onClick:t},"Got it"))},h6=e=>{let t=e.videoElement;const n=(0,a.useRef)(null);return(0,a.useEffect)((()=>{const e=n.current;if(e)return e.appendChild(t),t.play().catch((()=>{})),()=>{e.contains(t)&&e.removeChild(t)}}),[t]),a.createElement(N6,{"data-external-id":"video-slot",ref:n})},v6=u.default.div.withConfig({displayName:"InProductAnnouncementModal__IAMContainer",componentId:"sc-7jqtg0-0"})(["display:flex;flex-direction:column;"]),f6=u.default.div.withConfig({displayName:"InProductAnnouncementModal__IAMViewport",componentId:"sc-7jqtg0-1"})(["height:","px;overflow:hidden;@media (max-width:","px){height:auto;overflow:visible;}"],(e=>e.$slideHeight),vt.nm.sm),E6=u.default.div.withConfig({displayName:"InProductAnnouncementModal__IAMTrack",componentId:"sc-7jqtg0-2"})(["display:flex;flex-direction:column;transform:translateY( calc(-"," * ","px) );transition:transform 1s cubic-bezier(0.16,1,0.3,1);@media (max-width:","px){transform:none;transition:none;}"],(e=>e.$currentIndex),(e=>e.$slideHeight),vt.nm.sm),y6=u.default.div.withConfig({displayName:"InProductAnnouncementModal__IAMSlide",componentId:"sc-7jqtg0-3"})(["height:","px;display:flex;flex-direction:column;align-items:center;text-align:center;padding:"," ",";gap:",";flex-shrink:0;overflow:",";"," @media (max-width:","px){height:",";max-width:420px;width:100%;align-self:center;display:",";"," padding:"," ",";gap:",";"," ","}"],(e=>e.$slideHeight),vt.YK.xlarge,vt.YK.xxlarge,vt.YK.default,(e=>e.$checkout?"auto":"hidden"),(e=>{let t=e.$center,n=e.$checkout;return t&&"justify-content: center; ".concat(n?"padding-top: 0;":"")}),vt.nm.sm,(e=>{let t=e.$checkout,n=e.$slideHeight;return t?"auto":"".concat(n,"px")}),(e=>e.$isActive?"flex":"none"),(e=>{let t=e.$isActive,n=e.$isVideoSlide;return t&&!n&&(0,u.css)(["animation:"," 0.5s cubic-bezier(0.16,1,0.3,1);"],a6)}),vt.YK.default,vt.YK.large,vt.YK.small,(e=>{let t=e.$checkout,n=e.$center;return t&&n&&"justify-content: flex-start;"}),(e=>e.$checkout&&"padding-top: ".concat(vt.YK.xsmall,"; padding-bottom: 0;"))),b6=u.default.div.withConfig({displayName:"InProductAnnouncementModal__IAMPlusBadge",componentId:"sc-7jqtg0-4"})(["display:flex;align-items:center;gap:8px;"]),x6=u.default.img.withConfig({displayName:"InProductAnnouncementModal__IAMButterflyIcon",componentId:"sc-7jqtg0-5"})(["width:24px;height:24px;object-fit:contain;flex-shrink:0;"]),w6=u.default.span.withConfig({displayName:"InProductAnnouncementModal__IAMPlusBadgeText",componentId:"sc-7jqtg0-6"})(["font-size:",";font-weight:",";color:",";@media (max-width:","px){font-size:",";}"],vt.J.large,vt.Wy.medium,vt.Ee.color.content.primary,vt.nm.sm,vt.J.base),C6=u.default.h2.withConfig({displayName:"InProductAnnouncementModal__IAMSlideHeader",componentId:"sc-7jqtg0-7"})(["margin:0;font-size:",";font-weight:",";font-family:",";letter-spacing:-0.05em;line-height:120%;white-space:pre-line;color:",";max-width:420px;text-wrap:pretty;@media (max-width:","px){font-size:",";}"],vt.J.xxlarge,vt.Wy.medium,vt.mw.secondaryStyle,vt.Ee.color.content.primary,vt.nm.sm,vt.J.xlarge),A6=u.default.p.withConfig({displayName:"InProductAnnouncementModal__IAMSlideSubheader",componentId:"sc-7jqtg0-8"})(["margin:0;font-size:",";line-height:150%;color:",";max-width:",";text-wrap:pretty;@media (max-width:","px){font-size:",";}"],vt.J.base,vt.Ee.color.content.secondary,(e=>e.$narrow?"420px":"440px"),vt.nm.sm,vt.J.base),I6=u.default.div.withConfig({displayName:"InProductAnnouncementMod
1al__IAMAnimationArea",componentId:"sc-7jqtg0-9"})(["margin:auto 0;height:290px;max-height:290px;width:100%;max-width:440px;border-radius:12px;overflow:hidden;clip-path:inset(0 round 12px);position:relative;display:flex;align-items:stretch;@media (max-width:","px){height:200px;max-height:200px;margin:0;}"],vt.nm.sm),k6=u.default.div.withConfig({displayName:"InProductAnnouncementModal__IAMLottieWrapper",componentId:"sc-7jqtg0-10"})(["width:100%;height:100%;display:flex;align-items:center;justify-content:center;border-radius:12px;overflow:hidden;clip-path:inset(0 round 12px);div{background:transparent !important;width:100% !important;height:100% !important;clip-path:inset(0 round 12px);}svg{background:transparent !important;border-radius:12px;clip-path:inset(0 round 12px);}svg > rect:first-child{display:none;}"]),S6=u.default.video.withConfig({displayName:"InProductAnnouncementModal__IAMVideoElement",componentId:"sc-7jqtg0-11"})(["width:100%;height:100%;object-fit:contain;display:block;border-radius:12px;clip-path:inset(0 round 12px);"]),N6=u.default.div.withConfig({displayName:"InProductAnnouncementModal__IAMVideoSlot",componentId:"sc-7jqtg0-12"})(["width:100%;height:100%;display:flex;border-radius:12px;clip-path:inset(0 round 12px);overflow:hidden;"]),T6=u.default.img.withConfig({displayName:"InProductAnnouncementModal__IAMSlideImage",componentId:"sc-7jqtg0-13"})(["width:100%;height:100%;object-fit:contain;"]),_6=u.default.div.withConfig({displayName:"InProductAnnouncementModal__IAMCheckoutPanelWrapper",componentId:"sc-7jqtg0-14"})(["width:100%;max-width:420px;"]),D6=u.default.div.withConfig({displayName:"InProductAnnouncementModal__IAMButtonRow",componentId:"sc-7jqtg0-15"})(["display:flex;align-items:center;justify-content:center;gap:",";padding-bottom:",";visibility:",";@media (max-width:","px){padding-bottom:",";}"],vt.YK.small,vt.YK.xxlarge,(e=>e.$hidden?"hidden":"visible"),vt.nm.sm,vt.YK.large),R6=(0,u.default)(cu.WT).withConfig({displayName:"InProductAnnouncementModal__IAMAlreadyPlusButton",componentId:"sc-7jqtg0-16"})(["margin-top:",";width:100%;max-width:320px;"],vt.YK.default),M6="monarch-video-preload-container",L6=()=>{var e;null===(e=document.getElementById(M6))||void 0===e||e.remove()},O6=(e,t)=>{const n=document.createElement("video");n.preload="auto",n.muted=!0,n.playsInline=!0,n.loop=!0,n.style.width="100%",n.style.height="100%",n.style.objectFit="contain",n.style.display="block",n.style.borderRadius="12px",n.src=e,(()=>{const e=document.getElementById(M6);if(e)return e;const t=document.createElement("div");return t.id=M6,t.style.position="fixed",t.style.left="-9999px",t.style.top="0",t.style.width="1px",t.style.height="1px",t.style.overflow="hidden",t.style.pointerEvents="none",document.body.appendChild(t),t})().appendChild(n);let a=!1;const l=new Promise((e=>{const l=l=>{a||(a=!0,n.removeEventListener("canplaythrough",r),n.removeEventListener("error",o),null===t||void 0===t||t.removeEventListener("abort",i),e(l))},r=()=>l(!0),o=()=>l(!1),i=()=>l(!1);null!==t&&void 0!==t&&t.aborted?l(!1):(n.addEventListener("canplaythrough",r),n.addEventListener("error",o),null===t||void 0===t||t.addEventListener("abort",i))}));return{element:n,ready:l,dispose:()=>{var e;n.pause(),n.removeAttribute("src"),n.load(),null===(e=n.parentNode)||void 0===e||e.removeChild(n)}}};var P6=n(91614),B6=n(52072),z6=n(13204);var F6=n(56298);const G6="showPlusTierIPA",Y6=()=>{const e=(0,l.ok)(),t=(0,o.A)(e,2),n=t[0],r=t[1],i="true"===n.get(G6),s=!!(0,d.d4)(F6.e),c=(0,qG.e)(),m=c.hasPlusAccess,p=c.isLoading,g=(0,P6.f)(),h=g.isSponsored,f=g.isLoading,E=(()=>{var e;const t=(0,xq.bO)("dismissedPlusTierWalkthroughAt"),n=(0,o.A)(t,3),a=n[0],l=n[1],r=n[2],i=(0,P6.f)(),s=i.isSubscriptionActive,c=i.hasPaymentMethod,d=i.isSponsored,u=i.isTrialing,m=i.isLifetime,p=i.isEligibleForCoreToPlusPromo,g=i.isLoading,h=(0,et.I)(B6.sJ),f=h.data,E=h.isLoadingInitialData,y=r||g||E,b=(null===(e=null===f||void 0===f?void 0:f.myHousehold)||void 0===e?void 0:e.country)===z6.TP.CANADA;return{shouldShow:!y&&!a&&!(!s||!c||d||b||m||u),dismiss:(0,v.D)((()=>{l((new Date).toISOString())})),isLoading:y,isExistingMember:p}})(),y=E.shouldShow,b=E.dismiss,x=E.isExistingMember,w=E.isLoading,C="dark"===(0,u.useTheme)().uiTheme,A=(0,a.useState)(!1),I=(0,o.A)(A,2),k=I[0],S=I[1],N=(0,a.useState)(!1),T=(0,o.A)(N,2),_=T[0],D=T[1],R=(0,a.useState)(!1),M=(0,o.A)(R,2),L=M[0],O=M[1],P=(0,a.useState)(null),B=(0,o.A)(P,2),z=B[0],F=B[1],G=(0,a.useRef)(!1),Y=(0,a.useRef)(null);(0,a.useEffect)((()=>{w||p||f||G.current||(G.current=!0,y&&!s&&(D(!0),b()))}),[y,w,p,f,s,b]),(0,a.useEffect)((()=>{i&&!f&&(D(!0),s||b())}),[i,f,s,b]),(0,a.useEffect)((()=>
1{if(!_)return;O(!1);let e=!1;const t=new AbortController,n=O6(e6,t.signal);Y.current=n,(e=>{const t=o6.flatMap((t=>"lottie"===t.media.type?[t.media.load(e).catch((()=>{}))]:[]));Promise.all(t).then((()=>{}))})(C);(new Image).src=t6;const a=Symbol("timeout"),l=new Promise((e=>{setTimeout((()=>e(a)),5e3)}));let r=!1;return Promise.race([n.ready,l]).then((t=>{e||(!0===t?(r=!0,F(n.element)):(n.dispose(),Y.current=null,O(!0)),D(!1),S(!0))})),()=>{e=!0,t.abort(),r||(n.dispose(),Y.current=null)}}),[_,C]),(0,a.useEffect)((()=>()=>{var e;null===(e=Y.current)||void 0===e||e.dispose(),Y.current=null,L6()}),[]);return a.createElement(a.Fragment,null,k&&a.createElement(l6,{onClose:()=>{S(!1),Y.current&&(Y.current.dispose(),Y.current=null),F(null),L6(),i&&r((e=>(e.delete(G6),e)))},isExistingMember:x,hasPlusAccess:m,isSponsored:h,videoElement:z,fallbackImageSrc:L?t6:void 0}))},U6={forecasting:"Forecasting","business-tracking":"BusinessEntities",investments:"AssetAllocation"},V6=()=>{var e,t;const n=(0,Sq.k)().close,r=(0,l.Zp)(),i=(0,l.ok)(),s=(0,o.A)(i,2),c=s[0],d=s[1],u=null!==(e=c.get("startFeature"))&&void 0!==e?e:"",m=null!==(t=U6[u])&&void 0!==t?t:"Forecasting",p=(0,qG.e)(),g=p.hasPlusAccess,h=p.isLoading,v=(0,P6.f)(),f=v.isSponsored,E=v.isLoading,y=(0,xq.bO)("dismissedPlusTierWalkthroughAt"),b=(0,o.A)(y,3),x=b[0],w=b[2],C=(0,a.useRef)(!1),A=(0,a.useState)(!1),k=(0,o.A)(A,2),S=k[0],N=k[1];return(0,a.useLayoutEffect)((()=>{h||w||E||C.current||(C.current=!0,g||f?r(I.JZ.dashboard(),{replace:!0}):x?(d((e=>(e.delete("startFeature"),e)),{replace:!0}),N(!0)):r("".concat(I.JZ.dashboard(),"?showPlusTierIPA=true"),{replace:!0}))}),[g,f,x,h,w,E,r,d]),S?a.createElement(QG.N,{"data-external-id":"plus-tier-intro-route",type:m,analyticsName:"PlusTierIntroRoute",onClose:n,renderContentOnly:!0}):null},W6=e=>{var t;let n=e.module,l=e.feedbackByModule,r=e.onFeedbackChange;const o=null!==(t=l[n])&&void 0!==t?t:{},i=o.feedbackType,s=void 0===i?null:i,c=o.details,d=void 0===c?[]:c,u=[{icon:s===Ua.Positive?"thumbs-up-filled":"thumbs-up",onClick:()=>r(n,{feedbackType:Ua.Positive,details:[]}),label:s===Ua.Positive?"Positive feedback given":"Give positive feedback"},{icon:s===Ua.Negative?"thumbs-down-filled":"thumbs-down",onClick:()=>r(n,{feedbackType:Ua.Negative,details:[]}),label:s===Ua.Negative?"Negative feedback given":"Give negative feedback"}],m=s===Ua.Negative?At.lG.map((e=>({label:e,onClick:()=>r(n,{feedbackType:Ua.Negative,details:[e]}),isActive:d.includes(e)}))):void 0;return a.createElement(ji,{"data-external-id":"recap-feedback",actions:u,feedbackOptions:m})},j6=(0,u.keyframes)(["from{opacity:0;}to{opacity:1;}"]),H6=(0,u.keyframes)(["from{opacity:1;}to{opacity:0;}"]),K6=()=>{const e=(0,a.useState)(0),t=(0,o.A)(e,2),n=t[0],l=t[1],r=(0,a.useState)(!1),i=(0,o.A)(r,2),s=i[0],c=i[1];return(0,a.useEffect)((()=>{const e=setInterval((()=>{c(!0),setTimeout((()=>{l((e=>(e+1)%_t.wZ.FLOW.LOADING.MESSAGES.length)),c(!1)}),500)}),4e3);return()=>clearInterval(e)}),[]),a.createElement(q6,{"data-external-id":"recap-loading-view"},a.createElement($6,null,a.createElement(fe.bQo,{size:"xl",className:"animate-recap-sparkles-rotate text-content-brand"}),a.createElement(Z6,{$isFadingOut:s},_t.wZ.FLOW.LOADING.MESSAGES[n]),a.createElement(J6,null,_t.wZ.FLOW.LOADING.DESCRIPTION)))},q6=(0,u.default)(m.g).attrs({justifyCenter:!0,alignStart:!0}).withConfig({displayName:"RecapLoadingView__Root",componentId:"sc-1irkzd2-0"})(["min-height:100%;"]),$6=(0,u.default)(m.g).attrs({column:!0,center:!0,gap:"small"}).withConfig({displayName:"RecapLoadingView__LoadingContainer",componentId:"sc-1irkzd2-1"})(["max-width:350px;text-align:center;"]),Z6=(0,u.default)(xt.v).withConfig({displayName:"RecapLoadingView__MessageText",componentId:"sc-1irkzd2-2"})(["font-size:",";font-weight:",";color:",";animation:"," ","ms ease-in-out forwards;"],vt.J.xlarge,vt.Wy.medium,vt.Ee.color.content.primary,(e=>e.$isFadingOut?H6:j6),500),J6=(0,u.default)(xt.v).withConfig({displayName:"RecapLoadingView__DescriptionText",componentId:"sc-1irkzd2-3"})(["font-size:",";color:",";"],vt.J.large,vt.Ee.color.content.secondary),X6=e=>{let t=e.onConfirm,n=e.isLoading,l=void 0!==n&&n;const r=(0,i.n)(du.Ii),s=(0,o.A)(r,2),c=s[0],d=s[1].loading,u=(0,a.useCallback)((async()=>{await c({variables:{updateProfileInput:{aiAssistantOptedIn:!0},updateMeInput:{}}}),null===t||void 0===t||t()}),[c,t]);return l?a.createElement(Q6,{"data-external-id":"weekly-recap-opt-in-modal",column:!0,gap:"xxlarge",paddingTop:"xxxxlarge",alignCenter:!0},a.createElement(M.Al,{$height:"30px",$width:"132px"}),a.createElement(m.g,{column:!0,gap:"default"},a.createElement(M.Al,{$height:"68px",$width:"356px"}),a.createElement(M.Al,{$height:"110px",$width:"356px"}
1),a.createElement(M.Al,{$height:"89px",$width:"356px"})),a.createElement(M.Al,{$height:"100px",$width:"356px"})):a.createElement(Q6,{"data-external-id":"weekly-recap-opt-in-modal",column:!0,gap:"xxlarge",paddingTop:"xxxxlarge"},a.createElement(m.g,{column:!0,gap:"xxsmall",alignCenter:!0},a.createElement(xt.v,{size:"20",weight:"medium",align:"center"},_t.wZ.OPT_IN.TITLE)),a.createElement(m.g,{column:!0,gap:"default"},_t.wZ.OPT_IN.BULLET_POINTS.map(((e,t)=>a.createElement(m.g,{key:t,column:!0,gap:"xxxsmall"},a.createElement(xt.v,{weight:"medium",align:"center"},e.title),a.createElement(xt.v,{size:"small",color:"content.secondary",align:"center"},a.createElement(Ll.o,{source:e.description,className:"[&_a]:text-inherit [&_a]:underline [&_a:visited]:text-inherit"})))))),a.createElement(m.g,{column:!0,gap:"default"},a.createElement(e9,{onClick:u,pending:d,size:"large"},_t.wZ.OPT_IN.BUTTON_TEXT),a.createElement(xt.v,{size:"xsmall",color:"content.secondary",align:"center"},a.createElement(Ll.o,{source:_t.wZ.OPT_IN.PRIVACY_DISCLAIMER,className:"[&_a]:text-inherit [&_a]:underline [&_a:visited]:text-inherit"}))))},Q6=(0,u.default)(m.g).withConfig({displayName:"WeeklyRecapOptInModal__Container",componentId:"sc-1oxlo92-0"})(["max-width:356px;"]),e9=(0,u.default)(su.U).withConfig({displayName:"WeeklyRecapOptInModal__ConfirmButton",componentId:"sc-1oxlo92-1"})(["width:100%;",";"],cu.vc),t9=e=>{const t=(0,d.wA)();(e=>{let t=e.data,n=e.generateRecap,l=e.hasOptedIn;const r=(0,a.useMemo)((()=>(0,N8.xf)()),[]),o=r.startDate,i=r.endDate;(0,a.useEffect)((()=>{l&&(0,N8.oZ)({data:t,potentialStartDate:o,potentialEndDate:i})&&n(o,i)}),[o,i,t,n,l])})({data:(0,d.d4)(T8.k8),generateRecap:(0,a.useCallback)(((e,n)=>{t((0,g.wV)({startDate:e,endDate:n}))}),[t]),hasOptedIn:e})},n9="data-scrollable-container-key",a9=()=>{var e,t;const n=(0,Sq.k)().close,r=(0,d.d4)(T8.k8),i=(0,d.d4)(T8.Co),s=(0,d.d4)(T8.Sv),c=null!==r&&void 0!==r?r:{},u=c.id,p=c.dateRangeStart,g=c.dateRangeEnd,h=c.cards,v=void 0===h?[]:h,f=(0,z.h)().openAssistant,E=(0,l.ok)(),y=(0,o.A)(E,1)[0],b=(0,a.useState)(0),x=(0,o.A)(b,2),w=x[0],C=x[1],A=(0,a.useState)({}),I=(0,o.A)(A,2),k=I[0],S=I[1],N=(0,a.useState)(!1),T=(0,o.A)(N,2),_=T[0],D=T[1],R=(0,a.useState)(tF.Forward),M=(0,o.A)(R,2),L=M[0],O=M[1],P=(0,a.useRef)(null),B=(0,et.I)(Qe.ps),F=B.data,G=B.isLoadingInitialData,Y=null===F||void 0===F||null===(e=F.me)||void 0===e||null===(t=e.profile)||void 0===t?void 0:t.aiAssistantOptedInAt,V=!!Y&&new Date(Y)>=At.$N,W=!G&&!V;t9(V);const j=(0,a.useRef)(!1);(0,a.useEffect)((()=>{if(!s&&r&&p&&g&&!j.current&&!W){j.current=!0;const e=y.get("source")||f0(K0.y.RECAP);(0,Ge.u4)(Ye.P$.RecapOpened,{startDate:p,endDate:g,source:e})}}),[s,r,p,g,y,W]);const H=(0,a.useMemo)((()=>p&&g?(0,N8.jO)(p,g):""),[p,g]),K=(0,a.useMemo)((()=>{var e;return null!==(e=v[w])&&void 0!==e?e:{}}),[v,w]),q=(0,a.useRef)(r),$=(0,a.useRef)(K),Z=(0,a.useRef)(w),J=(0,a.useRef)(y);(0,a.useEffect)((()=>{q.current=r,$.current=K,Z.current=w,J.current=y}),[r,K,w,y]);const X=K.module===Ee.mE8.INTRO,Q=K.module===Ee.mE8.OUTRO,ee=X||Q,te=(0,a.useMemo)((()=>{var e;return(0,_r.get)(_t.wZ.FLOW.MODULE_TITLE,K.module,null!==(e=K.titleMarkdown)&&void 0!==e?e:K.title)}),[K.module,K.title,K.titleMarkdown]),ne=(0,a.useMemo)((()=>{var e;return(0,_r.get)(_t.wZ.FLOW.MODULE_DESCRIPTION,K.module,null!==(e=K.messageMarkdown)&&void 0!==e?e:K.message)}),[K.module,K.message,K.messageMarkdown]),ae=(0,a.useMemo)((()=>ne?ne.split("\n").filter((e=>!(0,PY.A)(e))):[]),[ne]),le=(null===K||void 0===K?void 0:K.module)&&K.module!==Ee.mE8.INTRO,re=(0,a.useRef)(null);(0,a.useEffect)((()=>{if(!s&&r&&null!==K&&void 0!==K&&K.module&&re.current!==w){re.current=w;const e=(0,N8.rp)(K.module);(0,Ge.u4)(Ye.P$.RecapScreenViewed,{screen:e,screenIndex:w})}}),[s,r,K,w]);const oe=(0,a.useCallback)((()=>{const e=P.current;if(!e)return;const t=((e,t)=>e.querySelector("[".concat(lF,'="').concat(t,'"]')))(e,w),n=e.querySelector("[".concat(n9,'="').concat(w,'"]'));if(!n||!t)return;const a=n.scrollTop,l=n.scrollHeight,r=n.clientHeight;D(l>r&&!(a+r>=l-10))}),[w]);(0,a.useEffect)((()=>{r&&!s&&oe()}),[r,s,oe]);const ie=(0,a.useCallback)((()=>{oe()}),[oe]),se=(0,a.useCallback)((()=>{const e=P.current;if(!e)return;const t=e.querySelector("[".concat(n9,'="').concat(w,'"]'));t&&t.scrollBy({top:t.getBoundingClientRect().height-75,behavior:"smooth"})}),[w]),ce=(0,a.useMemo)((()=>(null===K||void 0===K?void 0:K.module)!==Ee.mE8.INTRO?[]:v.filter((e=>e.module!==Ee.mE8.INTRO&&e.module!==Ee.mE8.OUTRO&&e.headline)).map((e=>{var t,n;return{icon:(0,N8.pD)(e.module),headline:null!==(t=null!==(n=e.headlineMarkdown)&&void 0!==n?n:e.headline)&&void 0!==t?t:""}}))),[null===K||void 0===K?void 0:K.module,v]),de=(0,a.useMemo)((()=>
1{if(null===K||void 0===K||!K.richBlocks)return[];const e=K.richBlocks.join("\n\n");return Li({content:e,messageType:"AssistantMessage",messageId:"recap-".concat(w)})}),[K,w]),ue=(0,a.useMemo)((()=>{if(!K)return"";if(K.module===Ee.mE8.INTRO)return _t.wZ.FLOW.BUTTON_PREVIEW[Ee.mE8.INTRO];if(K.module===Ee.mE8.OUTRO)return _t.wZ.FLOW.BUTTON_PREVIEW.FOLLOW_UP;const e=v[w+1];return e?_t.wZ.FLOW.BUTTON_PREVIEW[e.module]:""}),[K,w,v]),me=(0,a.useCallback)((()=>{const e=Math.min(v.length-1,w+1);O(tF.Forward),C(e)}),[w,v.length]);(0,a.useEffect)((()=>()=>{var e;q.current&&null!==(e=$.current)&&void 0!==e&&e.module&&(0,Ge.u4)(Ye.P$.RecapExited,{screen:(0,N8.rp)($.current.module),screenIndex:Z.current,source:J.current.get("source")||f0(K0.y.RECAP)})}),[]);const pe=(0,a.useCallback)((()=>{const e=Math.max(0,w-1);O(tF.Backward),C(e)}),[w]),ge=(0,a.useCallback)((()=>{f(void 0,Ye.rP.WeeklyRecap),n()}),[n,f]),he=(0,a.useMemo)((()=>a.createElement(d9,{icon:"arrow-left",onClick:pe,$hidden:0===w})),[w,pe]),ve=(0,a.useMemo)((()=>a.createElement(u9,null,(0,db.A)(0,v.length).map((e=>{const t=e<=w;return a.createElement(p9,{key:e,onClick:()=>{const t=e>w?tF.Forward:tF.Backward;O(t),C(e)}},a.createElement(g9,{$isSeen:t}))})))),[v,w]),ye=(0,a.useMemo)((()=>Q?a.createElement(A9,{size:"large",onClick:ge},a.createElement(fe.bQo,{size:20,className:"mr-xs"}),ue):a.createElement(C9,{size:"large",onClick:me},ue)),[Q,me,ue,ge]);return W||G?a.createElement(m9,{"data-external-id":"recap-flow",hideBottomBorder:!0},a.createElement(i9,null,a.createElement(X6,{isLoading:G}))):(0,BY.A)(i)&&(s||(0,BY.A)(r))?a.createElement(m9,{"data-external-id":"recap-flow",hideBottomBorder:!0},a.createElement(o9,null,a.createElement(K6,null))):(0,Tr.A)(i)||(0,PY.A)(v)?a.createElement(m9,{"data-external-id":"recap-flow",hideBottomBorder:!0},a.createElement(o9,null,a.createElement(SQ.W,{className:"py-0",title:_t.wZ.FLOW.ERROR.TITLE,message:_t.wZ.FLOW.ERROR.DESCRIPTION}))):a.createElement(m9,{"data-external-id":"recap-flow",leftControls:he,title:ve,hideBottomBorder:!0},a.createElement(s9,{ref:P},a.createElement(rF,{itemKey:w,direction:L,onAnimationStart:oe},a.createElement(r9,{onScroll:ie,[n9]:w},a.createElement(l9,null,Q&&a.createElement(q3.N,{portal:!0}),a.createElement(h9,null,a.createElement(fe.bQo,{size:20,className:"text-content-brand"}),a.createElement(It,null,a.createElement(xt.v,{size:"large",weight:"medium"},_t.wZ.FLOW.MODULE_HEADER[K.module],"\u2502",H))),a.createElement(m.g,null,a.createElement(v9,{$hero:ee},a.createElement(Ll.o,null,te))),de.length>0&&a.createElement(E9,null,de.map(((e,t)=>a.createElement(y9,{key:t},a.createElement(yn.t,{errorComponent:null,onError:Pi.jC},a.createElement(ia,{messageType:"AssistantMessage",block:e,blockRenderers:Bi,previousBlockInGroup:de[t-1],nextBlockInGroup:de[t+1],renderContext:la.Recap})))))),a.createElement(m.g,{column:!0},ae.map(((e,t)=>a.createElement(f9,{key:t},a.createElement(Ll.o,null,e))))),ce.length>0&&a.createElement(b9,null,ce.map(((e,t)=>a.createElement(x9,{key:t},a.createElement(fe.jeH,{name:e.icon,size:20,className:"text-content-brand"}),a.createElement(Ll.o,null,e.headline))))),a.createElement(m.g,{column:!0,gap:"large"},a.createElement(w9,null,_t.wZ.FLOW.ACCURACY_DISCLAIMER),le&&a.createElement(W6,{module:K.module,feedbackByModule:k,onFeedbackChange:(e,t)=>
1{S((n=>(0,U.A)((0,U.A)({},n),{},{[e]:t}))),(0,Ge.u4)(Ye.P$.FeedbackSubmitted,{feedbackType:t.feedbackType,details:t.details,module:e,recapId:u})}}))))),a.createElement(c9,{$visible:_}),a.createElement(k9,{$visible:_,onClick:se,"aria-label":"See more"},a.createElement(S9,null))),a.createElement(I9,{justifyCenter:!0,$hideBorder:!0},ye))},l9=u.default.div.withConfig({displayName:"RecapFlow__SlideBody",componentId:"qa25cu-0"})(["padding:"," "," ",";"],vt.YK.small,vt.YK.xxlarge,vt.YK.xxlarge),r9=u.default.div.withConfig({displayName:"RecapFlow__ScrollableContentWrapper",componentId:"qa25cu-1"})(["position:relative;min-height:","px;max-height:","px;overflow-y:auto;scroll-behavior:smooth;scrollbar-width:none;-ms-overflow-style:none;&::-webkit-scrollbar{display:none;}"],592,592),o9=u.default.div.withConfig({displayName:"RecapFlow__LoadingErrorContentWrapper",componentId:"qa25cu-2"})(["min-height:","px;display:flex;flex-direction:column;padding-top:","px;"],688,206.4),i9=(0,u.default)(o9).withConfig({displayName:"RecapFlow__OptInWrapper",componentId:"qa25cu-3"})(["align-items:center;padding-top:0;"]),s9=u.default.div.withConfig({displayName:"RecapFlow__SlideWrapper",componentId:"qa25cu-4"})(["position:relative;overflow:hidden;"]),c9=u.default.div.withConfig({displayName:"RecapFlow__FadeOverlay",componentId:"qa25cu-5"})(["position:absolute;bottom:0;left:0;right:0;height:","px;background:linear-gradient(to bottom,transparent,",");pointer-events:none;transition:opacity 0.2s ease-in-out;opacity:",";"],48,vt.Ee.color.background.secondary,(e=>e.$visible?1:0)),d9=(0,u.default)(B.L).attrs({size:"medium"}).withConfig({displayName:"RecapFlow__BackButton",componentId:"qa25cu-6"})(["opacity:1;transition:",";",""],(e=>e.theme.transition.createFastTransitions(["opacity"])),(e=>{let t=e.$hidden,n=e.theme;return t&&"\n    visibility: hidden;\n    pointer-events: none;\n    opacity: 0;\n    /* Delay the visibility change until after the opacity transition completes */\n    transition: ".concat(n.transition.createDefaultTransition(["opacity"]),", visibility 0s linear ").concat(n.transition.defaultDurationMs,"ms;\n  ")})),u9=(0,u.default)(m.g).attrs({center:!0}).withConfig({displayName:"RecapFlow__PageIndicatorContainer",componentId:"qa25cu-7"})(["width:100%;justify-content:center;"]),m9=(0,u.default)(Rc.L).withConfig({displayName:"RecapFlow__Card",componentId:"qa25cu-8"})(["background-color:",";border-radius:",";"],vt.Ee.color.background.secondary,vt.r8.large),p9=u.default.div.withConfig({displayName:"RecapFlow__ClickableDot",componentId:"qa25cu-9"})(["cursor:pointer;margin-right:",";&:last-child{margin-right:0;}"],vt.YK.xsmall),g9=u.default.div.withConfig({displayName:"RecapFlow__Dot",componentId:"qa25cu-10"})(["width:24px;height:6px;border-radius:",";background:",";transition:",";"],vt.r8.medium,(e=>{let t=e.$isSeen,n=e.theme;return t?n.variables.color.progress.brand:n.variables.color.progress.background}),vt.kY.default),h9=(0,u.default)(m.g).attrs({alignCenter:!0,gap:"xsmall"}).withConfig({displayName:"RecapFlow__SubHeader",componentId:"qa25cu-11"})(["font-size:",";color:",";font-weight:",";margin-bottom:",";"],vt.J.small,vt.Ee.color.content.secondary,vt.Wy.medium,vt.YK.xsmall),v9=(0,u.default)(xt.v).withConfig({displayName:"RecapFlow__TitleText",componentId:"qa25cu-12"})(["font-size:",";font-weight:",";margin-bottom:",";"],vt.J.xxlarge,(e=>{let t=e.theme;return e.$hero?t.fontWeight.medium:t.fontWeight.book}),vt.YK.xsmall),f9=(0,u.default)(xt.v).withConfig({displayName:"RecapFlow__ContentText",componentId:"qa25cu-13"})(["font-size:",";margin-bottom:",";&:last-child{margin-bottom:",";}"],vt.J.large,vt.YK.small,vt.YK.xlarge),E9=u.default.div.withConfig({displayName:"RecapFlow__RichBlocksContainer",componentId:"qa25cu-14"})(["margin-top:",";margin-bottom:",";"],vt.YK.default,vt.YK.xlarge),y9=u.default.div.withConfig({displayName:"RecapFlow__BlockContainer",componentId:"qa25cu-15"})(["&:not(:first-child){margin-top:",";}"],vt.YK.small),b9=(0,u.default)(m.g).attrs({column:!0,gap:"small"}).withConfig({displayName:"RecapFlow__HighlightList",componentId:"qa25cu-16"})(["background-color:",";border-radius:",";padding:",";margin-bottom:",";"],vt.Ee.color.background.primary,vt.r8.large,vt.YK.large,vt.YK.xlarge),x9=(0,u.default)(m.g).attrs({alignCenter:!0,gap:"small"}).withConfig({displayName:"RecapFlow__HighlightItem",componentId:"qa25cu-17"})(["font-size:",";color:",";
1"],vt.J.large,vt.Ee.color.content.primary),w9=(0,u.default)(xt.v).withConfig({displayName:"RecapFlow__NoteText",componentId:"qa25cu-18"})(["font-size:",";color:",";"],vt.J.small,vt.Ee.color.content.secondary),C9=(0,u.default)(cu.WT).withConfig({displayName:"RecapFlow__StyledButton",componentId:"qa25cu-19"})(["width:100%;"]),A9=(0,u.default)(C9).withConfig({displayName:"RecapFlow__StyledFollowUpButton",componentId:"qa25cu-20"})(["background:linear-gradient( to bottom right,"," 0%,"," 100% );:hover{background:linear-gradient( to bottom right,"," 0%,"," 100% );opacity:0.9;}"],vt.Ee.color.background.gradientRed,vt.Ee.color.background.gradientOrange,vt.Ee.color.background.gradientRed,vt.Ee.color.background.gradientOrange),I9=(0,u.default)(Cq.R).withConfig({displayName:"RecapFlow__StyledCardFooter",componentId:"qa25cu-21"})(["padding-top:",";padding-bottom:",";"],vt.YK.xsmall,vt.YK.xlarge),k9=u.default.button.withConfig({displayName:"RecapFlow__FloatingScrollArrow",componentId:"qa25cu-22"})(["position:absolute;bottom:",";left:50%;transform:translateX(-50%);width:","px;height:","px;background-color:",";border:1px solid ",";border-radius:",";display:flex;align-items:center;justify-content:center;cursor:pointer;box-shadow:0 2px 8px ",";transition:opacity 0.2s ease-in-out,transform 0.2s ease-in-out;opacity:",";pointer-events:",";&:hover{background-color:",";}"],vt.YK.small,36,36,vt.Ee.color.background.primary,vt.Ee.color.border.primary,vt.r8.round,vt.Ee.color.shadow.medium,(e=>e.$visible?1:0),(e=>e.$visible?"auto":"none"),vt.Ee.color.background.secondary),S9=(0,u.default)(sl.ZQ).attrs({name:"arrow-down",size:16}).withConfig({displayName:"RecapFlow__ScrollArrowIcon",componentId:"qa25cu-23"})(["color:",";"],vt.Ee.color.content.primary),N9=(0,u.default)(m.g).withConfig({displayName:"BadgeBlockRenderer__Root",componentId:"sc-2n3h1i-0"})(["margin-top:",";margin-bottom:",";"],vt.YK.small,vt.YK.small);var T9=n(47368);const _9=[{feature:"flex-budgeting",description:"Introducing Flex Budgeting",featureFlag:null,startDate:"2024-10-02",endDate:"2025-08-15",route:I.JZ.plan(),callToAction:"Check it out"},{feature:"bill-tracking",description:"Bill syncing and recurring merchant review.",featureFlag:null,startDate:"2024-10-29",endDate:"2025-08-15",route:I.JZ.recurring(),callToAction:"Check it out"},{feature:"goals-v3",description:"It's here! Introducing a completely new Goals experience.",featureFlag:"feat-goals-v3-web_mobile",startDate:"2025-11-06",endDate:"2025-11-30",route:I.JZ.goalsAnnouncement(),callToAction:"Learn more",eyebrowText:"New feature"},{feature:"june-2026-product-update",description:"Mobile reports, forecasting multiple scenarios, and more.",featureFlag:null,startDate:"2026-06-21",endDate:"2026-07-15",route:"https://www.monarch.c
1om/blog/june-product-update",callToAction:"Learn More"},{feature:"july-2026-product-update",description:"Email Forwarding, Side-by-Side Forecasting, and more.",featureFlag:null,startDate:"2026-08-03",endDate:"2026-08-31",route:"https://www.monarch.com/blog/july-product-update",callToAction:"Learn More"},{feature:"august-2026-product-update",description:"New Reports, Early Retirement Forecasting, and more.",featureFlag:null,startDate:"2026-09-14",endDate:"2026-10-15",route:"https://www.monarch.com/blog/august-product-update",callToAction:"Learn More"}],D9=(0,T9.A)(_9.map((0,mo.A)("featureFlag"))),R9=()=>{const e=(0,d4.h)(D9,"on"),t=(0,xq.bO)("hasDismissedWhatsNewAt"),n=(0,o.A)(t,3),l=n[0],r=n[1],i=n[2],s=(0,d.d4)(Od.x2),c=(0,a.useMemo)((()=>i?null:M9(l,e,s)),[l,e,i,s]),u=(0,v.D)((()=>{c&&(c.persistent||r(N.c9.now().toISO()))}));return{whatsNew:c,dismissWhatsNew:u}},M9=(e,t,n)=>{const a=L9(e,t,n),l=(0,Nc.A)((e=>{let t=e.startDate;return-1*N.c9.fromISO(t).toUnixInteger()}),a);return l.length>0?l[0]:null},L9=(e,t,n)=>_9.filter((a=>{var l;let r=a.featureFlag,o=a.startDate,i=a.endDate,s=a.maxJoinDate,c=a.persistent;const d=N.c9.now(),u=N.c9.fromISO(o),m=i?N.c9.fromISO(i):null,p=e?N.c9.fromISO(e):null,g=!c&&(!!p&&p>u),h=!c&&(!!p&&d.diff(p).as("days")<=1),v=!(!!m&&d>m)&&d>=u,f=!r||"on"===(null===(l=t[r])||void 0===l?void 0:l.treatment),E=!s||!n||n<N.c9.fromISO(s);return v&&f&&!g&&!h&&E})),O9=(0,u.default)(m.g).withConfig({displayName:"CtaBlockRenderer__Root",componentId:"sc-1d0p96e-0"})(["margin-top:",";margin-bottom:",";"],vt.YK.xlarge,vt.YK.xxlarge),P9=u.default.div.withConfig({displayName:"DividerBlockRenderer__Divider",componentId:"b7s6o-0"})(["height:1px;background-color:",";margin-top:",";margin-bottom:",";"],vt.Ee.color.divider.primary,vt.YK.xlarge,vt.YK.xlarge),B9=(e,t)=>{var n;return"dark"===t.uiTheme&&null!==(n=e.darkModeUrl)&&void 0!==n?n:e.url},z9=u.default.div.withConfig({displayName:"ImageBlockRenderer__Root",componentId:"sc-10nvjo7-0"})(["margin:"," 0;"],vt.YK.default),F9=u.default.img.withConfig({displayName:"ImageBlockRenderer__StyledImage",componentId:"sc-10nvjo7-1"})(["border-radius:",";background-color:",";width:100%;height:auto;"],vt.r8.medium,vt.Ee.color.background.primary),G9=(0,u.css)(["font-size:20px;font-weight:",";"],vt.Wy.medium),Y9={left:"[&_p]:text-left",center:"[&_p]:text-center",right:"[&_p]:text-right"},U9=e=>{let t=e.data,n=t.type,l=t.text,r=t.align;return"p"===n?a.createElement(Ll.o,{"data-external-id":"text-block-renderer",className:(0,q.cn)("[&_p]:mt-xs [&_p]:text-base [&_p]:leading-[inherit] [&_p]:text-content-secondary [&_strong]:text-content-primary",r&&Y9[r])},l):a.createElement(V9,{"data-external-id":"text-block-renderer",type:n,align:r},l)},V9=u.default.div.withConfig({displayName:"TextBlockRenderer__Text",componentId:"tini00-0"})([""," ",""],(e=>{let t=e.type;return{h1:G9}[t]}),(e=>{let t=e.align;return t&&"text-align: ".concat(t,";")})),W9={h1:U9,p:U9,image:e=>{let t=e.data;const n=(0,u.useTheme)();return a.createElement(z9,{"data-external-id":"image-block-renderer"},a.createElement(F9,{src:B9(t,n)}))},cta:e=>{let t=e.data,n=t.id,r=t.text,o=t.href;const i=(0,l.Zp)(),s=R9().dismissWhatsNew,c=(0,a.useMemo)((()=>o?()=>window.open(o,"_blank"):"navigateToReferrals"===n?()=>{s(),i(I.JZ.settings.referrals())}:void 0),[s,o,n,i]);return c?a.createElement(O9,{"data-external-id":"cta-block-renderer"},a.createElement(wt.Xb,{size:"medium",onClick:c},r)):null},badge:e=>{let t=e.data,n=t.text,l=t.color;return a.createElement(N9,{"data-external-id":"badge-block-renderer"},a.createElement(Oc.D,{color:l},n))},divider:()=>a.createElement(P9,{"data-external-id":"divider-block-renderer"})},j9=e=>{let t=e.blocks;return a.createElement(a.Fragment,null,t.map(((e,t)=>{const n=W9[e.type];return n?a.createElement(n,{key:t,data:e}):(console.warn("No renderer for block type: ".concat(e.type)),null)})))},H9=e=>{let t=e.post;return a.createElement(K9,{"data-external-id":"post-content"},a.createElement(j9,{blocks:t.content}))},K9=u.default.div.withConfig({displayName:"PostContent__Root",componentId:"sc-1p61omz-0"})(["padding:0 ",";"],vt.YK.xlarge);var q9=n(14893);const $9={},Z9=e=>{let t=e.onClose;const n=R9().dismissWhatsNew,r=(()=>{const e=(0,l.g)();return(0,q9.mapValues)((e=>{if("undefined"!==e)return"null"===e?null:e}))(e)})().slug,o=r&&$9[r];if((0,a.useEffect)((()=>{o?n():t()}),[n,o,t]),!o)return null;return a.createElement(Rc.L,{"data-external-id":"whats-new-modal",title:"What's new"},a.createElement(H9,{post:o}),a.createElement(J9,null,a.createElement(cu.WT,{size:"medium",onClick:()=>{n(),t()}},"Done")))},J9=(0,u.default)(m.g).attrs({justifyEnd:!0}).withConfig({displayName:"WhatsNewModal__Footer",componentId:"sc-13jf890-0"})(["border-top:1px solid ",";padding:"," ",";"],vt.Ee.color.divider.primary,vt.YK.default,vt.YK.xlarge);var X9=n(9133),Q9=n(11897);
1const e7=e=>{let t=e.onComplete;const n=(0,l.ok)(),r="ai_assistant"===(0,o.A)(n,1)[0].get("source")?{tags:[Q9.PC]}:void 0;return a.createElement(X9.s,{"data-external-id":"contact-support-route",onComplete:t,initialValues:r})},t7=()=>a.createElement(xt.v,{"data-external-id":"request-refund-help-center-text"},"Check out"," ",a.createElement(wb.gz,{href:VF._f,target:"_blank",rel:"noopener noreferrer"},"Monarch's Money-back Guarantee")," ","for information on our refund policy. If you'd like to proceed with requesting a refund, please fill out the form below.");var n7=n(46479),a7=n(64137),l7=n(14494),r7=n(92242);const o7=e=>{let t=e.next,n=e.initialValues;const l=(0,Sq.k)().close,r=(0,d.d4)(FY.qo),o=(0,a.useCallback)((async e=>{try{const n=(0,Q9.$r)(e,r,window.location.pathname);await(0,n7.M)(r7.F).createTicket(n),(0,Ge.u4)(Ye.z.RefundRequestCreated),t({})}catch(n){C.oR.error({description:_t.YH.ERROR_TOAST_SUBTEXT})}}),[r,t]);return(0,p4.n)(Ye.z.RefundRequestFormOpened),a.createElement(Rc.L,{"data-external-id":"request-refund-modal",title:"Submit a Refund Request",description:a.createElement(t7,null),hideBottomBorder:!0},a.createElement(Eu.lV,{initialValues:(0,U.A)((0,U.A)({},Q9.$m),{},{topic:Ee.tCi.REFUND,grantSupportAccountAccess:!1},n),onSubmit:e=>o(e)},a.createElement(s7,null,a.createElement(c7,null,a.createElement(xt.v,{weight:"medium",size:"small"},"Your email address"),a.createElement(xt.v,null,r)),a.createElement(i7,null)),a.createElement(Cq.R,null,a.createElement(wt.Xb,{onClick:l},"Cancel"),a.createElement(CJ.I,{size:"small"},"Submit request"))))},i7=()=>{const e=(0,hu.x)().isSubmitting,t=(0,l7.F)({formType:Ee.W4q.REFUND_REQUEST,topic:Ee.tCi.REFUND}),n=t.reasonOptions,l=t.isLoadingInitialData;return(0,a7.X)({name:"reason",required:!0}),a.createElement(a.Fragment,null,a.createElement(tC.zB.Select,{name:"reason",label:_t.YH.REQUEST_REFUND_FORM_REASON_LABEL,placeholder:_t.YH.FORM_REASON_PLACEHOLDER,options:n,loading:l,disabled:e}),a.createElement(vu.Q,{name:"description",label:_t.YH.REQUEST_REFUND_FORM_DESCRIPTION_LABEL,disabled:e,minRows:3,minLength:12,errorLabel:"Description",required:!0}))},s7=(0,u.default)(m.g).attrs({column:!0}).withConfig({displayName:"RequestRefundModal__Content",componentId:"sekny5-0"})(["padding:0 "," ",";gap:",";"],(e=>e.theme.spacing.xlarge),(e=>e.theme.spacing.xxlarge),(e=>e.theme.spacing.large)),c7=(0,u.default)(m.g).attrs({column:!0}).withConfig({displayName:"RequestRefundModal__ReplyToContainer",componentId:"sekny5-1"})(["gap:",";"],(e=>e.theme.spacing.xxsmall));var d7=n(24065),u7=n(80391);const m7=()=>{const e=(0,u7.$)().skipToComplete;return a.createElement(Rc.L,{"data-external-id":"request-refund-success-modal",title:"Request submitted",hideBottomBorder:!0},a.createElement(p7,null,a.createElement(d7.r,{iconSizePx:22,className:"size-11.25"}),a.createElement(g7,null,a.createElement(xt.v,{weight:"medium",size:"large"},_t.YH.FORM_SUCCESS_TITLE),a.createElement(xt.v,null,_t.YH.FORM_SUCCESS_SUBTITLE.join("\n\n")))),a.createElement(Cq.R,null,a.createElement(cu.WT,{onClick:()=>e()},"Okay")))},p7=(0,u.default)(m.g).attrs({column:!0}).withConfig({displayName:"RequestRefundSuccessModal__Content",componentId:"sc-1dsbrzt-0"})(["gap:",";padding:",";"],(e=>e.theme.spacing.default),(e=>e.theme.spacing.xlarge)),g7=(0,u.default)(m.g).attrs({column:!0}).withConfig({displayName:"RequestRefundSuccessModal__TextContainer",componentId:"sc-1dsbrzt-1"})(["gap:",";"],(e=>e.theme.spacing.xsmall));var h7=n(68924);const v7=e=>{let t=e.onComplete,n=e.onBack,l=e.initialValues;return a.createElement(h7.n,{"data-external-id":"request-refund-flow",initialProps:{initialValues:l},steps:[o7,m7],onComplete:t,onBack:n})};var f7=n(75541);const E7={[K0.y.PLAN]:k8,[K0.y.NET_WORTH]:()=>{const e=(0,qd.W)(),t=(0,o.A)(e,2),n=t[0],l=t[1].width,r=void 0===l?0:l,i=(0,a.useMemo)((()=>(0,hW.fD)()),[]),s=U0("web"),c=(0,o.A)(s,2),d=c[0],u=c[1],m=((e,t)=>{var n;const a=M0.find((e=>e.timeRange===t));return null!==(n=e.find((e=>e.display===(null===a||void 0===a?void 0:a.display))))&&void 0!==n?n:e[0]})(i,d.widgets[K0.y.NET_WORTH].filter),p=e=>{var t;e.display!==m.display&&((0,Ge.u4)(Ye.H8.DashboardWidgetUpdated,{type:K0.y.NET_WORTH,filter_name:"timeframe",from:m.display,to:e.display}),u((0,g0.A)({widgets:{[K0.y.NET_WORTH]:{filter:null!==(t=L0(e))&&void 0!==t?t:"1m"}}},d),!0))},g=(0,bZ.D)(vZ,{variables:{filters:{startDate:N.c9.local().minus(m.duration).toISODate(),endDate:null,accountType:null,useAdaptiveGranularity:!0,accountFilters:void 0}}}
1),h=g.data,v=g.isLoadingInitialData,f=g.isNetworkRequestInFlight,E=g.error,y=(0,a.useMemo)((()=>{var e;return(0,hW.Q8)(null!==(e=null===h||void 0===h?void 0:h.aggregateSnapshots)&&void 0!==e?e:[],!0)}),[h]).snapshots,b=(0,a.useMemo)((()=>(0,GV.e0)(y,"balance")),[y]),x=(0,o.A)(b,2),w=x[0],C=x[1],A=(0,a.useMemo)((()=>r-32),[r]),k=i.map((e=>({value:e.display,label:e.longDisplay,onClick:()=>p(e)}))),S=v||f,T=(0,a.useMemo)((()=>"Provide insights from my net worth ".concat((e=>{if("YTD"===e.display)return"for the year to date";if("ALL"===e.display)return"for all time";const t=N.c9.local(),n=t.minus(e.duration),a=Math.round(t.diff(n,"days").days);return"over the last ".concat(a," days")})(m))),[m]),_=(0,a.useMemo)((()=>"YTD"===m.display?"Understand how your net worth changed year to date":"ALL"===m.display?"Understand how your net worth changed over all time":"1M"===m.display?"Understand how your net worth changed over the last month":"1Y"===m.display?"Understand how your net worth changed over the last year":"Understand how your net worth changed over the last ".concat(m.longDisplay)),[m]),D=!S&&E?{message:VG.U.ACCOUNTS}:void 0;return a.createElement(b0,{"data-external-id":"accounts-dashboard-widget",title:S?"":a.createElement(a.Fragment,null,a.createElement("span",fl.zs,(0,rl.T3)(C))," net worth"),loading:S,widgetError:D,description:!S&&a.createElement(El.H,{className:"text-base",startAmount:w,endAmount:C,isAsset:!0}),headerLink:I.JZ.accounts(),showHeaderBorder:!0,headerLeftAddon:!S&&a.createElement(HK,{insightTheme:"ACCOUNTS",content:T,tooltipDescription:_,source:Ye.rP.DashboardWidgetAccounts,widgetState:{date_range:m.display},animationDelayMs:PU.q2}),headerRight:a.createElement(qV.h,{placeholder:qV.L,options:k,value:m.display,onValueChange:e=>{var t;const n=null!==(t=i.find((t=>t.display===e)))&&void 0!==t?t:i[0];p(n)},disabled:v,size:"sm",classNames:{trigger:"min-w-[150px]"}}),widgetType:K0.y.NET_WORTH},a.createElement(q0,{ref:n},a.createElement($0,null,a.createElement(ZW,{title:"Net Worth",aggregateSnapshotsData:null!==y&&void 0!==y?y:[],isAggreateSnapShotsNet
1workRequestInFlight:f,selectedDateRange:m,isAsset:!0,width:A,yDataKey:"balance"}))))},[K0.y.GOALS]:()=>{const e=(0,l.Zp)(),t=x1(K0.y.GOALS),n=t.trackImpression,r=t.trackCtaClicked,o=(0,u.useTheme)(),i=(0,R3.F)().requiresMigration,s=(0,et.I)(G3,{skip:i}),c=s.data,d=s.isLoadingInitialData,m=s.error,p=(null!==c&&void 0!==c?c:{}).goalsV2,g=void 0===p?[]:p,h=(0,M3.n)("".concat("goals","/").concat(D3.lr[o.uiTheme].hero)),v=(0,a.useMemo)((()=>{let e=(0,yl.DT)(g);return e=(0,yl.SZ)(e),e}),[g]),f=!d&&m?{message:VG.U.GOALS}:void 0,E={label:_t.lR.DASHBOARD_CARD.WIDGET_EMPTY.BUTTON_TITLE,href:I.JZ.goalsV2(),onClick:()=>r(_t.lR.DASHBOARD_CARD.WIDGET_EMPTY.BUTTON_TITLE)},y=!d&&!v.length&&!i;return b1({isVisible:y,trackImpression:n}),i?a.createElement(L3,{"data-external-id":"goals-dashboard-widget",title:_t.lR.DASHBOARD_CARD.TITLE,headerLink:I.JZ.goalsV2(),widgetType:K0.y.GOALS},a.createElement(O3,null,a.createElement(P3,null,a.createElement(B3,null,a.createElement(xt.v,{size:"20",weight:"medium"},D3.xJ.gateCard.title," ",a.createElement(xt.v,{color:"content.brand"},D3.xJ.gateCard.titleAccent)),a.createElement(xt.v,{size:"base",color:"content.secondary"},D3.xJ.gateCard.subtitle)),a.createElement(cu.WT,{className:"order-3 w-full",size:"large",onClick:()=>e(I.JZ.goals.savings.migrate.whatsNew.path)},D3.xJ.gateCard.cta)),a.createElement(z3,null,a.createElement(F3,{src:h,alt:""})))):a.createElement(L3,{"data-external-id":"goals-dashboard-widget",title:_t.lR.DASHBOARD_CARD.TITLE,description:_t.lR.DASHBOARD_CARD.SUBTITLE(Math.min(v.length,3)),loading:d,widgetError:f,headerLink:I.JZ.goalsV2(),widgetType:K0.y.GOALS,headerLeftAddon:a.createElement(HK,{insightTheme:"GOALS",content:(0,yl.FB)(),tooltipDescription:"Understand insights about your goals progress",source:Ye.rP.DashboardWidgetGoals,isLoading:d})},a.createElement(Ul.w,null,a.createElement(Ul.d,{when:!v.length},a.createElement(f1,{color:"blue",icon:a.createElement(fe.lGO,null),title:_t.lR.DASHBOARD_CARD.WIDGET_EMPTY.TITLE,description:_t.lR.DASHBOARD_CARD.WIDGET_EMPTY.SUBTITLE,cta:E})),a.createElement(Ul.d,{default:!0},(0,NF.A)(3,v).map((e=>a.createElement(l.N_,{to:I.JZ.goalsV2.goalDetail({id:e.id}),key:e.id},a.createElement(xl,{goal:e,key:e.id})))))))},[K0.y.CASH_FLOW]:()=>{var e;const t=(0,a.useState)(N.c9.local()),n=(0,o.A)(t,1)[0],l=U0("web"),i=(0,o.A)(l,2),s=i[0],c=i[1],d=null!==(e=s.widgets[K0.y.CASH_FLOW].filter)&&void 0!==e?e:x2.ThisMonthVersusLastMonth,u={[x2.ThisWeekVersusLastWeek]:n.minus({weeks:1}).startOf("week").toISODate(),[x2.ThisMonthVersusLastMonth]:n.minus({months:1}).startOf("month").toISODate(),[x2.ThisMonthVersusLastYear]:n.startOf("month").toISODate(),[x2.ThisMonthVersusAverageMonth]:n.startOf("month").toISODate(),[x2.ThisYearVersusLastYear]:n.startOf("year").toISODate()},m=(0,bZ.D)(gX,{variables:{filters:(0,U.A)((0,U.A)({},z2),{},{startDate:u[d],endDate:n.toISODate()})}}),p=m.data,g=m.isLoadingInitialData,h=m.error,v=d===x2.ThisMonthVersusLastYear||d===x2.ThisYearVersusLastYear,f=d===x2.ThisYearVersusLastYear?n.minus({years:1}).startOf("year").toISODate():n.minus({years:1}).startOf("month").toISODate(),E=d===x2.ThisYearVersusLastYear?n.minus({years:1}).endOf("year").toISODate():n.minus({years:1}).endOf("month").toISODate(),y=(0,bZ.D)(gX,{variables:{filters:(0,U.A)((0,U.A)({},z2),{},{startDate:f,endDate:E})},skip:!v}),b=y.data,x=y.isLoadingInitialData,w=y.error,C=(0,bZ.D)(gX,{variables:{filters:(0,U.A)((0,U.A)({},z2),{},{startDate:n.minus({months:12}).startOf("month").toISODate(),endDate:n.minus({months:1}).endOf("month").toISODate()})},skip:d!==x2.ThisMonthVersusAverageMonth}),A=C.data,k=C.isLoadingInitialData,S=C.error,T=(0,a.useMemo)((()=>x||g||k?[]:D2({previousAggregateData:b,currentAggregateData:p,timeRangeType:d,averageMonthData:A})),[d,g,x,k,b,p,A]),_=(0,a.useMemo)((()=>(0,yd.A)((e=>!!e.balance),null!==T&&void 0!==T?T:[])),[T]),D=(0,jY.mB)().isCashFlowSunsetOn,R="Provide insights about my spending for ".concat(d.toLowerCase()),M=(0,a.useMemo)((()=>(0,r.YW)(d).with(x2.ThisWeekVersusLastWeek,(()=>"Understand how your spending changed this week vs last week")).with(x2.ThisMonthVersusLastMonth,(()=>"Understand how your spending changed this month vs last month")).with(x2.ThisMonthVersusLastYear,(()=>"Understand how your spending changed this month vs the same month last year")).with(x2.ThisMonthVersusAverageMonth,(()=>"Understand how your spending changed this month vs the average month over the last 12 months")).with(x2.ThisYearVersusLastYear,(()=>"Understand how your spending changed this year vs last year")).exhaustive()),[d]),L=(0,r.YW)({error:h,needsPreviousYearData:v,previousYearError:w,selectedRange:d,averageMonthError:S}).with({error:r.P.nonNullable},(()=>!0)).with({needsPreviousYearData:!0,previousYearError:r.P.nonNullable},(()=>!0)).with({selectedRange:x2.ThisMonthVersusAverageMonth,averageMonthError:r.P.nonNullable},(()=>!0)).otherwise((()=>!1)),O=g||x||k,P=!O&&L?{message:VG.U.CASH_FLOW}:void 0;return a.createElement(b0,{"data-external-id":"cash-flow-dashboard-widget",title:"Spending",widgetError:P,description:_?a.createElement(a.Fragment,null,a.createElement("span",fl.zs,(0,rl.vv)(_.balance))," ",C2[d].currentPeriodLegend.toLowerCase()):d,loading:O,headerLink:D?I.JZ.reports.cashFlow():I.JZ.cashFlow(),headerRightFlexGrow:2,headerLeftAddon:a.createElement(HK,{insightTheme:"CASH_FLOW",content:R,tooltipDescription:M,source:Ye.rP.DashboardWidgetSpending,widgetState:{date_range:d},isLoading:O,animationDelayMs:PU.q2}),headerRight:a.createElement(G2,null,a.createElement(qV.h,{placeholder:qV.L,options:w2,value:d,onValueChange:e=>{var t;(t=e)!==d&&((0,Ge.u4)(Ye.H8.DashboardWidgetUpdated,{type:K0.y.CASH_FLOW,filter_name:"timeframe",from:d,to:t}),c((0,g0.A)({widgets:{[K0.y.CASH_FLOW]:{filter:t}}},s),!0))},disabled:g,size:"sm"})),widgetType:K0.y.CASH_FLOW},a.createElement(F2,null,!(null===T||void 0===T||!T.length)&&a.createElement(L2,{mergedData:T,lastBalance:_,selectedTimeRange:d})))},[K0.y.TRANSACTIONS]:()=>{var e,t,n;const r=(0,l.Zp)(),i=x1(K0.y.TRANSACTIONS),s=i.trackImpression,c=i.trackCtaClicked,u=(0,d.d4)(gG.pk),m=U0("web"),p=(0,o.A)(m,2),g=p[0],h=p[1],v=(0,nC.xd)(),f=(0,o.A)(v,1)[0].users,E=null!==(e=g.widgets[K0.y.TRANSACTIONS].filter)&&void 0!==e?e:B2.Bt.All,y=E!==B2.Bt.All,b=(0,a.useCallback)((()=>(e=>{const t={endDate:N.c9.local().toISODate()};return e!==B2.Bt.All?(0,U.A)((0,U.A)({},t),{},{needsReview:!0,needsReviewByUser:e===B2.Bt.NeedsReview?void 0:e,needsReviewUnassigned:e===B2.Bt.NeedsReview||void 0,transactionVisibility:Ee.h1.ALL_TRANSACTIONS}):(0,U.A)((0,U.A)({},t),{},{transactionVisibility:Ee.h1.NON_HIDDEN_TRANSACTIONS_ONLY})})(E)),[E]),x=(0,a.useCallback)((()=>
1{if(y)return{needsReview:!0,needsReviewByUser:E===B2.Bt.NeedsReview?null:E,needsReviewUnassigned:E===B2.Bt.NeedsReview||void 0,transactionVisibility:Ee.h1.ALL_TRANSACTIONS}}),[y,E]),w=(0,a.useMemo)((()=>({offset:void 0,limit:6,filters:b()})),[b]),C=(0,bZ.D)(V8.pu,{variables:w}),A=C.data,k=C.isLoadingInitialData,S=C.refetch,T=C.error,_=y?null===A||void 0===A?void 0:A.allTransactions.totalCount:(0,nj.A)(0,["aggregates",0,"summary","count"],A),D=null===A||void 0===A||null===(t=A.transactionRules)||void 0===t?void 0:t.length,R=!k&&!u&&0===_&&!y;b1({isVisible:R,trackImpression:s});const M=(0,a.useMemo)((()=>({label:_t.e6.DASHBOARD_CARD.WIDGET_EMPTY.BUTTON_TITLE,onClick:()=>{c(_t.e6.DASHBOARD_CARD.WIDGET_EMPTY.BUTTON_TITLE),r(I.JZ.accounts.addAccount())}})),[r,c]),L=(0,H8.y)(A),O=(0,o.A)(L,2),P=O[0],B=O[1],z=B.setDrawerTransactionId,F=B.previousTransactionId,G=B.nextTransactionId,Y=(0,W8.G)({totalCount:null!==(n=null===A||void 0===A?void 0:A.allTransactions.totalCount)&&void 0!==n?n:0}),V=(0,a.useMemo)((()=>({currentRuleCount:D,queryVariables:w,dashboardQueryVariables:y?w:void 0,showAccountColumn:!1,refetchAll:S})),[D,w,y,S]),W=null!==_&&void 0!==_?_:0,j=I.JZ.transactions({queryParams:x()}),H="".concat((0,De.LN)(W)," need").concat(1===W?"s":""," review"),K=(0,a.useMemo)((()=>{var e;if(!y||E===B2.Bt.All||E===B2.Bt.NeedsReview)return;const t=f.find((e=>e.id===E));return null!==(e=null===t||void 0===t?void 0:t.displayName)&&void 0!==e?e:null===t||void 0===t?void 0:t.name}),[E,y,f]),q=(0,a.useMemo)((()=>(e=>{let t=e.isReviewModeActive,n=e.filter,a=e.selectedHouseholdMemberName;return t?n===B2.Bt.NeedsReview?"Provide insights about transactions from the last two weeks that need review by anyone":a?"Provide insights about transactions from the last two weeks that need review by ".concat(a):"Provide insights about transactions from the last two weeks that need review":"Provide insights about transactions from the last two weeks"})({isReviewModeActive:y,filter:E,selectedHouseholdMemberName:K})),[E,y,K]),$=(0,a.useMemo)((()=>y?E===B2.Bt.NeedsReview?"Understand insights from your most recent transactions that need review":"Understand insights from your most recent transactions that need review by this household member":"Understand insights from your most recent transactions"),[E,y]),Z=!k&&T?{message:VG.U.TRANSACTIONS}:void 0;return a.createElement(b0,{"data-external-id":"transactions-dashboard-widget",title:"Transactions",description:E===B2.Bt.All?"Most recent":H,loading:k,widgetError:Z,headerLink:j,headerLeftAddon:a.createElement(HK,{insightTheme:"TRANSACTIONS",content:q,tooltipDescription:$,source:Ye.rP.DashboardWidgetTransactions,widgetState:{filter:K8(E)},isLoading:k}),headerRight:a.createElement("div",{className:"flex"},a.createElement($8,{value:E,onChange:e=>{var t;(t=e)!==E&&((0,Ge.u4)(Ye.H8.DashboardWidgetUpdated,{type:K0.y.TRANSACTIONS,filter_name:"reviewer",from:K8(E),to:K8(t)}),h((0,g0.A)({widgets:{[K0.y.TRANSACTIONS]:{filter:t}}},g),!0))}})),widgetType:K0.y.TRANSACTIONS},a.createElement(Ul.w,null,a.createElement(Ul.d,{when:0===_&&y},a.createElement(G8,{onClickViewAll:()=>r(I.JZ.transactions())})),a.createElement(Ul.d,{when:R},a.createElement("div",{className:"flex flex-col items-center justify-center p-xl"},a.createElement(f1,{color:"indigo",icon:a.createElement(fe.$OE,null),title:_t.e6.DASHBOARD_CARD.WIDGET_EMPTY.TITLE,description:_t.e6.DASHBOARD_CARD.WIDGET_EMPTY.SUBTITLE,cta:M}))),a.createElement(Ul.d,{when:0===_||!A},a.createElement(q8,null,"You have no transactions yet.")),a.createElement(Ul.d,{default:!0},a.createElement(a.Fragment,null,a.createElement(j8.pB.Provider,{value:V},a.createElement(Y8.n,{sections:[{data:(null===A||void 0===A?void 0:A.allTransactions.results.slice(0,5))||[],key:"",date:""}],showSectionHeaders:!1,drawerTransactionId:P,previousTransactionId:F,nextTransactionId:G,setDrawerTransactionId:z,onDrawerClose:()=>{z(null),S()},isReviewModeActive:y,hideHeader:!0,bulkUpdateState:Y}))))))},[K0.y.GETTING_STARTED]:()=>{const e=(0,l.Zp)(),t=(0,R3.F)().isOn,n=(0,a.useState)(!1),i=(0,o.A)(n,2),s=i[0],c=i[1],d=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.showTryDesktopItem,n=e.showInvitePartnerItem,l=e.isSavingsGoalsEnabled,o=e.showForecastOnDesktopCopy;var i,s,c;const d=(0,et.I)(E5),u=d.data,m=d.isLoadingInitialData,p=d.refetch,g=null===(i=null===u||void 0===u?void 0:u.me.profile)||void 0===i?void 0:i.collaboratesOnFinancesDetailed,h=(0,u5.kv)(g),v=(0,qG.e)(),f=v.hasAccess,E=v.isLoading,y=m||E,b=f,x=f,w=b||x,C=(0,Tj.Rq)({skip:!x}).businessEntities,A=(0,a.useCallback)((e=>{if(!u)return!1;const t=u.hasAccounts,n=u.goalsV2,a=u.savingsGoals,o=u.budgetStatus.hasBudget,i=u.me,s=i.profile,c=i.userDevicesUsage,d=u.householdInvites,m=null!==s&&void 0!==s?s:{},p=m.hasSeenCategoriesManagementTour,g=m.hasReviewedSpending,h=m.completedForecastOnboardingAt;return(0,r.YW)(e).with(s5.AddAccount,(()=>t)).with(s5.ReviewSpending,(()=>t&&!!g)).with(s5.CustomizeCategories,(()=>!!p)).with(s5.TryDesktop,(()=>!!(null===c||void 0===c?void 0:c.hasLoggedInOnDesktop))).with(s5.CreateGoal,(()=>(l?a:n).length>0)).with(s5.CreatePlan,(()=>o)).with(s5.InvitePartner,(()=>d.some((e=>!e.isRevoked)))).with(s5.ForecastFuture,(()=>!!h)).with(s5.TrackBusiness,(()=>C.length>0)).exhaustive()}),[u,l,C]),I=(0,a.useMemo)((()=>{const e=o?(0,U.A)((0,U.A)({},v5),{},{subheader:"Model your financial future on desktop"}):v5;let a=[...m5,...b?[e]:[],...x?[f5]:[],...p5];return n&&h&&(a=f?[...a,h5]:[...a.slice(0,1),h5,...a.slice(1)]),t&&(!b||A(s5.TryDesktop))&&(a=[...a,g5]),a.map((e=>(0,U.A)((0,U.A)({},e),{},{completed:A(e.name)}
1)))}),[f,b,x,n,t,o,h,A]),k=null!==(s=null===u||void 0===u?void 0:u.me.displayName)&&void 0!==s?s:(0,d5.A)(null!==(c=null===u||void 0===u?void 0:u.me.name.split(" "))&&void 0!==c?c:[]),S=I.reduce(((e,t)=>e+(t.completed?1:0)),0),N=S===I.length?"".concat(k?"Congratulations ".concat(k):"Congratulations",", you've set up your account"):"".concat(k?"".concat(k,", let's"):"Let's"," finish setting up your account");return{items:I,title:f&&S<I.length?"Welcome to Plus":"Getting Started",hasPlusItems:w,titleCopy:N,isLoadingInitialData:y,refetch:p,completedCount:S,collaboratesWithPartner:h,displayName:k,userId:null===u||void 0===u?void 0:u.me.id}}({showInvitePartnerItem:!0,isSavingsGoalsEnabled:t}),u=d.items,m=d.title,p=d.hasPlusItems,g=d.titleCopy,h=d.isLoadingInitialData,v=d.refetch,f=d.completedCount,E=d.userId,y=E?"onboarding-checklist-confetti-shown-".concat(E):null,b=y?"".concat(y).concat(p?"-plus":""):null,x=(0,a.useState)([]),w=(0,o.A)(x,2),A=w[0],k=w[1],S=(0,a.useRef)(new Set);(0,a.useEffect)((()=>{if(h)return;const e=S.current,t=u.filter((t=>t.completed&&!e.has(t.name))).map((e=>e.name));t.length>0&&k((e=>[...[...t].reverse(),...e.filter((e=>!t.includes(e)))])),S.current=new Set(u.filter((e=>e.completed)).map((e=>e.name)))}),[u,h]);const N=(0,a.useRef)(null),T=(0,a.useRef)(0);(0,a.useEffect)((()=>{if(h||!b||!y)return;const e=T.current;T.current=f,f===u.length&&u.length>0&&f>e&&!localStorage.getItem(b)&&(localStorage.setItem(b,"true"),localStorage.setItem(y,"true"),c(!0),N.current=setTimeout((()=>c(!1)),5e3))}),[f,u.length,h,b,y]),(0,a.useEffect)((()=>()=>{N.current&&clearTimeout(N.current)}),[]);const _=(0,a.useState)(!1),D=(0,o.A)(_,2),R=D[0],M=D[1],L=U0("web"),O=(0,o.A)(L,2),P=O[0],B=O[1],z=(0,Pd.h)(),F=(0,o.A)(z,2),G=F[0],Y=F[1],V=Y.open,W=Y.close,j=(0,Pd.h)(),H=(0,o.A)(j,2),K=H[0],$=H[1],Z=$.open,J=$.close,X=(0,a.useCallback)(((n,a)=>{(0,Ge.u4)(Ye.JF.OnboardingItemClicked,{itemName:n}),(0,r.YW)(n).with(s5.AddAccount,(()=>V())).with(s5.ReviewSpending,(()=>e(I.JZ.transactions()))).with(s5.InvitePartner,(()=>{a?e((0,Ue.AI)("members","household-members")):Z()})).with(s5.CustomizeCategories,(()=>e(I.JZ.settings.categories()))).with(s5.CreateGoal,(()=>{e(t?I.JZ.goals.savings():I.JZ.goalsV2())})).with(s5.CreatePlan,(()=>e(I.JZ.budget()))).with(s5.TryDesktop,(()=>{})).with(s5.ForecastFuture,(()=>e(I.su))).with(s5.TrackBusiness,(()=>e(I.JZ.businesses.setup()))).exhaustive()}),[V,e,t,Z]),Q=(0,a.useCallback)((()=>{(0,Ge.u4)(Ye.H8.WidgetRemoved,{type:K0.y.GETTING_STARTED}),B((0,g0.A)({widgets:{[K0.y.GETTING_STARTED]:{enabled:!1}}},P),!0),(0,C.oR)({title:_t.Y7.TITLE,description:_t.Y7.DESCRIPTION})}),[B,P]);return a.createElement(a.Fragment,null,a.createElement(b0,{title:m,description:!h&&a.createElement(O5,null,g),headerLink:"/accounts",headerRight:h?void 0:a.createElement(w5,{completed:f,total:u.length}),headerRightFlexGrow:0,stackHeader:!0,loading:h,widgetType:K0.y.GETTING_STARTED},s&&a.createElement(q3.N,{portal:!0}),a.createElement(A5,null,(e=>{const t=A.length>0?A.map((e=>u.find((t=>t.name===e&&t.completed)))).filter((e=>void 0!==e)).reverse():u.filter((e=>e.completed)),n=u.filter((e=>!e.completed)),l=n.slice(0,3),r=n.slice(3),o=t.length>=3,i=[...o?[]:t,...l],s=null===(e=l[0])||void 0===e?void 0:e.name,c=function(e,t){let n=e.name,l=e.title,r=e.subheader,o=e.completed,i=e.icon,c=arguments.length>2&&void 0!==arguments[2]&&arguments[2];const d=!o&&n===s;return a.createElement("button",{key:n,type:"button","data-onboarding-checklist-row":!0,tabIndex:c?-1:void 0,style:(0,y5.A)({"--onboarding-checklist-row-delay":"".concat(60*t,"ms")}),className:(0,q.cn)("\n                      flex w-full cursor-pointer appearance-none border-none bg-transparent\n                      px-default py-xs text-left text-inherit select-none [font:inherit]\n                      focus-visible:-outline-offset-1\n                    ","transition-all duration-100 ease-out","not-last:mb-xs","max-[500px]:pr-0 max-[500px]:pl-sm",o?"items-center rounded-md bg-background-secondary py-1.5":"items-start hover:rounded-md hover:bg-background-primary-hover"),onClick:()=>X(n,o)},a.createElement(C5,{completed:o,className:d?"mt-0.5":"mt-0.25"}),a.createElement(I5,null,a.createElement(k5,null,a.createElement(S5,{$checked:o},l),i&&a.createElement("span",{"aria-hidden":!0},i),d&&a.createElement(c5.C,{color:"brand",variant:"subtle",size:"sm"}
1,"Next")),!o&&r&&a.createElement(N5,null,r),o&&a.createElement(fe.SdJ,null,"Completed")),a.createElement("span",{className:"flex size-8 shrink-0 items-center justify-center self-center"},a.createElement(fe.hPJ,{className:o?"text-content-secondary":"text-content-primary"})))};return a.createElement(a.Fragment,null,o&&a.createElement(fe.X0s,{defaultOpen:!1,className:"mb-xs flex flex-col"},a.createElement(fe.X0s.Trigger,{render:a.createElement(fe.XZZ,{variant:"text",colorScheme:"secondary",className:"my-xs w-full justify-start gap-2xs",endIcon:a.createElement(fe.D39,{className:"transition-transform in-aria-expanded:rotate-180",size:"sm"})},"Completed items")}),a.createElement(fe.X0s.Content,null,a.createElement("div",{className:"rounded-md bg-background-secondary p-xs"},t.map((e=>{let t=e.name,n=e.title,l=e.icon;return a.createElement("button",{key:t,type:"button",className:(0,q.cn)("\n                                flex w-full cursor-pointer appearance-none items-center rounded-md\n                                border-none bg-transparent px-xs py-0.5 text-left text-inherit\n                                select-none [font:inherit]\n                              ","transition-colors hover:bg-background-secondary-hover"),onClick:()=>X(t,!0)},a.createElement(C5,{completed:!0}),a.createElement(I5,null,a.createElement(k5,null,a.createElement(S5,{$checked:!0},n),l&&a.createElement("span",{"aria-hidden":!0},l)),a.createElement(fe.SdJ,null,"Completed")),a.createElement("span",{className:"flex size-8 shrink-0 items-center justify-center self-center"},a.createElement(fe.hPJ,{className:"text-content-secondary"})))}))))),i.map(((e,n)=>c(e,o?n+t.length:n))),r.length>0&&a.createElement("div",{className:(0,q.cn)("grid transition-[grid-template-rows] duration-300",R?"grid-rows-[1fr]":"grid-rows-[0fr]")},a.createElement("div",{className:"overflow-hidden","aria-hidden":!R||void 0},r.map(((e,n)=>c(e,t.length+l.length+n,!R))))))})()),a.createElement(L5,null,u.filter((e=>!e.completed)).length>3&&a.createElement(P5,{type:"button",onClick:()=>M((e=>!e))},R?"See less":"See more",a.createElement(fe.D39,{size:"sm",className:(0,q.cn)("transition-transform",R&&"rotate-180")})),a.createElement(B5,{type:"button",onClick:Q},"I'll explore on my own"))),a.createElement(G,{onClose:v},a.createElement(SF.E,{onClose:W,onComplete:W})),a.createElement(K,{zIndex:10,onClose:J},a.createElement(J3,{refetch:v,onClose:J,onInviteSuccess:J})))},[K0.y.REVIEW]:()=>null,[K0.y.INVESTMENTS]:()=>{var e,t,n;const l=x1(K0.y.INVESTMENTS),r=l.trackImpression,o=l.trackCtaClicked,i=(0,bZ.D)(K3,{}),s=i.data,c=i.isLoadingInitialData,d=i.error,u=(0,et.I)(j3),m=u.data,p=u.isLoadingInitialData,g=null!==(e=null===s||void 0===s?void 0:s.portfolio.performance.topMovers)&&void 0!==e?e:[],h=null===s||void 0===s?void 0:s.portfolio.performance.totalValue,v=null===s||void 0===s?void 0:s.portfolio.performance.oneDayChangeDollars,f=(null!==h&&void 0!==h?h:0)-(null!==v&&void 0!==v?v:0),E=null!==h&&void 0!==h?h:0,y=!c&&0===g.length,b=!p&&0===(null!==(t=null===m||void 0===m||null===(n=m.accounts)||void 0===n?void 0:n.length)&&void 0!==t?t:0);b1({isVisible:b,trackImpression:r});const x={label:_t.RQ.DASHBOARD_CARD.WIDGET_EMPTY.BUTTON_TITLE,href:I.JZ.investments(),onClick:()=>o(_t.RQ.DASHBOARD_CARD.WIDGET_EMPTY.BUTTON_TITLE)},w=!c&&d?{message:VG.U.INVESTMENTS}:void 0;let C;C=b?a.createElement("div",{className:"flex flex-col items-center justify-center p-xl"},a.createElement(f1,{color:"blue",icon:a.createElement(fe.kHi,null),title:_t.RQ.DASHBOARD_CARD.WIDGET_EMPTY.TITLE,description:_t.RQ.DASHBOARD_CARD.WIDGET_EMPTY.SUBTITLE,cta:x})):y?a.createElement(a.Fragment,null,a.createElement(H3.X,null,"Top movers today"),a.createElement(cU.vx,{title:"No investment holdings with known securities",subtitle:"Please sync another investment account to see top movers"})):a.createElement(a.Fragment,null,a.createElement(H3.X,null,"Top movers today"),g.map((e=>{let t=e.ticker,n=e.name,l=e.currentPrice,r=e.oneDayChangePercent;return a.createElement(W3,{key:t,ticker:null!==t&&void 0!==t?t:"",securityName:n,currentPriceDollars:null!==l&&void 0!==l?l:0,returnPercent:null!==r&&void 0!==r?r:null})})));const A=c?"":a.createElement(a.Fragment,null,a.createElement("span",fl.zs,(0,rl.T3)(E))," investments");return a.createElement(b0,{"data-external-id":"investments-dashboard-widget",title:b?"Investments":A,widgetError:w,headerLink:I.JZ.investments(),widgetType:K0.y.INVESTMENTS,description:!c&&!b&&a.createElement(El.H,{className:"text-base",startAmount:f,endAmount:E,timeframeDisplay:"Today"}),showHeaderBorder:!0,loading:c||p},C)},[K0.y.RECURRING]:()=>{var e,t;const n=(0,a.useMemo)((()=>N.c9.local()),[]),l=U0("web"),r=(0,o.A)(l,2),i=r[0],s=r[1],c=x1(K0.y.RECURRING),d=c.trackImpression,u=c.trackCtaClicked,m=null!==(e=yr.kG.find((e=>e.key===i.widgets[K0.y.RECURRING].filter)))&&void 0!==e?e:yr.kG[0],g=m.value(),h=n.toISODate(),v=g,f=(0,a.useMemo)((()=>({label:_t._E.DASHBOARD_CARD.WIDGET_EMPTY.BUTTON_TITLE,href:I.JZ.recurring(),onClick:()=>u(_t._E.DASHBOARD_CARD.WIDGET_EMPTY.BUTTON_TITLE)})),[u]),E=(0,bZ.D)(B8,{variables:{startDate:h,endDate:v,includeLiabilities:!0,filters:(0,Ur.fj)({isCompleted:!1})}}),y=E.data,b=E.isLoadingInitialData,x=E.error,w=null===y||void 0===y||null===(t=y.recurringRemainingDue)||void 0===t?void 0:t.amount,C=(0,a.useMemo)((()=>{var e;return(0,yr.Ls)(null!==(e=null===y||void 0===y?void 0:y.recurringTransactionItems)&&void 0!==e?e:[])}),[y]),A=!b&&C.length<=0;b1({isVisible:A,trackImpression:d});const k=(0,a.useCallback)((e=>Math.ceil(N.c9.fromISO(e).diffNow("days").days)),[]),S=(0,a.useMemo)((()=>b?a.createElement(O8,null,a.createElement(p.i,null)):C.length<=0?a.createElement(f1,{color:"orange",icon:a.createElement(fe.cKU,null),title:_t._E.DASHBOARD_CARD.WIDGET_EMPTY.TITLE,description:_t._E.DASHBOARD_CARD.WIDGET_EMPTY.SUBTITLE,cta:f}):a.createElement(a.Fragment,null,C.slice(0,4).map((e=>{var t,l,r;const o=k(e.date),i=e.stream,s=i.id,c=i.name,d=i.logoUrl,u=i.merchant,m=i.creditReportLiabilityAccount,p=e.account,g=e.amount,h=e.date;return a.createElement(L8,{key:s},a.createElement(R8,{id:null!==(t=null!==(l=null===u||void 0===u?void 0:u.id)&&void 0!==l?l:null===m||void 0===m||null===(r=m.account)||void 0===r?void 0:r.id)&&void 0!==t?t:"",name:c,frequency:(0,yr.Bp)(e.stream.frequency),logoUrl:d,account:p,startDate:n,isMerchant:!!u}),a.createElement("div",{className:"flex flex-col items-end"},!!g&&a.createElement(P8,{$isIncome:!!g&&g>0},(0,jQ.s_)(g)),!!h&&a.createElement(xt.v,{color:"textLight",size:"small"}
1,(0,Ba.ro)(N.c9.fromISO(h),n)?"Today":"in ".concat(o," ").concat((0,De.td)("day",o)))))})))),[C,b,k,n,f]),T=a.createElement(a.Fragment,null,a.createElement("span",fl.zs,(0,rl.is)(-1*(null!==w&&void 0!==w?w:0)))," ","remaining due"),_=!b&&x?{message:VG.U.RECURRING}:void 0,D=(0,yr.NF)(h,v),R="Understand your upcoming recurring transactions for ".concat(m.label.toLowerCase());return a.createElement(M8,{"data-external-id":"recurring-transactions-dashboard-widget",title:"Recurring",description:b?a.createElement(p.i,{size:"sm"}):T,widgetError:_,headerLink:I.JZ.recurring(),showHeaderBorder:!1,widgetType:K0.y.RECURRING,headerLeftAddon:a.createElement(HK,Object.assign({insightTheme:"RECURRING"},D,{tooltipDescription:R,source:Ye.rP.DashboardWidgetRecurring,isLoading:b})),headerRight:a.createElement("div",{className:"flex"},a.createElement(qV.h,{placeholder:qV.L,options:yr.kG.map((e=>{let t=e.label;return{value:t,label:t}})),value:m.label,onValueChange:e=>{const t=yr.kG.find((t=>t.label===e));var n;t&&((n=t).key!==m.key&&((0,Ge.u4)(Ye.H8.DashboardWidgetUpdated,{type:K0.y.RECURRING,filter_name:"timeframe",from:m.label,to:n.label}),s((0,g0.A)({widgets:{[K0.y.RECURRING]:{filter:n.key}}},i),!0)))},disabled:b,size:"sm",classNames:{trigger:"min-w-[150px]"}}))},S)},[K0.y.ADVICE]:()=>{const e=x1(K0.y.ADVICE),t=e.trackImpression,n=e.trackCtaClicked,r=(0,d.d4)(gG.pk),o=(0,bZ.D)(C1),i=o.data,s=o.isLoadingInitialData,c=o.error,u=null!==i&&void 0!==i?i:{},m=u.adviceItems,p=u.profileQuestionnaire,g=(0,a.useMemo)((()=>{var e;return null!==(e=null===m||void 0===m?void 0:m.filter((e=>{let t=e.completedAt;return(0,BY.A)(t)})))&&void 0!==e?e:[]}),[m]),h=(null!==p&&void 0!==p?p:{}).state,v=null!==h&&void 0!==h?h:{},f=v.numQuestionsAnswered,E=v.completed,y=(null!==f&&void 0!==f?f:0)>0,b=!r&&!1===E,x=null===m||void 0===m?void 0:m.some((e=>{let t=e.completedAt;return(0,Tr.A)(t)})),w=g.length>0;b1({isVisible:b,trackImpression:t});const C=(0,a.useMemo)((()=>{const e=y?"Resume":_t.hc.DASHBOARD_CARD.WIDGET_EMPTY.BUTTON_TITLE;return{label:e,href:I.JZ.advice.questionnaireIntro({questionnaireName:w1.vx.General}),onClick:()=>n(e)}}),[y,n]),A=!s&&c?{message:VG.U.ADVICE}:void 0,k=f0(K0.y.ADVICE);return a.createElement(c1,{"data-external-id":"advice-dashboard-widget"},a.createElement(c1.Header,null,a.createElement(c1.TitleGroup,null,a.createElement(c1.Title,{render:a.createElement(l.k2,{to:I.JZ.advice({}),state:{referrerSource:k}}),onClick:()=>(0,Ge.u4)(Ye.H8.DashboardWidgetClicked,{type:K0.y.ADVICE,destination:I.JZ.advice({})})},"Advice"),a.createElement(c1.Description,null,"Prioritized by you"))),a.createElement(c1.Body,{className:"p-0",error:A},s?a.createElement("div",{className:"mx-auto my-default flex"},a.createElement(fe.ix7,null)):a.createElement(Ul.w,null,a.createElement(Ul.d,{when:b},a.createElement(f1,{color:"green",icon:a.createElement(fe.nRr,null),title:_t.hc.DASHBOARD_CARD.WIDGET_EMPTY.TITLE,description:_t.hc.DASHBOARD_CARD.WIDGET_EMPTY.SUBTITLE,cta:C})),a.createElement(Ul.d,{when:!w&&!!x},a.createElement(fe.erR,{icon:null,title:"No items",description:"All of your priorities are complete"})),a.createElement(Ul.d,{when:!w},a.createElement(fe.erR,{icon:null,title:"No items",description:"There's nothing to show here yet..."})),a.createElement(Ul.d,{default:!0},a.createElement(fe.Qey.Group,{rounded:g.length>4?"none":"bottom"},(0,NF.A)(4,g).map((e=>a.createElement(m1,{key:e.id,item:e,to:I.JZ.advice.itemDetails({itemId:e.id,category:w1.Ly})})))),g.length>4&&a.createElement(a.Fragment,null,a.createElement(fe.AVK,null),a.createElement(p1.E,{to:I.JZ.advice({category:w1.Ly,queryParams:{scroll:w1.Sd.Objective}}),variant:"text",colorScheme:"link",className:"justify-start px-default py-md"},"View all priorities (",g.length,")"))))))},[K0.y.CREDIT_SCORE]:()=>{var e,t,n,l,i,s,c,d;const u=(()=>{var e,t,n;const l=(0,a.useState)(!1),r=(0,o.A)(l,2),i=r[0],s=r[1],c=N.c9.now(),d=$2.plus({days:60}),u=(0,PH.p)(q2.QW,{pollUntil:e=>{var t;return(null!==(t=null===e||void 0===e?void 0:e.creditScoreSnapshots)&&void 0!==t?t:[]).length>0}
1,pollIntervalMs:J2,pollTimeoutMs:Z2,skipWhenNotPolling:!1,onTimeoutReached:()=>{s(!0)}}),m=(0,o.A)(u,2),p=m[0],g=m[1],h=null!==(n=null===(t=null===(e=g.data)||void 0===e?void 0:e.spinwheelUser)||void 0===t?void 0:t.creditScoreTrackingStatus)&&void 0!==n?n:Ee.HT2.DISABLED,v=X2.includes(h);return{query:g,showNewBadge:c<d&&!v,startPollingSnapshots:p,hasReachedPollTimeout:i}})(),m=u.query,p=u.showNewBadge,g=u.startPollingSnapshots;(0,a.useEffect)((()=>{var e,t,n,a;(null===(e=m.data)||void 0===e||null===(t=e.spinwheelUser)||void 0===t?void 0:t.creditScoreTrackingStatus)===Ee.HT2.ENABLED&&0===(null===(n=m.data.creditScoreSnapshots)||void 0===n?void 0:n.length)&&null===(null===(a=m.data.spinwheelUser)||void 0===a?void 0:a.onboardingErrorMessage)&&g()}),[null===(e=m.data)||void 0===e||null===(t=e.spinwheelUser)||void 0===t?void 0:t.onboardingErrorMessage,null===(n=m.data)||void 0===n||null===(l=n.spinwheelUser)||void 0===l?void 0:l.creditScoreTrackingStatus,null===(i=m.data)||void 0===i||null===(s=i.creditScoreSnapshots)||void 0===s?void 0:s.length,g]);const h=(0,Q2.u)({source:Ee.mEJ.DASHBOARD_WIDGET,onCompleted:e=>{var t,n;(null===(t=e.toggleCreditScoreTracking)||void 0===t||null===(n=t.spinwheelUser)||void 0===n?void 0:n.creditScoreTrackingStatus)===Ee.HT2.ENABLED&&m.refetch()}}),v=h.toggleCreditScoreTracking,f=h.isToggling;return a.createElement(c1,{"data-external-id":"credit-score-dashboard-widget"},a.createElement(c1.Header,null,a.createElement(fe.cIj,{size:"3xs",content:_t.ZC.TOOLTIP,label:a.createElement(fe.xz6.Title,{className:"truncate"},"Credit score")}),p&&a.createElement(fe.CQG,{color:"brand",variant:"solid"},"New"),a.createElement(c1.Action,null,a.createElement(K2,{creditScoreTrackingStatus:null===(c=m.data)||void 0===c||null===(d=c.spinwheelUser)||void 0===d?void 0:d.creditScoreTrackingStatus,onPauseTracking:()=>v(!1)}))),a.createElement(c1.Body,null,(0,r.YW)(m).with({loading:!0},(()=>a.createElement("div",{className:"mx-auto my-default flex"},a.createElement(fe.ix7,null)))).with({data:{creditScoreSnapshots:[],spinwheelUser:{onboardingErrorMessage:r.P.nonNullable}}},(()=>a.createElement(fe.erR,{title:"Sorry, something went wrong",variant:"danger",description:a.createElement(fe.c8D,null,"Our data partner,"," ",a.createElement(fe.liZ,{href:VF.vE,external:!0},"Spinwheel"),", encountered an issue while retrieving your latest credit report. This may resolve on its own with time; we'll attempt to refresh the report over the next couple of weeks.")}))).with({error:r.P.nonNullable},(()=>a.createElement(fe.erR,{variant:"danger",title:"We've run into an error",description:"Something went wrong loading your credit data. Please try again later."}))).with({data:{creditScoreSnapshots:r.P.nonNullable}},(e=>{let t=e.data;return a.createElement(H2,{data:t,toggleCreditScoreTracking:v,isToggling:f})})).otherwise((()=>null))))},[K0.y.SAVINGS_GOALS]:()=>{const e=((e,t)=>{let n=t.trackUpdate,l=t.shouldUseMockData,r=void 0!==l&&l;var i;const s=(0,pZ._)(Io.xA,r),c=s.data,d=s.isLoadingInitialData,u=s.error,m=s.refetch,p=(0,a.useMemo)((()=>{var e;return null!==(e=null===c||void 0===c?void 0:c.savingsGoals.filter((e=>!e.archivedAt)))&&void 0!==e?e:[]}),[null===c||void 0===c?void 0:c.savingsGoals]),g=(0,a.useCallback)((e=>{var t,a,l;const r=null===(t=null===e||void 0===e?void 0:e.widgets)||void 0===t?void 0:t[K0.y.SAVINGS_GOALS],i=null!==(l=null===(a=null===r||void 0===r?void 0:r.filter)||void 0===a?void 0:a.split(","))&&void 0!==l?l:[],s=(0,vj.A)((e=>{let t=e.id;return i.includes(t)}),p),c=(0,o.A)(s,2),d=c[0],u=c[1];n(d.map((e=>e.name)),u.map((e=>e.name)))}),[p,n]),h=U0(e,{onUpdateConfig:g}),v=(0,o.A)(h,2),f=v[0],E=v[1],y=null===(i=null===f||void 0===f?void 0:f.widgets)||void 0===i?void 0:i[K0.y.SAVINGS_GOALS],b=(0,a.useMemo)((()=>{const e=null===y||void 0===y?void 0:y.filter;return(0,BY.A)(e)?(0,NF.A)(5,p).map((e=>e.id)):e.length?e.split(",").map((e=>e.trim())).filter((e=>p.some((t=>t.id===e)))):[]}),[null===y||void 0===y?void 0:y.filter,p]),x=(0,a.useMemo)((()=>p.filter((e=>b.includes(e.id)))),[b,p]),w=(0,a.useMemo)((()=>{if(void 0!==(null===c||void 0===c?void 0:c.currentTotalBalanceForGoals)&&void 0!==(null===c||void 0===c?void 0:c.goalsBalanceThisMonth))return c.currentTotalBalanceForGoals-c.goalsBalanceThisMonth}),[null===c||void 0===c?void 0:c.currentTotalBalanceForGoals,null===c||void 0===c?void 0:c.goalsBalanceThisMonth]),C=(0,a.useCallback)((e=>{const t=e.join(",");E((0,g0.A)({widgets:{[K0.y.SAVINGS_GOALS]:{filter:t}}},f),!0)}),[f,E]);return{savingsGoals:p,enabledGoalIds:b,enabledSavingsGoals:x,startAmount:w,onUpdateEnabledGoalIds:C,isLoadingInitialData:d,currentTotalBalanceForGoals:null===c||void 0===c?void 0:c.currentTotalBalanceForGoals,error:u,refetch:m}})("web",{trackUpdate:F8}),t=e.savingsGoals,n=e.enabledGoalIds,i=e.enabledSavingsGoals,s=e.startAmount,c=e.onUpdateEnabledGoalIds,d=e.isLoadingInitialData,u=e.currentTotalBalanceForGoals,m=e.error,p=x1(K0.y.SAVINGS_GOALS),g=p.trackImpression,h=p.trackCtaClicked,v=(0,a.useState)(!1),f=(0,o.A)(v,2),E=f[0],y=f[1],b=(0,a.useMemo)((()=>({label:_t.lR.DASHBOARD_CARD.WIDGET_EMPTY.BUTTON_TITLE,href:I.JZ.goals.savings(),onClick:()=>h(_t.lR.DASHBOARD_CARD.WIDGET_EMPTY.BUTTON_TITLE)})),[h]),x=!d&&0===t.length;b1({isVisible:x,trackImpression:g});const w=(0,a.useCallback)((e=>{c(e),y(!1)}),[c]),C=!d&&m?{message:VG.U.SAVINGS_GOALS}:void 0,A=f0(K0.y.SAVINGS_GOALS);return a.createElement(c1,{"data-external-id":"savings-goals-dashboard-widget"},a.createElement(c1.Header,null,a.createElement(c1.TitleGroup,{className:"flex-initial flex-row flex-wrap items-center gap-x-3xs gap-y-px xl:gap-x-xs"},a.createElement(c1.Title,{render:a.createElement(l.k2,{to:I.JZ.goals.savings(),state:{referrerSource:A}}),onClick:()=>(0,Ge.u4)(Ye.H8.DashboardWidgetClicked,{type:K0.y.SAVINGS_GOALS,destination:I.JZ.goals.savings()})},"Goals"),a.createElement(HK,{insightTheme:"GOALS",content:(0,yl.FB)(),tooltipDescription:"Understand insights about your goals progress",source:Ye.rP.DashboardWidgetGoals,isLoading:d,className:"xl:order-last"}),!d&&!!t.length&&void 0!==s&&void 0!==u&&a.createElement(El.H,{className:"basis-full text-base xl:basis-auto",startAmount:s,endAmount:u,timeframeDisplay:"this month"})),!!t.length&&a.createElement(c1.Action,null,a.createElement(fe.SO$,{"aria-label":"Goal display settings",size:"sm",onClick:()=>y(!0)},a.createElement(fe.z79,null)))),a.createElement(c1.Body,{className:"p-0",error:C},d?a.createElement("div",{className:"mx-auto my-default flex"},a.createElement(fe.ix7,null)):(0,r.YW)({numSavingsGoals:t.length,numEnabledSavingsGoals:i.length}).with({numSavingsGoals:0},(()=>a.createElement(f1,{color:"blue",icon:a.createElement(fe.lGO,null),title:_t.lR.DASHBOARD_CARD.WIDGET_EMPTY.TITLE,description:_t.lR.DASHBOARD_CARD.WIDGET_EMPTY.SUBTITLE,cta:b}))).with({numSavingsGoals:r.P.when((e=>e>0)),numEnabledSavingsGoals:0},(()=>a.createElement(fe.erR,{icon:null,title:_t.$.DASHBOARD_CARD.NO_GOALS_ENABLED.TITLE,description:_t.$.DASHBOARD_CARD.NO_GOALS_ENABLED.SUBTITLE,actions:a.createElement(fe.XZZ,{size:"md",onClick:()=>y(!0)},_t.$.DASHBOARD_CARD.NO_GOALS_ENABLED.BUTTON_TITLE)}))).otherwise((()=>a.createElement("div",{className:"flex flex-col"},(0,NF.A)(5,i).map(((e,t)=>a.createElement("div",{key:e.id},a.createElement(l.N_,{to:I.JZ.goals.savings.detail({id:e.id}),key:e.id,className:"block text-inherit focus-visible:outline-none [&>div]:transition-colors hover:[&>div]:bg-background-primary-hover focus:[&>div]:bg-background-primary-hover"},a.createElement(yo.p,{goal:e,key:e.id,variant:"dashboard"})),t<Math.min(5,i.length)-1&&a.createElement(fe.AVK,null)))))))),a.createElement(z8,{open:E,onOpenChange:y,goals:t,enabledGoalIds:n,updateEnabledGoalIds:w}))},[K0.y.RECAP]:()=>{const e=(0,l.Zp)(),t=(0,d.d4)(T8.Sv),n=(0,a.useMemo)((()=>{const e=(0,N8.xf)(),t=e.startDate,n=e.endDate;return(0,N8.jO)(t,n)}),[]),r=t?a.createElement(fe.ix7,{size:"xs"}):null;return a.createElement(b0,{"data-external-id":"recap-dashboard-widget",title:a.createElement(_8,null),description:n,headerLink:I.JZ.weeklyRecap({queryParams:{source:"dashboard_widget"}}),headerRight:r,showHeaderBorder:!0,widgetType:K0.y.RECAP,analyticsData:{state:t?"loading":"ready_to_view"}},a.createElement(D8,{onClick:()=>{(0,Ge.u4)(Ye.H8.DashboardWidgetClicked,{type:K0.y.RECAP,destination:I.JZ.weeklyRecap(),state:t?"loading":"ready_to_view"}),e(I.JZ.weeklyRecap({queryParams:{source:"dashboard_widget"}}))}},a.createElement(fe.c8D,{className:"flex-1"},_t.wZ.WIDGET.DESCRIPTION),a.createElement(fe.hPJ,{className:"text-content-secondary"})))},[K0.y.BUSINESS_ENTITIES]:()=>{var e,t;const n=(0,l.Zp)(),r=U0("web"),i=(0,o.A)(r,2),s=i[0],c=i[1],d=(0,Pd.h)(),u=(0,o.A)(d,2),m=u[0],p=u[1].open,g=(0,a.useState)(!1),h=(0,o.A)(g,2),v=h[0],f=h[1],E=(0,eY.z)(),y=x1(K0.y.BUSINESS_ENTITIES),b=y.trackImpression,x=y.trackCtaClicked,w=(0,qd.W)(),C=(0,o.A)(w,2),A=C[0],k=C[1].width,S=void 0===k?0:k,N=0!==S&&S<yD.w.breakPoints.xs,T=(0,qG.e)(),_=T.hasAccess,D=T.isLoading,R="dark"===(0,lm.a)(),M=(0,i2.E)().includes(HQ.nQ.PREMIUM),L=(0,Tj.Rq)(),O=L.businessEntities,P=L.isLoadingInitialData,z=s.widgets[K0.y.BUSINESS_ENTITIES],F=null===z||void 0===z?void 0:z.businessEntitiesFilter,G=null!==(e=null===F||void 0===F?void 0:F.viewMode)&&void 0!==e?e:"income",Y=null!==(t=null===F||void 0===F?void 0:F.timeRange)&&void 0!==t?t:"1m",V=null===F||void 0===F?void 0:F.visibleEntityIds,W=(0,a.useMemo)((()=>V?O.filter((e=>V.includes(e.id))).slice(0,5):O.slice(0,5)),[O,V]),j=(0,a.useMemo)((()=>W.map((e=>e.id))),[W]),H=Z1({entityIds:j,viewMode:G,timeRange:Y}),K=H.financialData,q=H.isLoading,$=H.error,Z=(0,a.useMemo)((()=>Object.fromEntries(K.map((e=>[e.entityId,e])))),[K]),J=(0,a.useCallback)((e=>{const t=(0,U.A)((0,U.A)({},F),e);c((0,g0.A)({widgets:{[K0.y.BUSINESS_ENTITIES]:{businessEntitiesFilter:t}}},s),!0)}),[s,c,F]),X=(0,a.useCallback)((e=>{e!==G&&((0,Ge.u4)(Ye.H8.DashboardWidgetUpdated,{type:K0.y.BUSINESS_ENTITIES,filter_name:"viewMode",from:G,to:e}),J({viewMode:e}))}),[G,J]),Q=(0,a.useCallback)((e=>{e!==Y&&((0,Ge.u4)(Ye.H8.DashboardWidgetUpdated,{type:K0.y.BUSINESS_ENTITIES,filter_name:"timeRange",from:Y,to:e}),J({timeRange:e}))}),[Y,J]),ee=(0,a.useCallback)((e=>{(0,Ge.u4)(Ye.H8.DashboardWidgetUpdated,{type:K0.y.BUSINESS_ENTITIES,filter_name:"visibleEntityIds",from:V,to:e}),J({visibleEntityIds:e})}),[V,J]),te=(0,a.useCallback)((()=>{M?(E("BusinessEntitiesDashboardWidget"),f(!0)):n(I.JZ.settings.billing.subscribe())}),[M,E,f,n]),ne=(0,a.useCallback)((()=>{(0,Ge.u4)(Ye.H8.WidgetRemoved,{type:K0.y.BUSINESS_ENTITIES}),c((0,g0.A)({widgets:{[K0.y.BUSINESS_ENTITIES]:{enabled:!1}}},s),!0)}),[s,c]),ae=P||q||D,le=!ae&&!!$?{message:VG.U.DEFAULT}:void 0,re=!P&&0===O.length,oe=!P&&0===W.length;b1({isVisible:_&&re&&!ae,trackImpression:b});const ie={label:_t.bQ.DASHBOARD_CARD.WIDGET_EMPTY.BUTTON_TITLE,onClick:()=>{x(_t.bQ.DASHBOARD_CARD.WIDGET_EMPTY.BUTTON_TITLE),n(I.JZ.businesses.setup(),{state:{returnTo:I.JZ.dashboard()}})}}
1,se=_1[Y],ce=_&&!re,de=a.createElement(K1,{value:Y,onChange:Q,disabled:ae});return a.createElement(a.Fragment,null,a.createElement("div",{ref:A},a.createElement(b0,{title:"Business tracking",loading:ae,headerLink:I.JZ.settings.businesses(),widgetType:K0.y.BUSINESS_ENTITIES,widgetError:le,headerLeftAddon:ce&&!N?a.createElement("div",{onClick:e=>{e.preventDefault(),e.stopPropagation()}},a.createElement(c2,{fitContent:!0,options:T1,value:G,onChange:X})):void 0,headerRight:ce||!D&&!_?a.createElement("div",{className:"flex items-center gap-sm"},ce&&!N&&a.createElement(s2,null,de),ce&&a.createElement(O1,{onEditDisplay:p,disabled:ae||re}),!D&&!_&&a.createElement(B.L,{icon:"x",size:"xsmall",onClick:e=>{e.preventDefault(),e.stopPropagation(),ne()},"aria-label":"Dismiss business tracking widget"})):void 0,headerSubRow:ce&&N?a.createElement(a.Fragment,null,a.createElement(d2,{fitContent:!0,options:T1,value:G,onChange:X}),a.createElement(s2,null,de)):void 0},_?a.createElement("div",null,re&&a.createElement("div",{className:"flex flex-col items-center justify-center p-xl"},a.createElement(f1,{color:"purple",icon:a.createElement(fe.A6v,null),title:_t.bQ.DASHBOARD_CARD.WIDGET_EMPTY.TITLE,description:_t.bQ.DASHBOARD_CARD.WIDGET_EMPTY.SUBTITLE,cta:ie})),oe&&!re&&a.createElement("div",{className:"flex items-center justify-center p-xl"},a.createElement(cU.vx,{title:"No businesses selected",subtitle:"Select which businesses to display in this widget.",button:{title:"Edit display settings",onClick:p}})),W.map((e=>{var t;const n=Z[e.id];return a.createElement(H1,{key:e.id,businessEntity:e,amount:null!==(t=null===n||void 0===n?void 0:n.amount)&&void 0!==t?t:0,timePeriodLabel:se,viewMode:G,monthlyBreakdown:null===n||void 0===n?void 0:n.monthlyBreakdown,monthlyNetAssets:null===n||void 0===n?void 0:n.monthlyNetAssets,hideSparkline:N})})),W.length>0&&a.createElement(v2,null,a.createElement(f2,{to:I.JZ.reports.taxForms(),onClick:()=>{(0,Ge.u4)(Ye.H8.DashboardWidgetClicked,{type:K0.y.BUSINESS_ENTITIES,destination:I.JZ.reports.taxForms()})}},"Explore business tax tools",a.createElement(fe.hPJ,{size:"sm"})))):a.createElement(u2,null,a.createElement(m2,null,a.createElement(p2,{src:R?"https://monarch-static-assets-us-east-2.s3.us-east-2.amazonaws.com/plus/business-entities-dashboard-widget-dark.png":"https://monarch-static-assets-us-east-2.s3.us-east-2.amazonaws.com/plus/dashboard-widget.png",alt:"Business tracking preview"})),a.createElement(g2,null,a.createElement(xt.v,{weight:"medium",size:"base"},"One view for personal and business finances"),a.createElement(xt.v,{color:"textLight",size:"small"},"Track a small business or side hustle alongside your household."),a.createElement(h2,{size:"small",onClick:te},"Try business tracking"))))),a.createElement(m,null,a.createElement(M1,{businessEntities:O,visibleEntityIds:V,onSave:ee})),v&&a.createElement(QG.N,{type:"BusinessEntities",analyticsName:"BusinessEntitiesDashboardWidget",onClose:()=>f(!1)}))},[K0.y.FOUND_MONEY]:()=>{var e;const t=(0,l.Zp)(),n=(0,lm.a)(),o=(0,a.useMemo)((()=>"dark"===n?J4:Z4),[n]),i=(0,lt.L7)(),s=i.householdPreferences,c=i.isLoadingInitialData,d=null!==(e=null===s||void 0===s?void 0:s.continuousFinancialMonitoringEnabled)&&void 0!==e&&e,u=(0,C.RU)(),m=(0,a.useRef)(!1),p=R4({isOptedIn:d,statuses:E4.oH}),g=p.insights,h=p.summary,v=p.latestRunStatus,f=p.isGenerating,E=p.isGeneratingOverdue,y=p.isOptingIn,b=p.isLoading,x=p.error,w=p.refetch,A=p.startGeneration,k=(0,a.useMemo)((()=>g.filter((e=>E4.az.includes(e.status)))),[g]),S=(0,a.useCallback)((()=>{w()}),[w]),N=(0,a.useCallback)((async()=>{(0,Ge.u4)(Ye.I2.AgenticAnalysisStarted,{source:Ye.xD.DashboardWidget}),m.current=!0;try{await A()}catch(e){m.current=!1,u()}}),[A,u]),T=(0,a.useMemo)((()=>{var e;return y4({isOptedIn:d,isOptingIn:y,isGenerating:f,latestRunStatus:v,hasError:!!x,insights:g,completedInsightCount:null!==(e=null===h||void 0===h?void 0:h.completedCount)&&void 0!==e?e:0})}),[d,y,f,v,x,g,null===h||void 0===h?void 0:h.completedCount]);return a.createElement(b0,{"data-external-id":"found-money-dashboard-widget",title:"Advice",description:_t.vP.TITLE,tooltip:T===v4.Onboarding?a.createElement(fe.cIj,{size:"3xs",content:_t.vP.ONBOARDING_AI_TOOLTIP,triggerClassName:"ml-2xs self-center text-content-primary",iconSize:"xs"}):void 0,headerLink:I.JZ.advice({}),widgetType:K0.y.FOUND_MONEY,loading:(c||b)&&!f},(0,r.YW)(T).with(v4.Error,(()=>a.createElement(Q4,{variant:"danger",title:_t.vP.ERROR_TITLE,description:_t.vP.ERROR_DESCRIPTION,actions:a.createElement(wt.Xb,{size:"medium",onClick:S},_t.vP.ERROR_RETRY_BUTTON)}))).with(v4.RunFailed,v4.Generating,(e=>a.createElement(l3,{content:T4(e,E)}))).with(v4.HasOpportunities,(()=>m.current?a.createElement(n3,{opportunityCount:k.length,insights:k,onCheckThemOut:()=>{m.current=!1,t(I.JZ.advice({}))}}):a.createElement(e3,{insights:k,summary:h,onInsightClick:(e,n)=>{(0,Ge.u4)(Ye.H8.DashboardWidgetClicked,{type:K0.y.FOUND_MONEY,destination:"/advice/insight",merchant:n.merchantNameDisplay,savingsAmount:Math.round(b4(n))}),t({pathname:I.JZ.advice.insightDetail({insightId:e}),search:"?source=".concat(Ye.xD.DashboardWidget)})}}))).with(v4.AllCompleted,(()=>a.createElement(t3,{summary:h}))).with(v4.NoOpportunities,(e=>a.createElement(l3,{content:T4(e)}))).with(v4.Onboarding,(()=>a.createElement(a3,{isOptingIn:y,onStartSaving:N,onLearnMore:()=>t(I.JZ.advice({})),widgetImageUrl:o}))).exhaustive())}},y7=()=>{const e=U0("web"),t=(0,o.A)(e,1)[0],n=c4().onDragEnd,l=(0,hK.T)(),i=t.layout,s=t.widgets,c=i.length,u=(0,Pd.h)(),m=(0,o.A)(u,2),p=m[0],g=m[1].open,h=u4(),v=(0,l4.E)().isAdviceSunsetOn,f=(0,ht.S)().isAiFeaturesEnabled,E=(0,m4.W)(),y=(0,vQ.N)().preferredVersion;(0,nG.p)("feat-mcp-web","off",{trackImpression:!0});const b=(0,d.d4)(A.Nc),x={emptyTitle:_t.Gr.OVERLAY_TITLE,emptyButtonText:_t.Gr.OVERLAY_BUTTON},w=x.emptyTitle,C=x.emptyButtonText,k=(0,a.useMemo)((()=>i.map((e=>e.filter((e=>(0,r.YW)(e).with(K0.y.CREDIT_SCORE,(()=>E&&s[e].enabled)).with(K0.y.SAVINGS_GOALS,(()=>"v3"===y&&s[e].enabled)).with(K0.y.GOALS,(()=>"v2"===y&&s[e].enabled)).with(K0.y.RECAP,(()=>f&&s[e].enabled)).with(K0.y.BUSINESS_ENTITIES,(()=>s[e].enabled)).with(K0.y.ADVICE,(()=>!v&&!h&&s[e].enabled)).with(K0.y.FOUND_MONEY,(()=>!v&&h&&f&&s[e].enabled)).otherwise((()=>s[e].enabled))))))),[i,s,E,y,f,h,v]),S=Pt(new Date),N=b?", ".concat(b):"",T="".concat(S).concat(N,"!");return a.createElement(Yq,{"data-external-id":"dashboard",name:"Dashboard",overrideHtmlTitle:"Dashboard",overrideTitle:T,emptyIcon:"home",emptyTitle:w,emptyButtonText:C,onAccountAdded:()=>f7.S.resetStore(),controls:a.createElement(b7,{openCustomizeModal:g})},a.createElement(rV.T,{screenName:"Dashboard"}),a.createElement(Bk.Mp,{sensors:l,collisionDetection:n4,onDragEnd:n,accessibility:{announcements:gK.n}},a.createElement(pK.Z,null),a.createElement(pX.f,{className:"pt-0",rowGutterPx:0},k.map(((e,t)=>a.createElement(mX.V,{key:t,md:pX.Z/c},a.createElement(e4,{column:t,widgetNames:e,rootProps:(0,Ex.p)("dashboard-droppable-column-".concat(t))},e.map((e=>{const t=E7[e],n=HQ.gC[e];return a.createElement(p0,{key:e,feature:n},t&&a.createElement(Hk.U,{id:e,customDragHandle:!0},a.createElement(t,null)))})))))))),a.createElement(XU.U,{routes:[{path:I.JZ.contactSupport.relativePath,component:e=>{let t=e.close;return a.createElement(e7,{onComplete:t})}},{path:I.JZ.refundRequest.relativePath,component:e=>{let t=e.close;return a.createElement(v7,{onComplete:t})}},{path:I.JZ.whatsNew.relativePath,component:e=>{let t=e.close;return a.createElement(Z9,{onClose:t})}},{path:I.JZ.weeklyRecap.relativePath,component:a9,modalProps:{maxWidth:"768px"}},{path:I.JZ.plusTierIntro.relativePath,component:V6,modalProps:{maxWidth:"920px",bottomSheetOnMobile:!0}}]}),a.createElement(p,{large:!0},a.createElement(h4,null)),a.createElement(Y6,null))},b7=e=>{let t=e.openCustomizeModal;return a.createElement(uU.f,{"data-external-id":"dashboard-controls"},a.createElement(wt.Xb,{onClick:t,size:"small"},a.createElement(Yo.r,{name:"grid"}),a.createElement("span",null,"Customize")))};var x7=n(91763),w7=n(56207),C7=n(72572);const A7=u.default.span.withConfig({displayName:"DemoBanner__Text",componentId:"sc-1prwczx-0"})(["grid-column:2 / 2;text-align:center;"]),I7=(0,u.default)(sl.ZQ).withConfig({displayName:"DemoBanner__StyledIcon",componentId:"sc-1prwczx-1"})(["transform:translateY(2px);margin-left:",";"],(e=>{let t=e.theme;return x7.Fr?0:t.spacing.xsmall})),k7=(0,u.default)(m.g).attrs({alignCenter:!0,justifyEnd:!0}).withConfig({displayName:"DemoBanner__LinkContainer",componentId:"sc-1prwczx-2"})(["text-align:right;margin-left:",";"],(e=>e.theme.spacing.small)),S7=(0,u.default)((()=>{const e=(0,E.wA)();return a.createElement(w7.b,{"data-external-id":"demo-banner"},a.createElement(A7,null,"You are in demo mode, some features will be disabled."),a.createElement(k7,null,a.createElement(Vl.W,{stealthy:!0,to:I.JZ.signup(),onClick:()=>e((0,C7.Zm)(!0))},"Sign up ",x7.Fr?"":"for Monarch",a.createElement(I7,{name:"arrow-right"}))))})).withConfig({displayName:"DemoBanner__DemoBannerConnected",componentId:"sc-1prwczx-3"})([""]);var N7=n(18889);const T7=()=>{var e;const t=(0,lV.L)().id,n=(0,e$.L)(),l={merchants:[t]},r=(0,Pd.h)(),i=(0,o.A)(r,2),s=i[0],c=i[1],d=c.open,u=c.close,m=(0,et.I)(_7,{variables:{id:t}}).data,p=null!==(e=null===m||void 0===m?void 0:m.merchant)&&void 0!==e?e:{},g=p.name,h=p.logoUrl;return a.createElement(a.Fragment,null,a.createElement(l0,{title:null!==g&&void 0!==g?g:"",icon:a.createElement(Wl._,{url:h,size:24}),attributeFilter:l,attributeType:"merchant",extraControls:a.createElement(fe.XZZ,{variant:"default",onClick:d},"Edit merchant")}),a.createElement(s,{onClose:u},a.createElement(N7._,{merchantId:t,afterDelete:n})))},_7=Ee.lag;var D7,R7,M7;const L7=e=>{let t=e.children,n=e.className,l=e.collapsibleColumnWidth,r=e.isCollapsed,o=void 0!==r&&r;if(2!==a.Children.count(t))throw new Error("CollapsibleLayout must have exactly 2 children");return a.createElement(O7,{"data-external-id":"collapsible-layout",className:(0,q.cn)(o?"gap-0":"gap-gutter",n)},a.Children.map(t,((e,t)=>
10===t?a.createElement(P7,null,e):a.createElement(B7,{className:(0,q.cn)(o?"overflow-hidden opacity-0":"overflow-visible opacity-100"),style:{width:o?0:l}},a.createElement("div",{style:{width:l}},e)))))},O7=$d.s.div(D7||(D7=(0,wc.A)(["flex px-gutter pb-gutter transition-all duration-150 ease-in-out"]))),P7=$d.s.div(R7||(R7=(0,wc.A)(["min-w-(--breakpoint-sm) grow"]))),B7=$d.s.div(M7||(M7=(0,wc.A)(["sticky top-0 h-full transition-all duration-150 ease-in-out"])));var z7=n(76975),F7=n(10964),G7=n(43470),Y7=n(51761),U7=n(60995);const V7=[{key:"taxes",label:"Taxes (Fed/State/Local)",icon:"scan-receipt"},{key:"retirement",label:"Retirement Contributions",icon:"sunset"},{key:"health_insurance",label:"Health & Insurance Benefits",icon:"heart"},{key:"spending_accounts",label:"Tax-Advantaged Spending Accounts",icon:"credit-card"},{key:"other",label:"Other",icon:"more-horizontal"}],W7=new Map(V7.map((e=>[e.key,e]))),j7=[{type:"federal_income_tax",label:"Federal Income Tax",category:"taxes",sourceType:"statutory",taxTiming:"not_applicable",icon:"scan-receipt"},{type:"social_security_tax",label:"Social Security Tax",category:"taxes",sourceType:"statutory",taxTiming:"not_applicable",icon:"scan-receipt"},{type:"medicare_tax",label:"Medicare Tax",category:"taxes",sourceType:"statutory",taxTiming:"not_applicable",icon:"scan-receipt"},{type:"additional_medicare_tax",label:"Additional Medicare Tax",category:"taxes",sourceType:"statutory",taxTiming:"not_applicable",icon:"scan-receipt"},{type:"state_income_tax",label:"State Income Tax",category:"taxes",sourceType:"statutory",taxTiming:"not_applicable",icon:"scan-receipt"},{type:"state_disability_insurance",label:"State Disability / Paid Leave",category:"taxes",sourceType:"statutory",taxTiming:"not_applicable",icon:"scan-receipt"},{type:"paid_family_leave",label:"Paid Family Leave",category:"taxes",sourceType:"statutory",taxTiming:"not_applicable",icon:"scan-receipt"},{type:"state_unemployment",label:"State Unemployment Insurance",category:"taxes",sourceType:"statutory",taxTiming:"not_applicable",icon:"scan-receipt"},{type:"city_income_tax",label:"City / Local Income Tax",category:"taxes",sourceType:"statutory",taxTiming:"not_applicable",icon:"scan-receipt"},{type:"county_income_tax",label:"County Income Tax",category:"taxes",sourceType:"statutory",taxTiming:"not_applicable",icon:"scan-receipt"},{type:"school_district_tax",label:"School District Tax",category:"taxes",sourceType:"statutory",taxTiming:"not_applicable",icon:"scan-receipt"},{type:"traditional_401k",label:"Traditional 401(k)",category:"retirement",sourceType:"voluntary",taxTiming:"pre_tax",icon:"sunset"},{type:"plan_403b",label:"403(b)",category:"retirement",sourceType:"voluntary",taxTiming:"pre_tax",icon:"sunset"},{type:"plan_457b",label:"457(b)",category:"retirement",sourceType:"voluntary",taxTiming:"pre_tax",icon:"sunset"},{type:"simple_ira",label:"SIMPLE IRA",category:"retirement",sourceType:"voluntary",taxTiming:"pre_tax",icon:"sunset"},{type:"roth_401k",label:"Roth 401(k)",category:"retirement",sourceType:"voluntary",taxTiming:"post_tax",icon:"sunset"},{type:"roth_403b",label:"Roth 403(b)",category:"retirement",sourceType:"voluntary",taxTiming:"post_tax",icon:"sunset"},{type:"medical_insurance",label:"Medical Insurance Premium",category:"health_insurance",sourceType:"voluntary",taxTiming:"varies",icon:"heart"},{type:"dental_insurance",label:"Dental Insurance",category:"health_insurance",sourceType:"voluntary",taxTiming:"varies",icon:"heart"},{type:"vision_insurance",label:"Vision Insurance",category:"health_insurance",sourceType:"voluntary",taxTiming:"varies",icon:"heart"},{type:"hsa_payroll",label:"Health Savings Account (HSA)",category:"spending_accounts",sourceType:"voluntary",taxTiming:"pre_tax",icon:"credit-card"},{type:"healthcare_fsa",label:"Healthcare FSA",category:"spending_accounts",sourceType:"voluntary",taxTiming:"pre_tax",icon:"credit-card"},{type:"dependent_care_fsa",label:"Dependent Care FSA",category:"spending_accounts",sourceType:"voluntary",taxTiming:"pre_tax",icon:"credit-card"},{type:"transit_pass",label:"Commuter Benefits (Transit/Parking)",category:"spending_accounts",sourceType:"voluntary",taxTiming:"pre_tax",icon:"credit-card"},{type:"custom",label:"Other Payroll Deduction",category:"other",sourceType:"voluntary",taxTiming:"varies",icon:"more-horizontal"}],H7=new Map(j7.map((e=>[e.type,e]))),K7=e=>H7.get(e),q7=["excludeTypes","value","onChange","placeholder"],$7=new Map(V7.map((e=>[e.key,e.label]))),Z7=e=>{let t=e.excludeTypes,n=void 0===t?[]:t,l=e.value,r=e.onChange,o=e.placeholder,i=void 0===o?"Select deduction type...":o,s=(0,En.A)(e,q7);const c=(0,a.useMemo)((()=>new Set(n)),[n]),d=(0,a.useMemo)((()=>J7(j7,c)),[c]),u=(0,a.useMemo)((()=>{var e;return"string"===typeof l?null!==(e=d.find((e=>e.value===l)))&&void 0!==e?e:null:null!==l&&void 0!==l?l:null}),[l,d]);return a.createElement(U7.O,Object.assign({"data-external-id":"paycheck-deduction-select",options:d,value:u,onValueChange:e=>{var t;return null===r||void 0===r?void 0:r(null!==(t=e)&&void 0!==t?t:null)},placeholder:i},s))},J7=(e,t)=>e.filter((e=>"custom"===e.type||!t.has(e.type))).map((e=>{var t;return{value:e.type,label:e.label,icon:e.icon,category:e.category,sourceType:e.sourceType,taxTiming:e.taxTiming,leading:a.createElement("div",{className:"flex size-7 items-center justify-center rounded-md bg-background-secondary"},a.createElement(sl.ZQ,{name:e.icon,size:14})),description:null!==(t=$7.get(e.category))&&void 0!==t?t:e.category}})),X7=e=>{let t=e.payPeriodStart,n=e.payPeriodEnd,l=e.payDate,r=e.alreadyLinkedIds,i=e.onLink;const s=(0,Sq.k)().close,c=(0,a.useState)(new Set),d=(0,o.A)(c,2),u=d[0],m=d[1],g=(0,a.useState)(""),h=(0,o.A)(g,2),v=h[0],f=h[1],E=t&&l?t<l?t:l:null!==t&&void 0!==t?t:l,y=n&&l?n>l?n:l:null!==n&&void 0!==n?n:l,b=(0,Xo.IT)(V8.ZS,{variables:{filters:{startDate:E,endDate:y,creditsOnly:!0},limit:100,offset:0},skip:!E}),x=b.data,w=b.loading,C=(0,a.useMemo)((()=>{var e,t;return(null!==(e=null===x||void 0===x||null===(t=x.allTransactions)||void 0===t?void 0:t.results)&&void 0!==e?e:[]).filter((e=>!r.includes(e.id)))}),[x,r]),A=(0,a.useMemo)((()=>
1{if(!v.trim())return C;const e=v.toLowerCase();return C.filter((t=>{var n,a,l,r;return(null!==(n=null===(a=t.merchant)||void 0===a?void 0:a.name)&&void 0!==n?n:"").toLowerCase().includes(e)||(null===(l=t.account)||void 0===l||null===(r=l.displayName)||void 0===r?void 0:r.toLowerCase().includes(e))}))}),[C,v]),I=(0,a.useCallback)((e=>{m((t=>{const n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}))}),[]),k=(0,a.useCallback)((()=>{const e=C.filter((e=>u.has(e.id))).map((e=>{var t,n,a,l;return{transactionId:e.id,amount:e.amount,date:e.date,merchantName:null!==(t=null===(n=e.merchant)||void 0===n?void 0:n.name)&&void 0!==t?t:"Direct Deposit",accountName:null!==(a=null===(l=e.account)||void 0===l?void 0:l.displayName)&&void 0!==a?a:""}}));i(e),s()}),[C,u,i,s]);return a.createElement(Rc.L,{"data-external-id":"link-transaction-modal",title:"Link Transactions"},a.createElement(qY.S,null,a.createElement(Q7,{placeholder:"Search transactions...",value:v,onChange:e=>f(e.target.value),autoFocus:!0}),!E&&a.createElement(cU.vx,{icon:a.createElement(sl.ZQ,{name:"calendar",size:32}),title:"Set a pay period",subtitle:"Add pay period dates to see available transactions."}),E&&w&&a.createElement(iee,null,a.createElement(p.i,null)),E&&!w&&0===A.length&&a.createElement(cU.vx,{icon:a.createElement(sl.ZQ,{name:"search",size:32}),title:"No transactions found",subtitle:v?"Try adjusting your search.":"No income transactions found in this pay period."}),E&&!w&&A.length>0&&a.createElement(lee,null,A.map((e=>{var t,n,l,r,o;const i=u.has(e.id),s=e.amount<0;return a.createElement(eee,{key:e.id,$selected:i},a.createElement(fz.hm,{"aria-label":"Select ".concat(null!==(t=null===(n=e.merchant)||void 0===n?void 0:n.name)&&void 0!==t?t:"Unknown"),checked:i,onChange:()=>I(e.id)}),a.createElement(tee,null,a.createElement(nee,{size:"small",weight:"medium"},null!==(l=null===(r=e.merchant)||void 0===r?void 0:r.name)&&void 0!==l?l:"Unknown"),a.createElement(xt.v,{size:"xsmall",color:"textLight"},(0,Ba.AO)(e.date),null!==(o=e.account)&&void 0!==o&&o.displayName?" \xb7 ".concat(e.account.displayName):"")),a.createElement(aee,{size:"small",weight:"medium",$isCredit:s},s?"+":"",(0,rl.vv)(Math.abs(e.amount))))})))),a.createElement(Cq.R,null,a.createElement(ree,null,a.createElement(oee,{size:"small"},u.size>0?"".concat(u.size," transaction").concat(1!==u.size?"s":""," selected"):"Select transactions to link"),a.createElement(cu.WT,{size:"small",onClick:k,disabled:0===u.size},"Link Selected"))))},Q7=u.default.input.withConfig({displayName:"LinkTransactionModal__SearchInput",componentId:"jqwoup-0"})(["width:100%;padding:"," ",";border:1px solid ",";border-radius:6px;font-size:",";background:",";color:",";outline:none;margin-bottom:",";&:focus{border-color:",";}&::placeholder{color:",";}"],vt.YK.small,vt.YK.default,vt.Ee.color.border.primary,(e=>e.theme.fontSize.base),vt.Ee.color.background.primary,(e=>e.theme.color.text),vt.YK.default,(e=>e.theme.color.blue),vt.Ee.color.content.secondary),eee=u.default.label.withConfig({displayName:"LinkTransactionModal__TransactionRow",componentId:"jqwoup-1"})(["display:flex;align-items:center;gap:",";padding:"," ",";border-radius:",";cursor:pointer;transition:background 100ms ease;background:",";&:hover{background:",";}
1"],vt.YK.small,vt.YK.small,vt.YK.default,vt.r8.small,(e=>{let t=e.$selected,n=e.theme;return t?n.variables.color.background.info:"transparent"}),(e=>{let t=e.$selected,n=e.theme;return t?n.variables.color.background.infoHover:n.variables.color.background.secondary})),tee=(0,u.default)(m.g).attrs({column:!0}).withConfig({displayName:"LinkTransactionModal__TransactionInfo",componentId:"jqwoup-2"})(["flex:1;min-width:0;"]),nee=(0,u.default)(xt.v).withConfig({displayName:"LinkTransactionModal__MerchantName",componentId:"jqwoup-3"})(["white-space:nowrap;overflow:hidden;text-overflow:ellipsis;"]),aee=(0,u.default)(xt.v).withConfig({displayName:"LinkTransactionModal__TransactionAmount",componentId:"jqwoup-4"})(["color:",";white-space:nowrap;"],(e=>{let t=e.$isCredit,n=e.theme;return t?n.color.green:"inherit"})),lee=u.default.div.withConfig({displayName:"LinkTransactionModal__ScrollArea",componentId:"jqwoup-5"})(["max-height:400px;overflow-y:auto;margin:0 -",";"],vt.YK.default),ree=(0,u.default)(m.g).attrs({justifyBetween:!0,alignCenter:!0}).withConfig({displayName:"LinkTransactionModal__FooterContent",componentId:"jqwoup-6"})(["width:100%;"]),oee=(0,u.default)(xt.v).withConfig({displayName:"LinkTransactionModal__SelectedCount",componentId:"jqwoup-7"})(["color:",";"],vt.Ee.color.content.secondary),iee=(0,u.default)(m.g).attrs({center:!0}).withConfig({displayName:"LinkTransactionModal__LoadingContainer",componentId:"jqwoup-8"})(["padding:",";"],vt.YK.xlarge),see=e=>{let t=e.deposits,n=e.netAmount,l=e.payPeriodStart,r=e.payPeriodEnd,i=e.payDate,s=e.onAddDeposits,c=e.onRemoveDeposit;const d=(0,Pd.h)(),u=(0,o.A)(d,2),m=u[0],p=u[1].open,g=(0,a.useMemo)((()=>t.map((e=>e.transactionId))),[t]),h=(0,a.useMemo)((()=>t.reduce(((e,t)=>e+Math.abs(t.amount)),0)),[t]),v=void 0!==n&&n>0&&Math.abs(h-n)<.01;return a.createElement("div",{"data-external-id":"paycheck-deposits-section"},a.createElement(cee,null,"Net Deposits"),0===t.length&&a.createElement(xt.v,{size:"small",color:"textLight"},"No transactions linked yet. Link transactions that match your net pay deposit."),t.map((e=>a.createElement(dee,{key:e.transactionId},a.createElement(uee,null,a.createElement(mee,{size:"small",weight:"medium"},e.merchantName||"Direct Deposit"),a.createElement(xt.v,{size:"xsmall",color:"textLight"},(0,Ba.AO)(e.date),e.accountName?" \xb7 ".concat(e.accountName):"")),a.createElement(pee,{size:"small",weight:"medium"},"+",(0,rl.vv)(Math.abs(e.amount))),a.createElement(gee,{type:"button",onClick:()=>c(e.transactionId),title:"Remove linked transaction"},a.createElement(sl.ZQ,{name:"x",size:14}))))),a.createElement(hee,{type:"button",onClick:()=>p()},a.createElement(sl.ZQ,{name:"plus",size:14}),"Link transaction"),t.length>0&&void 0!==n&&n>0&&a.createElement(vee,{$matches:v},a.createElement(fee,null,a.createElement(xt.v,{size:"small",color:"textLight"},"Linked deposits"),a.createElement(xt.v,{size:"small",weight:"medium"},(0,rl.vv)(h))),a.createElement(fee,null,a.createElement(xt.v,{size:"small",color:"textLight"},"Expected net pay"),a.createElement(xt.v,{size:"small",weight:"medium"},(0,rl.vv)(n))),!v&&a.createElement(fee,null,a.createElement(xt.v,{size:"small",color:"textLight"},"Difference"),a.createElement(xt.v,{size:"small",weight:"medium",style:{color:"inherit"}},h>n?"+":"-",(0,rl.vv)(Math.abs(h-n)))),a.createElement(Eee,null,a.createElement(sl.ZQ,{name:v?"check-circle":"alert-circle",size:14}),a.createElement(xt.v,{size:"xsmall",weight:"medium"},v?"Deposits match net pay":"Deposits do not match net pay"))),a.createElement(m,null,a.createElement(X7,{payPeriodStart:l,payPeriodEnd:r,payDate:i,alreadyLinkedIds:g,onLink:s})))},cee=(0,u.default)(xt.v).withConfig({displayName:"PaycheckDepositsSection__SectionLabel",componentId:"sc-1ty1kdm-0"})(["display:block;font-weight:",";font-size:",";margin-bottom:",";"],(e=>e.theme.fontWeight.medium),(e=>e.theme.fontSize.base),vt.YK.xsmall),dee=(0,u.default)(m.g).attrs({justifyBetween:!0,alignCenter:!0}).withConfig({displayName:"PaycheckDepositsSection__DepositCard",componentId:"sc-1ty1kdm-1"})(["padding:",";background:",";border-radius:",";margin-bottom:",";gap:",";"],vt.YK.small,vt.Ee.color.background.secondary,vt.r8.small,vt.YK.xsmall,vt.YK.small),uee=(0,u.default)(m.g).attrs({column:!0}).withConfig({displayName:"PaycheckDepositsSection__DepositInfo",componentId:"sc-1ty1kdm-2"})(["flex:1;min-width:0;"]),mee=(0,u.default)(xt.v).withConfig({displayName:"PaycheckDepositsSection__DepositMerchant",componentId:"sc-1ty1kdm-3"})(["white-space:nowrap;overflow:hidden;text-overflow:ellipsis;"]),pee=(0,u.default)(xt.v).withConfig({displayName:"PaycheckDepositsSection__DepositAmount",componentId:"sc-1ty1kdm-4"})(["color:",";white-space:nowrap;"],(e=>e.theme.color.green)),gee=u.default.button.withConfig({displayName:"PaycheckDepositsSection__RemoveButton",componentId:"sc-1ty1kdm-5"})(["width:24px;height:24px;background:none;border:none;cursor:pointer;color:",";padding:0;border-radius:4px;display:flex;align-items:center;justify-content:center;flex-shrink:0;&:hover{color:",";background:",";}"],vt.Ee.color.content.secondary,(e=>e.theme.color.red),(e=>e.theme.color.redLight)),hee=u.default.button.withConfig({displayName:"PaycheckDepositsSection__LinkButton",componentId:"sc-1ty1kdm-6"})(["background:none;border:none;cursor:pointer;color:",";font-size:",";font-weight:",";padding:0;margin-top:",";display:inline-flex;align-items:center;gap:",";&:hover{text-decoration:underline;}"],(e=>e.theme.color.blue),(e=>e.theme.fontSize.small),(e=>e.theme.fontWeight.medium),vt.YK.small,vt.YK.xxsmall),vee=u.default.div.withConfig({displayName:"PaycheckDepositsSection__ReconciliationBox",componentId:"sc-1ty1kdm-7"})(["padding:"," ",";background:",";border:1px solid ",";border-radius:",";margin-top:",";"],vt.YK.small,vt.YK.default,(e=>e.$matches?"rgba(52, 199, 89, 0.08)":"rgba(255, 59, 48, 0.08)"),(e=>{let t=e.$matches,n=e.theme;return t?n.color.green:n.color.red}),vt.r8.small,vt.YK.small),fee=(0,u.default)(m.g).attrs({justifyBetween:!0,alignCenter:!0}).withConfig({displayName:"PaycheckDepositsSection__ReconciliationRow",componentId:"sc-1ty1kdm-8"})(["padding:2px 0;"]),Eee=(0,u.default)(m.g).attrs({alignCenter:!0,gap:"xxsmall"}).withConfig({displayName:"PaycheckDepositsSection__ReconciliationStatus",componentId:"sc-1ty1kdm-9"})(["margin-top:",";"],vt.YK.xxsmall),yee=(0,Qt.J)("\n  query Common_GetPaycheckEmployers($search: String, $limit: Int, $offset: Int) {\n    paycheckEmployers(search: $search, limit: $limit, offset: $offset) {\n      id\n      name\n      paycheckCount\n      createdAt\n    }\n    paycheckEmployerCount\n  }\n"),bee=(0,Qt.J)("\n  mutation Common_CreatePaycheckEmployer($input: CreatePaycheckEmployerInput!) {\n    createPaycheckEmployer(input: $input) {\n      employer {\n        id\n        name\n        paycheckCount\n        createdAt\n      }\n      errors {\n        message\n      }\n    }\n  }\n"),xee=(0,Qt.J)("\n  mutation Common_UpdatePaycheckEmployer($input: UpdatePaycheckEmployerInput!) {\n    updatePaycheckEmployer(input: $input) {\n      employer {\n        id\n        name\n        paycheckCount\n        createdAt\n      }\n      errors {\n        message\n      }\n    }\n  }\n"),wee=(0,Qt.J)("\n  mutation Common_DeletePaycheckEmployer($id: ID!) {\n    deletePaycheckEmployer(id: $id) {\n      success\n      errors {\n        message\n      }\n    }\n  }\n"),Cee=e=>{let t=e.initialName,n=void 0===t?"":t,l=e.onCreate;const r=(0,Sq.k)().close,s=(0,C.RU)(),c=(0,a.useState)(n),d=(0,o.A)(c,2),u=d[0],m=d[1],p=(0,a.useState)(!1),g=(0,o.A)(p,2),h=g[0],v=g[1],f=(0,i.n)(bee,{refetchQueries:[{query:yee}],awaitRefetchQueries:!0}),E=(0,o.A)(f,1)[0],y=(0,a.useCallback)((async()=>
1{if(u.trim()){v(!0);try{var e,t,n,a;const i=await E({variables:{input:{name:u.trim()}}}),c=null===(e=i.data)||void 0===e||null===(t=e.createPaycheckEmployer)||void 0===t?void 0:t.errors,d=null===(n=i.data)||void 0===n||null===(a=n.createPaycheckEmployer)||void 0===a?void 0:a.employer;var o;if(c)s({description:null!==(o=c.message)&&void 0!==o?o:void 0});else d&&(null===l||void 0===l||l(d),r())}catch(i){s({description:"Couldn't create employer."})}finally{v(!1)}}}),[u,E,s,l,r]);return a.createElement(Rc.L,{"data-external-id":"create-employer-modal",title:"Create Employer"},a.createElement(qY.S,null,a.createElement(Aee,null,"Employer name"),a.createElement(Ry.X,{name:"name",value:u,placeholder:"Enter employer name...",onChange:e=>m(e.target.value),onKeyDown:e=>{"Enter"===e.key&&y()},autoFocus:!0})),a.createElement(Cq.R,null,a.createElement(wt.Xb,{onClick:r},"Cancel"),a.createElement(cu.WT,{onClick:y,disabled:h||!u.trim()},h?"Creating...":"Create")))},Aee=(0,u.default)(xt.v).attrs({size:"small",weight:"medium"}).withConfig({displayName:"CreateEmployerModal__FieldLabel",componentId:"sc-1mj1z5q-0"})(["margin-bottom:",";"],(e=>e.theme.spacing.xsmall)),Iee=["value","onChange","placeholder","clearable"],kee=e=>{let t=e.value,n=e.onChange,l=e.placeholder,r=void 0===l?"Select employer...":l,i=e.clearable,s=void 0===i||i,c=(0,En.A)(e,Iee);const d=(0,a.useState)(""),u=(0,o.A)(d,2),m=u[0],p=u[1],g=(0,a.useState)(!1),h=(0,o.A)(g,2),v=h[0],f=h[1],E=(0,a.useState)(null),y=(0,o.A)(E,2),b=y[0],x=y[1],w=(0,xy.d)(m,200),C=(0,et.I)(yee,{variables:{search:w||null,limit:50}}),A=C.data,I=C.isNetworkRequestInFlight,k=C.refetch,S=(0,a.useMemo)((()=>{var e;return null!==(e=null===A||void 0===A?void 0:A.paycheckEmployers)&&void 0!==e?e:[]}),[null===A||void 0===A?void 0:A.paycheckEmployers]),N=(0,a.useMemo)((()=>S.map((e=>({value:e.id,label:e.name})))),[S]),T=(0,a.useMemo)((()=>{if("string"===typeof t&&t){const e=N.find((e=>e.value===t));return e||(b&&b.value===t?b:null)}return t||null}),[t,N,b]),_=(0,a.useRef)();(0,a.useEffect)((()=>{const e="string"===typeof t?t:null===t||void 0===t?void 0:t.value;e?T&&e!==_.current&&(_.current=e,p(T.label)):_.current=void 0}),[t,T]);const D=(0,a.useCallback)((e=>{e?null===n||void 0===n||n(e):null===n||void 0===n||n(null)}),[n]),R=(0,a.useCallback)((async e=>{const t={value:e.id,label:e.name};x(t),null===n||void 0===n||n(t),await k()}),[n,k]);return a.createElement(a.Fragment,null,a.createElement(U7.O.Root,Object.assign({},c,{items:N,value:T,onValueChange:D,isItemEqualToValue:(e,t)=>(null===e||void 0===e?void 0:e.value)===(null===t||void 0===t?void 0:t.value),inputValue:m,onInputValueChange:p,loading:I,onOpenChange:e=>{var t;e?p(""):(_.current=void 0,p(null!==(t=null===T||void 0===T?void 0:T.label)&&void 0!==t?t:""))},filter:()=>!0}),a.createElement(U7.O.InputGroup,null,a.createElement(U7.O.Input,{placeholder:r}),s&&a.createElement(U7.O.Clear,{"aria-label":"Clear"}),a.createElement(U7.O.Trigger,{"aria-label":"Toggle options"})),a.createElement(U7.O.Content,null,a.createElement(U7.O.Loading,null),a.createElement(U7.O.Empty,null),a.createElement(U7.O.List,null,(e=>a.createElement(U7.O.Option,{key:e.value,value:e},e.label))),a.createElement(U7.O.Footer,null,a.createElement(Wb.X,{variant:"text",colorScheme:"link",size:"sm",className:"px-0",onClick:()=>f(!0),icon:a.createElement(tR.Wa3,null)},"Create new employer")))),v&&a.createElement(um.b,{onClose:()=>f(!1)},a.createElement(Cee,{initialName:m,onCreate:R})))},See=e=>{let t=e.name,n=e.label,l=e.placeholder;return a.createElement(tC.zB,{"data-external-id":"paycheck-employer-select-field",name:t,label:n},(e=>a.createElement(kee,{value:e.value,onChange:t=>{var n;return e.onChange(null!==(n=null===t||void 0===t?void 0:t.value)&&void 0!==n?n:null)},placeholder:l})))},Nee=["value","onChange","placeholder"],Tee=[{value:"adp",label:"ADP (RUN Powered by ADP)"},{value:"paychex",label:"Paychex (Paychex Flex)"},{value:"gusto",label:"Gusto"},{value:"quickbooks",label:"QuickBooks Payroll (Intuit)"},{value:"paylocity",label:"Paylocity"},{value:"paycom",label:"Paycom"},{value:"paycor",label:"Paycor"},{value:"rippling",label:"Rippling"},{value:"onpay",label:"OnPay"},{value:"patriot",label:"Patriot Payroll"},{value:"square",label:"Square Payroll"},{value:"wave",label:"Wave Payroll"},{value:"homebase",label:"Homebase Payroll"},{value:"surepayroll",label:"SurePayroll"},{value:"deel",label:"Deel"},{value:"remote",label:"Remote"},{value:"papaya_global",label:"Papaya Global"},{value:"velocity_global",label:"Velocity Global"},{value:"justworks",label:"Justworks"},{value:"trinet",label:"TriNet"},{value:"insperity",label:"Insperity"},{value:"zenefits",label:"Zenefits (TriNet Zenefits)"},{value:"ukg",label:"UKG (Ultimate Kronos Group)"},{value:"workday",label:"Workday"},{value:"cloudpay",label:"CloudPay"},{value:"bamboohr",label:"BambooHR Payroll"},{value:"other",label:"Other"}],_ee=e=>
1{let t=e.value,n=e.onChange,l=e.placeholder,r=void 0===l?"Select provider...":l,o=(0,En.A)(e,Nee);const i=(0,a.useMemo)((()=>{var e;return"string"===typeof t?null!==(e=Tee.find((e=>e.value===t)))&&void 0!==e?e:null:null!==t&&void 0!==t?t:null}),[t]);return a.createElement(U7.O,Object.assign({"data-external-id":"payroll-provider-select"},o,{options:Tee,value:i,onValueChange:e=>null===n||void 0===n?void 0:n(e),placeholder:r}))};var Dee=n(82263);(0,Qt.J)("\n  fragment PaycheckDeductionFields on PaycheckDeduction {\n    id\n    deductionType\n    customDeductionName\n    amount\n    createdAt\n  }\n\n  fragment PaycheckDepositFields on PaycheckDeposit {\n    id\n    transaction {\n      id\n      amount\n      date\n      merchant {\n        id\n        name\n      }\n      account {\n        id\n        displayName\n      }\n    }\n    createdAt\n  }\n\n  fragment PaycheckFields on Paycheck {\n    id\n    employer {\n      id\n      name\n    }\n    employerName\n    payrollProvider\n    payDate\n    payPeriodStart\n    payPeriodEnd\n    grossAmount\n    createdAt\n    isMagicImported\n    owner {\n      id\n      name\n      profilePictureUrl\n    }\n    createdBy {\n      id\n      name\n    }\n    deductions {\n      ...PaycheckDeductionFields\n    }\n    deposits {\n      ...PaycheckDepositFields\n    }\n  }\n");const Ree=(0,Qt.J)("\n  query Common_GetPaychecks($startDate: Date, $endDate: Date, $ownerId: ID, $employerId: ID) {\n    paychecks(\n      startDate: $startDate\n      endDate: $endDate\n      ownerId: $ownerId\n      employerId: $employerId\n    ) {\n      ...PaycheckFields\n    }\n  }\n"),Mee=((0,Qt.J)("\n  query Common_GetPaycheck($id: ID!) {\n    paycheck(id: $id) {\n      ...PaycheckFields\n    }\n  }\n"),(0,Qt.J)("\n  mutation Common_CreatePaycheck($input: CreatePaycheckInput!) {\n    createPaycheck(input: $input) {\n      paycheck {\n        ...PaycheckFields\n      }\n      errors {\n        fieldErrors {\n          field\n          messages\n        }\n        message\n        code\n      }\n    }\n  }\n")),Lee=(0,Qt.J)("\n  mutation Common_UpdatePaycheck($input: UpdatePaycheckInput!) {\n    updatePaycheck(input: $input) {\n      paycheck {\n        ...PaycheckFields\n      }\n      errors {\n        fieldErrors {\n          field\n          messages\n        }\n        message\n        code\n      }\n    }\n  }\n"),Oee=(0,Qt.J)("\n  mutation Common_DeletePaycheck($input: DeletePaycheckInput!) {\n    deletePaycheck(input: $input) {\n      success\n      errors {\n        fieldErrors {\n          field\n          messages\n        }\n        message\n        code\n      }\n    }\n  }\n"),Pee=(0,Qt.J)("\n  query Common_GetPaychecksSummary(\n    $startDate: Date\n    $endDate: Date\n    $ownerIds: [ID!]\n    $employerId: ID\n  ) {\n    paychecksSummary(\n      startDate: $startDate\n      endDate: $endDate\n      ownerIds: $ownerIds\n      employerId: $employerId\n    ) {\n      count\n      totalGross\n      totalDeductions\n      totalNet\n      deductionRate\n      deductionsByType {\n        deductionType\n        totalAmount\n      }\n    }\n  }\n"),Bee=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const t=e.startDate,n=e.endDate,l=e.ownerId,r=e.employerId,o=(0,et.I)(Ree,{variables:{startDate:null!==t&&void 0!==t?t:null,endDate:null!==n&&void 0!==n?n:null,ownerId:null!==l&&void 0!==l?l:null,employerId:null!==r&&void 0!==r?r:null}}),i=o.data,s=o.isLoadingInitialData,c=o.refetch;return{paychecks:(0,a.useMemo)((()=>{var e;return null!==(e=null===i||void 0===i?void 0:i.paychecks)&&void 0!==e?e:[]}),[null===i||void 0===i?void 0:i.paychecks]),isLoadingInitialData:s,refetch:c}},zee="Common_GetPaychecks",Fee=()=>{const e=(0,i.n)(Mee,{refetchQueries:[zee]}),t=(0,o.A)(e,2),n=t[0],l=t[1].loading,r=(0,i.n)(Lee,{refetchQueries:[zee]}),s=(0,o.A)(r,2),c=s[0],d=s[1].loading,u=(0,i.n)(Oee,{refetchQueries:[zee]}),m=(0,o.A)(u,2),p=m[0],g=m[1].loading;return{createPaycheck:(0,a.useCallback)((async e=>{var t;return null===(t=(await n({variables:{input:e}})).data)||void 0===t?void 0:t.createPaycheck}),[n]),updatePaycheck:(0,a.useCallback)((async e=>{var t;return null===(t=(await c({variables:{input:e}})).data)||void 0===t?void 0:t.updatePaycheck}),[c]),deletePaycheck:(0,a.useCallback)((async e=>{var t;return null===(t=(await p({variables:{input:{id:e}}})).data)||void 0===t?void 0:t.deletePaycheck}),[p]),isCreating:l,isUpdating:d,isDeleting:g,isLoading:l||d||g}};let Gee=0;const Yee=e=>{var t,n;let l=e.paycheck,r=e.onClose;const i=Fee(),s=i.updatePaycheck,c=i.deletePaycheck,d=i.isDeleting,u=(0,C.RU)(),m=(0,Pd.h)(),p=(0,o.A)(m,2),g=p[0],h=p[1],v=h.open,f=h.close,E=(0,Pd.h)(),y=(0,o.A)(E,2),b=y[0],x=y[1],w=x.open,A=x.close,I=(0,a.useState)(null),k=(0,o.A)(I,2),S=k[0],N=k[1],T=(0,a.useMemo)((()=>l.deductions.reduce(((e,t)=>e+t.amount),0)),[l.deductions]),_=l.grossAmount-T,D=(0,a.useMemo)((()=>l.deposits.filter((e=>e.transaction)).map((e=>{var t,n,a,l;return{transactionId:e.transaction.id,amount:e.transaction.amount,date:e.transaction.date,merchantName:null!==(t=null===(n=e.transaction.merchant)||void 0===n?void 0:n.name)&&void 0!==t?t:"Direct Deposit",accountName:null!==(a=null===(l=e.transaction.account)||void 0===l?void 0:l.displayName)&&void 0!==a?a:""}}))),[l.deposits]),R=(0,a.useState)(D),M=(0,o.A)(R,2),L=M[0],O=M[1],P=(0,a.useCallback)((async e=>{try{await s({id:l.id,deposits:e.map((e=>({transactionId:e.transactionId}))),deductions:void 0,employerId:void 0,grossAmount:void 0,ownerId:void 0,payDate:void 0,payPeriodEnd:void 0,payPeriodStart:void 0,payrollProvider:void 0})}catch(t){u({description:"Couldn't update linked deposits."})}}),[l.id,s,u]),B=(0,a.useCallback)((e=>{const t=e.map((e=>({transactionId:e.transactionId,amount:e.amount,date:e.date,merchantName:e.merchantName,accountName:e.accountName}))),n=[...L,...t];O(n),P(n)}),[L,P]),z=(0,a.useCallback)((e=>{N(e),w()}),[w]),F=(0,a.useCallback)((()=>
1{if(!S)return;const e=L.filter((e=>e.transactionId!==S));O(e),P(e),N(null),A()}),[S,L,P,A]),G=(0,a.useMemo)((()=>{var e,t,n,a,r,o,i;return{employerId:null!==(e=null===(t=l.employer)||void 0===t?void 0:t.id)&&void 0!==e?e:"",payrollProvider:null!==(n=l.payrollProvider)&&void 0!==n?n:"other",payDate:l.payDate,payPeriodStart:null!==(a=l.payPeriodStart)&&void 0!==a?a:null,payPeriodEnd:null!==(r=l.payPeriodEnd)&&void 0!==r?r:null,grossAmount:l.grossAmount,ownerId:null!==(o=null===(i=l.owner)||void 0===i?void 0:i.id)&&void 0!==o?o:"",deductions:l.deductions.length>0?l.deductions.map(Uee):[]}}),[l]),Y=(0,a.useCallback)((async e=>{try{const t=e.deductions.filter((e=>{var t;return e.deductionType&&(null!==(t=e.amount)&&void 0!==t?t:0)>0})).map((e=>({deductionType:e.deductionType,customDeductionName:"custom"===e.deductionType&&e.customDeductionName?e.customDeductionName:void 0,amount:e.amount})));await s({id:l.id,employerId:e.employerId||void 0,payrollProvider:e.payrollProvider||void 0,payDate:e.payDate,payPeriodStart:e.payPeriodStart||void 0,payPeriodEnd:e.payPeriodEnd||void 0,grossAmount:e.grossAmount,ownerId:e.ownerId||void 0,deductions:t.map((e=>(0,U.A)((0,U.A)({},e),{},{deductionType:e.deductionType}))),deposits:L.map((e=>({transactionId:e.transactionId})))}),(0,Ge.u4)(Ye.i0.PaycheckEdited,{paycheck_id:l.id})}catch(t){u({description:"Couldn't update paycheck."})}}),[l.id,L,s,u]),V=(0,a.useCallback)((async()=>{await c(l.id),(0,Ge.u4)(Ye.i0.PaycheckDeleted,{paycheck_id:l.id}),f(),r()}),[c,l.id,r,f]);return a.createElement(F7.v,{"data-external-id":"paycheck-drawer",onClose:r,title:"Paycheck Details"},a.createElement(jee,null,a.createElement(Eu.lV,{key:l.id,initialValues:G,onSubmit:Y,submitOnBlur:!0},a.createElement(Hee,null,a.createElement(Kee,null,a.createElement("div",{className:"flex flex-col gap-xs"},a.createElement(Zee,null,l.employerName||"Unknown employer"),a.createElement(xt.v,{size:"small",color:"textLight"},(0,Ba.AO)(l.payDate))),a.createElement("div",{className:"flex flex-col items-end gap-sm"},a.createElement(qee,null,(0,rl.vv)(l.grossAmount)),a.createElement($ee,{size:"small"},"Net ",(0,rl.vv)(_))))),a.createElement(Jee,null,a.createElement(Dee.R,{label:"Employer"},a.createElement(See,{name:"employerId",label:null})),a.createElement(Dee.R,{label:"Payroll Provider"},a.createElement(tC.zB,{name:"payrollProvider",label:null},(e=>a.createElement(_ee,{value:e.value,onChange:t=>{var n;return e.onChange(null!==(n=null===t||void 0===t?void 0:t.value)&&void 0!==n?n:null)}})))),a.createElement(Dee.R,{label:"Pay Date"},a.createElement(tC.zB.Date,{name:"payDate",label:null,dateFormat:iC.yP})),a.createElement(Dee.R,{label:"Pay Period"},a.createElement("div",{className:"flex gap-default *:min-w-0 *:flex-1"},a.createElement(tC.zB.Date,{name:"payPeriodStart",label:null,dateFormat:"MMM d, yyyy",placeholder:"Start"}),a.createElement(tC.zB.Date,{name:"payPeriodEnd",label:null,dateFormat:"MMM d, yyyy",placeholder:"End"}))),a.createElement(Dee.R,{label:"Gross Pay"},a.createElement(tC.zB.Currency,{name:"grossAmount",label:null,precision:0,restoreOnClear:!0})),a.createElement(Y7.w,{name:"ownerId",label:"Owner",allowShared:!1,className:"mb-default"}),a.createElement(z7.P,{text:""}),a.createElement(Xee,null,a.createElement(Qee,null,a.createElement(ete,null,"Gross Pay"),a.createElement(tte,null,(0,rl.vv)(l.grossAmount))),a.createElement(Qee,null,a.createElement(ete,null,"Deductions (",l.deductions.length,")"),a.createElement(tte,{$variant:"red"},"-",(0,rl.vv)(T))),a.createElement(nte,null),a.createElement(Qee,null,a.createElement(ete,null,"Net Pay"),a.createElement(tte,{$variant:"green"},(0,rl.vv)(_)))),a.createElement(Wee,null),a.createElement(z7.P,{text:""}),a.createElement(see,{deposits:L,netAmount:_,payPeriodStart:null!==(t=l.payPeriodStart)&&void 0!==t?t:null,payPeriodEnd:null!==(n=l.payPeriodEnd)&&void 0!==n?n:null,payDate:l.payDate,onAddDeposits:B,onRemoveDeposit:z}),l.isMagicImported&&a.createElement(a.Fragment,null,a.createElement(z7.P,{text:""}),a.createElement(cte,null,a.createElement("div",{className:"flex items-center gap-sm"},a.createElement(dte,null,a.createElement(sl.ZQ,{name:"sparkle",size:16})),a.createElement(xt.v,{size:"small",weight:"medium"},"Created by Magic Import")))),a.createElement(ste,null,a.createElement(z7.P,{text:"Other Options"}),a.createElement(G7.jI,{type:"button",onClick:v},"Delete paycheck"))))),a.createElement(g,null,a.createElement(xC.$,{title:"Delete paycheck",confirm:"Delete",onCancel:f,onConfirm:V,isLoading:d},a.createElement("div",null,"Are you sure you want to delete this paycheck?"),a.createElement("div",null,"By deleting this paycheck, you will remove all of its data from Monarch."))),a.createElement(b,null,a.createElement(xC.$,{title:"Remove linked transaction",confirm:"Remove",onCancel:()=>{N(null),A()},onConfirm:F},a.createElement("div",null,"Are you sure you want to remove this linked transaction?"),a.createElement("div",null,"The transaction will be unlinked from this paycheck but will not be deleted."))))},Uee=e=>{var t;return{key:"ded-".concat(Gee+=1),deductionType:e.deductionType,customDeductionName:null!==(t=e.customDeductionName)&&void 0!==t?t:"",amount:e.amount}},Vee=e=>{var t,n,a,l,r;if(!e.deductionType)return null;const o=K7(e.deductionType),i="custom"===e.deductionType&&e.customDeductionName?e.customDeductionName:null!==(t=null===o||void 0===o?void 0:o.label)&&void 0!==t?t:e.deductionType;return{value:e.deductionType,label:i,icon:null!==(n=null===o||void 0===o?void 0:o.icon)&&void 0!==n?n:"minus-circle",category:null!==(a=null===o||void 0===o?void 0:o.category)&&void 0!==a?a:"other",sourceType:null!==(l=null===o||void 0===o?void 0:o.sourceType)&&void 0!==l?l:"voluntary",taxTiming:null!==(r=null===o||void 0===o?void 0:o.taxTiming)&&void 0!==r?r:"post_tax"}},Wee=()=>{const e=(0,hu.x)(),t=e.values,n=e.setFieldValue,l=e.handleSubmit,r=t.deductions,i=(0,a.useState)(null),s=(0,o.A)(i,2),c=s[0],d=s[1],u=(0,Pd.h)(),m=(0,o.A)(u,2),p=m[0],g=m[1],h=g.open,v=g.close,f=(0,a.useMemo)((()=>r.filter((e=>e.deductionType)).map((e=>e.deductionType))),[r]),E=e=>{var t;return e.deductionType&&(null!==(t=e.amount)&&void 0!==t?t:0)>0&&("custom"!==e.deductionType||!!e.customDeductionName.trim())},y=(0,a.useCallback)((()=>{const e={key:"ded-".concat(Gee+=1),deductionType:"",customDeductionName:"",amount:void 0};n("deductions",[...r,e])}),[r,n]),b=(0,a.useCallback)(((e,t)=>{if(!t)return;const a=r.map((n=>n.key===e?(0,U.A)((0,U.A)({},n),{},{deductionType:t.value,customDeductionName:""}):n));n("deductions",a);const o=a.find((t=>t.key===e));o&&E(o)&&setTimeout((()=>l()),0)}),[r,n,l]),x=(0,a.useCallback)(((e,t)=>{n("deductions",r.map((n=>n.key===e?(0,U.A)((0,U.A)({},n),{},{customDeductionName:t}):n)))}),[r,n]),w=(0,a.useCallback)((e=>{const t=r.find((t=>t.key===e));t&&E(t)&&l()}),[r,l]),C=(0,a.useCallback)((e=>{const t=r.find((t=>t.key===e));if(!t||!t.deductionType&&!t.amount)return n("deductions",r.filter((t=>t.key!==e))),void setTimeout((()=>l()),0);d(e),h()}),[r,n,l,h]),A=(0,a.useCallback)((()=>{c&&(n("deductions",r.filter((e=>e.key!==c))),setTimeout((()=>l()),0),d(null),v())}),[c,r,n,l,v]),I=(0,a.useCallback)(((e,t)=>{n("deductions",r.map((n=>n.key===e?(0,U.A)((0,U.A)({},n),{},{amount:t}):n)))}),[r,n]),k=(0,a.useCallback)((e=>{const t=r.find((t=>t.key===e));t&&E(t)&&l()}),[r,l]),S=c?r.find((e=>e.key===c)):null;return a.createElement(a.Fragment,null,a.createElement(Dee.R,{label:"Deductions"},r.map((e=>{var t;return a.createElement(ate,{key:e.key},a.createElement(lte,null,a.createElement("div",{className:"min-w-0"},a.createElement(Z7,{excludeTypes:f.filter((t=>t!==e.deductionType)),onChange:t=>b(e.key,t),value:Vee(e),placeholder:"Select deduction..."})),a.createElement(fe.K$5,{value:null!==(t=e.amount)&&void 0!==t?t:null,min:0,step:"any",onValueChange:t=>
1I(e.key,null!==t&&void 0!==t?t:void 0),name:"deduction_amount_".concat(e.key),onBlur:()=>k(e.key)}),a.createElement(ote,{type:"button",onClick:()=>C(e.key),title:"Remove deduction"},a.createElement(sl.ZQ,{name:"x",size:14}))),"custom"===e.deductionType&&a.createElement(rte,null,a.createElement(Ry.X,{name:"deduction_name_".concat(e.key),value:e.customDeductionName,onChange:t=>x(e.key,t.target.value),onBlur:()=>w(e.key),placeholder:"Enter deduction name...",small:!0})))})),a.createElement(ite,{type:"button",onClick:y},a.createElement(sl.ZQ,{name:"plus",size:14}),"Add deduction")),a.createElement(p,null,a.createElement(xC.$,{title:"Remove deduction",confirm:"Remove",onCancel:()=>{d(null),v()},onConfirm:A},a.createElement("div",null,"Are you sure you want to remove"," ",S?'"'.concat((e=>{var t;if("custom"===e.deductionType&&e.customDeductionName)return e.customDeductionName;const n=K7(e.deductionType);return null!==(t=null===n||void 0===n?void 0:n.label)&&void 0!==t?t:e.deductionType})(S),'"'):"this deduction","?"),a.createElement("div",null,"By removing this deduction, it will no longer be reflected in your paycheck summary."))))},jee=u.default.div.withConfig({displayName:"PaycheckDrawer__Root",componentId:"q6xvrq-0"})(["--main-padding:",";"],vt.YK.xlarge),Hee=u.default.div.withConfig({displayName:"PaycheckDrawer__HeaderRoot",componentId:"q6xvrq-1"})(["padding:var(--main-padding);padding-top:",";padding-bottom:0;"],vt.YK.xlarge),Kee=(0,u.default)(m.g).attrs({justifyBetween:!0,alignStart:!0}).withConfig({displayName:"PaycheckDrawer__TopRow",componentId:"q6xvrq-2"})(["width:100%;margin-bottom:",";"],vt.YK.xsmall),qee=(0,u.default)(xt.v).withConfig({displayName:"PaycheckDrawer__AmountDisplay",componentId:"q6xvrq-3"})(["font-size:",";font-weight:",";"],(e=>e.theme.fontSize.xlarge),(e=>e.theme.fontWeight.medium)),$ee=(0,u.default)(xt.v).withConfig({displayName:"PaycheckDrawer__NetPayText",componentId:"q6xvrq-4"})(["color:",";"],vt.Ee.color.content.secondary),Zee=(0,u.default)(xt.v).attrs({size:"xlarge",weight:"medium"}).withConfig({displayName:"PaycheckDrawer__EmployerTitle",componentId:"q6xvrq-5"})(["display:block;"]),Jee=u.default.div.withConfig({displayName:"PaycheckDrawer__BodyRoot",componentId:"q6xvrq-6"})(["display:flex;flex-direction:column;padding:var(--main-padding);"]),Xee=u.default.div.withConfig({displayName:"PaycheckDrawer__SummaryCard",componentId:"q6xvrq-7"})(["background:",";border-radius:",";padding:",";margin-bottom:",";"],vt.Ee.color.background.secondary,vt.r8.medium,vt.YK.default,vt.YK.default),Qee=(0,u.default)(m.g).attrs({justifyBetween:!0,alignCenter:!0}).withConfig({displayName:"PaycheckDrawer__SummaryRow",componentId:"q6xvrq-8"})(["padding:"," 0;"],vt.YK.xxsmall),ete=(0,u.default)(xt.v).withConfig({displayName:"PaycheckDrawer__SummaryLabel",componentId:"q6xvrq-9"})(["color:",";font-size:",";"],vt.Ee.color.content.secondary,(e=>e.theme.fontSize.small)),tte=(0,u.default)(xt.v).withConfig({displayName:"PaycheckDrawer__SummaryAmount",componentId:"q6xvrq-10"})(["font-weight:",";font-size:",";color:",";"],(e=>e.theme.fontWeight.medium),(e=>e.theme.fontSize.small),(e=>{let t=e.$variant,n=e.theme;return"red"===t?n.color.red:"green"===t?n.color.green:"inherit"})),nte=u.default.div.withConfig({displayName:"PaycheckDrawer__SummaryDivider",componentId:"q6xvrq-11"})(["height:1px;background-color:",";margin:"," 0;"],vt.Ee.color.border.primary,vt.YK.xsmall),ate=u.default.div.withConfig({displayName:"PaycheckDrawer__DeductionEntry",componentId:"q6xvrq-12"})(["&:not(:first-child){margin-top:",";}"],vt.YK.small),lte=u.default.div.withConfig({displayName:"PaycheckDrawer__DeductionRow",componentId:"q6xvrq-13"})(["display:grid;grid-template-columns:1fr 110px 24px;gap:",";align-items:center;"],vt.YK.xsmall),rte=u.default.div.withConfig({displayName:"PaycheckDrawer__CustomNameRow",componentId:"q6xvrq-14"})(["display:grid;grid-template-columns:1fr 110px 24px;gap:",";margin-top:",";"],vt.YK.xsmall,vt.YK.xxsmall),ote=u.default.button.withConfig({displayName:"PaycheckDrawer__RemoveButton",componentId:"q6xvrq-15"})(["width:24px;height:24px;background:none;border:none;cursor:pointer;color:",";padding:0;border-radius:4px;display:flex;align-items:center;justify-content:center;&:hover{color:",";background:",";}"],vt.Ee.color.content.secondary,(e=>e.theme.color.red),(e=>e.theme.color.redLight)),ite=u.default.button.withConfig({displayName:"PaycheckDrawer__AddDeductionLink",componentId:"q6xvrq-16"})(["background:none;border:none;cursor:pointer;color:",";font-size:",";font-weight:",";padding:0;margin-top:",";display:inline-flex;align-items:center;gap:",";&:hover{text-decoration:underline;}"],(e=>e.theme.color.blue),(e=>e.theme.fontSize.small),(e=>e.theme.fontWeight.medium),vt.YK.small,vt.YK.xxsmall),ste=(0,u.default)(m.g).attrs({column:!0,gap:"gutter"}).withConfig({displayName:"PaycheckDrawer__DangerArea",componentId:"q6xvrq-17"})([""]),cte=u.default.div.withConfig({displayName:"PaycheckDrawer__MagicImportCard",componentId:"q6xvrq-18"})(["padding:",";background:",";border-radius:",";border:1px solid ",";"],vt.YK.default,vt.Ee.color.background.secondary,vt.r8.medium,vt.Ee.color.border.primary),dte=u.default.div.withConfig({displayName:"PaycheckDrawer__MagicImportIcon",componentId:"q6xvrq-19"})(["display:flex;align-items:center;justify-content:center;color:",";"],vt.yW.purple9);var ute,mte=n(76467);const pte=[{value:"weekly",label:"Weekly"},{value:"biweekly",label:"Bi-weekly (every 2 weeks)"},{value:"semimonthly",label:"Semi-monthly (1st & 15th)"},{value:"monthly",label:"Monthly"}];let gte=0;const hte=()=>{const e=(0,Sq.k)().close,t=(0,C.RU)(),n=Fee().createPaycheck,l=(0,nC.xd)(),r=(0,o.A)(l,1)[0].currentUser,i=(0,a.useMemo)((()=>{var e;return{employerId:"",payrollProvider:"",payDate:null,payPeriodStart:null,payPeriodEnd:null,grossAmount:void 0,ownerId:null!==(e=null===r||void 0===r?void 0:r.id)&&void 0!==e?e:"",deductions:[{key:"ded-".concat(gte+=1),deductionType:"",customDeductionName:"",amount:void 0}
1],deposits:[],repeatMultiple:!1,repeatStartDate:null,repeatEndDate:null,repeatFrequency:"biweekly"}}),[null===r||void 0===r?void 0:r.id]),d=(0,a.useCallback)((async a=>{try{const r=a.deductions.filter((e=>{var t;return e.deductionType&&(null!==(t=e.amount)&&void 0!==t?t:0)>0})).map((e=>({deductionType:e.deductionType,customDeductionName:"custom"===e.deductionType&&e.customDeductionName?e.customDeductionName:void 0,amount:e.amount}))).map((e=>(0,U.A)((0,U.A)({},e),{},{deductionType:e.deductionType}))),o=a.repeatMultiple?[]:a.deposits.map((e=>({transactionId:e.transactionId}))),i={employerId:a.employerId,payrollProvider:a.payrollProvider||"other",payPeriodStart:a.payPeriodStart||void 0,payPeriodEnd:a.payPeriodEnd||void 0,grossAmount:a.grossAmount,ownerId:a.ownerId||void 0,deductions:r,deposits:o};if(a.repeatMultiple&&a.repeatStartDate&&a.repeatEndDate){const e=vte(a.repeatStartDate,a.repeatEndDate,a.repeatFrequency);if(0===e.length)throw new Error("No pay dates generated for the selected range.");const l=await e.reduce((async(e,t)=>{const l=await e;try{const e=fte(t,a.repeatFrequency),r=await n((0,U.A)((0,U.A)({},i),{},{payDate:t,payPeriodStart:e.start,payPeriodEnd:e.end}));return r&&(0,LV.A)(r.errors)?(0,U.A)((0,U.A)({},l),{},{created:l.created+1}):(0,U.A)((0,U.A)({},l),{},{failed:l.failed+1})}catch(r){return(0,U.A)((0,U.A)({},l),{},{failed:l.failed+1})}}),Promise.resolve({created:0,failed:0})),r=l.created,o=l.failed;(0,Ge.u4)(Ye.i0.MultiplePaychecksCreated,{created_count:r,failed_count:o,frequency:a.repeatFrequency}),o>0?t({description:"Created ".concat(r," paycheck(s), but ").concat(o," failed.")}):(0,C.oR)({title:"Paychecks created",description:"Successfully created ".concat(r," paycheck(s).")})}else{const e=await n((0,U.A)((0,U.A)({},i),{},{payDate:a.payDate}));if(!e||(0,c.A)(e.errors)){var l;const t=(null===e||void 0===e||null===(l=e.errors)||void 0===l?void 0:l.message)||"Failed to create paycheck";throw new Error(t)}(0,Ge.u4)(Ye.i0.PaycheckCreated,{deduction_count:r.length,deposit_count:o.length})}e()}catch(r){s.Cp(r),t({description:"We couldn't save the paycheck. Please try again."})}}),[n,e,t]),u=(0,a.useCallback)((e=>{const t={};e.employerId||(t.employerId="Employer is required"),e.repeatMultiple?(e.repeatStartDate||(t.repeatStartDate="Start date is required"),e.repeatEndDate||(t.repeatEndDate="End date is required"),e.repeatStartDate&&e.repeatEndDate&&e.repeatStartDate>e.repeatEndDate&&(t.repeatEndDate="End date must be on or after start date")):e.payDate||(t.payDate="Pay date is required"),(!e.grossAmount||e.grossAmount<=0)&&(t.grossAmount="Gross amount must be greater than zero"),e.payPeriodStart&&e.payPeriodEnd&&e.payPeriodStart>e.payPeriodEnd&&(t.payPeriodEnd="End date must be on or after start date");const n=e.deductions.filter((e=>e.deductionType)).reduce(((e,t)=>e+(t.amount||0)),0);return e.grossAmount&&n>e.grossAmount&&(t.deductions="Total deductions cannot exceed gross amount"),t}),[]);return a.createElement(Rc.L,{"data-external-id":"paycheck-form-modal",title:"Add Paycheck"},a.createElement(Eu.lV,{initialValues:i,onSubmit:d,validate:u},a.createElement(bte,null),a.createElement(Cq.R,null,a.createElement(Lte,null,a.createElement(Ote,null),a.createElement(wt.Xb,{onClick:e},"Cancel"),a.createElement(Ete,null)))))},vte=(e,t,n)=>{const a=N.c9.fromISO(e),l=N.c9.fromISO(t);if(!a.isValid||!l.isValid||a>l)return[];if("semimonthly"===n)return((e,t)=>(0,mte.A)((n=>{let a=n.cursor,l=n.count;if(a>t||l>=104)return!1;const r=[a.set({day:1}),a.set({day:15})].filter((n=>n>=e&&n<=t)).map((e=>e.toISODate()));return r.length>0?[r.join(","),{cursor:a.plus({months:1}),count:l+r.length}]:[null,{cursor:a.plus({months:1}),count:l}]}),{cursor:e.startOf("month"),count:0}).filter(Boolean).flatMap((e=>e.split(","))))(a,l);const r=(e=>"weekly"===e?{weeks:1}:"biweekly"===e?{weeks:2}:{months:1})(n);return(0,mte.A)((e=>e<=l&&[e.toISODate(),e.plus(r)]),a).slice(0,104)},fte=(e,t)=>{const n=N.c9.fromISO(e);return(0,r.YW)(t).with("weekly",(()=>({start:n.minus({days:6}).toISODate(),end:n.toISODate()}))).with("biweekly",(()=>({start:n.minus({days:13}).toISODate(),end:n.toISODate()}))).with("semimonthly",(()=>n.day<=14?{start:n.set({day:1}).toISODate(),end:n.set({day:14}).toISODate()}:{start:n.set({day:15}).toISODate(),end:n.endOf("month").toISODate()})).with("monthly",(()=>({start:n.startOf("month").toISODate(),end:n.endOf("month").toISODate()}))).exhaustive()},Ete=()=>{const e=(0,hu.x)().values,t=e.repeatMultiple&&e.repeatStartDate&&e.repeatEnd
1Date?vte(e.repeatStartDate,e.repeatEndDate,e.repeatFrequency):[],n=e.repeatMultiple?t.length:1;return a.createElement(CJ.I,{"data-external-id":"submit-button-label",size:"small",disableWhenValuesUnchanged:!1},n>1?"Create ".concat(n," Paychecks"):"Create")},yte=()=>{const e=(0,hu.x)(),t=e.values,n=e.setFieldValue,l=(0,a.useMemo)((()=>t.repeatMultiple&&t.repeatStartDate&&t.repeatEndDate?vte(t.repeatStartDate,t.repeatEndDate,t.repeatFrequency):[]),[t.repeatMultiple,t.repeatStartDate,t.repeatEndDate,t.repeatFrequency]),r=(0,a.useCallback)((e=>{n("repeatMultiple",e.target.checked)}),[n]),o=(0,a.useCallback)((e=>{n("repeatFrequency",e.target.value)}),[n]);return a.createElement(Cb.p9,{"data-external-id":"repeat-multiple-section",checked:t.repeatMultiple,onChange:r,label:"Create multiple paychecks",subtext:"Quickly backfill historical paychecks with the same deduction structure"},t.repeatMultiple&&a.createElement(a.Fragment,null,a.createElement("div",{className:"flex gap-default *:min-w-0 *:flex-1"},a.createElement(tC.zB.Date,{name:"repeatStartDate",label:"Start date"}),a.createElement(tC.zB.Date,{name:"repeatEndDate",label:"End date"}),a.createElement("div",null,a.createElement(Pte,null,"Pay frequency"),a.createElement(Bte,{value:t.repeatFrequency,onChange:o},pte.map((e=>a.createElement("option",{key:e.value,value:e.value},e.label)))))),l.length>0&&a.createElement(zte,null,a.createElement(xt.v,{size:"xsmall",color:"textLight",style:{width:"100%"}},l.length," paycheck",1!==l.length?"s":""," will be created:"),l.slice(0,12).map((e=>a.createElement(Fte,{key:e},(0,Ba.AO)(e)))),l.length>12&&a.createElement(Fte,null,"+",l.length-12," more")),0===l.length&&!t.repeatStartDate&&!t.repeatEndDate&&a.createElement(xt.v,{size:"xsmall",color:"textLight"},"Select a date range to see a preview of paychecks to create")))},bte=()=>{const e=(0,hu.x)(),t=e.values,n=e.setFieldValue,l=(0,a.useMemo)((()=>t.deductions.filter((e=>e.deductionType)).reduce(((e,t)=>e+(t.amount||0)),0)),[t.deductions]),r=void 0!==t.grossAmount&&t.grossAmount>0?t.grossAmount-l:void 0,o=(0,a.useCallback)((e=>{const a=e.map((e=>({transactionId:e.transactionId,amount:e.amount,date:e.date,merchantName:e.merchantName,accountName:e.accountName})));n("deposits",[...t.deposits,...a])}),[t.deposits,n]),i=(0,a.useCallback)((e=>{n("deposits",t.deposits.filter((t=>t.transactionId!==e)))}),[t.deposits,n]);return a.createElement(Cte,{"data-external-id":"paycheck-form-content"},a.createElement(Y7.w,{name:"ownerId",label:"Owner",allowShared:!1}),a.createElement(Ate,null,a.createElement(See,{name:"employerId",label:"Employer",placeholder:"Select employer..."}),a.createElement(tC.zB,{name:"payrollProvider",label:"Payroll Provider"},(e=>a.createElement(_ee,{value:e.value,onChange:t=>{var n;return e.onChange(null!==(n=null===t||void 0===t?void 0:t.value)&&void 0!==n?n:null)}})))),a.createElement(yte,null),!t.repeatMultiple&&a.createElement(a.Fragment,null,a.createElement(tC.zB.Date,{name:"payDate",label:"Pay Date"}),a.createElement("div",{className:"flex gap-default *:min-w-0 *:flex-1"},a.createElement(tC.zB.Date,{name:"payPeriodStart",label:"Pay Period Start"}),a.createElement(tC.zB.Date,{name:"payPeriodEnd",label:"Pay Period End"}))),a.createElement(tC.zB.Currency,{name:"grossAmount",label:"Gross Pay",precision:0,required:!0}),a.createElement(wte,null),!t.repeatMultiple&&a.createElement(see,{deposits:t.deposits,netAmount:r,payPeriodStart:t.payPeriodStart,payPeriodEnd:t.payPeriodEnd,payDate:t.payDate,onAddDeposits:o,onRemoveDeposit:i}))},xte=e=>{var t,n,a,l,r;if(!e.deductionType)return null;const o=K7(e.deductionType),i="custom"===e.deductionType&&e.customDeductionName?e.customDeductionName:null!==(t=null===o||void 0===o?void 0:o.label)&&void 0!==t?t:e.deductionType;return{value:e.deductionType,label:i,icon:null!==(n=null===o||void 0===o?void 0:o.icon)&&void 0!==n?n:"minus-circle",category:null!==(a=null===o||void 0===o?void 0:o.category)&&void 0!==a?a:"other",sourceType:null!==(l=null===o||void 0===o?void 0:o.sourceType)&&void 0!==l?l:"voluntary",taxTiming:null!==(r=null===o||void 0===o?void 0:o.taxTiming)&&void 0!==r?r:"post_tax"}},wte=()=>{const e=(0,hu.x)(),t=e.values,n=e.setFieldValue,l=t.deductions,r=t.grossAmount,o=(0,a.useMemo)((()=>l.filter((e=>e.deductionType)).map((e=>e.deductionType))),[l]),i=(0,a.useMemo)((()=>l.filter((e=>e.deductionType)).reduce(((e,t)=>e+(t.amount||0)),0)),[l]),s=(0,a.useCallback)((()=>{const e={key:"ded-".concat(gte+=1),deductionType:"",customDeductionName:"",amount:void 0};n("deductions",[...l,e])}),[l,n]),c=(0,a.useCallback)(((e,t)=>{t&&n("deductions",l.map((n=>n.key===e?(0,U.A)((0,U.A)({},n),{},{deductionType:t.value,customDeductionName:""}):n)))}),[l,n]),d=(0,a.useCallback)(((e,t)=>{n("deductions",l.map((n=>n.key===e?(0,U.A)((0,U.A)({},n),{},{customDeductionName:t}):n)))}),[l,n]),u=(0,a.useCallback)((e=>{n("deductions",l.filter((t=>t.key!==e)))}),[l,n]),m=(0,a.useCallback)(((e,t)=>{n("deductions",l.map((n=>n.key===e?(0,U.A)((0,U.A)({},n),{},{amount:t}):n)))}),[l,n]);return a.createElement("div",{"data-external-id":"deductions-section"},a.createElement(Pte,null,"Deductions"),l.map((e=>{var t;return a.createElement(Ite,{key:e.key},a.createElement(kte,null,a.createElement("div",{className:"min-w-0"},a.createElement(Z7,{excludeTypes:o.filter((t=>t!==e.deductionType)),onChange:t=>c(e.key,t),value:xte(e),placeholder:"Select deduction..."})),a.createElement(fe.K$5,{name:"deduction_amount_".concat(e.key),value:null!==(t=e.amount)&&void 0!==t?t:null,onValueChange:t=>m(e.key,null!==t&&void 0!==t?t:void 0)}),a.createElement(Nte,{type:"button",onClick:()=>u(e.key),title:"Remove deduction"},a.createElement(sl.ZQ,{name:"x",size:14}))),"custom"===e.deductionType&&a.createElement(Ste,null,a.createElement(Ry.X,{name:"deduction_name_".concat(e.key),value:e.customDeductionName,onChange:t=>d(e.key,t.target.value),placeholder:"Enter deduction name...",small:!0})))})),a.createElement(Tte,{type:"button",onClick:s},a.createElement(sl.ZQ,{name:"plus",size:14}),"Add deduction"),l.length>0&&i>0&&a.createElement(_te,null,a.createElement(Dte,null,a.createElement(xt.v,{size:"small",color:"textLight"},"Total Deductions"),a.createElement(Rte,{size:"small",weight:"medium"},"-",(0,rl.vv)(i))),void 0!==r&&null!==r&&r>0&&a.createElement(Dte,null,a.createElement(xt.v,{size:"small",color:"textLight"},"Net Pay"),a.createElement(Mte,{size:"small",weight:"medium"},(0,rl.vv)(r-i)))),void 0!==r&&null!==r&&r>0&&i>r&&a.createElement(fu.g,{type:"error"},"Total deductions exceed gross pay amount."))},Cte=(0,u.default)(qY.S).withConfig({displayName:"PaycheckFormModal__StyledCardBody",componentId:"sc-1kfy4gg-0"})(["display:flex;flex-direction:column;gap:",";"],vt.YK.default),Ate=u.default.div.withConfig({displayName:"PaycheckFormModal__EmployerProviderRow",componentId:"sc-1kfy4gg-1"})(["display:grid;grid-template-columns:1fr 180px;
1gap:",";align-items:start;"],vt.YK.default),Ite=u.default.div.withConfig({displayName:"PaycheckFormModal__DeductionEntry",componentId:"sc-1kfy4gg-2"})(["&:not(:first-child){margin-top:",";}"],vt.YK.small),kte=u.default.div.withConfig({displayName:"PaycheckFormModal__DeductionRow",componentId:"sc-1kfy4gg-3"})(["display:grid;grid-template-columns:1fr 110px 28px;gap:",";align-items:center;"],vt.YK.xsmall),Ste=u.default.div.withConfig({displayName:"PaycheckFormModal__CustomNameRow",componentId:"sc-1kfy4gg-4"})(["display:grid;grid-template-columns:1fr 110px 28px;gap:",";margin-top:",";"],vt.YK.xsmall,vt.YK.xxsmall),Nte=u.default.button.withConfig({displayName:"PaycheckFormModal__RemoveButton",componentId:"sc-1kfy4gg-5"})(["background:none;border:none;cursor:pointer;color:",";padding:",";margin-bottom:4px;border-radius:4px;display:flex;align-items:center;&:hover{color:",";background:",";}"],vt.Ee.color.content.secondary,vt.YK.xsmall,(e=>e.theme.color.red),(e=>e.theme.color.redLight)),Tte=u.default.button.withConfig({displayName:"PaycheckFormModal__AddDeductionLink",componentId:"sc-1kfy4gg-6"})(["background:none;border:none;cursor:pointer;color:",";font-size:",";font-weight:",";padding:0;margin-top:",";display:inline-flex;align-items:center;gap:",";&:hover{text-decoration:underline;}"],(e=>e.theme.color.blue),(e=>e.theme.fontSize.small),(e=>e.theme.fontWeight.medium),vt.YK.default,vt.YK.xxsmall),_te=u.default.div.withConfig({displayName:"PaycheckFormModal__SummaryBox",componentId:"sc-1kfy4gg-7"})(["padding:",";background:",";border-radius:8px;margin-top:",";"],vt.YK.default,vt.Ee.color.background.secondary,vt.YK.default),Dte=(0,u.default)(m.g).attrs({justifyBetween:!0,alignCenter:!0}).withConfig({displayName:"PaycheckFormModal__SummaryRow",componentId:"sc-1kfy4gg-8"})(["padding:"," 0;"],vt.YK.xxsmall),Rte=(0,u.default)(xt.v).withConfig({displayName:"PaycheckFormModal__DeductionsTotalAmount",componentId:"sc-1kfy4gg-9"})(["color:",";"],(e=>e.theme.color.red)),Mte=(0,u.default)(xt.v).withConfig({displayName:"PaycheckFormModal__NetPayAmount",componentId:"sc-1kfy4gg-10"})(["color:",";"],(e=>e.theme.color.green)),Lte=(0,u.default)(ZY.B).attrs({justifyEnd:!0}).withConfig({displayName:"PaycheckFormModal__ButtonRow",componentId:"sc-1kfy4gg-11"})(["gap:",";"],vt.YK.default),Ote=$d.s.div(ute||(ute=(0,wc.A)(["flex-1"]))),Pte=(0,u.default)(xt.v).withConfig({displayName:"PaycheckFormModal__SectionLabel",componentId:"sc-1kfy4gg-12"})(["display:block;font-weight:",";font-size:",";margin-bottom:",";"],(e=>e.theme.fontWeight.medium),(e=>e.theme.fontSize.base),vt.YK.xsmall),Bte=u.default.select.withConfig({displayName:"PaycheckFormModal__FrequencyNativeSelect",componentId:"sc-1kfy4gg-13"})(["width:100%;padding:8px ",";font-size:",";border:1px solid ",";border-radius:6px;background:",";color:",";outline:none;cursor:pointer;appearance:none;background-image:url(\"data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3e%3cpath fill='%23666' d='M6 8L1 3h10z'/%3e%3c/svg%3e\");background-repeat:no-repeat;background-position:right 10px center;padding-right:28px;&:focus{border-color:",";}"],vt.YK.small,(e=>e.theme.fontSize.small),vt.Ee.color.border.primary,vt.Ee.color.background.primary,(e=>e.theme.color.text),(e=>e.theme.color.blue)),zte=u.default.div.withConfig({displayName:"PaycheckFormModal__PreviewList",componentId:"sc-1kfy4gg-14"})(["display:flex;flex-wrap:wrap;gap:",";margin-top:",";"],vt.YK.xxsmall,vt.YK.small),Fte=u.default.span.withConfig({displayName:"PaycheckFormModal__PreviewChip",componentId:"sc-1kfy4gg-15"})(["display:inline-block;padding:2px ",";font-size:",";background:",";border-radius:4px;color:",";"],vt.YK.xsmall,(e=>e.theme.fontSize.xsmall),vt.Ee.color.background.secondary,vt.Ee.color.content.secondary),Gte=e=>{let t=e.onDrop;const n=(0,a.useState)(!1),l=(0,o.A)(n,2),r=l[0],i=l[1];return{isDragOver:r,dragHandlers:{onDragOver:(0,a.useCallback)((e=>{e.preventDefault(),e.stopPropagation(),i(!0)}),[]),onDragLeave:(0,a.useCallback)((e=>{e.preventDefault(),e.stopPropagation(),e.currentTarget===e.target&&i(!1)}),[]),onDrop:(0,a.useCallback)((e=>{e.preventDefault(),e.stopPropagation(),i(!1);const n=Array.from(e.dataTransfer.files);t(n)}),[t])}}},Yte=e=>"createdCount"in e,Ute=e=>({parsePaychecks:t=>{const n=new FormData;return t.forEach((e=>{n.append("files",e)})),e.post("/paychecks/parse",{data:n,timeout:3e4,extraHeaders:{"Content-Type":void 0}})},getPaycheckJobStatus:t=>
1e.get("/paychecks/parse/".concat(t,"/status"))});var Vte=n(62308);const Wte="idle",jte="uploading",Hte="processing",Kte="analyzing",qte="reviewing",$te=e=>"string"===typeof e?e:null===e||void 0===e?void 0:e[0],Zte=()=>{const e=(0,a.useState)(!1),t=(0,o.A)(e,2),n=t[0],l=t[1],r=(0,a.useState)(null),i=(0,o.A)(r,2),s=i[0],c=i[1],d=(0,a.useState)(Wte),u=(0,o.A)(d,2),m=u[0],p=u[1],g=(0,a.useRef)(!1),h=(0,a.useRef)([]),v=(0,a.useCallback)((()=>{g.current=!0,h.current.reduce(((e,t)=>clearTimeout(t)),void 0),h.current=[]}),[]);(0,a.useEffect)((()=>()=>v()),[v]);const f=(0,a.useCallback)((async e=>{if(0===e.length)return c("No files provided"),null;g.current=!1,h.current.reduce(((e,t)=>clearTimeout(t)),void 0),h.current=[],l(!0),c(null),p(jte);try{const n=await Ute(r7.F).parsePaychecks(e);if(g.current)return null;var t;if(!n.success||!n.jobId)return c(null!==(t=n.error)&&void 0!==t?t:"Failed to upload documents"),null;p(Hte);const a=setTimeout((()=>{g.current||p(Kte)}),3e4),l=setTimeout((()=>{g.current||p(qte)}),6e4);return h.current=[a,l],await(async e=>{const t=async n=>{if(n>=120)return c("Analysis timed out, please try again."),null;if(g.current)return null;try{const i=await Ute(r7.F).getPaycheckJobStatus(e);return g.current?null:"completed"===i.status?null!==(a=i.results)&&void 0!==a&&a.success&&i.results.data?i.results.data:(c(null!==(l=null===(r=i.results)||void 0===r?void 0:r.error)&&void 0!==l?l:"Analysis completed, no results found"),null):"failed"===i.status?(c(null!==(o=i.error)&&void 0!==o?o:"Analysis failed"),null):(await new Promise((e=>setTimeout(e,2e3))),t(n+1));var a,l,r,o}catch(i){if(g.current)return null;const e=i instanceof Error?i.message:"Failed to check job status";return c(e),null}};return t(0)})(n.jobId)}catch(n){return g.current||c((e=>{if(e instanceof Vte.LG&&e.data){const t=e.data,n=t.detail,a=t.error,l=t.message;return $te(n)||$te(a)||$te(l)||"Failed to parse documents"}return e instanceof Error&&e.message?e.message:"Failed to parse documents"})(n)),null}finally{v(),l(!1),p(Wte)}}),[v]);return{parseDocuments:f,isLoading:n,error:s,stage:m}},Jte=[".jpg",".jpeg",".png",".webp",".heic",".heif",".pdf"],Xte=new Set(Jte.map((e=>e.toLowerCase()))),Qte=e=>{let t=e.onComplete,n=e.onClose;const l=(0,a.useRef)(null),r="paycheck-import-file-input-".concat(a.useId().replaceAll(":","")),i=Zte(),s=i.parseDocuments,c=i.isLoading,d=i.error,u=i.stage,m=(0,a.useState)(null),g=(0,o.A)(m,2),h=g[0],v=g[1],f=(0,a.useState)([]),E=(0,o.A)(f,2),y=E[0],b=E[1],x=null!==h&&void 0!==h?h:d,w=c,C=(0,a.useCallback)((e=>{if(v(null),0===e.length)return;const t=[...y,...e];if(t.length>10)return void v("Too many files. Maximum is ".concat(10," files total."));const n=e.find((e=>!ene(e.name)));if(n)return void v('File "'.concat(n.name,'" is not a supported file type. Accepted types: ').concat(Jte.join(", ")));const a=e.find((e=>e.size>10485760));a?v('File "'.concat(a.name,'" is too large. Maximum size is ').concat(10,"MB per file.")):(b(t),(0,Ge.u4)(Ye.i0.MagicImportFileAdded,{file_count:e.length,total_file_count:t.length}),l.current&&(l.current.value=""))}),[y]),A=(0,a.useCallback)((()=>{var e;null===(e=l.current)||void 0===e||e.click()}),[]),I=(0,a.useCallback)((e=>{var t;const n=Array.from(null!==(t=e.target.files)&&void 0!==t?t:[]);C(n)}),[C]),k=Gte({onDrop:C}),S=k.isDragOver,N=k.dragHandlers,T=(0,a.useCallback)((async()=>{if(0===y.length)return;(0,Ge.u4)(Ye.i0.MagicImportStarted,{file_count:y.length});const e=await s(y);var a;e&&("unsupported"in(a=e)&&!0===a.unsupported?((0,Ge.u4)(Ye.i0.MagicImportFailed,{reason:"unsupported_content"}),v(e.displayMessage),b([]),l.current&&(l.current.value="")):Yte(e)&&(t(e),n()))}),[y,s,t,n]),_=(0,a.useCallback)((e=>{(0,Ge.u4)(Ye.i0.MagicImportFileRemoved);const t=y.filter(((t,n)=>n!==e));b(t),l.current&&(l.current.value="")}
1),[y]),D=y.length>0;return a.createElement(um.b,{"data-external-id":"paycheck-import-modal",onClose:n,maxWidth:"600px",nonDismissable:w},a.createElement(Rc.L,{title:"Magic Import"},a.createElement(qY.S,null,a.createElement(tne,null,a.createElement(nne,null,"Upload photos or PDFs of your pay stubs to automatically extract earnings and deduction details:"),a.createElement(ane,null,a.createElement(lne,null,a.createElement(rne,null,"\u2022"),a.createElement(one,null,"Take a clear photo or screenshot of your pay stub, or upload the PDF directly")),a.createElement(lne,null,a.createElement(rne,null,"\u2022"),a.createElement(one,null,"Make sure gross pay, deductions, and pay dates are visible")),a.createElement(lne,null,a.createElement(rne,null,"\u2022"),a.createElement(one,null,"You can upload multiple pay stubs at once to import several paychecks")),a.createElement(lne,null,a.createElement(rne,null,"\u2022"),a.createElement(one,null,"Paychecks will be created and can be edited afterwards for any wrong or missing information")))),a.createElement("input",{className:"peer sr-only",id:r,ref:l,type:"file",accept:Jte.join(","),onChange:I,multiple:!0}),a.createElement(ine,Object.assign({},N,{$isDragOver:S,onClick:A,className:"\n              peer-focus-visible:outline-2 peer-focus-visible:outline-offset-2\n              peer-focus-visible:outline-border-info peer-focus-visible:outline-solid\n            "}),a.createElement(sne,null,a.createElement(cne,{name:"sparkle",size:32})),a.createElement(dne,{as:"label",htmlFor:r,onClick:e=>e.stopPropagation()},"Select files or drag and drop to upload"),a.createElement(une,null,"Supported file types: ",Jte.join(", ")),D&&a.createElement(mne,{onClick:e=>e.stopPropagation()},y.map(((e,t)=>a.createElement(pne,{key:"".concat(e.name,"-").concat(t)},a.createElement(gne,null,a.createElement(sl.ZQ,{name:"application/pdf"===e.type?"file-text":"image",size:20})),a.createElement(hne,null,e.name),w?a.createElement(p.i,{size:"sm"}):a.createElement(vne,{type:"button","aria-label":"Remove ".concat(e.name),onClick:()=>_(t)},a.createElement(sl.ZQ,{name:"x",size:16}))))))),x&&a.createElement(fne,null,a.createElement(Ene,null,x))),a.createElement(Cq.R,null,a.createElement(wt.Xb,{onClick:n,disabled:w},"Cancel"),a.createElement(cu.WT,{onClick:T,disabled:!D||w},c?u===jte?"Uploading...":u===Hte?"Processing...":u===Kte?"Analyzing...":u===qte?"Reviewing...":"Processing...":"Upload"))))},ene=e=>{const t=e.toLowerCase().substring(e.lastIndexOf("."));return Xte.has(t)},tne=u.default.div.withConfig({displayName:"PaycheckImportModal__InstructionsContainer",componentId:"r1higk-0"})(["display:flex;flex-direction:column;"]),nne=(0,u.default)(xt.v).withConfig({displayName:"PaycheckImportModal__Description",componentId:"r1higk-1"})(["font-size:",";color:",";line-height:1.5;"],vt.J.small,vt.Ee.color.content.primary),ane=u.default.div.withConfig({displayName:"PaycheckImportModal__TipsContainer",componentId:"r1higk-2"})(["display:flex;flex-direction:column;gap:",";margin-top:",";"],vt.YK.xxxsmall,vt.YK.xsmall),lne=u.default.div.withConfig({displayName:"PaycheckImportModal__TipItem",componentId:"r1higk-3"})(["display:flex;gap:",";align-items:flex-start;"],vt.YK.xsmall),rne=u.default.span.withConfig({displayName:"PaycheckImportModal__TipBullet",componentId:"r1higk-4"})(["color:",";font-size:",";line-height:1.5;"],vt.Ee.color.content.primary,vt.J.small),one=(0,u.default)(xt.v).withConfig({displayName:"PaycheckImportModal__TipText",componentId:"r1higk-5"})(["font-size:",";color:",";line-height:1.5;flex:1;"],vt.J.small,vt.Ee.color.content.primary),ine=u.default.div.withConfig({displayName:"PaycheckImportModal__DropZone",componentId:"r1higk-6"})(["display:flex;flex-direction:column;align-items:center;justify-content:center;min-height:300px;padding:",";background:",";border:2px dashed ",";border-radius:",";cursor:pointer;transition:border-color 0.2s ease,background-color 0.2s ease;&:hover{border-color:",";}"],vt.YK.xlarge,vt.yW.purple3,(e=>e.$isDragOver?vt.yW.purple9:vt.yW.purple8),vt.r8.medium,vt.yW.purple9),sne=u.default.div.withConfig({displayName:"PaycheckImportModal__IconContainer",componentId:"r1higk-7"})(["margin-bottom:",";"],vt.YK.default),cne=(0,u.default)(sl.ZQ).withConfig({displayName:"PaycheckImportModal__StyledIcon",componentId:"r1higk-8"})(["color:",";"],vt.yW.purple9),dne=(0,u.default)(xt.v).withConfig({displayName:"PaycheckImportModal__UploadText",componentId:"r1higk-9"})(["font-size:",";font-weight:",";color:",";margin-bottom:",";"],vt.J.base,vt.Wy.medium,vt.yW.purple9,vt.YK.xxsmall),une=(0,u.default)(xt.v).withConfig({displayName:"PaycheckImportModal__SupportedTypesText",componentId:"r1higk-10"})(["font-size:",";color:",";"],vt.J.small,vt.yW.purple8),mne=u.default.div.withConfig({displayName:"PaycheckImportModal__SelectedFilesContainer",componentId:"r1higk-11"})(["margin-top:",";width:100%;display:flex;flex-direction:column;gap:",";"],vt.YK.large,vt.YK.xsmall),pne=u.default.div.withConfig({displayName:"PaycheckImportModal__FileItem",componentId:"r1higk-12"})(["display:flex;align-items:center;gap:",";padding:"," ",";background:",";border-radius:",";border:1px solid ",";"],vt.YK.small,vt.YK.small,vt.YK.default,vt.Ee.color.background.primary,vt.r8.small,vt.Ee.color.divider.secondary),gne=u.default.div.withConfig({displayName:"PaycheckImportModal__FileIcon",componentId:"r1higk-13"})(["display:flex;align-items:center;justify-content:center;color:",";flex-shrink:0;"],vt.Ee.color.content.secondary),hne=(0,u.default)(xt.v).withConfig({displayName:"PaycheckImportModal__FileName",componentId:"r1higk-14"})(["flex:1;font-size:",";color:",";overflow:hidden;text-overflow:ellipsis;white-space:nowrap;"],vt.J.small,vt.Ee.color.content.primary),vne=u.default.button.withConfig({displayName:"PaycheckImportModal__RemoveButton",componentId:"r1higk-15"})(["display:flex;align-items:center;justify-content:center;padding:0;background:none;border:none;color:",";cursor:pointer;flex-shrink:0;&:hover{color:",";}"],vt.Ee.color.content.secondary,vt.Ee.color.content.primary),fne=(0,u.default)(m.g).withConfig({displayName:"PaycheckImportModal__ErrorContainer",componentId:"r1higk-16"})(["padding:",";background:",";border-radius:",";color:",";
1"],vt.YK.small,vt.Ee.color.background.danger,vt.r8.small,vt.Ee.color.content.danger),Ene=(0,u.default)(xt.v).withConfig({displayName:"PaycheckImportModal__ErrorText",componentId:"r1higk-17"})(["font-size:",";"],vt.J.small),yne=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:N.c9.local();return[{title:"Last 7 days",startDate:e.minus({days:7}).toISODate(),endDate:e.toISODate()},{title:"Last 14 days",startDate:e.minus({days:14}).toISODate(),endDate:e.toISODate()},{title:"Last 30 days",startDate:e.minus({days:30}).toISODate(),endDate:e.toISODate()},{title:"This month",startDate:e.startOf("month").toISODate(),endDate:e.endOf("month").toISODate()},{title:"Last month",startDate:e.minus({months:1}).startOf("month").toISODate(),endDate:e.minus({months:1}).endOf("month").toISODate()},{title:"This year",startDate:e.startOf("year").toISODate(),endDate:e.endOf("year").toISODate()},{title:"Last year",startDate:e.minus({years:1}).startOf("year").toISODate(),endDate:e.minus({years:1}).endOf("year").toISODate()}]},bne=["title","id"],xne=e=>{let t=e.className,n=e.shortcuts,l=void 0===n?yne():n,r=e.selectedShortcutId,o=e.onSelectDateRange;return a.createElement(Tm,{"data-external-id":"deprecated-date-range-picker-shortcuts",role:"menu",className:(0,q.cn)("h-full min-w-35 gap-3xs border-r border-divider-primary p-xs",t)},l.map((e=>{let t=e.title,n=e.id,l=(0,En.A)(e,bne);const i=Boolean(n&&r===n);return a.createElement(Tm.Item,{key:null!==n&&void 0!==n?n:t,onClick:()=>o(l),selected:i,role:"menuitemradio","aria-checked":i,className:"text-sm"},t)})))},wne=e=>{let t=e.onClick,n=e.disabled;return a.createElement(Wb.X,{"data-external-id":"clear-date-field-button",variant:"text",colorScheme:"link",size:"xs",disabled:n,onClick:t},"Clear")},Cne=u.default.div.withConfig({displayName:"DateRangeInputContainer__Row",componentId:"hgfvtn-0"})(["display:grid;grid-template-columns:","px 1fr;"],140),Ane=u.default.div.withConfig({displayName:"DateRangeInputContainer__Column",componentId:"hgfvtn-1"})(["&:not(:last-child){border-right:1px solid ",";overflow:clip;}&:nth-child(2){width:","px;padding:",";}"],vt.Ee.color.divider.primary,360,vt.YK.large),Ine=(0,u.default)(xt.v).withConfig({displayName:"DateRangeInputContainer__Title",componentId:"hgfvtn-2"})(["display:flex;align-items:center;width:","px;border-bottom:1px solid ",";padding:0 ",";height:100%;"],140,vt.Ee.color.divider.primary,vt.YK.default),kne=(0,u.default)(Cq.R).attrs({$size:"small"}).withConfig({displayName:"DateRangeInputContainer__Footer",componentId:"hgfvtn-3"})(["[data-sc-tw~='DefaultButton__DefaultButton']:first-child{margin-right:auto;}"]),Sne=(0,u.default)(m.g).attrs({alignCenter:!0,justifyStart:!0}).withConfig({displayName:"DateRangeInputContainer__Header",componentId:"hgfvtn-4"})(["height:","px;font-weight:",";font-size:",";"],50,vt.Wy.medium,vt.J.small),Nne=(0,u.default)(m.g).attrs({column:!0,justifyCenter:!0}).withConfig({displayName:"DateRangeInputContainer__InputContainer",componentId:"hgfvtn-5"})(["flex:1;height:100%;gap:",";"],vt.YK.large),Tne=e=>{let t=e.dateRange,n=e.requiredBoundedRange,l=e.onChange,r=e.onClear,o=e.toggleOpen;return a.createElement(Eu.lV,{"data-external-id":"date-range-input-container",initialValues:t,onSubmit:e=>{l(e),null===o||void 0===o||o()},validate:e=>{const t={};return n&&(e.startDate||(t.startDate="Start date is required"),e.endDate||(t.endDate="End date is required")),e.startDate&&e.endDate&&N.c9.fromISO(e.startDate)>N.c9.fromISO(e.endDate)&&(t.startDate="Start date must be before end date"),t}},a.createElement(Cne,null,a.createElement(Ane,null,a.createElement(Sne,null,a.createElement(Ine,null,"Date Range")),a.createElement(_ne,null)),a.createElement(Ane,null,a.createElement(Nne,null,a.createElement(hu.c.Consumer,null,(e=>{let t=e.setFieldValue;return a.createElement(a.Fragment,null,a.createElement(tC.zB.Date,{label:"Start date",name:"startDate",placeholder:"MM/DD/YYYY",size:"sm",labelRight:a.createElement(wne,{onClick:()=>{t("startDate",void 0)}})}),a.createElement(tC.zB.Date,{label:"End date",name:"endDate",placeholder:"MM/DD/YYYY",size:"sm",labelRight:a.createElement(wne,{onClick:()=>{t("endDate",void 0)}})}))}))))),a.createElement(kne,null,a.createElement(wt.Xb,{size:"xsmall",onClick:()=>{r(),null===o||void 0===o||o()}},"Clear"),a.createElement(wt.Xb,{size:"xsmall",onClick:o},"Cancel"),a.createElement(CJ.I,{size:"xsmall"},"Apply")))},_ne=()=>{const e=(0,hu.x)(),t=e.setFieldValue,n=e.submitForm;return a.createElement(xne,{"data-external-id":"date-range-picker-shortcuts-field",shortcuts:yne(),onSelectDateRange:async e=>{await t("startDate",e.startDate),await t("endDate",e.endDate),await n()}})},Dne=a.memo(Tne);var Rne=n(74529);const Mne=["value"],Lne=e=>{let t=e.value,n=(0,En.A)(e,Mne);const l=(0,a.useState)(!1),r=(0,o.A)(l,2),i=r[0],s=r[1];return a.createElement(fS.k.Root,{"data-external-id":"date-range-picker-popover",open:i,onOpenChange:s},a.createElement(fS.k.Trigger,{render:a.createElement(Wb.X,{variant:"default",icon:a.createElement(Rne.MdsCalendarIcon,null),"data-pressed":i?"":void 0},t)}),a.createElement(fS.k.Content,{side:"bottom",align:"end",className:"max-w-none p-0"},a.createElement(Dne,Object.assign({toggleOpen:()=>s((e=>!e))},n))))};var One=n(23292);const Pne=e=>
1{let t=e.dateRange,n=e.onChangeDateRange,l=e.ownerId,r=e.onChangeOwnerId,o=e.employerId,i=e.onChangeEmployerId,s=e.onClearFilters,c=e.hasActiveFilters;const d=t.startDate,u=t.endDate,m=(0,One.d)().options,p=(0,et.I)(yee,{variables:{search:null,limit:200}}).data,g=(0,a.useMemo)((()=>({value:"",label:"All owners"})),[]),h=(0,a.useMemo)((()=>[g,...(0,Y7.W)(m,{allowShared:!1})]),[m,g]),v=(0,a.useMemo)((()=>({value:"",label:"All employers"})),[]),f=(0,a.useMemo)((()=>{var e;const t=null!==(e=null===p||void 0===p?void 0:p.paycheckEmployers)&&void 0!==e?e:[];return[v,...t.map((e=>({value:e.id,label:e.name})))]}),[null===p||void 0===p?void 0:p.paycheckEmployers,v]),E=(0,a.useMemo)((()=>{var e;return null!==(e=f.find((e=>e.value===o)))&&void 0!==e?e:v}),[f,o,v]),y=(0,a.useMemo)((()=>yne().find((e=>{let t=e.startDate,n=e.endDate;return d===t&&u===n}))),[d,u]),b=(0,a.useMemo)((()=>y?y.title:d||u?(0,Ba.tX)(d,u):"Date"),[d,u,y]),x=(0,a.useCallback)((()=>{n({startDate:void 0,endDate:void 0})}),[n]);return a.createElement(Bne,{"data-external-id":"paychecks-header-controls"},a.createElement(Lne,{dateRange:t,onChange:e=>{let t=e.startDate,a=e.endDate;return n({startDate:t,endDate:a})},onClear:x,value:b}),a.createElement("div",{className:"min-w-40"},a.createElement(qV.h,{options:h,value:l,onValueChange:e=>r(null!==e&&void 0!==e?e:""),placeholder:"All owners"})),a.createElement("div",{className:"min-w-55"},a.createElement(U7.O,{options:f,value:E,onValueChange:e=>{var t;return i(null!==(t=null===e||void 0===e?void 0:e.value)&&void 0!==t?t:"")},placeholder:"All employers"})),c&&a.createElement(bn.v,{onClick:s},"Clear"))},Bne=(0,u.default)(m.g).attrs({alignCenter:!0,gap:"xsmall"}).withConfig({displayName:"PaychecksHeaderControls__Root",componentId:"sc-14k5opr-0"})([""]);var zne=n(97241),Fne=n(88365);const Gne=e=>{let t=e.onAddPaycheck,n=e.hasActiveFilters,l=e.onClearFilters;return n?a.createElement(cU.vx,{"data-external-id":"paycheck-empty-state",icon:a.createElement(sl.ZQ,{name:"search",size:48}),title:"No paychecks found",subtitle:"No paychecks match your current filters. Try adjusting your date range or search.",button:l?{title:"Clear filters",onClick:l}:void 0}):a.createElement(cU.vx,{"data-external-id":"paycheck-empty-state",icon:a.createElement(sl.ZQ,{name:"file-text",size:48}),title:"No paychecks yet",subtitle:"Add your first paycheck to start tracking your income, deductions, and take-home pay.",button:{title:"Add Paycheck",onClick:t,isPrimary:!0}})},Yne=e=>{let t=e.paycheck,n=e.isActive,l=e.onClick;return a.createElement(Une,{"data-external-id":"paycheck-list-row",$isActive:n,onClick:l},a.createElement(Vne,null,t.isMagicImported&&a.createElement(P.D_,{content:"Created by Magic Import"},a.createElement(Wne,null,a.createElement(sl.ZQ,{name:"sparkle",size:14}))),(0,Ba.AO)(t.payDate)),a.createElement(jne,null,t.employerName),t.owner&&a.createElement(Hne,null,a.createElement(P.D_,{content:t.owner.name},a.createElement("div",null,a.createElement(Pw.n,{userId:t.owner.id,userName:t.owner.name,userProfilePictureUrl:t.owner.profilePictureUrl,showLabel:!1,avatarSize:20})))),a.createElement(Kne,null,(0,rl.vv)(t.grossAmount)))},Une=(0,u.default)(m.g).attrs({alignCenter:!0}).withConfig({displayName:"PaycheckListRow__Row",componentId:"vzlrxi-0"})(["padding:",";padding-left:",";padding-right:",";cursor:pointer;transition:background-color 0.15s ease;border-bottom:1px solid ",";background-color:",";&:hover{background-color:",";}"],vt.YK.default,vt.YK.large,vt.YK.large,vt.Ee.color.divider.primary,(e=>{let t=e.$isActive,n=e.theme;return t?n.color.grayFocus:"transparent"}),(e=>e.theme.color.grayFocus)),Vne=(0,u.default)(m.g).attrs({alignCenter:!0,gap:"xxsmall"}).withConfig({displayName:"PaycheckListRow__DateCell",componentId:"vzlrxi-1"})(["width:150px;flex-shrink:0;color:",";font-size:",";"],vt.Ee.color.content.secondary,(e=>e.theme.fontSize.small)),Wne=u.default.div.withConfig({displayName:"PaycheckListRow__MagicImportIndicator",componentId:"vzlrxi-2"})(["display:flex;align-items:center;color:",";cursor:help;"],vt.yW.purple9),jne=(0,u.default)(xt.v).withConfig({displayName:"PaycheckListRow__EmployerCell",componentId:"vzlrxi-3"})(["flex:1;min-width:0;font-weight:",";overflow:hidden;text-overflow:ellipsis;white-space:nowrap;"],(e=>e.theme.fontWeight.medium)),Hne=u.default.div.withConfig({displayName:"PaycheckListRow__OwnerCell",componentId:"vzlrxi-4"})(["flex-shrink:0;margin-left:",";margin-right:",";"],vt.YK.small,vt.YK.small),Kne=(0,u.default)(xt.v).withConfig({displayName:"PaycheckListRow__AmountCell",componentId:"vzlrxi-5"})(["width:120px;flex-shrink:0;text-align:right;font-weight:",";"],(e=>e.theme.fontWeight.book));var qne;const $ne=()=>a.createElement(Xne,{"data-external-id":"paychecks-list-loading"},a.createElement(Jne,{rowsCount:3}),a.createElement(Jne,{rowsCount:2}),a.createElement(Jne,{rowsCount:3})),Zne=()=>a.createElement(Qne,{"data-external-id":"paycheck-row-loading"},a.createElement(eae,null,a.createElement(M.Al,null)),a.createElement(eae,null,a.createElement(M.Al,null)),a.createElement(eae,null,a.createElement(M.Al,null))),Jne=e=>{let t=e.rowsCount;return a.createElement(a.Fragment,null,a.createElement(tae,null,a.createElement(Rr.s,null,a.createElement("rect",{x:"16",y:"10",rx:"5",ry:"5",width:"17%",height:"16"}),a.createElement("rect",{x:"calc(88% - 16px)",y:"10",rx:"5",ry:"5",width:"12%",height:"16"}))),(0,db.A)(0,t).map((e=>a.createElement(Zne,{key:e}))))},Xne=$d.s.div(qne||(qne=(0,wc.A)(["overflow-hidden"]))),Qne=(0,u.default)(m.g).attrs({gap:"gutter",alignCenter:!0,justifyBetween:!0}).withConfig({displayName:"PaychecksListLoading__RowRoot",componentId:"sc-16065w8-0"}
1)(["height:57px;width:100%;padding:0 ",";:not(:last-child){border-bottom:1px solid ",";}"],(e=>e.theme.spacing.large),vt.Ee.color.divider.primary),eae=(0,u.default)(m.g).attrs({alignCenter:!0,gap:"small"}).withConfig({displayName:"PaychecksListLoading__Column",componentId:"sc-16065w8-1"})(["&:first-child{flex:1;}&:nth-child(2){flex:2;}&:last-child{flex:0.8;}"]),tae=u.default.div.withConfig({displayName:"PaychecksListLoading__GroupHeader",componentId:"sc-16065w8-2"})(["height:36px;width:100%;background:",";"],vt.Ee.color.background.secondary);var nae;const aae=(0,Wd.A)((0,LD.A)((e=>e.payDate.substring(0,7))),zne.A,(0,jd.A)((e=>{let t=(0,o.A)(e,2),n=t[0],a=t[1];return{monthKey:n,label:(0,Ba.Tf)(a[0].payDate),paychecks:a,totalGross:(0,Fne.A)(((e,t)=>e+t.grossAmount),0,a)}}))),lae=e=>{let t=e.paychecks,n=e.isLoading,l=e.activePaycheckId,r=e.onPaycheckClick,o=e.onAddPaycheck,i=e.hasActiveFilters,s=e.onClearFilters;const c=(0,a.useMemo)((()=>aae(t)),[t]);return n?a.createElement($ne,{"data-external-id":"paychecks-list"}):0===t.length?a.createElement(Gne,{"data-external-id":"paychecks-list",onAddPaycheck:o,hasActiveFilters:i,onClearFilters:s}):a.createElement("div",{"data-external-id":"paychecks-list"},c.map((e=>a.createElement("div",{key:e.monthKey},a.createElement(rae,null,a.createElement("span",null,e.label),a.createElement("span",null,(0,rl.vv)(e.totalGross))),e.paychecks.map((e=>a.createElement(Yne,{key:e.id,paycheck:e,isActive:e.id===l,onClick:()=>r(e.id)})))))))},rae=(0,$d.s)(H3.X)(nae||(nae=(0,wc.A)(["px-default"]))),oae=e=>{let t=e.paychecks,n=e.isLoading;const l=(0,a.useMemo)((()=>{const e=t.length,n=t.reduce(((e,t)=>e+t.grossAmount),0),a=t.reduce(((e,t)=>e+t.deductions.reduce(((e,t)=>e+t.amount),0)),0),l=n-a,r=e>0?n/e:0,i=e>0?l/e:0,s=t.flatMap((e=>[...e.deductions])).reduce(((e,t)=>{var n,a,l;const r=null!==(n=null===(a=K7(t.deductionType))||void 0===a?void 0:a.category)&&void 0!==n?n:"other";return e.set(r,(null!==(l=e.get(r))&&void 0!==l?l:0)+t.amount)}),new Map);return{count:e,totalGross:n,totalDeductions:a,totalNet:l,avgGross:r,avgNet:i,categories:Array.from(s.entries()).sort(((e,t)=>{let n=(0,o.A)(e,2)[1];return(0,o.A)(t,2)[1]-n})).map((e=>{var t,n;let a=(0,o.A)(e,2),l=a[0],r=a[1];const i=W7.get(l);return{category:l,label:null!==(t=null===i||void 0===i?void 0:i.label)&&void 0!==t?t:l,icon:null!==(n=null===i||void 0===i?void 0:i.icon)&&void 0!==n?n:"more-horizontal",total:r}}))}}),[t]);return n?a.createElement(Xl.AM,{"data-external-id":"paychecks-summary-card",title:"Summary"},a.createElement(iae,null,(0,db.A)(0,6).map((e=>a.createElement(hae,{key:e},a.createElement(M.Al,null),a.createElement(M.Al,null)))))):0===t.length?null:a.createElement(Xl.AM,{"data-external-id":"paychecks-summary-card",title:"Summary"},a.createElement(iae,null,a.createElement(sae,null,a.createElement("span",null,"Paychecks"),a.createElement(cae,null,l.count)),a.createElement(sae,null,a.createElement("span",null,"Total Gross"),a.createElement(cae,null,(0,rl.vv)(l.totalGross))),a.createElement(sae,null,a.createElement("span",null,"Total Deductions"),a.createElement(cae,{$variant:"red"},"-",(0,rl.vv)(l.totalDeductions))),a.createElement(sae,null,a.createElement("span",null,"Total Net"),a.createElement(cae,{$variant:"green"},(0,rl.vv)(l.totalNet))),a.createElement(dae,null),a.createElement(sae,null,a.createElement("span",null,"Avg Gross / Paycheck"),a.createElement(cae,null,(0,rl.vv)(l.avgGross))),a.createElement(sae,null,a.createElement("span",null,"Avg Net / Paycheck"),a.createElement(cae,{$variant:"green"},(0,rl.vv)(l.avgNet))),l.categories.length>0&&a.createElement(a.Fragment,null,a.createElement(dae,null),a.createElement(uae,null,"Deductions by Category"),l.categories.map((e=>a.createElement(mae,{key:e.category},a.createElement(pae,null,a.createElement(sl.ZQ,{name:e.icon,size:14}),a.createElement("span",null,e.label)),a.createElement(gae,null,(0,rl.vv)(e.total))))))))},iae=u.default.div.withConfig({displayName:"PaychecksSummaryCard__CardInner",componentId:"sc-1pvjm3d-0"})(["padding:",";"],vt.YK.xlarge),sae=(0,u.default)(ZY.B).attrs({justifyBetween:!0}).withConfig({displayName:"PaychecksSummaryCard__CardItem",componentId:"sc-1pvjm3d-1"})(["font-size:",";color:",";:not(:last-child){margin-bottom:",";}"],vt.J.small,vt.yW.textLight,vt.YK.default),cae=u.default.span.withConfig({displayName:"PaychecksSummaryCard__ValueText",componentId:"sc-1pvjm3d-2"})(["font-size:",";font-weight:",";color:",";"],vt.J.base,(e=>{let t=e.theme;return e.$variant?t.fontWeight.medium:t.fontWeight.book}),(e=>{let t=e.$variant,n=e.theme;return"green"===t?n.color.greenText:"red"===t?n.color.red:n.color.text})),dae=u.default.div.withConfig({displayName:"PaychecksSummaryCard__SectionDivider",componentId:"sc-1pvjm3d-3"})(["height:1px;background-color:",";margin:"," 0;"],vt.Ee.color.divider.primary,vt.YK.large),uae=u.default.div.withConfig({displayName:"PaychecksSummaryCard__SectionTitle",componentId:"sc-1pvjm3d-4"})(["font-size:",";font-weight:",";color:",";text-transform:uppercase;letter-spacing:0.5px;margin-bottom:",";"],vt.J.small,(e=>e.theme.fontWeight.medium),vt.yW.textLight,vt.YK.default),mae=(0,u.default)(ZY.B).attrs({justifyBetween:!0}).withConfig({displayName:"PaychecksSummaryCard__CategoryRow",componentId:"sc-1pvjm3d-5"})(["font-size:",";color:",";:not(:last-child){margin-bottom:",";}"],vt.J.small,vt.yW.textLight,vt.YK.default),pae=(0,u.default)(m.g).attrs({alignCenter:!0,gap:"xsmall"}).withConfig({displayName:"PaychecksSummaryCard__CategoryLabel",componentId:"sc-1pvjm3d-6"})([""]),gae=u.default.span.withConfig({displayName:"PaychecksSummaryCard__CategoryAmount",componentId:"sc-1pvjm3d-7"})(["font-size:",";font-weight:",";color:",";"],vt.J.base,(e=>e.theme.fontWeight.book),(e=>e.theme.color.text)),hae=u.default.div.withConfig({displayName:"PaychecksSummaryCard__SkeletonRow",componentId:"sc-1pvjm3d-8"})(["width:100%;display:flex;justify-content:space-between;align-items:center;gap:",";height:",";&:not(:last-child){margin-bottom:",";}> [data-sc-tw~='Skeleton__Root']:last-child{flex-basis:50%;}"],vt.YK.default,vt.J.base,vt.YK.gutter),vae=(0,xZ.Z)((()=>n.e(7171).then(n.bind(n,37171)).then((e=>({default:e.PaychecksWalkthrough})))),"LazyLoadedPaychecksWalkthrough"),fae=()=>{var e,t,n,r;const i=(0,l.Zp)(),s=(0,C.RU)(),c=(0,xq.bO)("dismissedPaychecksWalkthroughAt"),d=(0,o.A)(c,2),u=d[0],m=d[1],p=null!==(e=(0,b.pE)("startDate"))&&void 0!==e?e:void 0,g=null!==(t=(0,b.pE)("endDate"))&&void 0!==t?t:void 0,h=null!==(n=(0,b.pE)("ownerId"))&&void 0!==n?n:"",v=null!==(r=(0,b.pE)("employerId"))&&void 0!==r?r:"",f=(0,b.ii)(),E=(0,o.A)(f,2)[1],y=(0,a.useState)(!0),x=(0,o.A)(y,2),w=x[0],A=x[1],k=(0,a.useState)(!1),S=(0,o.A)(k,2),N=S[0],T=S[1],_=(0,a.useMemo)((()=>({startDate:p,endDate:g})),[p,g]),D=Bee({startDate:p,endDate:g,ownerId:h||void 0,employerId:v||void 0}),R=D.paychecks,M=D.isLoadingInitialData,L=D.refetch,O=(0,a.useState)(null),P=(0,o.A)(O,2),z=P[0],F=P[1],G=(0,a.useMemo)((()=>{var e;return null!==(e=R.find((e=>e.id===z)))&&void 0!==e?e:null}),[R,z]),Y=!!(p||g||h||v),U=(0,a.useCallback)((e=>{var t,n,a,l;(0,Ge.u4)(Ye.i0.FiltersChanged,{filter_name:"date_range",start_date:null!==(t=e.startDate)&&void 0!==t?t:null,end_date:null!==(n=e.endDate)&&void 0!==n?n:null}),E({startDate:null!==(a=e.startDate)&&void 0!==a?a:"",endDate:null!==(l=e.endDate)&&void 0!==l?l:""})}),[E]),V=(0,a.useCallback)((e=>{(0,Ge.u4)(Ye.i0.FiltersChanged,{filter_name:"owner"}),E({ownerId:e})}),[E]),W=(0,a.useCallback)((e=>{(0,Ge.u4)(Ye.i0.FiltersChanged,{filter_name:"employer"}),E({employerId:e})}),[E]),j=(0,a.useCallback)((()=>{E(null)}),[E]),H=(0,a.useCallback)((()=>{(0,Ge.u4)(Ye.i0.ManualAddOpened),i(I.JZ.paychecks.addPaycheck())}),[i]),K=(0,a.useCallback)((e=>{(0,Ge.u4)(Ye.i0.DetailsOpened,{paycheck_id:e}),F(e)}),[]),q=(0,a.useCallback)((()=>{F(null)}),[]),$=R.length>0||M,Z=(0,a.useCallback)((()=>{(0,Ge.u4)(Ye.i0.SummaryToggled,{visible:!w}),A((e=>!e))}),[w]),J=(0,a.useCallback)((()=>{(0,Ge.u4)(Ye.i0.MagicImportOpened),T(!0)}),[]),X=(0,a.useCallback)((()=>{T(!1)}),[]),Q=(0,a.useCallback)((e=>{if(Yte(e)){const t=e.createdCount,n=e.failedCount;L(),n>0&&0===t?((0,Ge.u4)(Ye.i0.MagicImportFailed,{failed_count:n}),s({description:"Failed to import paychecks"})):n>0?((0,Ge.u4)(Ye.i0.MagicImportCompleted,{created_count:t,failed_count:n}),s({description:"Imported ".concat(t," paycheck").concat(1!==t?"s":"",", ").concat(n," failed")})):((0,Ge.u4)(Ye.i0.MagicImportCompleted,{created_count:t,failed_count:0}),(0,C.oR)({title:"Imported ".concat(t," paycheck").concat(1!==t?"s":"")}))}}),[L,s]);return a.createElement(rG.Y,{"data-external-id":"paychecks",name:"Paychecks",controls:a.createElement(uU.f,null,a.createElement(Pne,{dateRange:_,onCh
1angeDateRange:U,ownerId:h,onChangeOwnerId:V,employerId:v,onChangeEmployerId:W,onClearFilters:j,hasActiveFilters:Y}),a.createElement(Qi.Az,{placement:"bottom-end",overlay:a.createElement(Ji.SP,null,a.createElement(Ji.xm,{icon:"edit",onClick:H},"Enter manually"),a.createElement(Ji.xm,{icon:"zap",onClick:J},"Magic import"),a.createElement(Ji.xm,{icon:"link",disabled:!0},"Connect payroll provider (coming soon)"))},(e=>{let t=e.toggleOpen;return a.createElement(cu.WT,{onClick:t},a.createElement(Eae,null),"Add Paycheck")})),$&&a.createElement(B.L,{icon:"sidebar-right",onClick:Z,size:"small",active:w}))},a.createElement(L7,{isCollapsed:!w||!$,collapsibleColumnWidth:320},a.createElement(Xl.AM,null,a.createElement(lae,{paychecks:R,isLoading:M,activePaycheckId:z,onPaycheckClick:K,onAddPaycheck:H,hasActiveFilters:Y,onClearFilters:j})),a.createElement("div",null,a.createElement(oae,{paychecks:R,isLoading:M}))),G&&a.createElement(Yee,{paycheck:G,onClose:q}),a.createElement(XU.U,{routes:[{path:I.JZ.paychecks.addPaycheck.relativePath,component:hte}]}),N&&a.createElement(Qte,{onComplete:Q,onClose:X}),null===u&&a.createElement(a.Suspense,{fallback:null},a.createElement(vae,{onClose:()=>m((new Date).toISOString())})))},Eae=(0,u.default)(sl.ZQ).attrs({name:"plus",size:14}).withConfig({displayName:"Paychecks__PlusIcon",componentId:"sc-1r0t1qr-0"})(["margin-right:",";"],vt.YK.xsmall),yae=()=>{const e=(0,a.useState)(!1),t=(0,o.A)(e,2),n=t[0],l=t[1],r=(0,a.useState)(null),i=(0,o.A)(r,2),s=i[0],c=i[1],d=(0,a.useState)(0),u=(0,o.A)(d,2),m=u[0],p=u[1],g=(0,a.useRef)(!1);(0,a.useEffect)((()=>()=>{g.current=!0}),[]);return{analyzeDocuments:(0,a.useCallback)((async e=>{if(0===e.length)return c("No files provided"),null;g.current=!1,l(!0),c(null),p(0);try{const n=new FormData;e.forEach((e=>{n.append("files",e)}));const a=await r7.F.post("/protection/analyze-estate-documents",{data:n,timeout:3e4});if(g.current)return null;var t;if(!a.success||!a.jobId)return c(null!==(t=a.error)&&void 0!==t?t:"Failed to upload documents"),null;p(10);return await(async e=>{for(let l=0;l<120;l+=1){if(g.current)return null;try{const a=await r7.F.get("/protection/analyze-estate-documents/".concat(e,"/status"));if(g.current)return null;var t,n;if("processing"===a.status&&p((e=>Math.min(e+.5,90))),"completed"===a.status)return p(100),null!==(t=a.results)&&void 0!==t&&t.success&&a.results.data?a.results.data:(c("Analysis completed but no results available"),null);if("failed"===a.status)return c(null!==(n=a.error)&&void 0!==n?n:"Analysis failed"),null;await new Promise((e=>setTimeout(e,1e3)))}catch(a){if(g.current)return null;const e=a instanceof Error?a.message:"Failed to check job status";return c(e),null}}return c("Analysis timed out. Please try again."),null})(a.jobId)}catch(n){if(g.current)return null;const e=n instanceof Error?n.message:"Failed to analyze documents";return c(e),null}finally{l(!1)}}),[]),isAnalyzing:n,error:s,progress:m}};var bae=n(79138);const xae=(0,sG.Mz)((e=>e.protection),(e=>e.latestAnalysis));var wae,Cae;const Aae=".pdf,.doc,.docx",Iae=new Set(Aae.split(",").map((e=>e.toLowerCase().trim()))),kae=(0,u.keyframes)(["from{opacity:0;transform:translateY(20px);}to{opacity:1;transform:translateY(0);}"]),Sae=(0,u.keyframes)(["0%,100%{opacity:1;}50%{opacity:0.5;}"]),Nae=["Reading document structure...","Identifying assets...","Extracting beneficiary information...","Analyzing property details...","Parsing account information...","Detecting trust provisions...","Scanning for real estate holdings...","Reviewing investment accounts...","Examining will provisions...","Cross-referencing with Monarch data...","Identifying coverage gaps...","Analyzing beneficiary designations...","Validating asset ownership...","Checking document completeness...","Finalizing analysis..."],Tae=()=>{const e=(0,l.Zp)(),t=(0,d.wA)(),n=(0,d.d4)(xae),r=(0,a.useRef)(null),i=(0,a.useState)([]),s=(0,o.A)(i,2),c=s[0],u=s[1],m=(0,a.useState)(!1),p=(0,o.A)(m,2),g=p[0],h=p[1],v=(0,a.useState)(null),f=(0,o.A)(v,2),E=f[0],y=f[1],b=yae(),x=b.analyzeDocuments,w=b.isAnalyzing,C=b.error,A=b.progress,k=(0,a.useState)(""),S=(0,o.A)(k,2),N=S[0],T=S[1];(0,a.useEffect)((()=>{n&&e("".concat(I.JZ.protection(),"/results"),{replace:!0})}),[]);const _=(0,a.useCallback)((e=>{if(y(null),0===e.length)return;const t=[...c,...e];if(t.length>10)return y("Too many files. Maximum is ".concat(10," files total.")),void(r.current&&(r.current.value=""));const n=e.find((e=>!_ae(e.name)));if(n)return y('File "'.concat(n.name,'" is not a supported file type. Accepted types: ').concat(Aae)),void(r.current&&(r.current.value=""));const a=e.find((e=>e.size>10485760));if(a)return y('File "'.concat(a.name,'" is too large. Maximum size is ').concat(10,"MB per file.")),void(r.current&&(r.current.value=""));u(t),r.current&&(r.current.value="")}
1),[c]),D=(0,a.useCallback)((()=>{var e;null===(e=r.current)||void 0===e||e.click()}),[]),R=(0,a.useCallback)((e=>{var t;const n=Array.from(null!==(t=e.target.files)&&void 0!==t?t:[]);_(n)}),[_]),M=(0,a.useCallback)((e=>{e.preventDefault(),e.stopPropagation(),h(!0)}),[]),L=(0,a.useCallback)((e=>{e.preventDefault(),e.stopPropagation(),e.currentTarget===e.target&&h(!1)}),[]),O=(0,a.useCallback)((e=>{e.preventDefault(),e.stopPropagation(),h(!1);const t=Array.from(e.dataTransfer.files);_(t)}),[_]),P=(0,a.useCallback)((async()=>{if(0===c.length)return;y(null);let n=0;T(Nae[n]);const a=setInterval((()=>{n+=1,n<Nae.length&&T(Nae[n])}),4e3);try{const n=await x(c);clearInterval(a),n?(T("Analysis complete!"),t((0,bae.f)(n)),setTimeout((()=>{e("".concat(I.JZ.protection(),"/results")),r.current&&(r.current.value=""),u([]),T("")}),500)):y(C||"Failed to analyze documents. Please try again.")}catch(l){clearInterval(a),y("An unexpected error occurred. Please try again.")}}),[c,e,x,C,t]),B=(0,a.useCallback)((()=>{u([]),y(null),r.current&&(r.current.value="")}
1),[]),z=c.length>0;return a.createElement(rG.Y,{"data-external-id":"protection",name:"Protection",parentRoute:null},a.createElement("div",{className:"flex p-gutter"},a.createElement(Dae,{column:!0},a.createElement(Rae,null,a.createElement(Mae,null,"Estate Planning Intelligence"),a.createElement(Lae,null,"Protect what matters most"),a.createElement(Oae,null,"Upload your trust and will documents to ensure your estate plan is complete and aligned with your Monarch account. Our analysis will identify any assets in Monarch that may be missing from your estate documents, as well as any assets listed in your will that don't appear in your Monarch account.")),a.createElement(Pae,null,a.createElement("input",{className:"hidden",ref:r,type:"file",accept:Aae,onChange:R,multiple:!0}),a.createElement(Bae,{onDragOver:w?void 0:M,onDragLeave:w?void 0:L,onDrop:w?void 0:O,$isDragOver:g},a.createElement(zae,null,a.createElement(Fae,null,a.createElement(Hae,null,a.createElement(Kae,{name:"sparkle",size:20})),a.createElement(qae,null,a.createElement($ae,null,"Analyze documents with AI"),a.createElement(Zae,null,"Upload your trust and will documents (PDF, DOC, DOCX) to analyze coverage")),a.createElement(Jae,null,a.createElement(Xae,{onClick:D,disabled:w},a.createElement(sl.ZQ,{name:"upload",size:14}),z?"Add more":"Select files")))),w&&a.createElement(gle,null,a.createElement(hle,null,a.createElement(vle,{name:"sparkle",size:40})),a.createElement(fle,null,N),a.createElement("div",{className:"w-full max-w-140"},a.createElement(fe.cqk,{value:A,color:"progress-brand",size:"xs"},a.createElement(yle,null,a.createElement(fe.cqk.Fill,null))),a.createElement(Ele,null,Math.round(A),"%"))),!w&&!z&&a.createElement(Yae,null,a.createElement(Uae,null,a.createElement(Vae,{name:"upload-cloud",size:48}),a.createElement(Wae,null,"Drag and drop your documents here"),a.createElement(jae,null,'or click "Select files" above to browse'),a.createElement(jae,{$marginTop:!0,$dimmed:!0},"Supports PDF, DOC, DOCX \u2022 Maximum 10 files, 10MB each"))),!w&&z&&a.createElement(Gae,null,a.createElement(tle,null,a.createElement(nle,null,c.length," file",1!==c.length?"s":""," selected"),a.createElement(ale,{onClick:B},"Clear")),a.createElement(lle,null,c.map(((e,t)=>a.createElement(rle,{key:"".concat(e.name,"-").concat(t)},a.createElement(sl.ZQ,{name:"file-text",size:12}),a.createElement(ole,null,e.name))))),a.createElement(ile,{size:"small",onClick:P},a.createElement(sl.ZQ,{name:"zap",size:14}),"Analyze ",c.length>1?"documents":"document"))),E&&a.createElement(Qae,null,a.createElement(sl.ZQ,{name:"alert-circle",size:18}),a.createElement(ele,null,E))),a.createElement(sle,null,a.createElement(cle,null,a.createElement(dle,null,"Need a Trust or Will?"),a.createElement(ule,null,"We've partnered with Trust & Will to help you create comprehensive estate planning documents tailored to your needs."),a.createElement(mle,{href:"https://trustandwill.com",target:"_blank",rel:"noopener noreferrer"},"Get Started with Trust & Will",a.createElement(ple,null)))))))},_ae=e=>{const t=e.toLowerCase().substring(e.lastIndexOf("."));return Iae.has(t)},Dae=(0,u.default)(m.g).withConfig({displayName:"Protection__Container",componentId:"sc-14u73ho-0"})(["max-width:1200px;margin:0 auto;animation:"," 0.6s ease-out;"],kae),Rae=u.default.div.withConfig({displayName:"Protection__HeaderSection",componentId:"sc-14u73ho-1"})(["margin-bottom:",";animation:"," 0.6s ease-out;"],vt.YK.large,kae),Mae=u.default.div.withConfig({displayName:"Protection__Kicker",componentId:"sc-14u73ho-2"})(["font-size:",";letter-spacing:2px;text-transform:uppercase;color:",";font-weight:",";margin-bottom:",";display:flex;align-items:center;gap:",";&::before,&::after{content:'';height:1px;width:20px;background:linear-gradient(90deg,transparent,",",transparent);}"],vt.J.xxsmall,vt.Ee.color.content.brand,vt.Wy.bold,vt.YK.xsmall,vt.YK.small,vt.Ee.color.content.brand),Lae=u.default.h1.withConfig({displayName:"Protection__MainHeadline",componentId:"sc-14u73ho-3"})(["font-size:clamp(28px,4vw,36px);font-weight:",";line-height:1.1;color:",";margin:0 0 "," 0;letter-spacing:-0.02em;"],vt.Wy.bold,vt.Ee.color.content.primary,vt.YK.default),Oae=u.default.p.withConfig({displayName:"Protection__Dek",componentId:"sc-14u73ho-4"})(["font-size:",";line-height:1.5;color:",";max-width:680px;margin:0;font-weight:",";"],vt.J.small,vt.Ee.color.content.secondary,vt.Wy.book),Pae=u.default.div.withConfig({displayName:"Protection__UploadContainer",componentId:"sc-14u73ho-5"})(["margin-bottom:",";animation:"," 0.6s ease-out 0.1s backwards;"],vt.YK.large,kae),Bae=u.default.div.withConfig({displayName:"Protection__ContentContainer",componentId:"sc-14u73ho-6"})(["position:relative;padding:",";background:",";border-radius:",";border:",";transition:all 0.4s cubic-bezier(0.4,0,0.2,1);cursor:",";min-height:320px;display:flex;flex-direction:column;box-shadow:",";&::before{content:'';position:absolute;top:0;left:0;right:0;bottom:0;
1background-image:radial-gradient( circle at 20% 80%,"," 0%,transparent 50% ),radial-gradient( circle at 80% 20%,"," 0%,transparent 50% );pointer-events:none;border-radius:",";}"],vt.YK.large,(e=>e.$isDragOver?vt.Ee.color.background.secondary:vt.yW.white),vt.r8.medium,(e=>e.$isDragOver?"3px solid ".concat(vt.yW.orange):"1px solid ".concat(vt.Ee.color.border.primary)),(e=>e.$isDragOver?"copy":"default"),(e=>e.$isDragOver?"0 20px 60px ".concat(vt.Ee.color.shadow.large):"0 4px 20px ".concat(vt.Ee.color.shadow.medium)),vt.Ee.color.background.secondary,vt.Ee.color.background.secondary,vt.r8.medium),zae=u.default.div.withConfig({displayName:"Protection__TopSection",componentId:"sc-14u73ho-7"})(["position:relative;margin-bottom:",";padding-bottom:",";border-bottom:1px solid ",";"],vt.YK.default,vt.YK.default,vt.Ee.color.border.primary),Fae=u.default.div.withConfig({displayName:"Protection__TopSectionGrid",componentId:"sc-14u73ho-8"})(["display:grid;grid-template-columns:auto 1fr auto;align-items:center;gap:",";"],vt.YK.default),Gae=u.default.div.withConfig({displayName:"Protection__FilesSection",componentId:"sc-14u73ho-9"})(["position:relative;margin-top:auto;padding-top:",";"],vt.YK.default),Yae=u.default.div.withConfig({displayName:"Protection__CenterSection",componentId:"sc-14u73ho-10"})(["position:relative;flex:1;display:flex;align-items:center;justify-content:center;padding:"," 0;"],vt.YK.large),Uae=u.default.div.withConfig({displayName:"Protection__DropzonePrompt",componentId:"sc-14u73ho-11"})(["text-align:center;max-width:480px;"]),Vae=(0,u.default)(sl.ZQ).withConfig({displayName:"Protection__PromptIcon",componentId:"sc-14u73ho-12"})(["color:",";margin-bottom:",";opacity:0.4;"],vt.Ee.color.content.secondary,vt.YK.default),Wae=u.default.h3.withConfig({displayName:"Protection__PromptHeadline",componentId:"sc-14u73ho-13"})(["font-size:",";font-weight:",";color:",";margin:0 0 "," 0;letter-spacing:-0.01em;"],vt.J.large,vt.Wy.bold,vt.Ee.color.content.primary,vt.YK.small),jae=u.default.p.withConfig({displayName:"Protection__PromptText",componentId:"sc-14u73ho-14"})(["font-size:",";line-height:1.5;color:",";margin:0;"," ",""],vt.J.small,vt.Ee.color.content.secondary,(e=>e.$marginTop&&"margin-top: ".concat(vt.YK.default,";")),(e=>e.$dimmed&&"opacity: 0.6;")),Hae=u.default.div.withConfig({displayName:"Protection__IconContainer",componentId:"sc-14u73ho-15"})(["display:flex;align-items:center;justify-content:center;width:40px;height:40px;border-radius:",";background:",";flex-shrink:0;box-shadow:0 4px 12px ",";"],vt.r8.round,vt.yW.orange,vt.Ee.color.shadow.medium),Kae=(0,u.default)(sl.ZQ).withConfig({displayName:"Protection__StyledIcon",componentId:"sc-14u73ho-16"})(["color:",";"],vt.yW.white),qae=u.default.div.withConfig({displayName:"Protection__TextContainer",componentId:"sc-14u73ho-17"})(["flex:1;min-width:0;"]),$ae=u.default.h4.withConfig({displayName:"Protection__Title",componentId:"sc-14u73ho-18"})(["font-size:",";font-weight:",";color:",";margin:0 0 4px 0;letter-spacing:-0.01em;"],vt.J.base,vt.Wy.bold,vt.Ee.color.content.primary),Zae=u.default.p.withConfig({displayName:"Protection__Description",componentId:"sc-14u73ho-19"})(["font-size:",";line-height:1.4;color:",";margin:0;"],vt.J.small,vt.Ee.color.content.secondary),Jae=$d.s.div(wae||(wae=(0,wc.A)(["shrink-0"]))),Xae=(0,u.default)(wt.Xb).withConfig({displayName:"Protection__StyledButton",componentId:"sc-14u73ho-20"})(["display:inline-flex;align-items:center;gap:",";padding:10px 20px;background:",";color:"," !important;border:none;border-radius:",";font-size:",";font-weight:",";letter-spacing:0.01em;transition:all 0.3s cubic-bezier(0.4,0,0.2,1);box-shadow:0 2px 8px ",";&:hover{background:",";transform:translateY(-1px);box-shadow:0 4px 12px ",";color:"," !important;}&:active{transform:translateY(0);}&:disabled{opacity:0.5;cursor:not-allowed;transform:none;}svg,.monarch-icon{color:",";}"],vt.YK.xsmall,vt.yW.orange,vt.yW.white,vt.r8.small,vt.J.small,vt.Wy.bold,vt.Ee.color.shadow.medium,vt.yW.orangeDark,vt.Ee.color.shadow.large,vt.yW.white,vt.yW.white),Qae=u.default.div.withConfig({displayName:"Protection__ErrorContainer",componentId:"sc-14u73ho-21"})(["display:flex;align-items:flex-start;gap:",";margin-top:",";padding:",";background:",";border-left:3px solid ",";border-radius:",";animation:"," 0.3s ease-out;"],vt.YK.small,vt.YK.large,vt.YK.large,vt.Ee.color.background.danger,vt.Ee.color.border.danger,vt.r8.
1small,kae),ele=u.default.p.withConfig({displayName:"Protection__ErrorText",componentId:"sc-14u73ho-22"})(["font-size:",";line-height:1.5;color:",";margin:0;flex:1;"],vt.J.small,vt.Ee.color.content.danger),tle=u.default.div.withConfig({displayName:"Protection__SelectedFilesHeader",componentId:"sc-14u73ho-23"})(["display:flex;justify-content:space-between;align-items:center;margin-bottom:",";"],vt.YK.default),nle=u.default.h5.withConfig({displayName:"Protection__SelectedFilesLabel",componentId:"sc-14u73ho-24"})(["font-size:",";font-weight:",";color:",";margin:0;text-transform:uppercase;letter-spacing:1px;"],vt.J.xsmall,vt.Wy.bold,vt.Ee.color.content.primary),ale=u.default.button.withConfig({displayName:"Protection__ClearButton",componentId:"sc-14u73ho-25"})(["background:none;border:none;padding:6px 12px;font-size:",";font-weight:",";color:",";cursor:pointer;transition:all 0.2s ease;border-radius:",";&:hover{color:",";background:",";}"],vt.J.small,vt.Wy.medium,vt.Ee.color.content.secondary,vt.r8.small,vt.Ee.color.content.primary,vt.Ee.color.background.secondary),lle=u.default.div.withConfig({displayName:"Protection__FileList",componentId:"sc-14u73ho-26"})(["display:flex;flex-direction:column;gap:",";margin-bottom:",";"],vt.YK.small,vt.YK.default),rle=u.default.div.withConfig({displayName:"Protection__FileItem",componentId:"sc-14u73ho-27"})(["display:flex;align-items:center;gap:",";padding:"," ",";background:",";border:1px solid ",";border-radius:",";transition:all 0.2s ease;animation:"," 0.3s ease-out;&:hover{border-color:",";box-shadow:0 2px 8px ",";}"],vt.YK.default,vt.YK.small,vt.YK.default,vt.yW.white,vt.Ee.color.border.primary,vt.r8.small,kae,vt.yW.orange,vt.Ee.color.shadow.medium),ole=u.default.span.withConfig({displayName:"Protection__FileName",componentId:"sc-14u73ho-28"})(["flex:1;font-size:",";color:",";font-weight:",";overflow:hidden;text-overflow:ellipsis;white-space:nowrap;"],vt.J.small,vt.Ee.color.content.primary,vt.Wy.medium),ile=(0,u.default)(wt.Xb).withConfig({displayName:"Protection__AnalyzeButton",componentId:"sc-14u73ho-29"})(["width:100%;display:inline-flex;align-items:center;justify-content:center;gap:",";padding:12px 20px;background:",";color:"," !important;border:none;border-radius:",";font-size:",";font-weight:",";letter-spacing:0.02em;transition:all 0.3s cubic-bezier(0.4,0,0.2,1);box-shadow:0 4px 16px ",";position:relative;overflow:hidden;&::before{content:'';position:absolute;top:0;left:-100%;width:100%;height:100%;background:linear-gradient(90deg,transparent,rgba(255,255,255,0.2),transparent);transition:left 0.5s ease;}&:hover::before{left:100%;}&:hover{background:",";transform:translateY(-2px);box-shadow:0 6px 20px ",";color:"," !important;}&:active{transform:translateY(0);}svg,.monarch-icon{color:",";}"],vt.YK.small,vt.yW.orange,vt.yW.white,vt.r8.small,vt.J.base,vt.Wy.bold,vt.Ee.color.shadow.large,vt.yW.orangeDark,vt.Ee.color.shadow.large,vt.yW.white,vt.yW.white),sle=u.default.div.withConfig({displayName:"Protection__ReferralCard",componentId:"sc-14u73ho-30"})(["position:relative;padding:",";background:",";border-radius:",";overflow:hidden;animation:"," 0.6s ease-out 0.2s backwards;&::before{content:'';position:absolute;top:0;left:0;right:0;bottom:0;background-image:radial-gradient(circle at 80% 20%,rgba(255,255,255,0.1) 0%,transparent 50%),radial-gradient(circle at 20% 80%,rgba(255,255,255,0.05) 0%,transparent 50%);pointer-events:none;}"],vt.YK.large,vt.Ee.color.background.brand,vt.r8.medium,kae),cle=u.default.div.withConfig({displayName:"Protection__ReferralInner",componentId:"sc-14u73ho-31"})(["position:relative;text-align:center;max-width:600px;margin:0 auto;"]),dle=u.default.h3.withConfig({displayName:"Protection__ReferralTitle",componentId:"sc-14u73ho-32"})(["font-size:",";font-weight:",";color:",";margin:0 0 "," 0;letter-spacing:-0.01em;"],vt.J.large,vt.Wy.bold,vt.yW.white,vt.YK.small),ule=u.default.p.withConfig({displayName:"Protection__ReferralDescription",componentId:"sc-14u73ho-33"})(["font-size:",";line-height:1.5;color:",";opacity:0.9;margin:0 0 "," 0;"],vt.J.small,vt.yW.white,vt.YK.default),mle=(0,u.default)(wb.gz).withConfig({displayName:"Protection__ReferralLink",componentId:"sc-14u73ho-34"})(["display:inline-flex;align-items:center;gap:",";padding:10px 20px;background:",";color:",";text-decoration:none;border-radius:",";font-size:",";font-weight:",";letter-spacing:0.01em;transition:all 0.3s cubic-bezier(0.4,0,0.2,1);box-shadow:0 2px 8px ",";&:hover{background:",";transform:translateY(-1px);box-shadow:0 4px 12px ",";}&:active{transform:translateY(0);}"],vt.YK.small,vt.yW.white,vt.yW.orange,vt.r8.small,vt.J.small,vt.Wy.bold,vt.Ee.color.shadow.medium,vt.Ee.color.background.secondary,vt.Ee.color.shadow.large),ple=(0,u.default)(sl.ZQ).attrs({name:"external-link",size:16}).withConfig({displayName:"Protection__ExternalLinkIcon",componentId:"sc-14u73ho-35"})(["color:",";"],vt.yW.orange),gle=u.default.div.withConfig({displayName:"Protection__LoadingSection",componentId:"sc-14u73ho-36"})(["position:relative;flex:1;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:",";padding:",";"],vt.YK.xlarge,vt.YK.xxxlarge),hle=u.default.div.withConfig({displayName:"Protection__LoadingIconContainer",componentId:"sc-14u73ho-37"})(["position:relative;display:flex;align-items:center;justify-content:center;width:100px;height:100px;&::before{content:'';position:absolute;width:100%;height:100%;border-radius:",";background:radial-gradient(circle,"," 0%,transparent 70%);opacity:0.2;animation:"," 2s ease-in-out infinite;}"],vt.r8.round,vt.Ee.color.background.brand,Sae),vle=(0,u.default)(sl.ZQ).withConfig({displayName:"Protection__SpinningIcon",componentId:"sc-14u73ho-38"})(["color:",";animation:spin 3s linear infinite;@keyframes spin{from{transform:rotate(0deg);}to{transform:rotate(360deg);}}"],vt.yW.orange),fle=u.default.p.withConfig({displayName:"Protection__LoadingMessage",componentId:"sc-14u73ho-39"})(["font-size:",";font-weight:",";color:",";text-align:center;min-height:24px;margin:0;animation:"," 0.3s ease-out;"],vt.J.base,vt.Wy.medium,vt.Ee.color.content.primary,kae),Ele=u.default.p.withConfig({displayName:"Protection__ProgressPercentage",componentId:"sc-14u73ho-40"})(["font-size:",";color:",";margin:"," 0 0 0;text-align:center;font-weight:",";letter-spacing:1px;"],vt.J.xsmall,vt.Ee.color.content.secondary,vt.YK.small,vt.Wy.bold),yle=(0,$d.s)(fe.cqk.Track)(Cae||(Cae=(0,wc.A)(["\n  after:absolute after:inset-0 after:animate-shimmer after:bg-linear-to-r after:from-transparent\n  after:via-background-secondary after:to-transparent after:content-['']\n"])));var ble;!function(e){e.High="high",e.Medium="medium",e.Low="low",e.Info="info"}(ble||(ble={}));var xle;
1const wle=(0,u.keyframes)(["from{opacity:0;transform:translateY(20px);}to{opacity:1;transform:translateY(0);}"]),Cle=()=>{const e=(0,d.wA)(),t=(0,l.Zp)(),n=(0,d.d4)(xae);if((0,a.useEffect)((()=>{n||t(I.JZ.protection())}),[n,t]),!n)return null;const r=n.documentsAnalyzed,o=n.documentTypes,i=n.executorTrustee,s=n.estateStructure,c=n.metrics,u=n.warnings,m=n.advice,p=n.specificBequests,g=c.totalMonarchAssets?Math.round(c.residuaryVolume/c.totalMonarchAssets*100):0;return a.createElement(rG.Y,{"data-external-id":"protection-results",name:"Protection Results",parentRoute:null},a.createElement("div",{className:"flex p-gutter"},a.createElement(Ale,null,a.createElement(Tle,null,a.createElement(_le,{$variant:"primary",onClick:()=>{e((0,bae.f)(null)),t(I.JZ.protection())}},a.createElement(sl.ZQ,{name:"upload",size:16}),"Run New Analysis"),a.createElement(_le,{onClick:()=>t(I.JZ.dashboard())},"Back to Dashboard")),a.createElement(Ile,null,a.createElement(kle,null,"Estate Planning Intelligence"),a.createElement(Sle,null,"Your Gap Analysis Results"),a.createElement(Nle,null,"Analyzed ",r," document",r>1?"s":""," (",o.join(", "),")")),a.createElement(Dle,null,a.createElement(Rle,{$gradient:"linear-gradient(135deg, ".concat(vt.yW.orange,"15 0%, ").concat(vt.yW.orangeDark,"15 100%)")},a.createElement(Mle,null,"Total Monarch Assets"),a.createElement(Lle,null,(0,rl.T3)(c.totalMonarchAssets))),a.createElement(Rle,{$gradient:"linear-gradient(135deg, ".concat(vt.yW.purple,"15 0%, ").concat(vt.yW.purple10,"15 100%)")},a.createElement(Mle,null,"Residuary Volume"),a.createElement(Lle,null,(0,rl.T3)(c.residuaryVolume)),a.createElement(Ole,null,g,"% of total assets")),a.createElement(Rle,{$gradient:"linear-gradient(135deg, ".concat(vt.yW.blue,"15 0%, ").concat(vt.yW.blueDark,"15 100%)")},a.createElement(Mle,null,"Liquid Assets"),a.createElement(Lle,null,(0,rl.T3)(c.liquidAssets)),a.createElement(Ole,null,"Available cash for gifts")),a.createElement(Rle,{$gradient:"linear-gradient(135deg, ".concat(vt.yW.green,"15 0%, ").concat(vt.yW.greenDark,"15 100%)")},a.createElement(Mle,null,"Retirement Assets"),a.createElement(Lle,null,(0,rl.T3)(c.retirementAssets)),a.createElement(Ole,null,"Bypass will via beneficiaries"))),a.createElement(Ple,null,a.createElement(Ble,null,a.createElement(sl.ZQ,{name:"file-text",size:20}),"Estate Structure"),a.createElement(Kle,null,a.createElement(qle,null,a.createElement($le,null,"Residuary Clause"),a.createElement(Zle,null,s.hasResiduaryClause?"Yes":"No")),s.hasResiduaryClause&&s.residuaryBeneficiaries.length>0&&a.createElement(qle,null,a.createElement($le,null,"Residuary Beneficiaries"),a.createElement(Zle,null,s.residuaryBeneficiaries.join(", "))),a.createElement(qle,null,a.createElement($le,null,"Trust"),a.createElement(Zle,null,s.hasTrust?s.trustName||"Yes":"No")),i&&a.createElement(qle,null,a.createElement($le,null,"Executor/Trustee"),a.createElement(Zle,null,i)),s.specificDollarGifts>0&&a.createElement(qle,null,a.createElement($le,null,"Specific Cash Gifts"),a.createElement(Zle,null,(0,rl.T3)(s.specificDollarGifts))))),u.length>0&&a.createElement(Ple,null,a.createElement(Ble,null,a.createElement(sl.ZQ,{name:"alert-triangle",size:20}),"Warnings & Issues (",u.length,")"),u.map(((e,t)=>{return a.createElement(zle,{key:t,$severity:e.severity},a.createElement(Fle,null,a.createElement(Gle,{$severity:e.severity},a.createElement(sl.ZQ,{name:(n=e.severity,n===ble.High?"alert-circle":n===ble.Medium?"alert-triangle":"info"),size:20})),a.createElement("div",null,a.createElement(Yle,null,e.message),a.createElement(Ule,null,a.createElement("strong",null,"Action:")," ",e.action))));var n}))),u.length>0&&a.createElement(Jle,null,a.createElement(Xle,null,a.createElement(Qle,null,"Address These Issues with Our Trusted Partner"),a.createElement(ere,null,"We found ",u.length," potential ",1===u.length?"issue":"issues"," ","with your estate plan. Our trusted partner, Trust & Will, can help you create or update comprehensive estate planning documents to resolve these concerns and secure your family's future."),a.createElement(tre,null,a.createElement(nre,null,a.createElement(sl.ZQ,{name:"check-circle",size:20}),a.createElement("span",null,"State-specific legal documents")),a.createElement(nre,null,a.createElement(sl.ZQ,{name:"check-circle",size:20}),a.createElement("span",null,"Complete estate planning")),a.createElement(nre,null,a.createElement(sl.ZQ,{name:"check-circle",size:20}),a.createElement("span",null,"Easy online questionnaire")),a.createElement(nre,null,a.createElement(sl.ZQ,{name:"check-circle",size:20}),a.createElement("span",null,"Unlimited updates included"))),a.createElement(are,{as:"a",href:"https://trustandwill.com",target:"_blank",rel:"noopener noreferrer"},"Get Started with Trust & Will",a.createElement(sl.ZQ,{name:"external-link",size:16})))),p.length>0&&a.createElement(Ple,null,a.createElement(Ble,null,a.createElement(sl.ZQ,{name:"gift",size:20}),"Specific Bequests (",p.length,")"),a.createElement(Kle,null,p.map(((e,t)=>a.createElement(qle,{key:t},a.createElement($le,null,e.description,e.isSpecificAccount&&" \u26a0\ufe0f"),a.createElement(Zle,null,e.beneficiary||"Not specified",e.value&&" \u2022 ".concat((0,rl.T3)(e.value)))))))),m.length>0&&a.createElement(Ple,null,a.createElement(Ble,null,a.createElement(sl.ZQ,{name:"help-circle",size:20}),"Recommendations"),a.createElement(Vle,null,m.map(((e,t)=>a.createElement(Wle,{key:t},a.createElement(jle,null,a.createElement(sl.ZQ,{name:"check-circle",size:20})),a.createElement(Hle,null,e)))))),0===u.length&&0===m.length&&a.createElement(lre,null,a.createElement(sl.ZQ,{name:"check-circle",size:48}),a.createElement(rre,null,"No significant issues found. Your estate planning appears to be in good order.")))))},Ale=u.default.div.withConfig({displayName:"ProtectionResults__Container",componentId:"sc-11kdluk-0"})(["max-width:1200px;margin:0 auto;animation:"," 0.6s ease-out;"],wle),Ile=u.default.div.withConfig({displayName:"ProtectionResults__Header",componentId:"sc-11kdluk-1"})(["margin-bottom:",";"],vt.YK.large),kle=u.default.div.withConfig({displayName:"ProtectionResults__Kicker",componentId:"sc-11kdluk-2"})(["font-size:",";letter-spacing:2px;text-transform:uppercase;color:",";font-weight:",";margin-bottom:",";display:flex;align-items:center;gap:",";&::before,&::after{content:'';height:1px;width:20px;background:linear-gradient(90deg,transparent,",",transparent);}"],vt.J.xxsmall,vt.Ee.color.content.brand,vt.Wy.bold,vt.YK.xsmall,vt.YK.small,vt.Ee.color.content.brand),Sle=u.default.h1.withConfig({displayName:"ProtectionResults__Title",componentId:"sc-11kdluk-3"})(["font-size:clamp(28px,4vw,36px);font-weight:",";line-height:1.1;color:",";margin:0 0 "," 0;letter-spacing:-0.02em;"],vt.Wy.bold,vt.Ee.color.content.primary,vt.YK.default),Nle=u.default.p.withConfig({displayName:"ProtectionResults__Subtitle",componentId:"sc-11kdluk-4"})(["font-size:",";line-height:1.5;color:",";max-width:680px;margin:0;font-weight:",";"],vt.J.small,vt.Ee.color.content.secondary,vt.Wy.book),Tle=u.default.div.withConfig({displayName:"ProtectionResults__ButtonGroup",componentId:"sc-11kdluk-5"})(["display:flex;gap:",";margin-bottom:",";"],vt.YK.medium,vt.YK.large),_le=u.default.button.withConfig({displayName:"ProtectionResults__Button",componentId:"sc-11kdluk-6"})(["padding:"," ",";border-radius:",";font-weight:",";cursor:pointer;transition:all 0.2s;display:flex;align-items:center;gap:",";background:",";color:",";border:",";&:hover{background:",";}"],vt.YK.medium,vt.YK.large,vt.r8.medium,vt.Wy.medium,vt.YK.small,(e=>"primary"===e.$variant?vt.yW.orange:vt.Ee.color.background.secondary),(e=>"primary"===e.$variant?"white":vt.Ee.color.content.primary),(e=>"primary"===e.$variant?"none":"1px solid ".concat(vt.Ee.color.border.primary)),(e=>"primary"===e.$variant?vt.yW.orangeDark:vt.Ee.color.background.tertiary)),Dle=u.default.div.withConfig({displayName:"ProtectionResults__MetricsGrid",componentId:"sc-11kdluk-7"})(["display:grid;grid-template-columns:repeat(auto-fit,minmax(250px,1fr));gap:",";margin-bottom:",";"],vt.YK.large,vt.YK.xlarge),Rle=u.default.div.withConfig({displayName:"ProtectionResults__MetricCard",componentId:"sc-11kdluk-8"})(["background:",";border:1px solid ",";border-radius:",";padding:",";position:relative;overflow:hidden;&::before{content:'';position:absolute;top:0;left:0;right:0;height:3px;background:",";}"],(e=>e.$gradient||vt.Ee.color.background.secondary),vt.Ee.color.border.primary,vt.r8.large,vt.YK.large,(e=>e.$gradient||"transparent")),Mle=u.default.div.withConfig({displayName:"ProtectionResults__MetricLabel",componentId:"sc-11kdluk-9"})(["font-size:",";color:",";margin-bottom:",";font-weight:",";"],vt.J.small,vt.Ee.color.content.secondary,vt.YK.xsmall,vt.Wy.medium),Lle=u.default.div.withConfig({displayName:"ProtectionResults__MetricValue",componentId:"sc-11kdluk-10"})(["font-size:",";font-weight:",";color:",";"],vt.J.xxlarge,vt.Wy.bold,vt.Ee.color.content.primary),Ole=u.default.div.withConfig({displayName:"ProtectionResults__MetricSubtext",componentId:"sc-11kdluk-11"})(["font-size:",";color:",";margin-top:",";"],vt.J.xsmall,vt.Ee.color.content.secondary,vt.YK.xsmall),Ple=u.default.div.withConfig({displayName:"ProtectionResults__Section",componentId:"sc-11kdluk-12"})(["margin-bottom:",";"],vt.YK.xxlarge),Ble=u.default.h2.withConfig({displayName:"ProtectionResults__SectionTitle",componentId:"sc-11kdluk-13"})(["font-size:",";font-weight:",";color:",";margin:0 0 "," 0;letter-spacing:-0.01em;display:flex;align-items:center;gap:",";svg{color:",";}"],vt.J.large,vt.Wy.bold,vt.Ee.color.content.primary,vt.YK.medium,vt.YK.small,vt.Ee.color.background.brand),zle=u.default.div.withConfig({displayName:"ProtectionResults__WarningCard",componentId:"sc-11kdluk-14"})(["background:",";border-left:4px solid ",";border-radius:",";padding:",";margin-bottom:",";"],(e=>{switch(e.$severity){case ble.High:return vt.Ee.color.background.danger;case ble.Medium:return vt.Ee.color.background.warning;case ble.Low:return vt.Ee.color.background.info;default:return vt.Ee.color.background.secondary}}),(e=>{switch(e.$severity){case ble.High:return vt.Ee.color.border.danger;case ble.Medium:return vt.Ee.color.border.warning;case ble.Low:return vt.Ee.color.border.info;default:return vt.Ee.color.border.primary}}),vt.r8.medium,vt.YK.large,vt.YK.medium),Fle=u.default.div.withConfig({displayName:"ProtectionResults__WarningHeader",componentId:"sc-11kdluk-15"})(["display:flex;align-items:flex-start;gap:",";margin-bottom:",";"],vt.YK.medium,vt.YK.small),Gle=u.default.div.withConfig({displayName:"ProtectionResults__WarningIcon",componentId:"sc-11kdluk-16"})(["color:",";"],(e=>{switch(e.$severity){case ble.High:return vt.Ee.color.content.danger;case ble.Medium:return vt.Ee.color.content.warning;default:return vt.Ee.color.content.info}})),Yle=u.default.div.withConfig({displayName:"ProtectionResults__WarningMessage",componentId:"sc-11kdluk-17"})(["font-size:",";color:",";font-weight:",";margin-bottom:",";letter-spacing:-0.01em;"],vt.J.base,vt.Ee.color.content.primary,vt.Wy.bold,vt.YK.xsmall),Ule=u.default.div.withConfig({displayName:"ProtectionResults__WarningAction",componentId:"sc-11kdluk-18"})(["font-size:",";line-height:1.4;color:",";margin-left:",";"],vt.J.small,vt.Ee.color.content.secondary,vt.YK.xlarge),Vle=u.default.div.withConfig({displayName:"ProtectionResults__AdviceList",componentId:"sc-11kdluk-19"})(["display:flex;flex-direction:column;gap:",";"],vt.YK.medium),Wle=u.default.div.withConfig({displayName:"ProtectionResults__AdviceItem",componentId:"sc-11kdluk-20"})(["background:",";border:1px solid ",";border-radius:",";padding:",";display:flex;gap:",";"],vt.Ee.color.background.secondary,vt.Ee.color.border.primary,vt.r8.medium,vt.YK.large,vt.YK.medium),jle=u.default.div.withConfig({displayName:"ProtectionResults__AdviceIcon",componentId:"sc-11kdluk-21"})(["color:",";flex-shrink:0;"],vt.Ee.color.background.brand),Hle=u.default.div.withConfig({displayName:"ProtectionResults__AdviceText",componentId:"sc-11kdluk-22"})(["font-size:",";color:",";line-height:1.5;"],vt.J.small,vt.Ee.color.content.primary),Kle=u.default.div.withConfig({displayName:"ProtectionResults__InfoBox",componentId:"sc-11kdluk-23"})(["background:",";border:1px solid ",";border-radius:",";padding:",";margin-bottom:",";"],vt.Ee.color.background.secondary,vt.Ee.color.border.primary,vt.r8.large,vt.YK.large,vt.YK.large),qle=u.default.div.withConfig({displayName:"ProtectionResults__InfoRow",componentId:"sc-11kdluk-24"})(["display:flex;justify-content:space-between;padding:"," 0;border-bottom:1px solid ",";&:last-child{border-bottom:none;}"],vt.YK.medium,vt.Ee.color.border.secondary),$le=u.default.span.withConfig({displayName:"ProtectionResults__InfoLabel",componentId:"sc-11kdluk-25"})(["color:",";font-size:",";"],vt.Ee.color.content.secondary,vt.J.base),Zle=u.default.span.withConfig({displayName:"ProtectionResults__InfoValue",componentId:"sc-11kdluk-26"})(["color:",";font-weight:",";font-size:",";"],vt.Ee.color.content.primary,vt.Wy.medium,vt.J.base),Jle=u.default.div.withConfig({displayName:"ProtectionResults__UpsellCard",componentId:"sc-11kdluk-27"})(["background:linear-gradient(135deg,"," 0%,"," 100%);border-radius:",";padding:",";margin-bottom:",";color:white;position:relative;overflow:hidden;&::before{content:'';position:absolute;top:-50%;right:-10%;width:300px;height:300px;background:rgba(255,255,255,0.1);border-radius:50%;}"],vt.yW.orange,vt.yW.orangeDark,vt.r8.large,vt.YK.xlarge,vt.YK.xlarge),Xle=$d.s.div(xle||(xle=(0,wc.A)(["relative"]))),Qle=u.default.h3.withConfig({displayName:"ProtectionResults__UpsellTitle",componentId:"sc-11kdluk-28"})(["font-size:",";font-weight:",";color:white;margin:0 0 "," 0;letter-spacing:-0.01em;"],vt.J.large,vt.Wy.bold,vt.YK.small),ere=u.default.p.withConfig({displayName:"ProtectionResults__UpsellDescription",componentId:"sc-11kdluk-29"})(["font-size:",";line-height:1.5;color:white;opacity:0.9;margin:0 0 "," 0;"],vt.J.small,vt.YK.large),tre=u.default.ul.withConfig({displayName:"ProtectionResults__UpsellFeatures",componentId:"sc-11kdluk-30"})(["list-style:none;padding:0;margin:0 0 "," 0;
1display:grid;grid-template-columns:repeat(auto-fit,minmax(200px,1fr));gap:",";"],vt.YK.large,vt.YK.medium),nre=u.default.li.withConfig({displayName:"ProtectionResults__UpsellFeature",componentId:"sc-11kdluk-31"})(["display:flex;align-items:center;gap:",";font-size:",";color:rgba(255,255,255,0.95);svg{flex-shrink:0;color:white;}"],vt.YK.small,vt.J.base),are=u.default.button.withConfig({displayName:"ProtectionResults__UpsellButton",componentId:"sc-11kdluk-32"})(["background:white;color:",";border:none;padding:10px 20px;border-radius:",";font-weight:",";font-size:",";letter-spacing:0.01em;cursor:pointer;transition:all 0.3s cubic-bezier(0.4,0,0.2,1);display:inline-flex;align-items:center;gap:",";box-shadow:0 2px 8px ",";&:hover{background:",";transform:translateY(-1px);box-shadow:0 4px 12px ",";}&:active{transform:translateY(0);}"],vt.yW.orange,vt.r8.small,vt.Wy.bold,vt.J.small,vt.YK.small,vt.Ee.color.shadow.medium,vt.Ee.color.background.secondary,vt.Ee.color.shadow.large),lre=u.default.div.withConfig({displayName:"ProtectionResults__EmptyState",componentId:"sc-11kdluk-33"})(["text-align:center;padding:",";color:",";"],vt.YK.xxlarge,vt.Ee.color.content.secondary),rre=u.default.div.withConfig({displayName:"ProtectionResults__EmptyStateText",componentId:"sc-11kdluk-34"})(["margin-top:",";"],vt.YK.medium);var ore=n(39455),ire=n(58228),sre=n(87631),cre=n(4342),dre=n(92568),ure=n(32343),mre=n(28375),pre=n(7823);const gre={general:"What would you like to be able to do in Monarch?",project:"Why do you need this? What would this help you accomplish?",released:"How is it working for you? What would make it better?"},hre={general:"How much does this affect your experience with Monarch?",project:"How much would this impact your experience with Monarch?",released:"How much does this affect your experience with Monarch?"},vre={general:"Share context to help us understand your needs\u2026",project:"Giving us more detail will help us better shape this feature",released:"Share context to help us understand your needs\u2026"},fre=(e,t)=>(0,r.YW)(e).with("general",(()=>({title:"It reaches the right team",description:"Your feedback is routed to the people who build that part of Monarch."}))).with("project",(()=>({title:"It reaches the team",description:"Your feedback goes straight to the team working on \u201c".concat(t,"\u201d and helps shape what they build.")}))).with("released",(()=>({title:"It reaches the team",description:"Your feedback goes straight to the team that built \u201c".concat(t,"\u201d.")}))).exhaustive(),Ere=e=>(0,r.YW)(e).with("general",(()=>({title:"We track it",description:"If it becomes a project, you\u2019ll see it on our roadmap."}))).with("project",(()=>({title:"Follow its progress",description:"This project is already on our roadmap. Check back anytime to see where it stands."}))).with("released",(()=>({title:"It shapes improvements",description:"\u201cReleased\u201d doesn\u2019t mean \u201cfinished.\u201d Your feedback informs refinements after launch."}))).exhaustive(),yre=e=>e?{title:"We\u2019ll let you know",description:"You asked us to contact you. We\u2019ll email you if and when we address this."}:{title:"You\u2019re all set",description:"You chose not to be contacted. Check the roadmap for progress."};var bre=n(54348),xre=n(80530);const wre=[{score:4,label:"Deal-breaker without it"},{score:3,label:"I can work around it"},{score:2,label:"Nice to have"},{score:1,label:"Not important to me"}],Cre=[Ee.O4y.SUBSCRIPTION_ENDED,Ee.O4y.USER_IS_ONBOARDING,Ee.O4y.TOO_MANY_REQUESTS],Are=e=>{if(e instanceof bre.K4&&0!==e.graphQLErrors.length)return Cre.find((t=>(0,Vte.sn)(e.graphQLErrors,t)))},Ire=e=>e instanceof bre.K4?e.networkError?"network":e.graphQLErrors.length>0?"graphql":"unknown":e instanceof TypeError?"network":"unknown",kre={feedback:"",severity:"",canContact:!0},Sre=e=>{const t=e.mode,n=e.open,r=e.onOpenChange,s=e.source,c=(0,a.useRef)(0),u=(0,a.useRef)(!1),m=(0,a.useRef)(!1),p=(0,a.useRef)(!1),g=(0,a.useRef)(),h=(0,a.useRef)(kre),f=(0,a.useState)(null),E=(0,o.A)(f,2),y=E[0],b=E[1],x=(0,d.d4)(A.M1),w=(()=>{const e=(0,a.useRef)(null),t=(0,i.n)(xre.$),n=(0,o.A)(t,2),l=n[0],r=n[1],s=(0,a.useCallback)((()=>{e.current=null}),[]),c=(0,a.useCallback)((async t=>{let n=t.feedback,a=t.severity,r=t.contactConsent,o=t.metadata,i=t.projectExternalId;var s,c;if(e.current)return{success:!1,ignored:!0};const d={};e.current=d;try{const e=(await l({variables:{input:(0,U.A)({feedback:n.trim(),severity:a,contactConsent:r,metadata:JSON.stringify(o)},i?{projectExternalId:i}:{})}})).data,t=null===e||void 0===e?void 0:e.submitProductFeedback;return!(null===t||void 0===t?void 0:t.feedbackEvent)||t.errors?{success:!1,error:null!==(c=null===(s=null===t||void 0===t?void 0:t.errors)||void 0===s?void 0:s.message)&&void 0!==c?c:"Feedback submission failed",errorType:"graphql"}:{success:!0}}catch(u){return{success:!1,error:u instanceof Error?u.message:"Feedback submission failed",errorType:Ire(u),errorCode:Are(u)}}finally{e.current===d&&(e.current=null)}}),[l]);return[c,r,s]})(),k=(0,o.A)(w,3),S=k[0],N=k[2],T="general"===t,_=Boolean((0,l.RQ)(I.JZ.roadmap.path)),D=T&&!_,R=null===y?null:((e,t)=>{let n=t.canContact,a=t.projectName;return[fre(e,void 0===a?"":a),Ere(e),yre(n)]})(t,{canContact:y,projectName:T?void 0:e.projectName}),M=(0,v.D)((()=>{!u.current||m.current||p.current||(p.current=!0,(0,Ge.u4)(Ye.Sd.ProductFeedbackDismissed,(0,U.A)((0,U.A)({interaction_context:T?"general_feedback":"roadmap_project_feedback"},g.current?{source:g.current}:{}),{},{had_text:h.current.feedback.trim().length>0,severity_selected:h.current.severity.length>0})))}
1)),L=e=>{e||(M(),c.current+=1,N(),b(null)),r(e)};(0,a.useEffect)((()=>{n&&!u.current&&(m.current=!1,p.current=!1,g.current=s,(0,Ge.u4)(Ye.Sd.ProductFeedbackModalViewed,(0,U.A)({interaction_context:T?"general_feedback":"roadmap_project_feedback"},s?{source:s}:{}))),!n&&u.current&&M(),u.current=n}),[T,n,s,M]),(0,a.useEffect)((()=>()=>{M()}),[M]),(0,a.useEffect)((()=>{if(!n)return;const e=e=>{e.persisted||M()};return window.addEventListener("pagehide",e),()=>{window.removeEventListener("pagehide",e)}}),[n,M]);return a.createElement(sre.h.Root,{"data-external-id":"feedback-capture-modal",open:n,onOpenChange:L,size:"xl"},a.createElement(sre.h.Content,null,a.createElement(Eu.lV,{key:String(n),className:"contents",initialValues:kre,validate:e=>{const t={};return 0===e.feedback.trim().length&&(t.feedback="Please share some feedback."),0===e.severity.length&&(t.severity="Please select an option."),t},onSubmit:async n=>{const a=c.current,l=await S((0,U.A)({feedback:n.feedback,severity:Number(n.severity),contactConsent:n.canContact,metadata:_re(t,Dre(x))},T?{}:{projectExternalId:e.projectExternalId}));if(a===c.current&&(l.success||!("ignored"in l)))if(l.success)m.current=!0,(0,Ge.u4)(Ye.Sd.ProductFeedbackSubmitted,(0,U.A)((0,U.A)({interaction_context:T?"general_feedback":"roadmap_project_feedback"},s?{source:s}:{}),{},{severity:Number(n.severity),contact_consent:n.canContact,has_project:!T})),b(n.canContact);else{var r;if((0,Ge.u4)(Ye.Sd.ProductFeedbackSubmitFailed,(0,U.A)((0,U.A)({interaction_context:T?"general_feedback":"roadmap_project_feedback"},s?{source:s}:{}),{},{error_type:l.errorType,error_code:null!==(r=l.errorCode)&&void 0!==r?r:null,error_message:l.error})),l.errorCode===Ee.O4y.SUBSCRIPTION_ENDED||l.errorCode===Ee.O4y.USER_IS_ONBOARDING)return p.current=!0,void L(!1);if(l.errorCode===Ee.O4y.TOO_MANY_REQUESTS)return;(0,C.oR)({title:"We couldn't submit your feedback",description:"Please try again.",variant:"error"})}},preventSubmitWhileSubmitting:!0},a.createElement(Nre,{open:n,valuesRef:h}),a.createElement(sre.h.CloseTrigger,null),null!==R?a.createElement(a.Fragment,null,a.createElement(sre.h.Header,null,a.createElement("div",{className:"mb-sm flex size-11 items-center justify-center rounded-round bg-background-success"},a.createElement(cre.MdsCheckIcon,{size:"md",className:"text-content-success"})),a.createElement(sre.h.Title,null,"Got it \u2014 thank you")),a.createElement(sre.h.Body,{className:"flex flex-col gap-xl"},a.createElement(kD.c,{color:"secondary"},"Here's what happens with your feedback:"),a.createElement(pre.S.Root,{size:"lg",variant:"subtle"},a.createElement(pre.S.Item,null,a.createElement(pre.S.Connector,null,a.createElement(pre.S.Indicator,null,a.createElement(mre.MdsUsersIcon,{size:"sm"})),a.createElement(pre.S.Separator,null)),a.createElement(pre.S.Content,null,a.createElement(pre.S.Title,null,R[0].title),a.createElement(pre.S.Description,null,R[0].description))),a.createElement(pre.S.Item,null,a.createElement(pre.S.Connector,null,a.createElement(pre.S.Indicator,null,a.createElement(ure.MdsMapIcon,{size:"sm"})),a.createElement(pre.S.Separator,null)),a.createElement(pre.S.Content,null,a.createElement(pre.S.Title,null,R[1].title),a.createElement(pre.S.Description,null,R[1].description))),a.createElement(pre.S.Item,null,a.createElement(pre.S.Connector,null,a.createElement(pre.S.Indicator,{className:"bg-background-brand-subtle text-content-brand"},a.createElement(dre.MdsMailIcon,{size:"sm"})),a.createElement(pre.S.Separator,null)),a.createElement(pre.S.Content,null,a.createElement(pre.S.Title,null,R[2].title),a.createElement(pre.S.Description,null,R[2].description))))),a.createElement(sre.h.Footer,{className:D?"gap-xl":void 0},D?a.createElement(p1.E,{to:I.JZ.roadmap(),variant:"text",onClick:()=>L(!1)},"See the roadmap"):null,a.createElement(sre.h.Close,{render:a.createElement(Wb.X,{variant:"primary"},"Done")}))):a.createElement(a.Fragment,null,a.createElement(sre.h.Header,null,T?a.createElement(sre.h.Title,null,"Share feedback"):a.createElement(a.Fragment,null,a.createElement("div",{className:"flex items-center gap-sm"}
1,a.createElement("span",{"aria-hidden":!0,className:(0,q.cn)("flex size-8 shrink-0 items-center justify-center rounded-sm",e.projectIconClasses.tile)},a.createElement(fe.jeH,{name:e.projectIcon,className:e.projectIconClasses.icon})),a.createElement(sre.h.Title,null,e.projectName)),a.createElement(kD.c,{color:"secondary",className:"mt-2xs"},e.projectDescription))),a.createElement(sre.h.Body,{className:"flex flex-col gap-xl"},a.createElement(Tre,{mode:t})),a.createElement(sre.h.Footer,{className:"gap-sm"},a.createElement(sre.h.Close,{render:a.createElement(Wb.X,null,"Cancel")}),a.createElement(tC.zB.SubmitButton,{disableWhenValuesUnchanged:!1,className:"mt-0 w-auto"},"Submit feedback"))))))},Nre=e=>{let t=e.open,n=e.valuesRef;const a=(0,hu.x)().values;return t&&(n.current=a),null},Tre=e=>{let t=e.mode;const n=((e=>"project"===e)(t)?wre:wre.filter((e=>1!==e.score))).map((e=>{let t=e.score,n=e.label;return{value:t.toString(),label:n}})),l=a.createElement(tC.zB.Radio,{name:"severity",label:hre[t],options:n}),r=a.createElement(tC.zB.Textarea,{name:"feedback",label:gre[t],placeholder:vre[t],minRows:3,maxRows:8});return a.createElement(a.Fragment,null,(e=>"general"!==e)(t)?a.createElement(a.Fragment,null,l,r):a.createElement(a.Fragment,null,r,l),a.createElement(tC.zB.Checkbox,{name:"canContact",label:"Contact me if and when we address this"}))},_re=(e,t)=>{var n;return((e,t)=>{let n=t.platform,a=t.appEnvironment,l=t.appVersion,r=t.pageUrl,o=t.previousPageUrl,i=t.viewportWidth,s=t.viewportHeight,c=t.screenWidth,d=t.screenHeight;return(0,U.A)((0,U.A)((0,U.A)((0,U.A)((0,U.A)((0,U.A)({platform:n,viewport_width:i,viewport_height:s,interaction_context:"general"===e?"general_feedback":"roadmap_project_feedback"},a?{app_environment:a}:{}),l&&"undefined"!==l?{app_version:l}:{}),r?{page_url:r}:{}),o?{previous_page_url:o}:{}),c?{screen_width:c}:{}),d?{screen_height:d}:{})})(e,{platform:"web",appEnvironment:null!==(n="production")?n:"production",appVersion:(0,pY.s)(),pageUrl:"".concat(window.location.origin).concat(window.location.pathname),previousPageUrl:t,viewportWidth:window.innerWidth,viewportHeight:window.innerHeight,screenWidth:window.screen.width,screenHeight:window.screen.height})},Dre=e=>{const t=[...e].reverse().find((e=>e.path!==window.location.pathname));return t?"".concat(window.location.origin).concat(t.path):void 0},Rre=()=>((0,a.useEffect)((()=>{(()=>{if(!document.querySelector("script#ze-snippet")){const e=document.createElement("script"),t=document.getElementsByTagName("script"),n=(0,o.A)(t,1)[0];e.id="ze-snippet",e.defer=!0,e.src="https://static.zdassets.com/ekr/snippet.js?key=".concat("d8d33592-cf5c-4ae3-ae8f-553657823fbf"),n.parentNode.insertBefore(e,n),e.onload=()=>{zE("webWidget","hide")}}})()}),[]),a.createElement(a.Fragment,null));var Mre=n(49911),Lre=n(96882);const Ore=(0,u.default)(ZY.B).attrs({"data-sc-tw":"Flex__Flex LinkIcon__LinkIcon",center:!0}).withConfig({displayName:"LinkIcon",componentId:"sc-1qcij8x-0"})(["margin-right:",";position:relative;"],(e=>e.theme.spacing.small)),Pre=["iconName","children","hasUnsavedChanges","isActive","badge","to"];var Bre,zre;const Fre=u.default.span.withConfig({displayName:"NavBarLink__UnsavedChangesBadge",componentId:"sc-1xv1ifc-0"})(["width:6px;height:6px;position:absolute;background-color:",";top:0;right:-2px;border-radius:100%;"],(e=>e.theme.color.red)),Gre=$d.s.span(Bre||(Bre=(0,wc.A)(["ml-auto hidden in-aria-expanded:inline-flex"]))),Yre=$d.s.span(zre||(zre=(0,wc.A)(["hidden truncate in-aria-expanded:inline-block"]))),Ure=u.default.div.withConfig({displayName:"NavBarLink__Container",componentId:"sc-1xv1ifc-1"})(["cursor:pointer;:hover{color:",";}"],vt.yW.text),Vre=(0,u.default)((e=>{var t;let n=e.iconName,r=e.children,o=e.hasUnsavedChanges,i=e.isActive,s=e.badge,c=e.to,d=(0,En.A)(e,Pre);const u=(0,l.zy)(),m=(0,l.RQ)(null!==(t=null===c||void 0===c?void 0:c.toString())&&void 0!==t?t:""),p=c&&(m||(0,ma.gQ)(u.pathname,c.toString())),g="".concat(n,"-filled"),h=(0,fe.ek8)(g)?g:n,v=p||i?h:n;return a.createElement(Ure,Object.assign({as:c?l.k2:void 0,to:null!==c&&void 0!==c?c:"","data-active":!(!p&&!i)||void 0},d),a.createElement(Ore,null,a.createElement(fe.jeH,{name:v,size:"md"}),o&&a.createElement(Fre,null)),a.createElement(Yre,null,r),!!s&&a.createElement(Gre,null,s))}
1)).attrs((0,Ex.p)("nav-bar-link")).withConfig({displayName:"NavBarLink",componentId:"sc-1xv1ifc-2"})(["color:",";display:flex;align-items:center;padding:"," ",";height:var(--sidebar-button-height);transition:",";margin-bottom:",";border-radius:",";&:not([data-active]):hover{background-color:",";}&[data-active],&&:active{opacity:1;background-color:",";}"],vt.yW.text,vt.YK.xsmall,vt.YK.small,(e=>e.theme.transition.default),vt.YK.xxxsmall,vt.r8.small,vt.yW.gray4,vt.yW.gray4),Wre=(0,u.default)(Vre).withConfig({displayName:"NavBarLink__SecondaryNavBarLink",componentId:"sc-1xv1ifc-3"})(["color:",";"],vt.Ee.color.content.secondary),jre=["name","className","iconNameOverride"],Hre=["route","icon"],Kre=e=>{let t=e.name,n=e.className,l=e.iconNameOverride,r=(0,En.A)(e,jre);const o=pa.EC[t],i=o.route,s=o.icon,c=(0,En.A)(o,Hre),d="label"in c&&c.label?c.label:t;return a.createElement(Vre,Object.assign({"data-external-id":"side-bar-link",className:(0,q.cn)(qre,n),to:i,iconName:null!==l&&void 0!==l?l:s},r),d)},qre=(0,q.cn)("in-aria-[expanded='false']:max-w-[calc(var(--sidebar-collapsed-width)-var(--spacing-sm))]");var $re;const Zre=e=>{let t=e.onSupportButtonClick;return a.createElement(a.Fragment,null,a.createElement(Lre.g,null,a.createElement(Jre,{to:I.JZ.advisorPortal.clients(),end:!0,iconName:"home"},"Clients"),a.createElement(Jre,{to:I.JZ.advisorPortal.profile(),end:!0,iconName:"user"},"Profile"),a.createElement(Jre,{to:I.JZ.advisorPortal.billing(),end:!0,iconName:"
1credit-card"},"Billing"),a.createElement(Jre,{to:I.JZ.advisorPortal.security(),end:!0,iconName:"lock"},"Security")),a.createElement(Lre.g,{grow:1}),a.createElement(Lre.g,null,a.createElement(Wre,{onClick:t,iconName:"message-circle"},"Help & Support")))},Jre=(0,$d.s)(Vre)($re||($re=(0,wc.A)(["",""])),qre);var Xre=n(81755),Qre=n(84304);const eoe=()=>a.createElement(toe,{"data-external-id":"notification-center-empty",center:!0,column:!0,gap:"default"},a.createElement(aoe,null,a.createElement(loe,{size:32})),a.createElement(noe,{title:"All clear!",subtitle:"We'll keep you updated on any future notifications."})),toe=(0,u.default)(m.g).withConfig({displayName:"NotificationCenterEmpty__Root",componentId:"cggoj6-0"})(["padding:"," 0;padding-top:",";"],(e=>e.theme.spacing.xlarge),(e=>e.theme.spacing.xxxlarge)),noe=(0,u.default)(cU.vx).withConfig({displayName:"NotificationCenterEmpty__StyledEmpty",componentId:"cggoj6-1"})(["padding-top:0;"]),aoe=(0,u.default)(m.g).attrs({center:!0}).withConfig({displayName:"NotificationCenterEmpty__IconCircle",componentId:"cggoj6-2"})(["width:64px;height:64px;background:",";border-radius:",";"],vt.Ee.color.background.success,vt.r8.round),loe=(0,u.default)(sl.ZQ).attrs({name:"check"}).withConfig({displayName:"NotificationCenterEmpty__StyledIcon",componentId:"cggoj6-3"})(["color:",";"],vt.Ee.color.content.success);var roe=n(76693);const ooe=e=>{let t=e.children,n=e.title,l=e.body,r=e.icon,o=e.date,i=e.read,s=e.className,c=e.onClick;return a.createElement(ioe,{"data-external-id":"base-notification",className:s,$read:i,role:"button",tabIndex:0,onClick:c,onKeyDown:e=>{"Enter"===e.key&&(null===c||void 0===c||c())}},r,a.createElement(soe,null,a.createElement("div",null,!!n&&a.createElement(Ll.o,{className:"text-sm leading-[inherit] font-medium"},n),!!l&&a.createElement(Ll.o,{className:"mt-2xs text-base leading-[150%]"},l)),t),a.createElement(coe,null,a.createElement(roe.T,{date:o,short:!0})))},ioe=u.default.div.withConfig({displayName:"BaseNotification__Root",componentId:"sc-1fpucpj-0"})(["display:flex;gap:",";padding:",";padding-right:",";background:",";color:",";cursor:pointer;transition:",";:hover:not(:has(button:hover,[role='button']:hover)){background:",";}&:not(:last-child){border-bottom:1px solid ",";}"],vt.YK.small,vt.YK.small,vt.YK.xlarge,vt.Ee.color.background.primary,(e=>{let t=e.theme;return e.$read?t.variables.color.content.secondary:t.variables.color.content.primary}),(e=>e.theme.transition.default),vt.Ee.color.background.primaryHover,vt.Ee.color.divider.primary),soe=u.default.div.withConfig({displayName:"BaseNotification__ContentContainer",componentId:"sc-1fpucpj-1"})(["flex:1;"]),coe=u.default.div.withConfig({displayName:"BaseNotification__TimestampContainer",componentId:"sc-1fpucpj-2"})(["color:",";font-size:",";font-weight:",";padding-top:",";line-height:150%;"],vt.Ee.color.content.secondary,vt.J.xsmall,vt.Wy.medium,vt.YK.xxxsmall),doe=["title"],uoe=e=>{var t;let n=e.title,l=(0,En.A)(e,doe);const r=null!==(t=null===n||void 0===n?void 0:n.split(/ (.+)/))&&void 0!==t?t:[],i=(0,o.A)(r,2),s=i[0],c=i[1];return a.createElement(ooe,Object.assign({"data-external-id":"notification"},l,{title:c,icon:a.createElement(moe,null,a.createElement("span",null,s))}))},moe=(0,u.default)(m.g).attrs({center:!0}).withConfig({displayName:"Notification__IconCircle",componentId:"w4yc41-0"})(["width:32px;height:32px;background:",";border-radius:",";text-align:center;"],(e=>e.theme.color.grayFocus),(e=>e.theme.radius.round)),poe=["logo","primaryActionButtonLabel","onDismiss","onPrimaryActionButtonClick"],goe=e=>{let t=e.logo,n=e.primaryActionButtonLabel,l=e.onDismiss,r=e.onPrimaryActionButtonClick,o=(0,En.A)(e,poe);return a.createElement(foe,Object.assign({"data-external-id":"pinned-notification"},o,{icon:a.createElement(aq.i,{size:32,logo:t}),read:!1}),a.createElement(hoe,null,!!n&&a.createElement(cu.WT,{onClick:e=>{e.stopPropagation(),r()}},n),a.createElement(voe,{onClick:e=>{e.stopPropagation(),l()}},"Dismiss")))},hoe=u.default.div.withConfig({displayName:"PinnedNotification__ActionContainer",componentId:"sc-1nvhs34-0"})(["display:flex;gap:",";margin-top:",";"],(e=>e.theme.spacing.default),(e=>e.theme.spacing.default)),voe=(0,u.default)(bn.v).withConfig({displayName:"PinnedNotification__DismissButton",componentId:"sc-1nvhs34-1"})(["color:",";"],(e=>e.theme.color.textLight)),foe=(0,u.default)(ooe).withConfig({displayName:"PinnedNotification__Notification",componentId:"sc-1nvhs34-2"})(["user-select:none;:not(:last-child){border-bottom:1px solid ",";}"],(e=>e.theme.color.grayFocus)),Eoe=e=>{let t=e.id,n=e.title,r=e.body,o=e.action,i=e.createdAt,s=e.readAt,c=e.isPinned,d=e.logo,u=e.actionLabel,m=e.eventType,p=e.secondaryUrl,g=e.markAsRead,h=e.dismissActivity;const v=(0,l.Zp)(),f=(0,Qi.rL)().close,E=(0,C.RU)(),y=e=>{let n=e.isPinnedItemRootClick,a=void 0!==n&&n;f(),g({variables:{id:t}});const l=o&&(e=>{const t=null===e||void 0===e?void 0:e.match(/\[.*\]\(.*\)/),n=null===t||void 0===t?void 0:t[0];if(n)return n.substring(n.lastIndexOf("(")+1,n.lastIndexOf(")"))})(o),r=a?p:l,i=yoe({isPinned:c,isPinnedItemRootClick:a});(0,Ge.u4)(i,{type:m,destination:r}),r?/^https?:\/\//.test(r)?window.open(r,"_blank","noopener,noreferrer"):v(r):E({title:"Sorry, something went wrong",description:"Please, try again"})},b=()=>{h({variables:{id:t}}),(0,Ge.u4)(Ye.j4.NotificationCenterPinnedItemDismissed,{type:m})};
1return c?a.createElement(goe,{"data-external-id":"notification-center-list-item",title:null!==n&&void 0!==n?n:void 0,body:null!==r&&void 0!==r?r:void 0,logo:null!==d&&void 0!==d?d:null,primaryActionButtonLabel:null!==u&&void 0!==u?u:null,date:i,read:!!s,onClick:()=>y({isPinnedItemRootClick:!0}),onPrimaryActionButtonClick:()=>y({}),onDismiss:b}):a.createElement(uoe,{"data-external-id":"notification-center-list-item",title:null!==n&&void 0!==n?n:void 0,body:null!==r&&void 0!==r?r:void 0,date:i,read:!!s,onClick:()=>y({})})},yoe=e=>{let t=e.isPinned,n=e.isPinnedItemRootClick;return t?n?Ye.j4.NotificationCenterPinnedItemSelected:Ye.j4.NotificationCenterPinnedItemActioned:Ye.j4.NotificationCenterUnpinnedItemSelected},boe=(0,Qt.J)("\n  mutation Common_MarkAllActivityAsRead($first: Int) {\n    markAllActivityAsRead {\n      activityEvents(first: $first) {\n        edges {\n          node {\n            id\n            readAt\n          }\n        }\n      }\n    }\n  }\n"),xoe=(0,Qt.J)("\n  mutation Common_ClearAllActivities($excludeEventTypes: [ActivityEventType!]) {\n    clearAllActivities(excludeEventTypes: $excludeEventTypes) {\n      success\n    }\n  }\n"),woe=(0,Qt.J)("\n  mutation Common_MarkActivityAsRead($id: UUID!) {\n    markActivityAsRead(id: $id) {\n      node {\n        id\n        readAt\n      }\n    }\n  }\n"),Coe=(0,Qt.J)("\n  mutation Common_DismissActivity($id: ID!) {\n    dismissActivity(id: $id) {\n      node {\n        id\n        dismissedAt\n      }\n    }\n  }\n"),Aoe=(0,Qt.J)("\n  query Common_GetNotificationCenter(\n    $first: Int!\n    $afterCursor: String\n    $excludeEventTypes: [ActivityEventType!]\n  ) {\n    activityEvents(first: $first, after: $afterCursor, excludeEventTypes: $excludeEventTypes) {\n      pageInfo {\n        hasNextPage\n        endCursor\n      }\n      edges {\n        node {\n          id\n          createdAt\n          readAt\n          title\n          body\n          action\n          actionLabel\n          eventPriority\n          isPinned\n          logo\n          dismissedAt\n          eventType\n          eventData\n          secondaryUrl\n        }\n      }\n    }\n  }\n");var Ioe;const koe=()=>{const e=(0,Qi.rL)().close,t=function(){let e=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}).excludeEventTypes;var t,n,l;const r=(0,a.useMemo)((()=>
1({first:10,afterCursor:void 0,excludeEventTypes:e})),[e]),s=(0,Xo.IT)(Aoe,{variables:r}),c=s.data,d=s.loading,u=s.fetchMore,m=s.refetch,p=(0,a.useMemo)((()=>{var e,t;return null!==(t=null===(e=null===c||void 0===c?void 0:c.activityEvents)||void 0===e?void 0:e.edges.flatMap((e=>(null===e||void 0===e?void 0:e.node)?[e.node]:[])))&&void 0!==t?t:[]}),[c]),g=p.some((e=>{let t=e.readAt,n=e.isPinned;return!t&&!n})),h=null!==(n=null===(t=null===c||void 0===c?void 0:c.activityEvents)||void 0===t?void 0:t.pageInfo.hasNextPage)&&void 0!==n&&n,v=null===(l=null===c||void 0===c?void 0:c.activityEvents)||void 0===l?void 0:l.pageInfo.endCursor,f=p.length,E=(0,i.n)(boe,{variables:{first:f}}),y=(0,o.A)(E,2),b=y[0],x=y[1].loading,w=(0,i.n)(xoe,{variables:{excludeEventTypes:e},onCompleted:()=>{m()}}),C=(0,o.A)(w,2),A=C[0],I=C[1].loading,k=(0,i.n)(woe),S=(0,o.A)(k,1)[0],N=(0,i.n)(Coe,{update:(_={query:Aoe,variables:r},(e,t)=>{let n=t.data;var a,l;if(!(null===(l=null===(a=null===n||void 0===n?void 0:n.dismissActivity)||void 0===a?void 0:a.node)||void 0===l?void 0:l.id))return;const r=_.query,o=_.variables,i=e.readQuery({query:r,variables:o});if(!i)return;const s=i.activityEvents;if(!s)return;const c=s.edges.filter((e=>{var t;return null===(null===(t=null===e||void 0===e?void 0:e.node)||void 0===t?void 0:t.dismissedAt)}));e.writeQuery({data:(0,U.A)((0,U.A)({},i),{},{activityEvents:(0,U.A)((0,U.A)({},s),{},{edges:c})}),query:r,variables:o})})}),T=(0,o.A)(N,1)[0];var _;const D=(0,a.useCallback)((()=>
1{u({variables:{first:10,afterCursor:v,excludeEventTypes:e},updateQuery:(e,t)=>{let n=t.fetchMoreResult;return(0,Ru.A)({activityEvents:(0,mQ.gr)(null===n||void 0===n?void 0:n.activityEvents)},e)}})}),[u,v,e]),R=(0,a.useMemo)((()=>{const e=p.filter((e=>e.isPinned)),t=p.filter((e=>!e.isPinned));return{pinnedNotifications:e,readNotifications:t.filter((e=>!!e.readAt)),unreadNotifications:t.filter((e=>!e.readAt))}}),[p]);return(0,U.A)({notifications:p,loading:d,hasNextPage:h,hasUnreadNotifications:g,markAllAsRead:b,isLoadingMarkAllAsRead:x,clearAll:A,isLoadingClearAll:I,markAsRead:S,dismissActivity:T,requestNextPage:D,notificationsCount:f},R)}({excludeEventTypes:[Ee.o58.NET_WORTH_MILESTONE]}),n=t.pinnedNotifications,l=t.unreadNotifications,r=t.readNotifications,s=t.notificationsCount,c=t.loading,d=t.hasNextPage,u=t.markAllAsRead,g=t.clearAll,h=t.isLoadingClearAll,v=t.requestNextPage,f=t.hasUnreadNotifications,E=t.markAsRead,y=t.dismissActivity;(0,a.useEffect)((()=>()=>{f&&u()}),[u,f]);const b=s?[{data:n,key:"Needs attention"},{data:l,key:"Unread"},{data:r,key:"Read"}].filter((e=>e.data.length>0)):[];return a.createElement(Soe,{"data-external-id":"notification-center"},a.createElement(Noe,null,a.createElement(m.g,{alignCenter:!0},"Notifications"),a.createElement(m.g,{alignCenter:!0,gap:"xsmall"},a.createElement(_oe,{disabled:!s,onClick:()=>{g(),(0,Ge.u4)(Ye.j4.NotificationCenterAllUnpinnedNotificationsCleared)},pending:h,size:"xsmall"},"Clear all"),a.createElement(wt.Xb,{size:"xsmall",linkTo:I.JZ.settings.notifications(),onClick:e},a.createElement(Yo.r,{name:"settings"}),a.createElement("span",null,"Settings")))),a.createElement(Ul.w,null,a.createElement(Ul.d,{when:c&&!s},a.createElement(Toe,null,a.createElement(p.i,null))),a.createElement(Ul.d,{when:0===s},a.createElement(eoe,null)),a.createElement(Ul.d,{default:!0},a.createElement(_m.O,null,a.createElement(Qre.u,{hasNextPage:d,onRequestNextPage:v},b.map((e=>{let t=e.data,n=e.key;return a.createElement("div",{key:n},n&&a.createElement(Doe,null,n),t.map((e=>a.createElement(Eoe,Object.assign({key:e.id},e,{markAsRead:E,dismissActivity:y})))))})))))))},Soe=(0,u.default)(Xl.AM).withConfig({displayName:"NotificationCenter__Root",componentId:"bcagdw-0"})(["width:min(100vw,450px);overflow:hidden;max-height:min(calc(100vh - 100px),800px);"]),Noe=(0,u.default)(m.g).withConfig({displayName:"NotificationCenter__Header",componentId:"bcagdw-1"})(["padding:"," ",";align-items:center;justify-content:space-between;font-weight:",";font-size:",";border-bottom:1px solid ",";flex-shrink:0;"],vt.YK.small,vt.YK.default,vt.Wy.medium,vt.J.large,vt.Ee.color.divider.primary),Toe=(0,u.default)(m.g).attrs({center:!0,column:!0}).withConfig({displayName:"NotificationCenter__LoadingContainer",componentId:"bcagdw-2"})(["padding:"," 0;"],vt.YK.xlarge),_oe=(0,u.default)(su.U).withConfig({displayName:"NotificationCenter__DefaultAsyncButton",componentId:"bcagdw-3"})(["",";"],wt.CB),Doe=(0,$d.s)(H3.X)(Ioe||(Ioe=(0,wc.A)(["px-sm py-xs"]))),Roe="sidebar-collapsed",Moe=()=>{const e=(()=>{var e,t,n;const a=(0,uQ.p)(du.WC,{cacheExpiration:N.dw.fromObject({minutes:10})});return[null!==(n=null===(t=null===(e=null===a||void 0===a?void 0:a.data)||void 0===e?void 0:e.me)||void 0===t?void 0:t.hasNewActivity)&&void 0!==n&&n,a]})(),t=(0,o.A)(e,1)[0],n=(0,i.n)(du.DV),l=(0,o.A)(n,1)[0];return a.createElement(a.Fragment,null,a.createElement(Qi.Az,{placement:"bottom-start",overlay:a.createElement(Qi.j7,null,a.createElement(koe,null))},(e=>{let n=e.toggleOpen,r=e.isOpen;return a.createElement(Loe,{onClick:()=>{r||(0,Ge.u4)(Ye.j4.NotificationCenterOpened),t&&l(),n()},isOpen:r,icon:"bell",size:"small",active:r},t&&a.createElement(Ooe,null))})),t&&a.createElement(Poe,null))},Loe=(0,u.default)(B.L).withConfig({displayName:"NotificationCenterButton__Button",componentId:"qnc46m-0"})(["position:relative;color:",";."," &{display:none;}"],vt.Ee.color.content.secondary,Roe),Ooe=u.default.div.attrs({"data-testid":"unread-indicator"}).withConfig({displayName:"NotificationCenterButton__UnreadIndicator",componentId:"qnc46m-1"})(["width:",";height:",";background:",";border-radius:",";position:absolute;top:6px;right:6px;border:2px solid ",";"],(e=>e.theme.spacing.small),(e=>e.theme.spacing.small),(e=>e.theme.color.red),(e=>e.theme.radius.round),vt.Ee.color.background.page),Poe=(0,u.default)(Ooe).withConfig({displayName:"NotificationCenterButton__UnreadIndicatorSidebarCollapsed",componentId:"qnc46m-2"})(["top:",";left:calc(var(--sidebar-collapsed-width) - var(--spacing-sm));display:none;."," &{display:block;}"],vt.YK.xsmall,Roe),Boe=e=>{var t,n;return null!==(t=null===(n=e.split("/settings/")[1])||void 0===n?void 0:n.split("/")[0])&&void 0!==t?t:""},zoe=(e,t)=>{var n;const a=Boe(t);if(!a)return;const l=e.flatMap((e=>e.items)).find((e=>{let t=e.route;return Boe(t)===a}));return l&&(null!==(n=l.standaloneLabel)&&void 0!==n?n:l.label).replace(/\s+settings$/i,"")},Foe=function(){let e=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}).trackImpression,t=void 0!==e&&e;const n=(0,l.zy)().pathname,a=(0,G.U)("only screen and (max-width: ".concat(yD.w.breakPoints.md,"px)")),r=(0,on.u)("exp-settings-breadcrumbs-web","ca",{isAnonymous:!1,trackImpression:t&&a}),o=r.isVariant,i=r.isSplitReady,s=Boe(n);return{isVariant:o&&a,isResolved:i,isHub:!s,section:s}};var Goe=n(37314);const Yoe=()=>{const e=(0,E.wA)(),t=(0,d.d4)(ft.fm),n=Foe().isVariant;return(0,a.useCallback)((()=>{n&&t&&e((0,Goe.YO)())}),[e,t,n])};var Uoe,Voe=n(69631);const Woe=e=>{let t=e.onOpenSearch;const n=(0,E.wA)(),r=(0,l.zy)().pathname,o=(0,d.d4)(A.fm),i=(0,d.d4)(A.UF),s=Foe().isVariant,c=Yoe();return a.createElement(a.Fragment,null,a.createElement(Hoe,{to:I.JZ.dashboard()},a.createElement(Xre.C,{size:28,label:"Monarch home"})),i&&a.createElement(P.D_,{content:a.createElement(joe,{text:"Search",keys:["mod+k"]}),place:"bottom"},a.createElement(Koe,{icon:"search",size:"small",onClick:t})),a.createElement(Moe,null),i&&a.createElement(Koe,{icon:"settings",size:"small",linkTo:s?I.JZ.settings():I.JZ.settings.profile(),onClick:c,active:(0,ma.gQ)(r,I.JZ.settings())}),i&&a.createElement(P.D_,{content:a.createElement(joe,{text:o?"Collapse":"Pin",keys:["["]}),place:"bottom"},a.createElement(qoe,{icon:"sidebar",size:"small",onClick:()=>n((0,g.YO)())})))},joe=e=>{let t=e.text,n=e.keys;return a.createElement(Zoe,{"data-external-id":"tooltip-content"},a.createElement($oe,null,t),a.createElement(Voe.a,{variant:"outline",keys:n}))},Hoe=e=>{let t=e.to,n=e.children,r=e["aria-label"];return a.createElement("div",{"data-external-id":"header-link",className:"ml-3xs flex flex-1 items-center"},a.createElement(l.k2,{className:"inline-flex rounded-sm text-inherit [&&]:focus-visible:outline-offset-0",to:t,"aria-label":r},n))},Koe=(0,$d.s)(B.L)(Uoe||(Uoe=(0,wc.A)(["text-content-secondary"]))),qoe=Koe,$oe=(0,u.default)(xt.v).attrs({weight:"medium"}).withConfig({displayName:"SideBarDefaultHeader__TooltipText",componentId:"xcuyqd-0"})(["margin-right:",";"],(e=>e.theme.spacing.xsmall)),Zoe=u.default.div.withConfig({displayName:"SideBarDefaultHeader__TooltipContentContainer",componentId:"xcuyqd-1"})(["display:flex;align-items:center;padding:6px ",";"],(e=>e.theme.spacing.xsmall)),Joe=()=>{const e=(0,d.wA)(),t=(0,d.d4)(A.UF);return a.createElement(a.Fragment,null,a.createElement(Hoe,{to:I.JZ.advisorPortal.clients(),"aria-label":"Monarch Professional home"},a.createElement(Xoe,null,a.createElement(Xre.C,{size:28}),a.createElement(Qoe,null),a.createElement(eie,null,"Professional"))),t&&a.createElement(qoe,{icon:"sidebar",size:"small",onClick:()=>e((0,g.YO)())}))},Xoe=(0,u.default)(m.g).withConfig({displayName:"SideBarAdvisorPortalHeader__LogoContainer",componentId:"sc-4df41q-0"})(["align-items:center;gap:",";"],vt.YK.xsmall),Qoe=u.default.div.withConfig({displayName:"SideBarAdvisorPortalHeader__Separator",componentId:"sc-4df41q-1"})(["width:1px;height:16px;background-color:",";."," &{display:none;}"],vt.Ee.color.divider.secondary,Roe),eie=(0,u.default)(xt.v).withConfig({displayName:"SideBarAdvisorPortalHeader__Title",componentId:"sc-4df41q-2"})(["font-weight:",";font-size:",";color:",";."," &{display:none;}"],vt.Wy.medium,vt.J.small,vt.Ee.color.content.secondary,Roe);var tie=n(3569),nie=n.n(tie),aie=n(3626),lie=n(63203);const rie=e=>{var t,n,r,o,i;let s=e.data;const c=(0,l.Zp)(),d=s.trialEndsAt,u=s.trialDurationDays,p=s.trialType,g=s.entitlements,h=s.plusTrialEndsAt,v=!!h&&(null!==(t=(0,Q8.sX)(h))&&void 0!==t?t:0)>0,f=v?null!==(n=(0,Q8.sX)(h))&&void 0!==n?n:0:null!==(r=(0,Q8.sX)(d))&&void 0!==r?r:0,E=(v?(0,Q8.jo)(null!==(o=(0,Q8.sX)(s.plusTrialEndsAt))&&void 0!==o?o:0,u):(0,Q8.jo)(null!==(i=(0,Q8.sX)(d))&&void 0!==i?i:0,u))*lie.I6,y=p===Ee.tvk.G
1UEST_PASS,b=g.includes(Ee.nQu.PREMIUM_PLUS_TRIAL)||g.includes(Ee.nQu.PREMIUM_PLUS),x=()=>c(I.JZ.settings.billing());return a.createElement(oie,{"data-external-id":"free-trial-duration-panel",onClick:x},a.createElement(m.g,{alignCenter:!0,justifyBetween:!0,full:!0},y?a.createElement(m.g,{alignCenter:!0},a.createElement(sie,null),a.createElement(xt.v,{weight:"medium",size:"small"},aie.x[Ee.tvk.GUEST_PASS])):a.createElement(xt.v,{weight:"medium",size:"small"},"".concat(aie.x[null!==p&&void 0!==p?p:Ee.tvk.PREMIUM]).concat(b?" (Plus)":"")),a.createElement(iie,null,"".concat(null!==f&&void 0!==f?f:"-"," ").concat(nie()("days",null!==f&&void 0!==f?f:0)," left"))),a.createElement(fe.cqk,{value:E,color:f<=3?"progress-warning":"progress-success",className:"mt-xs shrink-0"}),!f&&a.createElement(cie,{onClick:x},"Subscribe ",a.createElement(sl.ZQ,{name:"chevron-right",size:12})))},oie=u.default.div.withConfig({displayName:"FreeTrialDurationPanel__Root",componentId:"sc-1hdmus3-0"})(["display:flex;flex-direction:column;padding:",";background-color:",";border-radius:",";cursor:pointer;",";"],vt.YK.small,vt.Ee.color.background.primary,(e=>e.theme.radius.small),wn.M.medium),iie=(0,u.default)(xt.v).withConfig({displayName:"FreeTrialDurationPanel__SecondaryText",componentId:"sc-1hdmus3-1"})(["font-weight:",";font-size:",";opacity:0.7;"],(e=>e.theme.fontWeight.medium),(e=>e.theme.fontSize.xsmall)),sie=(0,u.default)(sl.ZQ).attrs({name:"gift"}).withConfig({displayName:"FreeTrialDurationPanel__GiftIcon",componentId:"sc-1hdmus3-2"})(["font-size:",";margin-right:",";"],(e=>e.theme.fontSize.base),(e=>e.theme.spacing.xsmall)),cie=(0,u.default)(bn.v).withConfig({displayName:"FreeTrialDurationPanel__StyledTextButton",componentId:"sc-1hdmus3-3"})(["margin-top:",";justify-content:flex-start;padding-left:0;color:",";"],vt.YK.xsmall,vt.Ee.color.content.info);rie.fragments={daysLeftOfTrial:Ee.ffc};const die=["children"],uie=e=>{let t=e.children,n=(0,En.A)(e,die);return a.createElement(JY.d,Object.assign({"data-external-id":"deprecated-click-triggered-tooltip",delayHide:1e3,event:"click",eventOff:"mouseleave"},n),t)};var mie=n(98800);const pie=e=>{let t=e.color,n=e.href,l=e.title,r=e.icon,o=e.platform,i=e.sharedFrom;return a.createElement("a",{"data-external-id":"share-link-item",href:n,target:"_blank",rel:"noopener noreferrer",onClick:()=>(0,Ge.u4)(Ye.JW.Shared,(0,U.A)({method:o},i&&{sharedFrom:i})),style:{width:"100%"}},a.createElement(vie,{withTitle:!!l},a.createElement("div",{className:"flex gap-sm"},t?a.createElement(gie,{color:t,size:24},r):r,l&&a.createElement(fie,null,l)),l&&a.createElement(hie,null,a.createElement(mie.FiArrowRight,{size:24}))))},gie=(0,u.default)(m.g).attrs({center:!0}).withConfig({displayName:"ShareLinkItem__IconBox",componentId:"sc-1qigqs2-0"})(["background-color:",";flex-shrink:0;width:24px;height:24px;border-radius:",";"],(e=>e.color),vt.r8.small),hie=(0,u.default)(m.g).attrs({"data-sc-tw":"ShareLinkItem__ArrowContainer",justifyEnd:!0}).withConfig({displayName:"ShareLinkItem__ArrowContainer",componentId:"sc-1qigqs2-1"})(["transition:all 0.1s ease-in-out;color:",";flex-grow:1;"],vt.yW.gray),vie=(0,u.default)(m.g).attrs({alignCenter:!0,justifyStart:!0}).withConfig({displayName:"ShareLinkItem__ShareLinkRoot",componentId:"sc-1qigqs2-2"})(["background-color:",";padding:",";gap:",";border-radius:",";justify-content:",";color:",";cursor:pointer;transition:",";&:hover{background-color:",";[data-sc-tw~='ShareLinkItem__ArrowContainer']{transform:translateX(3px);color:",";}}&:active{background-color:",";}"],vt.Ee.color.background.secondary,vt.YK.large,vt.YK.xlarge,vt.r8.medium,(e=>e.withTitle?"flex-start":"center"),vt.yW.text,(e=>e.theme.transition.createDefaultTransition(["background-color"])),vt.Ee.color.background.secondaryHover,(e=>e.theme.color.textLight),vt.Ee.color.background.tertiaryHover),fie=(0,u.default)(xt.v).withConfig({displayName:"ShareLinkItem__TitleText",componentId:"sc-1qigqs2-3"})(["transition:",";"],(e=>e.theme.transition.createDefaultTransition(["color"]))),Eie=(e,t)=>"".concat(t,"/referral/").concat(e),yie=(e,t)=>"".concat(e).concat(e.includes("?")?"&":"?","r_source=").concat(t),bie=e=>{const t=_t.rF.SHARE_TWEET_BODY(e);return"https://x.com/intent/tweet?text=".concat(encodeURIComponent(t))},xie=e=>"http://www.linkedin.com/shareArticle?mini=true&url=".concat(encodeURIComponent(e)),wie=e=>{const t=_t.rF.GENERAL_SHARE_SUBJECT,n="".concat(_t.rF.GENERAL_SHARE_BODY," ").concat(e);return"mailto:?subject=".concat(encodeURIComponent(t),"&body=").concat(encodeURIComponent(n))},Cie=e=>{const t="".concat(_t.rF.GENERAL_SHARE_BODY," ").concat(e);return"sms:?body=".concat(encodeURIComponent(t))},Aie=e=>{let t=e.className,n=e.isCentered,l=e.isSidebarExpanded,r=e.referralUrl;const o=(0,u.useTheme)(),i=n?"modal":"screen";return a.createElement(Die,{"data-external-id":"share-link-section",className:t,isCentered:n,column:n,justifyCenter:n},a.createElement(Iie,{isCentered:n},a.createElement("div",{className:(0,q.cn)("flex flex-col gap-sm",n&&"items-center")},a.createElement("div",{className:"flex flex-col gap-xs"},a.createElement(kie,null,_t.rF.SHARE_LINK.HEADLINE),a.createElement(Sie,{isCentered:n},_t.rF.SHARE_LINK.SUB_HEADLINE))),a.createElement("div",null,a.createElement(uie,{content:"Copied",afterShow:()=>{(0,Bd.l)(yie(r,"copy")),(0,Ge.u4)(Ye.JW.Shared,{method:"copy",sharedFrom:i}),(0,Ge.u4)(Ye.JW.ModalLinkCopied,{sharedFrom:i})},place:"top"},a.createElement(cu.WT,{size:"medium"},a.createElement(Yo.r,{name:"copy"}),a.createElement("span",null,_t.rF.SHARE_LINK.COPY_BUTTON_TEXT)))),a.createElement(Rie,{isCentered:n},_t.rF.SHARE_LINK.DISCLAIMER_PLUS_TIER," ",a.createElement(cl.M,{href:VF.rj,target:"_blank",rel:"noopener noreferrer"},"Terms apply."))),a.createElement(Nie,{isCentered:n,isSidebarExpanded:l},a.createElement(pie,{icon:a.createElement(Tie,{name:"message-circle"}),title:"Share via text",color:o.color.green9,href:yie(Cie(r),"text"),platform:"text",sharedFrom:i}),a.createElement(pie,{icon:a.createElement(Tie,{name:"mail"}),title:"Share via email",color:o.color.orange,href:yie(wie(r),"email"),platform:"email",sharedFrom:i}),a.createElement("div",{className:"flex gap-xs"},a.createElement(pie,{icon:a.createElement(_ie,{name:"monarch-facebook-logo"}),href:yie((s=r,"https://www.facebook.com/sharer/sharer.php?u=".concat(s,"&quote=").concat(encodeURIComponent(_t.rF.GENERAL_SHARE_BODY))),"facebook"),platform:"facebook",sharedFrom:i}),a.createElement(pie,{icon:a.createElement(_ie,{name:"monarch-linkedin-logo"}),href:yie(xie(r),"linkedin"),platform:"linkedin",sharedFrom:i}),a.createElement(pie,{icon:a.createElement(_ie,{name:"monarch-x-logo"}),href:yie(bie(r),"x"),platform:"x",sharedFrom:i}))));var s},Iie=(0,u.default)(m.g).attrs({column:!0,gap:"xlarge",justifyCenter:!0}).withConfig({displayName:"ShareLinkSection__Messaging",componentId:"s64p34-0"})(["flex:1;align-items:",";"],(e=>e.isCentered?"center":"flex-start")),kie=(0,u.default)(xt.v).attrs({weight:"medium",size:"xlarge"}).withConfig({displayName:"ShareLinkSection__Headline",componentId:"s64p34-1"})(["display:block;"]),Sie=(0,u.default)(xt.v).attrs({size:"base",color:"content.secondary"}).withConfig({displayName:"ShareLinkSection__SubHeadline",componentId:"s64p34-2"})(["",""],(e=>e.isCentered?(0,u.css)(["max-width:","px;"],370):(0,u.css)(["max-width:none;@media (max-width:1800px){max-width:460px;}@media (max-width:1500px){max-width:370px;}"]))),Nie=(0,u.default)(m.g).attrs({column:!0,gap:"xsmall",justifyCenter:!0}).withConfig({displayName:"ShareLinkSection__ShareButtons",componentId:"s64p34-3"})(["",""],(e=>{let t=e.isCentered,n=e.isSidebarExpanded,a=e.theme;return t?(0,u.css)(["width:100%;max-width:","px;align-self:center;"],370):(0,u.css)(["flex:1;max-width:352px;@media (max-width:","px){max-width:none;}"],n?a.breakPoints.lg:a.breakPoints.sm)})),Tie=(0,u.default)(sl.ZQ).attrs({size:16}).withConfig({displayName:"ShareLinkSection__StyledBoxIcon",componentId:"s64p34-4"})(["color:",";transform:translateX(0.5px);"],vt.Ee.color.content.white),_ie=(0,u.default)(sl.ZQ).attrs({size:24}).withConfig({displayName:"ShareLinkSection__StyledLogoIcon",componentId:"s64p34-5"})(["border-radius:",";"],vt.r8.small),Die=(0,u.default)(m.g).withConfig({displayName:"ShareLinkSection__Container",componentId:"s64p34-6"})(["text-align:",";"],(e=>e.isCentered?"center":"left")),Rie=(0,u.default)(xt.v).attrs({size:"xsmall",color:"input.placeholder"}).withConfig({displayName:"ShareLinkSection__DisclaimerText",componentId:"s64p34-7"})(["",""],(e=>e.isCentered&&"max-width: 266px;"));var Mie=n(61421);const Lie=()=>{const e=(0,xq.bO)("hasHiddenReferralProgramPrompts"),t=(0,o.A)(e,3),n=t[0],l=(t[1],t[2]);return n||l?null:a.createElement(Oie,{"data-external-id":"referral-link-button"})},Oie=()=>{const e=(0,l.zy)(),t=(0,P6.f)().referralCode,n=null!==t&&void 0!==t?t:"",r=(0,a.useMemo)((()=>Eie(n,(0,Mie.v)("landing"))),[n]),i=(0,Pd.h)(),s=(0,o.A)(i,2),c=s[0],d=s[1],u=d.open,p=d.close,g=I.JZ.settings.referrals(),h=(0,a.useCallback)((()=>{p(),(0,Ge.u4)(Ye.JW.ButtonClicked,{source:"modal"})}),[p]),v=(0,a.useCallback)((()=>{u(),(0,Ge.u4)(Ye.JW.ButtonClicked,{source:"sidebar"}),(0,Ge.u4)(Ye.JW.ModalViewed,{source:"sidebar"})}),[u]),f=e.pathname===I.JZ.settings.referrals()?{to:g}:{onClick:v};return a.createElement(a.Fragment,null,a.createElement(Pie,Object.assign({iconName:"heart"},f,{style:{paddingRight:"6px"}}),a.createElement("span",{style:{whiteSpace:"normal"}},_t.rF.NAVIGATION_CALLOUT)),a.createElement(c,null,a.createElement(Rc.L,{hideBottomBorder:!0},a.createElement(Bie,null,a.createElement(zie,{referralUrl:r,isCentered:!0}),a.createElement(m.g,{column:!0,gap:"default",alignCenter:!0},a.createElement(Vl.W,{onClick:h,to:g},"Learn more"),a.createElement(Vl.W,{onClick:h,to:g},"Track your referrals"))))))},Pie=(0,u.default)(Vre).withConfig({displayName:"ReferralLinkButton__SecondaryNavBarLink",componentId:"sc-1xa6tr2-0"})(["color:",";height:auto;min-height:var(--sidebar-button-height);align-items:flex-start;[data-sc-tw~='LinkIcon__LinkIcon']{height:1.5rem;}"],vt.Ee.color.content.secondary),Bie=(0,u.default)(m.g).attrs({column:!0}).withConfig({displayName:"ReferralLinkButton__ModalContent",componentId:"sc-1xa6tr2-1"})(["padding:0 "," ",";gap:",";text-align:center;"],vt.YK.xlarge,vt.YK.xxxlarge,vt.YK.xxlarge),zie=(0,u.default)(Aie).withConfig({displayName:"ReferralLinkButton__StyledShareLinkSection",componentId:"sc-1xa6tr2-2"})(["gap:",";"],vt.YK.xxlarge),Fie=e=>{let t=e.items;const n=(0,l.Zp)(),r=(0,l.zy)(),o=(0,d.d4)(A.UF),i=t.filter((e=>!1!==e.isVisible)),s=i.some((e=>{var t;return(0,ma.gQ)(r.pathname,null===(t=pa.EC[e.name])||void 0===t?void 0:t.route)})),c=pa.EC.More.icon;return a.createElement(Qi.Az,{"data-external-id":"side-bar-more-menu",overlay:a.createElement(Ji.SP,null,i.map((e=>{const t=pa.EC[e.name],l="label"in t&&t.label?t.label:e.name;return a.createElement(Ji.xm,{key:e.name,icon:t.icon,onClick:()=>n(t.route)},l)}))),placement:"bottom-start"},(e=>{let t=e.toggleOpen;return a.createElement(Uie,{onClick:t,$isActive:s},a.createElement(Ore,null,a.createElement(Gie,{name:c}
1)),a.createElement(Yie,{$isSidebarExpanded:o},"More"))}))},Gie=(0,u.default)(sl.ZQ).attrs({size:16}).withConfig({displayName:"SideBarMoreMenu__NavIcon",componentId:"sas0u-0"})([""]),Yie=u.default.span.withConfig({displayName:"SideBarMoreMenu__Title",componentId:"sas0u-1"})(["",""],(e=>!e.$isSidebarExpanded&&"display: none;")),Uie=u.default.div.withConfig({displayName:"SideBarMoreMenu__Container",componentId:"sas0u-2"})(["cursor:pointer;color:",";display:flex;align-items:center;padding:"," ",";height:var(--sidebar-button-height);transition:",";border-radius:",";&:hover{background-color:",";}",""],vt.yW.text,vt.YK.xsmall,vt.YK.small,(e=>e.theme.transition.default),(e=>e.theme.radius.small),vt.yW.gray4,(e=>e.$isActive&&"\n    opacity: 1;\n    background-color: ".concat(vt.yW.gray4,";\n  ")));var Vie=n(68154),Wie=n(94191),jie=n(10528),Hie=n(7672);const Kie=(0,u.default)(m.g).attrs({column:!0}).withConfig({displayName:"UpgradeFormPlanOption__Root",componentId:"sc-1wpic6q-0"})(["background:",";border-radius:",";border:1px solid ",";"," transition:",";padding:",";cursor:pointer;position:relative;",";",";"],(e=>e.theme.color.white),(e=>e.theme.radius.medium),(e=>e.theme.color.grayLight),wn.M.small,(e=>e.theme.transition.default),(e=>e.theme.spacing.default),(e=>e.$isSelected&&(0,u.css)(["border-color:",";background:",";"],(e=>e.theme.color.orange),(e=>e.theme.color.orangeBackground))),(e=>e.$isDisabled&&(0,u.css)(["background:",";border:solid 1px ",";cursor:not-allowed;"],(e=>e.theme.color.grayBackground),(e=>e.theme.color.grayLight)))),qie=(0,u.default)(xt.v).attrs({size:"small"}).withConfig({displayName:"UpgradeFormPlanOption__Subtitle",componentId:"sc-1wpic6q-1"})(["margin-top:",";"],(e=>e.theme.spacing.xxsmall)),$ie=(0,u.default)(xt.v).attrs({size:"xxsmall"}).withConfig({displayName:"UpgradeFormPlanOption__SubsequentBilling",componentId:"sc-1wpic6q-2"})(["margin-top:",";"],(e=>e.theme.spacing.xxsmall)),Zie=u.default.div.withConfig({displayName:"UpgradeFormPlanOption__PromoBadge",componentId:"sc-1wpic6q-3"})(["position:absolute;top:0;right:0;text-transform:uppercase;color:",";background:",";padding:"," ",";font-size:11px;line-height:15px;font-weight:",";border-radius:0px 7px 0px 4px;"],(e=>e.theme.color.textWhite),(e=>{let t=e.theme;return"orange"===e.color?t.color.orange:t.color.black}),(e=>e.theme.spacing.xxsmall),(e=>e.theme.spacing.xsmall),(e=>e.theme.fontWeight.bold)),Jie=(0,u.default)(xt.v).withConfig({displayName:"UpgradeFormPlanOption__StrikeThroughText",componentId:"sc-1wpic6q-4"})(["text-decoration:line-through;color:",";margin-right:",";"],(e=>e.theme.color.textLight),(e=>e.theme.spacing.xsmall));var Xie=n(39124);const Qie=u.default.div.withConfig({displayName:"SubscriptionModalAnnualUpsellBody__CardBody",componentId:"cxblkj-0"})(["padding:",";"],(e=>e.theme.spacing.large)),ese=(0,u.default)(m.g).withConfig({displayName:"SubscriptionModalAnnualUpsellBody__Footer",componentId:"cxblkj-1"})(["margin-top:",";color:",";font-size:",";"],(e=>e.theme.spacing.large),(e=>e.theme.color.textLight),(e=>e.theme.fontSize.xsmall)),tse=(0,u.default)(su.U).withConfig({displayName:"SubscriptionModalAnnualUpsellBody__SubmitButton",componentId:"cxblkj-2"})([""," width:100%;margin-top:",";"],cu.vc,(e=>e.theme.spacing.small)),nse=u.default.div.withConfig({displayName:"SubscriptionModalAnnualUpsellBody__SubscriptionSection",componentId:"cxblkj-3"})(["display:flex;flex-direction:column;"]),ase=u.default.p.withConfig({displayName:"SubscriptionModalAnnualUpsellBody__Subtitle",componentId:"cxblkj-4"})(["margin:0;padding:0 ",";color:",";font-size:",";font-weight:",";line-height:150%;"],(e=>e.theme.spacing.large),(e=>e.theme.color.text),(e=>e.theme.fontSize.base),(e=>e.theme.fontWeight.book)),lse=(0,u.default)((e=>{let t=e.price,n=e.discountedPrice,l=e.period,r=e.duration,o=e.durationInMonths,i=e.isSelected,s=e.onClick,c=e.promoBadgeText,d=e.className,u=e.disabled,m=void 0!==u&&u,p=e.hideStrikethroughPrice,g=void 0!==p&&p,h=e.planTier,v=e.page;const f=null!==n&&void 0!==n?n:t,E=(0,a.useMemo)((()=>{switch(l){case Ee.YHE.MONTHLY:return{subtitle:"".concat((0,rl.vv)(f*iC.Sf)," per year, billed monthly"),priceInUsd:"".concat((0,rl.vv)(f)," / month")};case Ee.YHE.YEARLY:return{subtitle:"".concat((0,rl.vv)(f)," per year, billed yearly"),priceInUsd:"".concat((0,rl.vv)(f/iC.Sf)," / month")};case Ee.YHE.LIFETIME:return{subtitle:"Lifetime, billed once",priceInUsd:(0,rl.vv)(f)};default:return{subtitle:"",priceInUsd:""}}}),[f,l]),y=E.subtitle,b=E.priceInUsd,x=(0,a.useMemo)((()=>{switch(r){case Ee.mRw.FOREVER:return;case Ee.mRw.ONCE:return n?"Subsequent periods will be billed at the regular rate.":void 0;case Ee.mRw.REPEATING:return n?"Valid for ".concat(o," months. Subsequent periods will be billed at the regular rate."):void 0;default:return}}),[f,r,o,l]);return a.createElement(Kie,{"data-external-id":"upgrade-form-plan-option",$isDisabled:m,$isSelected:i,onClick:()=>{m||(ij.Ay.planOptionSelected({plan:l,plan_tier:h,page:v}),null===s||void 0===s||s())},className:d},a.createElement("div",{className:"flex"},a.createElement(xt.v,{weight:"medium"},b)),a.createElement(qie,null,(0,Tr.A)(n)&&!g&&a.createElement(Jie,null,(0,rl.vv)(t)),y),x&&a.createElement($ie,null,x),!!c&&a.createElement(Zie,{color:"orange"},c),l===Ee.YHE.LIFETIME&&a.createElement(Zie,{color:"black"},"BEST VALUE"))})).withConfig({displayName:"SubscriptionModalAnnualUpsellBody__StyledPlanOption",componentId:"cxblkj-5"})(["margin-bottom:",";"],(e=>e.theme.spacing.small)),rse=(0,u.default)(xt.v).withConfig({displayName:"SubscriptionModalAnnualUpsellBody__BilledThroughText",componentId:"cxblkj-6"})(["color:",";font-weight:",";text-align:center;margin-top:",";"],(e=>e.theme.color.textLight),(e=>e.theme.fontWeight.medium),(e=>e.theme.spacing.default)),ose=e=>{let t=e.hasPremiumEntitlement,n=e.willCancelAtPeriodEnd,r=e.plans,o=e.promoCodeDescription,i=e.promoCodeDuration,s=e.promoCodeDurationInMonths,c=e.hasPaymentMethod,d=e.paymentMethod,u=e.paymentSource,m=e.isLoading,p=e.setLoading,g=e.setNotLoading,h=e.appliedPromoCode,v=e.changeSubscription,f=e.createSubscription,E=e.reactivateSubscription,y=e.hasStripeSubscriptionId,b=e.onDone;const x=(0,l.Zp)(),w=r.find((e=>e.period===Ee.YHE.YEARLY)),C=u===Ee.vtX.STRIPE?"Subscribed with ".concat((0,Xie._M)(d,((e,t)=>"".concat((0,Wie.capitalCase)(e)," ending in ").concat(t)))):u||"";return a.createElement(a.Fragment,null,a.createElement(ase,null,"Your monthly fee will be adjusted based on your unused time, which will be applied to your annual subscription."),a.createElement(Qie,null,a.createElement(nse,null,r.map(((e,t)=>{let n=e.pricePerPeriodDollars,l=e.discountedPricePerPeriodDollars,o=e.period;return a.createElement(lse,{key:t,price:n,discountedPrice:l,duration:i,durationInMonths:s,peri
1od:o,isSelected:o===Ee.YHE.YEARLY,promoBadgeText:(0,Q8.EX)(r,o),disabled:o===Ee.YHE.MONTHLY})}))),a.createElement(jie.q,{skipPaymentMethod:!0,onSuccess:async e=>{if(w){const a=c||(0,Tr.A)(e);p();try{const l=o?h:null;if(t)if(n)if(a&&y)await E(e,w,l,"annual_upsell_modal");else{if(!a&&null!==w&&void 0!==w&&w.requirePaymentMethod)throw Error("No card entered! Something is wrong with the given subscription");await f(e,w,l,null,!1,"annual_upsell_modal")}else await v(w,l,"annual_upsell_modal");else x(I.JZ.settings.billing.subscribe())}finally{g()}b()}}},(e=>{let t=e.isValid,n=e.isLoading;return a.createElement(a.Fragment,null,a.createElement(ese,{column:!0},a.createElement(tse,{size:"large",disabled:!t,type:"submit",pending:n||m},"Switch to yearly"),a.createElement(rse,null,C)))}))))},ise=e=>a.createElement(Hie.l,{"data-external-id":"provider-wrapper"},a.createElement(ose,e));var sse=n(58153);const cse=e=>{var t;let n=e.onDone,l=e.changeSubscription,r=e.createSubscription,i=e.reactivateSubscription,s=e.title;const c=(0,d.d4)(sse.kV),u=(0,a.useState)(null),m=(0,o.A)(u,2),p=m[0],g=m[1],h=(0,E.pE)("promo-code"),v=(0,Pc.e)(!1),f=(0,o.A)(v,2),y=f[0],b=f[1],x=b.setOn,w=b.setOff,C=(0,Xo.IT)(Vie.FS,{variables:{promoCode:p||null}}).data,A=(null!==(t=null===C||void 0===C?void 0:C.subscription)&&void 0!==t?t:{}).paymentMethod,I=(0,Tr.A)(A);return(0,a.useEffect)((()=>{(h||c)&&g(h||(null!==c&&void 0!==c?c:null))}),[h]),a.createElement(Rc.L,{"data-external-id":"subscription-modal-annual-upsell",title:s,hideBottomBorder:!0},C?(()=>{const e=C.subscription,t=e.paymentSource,o=e.paymentMethod,s=e.hasStripeSubscriptionId,c=e.hasPremiumEntitlement,d=e.willCancelAtPeriodEnd,u=C.subscriptionOffering,m=u.plans,g=u.promoCodeDescription,h=u.promoCodeDuration,v=u.promoCodeDurationInMonths;return a.createElement(ise,{hasPremiumEntitlement:c,willCancelAtPeriodEnd:d,plans:m,createSubscription:r,reactivateSubscription:i,promoCodeDescription:g,promoCodeDuration:h,promoCodeDurationInMonths:v,hasPaymentMethod:I,paymentMethod:o,paymentSource:t,isLoading:y,setLoading:x,setNotLoading:w,appliedPromoCode:p,changeSubscription:l,hasStripeSubscriptionId:s,onDone:n})})():null)};var dse=n(76350),use=n(97582),mse=n(88626);const pse=e=>{let t=e.closeAnnualUpsellModal;const n=(0,use.H)().createSubscription,r=(0,mse.l)().reactivateSubscriptionWithPriceId,o=(0,dse.f)().changeSubscription,i=(0,l.Zp)();return a.createElement(cse,{"data-external-id":"annual-upsell-modal-card",title:"Switch to yearly and save",changeSubscription:o,createSubscription:n,reactivateSubscription:r,onDone:()=>{t(),i(I.JZ.settings.billing())}})},gse=e=>{let t=e.plans;const n=(0,nG.p)("ab-test-annual-upsell-web","on"),l=(0,nC.xd)(),r=(0,o.A)(l,1)[0],i=r.isCurrentUserOwner,s=r.isLoadingInitialData,c=(0,a.useMemo)((()=>{if(t){const e=t.find((e=>e.period===Ee.YHE.YEARLY)),n=t.find((e=>e.period===Ee.YHE.MONTHLY));if(e&&n){const t=e.pricePerPeriodDollars,a=n.pricePerPeriodDollars,l=100-Math.floor(t/(12*a)*100);return"Get ".concat(l,"% discount")}}return""}),[t]),d=(0,Pd.h)(),u=(0,o.A)(d,2),m=u[0],p=u[1],g=p.open,h=p.close;return n&&!s&&i?a.createElement(a.Fragment,null,a.createElement(hse,{onClick:()=>{g(),(0,Ge.u4)(Ye.A_.PurchaseUpsellAnnualButtonClicked)},iconName:"gift"},c),a.createElement(m,null,a.createElement(pse,{closeAnnualUpsellModal:h}))):a.createElement(hse,{"data-external-id":"sidebar-annual-upsell-button",to:I.JZ.settings.referrals(),onClick:()=>(0,Ge.u4)(Ye.JW.ButtonClicked),iconName:"gift"},"Get 1 Month Free")},hse=(0,u.default)(Vre).withConfig({displayName:"SidebarAnnualUpsellButton__SecondaryNavBarLink",componentId:"sc-11f7aox-0"})(["color:",";"],vt.Ee.color.content.secondary);var vse;const fse=e=>{let t=e.description,n=e.callToAction,l=e.image,r=e.onDismiss,o=e.onCheckItOut,i=e.eyebrowText,s=void 0===i?"What's New":i;e.persistent;const c=(0,u.useTheme)(),d=l&&B9(l,c);return a.createElement(kse,{"data-external-id":"whats-new-popup"},a.createElement(Lre.g,null,a.createElement(Ese,null,a.createElement(yse,null,a.createElement(xse,null,a.createElement(wse,null,s),a.createElement(Cse,{onClick:r,name:"x"})),a.createElement(bse,null,t),!!d&&a.createElement(Ise,{src:d})),a.createElement(Ase,{onClick:o},n," ",a.createElement(sl.ZQ,{name:"chevron-right",size:12})))))},Ese=(0,u.default)(ZY.B).attrs({column:!0}).withConfig({displayName:"WhatsNewPopup__WhatsNew",componentId:"sc-6c2y8a-0"})(["border-radius:",";padding:",";gap:",";background-color:",";",";."," &{display:none;}"],vt.r8.small,vt.YK.small,(e=>e.theme.spacing.xsmall),vt.Ee.color.background.primary,wn.M.medium,Roe),yse=(0,u.default)(ZY.B).attrs({column:!0}).withConfig({displayName:"WhatsNewPopup__Box",componentId:"sc-6c2y8a-1"})([""]),bse=(0,u.default)(xt.v).withConfig({displayName:"WhatsNewPopup__WhatsNewText",componentId:"sc-6c2y8a-2"})(["color:",";font-weight:",";font-size:",";margin:"," 0;"],(e=>e.theme.color.text),vt.Wy.book,(e=>e.theme.fontSize.small),(e=>e.theme.spacing.xxxsmall)),xse=(0,u.default)(ZY.B).attrs({row:!0,justifyBetween:!0,alignCenter:!0}).withConfig({displayName:"WhatsNewPopup__TopBox",componentId:"sc-6c2y8a-3"})(["margin-bottom:",";"],vt.YK.xxsmall),wse=(0,u.default)(xt.v).withConfig({displayName:"WhatsNewPopup__Subtitle",componentId:"sc-6c2y8a-4"})(["color:",";font-weight:",";font-size:",";text-transform:none;"],vt.Ee.color.content.secondary,(e=>e.theme.fontWeight.medium),vt.J.xsmall),Cse=(0,u.default)(sl.ZQ).attrs({size:16}).withConfig({displayName:"WhatsNewPopup__XIcon",componentId:"sc-6c2y8a-5"})(["color:",";font-weight:",";cursor:pointer;"],(e=>e.theme.color.textLight),(e=>e.theme.fontWeight.medium)),Ase=(0,$d.s)(bn.v)(vse||(vse=(0,wc.A)(["\n  justify-start truncate pl-0 text-content-info\n  hover:text-content-info-hover\n"]))),Ise=u.default.img.withConfig({displayName:"WhatsNewPopup__Image",componentId:"sc-6c2y8a-6"}
1)(["height:130px;width:100%;object-fit:contain;"]),kse=(0,u.default)(D.PY1.div).attrs({key:"whats-new-side-menu",initial:{opacity:0},transition:{duration:.2,ease:"easeOut"},animate:{opacity:1},exit:{opacity:0}}).withConfig({displayName:"WhatsNewPopup__AnimatedContainer",componentId:"sc-6c2y8a-7"})([""]);var Sse=n(55401);const Nse=()=>(0,nG.p)("feat-show-beta-messaging-goals-v3-web","on");var Tse=n(91339);const _se=a.createElement(c5.C,{color:"blue",size:"md"},"Beta"),Dse=e=>{var t,n;let r=e.subscription,i=e.subscriptionOffering,s=e.onSupportButtonClick,c=e.pendingStreamsCount,u=e.isSidebarExpanded;const m=(0,l.Zp)(),p=(0,l.zy)(),g=(0,Tse._)().isDemoHousehold,h=R9(),v=h.whatsNew,f=h.dismissWhatsNew,E=(0,a.useState)(!1),y=(0,o.A)(E,2),b=y[0],x=y[1];(0,a.useEffect)((()=>{x(!1)}),[null===v||void 0===v?void 0:v.feature]);const w=null!==r&&void 0!==r?r:{},C=w.paymentSource,A=w.billingPeriod,k=w.hasPremiumEntitlement,S=w.isOnFreeTrial,N=w.nextPaymentAmount,_=w.activeSponsorship,D=w.plusTrialEndsAt,R=!!w.canceledPlusTrialAt&&(null!==(t=(0,Q8.sX)(D))&&void 0!==t?t:0)>0,M=S||!!D&&(null!==(n=(0,Q8.sX)(D))&&void 0!==n?n:0)>0||R,L=!!_,O=(null!==i&&void 0!==i?i:{}).plans,P=(0,d.d4)(Od.T2),B=(0,F.K)(),G=(0,R3.F)().isOn,Y=(0,Sse.x)().isOn,U=Nse(),V=(0,d4.u)("feat-estate-planning","off").isOn,W=(0,ot.M)().isOn,j=(0,jY.mB)({trackImpression:!0}),H=j.isCashFlowSunsetOn,K=j.isResolved,q=(0,ht.S)().isAiFeaturesEnabled,$=u4(),Z=(0,l4.E)(),J=Z.isAdviceSunsetOn,X=Z.isResolved,Q=!!r&&!!k&&A===Ee.YHE.MONTHLY&&C===Ee.vtX.STRIPE&&!!N&&14.99===N,ee=p.pathname===I.JZ.goalsV2()||p.pathname===I.JZ.goals.savings()||p.pathname===I.JZ.goals.debtPaydown(),te=G&&U?_se:void 0,ne=c>0?a.createElement(c5.C,{color:"brand",variant:"solid",size:"md",preferCircle:!0},c):void 0,ae=Y?_se:void 0,le=$?_se:void 0,re=(0,z.h)().toggleAssistant,oe=q?a.createElement(It,{$fontWeight:"medium"},"AI Assistant"):"AI Assistant",ie=a.createElement(Mse,{iconName:"sparkles",onClick:()=>{B||re(Ye.rP.NavBar)},$disabled:!q,$rateLimited:B},oe),se=a.createElement(Rse,{iconName:"message-circle",onClick:s,color:"blue"},"Help & Support"),ce=a.createElement(Ul.w,null,a.createElement(Ul.d,{when:P},a.createElement(Rse,{to:I.JZ.advisorPortal.clients(),iconName:"users"},"Professional Portal")),a.createElement(Ul.d,{when:Q},a.createElement(gse,{plans:O})),a.createElement(Ul.d,{when:!Q},a.createElement(Lie,null)),a.createElement(Ul.d,{default:!0},null));return a.createElement(a.Fragment,null,a.createElement(Lre.g,null,a.createElement(Kre,{name:"Dashboard",end:!0}),W&&a.createElement(Kre,{name:"Assistant",end:!0,badge:_se}),a.createElement(Kre,{name:"Accounts"}),a.createElement(Kre,{name:"Transactions"}),a.createElement(uX,{name:"feat-paychecks-web",defaultOnTimeout:"off"},a.createElement(Kre,{name:"Paychecks"})),K&&!H&&a.createElement(Kre,{name:"Cash Flow"}),a.createElement(Kre,{name:"Reports"}),a.createElement(Kre,{name:"Budget"}),a.createElement(Kre,{name:"Recurring",badge:ne}),Y&&a.createElement(Kre,{name:"Recurring V2",badge:ae}),a.createElement(Kre,{name:G?"Savings Goals":"Goals",badge:te,isActive:ee}),a.createElement(Kre,{name:"Investments"}),!L&&a.createElement(Kre,{name:"Forecast"}),X&&!J&&!L&&!P&&a.createElement(Kre,{name:"Advice",iconNameOverride:$?"lightbulb":void 0,badge:le}),a.createElement(uX,{name:"feat-monarch-method-web",defaultOnTimeout:"off"},a.createElement(Kre,{name:"Monarch Method"})),V&&a.createElement(Fie,{items:[{name:"Protection"}]})),a.createElement(Lre.g,{grow:1}),a.createElement(Lse,null,a.createElement(T.N,null,!!v&&!b&&a.createElement(fse,{description:v.description,callToAction:v.callToAction,image:v.image,eyebrowText:v.eyebrowText,persistent:v.persistent,onDismiss:()=>{(0,Ge.u4)(Ye.SR.WhatsNewDismissed,v),f(),x(!0)},onCheckItOut:()=>{(0,Ge.u4)(Ye.SR.WhatsNewClicked,v),v.route.startsWith("http")?(window.open(v.route,"_blank"),f()):m(v.route)}})),M&&r&&!g&&u&&a.createElement(rie,{data:r})),a.createElement(Lre.g,null,!W&&ie,se,ce))},Rse=(0,u.default)(Vre).withConfig({displayName:"SideBarDefaultContent__SecondaryNavBarLink",componentId:"sc-17gy1v8-0"})(["color:",";"],vt.Ee.color.content.secondary),Mse=(0,u.default)(Vre).attrs((0,Ex.p)("sidebar-persistent-assistant")).withConfig({displayName:"SideBarDefaultContent__PersistentAssistantNavBarLink",componentId:"sc-17gy1v8-1"})(["color:",";cursor:",";opacity:",";[data-mds='icon']{"," color:",";}&:hover{color:",";[data-sc-tw~='AssistantGradient__AssistantGradientText']{","}[data-mds='icon']{","}}"],(e=>{let t=e.theme;return e.$disabled?t.variables.color.content.secondary:t.variables.color.background.brand}),(e=>{let t=e.$disabled,n=e.$rateLimited;return t||n?"not-allowed":"pointer"}),(e=>{let t=e.$disabled,n=e.$rateLimited;return t||n?.5:1}),(e=>!e.$disabled&&St),(e=>{let t=e.theme;return e.$disabled&&t.variables.color.content.secondary}),(e=>{let t=e.theme;return e.$disabled?t.variables.color.content.secondary:t.variables.color.background.brandHover}),(e=>{let t=e.$disabled,n=e.$rateLimited;return!t&&!n&&kt}),(e=>{let t=e.$disabled,n=e.$rateLimited;return!t&&!n&&Nt})),Lse=u.default.div.withConfig({displayName:"SideBarDefaultContent__PopupsContainer",componentId:"sc-17gy1v8-2"})(["display:flex;flex-direction:column;gap:",";padding-bottom:",";"],vt.YK.small,vt.YK.small),Ose=e=>
1{let t=e.title,n=e.subtitle,l=e.icon,r=e.onClick;return a.createElement(Fse,{"data-external-id":"deprecated-card-link",onClick:r},(0,Tr.A)(l)&&a.createElement(Pse,null,a.createElement(sl.ZQ,{name:l,size:19.2})),a.createElement(Gse,null,a.createElement(xt.v,{weight:"medium"},t),(0,Tr.A)(n)&&a.createElement(xt.v,{size:"small"},n)),a.createElement(zse,null,a.createElement(Bse,null)))},Pse=(0,u.default)(m.g).attrs({center:!0}).withConfig({displayName:"CardLink__IconCircle",componentId:"sc-15a5jom-0"})(["width:","px;height:","px;border-radius:50%;background-color:",";color:",";"],48,48,vt.yW.grayBackground,vt.yW.text),Bse=(0,u.default)(sl.ZQ).attrs({"data-sc-tw":"CardLink__ArrowIcon",name:"ArrowRight"}).withConfig({displayName:"CardLink__ArrowIcon",componentId:"sc-15a5jom-1"})(["width:","px;height:","px;transition:all 0.1s ease-in-out;color:",";"],24,24,vt.yW.gray),zse=(0,u.default)(m.g).attrs({justifyEnd:!0}).withConfig({displayName:"CardLink__ArrowContainer",componentId:"sc-15a5jom-2"})([""]),Fse=(0,u.default)(m.g).attrs({alignCenter:!0,justifyStart:!0}).withConfig({displayName:"CardLink__Root",componentId:"sc-15a5jom-3"})(["gap:",";padding:",";cursor:pointer;&:hover{[data-sc-tw~='CardLink__ArrowIcon']{transform:translateX(3px);color:",";}}"],vt.YK.default,vt.YK.xlarge,vt.yW.textLight),Gse=(0,u.default)(m.g).attrs({column:!0}).withConfig({displayName:"CardLink__Content",componentId:"sc-15a5jom-4"})(["flex:1;gap:",";"],vt.YK.xxsmall),Yse=e=>{let t=e.onClickContactSupport,n=e.onClickFeatureRequest,l=e.onClickHelpCenter,r=e.onClickRoadmap,o=e.onClickShareFeedback,i=e.onClickWhatsNew,s=e.isLoading;const c=(0,d4.u)("feat-voltron-feedback-web_mobile","off",{trackImpression:!0}).isOn;return a.createElement(Rc.L,{"data-external-id":"help-center-modal-card",title:"Help & Support"},s&&a.createElement("div",{className:"absolute inset-0 flex items-center justify-center px-default"},a.createElement(p.i,null)),a.createElement("div",{className:(0,q.cn)({invisible:s})},a.createElement(Ose,{title:"What's New",subtitle:"Catch up on the latest product improvements",onClick:i,icon:"zap"}),c?a.createElement(a.Fragment,null,a.createElement(Ose,{title:"Share feedback",subtitle:"Tell us what you'd like to be able to do",onClick:o,icon:"edit"}),a.createElement(Ose,{title:"Roadmap",subtitle:"What's planned, in progress, and recently launched",onClick:r,icon:"map"})):a.createElement(Ose,{title:"Feature Request",subtitle:"View our product roadmap and vote on features",onClick:n,icon:"map"}),a.createElement(wm.A,null),a.createElement(Ose,{title:"Help Center",subtitle:"Read more about how to fully utilize Monarch",onClick:l,icon:"book"}),a.createElement(p0,{feature:HQ.W1.CUSTOMER_SUPPORT},a.createElement(Ose,{title:"Contact Support",subtitle:"Get in touch with our customer success team",onClick:t,icon:"MessageCircle"}))))},Use=(0,Qt.J)("\n  query Common_GetProductboardCode {\n    productBoardToken\n  }\n");var Vse=n(65490);const Wse=()=>{const e=(()=>{const e=(0,uQ.p)(Use,{cacheExpiration:N.dw.fromObject({hours:1})}).data;return null===e||void 0===e?void 0:e.productBoardToken})();return a.createElement(Rc.L,{"data-external-id":"request-feature-modal-card",hideCloseButton:!0,hideHeader:!0},e&&a.createElement(jse,{title:"request-feature",src:"".concat((0,Vse.w)("REACT_APP_REQUEST_FEATURE_IFRAME_URL"),"?token=").concat(e),frameBorder:"0"}))},jse=u.default.iframe.withConfig({displayName:"RequestFeatureModalCard__RequestFeatureBody",componentId:"sc-7drn6t-0"})(["height:80vh;border-radius:",";"],(e=>e.theme.radius.medium)),Hse=u.default.div.attrs({"data-sc-tw":"components__Root"}).withConfig({displayName:"components__Root",componentId:"pompn1-0"})(["display:flex;justify-content:space-between;align-items:center;height:var(--sidebar-button-height);padding:"," ",";cursor:pointer;user-select:none;background:",";transition:",";border-radius:",";color:",";:hover{background:",";color:",";}:active{background-color:",";}",";"],vt.YK.xsmall,vt.YK.xsmall,(e=>e.$highlight&&"red"),(e=>e.theme.transition.default),vt.r8.small,vt.yW.textLight,vt.yW.gray4,vt.yW.text,vt.yW.gray5,(e=>e.$isOpen&&(0,u.css)(["&&{background-color:",";}"],vt.yW.gray5))),Kse=(0,u.default)(m.g).attrs({center:!0}).withConfig({displayName:"components__LinkIcon",componentId:"pompn1-1"})(["margin-right:",";"],(e=>e.theme.spacing.xsmall)),qse=(0,u.default)(sl.ZQ).withConfig({displayName:"components__StyledIcon",componentId:"pompn1-2"})(["opacity:0.7;color:",";transition:all 0.5s cubic-bezier(0.176,0.88,0.32,1.48);transform:",";."," &{display:none;}[data-sc-tw~='components__Root']:hover &{opacity:1;}"],vt.yW.text,(e=>e.$rotate?"rotate(180deg)":"rotate(0)"),Roe),$se=u.default.span.withConfig({displayName:"components__UserName",componentId:"pompn1-3"})(["white-space:nowrap;overflow:hidden;text-overflow:ellipsis;flex-grow:1;margin-right:",";."," &{display:none;}"],(e=>e.theme.spacing.xsmall),Roe);var Zse=n(67470);const Jse=e=>{let t=e.userName;const n=(0,u.useTheme)().uiTheme,l=(0,Zse.L)();return a.createElement(Qi.Az,{"data-external-id":"advisor-user-menu",offsetDistance:10,placement:"top-start",overlay:a.createElement(Ji.SP,null,a.createElement(Ji.xm,{icon:"dark"===n?"sun":"moon",onClick:()=>{const e="dark"===n?"light":"dark";l(e),ij.Ay.visualAppearancePreferenceUpdated({preference:e})}},"dark"===n?"Light mode":"Dark mode"),a.createElement(Ji.xm,{icon:"settings",linkTo:I.JZ.advisorPortal.profile()},"Profile"),a.createElement(Ji.xm,{icon:"log-out",linkTo:I.JZ.logout(),type:"danger"},"Sign out"))},(e=>{let n=e.toggleOpen,l=e.isOpen;return a.createElement(Hse,{onClick:n,$highlight:!1,$isOpen:l},a.createElement(Kse,null,a.createElement(sl.ZQ,{name:"user",size:16})),a.createElement($se,fl.TN,t),a.createElement(qse,{name:"chevron-down",size:16,$rotate:l}))}))},Xse=e=>{let t=e.isLoading,n=e.userId,l=e.userName,r=e.profilePictureUrl,o=e.avatarColor,i=e.hideSettingsButton;
1const s=(0,d.d4)(F6.e),c=(0,u.useTheme)().uiTheme,m=(0,Zse.L)(),p=Foe().isVariant,g=Yoe();return a.createElement(Qi.Az,{"data-external-id":"user-menu",offsetDistance:10,placement:"top-start",overlay:a.createElement(Ji.SP,null,a.createElement(Ji.xm,{icon:"dark"===c?"sun":"moon",onClick:()=>{const e="dark"===c?"light":"dark";m(e),ij.Ay.visualAppearancePreferenceUpdated({preference:e})}},"dark"===c?"Light mode":"Dark mode"),a.createElement(Ji.xm,{icon:"zap",onClick:()=>window.open(VF.Jt,"_blank")},"What's new"),!i&&a.createElement(Ji.xm,{icon:"settings",linkTo:p?I.JZ.settings():I.JZ.settings.profile(),onClick:g},"Settings"),s?a.createElement(Ji.xm,{icon:"log-out",linkTo:I.JZ.actAsUser({})},"Exit"):a.createElement(Ji.xm,{icon:"log-out",linkTo:I.JZ.logout(),type:"danger"},"Sign out"))},(e=>{let i=e.toggleOpen,c=e.isOpen;return a.createElement(Hse,{onClick:i,$highlight:!!s,$isOpen:c},a.createElement(Kse,null,a.createElement(Pw.n,Object.assign({isLoading:t,userProfilePictureUrl:r,userAvatarColor:o,avatarSize:24,userId:n,userName:l,showLabel:!1},fl.TN))),t?a.createElement(Qse,null):a.createElement($se,fl.TN,l),a.createElement(qse,{name:"chevron-down",size:16,$rotate:c}))}))},Qse=(0,u.default)(M.Al).attrs({$borderRadius:"xsmall"}).withConfig({displayName:"UserMenu__NameSkeleton",componentId:"sc-9b1l1x-0"})(["margin-right:",";"],vt.YK.default);var ece=n(61847),tce=n(66549);const nce=["stream","reviewStatus"],ace=e=>{var t,n,a;const l=(null!==e&&void 0!==e?e:{}).skip,r=(0,et.I)(lce,{variables:{includeLiabilities:!0},skip:l,fetchPolicy:"cache-first"}),i=r.data,s=r.isLoadingInitialData,c=r.refetch,d=(null!==(t=null===i||void 0===i?void 0:i.recurringTransactionStreams)&&void 0!==t?t:[]).length>0,u=(0,VW.A)((0,RK.A)(["stream","reviewStatus"],Ee._1Q.PENDING),null!==(n=null===i||void 0===i?void 0:i.recurringTransactionStreams)&&void 0!==n?n:[]),m=u.length,p=(0,VW.A)((0,tce.A)((0,RK.A)(nce,Ee._1Q.APPROVED),(0,RK.A)(nce,Ee._1Q.AUTOMATIC_APPROVED)),null!==(a=null===i||void 0===i?void 0:i.recurringTransactionStreams)&&void 0!==a?a:[]),g=(0,VW.A)((0,RK.A)(["stream","recurringType"],Ee.kjN.EXPENSE),p),h=(0,VW.A)((0,RK.A)(["stream","recurringType"],Ee.kjN.INCOME),p),v=(0,jd.A)(Gj.A,[g,h]),f=(0,o.A)(v,2);return{hasRecurringMerchants:d,isLoading:s,refetchHouseholdHasRecurring:c,pendingStreams:u,pendingStreamsCount:m,hasExpenses:f[0],hasIncome:f[1]}},lce=(0,gZ.J)("\n  query Common_GetRecurringStreams($includeLiabilities: Boolean) {\n    recurringTransactionStreams(includePending: true, includeLiabilities: $includeLiabilities) {\n      stream {\n        id\n        reviewStatus\n        frequency\n        amount\n        baseDate\n        dayOfTheMonth\n        isApproximate\n        name\n        logoUrl\n        recurringType\n        merchant {\n          id\n        }\n        creditReportLiabilityAccount {\n          id\n          account {\n            id\n          }\n\n          lastStatement {\n            id\n            dueDate\n          }\n        }\n      }\n    }\n  }\n");var rce,oce,ice,sce,cce,dce,uce,mce=n(42779);const pce=()=>{const e=(0,nG.p)("support-chat-bubble","on"),t=(0,d4.u)("feat-voltron-feedback-web_mobile","off"),n=t.isOn,r=t.isSplitReady,i=(0,b.pE)("helpCenterOpen"),s=(0,l.zy)(),c=(0,l.Zp)(),u=(0,d.d4)(A.kV),m=(0,et.I)(ece.c,{variables:{promoCode:u}}),p=m.data,h=m.isLoadingInitialData,v=null!==p&&void 0!==p?p:{},f=v.me,E=v.subscription,y=v.subscriptionOffering,x=(null!==E&&void 0!==E?E:{}).hasPremiumEntitlement,w=null!==f&&void 0!==f?f:{},C=w.id,k=w.displayName,S=void 0===k?"":k,N=w.profilePictureUrl,T=w.avatarColor,_=w.sponsorAccountName,D=void 0===_?"":_,R=(0,d.d4)(A.UF),M=(0,d.d4)(A.fm),L=ace({skip:!x}).pendingStreamsCount,O=(0,Pd.h)(),P=(0,o.A)(O,2),B=P[0],z=P[1].open,F=(0,a.useState)(!1),G=(0,o.A)(F,2),Y=G[0],U=G[1],V=(0,Pd.h)("true"===i),W=(0,o.A)(V,2),j=W[0],H=W[1],K=H.open,q=H.close,$=(0,Qm.Eo)(),Z=$.openContactSupportModal,J=$.openSupportChat,X=$.endSupportChat,Q=$.setIsChatLoading,ee=$.isChatLoading,te=$.isChatOpen,ne=(0,mce.WB)().toggleCommandPalette,ae=s.pathname.startsWith(I.JZ.advisorPortal.path),le=Boolean((0,l.RQ)(I.JZ.requestFeature.path))&&n&&r,re=(0,a.useCallback)((()=>{Q(!1),X(),K()}),[X,K,Q]);(0,a.useEffect)((()=>{te&&!ee&&q()}),[q,ee,te]);const oe=(0,a.useCallback)((()=>{window.open(I.kP.whatsNew)}),[]),ie=(0,a.useCallback)((()=>{window.open(I.kP.zendeskHelpCenter)}),[]),se=(0,a.useCallback)((()=>{z(),q()}),[z,q]),ce=(0,a.useCallback)((()=>{U(!0),q()}),[q]),de=(0,a.useCallback)((()=>{c(I.JZ.roadmap()),q()}),[c,q]),ue=(0,a.useCallback)((()=>{e?(Q(!0),J()):Z()}),[e,Q,J,Z]);(0,ire.i)({onClickWhatsNew:oe,onClickShareFeedback:ce,onClickRoadmap:de,onClickFeatureRequest:se,onClickHelpCenter:ie,onClickContactSupport:ue});const me=(0,a.useCallback)((()=>{ae||(ij.Ay.searchOpened({method:"click"}),ne())}),[ae,ne]),pe=(0,d.wA)(),ge=(0,a.useRef)(),he=(0,a.useCallback)((()=>{M||(ge.current=setTimeout((()=>pe((0,g.x5)(!0))),150))}),[M,pe]),ve=(0,a.useCallback)((()=>{M||(clearTimeout(ge.current),pe((0,g.x5)(!1)))}),[M,pe]);(0,a.useEffect)((()=>()=>clearTimeout(ge.current)),[]);const fe=(0,a.useState)(0),Ee=(0,o.A)(fe,2),ye=Ee[0],be=Ee[1],xe=(0,a.useRef)(R);return(0,a.useEffect)((()=>{xe.current&&!R&&be((e=>e+1)),xe.current=R}),[R]),a.createElement(gce,{"data-external-id":"side-bar",onMouseEnter:he,onMouseLeave:ve,"aria-expanded":R,"data-testid":"sidebar-root","data-pinned":M,className:!1===R?Roe:void 0},a.createElement(hce,{"data-pinned":M},a.createElement(Mre.b.Provider,{value:ye},a.createElement(vce,null,a.createElement(Rre,null),a.createElement(Ece,null,ae?a.createElement(Joe,null):a.createElement(Woe,{onOpenSearch:me})),a.createElement(yce,null,ae?a.createElement(Zre,{onSupportButtonClick:re}):a.createElement(Dse,{subscription:E,subscriptionOffering:y,onSupportButtonClick:re,pendingStreamsCount:L,isSidebarExpanded:R})),a.createElement(bce,null,ae?a.createElement(Jse,{userName:null!==D&&void 0!==D?D:""}):a.createElement(Xse,{isLoading:h,userId:C,userName:S,profilePictureUrl:N,avatarColor:T,hide
1SettingsButton:!1}))))),a.createElement(B,{large:!0},a.createElement(Wse,null)),r&&!n&&a.createElement(XU.l,{large:!0,path:I.JZ.requestFeature.path},a.createElement(Wse,null)),a.createElement(j,null,a.createElement(Yse,{onClickHelpCenter:ie,onClickFeatureRequest:se,onClickShareFeedback:ce,onClickRoadmap:de,onClickContactSupport:ue,isLoading:ee||te,onClickWhatsNew:oe})),a.createElement(Sre,{mode:"general",source:le?"request_feature_route":"help_center",open:Y||le,onOpenChange:e=>{U(e),!e&&le&&c("".concat(I.JZ.dashboard()).concat(s.search))}}),a.createElement(ore.x,null))},gce=$d.s.div.attrs({"data-sidebar":!0})(rce||(rce=(0,wc.A)(["\n  relative w-(--sidebar-collapsed-width) shrink-0 bg-background-page\n  transition-[transform,width] [--sidebar-width:var(--sidebar-collapsed-width)]\n  aria-expanded:[--sidebar-width:var(--sidebar-expanded-width)]\n  data-[pinned='true']:w-(--sidebar-width)\n"]))),hce=$d.s.div(oce||(oce=(0,wc.A)(['\n  absolute inset-y-0 left-0 z-10 flex w-(--sidebar-width) flex-col overflow-x-hidden\n  bg-background-page\n  data-[pinned="false"]:transition-[width]\n  in-aria-expanded:data-[pinned="false"]:w-[calc(var(--sidebar-width)+var(--spacing-gutter))]\n  in-aria-expanded:data-[pinned="false"]:pr-gutter\n  in-aria-expanded:data-[pinned="false"]:shadow-card\n']))),vce=$d.s.div(ice||(ice=(0,wc.A)(["flex min-h-0 min-w-(--sidebar-expanded-width) flex-1 flex-col"]))),fce=$d.s.div(sce||(sce=(0,wc.A)(["\n  relative flex flex-col p-sm pt-0 pr-0\n  [&_a:focus-visible]:outline-2 [&_a:focus-visible]:-outline-offset-2\n  [&_button:focus-visible]:outline-2 [&_button:focus-visible]:-outline-offset-2\n"]))),Ece=(0,$d.s)(fce)(cce||(cce=(0,wc.A)(["sticky top-0 min-h-(--app-header-height) flex-row items-center pb-0 pl-default"]))),yce=(0,$d.s)(fce)(dce||(dce=(0,wc.A)(["\n  h-full overflow-y-auto pb-0\n  [scrollbar-width:none]\n  [&::-webkit-scrollbar]:w-0 [&::-webkit-scrollbar]:bg-transparent\n"]))),bce=(0,$d.s)(fce)(uce||(uce=(0,wc.A)(["sticky bottom-0"])));var xce,wce,Cce=n(25770),Ace=n(90933);const Ice=()=>{var e;const t=(0,d4.h)(Ace.A,"on"),n=null===(e=a.useContext(Cce.w).factory)||void 0===e?void 0:e.config;return a.createElement(rG.Y,{"data-external-id":"split-client-test",name:"Split.io Client Test",parentRoute:null},a.createElement(kce,null,a.createElement(mX.V,null,a.createElement(Nce,null,"Flags"),a.createElement(Sce,null,JSON.stringify(t,null,2))),a.createElement(mX.V,null,a.createElement(Nce,null,"Split config"),a.createElement(Sce,null,JSON.stringify(n,null,2)))))},kce=u.default.div.withConfig({displayName:"SplitClientTest__Root",componentId:"sc-1vgolvy-0"})(["padding:0 ",";display:flex;gap:",";"],(e=>e.theme.spacing.xlarge),(e=>e.theme.spacing.xlarge)),Sce=$d.s.pre(xce||(xce=(0,wc.A)(["text-[11px]"]))),Nce=$d.s.h2(wce||(wce=(0,wc.A)(["mb-0"])));var Tce=n(35146);const _ce=e=>{let t=e.onConfirm,n=e.onClose;return a.createElement(um.b,{"data-external-id":"delete-receipt-confirmation",onClose:n},(()=>a.createElement(xC.$,{title:"Delete Receipt",confirm:"Delete",useDangerButton:!0,onConfirm:t,onCancel:n},a.createElement(xt.v,null,"Are you sure you want to delete this receipt? This action cannot be undone."))))};var Dce=n(60542),Rce=n(17693);const Mce=e=>{var t,n;if(!e)return{};const a=N.c9.fromISO(e);return a.isValid?{startDate:null!==(t=a.minus({days:30}).toISODate())&&void 0!==t?t:void 0,endDate:null!==(n=a.plus({days:30}).toISODate())&&void 0!==n?n:void 0}:{}},Lce=e=>{var t,n,l,r,s,c,d,u,m,g;let h=e.retailSync,v=e.onClose,f=e.onDone,E=e.entityLabel,y=void 0===E?"receipt":E;const b=null===(t=h.orders)||void 0===t?void 0:t[0],x=(0,a.useState)(null!==(n=null===b||void 0===b?void 0:b.merchantName)&&void 0!==n?n:""),w=(0,o.A)(x,2),A=w[0],I=w[1],k=(0,a.useState)(null),S=(0,o.A)(k,2),N=S[0],T=S[1],_=(0,a.useState)(!1),D=(0,o.A)(_,2),R=D[0],M=D[1],L=(0,xy.d)(A,300),O=(0,i.n)(Rce.Nb,{refetchQueries:h.id?[{query:Rce.Xi,variables:{syncId:h.id}}]:[]}),P=(0,o.A)(O,1)[0],B=null===b||void 0===b||null===(l=b.retailTransactions)||void 0===l?void 0:l[0],z=null===B||void 0===B?void 0:B.id,F=Pce(null===B||void 0===B||null===(r=B.transaction)||void 0===r||null===(s=r.merchant)||void 0===s?void 0:s.logoUrl),G=null!==(c=null===B||void 0===B?void 0:B.total)&&void 0!==c?c:null===b||void 0===b?void 0:b.grandTotal,Y=(0,et.I)(Bce,{variables:(0,U.A)({search:L,limit:100},Mce(null===b||void 0===b?void 0:b.date)),skip:!L}),V=Y.data,W=Y.isLoadingInitialData,j=null!==(d=null===V||void 0===V||null===(u=V.allTransactions)||void 0===u?void 0:u.results)&&void 0!==d?d:[],H=(0,a.useCallback)((async()=>
1{if(z&&N){M(!0);try{var e,t;const a=null===(e=(await P({variables:{retailTransactionId:z,transactionId:N}})).data)||void 0===e||null===(t=e.matchRetailTransaction)||void 0===t?void 0:t.errors;var n;if(a)return void(0,C.oR)({title:null!==(n=a.message)&&void 0!==n?n:"Failed to match ".concat(y)});(0,C.oR)({title:"".concat((0,EA.ZH)(y)," matched to transaction")}),f(N)}catch(a){(0,C.oR)({title:"Failed to match ".concat(y)})}finally{M(!1)}}}),[z,N,P,f,y]);return a.createElement(fe.hg1.Root,{"data-external-id":"find-match-modal",open:!0,onOpenChange:e=>{e||v()},size:"xl"},a.createElement(fe.hg1.Content,null,a.createElement(fe.hg1.CloseTrigger,null),a.createElement(fe.hg1.Header,null,a.createElement(fe.hg1.Title,null,"Find matching transaction")),a.createElement(fe.hg1.Body,{className:"flex flex-col gap-default"},b&&a.createElement(fe.RVf.Root,null,a.createElement(fe.RVf.Label,null,"Original ".concat(y)),a.createElement(Oce,{merchantName:null!==(m=b.merchantName)&&void 0!==m?m:(0,EA.ZH)(y),date:null!==(g=null===B||void 0===B?void 0:B.date)&&void 0!==g?g:b.date,amount:(0,rl.vv)(G),logoUrl:F})),a.createElement(fe.RVf.Root,null,a.createElement(fe.RVf.Label,null,"Search"),a.createElement(fe.i9A,null,a.createElement(fe.D_j,{placeholder:"Search transactions...",value:A,onChange:e=>{I(e.currentTarget.value),T(null)},autoFocus:!0}),a.createElement(fe.i9A.Addon,null,a.createElement(fe.s$r,{size:"md"})))),W&&a.createElement("div",{className:"flex justify-center py-xl"},a.createElement(p.i,{size:"md"})),!W&&0===j.length&&L&&a.createElement("div",{className:"py-xl text-center"},a.createElement(fe.c8D,{size:"sm",color:"secondary"},"No transactions found")),j.length>0&&a.createElement("div",{className:"flex flex-col gap-sm"},j.map((e=>{var t,n,l,r;const o=e.id===N,i=null!==(t=null!==(n=null===(l=e.merchant)||void 0===l?void 0:l.name)&&void 0!==n?n:e.plaidName)&&void 0!==t?t:"Unknown";return a.createElement(Oce,{key:e.id,merchantName:i,date:e.date,amount:(0,rl.vv)(Math.abs(e.amount)),logoUrl:Pce(null===(r=e.merchant)||void 0===r?void 0:r.logoUrl),showRadio:!0,isSelected:o,onSelect:()=>T(e.id)})})))),a.createElement(fe.hg1.Footer,null,a.createElement(fe.hg1.Close,{render:a.createElement(fe.XZZ,null)},"Cancel"),a.createElement(fe.XZZ,{variant:"primary",onClick:H,disabled:!N||R},"Link ".concat(y)))))},Oce=e=>{let t=e.merchantName,n=e.date,l=e.amount,r=e.logoUrl,o=e.showRadio,i=void 0!==o&&o,s=e.isSelected,c=void 0!==s&&s,d=e.onSelect;const u=n?N.c9.fromISO(n).toLocaleString(N.c9.DATE_MED):null,m=a.createElement(a.Fragment,null,a.createElement("div",{className:(0,q.cn)("flex min-w-0 flex-1 items-center gap-sm",fl.TN.className)},a.createElement(Wl._,{url:r,size:40}),a.createElement("div",{className:"flex min-w-0 flex-col gap-3xs"},a.createElement(fe.c8D,{weight:"medium",color:"primary",className:"truncate"},t),u&&a.createElement(fe.c8D,{size:"sm",color:"secondary"},u))),a.createElement(fe.c8D,{weight:"medium",color:"primary",className:fl.TN.className},l),i&&a.createElement(eH.rp,{isSelected:c,style:{marginRight:0,marginTop:0}},c&&a.createElement("div",{className:"size-2 rounded-round bg-content-white"}))),p=(0,q.cn)("flex w-full items-center rounded-default border bg-background-primary transition-colors",i?"gap-default py-sm pr-lg pl-default text-left":"gap-sm py-sm pr-lg pl-default",i&&!c&&"border-border-primary hover:bg-background-primary-hover",i&&c&&"border-border-brand",!i&&"border-border-primary");return d?a.createElement("button",{"data-external-id":"match-row-container",type:"button",onClick:d,className:p},m):a.createElement("div",{"data-external-id":"match-row-container",className:p},m)},Pce=e=>null!==e&&void 0!==e&&e.startsWith("http")?e:null,Bce=Ee.sCI;var zce=n(45957),Fce=n.n(zce),Gce=n(98593);const Yce=e=>{var t,n;const a=null!==e&&void 0!==e?e:{},l=a.status,r=a.orders,o=a.createdAt,i=null!==(t=null===r||void 0===r?void 0:r[0])&&void 0!==t?t:{},s=i.displayStatus,c=i.retailTransactions,d=null!==(n=null===c||void 0===c?void 0:c.some((e=>{var t;return null===(t=e.transaction)||void 0===t?void 0:t.isManual})))&&void 0!==n&&n;if(l===Ee.BX9.COMPLETED)return d?"Manual transaction created":"Match found";if(l===Ee.BX9.FAILED)return"Unable to scan";if(l===Ee.BX9.IN_PROGRESS)return"Scanning in background...";if(l===Ee.BX9.PENDING)return"Pending";if(l===Ee.BX9.PENDING_MATCHES){if(s===_t.V0)return s;
1return(o?Math.abs(N.c9.fromISO(o).diffNow("hours").hours):1/0)<120?"Waiting for match":"No match"}return null!==s&&void 0!==s?s:"Unknown"},Uce=e=>{var t;return null!==(t=null===e||void 0===e?void 0:e.find((e=>e.isGeneratedReceiptImage)))&&void 0!==t?t:null===e||void 0===e?void 0:e[0]},Vce=e=>{if(!e)return;const t=e.extension.toLowerCase();return"pdf"===t||"ai"===t?e.thumbnailUrl:e.originalAssetUrl},Wce=e=>{let t,n=0;return Object.keys(e).forEach((a=>{e[a]>n&&(t=a,n=e[a])})),t},jce=(e,t,n,a)=>{const l=e.filter((e=>e.title&&e.quantity&&e.price)).map((e=>"".concat(e.quantity," x ").concat(e.title," - ").concat(e.price))).join("\n");return[[!!t&&"Subtotal: ".concat(t),!!n&&n>0&&"Tax: ".concat(n),!!a&&a>0&&"Tip: ".concat(a)].filter(Boolean).join("  |  "),l].filter(Boolean).join("\n_______________\n")},Hce=e=>{let t=e.attachments;return a.createElement("div",{"data-external-id":"receipt-attachment-list",className:"flex flex-col gap-sm"},a.createElement(fe.c8D,{size:"sm",weight:"medium"},"Attachments"),a.createElement("div",{className:"flex flex-col gap-xs"},t.map((e=>{const t=(e=>null===e||void 0===e?void 0:e.thumbnailUrl)(e);return a.createElement("button",{key:e.id,type:"button",className:" group flex w-full appearance-none items-center gap-sm rounded-md border-0 bg-transparent p-xs text-left hover:bg-background-secondary ",onClick:()=>window.open(e.originalAssetUrl,"_blank","noopener,noreferrer")},a.createElement("div",{className:"size-16 shrink-0 overflow-hidden rounded-sm border border-border-primary bg-background-secondary"},t&&a.createElement("img",{className:(0,q.cn)("size-full object-cover",fl.TN.className),src:t,alt:"","aria-hidden":"true"})),a.createElement("div",{className:"flex min-w-0 flex-col"},a.createElement(fe.c8D,{className:(0,q.cn)("truncate group-hover:text-content-link-hover",fl.TN.className)},e.filename),a.createElement(fe.c8D,{size:"sm",weight:"book",color:"secondary",className:fl.TN.className},Fce()(e.sizeBytes))))}))))};var Kce=n(5211);const qce=e=>{let t=e.label,n=e.value,l=e.fieldType,r=void 0===l?"text":l,i=e.editable,s=void 0===i||i,c=e.leadingContent,d=e.onSave;const u=(0,a.useState)(!1),m=(0,o.A)(u,2),g=m[0],h=m[1],v=(0,a.useState)(String(null!==n&&void 0!==n?n:"")),f=(0,o.A)(v,2),E=f[0],y=f[1],b=(0,a.useState)("number"===typeof n?n:void 0),x=(0,o.A)(b,2),w=x[0],C=x[1],A=(0,a.useRef)(String(null!==n&&void 0!==n?n:""));(0,a.useEffect)((()=>{const e=String(null!==n&&void 0!==n?n:"");y(e),C("number"===typeof n?n:void 0),A.current=e}),[n]);const I=(0,a.useCallback)((async e=>{const t=e.target.value;if(d&&t!==A.current){A.current=t,h(!0);try{await d(t)}finally{h(!1)}}}),[d]),k=(0,a.useCallback)((async()=>{const e=String(null!==w&&void 0!==w?w:"");if(d&&e!==A.current){A.current=e,h(!0);try{await d(e)}finally{h(!1)}}}),[w,d]),S=(0,a.useCallback)((async e=>{const t=null!==e&&void 0!==e?e:"";if(y(t),d&&t!==A.current){A.current=t,h(!0);try{await d(t)}finally{h(!1)}}}),[d]);return a.createElement($ce,{"data-external-id":"receipt-editable-field"},t&&a.createElement(Zce,null,t),a.createElement(Jce,fl.TN,(()=>{if(!s){let e=E;if("currency"===r)e=void 0===w?"":(0,rl.vv)(w);else if("date"===r){const t=E?N.c9.fromISO(E):null;e=null!==t&&void 0!==t&&t.isValid?t.toLocaleString(N.c9.DATE_FULL):""}return a.createElement(fe.i9A,{disabled:!0,className:"w-full"},a.createElement(fe.D_j,{name:"receipt-field",type:"text",value:e,disabled:!0}),c&&a.createElement(fe.i9A.Addon,{align:"inline-start"},c))}return"currency"===r?a.createElement(fe.K$5,{value:null!==w&&void 0!==w?w:null,min:0,step:"any",onValueChange:e=>C(null!==e&&void 0!==e?e:void 0),name:"receipt-field",onBlur:k}):"date"===r?a.createElement("div",{className:"w-full"},a.createElement(Kce.J,{value:E||null,onValueChange:S})):a.createElement(Qce,{name:"receipt-field",type:"text",value:E,onChange:e=>y(e.target.value),onBlur:I})})(),g&&a.createElement(Xce,null,a.createElement(p.i,{size:"2xs"}))))},$ce=u.default.div.withConfig({displayName:"ReceiptEditableField__Root",componentId:"u8wc5v-0"})([""]),Zce=(0,u.default)(xt.v).withConfig({displayName:"ReceiptEditableField__Label",componentId:"u8wc5v-1"})(["font-size:",";font-weight:500;color:",";margin-bottom:",";"],vt.J.small,vt.Ee.color.content.secondary,vt.YK.xxsmall),Jce=(0,u.default)(m.g).attrs({alignCenter:!0}).withConfig({displayName:"ReceiptEditableField__InputRow",componentId:"u8wc5v-2"})(["position:relative;"]),Xce=u.default.div.withConfig({displayName:"ReceiptEditableField__SpinnerOverlay",componentId:"u8wc5v-3"})(["position:absolute;right:",";top:50%;transform:translateY(-50%);"],vt.YK.small),Qce=(0,u.default)(Ry.X).withConfig({displayName:"ReceiptEditableField__StyledTextInput",componentId:"u8wc5v-4"})(["width:100%;"]);var ede=n(43072);const tde="border border-transparent hover:border-input-hover-border focus:border-input-focus-border focus:ring-1 focus:ring-input-focus-border",nde=e=>{var t;let n=e.lineItem,l=e.editMode,r=e.onUpdate,i=e.onDelete;const s=(0,a.useState)(!1),c=(0,o.A)(s,2),d=c[0],u=c[1],m=(0,a.useState)(n.title),p=(0,o.A)(m,2),g=p[0],h=p[1],v=(0,a.useState)(n.price),f=(0,o.A)(v,2),E=f[0],y=f[1],b=(0,a.useState)(n.quantity),x=(0,o.A)(b,2),w=x[0],C=x[1],A=(0,a.useRef)(n.title),I=(0,a.useRef)(n.price),k=(0,a.useRef)(n.quantity);(0,a.useEffect)((()=>{h(n.title),y(n.price),C(n.quantity),A.current=n.title,I.current=n.price,k.current=n.quantity}),[n.title,n.price,n.quantity]);const S=(0,a.useCallback)((e=>{e.value&&r(n.id,{categoryId:e.value})}),[n.id,r]),N=(0,a.useCallback)((()=>{g!==A.current&&g.trim()&&(A.current=g,r(n.id,{title:g}))}),[n.id,g,r]),T=(0,a.useCallback)((()=>{null!==E?E!==I.current&&(I.current=E,r(n.id,{price:Math.round(100*E)/100})):y(I.current)}),[n.id,E,r]),_=(0,a.useCallback)((()=>{const e=Math.max(1,Math.round(w));C(e),e!==k.current&&(k.current=e,r(n.id,{quantity:e}))}),[n.id,w,r]),D=(0,a.useCallback)((async()=>{u(!0);try{await i(n.id)}finally{u(!1)}}),[n.id,i]);var R,M,L,O;return"readOnly"===l?a.createElement("div",{"data-external-id":"receipt-line-item-row",className:"flex items-center gap-sm p-md text-content-secondary"},a.createElement("div",{className:"flex min-w-0 flex-1 flex-col gap-xs"},a.createElement("div",{className:"flex items-center gap-sm"},a.createElement(fe.c8D,{weight:"medium",color:"secondary",className:(0,q.cn)("min-w-0 flex-1 truncate",fl.TN.className)},n.title),null!==n.total&&void 0!==n.total&&a.createElement(fe.c8D,{weight:"medium",color:"secondary",className:(0,q.cn)("shrink-0",fl.TN.className)},(0,rl.is)(n.total))),a.createElement("div",{className:"flex items-center gap-xs"},(null===(R=n.category)||void 0===R?void 0:R.icon)&&a.createElement("span",{className:"text-sm leading-none"},n.category.icon),a.createElement(fe.c8D,{size:"sm",color:"secondary",className:"min-w-0 flex-1 truncate"},null!==(M=null===(L=n.category)||void 0===L?void 0:L.name)&&void 0!==M?M:"Uncategorized"),null!==n.quantity&&null!==n.price&&a.createElement(fe.c8D,{size:"sm",color:"secondary",className:(0,q.cn)("shrink-0 whitespace-nowrap",fl.TN.className)},n.quantity," \xd7 ",(0,rl.is)(n.price))))):"categoryOnly"===l?a.createElement("div",{"data-external-id":"receipt-line-item-row",className:"flex items-center gap-sm p-md text-content-secondary"},a.createElement("div",{className:(0,q.cn)("flex min-w-0 flex-1 flex-col gap-xs",fl.TN.className)},a.createElement("div",{className:"flex items-center gap-sm"},a.createElement(fe.c8D,{weight:"medium",color:"secondary",className:"min-w-0 flex-1 truncate"},n.title),null!==n.total&&void 0!==n.total&&a.createElement(fe.c8D,{weight:"medium",color:"secondary",className:"shrink-0"},(0,rl.is)(n.total))),a.createElement("div",{className:"flex items-center gap-sm"},a.createElement("div",{className:"min-w-0 flex-1 **:data-full-screen-select:box-border **:data-full-screen-select:size-full **:data-full-screen-select:pl-sm"},a.createElement(ede.f,{value:null===(O=n.category)||void 0===O?void 0:O.id,onChange:S,placeholder:"Select category...",isClearable:!1,alwaysShowBorder:!1})),null!==n.quantity&&null!==n.price&&a.createElement(fe.c8D,{size:"sm",color:"secondary",className:(0,q.cn)("shrink-0 whitespace-nowrap",fl.TN.className)},n.quantity," \xd7 ",(0,rl.is)(n.price))))):a.createElement("div",{"data-external-id":"receipt-line-item-row",className:"flex items-center gap-sm p-md"},a.createElement("div",{className:(0,q.cn)("flex min-w-0 flex-1 flex-col gap-xs",fl.TN.className)},a.createElement("div",{className:"flex items-center gap-sm"},a.createElement(Ry.X,{name:"lineItemTitle",className:(0,q.cn)("min-w-0 flex-1",tde),value:g,onChange:e=>h(e.target.value),onBlur:N,small:!0}),a.createElement(fe.c8D,{weight:"medium",className:"shrink-0 pr-3.25"}
1,(0,rl.is)(n.total))),a.createElement("div",{className:"flex items-center gap-sm"},a.createElement("div",{className:"min-w-0 flex-1 **:data-full-screen-select:box-border **:data-full-screen-select:size-full **:data-full-screen-select:pl-sm"},a.createElement(ede.f,{value:null===(t=n.category)||void 0===t?void 0:t.id,onChange:S,placeholder:"Select category...",isClearable:!1,alwaysShowBorder:!1})),a.createElement("div",{className:"flex shrink-0 items-center gap-xs"},a.createElement(Ry.X,{name:"lineItemQuantity",type:"number",className:(0,q.cn)("w-20 shrink-0 text-right",tde),value:String(w),onChange:e=>{const t=parseInt(e.target.value,10);isNaN(t)||C(t)},onBlur:_,small:!0}),a.createElement(fe.c8D,{size:"sm",color:"secondary",className:"whitespace-nowrap"},"\xd7"),a.createElement(fe.K$5.Root,{value:E,min:0,step:"any",onValueChange:e=>y(e)},a.createElement(fe.i9A,{size:"sm",variant:"cell",align:"end",className:"w-25 shrink-0 border-transparent"},a.createElement(fe.K$5.Input,{name:"lineItemPrice",placeholder:"$",className:"text-base/6",onBlur:T})))))),a.createElement("div",{className:"shrink-0 self-center"},a.createElement(fe.SO$,{"aria-label":"Delete line item",size:"sm",onClick:D,disabled:d},a.createElement(fe.i01,{className:"text-content-danger"}))))},ade=e=>{let t=e.transaction,n=e.onClick;const l=t.id,r=t.merchantName,o=t.merchantLogoUrl,i=t.date,s=t.amount,c=t.pending,d=t.category,u=i?N.c9.fromISO(i).toLocaleString(N.c9.DATE_MED):null;return a.createElement("button",{"data-external-id":"receipt-transaction-row",type:"button",onClick:()=>n(l),className:" flex w-full items-center gap-sm rounded-default border border-border-primary bg-background-primary py-default pr-sm pl-default text-left transition-colors hover:cursor-pointer hover:border-border-primary-hover hover:bg-background-primary-hover "},a.createElement(Wl._,{url:null!==o&&void 0!==o?o:null,size:40}),a.createElement("div",{className:(0,q.cn)("flex min-w-0 flex-1 flex-col gap-3xs",fl.TN.className)},a.createElement(fe.c8D,{className:"truncate"},r),d&&a.createElement("div",{className:"flex items-center gap-3xs text-sm"},d.icon&&a.createElement(fe.xa2,null,d.icon),a.createElement(fe.c8D,{size:"sm"},d.name))),a.createElement("div",{className:"flex flex-col items-end gap-3xs"},a.createElement("div",{className:"flex items-center gap-xs"},c&&a.createElement(fe.CQG,{size:"2xs",rounded:"pill",preferCircle:!0},"P"),a.createElement(fe.c8D,fl.zs,(0,rl.vv)(Math.abs(null!==s&&void 0!==s?s:0)))),u&&a.createElement(fe.c8D,{size:"sm",color:"secondary"},u)),a.createElement(fe.hPJ,{size:"lg",className:"ml-2xs shrink-0 text-content-primary"}))};var lde=n(44335);const rde=()=>{const e=(0,i.n)(Rce.DD),t=(0,o.A)(e,1)[0],n=(0,i.n)(Rce.qU),l=(0,o.A)(n,1)[0],r=(0,i.n)(Rce.v6),s=(0,o.A)(r,1)[0],c=(0,i.n)(Rce.iI),d=(0,o.A)(c,1)[0],u=(0,i.n)(Rce._m),m=(0,o.A)(u,1)[0];return{createRetailSync:(0,a.useCallback)((function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:Ee.XcS.USER_IMPORT;return t({variables:{input:{vendor:e,isBackfill:arguments.length>1&&void 0!==arguments[1]&&arguments[1]}}})}),[t]),createBulkRetailSync:(0,a.useCallback)((e=>l({variables:{input:{count:e}}})),[l]),startRetailSync:(0,a.useCallback)(((e,t)=>s((0,U.A)({variables:{syncId:e}},t))),[s]),deleteRetailSync:(0,a.useCallback)((e=>d({variables:{syncId:e},update:(t,n)=>{let a=n.data;var l;const r=t.identify({id:e,__typename:"RetailSync"});r&&(null===(l=null===a||void 0===a?void 0:a.deleteUnmatchedRetailSync)||void 0===l?void 0:l.success)&&t.evict({id:r})}})),[d]),completeRetailSync:(0,a.useCallback)(((e,t)=>m((0,U.A)({variables:{syncId:e}},t))),[m])}},ode=e=>{const t=(0,a.useMemo)((()=>{var t,n,a,l,r,o,i;if(!e)return;const s=(e=>{var t,n,a,l;const r=null===(t=null===e||void 0===e?void 0:e.orders)||void 0===t?void 0:t[0],o=null===r||void 0===r?void 0:r.retailLineItems;if(!r||!o)return;const i=(0,T9.A)(o.map((e=>e.category))),s=(0,Gce.A)((e=>e.id),i),c=Wce(s),d=r.date,u=r.grandTotal,m=r.merchantName,p=r.retailTransactions,g=Uce(null===e||void 0===e?void 0:e.attachments);return{amount:Math.abs(u),amountUnit:u>=0?-1:1,categoryId:c,date:d,merchantName:null!==m&&void 0!==m?m:void 0,notes:jce(o,r.totalBeforeTax,r.tax,r.tip),retailTransactionId:null!==(a=null===(n=null===p||void 0===p?void 0:p[0])||void 0===n?void 0:n.id)&&void 0!==a?a:void 0,retailUserAttachmentId:null!==(l=null===g||void 0===g?void 0:g.id)&&void 0!==l?l:void 0}})(e);return s?{amount:s.amount,isCredit:(null!==(t=s.amountUnit)&&void 0!==t?t:-1)>0,date:null!==(n=s.date)&&void 0!==n?n:void 0,merchantName:null!==(a=s.merchantName)&&void 0!==a?a:void 0,categoryId:null!==(l=s.categoryId)&&void 0!==l?l:void 0,notes:null!==(r=s.notes)&&void 0!==r?r:void 0,retailTransactionId:null!==(o=s.retailTransactionId)&&void 0!==o?o:void 0,retailUserAttachmentId:null!==(i=s.retailUserAttachmentId)&&void 0!==i?i:void 0}:void 0}),[e]);return t};var ide=n(28269);const sde=e=>(0,r.YW)(e).with(Ee.BX9.COMPLETED,(()=>"green")).with(Ee.BX9.FAILED,(()=>"red")).with(Ee.BX9.IN_PROGRESS,(()=>"purple")).otherwise((()=>"grayLight"));var cde;const dde=e=>{var t,n,r,s,c,d,u,m,g,h,v;let f=e.retailSyncId,E=e.onClose,y=e.onMatchTransaction,b=e.onOpenTransaction;const x=(0,a.useState)(!1),w=(0,o.A)(x,2),A=w[0],k=w[1],S=(0,a.useState)(!1),T=(0,o.A)(S,2),_=T[0],D=T[1],R=(0,et.I)(Rce.Xi,{variables:{syncId:f},fetchPolicy:"cache-first",errorPolicy:"all",context:{suppressGlobalError:!0}}),M=R.data,L=R.isLoadingInitialData,O=null!==(t=null===M||void 0===M?void 0:M.retailSync)&&void 0!==t?t:void 0,P=null===O||void 0===O||null===(n=O.orders)||void 0===n?void 0:n[0],B=Uce(null===O||void 0===O?void 0:O.attachments),z=(e=>{var t;const n=Uce(e);return null!==(t=null===e||void 0===e?void 0:e.filter((e=>e.id!==(null===n||void 0===n?void 0:n.id))))&&void 0!==t?t:[]})(null===O||void 0===O?void 0:O.attachments),F=null!==(r=null===P||void 0===P?void 0:P.retailLineItems)&&void 0!==r?r:[],G=(null===O||void 0===O?void 0:O.status)===Ee.BX9.PENDING_MATCHES,Y=(null===O||void 0===O?void 0:O.status)===Ee.BX9.PENDING_MATCHES||(null===O||void 0===O?void 0:O.status)===Ee.BX9.FAILED,V=rde(),W=V.deleteRetailSync,j=V.completeRetailSync,H=(0,i.n)(Rce.Hn),K=(0,o.A)(H,1)[0],$=(0,i.n)(Rce._r),Z=(0,o.A)($,1)[0],J=ode(O),X=(0,ide.L)(),Q=(0,o.A)(X,2),ee=Q[0],te=Q[1].open,ne=Yce(null!==O&&void 0!==O?O:null),ae=sde(null===O||void 0===O?void 0:O.status),le=(0,a.useMemo)((()=>{var e;return null!==(e=null===P||void 0===P?void 0:P.retailTransactions)&&void 0!==e?e:[]}),[null===P||void 0===P?void 0:P.retailTransactions]),re=(0,o.A)(le,1)[0],oe=null!==(s=null===re||void 0===re||null===(c=re.transaction)||void 0===c||null===(d=c.merchant)||void 0===d?void 0:d.logoUrl)&&void 0!==s?s:null,ie=null!==(u=null===re||void 0===re||null===(m=re.transaction)||void 0===m||null===(g=m.merchant)||void 0===g?void 0:g.id)&&void 0!==u?u:null,se=(0,l.Zp)(),ce=le.some((e=>{var t;return null===(t=e.transaction)||void 0===t?void 0:t.id})),de=G&&!ce,ue=Y||ce,me=(0,a.useMemo)((()=>(0,Mu.A)((0,mo.A)("id"),le.flatMap((e=>{var t,n;const a=e.transaction;
1return a?a.hasSplitTransactions&&a.splitTransactions.length>0?a.splitTransactions.map((e=>{var t,n;return{id:e.id,merchantName:null===(t=e.merchant)||void 0===t?void 0:t.name,merchantLogoUrl:null===(n=e.merchant)||void 0===n?void 0:n.logoUrl,date:e.date,amount:e.amount,pending:e.pending,category:e.category}})):[{id:a.id,merchantName:null===(t=a.merchant)||void 0===t?void 0:t.name,merchantLogoUrl:null===(n=a.merchant)||void 0===n?void 0:n.logoUrl,date:e.date,amount:e.total,pending:a.pending,category:a.category}]:[]})))),[le]),pe=null===(h=le.find((e=>{var t;return(null===(t=e.transaction)||void 0===t?void 0:t.hasSplitTransactions)&&e.transaction.splitTransactions.length>0})))||void 0===h||null===(v=h.transaction)||void 0===v?void 0:v.id,ge=(0,a.useCallback)((async e=>{if(null===P||void 0===P||!P.id)return;let t;null!==re&&void 0!==re&&re.id&&(void 0!==e.date?t=[{retailTransactionId:re.id,date:e.date,total:re.total}]:void 0!==e.grandTotal&&(t=[{retailTransactionId:re.id,date:re.date,total:e.grandTotal}])),await K({variables:{input:(0,U.A)({retailOrderId:P.id,date:void 0,grandTotal:void 0,lineItemUpdates:void 0,merchantName:void 0,tax:void 0,tip:void 0,totalBeforeTax:void 0,transactionUpdates:t},e)}})}),[null===P||void 0===P?void 0:P.id,re,K]),he=(0,a.useCallback)((async(e,t)=>{var n,a,l,r;await ge({lineItemUpdates:[{retailLineItemId:e,title:null!==(n=t.title)&&void 0!==n?n:void 0,price:null!==(a=t.price)&&void 0!==a?a:void 0,quantity:null!==(l=t.quantity)&&void 0!==l?l:void 0,categoryId:null!==(r=t.categoryId)&&void 0!==r?r:void 0,delete:void 0}]})}),[ge]),ve=(0,a.useCallback)((async e=>{await ge({lineItemUpdates:[{retailLineItemId:e,delete:!0,categoryId:void 0,price:void 0,quantity:void 0,title:void 0}]})}),[ge]),ye=(0,a.useCallback)((async()=>{const e=le.filter((e=>{var t;return null===(t=e.transaction)||void 0===t?void 0:t.id})).map((e=>e.id)).filter((e=>Boolean(e)));if(0===e.length)return{total:0,failedCount:0};const t=(await Promise.allSettled(e.map((e=>Z({variables:{retailTransactionId:e},refetchQueries:["Common_RetailSyncQuery","Common_RetailSyncsQueryWithTotal","Web_GetTransactionDrawer"],awaitRefetchQueries:!0}))))).filter((e=>{var t,n;return"rejected"===e.status||Boolean(null===(t=e.value.data)||void 0===t||null===(n=t.unmatchRetailTransaction)||void 0===n?void 0:n.errors)})).length;return{total:e.length,failedCount:t}}),[le,Z]),be=(0,a.useCallback)((async()=>{const e=await ye(),t=e.total,n=e.failedCount;if(0!==t){if(0!==n)throw(0,C.oR)({title:n===t?"Failed to unlink receipt. Please try again.":"Some transactions couldn't be unlinked. Please try again."}),new Error("Failed to unlink receipt");(0,C.oR)({title:"Receipt unlinked"})}}),[ye]),xe=(0,a.useCallback)((async()=>{if((await ye()).failedCount>0)throw(0,C.oR)({title:"Failed to unlink receipt. Please try again."}),new Error("Failed to unlink receipt");try{var e,t;if(null!==(e=(await W(f)).data)&&void 0!==e&&null!==(t=e.deleteUnmatchedRetailSync)&&void 0!==t&&t.success)return(0,C.oR)({title:"Receipt deleted"}),void E()}catch(n){}throw(0,C.oR)({title:"Failed to delete receipt"}),new Error("Failed to delete receipt")}),[ye,W,f,E]),we=(0,a.useCallback)((async e=>{D(!1);try{await j(f),(0,C.oR)({title:"Transaction created from receipt"}),e&&y?y(e):E()}catch(t){(0,C.oR)({title:"Failed to complete receipt"})}}),[j,f,y,E]);return L?a.createElement(ude,{"data-external-id":"receipt-detail-drawer",title:a.createElement(fe.c8D,{size:"lg",weight:"medium"},"Receipt"),onClose:E},a.createElement(fe.AVK,null),a.createElement("div",{className:"flex items-center justify-center p-3xl"},a.createElement(p.i,{size:"lg"}))):O?a.createElement(a.Fragment,null,a.createElement(ude,{title:a.createElement(fe.c8D,{size:"lg",weight:"medium"},"Receipt details"),onClose:E},a.createElement(fe.AVK,null),a.createElement("div",{className:"flex flex-col gap-default p-xl"},(null===B||void 0===B?void 0:B.originalAssetUrl)&&a.createElement("div",{className:"relative h-50 w-full shrink-0 overflow-hidden rounded-default border border-border-primary"},a.createElement("img",{className:(0,q.cn)("size-full cursor-pointer rounded-default object-cover",B.isGeneratedReceiptImage?"object-top":"object-center",fl.TN.className),src:Vce(B),alt:"Receipt",onClick:()=>window.open(B.originalAssetUrl,"_blank","noopener,noreferrer")}),a.createElement("button",{type:"button",className:" absolute right-sm bottom-sm flex size-8 cursor-pointer items-center justify-center rounded-round border border-border-primary bg-background-primary text-content-primary shadow-sm hover:bg-background-tertiary ",onClick:()=>window.open(B.originalAssetUrl,"_blank","noopener,noreferrer")},a.createElement(fe.uGt,{size:"md"}))),z.length>0&&a.createElement(Hce,{attachments:z}),a.createElement("div",{className:"flex flex-col gap-xs"},a.createElement(fe.c8D,{size:"sm",weight:"medium"},"Status"),a.createElement("div",null,a.createElement(Oc.D,{color:ae},ne))),(null===B||void 0===B?void 0:B.originalAssetUrl)&&de&&a.createElement("div",{className:"flex flex-col gap-xs"},a.createElement(fe.c8D,{weight:"medium"},"Transaction"),a.createElement("div",{className:"flex gap-sm"},a.createElement(fe.XZZ,{size:"sm",className:"min-w-32.5",icon:a.createElement(fe.s$r,null),onClick:()=>k(!0)},"Find match"),a.createElement(fe.XZZ,{size:"sm",className:"min-w-45",icon:a.createElement(fe.Wa3,null),onClick:()=>D(!0)},"Create transaction"))),ce&&a.createElement("div",{className:"flex flex-col gap-xs"},a.createElement("div",{className:"flex items-center justify-between"},a.createElement(fe.c8D,{size:"sm",weight:"medium"},(0,De.td)("Transaction",me.length)),pe&&a.createElement(fe.XZZ,{variant:"text",colorScheme:"link",size:"sm",className:"h-auto px-0",icon:a.createElement(fe.KRt,{size:"xs"}),onClick:()=>te(pe)},"Open splits")),a.createElement("div",{className:"flex flex-col gap-sm"},me.map((e=>a.createElement(ade,{key:e.id,transaction:e,onClick:e=>null===b||void 0===b?void 0:b(e)}))),a.createElement(fe.V0Z,{tone:"destructive",title:"Unlink ".concat((0,De.td)("transaction",me.length)),description:"This receipt will no longer be linked to ".concat(me.length>1?"these transactions":"this transaction","."),confirmLabel:"Unlink",onConfirm:be,trigger:a.createElement(fe.XZZ,{variant:"danger",className:"mt-2xs w-full"},"Unlink ",(0,De.td)("transaction",me.length))}))),ce&&a.createElement(a.Fragment,null,a.createElement(fe.AVK,{className:"my-xs"}),a.createElement("div",{className:"flex flex-col gap-2xs"},a.createElement(fe.c8D,{size:"lg",weight:"medium",className:""},"Receipt details"),a.createElement(fe.c8D,{color:"secondary",size:"sm"},"Once a receipt is matched with a transaction, you won't be able to change the receipt details."))),a.createElement("div",{className:"flex flex-col gap-xs"},a.createElement(fe.c8D,{size:"sm",weight:"medium"},"Merchant"),a.createElement("div",{className:"flex items-stretch gap-2xs"},a.createElement("div",{className:"min-w-0 flex-1"},de?a.createElement("div",{className:(0,q.cn)("[&>button]:box-border [&>button]:h-auto [&>button]:w-full",fl.TN.className)},a.createElement(Dce.Fl,{fullWidthTrigger:!0,alwaysShowBorder:!0,transactionMerchantName:null===P||void 0===P?void 0:P.merchantName,transactionProviderDescription:null===P||void 0===P?void 0:P.merchantName,value:null!==P&&void 0!==P&&P.merchantName?{value:P.merchantName,label:P.merchantName}:void 0,renderSelectedOption:e=>{let t=e.label;return a.createElement("div",{className:"flex min-w-0 items-center gap-xs"},a.createElement(Wl._,{url:oe,size:24}),a.createElement("span",{className:"truncate"},t))},onChange:async e=>{e&&await ge({merchantName:e})}})):a.createElement(qce,{value:null===P||void 0===P?void 0:P.merchantName,fieldType:"text",editable:!1,leadingContent:a.createElement(Wl._,{url:oe,size:24})})),ie&&a.createElement("button",{type:"button","aria-label":"Go to merchant",onClick:()=>se(I.JZ.merchants({id:ie})),className:" flex shrink-0 items-center justify-center rounded-sm border border-border-primary bg-background-primary px-xs text-content-primary transition-colors hover:cursor-pointer hover:bg-background-secondary "},a.createElement(fe.Fug,{size:"xs"})))),a.createElement("div",{className:"flex flex-col gap-xs"},a.createElement(fe.c8D,{size:"sm",weight:"medium"},"Date"),de?a.createElement(qce,{value:null===P||void 0===P?void 0:P.date,fieldType:"date",editable:!0,onSave:e=>ge({date:e})}):a.createElement(qce,{value:null!==P&&void 0!==P&&P.date?N.c9.fromISO(P.date).toLocaleStr
1ing(N.c9.DATE_FULL):"",fieldType:"text",editable:!1})),a.createElement("div",{className:"flex gap-default"},a.createElement("div",{className:"flex flex-1 flex-col gap-xs"},a.createElement(fe.c8D,{size:"sm",weight:"medium"},"Subtotal"),a.createElement(qce,{value:null===P||void 0===P?void 0:P.totalBeforeTax,fieldType:"currency",editable:de,onSave:e=>ge({totalBeforeTax:parseFloat(e)||0})})),a.createElement("div",{className:"flex flex-1 flex-col gap-xs"},a.createElement(fe.c8D,{size:"sm",weight:"medium"},"Tax"),a.createElement(qce,{value:null===P||void 0===P?void 0:P.tax,fieldType:"currency",editable:de,onSave:e=>ge({tax:parseFloat(e)||0})}))),a.createElement("div",{className:"flex flex-col gap-xs"},a.createElement(fe.c8D,{size:"sm",weight:"medium"},"Total"),a.createElement(qce,{value:null===P||void 0===P?void 0:P.grandTotal,fieldType:"currency",editable:de,onSave:e=>ge({grandTotal:parseFloat(e)||0})})),F.length>0&&a.createElement("div",{className:"flex flex-col gap-xs"},a.createElement(fe.c8D,{size:"sm",weight:"medium"},"Line items"),a.createElement("div",{className:(0,q.cn)("flex flex-col overflow-hidden rounded-sm border border-border-primary",de?"bg-background-primary":"bg-background-secondary")},F.map(((e,t)=>a.createElement(a.Fragment,{key:e.id},t>0&&a.createElement(fe.AVK,{color:"secondary"}),a.createElement(nde,{lineItem:e,editMode:de?"full":"readOnly",onUpdate:he,onDelete:ve})))))),de&&!(null!==B&&void 0!==B&&B.originalAssetUrl)&&a.createElement("div",{className:"flex flex-wrap gap-sm"},a.createElement(fe.XZZ,{size:"sm",icon:a.createElement(fe.s$r,null),onClick:()=>k(!0)},"Find match"),a.createElement(fe.XZZ,{size:"sm",icon:a.createElement(fe.Wa3,null),onClick:()=>D(!0)},"Create transaction")),a.createElement(fe.V0Z,{tone:"destructive",title:"Delete receipt",description:ce?"This receipt will be permanently deleted from Monarch and removed from the linked ".concat((0,De.td)("transaction",me.length),". This cannot be undone."):"This receipt will be permanently deleted from Monarch. This cannot be undone.",confirmLabel:"Delete receipt",onConfirm:xe,trigger:a.createElement(fe.XZZ,{variant:"danger",className:"w-full",disabled:!ue},"Delete receipt")}))),A&&a.createElement(Lce,{retailSync:O,onClose:()=>k(!1),onDone:()=>{k(!1)}}),a.createElement(ee,null),_&&J&&a.createElement(um.b,{onClose:()=>D(!1)},(()=>a.createElement(lde.t,{initialValues:J,onDone:we,onCancel:()=>D(!1)})))):a.createElement(ude,{"data-external-id":"receipt-detail-drawer",title:a.createElement(fe.c8D,{size:"lg",weight:"medium"},"Receipt"),onClose:E},a.createElement(fe.AVK,null),a.createElement("div",{className:"flex flex-col gap-default p-xl"},a.createElement(fe.c8D,{color:"secondary",className:"p-3xl text-center"},"Receipt not found")))},ude=(0,$d.s)(F7.v)(cde||(cde=(0,wc.A)(['\n**:data-[component="NavigationHeader"]:py-sm **:data-[component="NavigationHeader"]:pr-default **:data-[component="NavigationHeader"]:pl-xl\n'])));var mde=n(68227);const pde=e=>{var t,n,l,r,o,i,s,c,d,u,m,g,h;let v=e.retailSync,f=e.onClick,E=e.onDelete,y=e.onReUpload;const b=null===(t=v.orders)||void 0===t?void 0:t[0],x=Uce(v.attachments),w=v.status===Ee.BX9.IN_PROGRESS,C=v.status===Ee.BX9.FAILED,A=null===b||void 0===b||null===(n=b.retailTransactions)||void 0===n||null===(l=n[0])||void 0===l||null===(r=l.transaction)||void 0===r||null===(o=r.merchant)||void 0===o?void 0:o.name,I=null!==A&&void 0!==A?A:null===b||void 0===b?void 0:b.merchantName,k=null!==I&&void 0!==I?I:"Receipt image",S=Boolean(I),N=null===b||void 0===b||null===(i=b.retailTransactions)||void 0===i||null===(s=i[0])||void 0===s||null===(c=s.transaction)||void 0===c||null===(d=c.merchant)||void 0===d?void 0:d.logoUrl,T=null!==N&&void 0!==N&&N.startsWith("http")?N:null,_=null!==(null===b||void 0===b?void 0:b.grandTotal)&&void 0!==(null===b||void 0===b?void 0:b.grandTotal),D=null!==(u=null===b||void 0===b||null===(m=b.retailTransactions)||void 0===m||null===(g=m[0])||void 0===g||null===(h=g.transaction)||void 0===h?void 0:h.hasSplitTransactions)&&void 0!==u&&u;return a.createElement(hde,{"data-external-id":"receipt-list-item",role:"button",tabIndex:0,onClick:f,onKeyDown:e=>{e.target===e.currentTarget&&(0,mde.l)(e,(()=>f()))}},a.createElement(vde,null,null!==x&&void 0!==x&&x.thumbnailUrl?a.createElement(fde,Object.assign({},fl.TN,{$isGenerated:x.isGeneratedReceiptImage,src:x.thumbnailUrl,alt:"Receipt"})):a.createElement(Ede,null,a.createElement(sl.ZQ,{name:"scan-receipt",size:20}))),a.createElement(yde,fl.TN,S&&a.createElement(Wl._,{url:T,size:20}),a.createElement(bde,null,k)),a.createElement(xde,null,a.createElement(gde,{retailSync:v})),a.createElement(Ade,null,C&&a.createElement(kde,null,E&&a.createElement(Sde,{onClick:e=>{e.stopPropagation(),E(v.id)}}),y&&a.createElement(wt.Xb,{size:"small",onClick:e=>{e.stopPropagation(),y(v.id)}},"Re-upload")),w?a.createElement(Nde,null,a.createElement(p.i,{size:"sm"})):a.createElement(a.Fragment,null,a.createElement(Ide,null,D&&a.createElement(Tde,{name:"split",size:14}),_&&a.createElement(xt.v,Object.assign({color:"content.primary",align:"right"},fl.zs),(0,rl.vv)(Math.abs(b.grandTotal)))),a.createElement(B.L,{className:"fs-drawer-toggle",icon:"chevron-right",size:"xsmall",tabIndex:-1,type:"button"}))))},gde=e=>{let t=e.retailSync;const n=t.status===Ee.BX9.IN_PROGRESS,l=n?"Scanning...":Yce(t),o=sde(t.status),i=(s=t.status,(0,r.YW)(s).with(Ee.BX9.IN_PROGRESS,(()=>"scan-receipt")).with(Ee.BX9.FAILED,(()=>"alert-triangle")).with(Ee.BX9.COMPLETED,(()=>"check-circle")).with(Ee.BX9.PENDING,(()=>"clock")).otherwise((()=>null)));var s;const c=t.status===Ee.BX9.FAILED,d=a.createElement(Oc.D,{color:o},a.createElement(Cde,null,n&&a.createElement(sl.ZQ,{name:"sparkle",size:12}),!n&&i&&a.createElement(sl.ZQ,{name:i,size:12}),l));
1return c?a.createElement(P.D_,{"data-external-id":"status-badge",content:"Poor lighting, wrinkled paper, and smudges on camera lens can cause text to be unreadable.",place:"top",maxWidth:240},a.createElement(wde,null,d)):d},hde=u.default.div.withConfig({displayName:"ReceiptListItem__Root",componentId:"sc-1x91v0c-0"})(["display:flex;align-items:center;gap:",";padding:"," "," "," ",";width:100%;border:none;border-bottom:1px solid ",";background:none;cursor:pointer;text-align:left;&:last-child{border-bottom:none;}&:hover{background-color:",";}"],vt.YK.default,vt.YK.default,vt.YK.xsmall,vt.YK.default,vt.YK.default,vt.Ee.color.divider.primary,vt.Ee.color.background.primaryHover),vde=u.default.div.withConfig({displayName:"ReceiptListItem__ThumbnailCell",componentId:"sc-1x91v0c-1"})(["width:32px;height:32px;flex-shrink:0;border:1px solid ",";border-radius:",";overflow:hidden;"],vt.Ee.color.divider.secondary,vt.r8.xsmall),fde=u.default.img.withConfig({displayName:"ReceiptListItem__Thumbnail",componentId:"sc-1x91v0c-2"})(["width:100%;height:100%;object-fit:cover;object-position:",";"],(e=>e.$isGenerated?"top":"center")),Ede=(0,u.default)(m.g).attrs({center:!0}).withConfig({displayName:"ReceiptListItem__ThumbnailPlaceholder",componentId:"sc-1x91v0c-3"})(["width:100%;height:100%;background-color:",";color:",";"],vt.Ee.color.background.tertiary,vt.Ee.color.content.secondary),yde=(0,u.default)(m.g).attrs({alignCenter:!0,gap:"xsmall"}).withConfig({displayName:"ReceiptListItem__MerchantCell",componentId:"sc-1x91v0c-4"})(["flex:0 1 30%;min-width:0;"]),bde=(0,u.default)(xt.v).withConfig({displayName:"ReceiptListItem__MerchantName",componentId:"sc-1x91v0c-5"})(["overflow:hidden;text-overflow:ellipsis;white-space:nowrap;color:",";"],vt.Ee.color.content.primary),xde=u.default.div.withConfig({displayName:"ReceiptListItem__BadgeCell",componentId:"sc-1x91v0c-6"})(["flex:1;min-width:0;overflow:hidden;> span{max-width:100%;overflow:hidden;text-overflow:ellipsis;}"]),wde=u.default.span.withConfig({displayName:"ReceiptListItem__BadgeWrapper",componentId:"sc-1x91v0c-7"})(["display:inline-flex;cursor:default;"]),Cde=u.default.span.withConfig({displayName:"ReceiptListItem__BadgeContent",componentId:"sc-1x91v0c-8"})(["display:inline-flex;align-items:center;gap:4px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;"]),Ade=(0,u.default)(m.g).attrs({alignCenter:!0,gap:"xxsmall"}).withConfig({displayName:"ReceiptListItem__RightCell",componentId:"sc-1x91v0c-9"})(["flex-shrink:0;margin-left:auto;"]),Ide=(0,u.default)(m.g).attrs({justifyEnd:!0,alignCenter:!0,gap:"xxsmall"}).withConfig({displayName:"ReceiptListItem__TrailingAmountGroup",componentId:"sc-1x91v0c-10"})(["flex-shrink:0;"]),kde=(0,u.default)(m.g).attrs({alignCenter:!0,gap:"xsmall"}).withConfig({displayName:"ReceiptListItem__ActionsContainer",componentId:"sc-1x91v0c-11"})(["flex-shrink:0;"]),Sde=(0,u.default)(B.L).attrs({icon:"trash",size:"xxsmall",color:"content.danger"}).withConfig({displayName:"ReceiptListItem__DeleteButton",componentId:"sc-1x91v0c-12"})([""]),Nde=u.default.div.withConfig({displayName:"ReceiptListItem__SpinnerContainer",componentId:"sc-1x91v0c-13"})(["display:flex;align-items:center;justify-content:center;width:80px;"]),Tde=(0,u.default)(sl.ZQ).withConfig({displayName:"ReceiptListItem__SplitIcon",componentId:"sc-1x91v0c-14"})(["color:",";flex-shrink:0;"],vt.Ee.color.content.secondary),_de={google:fe.VF4},Dde=e=>{var t;let n=e.providerKey,l=e.className;const r=null!==(t=_de[n])&&void 0!==t?t:fe.zSC;return a.createElement(r,{"data-external-id":"receipt-forwarding-provider-icon",className:l})},Rde=((0,Qt.J)("\n  fragment ReceiptForwardingAliasFields on ReceiptForwardingAliasType {\n    id\n    address\n    lastReceivedAt\n    addressCopiedAt\n    isSetupPending\n    createdAt\n    sources {\n      id\n      provider\n      forwardingAccount\n      status\n      isConfirmed\n      isActive\n      confirmedAt\n      lastReceivedAt\n    }\n  }\n"),(0,Qt.J)("\n  query Common_GetReceiptForwarding {\n    receiptForwardingAddress\n    receiptForwardingProviders {\n      key\n      displayName\n      helpUrl\n    }\n    receiptForwardingAlias {\n      ...ReceiptForwardingAliasFields\n    }\n  }\n")),Mde=(0,Qt.J)("\n  mutation Common_MarkReceiptForwardingAddressCopied {\n    markReceiptForwardingAddressCopied {\n      receiptForwardingAlias {\n        ...ReceiptForwardingAliasFields\n      }\n      errors {\n        ...PayloadErrorFields\n      }\n    }\n  }\n"),Lde=(0,Qt.J)("\n  mutation Common_CreateReceiptForwardingAlias {\n    createReceiptForwardingAlias {\n      receiptForwardingAlias {\n        ...ReceiptForwardingAliasFields\n      }\n      errors {\n        ...PayloadErrorFields\n      }\n    }\n  }\n"),Ode=(0,Qt.J)("\n  mutation Common_RotateReceiptForwardingAlias {\n    rotateReceiptForwardingAlias {\n      receiptForwardingAlias {\n        ...ReceiptForwardingAliasFields\n      }\n      errors {\n        ...PayloadErrorFields\n      }\n    }\n  }\n"),Pde=(0,Qt.J)("\n  mutation Common_RevokeReceiptForwardingSource($id: ID!) {\n    revokeReceiptForwardingSource(id: $id) {\n      success\n      errors {\n        ...PayloadErrorFields\n      }\n    }\n  }
1\n"),Bde=(0,Qt.J)("\n  mutation Common_ResumeReceiptForwardingSource($id: ID!) {\n    resumeReceiptForwardingSource(id: $id) {\n      success\n      errors {\n        ...PayloadErrorFields\n      }\n    }\n  }\n"),zde=(0,Qt.J)("\n  mutation Common_RemoveReceiptForwardingSource($id: ID!) {\n    removeReceiptForwardingSource(id: $id) {\n      success\n      errors {\n        ...PayloadErrorFields\n      }\n    }\n  }\n"),Fde=((0,Qt.J)("\n  mutation Common_ResetReceiptForwarding {\n    resetReceiptForwarding {\n      resetSummary {\n        deletedAliases\n        deletedSources\n      }\n      errors {\n        ...PayloadErrorFields\n      }\n    }\n  }\n"),()=>{var e,t,n;const l=(0,et.I)(Rde,{fetchPolicy:"cache-and-network",pollInterval:15e3}),r=l.data,s=l.error,c=l.isLoadingInitialData,d=l.refetch,u=null!==(e=null===r||void 0===r?void 0:r.receiptForwardingAlias)&&void 0!==e?e:null,m=null!==(t=null===r||void 0===r?void 0:r.receiptForwardingAddress)&&void 0!==t?t:null,p=(0,a.useMemo)((()=>{var e;return null!==(e=null===r||void 0===r?void 0:r.receiptForwardingProviders)&&void 0!==e?e:[]}),[r]),g=(0,a.useMemo)((()=>{var e;return null!==(e=null===u||void 0===u?void 0:u.sources)&&void 0!==e?e:[]}),[null===u||void 0===u?void 0:u.sources]),h=(0,a.useMemo)((()=>[...g].sort(((e,t)=>{const n=e=>e.isActive?0:1;return n(e)-n(t)}))),[g]),v=(0,a.useMemo)((()=>0===g.length&&!!(null===u||void 0===u?void 0:u.lastReceivedAt)),[g.length,null===u||void 0===u?void 0:u.lastReceivedAt]),f=(0,i.n)(Mde,{refetchQueries:[Rde]}),E=(0,o.A)(f,1)[0],y=(0,i.n)(Lde,{refetchQueries:[Rde]}),b=(0,o.A)(y,1)[0],x=(0,i.n)(Ode,{refetchQueries:[Rde]}),w=(0,o.A)(x,1)[0],C=(0,i.n)(Pde,{refetchQueries:[Rde]}),A=(0,o.A)(C,1)[0],I=(0,i.n)(Bde,{refetchQueries:[Rde]}),k=(0,o.A)(I,1)[0],S=(0,i.n)(zde,{refetchQueries:[Rde]}),N=(0,o.A)(S,1)[0],T=(0,a.useCallback)((async()=>{var e,t;const n=(await E()).data,a=null===n||void 0===n?void 0:n.markReceiptForwardingAddressCopied;return{alias:null!==(e=null===a||void 0===a?void 0:a.receiptForwardingAlias)&&void 0!==e?e:null,errors:null!==(t=null===a||void 0===a?void 0:a.errors)&&void 0!==t?t:null}}),[E]),_=(0,a.useState)(!1),D=(0,o.A)(_,2),R=D[0],M=D[1],L=(0,a.useState)(!1),O=(0,o.A)(L,2),P=O[0],B=O[1],z=(0,a.useCallback)((async()=>{var e,t;M(!0),B(!1);try{const n=(await b()).data,a=null===n||void 0===n?void 0:n.createReceiptForwardingAlias;return B(!(null===a||void 0===a?void 0:a.receiptForwardingAlias)),{alias:null!==(e=null===a||void 0===a?void 0:a.receiptForwardingAlias)&&void 0!==e?e:null,errors:null!==(t=null===a||void 0===a?void 0:a.errors)&&void 0!==t?t:null}}catch(n){return B(!0),{alias:null,errors:{message:_t.Rb}}}finally{M(!1)}}),[b]),F=(0,a.useRef)(!1);(0,a.useEffect)((()=>{F.current||!r||r.receiptForwardingAlias||(F.current=!0,z())}),[r,z]);const G=(0,a.useCallback)((async()=>{var e,t;const n=(await w()).data,a=null===n||void 0===n?void 0:n.rotateReceiptForwardingAlias;return{alias:null!==(e=null===a||void 0===a?void 0:a.receiptForwardingAlias)&&void 0!==e?e:null,errors:null!==(t=null===a||void 0===a?void 0:a.errors)&&void 0!==t?t:null}}),[w]),Y=(0,a.useCallback)((async e=>{var t,n;const a=(await A({variables:{id:e}})).data,l=null===a||void 0===a?void 0:a.revokeReceiptForwardingSource;return{success:null!==(t=null===l||void 0===l?void 0:l.success)&&void 0!==t&&t,errors:null!==(n=null===l||void 0===l?void 0:l.errors)&&void 0!==n?n:null}}),[A]),U=(0,a.useCallback)((async e=>{var t,n;const a=(await k({variables:{id:e}})).data,l=null===a||void 0===a?void 0:a.resumeReceiptForwardingSource;return{success:null!==(t=null===l||void 0===l?void 0:l.success)&&void 0!==t&&t,errors:null!==(n=null===l||void 0===l?void 0:l.errors)&&void 0!==n?n:null}}),[k]),V=(0,a.useCallback)((async e=>{var t,n;const a=(await N({variables:{id:e}})).data,l=null===a||void 0===a?void 0:a.removeReceiptForwardingSource;return{success:null!==(t=null===l||void 0===l?void 0:l.success)&&void 0!==t&&t,errors:null!==(n=null===l||void 0===l?void 0:l.errors)&&void 0!==n?n:null}}),[N]);return{alias:u,sharedAddress:m,providers:p,sources:h,hasUnattributedDelivery:v,isSetupPending:null!==(n=null===u||void 0===u?void 0:u.isSetupPending)&&void 0!==n&&n,hasLoadError:!!s&&!r,isLoadingInitialData:c,isCreatingAlias:R||!!r&&!u&&!P,hasCreateFailed:P,refetch:d,markAddressCopied:T,createAlias:z,rotateAlias:G,revokeSource:Y,resumeSource:U,removeSource:V}});var Gde,Yde;const Ude="https://mail.google.com/mail/u/0/#settings/fwdandpop",Vde=()=>{const e=Fde(),t=e.alias,n=e.sources,l=e.isSetupPending,r=e.hasUnattributedDelivery,i=e.hasLoadError,s=e.isLoadingInitialData,c=e.isCreatingAlias,d=e.refetch,u=e.markAddressCopied,m=e.createAlias,p=e.rotateAlias,g=e.revokeSource,h=e.resumeSource,v=e.removeSource,f=(0,a.useState)(!1),E=(0,o.A)(f,2),y=E[0],b=E[1],x=(0,a.useState)(null),w=(0,o.A)(x,2),A=w[0],I=w[1],k=(0,a.useCallback)((async()=>
1{if(t){try{await(0,Bd.l)(t.address)}catch(n){return void(0,C.oR)({title:"We couldn\u2019t copy the address. Please copy it manually."})}b(!0),setTimeout((()=>b(!1)),2e3),(0,Ge.u4)(Ye.IP.AutoForwardingAddressCopied);try{const t=(await u()).errors;var e;if(t)(0,C.oR)({title:null!==(e=t.message)&&void 0!==e?e:_t.Rb})}catch(a){(0,C.oR)({title:_t.Rb})}}}),[t,u]),S=(0,a.useCallback)((async()=>{const e=(await m()).errors;var t;e&&(0,C.oR)({title:null!==(t=e.message)&&void 0!==t?t:_t.Rb})}),[m]),N=(0,a.useCallback)((async()=>{let e;try{e=await p()}catch(a){throw(0,C.oR)({title:_t.Rb}),a}const t=e.errors;var n;if(t)throw(0,C.oR)({title:null!==(n=t.message)&&void 0!==n?n:_t.Rb}),new Error("Failed to rotate forwarding address");(0,Ge.u4)(Ye.IP.AutoForwardingAliasRotated),(0,C.oR)({title:"New forwarding address generated"})}),[p]),T=(0,a.useCallback)((async(e,t)=>{try{const a=await e(t),l=a.success,r=a.errors;var n;if(!l)(0,C.oR)({title:null!==(n=null===r||void 0===r?void 0:r.message)&&void 0!==n?n:_t.Rb});return l}catch(a){return(0,C.oR)({title:_t.Rb}),!1}}),[]),_=(0,a.useCallback)((async e=>{if(!await T(g,e.id))throw new Error("Failed to stop receipt forwarding source");(0,Ge.u4)(Ye.IP.AutoForwardingSourceRevoked),(0,C.oR)({title:"Stopped. Receipts already imported are unaffected."})}),[g,T]),D=(0,a.useCallback)((async e=>{I(e.id);try{await T(h,e.id)&&(0,Ge.u4)(Ye.IP.AutoForwardingSourceResumed)}finally{I(null)}}),[h,T]),R=(0,a.useCallback)((async e=>{if(!await T(v,e.id))throw new Error("Failed to remove receipt forwarding source");(0,Ge.u4)(Ye.IP.AutoForwardingSourceRemoved)}),[v,T]),M=n.length>0||l||r;let L;return L=t?a.createElement(Xde,{type:"button","aria-label":"Forward emails to ".concat(t.address," \u2014 copy address"),onClick:k},a.createElement(fe.c8D,{size:"base",className:"min-w-0 truncate"},"Forward emails to"," ",a.createElement(fe.c8D,{render:a.createElement("span",null),size:"inherit",weight:"medium",color:"link",className:"select-text"},t.address)),a.createElement("span",{className:"flex size-8 shrink-0 items-center justify-center rounded-round text-content-primary"},y?a.createElement(fe.GdR,{className:"size-4"}):a.createElement(fe.LpV,{className:"size-4"}))):s||c?a.createElement(Xde,{type:"button",disabled:!0},a.createElement(fe.c8D,{size:"base",className:"min-w-0 truncate"},"Getting your forwarding address\u2026"),a.createElement(fe.ix7,{size:"2xs"})):i?a.createElement(Qde,null,a.createElement(fe.c8D,{size:"base",className:"min-w-0 truncate"},"We couldn\u2019t load your forwarding address"),a.createElement(fe.XZZ,{size:"sm",onClick:()=>d()},"Try again")):a.createElement(Qde,null,a.createElement(fe.c8D,{size:"base",className:"min-w-0 truncate"},"We couldn\u2019t set up your forwarding address"),a.createElement(fe.XZZ,{size:"sm",onClick:S},"Try again")),a.createElement("div",{"data-external-id":"auto-forwarding-section",className:"flex flex-col gap-xl"},a.createElement("div",{className:"flex flex-col gap-default"},a.createElement("div",{className:"flex flex-col gap-2xs"},a.createElement(fe.c8D,{size:"base",weight:"medium"},"Auto-forwarding from Gmail"),a.createElement(fe.c8D,{size:"sm",color:"secondary",className:"text-pretty"},"Add this address in Gmail as a forwarding address, then create a filter that sends receipts to it. We\u2019ll confirm it for you, so Gmail won\u2019t ask you for a verification code."," ",a.createElement(fe.liZ,{size:"sm",href:VF.rq,external:!0},"See Gmail setup instructions."))),L),!!t&&a.createElement("div",{className:"flex flex-col gap-sm"},a.createElement(fe.c8D,{size:"base",weight:"medium"},"Your Gmail connections"),!M&&a.createElement(fe.erR,{variant:"secondary",icon:a.createElement(fe.zSC,null),title:"No Gmail connections yet",description:"Copy the address above, then add it in Gmail under Settings \u2192 Forwarding and POP/IMAP \u2192 Add a forwarding address.",actions:a.createElement(Jde,{href:Ude})}),M&&a.createElement(eue,null,n.map((e=>a.createElement(jde,{key:e.id,source:e,isResuming:A===e.id,onStop:_,onResume:D,onRemove:R}))),r&&a.createElement(qde,{lastReceivedAt:null===t||void 0===t?void 0:t.lastReceivedAt}),!r&&l&&a.createElement($de,{copiedAt:null===t||void 0===t?void 0:t.addressCopiedAt})),M&&a.createElement(fe.V0Z,{tone:"destructive",title:"Generate a new address?",description:n.length>0?"Forwarding you have already set up will stop working, and you will need to give the new address to Gmail.":"The current address will stop working immediately.",confirmLabel:"Generate a new address",onConfirm:N,trigger:a.createElement(fe.XZZ,{size:"sm",variant:"danger",className:"self-start"},"Generate a new address")})))},Wde=e=>{if(!e)return null;const t=N.c9.fromISO(e);return N.c9.now().diff(t,"seconds").seconds<60?"just now":t.toRelative()},jde=e=>{let t=e.source,n=e.isResuming,l=e.onStop,r=e.onResume,o=e.onRemove;if("STOPPED"===t.status||"REMOVABLE"===t.status){const e="STOPPED"===t.status;return a.createElement(Zde,{"data-external-id":"source-row",tone:"warning",icon:a.createElement(fe.WU2,{size:"2xs"}),overline:e?"Stopped \xb7 Gmail still forwarding":"Stopped",title:t.forwardingAccount,providerKey:t.provider,body:e?"Disable forwarding in Gmail under Settings \u2192 Forwarding and POP/IMAP, and it drops off this list on its own.":void 0,actions:e?a.createElement(Jde,{href:Ude}):void 0,trailing:e?a.createElement(fe.XZZ,{size:"sm",isLoading:n,"aria-label":"Resume forwarding from ".concat(t.forwardingAccount),onClick:()=>r(t)},"Resume forwarding"):a.createElement(Hde,{source:t,onRemove:o})})}if("STALE"===t.status)return a.createElement(Zde,{"data-external-id":"source-row",tone:"warning",icon:a.createElement(fe.WU2,{size:"2xs"}),overline:"No emails in 30 days",title:t.forwardingAccount,providerKey:t.provider,body:"Check that forwarding is still on in Gmail: Settings \u2192 Filters and Blocked Addresses, and confirm your receipt filter still forwards to this address.",actions:a.createElement(Jde,{href:"https://mail.google.com/mail/u/0/#settings/filters"},"Open Gmail filters"),trailing:a.createElement(Kde,{source:t,onStop:l})});const i=Wde(t.lastReceivedAt);return a.createElement(Zde,{"data-external-id":"source-row",tone:"success",icon:a.createElement(fe.GdR,{size:"2xs"}),overline:i?"Active \xb7 Last receipt ".concat(i):"Active",title:t.forwardingAccount,providerKey:t.provider,trailing:a.createElement(Kde,{source:t,onStop:l})})},Hde=e=>{let t=e.source,n=e.onRemove;return a.createElement(fe.V0Z,{"data-external-id":"remove-dialog",tone:"destructive",title:"Remove this connection?",description:"This drops the Gmail connection from this list. Receipts already imported are unaffected, and re-forwarding from Gmail brings it back.",confirmLabel:"Remove c
1onnection",onConfirm:()=>n(t),trigger:a.createElement(fe.XZZ,{size:"sm",variant:"danger","aria-label":"Remove connection to ".concat(t.forwardingAccount)},"Remove connection")})},Kde=e=>{let t=e.source,n=e.onStop;return a.createElement(fe.V0Z,{"data-external-id":"stop-dialog",tone:"destructive",title:"Stop auto-forwarding?",description:"We'll ignore receipts forwarded from ".concat(t.forwardingAccount," until you resume it. Gmail keeps sending them either way \u2014 we can't turn forwarding off for you."),confirmLabel:"Stop forwarding",onConfirm:()=>n(t),trigger:a.createElement(fe.XZZ,{size:"sm",variant:"danger","aria-label":"Stop forwarding from ".concat(t.forwardingAccount)},"Stop forwarding")})},qde=e=>{let t=e.lastReceivedAt;const n=Wde(t);return a.createElement(Zde,{"data-external-id":"unattributed-row",tone:"success",icon:a.createElement(fe.GdR,{size:"2xs"}),overline:n?"Active \xb7 Last receipt ".concat(n):"Active",title:"Receiving forwarded mail",body:"We can't confirm which account these are coming from, but the receipts are importing normally."})},$de=e=>{let t=e.copiedAt;const n=Wde(t);return a.createElement(Zde,{"data-external-id":"pending-row",tone:"warning",icon:a.createElement(fe.FWg,{size:"2xs"}),overline:n?"Address copied ".concat(n):"Address copied",title:"No emails received yet from Gmail",trailing:a.createElement(Jde,{href:Ude})})},Zde=e=>{let t=e.tone,n=e.icon,l=e.overline,r=e.title,o=e.providerKey,i=e.body,s=e.actions,c=e.trailing;return a.createElement("div",{"data-external-id":"row",className:"flex items-start gap-sm p-default"},a.createElement(fe.CWN,{shape:"circle",size:"sm",color:"success"===t?"green":"yellow",icon:n,className:"mt-3xs shrink-0"}),a.createElement("div",{className:"flex min-w-0 flex-1 flex-col gap-xs"},a.createElement("div",{className:"flex flex-col"},a.createElement(fe.c8D,{size:"xs",color:"secondary"},l),a.createElement("div",{className:"flex min-w-0 items-center gap-2xs"},o&&a.createElement(Dde,{providerKey:o,className:"size-4 shrink-0"}),a.createElement(fe.c8D,{size:"base",className:"min-w-0 truncate"},r))),i&&a.createElement(fe.c8D,{size:"sm",color:"secondary",className:"text-pretty"},i),s&&a.createElement("div",{className:"flex items-center gap-xs pt-2xs"},s)),c)},Jde=e=>{let t=e.href,n=e.className,l=e.children,r=void 0===l?"Open Gmail settings":l;return a.createElement(fe.TZm,{"data-external-id":"gmail-link",href:t,external:!0,size:"sm",endIcon:a.createElement(fe.bYN,null),className:n},r)},Xde=e=>a.createElement(fe.XZZ,Object.assign({"data-external-id":"address-button",variant:"unstyled",className:" flex w-full items-center justify-between gap-xs rounded-default border-none bg-background-secondary px-default py-sm text-left "},e)),Qde=$d.s.div(Gde||(Gde=(0,wc.A)(["\n  flex w-full items-center justify-between gap-xs rounded-default bg-background-secondary px-default\n  py-sm\n"]))),eue=$d.s.div(Yde||(Yde=(0,wc.A)(["\n  flex flex-col divide-y divide-divider-primary overflow-hidden rounded-default border border-divider-primary\n"]))),tue=(0,Qt.J)("\n  query Common_GetRetailExtensionSettings {\n    retailExtensionSettings {\n      id\n      retailVendorSettings {\n        id\n        vendor\n        shouldCategorizeAndSplitTransactions\n        shouldUpdateTransactionsNotes\n        merchant {\n          id\n          name\n          logoUrl\n        }\n      }\n    }\n  }\n"),nue=(0,Qt.J)("\n  mutation Common_UpdateRetailVendorSettings($input: UpdateRetailVendorSettingsInput!) {\n    updateRetailVendorSettings(input: $input) {\n      retailVendorSettings {\n        id\n        vendor\n        shouldCategorizeAndSplitTransactions\n        shouldUpdateTransactionsNotes\n        merchant {\n          id\n          name\n          logoUrl\n        }\n      }\n      errors {\n        ...PayloadErrorFields\n      }\n    }\n  }\n"),aue=()=>{const e=(0,et.I)(tue,{fetchPolicy:"cache-first"}),t=e.data,n=e.isLoadingInitialData,l=(0,a.useMemo)((()=>{var e;const n=null===t||void 0===t||null===(e=t.retailExtensionSettings)||void 0===e?void 0:e.retailVendorSettings;return null===n||void 0===n?void 0:n.find((e=>
1e.vendor===Ee.XcS.USER_IMPORT))}),[t]),r=(0,i.n)(nue),s=(0,o.A)(r,1)[0],c=(0,a.useCallback)((e=>s({variables:{input:{vendor:Ee.XcS.USER_IMPORT,shouldCategorizeAndSplitTransactions:e.shouldCategorizeAndSplitTransactions,shouldUpdateTransactionsNotes:e.shouldUpdateTransactionsNotes,merchantName:void 0,shouldUpdatePastTransactions:void 0}},optimisticResponse:l?{__typename:"Mutation",updateRetailVendorSettings:{__typename:"UpdateRetailVendorSettings",retailVendorSettings:(0,U.A)((0,U.A)({},l),e),errors:null}}:void 0})),[s,l]);return{receiptSettings:l,isLoadingInitialData:n,updateReceiptSettings:c}},lue=()=>{var e,t;const n=aue(),l=n.receiptSettings,r=n.updateReceiptSettings,o=null!==(e=null===l||void 0===l?void 0:l.shouldCategorizeAndSplitTransactions)&&void 0!==e&&e,i=null!==(t=null===l||void 0===l?void 0:l.shouldUpdateTransactionsNotes)&&void 0!==t&&t;return a.createElement("div",{"data-external-id":"receipt-transaction-updates-settings",className:"flex flex-col gap-default"},a.createElement(kD.c,{size:"base",weight:"medium"},"Transaction updates"),a.createElement(Cb.p9,{label:"Auto-split transactions",subtext:"Split and categorize matched transactions based on receipt details.",checked:o,onChange:e=>r({shouldCategorizeAndSplitTransactions:e.target.checked})}),a.createElement(Cb.p9,{label:"Add transaction notes",subtext:"Add receipt details to the transaction notes, such as tax, tip and line items, etc.",checked:i,onChange:e=>r({shouldUpdateTransactionsNotes:e.target.checked})}))};var rue,oue,iue,sue,cue;const due=e=>{let t=e.email,n=e.isVerified,l=e.readOnly,r=void 0!==l&&l,i=e.autoFocus,s=void 0!==i&&i,c=e.verificationCode,d=void 0===c?"":c,u=e.onVerificationCodeChange,m=e.onVerify,p=e.isVerifying,g=void 0!==p&&p,h=e.onDelete,v=e.onResend;const f=(0,a.useState)("idle"),E=(0,o.A)(f,2),y=E[0],b=E[1],x="idle"!==y;return a.createElement(uue,{"data-external-id":"trusted-receipt-sender-list-item"},a.createElement(mue,null,a.createElement("div",{className:"mr-sm flex shrink-0 items-center"},n?a.createElement("span",{className:"flex size-5 items-center justify-center rounded-round bg-background-success"},a.createElement(fe.GdR,{size:"xs",className:"text-content-success"})):a.createElement("span",{className:"size-5 rounded-round border border-dashed border-border-secondary"})),a.createElement("div",{className:"flex min-w-0 flex-1 flex-col"},a.createElement("div",{className:"flex min-w-0 items-center gap-xs"},a.createElement(kD.c,{size:"base",className:"truncate"},t),r&&!n&&a.createElement(fe.r8y,{size:"xs",rounded:"pill"},"Not verified")),r&&a.createElement(kD.c,{size:"xs",color:"secondary"},"Your Monarch account"),!r&&!n&&a.createElement(kD.c,{size:"xs",color:"secondary"},"Pending - Check your email for the verification code")),!r&&a.createElement("div",{className:"ml-sm flex shrink-0 items-center"},a.createElement(fe.SO$,{"aria-label":"Remove email",size:"sm",onClick:e=>{e.stopPropagation(),null===h||void 0===h||h()}},a.createElement(fe.i01,{size:"sm"})))),!r&&!n&&a.createElement(pue,null,a.createElement(kD.c,{size:"sm",weight:"medium"},"Verification code"),a.createElement(gue,null,a.createElement(hue,{type:"text",inputMode:"numeric",placeholder:"Enter code",value:d,onChange:e=>null===u||void 0===u?void 0:u(e.target.value),onKeyDown:e=>{"Enter"===e.key&&(null===m||void 0===m||m())},autoFocus:s,disabled:g}),a.createElement(fe.XZZ,{variant:"primary",size:"sm",onClick:m,disabled:!d.trim()||g},"Verify"),v&&a.createElement(Wi.Y,{content:x?"Resending a verification code is available 5 times per hour. If you don't see it, double check your spam folder.":void 0,side:"top",sideOffset:12},a.createElement("span",{className:x?"inline-flex cursor-default":"inline-flex"},a.createElement(fe.XZZ,{variant:"default",size:"sm",onClick:async()=>{if("idle"===y){b("sending");try{await(null===v||void 0===v?void 0:v()),b("sent")}catch(e){b("idle")}}},disabled:x,className:x?"pointer-events-none":void 0,icon:"sent"===y?a.createElement(fe.C14,{size:"sm"}):void 0},"sent"===y?"Sent":"Resend"))))))},uue=$d.s.div(rue||(rue=(0,wc.A)(["border-b border-divider-secondary last:border-b-0"]))),mue=$d.s.div(oue||(oue=(0,wc.A)(["flex h-16 items-center px-default"]))),pue=$d.s.div(iue||(iue=(0,wc.A)(["flex flex-col gap-xs pr-4xl pb-lg pl-3xl"]))),gue=$d.s.div(sue||(sue=(0,wc.A)(["flex items-center gap-sm"]))),hue=$d.s.input(cue||(cue=(0,wc.A)(["\n  h-9 w-50 shrink-0 rounded-sm border border-border-primary bg-background-primary px-sm\n  text-sm text-content-primary outline-none\n  placeholder:text-content-secondary\n  focus:border-border-secondary\n  disabled:opacity-50\n"])));var vue=n(17702);const fue=(0,Qt.J)("\n  query Common_GetTrustedReceiptSenders {\n    trustedReceiptSenders {\n      id\n      email\n      isVerified\n      isActive\n      createdAt\n    }\n  }\n"),Eue=(0,Qt.J)("\n  mutation Common_CreateTrustedReceiptSender($email: String!) {\n    createTrustedReceiptSender(email: $email) {\n      trustedReceiptSender {\n        id\n        email\n        isVerified\n        isActive\n        createdAt\n      }\n      errors {\n        ...PayloadErrorFields\n      }\n    }\n  }\n"),yue=(0,Qt.J)("\n  mutation Common_VerifyTrustedReceiptSender($trustedReceiptSenderId: ID!, $code: String!) {\n    verifyTrustedReceiptSender(trustedReceiptSenderId: $trustedReceiptSenderId, code: $code) {\n      trustedReceiptSender {\n        id\n        email\n        isVerified\n        isActive\n        createdAt\n      }\n      errors {\n        ...PayloadErrorFields\n      }\n    }\n  }
1\n"),bue=(0,Qt.J)("\n  mutation Common_ResendTrustedReceiptSenderVerification($trustedReceiptSenderId: ID!) {\n    resendTrustedReceiptSenderVerification(trustedReceiptSenderId: $trustedReceiptSenderId) {\n      success\n      errors {\n        ...PayloadErrorFields\n      }\n    }\n  }\n"),xue=(0,Qt.J)("\n  mutation Common_DeleteTrustedReceiptSender($id: ID!) {\n    deleteTrustedReceiptSender(id: $id) {\n      success\n      errors {\n        ...PayloadErrorFields\n      }\n    }\n  }\n");var wue,Cue,Aue,Iue;const kue=()=>{const e=(()=>{const e=(0,et.I)(fue,{fetchPolicy:"cache-and-network"}),t=e.data,n=e.isLoadingInitialData,l=(0,et.I)(vue.sK,{fetchPolicy:"cache-first"}).data,r=(0,a.useMemo)((()=>{var e;return[...null!==(e=null===t||void 0===t?void 0:t.trustedReceiptSenders)&&void 0!==e?e:[]].sort(((e,t)=>{const n=new Date(e.createdAt).getTime(),a=new Date(t.createdAt).getTime();return n!==a?n-a:e.id.localeCompare(t.id)}))}),[null===t||void 0===t?void 0:t.trustedReceiptSenders]),s=(0,a.useMemo)((()=>{var e,t,n;return null!==(e=null===l||void 0===l||null===(t=l.myHousehold)||void 0===t||null===(n=t.users)||void 0===n?void 0:n.map((e=>({email:e.email,isVerified:e.hasVerifiedEmail}))))&&void 0!==e?e:[]}),[l]),c=(0,i.n)(Eue,{refetchQueries:[fue]}),d=(0,o.A)(c,1)[0],u=(0,i.n)(yue),m=(0,o.A)(u,1)[0],p=(0,i.n)(bue),g=(0,o.A)(p,1)[0],h=(0,i.n)(xue,{refetchQueries:[fue]}),v=(0,o.A)(h,1)[0],f=(0,a.useCallback)((async e=>{var t,n;const a=(await d({variables:{email:e}})).data,l=null===a||void 0===a?void 0:a.createTrustedReceiptSender;return{trustedReceiptSender:null!==(t=null===l||void 0===l?void 0:l.trustedReceiptSender)&&void 0!==t?t:null,errors:null!==(n=null===l||void 0===l?void 0:l.errors)&&void 0!==n?n:null}}),[d]),E=(0,a.useCallback)((async(e,t)=>{var n,a;const l=(await m({variables:{trustedReceiptSenderId:e,code:t}})).data,r=null===l||void 0===l?void 0:l.verifyTrustedReceiptSender;return{trustedReceiptSender:null!==(n=null===r||void 0===r?void 0:r.trustedReceiptSender)&&void 0!==n?n:null,errors:null!==(a=null===r||void 0===r?void 0:r.errors)&&void 0!==a?a:null}}),[m]),y=(0,a.useCallback)((async e=>{await g({variables:{trustedReceiptSenderId:e}})}),[g]),b=(0,a.useCallback)((async e=>{var t,n;const a=(await v({variables:{id:e}})).data,l=null===a||void 0===a?void 0:a.deleteTrustedReceiptSender;return{success:null!==(t=null===l||void 0===l?void 0:l.success)&&void 0!==t&&t,errors:null!==(n=null===l||void 0===l?void 0:l.errors)&&void 0!==n?n:null}}),[v]);return{trustedReceiptSenders:r,householdMemberEmails:s,isLoadingInitialData:n,createTrustedReceiptSender:f,verifyTrustedReceiptSender:E,resendVerification:y,deleteTrustedReceiptSender:b}})(),t=e.trustedReceiptSenders,n=e.householdMemberEmails,l=e.deleteTrustedReceiptSender,r=e.createTrustedReceiptSender,s=e.verifyTrustedReceiptSender,c=e.resendVerification,d=(()=>{var e;const t=(0,et.I)(Rde,{fetchPolicy:"cache-first"}).data;return null!==(e=null===t||void 0===t?void 0:t.receiptForwardingAddress)&&void 0!==e?e:null})(),u=null!==d&&void 0!==d?d:"[email protected]",m=(0,Pd.h)(),p=(0,o.A)(m,2),g=p[0],h=p[1],v=h.open,f=h.close,E=h.context,y=(0,a.useState)(!1),b=(0,o.A)(y,2),x=b[0],w=b[1],A=(0,a.useState)(!1),I=(0,o.A)(A,2),k=I[0],S=I[1],N=(0,a.useState)(null),T=(0,o.A)(N,2),_=T[0],D=T[1],R=(0,a.useState)({}),M=(0,o.A)(R,2),L=M[0],O=M[1],P=(0,a.useState)(null),z=(0,o.A)(P,2),F=z[0],G=z[1],Y=(0,a.useState)({}),V=(0,o.A)(Y,2),W=V[0],j=V[1],H=(0,a.useMemo)((()=>new Set([...n.map((e=>e.email.toLowerCase())),...t.map((e=>e.email.toLowerCase()))])),[n,t]),K=(0,a.useCallback)((async()=>{await(0,Bd.l)(u),(0,Ge.u4)(Ye.IP.AddressCopied),S(!0),setTimeout((()=>S(!1)),2e3)}),[u]),q=async()=>{if(!_)return;const e=_.email.trim();if(e)if(H.has(e.toLowerCase()))(0,C.oR)({title:"This email is already associated with your account"});else{D((0,U.A)((0,U.A)({},_),{},{isSubmitting:!0}));try{const n=await r(e),a=n.trustedReceiptSender,l=n.errors;var t;if(l)return(0,C.oR)({title:null!==(t=l.message)&&void 0!==t?t:"Something went wrong"}),void D((0,U.A)((0,U.A)({},_),{},{isSubmitting:!1}));a?((0,Ge.u4)(Ye.IP.TrustedSenderAdded),D(null),G(a.id)):((0,C.oR)({title:"Something went wrong. Please try again."}),D((0,U.A)((0,U.A)({},_),{},{isSubmitting:!1})))}catch(n){(0,C.oR)({title:"Failed to add email. Please try again."}),D((0,U.A)((0,U.A)({},_),{},{isSubmitting:!1}))}}};return a.createElement("div",{"data-external-id":"trusted-receipt-sender-list",className:"flex flex-col gap-xl"},a.createElement("div",{className:"flex flex-col gap-default"},a.createElement("div",{className:"flex flex-col gap-2xs"},a.createElement(kD.c,{size:"base",weight:"medium"},"Receipt email forwarding"),a.createElement(kD.c,{size:"sm",color:"secondary"},"Import receipts to your Monarch account by forwarding your receipt emails to us."," ",a.createElement(cl.M,{href:VF.rq,target:"_blank"},"Learn more"))),a.createElement(Sue,{onClick:K,tabIndex:0,role:"button","aria-label":"Copy manual forwarding address",onKeyDown:e=>{"Enter"!==e.key&&" "!==e.key||K()}},a.createElement(kD.c,{size:"base"},"Forward emails yourself to"," ",a.createElement(kD.c,{size:"base",color:"link",weight:"medium"},u)),a.createElement(B.L,{icon:k?"check":"copy",size:"xsmall",onClick:e=>{e.stopPropagation(),K()},title:"Copy address"}))),a.createElement("div",{className:"flex flex-col gap-sm"},a.createElement(kD.c,{size:"base",weight:"medium"},"Your email addresses"),a.createElement(Nue,null,n.map((e=>{let t=e.email,n=e.isVerified;return a.createElement(due,{key:t,email:t,isVerified:n,readOnly:!0})})),t.map((e=>{var t,n;return a.createElement(due,{key:e.id,email:e.email,isVerified:e.isVerified,autoFocus:
1F===e.id,verificationCode:null!==(t=L[e.id])&&void 0!==t?t:"",onVerificationCodeChange:t=>O((n=>(0,U.A)((0,U.A)({},n),{},{[e.id]:t}))),onVerify:()=>(async e=>{var t;const n=null!==(t=L[e])&&void 0!==t?t:"";if(n.trim()){(0,Ge.u4)(Ye.IP.TrustedSenderVerificationSubmitted),j((t=>(0,U.A)((0,U.A)({},t),{},{[e]:!0})));try{const t=await s(e,n.trim()),l=t.trustedReceiptSender,r=t.errors;var a;if(r)return(0,Ge.u4)(Ye.IP.TrustedSenderVerificationFailed,{reason:"invalid_code"}),void(0,C.oR)({title:null!==(a=r.message)&&void 0!==a?a:"Invalid code"});if(!l)return(0,Ge.u4)(Ye.IP.TrustedSenderVerificationFailed,{reason:"unknown"}),void(0,C.oR)({title:"Something went wrong. Please try again."});(0,Ge.u4)(Ye.IP.TrustedSenderVerified),O((t=>(t[e],(0,En.A)(t,[e].map(nf.A))))),(0,C.oR)({title:"Email verified!"})}catch(l){(0,Ge.u4)(Ye.IP.TrustedSenderVerificationFailed,{reason:"error"}),(0,C.oR)({title:"Invalid or expired code. Please try again."})}finally{j((t=>(t[e],(0,En.A)(t,[e].map(nf.A)))))}}})(e.id),isVerifying:null!==(n=W[e.id])&&void 0!==n&&n,onResend:e.isVerified?void 0:()=>(async e=>{try{await c(e),O((t=>(0,U.A)((0,U.A)({},t),{},{[e]:""})))}catch(t){throw(0,C.oR)({title:"Couldn't resend the verification email. Please try again."}),new Error("resend failed")}})(e.id),onDelete:()=>v({id:e.id,email:e.email,isVerified:e.isVerified})})})),null!==_&&a.createElement(Tue,null,a.createElement("span",{className:"size-5 shrink-0 rounded-round border border-dashed border-border-secondary"}),a.createElement(_ue,{type:"email",placeholder:"Enter email address",value:_.email,onChange:e=>D((0,U.A)((0,U.A)({},_),{},{email:e.target.value})),onKeyDown:e=>{"Enter"===e.key&&q()},autoFocus:!0,disabled:_.isSubmitting}),a.createElement(cu.WT,{size:"small",onClick:q,disabled:!_.email.trim()||_.isSubmitting},"Save"),a.createElement(B.L,{icon:"trash",size:"xsmall",onClick:()=>D(null),disabled:_.isSubmitting}))),a.createElement(wt.Xb,{size:"small",className:"self-start",onClick:()=>D({email:"",isSubmitting:!1})},"Add new email"),a.createElement(g,null,a.createElement(xC.$,{title:null!==E&&void 0!==E&&E.isVerified?"Remove email from receipt forwarding":"Cancel verification",confirm:null!==E&&void 0!==E&&E.isVerified?"Remove email":"Cancel verification",isLoading:x,onConfirm:async()=>{if(E){w(!0);try{const e=await l(E.id);if(!e.success)return void(0,C.oR)({title:"Something went wrong. Please try again."});(0,Ge.u4)(Ye.IP.TrustedSenderDeleted,{isVerified:E.isVerified}),O((e=>{const t=E.id;e[t];return(0,En.A)(e,[t].map(nf.A))})),j((e=>{const t=E.id;e[t];return(0,En.A)(e,[t].map(nf.A))})),f()}catch(e){(0,C.oR)({title:"Failed to remove email. Please try again."})}finally{w(!1)}}},onCancel:f},a.createElement(kD.c,{size:"base"},null!==E&&void 0!==E&&E.isVerified?a.createElement(a.Fragment,null,"Are you sure you want to remove ",a.createElement("strong",null,null===E||void 0===E?void 0:E.email)," from forwarding receipts to your Monarch account?",a.createElement("br",null)," ",a.createElement("br",null),"You can re-add this email if you change your mind."):a.createElement(a.Fragment,null,"Cancel the pending verification for ",a.createElement("strong",null,null===E||void 0===E?void 0:E.email),"?"))))))},Sue=$d.s.div(wue||(wue=(0,wc.A)(["\n  flex h-14 cursor-pointer items-center justify-between rounded-sm bg-background-secondary p-default\n"]))),Nue=$d.s.div(Cue||(Cue=(0,wc.A)(["overflow-hidden rounded-sm border border-divider-secondary"]))),Tue=$d.s.div(Aue||(Aue=(0,wc.A)(["flex h-16 items-center gap-xs px-default"]))),_ue=$d.s.input(Iue||(Iue=(0,wc.A)(["\n  h-9 min-w-0 flex-1 rounded-sm border border-border-primary bg-background-primary px-sm\n  text-sm text-content-primary outline-none\n  placeholder:text-content-secondary\n  focus:border-border-secondary\n  disabled:opacity-50\n"]))),Due=function(){let e=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}).skip;var t,n;const a=(0,et.I)(Rue,{skip:e}),l=a.data,r=a.isLoadingInitialData,s=(0,i.n)(Mue),c=(0,o.A)(s,1)[0],d=null===(t=null===l||void 0===l?void 0:l.userProfile)||void 0===t?void 0:t.id;return{shouldPromote:!e&&!r&&!(null===(n=null===l||void 0===l?void 0:l.userProfile)||void 0===n?void 0:n.dismissedReceiptScanningLaunchB
1annerAt),dismiss:(0,v.D)((()=>{const e=N.c9.now().toISO();return c({variables:{dismissedReceiptScanningLaunchBannerAt:e},optimisticResponse:d?{__typename:"Mutation",updateUserProfile:{__typename:"UpdateUserProfile",userProfile:{__typename:"UserProfile",id:d,dismissedReceiptScanningLaunchBannerAt:e},errors:null}}:void 0})}))}},Rue=(0,Qt.J)("\n  query Common_ReceiptScanningLaunch {\n    userProfile {\n      id\n      dismissedReceiptScanningLaunchBannerAt\n    }\n  }\n"),Mue=(0,Qt.J)("\n  mutation Common_UpdateReceiptScanningLaunchDismissal(\n    $dismissedReceiptScanningLaunchBannerAt: DateTime\n  ) {\n    updateUserProfile(\n      input: { dismissedReceiptScanningLaunchBannerAt: $dismissedReceiptScanningLaunchBannerAt }\n    ) {\n      userProfile {\n        id\n        dismissedReceiptScanningLaunchBannerAt\n      }\n      errors {\n        ...PayloadErrorFields\n      }\n    }\n  }\n"),Lue=e=>{let t=e.onDone;const n=aue().isLoadingInitialData,l=(0,d4.u)("feat-receipt-auto-forwarding","off").isOn,r=(0,d4.u)("feat-receipt-scan-web","on").isOn,o=Due({skip:!r}),i=o.shouldPromote,s=o.dismiss;return(0,a.useEffect)((()=>{i&&s()}),[s,i]),n?a.createElement(Rc.L,{"data-external-id":"receipt-settings-form",title:"Receipt settings"},a.createElement("div",{className:"flex items-center justify-center p-3xl"},a.createElement(p.i,{size:"lg"}))):a.createElement(Rc.L,{"data-external-id":"receipt-settings-form",title:"Receipt settings"},a.createElement(a.Fragment,null,a.createElement("div",{className:"p-xl"},a.createElement(lue,null),a.createElement(wm.A,{className:"my-xl"}),a.createElement(kue,null),l&&a.createElement(a.Fragment,null,a.createElement(wm.A,{className:"my-xl"}),a.createElement(Vde,null))),a.createElement(Cq.R,null,a.createElement(wt.Xb,{onClick:t},"Cancel"),a.createElement(cu.WT,{onClick:t},"Done"))))};var Oue=n(4717),Pue=n(66748);const Bue={files:[],isUploading:!1},zue=(e,t,n)=>e.map((e=>e.id===t?(0,U.A)((0,U.A)({},e),n):e)),Fue=(e,t)=>(0,r.YW)(t).with({type:"START"},(e=>({isUploading:!0,files:e.files.map((e=>({id:e.id,fileName:e.fileName,status:"pending"})))}))).with({type:"FILE_UPLOADING"},(t=>{let n=t.id,a=t.syncId;return(0,U.A)((0,U.A)({},e),{},{files:zue(e.files,n,{status:"uploading",syncId:a})})})).with({type:"FILE_COMPLETED"},(t=>{let n=t.id;return(0,U.A)((0,U.A)({},e),{},{files:zue(e.files,n,{status:"completed"})})})).with({type:"FILE_FAILED"},(t=>{let n=t.id,a=t.error;return(0,U.A)((0,U.A)({},e),{},{files:zue(e.files,n,{status:"failed",error:a})})})).with({type:"DONE"},(()=>(0,U.A)((0,U.A)({},e),{},{isUploading:!1}))).with({type:"RESET"},(()=>Bue)).exhaustive(),Gue="order",Yue=e=>{let t=e.syncId,n=e.file;const a=JSON.stringify({orderId:GW().v4(),vendor:Ee.XcS.USER_IMPORT,payloadType:Gue,contentType:n.type}),l=new FormData;return l.append("payloads_count","1"),l.append("metadata_0",a),l.append("payload_0",n,n.name),r7.F.post("/retail-sync/".concat(t,"/files"),{data:l})},Uue=e=>crypto.randomUUID(),Vue=e=>e.name,Wue=e=>(e=>{let t=e.uploadFile,n=e.getFileId,l=e.getFileName,r=e.refetchQueries;const i=(0,a.useReducer)(Fue,Bue),s=(0,o.A)(i,2),c=s[0],d=s[1],u=rde(),m=u.createBulkRetailSync,p=u.startRetailSync,g=(0,V.m)(),h=(0,a.useRef)(!1),v=(0,a.useCallback)((async e=>{var a,o,i,s,c,u;const v=e.slice(0,10);h.current=!1;const f=v.map((e=>({id:n(e),fileName:l(e),file:e})));d({type:"START",files:f});try{const e=await m(v.length),n=e.data,l=e.errors,E=null===(a=null===n||void 0===n?void 0:n.createBulkRetailSync)||void 0===a?void 0:a.retailSyncs;if(!E||l){const e=null!==(u=null!==(s=null===(i=null===(o=null===n||void 0===n?void 0:n.createBulkRetailSync)||void 0===o?void 0:o.errors)||void 0===i?void 0:i.message)&&void 0!==s?s:null===(c=null===l||void 0===l?void 0:l[0])||void 0===c?void 0:c.message)&&void 0!==u?u:"Failed to create upload batch";return void f.forEach((t=>{let n=t.id;return d({type:"FILE_FAILED",id:n,error:e})}))}let y=0,b=0;const x=[],w=async e=>{var n;if(h.current)return;const a=f[e],l=a.id,r=a.file,o=null===(n=E[e])||void 0===n?void 0:n.id;if(!o)return d({type:"FILE_FAILED",id:l,error:"No sync ID available"}),void(b+=1);d({type:"FILE_UPLOADING",id:l,syncId:o});try{await t(r,o),await p(o),d({type:"FILE_COMPLETED",id:l}),y+=1,x.push(o)}catch(i){d({type:"FILE_FAILED",id:l,error:"Upload failed"}),b+=1}},C=f.map(((e,t)=>(0,U.A)((0,U.A)({},e),{},{index:t}))),A=(0,Pue.A)(3,C);return await A.reduce((async(e,t)=>{await e,h.current||await Promise.all(t.map((e=>{let t=e.index;return w(t)})))}),Promise.resolve()),(null===r||void 0===r?void 0:r.length)&&await g.refetchQueries({include:r}).catch((()=>{})),{completed:y,failed:b,completedSyncIds:x}}catch(E){return f.forEach((e=>{let t=e.id;return d({type:"FILE_FAILED",id:t,error:"Upload failed"})})),{completed:0,failed:f.length,completedSyncIds:[]}}finally{d({type:"DONE"})}}),[m,p,g,t,n,l,r]),f=(0,a.useCallback)((()=>d({type:"RESET"})),[]),E=c.files.filter((e=>"completed"===e.status)).length,y=c.files.filter((e=>"failed"===e.status)).length;return{fileItems:c.files,isUploading:c.isUploading,completedCount:E,failedCount:y,totalCount:c.files.length,startUpload:v,reset:f}})({uploadFile:(0,a.useCallback)((async(e,t)=>{if(!await Yue({syncId:t,file:e}))throw new Error("Failed to upload receipt")}),[]),getFileId:Uue,getFileName:Vue,refetchQueries:e}),jue=e=>{const t=rde(),n=t.createRetailSync,l=t.startRetailSync;return(0,a.useCallback)((async t=>{try{var a,r;const d=await n(),u=d.data,m=d.errors,p=null===u||void 0===u||null===(a=u.createRetailSync)||void 0===a||null===(r=a.retailSync)||void 0===r?void 0:r.id;var o,i;if(!p||m)throw new Error(null!==(o=null===m||void 0===m||null===(i=m[0])||void 0===i?void 0:i.message)&&void 0!==o?o:"Failed to create retail sync");if(!await Yue({file:t,syncId:p}))throw new Error("Failed to upload receipt");const g=await l(p,{refetchQueries:e}),h=g.data,v=g.errors;var s,c;if(!h||v)throw new Error(null!==(s=null===v||void 0===v||null===(c=v[0])||void 0===c?void 0:c.message)&&void 0!==s?s:"Failed to start retail sync");return p}catch(d){throw new Error("Failed to upload receipt",{cause:d})}}),[n,l,e])},Hue="Common_RetailSyncsQueryWithTotal",Kue=/mac/i.test(navigator.userAgent),que=["image/jpeg","image/jpg","image/png","image/heic","image/heif","image/webp","application/pdf"],$ue=[Hue],Zue=(0,u.default)(Oue.d).withConfig({displayName:"UploadReceiptPanel__StyledFileDropzone",componentId:"sc-1r39jg2-0"})(["div{min-width:0;}"]),Jue=(0,u.keyframes)(["0%{left:-30%;width:30%;}50%{left:30%;width:40%;}100%{left:100%;width:30%;}"]),Xue=()=>{const e=(0,nG.p)("feat-bulk-receipt-upload-web","on"),t=a.useState(),n=(0,o.A)(t,2),l=n[0],r=n[1],i=a.useState(),s=(0,o.A)(i,2),c=s[0],d=s[1],u=a.useState(!1),m=(0,o.A)(u,2),p=m[0],g=m[1],h=jue($ue),v=Wue($ue),f=v.fileItems,E=v.isUploading,y=v.failedCount,b=v.totalCount,x=v.startUpload,w=v.reset,C=p||E,A=!E&&b>0,k=(0,a.useCallback)((async(e,t)=>{w(),r(void 0),g(!0),d(e.name);try{const n=await h(e);(0,Ge.u4)(Ye.NE.AttachmentUploaded,{syncId:n,source:t})}catch(n){r("Failed to upload receipt. Please try again.")}finally{g(!1),d(void 0)}}),[h,w]),S=(0,a.useCallback)((async(t,n)=>{if(0===t.length)return;const a=t.find((e=>e.size>10485760));if(a)return void r('"'.concat(a.name,'" exceeds the 10MB limit.'));if(r(void 0),1===t.length||!e)return void await k(t[0],n);(0,Ge.u4)(Ye.NE.BulkUploadStarted,{fileCount:t.length});const l=await x(t);l&&((0,Ge.u4)(Ye.NE.BulkUploadCompleted,{totalFiles:t.length,succeeded:l.completed,failed:l.failed}),l.completedSyncIds.forEach((e=>{(0,Ge.u4)(Ye.NE.AttachmentUploaded,{syncId:e,source:"bulk_upload"})})))}),[k,e,x]);return(0,a.useEffect)((()=>{const e=e=>{var t,n;if(C)return;const a=Array.from(null!==(t=null===(n=e.clipboardData)||void 0===n?void 0:n.files)&&void 0!==t?t:[]).filter((e=>que.includes(e.type)));a.length>0&&(e.preventDefault(),S(a,"paste"))};return document.addEventListener("paste",e),()=>document.removeEventListener("paste",e)}),[C,S]),a.createElement(eme,{"data-external-id":"upload-receipt-panel"},a.createElement(tme,null,"Upload receipts"),a.createElement(nme,null,l&&a.createElement(ame,{type:"error"},l),p&&a.createElement(ome,null,a.createElement(Que,{fileName:null!==c&&void 0!==c?c:"",status:"uploading"}),a.createElement(ume,null,a.createElement(mme,null))),(E||A)&&a.createElement(ome,null,f.map((e=>a.createElement(Que,{key:e.id,fileName:e.fileName,status:e.status}))),E&&a.createElement(ume,null,a.createElement(mme,null)),A&&a.createElement(a.Fragment,null,y>0&&a.createElement(ame,{type:"error"},y," of ",b," receipts failed to upload."),a.createElement(pme,{onClick:w},"Upload more"))),!C&&!A&&a.createElement(a.Fragment,null,a.createElement(Zue,{acceptFileTypes:que,files:[],onChangeFiles:e=>S(e,"drop"),onDropRejected:e=>{const t=e.some((e=>e.errors.some((e=>"too-many-files"===e.code))));r(t?"You can upload a maximum of ".concat(10," files at once."):"This file type isn't supported. Please upload a JPG, PNG, WebP, HEIC, or HEIF instead.")},title:"Upload files",maxNumFiles:e?10:1}),a.createElement(lme,null,a.createElement(a.Fragment,null,a.createElement("span",null,"Paste from clipboard with ",a.createElement(rme,null,Kue?"\u2318":"Ctrl","+V")),a.createElement("br",null),a.createElement("span",null,"or"," ",a.createElement(Vl.W,{to:I.JZ.transactions.receipts.settings()},"forward emails")," ","with receipts"))))))},Que=e=>{let t=e.fileName,n=e.status;return a.createElement(ime,{"data-external-id":"file-progress-row"},a.createElement(sme,null,a.createElement(sl.ZQ,{name:(0,r.YW)(n).with("completed",(()=>"check")).with("failed",(()=>"x")).otherwise((()=>"paperclip")),size:16})),a.createElement(m.g,{column:!0,justifyCenter:!0},a.createElement(cme,null,t),a.createElement(dme,null,"pending"===n&&"Waiting...","uploading"===n&&"Uploading and scanning...","completed"===n&&"Done","failed"===n&&"Failed")))},eme=u.default.div.withConfig({displayName:"UploadReceiptPanel__Root",componentId:"sc-1r39jg2-1"})(["width:356px;flex-shrink:0;background-color:",";border-radius:",";padding:",";overflow:hidden;position:sticky;top:0;",""],vt.Ee.color.background.primary,vt.r8.default,vt.YK.default,wn.M.medium),tme=(0,u.default)(xt.v).withConfig({displayName:"UploadReceiptPanel__Title",componentId:"sc-1r39jg2-2"})(["font-weight:",";margin-bottom:",";display:block;"],vt.Wy.medium,vt.YK.small),nme=u.default.div.withConfig({displayName:"UploadReceiptPanel__DropzoneContainer",componentId:"sc-1r39jg2-3"})([""]),ame=(0,u.default)(fu.g).withConfig({displayName:"UploadReceiptPanel__StyledBanner",componentId:"sc-1r39jg2-4"})(["margin-bottom:",";"],vt.YK.default),lme=(0,u.default)(xt.v).attrs({size:"small"}).withConfig({displayName:"UploadReceiptPanel__PasteHint",componentId:"sc-1r39jg2-5"})(["color:",";text-align:center;margin-top:",";display:block;"],vt.Ee.color.content.secondary,vt.YK.small),rme=u.default.kbd.withConfig({displayName:"UploadReceiptPanel__Kbd",componentId:"sc-1r39jg2-6"})(["font-family:inherit;font-size:inherit;background-color:",";border-radius:",";padding:1px 4px;"],vt.Ee.color.background.secondary,vt.r8.small),ome=(0,u.default)(m.g).attrs({column:!0,gap:"small"}).withConfig({displayName:"UploadReceiptPanel__UploadingContainer",componentId:"sc-1r39jg2-7"})([""]),ime=(0,u.default)(m.g).attrs({alignCenter:!0,gap:"small"}).withConfig({displayName:"UploadReceiptPanel__UploadingRow",componentId:"sc-1r39jg2-8"})([""]),sme=(0,u.default)(m.g).attrs({justifyCenter:!0,alignCenter:!0,padding:"small"}).withConfig({displayName:"UploadReceiptPanel__FileIconContainer",componentId:"sc-1r39jg2-9"})(["background-color:",";border-radius:",";"],vt.Ee.color.background.secondary,vt.r8.medium),cme=(0,u.default)(xt.v).withConfig({displayName:"UploadReceiptPanel__UploadingFileName",componentId:"sc-1r39jg2-10"})(["text-overflow:ellipsis;overflow:hidden;max-width:260px;white-space:nowrap;"]),dme=(0,u.default)(xt.v).attrs({size:"small",color:"content.secondary"}).withConfig({displayName:"UploadReceiptPanel__UploadingLabel",componentId:"sc-1r39jg2-11"})([""]),ume=u.default.div.withConfig({displayName:"UploadReceiptPanel__ProgressBarTrack",componentId:"sc-1r39jg2-12"})(["width:100%;height:","px;border-radius:",";background-color:",";position:relative;overflow:hidden;"],6,vt.r8.small,vt.Ee.color.background.secondary),mme=u.default.div.withConfig({displayName:"UploadReceiptPanel__ProgressBarFill",componentId:"sc-1r39jg2-13"})(["position:absolute;top:0;height:100%;border-radius:",";background-color:",";animation:"," 1.5s ease-in-out infinite;"],vt.r8.small,vt.Ee.color.content.info,Jue),pme=u.default.button.withConfig({displayName:"UploadReceiptPanel__DoneButton",componentId:"sc-1r39jg2-14"})(["background:none;border:none;color:",";cursor:pointer;font-weight:",";padding:"," 0;text-align:center;&:hover{text-decoration:underline;}"],vt.Ee.color.content.info,vt.Wy.medium,vt.YK.xsmall);var gme=n(25291),hme=n(76103),vme=n(32029);const fme=()=>{const e=(0,nG.p)("feat-receipt-scan-web","on"),t=Due({skip:!e}),n=t.shouldPromote,l=t.dismiss,r=(0,a.useRef)(!1);(0,a.useEffect)((()=>{n&&!r.current&&(r.current=!0,(0,Ge.u4)(Ye.IP.LaunchBannerViewed))}),[n]);const o=(0,a.useCallback)((e=>{e.stopPropagation(),l()}),[l]);return n?a.createElement(gme.h.Root,{"data-external-id":"receipt-scanning-launch-banner",variant:"plain",className:"mb-md border border-divider-primary shadow-md"},a.createElement(gme.h.Icon,null,a.createElement(vme.MdsScanReceiptIcon,{size:16})),"You can now forward receipt emails to Monarch! Once added, we'll link and update the matching transaction.",a.createElement(gme.h.Actions,null,a.createElement(Vl.W,{to:I.JZ.transactions.receipts.settings(),tone:"neutral-primary",weight:"medium",onClick:()=>{(0,Ge.u4)(Ye.IP.LaunchBannerCtaClicked),l()}},"Set up"),a.createElement(hme.T,{size:"xs",onClick:o}))):null},Eme=["fetchMore","refetch","data","isDataAvailable"],yme=(e,t)=>
1(0,Ru.A)({retailSyncsWithTotal:{totalCount:e=>{var n;return null!==(n=t.retailSyncsWithTotal.totalCount)&&void 0!==n?n:e},results:e=>(0,Mu.A)((0,mo.A)("id"),[...e,...t.retailSyncsWithTotal.results])}},e),bme=(e,t)=>N.c9.fromISO(((e,t)=>{var n,a,l;return t===Ee.ZUq.RECEIPT_DATE&&null!==(l=null===(a=null===(n=e.orders)||void 0===n?void 0:n[0])||void 0===a?void 0:a.date)&&void 0!==l?l:e.createdAt})(e,t)).toFormat("yyyy-MM-dd");var xme;const wme=[Hue],Cme=12,Ame="all",Ime=[{label:"All Receipts",value:Ame},{label:"Unmatched",value:Ee.BX9.PENDING_MATCHES}],kme=[{label:"Sort by",options:[{value:Ee.ZUq.RECEIPT_DATE,label:"Receipt date"},{value:Ee.ZUq.UPLOAD_DATE,label:"Uploaded date"}]}],Sme=[Ee.XcS.USER_IMPORT,Ee.XcS.EMAIL_IMPORT],Nme=e=>N.c9.fromFormat(e,"yyyy-MM-dd").toLocaleString(N.c9.DATE_FULL),Tme=()=>{var e,t;const n=(0,l.Zp)(),r=(0,E.wA)(),i=(0,d.d4)(ft.Pi),s=(0,a.useState)(void 0),c=(0,o.A)(s,2),u=c[0],m=c[1],p=Ime.find((e=>e.value===(null!==u&&void 0!==u?u:Ame))),h=(e=>{let t=e.vendor,n=e.vendors,l=e.status,r=e.orderBy;var o;const i=(0,a.useMemo)((()=>({offset:0,limit:25,includeTotalCount:!0,filters:{vendor:t,vendors:n,status:l},orderBy:r})),[t,n,l,r]),s=(0,et.I)(Rce.ek,{variables:i}),c=s.fetchMore,d=s.refetch,u=s.data,m=s.isDataAvailable,p=(0,En.A)(s,Eme),g=(0,a.useRef)(r);m&&(g.current=r);const h=g.current!==r,v=h&&!p.error,f=v?void 0:u,E=p.isNetworkRequestInFlight&&!m||h,y=null!==(o=null===f||void 0===f?void 0:f.retailSyncsWithTotal)&&void 0!==o?o:{},b=y.totalCount,x=y.results,w=(null!==x&&void 0!==x?x:[]).length,C=!E&&!(0,BY.A)(b)&&w<b,A=(0,a.useCallback)((()=>{E||c({variables:{offset:w,orderBy:r},updateQuery:(e,t)=>{let n=t.fetchMoreResult;return yme(e,n)}})}),[c,w,E,r]),I=(0,a.useCallback)((()=>d((0,U.A)((0,U.A)({},i),{},{limit:Math.max(25,w)}))),[d,w,i]);return(0,U.A)((0,U.A)({retailSyncs:x,hasNextPage:C,fetchNextPage:A,refetchAll:I,isReordering:v,activeOrderBy:g.current},p),{},{isLoadingInitialData:p.isNetworkRequestInFlight&&!f})})({vendors:Sme,status:u,orderBy:i}),v=h.retailSyncs,f=h.hasNextPage,y=h.fetchNextPage,b=h.isLoadingInitialData,x=h.isReordering,w=h.activeOrderBy,A=h.refetchAll,k=rde().deleteRetailSync,S=jue(wme),N=(0,a.useRef)(null),T=(0,a.useRef)(null),_=(0,a.useState)(0),D=(0,o.A)(_,2),R=D[0],M=D[1],L=(0,a.useCallback)((e=>{e&&M(e.getBoundingClientRect().height)}),[]),O=(0,a.useState)(null),P=(0,o.A)(O,2),B=P[0],z=P[1],F=(0,a.useState)(null),G=(0,o.A)(F,2),Y=G[0],V=G[1],W=(0,a.useState)(null),j=(0,o.A)(W,2),H=j[0],K=j[1],q=(0,l.RQ)("/transactions/receipts/:id"),$=null===q||void 0===q||null===(e=q.params)||void 0===e?void 0:e.id,Z=$&&"upload"!==$&&"settings"!==$?$:null,J=(0,a.useMemo)((()=>{var e,t;return null!==(e=null===v||void 0===v||null===(t=v.find((e=>e.status===Ee.BX9.IN_PROGRESS)))||void 0===t?void 0:t.id)&&void 0!==e?e:null}),[v]),X=(0,PH.p)(Rce.Xi,{variables:{syncId:null!==J&&void 0!==J?J:""},pollIntervalMs:750,pollTimeoutMs:6e4,pollUntil:_me}),Q=(0,o.A)(X,1)[0];(0,a.useEffect)((()=>{J&&Q()}),[J,Q]);const ee=(0,a.useCallback)((e=>{V(null),z(null),n(I.JZ.transactions.receipts.detail({id:e.id}))}),[n]),te=(0,a.useCallback)((()=>n(I.JZ.transactions.receipts())),[n]),ne=(0,a.useCallback)((e=>{V(null),te(),z(e)}),[te]),ae=(0,a.useCallback)((e=>{V(Z),te(),z(e)}),[Z,te]),le=(0,a.useCallback)((()=>{z(null),Y&&(n(I.JZ.transactions.receipts.detail({id:Y})),V(null))}),[n,Y]),re=(0,a.useCallback)((e=>{K(e)}),[]),oe=(0,a.useCallback)((async()=>{if(H)try{await k(H),(0,C.oR)({title:"Receipt deleted"})}catch(e){(0,C.oR)({title:"Failed to delete receipt"})}finally{K(null)}}),[H,k]),ie=(0,a.useCallback)((e=>{T.current=e,N.current&&(N.current.value="",N.current.click())}),[]),se=(0,a.useCallback)((async e=>{var t;const n=null===(t=e.target.files)||void 0===t?void 0:t[0],a=T.current;if(T.current=null,n&&a)if(n.size>10485760)(0,C.oR)({title:"File size must be under 10MB"});else try{const e=await S(n);await k(a),(0,Ge.u4)(Ye.NE.AttachmentUploaded,{syncId:e,source:"file_picker"})}catch(l){(0,C.oR)({title:"Failed to re-upload receipt"})}}),[k,S]),ce=(0,a.useMemo)((()=>{if(null===v||void 0===v||!v.length)return[];const e=(0,LD.A)((e=>bme(e,w)),v);return Object.keys(e).sort(((e,t)=>t.localeCompare(e))).map((t=>{return{dateKey:t,dateLabel:Nme(t),total:(n=e[t],n.reduce(((e,t)=>{var n,a;const l=null===(n=t.orders)||void 0===n||null===(a=n[0])||void 0===a?void 0:a.grandTotal;return e+(null!==l&&void 0!==l?Math.abs(l):0)}),0)),receipts:e[t]};var n}))}),[w,v]),de=!v||0===v.length;return b&&!x?a.createElement("div",{"data-external-id":"receipts-content",className:"flex items-center justify-center p-xl"},a.createElement(fe.ix7,null)):a.createElement(a.Fragment,null,a.createElement(Dme,null,a.createElement(fme,null),a.createElement(Rme,null,a.createElement(Mme,null,de&&!x?a.createElement(Xl.AM,null,a.createElement(zme,null,a.createElement(cU.vx,{icon:a.createElement(Vme,null,a.createElement(sl.ZQ,{name:"scan-receipt",size:32}
1)),title:"Turn receipts into insights",subtitle:"Upload a receipt and we'll scan it, find the matching transaction, and add item details automatically."}))):a.createElement(Lme,{hideHeader:!0},a.createElement(Ome,{ref:L},a.createElement(Pme,null,a.createElement(Bme,null)),a.createElement("div",{className:"flex items-center gap-sm"},a.createElement(fe.hGA,{placeholder:fe.L2e,options:Ime,value:null!==(t=null===p||void 0===p?void 0:p.value)&&void 0!==t?t:null,onValueChange:e=>{m(e===Ame?void 0:e)},size:"sm",classNames:{trigger:"min-w-45"}})),a.createElement(fe.hGA,{options:kme,value:i,size:"sm",onValueChange:e=>r((0,g.PY)(e)),classNames:{trigger:"w-45"}})),a.createElement(Qre.u,{hasNextPage:f,onRequestNextPage:y},x?a.createElement("div",{className:"flex min-h-32 items-center justify-center p-xl"},a.createElement(fe.ix7,null)):ce.map((e=>{let t=e.dateKey,n=e.dateLabel,l=e.total,r=e.receipts;return a.createElement(Fme,{key:t},a.createElement(Gme,{style:{top:R}},a.createElement(Yme,null,n),a.createElement(Ume,fl.zs,(0,rl.vv)(l))),r.map((e=>a.createElement(pde,{key:e.id,retailSync:e,onClick:()=>ee(e),onDelete:re,onReUpload:ie}))))}))))),a.createElement(Xue,null))),Z&&a.createElement(po.K,null,a.createElement(dde,{retailSyncId:Z,onClose:te,onMatchTransaction:ne,onOpenTransaction:ae})),B&&a.createElement(po.K,null,a.createElement(go.TT,{id:B,previousTransactionId:null,nextTransactionId:null,setId:z,onClose:le,onDelete:A})),a.createElement(XU.l,{path:I.JZ.transactions.receipts.settings.relativePath},(e=>{let t=e.close;return a.createElement(Lue,{onDone:t})})),a.createElement("input",{className:"hidden",ref:N,type:"file",accept:".jpg,.jpeg,.png,.heic,.heif,.webp",onChange:se}),H&&a.createElement(_ce,{onConfirm:oe,onClose:()=>K(null)}))},_me=e=>!(null===e||void 0===e||!e.retailSync)&&e.retailSync.status!==Ee.BX9.IN_PROGRESS,Dme=u.default.div.withConfig({displayName:"Receipts__ContentWrapper",componentId:"sc-1vtftth-0"})(["padding:",";padding-top:0;"],vt.YK.gutter),Rme=u.default.div.withConfig({displayName:"Receipts__MainContent",componentId:"sc-1vtftth-1"})(["display:flex;flex-wrap:wrap;gap:",";align-items:flex-start;"],vt.YK.default),Mme=u.default.div.withConfig({displayName:"Receipts__ReceiptListContainer",componentId:"sc-1vtftth-2"})(["isolation:isolate;flex:1;min-width:320px;padding-bottom:",";"],vt.YK.medium),Lme=(0,u.default)(Xl.AM).withConfig({displayName:"Receipts__ListCard",componentId:"sc-1vtftth-3"})(["overflow:clip;"]),Ome=(0,u.default)(m.g).attrs({justifyBetween:!0,alignCenter:!0}).withConfig({displayName:"Receipts__ListToolbar",componentId:"sc-1vtftth-4"})(["position:sticky;top:0;z-index:2;padding:"," ",";border-bottom:1px solid ",";background-color:",";"],vt.YK.small,vt.YK.default,vt.Ee.color.divider.primary,vt.Ee.color.background.primary),Pme=u.default.div.withConfig({displayName:"Receipts__ListRoundedHeaderContainer",componentId:"sc-1vtftth-5"})(["background:",";position:absolute;left:-","px;top:-","px;right:-","px;height:","px;overflow:hidden;"],vt.Ee.color.background.page,Cme,Cme,Cme,24),Bme=u.default.div.withConfig({displayName:"Receipts__ListRoundedHeader",componentId:"sc-1vtftth-6"})(["position:absolute;top:","px;left:","px;right:","px;height:","px;",""],Cme,Cme,Cme,24,Xl.RM),zme=u.default.div.withConfig({displayName:"Receipts__EmptyContainer",componentId:"sc-1vtftth-7"})(["padding:",";"],vt.YK.xlarge),Fme=u.default.div.withConfig({displayName:"Receipts__DateGroup",componentId:"sc-1vtftth-8"})([""]),Gme=(0,$d.s)(H3.X)(xme||(xme=(0,wc.A)(["sticky z-1 px-default"]))),Yme=(0,u.default)(xt.v).withConfig({displayName:"Receipts__DateLabel",componentId:"sc-1vtftth-9"})(["font-size:",";font-weight:",";color:",";"],vt.J.small,vt.Wy.medium,vt.Ee.color.content.secondary),Ume=(0,u.default)(xt.v).withConfig({displayName:"Receipts__DateTotal",componentId:"sc-1vtftth-10"})(["font-size:",";font-weight:",";color:",";"],vt.J.small,vt.Wy.medium,vt.Ee.color.content.secondary),Vme=(0,u.default)(m.g).withConfig({displayName:"Receipts__StyledIcon",componentId:"sc-1vtftth-11"})(["background-color:",";color:",";border-radius:",";padding:",";"],vt.Ee.color.background.tertiary,vt.Ee.color.content.secondary,vt.r8.round,vt.YK.medium),Wme=e=>{var t,n,l,r,s,c;let d=e.vendor;const u=(e=>{const t=(0,et.I)(tue,{fetchPolicy:"cache-first"}),n=t.data,l=t.isLoadingInitialData,r=(0,a.useMemo)((()=>{var t,a;return null===(a=null===(t=null===n||void 0===n?void 0:n.retailExtensionSettings)||void 0===t?void 0:t.retailVendorSettings)||void 0===a?void 0:a.find((t=>t.vendor===e))}),[n,e]),s=(0,i.n)(nue),c=(0,o.A)(s,1)[0],d=(0,a.useCallback)((t=>c({variables:{input:{vendor:e,shouldCategorizeAndSplitTransactions:t.shouldCategorizeAndSplitTransactions,shouldUpdateTransactionsNotes:t.shouldUpdateTransactionsNotes,merchantName:t.merchantName,shouldUpdatePastTransactions:void 0}},optimisticResponse:r&&void 0===t.merchantName?{__typename:"Mutation",updateRetailVendorSettings:{__typename:"UpdateRetailVendorSettings",retailVendorSettings:(0,U.A)((0,U.A)({},r),t),errors:null}}:void 0})),[c,e,r]);return{settings:r,isLoadingInitialData:l,updateSettings:d}})(d),m=u.settings,p=u.updateSettings,g=(0,EA.ZH)(d),h=null!==(t=null===m||void 0===m||null===(n=m.merchant)||void 0===n?void 0:n.name)&&void 0!==t?t:"",v=(0,a.useState)(h),f=(0,o.A)(v,2),E=f[0],y=f[1],b=(0,a.useState)(!1),x=(0,o.A)(b,2),w=x[0],A=x[1];(0,a.useEffect)((()=>{y(h)}),[h]);const I=E.trim(),k=I.length>0&&I!==h;return a.createElement(fe.xz6,{"data-external-id":"retail-vendor-settings-card"},a.createElement("div",{className:"flex items-center gap-sm p-lg"},a.createElement(Wl._,{url:null!==(l=null===m||void 0===m||null===(r=m.merchant)||void 0===r?void 0:r.logoUrl)&&void 0!==l?l:null,size:32}),a.createElement(fe.c8D,{size:"lg",weight:"medium"},g)),a.createElement(wm.A,null),a.createElement("div",{className:"flex flex-col gap-sm p-lg"},a.createElement(fe.c8D,{size:"base",weight:"medium"},"Transaction update preferences"),a.createElement(Cb.p9,{label:"Add item details to transaction notes",checked:null!==(s=null===m||void 0===m?void 0:m.shouldUpdateTransactionsNotes)&&void 0!==s&&s,onChange:e=>p({shouldUpdateTransactionsNotes:e.target.checked})}),a.createElement(Cb.p9,{label:"Automatically split and categorize transactions",checked:null!==(c=null===m||void 0===m?void 0:m.shouldCategorizeAndSplitTransactions)&&void 0!==c&&c,onChange:e=>p({shouldCategorizeAndSplitTransactions:e.target.checked})})),a.createElement(wm.A,null),a.createElement("div",{className:"flex flex-wrap items-end justify-between gap-default p-lg"},a.createElement("div",{className:"flex flex-col gap-3xs"},a.createElement(fe.c8D,{size:"base",weight:"medium"},"Monarch merchant name"),a.createElement(fe.c8D,{size:"sm",color:"secondary"},"Ensure this matches the merchant name in Monarch.")),a.createElement("div",{className:"flex items-center gap-sm"},a.createElement(fe.D_j,{value:E,placeholder:g,onChange:e=>y(e.currentTarget.value)}),a.createElement(fe.XZZ,{variant:"default",onClick:async()=>{A(!0);try{var e,t;const a=null===(e=(await p({merchantName:I}
1)).data)||void 0===e||null===(t=e.updateRetailVendorSettings)||void 0===t?void 0:t.errors;var n;if(a)return void(0,C.oR)({title:null!==(n=a.message)&&void 0!==n?n:"Failed to update Monarch merchant name"});(0,C.oR)({title:"Monarch merchant name updated"})}catch(a){(0,C.oR)({title:"Failed to update Monarch merchant name"})}finally{A(!1)}},disabled:!k||w},"Update Monarch merchant name"))))},jme=e=>{let t=e.onDone;return(0,et.I)(tue,{fetchPolicy:"cache-first"}).isLoadingInitialData?a.createElement(Rc.L,{"data-external-id":"retail-sync-settings-form",title:"Retail Sync settings"},a.createElement("div",{className:"flex items-center justify-center p-3xl"},a.createElement(p.i,{size:"lg"}))):a.createElement(Rc.L,{"data-external-id":"retail-sync-settings-form",title:"Retail Sync settings"},a.createElement(a.Fragment,null,a.createElement("div",{className:"flex flex-col gap-default p-xl"},a.createElement(Wme,{vendor:Ee.XcS.AMAZON}),a.createElement(Wme,{vendor:Ee.XcS.TARGET})),a.createElement(Cq.R,null,a.createElement(fe.XZZ,{variant:"primary",onClick:t},"Done"))))};var Hme=n(61583);const Kme=e=>(0,r.YW)(e.vendor).with(Ee.XcS.AMAZON,(()=>"".concat("https://www.amazon.com/gp/css/summary/print.html","?orderID=").concat(e.vendorOrderId))).with(Ee.XcS.TARGET,(()=>e.inStorePurchase?"https://www.target.com/orders/stores/{:receipt_id}".replace("{:receipt_id}",e.vendorOrderId):"https://www.target.com/orders/{:order_number}".replace("{:order_number}",e.vendorOrderId))).otherwise((()=>{})),qme=e=>{var t,n;return(null===(t=e.transaction)||void 0===t?void 0:t.id)?e.transactionUpdateSkipped?{label:"Ignored",matched:!1}:{label:"Match found",matched:!0}:(null===(n=e.retailOrder)||void 0===n?void 0:n.displayStatus)===_t.V0?{label:_t.V0,matched:!1}:{label:"Waiting for match",matched:!1}},$me=e=>{var t,n,r,s,c,d;let u=e.retailTransaction,m=e.isLoading,g=void 0!==m&&m,h=e.onClose,v=e.onMatchTransaction,f=e.onOpenTransaction,E=e.onUnlink;const y=(0,a.useState)(!1),b=(0,o.A)(y,2),x=b[0],w=b[1],A=(0,a.useState)(!1),k=(0,o.A)(A,2),S=k[0],T=k[1],_=(0,i.n)(Rce.Hn),D=(0,o.A)(_,1)[0],R=(0,i.n)(Rce._r),M=(0,o.A)(R,1)[0],L=(0,ide.L)(),O=(0,o.A)(L,2),P=O[0],B=O[1].open,z=(0,l.Zp)(),F=null===u||void 0===u?void 0:u.retailOrder,G=null===u||void 0===u?void 0:u.transaction,Y=Boolean(null===G||void 0===G?void 0:G.id),V=!Y,W=null!==(t=null===u||void 0===u?void 0:u.lineItems)&&void 0!==t?t:[],j=null!==(n=null===G||void 0===G||null===(r=G.merchant)||void 0===r?void 0:r.logoUrl)&&void 0!==n?n:null,H=null!==(s=null===G||void 0===G||null===(c=G.merchant)||void 0===c?void 0:c.id)&&void 0!==s?s:null,K=(0,a.useMemo)((()=>{var e,t;return G&&u?G.hasSplitTransactions&&G.splitTransactions.length>0?(0,Mu.A)((0,mo.A)("id"),G.splitTransactions.map((e=>{var t,n;return{id:e.id,merchantName:null===(t=e.merchant)||void 0===t?void 0:t.name,merchantLogoUrl:null===(n=e.merchant)||void 0===n?void 0:n.logoUrl,date:e.date,amount:e.amount,pending:e.pending,category:e.category}}))):[{id:G.id,merchantName:null===(e=G.merchant)||void 0===e?void 0:e.name,merchantLogoUrl:null===(t=G.merchant)||void 0===t?void 0:t.logoUrl,date:u.date,amount:u.total,pending:G.pending,category:G.category}]:[]}),[G,u]),$=null!==G&&void 0!==G&&G.hasSplitTransactions&&G.splitTransactions.length>0?G.id:void 0,Z=(0,a.useCallback)((async()=>{var e,t;if(null===u||void 0===u||!u.id)return;if(null!==(e=(await M({variables:{retailTransactionId:u.id},refetchQueries:["Common_RetailTransaction","Web_GetTransactionDrawer"]})).data)&&void 0!==e&&null!==(t=e.unmatchRetailTransaction)&&void 0!==t&&t.errors)throw(0,C.oR)({title:"Failed to unlink transaction. Please try again."}),new Error("Failed to unlink transaction");null===E||void 0===E||E(),(0,C.oR)({title:"Transaction unlinked"})}),[null===u||void 0===u?void 0:u.id,M,E]),J=(0,a.useCallback)((async e=>{var t,n;if(null===F||void 0===F||!F.id)return;null!==(t=(await D({variables:{input:(0,U.A)({retailOrderId:F.id,date:void 0,grandTotal:void 0,lineItemUpdates:void 0,merchantName:void 0,tax:void 0,tip:void 0,totalBeforeTax:void 0,transactionUpdates:void 0},e)}})).data)&&void 0!==t&&null!==(n=t.updateRetailOrder)&&void 0!==n&&n.errors&&(0,C.oR)({title:"Failed to update retail order. Please try again."})}),[null===F||void 0===F?void 0:F.id,D]),X=(0,a.useCallback)(((e,t)=>{t.value&&J({lineItemUpdates:[{retailLineItemId:e,categoryId:t.value,title:void 0,price:void 0,quantity:void 0,delete:void 0}]})}),[J]);if(!F||!u)return a.createElement(F7.v,{"data-external-id":"retail-transaction-detail-drawer",title:"Transaction",onClose:h},a.createElement("div",{className:"flex justify-center p-3xl text-center"},g?a.createElement(p.i,null):a.createElement(fe.c8D,{color:"secondary"},"Transaction not found")));const Q=null!==(d=F.merchantName)&&void 0!==d?d:(0,EA.ZH)(F.vendor),ee=qme(u),te=Kme
1(F),ne=Jme(F,u,Q),ae={amount:Math.abs(u.total),isCredit:u.total<0,date:u.date,merchantName:Q,categoryId:Zme(W),notes:jce(W),retailTransactionId:u.id},le=a.createElement(fe.CQG,{size:"lg",rounded:"pill",color:ee.matched?"green":"gray-secondary",variant:"subtle"},ee.label);return a.createElement(a.Fragment,null,a.createElement(F7.v,{title:le,onClose:h,showBorder:!0,headerClassName:"px-default py-sm"},a.createElement("div",{className:"flex flex-col gap-md p-xl"},V&&a.createElement("div",{className:"-mt-md flex-1"},a.createElement("h2",{className:"mb-sm text-lg font-medium text-content-primary"},"Transaction"),a.createElement("div",{className:"flex flex-wrap gap-sm"},a.createElement(fe.XZZ,{variant:"default",size:"sm",onClick:()=>w(!0)},a.createElement(fe.XZZ.Icon,null,a.createElement(fe.s$r,null)),a.createElement(fe.XZZ.Label,null,"Find match")),a.createElement(fe.XZZ,{variant:"default",size:"sm",onClick:()=>T(!0)},a.createElement(fe.XZZ.Icon,null,a.createElement(fe.Wa3,null)),a.createElement(fe.XZZ.Label,null,"Create transaction")))),Y&&K.length>0&&a.createElement("div",{className:"-mt-md flex flex-col"},a.createElement("div",{className:"flex items-center justify-between"},a.createElement("h2",{className:"text-lg font-medium text-content-primary"},(0,De.td)("Transaction",K.length)),$&&a.createElement(fe.XZZ,{variant:"text",colorScheme:"link",size:"sm",className:"h-auto px-0",icon:a.createElement(fe.KRt,{size:"xs"}),onClick:()=>B($)},"Open splits")),a.createElement("div",{className:"flex flex-col gap-sm"},K.map((e=>a.createElement(ade,{key:e.id,transaction:e,onClick:e=>null===f||void 0===f?void 0:f(e)}))),a.createElement(fe.V0Z,{tone:"destructive",title:"Unlink ".concat((0,De.td)("transaction",K.length)),description:"This order will no longer be linked to ".concat(K.length>1?"these transactions":"this transaction","."),confirmLabel:"Unlink",onConfirm:Z,trigger:a.createElement(fe.XZZ,{variant:"danger",className:"w-full"},"Unlink ",(0,De.td)("transaction",K.length))}))),a.createElement(fe.AVK,{className:"mt-xs"}),a.createElement("div",{className:"flex flex-col gap-2xs"},a.createElement("h2",{className:"text-lg font-medium text-content-primary"},"Order details"),a.createElement(fe.c8D,{color:"secondary",size:"sm"},Y?"Once an order is matched with a transaction, you won't be able to change these details.":"Amazon and Target orders sync automatically, so you can only change categories.")),a.createElement("div",{className:"flex-1"},a.createElement(fe.c8D,{size:"sm",weight:"medium",color:"primary",className:"mb-2xs block"},"Merchant"),a.createElement("div",{className:"flex items-stretch gap-2xs"},a.createElement("div",{className:"min-w-0 flex-1"},a.createElement(qce,{value:Q,fieldType:"text",editable:!1,leadingContent:a.createElement(Wl._,{url:j,size:24})})),H&&a.createElement("button",{type:"button","aria-label":"Go to merchant",onClick:()=>z(I.JZ.merchants({id:H})),className:" flex shrink-0 items-center justify-center rounded-sm border border-border-primary bg-background-primary px-xs text-content-primary transition-colors hover:cursor-pointer hover:bg-background-secondary "},a.createElement(fe.Fug,{size:"xs"})))),F.vendorOrderId&&a.createElement("div",{className:"flex-1"},a.createElement(fe.c8D,{size:"sm",weight:"medium",color:"primary",className:"mb-2xs block"},"Order"),te?a.createElement(Hme.l,{href:te,external:!0,endIcon:!0,size:"sm",className:(0,q.cn)("max-w-full min-w-0 *:data-[mds=link-label]:min-w-0 *:data-[mds=link-label]:truncate",fl.TN.className)},F.vendorOrderId):a.createElement(fe.c8D,{size:"sm",color:"secondary",className:"truncate"},F.vendorOrderId)),a.createElement("div",{className:"flex-1"},a.createElement(fe.c8D,{size:"sm",weight:"medium",color:"primary",className:"mb-2xs block"},"Date"),a.createElement(qce,{value:u.date?N.c9.fromISO(u.date).toLocaleString(N.c9.DATE_FULL):"",fieldType:"text",editable:!1})),a.createElement("div",{className:"flex-1"},a.createElement(fe.c8D,{size:"sm",weight:"medium",color:"primary",className:"mb-2xs block"},"Total"),a.createElement(qce,{value:u.total,fieldType:"currency",editable:!1})),W.length>0&&a.createElement("div",{className:"flex flex-col gap-sm"},a.createElement(fe.c8D,{size:"sm",weight:"medium",color:"primary"},"Line items"),a.createElement(fe.xz6,{className:"w-full border border-border-primary shadow-none"},a.createElement("div",{className:"flex flex-col divide-y divide-border-primary"},W.map((e=>{var t,n,l,r;return a.createElement("div",{key:e.id,className:"flex flex-col gap-2xs p-md"},a.createElement("div",{className:(0,q.cn)("flex items-center gap-sm",fl.TN.className)},a.createElement(fe.c8D,{size:"sm",weight:"medium",className:"min-w-0 flex-1 truncate"},e.title),null!==e.total&&void 0!==e.total&&a.createElement(fe.c8D,{size:"sm",weight:"medium",className:"shrink-0"},(0,rl.is)(e.total))),a.createElement("div",{className:"flex items-center gap-xs"},a.createElement("div",{className:"min-w-0 flex-1"},V?a.createElement("div",{className:"**:data-full-screen-select:box-border **:data-full-screen-select:h-full **:data-full-screen-select:w-56 **:data-full-screen-select:px-xs **:data-full-screen-select:py-2xs **:data-full-screen-select:text-sm"},a.createElement(ede.f,{value:null===(t=e.category)||void 0===t?void 0:t.id,onChange:t=>X(e.id,t),placeholder:"Select category...",isClearable:!1,alwaysShowBorder:!0})):a.createElement("div",{className:"flex items-center gap-xs"},(null===(n=e.category)||void 0===n?void 0:n.icon)&&a.createElement("span",{className:"text-sm leading-none"},e.category.icon),a.createElement(fe.c8D,{size:"sm",color:"secondary",className:"min-w-0 truncate"},null!==(l=null===(r=e.category)||void 0===r?void 0:r.name)&&void 0!==l?l:"Uncategorized"))),null!==e.quantity&&null!==e.price&&a.createElement(fe.c8D,{size:"sm",color:"secondary",className:(0,q.cn)("shrink-0",fl.TN.className)},e.quantity," \xd7"," ",(0,rl.is)(e.price))))}))))))),a.createElement(P,null),x&&a.createElement(Lce,{retailSync:ne,entityLabel:"order",onClose:()=>w(!1),onDone:e=>{w(!1),v?v(e):h()}}),S&&a.createElement(um.b,{onClose:()=>T(!1)},(()=>a.createElement(lde.t,{initialValues:ae,onDone:e=>{T(!1),e&&v?v(e):h()},onCancel:()=>T(!1)}))))},Zme=e=>{const t=new Map;for(const o of e){var n;const e=null===(n=o.category)||void 0===n?void 0:n.id;var a;if(e)t.set(e,(null!==(a=t.get(e))&&void 0!==a?a:0)+1)}let l,r=0;return t.forEach(((e,t)=>{e>r&&(r=e,l=t)})),l}
1,Jme=(e,t,n)=>({__typename:"RetailSync",id:t.retailSyncId,vendor:e.vendor,status:Ee.BX9.PENDING_MATCHES,startedAt:null,endedAt:null,createdAt:(new Date).toISOString(),updatedAt:(new Date).toISOString(),orders:[(0,U.A)((0,U.A)({},e),{},{merchantName:n,retailTransactions:[t]})],attachments:[]}),Xme=e=>{var t,n,l,r;let o=e.retailTransaction,i=e.onClick;const s=o.retailOrder,c=o.transaction,d=null!==(t=null!==(n=null===c||void 0===c||null===(l=c.merchant)||void 0===l?void 0:l.name)&&void 0!==n?n:null===s||void 0===s?void 0:s.merchantName)&&void 0!==t?t:s?(0,EA.ZH)(s.vendor):"Order",u=null===c||void 0===c||null===(r=c.merchant)||void 0===r?void 0:r.logoUrl,m=null!==u&&void 0!==u&&u.startsWith("http")?u:null,p=s?Kme(s):void 0,g=qme(o);return a.createElement("div",{"data-external-id":"retail-transaction-list-item",role:"button",tabIndex:0,onClick:i,onKeyDown:e=>{e.target===e.currentTarget&&(0,mde.l)(e,i)},className:(0,q.cn)("\n          flex w-full cursor-pointer items-center gap-md border-b border-divider-primary py-sm\n          pr-xs pl-default text-left\n          last:border-b-0\n          hover:bg-background-primary-hover\n        ")},a.createElement("div",{className:(0,q.cn)("flex min-w-0 shrink-0 basis-[26%] items-center gap-xs",fl.TN.className)},m?a.createElement(Wl._,{url:m,size:20}):null,a.createElement(fe.c8D,{color:"primary",className:"truncate"},d)),a.createElement("div",{className:"min-w-0 shrink-0 basis-[22%]"},p?a.createElement(Hme.l,{href:p,external:!0,endIcon:!0,size:"base",onClick:e=>e.stopPropagation(),className:"max-w-full min-w-0 *:data-[mds=link-label]:min-w-0 *:data-[mds=link-label]:truncate"},null===s||void 0===s?void 0:s.vendorOrderId):a.createElement(fe.c8D,{size:"sm",color:"secondary",className:"truncate"},null===s||void 0===s?void 0:s.vendorOrderId)),a.createElement("div",{className:"min-w-0 flex-1 overflow-hidden"},a.createElement(fe.CQG,{size:"lg",rounded:"pill",color:g.matched?"green":"gray-secondary",variant:"subtle"},g.label)),a.createElement("div",{className:"ml-auto flex shrink-0 items-center gap-2xs"},a.createElement(fe.c8D,{color:"primary",className:(0,q.cn)("text-right",fl.TN.className)},(0,rl.vv)(Math.abs(o.total))),a.createElement(fe.SO$,{"aria-label":"Open transaction",variant:"default",size:"sm",tabIndex:-1},a.createElement(fe.hPJ,null))))},Qme=((0,Qt.J)("\n  fragment RetailTransactionRowFields on RetailTransaction {\n    ...RetailTransactionFields\n    retailSyncId\n    lineItems {\n      ...RetailLineItemFields\n    }\n    retailOrder {\n      __typename\n      id\n      vendorOrderId\n      vendor\n      inStorePurchase\n      merchantName\n      date\n      grandTotal\n      displayStatus\n      totalBeforeTax\n      tax\n    }\n  }\n"),(0,Qt.J)("\n  query Common_RetailTransactionsConnection(\n    $first: Int!\n    $afterCursor: String\n    $filters: RetailTransactionFiltersInput\n  ) {\n    retailTransactionsConnection(first: $first, after: $afterCursor, filters: $filters) {\n      pageInfo {\n        hasNextPage\n        endCursor\n      }\n      edges {\n        node {\n          ...RetailTransactionRowFields\n        }\n      }\n    }\n  }\n")),epe=(0,Qt.J)("\n  query Common_RetailTransaction($id: ID!) {\n    retailTransaction(id: $id) {\n      ...RetailTransactionRowFields\n    }\n  }\n"),tpe=(0,Qt.J)("\n  query Common_UserHasConfiguredRetailExtension {\n    userHasConfiguredRetailSyncExtension\n  }\n"),npe=["fetchMore","refetch","data"],ape=[],lpe=(e,t)=>{if(!t)return e;const n=t.retailTransactionsConnection,a=e.retailTransactionsConnection;return n&&a?(0,U.A)((0,U.A)({},e),{},{retailTransactionsConnection:(0,U.A)((0,U.A)({},a),{},{pageInfo:n.pageInfo,edges:(0,Mu.A)((e=>{var t;return null===(t=null===e||void 0===e?void 0:e.node)||void 0===t?void 0:t.id}),[...a.edges,...n.edges])})}):t.retailTransactionsConnection?t:e},rpe=()=>Boolean(window.chrome);var ope=n(87281);const ipe="all",spe=[{value:ipe,label:"All statuses"},{value:"matched",label:"Matched"},{value:"unmatched",label:"Unmatched"}],cpe=[{value:ipe,label:"All retailers"},{value:Ee.XcS.AMAZON,label:"Amazon"},{value:Ee.XcS.TARGET,label:"Target"}
1],dpe=[Ee.XcS.AMAZON,Ee.XcS.TARGET],upe=()=>{var e,t,n,r;const i=(0,l.Zp)(),s=rpe(),c=(0,et.I)(tpe,{fetchPolicy:"cache-first"}),d=c.data,u=c.isLoadingInitialData,m=null!==(e=null===d||void 0===d?void 0:d.userHasConfiguredRetailSyncExtension)&&void 0!==e&&e,g=!u&&!m,h=(0,a.useState)(ipe),v=(0,o.A)(h,2),f=v[0],E=v[1],y=(0,a.useState)(ipe),b=(0,o.A)(y,2),x=b[0],w=b[1],C=(0,a.useState)(0),A=(0,o.A)(C,2),k=A[0],S=A[1],N=(0,a.useRef)(null),T=(0,a.useCallback)((e=>{var t;if(null===(t=N.current)||void 0===t||t.disconnect(),N.current=null,e){const t=()=>S(e.offsetHeight);t();const n=new Wy.A(t);n.observe(e),N.current=n}else S(0)}),[]);(0,a.useEffect)((()=>()=>{var e;return null===(e=N.current)||void 0===e?void 0:e.disconnect()}),[]);const _=f!==ipe||x!==ipe,D=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.vendors,n=void 0===t?ape:t,l=e.startDate,r=e.endDate,o=e.isMatched;var i,s;const c=(0,a.useMemo)((()=>({first:25,afterCursor:null,filters:{vendors:n,startDate:l,endDate:r,isMatched:o}})),[n,l,r,o]),d=(0,et.I)(Qme,{variables:c}),u=d.fetchMore,m=d.refetch,p=d.data,g=(0,En.A)(d,npe),h=null===p||void 0===p?void 0:p.retailTransactionsConnection,v=(0,a.useMemo)((()=>{var e;return(null!==(e=null===h||void 0===h?void 0:h.edges)&&void 0!==e?e:[]).flatMap((e=>(null===e||void 0===e?void 0:e.node)?[e.node]:[]))}),[null===h||void 0===h?void 0:h.edges]),f=null!==(i=null===h||void 0===h?void 0:h.pageInfo.hasNextPage)&&void 0!==i&&i,E=null!==(s=null===h||void 0===h?void 0:h.pageInfo.endCursor)&&void 0!==s?s:null,y=(0,a.useCallback)((()=>{f&&u({variables:{afterCursor:E},updateQuery:(e,t)=>{let n=t.fetchMoreResult;return lpe(e,n)}})}),[u,f,E]),b=(0,a.useCallback)((()=>m((0,U.A)((0,U.A)({},c),{},{first:Math.max(25,v.length)}))),[m,c,v.length]);return(0,U.A)({retailTransactions:v,hasNextPage:f,fetchNextPage:y,refetchAll:b},g)}({vendors:(0,a.useMemo)((()=>f===ipe?dpe:[f]),[f]),isMatched:x===ipe?void 0:"matched"===x}),R=D.retailTransactions,M=D.hasNextPage,L=D.fetchNextPage,O=D.refetchAll,P=D.isLoadingInitialData,B=(0,a.useState)(null),z=(0,o.A)(B,2),F=z[0],G=z[1],Y=(0,a.useState)(null),V=(0,o.A)(Y,2),W=V[0],j=V[1],H=(0,l.RQ)("/transactions/retail-sync/:id"),K=null!==(t=null===H||void 0===H||null===(n=H.params)||void 0===n?void 0:n.id)&&void 0!==t?t:null,$="settings"===K?null:K,Z=(0,a.useMemo)((()=>new Map(R.map((e=>[e.id,e])))),[R]),J=$?Z.get($):void 0,X=(0,et.I)(epe,{variables:{id:null!==$&&void 0!==$?$:""},skip:!$||Boolean(J)}),Q=X.data,ee=X.isLoadingInitialData,te=null!==(r=null!==J&&void 0!==J?J:null===Q||void 0===Q?void 0:Q.retailTransaction)&&void 0!==r?r:void 0,ne=(0,a.useCallback)((e=>{j(null),G(null),i(I.JZ.transactions.retailSync.detail({id:e.id}))}),[i]),ae=(0,a.useCallback)((()=>i(I.JZ.transactions.retailSync())),[i]),le=(0,a.useCallback)((e=>{j(null),ae(),G(e),O()}),[ae,O]),re=(0,a.useCallback)((e=>{j($),ae(),G(e)}),[$,ae]),oe=(0,a.useCallback)((()=>{G(null),W&&(i(I.JZ.transactions.retailSync.detail({id:W})),j(null))}),[i,W]),ie=(0,a.useMemo)((()=>{if(!R.length)return[];const e=(0,LD.A)(mpe,R);return Object.keys(e).sort(((e,t)=>t.localeCompare(e))).map((t=>{var n,a;return{dateKey:t,dateLabel:ppe(t),total:gpe(null!==(n=e[t])&&void 0!==n?n:[]),rows:null!==(a=e[t])&&void 0!==a?a:[]}}))}),[R]);if(P)return a.createElement("div",{"data-external-id":"retail-orders-content",className:"flex items-center justify-center p-xl"},a.createElement(p.i,null));const se=0===R.length,ce=a.createElement("div",{className:"flex rounded-full bg-background-tertiary p-md text-content-secondary"},a.createElement(fe.ONz,{size:"2xl"})),de=g?a.createElement(cU.vx,{icon:ce,title:"Sync your retail orders",subtitle:"Install the Monarch browser extension to import your Amazon and Target orders and match them to your transactions automatically."},s&&a.createElement(fe.TZm,{href:ope.Vg,target:"_blank",rel:"noopener noreferrer",variant:"primary",onClick:()=>(0,Ge.u4)(Ye.Xt.EmptyStateLinkOpened,{destination:"chrome-web-store"})},"Install the Monarch Extension")):a.createElement(cU.vx,{icon:ce,title:"No orders synced yet",subtitle:"Your Amazon and Target orders will appear here once the Monarch extension syncs them."}),ue=a.createElement("div",{ref:T,className:" sticky top-0 z-2 flex flex-wrap items-center gap-sm rounded-t-default border-b border-divider-primary bg-background-primary px-default py-sm "},a.createElement(fe.hGA,{options:cpe,value:f,onValueChange:e=>E(e),size:"sm",classNames:{trigger:"w-auto"}}),a.createElement(fe.hGA,{options:spe,value:x,onValueChange:e=>w(e),size:"sm",classNames:{trigger:"w-auto"}}));return a.createElement(a.Fragment,null,a.createElement("div",{className:"px-gutter pb-md"},se&&!_?a.createElement(fe.xz6,null,a.createElement("div",{className:"p-xl"},de)):a.createElement(fe.xz6,{className:"overflow-clip"},ue,se?a.createElement("div",{className:"p-xl"},a.createElement(cU.vx,{icon:ce,title:"No matching orders",subtitle:"No orders match your current filters. Try adjusting them."})):a.createElement(a.Fragment,null,a.createElement(Qre.u,{hasNextPage:M,onRequestNextPage:L},ie.map((e=>{let t=e.dateKey,n=e.dateLabel,l=e.total,r=e.rows;return a.createElement("div",{key:t},a.createElement("div",{className:" sticky top-0 z-1 flex items-center justify-between bg-background-secondary px-default py-xs ",style:{to
1p:k}},a.createElement("span",{className:"text-sm font-medium text-content-secondary"},n),a.createElement("span",{className:(0,q.cn)("text-sm font-medium text-content-secondary",fl.TN.className)},(0,rl.vv)(l))),r.map((e=>a.createElement(Xme,{key:e.id,retailTransaction:e,onClick:()=>ne(e)}))))})))))),$&&a.createElement(po.K,null,a.createElement($me,{retailTransaction:te,isLoading:ee,onClose:ae,onMatchTransaction:le,onOpenTransaction:re,onUnlink:O})),F&&a.createElement(po.K,null,a.createElement(go.TT,{id:F,previousTransactionId:null,nextTransactionId:null,setId:G,onClose:oe,onDelete:O})),a.createElement(XU.l,{path:I.JZ.transactions.retailSync.settings.relativePath},(e=>{let t=e.close;return a.createElement(jme,{onDone:t})})))},mpe=e=>e.date?N.c9.fromISO(e.date).toFormat("yyyy-MM-dd"):"unknown",ppe=e=>"unknown"===e?"Unknown date":N.c9.fromFormat(e,"yyyy-MM-dd").toLocaleString(N.c9.DATE_FULL),gpe=e=>(0,De.Eb)(e.map((e=>Math.abs(e.total))));var hpe=n(24984),vpe=function(e){return e.HIDDEN="HIDDEN",e.INSTALL_AMAZON_AND_TARGET="INSTALL_AMAZON_AND_TARGET",e.CONNECT_TARGET="CONNECT_TARGET",e}(vpe||{});const fpe=()=>{var e,t;const n=(0,Xo.IT)(Epe),l=n.data,s=n.loading,c=(0,hpe.c)().sendOpenPopupMessage,d=null===l||void 0===l?void 0:l.userHasConfiguredRetailSyncExtension,u=null===l||void 0===l||null===(e=l.me.profile)||void 0===e?void 0:e.dismissedRetailSyncBanner,m=!(null===l||void 0===l||null===(t=l.me.profile)||void 0===t||!t.dismissedRetailSyncTargetBannerAt),p=(0,a.useState)(!1),g=(0,o.A)(p,2),h=g[0],v=g[1],f=rpe(),E=(0,r.YW)({loading:s,bannerHasBeenClosed:h,isChromiumBrowser:f,userHasConfiguredExtension:d,userDismissedInstallationBanner:u,userDismissedTargetBanner:m}).with({loading:!0},(()=>vpe.HIDDEN)).with({bannerHasBeenClosed:!0},(()=>vpe.HIDDEN)).with({isChromiumBrowser:!1},(()=>vpe.HIDDEN)).with({userHasConfiguredExtension:!1,userDismissedInstallationBanner:!0},(()=>vpe.HIDDEN)).with({userHasConfiguredExtension:!1,userDismissedInstallationBanner:!1},(()=>vpe.INSTALL_AMAZON_AND_TARGET)).with({userHasConfiguredExtension:!0,userDismissedTargetBanner:!1},(()=>vpe.CONNECT_TARGET)).otherwise((()=>vpe.HIDDEN)),y=(0,i.n)(ype),b=(0,o.A)(y,1)[0],x=(0,a.useCallback)((()=>{const e=E===vpe.INSTALL_AMAZON_AND_TARGET,t=E===vpe.INSTALL_AMAZON_AND_TARGET||E===vpe.CONNECT_TARGET?N.c9.now().toISO():void 0;v(!0),b({variables:{dismissedRetailSyncBanner:e,dismissedRetailSyncTargetBannerAt:t}})}),[E,b]),w=(0,a.useCallback)((()=>{(0,Ge.u4)(Ye.Xt.BannerLinkOpened,{destination:"extension-popup"}),c(),x()}),[c,x]),C=(0,a.useCallback)((()=>{(0,Ge.u4)(Ye.Xt.BannerLinkOpened,{destination:"chrome-web-store"}),x()}),[x]),A=(0,a.useCallback)((e=>{null===e||void 0===e||e.stopPropagation(),(0,Ge.u4)(Ye.Xt.BannerDismissed),x()}),[x]);return E===vpe.HIDDEN?null:a.createElement("div",{"data-external-id":"retail-sync-banner",className:"mb-md flex"},a.createElement(fu.g,{type:"brand",width:"100%"},a.createElement("div",{className:"flex items-center justify-between"},(0,r.YW)(E).with(vpe.INSTALL_AMAZON_AND_TARGET,(()=>a.createElement(xt.v,null,"Install the new"," ",a.createElement(wb.gz,{target:"_blank",rel:"noopener noreferrer",underlined:!0,unstyled:!0,href:ope.Vg,onClick:C},"Monarch Extension")," ","for smarter categorization of both Amazon and Target transactions."))).with(vpe.CONNECT_TARGET,(()=>a.createElement(xt.v,null,"New: Smarter categorization of your Target orders."," ",a.createElement(wb.gz,{underlined:!0,unstyled:!0,onClick:()=>{(0,Ge.u4)(Ye.Xt.BannerLinkOpened),w()}},"Connect to Target")," ","through the Monarch Extension to get started!"))).otherwise((()=>null)),a.createElement(B.L,{icon:"x",hoverOpacity:.1,color:"pureWhite",onClick:A}))))},Epe=Ee.h08,ype=Ee.VFZ,bpe=e=>{let t=e.dateRange,n=e.defaultRange,l=e.requiredBoundedRange,r=e.onChangeDateRange;const o=t.startDate,i=t.endDate,s=(0,a.useMemo)((()=>!!n&&(o!==n.startDate||i!==n.endDate)),[o,i,n]),c=(0,a.useMemo)((()=>yne().find((e=>{let t=e.startDate,n=e.endDate;return o===t&&i===n}))),[o,i]),d=(0,a.useMemo)((()=>c?c.title:o||i?(0,Ba.tX)(o,i):"Date"),[o,i,c]);return a.createElement(fe.qN2,{"data-external-id":"transaction-date-range-button",show:s},a.createElement(Lne,{dateRange:t,onChange:e=>{let t=e.startDate,n=e.endDate;return r({startDate:t,endDate:n})},onClear:()=>r({startDate:void 0,endDate:void 0}),value:d,requiredBoundedRange:l}))},xpe=["onCancel","onChangeSections"],wpe=e=>
1{let t=e.onCancel,n=e.onChangeSections,l=(0,En.A)(e,xpe);return a.createElement(xH,Object.assign({"data-external-id":"transaction-filter-menu-popover",onChange:n,onClickCancel:t},l))},Cpe=e=>{let t=e.filters,n=e.onChangeFilters;const l=(0,a.useState)(!1),r=(0,o.A)(l,2),i=r[0],s=r[1],d=(0,a.useMemo)((()=>(0,c.A)((0,VW.A)(e0.p6,t))),[t]),u=fQ({page:"transactions",filters:t,onApplyFilters:e=>{n(e),f()},renderAccountLogo:e=>a.createElement(Gl.v,{logoUrl:e.logoUrl,icon:e.icon,size:14,className:"mr-2xs"}),renderGoalImage:e=>a.createElement(aQ,{goal:e}),renderSavingsGoalImage:e=>a.createElement(iQ,{savingsGoal:e}),renderMerchantLogo:e=>a.createElement(Wl._,{url:e.logoUrl,size:14,className:"mr-2xs"}),renderMerchantAccessory:e=>e.transactionCount&&a.createElement("span",{className:"flex items-center gap-2xs text-sm/6 font-book text-content-secondary"},a.createElement(fe.$OE,{size:12}),(0,De.LN)(e.transactionCount)),renderTag:e=>a.createElement(Ta.c,{color:e.color,size:10,className:"mr-2xs"}),renderOwnership:e=>a.createElement(Pw.n,{userId:null===e||void 0===e?void 0:e.id,userName:null===e||void 0===e?void 0:e.displayName,userProfilePictureUrl:null===e||void 0===e?void 0:e.profilePictureUrl,avatarSize:14,showLabel:!1,className:"mr-2xs"})}),m=u.sections,p=u.isLoading,g=u.isFetchingMoreData,h=u.onSearchChange,v=u.onChangeSections,f=u.resetUnappliedChanges,E=u.handleApply;return a.createElement(fe.k_P.Root,{"data-external-id":"transaction-filter-button",open:i,onOpenChange:e=>{s(e),f()},size:"2xl"},a.createElement(fe.qN2,{show:d},a.createElement(fe.k_P.Trigger,{render:a.createElement(fe.XZZ,{icon:a.createElement(fe.evG,null),variant:"default"},"Filters")})),a.createElement(fe.k_P.Content,{side:"bottom",align:"end",className:"p-0"},a.createElement(wpe,{sections:m,isLoading:p,onCancel:()=>{f(),s(!1)},onChangeSections:v,onSearchChange:h,isSearchLoading:g,onClickApply:e=>{E(e),s(!1)}})))},Ape=(0,xZ.Z)((()=>n.e(2048).then(n.bind(n,2048)).then((e=>({default:e.TransactionSearchPopoverConnected})))),"TransactionSearchPopover"),Ipe=e=>{let t=e.search,n=e.onChangeSearch;const l=(0,a.useState)(!1),r=(0,o.A)(l,2),i=r[0],s=r[1],d=(0,a.useCallback)((()=>s((e=>!e))),[]);return a.createElement(fe.k_P.Root,{"data-external-id":"transaction-search-button",open:i,onOpenChange:s,size:"md"},a.createElement(fe.qN2,{show:(0,c.A)(t)},a.createElement(fe.k_P.Trigger,{render:a.createElement(fe.XZZ,{icon:a.createElement(fe.s$r,null),variant:"default"},t?'"'.concat(t,'"'):"Search")})),a.createElement(fe.k_P.Content,{side:"bottom",align:"end",className:"p-0"},a.createElement(a.Suspense,{fallback:a.createElement("div",{className:"flex h-50 w-container-md items-center justify-center"},a.createElement(fe.ix7,null))},a.createElement(Ape,{toggleOpen:d,initialValue:t,onChangeSearch:n}))))},kpe=a.memo(Ipe),Spe=["search","startDate","endDate","order","businessEntitySet"],Npe=(0,_V.A)(["startDate","endDate"]),Tpe=e=>{var t;let n=e.filters,l=e.isSummaryColumnVisible,r=e.toggleSummaryColumnShortcut,o=e.onChangeFilters,i=e.toggleIsCollapsed;const s=(0,qG.e)().hasAccess,c=(0,Tj.Rq)(),d=c.businessEntities,u=c.isLoadingInitialData,m=s&&(u||d.length>0),p=(0,a.useCallback)((e=>o({search:e})),[o]),g=(0,a.useCallback)((e=>o((0,TV.A)((0,_V.A)(Spe,n),e),!0)),[n,o]),h=(0,a.useMemo)((()=>Object.values(n).some(e0.p6)),[n]),v=(0,a.useCallback)((()=>o(CX.q9)),[o]);return a.createElement(uU.f,{"data-external-id":"transactions-header-controls"},h&&a.createElement(fe.XZZ,{variant:"text",colorScheme:"link",onClick:v},"Clear"),a.createElement(kpe,{search:n.search,onChangeSearch:e=>{p(e);const t=e!==n.search;e&&(null===e||void 0===e?void 0:e.length)>0&&t&&ij.Ay.transactionsSearchChanged({search:e})}}),a.createElement(bpe,{dateRange:Npe(n),defaultRange:{startDate:void 0,endDate:void 0},onChangeDateRange:e=>{if(o(e),e.startDate||e.endDate){const t=Npe(e),n=t.startDate,a=t.endDate;ij.Ay.transactionsDateRangeChanged({startDate:n||void 0,endDate:a||void 0})}}}),m&&a.createElement(OH.O,{businessEntitySet:null!==(t=n.businessEntitySet)&&void 0!==t?t:void 0,onChangeBusinessEntitySet:e=>{o({businessEntitySet:e})},source:Ye.rP.Transactions}),a.createElement(Cpe,{filters:(0,XX.A)(Spe,n),onChangeFilters:g}),a.createElement(wm.A,{orientation:"vertical",color:"tertiary",className:"mx-2xs h-default"}),a.createElement(p1.E,{to:I.JZ.transactions.addTransaction({queryParams:(0,e0.sO)(n)}),variant:"primary",size:"sm",icon:a.createElement(fe.Wa3,null)},"Add"),(0,Tr.A)(i)&&a.createElement(fe.Yvj,{content:a.createElement("div",{className:"flex items-center gap-xs"},a.createElement(fe.c8D,{size:"xs",weight:"medium",color:"primary"},"Toggle summary"),a.createElement(fe.acH,{variant:"outline",keys:r})),description:"Toggle summary"},a.createElement(fe.ENt,{"aria-label":"Toggle summary",pressed:l,onPressedCh
1ange:i,size:"sm"},a.createElement(fe.OfV,null))))},_pe=a.memo(Tpe),Dpe="h-8 pb-0 text-base font-normal hover:text-content-primary data-active:hover:text-content-brand",Rpe=()=>{const e=(0,l.zy)().pathname,t=(0,nG.p)("feat-receipt-scan-web","on"),n=Due({skip:!t}).shouldPromote;return a.createElement(fe.T36.Root,{"data-external-id":"transactions-header-tabs",className:"ml-xl pr-lg",value:Mpe(e),fitContent:!0},a.createElement(fe.T36.List,{"aria-label":"Transactions views",className:"gap-lg"},a.createElement(fe.T36.Tab,{value:"all",render:a.createElement(l.k2,{to:I.JZ.transactions.path,end:!0}),nativeButton:!1,className:Dpe},"All"),t&&a.createElement(fe.T36.Tab,{value:"receipts",render:a.createElement(l.k2,{to:I.JZ.transactions.receipts.path}),nativeButton:!1,className:Dpe},"Receipts",n&&a.createElement(fe.CQG,{color:"brand",variant:"solid",rounded:"default",size:"xs"},"New")),a.createElement(fe.T36.Tab,{value:"retail-sync",render:a.createElement(l.k2,{to:I.JZ.transactions.retailSync.path}),nativeButton:!1,className:Dpe},"Retail Sync"),a.createElement(fe.T36.Indicator,null)))},Mpe=e=>(0,ma.gQ)(e,I.JZ.transactions.receipts.path)?"receipts":(0,ma.gQ)(e,I.JZ.transactions.retailSync.path)?"retail-sync":"all";var Lpe=n(63322);const Ope=["]"];var Ppe=n(30612);const Bpe=(0,xZ.Z)((()=>n.e(8665).then(n.bind(n,18665)).then((e=>({default:e.TransactionsUpdateWalkthrough})))),"LazyLoadedTransactionsUpdateWalkthrough"),zpe=()=>a.createElement(l.BV,{"data-external-id":"transactions"},a.createElement(l.qh,{path:"receipts/*",element:a.createElement(OY,{name:"feat-receipt-scan-web",defaultOnTimeout:"on"},a.createElement(Fpe,null))}),a.createElement(l.qh,{path:"retail-sync/*",element:a.createElement(Gpe,null)}),a.createElement(l.qh,{path:"*",element:a.createElement(Ype,null)})),Fpe=()=>a.createElement(Yq,{"data-external-id":"receipts-tab",name:"Transactions",emptyIcon:"credit-card",emptyTitle:_t.AE,tabs:a.createElement(Rpe,null),controls:a.createElement(uU.f,null,a.createElement(wt.Xb,{linkTo:I.JZ.transactions.receipts.settings(),size:"small"},a.createElement(Yo.r,{name:"settings"}),a.createElement("span",null,"Settings")))},a.createElement(Tme,null)),Gpe=()=>a.createElement(Yq,{"data-external-id":"retail-sync-tab",name:"Transactions",emptyIcon:"credit-card",emptyTitle:_t.AE,tabs:a.createElement(Rpe,null),controls:a.createElement(uU.f,null,a.createElement(p1.E,{to:I.JZ.transactions.retailSync.settings(),variant:"default",size:"sm",icon:a.createElement(fe.z79,{size:"md"})},"Settings"))},a.createElement(upe,null)),Ype=()=>{var e,t,n,r;const i=(0,pG.w)(),s=(0,l.Zp)(),c=(0,nG.p)("transactions-ui-updates-walkthrough","off"),u=(0,xq.bO)("dismissedTransactionsListUpdatesTourAt"),m=(0,o.A)(u,2),p=m[0],h=m[1],f=(0,xq.bO)("hasReviewedSpending"),E=(0,o.A)(f,2),y=E[0],b=E[1];(0,a.useEffect)((()=>{!1!==y&&null!==y||b(!0)}),[y,b]);const x=(0,d.d4)(A.QG),w=(0,a.useCallback)((()=>{i((0,g.UM)(!x))}),[x,i]),C=(0,e0.R7)({initialFilters:CX.q9,includeFalsyValues:!0}),k=(0,o.A)(C,2),S=k[0],N=k[1],T=(0,a.useCallback)(((e,t)=>{N(t?e:(0,U.A)((0,U.A)({},S),e))}),[S,N]),_=(0,e0.sO)(S),D=!!(0,l.RQ)(I.JZ.transactions.addTransaction),R=(0,l.RQ)("/transactions/:id"),M=!D&&(null===R||void 0===R||null===(e=R.params)||void 0===e?void 0:e.id)||null,L=(0,a.useMemo)((()=>(0,CX.WD)(S)),[S]),O=(0,a.useState)(),P=(0,o.A)(O,2),B=P[0],z=P[1],F=(0,a.useCallback)((e=>{z(e)}),[]),G=(0,a.useCallback)((()=>{z(void 0),f7.S.refetchQueries({include:[kQ.B]})}),[]),Y=(0,QQ.j)({filters:S}),V=Y.currentSession,W=Y.downloadTransactions,j=Y.isLoading,H=(0,bZ.D)(Upe,{variables:{filters:L},notifyOnNetworkStatusChange:!0}),K=H.data,q=H.isLoadingInitialData,$=H.refetch,Z=(0,a.useMemo)((()=>a.createElement(cU.vx,{icon:a.createElement("div",{className:"flex rounded-full bg-background-tertiary p-md text-content-secondary"},a.createElement(fe.$OE,{size:"2xl"})),title:(0,Tce.A)(S,CX.q9)?"No transactions yet":"No transactions found",subtitle:(0,Tce.A)(S,CX.q9)?"Connect an account to see transactions here.":S.search?"We couldn't find any transactions matching your search of \"".concat(S.search,'".'):"We couldn't find any transactions matching your filters.",button:{title:"Clear filters",onClick:()=>N(CX.q9)}})),[S,N]),J=(e=>{let t=e.toggleSummaryColumnVisibility;const n=(0,d.d4)(Lpe.f9),l=(0,mce.WB)().registerCommand,r=(0,v.D)((()=>{t()}));return(0,a.useEffect)((()=>
1{if(n)return;const e=l({group:"actions",id:"transactions.toggle-summary-column",label:"Toggle summary column",action:r,keys:Ope,icon:a.createElement(sl.ZQ,{name:"sidebar-right"}),analyticsMetadata:{analyticsId:"transactions.toggle-summary-column"}});return()=>{e()}}),[l,r,n]),{toggleSummaryColumnShortcut:Ope}})({toggleSummaryColumnVisibility:w}),X=J.toggleSummaryColumnShortcut,Q=B?{onRetry:G}:void 0;return a.createElement(Yq,{"data-external-id":"transactions-tab",name:"Transactions",emptyIcon:"credit-card",emptyTitle:_t.AE,pageError:Q,tabs:a.createElement(Rpe,null),controls:a.createElement(_pe,{filters:S,onChangeFilters:T,toggleIsCollapsed:w,isSummaryColumnVisible:x,toggleSummaryColumnShortcut:X}),onAccountAdded:()=>{$(),(0,Ppe.w)([kQ.B])}},a.createElement(rV.T,{screenName:"Transactions",isInfiniteScroll:!0}),a.createElement(L7,{isCollapsed:!x,collapsibleColumnWidth:320},a.createElement(sH.j.Provider,{value:{searchWords:S.search?[S.search]:[]}},a.createElement(fpe,null),a.createElement(Xl.AM,null,a.createElement(kQ.j,{transactionFilters:L,refetchSummary:$,pageSize:25,isReviewModeActive:S.needsReview,sortBy:S.order,onChangeSortBy:e=>T({order:e}),overrideDrawer:{setDrawerTransactionId:e=>e&&s(I.JZ.transactions.details({id:e,queryParams:_})),drawerTransactionId:M,onTransactionDrawerClose:()=>s(I.JZ.transactions({queryParams:_}))},emptyComponent:S.needsReview?a.createElement(G8,{onClickViewAll:()=>N({})}):Z,allowBulkUpdate:!0,headerShouldHaveSortControls:!0,showOwner:!0,onErrorChange:F}))),a.createElement("div",null,a.createElement(KQ,{empty:Z,errorMessage:null!==(t=null===V||void 0===V?void 0:V.errorMessage)&&void 0!==t?t:void 0,filters:S,isDownloadingCsv:j,isLoading:q,onChangeFilters:N,onClickDownloadCsv:W,transactionsSummary:null===K||void 0===K||null===(n=K.aggregates[0])||void 0===n?void 0:n.summary}),a.createElement(IQ.T,{downloadUrl:null!==(r=null===V||void 0===V?void 0:V.url)&&void 0!==r?r:void 0}))),a.createElement(XU.l,{path:I.JZ.transactions.addTransaction.relativePath},(e=>{let t=e.close;return a.createElement(lde.t,{onDone:()=>{t(),$()},onCancel:t})})),c&&null===p&&a.createElement(a.Suspense,{fallback:null},a.createElement(Bpe,{onClose:()=>h((new Date).toISOString())})))},Upe=Ee.FUl;var Vpe=n(44564),Wpe=n(91120);const jpe=e=>{let t=e.icon,n=e.title,l=e.subtitle,r=e.button,o=r.text,i=r.icon,s=r.onClick,c=r.loading,d=void 0!==c&&c,u=e.defaultButton,m=e.className;return a.createElement(RF,{"data-external-id":"deprecated-empty-create-card",className:(0,q.cn)("\n        inset-x-2xl top-auto bottom-default w-auto items-start px-default py-lg\n        sm:top-0 sm:bottom-auto sm:mx-auto sm:mt-54.75 sm:w-125 sm:p-xl\n      ",m)},a.createElement(Xpe,{name:t}),a.createElement(Kpe,{weight:"medium"},n),!!l&&a.createElement(qpe,null,l),a.createElement(Jpe,null,a.createElement($pe,{onClick:s,disabled:d,pending:d},!!i&&a.createElement(Yo.r,{name:i}),a.createElement("span",null,o)),Hpe(u)?a.createElement(Zpe,{onClick:null===u||void 0===u?void 0:u.onClick},u.text):u))},Hpe=e=>!!e&&(0,Wpe.A)(["text"],e),Kpe=(0,u.default)(xt.v).withConfig({displayName:"EmptyCreateCard__Title",componentId:"sc-1okyvso-0"})(["font-size:",";@media (min-width:","px){font-size:",";}"],(e=>e.theme.fontSize.small),(e=>e.theme.breakPoints.sm),(e=>e.theme.fontSize.xlarge)),qpe=(0,u.default)(xt.v).withConfig({displayName:"EmptyCreateCard__Subtitle",componentId:"sc-1okyvso-1"})(["font-size:",";margin-top:",";@media (min-width:","px){font-size:",";}"],(e=>e.theme.fontSize.small),(e=>e.theme.spacing.default),(e=>e.theme.breakPoints.sm),(e=>e.theme.fontSize.base)),$pe=(0,u.default)(su.U).attrs({size:"medium"}).withConfig({displayName:"EmptyCreateCard__SubmitButton",componentId:"sc-1okyvso-2"})(["@media (max-width:","px){flex:1;}",""],(e=>e.theme.breakPoints.sm),(e=>(0,cu.vc)(e))),Zpe=(0,u.default)(bn.v).withConfig({displayName:"EmptyCreateCard__SkipButton",componentId:"sc-1okyvso-3"})(["margin-left:",";color:",";font-size:",";"],(e=>e.theme.spacing.xlarge),(e=>e.theme.color.textLight),(e=>e.theme.fontSize.xsmall)),Jpe=(0,u.default)(m.g).attrs({alignCenter:!0}).withConfig({displayName:"EmptyCreateCard__ButtonContainer",componentId:"sc-1okyvso-4"})(["margin-top:19px;@media (max-width:","px){width:100%;}@media (min-width:","px){margin-top:",";}"],(e=>e.theme.breakPoints.sm),(e=>e.theme.breakPoints.sm),(e=>e.theme.spacing.xxlarge)),Xpe=(0,u.default)(sl.ZQ).withConfig({displayName:"EmptyCreateCard__StyledIcon",componentId:"sc-1okyvso-5"})(["width:24px;height:24px;color:",";margin-bottom:27px;display:none;@media (min-width:","px){display:block;}"],(e=>e.theme.color.orange),(e=>e.theme.breakPoints.sm)),Qpe=e=>{let t=e.categories;return a.createElement(Tm,{"data-external-id":"advice-categories-menu",as:"nav","aria-label":"Advice categories",className:"px-2xs"},a.createElement(Tm.ItemLink,{to:I.JZ.advice({category:w1.Ly})},"Recommendations"),a.createElement(Tm.Separator,null),t.map((e=>{let t=e.name,n=e.displayName;return a.createElement(Tm.ItemLink,{key:t,to:I.JZ.advice({category:t})},n)})))},ege=e=>{let t=e.task,n=t.title,l=t.completedAt,r=e.onClickCheckbox,o=e.onClick,i=e.className;return a.createElement(nge,{"data-external-id":"advice-task-row",className:i},a.createElement(fz.hm,{"aria-label":n,checked:!!l,onChange:r}),a.createElement(age,{className:"group",onClick:o,completed:!!l},n,a.createElement(tge,null)))},tge=()=>a.createElement(fe.Fug,{"data-external-id":"link-arrow",size:"md",className:"ml-2xs inline -translate-x-2.5 align-middle opacity-0 transition-all group-hover:translate-x-0 group-hover:opacity-100"}),nge=(0,u.default)(m.g).withConfig({displayName:"AdviceTaskRow__Root",componentId:"sc-5k699m-0"})(["padding:"," ",";"],(e=>e.theme.spacing.default),(e=>e.theme.spacing.xxlarge)),age=(0,u.default)(xt.v).withConfig({displayName:"AdviceTaskRow__Title",componentId:"sc-5k699m-1"})(["transition:",";cursor:pointer;margin-left:",";:hover{color:",";}",""],(e=>e.theme.transition.default),(e=>e.theme.spacing.default),(e=>e.theme.color.blue),(e=>e.completed&&(0,u.css)(["color:",";text-decoration:line-through;"],(e=>e.theme.color.textLight))));ege.fragments={AdviceTaskRowFields:Ee.nr8};var lge=n(79741),rge=n(32761);const oge="previous",ige=e=>{let t=e.itemId,n=e.taskId;const a=(0,l.Zp)(),r=(0,lV.L)().category,o=(0,b.QF)(oge),i=null===o||void 0===o?void 0:o[0],s=!!n,c=!n;return{previousItemId:i,getAdviceItemRoute:e=>I.JZ.advice.itemDetails({itemId:e,category:r,queryParams:{[oge]:[t,...null!==o&&void 0!==o?o:[]]}}),navigateToAdviceTask:e=>()=>
1a(I.JZ.advice.taskDetails({itemId:t,taskId:e,category:r,queryParams:{[oge]:o}})),goBack:()=>{i&&c?a(I.JZ.advice.itemDetails({itemId:i,category:r,queryParams:{[oge]:(0,rge.A)(1,null!==o&&void 0!==o?o:[])}})):s&&a(I.JZ.advice.itemDetails({itemId:t,category:r,queryParams:{[oge]:o}}))},onClose:()=>a(I.JZ.advice({category:r}))}},sge=()=>{const e=(0,i.n)(cge),t=(0,o.A)(e,1)[0],n=(0,i.n)(dge),l=(0,o.A)(n,1)[0];return(0,a.useCallback)((e=>{let n=e.id;const a={adviceItemTaskId:n};return e.completedAt?l({variables:{input:a},optimisticResponse:{__typename:"Mutation",markAdviceItemTaskIncomplete:{__typename:"MarkAdviceItemTaskIncomplete",adviceItemTask:{__typename:"AdviceItemTask",id:n,completedAt:null},errors:null}}}):t({variables:{input:a},optimisticResponse:{__typename:"Mutation",markAdviceItemTaskComplete:{__typename:"MarkAdviceItemTaskComplete",adviceItemTask:{__typename:"AdviceItemTask",id:n,completedAt:N.c9.local().toISO()},errors:null}}})}),[t,l])},cge=Ee.gP8,dge=Ee.J5P,uge=()=>{const e=(0,lV.L)().itemId,t=ige({itemId:e}),n=t.previousItemId,l=t.getAdviceItemRoute,r=t.navigateToAdviceTask,o=t.goBack,i=t.onClose,s=(0,et.I)(mge,{variables:{itemId:e,previousItemId:null!==n&&void 0!==n?n:"",skipPrevious:!n}}),c=s.data,d=s.isLoadingInitialData,u=null!==c&&void 0!==c?c:{},m=u.adviceItem,p=u.previousItem,g=null!==m&&void 0!==m?m:{},h=g.category,v=g.title,f=g.description,E=g.tasks,y=void 0===E?[]:E,b=g.prerequisiteAdviceItems,x=void 0===b?[]:b,w=g.completedAt,C=g.name,A=sge();return(0,a.useEffect)((()=>{C&&ij.Ay.viewedAdviceItem({name:C})}),[C]),a.createElement(F7.v,{"data-external-id":"advice-item-drawer",onClose:i,title:null===p||void 0===p?void 0:p.title,onClickBack:p?o:void 0,key:e},d?a.createElement("div",{className:"flex h-[80%] flex-1 items-center justify-center"},a.createElement(fe.ix7,null)):a.createElement("div",{className:"pb-3xl"},a.createElement("div",{className:(0,q.cn)("flex flex-col items-start px-2xl pb-xl",p&&"mt-default")},h&&a.createElement(u1,{adviceCategory:h,completed:!!w}),a.createElement(fe.c8D,{size:"xl",weight:"medium",className:"mt-xl block"},v),!!f&&a.createElement(Ll.o,{source:f,className:"mt-sm block text-base leading-[150%] whitespace-pre-wrap"})),x.length>0&&a.createElement(Bc,{title:"Essentials recommended",subtitle:"This advice is important to complete before focusing on other priorities. We recommend completing these first to have a solid foundation.",initiallyExpanded:!0},a.createElement(fe.Qey.Group,{rounded:x.length>4?"none":"bottom"},(0,NF.A)(4,x).map((e=>a.createElement(m1,{key:e.id,item:e,to:l(e.id)})))),x.length>4&&a.createElement(a.Fragment,null,a.createElement(fe.AVK,null),a.createElement(lge.K.Consumer,null,(e=>{let t=e.close;return a.createElement(p1.E,{to:I.JZ.advice({category:w1.Ly,queryParams:{scroll:w1.Sd.Essential}}),onClick:t,variant:"text",colorScheme:"link",className:"justify-start px-default py-md"},"View all ",x.length)})))),a.createElement(Bc,{title:"Tasks",initiallyExpanded:!0},y.map((e=>a.createElement(ege,{key:e.id,task:e,onClick:r(e.id),onClickCheckbox:()=>A(e),className:"border-b border-divider-primary"}))))))},mge=Ee.XXo;var pge=n(45929),gge=n.n(pge);const hge=e=>{let t=e.item,n=t.title,l=t.description,r=t.category,o=t.completedAt,i=t.numTasksCompleted,s=t.numTasksRemaining,c=t.numTasks,d=e.onClick,u=e.className;const m=(0,a.useMemo)((()=>gge()(null!==l&&void 0!==l?l:"")),[l]);return a.createElement(vge,{"data-external-id":"advice-item-row",onClick:d,className:u},a.createElement(yge,null,a.createElement(u1,{adviceCategory:r,completed:!!o})),a.createElement("div",{className:"flex flex-col"},a.createElement(fge,null,n),a.createElement(Ege,null,m),a.createElement(Ul.w,null,a.createElement(Ul.d,{when:!!o},a.createElement(bge,null,N.c9.fromISO(null!==o&&void 0!==o?o:"").toFormat("MMM yyyy")," \u30fb ",i," ","tasks completed")),a.createElement(Ul.d,{when:!i},a.createElement(bge,null,"Not started \u30fb ",s," tasks to complete")),a.createElement(Ul.d,{default:!0},a.createElement(fe.cqk,{value:i,max:c,color:"progress-success",size:"xs",className:"mt-xl"},Array.from({length:c},((e,t)=>a.createElement(fe.cqk.Segment,{key:t,from:t,to:t+1,className:"w-11 flex-1 rounded-full"}))))))))},vge=(0,u.default)(m.g).withConfig({displayName:"AdviceItemRow__Root",componentId:"sc-1t1daxa-0"})(["padding:",";padding-left:0;cursor:pointer;transition:",";:hover{background:",";}:not(:last-child){border-bottom:1px solid ",";}:last-child{border-radius:0 0 "," ",";}"],(e=>e.theme.spacing.xlarge),(e=>e.theme.transition.default),(e=>
1e.theme.color.grayBackground),(e=>e.theme.color.grayFocus),(e=>e.theme.radius.medium),(e=>e.theme.radius.medium)),fge=(0,u.default)(xt.v).withConfig({displayName:"AdviceItemRow__Title",componentId:"sc-1t1daxa-1"})(["font-size:",";"],(e=>e.theme.fontSize.large)),Ege=(0,u.default)(xt.v).attrs({clampLines:2}).withConfig({displayName:"AdviceItemRow__Description",componentId:"sc-1t1daxa-2"})(["font-size:",";color:",";margin-top:",";"],(e=>e.theme.fontSize.small),(e=>e.theme.color.textLight),(e=>e.theme.spacing.xxsmall)),yge=(0,u.default)(m.g).attrs({justifyCenter:!0}).withConfig({displayName:"AdviceItemRow__IconContainer",componentId:"sc-1t1daxa-3"})(["width:96px;flex-shrink:0;"]),bge=(0,u.default)(xt.v).attrs({size:"xxsmall",weight:"bold"}).withConfig({displayName:"AdviceItemRow__StatusText",componentId:"sc-1t1daxa-4"})(["letter-spacing:0.08em;color:",";text-transform:uppercase;margin-top:10px;"],(e=>e.theme.color.textLight));hge.fragments={AdviceItemRowFields:Ee.RhQ};const xge=e=>{let t=e.items;const n=(0,l.Zp)(),r=(0,lV.L)().category,i=(0,a.useMemo)((()=>(0,vj.A)((e=>!e.completedAt),t)),[t]),s=(0,o.A)(i,2),c=s[0],d=s[1],u=e=>()=>n(I.JZ.advice.itemDetails({itemId:e.id,category:r}));return 0===t.length?a.createElement(cU.vx,{"data-external-id":"advice-item-list",title:"No items",subtitle:"There's nothing to show here yet..."}):a.createElement(wge,{"data-external-id":"advice-item-list"},c.map((e=>a.createElement(hge,{key:e.id,item:e,onClick:u(e)}))),d.length>0&&a.createElement(oK,{showText:"Show ".concat(d.length," completed"),hideText:"Hide ".concat(d.length," completed")},d.map((e=>a.createElement(Cge,{key:e.id,item:e,onClick:u(e)})))))},wge=u.default.div.withConfig({displayName:"AdviceItemList__Root",componentId:"nr9xay-0"})([""]),Cge=(0,u.default)(hge).withConfig({displayName:"AdviceItemList__CompletedAdviceItemRow",componentId:"nr9xay-1"})(["&&{border-bottom:1px solid ",";border-radius:0;}"],(e=>e.theme.color.grayFocus));xge.fragments={AdviceItemListFields:Ee.fiH};const Age=()=>{const e=(0,lV.L)(),t=e.itemId,n=e.taskId,l=ige({itemId:t,taskId:n}),r=l.goBack,o=l.onClose,i=(0,et.I)(Dge,{variables:{itemId:t,taskId:n}}),s=i.data,c=i.isLoadingInitialData,d=null!==s&&void 0!==s?s:{},u=d.adviceItem,m=d.adviceItemTask,g=null!==u&&void 0!==u?u:{},h=g.title,v=g.name,f=null!==m&&void 0!==m?m:{},E=f.title,y=f.description,b=f.completedAt,x=f.name,w=sge();return(0,a.useEffect)((()=>{x&&v&&ij.Ay.viewedAdviceTask({item_name:v,name:x})}),[x,v]),a.createElement(F7.v,{"data-external-id":"advice-task-drawer",title:h,onClose:o,onClickBack:r},c?a.createElement(kge,null,a.createElement(p.i,null)):a.createElement(Ige,null,a.createElement(Sge,null,E),!!y&&a.createElement(Ll.o,{source:y,className:"mt-sm mb-10 block text-base leading-[150%] whitespace-pre-wrap"}),!!b&&a.createElement(Tge,null,a.createElement(_ge,null),a.createElement(xt.v,{size:"xsmall"},"Completed on ",(0,Ba.AO)(b))),a.createElement(Nge,{size:"large",onClick:()=>{var e;return m&&w({id:m.id,completedAt:null!==(e=m.completedAt)&&void 0!==e?e:void 0})}},b?"Mark as incomplete":"Mark as complete")))},Ige=u.default.div.withConfig({displayName:"AdviceTaskDrawer__Container",componentId:"sc-1aqfoow-0"})(["padding:"," ",";"],(e=>e.theme.spacing.xxxlarge),(e=>e.theme.spacing.xxlarge)),kge=(0,u.default)(m.g).attrs({center:!0}).withConfig({displayName:"AdviceTaskDrawer__LoadingContainer",componentId:"sc-1aqfoow-1"})(["flex:1;height:80%;"]),Sge=(0,u.default)(xt.v).attrs({size:"xlarge",weight:"medium"}).withConfig({displayName:"AdviceTaskDrawer__Title",componentId:"sc-1aqfoow-2"})(["display:block;"]),Nge=(0,u.default)(su.U).attrs({size:"large"}).withConfig({displayName:"AdviceTaskDrawer__Button",componentId:"sc-1aqfoow-3"})(["",";width:100%;"],wt.CB),Tge=(0,u.default)(m.g).attrs({alignCenter:!0,justifyCenter:!0}).withConfig({displayName:"AdviceTaskDrawer__CompleteContainer",componentId:"sc-1aqfoow-4"})(["color:",";margin-bottom:",";"],(e=>e.theme.color.green),(e=>e.theme.spacing.small)),_ge=(0,u.default)(sl.ZQ).attrs({name:"check-square"}).withConfig({displayName:"AdviceTaskDrawer__CompleteIcon",componentId:"sc-1aqfoow-5"})(["width:",";height:",";margin-right:",";"],(e=>e.theme.spacing.small),(e=>e.theme.spacing.small),(e=>e.theme.spacing.xsmall)),Dge=Ee.xXG,Rge=e=>
1{let t=e.onStartSaving,n=e.isOptingIn,l=e.pageState,r=e.isGeneratingOverdue,o=void 0!==r&&r;const i=(0,lm.a)(),s=E4.fy.map((e=>{let t=e.light,n=e.dark;return"dark"===i?n:t})),c=T4(l,o);return a.createElement("div",{"data-external-id":"advice-v2-onboarding",className:"flex size-full flex-col gap-default px-gutter pb-gutter"},c?a.createElement(Lge,{content:c}):a.createElement(Mge,{onStartSaving:t,isOptingIn:n}),a.createElement("div",{className:"flex min-h-0 flex-1 flex-col gap-default md:flex-row"},_t.$y.SLIDES.map(((e,t)=>a.createElement(fe.xz6,{key:e.TITLE,className:"min-h-0 flex-1"},a.createElement("div",{className:" flex h-full min-h-0 flex-col items-center justify-end gap-xl overflow-hidden p-xl pb-2xl "},a.createElement("div",{className:"flex min-h-0 w-full flex-1 items-center justify-center"},a.createElement("video",{key:s[t],src:s[t],"aria-label":e.TITLE,autoPlay:!0,loop:!0,muted:!0,playsInline:!0,className:"aspect-4/3 max-h-full max-w-120 rounded-default object-contain"})),a.createElement("div",{className:"flex w-full flex-col gap-2xs text-center"},a.createElement(xt.v,{size:"large",weight:"medium"},e.TITLE),a.createElement(xt.v,{color:"content.secondary"},e.DESCRIPTION))))))),a.createElement(xt.v,{size:"small",color:"content.secondary"},_t.V4.DISCLAIMER_PRE_OPT_IN))},Mge=e=>{let t=e.onStartSaving,n=e.isOptingIn;return a.createElement(fe.xz6,{"data-external-id":"hero-card",className:"flex-1"},a.createElement("div",{className:"flex h-full flex-col items-center justify-center px-xl py-2xl md:py-4xl"},a.createElement("div",{className:"flex flex-col items-center gap-xl"},a.createElement("div",{className:"flex flex-col items-center gap-sm text-center"},a.createElement(xt.v,{as:"p",weight:"book",color:"content.primary",lineHeight:1.3,letterSpacing:"-0.05em",className:"m-0 w-full max-w-183.25 font-secondary text-2xl md:text-[48px]"},_t.V4.ONBOARDING.HEADING,a.createElement(xt.v,{as:"span",weight:"medium",italic:!0},_t.V4.ONBOARDING.HEADING_AND),_t.V4.ONBOARDING.HEADING_SUFFIX),a.createElement(xt.v,{as:"p",color:"content.secondary",className:"m-0 max-w-135.25"},_t.V4.ONBOARDING.SUBTITLE)),a.createElement(cu.WT,{size:"large",onClick:t,disabled:n},_t.V4.ONBOARDING.CTA))))},Lge=e=>{let t=e.content;return a.createElement(fe.xz6,{"data-external-id":"insights-state-card",className:"flex w-full flex-1 flex-col items-center justify-center py-4xl"},a.createElement("div",{className:"flex w-full flex-col items-center gap-default px-xl py-2xl"},a.createElement(M4,{icon:t.icon,variant:t.iconVariant}),a.createElement("div",{className:"flex w-full flex-col items-center gap-2xs text-center"},a.createElement(xt.v,{size:"large",weight:"medium"},t.title),a.createElement(xt.v,{as:"p",color:"content.secondary",className:"m-0 max-w-113.5"},t.description))))};var Oge,Pge,Bge,zge;const Fge=e=>{let t=e.insightId,n=e.merchant,l=e.savingsAmount,r=e.showSuccess,s=e.onSubmitted;const c=(0,Sq.k)().cancel,d=(0,C.RU)(),u=(0,a.useRef)(null);(0,a.useEffect)((()=>{var e;null===(e=u.current)||void 0===e||e.focus()}),[]);const m=(0,i.n)(D4.sL,{refetchQueries:[{query:D4.SV,variables:{statuses:E4.oH}}]}),p=(0,o.A)(m,2),g=p[0],h=p[1].loading;return r?a.createElement(Rc.L,{"data-external-id":"insight-not-interested-modal",title:void 0},a.createElement(Uge,null,a.createElement(d7.r,{className:"size-15",iconSizePx:32}),a.createElement(Vge,null,a.createElement(xt.v,{as:"p",size:"xlarge",weight:"medium"},_t.V4.NOT_INTERESTED_SUCCESS_TITLE),a.createElement(xt.v,{as:"p",color:"content.secondary"},_t.V4.NOT_INTERESTED_SUCCESS_BODY))),a.createElement(Cq.R,null,a.createElement(cu.WT,{size:"small",type:"button",onClick:()=>c()},_t.V4.NOT_INTERESTED_SUCCESS_OKAY))):a.createElement(Rc.L,{"data-external-id":"insight-not-interested-modal",title:_t.V4.INSIGHT_MENU_NOT_INTERESTED},a.createElement(Eu.lV,{initialValues:{feedback:""},onSubmit:async e=>{const a=e.feedback.trim();try{var r;const e=await g({variables:{input:(0,U.A)({id:t,status:Ee.yWn.DENIED},a?{denialReason:a}:{})}}),o=e.data,i=e.errors,c=null===o||void 0===o?void 0:o.updateFinancialInsightStatus;if(null!==i&&void 0!==i&&i.length||!c||null!==(r=c.errors)&&void 0!==r&&r.message)return void d();(0,Ge.u4)(Ye.I2.RecommendationDismissed,{merchant:n,savingsAmount:l}),s()}catch(o){d()}}},a.createElement(Gge,null,a.createElement(xt.v,{color:"content.secondary"},_t.V4.NOT_INTERESTED_MODAL_DESCRIPTION),a.createElement(Yge,null,a.createElement(vu.Q,{textAreaRef:u,formattedLabel:a.createElement(a.Fragment,null,a.createElement(xt.v,{as:"span",size:"small",weight:"medium"},_t.V4.NOT_INTERESTED_MODAL_FEEDBACK_LABEL),a.createElement(xt.v,{as:"span",color:"content.secondary",size:"small",weight:"book"}," ",_t.V4.NOT_INTERESTED_MODAL_FEEDBACK_OPTIONAL)),hideLabel:!1,hideResizeHandle:!0,label:"",minRows:5,name:"feedback",placeholder:_t.V4.NOT_INTERESTED_MODAL_FEEDBACK_PLACEHOLDER}))),a.createElement(Cq.R,null,a.createElement(wt.Xb,{size:"small",type:"button",onClick:()=>c()},_t.V4.NOT_INTERESTED_MODAL_CANCEL),a.createElement(CJ.I,{size:"small",disableWhenValuesUnchanged:!1,pending:h},_t.V4.NOT_INTERESTED_MODAL_SUBMIT))))},Gge=$d.s.div(Oge||(Oge=(0,wc.A)(["flex flex-col gap-lg px-xl pt-lg pb-xl"]))),Yge=$d.s.div(Pge||(Pge=(0,wc.A)(["w-full [&_textarea]:min-h-32.25 [&_textarea]:rounded-default"]))),Uge=$d.s.div(Bge||(Bge=(0,wc.A)(["flex flex-col items-center gap-sm px-xl py-lg"]))),Vge=$d.s.div(zge||(zge=(0,wc.A)(["\n  flex max-w-112.5 flex-col items-center gap-2xs text-center\n  [&_p]:m-0\n"]))),Wge=e=>{var t;let n=e.insight,l=e.size,r=e.className;const i=(e=>{if(!e)return[];const t=[{name:e.merchantNameDisplay,logoUrl:e.merchantLogoUrl},...e.relatedMerchants].filter((e=>e.name.trim()));return(0,Mu.A)((e=>e.name.trim().toLowerCase()),t).map((e=>{var t;return{logoUrl:null!==(t=e.logoUrl)&&void 0!==t?t:null}}))}
1)(n),s=(0,o.A)(i,1)[0];return a.createElement(Wl._,{"data-external-id":"insight-merchant-logo",url:null!==(t=null===s||void 0===s?void 0:s.logoUrl)&&void 0!==t?t:null,size:l,className:r})},jge=e=>{let t=e.status,n=e.trackingPayload,l=e.onViewDetails,r=e.onMarkComplete,o=e.onMarkIncomplete,i=e.onNotInterested,s=e.onUndoNotInterested,c=e.onReportBug;const d=E4.az.includes(t),u=t===Ee.yWn.COMPLETED,m=t===Ee.yWn.DENIED;return a.createElement(Ji.SP,{"data-external-id":"insight-options-menu"},l&&a.createElement(Ji.xm,{icon:"eye",onClick:l},_t.V4.INSIGHT_MENU_VIEW_DETAILS),d&&r&&a.createElement(Ji.xm,{icon:"check-circle",onClick:()=>{Hge(n,Ye.nS.MarkComplete),r()}},_t.V4.INSIGHT_MENU_MARK_COMPLETE),d&&r&&i&&a.createElement(Kge,null),d&&i&&a.createElement(Ji.xm,{icon:"minus-circle",onClick:()=>{Hge(n,Ye.nS.NotInterested),i()}},_t.V4.INSIGHT_MENU_NOT_INTERESTED),u&&o&&a.createElement(Ji.xm,{icon:"x-circle",onClick:()=>{Hge(n,Ye.nS.MarkIncomplete),o()}},_t.V4.INSIGHT_MENU_MARK_INCOMPLETE),m&&s&&a.createElement(Ji.xm,{icon:"undo",onClick:()=>{Hge(n,Ye.nS.UndoNotInterested),s()}},_t.V4.INSIGHT_MENU_UNDO_NOT_INTERESTED),a.createElement(Ji.xm,{type:"danger",icon:"alert-triangle",onClick:()=>{Hge(n,Ye.nS.ReportBug),c()}},_t.V4.INSIGHT_MENU_REPORT_A_BUG))},Hge=(e,t)=>(0,Ge.u4)(Ye.I2.RecommendationInteracted,(0,U.A)((0,U.A)({},e),{},{action:t})),Kge=()=>a.createElement("div",{"data-external-id":"insight-menu-inset-separator",role:"separator",className:"p-2xs before:block before:h-px before:w-full before:bg-divider-primary before:content-['']"});var qge,$ge;const Zge=e=>{let t=e.src,n=e.title;return a.createElement(Rc.L,{"data-external-id":"notion-feedback-modal",title:n},a.createElement(Jge,null,a.createElement(Xge,{allowFullScreen:!0,src:t,title:n})))},Jge=$d.s.div(qge||(qge=(0,wc.A)(["px-xl pt-lg pb-xl"]))),Xge=$d.s.iframe($ge||($ge=(0,wc.A)(["block h-150 w-full rounded-default border-none"]))),Qge=(0,a.createContext)(null),ehe=e=>{let t=e.children,n=e.open;return a.createElement(Qge.Provider,{"data-external-id":"open-not-interested-modal-provider",value:n},t)};var the;const nhe=e=>{let t=e.insight,n=e.section,r=e.isLast,s=void 0!==r&&r;const c=(0,l.Zp)(),d=(()=>{const e=(0,a.useContext)(Qge);if(!e)throw new Error("useOpenNotInterestedModal must be used within OpenNotInterestedModalProvider");return e})(),u=(0,Pd.h)(),m=(0,o.A)(u,2),p=m[0],g=m[1].open,h=(0,C.RU)(),v=b4(t),f=Math.max(0,t.currentAnnualCost-v),E=t.status===Ee.yWn.COMPLETED,y=(0,i.n)(D4.sL,{refetchQueries:[{query:D4.SV,variables:{statuses:E4.oH}}],onCompleted:e=>{var t,n;null!==e&&void 0!==e&&null!==(t=e.updateFinancialInsightStatus)&&void 0!==t&&null!==(n=t.errors)&&void 0!==n&&n.message&&h()},onError:()=>h()}),b=(0,o.A)(y,1)[0],x={recommendationId:t.id,merchant:t.merchantNameDisplay,savingsAmount:Math.round(v),recommendationType:t.suggestedActionType,section:n},w=()=>{(0,Ge.u4)(Ye.I2.RecommendationInteracted,(0,U.A)((0,U.A)({},x),{},{action:Ye.nS.ViewDetails})),c({pathname:I.JZ.advice.insightDetail({insightId:t.id}),search:"?source=".concat(Ye.xD.AdvicePage)})};return a.createElement(a.Fragment,null,a.createElement(lhe,{onClick:w,$hasDivider:!s},a.createElement("div",{className:"flex min-w-0 grow items-center gap-default"},a.createElement(ahe,null,a.createElement(Wge,{insight:t,size:40})),a.createElement("div",{className:"flex min-w-0 grow flex-col"}
1,a.createElement(xt.v,{weight:"medium",clampLines:1},t.description),a.createElement(xt.v,{color:"content.secondary",clampLines:2},t.reasoning))),a.createElement(ohe,{alignBaseline:!0,justifyEnd:!0,gap:"xxsmall",flexShrink:0},a.createElement(xt.v,{weight:"medium"},(0,rl.T3)(f)),a.createElement(rhe,{color:"content.secondary"},_t.V4.ANNUAL_COST((0,rl.T3)(t.currentAnnualCost)))),a.createElement(ihe,{alignCenter:!0,justifyEnd:!0,gap:"xsmall",flexShrink:0},E?a.createElement(che,null,a.createElement(sl.ZQ,{name:"check",size:12}),a.createElement(xt.v,{size:"xsmall",weight:"medium",color:"content.success"},_t.V4.SAVED((0,rl.T3)(v)))):a.createElement(she,null,a.createElement(xt.v,{size:"xsmall",weight:"medium",color:"content.info"},"Save ",(0,rl.T3)(v))),a.createElement(fA.A,{placement:"bottom-end",overlay:a.createElement(dhe,{onClick:e=>e.stopPropagation()},a.createElement(jge,{status:t.status,trackingPayload:x,onViewDetails:w,onMarkComplete:()=>b({variables:{input:{id:t.id,status:Ee.yWn.COMPLETED}}}),onNotInterested:()=>d({insightId:t.id,merchant:t.merchantNameDisplay,savingsAmount:Math.round(v)}),onMarkIncomplete:()=>b({variables:{input:{id:t.id,status:Ee.yWn.REOPENED}}}),onUndoNotInterested:()=>b({variables:{input:{id:t.id,status:Ee.yWn.REOPENED}}}),onReportBug:g}))},(e=>{let t=e.toggleOpen,n=e.isOpen;return a.createElement(B.L,{icon:"more-horizontal",onClick:e=>{e.stopPropagation(),t()},active:n})})))),a.createElement(p,{maxWidth:"".concat(720,"px")},a.createElement(Zge,{src:E4.h9,title:_t.V4.INSIGHT_MENU_REPORT_A_BUG})))},ahe=u.default.div.withConfig({displayName:"InsightRow__MerchantLogoWrapper",componentId:"sc-1ck2v25-0"})(["@media (max-width:","px){display:none;}"],vt.nm.sm),lhe=(0,u.default)(m.g).attrs({alignCenter:!0,gap:"xsmall"}).withConfig({displayName:"InsightRow__Root",componentId:"sc-1ck2v25-1"})(["padding:"," "," "," ",";border-bottom:1px solid ",";cursor:pointer;&:hover{background:",";}"],vt.YK.default,vt.YK.default,vt.YK.default,vt.YK.xlarge,(e=>{let t=e.$hasDivider,n=e.theme;return t?n.variables.color.divider.primary:"transparent"}),vt.Ee.color.background.primaryHover),rhe=(0,$d.s)(xt.v)(the||(the=(0,wc.A)(["line-through"]))),ohe=(0,u.default)(m.g).withConfig({displayName:"InsightRow__PriceColumn",componentId:"sc-1ck2v25-2"})(["@media (min-width:","px){width:","px;}"],vt.nm.sm,150),ihe=(0,u.default)(m.g).withConfig({displayName:"InsightRow__SavingsColumn",componentId:"sc-1ck2v25-3"})(["@media (min-width:","px){width:","px;}"],vt.nm.sm,300),she=(0,u.default)(m.g).attrs({alignCenter:!0,gap:"xxsmall"}).withConfig({displayName:"InsightRow__SavingsTag",componentId:"sc-1ck2v25-4"})(["background:",";padding:"," ",";border-radius:",";@media (max-width:","px){display:none;}"],vt.Ee.color.background.info,vt.YK.xxxsmall,vt.YK.xsmall,vt.r8.small,vt.nm.sm),che=(0,u.default)(she).withConfig({displayName:"InsightRow__CompletedSavingsTag",componentId:"sc-1ck2v25-5"})(["background:",";.","{color:",";}"],vt.Ee.color.background.success,sl.V6,vt.Ee.color.content.success),dhe=(0,u.default)(m.g).withConfig({displayName:"InsightRow__DropdownOverlayRoot",componentId:"sc-1ck2v25-6"})(["color:",";.","{color:currentColor;}"],vt.Ee.color.content.primary,sl.V6),uhe=e=>{let t=e.groups;const n=(0,Pd.h)(),l=(0,o.A)(n,2),r=l[0],i=l[1],s=i.open,c=i.context,d=(0,a.useState)(!1),u=(0,o.A)(d,2),m=u[0],p=u[1],g=(0,a.useCallback)((e=>{p(!1),s(e)}),[s]),h=(0,a.useCallback)((()=>{p(!0)}),[]),v=(0,a.useCallback)((()=>{p(!1)}),[]),f=t.filter((e=>"active"===e.status)),E=t.filter((e=>"active"!==e.status)),y=t.some((e=>"completed"===e.status)),b=0===f.length&&y;return a.createElement(ehe,{"data-external-id":"insights-list",open:g},a.createElement("div",{className:"flex flex-col gap-default"},f.map((e=>a.createElement(Xl.AM,{key:e.label,className:"overflow-hidden"},a.createElement(mhe,{group:e})))),b&&a.createElement(Xl.AM,{className:"overflow-hidden"},a.createElement(phe,null)),E.map((e=>a.createElement(Xl.AM,{key:e.label,className:"overflow-hidden"},a.createElement(mhe,{group:e})))),a.createElement(r,{onClose:v},c&&a.createElement(Fge,{insightId:c.insightId,merchant:c.merchant,savingsAmount:c.savingsAmount,showSuccess:m,onSubmitted:h}
1))))},mhe=e=>{let t=e.group;const n=t.section,l="active"===t.status,r="completed"===t.status,i=l||r?(0,rl.T3)(t.total):null,s=(0,Pc.e)(l),c=(0,o.A)(s,2),d=c[0],u=c[1].toggle;return a.createElement(a.Fragment,null,a.createElement(ghe,{$expanded:d,onClick:u},a.createElement($H.V,{expanded:d}),a.createElement("div",{className:"flex min-w-0 grow items-center gap-xs"},a.createElement(xt.v,{size:"large",weight:"medium"},t.label),t.subtitle&&a.createElement(xt.v,{weight:"medium",color:"content.secondary"},t.subtitle)),l&&i&&a.createElement(xt.v,{weight:"medium",color:"content.info"},_t.V4.SAVE_PER_YEAR(i)),r&&i&&a.createElement(xt.v,{weight:"medium",color:"content.success"},_t.V4.SAVED_PER_YEAR(i))),a.createElement(Ql.$,{open:d,shouldAnimateOnMount:!1},t.insights.map(((e,l)=>a.createElement(nhe,{key:e.id,insight:e,section:n,isLast:l===t.insights.length-1})))))},phe=()=>{const e=(0,Pc.e)(!0),t=(0,o.A)(e,2),n=t[0],l=t[1].toggle;return a.createElement(a.Fragment,null,a.createElement(ghe,{$expanded:n,onClick:l},a.createElement($H.V,{expanded:n}),a.createElement("div",{className:"flex min-w-0 grow items-center gap-xs"},a.createElement(xt.v,{size:"large",weight:"medium"},_t.V4.UPCOMING_CHARGES))),a.createElement(Ql.$,{open:n,shouldAnimateOnMount:!1},a.createElement(hhe,null,a.createElement(f4.R,{size:64}),a.createElement(vhe,null,a.createElement(xt.v,{weight:"medium"},_t.V4.ALL_COMPLETED_TITLE),a.createElement(xt.v,{size:"small",color:"content.secondary"},_t.V4.ALL_COMPLETED_SUBTITLE)))))},ghe=(0,u.default)(m.g).attrs({alignCenter:!0,gap:"xsmall"}).withConfig({displayName:"InsightsList__GroupHeader",componentId:"ngyeez-0"})(["min-height:","px;padding:"," "," "," ",";border-bottom:1px solid ",";cursor:pointer;&:hover{background:",";}"],48,vt.YK.small,vt.YK.xlarge,vt.YK.small,vt.YK.small,(e=>e.$expanded?vt.Ee.color.divider.primary:"transparent"),vt.Ee.color.background.primaryHover),hhe=u.default.div.withConfig({displayName:"InsightsList__EmptyStateContent",componentId:"ngyeez-1"})(["display:flex;flex-direction:column;align-items:center;gap:",";padding:"," ",";"],vt.YK.default,vt.YK.xxlarge,vt.YK.default),vhe=u.default.div.withConfig({displayName:"InsightsList__EmptyStateText",componentId:"ngyeez-2"})(["display:flex;flex-direction:column;align-items:center;gap:",";text-align:center;max-width:420px;"],vt.YK.xxsmall),fhe=()=>{var e,t,n,r;const o=(0,l.Zp)(),i=(0,lt.L7)(),s=i.householdPreferences,c=i.isLoadingInitialData,d=i.error,u=i.refetch,m=(0,C.RU)(),p=null!==(e=null===s||void 0===s?void 0:s.continuousFinancialMonitoringEnabled)&&void 0!==e&&e,g=R4({isOptedIn:p,statuses:E4.oH}),h=g.insights,v=g.summary,f=g.latestRunStatus,E=g.isGenerating,y=g.isGeneratingOverdue,b=g.isOptingIn,x=g.isLoading,w=g.error,A=g.refetch,k=g.startGeneration,S=(0,a.useRef)(!1);(0,a.useEffect)((()=>{var e,t,n;!S.current&&v&&(S.current=!0,(0,Ge.u4)(Ye.I2.RecommendationViewed,{recoupedAmount:Math.round(null!==(e=v.totalCapturedSavings)&&void 0!==e?e:0),potentialToSave:Math.round(null!==(t=v.totalIdentifiedSavingsLow)&&void 0!==t?t:0),completedOpportunities:null!==(n=v.completedCount)&&void 0!==n?n:0,totalOpportunities:h.length}))}),[v,h]);const N=(0,a.useMemo)((()=>{var e;return I4({insights:h,totalCapturedSavings:null!==(e=null===v||void 0===v?void 0:v.totalCapturedSavings)&&void 0!==e?e:0})}),[h,null===v||void 0===v?void 0:v.totalCapturedSavings]),T=(0,a.useMemo)((()=>h.filter((e=>E4.az.includes(e.status))).length),[h]),_=(0,a.useMemo)((()=>{var e;return y4({isOptedIn:p,isOptingIn:b,isGenerating:E,latestRunStatus:f,hasError:!!w,insights:h,completedInsightCount:null!==(e=null===v||void 0===v?void 0:v.completedCount)&&void 0!==e?e:0})}),[p,b,E,f,w,h,null===v||void 0===v?void 0:v.completedCount]),D=(0,a.useCallback)((async()=>{await Promise.all([u(),A()])}),[u,A]),R=Fq({error:null!==d&&void 0!==d?d:w,retryFn:D}),M=R.isRetrying,L=R.pageError,O=(0,ht.S)(),P=O.isAiFeaturesEnabled,z=O.isLoading,F=c||x||z||M,G=null===(t=null===s||void 0===s?void 0:s.eligibleForFinancialInsights)||void 0===t||t,Y=(0,a.useCallback)((async()=>{(0,Ge.u4)(Ye.I2.AgenticAnalysisStarted,{source:Ye.xD.AdvicePage});try{await k()}catch(e){m()}}),[k,m]),U=(0,a.useCallback)((()=>{o((0,Ue.AI)("preferences","ai-assistant"))}),[o]),V=E||!p||_===v4.RunFailed||_===v4.NoOpportunities,W=G&&!c&&V;if(L)return a.createElement(rG.Y,{"data-external-id":"advice-v2",name:"Advice",pageError:L,isLoading:F},null);if(!z&&!P)return a.createElement(rG.Y,{"data-external-id":"advice-v2",name:"Advice",isLoading:F,overlayEmptyComponent:a.createElement(jpe,{icon:"alert-triangle",title:_t.V4.AI_DISABLED.TITLE,subtitle:_t.V4.AI_DISABLED.DESCRIPTION,button:{text:_t.V4.AI_DISABLED.CTA,onClick:U}})},a.createElement(Rge,{onStartSaving:Y,isOptingIn:b,pageState:_,isGeneratingOverdue:y}));if(W)return a.createElement(rG.Y,{"data-external-id":"advice-v2",name:"Advice",isLoading:F&&
1!E},a.createElement(Rge,{onStartSaving:Y,isOptingIn:b,pageState:_,isGeneratingOverdue:y}));const j=x4(h);return a.createElement(rG.Y,{"data-external-id":"advice-v2",name:"Advice",isLoading:F,overlayEmptyComponent:G?void 0:a.createElement(jpe,{icon:"lightbulb",title:_t.V4.EMPTY_STATE.TITLE,subtitle:_t.V4.EMPTY_STATE.DESCRIPTION,button:{text:_t.V4.EMPTY_STATE.CTA,onClick:()=>o(I.JZ.recurring())}})},a.createElement(rV.T,{screenName:"Advice"}),a.createElement(Ehe,null,a.createElement(Xl.AM,null,a.createElement("div",{className:"flex items-center gap-xs px-lg py-default"},a.createElement(xt.v,{size:"large",weight:"medium"},_t.V4.TITLE),a.createElement(xt.v,{color:"content.secondary"},_t.V4.ALL_TIME)),a.createElement(yhe,null,a.createElement(bhe,null,a.createElement(xhe,null,a.createElement(fe.cIj,{size:"3xs",content:_t.V4.RECOUPED_TOOLTIP,label:a.createElement(fe.c8D,{size:"xs",color:"secondary"},_t.V4.RECOUPED_LABEL),iconSize:"xs"})),a.createElement(xt.v,{size:"xlarge",weight:"medium",color:"content.success"},(0,rl.T3)(null!==(n=null===v||void 0===v?void 0:v.totalCapturedSavings)&&void 0!==n?n:0))),a.createElement(bhe,null,a.createElement(xhe,null,a.createElement(fe.cIj,{size:"3xs",content:_t.V4.COMPLETED_OPPORTUNITIES_TOOLTIP,label:a.createElement(fe.c8D,{size:"xs",color:"secondary"},_t.V4.COMPLETED_OPPORTUNITIES),iconSize:"xs"})),a.createElement(xt.v,{size:"xlarge",weight:"medium"},null!==(r=null===v||void 0===v?void 0:v.completedCount)&&void 0!==r?r:0)),a.createElement(bhe,null,a.createElement(xhe,null,a.createElement(fe.cIj,{size:"3xs",content:_t.V4.REMAINING_POTENTIAL_TOOLTIP,label:a.createElement(fe.c8D,{size:"xs",color:"secondary"},_t.V4.REMAINING_POTENTIAL),iconSize:"xs"})),a.createElement(xt.v,{size:"xlarge",weight:"medium",color:"content.info"},(0,rl.T3)(j))),a.createElement(bhe,null,a.createElement(xhe,null,a.createElement(fe.cIj,{size:"3xs",content:_t.V4.REMAINING_OPPORTUNITIES_TOOLTIP,label:a.createElement(fe.c8D,{size:"xs",color:"secondary"},_t.V4.REMAINING_OPPORTUNITIES),iconSize:"xs"})),a.createElement(xt.v,{size:"xlarge",weight:"medium"},T)))),G?a.createElement(uhe,{groups:N}):a.createElement("div",{className:"flex flex-col gap-default"},A4.slice(0,2).map((e=>a.createElement(Xl.AM,{key:e.subtitle},a.createElement(whe,null,a.createElement("div",{className:"flex items-center px-lg py-default"},a.createElement(B.L,{icon:"chevron-down"}),a.createElement("div",{className:"flex grow items-center gap-xs"},a.createElement(xt.v,{size:"large",weight:"medium"},e.title),a.createElement(xt.v,{color:"content.secondary"},e.subtitle)))))))),a.createElement(xt.v,{size:"small",color:"content.secondary"},_t.V4.DISCLAIMER_POST_OPT_IN)))},Ehe=(0,u.default)(m.g).attrs({column:!0,gap:"default"}).withConfig({displayName:"AdviceV2__Root",componentId:"oxn0d-0"})(["width:100%;padding:0 "," ",";"],vt.YK.gutter,vt.YK.gutter),yhe=(0,u.default)(m.g).withConfig({displayName:"AdviceV2__StatsRow",componentId:"oxn0d-1"})(["border-top:1px solid ",";flex-wrap:wrap;"],vt.Ee.color.divider.primary),bhe=(0,u.default)(m.g).attrs({column:!0}).withConfig({displayName:"AdviceV2__StatCell",componentId:"oxn0d-2"})(["flex:1 1 0;min-width:","px;padding:",";border-right:1px solid ",";&:last-child{border-right:none;}"],140,vt.YK.default,vt.Ee.color.divider.primary),xhe=(0,u.default)(m.g).attrs({alignCenter:!0,gap:"xxsmall"}).withConfig({displayName:"AdviceV2__StatLabel",componentId:"oxn0d-3"})(["color:",";"],vt.Ee.color.content.secondary),whe=u.default.div.withConfig({displayName:"AdviceV2__PlaceholderCardContent",componentId:"oxn0d-4"})(["min-height:","px;"],300);var Che,Ahe,Ihe=n(70341);const khe=()=>{var e;const t=(0,lV.L)().category,n=(0,l.Zp)(),r=t===w1.Ly,i=(0,d.d4)(Od.qo),s=(0,d.d4)(Od.F6)||"",c=(0,nG.p)("show-advisor-directory-in-product","off",{trackImpression:!0}),u=u4(),m=(0,d.d4)(A.UN),p=(0,b.pE)("scroll"),g=(0,a.useRef)(null),h=(0,et.I)(Dhe,{variables:{categoryName:r?void 0:t},skip:u}),v=h.data,f=h.isLoadingInitialData,E=m||!f&&!(null!==v&&void 0!==v&&null!==(e=v.profileQuestionnaire)&&void 0!==e&&e.state.completed),y=(0,pZ.P)(Dhe,{skip:!E||u}),x=(0,o.A)(y,1)[0],w=E?x:v,C=null!==w&&void 0!==w?w:{},k=C.essentials,S=C.objectives,N=C.adviceItemCategories,T=void 0===N?[]:N,_=C.profileQuestionnaire,D=C.objectivesQuestionnaire,R=null!==_&&void 0!==_?_:{},M=R.state,L=R.firstQuestion,O=(null!==M&&void 0!==M?M:{}).numQuestionsAnswered,P=(null!==D&&void 0!==D?D:{}).firstQuestion,B=(0,a.useMemo)((()=>t?T.find((0,rK.A)("name",t)):void 0),[t,T]),z=(0,a.useMemo)((()=>[{type:w1.Sd.Objective,title:"Prioritized by you",tooltip:g4.hc.TOOLTIPS.PRIORITIES,items:null!==S&&void 0!==S?S:[]},{type:w1.Sd.Essential,title:"Essential advice",tooltip:g4.hc.TOOLTIPS.ESSENTIALS,items:null!==k&&void 0!==k?k:[]}]),[k,S]);if((0,a.useEffect)((()=>{var e;p&&!f&&(null===(e=g.current)||void 0===e||e.scrollTo(p))}),[p,f]),(0,a.useEffect)((()=>{u||t&&ij.Ay.viewedAdviceCategoryPage({name:t})}),[t,u]),u)return a.createElement(fhe,{"data-external-id":"advice"});if(c){const e={user_id:s,email:i};return a.createElement(rG.Y,{"data-external-id":"advice",name:"Advice"},a.createElement(Vpe.Widget,{id:"WK2S4nTF",hidden:e,style:{height:"100%"}}))}return t?a.createElement(rG.Y,{"data-external-id":"advice",name:"Advice",isLoading:f,controls:a.createElement(uU.f,null,L&&!E&&a.createElement(cu.WT,{linkTo:(0,Ihe.V)(w1.vx.General,L.name)},"Update profile")),overlayEmptyComponent:E?a.createElement(jpe,{icon:"thumbs-up",title:g4.hc.EMPTY.TITLE,subtitle:g4.hc.EMPTY.SUBTITLE,button:{text:(null!==O&&void 0!==O?O:0)>0?"Resume":"Get started",onClick:()=>n(I.JZ.advice.questionnaireIntro({questionnaireName:w1.vx.General}))}}):void 0,scrollRef:g},a.createElement(rV.T,{screenName:"Advice"}),a.createElement(The,{type:"info"},a.createElement(sl.ZQ,{name:"info",size:16}),g4.hc.NOTICE_BANNER),a.createElement(She,null,B?a.createElement(fe.cIj,{size:"3xs",side:"bottom",content:B.description,label:B.displayName}):"Recommendations"),a.createElement(Nhe,{template:'"advice categories" / 1fr 30%',md:'"advice" "categories"'},a.createElement(QU.E,{area:"advice"},z.map((e=>{let t=e.type,l=e.title,r=e.tooltip,o=e.items;return a.createElement(_he,{key:t,name:t},a.createElement(Xl.AM,{title:r?a.createElement(fe.cIj,{size:"3xs",content:r,label:a.createElement(fe.c8D,{size:"lg",weight:"medium"},l)}):a.createElement(fe.c8D,{size:"lg",weight:"medium"},l),controls:t===w1.Sd.Objective&&P&&a.createElement(bn.v,{onClick:()=>n((0,Ihe.V)(w1.vx.Objectives,P.name))},"Edit")},a.createElement(xge,{items:o})))}))),a.createElement(QU.E,{area:"categories",sticky:!0},a.createElement(Xl.AM,{title:"Categories"},a.createElement(Qpe,{categories:T})))),a.createElement(l.BV,null,a.createElement(l.qh,{path:":category?/item/:itemId",element:a.createElement(uge,null)}),a.createElement(l.qh,{path:":category?/item/:itemId/task/:taskId",element:a.createElement(Age,null)}))):a.createElement(l.C5,{"data-external-id":"advice",to:I.JZ.advice({category:w1.Ly}),replace:!0})},She=u.default.div.withConfig({displayName:"Advice__Title",componentId:"sc-1w5y5sn-0"})(["font-size:",";font-weight:",";margin-top:",";margin-left:",";"],(e=>e.theme.fontSize.xlarge),(e=>e.theme.fontWeight.medium),vt.YK.default,(e=>e.theme.spacing.xxlarge)),Nhe=(0,$d.s)(QU.a)(Che||(Che=(0,wc.A)(["pt-default"]))),The=(0,$d.s)(fu.g)(Ahe||(Ahe=(0,wc.A)(["mx-default mt-default flex items-center gap-xs"]))),_he=(0,u.default)(KH.Hg).withConfig({displayName:"Advice__SectionElement",componentId:"sc-1w5y5sn-1"})([":not(:last-child){margin-bottom:var(--spacing);}"]),Dhe=Ee.vM$,Rhe=e=>{let t=e.steps,n=e.currentStatus,l=e.onTransition;const r=(0,a.useState)(new Set),i=(0,o.A)(r,2),s=i[0],c=i[1],d=(0,a.useRef)(!1);!d.current&&n===Ee.yWn.COMPLETED&&t.length>
10&&(d.current=!0,c(new Set(t.map(((e,t)=>t)))));const u=(0,a.useCallback)((e=>{const a=((e,t,n)=>e.size===t&&t>0?Ee.yWn.COMPLETED:n===Ee.yWn.COMPLETED?Ee.yWn.REOPENED:0===e.size?Ee.yWn.NEW:Ee.yWn.IN_PROGRESS)(e,t.length,n);a!==n&&l(a)}),[t.length,n,l]),m=(0,a.useCallback)((e=>{const t=new Set(s);t.has(e)?t.delete(e):t.add(e),c(t),u(t)}),[s,u]),p=(0,a.useCallback)((()=>{if(0===t.length)return void(n!==Ee.yWn.COMPLETED&&l(Ee.yWn.COMPLETED));const e=new Set(t.map(((e,t)=>t)));c(e),u(e)}),[t,u,n,l]),g=(0,a.useCallback)((()=>{if(0===t.length)return void(n===Ee.yWn.COMPLETED&&l(Ee.yWn.REOPENED));const e=new Set;c(e),u(e)}),[t.length,u,n,l]),h=s.size,v=t.length,f=v>0?h===v:n===Ee.yWn.COMPLETED,E=(0,a.useCallback)((()=>{f?g():p()}),[f,p,g]);return{completedStepIndices:s,completedCount:h,totalSteps:v,allComplete:f,progressPercent:v>0?Math.round(h/v*100):0,handleToggle:m,handleToggleAllComplete:E,markAllComplete:p,markAllIncomplete:g}};var Mhe,Lhe,Ohe,Phe,Bhe,zhe,Fhe;const Ghe=()=>{var e,t,n,r,s,c,d,u,m;const p=(0,lV.L)().insightId,g=(0,l.ok)(),h=(0,o.A)(g,1)[0].get("source"),v=(0,C.RU)(),f=(0,Pd.h)(),E=(0,o.A)(f,2),y=E[0],b=E[1].open,x=(0,Pd.h)(),w=(0,o.A)(x,2),A=w[0],I=w[1].open,k=(0,a.useState)(!1),S=(0,o.A)(k,2),N=S[0],T=S[1],_=(0,a.useState)(0),D=(0,o.A)(_,2),R=D[0],M=D[1],L=(0,a.useCallback)((()=>M((e=>e+1))),[]),O=(0,Xo.IT)(D4.bw,{variables:{id:p}}),P=O.data,B=O.loading,z=(0,i.n)(D4.sL,{refetchQueries:[{query:D4.SV,variables:{statuses:E4.oH}}],onCompleted:e=>{var t,n;null!==e&&void 0!==e&&null!==(t=e.updateFinancialInsightStatus)&&void 0!==t&&null!==(n=t.errors)&&void 0!==n&&n.message&&v()},onError:()=>v()}),F=(0,o.A)(z,1)[0],G=null===P||void 0===P?void 0:P.financialInsight,Y=(e=>(null===e||void 0===e?void 0:e.length)?[...e].sort(((e,t)=>e.order-t.order)).flatMap((e=>{var t,n;return null!==(n=null===(t=e.merchantPlaybook)||void 0===t?void 0:t.diySteps)&&void 0!==n?n:[]})).map(((e,t)=>(0,U.A)((0,U.A)({},e),{},{step_number:t+1}))):[])(null===G||void 0===G?void 0:G.actions),V=G?Math.round(b4(G)):0,W=G?Math.max(0,G.currentAnnualCost-V):0,j=null!==(e=null===G||void 0===G?void 0:G.merchantNameDisplay)&&void 0!==e?e:"",H=null===G||void 0===G?void 0:G.status,K=H===Ee.yWn.COMPLETED,q=(0,a.useCallback)((e=>F({variables:{input:{id:p,status:e}}})),[p,F]),$=Rhe({steps:Y,currentStatus:null!==(t=null===G||void 0===G?void 0:G.status)&&void 0!==t?t:Ee.yWn.NEW,onTransition:q}),Z=$.completedStepIndices,J=$.completedCount,X=$.totalSteps,Q=$.allComplete,ee=$.progressPercent,te=$.handleToggle,ne=$.markAllComplete,ae=$.markAllIncomplete;(0,a.useEffect)((()=>{G&&(0,Ge.u4)(Ye.I2.ViewedInsightDetailPage,{merchant:j,savingsAmount:V,totalSteps:Y.length,stepsCompleted:J,source:null!==h&&void 0!==h?h:null})}),[null===G||void 0===G?void 0:G.id]);const le=(0,a.useMemo)((()=>({merchant:j,savingsAmount:V,totalSteps:X})),[j,V,X]),re=(0,a.useCallback)((e=>{var t,n;const a=!Z.has(e),l=a&&Z.size+1===X,r=!a&&Q;te(e),(0,Ge.u4)(a?Ye.I2.DIYStepMarkedComplete:Ye.I2.DIYStepMarkedIncomplete,(0,U.A)((0,U.A)({},le),{},{stepIndex:e,stepName:null!==(t=null===(n=Y[e])||void 0===n?void 0:n.instruction)&&void 0!==t?t:""})),l?((0,Ge.u4)(Ye.I2.DIYTaskCompleted,le),L()):r&&(0,Ge.u4)(Ye.I2.DIYTaskReopened,le)}),[Z,te,Q,le,X,Y,L]),oe=(0,a.useCallback)((()=>{(0,Ge.u4)(Ye.I2.DIYTaskCompleted,le),L(),ne()}),[ne,le,L]),ie=(0,a.useCallback)((()=>{(0,Ge.u4)(Ye.I2.DIYTaskReopened,le),ae()}),[ae,le]),se=(0,a.useCallback)((()=>{Q?((0,Ge.u4)(Ye.I2.RecommendationInteracted,(0,U.A)((0,U.A)({},le),{},{recommendationId:p,recommendationType:null===G||void 0===G?void 0:G.suggestedActionType,action:Ye.nS.MarkIncomplete})),ie()):((0,Ge.u4)(Ye.I2.RecommendationInteracted,(0,U.A)((0,U.A)({},le),{},{recommendationId:p,recommendationType:null===G||void 0===G?void 0:G.suggestedActionType,action:Ye.nS.MarkComplete})),oe())}),[Q,oe,ie,le,p,null===G||void 0===G?void 0:G.suggestedActionType]);return a.createElement(rG.Y,{"data-external-id":"insight-detail-page",name:"Advice",isLoading:B,pageError:!B&&!G,parentRoute:"Advice",overrideTitle:null!==(n=null===G||void 0===G?void 0:G.description)&&void 0!==n?n:"",icon:a.createElement(Wge,{insight:G,size:24}),controls:a.createElement("div",{className:"flex items-center gap-sm"},a.createElement(fA.A,{placement:"bottom-end",overlay:a.createElement(jge,{status:null!==H&&void 0!==H?H:Ee.yWn.NEW,trackingPayload:{recommendationId:p,merchant:j,savingsAmount:V,recommendationType:null===G||void 0===G?void 0:G.suggestedActionType},onNotInterested:()=>{T(!1),I()},onUndoNotInterested:()=>
1{F({variables:{input:{id:p,status:Ee.yWn.REOPENED}}})},onReportBug:b})},(e=>{let t=e.toggleOpen;return a.createElement(wt.Xb,{size:"small",onClick:t},a.createElement("span",null,_t.V4.DETAIL_PAGE.OPTIONS),a.createElement(Yo.r,{name:"chevron-down"}))})),a.createElement("div",{className:"h-4 w-px shrink-0 bg-divider-secondary"}),a.createElement(wt.Xb,{size:"small",onClick:se},a.createElement(Yo.r,{name:Q?"x-circle":"check-circle"}),a.createElement("span",null,Q?_t.V4.DETAIL_PAGE.MARK_ALL_INCOMPLETE:_t.V4.DETAIL_PAGE.MARK_ALL_COMPLETE)))},a.createElement("div",{className:"flex w-full flex-col gap-default px-gutter pb-gutter"},a.createElement(jhe,null,a.createElement("div",{className:"flex max-w-192.25 min-w-0 items-center gap-lg lg:flex-1"},a.createElement(Wge,{insight:G,size:58}),a.createElement("div",{className:"flex min-w-0 flex-1 flex-col gap-2xs"},a.createElement(xt.v,{size:"20"},_t.V4.DETAIL_PAGE.HEADLINE_PREFIX(null!==(r=null===G||void 0===G?void 0:G.description)&&void 0!==r?r:""),a.createElement(xt.v,{size:"20",weight:"medium",as:"span"},_t.V4.DETAIL_PAGE.HEADLINE_SAVINGS((0,rl.T3)(V)))),a.createElement(xt.v,{color:"content.secondary"},null!==(s=null===G||void 0===G?void 0:G.reasoning)&&void 0!==s?s:""))),a.createElement("div",{className:"flex shrink-0 items-baseline gap-2xs"},a.createElement(xt.v,{weight:"medium"},(0,rl.T3)(W)),a.createElement(Jhe,{color:"content.secondary"},(0,rl.T3)(null!==(c=null===G||void 0===G?void 0:G.currentAnnualCost)&&void 0!==c?c:0),"/yr"))),a.createElement("div",{className:"flex flex-col items-start gap-default lg:flex-row"},a.createElement(Hhe,null,a.createElement("div",{className:"flex items-center gap-sm border-b border-divider-primary py-sm pr-default pl-xl"},a.createElement(xt.v,{size:"large",weight:"medium",className:"flex-1"},_t.V4.DETAIL_PAGE.INSTRUCTIONS),a.createElement(Xi.G,{className:"shrink-0",onClick:se},Q?a.createElement($he,{iconSizePx:12}):a.createElement("div",{className:"size-5 rounded-round bg-progress-background"}))),a.createElement("div",{className:"flex flex-col gap-xs border-b border-divider-primary px-lg pt-lg pb-xl"},a.createElement("div",{className:"flex items-center justify-between"},a.createElement(xt.v,{size:"small"},_t.V4.DETAIL_PAGE.PROGRESS(K&&0===X?100:ee)),X>0&&a.createElement(xt.v,{size:"small",color:"content.secondary"},_t.V4.DETAIL_PAGE.STEPS_COUNT(X))),a.createElement(fe.cqk,{value:K&&0===X?1:J,max:X||1,color:"progress-success"})),X>0&&Y.map(((e,t)=>a.createElement(Yhe,{key:e.step_number,step:e,index:t,isChecked:Z.has(t),onToggle:re}))),0===X&&a.createElement(Uhe,{variant:K?"success":"danger",icon:K?"check":"alert-triangle",title:K?_t.V4.DETAIL_PAGE.COMPLETED_TITLE:_t.V4.DETAIL_PAGE.NO_INSTRUCTIONS_TITLE,description:K?_t.V4.DETAIL_PAGE.COMPLETED_DESCRIPTION:_t.V4.DETAIL_PAGE.NO_INSTRUCTIONS_DESCRIPTION})),a.createElement("div",{className:"flex w-full shrink-0 flex-col gap-default lg:grow-0 lg:basis-[30%]"},a.createElement(Whe,{paymentAccountLabel:null!==(d=null===G||void 0===G||null===(u=G.paymentAccount)||void 0===u?void 0:u.label)&&void 0!==d?d:null,nextChargeDate:null!==(m=null===G||void 0===G?void 0:G.nextChargeDate)&&void 0!==m?m:null,merchantName:j})))),a.createElement(A,{onClose:()=>T(!1)},a.createElement(Fge,{insightId:null!==p&&void 0!==p?p:"",merchant:j,savingsAmount:V,showSuccess:N,onSubmitted:()=>T(!0)})),a.createElement(y,{maxWidth:"".concat(720,"px")},a.createElement(Zge,{src:E4.h9,title:_t.V4.INSIGHT_MENU_REPORT_A_BUG})),R>0&&a.createElement(q3.N,{key:R,portal:!0}))},Yhe=e=>{let t=e.step,n=e.index,l=e.isChecked,r=e.onToggle;return a.createElement(Khe,{"data-external-id":"diy-step-row-component",role:"checkbox","aria-checked":l,onClick:()=>r(n)},a.createElement("div",{className:"flex min-w-0 flex-1 flex-col gap-2xs"},a.createElement(xt.v,{weight:l?void 0:"medium",color:l?"content.secondary":void 0},a.createElement("span",{className:(0,q.cn)(l&&"line-through")},t.step_number,". ",t.title||t.instruction)),!l&&!!t.title&&a.createElement(xt.v,{color:"content.secondary"},a.createElement("span",null,t.instruction)),!l&&t.url&&a.createElement(qhe,{href:t.url,target:"_blank",rel:"noopener noreferrer",onClick:e=>e.stopPropagation()},a.createElement(xt.v,{size:"small",weight:"medium",color:"content.link"},t.url),a.createElement(sl.ZQ,{name:"external-link",size:12}))),l?a.createElement($he,{iconSizePx:12}):a.createElement("div",{className:"size-5 shrink-0 rounded-round bg-progress-background"}))},Uhe=e=>{let t=e.variant,n=e.icon,l=e.title,r=e.description;return a.createElement("div",{"data-external-id":"empty-state",className:"flex flex-col items-center gap-default px-default pt-2xl pb-3xl"},a.createElement("div",{className:(0,q.cn)("flex size-16 items-center justify-center rounded-[32px]","success"===t?"bg-background-success":"bg-background-danger")},a.createElement(sl.ZQ,{name:n,size:32,className:"success"===t?"text-content-success":"text-content-danger"})),a.createElement("div",{className:"flex max-w-104.5 flex-col items-center gap-2xs text-center"},a.createElement(xt.v,{size:"large",weight:"medium"},l),a.createElement(xt.v,{color:"content.secondary"},r)))},Vhe=e=>{let t=e.label,n=e.children;return a.createElement("div",{"data-external-id":"details-row",className:"flex items-center gap-sm"},a.createElement(xt.v,{color:"content.secondary",className:"flex-1"},t),a.createElement("div",{className:"flex items-center gap-xs text-right"},n))},Whe=e=>{let t=e.paymentAccountLabel,n=e.nextChargeDate,r=e.merchantName;const o=n?N.c9.fromISO(n):null,i=N.c9.local().startOf("day"),s=!(null===o||void 0===o||!o.isValid)&&o<i,c=null!==o&&void 0!==o&&o.isValid&&!s?Math.ceil(o.diff(i,"days").days):null,d=!!t||!(null===o||void 0===o||!o.isValid);return a.createElement(Zhe,{"data-external-id":"details-card"},d&&a.createElement(a.Fragment,null,a.createElement("div",{className:"flex h-14 items-center border-b border-divider-primary px-xl py-sm"},a.createElement(xt.v,{size:"large",weight:"medium",className:"flex-1"},_t.V4.DETAIL_PAGE.DETAILS.TITLE)),a.createElement("div",{className:"flex flex-col gap-default p-xl"},t&&a.createElement(Vhe,{label:_t.V4.DETAIL_PAGE.DETAILS.PAYMENT_ACCOUNT},a.createElement(xt.v,null,t)),(null===o||void 0===o?void 0:o.isValid)&&a.createElement(Vhe,{label:s?_t.V4.DETAIL_PAGE.DETAILS.EXPECTED_NEXT_CHARGE_DATE:_t.V4.DETAIL_PAGE.DETAILS.NEXT_CHARGE_DATE}
1,a.createElement(xt.v,null,o.toLocaleString({month:"short",day:"numeric"})),null!==c&&a.createElement(xt.v,{color:"content.secondary"},_t.V4.DETAIL_PAGE.DETAILS.DAYS_UNTIL(c))))),a.createElement(l.k2,{to:I.JZ.transactions({queryParams:{search:r}}),className:(0,q.cn)("flex items-center justify-center gap-xs py-default text-content-link",d&&"border-t border-divider-primary")},a.createElement(sl.ZQ,{name:"credit-card",size:12}),a.createElement(xt.v,{size:"small",weight:"medium",color:"content.link"},_t.V4.DETAIL_PAGE.DETAILS.VIEW_RELATED_TRANSACTIONS)))},jhe=(0,$d.s)(fe.xz6)(Mhe||(Mhe=(0,wc.A)(["flex-col gap-xl px-xl py-lg lg:flex-row lg:items-center lg:justify-between"]))),Hhe=(0,$d.s)(fe.xz6)(Lhe||(Lhe=(0,wc.A)(["min-w-0 flex-1 overflow-hidden"]))),Khe=$d.s.div(Ohe||(Ohe=(0,wc.A)(["\n  flex cursor-pointer items-center gap-xl border-b border-divider-primary py-gutter pr-xl\n  pl-gutter\n  last:border-b-0\n"]))),qhe=$d.s.a(Phe||(Phe=(0,wc.A)(["\n  inline-flex items-center gap-2xs self-start text-content-link no-underline\n  hover:underline\n"]))),$he=(0,$d.s)(d7.r)(Bhe||(Bhe=(0,wc.A)(["size-5 shrink-0 bg-progress-success text-content-white"]))),Zhe=(0,$d.s)(fe.xz6)(zhe||(zhe=(0,wc.A)(["w-full"]))),Jhe=(0,$d.s)(xt.v)(Fhe||(Fhe=(0,wc.A)(["line-through"])));var Xhe=n(94387),Qhe=n(44738);const eve=e=>{let t=e.invoices;const n=(0,Qhe.x)("receipts");return a.createElement(Xl.AM,{"data-external-id":"invoices-card",title:"Receipts",rootProps:n},t.map((e=>a.createElement(tve,{key:e.id,invoice:e}))))},tve=e=>{let t=e.invoice;return a.createElement(nve,{"data-external-id":"invoice-row",onClick:()=>{var e;(e=t.receiptUrl)&&window.open(e,"_blank")},key:t.id},a.createElement(ave,null,N.c9.fromISO(t.date).toLocaleString(N.c9.DATE_FULL)),a.createElement(lve,null,a.createElement(hl.t,{value:t.amount})))},nve=u.default.div.withConfig({displayName:"InvoicesCard__Row",componentId:"sc-1lqyb20-0"})(["padding:",";:not(:last-child){border-bottom:1px solid ",";}display:flex;flex-direction:row;cursor:pointer;"],(e=>e.theme.spacing.xlarge),(e=>e.theme.color.grayBackground)),ave=u.default.div.withConfig({displayName:"InvoicesCard__Column",componentId:"sc-1lqyb20-1"})(["display:flex;flex-direction:column;flex:1;"]),lve=(0,u.default)(ave).withConfig({displayName:"InvoicesCard__Amount",componentId:"sc-1lqyb20-2"})(["text-align:right;"]);var rve=n(56728);const ove=e=>{let t=e.onDone,n=e.onSuccess,l=e.title;const i=(0,nC.xd)({fetchPolicy:"cache-first"}),s=(0,o.A)(i,1)[0],c=s.isCurrentUserOwner,d=s.isLoadingInitialData;return a.createElement(Xl.AM,{"data-external-id":"update-payment-method-modal",title:null!==l&&void 0!==l?l:"Update Payment Method"},a.createElement(sve,null,(0,r.YW)({isCurrentUserOwner:c,isLoadingInitialData:d}).with({isLoadingInitialData:!0},(()=>a.createElement("div",{className:"my-lg flex size-full flex-1 items-center justify-center"},a.createElement(p.i,null)))).with({isCurrentUserOwner:!0},(()=>a.createElement(a.Fragment,null,a.createElement(jie.q,{skipPaymentMethod:!1,onSuccess:async e=>{if(e){await n(e)&&t()}}},(e=>{let t=e.isValid,n=e.isLoading;return a.createElement(cve,{justifyBetween:!0,alignCenter:!0},a.createElement("div",{className:"flex items-center"},a.createElement(dve,null),"Powered by Stripe"),a.createElement(uve,{size:"medium",disabled:!t,type:"submit",pending:n},"Update"))}))))).otherwise((()=>a.createElement(a.Fragment,null,a.createElement(rve.X,null,(e=>{let t=e.name;return a.createElement("span",null,"Only household admins have the ability to update your household's payment method. Please reach out to ",t," and ask them to update the payment method.")})),a.createElement(cve,{justifyEnd:!0},a.createElement(cu.WT,{onClick:t},"Okay")))))))},ive=e=>a.createElement(Hie.l,{"data-external-id":"provider-wrapper"},a.createElement(ove,e)),sve=u.default.div.withConfig({displayName:"UpdatePaymentMethodModal__CardBody",componentId:"sc-1lldmnl-0"})(["padding:",";"],(e=>e.theme.spacing.xlarge)),cve=(0,u.default)(m.g).withConfig({displayName:"UpdatePaymentMethodModal__Footer",componentId:"sc-1lldmnl-1"})(["margin-top:",";color:",";font-size:",";"],(e=>e.theme.spacing.xlarge),(e=>e.theme.color.textLight),(e=>e.theme.fontSize.xsmall)),dve=(0,u.default)(sl.ZQ).attrs({name:"lock"}).withConfig({displayName:"UpdatePaymentMethodModal__LockIcon",componentId:"sc-1lldmnl-2"})(["width:",";height:",";margin-right:",";"],(e=>e.theme.spacing.small),(e=>e.theme.spacing.small),(e=>e.theme.spacing.xsmall)),uve=(0,u.default)(su.U).withConfig({displayName:"UpdatePaymentMethodModal__SubmitButton",componentId:"sc-1lldmnl-3"})(["",""],cu.vc);var mve;!function(e){e.Active="active",e.Canceled="canceled"}(mve||(mve={}));const pve=(e,t)=>
1{if("demo"===e)return"purpleBackground";if(e===Ee.H4H.PENDING)return"grayBackground";switch(t){case mve.Active:return"greenBackground";case mve.Canceled:return"redBackground"}},gve=(e,t)=>{if("demo"===e)return"purple";if(e===Ee.H4H.PENDING)return"textLight";switch(t){case mve.Active:return"green";case mve.Canceled:return"red"}},hve=(e,t,n)=>_t.R9.INVITE_CLIENT_EMAIL_BODY(e,t,n),vve=()=>{var e,t,n,l;const r=(0,C.RU)(),s=(0,et.I)(yve),c=s.data,d=s.isLoadingInitialData,u=s.refetch,m=(0,i.n)(bve),g=(0,o.A)(m,1)[0],h=(0,Pd.h)(),v=(0,o.A)(h,2),f=v[0],E=v[1],y=E.open,b=E.close,x=(0,a.useCallback)((async e=>{let t=e.id;const n=(await g({variables:{input:{paymentMethodId:t}}})).data,a=(0,DJ.A)(["updateOrCreateStripePaymentMethod","errors"],n);return a?(r({title:"Couldn't update payment method",description:a.message}),!1):(u(),!0)}),[g,u,r]),w=null===c||void 0===c||null===(e=c.subscription)||void 0===e?void 0:e.paymentMethod,A=(null!==c&&void 0!==c?c:{}).upcomingSponsorInvoice,I=null!==(t=null===c||void 0===c?void 0:c.sponsorInvoices)&&void 0!==t?t:[],k=null!==(n=null===c||void 0===c||null===(l=c.subscriptionSponsorships)||void 0===l?void 0:l.filter((e=>e.status===mve.Active)))&&void 0!==n?n:[],S=d,T=!d&&!w,_=!d&&w,D=null!==A&&void 0!==A&&A.date?N.c9.fromISO(null===A||void 0===A?void 0:A.date):void 0,R=D?D.diffNow("days").days.toFixed(0):void 0;return a.createElement(rG.Y,{"data-external-id":"advisor-billing",name:"Billing",parentRoute:null},a.createElement(fve,null,a.createElement(Xhe.Ay,null,a.createElement("title",null,"Advisor Portal | Billing")),S&&a.createElement("div",{className:"my-lg flex size-full flex-1 items-center justify-center"},a.createElement(p.i,null)),T&&a.createElement(Xl.AM,null,a.createElement(cU.vx,{emptyTheme:cU.dO.NEW,title:"Setup payment method",subtitle:"Add a payment method to start inviting clients.",button:{title:"Add Payment Method",onClick:()=>y(),isPrimary:!0}})),_&&a.createElement(a.Fragment,null,a.createElement(Xl.AM,{title:"Payment"},a.createElement(Eve,null,a.createElement(xt.v,{color:"textLight",weight:"medium",size:"small"},"Active clients"),a.createElement(xt.v,{color:"text",size:"small"},k.length)),a.createElement(Eve,null,a.createElement(xt.v,{color:"textLight",weight:"medium",size:"small"},"Payment method"),a.createElement("div",{className:"flex items-start justify-between"},a.createElement(xt.v,{color:"text",size:"small"},(0,Xie._M)(w,((e,t)=>"".concat((0,Wie.capitalCase)(e)," ending in ").concat(t)))),a.createElement(bn.v,{onClick:y},"Update payment method"))),(0,Tr.A)(null===A||void 0===A?void 0:A.date)&&a.createElement(Eve,null,a.createElement(xt.v,{color:"textLight",weight:"medium",size:"small"},"Next payment"),a.createElement(xt.v,{color:"text",size:"small"},"".concat((0,rl.vv)(null===A||void 0===A?void 0:A.amount)," on ").concat(null===D||void 0===D?void 0:D.toLocaleString(N.c9.DATE_MED)," (").concat(R," days)")))),(0,Gj.A)(I)?a.createElement(eve,{invoices:I}):a.createElement(Xl.AM,{title:"Receipts"},a.createElement(Eve,null,a.createElement(xt.v,{color:"textLight"},"No receipts yet")))),a.createElement(f,null,a.createElement(ive,{title:w?"Update payment method":"Setup payment method",onSuccess:x,onDone:b}))))},fve=u.default.div.withConfig({displayName:"AdvisorBilling__Container",componentId:"bwftlv-0"})(["display:flex;flex-direction:column;align-items:center;padding:",";padding-bottom:0;> *{width:640px;margin-bottom:",";}"],(e=>e.theme.spacing.xxlarge),(e=>e.theme.spacing.large)),Eve=u.default.div.withConfig({displayName:"AdvisorBilling__CardSection",componentId:"bwftlv-1"})(["display:flex;padding:",";border-bottom:1px solid ",";flex-direction:column;gap:",";"],(e=>e.theme.spacing.xlarge),(e=>e.theme.color.grayBackground),(e=>e.theme.spacing.default)),yve=Ee.reC,bve=Ee.hh$;var xve,wve=n(17681);const Cve=["We\u2019ll generate a unique code for each client","We\u2019ll email the codes to your clients (we also recommend you send them directly)","You\u2019ll only be charged when a code is redeemed","You can revoke codes at any time"],Ave=e=>{let t=e.onDone;const n=(0,C.RU)(),l=(0,a.useState)(1),r=(0,o.A)(l,2),s=r[0],c=r[1],d=(0,a.useState)(!1),u=(0,o.A)(d,2),m=u[0],p=u[1],g=(0,i.n)(Mve,{refetchQueries:["Web_GetAdvisorClientsPage"]}),h=(0,o.A)(g,1)[0],v=()=>{s>=15?p(!0):c(s+1)};return a.createElement(Rc.L,{"data-external-id":"add-clients-modal",title:"Add clients"},a.createElement(Eu.lV,{onSubmit:async e=>{p(!1);const a=(0,Fne.A)(((t,n)=>{const a=e["client-email-".concat(n)],l=e["client-nickname-".concat(n)];return a?[...t,{email:a,name:(null===l||void 0===l?void 0:l.length)>0?l:void 0}]:t}),[],(0,db.A)(0,s)),l=(await h({variables:{input:{quantity:void 0,invites:a}}})).data,r=(0,DJ.A)(["createSubscriptionSponsorshipInvites","errors"],l);r?n({description:r.message}):null===t||void 0===t||t()}},a.createElement(hu.c.Consumer,null,(e=>{let t=e.isValid;return a.createElement(a.Fragment,null,a.createElement(Ive,null,a.createElement(kve,null,a.createElement(xt.v,{weight:"medium"},"How it works"),a.createElement(Sve,null,Cve.map(((e,t)=>a.createElement(xt.v,{key:t},"\u2022 ",e)))),a.createElement(Tve,null,"If you work with families, enter only one email address for that family. Once they sign up, they will be able to add their partner to their household at no additional cost.")),a.createElement(kve,null,a.createElement("div",{className:"flex flex-col"},a.createElement("div",{className:"flex size-full flex-1 items-center pr-12.5"},a.createElement(Rve,null,"Email"),a.createElement(Rve,null,"Name (optional)")),(0,db.A)(0,s).map((e=>a.createElement(Dve,{key:e,row:!0,full:!0,alignStart:!0},a.createElement("div",{className:"flex items-start"},a.createElement(_ve,{name:"client-email-".concat(e),placeholder:"Enter an email",hideLabel:!0,label:"Email",email:!0}),a.createElement(_ve,{name:"client-nickname-".concat(e),placeholder:"Enter an nickname",hideLabel:!0})),e===s-1&&a.createElement(B.L,{icon:"plus-circle",onClick:v}))))),a.createElement(Nve,{emphasis:m},"Note that if you are inviting more than ",15," clients, you can just email us a list of names and email addresses at [email protected]
1om. We can add them for you."))),a.createElement(Cq.R,null,a.createElement(wve.j,null),a.createElement(CJ.I,{size:"small",disabled:s<=0||!t},"Generate codes")))}))))},Ive=$d.s.div(xve||(xve=(0,wc.A)(["min-h-70"]))),kve=u.default.div.withConfig({displayName:"AddClientsModal__FormSection",componentId:"sc-15l2bom-0"})(["padding:",";:not(:last-child){padding-bottom:0;}"],(e=>{let t=e.theme;return"".concat(t.spacing.default," ").concat(t.spacing.xlarge)})),Sve=(0,u.default)(ZY.B).withConfig({displayName:"AddClientsModal__StepsContainer",componentId:"sc-15l2bom-1"})(["flex-direction:column;padding:",";padding-top:",";"],(e=>e.theme.spacing.xsmall),(e=>e.theme.spacing.small)),Nve=u.default.div.withConfig({displayName:"AddClientsModal__HighInviteInfo",componentId:"sc-15l2bom-2"})(["font-size:",";color:",";"],(e=>e.theme.fontSize.small),(e=>{let t=e.theme;return e.emphasis?t.color.redDark:t.color.text})),Tve=(0,u.default)(xt.v).withConfig({displayName:"AddClientsModal__FamilyText",componentId:"sc-15l2bom-3"})(["font-size:",";color:",";"],(e=>e.theme.fontSize.small),(e=>e.theme.color.text)),_ve=(0,u.default)(Qw.X).withConfig({displayName:"AddClientsModal__StyledTextInput",componentId:"sc-15l2bom-4"})(["margin-top:0;width:200px;padding-right:",";:not(:last-child){margin-bottom:0;}"],(e=>e.theme.spacing.small)),Dve=(0,u.default)(ZY.B).withConfig({displayName:"AddClientsModal__Row",componentId:"sc-15l2bom-5"})(["margin-bottom:",";"],(e=>e.theme.spacing.default)),Rve=u.default.label.withConfig({displayName:"AddClientsModal__Label",componentId:"sc-15l2bom-6"})(["width:200px;font-size:",";font-weight:",";margin-bottom:",";"],(e=>e.theme.fontSize.small),(e=>e.theme.fontWeight.medium),(e=>e.theme.spacing.default)),Mve=Ee.ARU,Lve=e=>{let t=e.onAddClients;return a.createElement("div",{"data-external-id":"advisor-portal-clients-header-controls",className:"flex items-center justify-end"},a.createElement(cu.WT,{onClick:t},a.createElement(Yo.r,{name:"plus"}),a.createElement("span",null,"Add clients")))},Ove=()=>a.createElement(Pve,{"data-external-id":"clients-list-header"},a.createElement(Bve,{span:2},"Code"),a.createElement(Bve,{span:3},"Name"),a.createElement(Bve,{span:2},"Status"),a.createElement(Bve,{span:2})),Pve=(0,u.default)(ZY.B).withConfig({displayName:"ClientsListHeader__Root",componentId:"sc-17r3c70-0"})(["align-items:center;height:","px;padding:0 ",";gap:",";background:",";border-bottom:1px solid ",";border-top:1px solid ",";"],57,(e=>e.theme.spacing.xlarge),(e=>e.theme.spacing.xxsmall),(e=>e.theme.color.white),(e=>e.theme.color.grayBackground),(e=>e.theme.color.grayBackground)),Bve=(0,u.default)(xt.v).attrs({weight:"medium"}).withConfig({displayName:"ClientsListHeader__Column",componentId:"sc-17r3c70-1"})(["flex:",";font-size:",";"],(e=>{var t;return null!==(t=e.span)&&void 0!==t?t:1}),(e=>e.theme.fontSize.small)),zve=e=>{let t=e.sponsoredHouseholdName,n=e.onConfirm,l=e.onCancel,r=e.isLoading;return a.createElement(xC.$,{"data-external-id":"cancel-sponsorship-confirmation",title:"Stop sponsoring client",confirm:"Stop sponsoring client",isLoading:r,onCancel:l,onConfirm:n},a.createElement(xt.v,null,"Are you sure you want to stop paying for your client ",t,"? This action cannot be undone."))},Fve="Click to copy",Gve=e=>{let t=e.value;const n=(0,a.useState)(Fve),l=(0,o.A)(n,2),r=l[0],i=l[1];return a.createElement(JY.d,{"data-external-id":"click-to-copy-code",place:"top",effect:"solid",content:r,fitContent:!1,afterHide:()=>i(Fve)},a.createElement(xt.v,{className:"cursor-pointer",onClick:()=>{i("Copied!"),(0,Bd.l)(t)}},t))};var Yve,Uve=n(18103);const Vve=e=>{let t=e.inviteStatus,n=e.sponsorshipStatus;return a.createElement(Wve,{"data-external-id":"client-status-pill",backgroundColor:pve(t,n),textColor:gve(t,n)},((e,t)=>{if("demo"===e)return"Demo (Free)";if(e===Ee.H4H.PENDING)return"Not redeemed";switch(t){case mve.Active:return"Active";case mve.Canceled:return"Canceled"}})(t,n))},Wve=(0,$d.s)(Uve.f)(Yve||(Yve=(0,wc.A)(["w-max"]))),jve=e=>{let t=e.onEditClient,n=e.onRevokeInvite,l=e.onCancelSponsorship,r=e.hideRevokeAction,o=e.hideCancelSponsorshipAction;return a.createElement(a.Fragment,null,a.createElement(fA.A,{placement:"bottom-start",overlay:a.createElement(Ji.SP,null,a.createElement(Ji.xm,{onClick:t,icon:"edit"},"Edit client"),!r&&a.createElement(Hve,{onClick:n,icon:"x"},"Revoke invite"),!o&&a.createElement(Hve,{onClick:l,icon:"x"},"Stop paying for client"))},(e=>{let t=e.toggleOpen,n=e.isOpen;return a.createElement(B.L,{icon:"more-horizontal",size:"medium",onClick:t,active:n})})))},Hve=(0,u.default)(Ji.xm).withConfig({displayName:"ClientsListRowMenu__DestructiveDropdownMenuItem",componentId:"sc-1olu5o5-0"})(["color:",";:hover{color:",";background-color:",";}"],(e=>e.theme.color.red),(e=>e.theme.color.red),(e=>
1e.theme.color.redBackground)),Kve=(0,Qt.J)("\n  mutation Common_UpdateSponsorshipInvite($input: UpdateSponsorshipInviteInput!) {\n    updateSubscriptionSponsorshipInvite(input: $input) {\n      invite {\n        id\n        label\n      }\n      errors {\n        ...PayloadErrorFields\n      }\n    }\n  }\n"),qve=e=>{let t=e.initiaValues,n=e.onDone;const l=(0,C.RU)(),r=(0,i.n)(Kve),s=(0,o.A)(r,1)[0];return a.createElement(Rc.L,{"data-external-id":"edit-invite-modal",title:"Edit invite"},a.createElement(Eu.lV,{initialValues:t,onSubmit:async e=>{const t=e.id,a=e.label,r=(await s({variables:{input:{id:t,label:a}}})).data,o=(0,DJ.A)(["updateSubscriptionSponsorshipInvite","errors"],r);o?l({description:o.message}):null===n||void 0===n||n()}},a.createElement(hu.c.Consumer,null,(e=>{e.values;let t=e.isValid;return a.createElement(a.Fragment,null,a.createElement($ve,{className:"flex flex-col gap-default"},a.createElement(Qw.X,{name:"label",label:"Name",placeholder:"Enter a label...",required:!0}),a.createElement(xt.v,{size:"xsmall",color:"textLight"},"Give this invite a name that will make it easier to find later")),a.createElement($ve,null,a.createElement(Qw.X,{name:"sentToEmail",disabled:!0,label:"Email",placeholder:"Email..."})),a.createElement(Cq.R,null,a.createElement(wve.j,null),a.createElement(CJ.I,{size:"small",disabled:!t},"Save")))}))))},$ve=u.default.div.withConfig({displayName:"EditInviteModal__FormContent",componentId:"sc-17g3jr4-0"})(["padding:",";:first-child{padding-bottom:0;}"],(e=>{let t=e.theme;return"".concat(t.spacing.default," ").concat(t.spacing.xlarge)})),Zve=e=>{let t=e.onCancel,n=e.onConfirm,l=e.isLoading;return a.createElement(xC.$,{"data-external-id":"revoke-invite-confirmation",title:"Revoke invite",confirm:"Revoke invite",isLoading:l,onCancel:t,onConfirm:n},a.createElement(xt.v,null,"Are you sure you want to revoke this invite? This action cannot be undone."))};var Jve=n(58814);const Xve=e=>{let t=e.messageToCopy,n=e.hypertextVersionOfMessageToCopy;const l=(0,a.useState)("idle"),r=(0,o.A)(l,2),i=r[0],s=r[1];return a.createElement(fe.Yvj,{"data-external-id":"copy-to-clipboard-button",content:"idle"!==i?"Copied!":void 0,open:"copied"===i,onOpenChange:(e,t)=>
1{let n=t.reason;e||"trigger-hover"!==n&&"escape-key"!==n||s("dismissed")},onOpenChangeComplete:e=>{e||s("idle")},closeDelay:300},a.createElement(fe.XZZ,{variant:"default",onClick:()=>{(0,Bd.l)(t,n),s("copied")}},"Copy text to clipboard"))},Qve=e=>{let t=e.templateMessage,n=e.initialValues;const l=(0,i.n)(Kve),r=(0,o.A)(l,1)[0],s=(0,a.useState)(null!==t&&void 0!==t?t:""),c=(0,o.A)(s,2),d=c[0],u=c[1];return(0,a.useEffect)((()=>{u(null!==t&&void 0!==t?t:"")}),[t]),a.createElement(Rc.L,{"data-external-id":"send-invite-modal",title:"Edit client"},a.createElement(Eu.lV,{initialValues:n,submitOnBlur:!0,mutation:r},a.createElement(efe,null,a.createElement(nfe,null,a.createElement(Qw.X,{name:"label",label:"Name",placeholder:"Enter a name..."}),a.createElement(xt.v,{size:"small",color:"textLight"},"This is just for your reference to keep track of who is receiving this code")),a.createElement(nfe,null,a.createElement(Qw.X,{name:"sentToEmail",label:"Email",disabled:!0,placeholder:"Email..."})),a.createElement(z7.P,{text:""}),a.createElement(afe,null,a.createElement(xt.v,{weight:"medium",size:"large"},"Send code to client"),a.createElement(xt.v,{size:"small"},"We recommend you send your potential clients invite codes from your own email address as well. You can copy the template below."),a.createElement(lfe,null,a.createElement(Xve,{messageToCopy:d}))),a.createElement(tfe,{value:d,onChange:e=>{let t=e.target.value;return u(t)},hideResizeHandle:!0,readOnly:!0}))))},efe=u.default.div.withConfig({displayName:"SendInviteModal__FormContent",componentId:"rgepkv-0"})(["padding:",";"],(e=>{let t=e.theme;return"".concat(t.spacing.default," ").concat(t.spacing.xlarge)})),tfe=(0,u.default)(Jve.O).withConfig({displayName:"SendInviteModal__StyledTextAreaInput",componentId:"rgepkv-1"})(["width:100%;background:",";font-size:",";box-sizing:border-box;pointer-events:none;"],(e=>e.theme.color.grayBackground),(e=>e.theme.fontSize.small)),nfe=u.default.div.withConfig({displayName:"SendInviteModal__FieldContainer",componentId:"rgepkv-2"})([">:first-child{margin-bottom:",";}margin-bottom:",";"],(e=>e.theme.spacing.xxxsmall),(e=>e.theme.spacing.small)),afe=u.default.div.withConfig({displayName:"SendInviteModal__SendCodeToClientContainer",componentId:"rgepkv-3"})(["display:flex;flex-direction:column;gap:",";padding-top:",";padding-bottom:",";>:last-child{padding-top:",";}"],(e=>e.theme.spacing.small),(e=>e.theme.spacing.xsmall),(e=>e.theme.spacing.small),(e=>e.theme.spacing.xxsmall)),lfe=u.default.div.withConfig({displayName:"SendInviteModal__ActionsRow",componentId:"rgepkv-4"})(["display:flex;gap:",";"],(e=>e.theme.spacing.default)),rfe=e=>{let t=e.id,n=e.code,l=e.label,r=e.inviteStatus,s=e.sponsor,c=e.sponsorship,d=e.userId,u=e.sentToEmail;const m="demo"===r,p=(0,i.n)(pfe,{refetchQueries:["Web_GetAdvisorClientsPage"]}),g=(0,o.A)(p,2),h=g[0],v=g[1].loading,f=(0,i.n)(mfe,{refetchQueries:["Web_GetAdvisorClientsPage"]}),E=(0,o.A)(f,2),y=E[0],b=E[1].loading,x=(0,Pc.e)(!1),w=(0,o.A)(x,2),C=w[0],A=w[1],k=A.setOn,S=A.setOff,T=(0,Pc.e)(!1),_=(0,o.A)(T,2),D=_[0],R=_[1],M=R.setOn,L=R.setOff,O=(0,Pc.e)(!1),P=(0,o.A)(O,2),B=P[0],z=P[1],F=z.setOn,G=z.setOff,Y=(0,Pc.e)(!1),U=(0,o.A)(Y,2),V=U[0],W=U[1],j=W.setOn,H=W.setOff,K=null!==c&&void 0!==c?c:{},q=K.status,$=K.household,Z=async()=>{(0,Ge.u4)(Ye.vb.ClientRevokeInviteConfirmClicked),await h({variables:{input:{id:t}}}),S()},J=async()=>{(0,Ge.u4)(Ye.vb.ClientCancelSponsorshipConfirmClicked),null!==c&&void 0!==c&&c.id&&(await y({variables:{input:{id:null===c||void 0===c?void 0:c.id}}}),L())};return a.createElement(ofe,{"data-external-id":"clients-list-row",$enablePointer:!1},a.createElement(ife,null,a.createElement(sfe,{span:2},a.createElement("div",null,a.createElement(Gve,{value:n}))),a.createElement(sfe,{span:3},a.createElement("div",{className:"flex flex-col"},a.createElement(dfe,{align:"left"},null!==l&&void 0!==l?l:"-"),r===Ee.H4H.PENDING&&a.createElement(ufe,null,"Sent to: ",u),a.createElement(xt.v,{color:"textLight",size:"small"},(null===$||void 0===$?void 0:$.lastActivityAt)&&"Last active: ".concat((0,Ba.fw)(N.c9.fromISO(null===$||void 0===$?void 0:$.lastActivityAt))," ago")))),a.createElement(sfe,{span:2},a.createElement("div",null,a.createElement(Vve,{inviteStatus:r,sponsorshipStatus:q}))),a.createElement(sfe,{span:2},a.createElement(cfe,{justifyEnd:!0},((0,Tr.A)(c)&&q===mve.Active||m)&&a.createElement(cfe,{justifyEnd:!0},a.createElement(wt.zC,{pending:!d,linkTo:I.JZ.actAsUser({id:d}),onClick:()=>{(0,Ge.u4)(Ye.vb.ClientViewHouseholdOptionClicked)},target:"_blank"},a.createElement(Yo.r,{name:"external-link"}),a.createElement("span",{className:"whitespace-nowrap"},"View household"))),r===Ee.H4H.PENDING&&a.createElement(wt.Xb,{onClick:()=>{(0,Ge.u4)(Ye.vb.ClientSendCodeOptionClicked),F()}},a.createElement(Yo.r,{name:"mail"}),a.createElement("span",{className:"whitespace-nowrap"},"Send code")),a.createElement(jve,{onEditClient:()=>{(0,Ge.u4)(Ye.vb.ClientEditOptionClicked),j()},onRevokeInvite:()=>{(0,Ge.u4)(Ye.vb.ClientRevokeInviteOptionClicked),k()},onCancelSponsorship:()=>{(0,Ge.u4)(Ye.vb.ClientCancelSponsorshipOptionClicked),M()},hideRevokeAction:r!==Ee.H4H.PENDING,hideCancelSponsorshipAction:q!==mve.Active})))),C&&a.createElement(um.b,{onClose:S},(e=>{let t=e.close;return a.createElement(Zve,{isLoading:v,onConfirm:Z,onCancel:t})})),D&&a.createElement(um.b,{onClose:L},(e=>{let t=e.close;return a.createElement(zve,{isLoading:b,sponsoredHouseholdName:null===$||void 0===$?void 0:$.name,onConfirm:J,onCancel:t})})),V&&a.createElement(um.b,{onClose:H},(e=>{let n=e.close;return a.createElement(qve,{initiaValues:{id:t,label:l,sentToEmail:u},onDone:n})})),B&&a.createElement(um.b,{onClose:G},(()=>{var e;return a.createElement(Qve,{initialValues:{id:t,label:l,sentToEmail:u},templateMessage:hve(null!==(e=null===s||void 0===s?void 0:s.name)&&void 0!==e?e:"",n,(0,Vse.w)("REACT_APP_BASE_URL"))})})))},ofe=u.default.div.withConfig({displayName:"ClientsListRow__Root",componentId:"sc-1x2b0pa-0"})(["display:flex;align-items:center;border:1px solid transparent;cursor:",";user-select:",";transition:background-color 0.1s ease-out;background-color:transparent;:not(:last-child){border-bottom-color:",";}border-bottom-color:",";"],(e=>e.$enablePointer?"pointer":"inherit"),(e=>e.$enablePointer?"none":"auto"),(e=>
1e.theme.color.grayBackground),(e=>e.theme.color.grayBackground)),ife=(0,u.default)(ZY.B).withConfig({displayName:"ClientsListRow__RowContainer",componentId:"sc-1x2b0pa-1"})(["width:100%;height:","px;padding:0 ",";padding-top:",";grid-gap:",";background-color:",";font-size:",";transition:border-color 0.1s ease-out;margin:-1px -1px 0;&:first-child{margin-top:0;}"],76,(e=>e.theme.spacing.xlarge),(e=>e.theme.spacing.xxsmall),(e=>e.theme.spacing.xxsmall),(e=>e.theme.color.white),(e=>e.theme.fontSize.base)),sfe=(0,u.default)(ZY.B).withConfig({displayName:"ClientsListRow__Column",componentId:"sc-1x2b0pa-2"})(["display:flex;align-items:center;flex:",";> *{width:100%;}"],(e=>{var t;return null!==(t=e.span)&&void 0!==t?t:1})),cfe=(0,u.default)(ZY.B).withConfig({displayName:"ClientsListRow__ActionsContainer",componentId:"sc-1x2b0pa-3"})(["gap:",";"],(e=>e.theme.spacing.small)),dfe=(0,u.default)(xt.v).withConfig({displayName:"ClientsListRow__NameLabel",componentId:"sc-1x2b0pa-4"})(["text-overflow:ellipsis;width:100%;"]),ufe=(0,u.default)(xt.v).withConfig({displayName:"ClientsListRow__EmailLabel",componentId:"sc-1x2b0pa-5"})(["text-overflow:ellipsis;width:100%;color:",";font-size:",";"],(e=>e.theme.color.textLight),(e=>e.theme.fontSize.small)),mfe=Ee.L3F,pfe=Ee.OsH;var gfe;const hfe=()=>a.createElement(Efe,{"data-external-id":"clients-list-loading"},a.createElement(vfe,null),(0,db.A)(0,3).map((e=>a.createElement(ffe,{key:e})))),vfe=()=>a.createElement(yfe,{"data-external-id":"header-loading"},a.createElement(Rr.s,null,a.createElement("rect",{x:"24",y:"17",rx:"5",ry:"5",width:"48",height:"19"}),a.createElement("rect",{x:"180",y:"17",rx:"5",ry:"5",width:"60",height:"19"}),a.createElement("rect",{x:"520",y:"17",rx:"5",ry:"5",width:"60",height:"19"}),a.createElement("rect",{x:"680",y:"17",rx:"5",ry:"5",width:"72",height:"19"}))),ffe=()=>a.createElement(bfe,{"data-external-id":"row-loading"},a.createElement(Rr.s,null,a.createElement("rect",{x:"24",y:"30",rx:"5",ry:"5",width:"64",height:"19"}),a.createElement("rect",{x:"180",y:"30",rx:"5",ry:"5",width:"96",height:"19"}),a.createElement("rect",{x:"520",y:"30",rx:"5",ry:"5",width:"64",height:"19"}),a.createElement("rect",{x:"680",y:"30",rx:"5",ry:"5",width:"92",height:"19"}),a.createElement("rect",{x:"calc(89% - 32px)",y:"30",rx:"5",ry:"5",width:"96",height:"19"}),a.createElement("circle",{cx:"calc(97%)",cy:"40",r:"12"}))),Efe=$d.s.div(gfe||(gfe=(0,wc.A)(["overflow-hidden"]))),yfe=u.default.div.withConfig({displayName:"ClientsListLoading__HeaderRoot",componentId:"sc-17vkbty-0"})(["height:","px;border-bottom:1px solid ",";width:100%;"],57,vt.Ee.color.divider.primary),bfe=u.default.div.withConfig({displayName:"ClientsListLoading__RowRoot",componentId:"sc-17vkbty-1"})(["height:","px;width:100%;:not(:last-child){border-bottom:1px solid ",";}"],76,vt.Ee.color.divider.primary),xfe=e=>!!e,wfe=e=>{let t=e.sponsor,n=e.invites,l=void 0===n?[]:n,i=e.isLoading,s=e.demoUserId,c=e.demoUserCreationStatus;const d=(0,a.useState)(""),u=(0,o.A)(d,2),m=u[0],p=u[1],g=(0,a.useMemo)((()=>{let e=null!==l&&void 0!==l?l:[];return m&&(e=e.filter((e=>{let t=e.sentToEmail,n=e.sponsorship,a=e.label;const l=(null!==n&&void 0!==n?n:{}).household,r=(null!==l&&void 0!==l?l:{}).owner;return[t,null===l||void 0===l?void 0:l.name,null===r||void 0===r?void 0:r.email,a].filter(xfe).some((e=>e.toLowerCase().includes(m.toLowerCase())))}))),e}),[l,m]),h=(0,VW.A)((e=>e.status===Ee.H4H.REDEEMED),g),v=!i&&(null===h||void 0===h?void 0:h.length)<=1,f=(0,a.useMemo)((()=>(e,n)=>{var l,r;let o=n.id,i=n.code,s=n.label,c=n.status,d=n.createdAt,u=n.sponsorship,m=n.sentToEmail;return a.createElement(rfe,{key:o,id:o,code:i,label:s,sponsor:t,createdAt:d,inviteStatus:c,sponsorship:u,userId:null===u||void 0===u||null===(l=u.household)||void 0===l||null===(r=l.owner)||void 0===r?void 0:r.id,sentToEmail:m})}),[]);return a.createElement("div",{"data-external-id":"clients-list",className:"flex flex-col"},(0,r.YW)({isLoading:i,filteredInvites:g,demoUserId:s,demoUserCreationStatus:c}).with({isLoading:!0},(()=>a.createElement(hfe,null))).with({filteredInvites:[],demoUserId:r.P.nullish,demoUserCreationStatus:Ee.e93.COMPLETED},(()=>a.createElement(cU.vx,{emptyTheme:cU.dO.NEW,title:"No clients yet",subtitle:"Invite clients to get started"}))).otherwise((()=>a.createElement(a.Fragment,null,a.createElement(Afe,{placeholder:"Search by name or email",name:"search-clients",value:m,onChange:p}),a.createElement(Ove,null),a.createElement(Cfe,null,a.createElement(Ac.aY,{data:g,itemContent:f,components:{Footer:()=>a.createElement(rfe,{code:"DEMO",key:"demo",id:s,label:"Demo User",sponsor:t,inviteStatus:"demo",userId:s})}}))))),v&&a.createElement(cU.vx,{emptyTheme:cU.dO.NEW,title:"Need help getting started?",subtitle:a.createElement(a.Fragment,null,"You can book an"," ",a.createElement(wb.gz,{target:"_blank",href:VF.EY},"onboarding session")," ","with our Customer Success team, watch our"," ",a.createElement(wb.gz,{target:"_blank",href:VF.XE},"onboarding video"),", or read our"," ",a.createElement(wb.gz,{target:"_blank",href:VF.aD},"FAQ"),".")}))},Cfe=u.default.div.withConfig({displayName:"ClientsList__VirtuosoContainer",componentId:"kiqe75-0"}
1)(["height:calc(100vh - 580px);min-height:300px;"]),Afe=(0,u.default)(TF.J).withConfig({displayName:"ClientsList__StyledSearchBar",componentId:"kiqe75-1"})(["margin:",";margin-top:0;"],vt.YK.xlarge),Ife=(0,Vse.w)("REACT_APP_BASE_URL"),kfe=e=>{let t=e.email;const n=(0,P6.f)().referralCode,l=(0,a.useMemo)((()=>Eie(n||"",(0,Mie.v)("landing"))),[n]),r=(0,a.useMemo)((()=>Sfe(t,l)),[t,l]);return a.createElement(Rc.L,{"data-external-id":"get-access-grant-modal",title:"Get Access to Client"},a.createElement(Tfe,null,"Clients will need to have their own Monarch account to grant you temporary access. If you need permanent access, we recommend sponsoring them instead.",a.createElement("br",null),a.createElement("br",null),"To get temporary access, you can copy the template below.",a.createElement("br",null),a.createElement("br",null),"New Monarch users can get 50% off their first year annual plan on web, plus a 7-day free trial, when they sign up using the embedded referral link. (The offer is valid for new customers only and will not apply to existing Monarch users.)",a.createElement(Nfe,null,a.createElement(Xve,{messageToCopy:r})),a.createElement(_fe,{value:r,hideResizeHandle:!0,readOnly:!0})))},Sfe=(e,t)=>"\nHi,\n\nI'd like to collaborate with you on your finances in Monarch Money.\n\n".concat("If you don't already have an account with Monarch, you can learn more and sign up using the link below to receive 50% off your first year:","\n\n  ",t,"\n\nOnce you have an account (or if you already have one), you can head to the following link to grant me temporary access to your account:\n\n  ").concat(Ife,"/settings/members\n\nFrom there, you can grant access to my email address:\n\n  ").concat(e,"\n"),Nfe=u.default.div.withConfig({displayName:"GetAccessGrantModal__ActionsRow",componentId:"sc-1a8p0te-0"})(["display:flex;gap:",";margin-top:",";margin-bottom:",";"],(e=>e.theme.spacing.default),(e=>e.theme.spacing.default),(e=>e.theme.spacing.default)),Tfe=u.default.div.withConfig({displayName:"GetAccessGrantModal__Container",componentId:"sc-1a8p0te-1"})(["padding:",";"],(e=>{let t=e.theme;return"".concat(t.spacing.default," ").concat(t.spacing.xlarge)})),_fe=(0,u.default)(Jve.O).withConfig({displayName:"GetAccessGrantModal__StyledTextAreaInput",componentId:"sc-1a8p0te-2"})(["width:100%;background:",";font-size:",";box-sizing:border-box;pointer-events:none;"],(e=>e.theme.color.grayBackground),(e=>e.theme.fontSize.small)),Dfe=e=>{let t=e.isLoading,n=e.accessGrants;const l=!t&&(0,PY.A)(n),o=(0,a.useMemo)((()=>[{accessorKey:"householdGivingAccessName",header:"Household",cell:e=>{let t=e.getValue,n=e.row;return a.createElement("div",{className:"flex flex-col"},a.createElement(xt.v,null,t()),a.createElement(xt.v,{color:"textLight",size:"small"},"Access expires ",a.createElement(roe.T,{date:n.original.expiresAt})))}},{accessorKey:"userGivingAccessId",header:"Access",enableSorting:!1,cell:e=>{let t=e.getValue;return a.createElement("div",{className:"flex justify-end"},a.createElement(wt.Xb,{linkTo:I.JZ.actAsUser({id:t()}),target:"_blank"},a.createElement(Yo.r,{name:"external-link"}),a.createElement("span",{className:"whitespace-nowrap"},"View household")))}},{accessorKey:"id",cell:()=>a.createElement(a.Fragment,null)}]),[]);return(0,r.YW)({isEmpty:l,isLoading:t}).with({isEmpty:!0,isLoading:!1},(()=>a.createElement(cU.vx,{emptyTheme:cU.dO.NEW,title:"No access-only clients yet"}))).with({isEmpty:!1,isLoading:!1},(()=>a.createElement(Jo.k1,{columns:o,data:n,isLoading:t,showFooter:!1}))).with({isLoading:!0},(()=>a.createElement("div",{className:"flex items-center justify-center p-3xl"},a.createElement(p.i,null)))).exhaustive()};var Rfe;const Mfe=()=>{var e,t,n,r;const i=(0,l.Zp)(),s=(0,PH.p)(Bfe,{onComplete:()=>{(0,C.oR)({title:"Demo account created",description:"The demo account is now ready to use."})},pollUntil:e=>{var t;const n=null===e||void 0===e||null===(t=e.subscriptionSponsorshipDemoAccount)||void 0===t?void 0:t.user;return(0,Tr.A)(n)},skipWhenNotPolling:!1}),c=(0,o.A)(s,2),d=c[0],u=c[1],m=u.data,p=u.loading,g=null!==(e=null===m||void 0===m?void 0:m.subscriptionSponsorshipInvites)&&void 0!==e?e:[],h=null!==(t=null===m||void 0===m?void 0:m.subscriptionSponsorAccessGrants)&&void 0!==t?t:[],v=null===m||void 0===m?void 0:m.subscriptionSponsor,f=null===m||void 0===m?void 0:m.subscriptionSponsorshipDemoAccount,E=null===f||void 0===f||null===(n=f.user)||void 0===n?void 0:n.id,y=null===f||void 0===f?void 0:f.status;return(0,a.useEffect)((()=>{E||p||void 0===y||![Ee.e93.IN_PROGRESS,Ee.e93.NOT_STARTED].includes(y)||(setTimeout((()=>{(0,C.oR)({title:"Creating demo account...",description:"We are creating a demo account just for you. This may take a few seconds."})}),0),d())}),[E,p]),a.createElement(rG.Y,{"data-external-id":"advisor-clients",name:"Clients",parentRoute:null},a.createElement(Xhe.Ay,null,a.createElement("title",null,"Professional Portal | Clients")),a.createElement(Lfe,null,a.createElement(Ofe,null,a.createElement($Y.H8,{title:"Sponsored Clients",description:"A sponsored client is a client you pay for. You will be charged a fixed amount for each active client.",controls:a.createElement(Lve,{onAddClients:()=>i(I.JZ.advisorPortal.clients.addClients.path)}),hideBottomBorder:!0}),a.createElement(wfe,{invites:g,isLoading:p,sponsor:v,demoUserId:E,demoUserCreationStatus:y})),a.createElement(Ofe,null,a.createElement($Y.H8,{title:"Access-Only Clients",description:"You have temporary access to these clients' households. They will need their own Monarch subscription, and 
1you will not be billed for the access. ",controls:a.createElement("div",{className:"ml-default flex items-center justify-end"},a.createElement(cu.WT,{onClick:()=>i(I.JZ.advisorPortal.clients.getAccessGrant.path)},a.createElement(Yo.r,{name:"plus"}),a.createElement(Pfe,null,"Get access")))}),a.createElement(Dfe,{isLoading:p,accessGrants:h}))),a.createElement(XU.l,{path:I.JZ.advisorPortal.clients.addClients.relativePath},(e=>{let t=e.close;return a.createElement(Ave,{onDone:()=>{t()}})})),a.createElement(XU.l,{path:I.JZ.advisorPortal.clients.getAccessGrant.relativePath},a.createElement(kfe,{email:(null===m||void 0===m||null===(r=m.me)||void 0===r?void 0:r.email)||""})))},Lfe=(0,u.default)(ZY.B).withConfig({displayName:"AdvisorClients__Container",componentId:"nd8e85-0"})(["flex-direction:column;padding:",";padding-bottom:0;padding-top:0;"],(e=>e.theme.spacing.gutter)),Ofe=(0,u.default)(Xl.AM).withConfig({displayName:"AdvisorClients__StyledCard",componentId:"nd8e85-1"})(["margin-bottom:",";"],(e=>e.theme.spacing.gutter)),Pfe=$d.s.span(Rfe||(Rfe=(0,wc.A)(["whitespace-nowrap"]))),Bfe=Ee.eOF,zfe=["loading","isDemo","anchorId","rootProps"],Ffe=e=>{let t=e.loading,n=e.isDemo,l=void 0!==n&&n,r=e.anchorId,o=e.rootProps,i=(0,En.A)(e,zfe);const s=(0,Qhe.x)(r);return t?a.createElement(Gfe,{"data-external-id":"settings-card"},a.createElement(p.i,null)):a.createElement(JY.d,{"data-external-id":"settings-card",content:_t.Sk.PAGE_DISABLED,disable:!l},a.createElement(Ufe,{$disabled:l},a.createElement(Yfe,Object.assign({$disabled:l,rootProps:(0,U.A)((0,U.A)({},o),s)},i))))},Gfe=(0,u.default)(m.g).attrs({center:!0}).withConfig({displayName:"SettingsCard__LoadingContainer",componentId:"sc-189f681-0"})(["padding:",";"],(e=>e.theme.spacing.xxxlarge)),Yfe=(0,u.default)(Xl.AM).attrs((0,Ex.p)("settings-card")).withConfig({displayName:"SettingsCard__StyledCard",componentId:"sc-189f681-1"})(["",""],(e=>e.$disabled?(0,u.css)(["opacity:50%;pointer-events:none;user-select:none;"]):"")),Ufe=u.default.div.withConfig({displayName:"SettingsCard__Placeholder",componentId:"sc-189f681-2"})(["cursor:",";"],(e=>e.$disabled?"not-allowed":"inherit")),Vfe=()=>{var e;const t=(0,C.RU)(),n=(0,et.I)(Kfe),l=n.data,r=n.isLoadingInitialData,s=(0,i.n)(qfe,{refetchQueries:[ece.c]}),c=(0,o.A)(s,1)[0];return a.createElement(rG.Y,{"data-external-id":"advisor-profile",name:"Profile",parentRoute:null},a.createElement(Xhe.Ay,null,a.createElement("title",null,"Professional Portal | Profile")),a.createElement(Wfe,null,r?a.createElement("div",{className:"my-lg flex size-full flex-1 items-center justify-center"},a.createElement(p.i,null)):a.createElement(Ffe,{title:"Profile"},a.createElement(jfe,fl.TN,a.createElement(Eu.lV,{initialValues:{name:null===l||void 0===l||null===(e=l.subscriptionSponsor)||void 0===e?void 0:e.name},onSubmit:async e=>{const n=e.name,a=(await c({variables:{input:{name:n}}})).data,l=(0,DJ.A)(["updateSponsor","errors"],a);l&&t({description:l.message})}},a.createElement("div",{className:"flex flex-col gap-default"},a.createElement(Qw.X,{name:"name",label:"Name"}),a.createElement(Hfe,null,"Your clients will see this when they redeem an invite code you send them. It should be either your personal name or your business name.")),a.createElement(CJ.I,null,"Update Profile"))))))},Wfe=(0,u.default)(ZY.B).withConfig({displayName:"AdvisorProfile__Container",componentId:"sc-168com-0"})(["flex-direction:column;align-items:center;padding:",";padding-bottom:0;"],(e=>e.theme.spacing.xxlarge)),jfe=u.default.div.withConfig({displayName:"AdvisorProfile__FormContainer",componentId:"sc-168com-1"})(["width:406px;margin:",";"],(e=>e.theme.spacing.xlarge)),Hfe=(0,u.default)(xt.v).attrs({size:"xsmall",color:"textLight"}).withConfig({displayName:"AdvisorProfile__StyledText",componentId:"sc-168com-2"})(["display:block;"]),Kfe=Ee.dsb,qfe=Ee.F_p,$fe=(0,u.default)(ZY.B).attrs({"data-sc-tw":"Flex__Flex SettingsSection__SettingsSection",justifyBetween:!0,alignCenter:!0}).withConfig({displayName:"SettingsSection",componentId:"sc-1ruj14l-0"})(["padding:",";:not(:last-child){border-bottom:1px solid ",";}"],(e=>e.theme.spacing.xlarge),vt.Ee.color.divider.primary),Zfe=e=>{let t=e.title,n=e.description;return a.createElement(a.Fragment,null,a.createElement(Xfe,null,t),a.createElement(Jfe,null,n))},Jfe=u.default.div.withConfig({displayName:"SettingsTitle__Description",componentId:"u3tlvx-0"})(["font-size:",";color:",";"],(e=>e.theme.fontSize.base),(e=>e.theme.color.text)),Xfe=u.default.div.withConfig({displayName:"SettingsTitle__Title",componentId:"u3tlvx-1"})(["font-size:",";font-weight:",";padding-bottom:",";color:",";"],(e=>e.theme.fontSize.base),(e=>e.theme.fontWeight.medium),(e=>e.theme.spacing.xxxsmall),(e=>e.theme.color.text));var Qfe=n(23812);const eEe=e=>{let t=e.onConfirm,n=e.onCancel,l=e.daysLeftOfTrial;return a.createElement(xC.$,{"data-external-id":"delete-household-initial-confirmation",title:_t.bN,confirm:"Delete",onCancel:n,onConfirm:t},a.createElement(xt.v,null,l&&l>0?"You have ".concat(l," ").concat(nie()("days",l)," left in your trial."):"This action is not reversible."),a.createElement(tEe,null,"Are you sure you wish to delete all your data?"))},tEe=(0,u.default)(xt.v).withConfig({displayName:"DeleteHouseholdInitialConfirmation__StyledText",componentId:"sc-1iovt7s-0"})(["margin-bottom:",";"],(e=>e.theme.spacing.xsmall));var nEe=n(67955);const aEe=e=>{let t=e.onCancel,n=e.onDisable;const l=(0,i.n)(lEe),r=(0,o.A)(l,2),s=r[0],c=r[1].loading;return a.createElement(xC.$,{"data-external-id":"disable-mfa-confirmation",title:"Disable multi-factor authentication",confirm:"Disable multi-factor authentication",isLoading:c,onCancel:t,onConfirm:async()=>{var e;const a=await s(),l=a.data,r=a.errors;var o;null!==l&&void 0!==l&&null!==(e=l.deleteTotpDevice)&&void 0!==e&&e.deleted?n():(nEe.v.error("MFA not disabled.",r,null===l||void 0===l||null===(o=l.deleteTotpDevice)||void 0===o?void 0:o.errors),t())},useDangerButton:!0},a.createElement("div",null,"Are you sure you want to disable multi-factor authentication? This will remove the extra security layer for your account completely. You can re-enable multi-factor authentication at any time."))},lEe=Ee.n9O;var rEe=n(50925),oEe=n(23176),iEe=n(46897);const sEe=e=>{let t=e.provider,n=e.providerLabel,l=e.providerEmail,r=e.onCancel,o=e.onDisconnect;const i=(0,C.RU)(),s=(0,iEe.m)({onSuccess:async e=>{try{await(0,rEe.q)(r7.F).revokeProviderSSO(t,{token:e.access_token}),o()}catch(n){i()}},flow:"implicit"}),c=(0,oEe.L)({onSuccess:async e=>{const n=e.authorization.code;try{await(0,rEe.q)(r7.F).revokeProviderSSO(t,{token:n}),o()}catch(a){i()}}}),d=c.isLoaded,u=c.onClick;return a.createElement(xC.$,{"data-external-id":"disconnect-sso-confirmation",title:"Remove Log in with ".concat(n),confirm:"Log out",onCancel:r,onConfirm:()=>{"google"===t?s():"apple"===t&&u()},isLoading:"apple"===t&&!d,useDangerButton:!0},a.createElement("div",null,"Are you sure you want to disconnect"," ",a.createElement(xt.v,{weight:"medium"},l)," from ",n," Log in?"))};var cEe=n(54279);const dEe=e=>{let t=e.onDone,n=e.onCancel;const l=(0,E.wA)();return a.createElement(Rc.L,{"data-external-id":"edit-password-modal",title:"Update Password"},a.createElement(Eu.lV,{initialValues:{current_password:"",new_password:""},onSubmit:async e=>{await l((0,C7.CJ)(e,!0)),t()}},a.createElement(uEe,{className:"flex flex-col gap-default"},a.createElement(cEe.S,{name:"current_password",label:"Current Password",required:!0,autoComplete:"current-password"}),a.createElement(cEe.S,{name:"new_password",label:"New Password",password:!0,required:!0,autoComplete:"new-password"}),a.createElement(cEe.S,{name:"confirm_new_password",label:"Confirm New Password",sameAs:"new_password",required:!0,autoComplete:"new-password"})),a.createElement(Cq.R,null,a.createElement(wt.Xb,{onClick:n},"Cancel"),a.createElement(CJ.I,{size:"small"}
1,"Save"))))},uEe=u.default.div.withConfig({displayName:"EditPasswordModal__FormContainer",componentId:"sc-1x1jchv-0"})(["margin:",";"],(e=>e.theme.spacing.xlarge)),mEe=e=>{let t=e.next;return a.createElement(vEe,{"data-external-id":"enable-mfa-info-modal",title:"Enable multi-factor authentication"},a.createElement(fEe,{column:!0,margin:"large"},a.createElement(EEe,null,"Use an application on your phone to get two-factor authentication codes when prompted by Monarch when you log in."),a.createElement(EEe,null,"We recommend using an application such as ",a.createElement(pEe,null),", ",a.createElement(gEe,null),", ",a.createElement(hEe,null),". These applications support secure backup of your authentication codes in the cloud and can be restored if you lose access to your device.")),a.createElement(Cq.R,null,a.createElement(wve.j,null),a.createElement(cu.WT,{onClick:t},"Set up using an app")))},pEe=()=>a.createElement(yEe,{"data-external-id":"authy-link",href:I.kP.authy,target:"_blank"},"Authy"),gEe=()=>a.createElement(yEe,{"data-external-id":"one-pass-link",href:I.kP.onePass,target:"_blank"},"1Password"),hEe=()=>a.createElement(yEe,{"data-external-id":"last-pass-link",href:I.kP.lastPassAuth,target:"_blank"},"LastPass Authenticator"),vEe=(0,u.default)(Rc.L).withConfig({displayName:"EnableMfaInfoModal__StyledModalCard",componentId:"cvn8sf-0"})(["width:570px;"]),fEe=(0,u.default)(m.g).withConfig({displayName:"EnableMfaInfoModal__Root",componentId:"cvn8sf-1"})([""]),EEe=(0,u.default)(xt.v).withConfig({displayName:"EnableMfaInfoModal__Body",componentId:"cvn8sf-2"})(["margin-bottom:",";"],(e=>e.theme.spacing.xlarge)),yEe=(0,u.default)(cl.M).withConfig({displayName:"EnableMfaInfoModal__StyledLink",componentId:"cvn8sf-3"})(["font-weight:",";"],(e=>e.theme.fontWeight.book));var bEe=n(42484),xEe=n(20570);const wEe=e=>{let t=e.device;return e.loading&&!t?a.createElement(CEe,{"data-external-id":"qr-code-box-mfa"},a.createElement(p.i,null)):a.createElement(xEe.N,{"data-external-id":"qr-code-box-mfa",forceTheme:"light"},a.createElement(AEe,{padding:"xlarge"},!(null===t||void 0===t||!t.configUrl)&&a.createElement(bEe.Ay,Ob
1ject.assign({value:t.configUrl,size:150},fl.TN)),a.createElement("div",{className:"ml-xl flex flex-col justify-between py-sm"},a.createElement(xt.v,{color:"text"},"If you\u2019re unable to scan the QR code, enter the text code below instead."),a.createElement("div",null,a.createElement(IEe,null,"Two-factor text code"),a.createElement(kEe,Object.assign({name:"secret",value:null===t||void 0===t?void 0:t.secret,disabled:!0},fl.TN))))))},CEe=(0,u.default)(m.g).attrs({center:!0}).withConfig({displayName:"QRCodeBoxMfa__LoadingContainer",componentId:"ev2569-0"})(["flex:1;padding:",";"],(e=>e.theme.spacing.xlarge)),AEe=(0,u.default)(m.g).withConfig({displayName:"QRCodeBoxMfa__Box",componentId:"ev2569-1"})(["border-radius:",";border:1px solid ",";margin-bottom:",";background:",";"],(e=>e.theme.radius.small),(e=>e.theme.color.grayFocus),(e=>e.theme.spacing.xxlarge),(e=>e.theme.color.textWhite)),IEe=(0,u.default)(Ey._J).withConfig({displayName:"QRCodeBoxMfa__StyledLabel",componentId:"ev2569-2"})(["margin-bottom:",";color:",";"],(e=>e.theme.spacing.xsmall),(e=>e.theme.color.text)),kEe=(0,u.default)(Ry.X).withConfig({displayName:"QRCodeBoxMfa__StyledInput",componentId:"ev2569-3"})(["width:100%;"]),SEe=e=>{var t;let n=e.next;const l=(0,i.n)(NEe),r=(0,o.A)(l,2),s=r[0],c=r[1],d=c.data,u=c.loading,m=(0,i.n)(TEe,{onCompleted:e=>{var t;null!==(t=e.confirmTotpDevice)&&void 0!==t&&t.isTokenValid&&n()}}),p=(0,o.A)(m,1)[0];(0,a.useEffect)((()=>{s()}),[s]);const g=null===d||void 0===d||null===(t=d.createUnconfirmedTotpDevice)||void 0===t?void 0:t.device;return a.createElement(Rc.L,{"data-external-id":"qr-code-mfa-modal",className:"w-161.25",title:"Scan this QR code with your app",description:"Scan the QR code below with your two-factor authentication app."},a.createElement(Eu.lV,{initialValues:{token:""},mutation:p},a.createElement("div",{className:"m-lg flex flex-col"},a.createElement(wEe,{device:g,loading:u}),a.createElement(xt.v,{className:"mb-sm",size:"large",weight:"medium"},"Enter the six-digit code from the application"),a.createElement(xt.v,{className:"mb-lg"},"After scanning the QR code above, the app will display a six-digit code. Enter it below to continue."),a.createElement(tC.zB.OTP,Object.assign({},fl.TN,{name:"token",label:"Six-digit code from application",errorLabel:"error",required:!0,autoFocus:!0}))),a.createElement(Cq.R,null,a.createElement(wve.j,null),a.createElement(CJ.I,{size:"small"},"Next"))))},NEe=Ee.oX8,TEe=Ee.kLC;var _Ee=n(79965),DEe=n.n(_Ee);const REe=e=>{let t=e.tokenArray,n=e.codesRef,l=e.allowNext;const r=t.join("\r\n");return a.createElement("div",{"data-external-id":"recovery-codes-mfa-action-buttons",className:"mb-lg flex justify-center"},a.createElement(LEe,{marginRight:"large",onClick:()=>{l(),MEe(r)}},"Download"),a.createElement(DEe(),{trigger:()=>a.createElement(LEe,{marginRight:"large",onClick:()=>l()},"Print"),content:()=>n.current}),a.createElement(LEe,{onClick:()=>{l(),(0,Bd.l)(r)}},"Copy to Clipboard"))},MEe=e=>{const t=document.createElement("a"),n=new Blob([e],{type:"text/plain",endings:"native"});t.href=URL.createObjectURL(n),t.download="monarchRecoveryTokens.txt",document.body.appendChild(t),t.click()},LEe=(0,u.default)(wt.Xb).withConfig({displayName:"RecoveryCodesMfaActionButtons__StyledDefaultButton",componentId:"sc-1oavp1s-0"})(["margin-right:",";"],(e=>{let t=e.theme,n=e.marginRight;return n&&t.spacing[n]})),OEe=e=>{let t=e.allowNext,n=e.tokenArray,l=e.loading;const r=(0,a.useRef)(null);return l&&!n?a.createElement(zEe,{"data-external-id":"recovery-codes-mfa-box"},a.createElement(p.i,null)):a.createElement(PEe,{"data-external-id":"recovery-codes-mfa-box",column:!0},a.createElement(m.g,Object.assign({wrap:!0,marginTop:"large",marginBottom:"default",ref:r},fl.TN),n.map((e=>a.createElement(BEe,{key:e,basis:"33%",grow:1},e)))),a.createElement(REe,{tokenArray:n,codesRef:r,allowNext:t}))},PEe=(0,u.default)(m.g).withConfig({displayName:"RecoveryCodesMfaBox__Box",componentId:"trl0fy-0"})(["border-radius:",";border:1px solid ",";padding-left:53px;padding-right:53px;margin-bottom:",";"],(e=>e.theme.radius.small),(e=>e.theme.color.grayFocus),(e=>e.theme.spacing.xxlarge)),BEe=(0,u.default)(Lre.g).withConfig({displayName:"RecoveryCodesMfaBox__Code",componentId:"trl0fy-1"})(["font-family:Meslo LG L,sans-serif;text-align:center;margin-bottom:",";"],(e=>e.theme.spacing.xsmall)),zEe=(0,u.default)(m.g).attrs({center:!0}).withConfig({displayName:"RecoveryCodesMfaBox__LoadingContainer",componentId:"trl0fy-2"})(["flex:1;padding:",";"],(e=>e.theme.spacing.xlarge)),FEe=e=>{var t;let n=e.next,l=e.onDone;const r=(0,Pc.e)(!1),s=(0,o.A)(r,2),c=s[0],d=s[1].setOn,u=(0,i.n)(qEe),m=(0,o.A)(u,2),p=m[0],g=m[1],h=g.data,v=g.loading;(0,a.useEffect)((()=>{p()}),[]);const f=(null!==(t=null===h||void 0===h?void 0:h.createRecoveryCodes)&&void 0!==t?t:{}).staticTokens,E=void 0===f?[]:f,y=(0,jd.A)((0,mo.A)("token"),E);return a.createElement(WEe,{"data-external-id":"save-recovery-codes-mfa-modal",title:l?"Recovery codes":"Save your recovery codes",description:"Recovery codes are used to access your account in the event you cannot receive two-factor authentication codes."},a.createElement(jEe,{column:!0,margin:"large"},a.createElement(OEe,{allowNext:d,tokenArray:y,loading:v}),a.createElement(HEe,null,"Treat your recovery codes with the same level of attention as you would your password. We recommend saving them with a password manager such as"," ",a.createElement(UEe,null),", ",a.createElement(YEe,null),", or ",a.createElement(GEe,null),".")),a.createElement(Cq.R,null,n&&a.createElement(a.Fragment,null,a.createElement(wve.j,null),a.createElement(VEe,{allowNext:c,next:n})),l&&a.createElement(cu.WT,{onClick:l},"Done")))},GEe=()=>
1a.createElement(KEe,{"data-external-id":"keeper-link",href:I.kP.keeper,target:"_blank"},"Keeper"),YEe=()=>a.createElement(KEe,{"data-external-id":"one-pass-link",href:I.kP.onePass,target:"_blank"},"1Password"),UEe=()=>a.createElement(KEe,{"data-external-id":"last-pass-link",href:I.kP.lastPass,target:"_blank"},"LastPass"),VEe=e=>{let t=e.allowNext,n=e.next;return a.createElement(JY.d,{"data-external-id":"next-button",content:!t&&"Download, print, or copy your recovery codes before continuing."},a.createElement("div",null,a.createElement(cu.WT,{onClick:n,disabled:!t},"Next")))},WEe=(0,u.default)(Rc.L).withConfig({displayName:"SaveRecoveryCodesMfaModal__StyledModalCard",componentId:"sc-1g6uui5-0"})(["width:570px;"]),jEe=(0,u.default)(m.g).withConfig({displayName:"SaveRecoveryCodesMfaModal__Root",componentId:"sc-1g6uui5-1"})([""]),HEe=(0,u.default)(xt.v).withConfig({displayName:"SaveRecoveryCodesMfaModal__Body",componentId:"sc-1g6uui5-2"})(["margin-bottom:",";"],(e=>e.theme.spacing.xxlarge)),KEe=(0,u.default)(cl.M).withConfig({displayName:"SaveRecoveryCodesMfaModal__StyledLink",componentId:"sc-1g6uui5-3"})(["font-weight:",";"],(e=>e.theme.fontWeight.book)),qEe=Ee.J8U,$Ee=e=>{let t=e.onComplete;return a.createElement(h7.n,{"data-external-id":"enable-mfa-flow",steps:[mEe,FEe,SEe],onComplete:t})};var ZEe=n(5055);const JEe=e=>{var t;let n=e.provider,l=e.providerLabel,r=e.onClick,o=e.disabled,i=e.disableTooltip;return a.createElement(JY.d,{"data-external-id":"provider-auth-button",content:"Create a password and update your email to disconnect from ".concat((0,EA.ZH)(n)," login."),place:"top",disable:!!i},a.createElement("div",null,a.createElement(Wb.X,{disabled:o,icon:null===(t=ZEe.A[n])||void 0===t?void 0:t.call(ZEe.A),endIcon:a.createElement(fe.sOb,null),onClick:r},"".concat(l," is connected"))))},XEe=u.default.div.withConfig({displayName:"UpdateEmailFormModal__FormContainer",componentId:"sc-141ny1k-0"})(["margin:",";"],(e=>e.theme.spacing.xlarge)),QEe=(0,u.default)(xt.v).withConfig({displayName:"UpdateEmailFormModal__StyledText",componentId:"sc-141ny1k-1"})(["display:block;margin-top:",";"],(e=>e.theme.spacing.default)),eye=e=>{let t=e.next;e.goBack;return a.createElement(Rc.L,{"data-external-id":"edit-email-modal",title:"Change Email"},a.createElement(Eu.lV,{initialValues:{new_email:"",confirm_new_email:"",current_password:""},onSubmit:async e=>{let n=e.new_email,a=e.current_password;await(0,rEe.q)(r7.F).createEmailUpdateVerification(n,a),t({newEmail:n,currentPassword:a})}},a.createElement(XEe,{className:"flex flex-col gap-default"},a.createElement(QEe,null,"Your email will not change until you've verified the new email with a code."),a.createElement(Qw.X,{name:"new_email",email:!0,label:"New email",required:!0,autoComplete:"new-email"}),a.createElement(Qw.X,{name:"confirm_new_email",label:"Confirm new email",sameAs:"new_email",email:!0,required:!0,autoComplete:"confirm-new-email"}),a.createElement(cEe.S,{name:"current_password",label:"Current password",required:!0,autoComplete:"current-password"})),a.createElement(Cq.R,null,a.createElement(wve.j,null),a.createElement(CJ.I,{size:"small"},"Save"))))},tye=e=>{let t=e.newEmail,n=e.next;return a.createElement(Rc.L,{"data-external-id":"update-email-verification-modal",title:"Verify your email"},a.createElement(Eu.lV,{initialValues:{code:""},onSubmit:async e=>{let a=e.code;await(0,rEe.q)(r7.F).verifyNewEmail({newEmail:t,code:a}),n()}},a.createElement("div",{className:"m-xl"},a.createElement(xt.v,{className:"my-default block"},"We just sent a 6-digit code to ",t,", enter it below:"),a.createElement(tC.zB.OTP,{name:"code",label:"Code",required:!0}),a.createElement(xt.v,{className:"my-default block"},"Don't see a code?"," ",a.createElement(cl.M,{className:"font-book",onClick:async()=>{await(0,rEe.q)(r7.F).resendEmailUpdateVerification(),(0,C.oR)({title:"Verify your email",description:"A new verification code was sent to ".concat(t),dismissable:!0})}},"Resend to email."))),a.createElement(Cq.R,null,a.createElement(wve.j,null),a.createElement(CJ.I,{size:"small"},"Save"))))},nye=e=>{let t=e.onComplete;return a.createElement(h7.n,{"data-external-id":"update-email-flow",steps:[eye,tye],onComplete:t})};var aye=n(86269);const lye=e=>{let t=e.supportAccountAccessGrant,n=e.toggleSupportAccountAccess,l=e.isTogglingSupportAccountAccess;const r=(0,Qm.Eo)().openContactSupportModal,o=(0,Qhe.x)("account-access");return a.createElement("div",Object.assign({"data-external-id":"support-settings-card-content"},o),a.createElement(rye,{title:a.createElement(oye,null,"Account access"),subtitle:a.createElement(iye,null,a.createElement("span",null,"To better help troubleshoot your issues, you may grant full account access to Monarch authorized support agents. Access will auto-disable after 14 days, or can be revoked by you at any time."),a.createElement("span",null,"If you haven't already, you may also"," ",a.createElement(wb.gz,{onClick:()=>r()},"create a new support ticket"),"."),(0,Tr.A)(t)&&a.createElement(xt.v,{color:"greenText",italic:!0},"Access granted"," ",(0,Ba.AO)(t.createdAt),". Expires"," ",(0,Ba.AO)(t.expiresAt),".")),rightAccessory:a.createElement(sye,null,a.createElement(Wb.X,{onClick:()=>!l&&n(!t),isLoading:l},t?"Revoke access":"Grant access")),borderless:!0}))},rye=(0,u.default)(aye.Nx).withConfig({displayName:"SupportSettingsCardContent__Root",componentId:"sc-1qqq8tz-0"})(["padding:",";[data-sc-tw~='FieldCell__GroupHorizontalContainer']{align-items:flex-start;}"],(e=>e.theme.spacing.xlarge)),oye=u.default.span.withConfig({displayName:"SupportSettingsCardContent__Title",componentId:"sc-1qqq8tz-1"})(["font-size:",";font-weight:",";"],(e=>e.theme.fontSize.base),(e=>e.theme.fontWeight.medium)),iye=(0,u.default)(m.g).attrs({gap:"default",marginTop:"xxsmall",column:!0}).withConfig({displayName:"SupportSettingsCardContent__Subtitle",componentId:"sc-1qqq8tz-2"})([""]),sye=(0,u.default)(m.g).attrs({justifyEnd:!0}).withConfig({displayName:"SupportSettingsCardContent__ButtonContainer",componentId:"sc-1qqq8tz-3"})(["min-width:140px;"]);var cye=n(95364);
1const dye=()=>{var e,t,n,r,s,c,u,m;const p=(0,l.Zp)(),g=(0,d.wA)(),h=(0,Tse._)(),v=h.isDemoHousehold,f=h.blockActionForDemoHousehold,E=(0,et.I)(vye),y=E.data,b=E.refetch,x=E.isLoadingInitialData,w=E.isNetworkRequestInFlight,A=null!==(e=null===y||void 0===y?void 0:y.me)&&void 0!==e?e:{},k=A.email,S=A.hasMfaOn,N=A.hasPassword,T=A.externalAuthProviders,_=void 0===T?[]:T,D=A.pendingEmailUpdateVerification,R=void 0===D?{email:null}:D,M=(0,a.useState)(!1),L=(0,o.A)(M,2),O=L[0],B=L[1],z=(0,a.useState)(!1),F=(0,o.A)(z,2),G=F[0],Y=F[1],U=(0,a.useState)(!1),V=(0,o.A)(U,2),W=V[0],j=V[1],H=(0,a.useState)(!1),K=(0,o.A)(H,2),q=K[0],$=K[1],Z=(0,a.useState)(!1),J=(0,o.A)(Z,2),X=J[0],Q=J[1],ee=(0,a.useState)(!1),te=(0,o.A)(ee,2),ne=te[0],ae=te[1],le=(0,a.useState)(!1),re=(0,o.A)(le,2),oe=re[0],ie=re[1],se=(0,Pd.h)(),ce=(0,o.A)(se,2),de=ce[0],ue=ce[1],me=ue.open,pe=ue.close,ge=(0,Pd.h)(),he=(0,o.A)(ge,2),ve=he[0],fe=he[1],Ee=fe.open,ye=fe.close;(0,a.useEffect)((()=>{G||b()}),[G,b]);const be=e=>{Q(!0)},xe=(null===R||void 0===R?void 0:R.email)||null,we=!N&&!xe,Ce=_.length>0,Ae=(0,cye.l)(_.map((e=>e.provider))),Ie=null===(t=_[0])||void 0===t?void 0:t.provider,ke=null===(n=_[0])||void 0===n?void 0:n.email,Se=ke===k,Ne=(0,nj.A)(null,["userDiscordData"],y),Te=(0,Tr.A)(Ne),_e=(0,i.n)(Eye,{onCompleted:()=>{(0,C.oR)({title:"Discord account disconnected successfully",description:"You can reconnect your Discord account anytime through the Monarch Lab server."}),b()}}),De=(0,o.A)(_e,2),Re=De[0],Me=De[1].loading,Le=null===y||void 0===y||null===(r=y.me)||void 0===r?void 0:r.activeSupportAccountAccessGrant,Oe=(0,i.n)(fye,{onCompleted:()=>b()}),Pe=(0,o.A)(Oe,2),Be=Pe[0],ze=Pe[1].loading,Fe=(0,d.d4)(FY.vS),Ge=(0,Qhe.x)("external-email"),Ye=(0,Qhe.x)("email"),Ue=(0,Qhe.x)("password"),Ve=(0,Qhe.x)("recovery-codes"),We=(0,Qhe.x)("delete-household"),je=(0,Qhe.x)("discord"),He=(0,P6.f)(),Ke=He.isLoading,qe=He.isSubscriptionActive,$e=He.willCancelAtPeriodEnd,Ze=He.trialEndsAt,Je=He.trialDurationDays,Xe=He.isTrialing,Qe=He.plusTrialEndsAt,tt=!!Qe&&(null!==(s=(0,Q8.sX)(Qe))&&void 0!==s?s:0)>0?Qe:Ze,nt=Xe&&null!==(c=null!==(u=(0,Q8.sX)(tt))&&void 0!==u?u:Je)&&void 0!==c?c:0,at=qe&&!$e,lt=at||Ke,rt=(0,Pd.h)(),ot=(0,o.A)(rt,2),it=ot[0],st=ot[1],ct=st.open,dt=st.close,ut=(0,Pd.h)(),mt=(0,o.A)(ut,2),pt=mt[0],gt=mt[1],ht=gt.open,vt=gt.close;return a.createElement(mX.V,{"data-external-id":"security-settings",md:9},a.createElement(Xhe.Ay,null,a.createElement("title",null,"Security Settings")),a.createElement(gye,{title:"Email & Password",anchorId:"email-password",loading:x,isDemo:v},Ce&&!Se&&a.createElement($fe,Ge,a.createElement("span",null,a.createElement(Zfe,{title:"Email",description:a.createElement("div",{className:"flex items-center gap-xs"},ke,a.createElement(Oc.D,{color:"green"},"Verified"))})),Ce&&Ie&&a.createElement(JEe,{providerLabel:Ae[0],provider:Ie,disableTooltip:!0,onClick:()=>be()}),R&&a.createElement(Wb.X,{onClick:()=>f((()=>j(!0)),!1)},"Verify email")),a.createElement(mye,Ye,a.createElement("div",null,a.createElement(Zfe,{title:"Email",description:a.createElement("div",{className:"flex items-center gap-xs"},xe||k,xe?a.createElement(Oc.D,{color:"orange"},"Not verified"):a.createElement(Oc.D,{color:"green"},"Verified"))})),a.createElement("div",null,a.createElement("div",{className:"flex items-center gap-sm"},a.createElement(Wb.X,{disabled:we,onClick:()=>f((()=>Y(!0)),!1)},"Edit email"),Ce&&Ie&&Se&&a.createElement(JEe,{providerLabel:Ae[0],provider:Ie,disabled:!N||!!xe||Se,onClick:()=>be()}),R&&a.createElement(Wb.X,{onClick:()=>f((()=>j(!0)),!1)},"Verify email")))),ne&&a.createElement(pye,{type:"success"},"Check your email for instructions to create a Monarch account password."),a.createElement($fe,Ue,N?a.createElement(a.Fragment,null,a.createElement("span",null,a.createElement(Zfe,{title:"Password",description:"Click the button to change your password"})),a.createElement("span",null,a.createElement(Wb.X,{onClick:()=>f((()=>Ee()),!1)},"Edit password"))):a.createElement(a.Fragment,null,a.createElement("span",null,a.createElement(Zfe,{title:"Create password",description:Ce&&Ie?"Currently using Log in with ".concat((0,EA.ZH)(Ie)):"Click the button to create a password"})),a.createElement("span",null,a.createElement(Wb.X,{className:"w-full",isLoading:oe,onClick:()=>f((async()=>{ie(!0),g((0,C7.MZ)()),ie(!1),ae(!0)}),!1)},"Create Password"))))),N&&a.createElement(gye,{title:"Multi-Factor Authentication",anchorId:"multi-factor-authentication",loading:x,isDemo:v},a.createElement($fe,null,a.createElement("span",null,a.createElement(Zfe,{title:a.createElement("div",{className:"flex items-center gap-xs"},"Multi-Factor Authentication",S?a.createElement(Oc.D,{color:"green"},"Enabled"):a.createElement(Oc.D,{color:"orange"},"Disabled")),description:"Protect your Monarch account with an extra security step"})),a.createElement("span",null,S?a.createElement(Wb.X,{onClick:()=>$(!0)},"Disable"):a.createElement(Wb.X,{onClick:()=>f((()=>B(!0)),!1)}
1,"Enable MFA"))),S&&a.createElement($fe,Ve,a.createElement("span",{style:{paddingRight:"48px"}},a.createElement(Zfe,{title:"Recovery Codes",description:"Recovery codes are used to access your account in the event you lose access to your device and cannot receive two-factor authentication codes."}),a.createElement(uye,{size:"small"},"Save your recovery codes in a safe place to keep access to your account. Monarch Support cannot restore access to accounts with two-factor authentication enabled for security reasons.")),a.createElement("span",{style:{alignSelf:"flex-start"}},a.createElement(Wb.X,{onClick:me},"Codes"))),a.createElement(de,null,a.createElement(FEe,{onDone:pe})),a.createElement(ve,null,a.createElement(dEe,{onDone:ye,onCancel:ye})),q&&a.createElement(um.b,{onClose:()=>$(!1)},(e=>{let t=e.close;return a.createElement(aEe,{onCancel:t,onDisable:()=>{t(),b()}})})),X&&a.createElement(um.b,{onClose:()=>Q(!1)},(e=>{let t=e.close;return a.createElement(sEe,{provider:Ie,providerLabel:Ae[0],providerEmail:ke,onCancel:t,onDisconnect:()=>{t(),b()}})})),O&&a.createElement(um.b,{onClose:()=>B(!1)},(e=>{let t=e.close;return a.createElement($Ee,{onComplete:()=>{t(),b()}})})),G&&a.createElement(um.b,{onClose:()=>Y(!1)},(e=>{let t=e.close;return a.createElement(nye,{onComplete:()=>{t(),b()}})})),W&&a.createElement(um.b,{onClose:()=>j(!1)},(e=>{let t=e.close;return a.createElement(tye,{newEmail:xe,next:()=>{t(),b()}})}))),a.createElement(gye,{title:"Customer Support",anchorId:"customer-support",loading:x,isDemo:v},a.createElement(lye,{supportAccountAccessGrant:Le,toggleSupportAccountAccess:e=>{Be({variables:{isEnabled:e}})},isTogglingSupportAccountAccess:!x&&(ze||w)})),Fe&&a.createElement(gye,{title:"Account Data",anchorId:"account-data"},a.createElement($fe,We,a.createElement("span",null,a.createElement(Zfe,{title:_t.A1,description:"".concat(_t.vE).concat(at?" ".concat(_t.oF):"")})),a.createElement(Wb.X,{disabled:lt,onClick:()=>f((null!==nt&&void 0!==nt?nt:0)>0?ct:ht,!1)},_t.A1))),a.createElement(it,null,a.createElement(eEe,{onCancel:dt,onConfirm:ht,daysLeftOfTrial:nt})),a.createElement(pt,null,a.createElement(Qfe.a,{onCancel:vt})),Te&&a.createElement(gye,{title:"Integrations",anchorId:"integrations"},a.createElement($fe,je,a.createElement("span",null,a.createElement(Zfe,{title:a.createElement("div",{className:"flex items-center gap-xs"},a.createElement("span",null,"Discord"),Ne&&a.createElement(P.D_,{content:"Your Discord username",place:"top"},a.createElement(hye,null,"(Connected as @",Ne.username,")"))),description:a.createElement("div",{className:"flex flex-col gap-xs"},a.createElement("span",null,"Connect your Discord account to your Monarch account to be able to participate in beta testing."),(null===Ne||void 0===Ne||null===(m=Ne.roles)||void 0===m?void 0:m.length)>0&&a.createElement("div",{className:"flex items-center gap-xs"},"Your current roles:"," ",null===Ne||void 0===Ne?void 0:Ne.roles.map((e=>a.createElement(Oc.D,{color:"Verified Member"===e?"orange":"grayLight",key:e,variant:"subtle"},e)))))})),a.createElement("span",null,Ne?a.createElement(Wb.X,{isLoading:Me,onClick:()=>Re()},"Disconnect"):a.createElement(Wb.X,{onClick:()=>p(I.JZ.discord.startOAuth2Connection())},"Connect")))))},uye=(0,u.default)(xt.v).withConfig({displayName:"SecuritySettings__StyledText",componentId:"r92gm3-0"})(["display:block;margin:-"," 0 "," 0;padding-top:",";"],(e=>e.theme.spacing.xsmall),(e=>e.theme.spacing.default),(e=>e.theme.spacing.xlarge)),mye=(0,u.default)($fe).withConfig({displayName:"SecuritySettings__StyledSettingsSection",componentId:"r92gm3-1"})(["flex-wrap:wrap;row-gap:",";"],(e=>e.theme.spacing.small)),pye=(0,u.default)(fu.g).withConfig({displayName:"SecuritySettings__StyledBanner",componentId:"r92gm3-2"})(["margin:"," "," 0 ",";font-size:",";+ [data-sc-tw~='SettingsSection__SettingsSection']{padding-top:",";}"],(e=>e.theme.spacing.default),(e=>e.theme.spacing.xlarge),(e=>e.theme.spacing.xlarge),(e=>e.theme.fontSize.small),(e=>e.theme.spacing.default)),gye=(0,u.default)(Ffe).withConfig({displayName:"SecuritySettings__StyledSettingsCard",componentId:"r92gm3-3"})(["margin-bottom:",";"],(e=>e.theme.spacing.gutter)),hye=u.default.div.withConfig({displayName:"SecuritySettings__DiscordDescription",componentId:"r92gm3-4"})(["font-size:",";color:",";cursor:default;font-weight:",";"],vt.J.small,vt.Ee.color.content.secondary,vt.Wy.book),vye=Ee.eSX,fye=Ee.RJ9,Eye=Ee.P1n,yye=()=>a.createElement(rG.Y,{"data-external-id":"advisor-security",name:"Security",parentRoute:null},a.createElement(Xhe.Ay,null,a.createElement("title",null,"Professional Portal | Security")),a.createElement(bye,null,a.createElement(dye,null))),bye=u.default.div.withConfig({displayName:"AdvisorSecurity__Container",componentId:"valq52-0"})(["display:flex;flex-direction:column;align-items:center;padding:",";padding-bottom:0;> *{width:640px;margin-bottom:",";}"],(e=>e.theme.spacing.xxlarge),(e=>e.theme.spacing.large)),xye=e=>{let t=e.goal,n=e.isLoading;const l=null!==t&&void 0!==t?t:{},r=l.priority,o=l.plannedMonthlyContribution,i=l.plannedMonthlyPretaxContribution,s=l.startingAmount,c=l.targetAmount,d=l.currentAmount,u=l.type,g=void 0===u?"":u,h=l.objective,v=g===bl.IW.Debt,f=h===bl.$X.Retirement;return a.createElement(a.Fragment,null,a.createElement(fe.xz6,null,a.createElement(fe.xz6.Header,{className:"justify-between px-xl"},a.createElement(fe.xz6.Title,null,"Details")),a.createElement(fe.xz6.Content,{className:"gap-default p-xl"},n?a.createElement(m.g,{justifyCenter:!0,alignCenter:!0},a.createElement(p.i,null)):a.createElement(a.Fragment,null,a.createElement(wye,{title:"Goal type",subtitle:yl.Jz[g]}),v?a.createElement(wye,{title:"Starting balance",subtitle:(0,rl.vv)(-1*(null!==s&&void 0!==s?s:0))}):a.createElement(wye,{title:"Target amount",subtitle:(0,rl.vv)(c)}),a.createElement(wye,{title:"Amount left",subtitle:(0,rl.vv)((null!==c&&void 0!==c?c:0)-(null!==d&&void 0!==d?d:0))}),f&&a.createElement(wye,{title:"Pre-paycheck contribution",subtitle:Cye(i)}),a.createElement(wye,{title:f?"Post-paycheck contribution":"Budget 
1contribution",subtitle:Cye(o)}),a.createElement(wye,{title:"Goal priority",subtitle:"#".concat(r)})))))},wye=e=>{let t=e.title,n=e.subtitle;const l=(0,a.useId)();return a.createElement(m.g,{"data-external-id":"detail-row",justifyBetween:!0,alignCenter:!0},a.createElement(xt.v,{size:"small",color:"content.secondary",id:l},t),a.createElement(xt.v,{"aria-labelledby":l},n))},Cye=e=>"".concat((0,rl.T3)(null!==e&&void 0!==e?e:0)," / mo.");var Aye=n(91581),Iye=n(1582);const kye=u.default.span.withConfig({displayName:"AccountMask__Root",componentId:"w4lj1s-0"})(["color:",";"],vt.yW.textLight),Sye="goal-account-balance-row-large",Nye=e=>{var t,n;let l=e.data,r=e.goalType,o=e.large,i=e.className;const s=l.account,c=l.currentAmount,d=l.currentMonthChange,u=s.subtype,m=s.displayName,p=s.icon,g=s.logoUrl,h=s.hideFromList||s.deactivatedAt;return a.createElement(Tye,{"data-external-id":"goal-account-balance-row",className:(0,q.cn)(i,o&&Sye)},a.createElement(Gl.v,{icon:p,logoUrl:g,size:o?48:24}),a.createElement(_ye,null,a.createElement("div",{className:"flex items-center"},a.createElement(Dye,{clampLines:1},m),h&&a.createElement(Oye,null)),a.createElement(Rye,{clampLines:1},null!==(t=null===u||void 0===u?void 0:u.display)&&void 0!==t?t:""," ",a.createElement(Mye,{account:s,fallbackToSubtype:!1}))),a.createElement("div",{className:"flex flex-col items-end"},a.createElement(Lye,{value:(0,yl.kD)(c,r)}),a.createElement(El.H,{className:"mt-3xs",percentChange:(null!==(n=null===d||void 0===d?void 0:d.percent)&&void 0!==n?n:0)/lie.I6,startAmount:0,endAmount:(0,yl.kD)(null===d||void 0===d?void 0:d.amount,r),isAsset:r!==bl.IW.Debt})))},Tye=(0,u.default)(m.g).withConfig({displayName:"GoalAccountBalanceRow__Root",componentId:"ug7fqr-0"})(["padding:"," ",";transition:",";:hover{background-color:",";}&.","{padding:",";}"],(e=>e.theme.spacing.default),(e=>e.theme.spacing.xlarge),(e=>e.theme.transition.default),(e=>e.theme.color.grayBackground),Sye,(e=>e.theme.spacing.xlarge)),_ye=(0,u.default)(m.g).attrs({column:!0}).withConfig({displayName:"GoalAccountBalanceRow__TitleContainer",componentId:"ug7fqr-1"})(["flex:1;margin-right:",";margin-left:",";overflow:hidden;."," &{margin-left:",";}"],(e=>e.theme.spacing.default),(e=>e.theme.spacing.xsmall),Sye,(e=>e.theme.spacing.default)),Dye=(0,u.default)(xt.v).withConfig({displayName:"GoalAccountBalanceRow__Title",componentId:"ug7fqr-2"})(["."," &{font-size:",";}"],Sye,(e=>e.theme.fontSize.large)),Rye=(0,u.default)(xt.v).attrs({size:"small",color:"textLight"}).withConfig({displayName:"GoalAccountBalanceRow__Subtitle",componentId:"ug7fqr-3"})(["margin-top:",";"],(e=>e.theme.spacing.xxsmall)),Mye=(0,u.default)((e=>{let t=e.account,n=t.mask,l=t.subtype.display,r=e.fallbackToSubtype,o=void 0===r||r,i=e.className;return a.createElement(kye,{"data-external-id":"account-mask",className:i},a.createElement("span",fl.TN,n?[(0,Iye.A)("\u2022 ",4),n]:o?l:""))})).withConfig({displayName:"GoalAccountBalanceRow__StyledAccountMask",componentId:"ug7fqr-4"})(["margin-left:",";"],(e=>e.theme.spacing.xxsmall)),Lye=(0,u.default)(hl.t).withConfig({displayName:"GoalAccountBalanceRow__StyledCurrency",componentId:"ug7fqr-5"})(["."," &{font-size:",";}"],Sye,(e=>e.theme.fontSize.large)),Oye=(0,u.default)(sl.ZQ).attrs({name:"eye-off",size:14}).withConfig({displayName:"GoalAccountBalanceRow__HiddenAccountIcon",componentId:"ug7fqr-6"})(["margin-left:",";"],(e=>e.theme.spacing.small));Nye.fragments={WebGoalAccountBalanceRowFields:Ee.ONx};const Pye=e=>{let t=e.goal,n=e.isLoading,r=e.large;const i=null!==t&&void 0!==t?t:{},s=i.accountAllocations,c=i.defaultName,d=i.type,u=void 0===d?"":d,m=i.id,g=void 0===m?"":m,h=(0,a.useMemo)((()=>(0,yl.SM)(null!==s&&void 0!==s?s:[])),[s]),v=(0,Pd.h)(),f=(0,o.A)(v,2),E=f[0],y=f[1],b=y.open,x=y.close;return a.createElement(a.Fragment,null,a.createElement(Xl.AM,{title:"Balances",controls:!n&&null!==s&&void 0!==s&&s.length?a.createElement(El.H,{className:"text-sm font-medium",startAmount:0,endAmount:(0,yl.kD)(h,u),timeframeDisplay:"this month",isAsset:u!==bl.IW.Debt}):void 0},a.createElement(Ul.w,null,a.createElement(Ul.d,{when:n},a.createElement(p.i,{className:"m-xl self-center"})),a.createElement(Ul.d,{when:!(null!==s&&void 0!==s&&s.length)},a.createElement(cU.vx,{title:(0,yl.hs)(c||""),subtitle:bl.IW.Debt?_t.lR.BALANCES.EMPTY.DEBT:_t.lR.BALANCES.EMPTY.ASSET,button:{title:"Edit accounts",onClick:b}})),a.createElement(Ul.d,{default:!0},null===s||void 0===s?void 0:s.map(((e,t)=>a.createElement(wb.gz,{key:e.id,as:l.k2,to:I.JZ.accounts.accountDetails({id:e.account.id}),unstyled:!0},a.createElement(Bye,{data:e,goalType:u,$topBorder:0!==t,large:r}))))))),a.createElement(E,null,a.createElement(Aye.P,{goalId:g,onClickDone:x})))},Bye=(0,u.default)(Nye).withConfig({displayName:"GoalBalancesCard__StyledGoalAccountBalanceRow",componentId:"sc-9fzcka-0"})(["",""],(e=>e.$topBorder&&(0,u.css)(["border-top:1px solid ",";"],(e=>
1e.theme.color.grayBackground))));Pye.fragments={WebGoalBalancesCardFields:Ee.yVk};var zye=n(7103);const Fye=e=>{let t=e.goal,n=e.right;const l=t.name,r=t.archivedAt,o=t.completedAt,i=t.defaultName,s=(0,yl.We)(t);return a.createElement(Gye,{"data-external-id":"goal-name-progress-bar"},(0,yl.PQ)(t)?a.createElement(m.g,{column:!0},a.createElement(Yye,null,l),a.createElement(Vye,null,(0,yl.hs)(i||""))):a.createElement(a.Fragment,null,a.createElement(m.g,{alignEnd:!0,justifyBetween:!0},a.createElement(m.g,{column:!0},a.createElement(Yye,null,l),a.createElement(Uye,{value:(0,yl.e3)(t)})),r||o?a.createElement(m.g,{alignCenter:!0},a.createElement(fe.cyv,{size:12,className:"text-content-white"}),a.createElement(Wye,null,r?"Archived":"Completed")):n),a.createElement(fe.cqk,{value:s,max:1,color:"content-white",trackBgColor:"overlay-secondary-7",size:"sm",className:"mt-xs"})))},Gye=(0,u.default)(m.g).attrs({column:!0}).withConfig({displayName:"GoalNameProgressBar__Root",componentId:"b4wh19-0"})(["position:relative;flex:1;"]),Yye=(0,u.default)(xt.v).attrs({weight:"bold",size:"xsmall"}).withConfig({displayName:"GoalNameProgressBar__Title",componentId:"b4wh19-1"})(["color:",";margin-bottom:",";"],(e=>e.theme.color.textWhite),(e=>e.theme.spacing.xxxsmall)),Uye=(0,u.default)(hl.t).withConfig({displayName:"GoalNameProgressBar__Balance",componentId:"b4wh19-2"})(["color:",";text-transform:uppercase;margin-bottom:",";font-weight:",";font-size:",";line-height:150%;"],(e=>e.theme.color.textWhite),(e=>e.theme.spacing.xsmall),(e=>e.theme.fontWeight.medium),(e=>e.theme.fontSize.xlarge)),Vye=(0,u.default)(xt.v).attrs({weight:"medium",size:"xlarge"}).withConfig({displayName:"GoalNameProgressBar__SetupLabel",componentId:"b4wh19-3"})(["margin-top:",";color:",";"],(e=>e.theme.spacing.xsmall),(e=>e.theme.color.textWhite)),Wye=(0,u.default)(xt.v).attrs({weight:"medium",size:"xsmall"}).withConfig({displayName:"GoalNameProgressBar__StatusText",componentId:"b4wh19-4"})(["color:",";margin-left:6px;"],(e=>e.theme.color.textWhite));Fye.fragments={WebGoalNameProgressBarFields:Ee.Il5};const jye=e=>{let t=e.goal,n=e.imageSize,l=void 0===n?"medium":n,r=e.right,o=e.className;const i=t.imageStorageProvider,s=t.imageStorageProviderId,c=t.archivedAt,d=t.accountAllocations,u=(0,a.useMemo)((()=>d.map((e=>e.account))),[d]);return a.createElement(Hye,{"data-external-id":"goal-card",className:o},a.createElement(Kye,{size:l,showGradient:!0,imageStorageProvider:i,imageStorageProviderId:s,archived:!!c}),a.createElement(Fye,{goal:t,right:null!==r&&void 0!==r?r:a.createElement(qye,{accounts:u})}))},Hye=u.default.div.withConfig({displayName:"GoalCard__Root",componentId:"sc-1wf271x-0"})(["background-color:white;border-radius:",";"," flex:1;overflow:hidden;position:relative;padding:",";display:flex;align-items:flex-end;"],(e=>e.theme.radius.medium),wn.M.medium,(e=>e.theme.spacing.xlarge)),Kye=(0,u.default)(vl.b).withConfig({displayName:"GoalCard__StyledGoalImage",componentId:"sc-1wf271x-1"})([""]),qye=(0,u.default)(zye.B).withConfig({displayName:"GoalCard__StyledAccountLogosGroup",componentId:"sc-1wf271x-2"})(["margin-bottom:",";"],(e=>e.theme.spacing.small));jye.fragments={WebGoalCardFields:Ee.xS$};const $ye=24,Zye=e=>{let t=e.goal;const n=t.plannedMonthlyContribution,l=(0,u.useTheme)(),r=(0,qd.W)(),i=(0,o.A)(r,2),s=i[0],c=i[1].width,d=(void 0===c?0:c)-48,m=(0,a.useMemo)((()=>{const e=Math.floor((d-2*PU.g_)/90);return(0,yl.Qd)(t.monthlyContributionSummaries,e)}),[t,d]),p=(0,a.useMemo)((()=>(0,yl.Ou)(m).range),[m]),g=(0,a.useMemo)((()=>[Math.min(0,-p[0]),Math.max(1,null!==n&&void 0!==n?n:0,p[1])]),[p,n]),h=(0,a.useMemo)((()=>m.map((e=>(0,U.A)((0,U.A)({},e),{},{label:(0,Ba.tF)(N.c9.fromISO(e.month),N.c9.local())?(0,rl.T3)(e.sum):"",placeholder:e.sumCredit||e.sumDebit?void 0:.07*g[1]})))),[m,g]),v=g[0]<0,f=(0,a.useMemo)((()=>(0,EJ.uu)(m.map((e=>({startDate:e.month}))))),[m]);return a.createElement(Jye,{"data-external-id":"goal-contribution-graph",ref:s},a.createElement(Xye,null,a.createElement(PU.vD,{data:h,heightPx:200,widthPx:d,barWidthPx:60,minBarWidthPx:60,xAxisDataKey:"month",labelDataKey:"label",totalDataKey:v?"sum":void 0,formatXAxis:Ba.jY,formatYAxis:rl.T3,xAxisReferenceLines:f,barDataKeys:[{name:"sumDebit",color:l.color.red},{name:"sumCredit",color:l.color.green},{name:"placeholder",color:l.color.gray}
1],hideGrid:!0,roundBarCorners:!0,yAxis:a.createElement(wa.h,{domain:g,axisLine:!1,tick:!1}),yAxisReferenceLines:n?[{y:0,labels:[]},{y:n,labels:["Budget",(0,rl.T3)(n)],dashed:!0}]:void 0,xAxisProps:{height:57,axisLine:!1,tickLine:!1,tick:e=>{let t=e.x,n=e.y;const r=e.payload.value,o=m[r],i=o.month,s=o.sumCredit,c=o.plannedAmount;return a.createElement("g",{transform:"translate(".concat(t,",").concat(n,")")},a.createElement("text",{x:0,y:0,fill:l.color.textLight,fontWeight:l.fontWeight.medium,fontSize:l.fontSize.small},a.createElement("tspan",{dy:"16",textAnchor:"middle"},(0,Ba.jY)(i))),a.createElement(Ul.w,null,a.createElement(Ul.d,{when:s>0},a.createElement(fe.cyv,{className:"text-chart-fill-green",x:"".concat(-12),y:"30",size:24})),a.createElement(Ul.d,{when:!!c},a.createElement(fe.C14,{className:"text-chart-fill-gray",x:"".concat(-12),y:"30",size:24})),a.createElement(Ul.d,{default:!0},a.createElement("circle",{cx:"0",cy:"42",r:"".concat(4),fill:l.color.gray}))))}},tooltipComponent:e=>{const t=e.active,n=(0,_a.WS)(e);if(!n)return null;const r=n.month,o=n.sumCredit,i=n.sumDebit,s=n.sum;return a.createElement(Sa.II,{active:t,header:(0,Ba.Rc)(r)},a.createElement(Na.B,{label:"Contributions",value:a.createElement(hl.t,{value:o}),dotFillColor:l.color.green}),a.createElement(Na.B,{label:"Deductions",value:a.createElement(hl.t,{value:i}),dotFillColor:l.color.red}),a.createElement(Na.B,{label:"Total",value:a.createElement(hl.t,{value:s}),strokeColor:l.color.gray}))}})))},Jye=u.default.div.withConfig({displayName:"GoalContributionGraph__Root",componentId:"sc-1jeu0ug-0"})(["position:relative;height:","px;"],248),Xye=u.default.div.withConfig({displayName:"GoalContributionGraph__Container",componentId:"sc-1jeu0ug-1"})(["position:absolute;top:","px;left:","px;right:","px;bottom:","px;"],$ye,$ye,$ye,$ye);Zye.fragments={WebGoalContributionGraphFields:Ee.jBC};const Qye=e=>{let t=e.goal,n=e.isLoading;return a.createElement(Xl.AM,{"data-external-id":"goal-contributions-card",title:"Contributions"},n&&a.createElement(p.i,{className:"m-xl self-center"}),t&&a.createElement(Zye,{goal:t}))};var ebe=n(6848);const tbe=()=>{const e=(0,Sq.k)().close,t=(0,et.I)(nbe,{variables:{startDate:N.c9.local().startOf("month").minus({months:bl.Sx}).toISODate(),endDate:N.c9.local().startOf("month").toISODate()}}).data;return a.createElement(Rc.L,{"data-external-id":"monthly-budget-goals-modal",title:_t.lR.MONTHLY_BUDGETS.TITLE,description:_t.lR.MONTHLY_BUDGETS.SUBTITLE,hideBottomBorder:!0},a.createElement(ebe.s,{data:t}),a.createElement(Cq.R,null,a.createElement(cu.WT,{onClick:e},"Done")))},nbe=Ee.eNC;var abe=n(11406);const lbe=()=>{const e=(0,Sq.k)().close;return a.createElement(Rc.L,{"data-external-id":"pre-tax-budget-goals-modal",title:_t.lR.PRE_TAX_BUDGETS.TITLE,description:_t.lR.PRE_TAX_BUDGETS.SUBTITLE,hideBottomBorder:!0},a.createElement(m.g,{full:!0},a.createElement(abe.s,null)),a.createElement(Cq.R,null,a.createElement(cu.WT,{onClick:e},"Done")))};var rbe=n(89294);const obe=()=>{const e=(0,Sq.k)().close;return a.createElement(Rc.L,{"data-external-id":"rank-goals-modal",title:_t.lR.RANK_GOALS.TITLE,description:_t.lR.RANK_GOALS.SUBTITLE},a.createElement(ibe,null,a.createElement(rbe.Z,null)),a.createElement(Cq.R,null,a.createElement(cu.WT,{onClick:e},"Done")))},ibe=(0,u.default)(m.g).withConfig({displayName:"RankGoalsModal__Container",componentId:"sc-1of69dv-0"})(["padding:",";width:100%;"],(e=>e.theme.spacing.xlarge));var sbe=n(20387);const cbe=e=>{const t=(0,Sq.k)().close;return a.createElement(Rc.L,{"data-external-id":"target-amounts-modal",title:e.useStartingAmount?_t.lR.STARTING_AMOUNTS.TITLE:_t.lR.TARGET_AMOUNTS.TITLE,description:e.useStartingAmount?_t.lR.STARTING_AMOUNTS.SUBTITLE:_t.lR.TARGET_AMOUNTS.SUBTITLE,hideBottomBorder:!0},a.createElement(m.g,{full:!0},a.createElement(sbe.X,e)),a.createElement(Cq.R,null,a.createElement(cu.WT,{onClick:t},"Done")))},dbe=e=>{let t=e.goal,n=e.isLoading;const l=null!==t&&void 0!==t?t:{},r=l.priority,i=l.plannedMonthlyContribution,s=l.plannedMonthlyPretaxContribution,c=l.startingAmount,d=l.targetAmount,u=l.type,m=void 0===u?"":u,g=l.objective,h=m===bl.IW.Debt,v=g===bl.$X.Retirement,f=(0,Pd.h)(),E=(0,o.A)(f,2),y=E[0],b=E[1].open,x=(0,Pd.h)(),w=(0,o.A)(x,2),C=w[0],A=w[1].open,I=(0,Pd.h)(),k=(0,o.A)(I,2),S=k[0],N=k[1].open,T=(0,Pd.h)(),_=(0,o.A)(T,2),D=_[0],R=_[1].open,M=(0,Pd.h)(),L=(0,o.A)(M,2),O=L[0],P=L[1].open;return a.createElement(a.Fragment,null,a.createElement(Xl.AM,{title:"Details"},n?a.createElement(p.i,{className:"m-xl self-center"}):a.createElement(a.Fragment,null,a.createElement(mbe,{title:"Goal priority",subtitle:"#".concat(r),onClick:b}),v&&a.createElement(mbe,{title:"Pre-paycheck contributions",subtitle:null===s?"Set your budget":"".concat((0,rl.T3)(s),"/mo"),onClick:R}),a.createElement(mbe,{title:v?"Post-paycheck contributions":"Budget 
1contributions",subtitle:null===i?"Set your budget":"".concat((0,rl.T3)(i),"/mo"),onClick:N}),h?a.createElement(mbe,{title:"Starting balance",subtitle:(0,rl.T3)(-1*(null!==c&&void 0!==c?c:0)),onClick:P}):a.createElement(mbe,{title:"Target amount",subtitle:null===d?"Set your target":(0,rl.T3)(d),onClick:A}))),a.createElement(y,null,a.createElement(obe,null)),a.createElement(C,null,a.createElement(cbe,{restrictToGoalId:null===t||void 0===t?void 0:t.id})),a.createElement(S,null,a.createElement(tbe,null)),a.createElement(D,null,a.createElement(lbe,null)),a.createElement(O,null,a.createElement(cbe,{restrictToGoalId:null===t||void 0===t?void 0:t.id,useStartingAmount:!0})))},ube=(0,u.default)(xt.v).withConfig({displayName:"GoalDetailsCard__Subtitle",componentId:"sc-1oorthp-0"})(["color:",";font-size:",";margin-top:",";"],(e=>e.theme.color.textLight),(e=>e.theme.fontSize.small),(e=>e.theme.spacing.xxsmall)),mbe=(0,u.default)((e=>{let t=e.title,n=e.subtitle,l=e.onClick,r=e.className;return a.createElement(m.g,{alignCenter:!0,justifyBetween:!0,className:r,onClick:l},a.createElement(m.g,{column:!0},a.createElement(xt.v,null,t),a.createElement(ube,null,n)),a.createElement(sl.ZQ,{name:"chevron-right",size:16}))})).withConfig({displayName:"GoalDetailsCard__DetailRow",componentId:"sc-1oorthp-1"})(["padding:"," ",";cursor:pointer;transition:all ",";:not(:last-child){border-bottom:1px solid ",";}:last-child{border-bottom-left-radius:",";border-bottom-right-radius:",";}:hover{background:",";}"],(e=>e.theme.spacing.default),(e=>e.theme.spacing.xlarge),(e=>e.theme.transition.default),vt.Ee.color.divider.primary,(e=>e.theme.radius.medium),(e=>e.theme.radius.medium),(e=>e.theme.color.grayBackground));dbe.fragments={WebGoalDetailsCardFields:Ee.xvc};var pbe=n(17206);const gbe="".concat(72,"px"),hbe=e=>{let t=e.goal,n=e.variant,l=void 0===n?"table":n;const r=t.imageStorageProvider,o=t.imageStorageProviderId,i=(0,pbe.b)({imageStorageProvider:r,imageStorageProviderId:o,size:"small"}),s=t.type===bl.IW.Debt,c=(0,yl.GC)(t),d=(0,yl.e3)(t),u=(0,yl.We)(t),m=Math.round(100*u),p=100===m&&u<1?parseFloat((100*u).toFixed(2)):m,g=!(0,BY.A)(t.completedAt);return a.createElement("div",{"data-external-id":"goal-summary-card",className:"flex items-center gap-default p-xl"},"table"===l&&a.createElement("div",{className:"flex overflow-hidden rounded-sm",style:{width:gbe,height:gbe}},a.createElement("img",{src:i,alt:t.name,className:"size-full object-cover"})),t.archivedAt?a.createElement("div",{className:"flex flex-1 flex-col"},a.createElement(xt.v,{size:"large"},t.name),a.createElement(xt.v,{size:"small",color:"content.secondary",weight:"medium"},"Archived ",(0,Ba.z9)(N.c9.fromISO(t.archivedAt)))):a.createElement("div",{className:"flex flex-1 flex-col gap-sm"},a.createElement("div",{className:"flex flex-col"},a.createElement("div",{className:"flex justify-between"},a.createElement("div",{className:"flex items-center gap-xs"},a.createElement(xt.v,"header"===l?{size:"20",weight:"medium"}:{size:"large"},t.name),"table"===l&&a.createElement(zye.B,{size:16,accounts:t.accountAllocations.map((e=>e.account)),maxDisplayCount:10})),a.createElement(xt.v,"header"===l?{size:"20",weight:"medium"}:{size:"large"},(0,rl.vv)(d))),a.createElement("div",{className:"flex justify-between text-content-secondary"},a.createElement("div",{className:"flex items-center gap-xs"},g&&a.createElement(a.Fragment,null,a.createElement(xt.v,{size:"small",color:"content.success",weight:"medium"},"Complete"),a.createElement("div",{className:"flex rounded-sm bg-divider-secondary",style:{width:"1px",height:"16px"}})),a.createElement(xt.v,"header"===l?{size:"base"}:{size:"small"},"Priority #",t.priority)),a.createElement(xt.v,"header"===l?{size:"base"}:{size:"small"},s?"Paid off":"Saved"," ",p,"% of ",(0,rl.vv)(c)))),a.createElement("div",{className:"flex"},a.createElement(fe.cqk,{value:p,color:"progress-success"}))))};var vbe=n(60412),fbe=n(28102);const Ebe=e=>{let t=e.goal;const n=t.imageStorageProvider,l=t.imageStorageProviderId,r=(0,Pd.h)(),i=(0,o.A)(r,2),s=i[0],c=i[1],d=c.open,u=c.close,m=(0,fbe.S)(t).updateGoal,p=(0,pbe.b)({imageStorageProvider:n,imageStorageProviderId:l,size:"large"});return a.createElement(a.Fragment,null,a.createElement(ybe,{padding:"xlarge",position:"relative",$backgroundImage:p,borderRadius:"default",column:!0,justifyBetween:!0,alignEnd:!0},a.createElement(wt.Xb,{onClick:d},"Customize image"),a.createElement(fe.xz6,{className:"w-full"},a.createElement(hbe,{goal:t,variant:"header"}))),a.createElement(s,null,a.createElement(vbe.n,{GoalImage:vl.b,onSelect:e=>{m({imageStorageProvider:"unsplash",imageStorageProviderId:e.urls.raw})},onClose:u})))},ybe=(0,u.default)(m.g).withConfig({displayName:"GoalProgressCardFacelift__Root",componentId:"as5hal-0"})(["background-image:url(",");background-size:cover;background-position:center;background-repeat:no-repeat;height:400px;width:100%;"," & > button{transition:",";opacity:0;}&:hover{& > button{opacity:1;}}"],(e=>e.$backgroundImage),wn.M.medium,(e=>e.theme.transition.default)),bbe=e=>{let t=e.goalId,n=e.goalName;const l=(0,a.useMemo)((()=>({goalId:t,transactionVisibility:Ee.h1.ALL_TRANSACTIONS})),[t]);return a.createElement(Xl.AM,{"data-external-id":"goal-transactions-card",title:"Transactions"},a.createElement(kQ.j,{hideHeader:!0,allowBulkUpdate:!1,transactionFilters:l,emptyComponent:a.createElement(cU.vx,{title:"No transactions",subtitle:"No transactions have been linked to ".concat(null!==n&&void 0!==n?n:"this goal"," yet.")})}))};var xbe=n(37060);const wbe=e=>{const t=(0,i.n)(Cbe,e),n=(0,o.A)(t,2),l=n[0],r=n[1];return[(0,a.useCallback)((e=>l({variables:{input:{id:e}},optimisticResponse:{__typename:"Mutation",archiveGoal:{__typename:"ArchiveGoal",goal:{__typename:"GoalV2",id:e,archivedAt:N.c9.local().toISO()},errors:null}}})),[l]),r]},Cbe=(0,Qt.J)("\n  mutation Common_ArchiveGoal($input: ArchiveGoalInput!) {\n    archiveGoal(input: $input) {\n      goal {\n        id\n        archivedAt\n      }\n      errors {\n        ...PayloadErrorFields\n      }\n    }\n  }\n");var Abe=n(44272);const Ibe=()=>{const e=(0,i.n)(kbe),t=(0,o.A)(e,2),n=t[0],l=t[1];return[(0,a.useCallback)((e=>n({variables:{input:{id:e}},optimisticResponse:{__typename:"Mutation",markGoalComplete:{__typename:"MarkGoalComplete",goal:{__typename:"GoalV2",id:e,completedAt:N.c9.local().toISO()},errors:null}}})),[n]),l]}
1,kbe=(0,Qt.J)("\n  mutation Common_MarkGoalComplete($input: MarkGoalCompleteInput!) {\n    markGoalComplete(input: $input) {\n      goal {\n        id\n        completedAt\n      }\n      errors {\n        ...PayloadErrorFields\n      }\n    }\n  }\n"),Sbe=()=>{const e=(0,i.n)(Nbe),t=(0,o.A)(e,2),n=t[0],l=t[1];return[(0,a.useCallback)((e=>n({variables:{input:{id:e}},optimisticResponse:{__typename:"Mutation",markGoalIncomplete:{__typename:"MarkGoalIncomplete",goal:{__typename:"GoalV2",id:e,completedAt:null},errors:null}}})),[n]),l]},Nbe=(0,Qt.J)("\n  mutation Common_MarkGoalIncomplete($input: MarkGoalIncompleteInput!) {\n    markGoalIncomplete(input: $input) {\n      goal {\n        id\n        completedAt\n      }\n      errors {\n        ...PayloadErrorFields\n      }\n    }\n  }\n"),Tbe=()=>{const e=(0,i.n)(_be),t=(0,o.A)(e,2),n=t[0],l=t[1];return[(0,a.useCallback)((e=>n({variables:{input:{id:e}},optimisticResponse:{__typename:"Mutation",unarchiveGoal:{__typename:"UnarchiveGoal",goal:{__typename:"GoalV2",id:e,archivedAt:null},errors:null}}})),[n]),l]},_be=(0,Qt.J)("\n  mutation Common_UnarchiveGoal($input: UnarchiveGoalInput!) {\n    unarchiveGoal(input: $input) {\n      goal {\n        id\n        archivedAt\n      }\n      errors {\n        ...PayloadErrorFields\n      }\n    }\n  }\n"),Dbe=e=>{let t=e.goal;const n=null!==t&&void 0!==t?t:{},r=n.completedAt,i=n.archivedAt,s=n.id,c=(0,l.Zp)(),d=(0,Pd.h)(),u=(0,o.A)(d,2),m=u[0],p=u[1],g=p.open,h=p.close,v=(0,Pd.h)(),f=(0,o.A)(v,2),E=f[0],y=f[1],b=y.open,x=y.close,w=(0,Pd.h)(),C=(0,o.A)(w,2),A=C[0],k=C[1],S=k.open,N=k.close,T=(0,Pd.h)(),_=(0,o.A)(T,2),D=_[0],R=_[1].open,M=wbe({onCompleted:N}),L=(0,o.A)(M,2),O=L[0],P=L[1].loading,B=Tbe(),z=(0,o.A)(B,1)[0],F=Ibe(),G=(0,o.A)(F,1)[0],Y=Sbe(),U=(0,o.A)(Y,1)[0],V=(0,Abe.g)({onCompleted:()=>{x(),c(I.JZ.goalsV2())}}),W=(0,o.A)(V,2),j=W[0],H=W[1].loading,K=!!t&&(0,yl.PQ)(t),q=Boolean(!r&&!i&&!K),$=Boolean(r&&!i&&!K),Z=Boolean(!i&&!K),J=Boolean(i&&!K);return a.createElement(a.Fragment,null,a.createElement(uU.f,null,a.createElement(Qi.Az,{overlay:a.createElement(Ji.SP,null,a.createElement(Ji.xm,{onClick:g},"Edit accounts"),q&&a.createElement(Ji.xm,{onClick:()=>G(s)},"Mark as complete"),$&&a.createElement(Ji.xm,{onClick:()=>U(s)},"Mark as incomplete"),Z&&a.createElement(Ji.xm,{onClick:S},"Archive goal"),J&&a.createElement(Ji.xm,{onClick:()=>z(s)},"Unarchive goal"),a.createElement(Ji.xm,{type:"danger",onClick:b},"Delete goal")),placement:"bottom-end"},(e=>{let t=e.toggleOpen,n=e.isOpen;return a.createElement(Rbe,{onClick:t,active:n},"Actions ",a.createElement(Yo.r,{name:"chevron-down"}))})),a.createElement(cu.WT,{onClick:R},"Customize goal")),a.createElement(m,null,a.createElement(Aye.P,{goalId:s,onClickDone:h})),a.createElement(E,null,a.createElement(xC.$,{title:_t.lR.DELETE_CONFIRMATION.TITLE,confirm:"Delete",useDangerButton:!0,onCancel:x,onConfirm:()=>j(s),isLoading:H},_t.lR.DELETE_CONFIRMATION.DESCRIPTION)),a.createElement(A,null,a.createElement(xC.$,{title:_t.lR.ARCHIVE_CONFIRMATION.TITLE,confirm:"Archive",useDangerButton:!0,onCancel:N,onConfirm:()=>O(s),isLoading:P},_t.lR.ARCHIVE_CONFIRMATION.DESCRIPTION)),a.createElement(D,null,a.createElement(xbe.O,{data:t})))},Rbe=(0,u.default)(wt.Xb).attrs({size:"small"}).withConfig({displayName:"GoalDetailControls__OptionsButton",componentId:"sc-11d7x4j-0"})(["position:relative;padding-right:",";"],(e=>e.theme.spacing.xxsmall)),Mbe=e=>{let t=e.onConfirm,n=e.onDiscard,l=e.onCancel,r=e.isLoading;return a.createElement(Rc.L,{"data-external-id":"goal-settings-unsaved-changes-confirmation",title:"Unsaved changes",role:"alertdialog"},a.createElement(qY.S,null,"You\u2019ve made changes which have not been saved. Would you like to save those changes before continuing?"),a.createElement(Cq.R,{justifyBetween:!0},a.createElement(wt.Xb,{onClick:l,disabled:r},"Cancel"),a.createElement(m.g,{alignCenter:!0},a.createElement(wt.Xb,{onClick:n,disabled:r},a.createElement(xt.v,{color:"content.danger"},"Discard changes")),a.createElement(cu.gs,{onClick:t,pending:r},"Save changes"))))},Lbe=e=>{let t=e.data,n=e.onSuccess;const l=(0,Sq.k)().close,i=t.name,s=t.imageStorageProvider,c=t.imageStorageProviderId,d=t.targetAmount,u=t.startingAmount,m=t.plannedMonthlyContribution,p=t.plannedMonthlyPretaxContribution,g=(0,a.useState)(!1),h=(0,o.A)(g,2),v=h[0],f=h[1],E=(0,Pd.h)(),y=(0,o.A)(E,2),b=y[0],x=y[1],w=x.open,C=x.close,A=(0,Pd.h)(),I=(0,o.A)(A,2),k=I[0],S=I[1].open,N=(0,Pd.h)(),T=(0,o.A)(N,2),_=T[0],D=T[1],R=D.open,M=D.close,L=(0,fbe.S)(t).updateGoal,O=e=>{let t=e.dirty;return()=>{t?R():S()}}
1,P=async e=>{const t=Object.fromEntries(Object.entries(e).filter((e=>{let t=(0,o.A)(e,2),n=(t[0],t[1]);return null!==n&&void 0!==n})).map((e=>(0,r.YW)(e).with(["startingAmount",r.P.number],(e=>{let t=(0,o.A)(e,2);return[t[0],-1*t[1]]})).otherwise((()=>e)))));await L(t),null===n||void 0===n||n(t)};return a.createElement(Rc.L,{"data-external-id":"goal-settings-modal-card",title:i},a.createElement(Eu.lV,{initialValues:{name:i,targetAmount:d,startingAmount:(0,BY.A)(u)?void 0:Math.abs(u),plannedMonthlyContribution:m,plannedMonthlyPretaxContribution:p},onSubmit:e=>{P(e),l()}},a.createElement(Obe,null,a.createElement(zbe,null,a.createElement(Bbe,{imageStorageProvider:s,imageStorageProviderId:c,size:"large",showGradient:!1}),a.createElement(Fbe,{onClick:w},a.createElement(Yo.r,{name:"edit"}),a.createElement("span",null,"Customize image"))),a.createElement("div",{className:"mb-default flex flex-col gap-default"},a.createElement(Qw.X,{name:"name",label:"Name"}),(0,r.YW)(t).with({objective:bl.$X.Retirement},(()=>a.createElement(a.Fragment,null,a.createElement(tC.zB.Currency,{name:"targetAmount",label:"Target amount"}),a.createElement(tC.zB.Currency,{name:"plannedMonthlyPretaxContribution",label:a.createElement(xt.v,null,"Pre-paycheck contributions"," ",a.createElement(xt.v,{color:"content.secondary",weight:"book"},"(monthly)")),info:"This will be added to your goal to help you track your pre-paycheck contributions."}),a.createElement(tC.zB.Currency,{name:"plannedMonthlyContribution",label:a.createElement(xt.v,null,"Post-paycheck contributions"," ",a.createElement(xt.v,{color:"content.secondary",weight:"book"},"(monthly)")),description:a.createElement(xt.v,{size:"small"},"Set up your post-paycheck contributions alongside your"," ",a.createElement(hu.c.Consumer,null,(e=>{let t=e.dirty;return a.createElement(Pbe,{onClick:O({dirty:t})},"goal contributions")})),"."),disabled:!0})))).with({type:bl.IW.Asset},(()=>a.createElement(tC.zB.Currency,{name:"targetAmount",label:"Target amount"}))).with({type:bl.IW.Debt},(()=>a.createElement(tC.zB.Currency,{name:"startingAmount",label:"Starting balance"}))).otherwise((()=>null)))),a.createElement(Cq.R,null,a.createElement(wt.Xb,{size:"small",onClick:l},"Cancel"),a.createElement(hu.c.Consumer,null,(e=>{let t=e.submitForm,n=e.dirty;return a.createElement(cu.WT,{size:"small",onClick:()=>{n?t():l()},disabled:!n&&!v},"Save")}))),a.createElement(hu.c.Consumer,null,(e=>{let t=e.isSubmitting,n=e.values;return a.createElement(_,null,a.createElement(Mbe,{onDiscard:()=>{M(),S()},onConfirm:()=>{P(n),M(),S()},onCancel:M,isLoading:t}))}))),a.createElement(b,null,a.createElement(vbe.n,{GoalImage:vl.b,onSelect:e=>{L({imageStorageProvider:"unsplash",imageStorageProviderId:e.urls.raw}),f(!0)},onClose:C})),a.createElement(k,null,a.createElement(tbe,null)))},Obe=u.default.div.withConfig({displayName:"GoalSettingsModalCard__FormContainer",componentId:"ow8gpx-0"})(["margin:",";"],(e=>e.theme.spacing.xlarge)),Pbe=(0,u.default)(bn.v).withConfig({displayName:"GoalSettingsModalCard__StyledTextButton",componentId:"ow8gpx-1"})(["display:inline;padding:0;"]),Bbe=(0,u.default)(vl.b).withConfig({displayName:"GoalSettingsModalCard__StyledGoalImage",componentId:"ow8gpx-2"})(["width:100%;max-width:100%;max-height:","px;position:relative;aspect-ratio:2.14;"],238),zbe=u.default.div.withConfig({displayName:"GoalSettingsModalCard__ImageContainer",componentId:"ow8gpx-3"})(["position:relative;margin-bottom:",";min-height:238px;"],(e=>e.theme.spacing.xlarge)),Fbe=(0,u.default)(wt.Xb).withConfig({displayName:"GoalSettingsModalCard__CustomizeImageButton",componentId:"ow8gpx-4"})(["position:absolute;bottom:",";right:",";"],(e=>e.theme.spacing.default),(e=>e.theme.spacing.default));Lbe.fragments={WebGoalSettingsModalCardFields:Ee.vai};const Gbe=e=>{let t=e.goal;const n=null!==t&&void 0!==t?t:{},r=n.completedAt,i=n.archivedAt,s=n.id,c=(0,l.Zp)(),d=(0,Pd.h)(),u=(0,o.A)(d,2),m=u[0],p=u[1],g=p.open,h=p.close,v=(0,Pd.h)(),f=(0,o.A)(v,2),E=f[0],y=f[1],b=y.open,x=y.close,w=(0,Pd.h)(),C=(0,o.A)(w,2),A=C[0],k=C[1],S=k.open,N=k.close,T=(0,Pd.h)(),_=(0,o.A)(T,2),D=_[0],R=_[1].open,M=(0,Pd.h)(),L=(0,o.A)(M,2),O=L[0],P=L[1].open,B=(0,Pd.h)(),z=(0,o.A)(B,2),F=z[0],G=z[1].open,Y=wbe({onCompleted:N}),U=(0,o.A)(Y,2),V=U[0],W=U[1].loading,j=Tbe(),H=(0,o.A)(j,1)[0],K=Ibe(
1),q=(0,o.A)(K,1)[0],$=Sbe(),Z=(0,o.A)($,1)[0],J=(0,Abe.g)({onCompleted:()=>{x(),c(I.JZ.goalsV2())}}),X=(0,o.A)(J,2),Q=X[0],ee=X[1].loading,te=!!t&&(0,yl.PQ)(t),ne=Boolean(!r&&!i&&!te),ae=Boolean(r&&!i&&!te),le=Boolean(!i&&!te),re=Boolean(i&&!te);return a.createElement(a.Fragment,null,a.createElement(uU.f,null,a.createElement(Qi.Az,{overlay:a.createElement(Ji.SP,null,a.createElement(Ji.xm,{onClick:R},"Goal settings"),a.createElement(Ji.NM,null),a.createElement(Ji.xm,{onClick:g},"Edit accounts"),a.createElement(Ji.xm,{onClick:P},"Edit goal priorities"),a.createElement(Ji.xm,{onClick:G},"Edit contributions"),a.createElement(Ji.NM,null),ne&&a.createElement(Ji.xm,{onClick:()=>q(s)},"Mark as complete"),ae&&a.createElement(Ji.xm,{onClick:()=>Z(s)},"Mark as incomplete"),le&&a.createElement(Ji.xm,{onClick:S},"Archive goal"),re&&a.createElement(Ji.xm,{onClick:()=>H(s)},"Unarchive goal"),a.createElement(Ji.xm,{type:"danger",onClick:b},"Delete goal")),placement:"bottom-end"},(e=>{let t=e.toggleOpen,n=e.isOpen;return a.createElement(wt.Xb,{size:"small",onClick:t,active:n},a.createElement(Yo.r,{name:"settings"}),a.createElement("span",null,"Manage"))}))),a.createElement(m,null,a.createElement(Aye.P,{goalId:s,onClickDone:h})),a.createElement(E,null,a.createElement(xC.$,{title:_t.lR.DELETE_CONFIRMATION.TITLE,confirm:"Delete",useDangerButton:!0,onCancel:x,onConfirm:()=>Q(s),isLoading:ee},_t.lR.DELETE_CONFIRMATION.DESCRIPTION)),a.createElement(A,null,a.createElement(xC.$,{title:_t.lR.ARCHIVE_CONFIRMATION.TITLE,confirm:"Archive",useDangerButton:!0,onCancel:N,onConfirm:()=>V(s),isLoading:W},_t.lR.ARCHIVE_CONFIRMATION.DESCRIPTION)),a.createElement(D,null,a.createElement(Lbe,{data:t})),a.createElement(O,null,a.createElement(obe,null)),a.createElement(F,null,a.createElement(tbe,null)))};var Ybe,Ube,Vbe,Wbe=n(85115);const jbe=()=>{var e;const t=(0,lV.L)().id,n=(0,Wbe.C)({id:"GoalV2:".concat(t),fragment:jye.fragments.WebGoalCardFields,fragmentName:"WebGoalCardFields"}),r=(0,et.I)(Zbe,{variables:{goalId:t}}),o=r.data,i=r.isLoadingInitialData,s=(null!==o&&void 0!==o?o:{}).goalV2,c=null!==(e=null!==s&&void 0!==s?s:n)&&void 0!==e?e:{},d=c.imageStorageProvider,u=c.imageStorageProviderId,m=null===s||void 0===s?void 0:s.newGoalId,p=null!==s&&void 0!==s?s:n,g=!!s&&(0,yl.Pb)(s),h=(0,nG.p)("feat-goals-facelift-web_mobile","off"),v=h?Gbe:Dbe,f=h?Ebe:qbe,E=h?xye:dbe,y=(0,R3.F)(),b=y.isOn,x=y.canToggleVersions,w=(0,l.Zp)();return(0,a.useEffect)((()=>{b&&m&&!x&&w(I.JZ.goals.savings.detail({id:m}),{replace:!0})}),[b,w,m,x]),a.createElement(rG.Y,{"data-external-id":"goal-details-v2",name:"Goal Details",parentRoute:"Goals",overrideTitle:null===p||void 0===p?void 0:p.name,icon:a.createElement(Kbe,{imageStorageProvider:d,imageStorageProviderId:u}),controls:p?a.createElement(v,{goal:p}):void 0},a.createElement(rV.T,{screenName:"Goal Details"}),a.createElement(Hbe,{template:'"image image" "list summary" / 1fr 30%',md:'"image" "summary" "list"'},a.createElement(QU.E,{area:"image"},p&&a.createElement(f,{goal:p})),a.createElement($be,{area:"list"},g?a.createElement(Pye,{large:!0,goal:s,isLoading:i}):a.createElement(a.Fragment,null,a.createElement(Qye,{goal:s,isLoading:i}),a.createElement(bbe,{goalId:t,goalName:null===p||void 0===p?void 0:p.name}))),a.createElement($be,{area:"summary"},!g&&a.createElement(Pye,{goal:s,isLoading:i}),a.createElement(E,{goal:s,isLoading:i}))))},Hbe=(0,$d.s)(QU.a)(Ybe||(Ybe=(0,wc.A)(["pt-0"]))),Kbe=(0,u.default)(vl.b).attrs({showGradient:!1,size:"small"}).withConfig({displayName:"GoalDetailsV2__SmallGoalImage",componentId:"sc-7rzwqg-0"})(["width:24px;height:24px;border-radius:",";position:relative;"],(e=>e.theme.radius.xsmall)),qbe=(0,$d.s)((e=>{let t=e.goal,n=e.className;const l=t.type===bl.IW.Debt,r=(0,yl.We)(t),o=(0,yl.GC)(t);return a.createElement(jye,{"data-external-id":"goal-progress-card",className:n,goal:t,imageSize:"large",right:a.createElement("div",{className:"flex flex-col items-end"},!l&&a.createElement(kD.c,{size:"sm",weight:"medium",color:"white",className:"mt-2xs text-right"},(0,rl.is)((0,yl.UV)(t))," left to save"),a.createElement(kD.c,{size:"base",weight:"medium",color:"white",className:"mt-2xs mb-xs text-right"},l?"Paid off ":"Saved ",(0,De.gj)(r)," of ",(0,rl.T3)(o)))})}))(Ube||(Ube=(0,wc.A)(["h-78"]))),$be=(0,$d.s)(QU.E)(Vbe||(Vbe=(0,wc.A)(["[&>*:not(:last-child)]:mb-(--grid-spacing)"]))),Zbe=Ee.dgf;var Jbe,Xbe,Qbe,exe=n(27470),txe=n(93302);const nxe=e=>{var t,n;let l=e.account;const r=(0,Pc.e)(!1),i=(0,o.A)(r,2),s=i[0],c=i[1],d=(0,De.Ym)(l.goals.reduce(((e,t)=>{var n;return e+(null!==(n=t.accountAllocation.currentAmount)&&void 0!==n?n:0)}),0)),u=(0,De.Ym)((null!==(t=l.currentBalance)&&void 0!==t?t:0)-d),m=u<0,p=l.goals.filter((e=>{var t;return(null!==(t=e.accountAllocation.currentAmount)&&void 0!==t?t:0)>0}));return 0===p.length?null:a.createElement("div",{"data-external-id":"goals-allocation-card-row",className:"flex flex-col"},a.createElement("div",{className:"flex items-center gap-xs pr-2xs"},a.createElement("div",{className:"-ml-2xs flex items-center gap-2xs"},a.createElement(B.L,{icon:s?"chevron-down":"chevron-right",onClick:c.toggle,size:"xxsmall","aria-label":"Toggle ".concat(l.displayName," allocation")}
1),a.createElement(Gl.v,{logoUrl:l.logoUrl,size:24})),a.createElement("div",{className:"flex flex-1 items-center justify-between gap-2xs overflow-hidden"},a.createElement(xt.v,{clampLines:1},l.displayName),a.createElement(rxe,{"data-open":s,weight:"medium"},(0,rl.vv)(u)))),a.createElement(Ql.$,{open:s,onClosed:c.setOff},a.createElement("div",{className:"flex flex-col gap-sm pt-xs",style:{paddingLeft:"60px"}},a.createElement("div",{className:"flex items-center justify-between"},a.createElement(xt.v,{size:"small",id:"total-balance-".concat(l.id)},"Total balance"),a.createElement(xt.v,{"aria-labelledby":"total-balance-".concat(l.id),size:"small"},(0,rl.vv)(l.currentBalance))),p.length>0&&a.createElement(a.Fragment,null,a.createElement(z7.P,{text:"",height:"1px"}),a.createElement("div",{className:"flex flex-col gap-xs"},p.map((e=>{const t=e.imageStorageProvider,n=e.imageStorageProviderId,l=(0,pbe.b)({imageStorageProvider:t,imageStorageProviderId:n,size:"small",width:16});return a.createElement("div",{key:e.id,className:"flex justify-between"},a.createElement("div",{className:"flex items-center gap-xs overflow-hidden"},a.createElement(axe,null,a.createElement(lxe,{src:l})),a.createElement(xt.v,{size:"small",id:"goal-name-".concat(e.id),clampLines:1},e.name)),a.createElement(xt.v,{size:"small","aria-labelledby":"goal-name-".concat(e.id)},(0,rl.vv)(e.accountAllocation.currentAmount)))}))),a.createElement(z7.P,{text:"",height:"1px"})),a.createElement("div",{className:"flex items-center justify-between"},a.createElement(xt.v,{as:"span",size:"small",id:"available-label-".concat(l.id),weight:"medium"},"Available"),a.createElement(xt.v,{size:"small",as:"span",weight:"medium","aria-labelledby":"available-label-".concat(l.id),color:m?"content.danger":"content.primary"},(0,rl.vv)((null!==(n=l.currentBalance)&&void 0!==n?n:0)-d))))),m&&a.createElement("div",{className:"flex w-full flex-col items-stretch pt-default pl-xl"},a.createElement("div",{className:"flex w-full flex-col items-stretch rounded-default bg-background-secondary px-default py-sm"},a.createElement(xt.v,{weight:"medium",size:"small"},"Account over-allocated"))))},axe=$d.s.div(Jbe||(Jbe=(0,wc.A)(["flex size-4 shrink-0 grow-0 overflow-hidden rounded-xs"]))),lxe=$d.s.img(Xbe||(Xbe=(0,wc.A)(["size-full object-cover"]))),rxe=(0,$d.s)(xt.v)(Qbe||(Qbe=(0,wc.A)(["opacity-0 transition-opacity data-[open=false]:opacity-100"]))),oxe=(0,a.createContext)(void 0),ixe=e=>{let t=e.refetchGoals,n=e.children;const l=(0,a.useState)("type"),r=(0,o.A)(l,2),i=r[0],s=r[1],c=(0,yu.X)(t),d=(0,a.useMemo)((()=>({groupBy:i,setGroupBy:s,refetchGoals:c})),[i,s,c]);return a.createElement(oxe.Provider,{"data-external-id":"goals-table-provider",value:d},n)},sxe=()=>{const e=(0,a.useContext)(oxe);if(!e)throw new Error("useGoalsTableContext must be used within a GoalsTableProvider");return e};var cxe,dxe,uxe,mxe;const pxe=e=>a.createElement(vxe,Object.assign({"data-external-id":"goals-table-root",gap:"gutter",paddingHorizontal:"gutter",paddingBottom:"xlarge"},e)),gxe=e=>a.createElement(m.g,Object.assign({"data-external-id":"goals-table-sections",column:!0,gap:"gutter",flex:2,minWidth:"0"},e)),hxe=e=>a.createElement(fxe,Object.assign({"data-external-id":"goals-table-card-container",column:!0,gap:"default",flex:1},e)),vxe=(0,u.default)(m.g).withConfig({displayName:"GoalsTableUI__Root",componentId:"sc-1khkf8q-0"})(["","{flex-direction:column-reverse;}"],Wo.J.md),fxe=(0,u.default)(m.g).withConfig({displayName:"GoalsTableUI__CardContainer",componentId:"sc-1khkf8q-1"})(["max-width:440px;overflow:visible;position:sticky;top:0;height:fit-content;max-height:calc(100vh - var(--app-header-height));min-height:0;","{position:relative;width:100%;max-width:100%;min-width:100%;max-height:none;}"],Wo.J.md),Exe=(0,$d.s)(fe.xz6.Header)(cxe||(cxe=(0,wc.A)(["gap-sm pr-xl pl-lg"]))),yxe=e=>a.createElement(m.g,Object.assign({"data-external-id":"goals-table-section-header-left",alignCenter:!0,gap:"xxsmall"},e)),bxe=e=>a.createElement(m.g,Object.assign({"data-external-id":"goals-table-section-header-right",flex:1,justifyEnd:!0},e)),xxe=e=>{const t=kxe(),n=t.isOpen,l=t.collapse;return a.createElement(Ql.$,Object.assign({"data-external-id":"goals-table-section-drawer",shouldAnimateOnMount:!1,open:n,onClosed:l},e))},wxe=(0,u.default)(B.L).attrs({size:"xsmall",icon:"chevron-right"}).withConfig({displayName:"GoalsTableUI__Toggle",componentId:"sc-1khkf8q-2"})(["transition:transform 0.2s ease-in-out;transform:rotate(",");"],(e=>
1e.$isOpen?"90deg":"0deg")),Cxe=e=>{const t=kxe(),n=t.isOpen,l=t.toggle,r=t.title;return a.createElement(wxe,Object.assign({"data-external-id":"goals-table-section-toggle",$isOpen:n,onClick:l,"aria-label":"Toggle ".concat(r)},e))},Axe=u.default.div.withConfig({displayName:"GoalsTableUI__GoalsTableSectionContent",componentId:"sc-1khkf8q-3"})(["border-bottom-left-radius:",";border-bottom-right-radius:",";overflow:hidden;"],vt.r8.medium,vt.r8.medium),Ixe=(0,a.createContext)(void 0),kxe=()=>{const e=(0,a.useContext)(Ixe);if(!e)throw new Error("useGoalsTableCardContext must be used within a GoalsTableCard");return e},Sxe=e=>{let t=e.children,n=e.defaultOpen,l=void 0===n||n,r=e.title;const i=(0,Pc.e)(l),s=(0,o.A)(i,2),c=s[0],d=s[1],u=(0,a.useMemo)((()=>({isOpen:c,toggle:d.toggle,collapse:d.setOff,title:r})),[c,d,r]);return a.createElement(Ixe.Provider,{"data-external-id":"goals-table-section-card",value:u},a.createElement(fe.xz6,{sticky:c},t))},Nxe=(0,$d.s)(fe.xz6.Header)(dxe||(dxe=(0,wc.A)(["flex-col gap-default p-default"]))),Txe=(0,$d.s)(fe.xz6.Content)(uxe||(uxe=(0,wc.A)(["min-h-0 flex-1 overflow-y-auto p-0"]))),_xe=(0,u.default)(m.g).attrs({column:!0}).withConfig({displayName:"GoalsTableUI__GoalsAllocationCardRowsContainer",componentId:"sc-1khkf8q-4"})(["& > *{padding:",";}& > *:not(:last-child){border-bottom:1px solid ",";}"],vt.YK.default,vt.Ee.color.divider.primary),Dxe=(0,$d.s)(fe.xz6.Footer)(mxe||(mxe=(0,wc.A)(["w-full flex-col items-stretch gap-sm"])));var Rxe=n(71078),Mxe=n(14063),Lxe=n(3771),Oxe=n(47829),Pxe=n(78584);const Bxe=e=>{let t=e.allocation;const n=t.account,l=n.id,r=n.availableBalanceForGoals,i=t.goal.id,s=t.currentAmount,c=t.id,d=(0,Oxe.L)(),u=(0,o.A)(d,1)[0];return a.createElement(zxe,{"data-external-id":"goal-allocation-amount-input",submitOnBlur:!0,onSubmit:e=>{const t=e.allocationAmount;t!==s&&u({id:c,goalId:i,accountId:l,availableBalanceForGoals:r,amount:null!==t&&void 0!==t?t:0})},initialValues:{allocationAmount:null!==s&&void 0!==s?s:void 0}},a.createElement(tC.zB,{name:"allocationAmount",label:null,className:(0,q.cn)(fl.TN.className,"min-w-0 flex-1")},(e=>{var t;return a.createElement(Mxe.K.Root,{value:null!==(t=e.value)&&void 0!==t?t:null,step:"any",min:0,onValueChange:t=>e.onChange(t),onBlur:e.onBlur},a.createElement(Lxe.i,{variant:"plain",invalid:e.invalid},a.createElement(Mxe.K.Input,{name:e.name,placeholder:"$0.00"})))})),!!r&&a.createElement(hu.c.Consumer,null,(e=>{let t=e.setFieldValue,n=e.submitForm;return a.createElement(Fxe,{size:"small",onClick:()=>{t("allocationAmount",(null!==s&&void 0!==s?s:0)+r),n()}},"Add ",(0,rl.vv)(r))})))},zxe=(0,u.default)(Eu.lV).withConfig({displayName:"GoalAllocationAmountInput__StyledForm",componentId:"sc-10751l5-0"})(["border:1px solid ",";display:flex;flex:1;border-radius:",";padding:5px;min-height:50px;:focus-within{","}"],(e=>e.theme.color.grayFocus),(e=>e.theme.radius.small),Pxe.Oe),Fxe=(0,u.default)(wt.Xb).withConfig({displayName:"GoalAllocationAmountInput__StyledDefaultButton",componentId:"sc-10751l5-1"})(["margin-left:auto;"]),Gxe=e=>{let t=e.onFinishAllocation,n=e.accounts,l=e.isLoading;const r=(0,u.useTheme)(),i=(0,a.useState)(0),s=(0,o.A)(i,2),c=s[0],d=s[1],g=(0,Sq.k)().close,h=n[c],v=(0,a.useRef)(!1);(0,a.useEffect)((()=>{n.length&&(v.current=!0),v.current&&!n.length&&g()}),[n.length,g]);const f=null!==h&&void 0!==h?h:{},E=f.goalAllocations,y=void 0===E?[]:E,b=f.displayName,x=f.displayBalance,w=f.availableBalanceForGoals,C=c===n.length-1,A=y.length>1,I=(0,Oxe.L)(),k=(0,o.A)(I,1)[0];return a.createElement(Yxe,{"data-external-id":"goals-allocate-balance-modal",hideBottomBorder:!0,hideHeader:!0},l?a.createElement(Xxe,null,a.createElement(p.i,null)):a.createElement(a.Fragment,null,a.createElement(Uxe,null,a.createElement(Wxe,null,"account ",c+1," of ",n.length),a.createElement(Vxe,null,_t.lR.ALLOCATE.TITLE),a.createElement(Qxe,{onClick:g,icon:"x"}),h&&a.createElement(m.g,null,a.createElement(Gl.v,{logoUrl:h.logoUrl,icon:h.icon,size:40}),a.createElement(Hxe,{alignStart:!0},a.createElement(xt.v,null,b),a.createElement(qxe,{$color:GX(null!==w&&void 0!==w?w:0,r)},(0,rl.vv)(w)," ",a.createElement(Kxe,{$color:r.color.textLight},"available")),!!w&&a.createElement(wt.Xb,{onClick:()=>
1{if(!y.length)return;const e=(null!==w&&void 0!==w?w:0)/y.length;y.forEach((t=>{let n=t.id,a=t.currentAmount,l=t.account.id,r=t.goal.id;k({id:n,goalId:r,accountId:l,availableBalanceForGoals:w,amount:(null!==a&&void 0!==a?a:0)+e})}))}},A?"Add to goals evenly":"Add to goal")),a.createElement(hl.t,{value:x||0}))),a.createElement(m.g,{column:!0},y.map((e=>a.createElement(jxe,{key:e.id},a.createElement($xe,{data:e.goal,showAccountLogos:!1}),a.createElement(Zxe,null,a.createElement(Bxe,{allocation:e})))))),a.createElement(Jxe,null,a.createElement(wt.Xb,{size:"small",onClick:g},"Cancel"),a.createElement(cu.WT,{size:"small",onClick:()=>{C?(t(),g()):d((e=>e+1))}},C?"Done":"Next"))))},Yxe=(0,u.default)(Rc.L).withConfig({displayName:"GoalsAllocateBalanceModal__StyledModalCard",componentId:"sc-1r03v1g-0"})(["padding:0;"]),Uxe=(0,u.default)(m.g).attrs({column:!0}).withConfig({displayName:"GoalsAllocateBalanceModal__Header",componentId:"sc-1r03v1g-1"})(["padding:",";border-bottom:1px solid ",";"],(e=>e.theme.spacing.xlarge),(e=>e.theme.color.grayBackground)),Vxe=(0,u.default)(xt.v).attrs({size:"large",weight:"medium"}).withConfig({displayName:"GoalsAllocateBalanceModal__Title",componentId:"sc-1r03v1g-2"})(["margin-bottom:",";"],(e=>e.theme.spacing.xlarge)),Wxe=(0,u.default)(xt.v).attrs({size:"xsmall",weight:"bold",color:"textLight"}).withConfig({displayName:"GoalsAllocateBalanceModal__SubHeader",componentId:"sc-1r03v1g-3"})(["text-transform:uppercase;"]),jxe=u.default.div.withConfig({displayName:"GoalsAllocateBalanceModal__GoalRow",componentId:"sc-1r03v1g-4"})([":not(:first-child){border-top:1px solid ",";}"],(e=>e.theme.color.grayBackground)),Hxe=(0,u.default)(m.g).attrs({column:!0}).withConfig({displayName:"GoalsAllocateBalanceModal__AccountTitleContainer",componentId:"sc-1r03v1g-5"})(["flex:1;margin:0 ",";"],(e=>e.theme.spacing.default)),Kxe=(0,u.default)(xt.v).attrs({size:"small",weight:"medium"}).withConfig({displayName:"GoalsAllocateBalanceModal__AccountSubtitleText",componentId:"sc-1r03v1g-6"})(["color:",";"],(e=>e.$color)),qxe=(0,u.default)(Kxe).withConfig({displayName:"GoalsAllocateBalanceModal__AccountSubtitle",componentId:"sc-1r03v1g-7"})(["margin-top:",";margin-bottom:",";"],(e=>e.theme.spacing.xxsmall),(e=>e.theme.spacing.small)),$xe=(0,u.default)(Rxe.a).withConfig({displayName:"GoalsAllocateBalanceModal__StyledGoalAccountsMapRow",componentId:"sc-1r03v1g-8"})(["padding:",";"],(e=>e.theme.spacing.xlarge)),Zxe=u.default.div.withConfig({displayName:"GoalsAllocateBalanceModal__AllocationInputContainer",componentId:"sc-1r03v1g-9"})(["padding:",";padding-top:0;"],(e=>e.theme.spacing.xlarge)),Jxe=(0,u.default)(Cq.R).withConfig({displayName:"GoalsAllocateBalanceModal__StyledCardFooter",componentId:"sc-1r03v1g-10"})(["margin-top:",";"],(e=>e.theme.spacing.xlarge)),Xxe=(0,u.default)(m.g).attrs({alignCenter:!0,justifyCenter:!0}).withConfig({displayName:"GoalsAllocateBalanceModal__LoadingWrapper",componentId:"sc-1r03v1g-11"})(["min-height:600px;"]),Qxe=(0,u.default)(B.L).attrs({size:"medium"}).withConfig({displayName:"GoalsAllocateBalanceModal__StyledIconButton",componentId:"sc-1r03v1g-12"})(["position:absolute;right:",";top:",";"],(e=>e.theme.spacing.default),(e=>e.theme.spacing.default));var ewe;Gxe.fragments={Web_GoalsAllocateBalanceModalFields:Ee.tUE};const twe=()=>a.createElement(p$.B,{"data-external-id":"goals-map-accounts-modal",initial:{component:nwe,props:{}}}),nwe=()=>{const e=(0,et.I)(lwe),t=e.data,n=e.isLoadingInitialData,l=e.error,o=(0,Sq.k)().close,i=(0,r$.j)(),s=i.push,c=i.pop,d=(0,a.useMemo)((()=>{var e;return(0,yl.Zk)(null!==(e=null===t||void 0===t?void 0:t.goalsV2)&&void 0!==e?e:[])}),[null===t||void 0===t?void 0:t.goalsV2]);return a.createElement(Rc.L,{"data-external-id":"goals-map-accounts-modal-initial",title:_t.lR.MAP_ACCOUNTS.TITLE,description:_t.lR.MAP_ACCOUNTS.SUBTITLE},(0,r.YW)({isLoadingInitialData:n,error:l}).with({isLoadingInitialData:!0},(()=>a.createElement("div",{className:"my-3xl flex items-center justify-center"},a.createElement(p.i,null)))).with({error:r.P.nonNullable},(()=>a.createElement(SQ.W,{message:VG.U.GOALS}))).otherwise((()=>a.createElement("div",{className:"flex flex-col"},d.map(((e,t)=>a.createElement(awe,{key:t},a.createElement(Rxe.a,{data:e,onClickAddAccounts:()=>{s(Aye.P,{goalId:e.id,onClickBackButton:c,onClickDone:c})}}))))))),a.createElement(Cq.R,null,a.createElement(cu.WT,{onClick:o},"Done")))},awe=$d.s.div(ewe||(ewe=(0,wc.A)(["flex w-full flex-col p-xl"]))),lwe=Ee.otP;var rwe,owe=n(63313);const iwe=e=>{var t,n;let l=e.goals;const i=(0,owe.zh)(l),s=(0,owe.mI)(i),c=(0,owe.FZ)(i)-s,d=(0,Pd.h)(),u=(0,o.A)(d,2),p=u[0],g=u[1].open,h=(0,Pd.h)(),v=(0,o.A)(h,2),f=v[0],E=v[1],y=E.open,b=E.isOpen,x=0===c,w=c<0,C=(0,r.YW)({allAllocated:x,overAllocated:w}).with({overAllocated:!0},(()=>"danger")).with({allAllocated:!0},(()=>"secondary")).otherwise((()=>"success")),A=sxe().refetchGoals,I=Object.keys(i),k=(0,et.I)(cwe,{skip:!I.length||!b,variables:{filters:(0,iZ.V)({ids:I})}}),S=(0,sU.A)(((e,t)=>I.indexOf(e.id)-I.indexOf(t.id)),null!==(t=null===(n=k.data)||void 0===n?void 0:n.accounts)&&void 0!==t?t:[]);return a.createElement(fe.xz6,{"data-external-id":"goals-allocation-card",role:"article",className:"max-h-full min-h-0"},a.createElement(Nxe,null,a.createElement(m.g,Object.assign({width:"100%",borderRadius:"small",center:!0,paddingVertical:"large",column:!0,gap:"xxxsmall"},(0,r.YW)({allAllocated:x,overAllocated:w}).with({allAllocated:!0},(()=>({backgroundColor:"background.secondary",color:"content.secondary"}))).with({overAllocated:!0},(()=>({backgroundColor:"background.danger",color:"content.danger"}))).otherwise((()=>({backgroundColor:"background.success",color:"content.success"})))),a.createElement(xt.v,{size:"xxlarge",weight:"medium","aria-labelledby":"available-to-allocate"},(0,rl.vv)(c)),a.createElement(m.g,{alignCenter:!0,gap:"xxsmall"},a.createElement(fe.cIj,{size:"3xs",side:"bottom",content:_t.$.AVAILABLE_FOR_GOALS_TOOLTIP,label:a.createElement(fe.c8D,{weight:"medium",color:C,id:"available-to-allocate"},"Available to allocate")})))),x?a.createElement(swe,null,a.createElement(txe.m,{title:"You're fully allocated",description:"When you have more funds for your goals available, we'll show those amounts here.",iconName:"
1check",width:320,icon:a.createElement(m.g,{padding:"default",borderRadius:"round",backgroundColor:"background.success",color:"content.success",center:!0},a.createElement(sl.ZQ,{name:"check",size:32}))},a.createElement(wt.Xb,{onClick:g},"Edit goal accounts"))):a.createElement(a.Fragment,null,a.createElement(Txe,null,a.createElement(_xe,null,Object.entries(i).map((e=>{let t=(0,o.A)(e,2),n=t[0],l=t[1];return a.createElement(nxe,{key:n,account:l})})))),a.createElement(Dxe,null,a.createElement(wt.Xb,{onClick:g},"Edit goal accounts"),a.createElement(cu.WT,{onClick:y},"Update allocations"))),a.createElement(p,null,a.createElement(twe,null)),a.createElement(f,null,a.createElement(Gxe,{onFinishAllocation:A,accounts:S,isLoading:k.isLoadingInitialData})))},swe=(0,$d.s)(fe.xz6.Content)(rwe||(rwe=(0,wc.A)(["*:mx-auto *:my-0 *:p-default"]))),cwe=Ee.J5z,dwe=()=>a.createElement(pxe,{"data-external-id":"goals-table-loading"},a.createElement(gxe,null,a.createElement(mwe,{title:"Savings"}),a.createElement(mwe,{title:"Debt"})),a.createElement(hxe,{column:!0,gap:"gutter",flex:1},a.createElement(fe.xz6,null,a.createElement(Nxe,null,a.createElement(M.Al,{$width:"100%",$height:"110px",$borderRadius:"default"})),a.createElement(Txe,null,a.createElement(_xe,null,a.createElement(uwe,null),a.createElement(uwe,null),a.createElement(uwe,{borderBottom:"none"}))),a.createElement(Dxe,{className:"py-lg"},a.createElement(M.Al,{$width:"100%",$height:"40px",$borderRadius:"default"}),a.createElement(M.Al,{$width:"100%",$height:"40px",$borderRadius:"default"}))))),uwe=e=>a.createElement(m.g,Object.assign({"data-external-id":"row",paddingVertical:"small",paddingHorizontal:"default",borderBottom:"1px solid divider.primary",justifyBetween:!0},e),a.createElement(M.Al,{$width:"45%",$height:"16px"}),a.createElement(M.Al,{$width:"20%",$height:"16px"})),mwe=e=>{let t=e.title;return a.createElement(Sxe,{"data-external-id":"goals-group",defaultOpen:!0,title:t},a.createElement(Exe,null,a.createElement(yxe,null,a.createElement(Cxe,null),a.createElement(fe.xz6.Title,null,t)),a.createElement(M.Al,{$width:"200px",$height:"16px"}),a.createElement(bxe,null,a.createElement(M.Al,{$width:"200px",$height:"16px"}))),a.createElement(Axe,null,a.createElement(xxe,null,a.createElement(pwe,null),a.createElement(pwe,null),a.createElement(pwe,null))))},pwe=()=>a.createElement(m.g,{"data-external-id":"goal-row",padding:"xlarge",gap:"default",alignCenter:!0,borderBottom:"1px solid divider.primary"},a.createElement(M.Al,{$width:"72px",$height:"72px",$borderRadius:"default"}),a.createElement(m.g,{column:!0,gap:"small",width:"100%"},a.createElement(m.g,{column:!0,gap:"xsmall"},a.createElement(m.g,{justifyBetween:!0},a.createElement(M.Al,{$width:"25%",$height:"16px"}),a.createElement(M.Al,{$width:"12%",$height:"16px"})),a.createElement(m.g,{justifyBetween:!0},a.createElement(M.Al,{$width:"12%",$height:"16px"}),a.createElement(M.Al,{$width:"25%",$height:"16px"}))),a.createElement(m.g,null,a.createElement(M.Al,{$width:"100%",$height:"8px",$minHeight:"8px",$borderRadius:"xxsmall"}))));var gwe;const hwe=(0,$d.s)(l.N_)(gwe||(gwe=(0,wc.A)(["\n  block w-full border-b border-divider-primary text-inherit\n  [--current-bg-color:var(--color-background-primary)]\n  hover:[--current-bg-color:var(--color-background-primary-hover)]\n  focus:[--current-bg-color:var(--color-background-primary-hover)]\n  focus-visible:outline-none\n  active:[--current-bg-color:var(--color-background-secondary)]\n  data-archived:border-divider-secondary\n  data-archived:[--current-bg-color:var(--color-background-secondary)]\n  data-archived:hover:[--current-bg-color:var(--color-background-secondary)]\n  data-archived:focus:[--current-bg-color:var(--color-background-secondary)]\n  [&>div]:bg-(--current-bg-color)\n"]))),vwe=e=>{let t=e.goals,n=e.defaultOpen,l=void 0===n||n,r=e.headerRight,i=e.description,s=e.title,c=e.getArchivedTitle;const d=(0,vj.A)((e=>!!e.archivedAt),t),u=(0,o.A)(d,2),m=u[0],p=u[1],g=(0,sU.A)((0,Go.A)((e=>{let t=e.archivedAt;return null!==t&&void 0!==t?t:""})),m);return a.createElement(Sxe,{"data-external-id":"goals-table-section",defaultOpen:l,title:null!==s&&void 0!==s?s:""},a.createElement(Exe,null,a.createElement(yxe,null,a.createElement(Cxe,null),a.createElement(fe.xz6.Title,null,s)),i,a.createElement(bxe,null,r)),a.createElement(Axe,null,a.createElement(xxe,null,p.map((e=>a.createElement(hwe,{key:e.id,to:I.JZ.goalsV2.goalDetail({id:e.id})},a.createElement(hbe,{goal:e}))))),g.length>0&&a.createElement(oK,{showText:"Show ".concat(c(g.length)),hideText:"Collapse ".concat(c(g.length))},g.map((e=>a.createElement(hwe,{key:e.id,to:I.JZ.goalsV2.goalDetail({id:e.id}),"data-archived":!0},a.createElement(hbe,{goal:e})))))))},fwe="Priority",Ewe=[bl.IW.Asset,bl.IW.Debt],ywe=e=>{let t=e.goals,n=e.isLoading;const l=sxe().groupBy,i=(0,r.YW)(l).with("type",(()=>{const e=Object.entries((0,LD.A)((0,mo.A)("type"),t));return(0,Nc.A)((e=>{let t=(0,o.A)(e,1)[0];const n=(0,DV.A)(t,Ewe);return-1===n?1/0:n}),e)})).with("priority",(()=>[[fwe,t]])).exhaustive();return n?a.createElement(dwe,{"data-external-id":"goals-table"}):a.createElement(pxe,{"data-external-id":"goals-table"},a.createElement(gxe,null,i.map((e=>{let t=(0,o.A)(e,2),n=t[0],l=t[1];const i=l.filter((e=>!e.archivedAt)),s=(0,owe.gb)(i);return a.createElement(vwe,Object.assign({key:n,description:a.createElement(El.H,{className:"text-base",startAmount:s.startAmount,endAmount:s.endAmount,timeframeDisplay:"this month",isAsset:n===bl.IW.Asset}),getArchivedTitle:e=>(0,De.td)("goal",e,{inclusive:!0,modifier:"archived"})},(0,r.YW)(n).with(fwe,(()=>({title:fwe,description:null}))).with(bl.IW.Debt,(()=>({title:"Debt",getArchivedTitle:e=>(0,De.td)("goal",e,{inclusive:!0,modifier:"archived debt"}),headerRight:a.createElement(xt.v,{size:"large",weight:"medium","aria-label":"Debt total"},(0,rl.vv)(i.reduce(((e,t)=>e+(0,yl.e3)(t)),0)))}
1))).with(bl.IW.Asset,(()=>({title:"Savings",getArchivedTitle:e=>(0,De.td)("goal",e,{inclusive:!0,modifier:"archived savings"}),headerRight:a.createElement(xt.v,{size:"large",weight:"medium","aria-label":"Savings total"},(0,rl.vv)(i.reduce(((e,t)=>e+(0,yl.e3)(t)),0)))}))).otherwise((()=>({}))),{goals:l}))}))),a.createElement(hxe,null,a.createElement(iwe,{goals:t})))},bwe=e=>{let t=e.accounts,n=e.onFinishAllocation;const l=(0,Pd.h)(),r=(0,o.A)(l,2),i=r[0],s=r[1].open,c=(0,et.I)(Awe),d=c.data,u=c.isLoadingInitialData,p=(null!==d&&void 0!==d?d:{}).accountsWithUnallocatedBalancesForGoals,g=void 0===p?[]:p;return a.createElement(xwe,{"data-external-id":"goals-allocate-banner"},a.createElement(wwe,{type:"info"},a.createElement(m.g,{justifyBetween:!0},a.createElement(m.g,{alignCenter:!0},a.createElement(zye.B,{size:36,accounts:t}),a.createElement(Cwe,{weight:"medium",color:"blueText"},_t.lR.ALLOCATE.BANNER)),a.createElement(wt.Xb,{onClick:s},"Update now"))),a.createElement(i,null,a.createElement(Gxe,{onFinishAllocation:n,isLoading:u,accounts:g})))},xwe=(0,u.default)(m.g).attrs({alignCenter:!0}).withConfig({displayName:"GoalsAllocateBanner__Root",componentId:"g0vgyh-0"})(["padding:",";"],(e=>e.theme.spacing.default)),wwe=(0,u.default)(fu.g).withConfig({displayName:"GoalsAllocateBanner__StyledBanner",componentId:"g0vgyh-1"})(["padding:",";"," width:100%;"],(e=>e.theme.spacing.default),wn.M.medium),Cwe=(0,u.default)(xt.v).withConfig({displayName:"GoalsAllocateBanner__StyledText",componentId:"g0vgyh-2"})(["margin-left:",";"],(e=>e.theme.spacing.xsmall));bwe.fragments={Web_GoalsAllocateBannerFields:Ee.sdV};const Awe=Ee.T5P,Iwe=[.5,1,2,4,8,16,32,64],kwe=u.default.div.withConfig({displayName:"ProgressiveBlur__BlurContainer",componentId:"sc-1lguxv1-0"})(["position:absolute;"," left:0;right:0;height:",";pointer-events:none;"],(e=>"top"===e.$position?"top: 0;":"bottom: 0;"),(e=>e.$height)),Swe=u.default.div.withConfig({displayName:"ProgressiveBlur__BlurLayer",componentId:"sc-1lguxv1-1"})(["position:absolute;inset:0;backdrop-filter:blur(","px);mask-image:linear-gradient( to ",",rgba(0,0,0,",") 0%,transparent 100% );"],(e=>e.$blur),(e=>e.$isTop?"bottom":"top"),(e=>e.$opacity)),Nwe=u.default.div.withConfig({displayName:"ProgressiveBlur__GradientLayer",componentId:"sc-1lguxv1-2"})(["position:absolute;inset:0;background:linear-gradient( to ",","," 0%,transparent 100% );pointer-events:none;"],(e=>e.$isTop?"bottom":"top"),(e=>e.$color));var Twe=n(54959),_we=n(77391);const Dwe="".concat(1008,"px"),Rwe=[0,1,2,4,8,16,32],Mwe=e=>{let t=e.close,n=e.cancel,r=e.onStartMigration,s=e.isMigrating;const c=(0,Ao.Q)().shouldShowMigrationFlow,d=Nse(),m=(0,u.useTheme)(),p=(0,a.useRef)(null),g=(0,a.useRef)(null),h=(0,a.useRef)(null),f=(0,a.useState)(!1),E=(0,o.A)(f,2),y=E[0],b=E[1],x=(0,a.useCallback)((()=>{if(p.current){const e=p.current.scrollTop>200;b((t=>t||e))}}),[]);(0,a.useLayoutEffect)((()=>(x(),window.addEventListener("resize",x),()=>window.removeEventListener("resize",x))),[x]);const w=(0,l.Zp)(),C=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.onStart,n=e.onComplete,l=e.onError;const r=(0,Ao.Q)(),s=r.hasMigrated,c=r.loading,d=(0,V.m)(),u=(0,i.n)(Io.UH),m=(0,o.A)(u,2),p=m[0],g=m[1].loading,h=(0,v.D)((async()=>{try{const e=await p();(0,_we.ZL)(e.data),d.cache.updateQuery({query:Io.Cd},(e=>(0,U.A)((0,U.A)({__typename:"Query"},e),{},{migratedToSavingsGoals:!0}))),d.cache.updateQuery({query:Io.b3},(e=>{var t;return{__typename:"Query",legacyGoalsMigrationData:null!==(t=null===e||void 0===e?void 0:e.legacyGoalsMigrationData)&&void 0!==t?t:[],migratedToSavingsGoals:!0}})),null===n||void 0===n||n()}catch(e){null===l||void 0===l||l(e)}})),f=(0,v.D)((e=>{null===l||void 0===l||l(new Error(e))})),E=(0,Twe.E)({onComplete:h,onError:f}),y=E.startMigration,b=E.isMigrating;return{automigrate:(0,a.useCallback)((async()=>{s||(null===t||void 0===t||t(),await y())}),[s,t,y]),loading:c||b||g}}(),A=C.automigrate,k=C.loading;return a.createElement(Rc.L,{"data-external-id":"goals-announcement-modal",fullHeight:!0,hideBottomBorder:!0},a.createElement(Pwe,null,a.createElement(Bwe,{ref:p,onScroll:x},a.createElement(zwe,null,a.createElement(Fwe,null,a.createElement(Gwe,null,a.createElement(Ywe,null,"Savings goals. Debt pay down. ",a.createElement(Uwe,null,"Reimagined.")),a.createElement(Vwe,null,"We heard your feedback and completely redesigned the goals experience. Saving up and paying down are now distinct features to give you even more functionality.")),a.createElement(Wwe,{$fileName:D3.lr[m.uiTheme].hero})),d&&a.createElement(jwe,{ref:g},a.createElement(Hwe,null,a.createElement(c5.C,{color:"blue",className:"self-start"},"Beta"),a.createElement(Kwe,null,D3.GH.header),a.createElement("div",{className:"flex max-w-132 flex-col gap-lg"},D3.GH.description.map(((e,t)=>a.createElement(Qwe,{key:t},e)))))),a.createElement(jwe,{ref:h},a.createElement(Hwe,null,a.createElement(Oc.D,{color:"orange",variant:"subtle"},"What's new"),a.createElement(Kwe,null,"Savings goals")),D3.jM.map((e=>a.createElement(Lwe,{key:e.fileName,fileName:e.fileName,header:e.header,description:e.description})))),a.createElement(jwe,null,a.createElement(Hwe,null,a.createElement(Oc.D,{color:"orange",variant:"subtle"},"What's new"),a.createElement(Kwe,null,"Debt pay down")),D3.fX.map((e=>a.createElement(Lwe,{key:e.fileName,fileName:e.fileName,header:e.header,description:e.description})))))),a.createElement(Owe,{className:y?"hidden":""},a.createElement(eCe,{blurLevels:Rwe})),!y&&a.createElement(tCe,{onClick:()=>{var e;const t=null!==(e=g.current)&&void 0!==e?e:h.current;null===t||void 0===t||t.scrollIntoView({behavior:"smooth"})}},a.createElement(Yo.r,{name:"arrow-down"}),a.createElement("span",null,"Learn more"))),y&&a.createElement(Cq.R,{className:"justify-between"},c?a.createElement(a.Fragment,null,a.createElement(wt.Xb,{onClick:()=>n()}
1,"Update later"),a.createElement(cu.gs,{onClick:r,pending:s},"Update",d?" to the beta":"")):a.createElement(a.Fragment,null,a.createElement("span",null)," ",a.createElement(cu.gs,{onClick:async()=>{await A(),t(),w(I.JZ.goals.savings.path)},pending:k},"Go to Goals"))))},Lwe=e=>{let t=e.fileName,n=e.header,l=e.description;const r=(0,u.useTheme)(),o=D3.lr[r.uiTheme][t],i=(0,M3.n)("".concat("goals","/").concat(o));return a.createElement(qwe,{"data-external-id":"feature-item-component"},a.createElement($we,null,a.createElement(Zwe,{src:i,alt:n})),a.createElement(Jwe,null,a.createElement(Xwe,null,n),l.map(((e,t)=>a.createElement(Qwe,{key:t},e)))))},Owe=u.default.div.withConfig({displayName:"GoalsAnnouncementModal__BlurWrapper",componentId:"sc-1y0vdvr-0"})(["position:absolute;inset:0;pointer-events:none;opacity:1;transition:",";&.hidden{opacity:0;}"],(e=>e.theme.transition.default)),Pwe=u.default.div.withConfig({displayName:"GoalsAnnouncementModal__ModalContentWrapper",componentId:"sc-1y0vdvr-1"})(["position:relative;flex:1;min-height:0;display:flex;flex-direction:column;"]),Bwe=u.default.div.withConfig({displayName:"GoalsAnnouncementModal__ScrollableContent",componentId:"sc-1y0vdvr-2"})(["flex:1;overflow-y:auto;scrollbar-width:thin;scrollbar-color:"," ",";"],vt.yW.gray6,vt.Ee.color.background.primary),zwe=(0,u.default)(qY.S).withConfig({displayName:"GoalsAnnouncementModal__StyledCardBody",componentId:"sc-1y0vdvr-3"})(["padding:",";padding-top:0;gap:",";"],vt.YK.xxxlarge,vt.YK.xxxlarge),Fwe=(0,u.default)(m.g).attrs({column:!0}).withConfig({displayName:"GoalsAnnouncementModal__HeroSection",componentId:"sc-1y0vdvr-4"})(["gap:40px;align-items:center;"]),Gwe=(0,u.default)(m.g).attrs({column:!0}).withConfig({displayName:"GoalsAnnouncementModal__HeroTextContainer",componentId:"sc-1y0vdvr-5"})(["gap:",";align-items:center;text-align:center;max-width:754px;"],vt.YK.xsmall),Ywe=(0,u.default)(xt.v).withConfig({displayName:"GoalsAnnouncementModal__HeroTitle",componentId:"sc-1y0vdvr-6"})(["font-size:",";font-weight:",";color:",";"],vt.J.xxlarge,vt.Wy.medium,vt.Ee.color.content.primary),Uwe=u.default.span.withConfig({displayName:"GoalsAnnouncementModal__BrandText",componentId:"sc-1y0vdvr-7"})(["color:",";"],vt.Ee.color.content.brand),Vwe=(0,u.default)(xt.v).withConfig({displayName:"GoalsAnnouncementModal__HeroSubtitle",componentId:"sc-1y0vdvr-8"})(["font-size:",";font-weight:",";color:",";"],vt.J[20],vt.Wy.book,vt.Ee.color.content.secondary),Wwe=u.default.div.withConfig({displayName:"GoalsAnnouncementModal__HeroImagesContainer",componentId:"sc-1y0vdvr-9"})(["width:100%;aspect-ratio:1.85 / 1;border-radius:",";background-image:url(",");background-size:cover;background-position:center;background-repeat:no-repeat;"],vt.r8.medium,(e=>{let t=e.$fileName;return(0,M3.n)("goals/".concat(t))})),jwe=(0,u.default)(m.g).attrs({column:!0}).withConfig({displayName:"GoalsAnnouncementModal__FeatureSection",componentId:"sc-1y0vdvr-10"})(["gap:",";"],vt.YK.xxlarge),Hwe=(0,u.default)(m.g).attrs({column:!0}).withConfig({displayName:"GoalsAnnouncementModal__SectionHeader",componentId:"sc-1y0vdvr-11"})(["gap:",";"],vt.YK.small),Kwe=(0,u.default)(xt.v).withConfig({displayName:"GoalsAnnouncementModal__SectionTitle",componentId:"sc-1y0vdvr-12"})(["font-size:",";font-weight:",";color:",";"],vt.J.xxlarge,vt.Wy.medium,vt.Ee.color.content.primary),qwe=(0,u.default)(m.g).withConfig({displayName:"GoalsAnnouncementModal__FeatureItem",componentId:"sc-1y0vdvr-13"})(["gap:",";align-items:center;justify-content:space-between;","{flex-direction:column;}"],vt.YK.xxlarge,Wo.J.xs),$we=u.default.div.withConfig({displayName:"GoalsAnnouncementModal__FeatureImageContainer",componentId:"sc-1y0vdvr-14"})(["position:relative;max-width:436px;max-height:280px;flex-shrink:0;width:50%;border-radius:",";overflow:hidden;background-color:",";border:1px solid ",";","{width:100%;}"],vt.r8.medium,vt.Ee.color.background.secondary,vt.Ee.color.divider.primary,Wo.J.xs),Zwe=u.default.img.withConfig({displayName:"GoalsAnnouncementModal__FeatureImage",componentId:"sc-1y0vdvr-15"})(["width:100%;height:100%;object-fit:cover;"]),Jwe=(0,u.default)(m.g).attrs({column:!0}
1).withConfig({displayName:"GoalsAnnouncementModal__FeatureTextContainer",componentId:"sc-1y0vdvr-16"})(["gap:",";flex:1;"],vt.YK.xsmall),Xwe=(0,u.default)(xt.v).withConfig({displayName:"GoalsAnnouncementModal__FeatureItemTitle",componentId:"sc-1y0vdvr-17"})(["font-size:",";font-weight:",";color:",";"],vt.J.xlarge,vt.Wy.medium,vt.Ee.color.content.primary),Qwe=(0,u.default)(xt.v).withConfig({displayName:"GoalsAnnouncementModal__FeatureItemDescription",componentId:"sc-1y0vdvr-18"})(["color:",";"],vt.Ee.color.content.secondary),eCe=(0,u.default)((e=>{let t=e.className,n=e.height,l=void 0===n?"30%":n,r=e.position,o=void 0===r?"bottom":r,i=e.blurLevels,s=void 0===i?Iwe:i,c=e.children,d=e.backgroundColor;const m=(0,u.useTheme)(),p=d?(0,xi.HE)(d,m):void 0,g=e=>s.map(((t,n)=>{const l=(n+1)/s.length;return a.createElement(Swe,{key:"".concat(e?"top":"bottom","-").concat(t,"-").concat(n),$blur:t,$opacity:l,$isTop:e})}));return a.createElement(a.Fragment,null,("top"===o||"both"===o)&&a.createElement(kwe,{className:t,$height:l,$position:"top"},g(!0),p&&a.createElement(Nwe,{$color:p,$isTop:!0}),c),("bottom"===o||"both"===o)&&a.createElement(kwe,{className:t,$height:l,$position:"bottom"},g(!1),p&&a.createElement(Nwe,{$color:p,$isTop:!1}),c))})).attrs({height:"20%"}).withConfig({displayName:"GoalsAnnouncementModal__StyledProgressiveBlur",componentId:"sc-1y0vdvr-19"})(["border-radius:",";overflow:hidden;"],vt.r8.medium),tCe=(0,u.default)(wt.Xb).attrs({size:"large"}).withConfig({displayName:"GoalsAnnouncementModal__LearnMoreButton",componentId:"sc-1y0vdvr-20"})(["align-self:center;position:absolute;bottom:",";border-radius:",";",""],vt.YK.xxlarge,vt.r8.pill,wn.M.large);var nCe=n(65695);const aCe=e=>{let t=e.close,n=e.cancel;const l=(0,R3.F)().isTransactionLinkingFlagOn,r=(0,a.useState)(!1),i=(0,o.A)(r,2),s=i[0],c=i[1],d=(0,nCe.E)({onBeforeNavigate:t}),u=d.startMigrationFlow,m=d.isMigrating;return a.createElement(Rc.L,{"data-external-id":"goals-start-migration-modal",hideBottomBorder:!0},a.createElement(lCe,null,a.createElement(rCe,null,a.createElement(oCe,null,a.createElement(c5.C,{color:"blue",className:"self-start"},"Beta"),a.createElement(iCe,null,D3.vH.header),a.createElement("div",{className:"flex max-w-132 flex-col gap-lg"},D3.vH.description.filter((e=>!l||e!==D3.Id)).map(((e,t)=>a.createElement(sCe,{key:t},e))))),a.createElement(uCe,null),a.createElement(cCe,{checked:s,onChange:e=>c(e.target.checked)},a.createElement(dCe,null,D3.vH.acknowledgement)))),a.createElement(Cq.R,{className:"justify-between"},a.createElement(wt.Xb,{onClick:()=>n()},"Update later"),a.createElement(cu.gs,{onClick:u,disabled:!s,pending:m},"Accept")))},lCe=u.default.div.withConfig({displayName:"GoalsStartMigrationModal__ModalContentWrapper",componentId:"sc-1jnno16-0"})(["position:relative;flex:1;min-height:0;display:flex;flex-direction:column;"]),rCe=(0,u.default)(qY.S).withConfig({displayName:"GoalsStartMigrationModal__StyledCardBody",componentId:"sc-1jnno16-1"})(["gap:",";padding:",";padding-top:0px;"],vt.YK.xlarge,vt.YK.xlarge),oCe=(0,u.default)(m.g).attrs({column:!0}).withConfig({displayName:"GoalsStartMigrationModal__ContentContainer",componentId:"sc-1jnno16-2"})(["gap:",";"],vt.YK.small),iCe=(0,u.default)(xt.v).withConfig({displayName:"GoalsStartMigrationModal__Title",componentId:"sc-1jnno16-3"})(["font-size:",";font-weight:",";color:",";"],vt.J.xxlarge,vt.Wy.medium,vt.Ee.color.content.primary),sCe=(0,u.default)(xt.v).withConfig({displayName:"GoalsStartMigrationModal__Description",componentId:"sc-1jnno16-4"})(["color:",";"],vt.Ee.color.content.primary),cCe=(0,u.default)(fz.hm).withConfig({displayName:"GoalsStartMigrationModal__StyledCheckbox",componentId:"sc-1jnno16-5"})(["gap:",";"],vt.YK.xsmall),dCe=(0,u.default)(xt.v).attrs({size:"base",weight:"book"}).withConfig({displayName:"GoalsStartMigrationModal__CheckboxLabel",componentId:"sc-1jnno16-6"})(["color:",";"],vt.Ee.color.content.primary),uCe=u.default.div.withConfig({displayName:"GoalsStartMigrationModal__Divider",componentId:"sc-1jnno16-7"})(["height:1px;background-color:",";"],vt.Ee.color.divider.primary),mCe=e=>{let t=e.isAutoAnnounceEnabled,n=e.onAutoOpen,l=e.profileFlagKey;const r=(0,xq.bO)(l,void 0,{fetchPolicy:"cache-first"}),i=(0,o.A)(r,3),s=i[0],c=i[2],d=(e=>{const t=(0,xq.bO)(e,void 0,{fetchPolicy:"cache-first"}),n=(0,o.A)(t,2)[1];return(0,v.D)((()=>n((new Date).toISOString())))})(l),u=(0,v.D)(n),m=(0,a.useRef)(!1),p=(0,v.D)((()=>{m.current||(m.current=!0,d())}));return(0,a.useEffect)((()=>{!t||c||s||m.current||(p(),u())}),[t,c,s,p,u]),{markAnnouncementSeen:p}},pCe=()=>{const e=Nse(),t=(0,Pd.h)(),n=(0,o.A)(t,2),l=n[0],r=n[1],i=r.open,s=r.close,c=r.cancel,d=(0,Pd.h)(),u=(0,o.A)(d,2),p=u[0],g=u[1],h=g.open,v=g.close,f=g.cancel,E=(0,nCe.E)({onBeforeNavigate:s}),y=E.startMigrationFlow,b=E.isMigrating,x=(0,nG.p)("feat-goals-v3-auto-announce-web_mobile","off"),w=mCe({isAutoAnnounceEnabled:x,profileFlagKey:"dismissedGoalsV3AnnouncementAt",onAutoOpen:()=>{(0,Ge.u4)(Ye.L1.Opened,{identifier:Ye.Uu,source:"auto"}),i()}}).markAnnouncementSeen,C=()=>{(0,Ge.u4)(Ye.L1.Skipped,{identifier:Ye.Uu})};return a.createElement(a.Fragment,null,a.createElement(gCe,{type:"gradient"},a.createElement(m.g,{alignCenter:!0,justifyBetween:!0},a.createElement(m.g,{alignCenter:!0,gap:"xsmall"},a.createElement(fe.lGO,{size:"md",className:"text-content-primary"}),a.createElement(xt.v,{size:"small",weight:"medium"},(0,D3.nc)(e))),a.createElement(hCe,{onClick:()=>{w(),(0,Ge.u4)(Ye.L1.Opened,{identifier:Ye.Uu,source:"banner"}),i()}},"Learn more"))),a.createElement(l,{maxWidth:Dwe,onCancel:C},a.createElement(Mwe,{close:s,cancel:c,onStartMigration:()=>{e?(s(),h()):y()},isMigrating:b})),a.createElement(p,{maxWidth:"560px",onCancel:C},a.createElement(aCe,{close:v,cancel:f})))},gCe=(0,u.default)(fu.g).withConfig({displayName:"GoalsAnnouncementBanner__StyledBanner",componentId:"sc-1wztrf5-0"})(["border-radius:",";padding:10px "," 10px ",";"],vt.r8.medium,vt.YK.small,vt.YK.default),hCe=(0,u.default)(cu.WT).withConfig({displayName:"GoalsAnnouncementBanner__BannerLearnMoreButton",componentId:"sc-1wztrf5-1"})(["background-color:rgba(255,255,255,0.15);"]),vCe=e=>a.createElement(m.g,Object.assign({"data-external-id":"deprecated-button-separator",role:"separator",height:"16px",width:"1px",backgroundColor:"divider.secondary"},e)),fCe=()=>{const e=sxe(),t=e.groupBy,n=e.setGroupBy;return a.createElement(Qi.Az,{"data-external-id":"goals-table-group-by-toggle",overlay:a.createElement(Ji.SP,null,a.createElement(Ji.xm,{selected:"type"===t,onClick:()=>n("type")},"Group by type"),a.createElement(Ji.xm,{selected:"priority"===t,onClick:()=>n("priority")},"Group by priority")),placement:"bottom-end"},(e=>{let n=e.toggleOpen,l=e.isOpen;return a.createElement(wt.Xb,{onClick:n,active:l,size:"small"},a.createElement("span",null,"type"===t?"By type":"By priority"),a.createElement(Yo.r,{name:"chevron-down"}))}))},ECe=()=>{const e=(0,l.Zp)(),t=(0,Pd.h)(),n=(0,o.A)(t,2),r=n[0],i=n[1].open,s=(0,Pd.h)(),c=(0,o.A)(s,2),d=c[0],u=c[1].open,m=(0,Pd.h)(),p=(0,o.A)(m,2),g=p[0],h=p[1].open,v=(0,nG.p)("feat-goals-facelift-web_mobile","off");return a.createElement(uU.f,{"data-external-id":"goals-header-control
1s"},v&&a.createElement(a.Fragment,null,a.createElement(fCe,null),a.createElement(vCe,null)),a.createElement(Qi.Az,{overlay:a.createElement(Ji.SP,null,a.createElement(Ji.xm,{onClick:i},"Edit accounts"),a.createElement(Ji.xm,{onClick:u},"Edit goal priorities"),a.createElement(Ji.xm,{onClick:h},"Edit contributions")),placement:"bottom-end"},(e=>{let t=e.toggleOpen,n=e.isOpen;return a.createElement(wt.Xb,{size:"small",onClick:t,active:n},a.createElement(Yo.r,{name:"settings"}),a.createElement("span",null,"Manage"))})),a.createElement(cu.WT,{size:"small",onClick:()=>e(I.JZ.goalsV2.select())},a.createElement(Yo.r,{name:"plus"}),a.createElement("span",null,"Add goals")),a.createElement(r,null,a.createElement(twe,null)),a.createElement(d,null,a.createElement(obe,null)),a.createElement(g,null,a.createElement(tbe,null)))};var yCe;const bCe=()=>{const e=(0,u.useTheme)(),t=(0,l.Zp)(),n=(0,M3.n)("".concat("goals","/").concat(D3.lr[e.uiTheme].hero));return a.createElement(xCe,{"data-external-id":"required-migration-interstitial"},a.createElement("div",{className:"flex w-full max-w-188.5 flex-col items-center gap-xl text-center"},a.createElement("div",{className:"flex w-full flex-col gap-xs"},a.createElement(xt.v,{size:"xxlarge",className:"font-medium text-content-primary"},D3.xJ.gateCard.title," ",a.createElement(xt.v,{className:"text-content-brand"},D3.xJ.gateCard.titleAccent)),a.createElement(xt.v,{className:"text-20 font-book text-content-secondary"},D3.xJ.gateCard.subtitle)),a.createElement(cu.WT,{size:"medium",onClick:()=>t(I.JZ.goals.savings.migrate.whatsNew.path)},D3.xJ.gateCard.cta)),a.createElement("div",{className:"w-full max-w-225.75 overflow-hidden rounded-sm border border-divider-primary bg-background-secondary"},a.createElement("img",{className:"block h-auto w-full",src:n,alt:""})))},xCe=(0,$d.s)(Xl.AM)(yCe||(yCe=(0,wc.A)(["mx-xl flex flex-1 flex-col items-center gap-2xl overflow-y-auto py-3xl"]))),wCe=["children"],CCe=e=>{let t=e.children,n=(0,En.A)(e,wCe);return a.createElement(Yq,Object.assign({"data-external-id":"goals-v2-page-shell",parentRoute:null,name:"Goals",emptyIcon:"target",emptyTitle:_t.DX},n),a.createElement(rV.T,{screenName:"Goals (Legacy)"}),t)},ACe=()=>{const e=(0,l.Zp)(),t=(0,d.d4)(gG.pk),n=(0,a.useState)(!1),r=(0,o.A)(n,2),i=r[0],s=r[1],c=(0,nG.p)("feat-goals-facelift-web_mobile","off"),u=(0,R3.F)(),m=u.isOnNotMigrated,p=u.isOn,g=u.requiresMigration,h=u.canToggleVersions,v=(0,pZ._)(TCe,t,{skip:g}),f=v.data,E=v.isLoadingInitialData,y=v.refetch,b=null!==f&&void 0!==f?f:{},x=b.goalsV2,w=b.accountsWithUnallocatedBalancesForGoals,C=(0,a.useMemo)((()=>(0,yl.SZ)(null!==x&&void 0!==x?x:[])),[x]),A=!C.length&&!E,k=(0,a.useMemo)((()=>(0,vj.A)((e=>!!e.archivedAt),C)),[C]),S=(0,o.A)(k,2),N=S[0],T=S[1],_=(0,a.useMemo)((()=>i?[...T,...N]:T),[N,T,i]);return(0,a.useEffect)((()=>{p&&!h&&e(I.JZ.goals.savings.path,{replace:!0})}),[p,e,h]),g?a.createElement(CCe,{"data-external-id":"goals-v2"},a.createElement(bCe,null)):a.createElement(ixe,{"data-external-id":"goals-v2",refetchGoals:y},a.createElement(CCe,{controls:a.createElement(ECe,null),overlayEmptyComponent:A?a.createElement(jpe,{icon:"Target",title:_t.lR.EMPTY.TITLE,subtitle:_t.lR.EMPTY.SUBTITLE,button:{text:_t.lR.EMPTY.BUTTON,onClick:()=>e(I.JZ.goalsV2.select())}}):void 0},m&&a.createElement(NCe,null,a.createElement(pCe,null)),c?a.createElement(ywe,{goals:C,isLoading:E}):a.createElement(a.Fragment,null,!(null===w||void 0===w||!w.length)&&a.createElement(bwe,{accounts:w,onFinishAllocation:y}),a.createElement(ICe,null,_.map((e=>a.createElement(l.N_,{to:I.JZ.goalsV2.goalDetail({id:e.id}),key:e.id},a.createElement(jye,{className:"h-full",key:e.id,goal:e}))))),N.length>0&&a.createElement(kCe,{onClick:()=>s(exe.A)},a.createElement(SCe,{name:i?"chevron-up":"chevron-down"}),i?"Hide":"Show"," archived goals (",N.length,")"))))},ICe=u.default.div.withConfig({displayName:"GoalsV2__GoalsList",componentId:"sc-99ag4o-0"})(["display:grid;grid-template-columns:repeat(1,1fr);grid-auto-rows:227px;grid-column-gap:",";grid-row-gap:",";padding:",";padding-top:0;@media (min-width:","px){padding:",";grid-template-columns:repeat(2,1fr);padding-top:0;}@media (min-width:","px){grid-template-columns:repeat(3,1fr);}"],(e=>e.theme.spacing.gutter),(e=>e.theme.spacing.gutter),(e=>e.theme.spacing.default),(e=>e.theme.breakPoints.sm),(e=>e.theme.spacing.gutter),(e=>e.theme.breakPoints.lg)),kCe=(0,u.default)(bn.v).withConfig({displayName:"GoalsV2__ExpandButton",componentId:"sc-99ag4o-1"})(["margin:auto;margin-top:",";margin-bottom:",";color:",";"],(e=>e.theme.spacing.large),(e=>e.theme.spacing.xxlarge),(e=>e.theme.color.text)),SCe=(0,u.default)(sl.ZQ).attrs({size:16}).withConfig({displayName:"GoalsV2__ExpandIcon",componentId:"sc-99ag4o-2"})(["margin-right:",";"],(e=>e.theme.spacing.default)),NCe=u.default.div.withConfig({displayName:"GoalsV2__GoalsV3BannerContainer",componentId:"sc-99ag4o-3"})(["padding:0 "," ",";"],vt.YK.default,vt.YK.default),TCe=Ee.nK6,_Ce=e=>{let t=e.accounts,n=e.activeFilters,r=e.onApply,o=e.onClear,i=e.showAddButton,s=void 0===i||i,c=e.advancedActions;const d=(0,l.zy)().pathname.includes(I.JZ.investments.holdings.allocation.path)?I.JZ.investments.holdings.allocation.addHolding():I.JZ.investments.holdings.market.addHolding(),u=(0,a.useMemo)((()=>(0,jd.A)((e=>({value:e.id,label:a.createElement("span",null,e.displayName),icon:a.createElement(Gl.v,{logoUrl:e.logoUrl,icon:e.icon,size:24,className:"mr-xs"})})),(0,Nc.A)((0,mo.A)("order"),t))),[t]),m=(0,a.useMemo)((()=>{var e;return null!==(e=n.accounts)&&void 0!==e?e:[]}),[n.accounts]);return a.createElement("div",{"data-external-id":"investments-header-control
1s",className:"flex items-center justify-end gap-xs"},m.length>0&&a.createElement(bn.v,{onClick:()=>{o(),(0,Ge.u4)(Ye.Vi.AccountFilterChanged,{account_count:0})}},"Clear"),a.createElement(fe.qN2,{show:m.length>0},a.createElement(Qi.Az,{overlay:a.createElement(Ji.SP,null,u.map((e=>a.createElement(Ji.xm,{key:e.value,selected:m.includes(e.value),keepMenuOpenOnClick:!0,onClick:()=>{const t=m.includes(e.value)?m.filter((t=>t!==e.value)):[...m,e.value];r(t),(0,Ge.u4)(Ye.Vi.AccountFilterChanged,{account_count:t.length})}},e.icon,e.label)))),placement:"bottom-end"},(e=>{let t=e.toggleOpen,n=e.isOpen;return a.createElement(wt.Xb,{size:"small",onClick:t,active:n},m.length>0?"".concat(m.length," account").concat(m.length>1?"s":""):"Accounts",a.createElement(sl.ZQ,{name:"chevron-down",size:16,className:"ml-2xs translate-y-px"}))}))),a.createElement(wm.A,{orientation:"vertical",color:"tertiary",className:"mx-2xs h-default"}),c&&a.createElement(Qi.Az,{overlay:a.createElement(Ji.SP,null,a.createElement(Ji.xm,{onClick:c.openAddHolding},"Add holding"),a.createElement(Ji.xm,{onClick:c.openImportModal},"Add tax lots")),placement:"bottom-end"},(e=>{let t=e.toggleOpen,n=e.isOpen;return a.createElement(cu.WT,{onClick:t,active:n},"Add",a.createElement(sl.ZQ,{name:"chevron-down",size:16,className:"ml-2xs translate-y-px"}))})),!c&&s&&a.createElement(cu.WT,{linkTo:d},a.createElement(sl.ZQ,{name:"plus",size:14,className:"mt-3xs mr-xs"}),"Add Holding"))},DCe=["className"],RCe="tab-nav-item-active",MCe=(0,u.default)((e=>{let t=e.className,n=(0,En.A)(e,DCe);return a.createElement(l.k2,Object.assign({"data-external-id":"base-tab-nav-link"},n,{className:e=>{let n=e.isActive;return[t,n?RCe:""].filter(Boolean).join(" ")}}))})).withConfig({displayName:"TabNavLink__DEPRECATEDTabNavLink",componentId:"sc-1sfjdtm-0"})(["height:32px;color:",";font-size:",";:hover{color:",";}&.","{color:",";transition:unset;box-shadow:inset 0 -2px 0 0 ",";&:hover{color:",";}}"],(e=>e.theme.color.textLight),(e=>e.theme.fontSize.base),(e=>e.theme.color.text),RCe,(e=>e.theme.color.orange),(e=>e.theme.color.orange),(e=>e.theme.color.orange));var LCe;const OCe="AdvancedTab",PCe=()=>{const e=(0,qG.e)(),t=e.hasPlusAccess,n=e.isLoading,r=(0,P6.f)().isSponsored,i=(0,l.zy)().search,s=(0,a.useState)(!1),c=(0,o.A)(s,2),d=c[0],u=c[1],m=(0,eY.z)();return a.createElement("div",{"data-external-id":"header-tabs",className:"ml-xl flex items-stretch"},a.createElement(BCe,{to:"".concat(I.JZ.investments.holdings.path).concat(i)},"Holdings"),!r&&a.createElement(BCe,{to:"".concat(I.JZ.investments.advanced.path).concat(i),onClick:e=>{t||n||(e.preventDefault(),m(OCe),u(!0))}},"Advanced",a.createElement($G,null)),d&&a.createElement(QG.N,{type:"AssetAllocation",analyticsName:OCe,onClose:()=>u(!1)}))},BCe=(0,$d.s)(MCe)(LCe||(LCe=(0,wc.A)(["mr-lg flex items-center gap-2xs whitespace-nowrap"]))),zCe=[{title:"1W",duration:{week:1}},{title:"1M",duration:{month:1}},{title:"3M",duration:{month:3}},{title:"6M",duration:{month:6}},{title:"YTD",duration:{year:1}},{title:"1Y",duration:{year:1}},{title:"5Y",duration:{year:5}}],FCe=e=>{let t=e.duration,n=e.title;const a=N.c9.local();return"YTD"===n?{startDate:a.startOf("year").toISODate(),endDate:a.toISODate()}:t?{startDate:a.minus(t).toISODate(),endDate:a.toISODate()}:{startDate:void 0,endDate:void 0}};var GCe=n(43077),YCe=n(20503);
1const UCe={[HQ.W1.TAGS]:"tag",[HQ.W1.INVESTMENTS]:"trending-up"},VCe=e=>{var t,n;let l=e.feature,r=e.useDescriptionAsTitle,i=e.className;const s=null!==(t=HQ.Gx[l])&&void 0!==t?t:{},c=s.title,d=void 0===c?"":c,u=s.description,m=void 0===u?"":u,p=(0,YCe._)().hasPremiumTrialAvailable,g=(0,Pd.h)(),h=(0,o.A)(g,2),v=h[0],f=h[1],E=f.open,y=f.close;return a.createElement(a.Fragment,null,a.createElement(jpe,{className:i,title:r?m:d,subtitle:r?void 0:m,icon:null!==(n=UCe[l])&&void 0!==n?n:"",button:{icon:"diamond",text:p?_t.se.UPGRADE_CTA.TRIAL_AVAILABLE:_t.se.UPGRADE_CTA.TRIAL_UNAVAILABLE,onClick:E}}),a.createElement(v,null,a.createElement(GCe.E,{context:"upgrade",analyticsName:l,onBack:y,onComplete:y})))};var WCe=n(76158);const jCe=e=>{let t=e.children;const n=(0,a.useMemo)((()=>a.Children.count(t)),[t]),l=(0,a.useMemo)((()=>a.Children.toArray(t).findIndex((e=>e.props.isActive))),[t]);return a.createElement(KCe,{"data-external-id":"deprecated-tab-toggle",$size:n},a.createElement(ZCe,{$size:n,$activeIndex:l}),t)},HCe=e=>{let t=e.title,n=e.isActive,l=e.onClick;return a.createElement($Ce,{"data-external-id":"deprecated-tab",onClick:l,$isActive:n},a.createElement(qCe,null,t))},KCe=u.default.div.withConfig({displayName:"TabToggle__GroupRoot",componentId:"v1c84g-0"})(["display:grid;grid-template-columns:",";background-color:",";border:","px solid ",";border-radius:",";height:","px;width:fit-content;align-self:center;position:relative;"],(e=>{let t=e.$size;return"repeat(".concat(t,", ").concat(90,"px)")}),(e=>e.theme.color.grayFocus),2,(e=>e.theme.color.grayFocus),(e=>e.theme.radius.pill),36),qCe=u.default.div.attrs({"data-sc-tw":"TabToggle__Content"}).withConfig({displayName:"TabToggle__Content",componentId:"v1c84g-1"})(["transition:",";position:relative;",""],(e=>e.theme.transition.default),(e=>{let t=e.theme;return(0,xb.gO)(90-parseInt(t.spacing.default,10))})),$Ce=(0,u.default)(m.g).attrs({center:!0}).withConfig({displayName:"TabToggle__TabRoot",componentId:"v1c84g-2"})(["font-weight:",";font-size:",";cursor:pointer;[data-sc-tw~='TabToggle__Content']{color:",";}&:hover [data-sc-tw~='TabToggle__Content']{color:",";}"],(e=>e.theme.fontWeight.medium),(e=>e.theme.fontSize.small),(e=>{let t=e.theme;return e.$isActive?t.color.text:t.color.textLight}),(e=>{let t=e.theme;return e.$isActive?"inherit":(0,xb.e$)(.1,t.color.textLight)})),ZCe=u.default.div.withConfig({displayName:"TabToggle__Pill",componentId:"v1c84g-3"})(["transition:left 0.2s cubic-bezier(0.65,0.05,0.36,1);border-radius:",";background-color:",";position:absolute;width:",";left:",";height:100%;top:0;"],(e=>e.theme.radius.pill),(e=>e.theme.color.white),(e=>{let t=e.$size;return"calc(100% / ".concat(t,")")}),(e=>{let t=e.$size,n=e.$activeIndex;return"calc(100% / ".concat(t," * ").concat(n,")")}));var JCe=n(70726),XCe=n(81833);const QCe=e=>{var t;return(null!==(t=e.taxLots)&&void 0!==t?t:[]).length>0},eAe=e=>{const t=(e=>{var t;const n=null!==(t=e.taxLots)&&void 0!==t?t:[];return 0===n.length?null:(0,MK.A)(n.map((e=>e.acquisitionQuantity*e.costBasisPerUnit)))})(e);return null!==t?t:(0,BY.A)(e.userCostBasis)?!(0,BY.A)(e.costBasis)&&((e,t)=>{var n;const a=null===(n=t.security)||void 0===n?void 0:n.currentPrice,l=t.quantity;if(!a||!l)return!0;const r=Math.abs(l*a);return Math.abs(e)<=10*r&&Math.abs(e)>=r/10})(e.costBasis,e)?e.costBasis:null:e.userCostBasis},tAe=e=>{var t,n;const a=null===(t=e.security)||void 0===t?void 0:t.currentPrice;return null!==a&&void 0!==a&&null!==e.quantity&&void 0!==e.quantity?a*e.quantity:null!==(n=e.value)&&void 0!==n?n:null},nAe=e=>{const t=eAe(e),n=tAe(e);return null===t||void 0===t||0===t||null===n||void 0===n?null:n-t},aAe=e=>{const t=eAe(e),n=nAe(e);return null===t||void 0===t||null===n||0===t?null:n/Math.abs(t)*100};var lAe=n(37011);const rAe=[{label:"By asset class",value:lAe.O.AssetClass},{label:"By security type",value:lAe.O.Type},{label:"By account",value:lAe.O.Account},{label:"By institution",value:lAe.O.Institution},{label:"By security",value:lAe.O.Security}];var oAe,iAe,sAe,cAe=n(14482);const dAe=e=>{let t=e.holdings,n=e.isLoading,l=e.groupBy,r=e.onGroupByChange;const i=(0,u.useTheme)(),s=(0,a.useState)(lAe.O.Security),c=(0,o.A)(s,2),d=c[0],m=c[1],g=null!==l&&void 0!==l?l:d,h=(0,qd.W)(),v=(0,o.A)(h,2),f=v[0],E=v[1].width,y=void 0===E?0:E,b=(0,a.useMemo)((()=>[{name:"costBasis",label:"Cost Basis",color:vt.Ee.color.chart.fill.blue({theme:i})},{name:"gain",label:"Gain",color:vt.Ee.color.chart.fill.green({theme:i})},{name:"loss",label:"Loss",color:vt.Ee.color.chart.fill.red({theme:i})}]),[i]),x=(0,a.useMemo)((()=>mAe(t,g)),[t,g]),w=(0,a.useCallback)((e=>{if(0===e.length)return;const t=Math.max(0,...e.map((e=>e.costBasis+e.gain))),n=Math.min(0,...e.map((e=>e.loss)));return t!==n?(0,HW.dG)([n,1.05*t],6,!1):void 0}),[]);return n?a.createElement(pAe,{"data-external-id":"investments-cost-basis-chart"},a.createElement(p.i,null)):0===x.length?a.createElement(pAe,{"data-external-id":"investments-cost-basis-chart"},a.createElement(txe.m,{iconName:"bar-chart",title:"No holdings data available",description:"Connect an investment account to see your cost basis breakdown.",marginVertical:"xlarge",width:300})):a.createElement("div",{"data-external-id":"investments-cost-basis-chart",className:"flex flex-col gap-xs"},void 0===l&&a.createElement("div",{className:"flex justify-end"},a.createElement("div",{className:"w-50"},a.createElement(Eu.lV,{initialValues:{groupBy:g},onSubmit:()=>{},submitOnChange:!0},a.createElement(tC.zB.Select,{label:null,name:"groupBy",options:rAe,onValueChanged:(e,t)=>
1(e=>{m(e),null===r||void 0===r||r(e)})(t)})))),a.createElement("div",{ref:f,className:"w-full"},y>0&&a.createElement(PU.vD,{data:x,heightPx:373,widthPx:y,xAxisDataKey:"label",formatXAxis:e=>uAe(String(e)),barDataKeys:b,formatYAxis:rl.fw,yAxis:e=>{const t=w(e);if(t)return a.createElement(wa.h,{ticks:t,domain:[t[0],t[t.length-1]],tickFormatter:rl.fw,tick:{fontSize:i.fontSize.xsmall,fill:vt.Ee.color.chart.label({theme:i}),fontWeight:parseInt(i.fontWeight.medium,10),transform:"translate(".concat(-parseInt(i.spacing.xsmall,10),", 0)")},stroke:vt.Ee.color.chart.axis({theme:i}),tickLine:!1,axisLine:!1,allowDataOverflow:!0})},withLegend:!0,barWidthPx:100,minBarWidthPx:100,initialPanPosition:"start",margin:{top:24},barStroke:i.color.white,labelDataKey:"gainLossPercent",labelBarDataKey:"gain",labelOffsetPx:4,formatLabel:e=>{const t=Number(e);if(!isFinite(t))return"";const n=Math.abs(t).toLocaleString(void 0,{minimumFractionDigits:1,maximumFractionDigits:1});return"".concat(t>=0?"+":"-").concat(n,"%")},labelColorFn:e=>{const t=Number(e);return 0===t?vt.Ee.color.chart.label({theme:i}):t>0?vt.Ee.color.chart.fill.green({theme:i}):vt.Ee.color.chart.fill.red({theme:i})},tooltipComponent:e=>{var t;const n=(0,_a.WS)(e);return e.active&&n?a.createElement(gAe,{active:e.active,header:null!==(t=n.tooltipLabel)&&void 0!==t?t:n.label},a.createElement(hAe,null,a.createElement(xt.v,{size:"xsmall",color:"content.secondary"},"Current Value"),a.createElement(xt.v,{size:"xsmall",weight:"medium"},(0,rl.vv)(n.currentValue))),a.createElement(hAe,null,a.createElement(xt.v,{size:"xsmall",color:"content.secondary"},"Cost Basis"),a.createElement(xt.v,{size:"xsmall",weight:"medium"},(0,rl.vv)(n.costBasis))),a.createElement(hAe,null,a.createElement(xt.v,{size:"xsmall",color:"content.secondary"},"Gain / Loss"),a.createElement(JCe.Q,{value:n.gain+n.loss},n.gain+n.loss>=0?"+":"",(0,rl.vv)(n.gain+n.loss)))):null}})))},uAe=e=>e.length>30?"".concat(e.slice(0,30),"\u2026"):e,mAe=(e,t)=>{const n=new Map;return e.forEach((e=>{const a=eAe(e),l=tAe(e);if(null===nAe(e)||null===a)return;const o=(0,r.YW)(t).with(lAe.O.Security,(()=>{var t,n,a,l,r,o,i,s;return{key:null!==(t=null===(n=e.security)||void 0===n?void 0:n.id)&&void 0!==t?t:e.id,label:null!==(a=null!==(l=null!==(r=null!==(o=null===(i=e.security)||void 0===i?void 0:i.ticker)&&void 0!==o?o:e.ticker)&&void 0!==r?r:null===(s=e.security)||void 0===s?void 0:s.name)&&void 0!==l?l:e.name)&&void 0!==a?a:"Unknown",tooltipLabel:void 0}})).with(lAe.O.Account,(()=>{var t,n,a,l;return{key:null!==(t=null===(n=e.account)||void 0===n?void 0:n.id)&&void 0!==t?t:"unknown",label:null!==(a=null===(l=e.account)||void 0===l?void 0:l.displayName)&&void 0!==a?a:"Unknown Account",tooltipLabel:void 0}})).with(lAe.O.Type,(()=>{var t,n,a,l;const r=null!==(t=null!==(n=null!==(a=null===(l=e.security)||void 0===l?void 0:l.typeDisplay)&&void 0!==a?a:e.typeDisplay)&&void 0!==n?n:e.type)&&void 0!==t?t:"Other";return{key:r,label:r,tooltipLabel:void 0}})).with(lAe.O.AssetClass,(()=>{const t=(0,cAe.AC)(e);return{key:t,label:t,tooltipLabel:void 0}})).with(lAe.O.Institution,(()=>{var t,n,a;const l=null!==(t=null===(n=e.account)||void 0===n||null===(a=n.institution)||void 0===a?void 0:a.name)&&void 0!==t?t:"Manual Holdings";return{key:l,label:l,tooltipLabel:void 0}})).with(lAe.O.Holding,(()=>{var t,n,a,l,r,o,i;const s=null!==(t=null!==(n=null!==(a=null!==(l=null===(r=e.security)||void 0===r?void 0:r.ticker)&&void 0!==l?l:e.ticker)&&void 0!==a?a:null===(o=e.security)||void 0===o?void 0:o.name)&&void 0!==n?n:e.name)&&void 0!==t?t:"Unknown",c=null===(i=e.account)||void 0===i?void 0:i.displayName;return{key:e.id,label:s,tooltipLabel:c?"".concat(s," \xb7 ").concat(c):void 0}})).exhaustive(),i=o.key,s=o.label,c=o.tooltipLabel,d=n.get(i);d?(d.totalCostBasis+=null!==a&&void 0!==a?a:0,d.totalCurrentValue+=null!==l&&void 0!==l?l:0):n.set(i,{label:s,tooltipLabel:null!==c&&void 0!==c?c:s,totalCostBasis:null!==a&&void 0!==a?a:0,totalCurrentValue:null!==l&&void 0!==l?l:0})})),Array.from(n.values()).filter((e=>e.totalCostBasis>0||e.totalCurrentValue>0)).sort(((e,t)=>Math.max(t.totalCurrentValue,t.totalCostBasis)-Math.max(e.totalCurrentValue,e.totalCostBasis))).map((e=>{let t=e.label,n=e.tooltipLabel,a=e.totalCostBasis,l=e.totalCurrentValue;const r=l-a,o=0!==a?r/a*100:0;return{label:t,tooltipLabel:n,costBasis:a,gain:Math.max(0,r),loss:Math.min(0,r),currentValue:l,gainLossPercent:o}}))},pAe=$d.s.div(oAe||(oAe=(0,wc.A)(["flex h-93.25 w-full items-center justify-center"]))),gAe=(0,$d.s)(Sa.II)(iAe||(iAe=(0,wc.A)(["max-w-70 min-w-45"]))),hAe=$d.s.div(sAe||(sAe=(0,wc.A)(["mb-2xs flex justify-between gap-xl last:mb-0"])));var vAe,fAe,EAe,yAe,bAe,xAe,wAe;const CAe="https://monarch-static-assets-us-east-2.s3.us-east-2.amazonaws.com/investments",AAe="".concat(CAe,"/gnl-line-empty-state-light.png"),IAe="".concat(CAe,"/gnl-line-empty-state-dark.png");let kAe=function(e){return e.CostBasis="costBasis",e.TaxLots="taxLots",e}({});const SAe=e=>{let t=e.data,n=e.isLoading,l=e.dateRange,i=e.selectedHoldingInfos,c=void 0===i?[]:i,d=e.exportFilePrefix,m=void 0===d?"gnl-performance":d,p=e.holdings,g=void 0===p?[]:p,h=e.isLoadingHoldings,v=void 0!==h&&h,f=e.viewMode,E=e.onViewModeChange,y=e.hideCard,b=void 0!==y&&y,x=e.groupBy,w=e.onGroupByChange,C=e.onOpenImportModal;const A=(0,u.useTheme)(),I="dark"===(0,lm.a)(),k=(0,a.useRef)(null),S=(0,a.useRef)(null),T=(0,a.useState)(kAe.CostBasis),_=(0,o.A)(T,2),D=_[0],R=_[1],M=null!==f&&void 0!==f?f:D,L=(0,a.useCallback)((e=>{R(e),null===E||void 0===E||E(e)}),[E]),O=(0,a.useState)(!1),P=(0,o.A)(O,2),B=P[0],z=P[1],F=(0,a.useState)(),G=(0,o.A)(F,2),Y=G[0],U=G[1],V=(0,a.useState)(),W=(0,o.A)(V,2),j=W[0],H=W[1],K=(0,a.useCallback)((e=>a.createElement(NAe,{cx:e.cx,cy:e.cy,setActiveDataPointX:U,setActiveDataPointY:H})),[U,H]),q=(0,a.useMemo)((()=>{var e,t,n;if(void 0===Y||void 0===j)return;const a=S.current,l=a?getComputedStyle(a):null,r=(null!==(e=null===a||void 0===a?void 0:a.offsetWidth)&&void 0!==e?e:0)-p
1arseFloat(null!==(t=null===l||void 0===l?void 0:l.paddingLeft)&&void 0!==t?t:"0")-parseFloat(null!==(n=null===l||void 0===l?void 0:l.paddingRight)&&void 0!==n?n:"0");return{x:Math.max(0,Math.min(Y-130,r-260)),y:j-6-8}}),[Y,j]),$=0===t.length&&!n,Z=(0,a.useMemo)((()=>l.startDate&&l.endDate?N.c9.fromISO(l.endDate).diff(N.c9.fromISO(l.startDate),"days").days:0),[l.startDate,l.endDate])>365?Ba.Ex:Ba.SR,J=(0,a.useMemo)((()=>(0,_a.Bb)(t,"date",Z)),[t,Z]),X=(0,a.useCallback)((async()=>{const e=k.current;if(e){z(!0);try{await(0,_a.o0)(e,"".concat(m,"-").concat((0,Ba.Fv)(new Date),".png")),ij.Ay.chartDownloaded({chart:"Investment Performance"})}catch(t){s.Cp(new Error("Failed to export chart",{cause:t}))}finally{z(!1)}}}),[m]),Q=M===kAe.TaxLots?0===t.length:0===g.length,ee=a.createElement(a.Fragment,null,a.createElement("div",{ref:S,className:"my-default w-full pr-xl pl-xs"},(0,r.YW)({viewMode:M,isEmpty:$}).with({viewMode:kAe.CostBasis},(()=>a.createElement(dAe,{holdings:g,isLoading:v,groupBy:x,onGroupByChange:w}))).with({viewMode:kAe.TaxLots,isEmpty:!0},(()=>a.createElement("div",{className:"flex h-93.25 w-full items-center justify-center gap-xl"},a.createElement("div",{className:"flex max-w-75 flex-col items-start gap-sm"},a.createElement(xt.v,{size:"20",weight:"medium"},"View your unrealized gains & losses over time"),a.createElement(xt.v,{size:"base",color:"content.secondary"},"Tax lots are what powers this chart. Add your tax lots to get started."),a.createElement("div",{className:"flex gap-sm"},a.createElement(cu.WT,{onClick:C},"Add tax lot"),a.createElement(wt.Xb,{as:"a",href:XCe.X,target:"_blank",rel:"noopener noreferrer"},"Learn more"))),a.createElement("img",{className:"h-60 shrink-0",src:I?IAe:AAe,alt:"Gains and losses line graph preview"})))).otherwise((()=>a.createElement(Do.rT,{height:373,xDataKey:"date",yDataKeys:["portfolioValue","portfolioCostBasis",...c.flatMap((e=>[e.dataKey,"".concat(e.dataKey,"-cost-basis")]))],lineOptions:[{lineColor:vt.Ee.color.chart.fill.blue({theme:A}),hasArea:!0,customActiveDot:K},{lineColor:vt.Ee.color.chart.fill.gray({theme:A}),isDashed:!0,strokeWidth:2},...c.flatMap((e=>[{lineColor:e.color,hasArea:!0},{lineColor:e.color,isDashed:!0,strokeWidth:2}]))],formatXAxis:Z,xAxisProps:J,formatYAxis:rl.fw,smoothGradient:!0,isAnimationActive:!0,isLoadingNewData:n,data:t,domain:[e=>Math.min(0,e),"auto"],yAxisProps:{width:78},onMouseLeave:()=>{U(void 0),H(void 0)},tooltipProps:{position:q,isAnimationActive:!1,wrapperStyle:{opacity:q?1:0},allowEscapeViewBox:{x:!1,y:!0}},tooltipComponent:e=>{var t,n,l,r;const o=(0,_a.WS)(e);if(!e.active||!o)return null;const i=Number(null!==(t=o.portfolioValue)&&void 0!==t?t:0),s=Number(null!==(n=o.portfolioCostBasis)&&void 0!==n?n:0),d=Number(null!==(l=o.portfolioReturn)&&void 0!==l?l:0),u=Number(null!==(r=o.portfolioReturnPercent)&&void 0!==r?r:0),m=o.date?(0,Ba.AO)(String(o.date)):"";return a.createElement(MAe,{active:e.active,header:m},a.createElement(OAe,null,a.createElement(PAe,null,"Portfolio Value"),a.createElement(BAe,null,(0,rl.vv)(i))),a.createElement(OAe,null,a.createElement(PAe,null,"Cost Basis"),a.createElement(BAe,null,(0,rl.vv)(s))),a.createElement(OAe,null,a.createElement(PAe,null,"Unrealized Gains"),a.createElement(JCe.Q,{value:d,defaultZeroColor:A.color.textWhite},d>=0?"+":"",(0,rl.vv)(d))),a.createElement(OAe,null,a.createElement(PAe,null,"Percent Gain"),a.createElement(JCe.Q,{value:u,defaultZeroColor:A.color.textWhite},u>0?"+":"",u.toFixed(2),"%")),c.length>0&&a.createElement(a.Fragment,null,a.createElement(LAe,null),c.map((e=>{var t,n,l;const r=Number(null!==(t=o[e.dataKey])&&void 0!==t?t:0)-Number(null!==(n=o["".concat(e.dataKey,"-cost-basis")])&&void 0!==n?n:0);return a.createElement(OAe,{key:e.dataKey},a.createElement(PAe,null,null!==(l=e.ticker)&&void 0!==l?l:e.name),a.createElement(JCe.Q,{value:r,defaultZeroColor:A.color.textWhite},r>=0?"+":"",(0,rl.vv)(r)))}))))}})))),M===kAe.TaxLots&&t.length>0&&a.createElement("div",{className:"flex flex-wrap items-center justify-center px-xl pb-lg leading-[1.8] [&>*:not(:last-child)]:mr-lg"},a.createElement("div",{className:"flex items-center gap-xs"},a.createElement(TAe,{color:vt.Ee.color.chart.fill.blue({theme:A})}),a.createElement(RAe,null,"Portfolio Value")),a.createElement("div",{className:"flex items-center gap-xs"},a.createElement(_Ae,{color:vt.Ee.color.chart.fill.gray({theme:A})}),a.createElement(RAe,null,"Cost Basis")),c.map((e=>{var t;return a.createElement("div",{key:e.dataKey,className:"flex items-center gap-xs"},a.createElement(TAe,{color:e.color}),a.createElement(RAe,null,null!==(t=e.ticker)&&void 0!==t?t:e.name))}))));return b?a.createElement("div",{"data-external-id":"investments-gains-and-losses-graph",ref:k},ee):a.createElement(DAe,{"data-external-id":"investments-gains-and-losses-graph",ref:k},a.createElement("div",{className:"flex flex-col gap-2xs border-b border-divider-primary px-xl py-default"},a.createElement("div",{className:"flex items-center justify-between"},a.createElement("div",{className:"flex items-center gap-xs"},a.createElement(fe.cIj,{size:"3xs",side:"right",content:_t.RQ.UNREALIZED_GAINS_AND_LOSSES_TOOLTIP,triggerClassName:"text-content-secondary",iconSize:"xs",label:a.createElement(RV.W,null,"Unrealized gains & losses")}),a.createElement($G,null)),a.createElement("div",{className:"flex items-center gap-default"},B?a.createElement(xt.v,{weight:"medium",color:"textLight"},"Shared via ",(0,Mie.Q)("landing")):a.createElement("div",{className:"flex h-9 items-stretch"},a.createElement(wt.Xb,{onClick:X,disabled:Q,"aria-label":"Download chart"},a.createElement(sl.ZQ,{name:"download",size:12}))),void 0===f&&a.createElement(jCe,null,a.createElement(HCe,{title:"Cost Basis",isActive:M===kAe.CostBasis,onClick:()=>L(kAe.CostBasis)}),a.createElement(HCe,{title:"Tax Lots",isActive:M===kAe.TaxLots,onClick:()=>L(kAe.TaxLots)}))))),ee)},NAe=e=>{let t=e.cx,n=e.cy,l=e.setActiveDataPointX,r=e.setActiveDataPointY;const o=(0,u.useTheme)();return(0,a.useLayoutEffect)((()=>
1{l(t),r(n)}),[t,n,l,r]),a.createElement("circle",{"data-external-id":"active-dot",cx:t,cy:n,r:6,fill:vt.Ee.color.chart.fill.blue({theme:o}),strokeWidth:0})},TAe=e=>{let t=e.color;return a.createElement("div",{"data-external-id":"legend-dot",className:"size-3 shrink-0 rounded-round",style:{backgroundColor:t}})},_Ae=e=>{let t=e.color;return a.createElement("svg",{"data-external-id":"legend-dashed-line",width:"27",height:"3",style:{flexShrink:0}},a.createElement("line",{x1:"1",y1:"1.5",x2:"25",y2:"1.5",stroke:t,strokeWidth:2,strokeDasharray:Do.V7,strokeDashoffset:-5,strokeLinecap:"round"}))},DAe=(0,$d.s)(Xl.AM)(vAe||(vAe=(0,wc.A)(["mb-default"]))),RAe=$d.s.span(fAe||(fAe=(0,wc.A)(["text-xs font-medium text-content-secondary"]))),MAe=(0,$d.s)(Sa.II)(EAe||(EAe=(0,wc.A)(["w-65 -translate-y-full rounded-md"]))),LAe=$d.s.div(yAe||(yAe=(0,wc.A)(["my-xs border-t border-divider-primary"]))),OAe=$d.s.div(bAe||(bAe=(0,wc.A)(["\n  grid grid-flow-col items-center justify-between gap-xl text-xs font-medium\n"]))),PAe=$d.s.span(xAe||(xAe=(0,wc.A)(["text-left"]))),BAe=$d.s.span(wAe||(wAe=(0,wc.A)(["whitespace-nowrap"]))),zAe=e=>{let t=e.fileInputRef,n=e.selectedFiles,l=e.isDragOver,r=e.dragHandlers,o=e.isBusy,i=e.accept,s=e.onButtonClick,c=e.onFileChange,d=e.onRemoveFile;const m=(0,u.useTheme)(),g="tax-lot-file-input-".concat(a.useId().replaceAll(":","")),h=n.length>0,v={"--dz-purple-3":m.color.purple3,"--dz-purple-6":m.color.purple6,"--dz-purple-7":m.color.purple7,"--dz-purple-8":m.color.purple8,"--dz-purple-9":m.color.purple9};return a.createElement(a.Fragment,null,a.createElement("input",{ref:t,id:g,type:"file",accept:i,onChange:c,multiple:!0,className:"peer sr-only"}),a.createElement("div",Object.assign({},r,{onClick:s,style:v,className:(0,q.cn)("flex min-h-75 min-w-0 cursor-pointer flex-col items-center justify-center","rounded-md bg-(--dz-purple-3) p-xl","border-2 border-dashed transition-colors","hover:border-(--dz-purple-9)","\n            peer-focus-visible:outline-2 peer-focus-visible:outline-offset-2\n            peer-focus-visible:outline-border-info peer-focus-visible:outline-solid\n          ",l?"border-(--dz-purple-9)":"border-(--dz-purple-8)")}),a.createElement("div",{className:"mb-default"},a.createElement(sl.ZQ,{name:"sparkle",size:32,className:"text-(--dz-purple-9)"})),a.createElement("label",{htmlFor:g,onClick:e=>e.stopPropagation(),className:"mb-2xs cursor-pointer text-base font-medium text-(--dz-purple-9)"},"Select files or drag and drop to upload"),a.createElement(xt.v,{className:"text-sm text-(--dz-purple-8)"},"Supported file types: ",i.split(",").join(", ")),!h&&a.createElement(a.Fragment,null,a.createElement("hr",{className:"my-default w-full border-0 border-t border-(--dz-purple-7)"}),a.createElement("div",{className:"w-full text-left",onClick:e=>e.stopPropagation()},a.createElement(xt.v,{className:"mb-2xs text-sm font-medium text-(--dz-purple-9)"},"What you can import:"),a.createElement("ul",{className:"m-0 list-disc pl-default"},a.createElement("li",{className:"text-sm leading-[1.6] text-(--dz-purple-8)"},"Tax lot records"),a.createElement("li",{className:"text-sm leading-[1.6] text-(--dz-purple-8)"},"Brokerage screenshots"),a.createElement("li",{className:"text-sm leading-[1.6] text-(--dz-purple-8)"},"Transaction list")))),h&&a.createElement("div",{className:"mt-lg flex w-full flex-col gap-xs",onClick:e=>e.stopPropagation()},n.map(((e,t)=>a.createElement("div",{key:"".concat(e.name,"-").concat(t),className:" flex items-center gap-sm rounded-sm border border-(--dz-purple-6) bg-background-primary px-default py-sm "},a.createElement("div",{className:"flex shrink-0 items-center justify-center text-(--dz-purple-8)"},a.createElement(sl.ZQ,{name:"application/pdf"===e.type?"file-text":"image",size:20})),a.createElement(xt.v,{className:"flex-1 truncate text-sm text-(--dz-purple-9)"},e.name),o?a.createElement(p.i,{size:"sm",className:"shrink-0"}):a.createElement("button",{type:"button","aria-label":"Remove ".concat(e.name),onClick:()=>d(t),className:" flex shrink-0 cursor-pointer items-center justify-center border-0 bg-transparent p-0 text-(--dz-purple-7) hover:text-(--dz-purple-9) "},a.createElement(sl.ZQ,{name:"x",size:16}))))))))}
1,FAe="flex flex-col gap-2xs mb-default",GAe="text-sm font-medium text-content-primary",YAe=e=>{let t=e.holdingOptions,n=e.selectedHoldingId,l=e.onHoldingChange,r=e.acquisitionDate,o=e.onDateChange,i=e.acquisitionQuantity,s=e.onQuantityChange,c=e.costBasisPerUnit,d=e.onCostBasisPerUnitChange,u=e.totalCostBasis,m=e.onTotalCostBasisChange;return a.createElement(a.Fragment,null,a.createElement("div",{className:FAe},a.createElement(xt.v,{className:GAe},"Security"),a.createElement(fe.hGA,{options:t,value:n||null,placeholder:"Select a security","aria-label":"Security",onValueChange:e=>l(null!==e&&void 0!==e?e:"")})),a.createElement("div",{className:FAe},a.createElement(xt.v,{className:GAe},"Acquisition date"),a.createElement(Kce.J,{value:r||null,onValueChange:e=>o(null!==e&&void 0!==e?e:"")})),a.createElement("div",{className:FAe},a.createElement(xt.v,{className:GAe},"Quantity"),a.createElement(fe._CU,Object.assign({name:"acquisitionQuantity",placeholder:"0.00",value:null!==i&&void 0!==i?i:null,min:0,locale:"en-US",format:{maximumFractionDigits:8},step:"any",onValueChange:e=>s(null!==e&&void 0!==e?e:void 0)},(0,Ex.p)("numeric-input")))),a.createElement("div",{className:FAe},a.createElement(xt.v,{className:GAe},"Cost basis per share"),a.createElement(fe.K$5,{name:"costBasisPerUnit",value:null!==c&&void 0!==c?c:null,step:"any",format:{minimumFractionDigits:2,maximumFractionDigits:4},onValueChange:e=>d(null!==e&&void 0!==e?e:void 0)})),a.createElement("div",{className:FAe},a.createElement(xt.v,{className:GAe},"Total cost basis"),a.createElement(fe.K$5,{name:"totalCostBasis",value:null!==u&&void 0!==u?u:null,onValueChange:e=>m(null!==e&&void 0!==e?e:void 0)})))},UAe=e=>{let t=e.unmatchedLots,n=e.holdingOptions,l=e.lotAssignments,r=e.onAssignmentChange,o=e.bulkHoldingId,i=e.onBulkHoldingChange,s=e.onApplyBulk;return a.createElement(a.Fragment,null,a.createElement(xt.v,{className:"mb-default block text-sm/normal text-content-primary"},"We couldn't match ",t.length," ",(0,De.td)("tax lot",t.length)," to a holding. Please assign each one to continue."),a.createElement("div",{className:"mb-default flex items-center gap-sm"},a.createElement("div",{className:"flex-1"},a.createElement(Eu.lV,{initialValues:{holding:null!==o&&void 0!==o?o:""},onSubmit:()=>{},enableReinitialize:!0},a.createElement(tC.zB.Select,{label:null,name:"holding",options:n,placeholder:"Assign all to...",onValueChanged:(e,t)=>i(t||void 0)}))),a.createElement(wt.Xb,{disabled:!o,onClick:s},"Apply to all")),a.createElement("div",{className:"flex max-h-80 flex-col gap-sm overflow-y-auto"},t.map(((e,t)=>{var o,i;return a.createElement("div",{key:t,className:"flex items-center gap-default rounded-sm bg-background-secondary px-default py-sm"},a.createElement("div",{className:"flex min-w-0 flex-1 flex-col gap-3xs"},a.createElement(xt.v,{className:"block text-sm font-medium text-content-primary"},null!==(o=e.securitySymbol)&&void 0!==o?o:"Unknown"),a.createElement(xt.v,{className:"block text-sm text-content-secondary"},[e.acquisitionDate,null!==e.quantity&&void 0!==e.quantity?"".concat(e.quantity," shares"):null].filter(Boolean).join(" \xb7 "))),a.createElement("div",{className:"shrink-0 basis-55"},a.createElement(Eu.lV,{initialValues:{holding:null!==(i=l[t])&&void 0!==i?i:""},onSubmit:()=>{},enableReinitialize:!0},a.createElement(tC.zB.Select,{label:null,name:"holding",options:n,placeholder:"Select a holding",onValueChanged:(e,n)=>r(t,null!==n&&void 0!==n?n:"")}))))}))))},VAe=e=>({parseTaxLots:t=>{const n=new FormData;return t.forEach((e=>{n.append("files",e)})),e.post("/investments/parse-tax-lots",{data:n,timeout:3e4,extraHeaders:{"Content-Type":void 0}})},getTaxLotJobStatus:t=>e.get("/investments/parse-tax-lots/".concat(t,"/status"))}),WAe="idle",jAe="uploading",HAe="processing",KAe="analyzing",qAe="reviewing",$Ae=e=>"string"===typeof e?e:null===e||void 0===e?void 0:e[0],ZAe=()=>{const e=(0,a.useState)(!1),t=(0,o.A)(e,2),n=t[0],l=t[1],r=(0,a.useState)(null),i=(0,o.A)(r,2),s=i[0],c=i[1],d=(0,a.useState)(WAe),u=(0,o.A)(d,2),m=u[0],p=u[1],g=(0,a.useRef)(!1),h=(0,a.useRef)([]),v=(0,a.useCallback)((()=>{g.current=!0,h.current.forEach(clearTimeout),h.current=[]}
1),[]);(0,a.useEffect)((()=>()=>v()),[v]);const f=(0,a.useCallback)((async e=>{if(0===e.length)return c("No files provided"),null;g.current=!1,h.current.forEach(clearTimeout),h.current=[],l(!0),c(null),p(jAe);try{const n=await VAe(r7.F).parseTaxLots(e);if(g.current)return null;var t;if(!n.success||!n.jobId)return c(null!==(t=n.error)&&void 0!==t?t:"Failed to upload documents"),(0,Ge.u4)(Ye.Vi.TaxLotAIParseFailed,{reason:"upload_failed"}),null;p(HAe);const a=setTimeout((()=>{g.current||p(KAe)}),3e4),l=setTimeout((()=>{g.current||p(qAe)}),6e4);return h.current=[a,l],await(async e=>{for(let o=0;o<150;o+=1){if(g.current)return null;try{const r=await VAe(r7.F).getTaxLotJobStatus(e);if(g.current)return null;if("completed"===r.status){var t,n,a;if(null!==(t=r.results)&&void 0!==t&&t.success&&r.results.data)return r.results.data;const e=null!==(n=null===(a=r.results)||void 0===a?void 0:a.error)&&void 0!==n?n:"Analysis completed, no results found";return c(e),(0,Ge.u4)(Ye.Vi.TaxLotAIParseFailed,{reason:"analysis_error"}),null}var l;if("failed"===r.status)return c(null!==(l=r.error)&&void 0!==l?l:"Analysis failed"),(0,Ge.u4)(Ye.Vi.TaxLotAIParseFailed,{reason:"job_failed"}),null;await new Promise((e=>setTimeout(e,2e3)))}catch(r){if(g.current)return null;const e=r instanceof Error?r.message:"Failed to check job status";return c(e),(0,Ge.u4)(Ye.Vi.TaxLotAIParseFailed,{reason:"polling_error"}),null}}return c("Analysis timed out, please try again."),(0,Ge.u4)(Ye.Vi.TaxLotAIParseFailed,{reason:"timeout"}),null})(n.jobId)}catch(n){return g.current||(c((e=>{if(e instanceof Vte.LG&&e.data){const t=e.data,n=t.detail,a=t.error,l=t.message;return $Ae(n)||$Ae(a)||$Ae(l)||"Failed to parse documents"}return e instanceof Error&&e.message?e.message:"Failed to parse documents"})(n)),(0,Ge.u4)(Ye.Vi.TaxLotAIParseFailed,{reason:"upload_error"})),null}finally{v(),l(!1),p(WAe)}}),[v]);return{parseDocuments:f,cancelOperation:v,isLoading:n,error:s,stage:m}};var JAe=function(e){return e.Upload="upload",e.Review="review",e}(JAe||{});const XAe=[".jpg",".jpeg",".png",".webp",".heic",".heif",".pdf",".csv"],QAe=new Set(XAe.map((e=>e.toLowerCase()))),eIe=e=>{let t=e.onParsed,n=e.onFinalizeUnmatched,l=e.onClose,r=e.isImporting,i=void 0!==r&&r,s=e.accounts,c=e.accountId,d=e.onAccountChange,u=e.holdings;const m=(0,a.useRef)(null),p=ZAe(),g=p.parseDocuments,h=p.cancelOperation,v=p.isLoading,f=p.error,E=p.stage,y=(0,Pd.h)(),b=(0,o.A)(y,2),x=b[0],w=b[1],C=w.open,A=w.close,I=(0,a.useState)(null),k=(0,o.A)(I,2),S=k[0],N=k[1],T=(0,a.useState)([]),_=(0,o.A)(T,2),D=_[0],R=_[1],M=(0,a.useState)(JAe.Upload),L=(0,o.A)(M,2),O=L[0],P=L[1],B=(0,a.useState)([]),z=(0,o.A)(B,2),F=z[0],G=z[1],Y=(0,a.useState)({}),V=(0,o.A)(Y,2),W=V[0],j=V[1],H=(0,a.useState)(void 0),K=(0,o.A)(H,2),q=K[0],$=K[1],Z=(0,a.useState)(!1),J=(0,o.A)(Z,2),X=J[0],Q=J[1],ee=(0,a.useState)(!1),te=(0,o.A)(ee,2),ne=te[0],ae=te[1],le=(0,a.useState)(null!==c&&void 0!==c?c:""),re=(0,o.A)(le,2),oe=re[0],ie=re[1],se=(0,a.useState)(""),ce=(0,o.A)(se,2),de=ce[0],ue=ce[1],me=(0,a.useState)(""),pe=(0,o.A)(me,2),ge=pe[0],he=pe[1],ve=(0,a.useState)(void 0),fe=(0,o.A)(ve,2),Ee=fe[0],ye=fe[1],be=(0,a.useState)(void 0),xe=(0,o.A)(be,2),we=xe[0],Ce=xe[1],Ae=(0,a.useState)(void 0),Ie=(0,o.A)(Ae,2),ke=Ie[0],Se=Ie[1],Ne=null!==S&&void 0!==S?S:f,Te=v||i,_e=(0,a.useMemo)((()=>(null!==u&&void 0!==u?u:[]).filter((e=>{var t;return!oe||(null===(t=e.account)||void 0===t?void 0:t.id)===oe}))),[u,oe]),De=(0,a.useMemo)((()=>(null!==s&&void 0!==s?s:[]).map((e=>({value:e.id,label:e.displayName})))),[s]),Re=(0,a.useMemo)((()=>_e.map((e=>{var t,n,a,l;const r=null!==(t=null===(n=e.security)||void 0===n?void 0:n.ticker)&&void 0!==t?t:e.ticker,o=null!==(a=null===(l=e.security)||void 0===l?void 0:l.name)&&void 0!==a?a:e.name,i=r?"".concat(r).concat(o?" - ".concat(o):""):null!==o&&void 0!==o?o:e.id;return{value:e.id,label:i}}))),[_e]),Me=(0,a.useCallback)((e=>{Ce(e),Se(void 0!==e&&Ee&&Ee>0?Math.round(Ee*e*100)/100:void 0)}),[Ee]),Le=(0,a.useCallback)((e=>{Se(e),Ce(void 0!==e&&Ee&&Ee>0?Math.round(e/Ee*1e4)/1e4:void 0)}),[Ee]),Oe=(0,a.useCallback)((e=>{G(e),j({}),$(void 0),P(JAe.Review),(0,Ge.u4)(Ye.Vi.TaxLotReconciliationStarted,{unmatched_count:e.length})}),[]),Pe=(0,a.useCallback)(((e,t)=>{(0,Ge.u4)(Ye.Vi.TaxLotAIParseFileRejected,t),N(e),m.current&&(m.current.value="")}
1),[]),Be=(0,a.useCallback)((e=>{if(N(null),0===e.length)return;const t=[...D,...e];if(t.length>10)return void Pe("Too many files. Maximum is ".concat(10," files total."),{reason:"too_many_files",attempted_file_count:t.length});const n=e.find((e=>!(e=>{const t=e.toLowerCase().substring(e.lastIndexOf("."));return QAe.has(t)})(e.name)));if(n)return void Pe('File "'.concat(n.name,'" is not a supported file type. Accepted types: ').concat(XAe.join(", ")),{reason:"invalid_file_type",file_extension:n.name.substring(n.name.lastIndexOf("."))});const a=e.find((e=>e.size>10485760));a?Pe('File "'.concat(a.name,'" is too large. Maximum size is ').concat(10,"MB per file."),{reason:"file_too_large"}):(R(t),m.current&&(m.current.value=""))}),[D,Pe]),ze=Gte({onDrop:Be}),Fe=ze.isDragOver,Ue=ze.dragHandlers,Ve=(0,a.useCallback)((()=>{var e;null===(e=m.current)||void 0===e||e.click()}),[]),We=(0,a.useCallback)((e=>{var t;Be(Array.from(null!==(t=e.target.files)&&void 0!==t?t:[]))}),[Be]),je=(0,a.useCallback)((e=>{R(D.filter(((t,n)=>n!==e))),m.current&&(m.current.value="")}
1),[D]),He=(0,a.useCallback)((async()=>{if(0===D.length)return;(0,Ge.u4)(Ye.Vi.TaxLotAIParseClicked,{num_files_uploaded:D.length});const e=await g(D);if(e)if(Array.isArray(e))try{const n=(await t(e,oe||void 0)).unmatchedLots;n.length>0?Oe(n):l()}catch(n){N(n instanceof Error?n.message:"Failed to import tax lots")}else e.unsupported&&(N(e.displayMessage),R([]),m.current&&(m.current.value=""))}),[D,g,t,oe,l,Oe]),Ke=(0,a.useCallback)((async()=>{(0,Ge.u4)(Ye.Vi.TaxLotManuallyAdded,{source:"import_modal"});const e={acquisitionDate:ge||void 0,quantity:Ee,costBasisPerUnit:null!==we&&void 0!==we?we:void 0!==ke&&Ee?ke/Ee:void 0,confidence:1};try{ae(!0),await n([{lot:e,holdingId:de}]),l()}catch(t){N(t instanceof Error?t.message:"Failed to add tax lot")}finally{ae(!1)}}),[de,ge,Ee,we,ke,n,l]),qe=(0,a.useCallback)((async()=>{const e=F.map(((e,t)=>{var n;return{lot:e,holdingId:null!==(n=W[t])&&void 0!==n?n:""}})).filter((e=>e.holdingId));try{await n(e),(0,Ge.u4)(Ye.Vi.TaxLotReconciliationCompleted,{lots_assigned:e.length,unmatched_count:F.length}),l()}catch(t){N(t instanceof Error?t.message:"Failed to finalize tax lots")}}),[F,W,n,l]),$e=(0,a.useCallback)((()=>{v?C():l()}),[v,C,l]),Ze=(0,a.useCallback)((()=>{h(),A(),l()}),[h,A,l]),Je=(null!==u&&void 0!==u?u:[]).length>0,Xe=F.length>0&&F.every(((e,t)=>!!W[t])),Qe=!!de&&!!ge&&void 0!==Ee&&!isNaN(Ee)&&Ee>0&&(void 0!==we||void 0!==ke);return a.createElement(um.b,{"data-external-id":"add-tax-lot-modal",onClose:$e,maxWidth:"600px",nonDismissable:i,animate:!v},a.createElement(Rc.L,{title:"Import tax lots"},a.createElement(qY.S,null,O===JAe.Review&&a.createElement(UAe,{unmatchedLots:F,holdingOptions:Re,lotAssignments:W,onAssignmentChange:(e,t)=>
1{j((n=>(0,U.A)((0,U.A)({},n),{},{[e]:t}))),(0,Ge.u4)(Ye.Vi.TaxLotReconciliationLotAssigned,{method:"individual"})},bulkHoldingId:q,onBulkHoldingChange:$,onApplyBulk:()=>{if(!q)return;const e={};F.forEach(((t,n)=>{e[n]=q})),j(e),(0,Ge.u4)(Ye.Vi.TaxLotReconciliationLotAssigned,{method:"bulk",lots_assigned_count:F.length})}}),O===JAe.Upload&&!Je&&a.createElement(xt.v,{className:"text-sm/normal text-content-secondary"},"You need to add a holding to this account before you can import tax lots."),O===JAe.Upload&&Je&&a.createElement(a.Fragment,null,a.createElement(xt.v,{className:"text-base/normal text-content-secondary"},"Upload files or screenshots for any of your holdings to automatically pre-populate their tax lot details. You can also add tax lots manually."),a.createElement("div",{className:"flex justify-start"},a.createElement(Dc.t,{index:X?1:0,onChangeIndex:e=>Q(1===e)},a.createElement(MA.c,null,a.createElement(RA.Q,{index:0,$background:"base"},"Upload document"),a.createElement(RA.Q,{index:1,$background:"base"},"Manually")))),a.createElement(z7.P,{text:""}),s&&s.length>0&&a.createElement(Eu.lV,{initialValues:{account:oe},onSubmit:()=>{},enableReinitialize:!0},a.createElement(tC.zB.Select,{label:"Account",name:"account",options:De,placeholder:"Select account",onValueChanged:(e,t)=>{ie(null!==t&&void 0!==t?t:""),null===d||void 0===d||d(t||void 0),ue("")}})),X?a.createElement(YAe,{holdingOptions:Re,selectedHoldingId:de,onHoldingChange:ue,acquisitionDate:ge,onDateChange:he,acquisitionQuantity:Ee,onQuantityChange:ye,costBasisPerUnit:we,onCostBasisPerUnitChange:Me,totalCostBasis:ke,onTotalCostBasisChange:Le}):a.createElement(zAe,{fileInputRef:m,selectedFiles:D,isDragOver:Fe,dragHandlers:Ue,isBusy:Te,accept:XAe.join(","),onButtonClick:Ve,onFileChange:We,onRemoveFile:je}),Ne&&a.createElement(tIe,null,Ne)),O===JAe.Review&&Ne&&a.createElement(tIe,null,Ne)),a.createElement(Cq.R,null,a.createElement(wt.Xb,{onClick:$e,disabled:i},"Cancel"),O===JAe.Review&&a.createElement(cu.WT,{onClick:qe,disabled:!Xe||Te},i?"Finalizing...":"Finalize"),O===JAe.Upload&&Je&&X&&a.createElement(cu.WT,{onClick:Ke,disabled:!Qe||ne},ne?"Adding...":"Add"),O===JAe.Upload&&Je&&!X&&a.createElement(cu.WT,{onClick:He,disabled:0===D.length||Te||!(null===s||void 0===s||!s.length)&&!oe},i?"Finalizing...":v?E===jAe?"Uploading...":E===HAe?"Processing...":E===KAe?"Analyzing...":E===qAe?"Reviewing...":"Processing...":"Upload"))),a.createElement(x,{maxWidth:"600px"},a.createElement(xC.$,{title:"Cancel import?",confirm:"Cancel import",cancel:"Keep waiting",onConfirm:Ze,onCancel:A,useDangerButton:!0},"The import will be stopped and no tax lots will be added.")))},tIe=e=>{let t=e.children;return a.createElement("div",{"data-external-id":"error-banner",className:"mt-sm rounded-sm bg-background-danger p-sm text-content-danger"},a.createElement(xt.v,{className:"text-sm"},t))};let nIe=function(e){return e.Default="default",e.MarketWeight="market_weight",e.Reference="reference",e.Manual="manual",e}({});const aIe=[{value:"cash",label:"Cash"},{value:"us_bonds",label:"U.S. Bonds"},{value:"international_bonds",label:"Intl. Bonds"},{value:"us_stocks",label:"U.S. Stocks"},{value:"international_stocks",label:"Intl. Stocks"},{value:"alternatives",label:"Alternatives"}],lIe={us_stocks:[{value:"us_large_cap_value",label:"Large Cap Value"},{value:"us_large_cap_blend",label:"Large Cap Blend"},{value:"us_large_cap_growth",label:"Large Cap Growth"},{value:"us_mid_cap_value",label:"Mid Cap Value"},{value:"us_mid_cap_blend",label:"Mid Cap Blend"},{value:"us_mid_cap_growth",label:"Mid Cap Growth"},{value:"us_small_cap_value",label:"Small Cap Value"},{value:"us_small_cap_blend",label:"Small Cap Blend"},{value:"us_small_cap_growth",label:"Small Cap Growth"}],international_stocks:[{value:"international_developed",label:"Developed"},{value:"international_emerging",label:"Emerging"}],us_bonds:[{value:"us_government_bonds",label:"Government"},{value:"us_corporate_bonds",label:"Corporate"},{value:"us_municipal_bonds",label:"Municipal"}],international_bonds:[{value:"international_government_bonds",label:"Government"},{value:"international_corporate_bonds",label:"Corporate"}],alternatives:[{value:"real_estate",label:"Real Estate"},{value:"reits",label:"REITs"},{value:"commodities",label:"Commodities"},{value:"crypto",label:"Crypto"},{value:"hedge_funds",label:"Hedge Funds"},{value:"private_equity",label:"Private Equity"}]},rIe=(0,U.A)((0,U.A)({},Object.fromEntries(aIe.map((e=>[e.value,e.label])))),Object.fromEntries(Object.values(lIe).flat().map((e=>[e.value,e.label])))),oIe={us_high_yield_bonds:"us_corporate_bonds",us_investment_grade_bonds:"us_corporate_bonds",tips:"us_government_bonds",long_term_treasuries:"us_government_bonds",intermediate_treasuries:"us_government_bonds",short_term_treasuries:"us_government_bonds"},iIe={equity:"us_stocks",fixed_income:"us_bonds",cash:"cash",real_estate:"real_estate",cryptocurrency:"crypto",alternative:"alternatives"},sIe=(e,t)=>!e&&!t.useMarketWeight&&t.subSlices.length>0,cIe=e=>"group-".concat(e),dIe=(e,t)=>"".concat(e,"-sub-").concat(t),uIe=e=>e.filter((e=>e.breakdownMode!==nIe.Reference)).map(((e,t)=>{var n;const a=cIe(t),l=e.breakdownMode===nIe.MarketWeight,r=null!==(n=lIe[e.allocationSlug])&&void 0!==n?n:[],o=new Map(e.subSlices.map((e=>[e.allocationSlug,e.percentage]))),i=e.subSlices.length>0?r.map(((t,n)=>{const l=o.get(t.value);return{uid:dIe(a,n),allocationSlug:t.value,percentageStr:void 0!==l?String(Math.round(l*e.percentage*1e4)/100):""}})):[],s=r.map(((e,t)=>({uid:dIe(a,t),allocationSlug:e.value,percentageStr:""})));return{uid:a,allocationSlug:e.allocationSlug,percentageStr:String(Math.round(1e4*e.percentage)/100),useMarketWeight:l,subSlices:e.breakdownMode===nIe.Manual?i:s}})),mIe=e=>({uid:e,allocationSlug:"",percentageStr:"",useMarketWeight:!0,subSlices:[]}),pIe=(e,t)=>{var n;const a=null!==(n=lIe[e.allocationSlug])&&void 0!==n?n:[],l=(parseFloat(e.percentageStr)||0)/100,r=new Map;for(const d of t){var o,i;const e=null!==(o=oIe[d.category.slug])&&void 0!==o?o:d.category.slug;r.set(e,(null!==(i=r.get(e))&&void 0!==i?i:0)+d.weight)}const s=a.reduce(((e,t)=>{var n;return e+(null!==(n=r.get(t.value))&&void 0!==n?n:0)}),0),c=s>0?1/s:0;return a.map(((t,n)=>{var a;return{uid:dIe(e.uid,n),allocationSlug:t.value,percentageStr:String(Math.round((null!==(a=r.get(t.value))&&void 0!==a?a:0)*c*l*1e4)/100)}}))},gIe=(e,t)=>{const n=new Set(aIe.map((e=>e.value))),a=new Map(t.map((e=>[e.id,e.slug]))),l=new Map(t.map((e=>{var t,n;return[e.id,null!==(t=null===(n=e.parent)||void 0===n?void 0:n.id)&&void 0!==t?t:null]}))),r=function(e){var t;let o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new Set;if(!e||o.has(e))return null;const i=a.get(e);return i&&n.has(i)?i:r(null!==(t=l.get(e))&&void 0!==t?t:null,new Set([...o,e]))},i=e.flatMap((e=>{var t,n;let l=e.weight,o=e.category;const i=r(o.id);if(!i)return[];const s=a.get(o.id),c=null!==(t=null===(n=lIe[i])||void 0===n?void 0:n.map((e=>e.value)))&&void 0!==t?t:[],d=!!s&&c.includes(s)&&s!==i,u=s?oIe[s]:void 0,m=!!u&&c.includes(u);let p=null;return d&&s?p=s:m&&u&&(p=u),[{topSlug:i,subSlug:p,weight:l}]})),s=i.reduce(((e,t)=>{var n;
1let a=t.topSlug,l=t.weight;return(0,U.A)((0,U.A)({},e),{},{[a]:(null!==(n=e[a])&&void 0!==n?n:0)+l})}),{}),c=i.reduce(((e,t)=>{var n,a;let l=t.topSlug,r=t.subSlug,o=t.weight;return r?(0,U.A)((0,U.A)({},e),{},{[l]:(0,U.A)((0,U.A)({},e[l]),{},{[r]:(null!==(n=null===(a=e[l])||void 0===a?void 0:a[r])&&void 0!==n?n:0)+o})}):e}),{});return Object.entries(s).filter((e=>(0,o.A)(e,2)[1]>.001)).map(((e,t)=>{var n,a;let l=(0,o.A)(e,2),r=l[0],i=l[1];const s=cIe("provider-".concat(t)),d=c[r],u=null!==(n=null===(a=lIe[r])||void 0===a?void 0:a.map((e=>e.value)))&&void 0!==n?n:[],m=u.map(((e,t)=>{var n;return{uid:dIe(s,t),allocationSlug:e,percentageStr:d?String(Math.round(1e4*(null!==(n=d[e])&&void 0!==n?n:0))/100):""}})),p=u.length>0&&m.some((e=>(parseFloat(e.percentageStr)||0)>0)),g=u.length>0&&!p;return{uid:s,allocationSlug:r,percentageStr:String(Math.round(1e4*i)/100),useMarketWeight:g,subSlices:m}}))};var hIe,vIe,fIe,EIe,yIe,bIe=n(11311);const xIe=e=>{var t,n;let l=e.group,r=e.onChange,o=e.onRemove,i=e.disabled,s=void 0!==i&&i,c=e.weightTooltip;const d=(0,a.useId)(),u=null!==(t=rIe[l.allocationSlug])&&void 0!==t?t:l.allocationSlug,m=(null!==(n=lIe[l.allocationSlug])&&void 0!==n?n:[]).length>0,p=((e,t,n)=>null!==e&&void 0!==e?e:sIe(t,n)?"Asset class weights are the total of the sub-class weights below.":void 0)(c,s,l);return a.createElement("div",{"data-external-id":"classification-group-row"},a.createElement("div",{className:"flex w-full items-end gap-sm"},a.createElement("div",{className:"min-w-0 flex-1"},a.createElement(IIe,null,"Asset class"),s?a.createElement("div",{className:"flex h-10 items-center rounded-sm border border-input-default-border bg-background-secondary px-sm"},a.createElement(kD.c,{size:"base",color:"secondary"},u)):a.createElement(qV.h,{options:aIe,value:l.allocationSlug||null,onValueChange:e=>{var t;const n=(null!==(t=lIe[e])&&void 0!==t?t:[]).map(((e,t)=>({uid:wIe(d,t),allocationSlug:e.value,percentageStr:""}))),a=!l.useMarketWeight&&n.length>0?"":l.percentageStr;r((0,U.A)((0,U.A)({},l),{},{allocationSlug:e,subSlices:n,percentageStr:a}))},placeholder:"Select asset class"})),a.createElement("div",{className:"w-22 shrink-0 text-right"},a.createElement(IIe,{className:"pr-xs"},"Weight"),a.createElement(AIe,{value:l.percentageStr,disabled:s||sIe(s,l),onChange:e=>r((0,U.A)((0,U.A)({},l),{},{percentageStr:e})),tooltip:p}))),m&&!s&&a.createElement(kIe,null,a.createElement(fz.hm,{id:"".concat(d,"-market-weight"),checked:l.useMarketWeight,onChange:e=>{return t=e.target.checked,void r((0,U.A)((0,U.A)({},l),{},{useMarketWeight:t}));var t},size:16}),a.createElement("label",{htmlFor:"".concat(d,"-market-weight"),style:{cursor:"pointer"}},a.createElement(kD.c,{size:"sm"},"Use market weight")),a.createElement(P.D_,{maxWidth:260,content:a.createElement(P.fn,null,a.createElement("p",null,"Automatically weights each asset class by market capitalization for a market-neutral starting point, without entering custom allocations."))},a.createElement("span",{className:"inline-flex shrink-0 cursor-default items-center text-content-secondary"},a.createElement(fe.ucZ,{size:"xs"})))),l.subSlices.length>0&&a.createElement(SIe,null,l.subSlices.map(((e,t)=>{var n;const o=null!==(n=rIe[e.allocationSlug])&&void 0!==n?n:e.allocationSlug,i=s||l.useMarketWeight;return a.createElement(NIe,{key:e.uid},a.createElement(CIe,null),a.createElement("div",{className:"min-w-0 flex-1"},a.createElement(TIe,null,o)),a.createElement("div",{className:"w-22 shrink-0 text-right"},a.createElement(AIe,{value:e.percentageStr,disabled:i,onChange:e=>((e,t)=>{const n=[...l.subSlices];n[e]=(0,U.A)((0,U.A)({},n[e]),{},{percentageStr:t});const a=n.reduce(((e,t)=>e+(parseFloat(t.percentageStr)||0)),0),o=String(Math.round(100*a)/100);r((0,U.A)((0,U.A)({},l),{},{subSlices:n,percentageStr:o}))})(t,e),tooltip:c})))}))),!s&&a.createElement(Wb.X,{variant:"text",colorScheme:"red",icon:a.createElement(fe.i01,{size:"sm"}),onClick:o,className:"mt-sm h-auto gap-2xs py-0 pr-0 ".concat(l.subSlices.length>0?"pl-13":"pl-sm")},"Remove classification"))},wIe=(e,t)=>"".concat(e,"-sub-").concat(t),CIe=()=>a.createElement("svg",{"data-external-id":"subclass-connector",width:"25",height:"37",viewBox:"0 0 25 37",fill:"none","aria-hidden":"true",style:{position:"absolute",left:-33,top:-16,flexShrink:0,pointerEvents:"none"}},a.createElement("path",{d:"M0.5 0V20C0.5 28.8366 7.66345 36 16.5 36H24.5",stroke:"var(--input-default-border)"})),AIe=e=>{let t=e.value,n=e.disabled,l=e.onChange,r=e.tooltip;const o=""===t?null:Number(t),i=null!==o&&Number.isNaN(o)?null:o,s=a.createElement(Lxe.i,{disabled:n,className:r?"pointer-events-none":void 0}
1,a.createElement(bIe._,{min:0,max:100,step:.01,placeholder:"0",value:i,onValueChange:e=>null===l||void 0===l?void 0:l(null===e?"":String(e)),className:"text-right"}),a.createElement(Lxe.i.Addon,{align:"inline-end"},a.createElement(Lxe.i.Text,null,"%")));return r?a.createElement(Wi.Y,{"data-external-id":"weight-field",content:r,side:"left",align:"center",sideOffset:12,collisionAvoidance:{side:"none"},contentClassName:"max-w-65"},a.createElement("span",{className:"inline-block w-full cursor-default"},s)):s},IIe=(0,$d.s)(kD.c).attrs({size:"sm",weight:"medium"})(hIe||(hIe=(0,wc.A)(["mb-xs block"]))),kIe=$d.s.div(vIe||(vIe=(0,wc.A)(["\n  relative mt-sm flex items-center gap-xs pl-13\n  before:absolute before:-top-3 before:bottom-0 before:left-4.75 before:w-px\n  before:bg-input-default-border before:content-['']\n"]))),SIe=$d.s.div(fIe||(fIe=(0,wc.A)(["relative mt-default pl-13"]))),NIe=$d.s.div(EIe||(EIe=(0,wc.A)(["\n  relative flex w-full items-center gap-sm\n  not-last:after:absolute not-last:after:top-0 not-last:after:-bottom-4.75 not-last:after:-left-8.25\n  not-last:after:w-px not-last:after:bg-input-default-border not-last:after:content-['']\n  [&+&]:mt-default\n"]))),TIe=(0,$d.s)(kD.c).attrs({size:"sm",weight:"medium"})(yIe||(yIe=(0,wc.A)(["flex h-9 items-center"])));var _Ie=n(50094),DIe=n(50163),RIe=n(22647);const MIe=e=>{var t,n,l,r,s;let c=e.target,d=e.existingClassification,u=e.holdingCategoryWeights,m=e.onSaved;const p="security"===c.type?c.securityId:c.holdingId,g=(0,a.useId)(),h=(0,et.I)(_Ie.QV).data,v=null!==(t=null===h||void 0===h||null===(n=h.myHousehold)||void 0===n?void 0:n.allocationCategories)&&void 0!==t?t:[],f=u&&v.length>0?Object.fromEntries(gIe(u,v).map((e=>[e.allocationSlug,{slices:e.subSlices,topPct:(parseFloat(e.percentageStr)||100)/100}]))):{},E=d&&(null===(y=d.slices[0])||void 0===y?void 0:y.breakdownMode)!==nIe.Reference?uIe(d.slices):u&&v.length>0?gIe(u,v):[];var y;const b=!!d&&1===d.slices.length&&d.slices[0].breakdownMode===nIe.Reference,x=(null!==(l=null===u||void 0===u?void 0:u.length)&&void 0!==l?l:0)>0,w=(0,a.useState)((()=>b?"proxy":d?"manual":null!==u&&void 0!==u&&u.length?"default":"proxy")),A=(0,o.A)(w,2),I=A[0],k=A[1],S=(0,a.useState)((()=>d&&!b?uIe(d.slices):[mIe(cIe("".concat(g,"-0")))])),N=(0,o.A)(S,2),T=N[0],_=N[1],D=b&&null!==(r=null===d||void 0===d?void 0:d.slices[0].referenceSecurityId)&&void 0!==r?r:null,R=(0,a.useState)(null),M=(0,o.A)(R,2),L=M[0],O=M[1],P=(0,a.useState)(""),B=(0,o.A)(P,2),z=B[0],F=B[1],G=(0,xy.d)(z,RIe.N),Y=(0,et.I)(DIe.r0,{variables:{search:G,limit:10},skip:G.length<1}),V=Y.data,W=Y.isNetworkRequestInFlight,j=(null!==(s=null===V||void 0===V?void 0:V.securities)&&void 0!==s?s:[]).map((e=>({value:e.id,label:e.ticker?"".concat(e.ticker," \u2013 ").concat(e.name):e.name}))),H=(0,et.I)(_Ie.Nk,{variables:{id:null!==D&&void 0!==D?D:""},skip:!D||null!==L}).data,K=(0,i.n)(_Ie.th),q=(0,o.A)(K,1)[0],$=(0,i.n)(_Ie.g7),Z=(0,o.A)($,1)[0],J=(0,i.n)(_Ie.UW),X=(0,o.A)(J,1)[0],Q=(0,i.n)(_Ie.lZ),ee=(0,o.A)(Q,1)[0],te=["Web_GetAllocationBreakdown","Web_GetAllocation","Web_GetPortfolio","Web_GetPortfolioWithClassification"],ne=async e=>{var t,n,a,l;if("security"===c.type){var r,o,i,s;return null!==(r=null===(o=(await q({variables:{input:{securityId:c.securityId,slices:e}},refetchQueries:te})).data)||void 0===o||null===(i=o.setSecurityClassification)||void 0===i||null===(s=i.errors)||void 0===s?void 0:s.message)&&void 0!==r?r:void 0}return null!==(t=null===(n=(await X({variables:{input:{holdingId:c.holdingId,slices:e}},refetchQueries:te})).data)||void 0===n||null===(a=n.setHoldingClassification)||void 0===a||null===(l=a.errors)||void 0===l?void 0:l.message)&&void 0!==t?t:void 0},ae=(0,NV._)(_Ie.vr),le=(0,o.A)(ae,1)[0],re=(0,a.useRef)({}),oe=(0,a.useRef)({}),ie=e=>{oe.current=(0,U.A)((0,U.A)({},oe.current),Object.fromEntries(e.map((e=>[e.slug,e.weights]))))},se=(0,a.useRef)(!0),ce=(0,a.useRef)(!1),de=(0,a.useRef)(Promise.resolve()),ue=(0,a.useRef)(T);ue.current=T;const me=(0,xy.d)(T,200),pe=(0,xy.d)(L,200),ge=(0,a.useRef)(!1);(0,a.useEffect)((()=>{if(ge.current)return;const e=null===H||void 0===H?void 0:H.security;if(!e)return;const t=e.ticker?"".concat(e.ticker," \u2013 ").concat(e.name):e.name;ge.current=!0,O({value:e.id,label:t}),F(t)}),[H]),(0,a.useEffect)((()=>
1{if(se.current)return void(se.current=!1);de.current=de.current.then((async()=>{try{if("default"===I){const e=await(async()=>{var e,t,n,a,l,r,o,i;return"security"===c.type?null!==(l=null===(r=(await Z({variables:{securityId:c.securityId},refetchQueries:te})).data)||void 0===r||null===(o=r.clearSecurityClassification)||void 0===o||null===(i=o.errors)||void 0===i?void 0:i.message)&&void 0!==l?l:void 0:null!==(e=null===(t=(await ee({variables:{holdingId:c.holdingId},refetchQueries:te})).data)||void 0===t||null===(n=t.clearHoldingClassification)||void 0===n||null===(a=n.errors)||void 0===a?void 0:a.message)&&void 0!==e?e:void 0})();if(e)throw new Error(e);return ce.current&&(0,Ge.u4)(Ye.Vi.AllocationHoldingReclassified,{mode:"cleared",target_type:c.type}),void(null===m||void 0===m||m())}if("proxy"===I){var e,t;if(!pe)return;if(pe.value===D)return;const n=null===V||void 0===V?void 0:V.securities.find((e=>e.id===pe.value)),a=null!==(e=iIe[null!==(t=null===n||void 0===n?void 0:n.type)&&void 0!==t?t:""])&&void 0!==e?e:"stocks",l=await ne([{allocationSlug:a,percentage:1,breakdownMode:nIe.Reference,referenceSecurityId:pe.value}]);if(l)throw new Error(l)}else{if(me!==ue.current)return;const e=me.filter((e=>(parseFloat(e.percentageStr)||0)>0));if(0===e.length)return;const t=e.reduce(((e,t)=>e+(parseFloat(t.percentageStr)||0)),0);if(Math.abs(t-100)>=.1)return;const n=await ne((e=>e.map((e=>{const t=(parseFloat(e.percentageStr)||0)/100;if(e.useMarketWeight)return{allocationSlug:e.allocationSlug,percentage:t,breakdownMode:nIe.MarketWeight};if(e.subSlices.length>0){const n=e.subSlices.filter((e=>(parseFloat(e.percentageStr)||0)>0));return 0===n.length?{allocationSlug:e.allocationSlug,percentage:t,breakdownMode:nIe.MarketWeight}:{allocationSlug:e.allocationSlug,percentage:t,breakdownMode:nIe.Manual,subSlices:n.map((e=>({allocationSlug:e.allocationSlug,percentage:t>0?(parseFloat(e.percentageStr)||0)/100/t:0,breakdownMode:nIe.Default})))}}return{allocationSlug:e.allocationSlug,percentage:t,breakdownMode:nIe.Default}})))(e));if(n)throw new Error(n)}ce.current&&(0,Ge.u4)(Ye.Vi.AllocationHoldingReclassified,{mode:"proxy"===I?"proxy":"manual",target_type:c.type}),null===m||void 0===m||m()}catch(n){const e=n instanceof Error?n.message:"Please try again.";(0,C.oR)({title:"Failed to save",description:e,duration:4e3})}}))}),[I,me,pe,p]),(0,a.useEffect)((()=>{for(const t of Object.entries(f)){var e=(0,o.A)(t,2);const n=e[0],a=e[1];a.slices.length>0&&!re.current[n]&&(re.current[n]=a)}}),[v,u]),(0,a.useEffect)((()=>{const e=T.map(((e,t)=>({group:e,index:t}))).filter((e=>{let t=e.group;return t.useMarketWeight&&t.allocationSlug}));0!==e.length&&Promise.all(e.map((e=>{let t=e.group,n=e.index;return le({variables:{slug:t.allocationSlug}}).then((e=>{var a,l,r;return{index:n,slug:t.allocationSlug,weights:null!==(a=null===(l=e.data)||void 0===l||null===(r=l.allocationCategory)||void 0===r?void 0:r.marketWeights)&&void 0!==a?a:[]}}))}))).then((e=>{ie(e),_((t=>t.map(((t,n)=>{const a=e.find((e=>e.index===n));return a&&t.useMarketWeight&&t.allocationSlug===a.slug?(0,U.A)((0,U.A)({},t),{},{subSlices:pIe(t,a.weights)}):t}))))}))}),[]);const he=(e,t)=>_((n=>n.map(((n,a)=>a===e?t:n)))),ve=(e=>e.reduce(((e,t)=>e+(parseFloat(t.percentageStr)||0)),0))(T),fe=Math.abs(ve-100)<.1;return{idSeed:g,mode:I,groups:T,mirrorSecurity:L,setMirrorSecurity:e=>{ce.current=!0,O(e)},searchQuery:z,setSearchQuery:F,securityOptions:j,isSearching:W,providerGroups:E,hasProviderData:x,total:ve,isTotalValid:fe,handleAddGroup:()=>{ce.current=!0,_((e=>[...e,mIe(cIe("".concat(g,"-").concat(e.length)))]))},handleGroupChange:(e,t)=>
1{ce.current=!0;const n=T[e];if(!t.useMarketWeight&&null!==n&&void 0!==n&&n.useMarketWeight&&t.allocationSlug){var a,l;const n=re.current[t.allocationSlug],r=null!==n&&void 0!==n&&null!==(a=n.slices)&&void 0!==a&&a.length?n.slices:t.subSlices,o=null!==(l=null===n||void 0===n?void 0:n.topPct)&&void 0!==l?l:1,i=(parseFloat(t.percentageStr)||0)/100,s=o>0?i/o:1,c=r.map((e=>(0,U.A)((0,U.A)({},e),{},{percentageStr:String(Math.round((parseFloat(e.percentageStr)||0)*s*100)/100)})));return void he(e,(0,U.A)((0,U.A)({},t),{},{subSlices:c}))}const r=t.useMarketWeight&&!(null!==n&&void 0!==n&&n.useMarketWeight)&&t.allocationSlug,o=t.useMarketWeight&&t.allocationSlug&&t.allocationSlug!==(null===n||void 0===n?void 0:n.allocationSlug);if(r||o)return he(e,t),t.subSlices.length>0&&(re.current[t.allocationSlug]={slices:t.subSlices,topPct:(parseFloat(t.percentageStr)||100)/100}),void le({variables:{slug:t.allocationSlug}}).then((n=>{var a,l,r;const o=null!==(a=null===(l=n.data)||void 0===l||null===(r=l.allocationCategory)||void 0===r?void 0:r.marketWeights)&&void 0!==a?a:[];ie([{slug:t.allocationSlug,weights:o}]),_((n=>n.map(((n,a)=>a===e&&n.useMarketWeight&&n.allocationSlug===t.allocationSlug?(0,U.A)((0,U.A)({},n),{},{subSlices:pIe(n,o)}):n))))}));if(t.useMarketWeight&&t.allocationSlug===(null===n||void 0===n?void 0:n.allocationSlug)&&t.percentageStr!==(null===n||void 0===n?void 0:n.percentageStr)){const a=((e,t,n)=>{var a;const l=n[e.allocationSlug];if(l)return pIe(e,l);const r=(parseFloat(null!==(a=null===t||void 0===t?void 0:t.percentageStr)&&void 0!==a?a:"")||0)/100,o=(parseFloat(e.percentageStr)||0)/100;return r<=0?e.subSlices:e.subSlices.map((e=>(0,U.A)((0,U.A)({},e),{},{percentageStr:String(Math.round((parseFloat(e.percentageStr)||0)*o*100/r)/100)})))})(t,n,oe.current);he(e,(0,U.A)((0,U.A)({},t),{},{subSlices:a}))}else he(e,t)},handleGroupRemove:e=>{ce.current=!0,_((t=>{const n=t.filter(((t,n)=>n!==e)),a=n.reduce(((e,t)=>e+(parseFloat(t.percentageStr)||0)),0);if(a<=0||100===a)return n;const l=100/a;return n.map((e=>{const t=parseFloat(e.percentageStr)||0,n=Math.round(t*l*100)/100;return(0,U.A)((0,U.A)({},e),{},{percentageStr:String(n),subSlices:e.subSlices.map((e=>(0,U.A)((0,U.A)({},e),{},{percentageStr:t>0?String(Math.round((parseFloat(e.percentageStr)||0)*(n/t)*100)/100):e.percentageStr})))})}))}))},handleSetMode:e=>{if(ce.current=!0,k(e),"manual"===e){F(""),O(null);const e=E.length>0?E:[mIe(cIe("".concat(g,"-0")))];_(e);const t=e.map(((e,t)=>({group:e,index:t}))).filter((e=>{let t=e.group;return t.useMarketWeight&&t.allocationSlug}));t.length>0&&Promise.all(t.map((e=>{let t=e.group,n=e.index;return le({variables:{slug:t.allocationSlug}}).then((e=>{var a,l,r;return{index:n,slug:t.allocationSlug,weights:null!==(a=null===(l=e.data)||void 0===l||null===(r=l.allocationCategory)||void 0===r?void 0:r.marketWeights)&&void 0!==a?a:[]}}))}))).then((e=>{ie(e),_((t=>t.map(((t,n)=>{const a=e.find((e=>e.index===n));return a&&t.useMarketWeight&&t.allocationSlug===a.slug?(0,U.A)((0,U.A)({},t),{},{subSlices:pIe(t,a.weights)}):t}))))}))}else"default"===e&&(F(""),O(null))}}};var LIe=n(53407);const OIe=e=>{let t=e.target,n=e.existingClassification,l=e.holdingCategoryWeights,r=e.isLoadingClassification,i=void 0!==r&&r,s=e.onSaved;const c=MIe({target:t,existingClassification:n,holdingCategoryWeights:l,onSaved:s}),d=c.idSeed,u=c.mode,m=c.groups,p=c.mirrorSecurity,g=c.setMirrorSecurity,h=c.searchQuery,v=c.setSearchQuery,f=c.securityOptions,E=c.isSearching,y=c.providerGroups,b=c.hasProviderData,x=c.total,w=c.isTotalValid,C=c.handleAddGroup,A=c.handleGroupChange,I=c.handleGroupRemove,k=c.handleSetMode,S=a.useRef(null),N=a.useState(0),T=(0,o.A)(N,2),_=T[0],D=T[1],R="security"===t.type?t.securityId:t.holdingId;return a.useLayoutEffect((()=>{var e,t;D(null!==(e=null===(t=S.current)||void 0===t?void 0:t.offsetHeight)&&void 0!==e?e:0)}),[R]),a.useEffect((()=>{const e=S.current;if(!e)return;const t=new ResizeObserver((()=>{const t=e.offsetHeight;D((e=>t>e?t:e))}));return t.observe(e),()=>t.disconnect()}),[]),a.createElement("div",{"data-external-id":"security-classification-section",style:{minHeight:_||void 0}},a.createElement("div",{ref:S,className:"flex flex-col gap-default py-lg"},i?a.createElement(kD.c,{size:"base",weight:"medium"},"Classification"):a.createElement(a.Fragment,null,a.createElement(kD.c,{size:"lg",weight:"medium"},"Classification"),b&&a.createElement("div",{className:"flex items-center gap-xs"},a.createElement(LIe.K.Root,{id:"".concat(d,"-enable"),size:"sm",checked:"default"!==u,onCheckedChange:e=>k(e?"proxy":"default")},a.createElement(LIe.K.Indicator,null)),a.createElement(LIe.K.Label,{htmlFor:"".concat(d,"-enable")},a.createElement(kD.c,{size:"base"},"Override default classification"))),"default"===u&&y.length>0&&a.createElement(PIe,{groups:y,weightTooltip:"Override default classification to change weights."}),"default"!==u&&a.createElement(a.Fragment,null,a.createElement("div",null,a.createElement(kD.c,{size:"sm",weight:"medium",className:"mb-xs block"},"Method"),a.createElement("div",{className:"flex gap-lg"},a.createElement("label",{className:"flex cursor-pointer items-center gap-xs font-[inherit] text-content-primary"},a.createElement("span",{className:"relative inline-flex"},a.createElement("input",{type:"radio",name:"".concat(d,"-mode"),value:"proxy",checked:"proxy"===u,onChange:()=>k("proxy"),className:"absolute inset-0 cursor-pointer opacity-0"}),a.createElement(BIe,{selected:"proxy"===u})),a.createElement(kD.c,{size:"base"},"Ticker weight")),a.createElement("label",{className:"flex cursor-pointer items-center gap-xs font-[inherit] text-content-primary"},a.createElement("span",{className:"relative inline-flex"},a.createElement("input",{type:"radio",name:"".concat(d,"-mode"),value:"manual",checked:"manual"===u,onChange:()=>k("manual"),className:"absolute inset-0 cursor-pointer opacity-0"}),a.createElement(BIe,{selected:"manual"===u})),a.createElement(kD.c,{size:"base"},"Custom percentage")))),"proxy"===u&&a.createElement(U7.O.Root,{items:f,value:p,onValueChange:g,inputValue:h,onInputValueChange:e=>{v(e),0===e.length&&g(null)},loading:E,filter:null,isItemEqualToValue:(e,t)=>
1(null===e||void 0===e?void 0:e.value)===(null===t||void 0===t?void 0:t.value)},a.createElement(U7.O.InputGroup,null,a.createElement(fe.s$r,{size:"md",className:"shrink-0 text-input-default-icon"}),a.createElement(U7.O.Input,{placeholder:"Search for a proxy ticker"})),a.createElement(U7.O.Content,null,a.createElement(U7.O.Loading,null),a.createElement(U7.O.Empty,null,0===h.trim().length?"Type a ticker or name to search\u2026":'No matches for "'.concat(h,'"')),a.createElement(U7.O.List,null,(e=>a.createElement(U7.O.Option,{key:e.value,value:e},e.label))))),"proxy"===u&&p&&y.length>0&&a.createElement(PIe,{groups:y,weightTooltip:"Select custom percentage to change weights."}),"manual"===u&&a.createElement(a.Fragment,null,a.createElement("div",{className:"flex flex-col"},m.map(((e,t)=>a.createElement(a.Fragment,{key:e.uid},t>0&&a.createElement(wm.A,{className:"my-xl"}),a.createElement(xIe,{group:e,onChange:e=>A(t,e),onRemove:()=>I(t)}))))),a.createElement(wm.A,null),a.createElement("div",{className:"flex items-center justify-between"},a.createElement(kD.c,{size:"base",weight:"medium"},"Total"),a.createElement(kD.c,{size:"base",weight:"medium",color:w?"primary":"danger"},x%1===0?x:x.toFixed(2),"%")),a.createElement(Wb.X,{variant:"default",size:"md",icon:a.createElement(fe.Wa3,{size:"sm"}),onClick:C,className:"mt-xs self-start"},"Add classification group"))))))},PIe=e=>{let t=e.groups,n=e.weightTooltip;if(0===t.length)return null;const l=t.reduce(((e,t)=>e+(parseFloat(t.percentageStr)||0)),0);return a.createElement("div",{"data-external-id":"read-only-groups-from-state",className:"flex flex-col"},t.map(((e,t)=>a.createElement(a.Fragment,{key:e.uid},t>0&&a.createElement(wm.A,{className:"my-xl"}),a.createElement(xIe,{group:e,onChange:()=>{},onRemove:()=>{},disabled:!0,weightTooltip:n})))),a.createElement("div",{className:"mt-xl flex items-center justify-between border-t border-divider-primary py-xl"},a.createElement(kD.c,{size:"base",weight:"medium"},"Total"),a.createElement(kD.c,{size:"base",weight:"medium"},l%1===0?l:l.toFixed(2),"%")))},BIe=e=>e.selected?a.createElement("div",{"data-external-id":"method-radio-indicator","aria-hidden":!0,className:"flex size-4 shrink-0 items-center justify-center rounded-full bg-background-brand"},a.createElement("span",{className:"size-1.5 rounded-full bg-content-white"})):a.createElement("div",{"data-external-id":"method-radio-indicator","aria-hidden":!0,className:"size-4 shrink-0 rounded-full border border-border-secondary"});var zIe,FIe=n(38437),GIe=n(84348);const YIe=e=>{var t;let n=e.account,r=e.quantity,o=e.value;const i=(0,l.Zp)();return a.createElement(UIe,{"data-external-id":"investments-holding-drawer-account-row",onClick:()=>{(null===n||void 0===n?void 0:n.id)&&i(I.JZ.accounts.accountDetails({id:n.id}))}},a.createElement(Gl.v,{logoUrl:n.logoUrl,icon:n.icon,size:40}),a.createElement(VIe,null,a.createElement(WIe,null,a.createElement(xt.v,null,null===n||void 0===n?void 0:n.displayName),a.createElement(xt.v,{size:"xsmall",color:"textLight"},null===(t=n.subtype)||void 0===t?void 0:t.display)),a.createElement(jIe,null,a.createElement(xt.v,{size:"base",color:"text",align:"right"},(0,rl.vv)(o)),a.createElement(xt.v,{size:"xsmall",color:"textLight",align:"right"},(0,GIe.Zj)("".concat((0,De.LN)(null!==r&&void 0!==r?r:0)," ").concat(nie()("share",null!==r&&void 0!==r?r:0)))))))},UIe=$d.s.div(zIe||(zIe=(0,wc.A)(["\n  -mx-xl flex cursor-pointer items-center gap-sm px-xl py-sm transition-colors\n  not-last:border-b not-last:border-divider-primary\n  hover:bg-background-secondary\n"]))),VIe=(0,u.default)(m.g).withConfig({displayName:"InvestmentsHoldingDrawerAccountRow__SecurityInfoContainer",componentId:"lqernh-0"})(["flex:1;gap:",";align-items:center;justify-content:space-between;"],(e=>e.theme.spacing.xxxsmall)),WIe=(0,u.default)(m.g).withConfig({displayName:"InvestmentsHoldingDrawerAccountRow__GeneralSecurityInfoContainer",componentId:"lqernh-1"})(["flex-direction:column;gap:",";align-items:flex-start;"],(e=>e.theme.spacing.xxxsmall)),jIe=(0,u.default)(m.g).withConfig({displayName:"InvestmentsHoldingDrawerAccountRow__HoldingValueContainer",componentId:"lqernh-2"})(["flex-direction:column;gap:",";align-items:center;> *{width:100%;}"],(e=>e.theme.spacing.xxxsmall));var HIe,KIe=n(41506);const qIe=[{display:"1M",duration:{months:1},longDisplay:"Past Month"},{display:"3M",duration:{months:3},longDisplay:"Past 3 Months"},{display:"6M",duration:{months:6},longDisplay:"Past 6 Months"},{display:"YTD",duration:{days:-N.c9.local().set({day:1,month:1}).diffNow("day").days},longDisplay:"Year to date"},{display:"1Y",duration:{years:1},longDisplay:"Past 1 Year"},{display:"5Y",duration:{years:5},longDisplay:"Past 5 Years"}],$Ie=(0,$d.s)(kD.c).attrs({size:"lg",weight:"medium"}
1)(HIe||(HIe=(0,wc.A)(["pt-lg pb-sm"]))),ZIe=(e,t)=>{var n,l;let r=e.children,i=e.securityId,s=e.securityName,c=e.securityTicker,d=e.securityCurrentPrice,u=e.totalQuantity,m=e.totalValue,p=e.holdings;const g=N.c9.local(),h=(0,a.useState)(1),v=(0,o.A)(h,2),f=v[0],E=v[1],y=qIe,b=y[f],x=b.duration,w=b.longDisplay,C=(0,et.I)(JIe,{variables:{input:{securityIds:i?[i]:[],startDate:g.minus(x).toISODate(),endDate:g.toISODate()}}}),A=C.data,I=C.isNetworkRequestInFlight,k=C.isLoadingInitialData,S=(0,a.useMemo)((()=>{const e=g.minus(x),t=g.diff(e).as("days");return(0,db.A)(0,t).map((t=>{var n;return{date:e.plus({days:t}).toISO(),returnPercent:null!==(n=(0,KIe.d6)([0,10,-10,0]))&&void 0!==n?n:0}}))}),[x]),T=null!==(n=null===A||void 0===A||null===(l=A.securityHistoricalPerformance[0])||void 0===l?void 0:l.historicalChart)&&void 0!==n?n:[];let _,D=0,R=0;if(T&&T.length>0){var M,L,O,P,B,z;D=null!==(M=null===(L=T[0])||void 0===L?void 0:L.value)&&void 0!==M?M:0,R=null!==(O=null===(P=T[T.length-1])||void 0===P?void 0:P.value)&&void 0!==O?O:0;const e=null!==(B=null===(z=T[T.length-1])||void 0===z?void 0:z.returnPercent)&&void 0!==B?B:null;_=null===e?void 0:e/100}const F=I||k;return a.createElement("div",{"data-external-id":"holding-drawer-body",className:"flex flex-col px-xl pt-xl pb-12",ref:t},a.createElement("div",{className:"mb-lg flex flex-col"},a.createElement(kD.c,{weight:"medium",size:"sm"},c),a.createElement(kD.c,{weight:"medium",size:"xl"},s),a.createElement("div",{className:"flex"},a.createElement(kD.c,{weight:"medium",size:"xl"},(0,rl.vv)(d)),a.createElement(El.H,{className:"ml-sm text-base",startAmount:D,endAmount:R,percentChange:_,timeframeDisplay:w}))),(T.length>0||F)&&a.createElement(Dc.t,{index:f,onChangeIndex:e=>E(e)},a.createElement(MA.c,{className:"ml-auto w-max pr-sm"},y.map(((e,t)=>{let n=e.display;return a.createElement(RA.Q,{key:n,index:t,$background:"card"},n)})))),a.createElement("div",{className:"flex flex-col"},a.createElement(FIe.b,{securityId:null!==i&&void 0!==i?i:"",securityName:s,securityTicker:null!==c&&void 0!==c?c:"",dataKey:"returnPercent",data:T.map((e=>({date:e.date,returnPercent:e.returnPercent}))),isLoading:F,emptyComponent:a.createElement("div",{className:" absolute inset-x-lg inset-y-0 flex flex-col items-center justify-center gap-2xs bg-background-secondary/50 "},a.createElement(kD.c,{weight:"medium"},"Historical information missing"),a.createElement(kD.c,null,"The history for this holding is not currently available.")),emptyData:S})),a.createElement("div",{className:"flex flex-col pb-default"},a.createElement($Ie,null,"Summary"),a.createElement("div",{className:"flex justify-between py-xs"},a.createElement(kD.c,null,"Quantity"),a.createElement(kD.c,null,(0,GIe.oH)((0,De.LN)(null!==u&&void 0!==u?u:0)))),a.createElement("div",{className:"flex justify-between py-xs"},a.createElement(kD.c,null,"Value"),a.createElement(kD.c,null,(0,rl.vv)(m)))),a.createElement("div",{className:"-mx-xl border-t border-divider-primary"}),a.createElement("div",{className:"flex flex-col pb-default"},a.createElement($Ie,null,"Accounts"),null===p||void 0===p?void 0:p.map((e=>e.account&&a.createElement(YIe,{key:e.account.id,account:e.account,quantity:e.quantity,value:e.value})))),r&&a.createElement(a.Fragment,null,a.createElement("div",{className:"-mx-xl border-t border-divider-primary"}),r))},JIe=Ee.Tnz,XIe=a.forwardRef(ZIe),QIe=e=>{var t,n,l,r,i,s,c;let d=e.holdingAggregate,u=e.onClose,m=e.showManualClassification,p=void 0!==m&&m;const g=null!==(t=null===d||void 0===d?void 0:d.holdings)&&void 0!==t?t:[],h=(0,o.A)(g,1)[0],v=null===d||void 0===d||null===(n=d.security)||void 0===n?void 0:n.id,f=null===h||void 0===h?void 0:h.id,E=(0,P6.f)().isSponsored,y=(0,qG.e)().hasAccess,b=(0,nG.p)("feat-investments-allocation_manual_classification-web","off"),x=eke(v,f),w=v?null===h||void 0===h?void 0:h.securityClassification:null===h||void 0===h?void 0:h.holdingClassification;return a.createElement(F7.v,{"data-external-id":"investments-holding-drawer",onClose:u},a.createElement(XIe,{totalQuantity:null===d||void 0===d?void 0:d.quantity,totalValue:null===d||void 0===d?void 0:d.totalValue,securityId:v,securityName:null!==(l=null===d||void 0===d||null===(r=d.security)||void 0===r?void 0:r.name)&&void 0!==l?l:null===h||void 0===h?void 0:h.name,securityTicker:null!==(i=null===d||void 0===d||null===(s=d.security)||void 0===s?void 0:s.ticker)&&void 0!==i?i:null===h||void 0===h?void 0:h.ticker,securityCurrentPrice:null===d||void 0===d||null===(c=d.security)||void 0===c?void 0:c.currentPrice,holdings:null===d||void 0===d?void 0:d.holdings},p&&x&&!E&&y&&b&&a.createElement(OIe,{key:"security"===x.type?x.securityId:x.holdingId,target:x,existingClassification:w,holdingCategoryWeights:null===h||void 0===h?void 0:h.allocationCategoryWeights})))},eke=(e,t)=>e?{type:"security",securityId:e}:t?{type:"holding",holdingId:t}:void 0;var tke;const nke=(0,a.forwardRef)(((e,t)=>{let n=e.title,l=e.titleAdornment,r=e.tabs,o=e.controls,i=e.children;return a.createElement("div",{"data-external-id":"investments-graph-card",ref:t,className:"overflow-hidden rounded-md bg-background-primary shadow-card"},a.createElement("div",{className:"flex flex-col gap-sm border-b border-divider-primary px-lg py-default"},a.createElement("div",{className:"flex items-center gap-2xs"},a.createElement("span",{className:"text-lg font-medium text-content-primary"},n),l),a.createElement("div",{className:"flex items-center justify-between"},r,a.createElement("div",{className:"flex h-9 items-stretch gap-xs"},o))),i)}));nke.displayName="InvestmentsGraphCard";const ake=$d.s.button(tke||(tke=(0,wc.A)(["\n  flex cursor-default items-center justify-center border-0 bg-transparent p-0\n  text-content-secondary\n"]))),lke=e=>{let t=e.summaryTiles,n=e.graph,l=e.holdingsTable;return a.createElement("div",{"data-external-id":"investments-tab-layout",className:"flex w-full flex-col gap-default px-gutter pt-0 pb-gutter"},a.createElement("div",{className:"flex flex-col"},null!==t&&void 0!==t?t:null,n),a.createElement("div",{className:"w-full"},l))};let rke=function(e){return e.Allocation="allocation",e.GainsLosses="gainsLosses",e.Funds="funds",e}({});const oke=e=>{let t=e.activeSubTab,n=e.onSubTabChange,l=e.showAllocationBreakdownTab,r=void 0!==l&&l;const o=(0,a.useMemo)((()=>Object.values(rke).filter((e=>e!==rke.Allocation||r))),[r]),i=(0,a.useCallback)((e=>{const t=o[e];n(t),(0,Ge.u4)(Ye.Vi.AdvancedVisualizationTabChanged,{tab:t})}),[n,o]);return a.createElement(Dc.t,{"data-external-id":"advanced-sub-tab-bar",index:o.indexOf(t),onChangeIndex:i},a.createElement(MA.c,null,r&&a.createElement(RA.Q,{index:o.indexOf(rke.Allocation),$background:"card"},"Allocation"),a.createElement(RA.Q,{index:o.indexOf(rke.GainsLosses),$background:"card"},"Gains & Losses"),a.createElement(RA.Q,{index:o.indexOf(rke.Funds),$background:"card"},"Funds")))};var ike=n(97499);const ske=e=>{let t=e.tree,n=e.portfolioTotal,l=e.isLoading,r=e.isEmpty,o=e.onFocusChange,i=e.selectedHoldingId,s=e.onHoldingSelect,c=e.tabs,d=e.titleAdornment;return a.createElement(nke,{"data-external-id":"allocation-breakdown-graph-pane",title:"Allocation breakdown",titleAdornment:d,tabs:c,controls:null},a.createElement("div",{className:"h-144 w-full px-lg pt-default pb-lg"},a.createElement(cke,{tree:t,portfolioTotal:n,isLoading:l,isEmpty:r,onFocusChange:o,selectedHoldingId:i,onHoldingSelect:s})))},cke=e=>{let t=e.tree,n=e.portfolioTotal,l=e.isLoading,r=e.isEmpty,o=e.onFocusChange,i=e.selectedHoldingId,s=e.onHoldingSelect;if(l)return a.createElement("div",{"data-external-id":"pane-body",className:"flex h-full items-center justify-center"},a.createElement(p.i,null));if(!t||r)return a.createElement("div",{"data-external-id":"pane-body",className:"flex h-full items-center justify-center"},a.createElement(xt.v,{color:"textLight"},"No allocation data available"));return a.createElement(dke,{"data-external-id":"pane-body",tree:t,formatValue:e=>(0,rl.vv)(e),formatSecondaryValue:e=>n>0?"".concat((e/n*100).toFixed(2),"%"):null,onFocusChange:o,selectedHoldingId:i,onHoldingSelect:s})},dke=e=>{let t=e.tree,n=e.formatValue,l=e.formatSecondaryValue,r=e.onFocusChange,o=e.selectedHoldingId,i=e.onHoldingSelect;const s=(0,a.useRef)(0),c=(0,a.useCallback)((e=>{const t=e.length,n=s.current;t>n?(0,Ge.u4)(Ye.Vi.AllocationTreemapInteracted,{interaction_type:"drill_in",depth:t}):t<n&&(0,Ge.u4)(Ye.Vi.AllocationTreemapInteracted,{interaction_type:"drill_out",depth:t}),s.current=t,r(e)}),[r]);return a.createElement(ike.V,{"data-external-id":"investments-treemap",tree:t,formatValue:n,formatSecondaryValue:l,renderHeader:uke,onFocusChange:c,selectedLeafId:o,onLeafClick:e=>{void 0===e.otherCount&&((0,Ge.u4)(Ye.Vi.AllocationTreemapInteracted,{interaction_type:"leaf_select",depth:s.current}),null===i||void 0===i||i(e.id))}})},uke=e=>{let t=e.breadcrumb,n=e.navigateTo;return a.createElement("div",{className:"mb-default flex h-9 items-center gap-sm"},a.createElement("div",{className:"flex items-center gap-xs text-sm font-medium text-content-secondary"},a.createElement("button",{type:"button",onClick:()=>n([]),className:"cursor-pointer border-0 bg-transparent p-0 font-medium hover:underline ".concat(0===t.length?"text-content-primary":"text-content-secondary")},"Asset class"),t.map(((e,l)=>{const r=l===t.length-1;return a.createElement(a.Fragment,{key:e.id},a.createElement(tR.hPJ,{size:"xs",className:"text-content-secondary"}),a.createElement("button",{type:"button",onClick:()=>n(e.path),className:"cursor-pointer border-0 bg-transparent p-0 font-medium hover:underline ".concat(r?"text-content-primary":"text-content-secondary")},e.label))}))))};var mke=n(50549),pke=n(77587);const gke="grid w-full grid-cols-[minmax(0,1fr)_minmax(72px,120px)_minmax(72px,120px)_minmax(72px,120px)_minmax(72px,120px)_36px] items-center gap-default pl-lg pr-default font-[inherit] text-inherit",hke=e=>{let t=e.groups,n=e.portfolioTotal,l=e.onHoldingClick;return a.createElement("div",{"data-external-id":"allocation-breakdown-table",className:"flex w-full flex-col gap-default"},t.map((e=>a.createElement(vke,{key:e.assetClassId,group:e,portfolioTotal:n,onHoldingClick:l}))))},vke=e=>{let t=e.group,n=e.portfolioTotal,l=e.onHoldingClick;const r=(0,a.useState)(!1),i=(0,o.A)(r,2),s=i[0],c=i[1],d=(0,a.useState)({}),u=(0,o.A)(d,2),m=u[0],p=u[1];return a.createElement(fe.X0s,{"data-external-id":"allocation-breakdown-group",open:!s,onOpenChange:e=>c(!e)},a.createElement("div",{className:(0,q.cn)(gke,"h-10 rounded-md bg-(--gray-4) pl-sm")},a.createElement("div",{className:"flex items-center gap-xs"},a.createElement(xke,{collapsed:s,label:t.label}),a.createElement(fe.c8D,{size:"sm",weight:"medium",color:"secondary"},t.label)),a.createElement(bke,null,"Price"),a.createElement(bke,null,"Quantity"),a.createElement(bke,null,"Value"),a.createElement(bke,null,"Weight"),a.createElement("div",null)),a.createElement(fe.X0s.Content,{className:"-mx-xs"},a.createElement("div",{className:"flex flex-col gap-default px-xs pt-default pb-xs"},t.subsections.map((e=>{var t;return a.createElement("div",{key:e.id,className:"overflow-hidden rounded-md bg-background-primary shadow-card"},a.createElement(fke,{subsection:e,portfolioTotal:n,onHoldingClick:l,collapsed:null!==(t=m[e.i
1d])&&void 0!==t&&t,onCollapsedChange:t=>p((n=>(0,U.A)((0,U.A)({},n),{},{[e.id]:t})))}))})))),a.createElement("div",{className:(0,q.cn)(gke,"rounded-md bg-background-primary py-default shadow-card",s?"mt-default":"mt-xs")},a.createElement(fe.c8D,{size:"lg",weight:"medium",className:"truncate"},"Total ",t.label.toLowerCase()),a.createElement(yke,null),a.createElement(yke,null),a.createElement(yke,null,a.createElement(fe.c8D,{size:"lg",weight:"medium"},(0,rl.vv)(t.totalValue))),a.createElement(yke,null,a.createElement(fe.c8D,{size:"lg",weight:"medium"},wke(t.totalWeightPercent))),a.createElement("div",null)))},fke=e=>{let t=e.subsection,n=e.portfolioTotal,l=e.onHoldingClick,r=e.collapsed,o=e.onCollapsedChange;return a.createElement(fe.X0s,{"data-external-id":"subsection-rows",open:!r,onOpenChange:e=>o(!e)},a.createElement("div",{className:(0,q.cn)(gke,"py-sm pl-sm")},a.createElement("div",{className:"flex min-w-0 items-center gap-xs"},a.createElement(xke,{collapsed:r,label:t.displayName}),a.createElement(fe.c8D,{size:"lg",weight:"medium",className:"truncate"},t.displayName)),a.createElement(yke,null),a.createElement(yke,null),a.createElement(yke,null,a.createElement(fe.c8D,{size:"lg",weight:"medium"},(0,rl.vv)(t.value))),a.createElement(yke,null,a.createElement(fe.c8D,{size:"lg",weight:"medium"},wke(t.weightPercent))),a.createElement("div",null)),a.createElement(fe.X0s.Content,null,t.holdings.map((e=>a.createElement(Eke,{key:e.id,holding:e,subsectionName:t.displayName,portfolioTotal:n,onHoldingClick:l})))))},Eke=e=>{var t;let n=e.holding,l=e.subsectionName,r=e.portfolioTotal,o=e.onHoldingClick;const i=r>0?n.value/r*100:0,s=(0,De.Ym)(n.value)<(0,De.Ym)(n.totalValue),c=s?n.quantity*(n.value/n.totalValue):n.quantity,d=null!==(t=n.ticker)&&void 0!==t?t:n.name;return a.createElement("div",{"data-external-id":"holding-row",role:"button",tabIndex:0,onClick:()=>o(n.id),onKeyDown:e=>{"Enter"!==e.key&&" "!==e.key||(e.preventDefault(),o(n.id))},className:(0,q.cn)(gke,"\n          cursor-pointer border-t border-divider-primary py-default text-left\n          focus-visible:outline-2 focus-visible:-outline-offset-2\n          focus-visible:outline-input-focus-border\n        ")},a.createElement("div",{className:"flex min-w-0 items-center gap-sm"},a.createElement("div",{className:"flex min-w-0 flex-col"},a.createElement(xt.v,{weight:"medium",className:"truncate"},d),n.ticker&&a.createElement(xt.v,{size:"small",color:"content.secondary",className:"truncate"},n.name))),a.createElement(yke,null,null!==n.price?(0,rl.vv)(n.price):null),a.createElement(yke,null,s?a.createElement("div",{className:"flex items-center justify-end gap-xs"},a.createElement(P.D_,{maxWidth:220,content:a.createElement(P.fn,null,a.createElement("div",{className:"flex flex-col gap-xs text-left"},a.createElement("span",{className:"font-medium"},d),a.createElement("span",null,l," Quantity:"," ",(0,pke.X5)(c,n.securityType)),a.createElement("span",null,"Total Quantity:"," ",(0,pke.X5)(n.quantity,n.securityType))))},a.createElement("span",{className:"inline-flex shrink-0 cursor-default items-center text-content-secondary",onClick:e=>e.stopPropagation()},a.createElement(fe.ucZ,{size:"xs"}))),a.createElement("span",null,(0,pke.X5)(c,n.securityType))):(0,pke.X5)(n.quantity,n.securityType)),a.createElement(yke,null,(0,rl.vv)(n.value)),a.createElement(yke,null,wke(i)),a.createElement(mke.h,null))},yke=e=>{let t=e.children,n=e.className;return a.createElement("div",{"data-external-id":"numeric-cell",className:(0,q.cn)("text-right",n)},t)},bke=e=>{let t=e.children;return a.createElement(fe.c8D,{"data-external-id":"column-header",size:"sm",weight:"medium",color:"secondary",className:"text-right"},t)},xke=e=>{let t=e.collapsed,n=e.label;return a.createElement(fe.X0s.Trigger,{"data-external-id":"collapse-chevron-trigger",render:a.createElement(fe.SO$,{variant:"default",size:"xs","aria-label":"".concat(t?"Expand":"Collapse"," ").concat(n)},a.createElement(fe.D39,{className:(0,q.cn)("text-content-secondary transition-transform",{"-rotate-90":t})}))})},wke=e=>"".concat(e.toFixed(2),"%"),Cke=(e,t)=>t>0?e/t*100:0,Ake=e=>{let t=e.breakdown,n=e.focusPath,l=e.portfolioTotal,r=e.isLoading,o=e.isEmpty,i=e.onHoldingClick,s=e.filteredHoldingId,c=e.onClearFilter;const d=(0,a.useMemo)((()=>t?((e,t,n)=>{const a=((e,t)=>{let n=e;for(const a of t){const e=n.children.find((e=>e.id===a));if(!e)return n;n=e}return n})(e,t),l=a.children.length>0?a.children:[a],r=[];for(const o of l){const e={id:o.id,displayName:o.displayName,value:o.value,weightPercent:Cke(o.value,n),holdings:o.holdings},t=r[r.length-1];t&&t.assetClassId===o.assetClassId?t.subsections.push(e):r.push({assetClassId:o.assetClassId,label:o.assetClassLabel,subsections:[e],totalValue:0,totalWeightPercent:0})}return r.map((e=>{const t=(0,De.Eb)(e.subsections.map((e=>e.value)));return(0,U.A)((0,U.A)({},e),{},{totalValue:t,totalWeightPercent:Cke(t,n)})}))})(t,n,l):[]),[t,n,l]),u=(0,a.useMemo)((()=>
1s?((e,t,n)=>e.flatMap((e=>{const a=e.subsections.flatMap((e=>{const a=e.holdings.filter((e=>e.id===t));if(0===a.length)return[];const l=(0,De.Eb)(a.map((e=>e.value)));return[(0,U.A)((0,U.A)({},e),{},{holdings:a,value:l,weightPercent:Cke(l,n)})]}));if(0===a.length)return[];const l=(0,De.Eb)(a.map((e=>e.value)));return[(0,U.A)((0,U.A)({},e),{},{subsections:a,totalValue:l,totalWeightPercent:Cke(l,n)})]})))(d,s,l):d),[d,s,l]),m=(0,a.useMemo)((()=>{if(!s)return null;for(const t of u)for(const n of t.subsections){var e;const t=n.holdings.find((e=>e.id===s));if(t)return null!==(e=t.ticker)&&void 0!==e?e:t.name}return null}),[u,s]);return r?a.createElement(Ike,{"data-external-id":"investments-allocation-breakdown-section"},a.createElement(p.i,null)):o||!t||0===u.length&&!s?a.createElement(Ike,{"data-external-id":"investments-allocation-breakdown-section"},a.createElement(xt.v,{color:"content.secondary"},"No allocation data available")):a.createElement("div",{"data-external-id":"investments-allocation-breakdown-section",className:"flex w-full flex-col gap-default"},s&&a.createElement("div",{className:"flex items-center justify-between gap-sm"},a.createElement(xt.v,{color:"content.secondary"},"Showing"," ",a.createElement(xt.v,{weight:"medium"},null!==m&&void 0!==m?m:"selected holding")),a.createElement(Wb.X,{variant:"text",size:"sm",onClick:c},"Clear filter")),u.length>0?a.createElement(hke,{groups:u,portfolioTotal:l,onHoldingClick:i}):a.createElement(Ike,null,a.createElement(xt.v,{color:"content.secondary"},"This holding isn\u2019t in the current view")))},Ike=e=>{let t=e.children;return a.createElement("div",{"data-external-id":"placeholder",className:" flex min-h-96 w-full items-center justify-center rounded-md bg-background-primary p-2xl shadow-card "},t)};var kke=n(3788);const Ske={green:"var(--chart-fill-green)",blue:"var(--chart-fill-blue)",pink:"var(--chart-fill-pink)",indigo:"var(--chart-fill-indigo)",purple:"var(--chart-fill-purple)",orange:"var(--chart-fill-orange)",unclassified:"var(--background-tertiary)"},Nke={green:"var(--green-10)",blue:"var(--blue-10)",pink:"var(--pink-10)",indigo:"var(--indigo-10)",purple:"var(--purple-10)",orange:"var(--orange-10)",unclassified:"var(--background-tertiary-hover)"},Tke={green:"var(--green-4)",blue:"var(--blue-4)",pink:"var(--pink-4)",indigo:"var(--indigo-4)",purple:"var(--purple-4)",orange:"var(--orange-4)",unclassified:"var(--gray-4)"},_ke={green:"var(--green-5)",blue:"var(--blue-5)",pink:"var(--pink-5)",indigo:"var(--indigo-5)",purple:"var(--purple-5)",orange:"var(--orange-5)",unclassified:"var(--gray-5)"},Dke="var(--content-primary)",Rke=e=>e===Ske.unclassified?Dke:"var(--content-white)",Mke=e=>({background:Tke[e],stripeColor:_ke[e],text:Dke}),Lke={name:"root",children:[{slug:"cash",name:"Cash",color:"green"},{slug:"bonds",name:"Bonds",collapse:!0,children:[{slug:"international_bonds",name:"International Bonds",displayName:"Intl. bonds",color:"blue",children:[{slug:"international_government_bonds",name:"Government",displayName:"Intl. Government"},{slug:"international_corporate_bonds",name:"Corporate",displayName:"Intl. Corporate"}]},{slug:"us_bonds",name:"US Bonds",displayName:"U.S. bonds",color:"pink",children:[{slug:"us_government_bonds",name:"Government",displayName:"U.S. Government"},{slug:"us_corporate_bonds",name:"Corporate",displayName:"U.S. Corporate"},{slug:"us_municipal_bonds",name:"Municipal",displayName:"U.S. Municipal"}]}]},{slug:"stocks",name:"Stocks",collapse:!0,children:[{slug:"international_stocks",name:"International Stocks",displayName:"Intl. stocks",color:"indigo",children:[{slug:"international_developed",name:"Developed"},{slug:"international_emerging",name:"Emerging"}]},{slug:"us_stocks",name:"US Stocks",displayName:"U.S. stocks",color:"purple",tileDirection:kke.i7.Vertical,children:[{slug:"us_large_cap",name:"Large Cap",collapse:!0,children:[{slug:"us_large_cap_value",name:"Large Cap Value"},{slug:"us_large_cap_blend",name:"Large Cap Blend"},{slug:"us_large_cap_growth",name:"Large Cap Growth"}]},{slug:"us_mid_cap",name:"Mid Cap",collapse:!0,children:[{slug:"us_mid_cap_value",name:"Mid Cap Value"},{slug:"us_mid_cap_blend",name:"Mid Cap Blend"},{slug:"us_mid_cap_growth",name:"Mid Cap Growth"}]},{slug:"us_small_cap",name:"Small Cap",collapse:!0,children:[{slug:"us_small_cap_value",name:"Small Cap Value"},{slug:"us_small_cap_blend",name:"Small Cap Blend"},{slug:"us_small_cap_growth",name:"Small Cap Growth"}]}]}]},{slug:"alternatives",name:"Alternatives",color:"orange",children:[{slug:"real_estate",name:"Real Estate"},{slug:"reits",name:"REITs"},{slug:"commodities",name:"Commodities"},{slug:"crypto",name:"Crypto"},{slug:"hedge_funds",name:"Hedge Funds"},{slug:"private_equity",name:"Private Equity"}]}]},Oke="__unclassified__",Pke="Unclassified",Bke={totalHoldingsCount:0,unclassifiedHoldingsCount:0},zke=(e,t)=>{const n=Gke(t),a=jke(e,n),l=a.contributionsByAuthored,r=a.unclassifiedContributions,o=new Set(r.map((e=>e.holding.id))).size;return{tree:Fke(l,r),breakdown:eSe(l,r),stats:{totalHoldingsCount:e.length,unclassifiedHoldingsCount:o}}},Fke=(e,t)=>{var n;const a=(null!==(n=Lke.children)&&void 0!==n?n:[]).flatMap((t=>Kke(t,void 0,void 0,e)));return t.length>0&&a.push($ke(t)),{id:"root",children:a}},Gke=e=>{const t=new Map,n=new Map;for(const o of e)t.set(o.id,o),n.set(o.slug,o);const a=Yke(n),l=e=>{var t;return!!e&&!e.collapse&&!(null!==(t=e.children)&&void 0!==t&&t.length)},r=function(e){var n,a;let l=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new Set;if(l.has(e))return[];const o=null===(n=t.get(e))||void 0===n||null===(a=n.parent)||void 0===a?void 0:a.id;return void 0===o?[e]:[e,...r(o,new Set([...l,e]))]};return{categoryForSlug:e=>n.get(e),authoredLeafForCategory:e=>{const t=a.get(e);return l(t)?t:null},resolveAuthoredLeaf:e=>{var t;return null!==(t=r(e).map((e=>a.get(e))).find(l))&&void 0!==t?t:null},isDescendantOf:(e,t)=>r(e).includes(t)}},Yke=e=>{const t=new Map,n=a=>
1{if(a.slug){const n=e.get(a.slug);n&&t.set(n.id,a)}for(const e of null!==(l=a.children)&&void 0!==l?l:[]){var l;n(e)}};return n(Lke),t},Uke=(e,t,n)=>{if(e.breakdownMode===nIe.Reference)return[];if(e.breakdownMode===nIe.Manual&&e.subSlices.length>0)return e.subSlices.flatMap((t=>{const a=n.categoryForSlug(t.allocationSlug);return a?[{weight:t.percentage*e.percentage,category:{id:a.id}}]:[]}));const a=n.categoryForSlug(e.allocationSlug);return a?n.authoredLeafForCategory(a.id)?[{weight:e.percentage,category:{id:a.id}}]:Vke(a.id,e.percentage,t,n):[]},Vke=(e,t,n,a)=>{const l=n.filter((t=>a.isDescendantOf(t.category.id,e)));if(0===l.length)return[{weight:t,category:{id:e}}];const r=l.reduce(((e,t)=>e+t.weight),0);return l.map((e=>({weight:r>0?e.weight/r*t:0,category:e.category})))},Wke=(e,t)=>{const n=((e,t)=>{var n,a,l,r;const i=(0,o.A)(e.holdings,1)[0],s=null!==(n=null===i||void 0===i?void 0:i.allocationCategoryWeights)&&void 0!==n?n:[],c=null!==(a=e.security?null===i||void 0===i||null===(l=i.securityClassification)||void 0===l?void 0:l.slices:null===i||void 0===i||null===(r=i.holdingClassification)||void 0===r?void 0:r.slices)&&void 0!==a?a:[];if(0===c.length)return s;const d=c.flatMap((e=>Uke(e,s,t)));return d.length>0?d:s})(e,t);return 0===n.length?[{node:null,contribution:{holding:e,value:e.totalValue}}]:n.map((n=>{let a=n.weight,l=n.category;return{node:t.resolveAuthoredLeaf(l.id),contribution:{holding:e,value:e.totalValue*a}}}))},jke=(e,t)=>{const n=e.flatMap((e=>Wke(e,t))),a=n.filter((e=>null===e.node)).map((e=>e.contribution));return{contributionsByAuthored:n.reduce(((e,t)=>{var n;let a=t.node,l=t.contribution;return a?e.set(a,[...null!==(n=e.get(a))&&void 0!==n?n:[],l]):e}),new Map),unclassifiedContributions:a}},Hke=(e,t,n)=>{const a=e.slice(0,14),l=e.slice(14),r=[...a];if(l.length>0){const e=null!==n&&void 0!==n?n:"unclassified";r.push({id:"__other__",primaryLabel:["Everything else",kke.MK.All],value:(0,De.Eb)(l.map((e=>{var t;return null!==(t=e.value)&&void 0!==t?t:0}))),background:Ske[e],backgroundHover:Nke[e],text:Rke(Ske[e]),empty:Mke(e),otherCount:l.length})}if(t||r.length<=5)return{children:r,overrideTileDirection:void 0};return{children:r.map(((e,t)=>(0,U.A)((0,U.A)({},e),{},{groupKey:"holding_row_".concat(Math.floor(t/5))}))),overrideTileDirection:kke.i7.Vertical}},Kke=(e,t,n,a)=>{var l,r,o,i;const s=null!==(l=e.color)&&void 0!==l?l:t;var c;if(e.collapse)return(null!==(c=e.children)&&void 0!==c?c:[]).flatMap((t=>Kke(t,s,e.name,a)));const d=(null!==(r=e.children)&&void 0!==r?r:[]).flatMap((e=>Kke(e,s,void 0,a))),u=Zke(null!==(o=a.get(e))&&void 0!==o?o:[]).sort(((e,t)=>t.value-e.value)).map((e=>qke(e,s))),m=Hke(u,d.length>0,s),p=m.children,g=m.overrideTileDirection,h=[...d,...p],v=null!==s&&void 0!==s?s:"unclassified";return[{id:e.name,primaryLabel:[null!==(i=e.displayName)&&void 0!==i?i:e.name,kke.MK.All],value:0===h.length?0:void 0,background:Ske[v],backgroundHover:Nke[v],text:Rke(Ske[v]),empty:Mke(v),tileDirection:null!==g&&void 0!==g?g:e.tileDirection,groupKey:n,children:h.length>0?h:void 0}]},qke=(e,t)=>{var n,a,l,r,i,s;const c=e.holding,d=e.value,u=(0,o.A)(c.holdings,1)[0],m=null!==(n=null!==(a=null===(l=c.security)||void 0===l?void 0:l.ticker)&&void 0!==a?a:null===u||void 0===u?void 0:u.ticker)&&void 0!==n?n:null,p=null!==(r=null!==(i=null===(s=c.security)||void 0===s?void 0:s.name)&&void 0!==i?i:null===u||void 0===u?void 0:u.name)&&void 0!==r?r:"Unknown holding",g=null!==t&&void 0!==t?t:"unclassified",h=null!==m&&void 0!==m?m:p,v=h===p?null:p;return{id:c.id,primaryLabel:[h,kke.MK.All],secondaryLabel:null!==v?[v,kke.MK.All]:void 0,value:d,background:Ske[g],backgroundHover:Nke[g],text:Rke(Ske[g]),empty:Mke(g)}},$ke=e=>{const t=Zke(e).sort(((e,t)=>t.value-e.value)).map((e=>qke(e,"unclassified"))),n=Hke(t,!1,"unclassified"),a=n.children,l=n.overrideTileDirection;return{id:Oke,primaryLabel:[Pke,kke.MK.All],background:Ske.unclassified,backgroundHover:Nke.unclassified,text:Rke(Ske.unclassified),empty:Mke("unclassified"),tileDirection:l,children:a}},Zke=e=>[...e.reduce(((e,t)=>{const n=e.get(t.holding.id);return e.set(t.holding.id,n?(0,U.A)((0,U.A)({},n),{},{value:(0,De.Eb)([n.value,t.value])}):t)}),new Map).values()],Jke=e=>{var t,n,a,l,r,i,s,c,d,u,m,p,g,h,v,f;const E=e.holding,y=e.value,b=(0,o.A)(E.holdings,1)[0];return{id:E.id,securityId:null!==(t=null===(n=E.security)||void 0===n?void 0:n.id)&&void 0!==t?t:null,ticker:null!==(a=null!==(l=null===(r=E.security)||void 0===r?void 0:r.ticker)&&void 0!==l?l:null===b||void 0===b?void 0:b.ticker)&&void 0!==a?a:null,name:null!==(i=null!==(s=null===(c=E.security)||void 0===c?void 0:c.name)&&void 0!==s?s:null===b||void 0===b?void 0:b.name)&&void 0!==i?i:"Unknown holding",price:null!==(d=null!==(u=null!==(m=null===(p=E.security)||void 0===p?void 0:p.currentPrice)&&void 0!==m?m:null===(g=E.holdings[0])||void 0===g?void 0:g.closingPrice)&&void 0!==u?u:null===(h=E.security)||void 0===h?void 0:h.closingPrice)&&void 0!==d?d:null,quantity:E.quantity,securityType:null!==(v=null===(f=E.security)||void 0===f?void 0:f.type)&&void 0!==v?v:null,value:y,totalValue:E.totalValue}},Xke=e=>[...e.reduce(((e,t)=>{const n=e.get(t.id);
1return e.set(t.id,n?(0,U.A)((0,U.A)({},n),{},{value:(0,De.Eb)([n.value,t.value])}):t)}),new Map).values()],Qke=(e,t,n)=>{var a,l,r,o;if(e.collapse)return(null!==(o=e.children)&&void 0!==o?o:[]).flatMap((e=>Qke(e,t,n)));const i=(null!==(a=e.children)&&void 0!==a?a:[]).flatMap((e=>Qke(e,t,n))),s=(null!==(l=n.get(e))&&void 0!==l?l:[]).map(Jke),c=Xke([...s,...i.flatMap((e=>e.holdings))]);return[{id:e.name,displayName:null!==(r=e.displayName)&&void 0!==r?r:e.name,assetClassId:t.id,assetClassLabel:t.label,value:(0,De.Eb)(c.map((e=>e.value))),holdings:c,children:i}]},eSe=(e,t)=>{var n;const a=(null!==(n=Lke.children)&&void 0!==n?n:[]).flatMap((t=>{var n;return Qke(t,{id:t.name,label:null!==(n=t.displayName)&&void 0!==n?n:t.name},e)}));if(t.length>0){const e=Xke(t.map(Jke));a.push({id:Oke,displayName:Pke,assetClassId:Oke,assetClassLabel:Pke,value:(0,De.Eb)(e.map((e=>e.value))),holdings:e,children:[]})}return{id:"root",displayName:"Allocation",assetClassId:"",assetClassLabel:"",value:(0,De.Eb)(a.map((e=>e.value))),holdings:[],children:a}},tSe=Ee.gyN;var nSe,aSe;const lSe=$d.s.div(nSe||(nSe=(0,wc.A)(["\n  flex items-center gap-sm rounded-sm bg-background-info px-default py-sm text-sm\n  text-content-info\n"]))),rSe=$d.s.button(aSe||(aSe=(0,wc.A)(["\n  cursor-pointer border-0 bg-transparent p-0 text-sm font-medium whitespace-nowrap\n  text-content-info\n"]))),oSe=()=>{const e=(0,xq.bO)("dismissedFundAnalysisDisclosureAt"),t=(0,o.A)(e,3),n=t[0],l=t[1];return t[2]||n?null:a.createElement(lSe,{"data-external-id":"fund-analysis-disclosure-banner",className:"mx-lg mt-default"},a.createElement(sl.ZQ,{name:"info",size:16}),a.createElement("span",{className:"flex-1"},"Fund analysis includes ETFs and mutual funds only. Individual stocks, bonds, and other securities are not included."),a.createElement(rSe,{type:"button",onClick:()=>l((new Date).toISOString())},"Got it"))},iSe=Ee.lz5,sSe={morningstarCategory:!1,globalCategory:!1,broadAssetClass:!1,legalStructure:!1,prospectusObjective:!1,aggregatedCategory:!1,indexStrategy:!1},cSe=iSe.BROAD_ASSET_CLASS,dSe="Morningstar classifications",uSe=[{value:iSe.BROAD_ASSET_CLASS,label:"Broad asset class"},{value:iSe.MORNINGSTAR_CATEGORY,label:"Category"},{value:iSe.GLOBAL_CATEGORY,label:"Global category"},{value:iSe.AGGREGATED_CATEGORY,label:"Aggregated category"},{value:iSe.PROSPECTUS_OBJECTIVE,label:"Prospectus objective"},{value:iSe.INDEX_STRATEGY,label:"Index strategy"},{value:iSe.LEGAL_STRUCTURE,label:"Legal structure"}],mSe={[iSe.MORNINGSTAR_CATEGORY]:"morningstarCategory",[iSe.GLOBAL_CATEGORY]:"globalCategory",[iSe.BROAD_ASSET_CLASS]:"broadAssetClass",[iSe.LEGAL_STRUCTURE]:"legalStructure",[iSe.PROSPECTUS_OBJECTIVE]:"prospectusObjective",[iSe.AGGREGATED_CATEGORY]:"aggregatedCategory",[iSe.INDEX_STRATEGY]:"indexStrategy"};var pSe=n(3395),gSe=n(14102),hSe=n(83254),vSe=n(47197);const fSe=["data","width","height","xDataKey","yDataKey","barWidth","xAxisFormatter","yAxisFormatter","labelFormatter","onClickBar","onHoverBar","selectedBarId","tooltipComponent","yAxisWidth"],ESe=parseInt(yD.w.spacing.xxlarge,10),ySe=(0,u.keyframes)(["from{opacity:0;transform:translateX(-5px);}to{opacity:1;transform:translateX(0);}"]),bSe=(0,u.default)(m.g).withConfig({displayName:"HorizontalBarChart__Root",componentId:"g5any8-0"})(["g.recharts-cartesian-grid-horizontal > line:first-child{stroke-opacity:0;}.recharts-tooltip-wrapper{z-index:var(--z-tooltip);}.recharts-text.recharts-label{&:not(.disable-animation){animation:"," ","ms ease-in-out;animation-iteration-count:1;}}",""],ySe,400,(e=>e.$clickable&&(0,u.css)([".recharts-layer.recharts-bar-rectangle .recharts-rectangle:hover{filter:brightness(",");opacity:1;}.recharts-layer.recharts-bar{cursor:pointer;}"],.75))),xSe=e=>{let t=e.data,n=e.width,l=e.height,r=e.xDataKey,o=e.yDataKey,i=e.barWidth,s=e.xAxisFormatter,c=e.yAxisFormatter,d=e.labelFormatter,m=e.onClickBar,p=e.onHoverBar,g=e.selectedBarId,h=e.tooltipComponent,v=e.yAxisWidth,f=void 0===v?180:v,E=(0,En.A)(e,fSe);const y=(0,vSe.mM)(),b=(0,a.useMemo)((()=>[{[r]:null,[o]:"",color:""},...t,{[r]:null,[o]:"",color:""}].map(((e,t)=>(0,U.A)((0,U.A)({},e),{},{index:t})))),[t]),x=e=>(0,BY.A)(g)||g===e,w=(0,u.useTheme)(),C=(0,a.useMemo)((()=>({fontSize:w.fontSize.xsmall,fill:w.color.textLight,fontWeight:parseInt(w.fontWeight.medium,10)})),[w]),A=(0,a.useMemo)((()=>b.filter((e=>(0,Tr.A)(e[r]))).some((e=>(0,gSe.A)(e[r])))),[b,r]);return setTimeout((()=>wSe(w))),a.createElement(bSe,Object.assign({"data-external-id":"bar-chart",alignCenter:!0},fl.TN,{$clickable:(0,Tr.A)(m)}),a.createElement(ya.u,{width:null!==n&&void 0!==n?n:"100%",height:l},a.createElement(ba.E,Object.assign({data:b,margin:{top:ESe,left:0,right:100},layout:"vertical"},E),a.createElement(ka.d,{horizontal:A,vertical:!0,dashed:!0}),h&&a.createElement(Aa.m,{cursor:!1,content:h}
1),a.createElement(xa.W,{tickFormatter:s,type:"number",tick:C,stroke:w.color.gray}),a.createElement(wa.h,{dataKey:"index",width:f,tickFormatter:e=>{var t;return String(null!==(t=null===c||void 0===c?void 0:c(b[e],e))&&void 0!==t?t:b[e][o])},tickCount:b.length,tick:C,stroke:w.color.gray,interval:0}),a.createElement(Ca.yP,{dataKey:r,barSize:i,animationBegin:400,animationDuration:400,radius:[0,4,4,0],fill:w.color.gray,isAnimationActive:!1,onClick:e=>{let t=e.id;return t?null===m||void 0===m?void 0:m(t):void 0},onMouseEnter:e=>{let t=e.id;return t?null===p||void 0===p?void 0:p(t):void 0},onMouseLeave:()=>null===p||void 0===p?void 0:p(null)},b.map(((e,t)=>{let n=e.id,l=e.color;return a.createElement(z1.f,{key:t,fill:l,opacity:x(n)?1:.32})})),a.createElement(hSe.Ze,Object.assign({dataKey:r,position:"right",offset:parseInt(w.spacing.default,10),formatter:d,className:(0,pSe.A)({"disable-animation":y})},C))))))},wSe=e=>{const t=document.querySelectorAll(".recharts-text.recharts-label");Array.from(t).filter((e=>{const t=e.getAttribute("width");return t&&parseFloat(t)<-40})).forEach((t=>{const n=t.getAttribute("color"),a=n?(0,xb.W0)(n,e.color.black,e.color.textWhite):e.color.textWhite;t.setAttribute("fill",a)}))};var CSe=n(34644);const ASe=Ee.lz5,ISe="TOP_HOLDINGS",kSe="BY_ACCOUNT",SSe=new Set(["Other","Unclassified"]),NSe={[ASe.SECURITY_TYPE]:"Security type",[ASe.BROAD_ASSET_CLASS]:"Broad asset class",[ASe.GLOBAL_CATEGORY]:"Global category",[ASe.MORNINGSTAR_CATEGORY]:"Category",[ASe.CATEGORY_GROUP]:"Asset class",[ASe.PROSPECTUS_OBJECTIVE]:"Prospectus objective",[ASe.LEGAL_STRUCTURE]:"Legal structure",[ASe.AGGREGATED_CATEGORY]:"Aggregated category",[ASe.INDEX_STRATEGY]:"Index strategy",[ASe.EXCHANGE_CODE]:"Exchange code"};let TSe=function(e){return e.Pie="pie",e.Bar="bar",e}({});const _Se=[{value:TSe.Pie,label:"Pie",description:"Your allocation at a glance",thumbnail:"pie"},{value:TSe.Bar,label:"Breakdown",description:"Allocation, biggest to smallest",thumbnail:"rankedBars"}],DSe=[{value:ASe.CATEGORY_GROUP,label:"Asset class"},{value:ASe.SECURITY_TYPE,label:"Security type"},{value:kSe,label:"Account"},{value:ISe,label:"Security"}],RSe=e=>{let t=e.chartType,n=e.pieChartData,l=e.horizontalBarData,r=e.totalValue,o=e.pieAnimationIdentity,i=e.barChartHe
1ight,s=e.hoveredId,c=e.legendHoveredId,d=e.onChangeHoveredId,u=e.onPieAnimationStateChange;const m=(0,a.useRef)(null);return(0,a.useEffect)((()=>{if(t===TSe.Pie&&m.current){const e=m.current.querySelector(".recharts-wrapper > svg");e instanceof SVGElement&&(e.style.overflow="visible")}}),[t,n]),t===TSe.Pie?a.createElement("div",{"data-external-id":"allocation-chart",className:"min-w-0"},a.createElement("div",{ref:m,className:"relative flex items-center justify-center p-default"},a.createElement("div",{"data-testid":"pie-center-total",className:"pointer-events-none absolute inset-0 flex flex-col items-center justify-center"},a.createElement(xt.v,Object.assign({size:"large",weight:"medium"},fl.zs),(0,rl.vv)(r)),a.createElement(xt.v,{size:"small",color:"textLight"},"Total value")),a.createElement(CSe.r,{data:n,width:285,height:234,innerRadius:"76%",outerRadius:"100%",showLabels:!1,startAngle:90,endAngle:450,paddingAngle:1,isAnimationActive:!0,showTooltip:!1,animationIdentity:o,activeDatumIds:s?[s]:[],legendActiveDatumId:c,onAnimationStateChange:u,onChangeActiveDatumId:e=>d(null!==e&&void 0!==e?e:null)}))):a.createElement("div",{"data-external-id":"allocation-chart",className:(0,q.cn)("min-w-0","flex-1")},a.createElement(xSe,{data:l,height:i,xDataKey:"value",yDataKey:"label",yAxisWidth:130,xAxisFormatter:e=>"".concat(e,"%"),labelFormatter:e=>"".concat(Number(e).toFixed(1),"%"),selectedBarId:null!==s&&void 0!==s?s:void 0,onHoverBar:e=>d(null!==e&&void 0!==e?e:null)}))},MSe=Ee.pmx,LSe=Ee.wHt,OSe=Ee.lS2,PSe=["var(--chart-fill-blue)","var(--chart-fill-purple)","var(--chart-fill-green)","var(--chart-fill-orange)","var(--chart-fill-red)","var(--chart-fill-indigo)","var(--chart-fill-teal)","var(--chart-fill-pink)","var(--chart-fill-yellow)","var(--chart-fill-brown)","var(--chart-fill-gray)"],BSe=e=>PSe[e%PSe.length],zSe=e=>{let t=e.activeAccountIds,n=e.selectedOption,l=e.chartType,r=e.onHiddenCategoriesChange;const i=(0,a.useState)(null),s=(0,o.A)(i,2),c=s[0],d=s[1],u=(0,a.useState)(null),m=(0,o.A)(u,2),p=m[0],g=m[1],h=(0,a.useState)(!1),v=(0,o.A)(h,2),f=v[0],E=v[1],y=(0,a.useState)(new Set),b=(0,o.A)(y,2),x=b[0],w=b[1],C=n===ISe,A=n===kSe,I=!C&&!A,k=I?n:null,S={accountIds:t.length>0?t:null,endDate:null,includeHiddenHoldings:null,startDate:null,topMoversLimit:null},N=(0,et.I)(MSe,{variables:{porfolioInput:S,classificationField:k},skip:!I}),T=(0,et.I)(LSe,{variables:{porfolioInput:S,limit:10},skip:!C}),_=(0,et.I)(OSe,{variables:{porfolioInput:S,limit:10},skip:!A}),D=A?_:C?T:N,R=D.data,M=D.isLoadingInitialData,L=D.error,O=D.refetch,P=(0,a.useMemo)((()=>(e=>[...e.filter((e=>!SSe.has(e.type))),...e.filter((e=>SSe.has(e.type)))])((0,cAe.Dw)((0,cAe.PI)(R)))),[R]);(0,a.useEffect)((()=>{w(new Set)}),[n,l]),(0,a.useEffect)((()=>{d(null),g(null)}),[n]),(0,a.useEffect)((()=>{if(!r)return;const e=new Set(P.filter((e=>x.has(e.type))).map((e=>e.typeDisplay)));r(e)}),[x,P,r]);const B=(0,a.useCallback)((e=>{w((t=>{const n=new Set(t);if(n.has(e))n.delete(e);else{const a=[...n].filter((e=>P.some((t=>t.type===e)))).length;if(P.length-a<=1)return t;n.add(e)}return n})),d((t=>t===e?null:t)),g((t=>t===e?null:t))}),[P]),z=(0,a.useMemo)((()=>{if(0===x.size)return P;const e=P.filter((e=>!x.has(e.type))),t=(0,De.Eb)(e.map((e=>{var t;return null!==(t=e.totalValue)&&void 0!==t?t:0})));return e.map((e=>{var n;return(0,U.A)((0,U.A)({},e),{},{allocationPercent:t>0?(null!==(n=e.totalValue)&&void 0!==n?n:0)/t*100:0})}))}),[P,x]),F=(0,a.useMemo)((()=>(0,De.Eb)(z.map((e=>{var t;return null!==(t=e.totalValue)&&void 0!==t?t:0})))),[z]),G=(0,a.useMemo)((()=>new Map(P.map(((e,t)=>[e.type,BSe(t)])))),[P]),Y=(0,a.useMemo)((()=>z.map((e=>{var t,n,a,l,r;return{id:e.type,label:e.typeDisplay,value:null!==(t=e.totalValue)&&void 0!==t?t:0,color:null!==(n=G.get(e.type))&&void 0!==n?n:BSe(0),formattedValue:"".concat((0,rl.vv)(null!==(a=e.totalValue)&&void 0!==a?a:0)," (").concat((null!==(l=e.allocationPercent)&&void 0!==l?l:0).toFixed(1),"%)"),percent:(null!==(r=e.allocationPercent)&&void 0!==r?r:0)/100}}))),[z,G]),V=(0,a.useMemo)((()=>z.map((e=>{var t,n;return{id:e.type,label:e.typeDisplay,value:null!==(t=e.allocationPercent)&&void 0!==t?t:0,color:null!==(n=G.get(e.type))&&void 0!==n?n:BSe(0)}}))),[z,G]),W=Math.max(300,56*z.length+60),j=(0,a.useMemo)((()=>z.map((e=>{var t;return"".concat(e.type,":").concat(null!==(t=e.totalValue)&&void 0!==t?t:0)})).join("|")),[z]);return(0,a.useEffect)((()=>{l!==TSe.Pie&&E(!1)}),[l]),{isLoading:M,isEmpty:0===P.length,error:L,refetch:O,sortedData:P,visibleData:z,totalValue:F,colorByType:G,pieChartData:Y,horizontalBarData:V,pieAnimationIdentity:j,barChartHe
1ight:W,hiddenIds:x,toggleVisibility:B,hoveredId:c,setHoveredId:d,legendHoveredId:p,setLegendHoveredId:g,isPieChartAnimating:f,setIsPieChartAnimating:E}};var FSe;const GSe=e=>{let t=e.selectedOption,n=e.sortedData,l=e.visibleData,r=e.hiddenIds,o=e.toggleVisibility,i=e.totalValue,s=e.colorByType,c=e.hoveredId,d=e.setHoveredId,u=e.setLegendHoveredId,m=e.chartType,p=e.isPieChartAnimating,g=e.showFundCategoriesLink,h=void 0!==g&&g;const v=(e=>{var t;return e===ISe?"Security":e===kSe?"Account":null!==(t=NSe[e])&&void 0!==t?t:"Asset class"})(t);return a.createElement("div",{"data-external-id":"allocation-legend","data-testid":"legend",className:"flex w-118 shrink-0 flex-col gap-sm max-[950px]:w-full"},a.createElement(VSe,null,a.createElement("div",{className:"min-w-0 flex-1"},a.createElement(xt.v,{size:"small",weight:"medium",color:"textLight"},v)),a.createElement("div",{className:"w-12 shrink-0 text-right"},a.createElement(xt.v,{size:"small",weight:"medium",color:"textLight"},"Percent")),a.createElement("div",{className:"w-30 shrink-0 text-right"},a.createElement(xt.v,{size:"small",weight:"medium",color:"textLight"},"Value"))),a.createElement(USe,null),a.createElement("div",{className:"flex flex-col gap-2xs",onMouseLeave:()=>{d(null),u(null)}},n.map((e=>{var t,n,i;const g=r.has(e.type),h=g?void 0:l.find((t=>t.type===e.type)),v=g?"\u2014":"".concat((null!==(t=null===h||void 0===h?void 0:h.allocationPercent)&&void 0!==t?t:0).toFixed(1),"%"),f=!g&&c===e.type;return a.createElement("div",{key:e.type,role:"button",tabIndex:0,"data-testid":"legend-row","data-highlighted":String(f),"data-hidden":String(g),onClick:()=>o(e.type),onMouseEnter:()=>
1{if(m!==TSe.Pie||!p){if(g)return d(null),void u(null);d(e.type),u(e.type)}},onKeyDown:t=>{"Enter"!==t.key&&" "!==t.key||(t.preventDefault(),o(e.type))},className:(0,q.cn)("\n                  group flex cursor-pointer items-center gap-2 rounded-sm px-sm py-xs\n                  hover:bg-background-secondary\n                ",f||g?"bg-background-secondary":"bg-transparent")},a.createElement("div",{className:"flex min-w-0 flex-1 items-center gap-sm"},a.createElement("div",{className:"size-2 shrink-0 rounded-round",style:{backgroundColor:null!==(n=s.get(e.type))&&void 0!==n?n:BSe(0)}}),a.createElement("div",{className:"truncate"},a.createElement(YSe,{isHidden:g},a.createElement(xt.v,{size:"small",color:g?"textLight":void 0},e.typeDisplay)))),a.createElement("div",{className:(0,q.cn)("w-12 shrink-0",g?"text-center":"text-right")},a.createElement(YSe,{isHidden:g},a.createElement(xt.v,Object.assign({size:"small",color:g?"textLight":void 0},fl.TN),v))),a.createElement("div",{className:"w-30 shrink-0 text-right"},a.createElement(YSe,{isHidden:g},a.createElement(xt.v,Object.assign({size:"small",color:g?"textLight":void 0},fl.zs),(0,rl.vv)(null!==(i=e.totalValue)&&void 0!==i?i:0)))),a.createElement("div",{"data-testid":"eye-off-icon",className:(0,q.cn)("flex w-5 shrink-0 items-center pl-xs text-content-secondary",g?"opacity-100":"opacity-0 group-hover:opacity-100")},a.createElement(sl.ZQ,{name:"eye-off",size:12})))}))),a.createElement(USe,null),a.createElement(VSe,{"data-testid":"legend-total"},a.createElement("div",{className:"min-w-0 flex-1"},a.createElement(xt.v,{size:"small",weight:"medium"},"Total")),a.createElement("div",{className:"w-12 shrink-0 text-right"},a.createElement(xt.v,{size:"small",weight:"medium"},"100.0%")),a.createElement("div",{className:"w-30 shrink-0 text-right"},a.createElement(xt.v,Object.assign({size:"small",weight:"medium"},fl.zs),(0,rl.vv)(i)))),h&&a.createElement(a.Fragment,null,a.createElement(USe,null),a.createElement("div",{className:"text-center"},a.createElement(xt.v,{size:"small",color:"textLight"},"Learn more about"," ",a.createElement(wb.gz,{href:XCe.f,target:"_blank",rel:"noopener noreferrer",small:!0},"fund categories")))))},YSe=e=>{let t=e.isHidden,n=e.children;return a.createElement("span",{"data-external-id":"hidden-text",className:(0,q.cn)("decoration-content-secondary",t&&"line-through")},n)},USe=()=>a.createElement("div",{"data-external-id":"legend-divider",className:"pr-10 pl-sm"},a.createElement("div",{className:"h-px bg-divider-primary"})),VSe=$d.s.div(FSe||(FSe=(0,wc.A)(["flex items-center gap-xs pr-10 pl-sm"]))),WSe=e=>{let t=e.activeAccountIds,n=e.selectedOption,l=e.chartType,r=e.onHiddenCategoriesChange,o=e.onQueryStateChange,i=e.showFundCategoriesLink,s=void 0!==i&&i;const c=zSe({activeAccountIds:t,selectedOption:n,chartType:l,onHiddenCategoriesChange:r});if((0,a.useEffect)((()=>{null===o||void 0===o||o({error:c.error,refetch:c.refetch})}),[c.error,c.refetch,o]),(0,a.useEffect)((()=>()=>null===o||void 0===o?void 0:o(void 0)),[o]),c.isLoading)return a.createElement("div",{"data-external-id":"investments-allocation-content",className:"flex h-112.5 items-center justify-center"},a.createElement(p.i,null));if(c.error&&o)return null;if(c.isEmpty)return a.createElement("div",{"data-external-id":"investments-allocation-content",className:"flex h-75 items-center justify-center"},a.createElement(xt.v,{color:"textLight"},"No allocation data available"));const d=l===TSe.Pie;return a.createElement("div",{"data-external-id":"investments-allocation-content",className:(0,q.cn)("flex items-center gap-17.75 px-xl py-2xl max-[950px]:flex-col max-[950px]:items-stretch",d&&"justify-center")},a.createElement(RSe,{chartType:l,pieChartData:c.pieChartData,horizontalBarData:c.horizontalBarData,totalValue:c.totalValue,pieAnimationIdentity:c.pieAnimationIdentity,barChartHeight:c.barChartHeight,hoveredId:c.hoveredId,legendHoveredId:c.legendHoveredId,onChangeHoveredId:c.setHoveredId,onPieAnimationStateChange:c.setIsPieChartAnimating}),a.createElement(GSe,{selectedOption:n,sortedData:c.sortedData,visibleData:c.visibleData,hiddenIds:c.hiddenIds,toggleVisibility:c.toggleVisibility,totalValue:c.totalValue,colorByType:c.colorByType,hoveredId:c.hoveredId,setHoveredId:c.setHoveredId,setLegendHoveredId:c.setLegendHoveredId,chartType:l,isPieChartAnimating:c.isPieChartAnimating,showFundCategoriesLink:s}))},jSe=e=>{let t=e.filename,n=e.analyticsName;const l=(0,a.useRef)(null),r=(0,a.useState)(!1),i=(0,o.A)(r,2),c=i[0],d=i[1],u=(0,a.useRef)(t);u.current=t;const m=(0,a.useRef)(n);m.current=n;const p=(0,a.useCallback)((async()=>
1{if(l.current){d(!0);try{const e=u.current,t="function"===typeof e?e():e;await(0,_a.o0)(l.current,t),ij.Ay.chartDownloaded({chart:m.current})}catch(e){s.Cp(new Error("Failed to export chart",{cause:e}))}finally{d(!1)}}}),[]);return{ref:l,isExporting:c,onExport:p}},HSe=e=>{var t,n;let l=e.activeAccountIds,r=e.fundsClassification,o=e.onFundsClassificationChange,i=e.chartType,s=e.onChartTypeChange,c=e.onHiddenCategoriesChange,d=e.tabs;const u=jSe({filename:"portfolio-allocation.png",analyticsName:"portfolio-allocation"}),m=u.ref,p=u.isExporting,g=u.onExport,h=(0,a.useCallback)((e=>{o(e),(0,Ge.u4)(Ye.Vi.FundsClassificationChanged,{classification:e,source:"chart"})}),[o]),v=(0,a.useCallback)((e=>{s(e),(0,Ge.u4)(Ye.Vi.FundsChartTypeChanged,{chart_type:e})}),[s]);return a.createElement(nke,{"data-external-id":"funds-graph-pane",ref:m,title:"Fund analysis",titleAdornment:a.createElement(KSe,null),tabs:d,controls:a.createElement(a.Fragment,null,a.createElement(fe.u$N.Root,null,a.createElement(fe.u$N.Trigger,{render:a.createElement(fe.XZZ,{variant:"default",endIcon:a.createElement(fe.D39,{size:"md"})},null!==(t=null===(n=uSe.find((e=>e.value===r)))||void 0===n?void 0:n.label)&&void 0!==t?t:"Category")}),a.createElement(fe.u$N.Content,{align:"end"},a.createElement("div",{className:"px-3 pt-2xs pb-3xs"},a.createElement(fe.c8D,{size:"sm",weight:"medium",color:"secondary"},dSe)),a.createElement(fe.u$N.RadioGroup,{value:r,onValueChange:e=>h(e)},uSe.map((e=>a.createElement(fe.u$N.RadioItem,{key:e.value,value:e.value,closeOnClick:!0},e.label)))))),a.createElement(fe.AVK,{orientation:"vertical",color:"secondary",className:"mx-2xs h-default"}),a.createElement(pW,{"aria-label":"Chart type",options:_Se,value:i,onValueChange:v}),a.createElement(fe.AVK,{orientation:"vertical",color:"secondary",className:"mx-2xs h-default"}),a.createElement("div",{className:"flex"},a.createElement(wt.Xb,{onClick:g,disabled:p,"aria-label":"Download chart"},a.createElement(fe.UTA,{size:"2xs"}))))},a.createElement(oSe,null),a.createElement(WSe,{activeAccountIds:l,selectedOption:r,chartType:i,onHiddenCategoriesChange:c,showFundCategoriesLink:!0}))},KSe=()=>a.createElement(JY.d,{"data-external-id":"title-adornment",content:a.createElement("div",{className:"flex flex-col items-center gap-2xs px-sm py-xs leading-normal"},a.createElement("span",null,"Your funds' market exposure, diversification, and purpose."),a.createElement("span",{className:"my-2xs text-2xs/normal text-content-secondary"},"Data provided by Morningstar. Use governed by Disclosures."),a.createElement(wb.gz,{href:XCe.f,target:"_blank",rel:"noopener noreferrer"},"Learn more")),maxWidth:190,place:"right",clickable:!0},a.createElement(ake,{type:"button","aria-label":"More information"},a.createElement(fe.ucZ,{size:"sm"}))),qSe="Security",$Se="Quantity",ZSe="Total cost basis",JSe="Current value",XSe="Gain/loss $",QSe="Gain/loss %",eNe="Acquired date",tNe="Holding period",nNe="Price per share",aNe="Lot quantity",lNe="Cost basis",rNe="Current value",oNe="Gain/loss $",iNe="Gain/loss %",sNe=1200,cNe=415,dNe=100,uNe=130,mNe=120,pNe=110,gNe=110,hNe=45;var vNe,fNe,ENe;const yNe=$d.s.div(vNe||(vNe=(0,wc.A)(["sticky top-0 z-2 h-0 w-full overflow-visible"]))),bNe=$d.s.div(fNe||(fNe=(0,wc.A)(["relative overflow-hidden will-change-transform"]))),xNe=$d.s.div((e=>["pointer-events-none will-change-transform",e.$layered&&"absolute top-0 left-0 w-full"])),wNe=$d.s.th(ENe||(ENe=(0,wc.A)(["\n  border-b border-divider-primary bg-background-primary px-lg py-default text-right text-sm\n  font-medium whitespace-normal select-none\n  first:text-left\n"])));var CNe;const ANe=e=>{let t=e.title,n=e.variant,l=void 0===n?"default":n,r=e.controls,o=e.minWidth,i=e.stickyHideBelowPx,s=void 0===i?o+100:i,c=e.stickyHeader,d=e.stickyInnerRef,u=e.stickyIsVisible,m=e.scrollContainerRef,p=e.banner,g=e.totals,h=e.allowOverflow,v=void 0!==h&&h,f=e.children;return a.createElement(a.Fragment,null,c&&a.createElement(INe,{hideBelowPx:s},u&&a.createElement(bNe,{ref:d},c)),a.createElement("div",{ref:m,className:"-m-1 overflow-x-auto p-1"},a.createElement("div",{style:{minWidth:"".concat(o,"px")}},a.createElement("div",{className:"overflow-clip rounded-md shadow-card"},a.createElement("div",{className:SNe({variant:l})},a.createElement("div",{className:"sticky left-lg z-1 bg-background-primary"},a.createElement(xt.v,{size:"large",weight:"medium"},t)),a.createElement("div",{className:"sticky right-lg z-1 flex items-center gap-xs bg-background-primary"},r)),p,a.createElement(NNe,{"data-flush-first-column":"funds"===l||void 0,className:(0,q.cn)(v?"overflow-visible":"overflow-clip")},f)),g&&a.createElement("div",{className:"mt-default overflow-clip rounded-md shadow-card"},a.createElement("table",{className:"w-full table-fixed border-spacing-0"},g)))))},INe=e=>{let t=e.hideBelowPx,n=e.children;const l=(0,a.useState)("undefined"!==typeof window&&window.innerWidth<t),r=(0,o.A)(l,2),i=r[0],s=r[1];return(0,a.useEffect)((()=>
1{if("undefined"===typeof window)return;const e=window.matchMedia("(max-width: ".concat(t,"px)"));s(e.matches);const n=e=>s(e.matches);return e.addEventListener("change",n),()=>e.removeEventListener("change",n)}),[t]),i?null:a.createElement(yNe,{"data-external-id":"conditional-sticky-header"},n)},kNe=e=>{let t=e.value,n=e.children;return a.createElement("div",{"data-external-id":"totals-amount-cell",className:"flex justify-end"},null!==t&&void 0!==t&&Math.abs(t)>=1e-8?n:a.createElement(xt.v,null,"-"))},SNe=(0,y0.tv)({base:"flex items-center justify-between bg-background-primary",variants:{variant:{default:"py-default",funds:"pt-lg pb-default"}}}),NNe=$d.s.div(CNe||(CNe=(0,wc.A)(["\n  relative z-0 border-t border-divider-primary\n  [&_tbody_tr:last-child_td:first-child]:rounded-none\n  [&_tbody_tr:last-child_td:last-child]:rounded-none\n  [&_thead_th:first-child]:rounded-none\n  [&_thead_th:last-child]:rounded-none\n  [&[data-flush-first-column]_td:first-child]:pl-lg\n  [&[data-flush-first-column]_th:first-child]:pl-lg\n"])));var TNe=n(62730),_Ne=n(68781),DNe=n(41819);const RNe=e=>{let t=e.onConfirm,n=e.onCancel,l=e.isLoading,r=e.description,o=void 0===r?"Are you sure you want to delete all tax lots for this holding?":r;return a.createElement(xC.$,{"data-external-id":"investments-delete-all-tax-lots-confirmation-modal",title:"Delete all tax lots",confirm:"Delete all",onCancel:n,onConfirm:t,isLoading:l,useDangerButton:!0},a.createElement("div",null,o),a.createElement("div",null,"This action cannot be undone."))},MNe=e=>{let t=e.onConfirm,n=e.onCancel,l=e.isLoading;return a.createElement(xC.$,{"data-external-id":"investments-delete-tax-lot-confirmation-modal",title:"Delete tax lot",confirm:"Delete",onCancel:n,onConfirm:t,isLoading:l,useDangerButton:!0},a.createElement("div",null,"Are you sure you want to delete this tax lot?"),a.createElement("div",null,"This action cannot be undone."))},LNe="Tax lot quantities don\u2019t match your position. Edit your tax lots to correct the mismatch.",ONe=(e,t)=>{var n;if(!e.taxLots||0===e.taxLots.length)return null;const a=(null!==(n=e.quantity)&&void 0!==n?n:0)-(0,MK.A)(e.taxLots.map((e=>e.acquisitionQuantity)));return Math.abs(a)<=(e=>{const t=(0,pke.so)(e);return 6*Math.pow(10,-(t+1))})(t)?null:{difference:a}};var PNe,BNe,zNe,FNe,GNe,YNe,UNe,VNe,WNe,jNe,HNe,KNe,qNe;const $Ne=["hasError","className","maximumFractionDigits","value","onValueChange"],ZNe=e=>isNaN(e)?"$0.00":"$".concat((0,De.$z)(e)),JNe=e=>{let t=e.oldValue,n=e.newValue;return e.show&&t!==n?a.createElement(cTe,{"data-external-id":"value-change-popover"},a.createElement(dTe,null,a.createElement(uTe,null,t),a.createElement(sl.ZQ,{name:"arrow-right",size:12,className:"text-content-link"}),a.createElement(mTe,{weight:"medium"},n))):null},XNe=a.memo((e=>{let t=e.initialValue,n=e.onSave,l=e.hasError;const r=(0,a.useState)(t),i=(0,o.A)(r,2),s=i[0],c=i[1],d=(0,a.useState)(!1),u=(0,o.A)(d,2),m=u[0],p=u[1],g=(0,a.useRef)(t),h=(0,a.useRef)(t),v=(0,a.useRef)(!1),f=(0,a.useRef)(null);(0,a.useEffect)((()=>{t!==g.current&&(g.current=t,h.current=t,v.current=!1,f.current=null,c(t))}),[t]);const E=e=>{e!==t&&e!==f.current&&(f.current=e,Promise.resolve(n(e)).then((e=>{!0!==(null===e||void 0===e?void 0:e.success)&&(f.current=null)}),(()=>{f.current=null})))};return a.createElement("div",{"data-external-id":"editable-date-cell",className:"max-w-37.5",onKeyDown:e=>{"Enter"===e.key?h.current!==t?(v.current=!1,E(h.current)):v.current=!0:v.current=!1}},a.createElement(Kce.J,{variant:"cell",value:s||null,onValueChange:e=>{const t=null!==e&&void 0!==e?e:"";c(t),h.current=t,v.current&&(v.current=!1,E(t))},onOpenChange:e=>{const n=m;p(e),n&&!e&&h.current!==t&&(v.current=!1,E(h.current))},onBlur:()=>{h.current!==t&&(v.current=!1,E(h.current))},invalid:l}))})),QNe=e=>{let t=e.hasError,n=e.className,l=e.maximumFractionDigits,r=void 0===l?2:l,o=e.value,i=e.onValueChange,s=(0,En.A)(e,$Ne);return a.createElement(fe.K$5.Root,{"data-external-id":"currency-cell-input",value:null!==o&&void 0!==o?o:null,min:0,step:"any",format:{minimumFractionDigits:2,maximumFractionDigits:r},onValueChange:i}
1,a.createElement(fe.i9A,{variant:"cell",align:"end",invalid:t,className:"w-full"},a.createElement(fe.K$5.Input,Object.assign({placeholder:"$"},s,{className:n}))))},eTe=e=>{let t=e.children;const n=(0,u.useTheme)();return a.createElement("div",{"data-external-id":"magic-import-indicator-wrapper",style:{color:n.color.purple9},className:"absolute top-1/2 -left-lg flex -translate-y-1/2 cursor-help items-center"},t)},tTe=$d.s.div(PNe||(PNe=(0,wc.A)(["relative -my-2xs -mr-3.25 ml-auto w-full max-w-37.5"]))),nTe=a.memo((e=>{let t=e.initialValue,n=e.onSave,l=e.autoFocus,r=e.hasError,i=e.securityType;const s=parseFloat(t),c=(0,a.useState)(isNaN(s)?void 0:s),d=(0,o.A)(c,2),u=d[0],m=d[1],p=(0,a.useState)(!1),g=(0,o.A)(p,2),h=g[0],v=g[1],f=(0,a.useRef)(t);(0,a.useEffect)((()=>{if(t!==f.current){f.current=t;const e=parseFloat(t);m(isNaN(e)?void 0:e)}}),[t]);const E=(0,pke.so)(i),y=(0,a.useMemo)((()=>({maximumFractionDigits:E})),[E]),b=isNaN(s)?"0":(0,pke.VZ)(s,i),x=void 0!==u?(0,pke.VZ)(u,i):"0",w=(0,a.useCallback)((()=>{const e=null!==u&&void 0!==u?u:NaN,t=null!==s&&void 0!==s?s:NaN;e===t||isNaN(e)&&isNaN(t)||n(void 0!==u?String(u):"")}),[u,s,n]);return a.createElement(tTe,{"data-external-id":"editable-quantity-cell",onKeyDown:e=>{"Enter"===e.key&&w()}},a.createElement(fe._CU.Root,{value:null!==u&&void 0!==u?u:null,invalid:r,min:0,step:"any",locale:"en-US",format:y,onValueChange:e=>m(null!==e&&void 0!==e?e:void 0)},a.createElement(fe.i9A,{variant:"cell",align:"end",invalid:r,className:"w-full"},a.createElement(fe._CU.Input,Object.assign({name:"quantity",placeholder:"0",autoFocus:l,onFocus:()=>v(!0),onBlur:()=>
1{v(!1),w()}},(0,Ex.p)("numeric-input"))))),a.createElement(JNe,{oldValue:b,newValue:x,show:h}))})),aTe=a.memo((e=>{let t=e.initialValue,n=e.onSave,l=e.hasError,r=e.autoFocus;const i=(0,a.useState)(t),s=(0,o.A)(i,2),c=s[0],d=s[1],u=(0,a.useState)(!1),m=(0,o.A)(u,2),p=m[0],g=m[1],h=(0,a.useRef)(t);(0,a.useEffect)((()=>{t!==h.current&&(h.current=t,d(t))}),[t]);const v=ZNe(null!==t&&void 0!==t?t:0),f=ZNe(null!==c&&void 0!==c?c:0);return a.createElement(tTe,{"data-external-id":"editable-cost-cell"},a.createElement(QNe,{hasError:l,name:"cost",placeholder:"$0.00",autoFocus:r,value:c,onValueChange:e=>{d(null!==e&&void 0!==e?e:void 0)},onKeyDown:e=>{"Enter"===e.key&&c!==t&&n(c)},onFocus:()=>g(!0),onBlur:()=>{g(!1),c!==t&&n(c)},maximumFractionDigits:5}),a.createElement(JNe,{oldValue:v,newValue:f,show:p}))})),lTe=a.memo((e=>{let t=e.initialValue,n=e.quantity,l=e.onSave,r=e.hasError;const i=(0,a.useState)(t),s=(0,o.A)(i,2),c=s[0],d=s[1],u=(0,a.useState)(!1),m=(0,o.A)(u,2),p=m[0],g=m[1],h=(0,a.useRef)(t);(0,a.useEffect)((()=>{t!==h.current&&(h.current=t,d(t))}),[t]);const v=(0,a.useCallback)((()=>{if(c===t)return;let e;void 0!==c&&null!==n&&0!==n&&(e=c/n),l(c,e)}),[c,t,n,l]),f=(0,rl.vv)((0,De.Ym)(null!==t&&void 0!==t?t:0)),E=(0,rl.vv)((0,De.Ym)(null!==c&&void 0!==c?c:0));return a.createElement(tTe,{"data-external-id":"editable-total-cost-basis-cell"},a.createElement(QNe,{hasError:r,name:"totalCostBasis",placeholder:"$0.00",value:c,onValueChange:e=>{d(null!==e&&void 0!==e?e:void 0)},onKeyDown:e=>{"Enter"===e.key&&c!==t&&v()},onFocus:()=>g(!0),onBlur:()=>{g(!1),c!==t&&v()}}),a.createElement(JNe,{oldValue:f,newValue:E,show:p}
1))})),rTe=$d.s.div(BNe||(BNe=(0,wc.A)(["-mx-lg flex justify-center"]))),oTe=(0,$d.s)(B.L)(zNe||(zNe=(0,wc.A)(["rounded-full transition-colors hover:bg-background-primary"]))),iTe=$d.s.div(FNe||(FNe=(0,wc.A)(["\n  -mx-lg flex items-center justify-center\n  [&_button]:rounded-full\n  [&_button]:transition-colors\n  [&_button:hover]:bg-background-primary\n"]))),sTe=$d.s.div(GNe||(GNe=(0,wc.A)(["relative"]))),cTe=$d.s.div(YNe||(YNe=(0,wc.A)(["\n  pointer-events-none absolute top-[calc(100%+var(--spacing-2xs))] left-1/2 z-10 -translate-x-1/2\n"]))),dTe=$d.s.div(UNe||(UNe=(0,wc.A)(["\n  flex items-center gap-xs rounded-md bg-background-primary px-default py-sm whitespace-nowrap\n  shadow-[0_2px_8px_rgba(0,0,0,0.15)]\n"]))),uTe=(0,$d.s)(xt.v)(VNe||(VNe=(0,wc.A)(["text-content-secondary"]))),mTe=(0,$d.s)(xt.v)(WNe||(WNe=(0,wc.A)(["text-content-primary"]))),pTe=$d.s.div(jNe||(jNe=(0,wc.A)(["inline-block w-full text-left"]))),gTe=$d.s.span(HNe||(HNe=(0,wc.A)(["inline-block"]))),hTe=(0,$d.s)(Y3.g)(KNe||(KNe=(0,wc.A)(["-mr-xs"]))),vTe=(0,$d.s)(V3)(qNe||(qNe=(0,wc.A)(["-mr-xs"]))),fTe=e=>{let t=e.sortBy,n=e.toColumnSort,l=e.onChange;const r=(0,a.useMemo)((()=>t?[n(t)]:[]),[t,n]),i=(0,a.useCallback)((e=>{const t=(0,_Ne.Zw)(e,r),n=(0,o.A)(t,1)[0];l(null!==n&&void 0!==n?n:null)}),[l,r]);return{sorting:r,onSortingChange:i}};var ETe,yTe,bTe,xTe,wTe,CTe;const ATe="__new__",ITe="__subtotal__",kTe="__missing__",STe="__extra__",NTe="__total__";let TTe=0,_Te=function(e){return e.Data="data",e.New="new",e.Draft="draft",e.AddTaxLot="addTaxLot",e.Subtotal="subtotal",e.MissingShares="missingShares",e.ExtraShares="extraShares",e.Total="total",e}({});const DTe=e=>({id:e.columnId,desc:!e.isAscending}),RTe=(e,t,n)=>({id:ITe,createdAt:null,acquisitionDate:null,acquisitionQuantity:e,costBasisPerUnit:e>0?t/e:0,holdingPeriod:null,gainLoss:{dollars:0,percent:0},totalCostBasis:t,totalCurrentValue:n,rowType:_Te.Subtotal}),MTe=(e,t,n,a)=>{const l=n-t;return{id:NTe,createdAt:null,acquisitionDate:null,acquisitionQuantity:e,costBasisPerUnit:e>0?t/e:0,holdingPeriod:null,gainLoss:{dollars:l,percent:t>0?l/t*100:0},totalCostBasis:t,totalCurrentValue:n,rowType:_Te.Total,hasDiscrepancy:a}},LTe=e=>{let t=e.startAdding,n=e.onOpenImportModal;return a.createElement(Qi.Az,{"data-external-id":"add-tax-lot-button",placement:"bottom-start",overlay:e=>{let l=e.close;return a.createElement(VTe,null,a.createElement(pm.sR,{onClick:()=>{t(),l()}},"Add manually"),n&&a.createElement(pm.sR,{onClick:()=>{n(),l()}},"Upload document"))}},(e=>{let t=e.toggleOpen;return a.createElement(UTe,{onClick:t,"data-row-type":_Te.AddTaxLot},"Add tax lot")}))},OTe=()=>(TTe+=1,"__draft_".concat(TTe,"__")),PTe=(0,$d.s)(Jo.eG)((e=>["[&_td]:border-b-0",e.$isHighlighted&&"animate-[flash-success_2s_ease-out]"])),BTe=$d.s.table(ETe||(ETe=(0,wc.A)(["\n  relative mb-0 w-full table-fixed border-spacing-0 bg-(--tax-lot-bg)\n  [&_tbody]:shadow-none\n  [&_tbody_td]:px-lg [&_tbody_td]:py-xs\n  [&_tbody_td:first-child]:pl-[calc(var(--spacing-2xl)+var(--spacing-xl))]\n  [&_tbody_tr]:h-13.75 [&_tbody_tr]:bg-(--tax-lot-bg) [&_tbody_tr]:transition-colors\n  [&_tbody_tr_.tax-lot-actions]:opacity-0 [&_tbody_tr_.tax-lot-actions]:transition-opacity\n  [&_tbody_tr:hover]:bg-background-secondary\n  [&_tbody_tr:hover_.tax-lot-actions]:opacity-100\n  [&_tbody:empty_~_tfoot_tr:has([data-row-type=addTaxLot])_td]:pt-default\n  [&_tbody:not(:empty)_~_tfoot_tr:has([data-row-type=total])_td]:border-t\n  [&_tbody:not(:empty)_~_tfoot_tr:has([data-row-type=total])_td]:border-(--tax-lot-border)\n  [&_tfoot]:transform-none [&_tfoot]:shadow-none\n  [&_tfoot_td]:px-lg [&_tfoot_td]:py-sm [&_tfoot_td]:pt-default\n  [&_tfoot_td:first-child]:pl-[calc(var(--spacing-2xl)+var(--spacing-xl))]\n  [&_tfoot_tr]:bg-(--tax-lot-bg)\n  [&_tfoot_tr:has([data-row-type=addTaxLot])_td]:pt-xs\n  [&_tfoot_tr:has([data-row-type=addTaxLot])+tr:has([data-row-type=total])_td]:border-t\n  [&_tfoot_tr:has([data-row-type=addTaxLot])+tr:has([data-row-type=total])_td]:border-(--tax-lot-border)\n  [&_tfoot_tr:has([data-row-type=extraShares])]:animate-[slide-in_0.15s_ease-out]\n  [&_tfoot_tr:has([data-row-type=extraShares])]:bg-background-warning\n  [&_tfoot_tr:has([data-row-type=extraShares])_td]:border-b\n  [&_tfoot_tr:has([data-row-type=extraShares])_td]:border-border-warning\n  [&_tfoot_tr:has([data-row-type=extraShares])+tr:has([data-row-type=total])_td]:border-t-0\n  [&_tfoot_tr:has([data-row-type=missingShares])]:animate-[slide-in_0.15s_ease-out]\n  [&_tfoot_tr:has([data-row-type=missingShares])]:bg-background-warning\n  [&_tfoot_tr:has([data-row-type=missingShares])_td]:border-b\n  [&_tfoot_tr:has([data-row-type=missingShares])_td]:border-border-warning\n  [&_tfoot_tr:has([data-row-type=missingShares])+tr:has([data-row-type=total])_td]:border-t-0\n  [&_tfoot_tr:has([data-row-type=subtotal])]:animate-[slide-in_0.15s_ease-out]\n  [&_tfoot_tr:has([data-row-type=subtotal])]:border-t\n  [&_tfoot_tr:has([data-row-type=subtotal])]:border-(--tax-lot-border)\n  [&_tfoot_tr:has([data-row-type=subtotal])]:bg-background-tertiary\n  [&_tfoot_tr:has([data-row-type=total])_td]:border-b\n  [&_tfoot_tr:has([data-row-type=total])_td]:border-(--tax-lot-border)\n  [&_thead]:shadow-none\n  [&_thead_th]:h-10 [&_thead_th]:border-b [&_thead_th]:border-(--tax-lot-border) [&_thead_th]:px-lg\n  [&_thead_th]:py-xs [&_thead_th]:leading-normal [&_thead_th]:text-content-secondary\n  [&_thead_th]:select-none\n  [&_thead_th:first-child]:pl-[calc(var(--spacing-2xl)+var(--spacing-xl))]\n  [&_thead_tr]:bg-(--tax-lot-bg)\n"]))),zTe=$d.s.th(yTe||(yTe=(0,wc.A)(["\n  cursor-pointer bg-(--tax-lot-bg) px-lg py-xs text-sm font-medium whitespace-nowrap select-none\n  hover:text-content-link\n"]))),FTe=(0,$d.s)(sl.ZQ)(bTe||(bTe=(0,wc.A)(["relative -bottom-0.5 ml-xs"]))),GTe=$d.s.td(xTe||(xTe=(0,wc.A)(["bg-(--tax-lot-bg)"]))),YTe=a.memo((e=>{let t=e.holdingId,n=e.taxLots,l=e.currentPrice,r=e.holdingQuantity,i=e.onCreateTaxLot,s=e.onUpdateTaxLot,c=e.onDeleteTaxLot,d=e.onDeleteAllTaxLots,m=e.shouldStartAdding,p=e.onCancelAdding,g=e.onOpenImportModal,h=e.securityType,v=e.magicImportedTaxLotIds,f=e.onTaxLotSaved,E=e.draftTaxLots,y=e.onDeleteDraft,b=e.onSaveDraft;const x=(0,u.useTheme)(),w=(0,a.useState)(!1),C=(0,o.A)(w,2),A=C[0],I=C[1],k=(0,a.useState)(null),S=(0,o.A)(k,2),T=S[0],_=S[1],D=(0,a.useState)(null),R=(0,o.A)(D,2),M=R[0],L=R[1],O=(0,a.useState)({}),z=(0,o.A)(O,2),F=z[0],G=z[1],Y=(0,a.useRef)({acquisitionDate:"",acquisitionQuantity:"",costBasisPerUnit:void 0,totalCostBasis:void 0}),V=(0,a.useRef)(!1),W=(0,a.useRef)(!1),j=(0,a.useRef)({});(0,a.useEffect)((()=>{G(E?e=>{const t={};
1return E.forEach((n=>{var a;t[n.draftId]=null!==(a=e[n.draftId])&&void 0!==a?a:{acquisitionDate:n.acquisitionDate,acquisitionQuantity:n.acquisitionQuantity,costBasisPerUnit:n.costBasisPerUnit,totalCostBasis:n.totalCostBasis}})),t}:{})}),[E]);const H=(0,a.useCallback)(((e,t)=>{G((n=>(0,U.A)((0,U.A)({},n),{},{[e]:(0,U.A)((0,U.A)({},n[e]),t)})))}),[]),K=(0,a.useRef)(new Set),q=(0,a.useCallback)((async(e,t)=>{var n;if(!b||K.current.has(e))return;const a=parseFloat(t.acquisitionQuantity);if(!t.acquisitionDate||isNaN(a)||0===a)return;const l=null!==(n=t.costBasisPerUnit)&&void 0!==n?n:void 0!==t.totalCostBasis?t.totalCostBasis/a:void 0;if(void 0!==l&&!isNaN(l)){K.current.add(e);try{const n=await b(e,{acquisitionDate:t.acquisitionDate,quantity:a,costBasisPerUnit:l});null!==n&&void 0!==n&&n.success&&n.taxLotId&&(L(n.taxLotId),null===f||void 0===f||f(n.taxLotId))}finally{K.current.delete(e)}}}),[b,f]),$=(0,a.useCallback)((e=>{null===y||void 0===y||y(e)}),[y]),Z=(0,a.useCallback)((()=>{var e;Y.current={acquisitionDate:null!==(e=N.c9.local().toISODate())&&void 0!==e?e:"",acquisitionQuantity:"",costBasisPerUnit:void 0,totalCostBasis:void 0},V.current=!0,I(!0)}),[]),J=(0,a.useCallback)((()=>{I(!1),V.current=!1,null===p||void 0===p||p(t)}),[p,t]),X=(0,a.useCallback)((async()=>{if(W.current)return;const e=parseFloat(Y.current.acquisitionQuantity);if(isNaN(e)||0===e)return;const n=Y.current,a=n.acquisitionDate,l=n.costBasisPerUnit,r=n.totalCostBasis;if(!i||!a)return;const o=null!==l&&void 0!==l?l:void 0!==r?r/e:void 0;if(void 0!==o){W.current=!0;try{const n=await i({acquisitionDate:a,quantity:e,costBasisPerUnit:o});null!==n&&void 0!==n&&n.success&&(I(!1),V.current=!1,null===p||void 0===p||p(t),n.taxLotId&&(L(n.taxLotId),null===f||void 0===f||f(n.taxLotId)))}finally{W.current=!1}}}),[i,p,t,f]),Q=(0,a.useCallback)((async e=>{if(!s)return;const t=await s(e);return null!==t&&void 0!==t&&t.success&&(L(e.id),null===f||void 0===f||f(e.id)),t}),[s,f]);(0,a.useEffect)((()=>{m&&!V.current&&(V.current=!0,Z())}),[m,Z]),(0,a.useEffect)((()=>{if(!M)return;const e=j.current[M];e&&e.scrollIntoView({behavior:"smooth",block:"nearest"});const t=setTimeout((()=>{L(null)}),2e3);return()=>clearTimeout(t)}),[M]);const ee=(0,a.useMemo)((()=>{const e=(0,sU.A)(((e,t)=>{if(e.acquisitionDate&&t.acquisitionDate){const n=t.acquisitionDate.diff(e.acquisitionDate).as("milliseconds");if(0!==n)return n}return t.id.localeCompare(e.id)}),n).map((e=>{const t=e.acquisitionQuantity,n=e.costBasisPerUnit,a=(r=e.acquisitionDate)?{isLongTerm:N.c9.local().startOf("day")>r.startOf("day").plus({years:1})}:null;var r;const o=((e,t,n)=>{const a=e*t,l=e*n-a;return{dollars:l,percent:a>0?l/a*100:0}})(t,n,l),i=t*n,s=t*l;return(0,U.A)((0,U.A)({},e),{},{holdingPeriod:a,gainLoss:o,totalCostBasis:i,totalCurrentValue:s,rowType:_Te.Data})})),t=(null!==E&&void 0!==E?E:[]).map((e=>{var t,n;return{id:e.draftId,createdAt:null,acquisitionDate:e.acquisitionDate?N.c9.fromISO(e.acquisitionDate):null,acquisitionQuantity:e.acquisitionQuantity&&parseFloat(e.acquisitionQuantity)||null,costBasisPerUnit:null!==(t=e.costBasisPerUnit)&&void 0!==t?t:null,holdingPeriod:null,gainLoss:{dollars:0,percent:0},totalCostBasis:null!==(n=e.totalCostBasis)&&void 0!==n?n:0,totalCurrentValue:0,rowType:_Te.Draft}}));return[...A?[{id:ATe,createdAt:null,acquisitionDate:null,acquisitionQuantity:null,costBasisPerUnit:null,holdingPeriod:null,gainLoss:{dollars:0,percent:0},totalCostBasis:0,totalCurrentValue:0,rowType:_Te.New}]:[],...t,...e]}),[n,l,A,E]),te=(0,a.useMemo)((()=>{const e=ee.filter((e=>e.rowType===_Te.Data)),t=(0,MK.A)(e.map((e=>{var t;return null!==(t=e.acquisitionQuantity)&&void 0!==t?t:0}))),n=(0,MK.A)(e.map((e=>e.totalCostBasis))),a=(0,MK.A)(e.map((e=>e.totalCurrentValue))),l=ONe({quantity:r,taxLots:e.map((e=>{var t;return{acquisitionQuantity:null!==(t=e.acquisitionQuantity)&&void 0!==t?t:0}}))},h),o=null!==l;var i;return[...o?[RTe(t,n,a),(i=l.difference,{id:i>0?kTe:STe,createdAt:null,acquisitionDate:null,acquisitionQuantity:Math.abs(i),costBasisPerUnit:null,holdingPeriod:null,gainLoss:{dollars:0,percent:0},totalCostBasis:0,totalCurrentValue:0,rowType:i>0?_Te.MissingShares:_Te.ExtraShares})]:[],MTe(null!==r&&void 0!==r?r:0,n,a,o)]}),[ee,r,h]),ne=(e=>{let t=e.newRowValuesRef,n=e.createTaxLot,l=e.cancelAdding,r=e.updateTaxLot,o=e.onDeleteTaxLot,i=e.onDeleteAllTaxLots,s=e.securityType,c=e.magicImportedTaxLotIds,d=e.draftRowValues,u=e.updateDraftRow,m=e.s
1aveDraft,p=e.deleteDraft;const g=a.useCallback(((e,t)=>r({id:e,acquisitionDate:t||void 0})),[r]),h=a.useCallback(((e,t)=>{const n=parseFloat(t);isNaN(n)||0===n||r({id:e,quantity:n})}),[r]),v=a.useCallback(((e,t)=>{void 0!==t&&r({id:e,costBasisPerUnit:t})}),[r]),f=a.useCallback(((e,t)=>{void 0!==t&&r({id:e,costBasisPerUnit:t})}),[r]),E=a.useCallback(((e,t)=>{t===_Te.New?l():t===_Te.Draft?p(e):o&&o(e)}),[l,o,p]);return(0,a.useMemo)((()=>[{id:"acquisitionDate",header:eNe,size:190,meta:{align:"left"},accessorFn:e=>{var t;let n=e.acquisitionDate;return null!==(t=null===n||void 0===n?void 0:n.toMillis())&&void 0!==t?t:0},sortingFn:(e,t)=>{var n,a,l,r;const o=null!==(n=null===(a=e.original.acquisitionDate)||void 0===a?void 0:a.toMillis())&&void 0!==n?n:0,i=null!==(l=null===(r=t.original.acquisitionDate)||void 0===r?void 0:r.toMillis())&&void 0!==l?l:0;return o!==i?o>i?1:-1:e.original.id.localeCompare(t.original.id)},sortDescFirst:!0,cell:e=>{var l,r;let o=e.row.original;if(o.rowType===_Te.Subtotal)return a.createElement(xt.v,{weight:"medium","data-row-type":"subtotal"},"Subtotal");if(o.rowType===_Te.MissingShares)return a.createElement(xt.v,{weight:"medium","data-row-type":"missingShares"},"Missing shares");if(o.rowType===_Te.ExtraShares)return a.createElement(xt.v,{weight:"medium","data-row-type":"extraShares"},"Extra shares");if(o.rowType===_Te.Total)return a.createElement("div",{"data-row-type":"total",className:"flex items-center gap-xs"},a.createElement(xt.v,{weight:"bold"},"Total"),o.hasDiscrepancy&&a.createElement("div",{className:"flex items-center gap-2xs"},a.createElement(sl.ZQ,{name:"alert-triangle",size:14,className:"text-content-warning"}),a.createElement(xt.v,{color:"content.warning",weight:"medium"},"Partial data")));if(o.rowType===_Te.New)return a.createElement("div",{"data-row-type":"new"},a.createElement(XNe,{initialValue:t.current.acquisitionDate,onSave:e=>(t.current.acquisitionDate=e,n())}));if(o.rowType===_Te.Draft){var i;const e=d[o.id],t=null!==(i=null===e||void 0===e?void 0:e.acquisitionDate)&&void 0!==i?i:"";return a.createElement(sTe,null,a.createElement(P.D_,{content:"Created by Magic Import",place:"top"},a.createElement(eTe,null,a.createElement(sl.ZQ,{name:"sparkle",size:14}))),a.createElement(XNe,{initialValue:t,hasError:!t,onSave:e=>{const t=(0,U.A)((0,U.A)({},d[o.id]),{},{acquisitionDate:e});return u(o.id,{acquisitionDate:e}),m(o.id,t)}}))}const s=null===c||void 0===c?void 0:c.has(o.id);return a.createElement(sTe,null,s&&a.createElement(P.D_,{content:"Created by Magic Import",place:"top"},a.createElement(eTe,null,a.createElement(sl.ZQ,{name:"sparkle",size:14}))),a.createElement(XNe,{initialValue:null!==(l=null===(r=o.acquisitionDate)||void 0===r?void 0:r.toISODate())&&void 0!==l?l:"",onSave:e=>g(o.id,e)}))}},{id:"holdingPeriod",header:tNe,size:105,meta:{align:"left"},accessorFn:e=>{let t=e.holdingPeriod;return t?t.isLongTerm?"Long":"Short":"-"},cell:e=>{let t=e.row.original;return t.rowType===_Te.Data&&t.holdingPeriod?a.createElement(pTe,null,t.holdingPeriod.isLongTerm?"Long":"Short"):a.createElement(pTe,null,"-")}},{id:"costBasisPerUnit",header:()=>a.createElement(gTe,null,nNe),size:120,accessorFn:e=>{let t=e.costBasisPerUnit;return(0,rl.vv)(null!==t&&void 0!==t?t:0)},cell:e=>{var l;let r=e.row.original;var o,i,s,c;if(r.rowType===_Te.Subtotal)return Math.abs(null!==(o=r.costBasisPerUnit)&&void 0!==o?o:0)<.01?a.createElement("span",null,"-"):a.createElement("span",null,(0,rl.vv)(null!==(i=r.costBasisPerUnit)&&void 0!==i?i:0));if(r.rowType===_Te.Total)return Math.abs(null!==(s=r.costBasisPerUnit)&&void 0!==s?s:0)<.01?a.createElement(xt.v,{weight:"bold"},"-"):a.createElement(xt.v,{color:r.hasDiscrepancy?"content.warning":void 0,weight:"bold"},(0,rl.vv)(null!==(c=r.costBasisPerUnit)&&void 0!==c?c:0));if(r.rowType!==_Te.Data&&r.rowType!==_Te.New&&r.rowType!==_Te.Draft)return a.createElement("span",null,"-");if(r.rowType===_Te.New)return a.createElement(aTe,{initialValue:t.current.costBasisPerUnit,onSave:e=>{t.current.costBasisPerUnit=e,n()},autoFocus:!0});if(r.rowType===_Te.Draft){const e=d[r.id],t=null===e||void 0===e?void 0:e.costBasisPerUnit;return a.createElement(aTe,{initialValue:t,hasError:void 0===t,onSave:e=>{const t=(0,U.A)((0,U.A)({},d[r.id]),{},{costBasisPerUnit:e});u(r.id,{costBasisPerUnit:e}),m(r.id,t)}})}return a.createElement(aTe,{initialValue:null!==(l=r.costBasisPerUnit)&&void 0!==l?l:void 0,onSave:e=>v(r.id,e)})}},{id:"acquisitionQuantity",header:()=>a.createElement(gTe,null,aNe),size:100,accessorFn:e=>{let t=e.acquisitionQuantity;
1return(null!==t&&void 0!==t?t:0).toLocaleString()},cell:e=>{var l;let r=e.row.original;var o,i,c;if(r.rowType===_Te.Subtotal)return a.createElement("span",null,(0,pke.VZ)(null!==(o=r.acquisitionQuantity)&&void 0!==o?o:0,s));if(r.rowType===_Te.MissingShares||r.rowType===_Te.ExtraShares)return a.createElement(xt.v,{color:"content.warning",weight:"medium"},(0,pke.VZ)(null!==(i=r.acquisitionQuantity)&&void 0!==i?i:0,s));if(r.rowType===_Te.Total)return a.createElement(xt.v,{color:r.hasDiscrepancy?"content.warning":void 0,weight:"bold"},(0,pke.VZ)(null!==(c=r.acquisitionQuantity)&&void 0!==c?c:0,s));if(r.rowType===_Te.New)return a.createElement(nTe,{initialValue:t.current.acquisitionQuantity,securityType:s,onSave:e=>{t.current.acquisitionQuantity=e,n()}});if(r.rowType===_Te.Draft){var p;const e=d[r.id],t=null!==(p=null===e||void 0===e?void 0:e.acquisitionQuantity)&&void 0!==p?p:"";return a.createElement(nTe,{initialValue:t,hasError:!t||0===parseFloat(t),securityType:s,onSave:e=>{const t=(0,U.A)((0,U.A)({},d[r.id]),{},{acquisitionQuantity:e});u(r.id,{acquisitionQuantity:e}),m(r.id,t)}})}return a.createElement(nTe,{initialValue:String(null!==(l=r.acquisitionQuantity)&&void 0!==l?l:""),securityType:s,onSave:e=>h(r.id,e)})}},{id:"totalCostBasis",header:()=>a.createElement(gTe,null,lNe),size:130,accessorFn:e=>{let t=e.totalCostBasis;return(0,rl.vv)(t)},cell:e=>{let l=e.row.original;if(l.rowType===_Te.Subtotal||l.rowType===_Te.MissingShares||l.rowType===_Te.ExtraShares)return Math.abs(l.totalCostBasis)<.01?a.createElement("span",null,"-"):a.createElement("span",null,(0,rl.vv)(l.totalCostBasis));if(l.rowType===_Te.Total)return Math.abs(l.totalCostBasis)<.01?a.createElement(xt.v,{weight:"bold"},"-"):a.createElement(xt.v,{color:l.hasDiscrepancy?"content.warning":void 0,weight:"bold"},(0,rl.vv)(l.totalCostBasis));if(l.rowType===_Te.New)return a.createElement(lTe,{initialValue:t.current.totalCostBasis,quantity:parseFloat(t.current.acquisitionQuantity)||null,onSave:(e,a)=>{t.current.totalCostBasis=e,void 0!==a&&(t.current.costBasisPerUnit=a),n()}});if(l.rowType===_Te.Draft){var r;const e=d[l.id],t=null===e||void 0===e?void 0:e.totalCostBasis,n=void 0===(null===e||void 0===e?void 0:e.costBasisPerUnit)&&void 0===t;return a.createElement(lTe,{initialValue:t,quantity:parseFloat(null!==(r=null===e||void 0===e?void 0:e.acquisitionQuantity)&&void 0!==r?r:"")||null,hasError:n,onSave:(e,t)=>{const n={totalCostBasis:e};void 0!==t&&(n.costBasisPerUnit=t);const a=(0,U.A)((0,U.A)({},d[l.id]),n);u(l.id,n),m(l.id,a)}})}return a.createElement(lTe,{initialValue:l.totalCostBasis,quantity:l.acquisitionQuantity,onSave:(e,t)=>f(l.id,t)})}},{id:"totalCurrentValue",header:()=>a.createElement(gTe,null,rNe),size:120,accessorFn:e=>{let t=e.totalCurrentValue;return(0,rl.vv)(t)},cell:e=>{let t=e.row.original;return t.rowType!==_Te.Data&&t.rowType!==_Te.Total?a.createElement("span",null,"-"):t.rowType===_Te.Total?Math.abs(t.totalCurrentValue)<.01?a.createElement(xt.v,{weight:"bold"},"-"):a.createElement(xt.v,{weight:"bold"},(0,rl.vv)(t.totalCurrentValue)):a.createElement("span",null,(0,rl.vv)(t.totalCurrentValue))}},{id:"gainLossDollars",header:()=>a.createElement(gTe,null,oNe),size:110,accessorFn:e=>e.gainLoss.dollars,cell:e=>{let t=e.row.original;return t.rowType!==_Te.Data&&t.rowType!==_Te.Total?a.createElement("span",null,"-"):Math.abs(t.gainLoss.dollars)<1e-8?a.createElement("div",{className:"flex justify-end"},a.createElement(xt.v,null,"-")):a.createElement("div",{className:"flex justify-end"},a.createElement(hTe,{value:t.gainLoss.dollars,formatter:rl.vv}))}},{id:"gainLossPercent",header:()=>a.createElement(gTe,null,iNe),size:110,accessorFn:e=>e.gainLoss.percent,cell:e=>{let t=e.row.original;return t.rowType!==_Te.Data&&t.rowType!==_Te.Total?a.createElement("span",null,"-"):Math.abs(t.gainLoss.percent)<1e-8?a.createElement("div",{className:"flex justify-end"},a.createElement(xt.v,null,"-")):a.createElement("div",{className:"flex justify-end"},a.createElement(vTe,{returnPercent:t.gainLoss.percent}))}},{id:"actions",size:45,enableSorting:!1,header:()=>i?a.createElement(rTe,null,a.createElement(Qi.Az,{overlay:a.createElement(Ji.SP,null,a.createElement(Ji.xm,{type:"danger",icon:"trash",onClick:i},"Delete all tax lots")),placement:"bottom-end"},(e=>{let t=e.toggleOpen,n=e.isOpen;return a.createElement(oTe,{onClick:e=>{e.stopPropagation(),t()},active:n,icon:"more-horizontal",size:"small"})}))):null,cell:e=>{let t=e.row.original;return t.rowType===_Te.Subtotal||t.rowType===_Te.ExtraShares||t.rowType===_Te.Total||t.rowType===_Te.MissingShares?null:a.createElement(iTe,{className:"tax-lot-actions"},a.createElement(B.L,{icon:"trash",size:"small",onClick:()=>
1E(t.id,t.rowType),"aria-label":"Delete"}))}}]),[t,n,g,h,v,f,E,i,s,c,d,u,m])})({holdingId:t,newRowValuesRef:Y,createTaxLot:X,cancelAdding:J,updateTaxLot:Q,onDeleteTaxLot:c,onDeleteAllTaxLots:d,securityType:h,magicImportedTaxLotIds:v,draftRowValues:F,updateDraftRow:H,saveDraft:q,deleteDraft:$}),ae=(0,a.useCallback)((e=>_(e?{columnId:e.id,isAscending:!e.desc}:null)),[_]),le=fTe({sortBy:T,toColumnSort:DTe,onChange:ae}),re=le.sorting,oe=le.onSortingChange,ie=(0,a.useMemo)((()=>({sorting:re})),[re]),se=(0,TNe.N4)({data:ee,columns:ne,getRowId:e=>e.id,state:ie,onSortingChange:oe,defaultColumn:(0,Jo.rN)(),getCoreRowModel:(0,_Ne.HT)(),getSortedRowModel:(0,_Ne.h5)(),enableMultiSort:!1});return a.createElement(a.Fragment,null,a.createElement(BTe,{style:{minWidth:"".concat(sNe,"px"),"--tax-lot-bg":x.color.gray1,"--tax-lot-border":x.color.gray3}},a.createElement("thead",null,se.getHeaderGroups().map((e=>a.createElement(Jo.eG,{key:e.id},e.headers.map((e=>{var t;return a.createElement(zTe,{key:e.id,onClick:e.column.getCanSort()?e.column.getToggleSortingHandler():void 0,style:{width:e.getSize(),textAlign:(null===(t=e.column.columnDef.meta)||void 0===t?void 0:t.align)||"right"}},e.isPlaceholder?null:(0,TNe.Kv)(e.column.columnDef.header,e.getContext()),"desc"===e.column.getIsSorted()?a.createElement(FTe,{name:"arrow-down",size:12}):null,"asc"===e.column.getIsSorted()?a.createElement(FTe,{name:"arrow-up",size:12}):null)})))))),a.createElement("tbody",null,se.getRowModel().rows.map((e=>{const t=e.original.rowType===_Te.Data,n=e.original.rowType===_Te.Draft,l=t&&M===e.original.id;return a.createElement(PTe,{key:e.id,ref:a=>{(t||n)&&(j.current[e.original.id]=a)},$isHighlighted:l},e.getVisibleCells().map((e=>a.createElement(Jo.Si,{key:e.id,$defaultAlignment:"right",style:{width:e.column.getSize()}},(0,TNe.Kv)(e.column.columnDef.cell,e.getContext())))))}))),a.createElement("tfoot",null,a.createElement(Jo.eG,null,a.createElement(GTe,{colSpan:ne.length},a.createElement(LTe,{startAdding:Z,onOpenImportModal:g}))),te.map((e=>a.createElement(Jo.eG,{key:e.id},ne.map((t=>{const n=t.cell;return a.createElement(Jo.Si,{key:t.id,$defaultAlignment:"right",style:{width:t.size}},"function"===typeof n?n({row:{original:e}}):null)}))))))))})),UTe=$d.s.button(wTe||(wTe=(0,wc.A)(["\n  flex cursor-pointer items-center gap-2xs border-0 bg-transparent p-0 text-sm\n  font-medium text-content-link transition\n  hover:text-content-link-hover\n"]))),VTe=(0,$d.s)(Qi.j7)(CTe||(CTe=(0,wc.A)(["min-w-45 px-0 py-2xs"]))),WTe=Ee.Mw1,jTe=Ee.LPY,HTe=Ee.kyz,KTe=Ee.Cww,qTe=Ee.DGn,$Te=Ee.eoR;var ZTe=n(91248);const JTe=(e,t,n)=>{const a=n?t.filter((e=>{var t;return(null===(t=e.account)||void 0===t?void 0:t.id)===n})):t,l=[],r=[];return e.forEach((e=>{if(!e.securitySymbol)return void r.push(e);const t=e.securitySymbol,n=a.find((e=>{var n;return!!e.ticker&&(0,ZTe.i_)(t,e.ticker)||!(null===(n=e.security)||void 0===n||!n.ticker)&&(0,ZTe.i_)(t,e.security.ticker)}));if(n){const t=l.find((e=>e.holding.id===n.id));t?t.lots.push(e):l.push({holding:n,lots:[e]})}else r.push(e)})),{matched:l,unmatched:r}};var XTe=n(81406);const QTe=e=>void 0!==e.acquisitionDate&&""!==e.acquisitionDate.trim()||void 0!==e.quantity&&!isNaN(e.quantity)&&0!==e.quantity||void 0!==e.costBasisPerUnit&&!isNaN(e.costBasisPerUnit),e_e=e=>{const t=(0,a.useState)(!1),n=(0,o.A)(t,2),l=n[0],r=n[1],c=(0,C.RU)(),d=(0,i.n)($Te,{refetchQueries:["Web_GetPortfolio","Web_GetTaxLotPerformance"],awaitRefetchQueries:!0}),u=(0,o.A)(d,1)[0],m=(0,a.useCallback)((async t=>{if(!e)return c({description:"Failed to import tax lots - no account specified"}),{success:!1,importedCount:0,importedTaxLotIds:[],incompleteLots:[]};r(!0);const n=t.map((e=>(0,U.A)((0,U.A)({},e),{},{lots:e.lots.filter(QTe)}))),a=t.reduce(((e,t)=>e+t.lots.length),0)-n.reduce(((e,t)=>e+t.lots.length),0);if(a>0&&n.every((e=>0===e.lots.length)))return r(!1),(0,C.oR)({title:"No tax lots found in the uploaded documents"}),{success:!1,importedCount:0,importedTaxLotIds:[],incompleteLots:[]};a>0&&(0,C.oR)({title:"Couldn't import ".concat(a," tax ").concat(1===a?"lot":"lots"),description:"Some rows had no recognizable data and were skipped."});const l=n.flatMap((e=>e.lots)),o=[],i=[];
1n.forEach((e=>{const t=[];e.lots.forEach((n=>{(e=>{const t=void 0!==e.quantity&&!isNaN(e.quantity)&&0!==e.quantity,n=void 0!==e.acquisitionDate&&""!==e.acquisitionDate.trim(),a=void 0!==e.costBasisPerUnit&&!isNaN(e.costBasisPerUnit);return t&&n&&a})(n)?t.push(n):i.push({holdingId:e.holdingId,lot:n})})),t.length>0&&o.push({holdingId:e.holdingId,lots:t})}));const d=o.flatMap((e=>e.lots)),m=i.length;if(0===d.length&&0===m)return r(!1),(0,C.oR)({title:"No valid tax lots found to import"}),{success:!1,importedCount:0,importedTaxLotIds:[],incompleteLots:i};if(0===d.length)return r(!1),(0,C.oR)({title:"".concat(m," tax lot").concat(1!==m?"s":""," need additional data")}),{success:!0,importedCount:0,importedTaxLotIds:[],incompleteLots:i};try{var p,g,h,v;const t=o.flatMap((e=>e.lots.map((t=>({holdingId:e.holdingId,acquisitionDate:t.acquisitionDate,acquisitionQuantity:t.quantity,costBasisPerUnit:t.costBasisPerUnit}))))),n={accountId:e,taxLots:t},a=(await u({variables:{input:n}})).data,s=null!==(p=null===a||void 0===a?void 0:a.createManualTaxLotsBulk)&&void 0!==p?p:{},f=s.taxLots,E=s.errors,y=null!==(g=null===f||void 0===f?void 0:f.length)&&void 0!==g?g:0,b=null!==(h=null===E||void 0===E?void 0:E.length)&&void 0!==h?h:0,x=null!==(v=null===f||void 0===f?void 0:f.map((e=>e.id)))&&void 0!==v?v:[],w=l.length>0?l.reduce(((e,t)=>e+t.confidence),0)/l.length:0;if((0,Ge.u4)(Ye.Vi.TaxLotsImported,{lots_imported_count:y,lots_extracted_count:l.length,lots_failed_count:b,lots_incomplete_count:m,import_rate:d.length>0?y/d.length:0,confidence_bucket:(0,XTe.v0)(w),has_symbols:l.some((e=>e.securitySymbol))}),r(!1),0===y&&0===m)return c({description:"Failed to import tax lots"}),{success:!1,importedCount:0,importedTaxLotIds:[],incompleteLots:i};const A=[];return y>0&&A.push("Imported ".concat(y," tax lot").concat(1!==y?"s":"")),b>0&&A.push("".concat(b," failed")),m>0&&A.push("".concat(m," need additional data")),b>0?c({description:A.join(", ")}):m>0&&(0,C.oR)({title:A.join(", ")}),{success:y>0||m>0,importedCount:y,importedTaxLotIds:x,incompleteLots:i}}catch(f){return s.Cp(new Error("Failed to import tax lots",{cause:f})),c({description:"Failed to import tax lots"}),r(!1),{success:!1,importedCount:0,importedTaxLotIds:[],incompleteLots:i}}}),[e,u,c]);return{importTaxLots:m,isImporting:l}},t_e=e=>{var t,n,l,r,c,d;let u=e.holding,m=e.currentPrice,p=e.shouldStartAdding,g=e.onCancelAdding,h=e.magicImportedTaxLotIds,v=e.onAddMagicImportedTaxLots,f=e.onRemoveMagicImportedTaxLot,E=e.draftTaxLots,y=e.onDeleteDraft,b=e.onAddDrafts,x=e.allAccountHoldings;const w=(0,C.RU)(),A=(0,Pd.h)(),I=(0,o.A)(A,2),k=I[0],S=I[1],T=S.open,_=S.close,D=(0,a.useState)(null),R=(0,o.A)(D,2),M=R[0],L=R[1],O=(0,Pd.h)(),P=(0,o.A)(O,2),B=P[0],z=P[1],F=z.open,G=z.close,Y=(0,a.useState)(!1),U=(0,o.A)(Y,2),V=U[0],W=U[1],j=e_e(null===(t=u.account)||void 0===t?void 0:t.id),H=j.importTaxLots,K=j.isImporting,q=(0,i.n)(jTe,{update(e,t){var n;let a=t.data;const l=null===a||void 0===a||null===(n=a.createManualTaxLot)||void 0===n?void 0:n.taxLot;l&&e.modify({id:e.identify({__typename:"Holding",id:u.id}),fields:{taxLots(){return[...arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],e.writeFragment({data:l,fragment:WTe})]}}})},refetchQueries:["Web_GetTaxLotPerformance"],awaitRefetchQueries:!1}),$=(0,o.A)(q,1)[0],Z=(0,i.n)(HTe,{update(e,t){var n;let a=t.data;const l=null===a||void 0===a||null===(n=a.updateTaxLot)||void 0===n?void 0:n.taxLot;l&&e.writeFragment({id:e.identify({__typename:"TaxLot",id:l.id}),fragment:WTe,data:l})},refetchQueries:["Web_GetTaxLotPerformance"],awaitRefetchQueries:!1}),J=(0,o.A)(Z,1)[0],X=(0,i.n)(KTe,{update(e,t,n){var a;let l=t.data,r=n.variables;if(!(null===l||void 0===l||null===(a=l.deleteTaxLot)||void 0===a?void 0:a.deleted)||!r)return;const o=r.id;e.modify({id:e.identify({__typename:"Holding",id:u.id}),fields:{taxLots(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=(arguments.length>1?arguments[1]:void 0).readField;return e.filter((e=>o!==t("id",e)))}}}),e.evict({id:e.identify({__typename:"TaxLot",id:o})})},refetchQueries:["Web_GetTaxLotPerformance"],awaitRefetchQueries:!1}),Q=(0,o.A)(X,2),ee=Q[0],te=Q[1].loading,ne=(0,i.n)(qTe,{update(e,t,n){var a;let l=t.data,r=n.variables;if(!(null===l||void 0===l||null===(a=l.deleteTaxLotsBulk)||void 0===a?void 0:a.deletedCount)||!r)return;const o=new Set(r.input.ids);e.modify({id:e.identify({__typename:"Holding",id:u.id}),fields:{taxLots(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=(arguments.length>1?arguments[1]:void 0).readField;return e.filter((e=>!o.has(t("id",e))))}}}),r.input.ids.forEach((t=>{e.evict({id:e.identify({__typename:"TaxLot",id:t})})}))},refetchQueries:["Web_GetTaxLotPerformance"],awaitRefetchQueries:!1}),ae=(0,o.A)(ne,2),le=ae[0],re=ae[1].loading,oe=(0,a.useMemo)((()=>{var e;return(null!==(e=u.taxLots)&&void 0!==e?e:[]).map((e=>({id:e.id,createdAt:N.c9.fromISO(e.createdAt),acquisitionDate:N.c9.fromISO(e.acquisitionDate),acquisitionQuantity:e.acquisitionQuantity,costBasisPerUnit:e.costBasisPerUnit})))}),[u.taxLots]),ie=(0,a.useCallback)((async e=>{try{var t,n;if(null===(t=u.account)||void 0===t||!t.id)return{success:!1};(0,Ge.u4)(Ye.Vi.TaxLotManuallyAdded,{source:"table"});const l={holdingId:u.id,accountId:u.account.id,acquisitionDate:e.acquisitionDate,acquisitionQuantity:e.quantity,costBasisPerUnit:e.costBasisPerUnit},r=(await $({variables:{input:l}})).data,o=null!==(n=null===r||void 0===r?void 0:r.createManualTaxLot)&&void 0!==n?n:{},i=o.errors,s=o.taxLot;var a;return i||!s?(w({description:null!==(a=null===i||void 0===i?void 0:i.message)&&void 0!==a?a:"Failed to create tax lot"}),{success:!1}):{success:!0,taxLotId:s.id}}catch(l){return w({description:"Failed to create tax lot"}),s.Cp(new Error("Failed to create tax lot",{cause:l})),{success:!1}}}),[u.id,null===(n=u.account)||void 0===n?void 0:n.id,$,w]),se=(0,a.useCallback)((async e=>{(0,Ge.u4)(Ye.Vi.TaxLotManuallyUpdated),null!==h&&void 0!==h&&h.has(e.id)&&(0,Ge.u4)(Ye.Vi.TaxLotAIImportEdited,{action:"updated"});try{var t;const a={id:e.id,acquisitionDate:e.acquisitionDate,acquisitionQuantity:e.quantity,costBasisPerUnit:e.costBasisPerUnit},l=(await J({variables:{input:a}})).data,r=null!==(t=null===l||void 0===l?void 0:l.updateTaxLot)&&void 0!==t?t:{},o=r.errors,i=r.taxLot;var n;return o||!i?(w({description:null!==(n=null===o||void 0===o?void 0:o.message)&&void 0!==n?n:"Failed to update tax lot"}),{success:!1}):{success:!0,taxLotId:i.id}}catch(a){return w({description:"Failed to update tax lot"}),s.Cp(new Error("Failed to update tax lot",{cause:a})),{success:!1}}}),[J,h,w]),ce=(0,a.useCallback)((async e=>{L(e),T(e)}
1),[T]),de=(0,a.useCallback)((async()=>{var e;if(!M)return;const t=null!==(e=null===h||void 0===h?void 0:h.has(M))&&void 0!==e&&e;(0,Ge.u4)(Ye.Vi.TaxLotManuallyDeleted),t&&(0,Ge.u4)(Ye.Vi.TaxLotAIImportEdited,{action:"deleted"});try{var n;const e=(await ee({variables:{id:M}})).data,l=null!==(n=null===e||void 0===e?void 0:e.deleteTaxLot)&&void 0!==n?n:{},r=l.errors,o=l.deleted;var a;if(r||!o)w({description:null!==(a=null===r||void 0===r?void 0:r.message)&&void 0!==a?a:"Failed to delete tax lot"});else t&&f(M),_(),L(null)}catch(l){w({description:"Failed to delete tax lot"}),s.Cp(new Error("Failed to delete tax lot",{cause:l}))}}),[M,ee,_,h,f,w]),ue=(0,a.useCallback)((()=>{_(),L(null)}),[_]),me=(0,a.useCallback)((()=>{F()}),[F]),pe=(0,a.useCallback)((async()=>{const e=oe.map((e=>e.id));(0,Ge.u4)(Ye.Vi.TaxLotsManuallyDeletedAll,{count:e.length});const t=e.filter((e=>null===h||void 0===h?void 0:h.has(e)));t.length>0&&(0,Ge.u4)(Ye.Vi.TaxLotAIImportEdited,{action:"deleted"});try{if(e.length>0){var n;const l=(await le({variables:{input:{ids:e}}})).data,r=null!==(n=null===l||void 0===l?void 0:l.deleteTaxLotsBulk)&&void 0!==n?n:{},o=r.errors,i=r.deletedCount;var a;if(o||void 0===i)return void w({description:null!==(a=null===o||void 0===o?void 0:o.message)&&void 0!==a?a:"Failed to delete all tax lots"});t.forEach(f)}null===E||void 0===E||E.forEach((e=>{let t=e.draftId;return null===y||void 0===y?void 0:y(u.id,t)})),G()}catch(l){w({description:"Failed to delete all tax lots"}),s.Cp(new Error("Failed to delete all tax lots",{cause:l}))}}),[oe,le,h,f,E,y,u.id,G,w]),ge=(0,a.useCallback)((()=>{W(!0),(0,Ge.u4)(Ye.Vi.TaxLotImportModalOpened,{source:"holding_table"})}),[]),he=(0,a.useCallback)((()=>{W(!1)}),[]),ve=(0,a.useCallback)((e=>{e.importedTaxLotIds.length>0&&v(e.importedTaxLotIds),e.incompleteLots.length>0&&b&&e.incompleteLots.forEach((e=>{var t;let n=e.holdingId,a=e.lot;b(n,[{draftId:OTe(),acquisitionDate:null!==(t=a.acquisitionDate)&&void 0!==t?t:"",acquisitionQuantity:void 0===a.quantity||isNaN(a.quantity)?"":String(a.quantity),costBasisPerUnit:void 0===a.costBasisPerUnit||isNaN(a.costBasisPerUnit)?void 0:a.costBasisPerUnit,totalCostBasis:void 0}])}))}),[v,b]),fe=(0,a.useCallback)((async e=>{var t;(0,Ge.u4)(Ye.Vi.TaxLotAIParseReceived,{lots_extracted_count:e.length,has_symbols:e.some((e=>e.securitySymbol)),is_account_level_import:!1});const n=e.filter(QTe);if(0===n.length)return W(!1),(0,C.oR)({title:"No tax lots found in the uploaded documents"}),{unmatchedLots:[]};const a=null!==x&&void 0!==x?x:[u],l=JTe(n,a,null===(t=u.account)||void 0===t?void 0:t.id),r=l.matched,o=l.unmatched,i=0===r.length&&1===a.length,s=i?[{holding:a[0],lots:n}]:r;if(s.length>0){const e=s.map((e=>({holdingId:e.holding.id,lots:e.lots}))),t=await H(e);ve(t)}return{unmatchedLots:i?[]:o}}),[x,u,H,ve]),Ee=(0,a.useCallback)((e=>{null===y||void 0===y||y(u.id,e)}),[y,u.id]),ye=(0,a.useCallback)((async(e,t)=>{const n=await ie(t);return n.success&&(null===y||void 0===y||y(u.id,e),n.taxLotId&&v([n.taxLotId])),n}),[ie,v,y,u.id]);return a.createElement(a.Fragment,null,a.createElement(YTe,{holdingId:u.id,taxLots:oe,currentPrice:m,holdingQuantity:null!==(l=u.quantity)&&void 0!==l?l:null,onCreateTaxLot:ie,onUpdateTaxLot:se,onDeleteTaxLot:ce,onDeleteAllTaxLots:oe.length>0||(null!==(r=null===E||void 0===E?void 0:E.length)&&void 0!==r?r:0)>0?me:void 0,shouldStartAdding:p,onCancelAdding:g,onOpenImportModal:ge,securityType:null===(c=u.security)||void 0===c?void 0:c.type,magicImportedTaxLotIds:h,draftTaxLots:E,onDeleteDraft:Ee,onSaveDraft:ye}),a.createElement(k,null,a.createElement(MNe,{onConfirm:de,onCancel:ue,isLoading:te})),a.createElement(B,null,a.createElement(RNe,{onConfirm:pe,onCancel:G,isLoading:re})),V&&a.createElement(eIe,{onParsed:fe,onFinalizeUnmatched:async e=>{const t=e.map((e=>{let t=e.lot;return{holdingId:e.holdingId,lots:[t]}})),n=await H(t);ve(n)},onClose:he,isImporting:K,holdings:null!==x&&void 0!==x?x:[u],accountId:null===(d=u.account)||void 0===d?void 0:d.id,accounts:u.account?[{id:u.account.id,displayName:u.account.displayName}]:void 0}))};var n_e=n(22133);const a_e=e=>{try{const t=localStorage.getItem(e);return t?new Set(JSON.parse(t)):new Set}catch(t){return new Set}},l_e=(e,t)=>
1{const n=(0,d.d4)(Od.F6),l="".concat(e,"-").concat(null!==n&&void 0!==n?n:"anon","-").concat(t),r=(0,a.useState)((()=>a_e(l))),i=(0,o.A)(r,2),s=i[0],c=i[1],u=(0,a.useRef)(l);(0,a.useEffect)((()=>{l!==u.current&&(u.current=l,c(a_e(l)))}),[l]);const m=(0,a.useCallback)((e=>{c((t=>{const n=new Set(t);return n.has(e)?n.delete(e):n.add(e),((e,t)=>{try{localStorage.setItem(e,JSON.stringify([...t]))}catch(n){}})(l,n),n}))}),[l]);return[s,{toggle:m}]};var r_e,o_e,i_e,s_e,c_e,d_e,u_e,m_e,p_e;const g_e="border-b border-divider-primary bg-background-primary whitespace-normal select-none",h_e=[3,5,2],v_e=e=>{var t,n,l;let r=e.columns,i=e.data,s=e.empty,c=e.initialState,d=e.state,u=e.onSortingChange,m=e.expandedHoldingIds,p=e.holdingsWithActiveAdd,g=e.onCancelAddingTaxLot,h=e.onToggleHolding,v=e.defaultAlignment,f=e.isLoading,E=e.magicImportedTaxLotIds,y=e.onAddMagicImportedTaxLots,b=e.onRemoveMagicImportedTaxLot,x=e.pendingDraftsByHolding,w=e.onDeleteDraft,C=e.onAddDrafts,A=e.expandable,I=void 0===A||A,k=e.collapsedGroupsResetKey,S=e.onStickyChange;const N=l_e("investments-gainslosses-collapsed",String(null!==k&&void 0!==k?k:"")),T=(0,o.A)(N,2),_=T[0],D=T[1].toggle,R=(0,TNe.N4)((0,U.A)((0,U.A)((0,U.A)({data:i,columns:r,initialState:(0,U.A)({expanded:!0},c)},d?{state:d}:{}),u?{onSortingChange:u}:{}),{},{enableMultiSort:!1,groupedColumnMode:!1,autoResetExpanded:!1,defaultColumn:(0,Jo.rN)(),getCoreRowModel:(0,_Ne.HT)(),getGroupedRowModel:(0,_Ne.cU)(),getSortedRowModel:(0,_Ne.h5)(),getExpandedRowModel:(0,_Ne.D0)()})),M=i.length>0,L=(0,a.useContext)(ri.z).scrollRef,O=(0,a.useState)({}),P=(0,o.A)(O,2),z=P[0],F=P[1],G=(0,a.useCallback)(((e,t)=>{F((n=>n[e]===t||!t&&!(e in n)?n:t?(0,U.A)((0,U.A)({},n),{},{[e]:!0}):Object.fromEntries(Object.entries(n).filter((t=>(0,o.A)(t,1)[0]!==e)))))}),[]),Y=null!==(t=z["outer-top"])&&void 0!==t&&t,V=null!==(n=z["outer-bottom"])&&void 0!==n&&n,W=Y&&!V;if((0,a.useEffect)((()=>{null===S||void 0===S||S(W)}),[W,S]),f){var j,H;const e=new Set(Object.entries(null!==(j=null!==(H=null===d||void 0===d?void 0:d.columnVisibility)&&void 0!==H?H:null===c||void 0===c?void 0:c.columnVisibility)&&void 0!==j?j:{}).filter((e=>!(0,o.A)(e,2)[1])).map((e=>(0,o.A)(e,1)[0]))),t=r.filter((t=>{var n;return!e.has(null!==(n=t.id)&&void 0!==n?n:"")}));return a.createElement(b_e,{"data-external-id":"investments-expandable-tax-lots-table",columns:t,defaultAlignment:v})}if(!M)return a.createElement("div",{"data-external-id":"investments-expandable-tax-lots-table"},a.createElement("table",{style:{width:"100%",borderSpacing:0}},a.createElement(Jo.Dh,null,a.createElement(Jo.eG,null,r.map((e=>a.createElement(Jo.ft,{key:e.id,$defaultAlignment:v,className:g_e},"string"===typeof e.header?e.header:""))))),a.createElement("tbody",null,a.createElement(Jo.eG,null,a.createElement(n_e.j.EmptyCell,Object.assign({colSpan:r.length,title:"No data found."},s))))));const K=null!==(l=null===L||void 0===L?void 0:L.current)&&void 0!==l?l:null;return a.createElement(a.Fragment,null,a.createElement(E_e,{sentinelKey:"outer-top",scrollRoot:K,onStateChange:G}),a.createElement(A_e,null,a.createElement(Jo.Dh,null,R.getHeaderGroups().map((e=>a.createElement(Jo.eG,{key:e.id},e.headers.map((e=>a.createElement(Jo.ft,{key:e.id,$defaultAlignment:v,$hasHover:e.column.getCanSort(),className:g_e,style:{width:e.getSize()},onClick:e.column.getCanSort()?e.column.getToggleSortingHandler():void 0},e.isPlaceholder?null:(0,TNe.Kv)(e.column.columnDef.header,e.getContext()),"desc"===e.column.getIsSorted()?a.createElement(N_e,{name:"arrow-down",size:12}):null,"asc"===e.column.getIsSorted()?a.createElement(N_e,{name:"arrow-up",size:12}):null))))))),a.createElement("tbody",null,(()=>{let e=null;return R.getRowModel().rows.map((t=>{var n,l,r,o,s,c,d,u,f;if(t.getIsGrouped())e=String(null!==(f=t.groupingValue)&&void 0!==f?f:"");else if(null!==e&&_.has(e))return null;const A=m.has(null!==(n=null===(l=t.original)||void 0===l?void 0:l.id)&&void 0!==n?n:""),k=String(null!==(r=t.groupingValue)&&void 0!==r?r:""),S=t.getIsGrouped()&&_.has(k),N=t.getVisibleCells().map(((e,n)=>{var l;const r=e.getIsGrouped()||e.getIsAggregated(),o=0===n,i=(0,TNe.Kv)(e.getIsAggregated()&&null!==(l=e.column.columnDef.aggregatedCell)&&void 0!==l?l:e.column.columnDef.cell,e.getContext());let s=i;return o&&(t.getIsGrouped()?s=a.createElement("div",{className:"flex items-center gap-xs"},a.createElement(B.L,{icon:S?"chevron-right":"chevron-down",size:"xsmall","aria-label":S?"Expand group":"Collapse group",onClick:e=>{e.stopPropagation(),D(k)}}),a.createElement(S_e,null,i)):I&&(s=a.createElement(x_e,null,a.createElement(B.L,{icon:A?"chevron-down":"chevron-right",size:"xsmall","aria-label":A?"Collapse tax lots":"Expand tax lots",onClick:()=>h(t.original.id)}),i))),a.createElement(Jo.Si,{key:e.id,$defaultAlignment:v,$isHeader:r,className:e.getIsAggregated()?"first:pl-default":void 0,"data-is-header":r,"data-is-aggregated":e.getIsAggregated()||void 0},s)}));return a.createElement(a.Fragment,{key:t.id},t.getIsGrouped()?a.createElement(k_e,{onClick:()=>D(k),style:{cursor:"pointer"}},N):a.createElement(I_e,{"data-holding-id":null===(o=t.original)||void 0===o?void 0:o.id,"data-has-no-tax-lots":I&&!QCe(t.original)&&!A||void 0},N),!t.getIsGrouped()&&(null===(s=t.original)||void 0===s?void 0:s.id)&&I&&a.createElement(Jo.eG,null,a.createElement(w_e,{colSpan:t.getVisibleCells().length},A&&a.createElement(E_e,{sentinelKey:"".concat(t.original.id,"-top"),sentinelType:"inner-top",scrollRoot:K}),a.createElement(f_e,{open:A},a.createElement(C_e,null,a.createElement(t_e,{holding:t.original,currentPrice:null!==(c=null!==(d=null===(u=t.original.security)||void 0===u?void 0:u.currentPrice)&&void 0!==d?d:t.original.closingPrice)&&void 0!==c?c:0,shouldStartAdding:p.has(t.original.id),onCancelAdding:g,magicImportedTaxLotIds:E,onAddMagicImportedTaxLots:y,onRemoveMagicImportedTaxLot:b,draftTaxLots:null===x||void 0===x?void 0:x[t.original.id],onDeleteDraft:w,onAddDrafts:C,allAccountHoldings:i.filter((e=>{var n,a;return(null===(n=e.account)||void 0===n?void 0:n.id)===(null===(a=t.original.account)||void 0===a?void 0:a.id)}))}))),A&&a.createElement(E_e,{sentinelKey:"".concat(t.original.id,"-bottom"),sentinelType:"inner-bottom",scrollRoot:K}))))}))})())),a.createElement(E_e,{sentinelKey:"outer-bottom",scrollRoot:K,onStateChange:G}))},f_e=e=>{let t=e.open,n=e.children;const l=(0,qd.W)(),r=(0,o.A)(l,2),i=r[0],s=r[1].height,c=(0,DNe.z)(0);return(0,a.useEffect)((()=>{c.set(t&&null!==s&&void 0!==s?s:0)}),[t,s,c]),a.createElement(D.PY1.div,Object.assign({"data-external-id":"tax-lots-drawer",style:{height:c,overflow:"clip"}},t?{}:{inert:""}),a.createElement("div",{ref:i},n))},E_e=(0,a.memo)((e=>{let t=e.sentinelKey,n=e.sentinelType,l=e.scrollRoot,r=e.onStateChange;const i=(0,a.useRef)(null);return(0,a.useEffect)((()=>{const e=i.current;if(!e||!r)return;const n=new IntersectionObserver((e=>{var n,a;let l=(0,o.A)(e,1)[0];const i=null!==(n=null===(a=l.rootBounds)||void 0===a?void 0:a.top)&&void 0!==n?n:0,s=!l.isIntersecting&&l.boundingClientRect.top<i;r(t,s)}),{threshold:0,root:l});return n.observe(e),()=>{n.disconnect(),r(t,!1)}}),[t,l,r]),a.createElement("div",Object.assign({"data-external-id":"table-boundary-sentinel",ref:i},n?{"data-sentinel-type":n,"data-sentinel-key":t}:{}))})),y_e=e=>{let t=e.columns,n=e.defaultAlignment;return a.createElement(Jo.eG,{"data-external-id":"loading-row",className:"[&_td]:border-b [&_td]:border-divider-primary [&_td:first-child]:pl-default"},t.map(((e,t)=>0===t?a.createElement(Jo.Si,{key:e.id,$defaultAlignment:n},a.createElement("div",{className:"flex items-center gap-default"},a.createElement("div",{className:"size-6 shrink-0 animate-pulse rounded-full bg-background-secondary"}),a.createElement(T_e,{className:"w-40"}))):a.createElement(Jo.Si,{key:e.id,$defaultAlignment:n},"actions"!==e.id&&a.createElement("div",{className:"flex justify-end"},a.createElement(T_e,{className:"w-16"}))))))},b_e=e=>{let t=e.columns,n=e.defaultAlignment;return a.createElement(A_e,{"data-external-id":"loading-table"},a.createElement(Jo.Dh,null,a.createElement(Jo.eG,null,t.map((e=>a.createElement(Jo.ft,{key:e.id,$defaultAlignment:n,className:g_e,style:{width:e.size}},"string"===typeof e.header?e.header:""))))),a.createElement("tbody",null,h_e.map(((e,l)=>a.createElement(a.Fragment,{key:l},a.createElement(Jo.eG,null,a.createElement(Jo.Si,{colSpan:t.length,$defaultAlignment:"left",className:"bg-background-secondary"},a.createElement(T_e,{className:"w-32"}))),(0,db.A)(0,e).map((e=>a.createElement(y_e,{key:e,columns:t,defaultAlignment:n}))))))))},x_e=$d.s.div(r_e||(r_e=(0,wc.A)(["flex items-start gap-xs [&>button:first-child]:mt-2.5"]))),w_e=$d.s.td(o_e||(o_e=(0,wc.A)(["w-full p-0 leading-none"]))),C_e=$d.s.div(i_e||(i_e=(0,wc.A)(["relative z-2 leading-normal"]))),A_e=$d.s.table(s_e||(s_e=(0,wc.A)(["w-full min-w-300 table-fixed border-spacing-0"]))),I_e=(0,$d.s)(Jo.eG)(c_e||(c_e=(0,wc.A)(["\n  [&_td]:border-b\n  [&_td]:border-divider-primary\n  [&_td:first-child]:pl-default\n  [&:hover_[data-editable-cost-basis]_button]:border-border-primary\n  [&[data-has-no-tax-lots]_td]:pb-[calc(var(--spacing-default)+var(--spacing-xl)+var(--spacing-default))]\n  [&[data-has-no-tax-lots]_td:first-child]:pb-default\n"]))),k_e=(0,$d.s)(Jo.eG)(d_e||(d_e=(0,wc.A)(["\n  [&_td:first-child]:relative\n  [&_td:last-child]:py-0\n  [&_td:not([data-is-aggregated])]:border-b\n  [&_td:not([data-is-aggregated])]:border-divider-secondary\n"]))),S_e=$d.s.div(u_e||(u_e=(0,wc.A)(["absolute left-13 max-w-175 truncate"]))),N_e=(0,$d.s)(sl.ZQ)(m_e||(m_e=(0,wc.A)(["relative -bottom-0.5 ml-xs"]))),T_e=$d.s.div(p_e||(p_e=(0,wc.A)(["h-4 animate-pulse rounded-sm bg-background-secondary"]))),__e=e=>{let t=e.tooltipText,n=e.extraNode;return a.createElement(JY.d,{"data-external-id":"excluded-from-portfolio-indicator",content:a.createElement("div",{className:"max-w-40 px-sm py-xs text-left text-xs"},t),place:"right",effect:"solid"},a.createElement("div",{className:"flex items-center justify-start"},a.createElement("div",{className:"flex size-2.75 rounded-round bg-background-secondary"},a.createElement(sl.ZQ,{className:"text-content-secondary",name:"circle-slashed",size:12})),n))},D_e=e=>{let t=e.primaryText,n=e.primarySuffix,l=e.secondaryText,r=e.color,o=e.canClick,i=e.disabled,s=e.onClick,c=e.tooltipText,d=e.accountLogoUrl,m=e.accountIcon,p=e.accountInfoRow,g=e.showDot,h=void 0===g||g;const v=(0,u.useTheme)(),f=null!==r&&void 0!==r?r:v.color.grayLight;return a.createElement(JY.d,{"data-external-id":"investments-indicator",content:c,place:"top",effect:"solid"},a.createElement("div",{onClick:s,className:(0,q.cn)("flex items-center justify-start",o?"cursor-pointer":"cursor-default")},a.createElement("div",{className:"flex items-center gap-sm"},h&&a.createElement("div",{className:"flex min-w-3 items-center justify-center gap-default"},i?a.createElement(__e,{tooltipText:"Historical data not available for this holding"}):a.createElement("div",{className:"size-3 shrink-0 rounded-round",style:{backgroundColor:f}}),void 0!==d&&void 0!==m&&a.createElement(Gl.v,{logoUrl:d,icon:m,size:36})),a.createElement("div",{className:"flex flex-col gap-2xs"},a.createElement("div",{className:"flex min-w-0 items-center overflow-hidden"},a.createElement(xt.v,{weight:"medium"},t),n,p&&a.createElement("div",{className:"ml-sm flex max-w-100 min-w-0 items-center gap-xs"},a.createElement("span",{className:"shrink-0"},a.createElement(Gl.v,{logoUrl:p.logoUrl,icon:p.icon,size:16})),a.createElement(xt.v,{weight:"book",size:"small",color:"content.secondary",className:"min-w-0 flex-1 truncate"},p.name))),a.createElement(xt.v,{weight:"book",size:"small",color:"content.secondary"},l)))))},R_e="Unclassified",M_e=new Set,L_e=e=>{let t=e.holdings,n=e.groupByColumnId,l=e.isLoading,r=e.onStickyChange;const i=function(){let e=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}).onClickHolding;return(0,a.useMemo)((()=>[{id:"morningstarCategory",header:"Morningstar Category",accessorFn:e=>{var t,n;return null!==(t=null===(n=e.security)||void 0===n?void 0:n.morningstarCategory)&&void 0!==t?t:R_e}},{id:"globalCategory",header:"Global Category",accessorFn:e=>{var t,n;return null!==(t=null===(n=e.security)||void 0===n?void 0:n.globalCategory)&&void 0!==t?t:R_e}},{id:"broadAssetClass",header:"Broad Asset Class",accessorFn:e=>{var t,n;return null!==(t=null===(n=e.security)||void 0===n?void 0:n.broadAssetClass)&&void 0!==t?t:R_e}},{id:"legalStructure",header:"Legal Structure",accessorFn:e=>{var t,n;return null!==(t=null===(n=e.security)||void 0===n?void 0:n.legalStructure)&&void 0!==t?t:R_e}},{id:"prospectusObjective",header:"Prospectus Objective",accessorFn:e=>{var t,n;return null!==(t=null===(n=e.security)||void 0===n?void 0:n.prospectusObjective)&&void 0!==t?t:R_e}},{id:"aggregatedCategory",header:"Aggregated Category",accessorFn:e=>{var t,n;return null!==(t=null===(n=e.security)||void 0===n?void 0:n.aggregatedCategory)&&void 0!==t?t:R_e}},{id:"indexStrategy",header:"Index Strategy",accessorFn:e=>{var t,n;return null!==(t=null===(n=e.security)||void 0===n?void 0:n.indexStrategy)&&void 0!==t?t:R_e}},{id:"security",header:"Security",size:cNe,accessorFn:e=>{var t,n,a,l,r;return null!==(t=null!==(n=null!==(a=null===(l=e.security)||void 0===l?void 0:l.ticker)&&void 0!==a?a:e.ticker)&&void 0!==n?n:null===(r=e.security)||void 0===r?void 0:r.name)&&void 0!==t?t:e.name},cell:e=>{var t;let n=e.getValue,l=e.row;if(!n())return null;const r=l.original,o=r.ticker,i=r.name,s=null!==(t=l.original.security)&&void 0!==t?t:{}
1,c=s.ticker,d=s.name||i||"",u=c||o||d;return a.createElement(D_e,{primaryText:u,secondaryText:d!==u?d:void 0,showDot:!1})},aggregatedCell:e=>{let t=e.row,n=e.table;const l=(0,o.A)(n.getState().grouping,1)[0],r=t.getValue(l);return a.createElement("div",{className:"max-w-175 truncate"},a.createElement(xt.v,{weight:"medium"},r))}},{id:"quantity",header:"Quantity",size:dNe,accessorFn:e=>{var t;return null!==(t=e.quantity)&&void 0!==t?t:0},cell:e=>{var t;let n=e.getValue,l=e.row;const r=n();return l.getIsGrouped()?null:a.createElement("div",{className:"flex justify-end"},a.createElement(xt.v,null,(0,pke.VZ)(r,null===(t=l.original.security)||void 0===t?void 0:t.type)))}},{id:"totalCost",header:"Total cost basis",size:uNe,accessorFn:e=>eAe(e),cell:e=>{let t=e.getValue,n=e.row;const l=t();return n.getIsGrouped()?null:null===l||void 0===l?a.createElement("div",{className:"flex justify-end"},a.createElement(xt.v,null,"-")):a.createElement("div",{className:"flex justify-end"},a.createElement(xt.v,null,(0,rl.vv)(l)))}},{id:"currentValue",header:"Current value",size:mNe,accessorFn:e=>tAe(e),cell:e=>{let t=e.getValue,n=e.row;const l=t();return n.getIsGrouped()?null:null===l||void 0===l?a.createElement("div",{className:"flex justify-end"},a.createElement(xt.v,null,"-")):a.createElement("div",{className:"flex justify-end"},a.createElement(xt.v,null,(0,rl.vv)(l)))}},{id:"gainLossDollars",header:"Gain/loss $",size:pNe,accessorFn:e=>nAe(e),cell:e=>{let t=e.getValue,n=e.row;const l=t();return n.getIsGrouped()?null:null===l||void 0===l||Math.abs(l)<1e-8?a.createElement("div",{className:"flex justify-end"},a.createElement(xt.v,null,"-")):a.createElement("div",{className:"flex justify-end"},a.createElement(Y3.g,{value:l,formatter:rl.vv}))}},{id:"gainLossPercent",header:"Gain/loss %",size:gNe,accessorFn:e=>aAe(e),cell:e=>{let t=e.getValue,n=e.row;const l=t();return n.getIsGrouped()?null:null===l||void 0===l||Math.abs(l)<1e-8?a.createElement("div",{className:"flex justify-end"},a.createElement(xt.v,null,"-")):a.createElement("div",{className:"flex justify-end"},a.createElement(V3,{returnPercent:l}))}},{id:"actions",size:hNe,enableSorting:!1,accessorFn:e=>e.id,cell:t=>{let n=t.getValue,l=t.row;const r=n();return l.getIsGrouped()||!r?null:a.createElement("div",{className:"-mx-lg flex items-center justify-center"},a.createElement(mke.h,{onClick:e?()=>e(r):void 0}))}}]),[e])}({onClickHolding:e.onClickHolding}),s=(0,a.useMemo)((()=>[n]),[n]),c=(0,a.useMemo)((()=>({grouping:s,columnVisibility:sSe})),[s]);return a.createElement(v_e,{"data-external-id":"investments-funds-table",columns:i,data:t,empty:{title:"No holdings data available"},state:c,expandedHoldingIds:M_e,holdingsWithActiveAdd:M_e,onCancelAddingTaxLot:O_e,onToggleHolding:O_e,defaultAlignment:"right",isLoading:l,expandable:!1,onStickyChange:r,onAddMagicImportedTaxLots:O_e,onRemoveMagicImportedTaxLot:O_e,collapsedGroupsResetKey:n})},O_e=()=>{},P_e=()=>{const e=(0,a.useState)(!1),t=(0,o.A)(e,2),n=t[0],l=t[1],r=(0,a.useRef)(null),i=(0,a.useRef)(null),s=(0,a.useCallback)((e=>{l(e)}),[]);return(0,a.useEffect)((()=>{const e=r.current;if(!e)return;const t=()=>{i.current&&(i.current.style.transform="translateX(-".concat(e.scrollLeft,"px)"))};return e.addEventListener("scroll",t,{passive:!0}),()=>e.removeEventListener("scroll",t)}),[]),(0,a.useLayoutEffect)((()=>{n&&i.current&&r.current&&(i.current.style.transform="translateX(-".concat(r.current.scrollLeft,"px)"))}),[n]),{stickyIsVisible:n,onStickyChange:s,scrollContainerRef:r,stickyInnerRef:i}};var B_e,z_e;const F_e=e=>{var t,n;let l=e.fundsClassification,r=e.onFundsClassificationChange,o=e.holdings,i=e.isLoading,s=e.onClickHolding;const c=P_e(),d=c.stickyIsVisible,u=c.onStickyChange,m=c.scrollContainerRef,p=c.stickyInnerRef,g=!i&&o.length>0?(()=>{const e=o.map(tAe).filter((e=>null!==e&&void 0!==e)),t=(0,De.Eb)(e),n=o.map((e=>({currentValue:tAe(e),positionCost:eAe(e)}))).filter((e=>null!==e.currentValue&&void 0!==e.currentValue&&null!==e.positionCost&&void 0!==e.positionCost)),a=(0,De.Eb)(n.map((e=>e.currentValue))),l=(0,De.Eb)(n.map((e=>e.positionCost))),r=a-l;return{totalCurrentValue:t,gainLossDollars:r,gainLossPercent:l>0?r/l*100:0}})():null;return a.createElement(ANe,{"data-external-id":"investments-funds-table-section",title:"Holdings",variant:"funds",controls:a.createElement(fe.u$N.Root,null,a.createElement(fe.u$N.Trigger,{render:a.createElement(fe.XZZ,{variant:"default",endIcon:a.createElement(fe.D39,{size:"md"})},null!==(t=null===(n=uSe.find((e=>e.value===l)))||void 0===n?void 0:n.label)&&void 0!==t?t:"Classify by")}),a.createElement(fe.u$N.Content,{align:"end"},a.createElement("div",{className:"px-3 pt-2xs pb-3xs"},a.createElement(fe.c8D,{size:"sm",weight:"medium",color:"secondary"},dSe)),a.createElement(fe.u$N.RadioGroup,{value:l,onValueChange:e=>{r(e),(0,Ge.u4)(Ye.Vi.FundsClassificationChanged,{classification:e,source:"table"})}},uSe.map((e=>a.createElement(fe.u$N.RadioItem,{key:e.value,value:e.value,closeOnClick:!0},e.label)))))),minWidth:sNe,stickyIsVisible:d,stickyInnerRef:p,scrollContainerRef:m,stickyHeader:a.createElement(xNe,null,a.createElement(G_e,null,a.createElement("thead",null,a.createElement("tr",null,a.createElement(wNe,{style:{width:cNe}},qSe),a.createElement(wNe,{style:{width:dNe}},$Se),a.createElement(wNe,{style:{width:uNe}},ZSe),a.createElement(wNe,{style:{width:mNe}},JSe),a.createElement(wNe,{style:{width:pNe}},XSe),a.createElement(wNe,{style:{width:gNe}},QSe),a.createElement(wNe,{style:{width:hNe}}))))),totals:g?a.createElement("tbody",null,a.createElement("tr",null,a.createElement(Y_e,{style:{width:cNe}},a.createElement(xt.v,{weight:"medium"},"Total")),a.createElement(Y_e,{style:{width:dNe}}),a.createElement(Y_e,{style:{width:uNe}}),a.createElement(Y_e,{style:{width:mNe}},a.createElement("div",{className:"flex justify-end"},a.createElement(xt.v,{weight:"medium"},(0,rl.vv)(g.totalCurrentValue)))),a.createElement(Y_e,{style:{width:pNe}},a.createElement(kNe,{value:g.gainLossDollars},a.createElement(Y3.g,{value:g.gainLossDollars,formatter:rl.vv}))),a.createElement(Y_e,{style:{width:gNe}},a.createElement(kNe,{value:g.gainLossPercent},a.createElement(V3,{returnPercent:g.gainLossPercent}))),a.createElement(Y_e,{style:{width:hNe}}))):void 0},a.createElement(L_e,{holdings:o,groupByColumnId:mSe[l],isLoading:i,onStickyChange:u,onClickHolding:s}))},G_e=$d.s.table(B_e||(B_e=(0,wc.A)(["w-full min-w-300 table-fixed border-spacing-0"]))),Y_e=$d.s.td(z_e||(z_e=(0,wc.A)(["bg-background-primary px-lg py-default first:pl-lg"])));var U_e=n(461);const V_e=Ee.lrl,W_e=Ee.Rnc,j_e=Ee.dHt,H_e=Ee.vR4;var K_e=n(35551);const q_e=e=>{var t,n;return!0===(null===(t=e.holdings)||void 0===t||null===(n=t[0])||void 0===n?void 0:n.isFund)};var $_e=n(38892);const Z_e=e=>{let t=e.text;return a.createElement(JY.e,{"data-external-id":"summary-card-tooltip",className:"flex flex-col items-center gap-2xs"},a.createElement("span",null,t),a.createElement(cl.M,{href:XCe.X,target:"_blank",rel:"noopener noreferrer"},"Learn more"))},J_e=a.createElement(Z_e,{text:"Derived from total cost basis or tax lots in the holdings table below."}),X_e=a.createElement(Z_e,{text:"Derived from total tax lots in the holdings table below."}),Q_e=e=>{const t=e.totalCurrentValue,n=e.isLoading;return a.createElement("div",{"data-external-id":"cost-basis-summary-cards",className:"flex w-full items-center rounded-default border border-divider-secondary"},a.createElement(eDe,{value:(0,rl.vv)(t),label:"Portfolio value",isLoading:n}),(0,r.YW)(e).with({viewMode:kAe.TaxLots},(e=>{const t=e.isMissingTaxLots?" (partial)":"";return a.createElement(a.Fragment,null,a.createElement(eDe,{value:nDe(e.totalUnrealizedGains),valueClassName:tDe(e.totalUnrealizedGains),label:"Total gain / loss".concat(t),tooltipText:X_e,isLoading:n}),a.createElement(eDe,{value:nDe(e.periodGainLoss),valueClassName:tDe(e.periodGainLoss),label:"Gain / loss value - ".concat(e.periodLabel).concat(t),tooltipText:X_e,isLoading:n}),a.createElement(eDe,{value:aDe(e.periodPercentRatio),valueClassName:tDe(e.periodPercentRatio),label:"Gain / loss percent - ".concat(e.periodLabel).concat(t),tooltipText:X_e,isLoading:n}))})).otherwise((e=>{const t=e.isMissingCostBasis?" (partial)":"";return a.createElement(a.Fragment,null,a.createElement(eDe,{value:(0,rl.vv)(e.totalCostBasis),label:"Portfolio cost".concat(t),tooltipText:J_e,isLoading:n}),a.createElement(eDe,{value:nDe(e.gainLossDollars),valueClassName:tDe(e.gainLossDollars),label:"Gain / loss value".concat(t),tooltipText:J_e,isLoading:n}),a.createElement(eDe,{value:aDe(e.gainLossPercent/100),valueClassName:tDe(e.gainLossPercent),label:"Gain / loss percent".concat(t),tooltipText:J_e,isLoading:n}))})))},eDe=e=>{let t=e.value,n=e.label,l=e.valueClassName,r=e.tooltipText,o=e.isLoading;return a.createElement("div",{"data-external-id":"cell",className:"\n      flex flex-1 flex-col items-center justify-center gap-2xs border-r border-divider-secondary\n      p-xl\n      last:border-r-0\n    "},o?a.createElement(a.Fragment,null,a.createElement(M.Al,{$width:"138px",$height:"24px"}),a.createElement(M.Al,{$width:"98px",$height:"16px"})):a.createElement(a.Fragment,null,a.createElement("span",{className:(0,q.cn)("text-20 font-medium",l)},t),a.createElement("div",{className:"flex items-center gap-2xs"},a.createElement("span",{className:"text-sm font-medium text-content-secondary"},n),r&&a.createElement(JY.d,{maxWidth:250,content:r,clickable:!0},a.createElement(sl.ZQ,{name:"info",size:12,className:"cursor-default text-content-secondary"})))))},tDe=e=>e>=0?"text-content-success":"text-content-danger",nDe=e=>e>0?"+".concat((0,rl.vv)(e)):(0,rl.vv)(e),aDe=e=>(0,De.PE)(e,2,{showPlus:!0,showAllDecimals:!0});var lDe=n(33092);const rDe={"1W":"1 Week","1M":"1 Month","3M":"3 Months","6M":"6 Months",YTD:"Year to Date","1Y":"1 Year","5Y":"5 Years",ALL:"All Time"},oDe={"1W":"Past Week","1M":"Past Month","3M":"Past 3 Months","6M":"Past 6 Months",YTD:"Year to Date","1Y":"Past 1 Year","5Y":"Past 5 Years"},iDe=e=>{var t;return null!==(t=rDe[e])&&void 0!==t?t:e},sDe=e=>{var t;return null!==(t=oDe[e])&&void 0!==t?t:e},cDe=zCe.map((e=>({value:e.title,label:iDe(e.title)}
1))),dDe=[...cDe,{value:"ALL",label:iDe("ALL")}],uDe=rAe,mDe=e=>{var t,n;let l=e.allHoldingIds,r=e.selectedHoldingInfos,o=e.individualHoldings,i=e.isLoadingHoldings,s=e.useMockData,c=e.groupBy,u=e.onGroupByChange,m=e.shortcutTitle,p=e.onShortcutChange,g=e.viewMode,h=e.onViewModeChange,v=e.onOpenImportModal,f=e.totalCurrentValue,E=e.totalCostBasis,y=e.gainLossDollars,b=e.gainLossPercent,x=e.isMissingCostBasis,w=e.isMissingTaxLots,C=e.isLoadingTotals,A=e.onScrollToMissingCostBasis,I=e.onScrollToMissingTaxLots,k=e.tabs;const S=jSe({filename:()=>"gains-losses-".concat((0,Ba.Fv)(new Date),".png"),analyticsName:"Gains & Losses"}),T=S.ref,_=S.isExporting,D=S.onExport,R=(0,a.useCallback)((e=>{p(e),(0,Ge.u4)(Ye.Vi.GainsAndLossesDateRangeChanged,{date_range:e,source:"chart"})}),[p]),M=(0,a.useCallback)((e=>{u(e),(0,Ge.u4)(Ye.Vi.GainsAndLossesGroupByChanged,{group_by:e,source:"chart"})}),[u]),L=(0,a.useCallback)((e=>{h(e),(0,Ge.u4)(Ye.Vi.GainsAndLossesViewModeChanged,{view_mode:e})}),[h]),O=(0,a.useMemo)((()=>{let e;if("ALL"===m){const t=o.flatMap((e=>{var t;return(null!==(t=e.taxLots)&&void 0!==t?t:[]).map((e=>e.acquisitionDate))}));t.length>0&&(e={startDate:t.sort()[0],endDate:N.c9.local().toISODate()})}if(!e){const t=zCe.find((e=>e.title===m));e=FCe(null!==t&&void 0!==t?t:zCe[2])}return e}),[m,o]),P=((e,t,n,l)=>{const r=(0,d.d4)(gG.pk),o=(0,et.I)(H_e,{variables:{input:{holdingIds:e,startDate:t.startDate,endDate:t.endD
1ate}},skip:r||0===e.length||l}),i=o.data,s=o.isNetworkRequestInFlight,c=o.isLoadingInitialData,u=JSON.stringify(n);return{chartData:(0,a.useMemo)((()=>{var e;return(0,lDe.U7)(null!==(e=null===i||void 0===i?void 0:i.taxLotPerformance)&&void 0!==e?e:[],n)}),[i,u]),isTaxLotPerformanceLoading:s,isLoadingTaxLotPerformanceInitialData:c}})(l,O,r.map((e=>e.dataKey)),s),B=P.chartData,z=P.isTaxLotPerformanceLoading,F=(0,a.useMemo)((()=>{var e,t,n,a,l;const r=(0,d5.A)(B),o=(0,Sc.A)(B),i="ALL"===m,s=Number(null!==(e=null===o||void 0===o?void 0:o.portfolioReturn)&&void 0!==e?e:0),c=i?s:Number(null!==(t=null===o||void 0===o?void 0:o.portfolioReturn)&&void 0!==t?t:0)-Number(null!==(n=null===r||void 0===r?void 0:r.portfolioReturn)&&void 0!==n?n:0),d=Number(null!==(a=null===r||void 0===r?void 0:r.portfolioValue)&&void 0!==a?a:0);return{totalUnrealizedGains:s,periodGainLoss:c,periodPercentRatio:0!==d?c/Math.abs(d):Number(null!==(l=null===o||void 0===o?void 0:o.portfolioReturnPercent)&&void 0!==l?l:0)/100,periodLabel:iDe(m)}}),[B,m]),G=g===kAe.CostBasis&&x||g===kAe.TaxLots&&w;return a.createElement(nke,{"data-external-id":"gains-and-losses-graph-pane",ref:T,title:"Unrealized gains & losses",titleAdornment:a.createElement(pDe,null),tabs:k,controls:a.createElement(a.Fragment,null,g===kAe.TaxLots?a.createElement($_e.O,{title:iDe(m)},dDe.map((e=>a.createElement(Ji.xm,{key:e.value,selected:m===e.value,onClick:()=>R(e.value)},e.label)))):a.createElement($_e.O,{title:null!==(t=null===(n=uDe.find((e=>e.value===c)))||void 0===n?void 0:n.label)&&void 0!==t?t:"Group by"},uDe.map((e=>a.createElement(Ji.xm,{key:e.value,selected:c===e.value,onClick:()=>M(e.value)},e.label)))),a.createElement(fe.AVK,{orientation:"vertical",color:"secondary",className:"mx-2xs h-default"}),a.createElement(Gk,null,a.createElement(wt.Xb,{onClick:()=>L(kAe.CostBasis),active:g===kAe.CostBasis,"aria-label":"Bar chart"},a.createElement(fe.rWr,{size:"md"})),a.createElement(wt.Xb,{onClick:()=>L(kAe.TaxLots),active:g===kAe.TaxLots,"aria-label":"Line chart"},a.createElement(fe.kHi,{size:"md"}))),a.createElement(fe.AVK,{orientation:"vertical",color:"secondary",className:"mx-2xs h-default"}),a.createElement("div",{className:"flex"},a.createElement(wt.Xb,{onClick:D,disabled:_,"aria-label":"Download chart"},a.createElement(fe.UTA,{size:"2xs"}))))},G&&a.createElement(lSe,{className:"mx-lg mt-default"},a.createElement(fe.ucZ,{size:"md"}),a.createElement("span",{className:"flex-1"},"Get a complete picture of your gains & losses by filling in missing"," ",g===kAe.CostBasis?"cost basis or tax lots":"tax lots"," in the holdings table below."," ",a.createElement("a",{href:XCe.X,target:"_blank",rel:"noopener noreferrer",className:"font-medium text-content-info underline"},"Learn more")),a.createElement(rSe,{type:"button",onClick:g===kAe.CostBasis?A:I},g===kAe.CostBasis?"Add cost basis":"Add tax lots")),a.createElement("div",{className:"px-lg pt-default"},g===kAe.TaxLots?a.createElement(Q_e,{viewMode:kAe.TaxLots,totalCurrentValue:f,totalUnrealizedGains:F.totalUnrealizedGains,periodGainLoss:F.periodGainLoss,periodPercentRatio:F.periodPercentRatio,periodLabel:F.periodLabel,isMissingTaxLots:w,isLoading:C}):a.createElement(Q_e,{totalCurrentValue:f,totalCostBasis:E,gainLossDollars:y,gainLossPercent:b,isMissingCostBasis:x,isLoading:C})),a.createElement(SAe,{data:B,isLoading:z,dateRange:O,selectedHoldingInfos:r,exportFilePrefix:"gnl-performance",holdings:o,isLoadingHoldings:i,viewMode:g,onViewModeChange:L,groupBy:c,onGroupByChange:M,onOpenImportModal:v?()=>{v(),(0,Ge.u4)(Ye.Vi.TaxLotImportModalOpened,{source:"gnl_graph"})}:void 0,hideCard:!0}))},pDe=()=>a.createElement(JY.d,{"data-external-id":"title-adornment",content:"Unrealized profit or loss based on your cost basis.",maxWidth:190,place:"right"},a.createElement(ake,{type:"button","aria-label":"More information"},a.createElement(fe.ucZ,{size:"sm"})));var gDe;const hDe=e=>{let t=e.holding,n=e.value,l=e.onSave;const r=QCe(t),i=(0,a.useState)(!1),s=(0,o.A)(i,2),c=s[0],d=s[1],u=(0,a.useState)(void 0),m=(0,o.A)(u,2),p=m[0],g=m[1],h=(0,a.useRef)(void 0),v=(0,a.useRef)(void 0),f=(0,a.useRef)(!1),E=(0,a.useRef)(!1),y=(0,a.useCallback)((e=>{h.current=e,g(e)}),[]),b=(0,a.useCallback)((()=>
1{if(r)return;const e=null!==n&&void 0!==n?n:void 0;h.current=e,v.current=e,g(e),d(!0)}),[r,n]),x=(0,a.useCallback)((async()=>{var e,n;if(f.current||E.current)return;const a=null!==(e=h.current)&&void 0!==e?e:null;if(a!==(null!==(n=v.current)&&void 0!==n?n:null)){f.current=!0,d(!1);try{await l(t.id,a)}finally{f.current=!1}}else d(!1)}),[t.id,l]),w=(0,a.useCallback)((()=>{E.current?E.current=!1:x()}),[x]),C=(0,a.useCallback)((e=>{"Enter"===e.key?x():"Escape"===e.key&&(E.current=!0,d(!1))}),[x]);if(c)return a.createElement("div",{"data-external-id":"cost-basis-editable-cell",className:"flex justify-end"},a.createElement(fe.K$5.Root,{value:null!==p&&void 0!==p?p:null,min:0,step:"any",onValueChange:e=>y(null!==e&&void 0!==e?e:void 0)},a.createElement(fe.i9A,{variant:"cell",align:"end",className:"-mr-3.25 w-30"},a.createElement(fe.K$5.Input,{name:"cost-basis",placeholder:"$",onBlur:w,onKeyDown:C,autoFocus:!0,onFocus:ix.X}))));if(r)return a.createElement("div",{"data-external-id":"cost-basis-editable-cell",className:"flex justify-end"},a.createElement(P.D_,{content:"Edit tax lots to adjust cost basis",place:"top"},a.createElement(xt.v,null,null!==n&&void 0!==n?(0,rl.vv)(n):"-")));return null===n||void 0===n||0===n?a.createElement("div",{"data-external-id":"cost-basis-editable-cell","data-editable-cost-basis":!0,className:"flex justify-end"},a.createElement(bn.v,{onClick:b,className:"text-right"},"Add total cost basis")):a.createElement("div",{"data-external-id":"cost-basis-editable-cell","data-editable-cost-basis":!0,className:"flex justify-end"},a.createElement(vDe,{onClick:b},(0,rl.vv)(n)))},vDe=$d.s.button(gDe||(gDe=(0,wc.A)(["\n  -mr-3.25 w-30 cursor-pointer rounded-sm border border-transparent bg-transparent px-sm\n  py-1.75 text-right font-[inherit] [font-size:inherit] leading-normal text-content-primary\n  transition\n"]))),fDe=e=>t=>n=>(a,l,r)=>{if(a.getIsGrouped()){var o,i;return(null!==(o=null===(i=t.find((e=>e.id===r)))||void 0===i?void 0:i.desc)&&void 0!==o&&o?-1:1)*e(a,l)}return n(a,l,r)};var EDe,yDe,bDe,xDe,wDe,CDe,ADe,IDe;const kDe=e=>{var t;return null!==ONe(e,null===(t=e.security)||void 0===t?void 0:t.type)},SDe=(0,$d.s)(Qi.j7)(EDe||(EDe=(0,wc.A)(["min-w-45 px-0 py-2xs"]))),NDe=(0,$d.s)(bn.v)(yDe||(yDe=(0,wc.A)(["mt-lg ml-0 p-0 text-sm"]))),TDe=$d.s.span(bDe||(bDe=(0,wc.A)(["\n  ml-2xs shrink-0 text-base leading-none whitespace-nowrap text-content-secondary\n"]))),_De=(0,$d.s)(xt.v)(xDe||(xDe=(0,wc.A)(["max-w-175 truncate"]))),DDe=(0,$d.s)(Y3.g)(wDe||(wDe=(0,wc.A)(["-mr-xs"]))),RDe=(0,$d.s)(V3)(CDe||(CDe=(0,wc.A)(["-mr-xs"]))),MDe=$d.s.div(ADe||(ADe=(0,wc.A)(["-mx-lg flex items-center justify-center"]))),LDe=(0,$d.s)(B.L)(IDe||(IDe=(0,wc.A)(["\n  rounded-full transition-colors hover:bg-background-primary\n"]))),ODe=e=>{let t=e.id,n=e.desc;return{id:t,desc:null!==n&&void 0!==n&&n}},PDe=e=>{var t;let n=e.holdings,l=e.groupBy,r=e.isLoading,c=e.sortBy,d=e.setSortBy,u=e.selectedHoldingInfos,m=e.onClickHolding,p=e.onClickHoldingDetails,g=e.expandable,h=void 0===g||g,v=e.showSelector,f=void 0===v||v,E=e.magicImportedTaxLotIds,y=e.onAddMagicImportedTaxLots,b=e.onRemoveMagicImportedTaxLot,x=e.pendingDraftsByHolding,w=e.onDeleteDraft,A=e.onAddDrafts,I=e.holdingsToAutoExpand,k=e.onStickyChange,S=e.onOpenImportModal;const N=(0,C.RU)(),T=(0,V.m)(),_=(0,a.useState)(new Set),D=(0,o.A)(_,2),R=D[0],M=D[1],L=(0,a.useRef)(R);L.current=R;const O=(0,a.useState)(new Set),B=(0,o.A)(O,2),z=B[0],F=B[1],G=(0,a.useState)([]),Y=(0,o.A)(G,2),U=Y[0],W=Y[1],j=(0,a.useState)("account"),H=(0,o.A)(j,2),K=H[0],q=H[1],$=(0,Pd.h)(),Z=(0,o.A)($,2),J=Z[0],X=Z[1],Q=X.open,ee=X.close,te=(0,i.n)(Ee.qtc),ne=(0,o.A)(te,1)[0],ae=(0,a.useCallback)((async(e,t)=>{let n;(0,Ge.u4)(Ye.Vi.HoldingCostBasisManuallyEdited),T.cache.modify({id:T.cache.identify({__typename:"Holding",id:e}),fields:{userCostBasis:e=>(n=e,t)}});try{var a;const r=(await ne({variables:{input:{id:e,userCostBasis:t}}})).data;var l;if(null!==r&&void 0!==r&&null!==(a=r.updateHolding)&&void 0!==a&&a.errors)T.cache.modify({id:T.cache.identify({__typename:"Holding",id:e}),fields:{userCostBasis:()=>{var e;return null!==(e=n)&&void 0!==e?e:null}}}),N({description:null!==(l=r.updateHolding.errors.message)&&void 0!==l?l:"Failed to update cost basis"})}catch(r){T.cache.modify({id:T.cache.identify({__typename:"Holding",id:e}),fields:{userCostBasis:()=>{var e;return null!==(e=n)&&void 0!==e?e:null}}}),N({description:"Failed to update cost basis"}),s.Cp(new Error("Failed to update holding cost basis",{cause:r}))}}),[T,ne,N]),le=(0,i.n)(qTe,{update(e,t,a){var l;let r=t.data,o=a.variables;if(!(null===r||void 0===r||null===(l=r.deleteTaxLotsBulk)||void 0===l?void 0:l.deletedCount)||!o)return;const i=new Set(o.input.ids);
1n.forEach((t=>{e.modify({id:e.identify({__typename:"Holding",id:t.id}),fields:{taxLots(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=(arguments.length>1?arguments[1]:void 0).readField;return e.filter((e=>{var n;return!i.has(null!==(n=t("id",e))&&void 0!==n?n:"")}))}}})})),o.input.ids.forEach((t=>{e.evict({id:e.identify({__typename:"TaxLot",id:t})})}))},refetchQueries:["Web_GetTaxLotPerformance"],awaitRefetchQueries:!1}),re=(0,o.A)(le,2),oe=re[0],ie=re[1].loading,se=(0,a.useCallback)((e=>{M((t=>{const n=new Set(t);return n.add(e),n})),F((t=>{const n=new Set(t);return n.add(e),n})),(0,Ge.u4)(Ye.Vi.TaxLotRowExpanded)}),[]),ce=(0,a.useCallback)((e=>{const t=!L.current.has(e);M((t=>{const n=new Set(t);return t.has(e)?n.delete(e):n.add(e),n})),t&&(0,Ge.u4)(Ye.Vi.TaxLotRowExpanded),F((t=>{if(!t.has(e))return t;const n=new Set(t);return n.delete(e),n}))}),[]),de=(0,a.useCallback)((e=>{F((t=>{const n=new Set(t);return n.delete(e),n}))}),[]);(0,a.useEffect)((()=>{I&&I.length>0&&M((e=>{const t=new Set(e);return I.forEach((e=>t.add(e))),t}))}),[I]);const ue=(0,a.useCallback)(((e,t)=>{W(e),q(t),Q()}),[Q]),me=(0,a.useCallback)((async()=>{const e=new Set(U),t=n.filter((t=>e.has(t.id))).flatMap((e=>{var t;return(null!==(t=e.taxLots)&&void 0!==t?t:[]).map((e=>e.id))}));try{if(t.length>0){var a;const e=(await oe({variables:{input:{ids:t}}})).data,n=null!==(a=null===e||void 0===e?void 0:e.deleteTaxLotsBulk)&&void 0!==a?a:{},r=n.errors,o=n.deletedCount;var l;if(r||void 0===o)return void N({description:null!==(l=null===r||void 0===r?void 0:r.message)&&void 0!==l?l:"Failed to delete all tax lots"})}U.forEach((e=>{var t;null===x||void 0===x||null===(t=x[e])||void 0===t||t.forEach((t=>{let n=t.draftId;return null===w||void 0===w?void 0:w(e,n)}))})),ee()}catch(r){N({description:"Failed to delete all tax lots"}),s.Cp(new Error("Failed to delete all account tax lots",{cause:r})),T.refetchQueries({include:["Web_GetTaxLotPerformance"]})}}),[U,n,oe,x,w,ee,T,N]),pe=fTe({sortBy:c,toColumnSort:ODe,onChange:d}),ge=pe.sorting,he=pe.onSortingChange,ve=(e=>{let t=e.groupBy,n=e.selectedHoldingInfos,l=e.onClickHolding,r=e.onClickHoldingDetails,i=e.onDeleteAllGroupTaxLots,s=e.onUpdateCostBasis,c=e.showSelector,d=void 0===c||c,u=e.expandable,m=void 0===u||u,p=e.pendingDraftsByHolding,g=e.onOpenImportModal,h=e.onAddTaxLotToHolding,v=e.expandedHoldingIds,f=e.sorting;return(0,a.useMemo)((()=>{const e=fDe(((e,n)=>{var a,l,r,o,i,s,c,d;if(t===lAe.O.Account)return(null!==(a=null===(l=e.subRows[0])||void 0===l||null===(r=l.original)||void 0===r||null===(o=r.account)||void 0===o?void 0:o.order)&&void 0!==a?a:Number.MAX_SAFE_INTEGER)-(null!==(i=null===(s=n.subRows[0])||void 0===s||null===(c=s.original)||void 0===c||null===(d=c.account)||void 0===d?void 0:d.order)&&void 0!==i?i:Number.MAX_SAFE_INTEGER);if(t===lAe.O.Type){const t=e.groupingValue,a=n.groupingValue;return cAe.xR.indexOf(t)-cAe.xR.indexOf(a)}const u=e.groupingValue,m=n.groupingValue;return u.localeCompare(m)}))(f);return[{id:"type",accessorFn:e=>{var t,n;return null!==(t=e.typeDisplay)&&void 0!==t?t:null===(n=e.security)||void 0===n?void 0:n.typeDisplay}},{id:"account",accessorFn:e=>{var t;return null===(t=e.account)||void 0===t?void 0:t.displayName}},{id:"institution",accessorFn:e=>{var t,n;return(null===(t=e.account)||void 0===t||null===(n=t.institution)||void 0===n?void 0:n.name)||"Manual Holdings"}},{id:"assetClass",accessorFn:e=>(0,cAe.AC)(e)},{id:"securityGroup",accessorFn:e=>{var t,n,a,l;const r=null!==(t=null===(n=e.security)||void 0===n?void 0:n.name)&&void 0!==t?t:e.name;return(null!==(a=null===(l=e.security)||void 0===l?void 0:l.ticker)&&void 0!==a?a:e.ticker)||r||""}},{id:"holding",accessorFn:e=>e.id},{id:"security",header:qSe,size:cNe,accessorFn:e=>{var t,n,a,l;const r=null!==(t=null===(n=e.security)||void 0===n?void 0:n.name)&&void 0!==t?t:e.name;return(null!==(a=null===(l=e.security)||void 0===l?void 0:l.ticker)&&void 0!==a?a:e.ticker)||r||""},sortingFn:e(((e,t)=>{const n=e.getValue("security"),a=t.getValue("security");return n.localeCompare(a)})),sortDescFirst:!0,cell:e=>{var t,r,o,i,s;let c=e.getValue,u=e.row;if(!c())return null;const m=u.original,p=m.ticker,f=m.name,E=m.account,y=null!==(t=u.original.security)&&void 0!==t?t:{},b=y.ticker,x=y.name||f||"",w=b||p||x,C=null===(r=n.find((e=>e.id===u.original.id)))||void 0===r?void 0:r.color,A=null!==(o=null===(i=u.original.taxLots)||void 0===i?void 0:i.length)&&void 0!==o?o:0,I=a.createElement(P.D_,{content:"".concat(A," tax lot").concat(1===A?"":"s"),place:"top"},a.createElement(TDe,null,"(",A,")"));return a.createElement("div",{className:"min-w-75"},a.createElement(D_e,{primaryText:w,primarySuffix:I,secondaryText:x!==w?x:void 0,color:C,canClick:!!u.original.security,onClick:()=>{u.original.security&&l(u.original.id,u.original.security)},showDot:d,accountInfoRow:E?{logoUrl:E.logoUrl,icon:E.icon,name:null!==(s=E.displayName)&&void 0!==s?s:""}:null}),!QCe(u.original)&&h&&!(null!==v&&void 0!==v&&v.has(u.original.id))&&a.createElement(Qi.Az,{placement:"bottom-start",overlay:e=>{let t=e.close;return a.createElement(SDe,null,a.createElement(pm.sR,{onClick:()=>{h(u.original.id),t()}},"Add manually"),g&&a.createElement(pm.sR,{onClick:()=>{var e;g(null===(e=u.original.account)||void 0===e?void 0:e.id),t()}},"Upload document"))}},(e=>{let t=e.toggleOpen;return a.createElement(NDe,{onClick:e=>{e.stopPropagation(),t()}},"Add tax lot")})))},aggregatedCell:e=>{let t=e.row,n=e.table;const l=(0,o.A)(n.getState().grouping,1)[0],r=t.getValue(l);return a.createElement("div",{className:"flex items-center gap-xs"},a.createElement(_De,{weight:"medium"},r))}},{header:$Se,size:dNe,accessorFn:e=>{var t;return null!==(t=e.quantity)&&void 0!==t?t:0},sortingFn:e(((e,t)=>{var n,a;return(null!==(n=e.original.quantity)&&void 0!==n?n:0)-(null!==(a=t.original.quantity)&&void 0!==a?a:0)}
1)),sortDescFirst:!0,cell:e=>{var t;let n=e.getValue,l=e.row;const r=n();return l.getIsGrouped()?null:kDe(l.original)?a.createElement("div",{className:"flex justify-end"},a.createElement(P.D_,{content:LNe,place:"top",maxWidth:200},a.createElement("div",{className:"flex items-center gap-2xs"},a.createElement(sl.ZQ,{name:"alert-triangle",size:14,className:"text-content-warning"}),a.createElement(xt.v,{color:"content.warning"},(0,pke.VZ)(r,null===(o=l.original.security)||void 0===o?void 0:o.type))))):a.createElement("div",{className:"flex justify-end"},a.createElement(xt.v,null,(0,pke.VZ)(r,null===(t=l.original.security)||void 0===t?void 0:t.type)));var o}},{header:ZSe,size:uNe,accessorFn:e=>eAe(e),sortingFn:e(((e,t)=>{var n,a;return(null!==(n=eAe(e.original))&&void 0!==n?n:0)-(null!==(a=eAe(t.original))&&void 0!==a?a:0)})),sortDescFirst:!0,cell:e=>{let t=e.getValue,n=e.row;const l=t();return n.getIsGrouped()?null:kDe(n.original)?a.createElement("div",{className:"flex justify-end"},a.createElement(P.D_,{content:LNe,place:"top",maxWidth:200},a.createElement("div",{className:"flex items-center gap-2xs"},a.createElement(sl.ZQ,{name:"alert-triangle",size:14,className:"text-content-warning"}),a.createElement(xt.v,{color:"content.warning"},(0,rl.vv)(null!==l&&void 0!==l?l:0))))):s?a.createElement(hDe,{holding:n.original,value:l,onSave:s}):null===l||void 0===l?a.createElement("div",{className:"flex justify-end"},a.createElement(xt.v,null,"-")):a.createElement("div",{className:"flex justify-end"},a.createElement(xt.v,null,(0,rl.vv)(l)))}},{header:JSe,size:mNe,accessorFn:e=>tAe(e),sortingFn:e(((e,t)=>{var n,a;return(null!==(n=tAe(e.original))&&void 0!==n?n:0)-(null!==(a=tAe(t.original))&&void 0!==a?a:0)})),sortDescFirst:!0,cell:e=>{let t=e.getValue,n=e.row;const l=t();return n.getIsGrouped()?null:null===l||void 0===l?a.createElement("div",{className:"flex justify-end"},a.createElement(xt.v,null,"-")):a.createElement("div",{className:"flex justify-end"},a.createElement(xt.v,null,(0,rl.vv)(l)))}},{header:XSe,size:pNe,accessorFn:e=>nAe(e),sortingFn:e(((e,t)=>{var n,a;return(null!==(n=nAe(e.original))&&void 0!==n?n:0)-(null!==(a=nAe(t.original))&&void 0!==a?a:0)})),sortDescFirst:!0,cell:e=>{let t=e.getValue,n=e.row;const l=t();return n.getIsGrouped()?null:null===l||void 0===l||Math.abs(l)<1e-8?a.createElement("div",{className:"flex justify-end"},a.createElement(xt.v,null,"-")):a.createElement("div",{className:"flex justify-end"},a.createElement(DDe,{value:l,formatter:rl.vv}))}},{header:QSe,size:gNe,accessorFn:e=>aAe(e),sortingFn:e(((e,t)=>{var n,a;return(null!==(n=aAe(e.original))&&void 0!==n?n:0)-(null!==(a=aAe(t.original))&&void 0!==a?a:0)})),sortDescFirst:!0,cell:e=>{let t=e.getValue,n=e.row;const l=t();return n.getIsGrouped()?null:null===l||void 0===l||Math.abs(l)<1e-8?a.createElement("div",{className:"flex justify-end"},a.createElement(xt.v,null,"-")):a.createElement("div",{className:"flex justify-end"},a.createElement(RDe,{returnPercent:l}))}},{id:"actions",size:hNe,enableSorting:!1,accessorFn:e=>e.id,cell:e=>{const t=(0,e.getValue)();return r&&t?a.createElement("div",{className:"-mx-lg flex items-center justify-center"},a.createElement(mke.h,{onClick:()=>r(t)})):null},aggregatedCell:e=>{let t=e.row,n=e.table;if(!i||!m)return null;const l=t.subRows.filter((e=>{var t,n,a;return(null!==(t=e.original.taxLots)&&void 0!==t?t:[]).length>0||(null!==(n=null===p||void 0===p||null===(a=p[e.original.id])||void 0===a?void 0:a.length)&&void 0!==n?n:0)>0})).map((e=>e.original.id));if(0===l.length)return null;const r="account"===(0,o.A)(n.getState().grouping,1)[0]?"account":"security";return a.createElement(MDe,{onClick:e=>e.stopPropagation()},a.createElement(Qi.Az,{overlay:a.createElement(Ji.SP,null,a.createElement(Ji.xm,{type:"danger",icon:"trash",onClick:()=>i(l,r)},"Delete all tax lots")),placement:"bottom-end"},(e=>{let t=e.toggleOpen,n=e.isOpen;return a.createElement(LDe,{onClick:e=>{e.stopPropagation(),t()},active:n,icon:"more-horizontal",size:"small"})})))}}]}),[t,n,l,r,i,s,d,m,p,g,h,v,f])})({groupBy:l,selectedHoldingInfos:u,onClickHolding:m,onClickHoldingDetails:p,onDeleteAllGroupTaxLots:ue,onUpdateCostBasis:ae,showSelector:f,expandable:h,pendingDraftsByHolding:x,onOpenImportModal:S,onAddTaxLotToHolding:h?se:void 0,expandedHoldingIds:R,sorting:ge}),fe=null!==(t={[lAe.O.Account]:"account",[lAe.O.Security]:"securityGroup",[lAe.O.Type]:"type",[lAe.O.AssetClass]:"assetClass",[lAe.O.Institution]:"institution",[lAe.O.Holding]:"holding"}[l])&&void 0!==t?t:"securityGroup",ye=(0,a.useMemo)((()=>[fe]),[fe]),be=(0,a.useMemo)((()=>({type:!1,securityGroup:!1,account:!1,institution:!1,assetClass:!1,holding:!1})),[]),xe=(0,a.useMemo)((()=>({grouping:ye,sorting:ge,columnVisibility:be})),[be,ye,ge]);return a.createElement(a.Fragment,null,a.createElement(v_e,{columns:ve,data:n,empty:{title:"No tax lots data available"},state:xe,onSortingChange:he,expandedHoldingIds:R,holdingsWithActiveAdd:z,onCancelAddingTaxLot:de,onToggleHolding:ce,defaultAlignment:"right",isLoading:r,expandable:h,magicImportedTaxLotIds:E,onAddMagicImportedTaxLots:y,onRemoveMagicImportedTaxLot:b,pendingDraftsByHolding:x,onDeleteDraft:w,onAddDrafts:A,collapsedGroupsResetKey:fe,onStickyChange:k}),a.createElement(J,null,a.createElement(RNe,{onConfirm:me,onCancel:ee,isLoading:ie,description:"account"===K?"Are you sure you want to delete all tax lots for all holdings in this account?":"Are you sure you want to delete all tax lots for this security across all accounts?"})))},BDe=["widthPx","heightPx"],zDe=(0,u.default)(sl.ZQ).attrs({name:"X"}).withConfig({displayName:"CloseButton__XIcon",componentId:"sc-1x51smz-0"})([""," ",""],(e=>{let t=e.widthPx;return t&&(0,u.css)(["width:","px;"],t)}),(e=>{let t=e.heightPx;
1return t&&(0,u.css)(["height:","px;"],t)})),FDe=e=>{let t=e.widthPx,n=e.heightPx,l=(0,En.A)(e,BDe);return a.createElement(Xi.G,Object.assign({"data-external-id":"deprecated-text-button"},l),a.createElement(zDe,{widthPx:t,heightPx:n}))},GDe=["children","dismissed","onDismiss"],YDe=e=>{let t=e.children,n=e.dismissed,l=e.onDismiss,r=(0,En.A)(e,GDe);return n?null:a.createElement(UDe,Object.assign({"data-external-id":"deprecated-dismissible-banner"},r),a.createElement(m.g,{gap:"xxsmall",alignStretch:!0,justifyStart:!0},a.createElement(m.g,{full:!0},a.createElement("span",null,t)),a.createElement(m.g,{alignStart:!0,justifyEnd:!0},a.createElement(VDe,{onClick:l}))))},UDe=(0,u.default)(fu.g).withConfig({displayName:"DismissibleBanner__StyledBanner",componentId:"sc-1g7y6oz-0"})(["width:100%;padding:"," "," "," ",";"],vt.YK.small,vt.YK.xsmall,vt.YK.small,vt.YK.default),VDe=(0,u.default)(FDe).withConfig({displayName:"DismissibleBanner__StyledCloseButton",componentId:"sc-1g7y6oz-1"})(["padding:",";margin:",";color:inherit;"],vt.YK.small,vt.YK["-xsmall"]);var WDe;const jDe=e=>{let t=e.dismissed,n=e.onDismiss;(0,a.useEffect)((()=>{t||(0,Ge.u4)(Ye.Vi.TaxLotMismatchBannerViewed)}),[]);return a.createElement(HDe,{"data-external-id":"investments-tax-lot-mismatch-banner",type:"warning",dismissed:t,onDismiss:()=>{(0,Ge.u4)(Ye.Vi.TaxLotMismatchBannerDismissed),n()}},a.createElement("div",{className:"flex size-full flex-1 items-center gap-xs"},a.createElement(sl.ZQ,{name:"alert-triangle",size:16,className:"shrink-0 text-content-warning"}),a.createElement(xt.v,null,"One or more positions have missing or inaccurate lots. Gain and loss values reflect existing lots.")))},HDe=(0,$d.s)(YDe)(WDe||(WDe=(0,wc.A)(["py-xs"])));var KDe,qDe,$De,ZDe;const JDe=["children","style","className"],XDe=e=>{var t,n;let l=e.holdings,r=e.tableState,i=e.importModal,s=e.drafts,c=e.banner,d=e.expandable,u=e.showSelector,m=e.onClickHoldingDetails;const p=(()=>{const e=(0,a.useContext)(ri.z).scrollRef,t=(0,a.useState)(!1),n=(0,o.A)(t,2),l=n[0],r=n[1],i=(0,a.useRef)(null),s=(0,a.useRef)(null),c=(0,a.useRef)(null),d=(0,a.useRef)(null),u=(0,a.useCallback)((e=>{r(e)}),[]),m=(0,a.useCallback)((()=>{const t=null===e||void 0===e?void 0:e.current,n=c.current,a=d.current;if(!t||!n||!a)return;const l=t.getBoundingClientRect().top,r=n.offsetHeight||40,o=i.current;let s=0;o&&o.querySelectorAll('[data-sentinel-type="inner-top"]').forEach((e=>{const t=e.getBoundingClientRect().top,n=Math.max(0,Math.min(1,(l+r-t)/r));if(n>0){var a;const t=null===(a=e.getAttribute("data-sentinel-key"))||void 0===a?void 0:a.replace(/-top$/,""),i=t?o.querySelector('[data-sentinel-type="inner-bottom"][data-sentinel-key="'.concat(t,'-bottom"]')):null;let c=0;if(i){const e=i.getBoundingClientRect().top;c=Math.max(0,Math.min(1,(l+2*r-e)/r))}s=Math.max(s,n*(1-c))}})),n.style.transform="translateY(".concat(-s*r,"px)"),a.style.transform="translateY(".concat((1-s)*r,"px)")}),[e,i,c,d]);return(0,a.useEffect)((()=>{const e=i.current;if(!e)return;const t=()=>{s.current&&(s.current.style.transform="translateX(-".concat(e.scrollLeft,"px)"))};return e.addEventListener("scroll",t,{passive:!0}),()=>e.removeEventListener("scroll",t)}),[]),(0,a.useEffect)((()=>{const t=null===e||void 0===e?void 0:e.current;if(t)return t.addEventListener("scroll",m,{passive:!0}),()=>t.removeEventListener("scroll",m)}),[e,m]),(0,a.useLayoutEffect)((()=>{l&&(s.current&&i.current&&(s.current.style.transform="translateX(-".concat(i.current.scrollLeft,"px)")),m())}),[l,m]),{stickyIsVisible:l,onStickyChange:u,scrollContainerRef:i,stickyInnerRef:s,outerHeaderRowRef:c,innerHeaderRowRef:d}})(),g=p.stickyIsVisible,h=p.onStickyChange,v=p.scrollContainerRef,f=p.stickyInnerRef,E=p.outerHeaderRowRef,y=p.innerHeaderRowRef;return a.createElement(ANe,{"data-external-id":"investments-cost-basis-table-section",title:"Holdings",controls:a.createElement($_e.O,{title:null!==(t=null===(n=rAe.find((e=>e.value===r.groupBy)))||void 0===n?void 0:n.label)&&void 0!==t?t:"Group by"},rAe.map((e=>a.createElement(Ji.xm,{key:e.value,selected:r.groupBy===e.value,onClick:()=>{r.setGroupBy(e.value),(0,Ge.u4)(Ye.Vi.GainsAndLossesGroupByChanged,{group_by:e.value,source:"table"})}},e.label)))),minWidth:sNe,stickyIsVisible:g,stickyInnerRef:f,scrollC
1ontainerRef:v,stickyHeader:a.createElement(a.Fragment,null,a.createElement(xNe,{ref:E},a.createElement(eRe,null,a.createElement("thead",null,a.createElement("tr",null,a.createElement(wNe,{style:{width:cNe}},qSe),a.createElement(wNe,{style:{width:dNe}},$Se),a.createElement(wNe,{style:{width:uNe}},ZSe),a.createElement(wNe,{style:{width:mNe}},JSe),a.createElement(wNe,{style:{width:pNe}},XSe),a.createElement(wNe,{style:{width:gNe}},QSe),a.createElement(wNe,{style:{width:hNe}}))))),a.createElement(xNe,{ref:y,$layered:!0,style:{transform:"translateY(100%)"}},a.createElement(eRe,null,a.createElement("thead",null,a.createElement("tr",null,a.createElement(QDe,{style:{width:190}},eNe),a.createElement(QDe,{style:{width:105},className:"text-left"},tNe),a.createElement(QDe,{style:{width:120}},nNe),a.createElement(QDe,{style:{width:100}},aNe),a.createElement(QDe,{style:{width:130}},lNe),a.createElement(QDe,{style:{width:120}},rNe),a.createElement(QDe,{style:{width:110}},oNe),a.createElement(QDe,{style:{width:110}},iNe),a.createElement(QDe,{style:{width:45}})))))),banner:l.hasMismatchedTaxLots&&!c.dismissed?a.createElement("div",{className:"bg-background-primary px-lg pt-xs pb-default"},a.createElement(jDe,{dismissed:c.dismissed,onDismiss:c.onDismiss})):void 0,totals:!l.isLoading&&l.individualHoldings.length>0?a.createElement("tbody",null,a.createElement("tr",null,a.createElement(tRe,{style:{width:cNe}},a.createElement(xt.v,{weight:"medium"},"Total")),a.createElement(tRe,{style:{width:dNe}}),a.createElement(tRe,{style:{width:uNe}}),a.createElement(tRe,{style:{width:mNe}}),a.createElement(tRe,{style:{width:pNe}},a.createElement(kNe,{value:l.totals.gainLossDollars},a.createElement(nRe,{value:l.totals.gainLossDollars,formatter:rl.vv}))),a.createElement(tRe,{style:{width:gNe}},a.createElement(kNe,{value:l.totals.gainLossPercent},a.createElement(aRe,{returnPercent:l.totals.gainLossPercent}))),a.createElement(tRe,{style:{width:hNe}}))):void 0},a.createElement(PDe,{holdings:l.individualHoldings,groupBy:r.groupBy,isLoading:l.isLoading,sortBy:r.sortBy,setSortBy:r.setSortBy,selectedHoldingInfos:l.selectedHoldingInfos,onClickHolding:l.onClickHolding,onClickHoldingDetails:m,expandable:d,showSelector:u,magicImportedTaxLotIds:i.magicImportedTaxLotIds,onAddMagicImportedTaxLots:i.onAddMagicImportedTaxLotIds,onRemoveMagicImportedTaxLot:i.onRemoveMagicImportedTaxLot,pendingDraftsByHolding:s.pendingDraftsByHolding,onDeleteDraft:s.onDeleteDraft,onAddDrafts:s.onAddDrafts,holdingsToAutoExpand:s.holdingsToAutoExpand,onStickyChange:h,onOpenImportModal:i.onOpen}))},QDe=e=>{let t=e.children,n=e.style,l=e.className,r=(0,En.A)(e,JDe);const o=(0,u.useTheme)();return a.createElement("th",Object.assign({"data-external-id":"inner-sticky-th"},r,{className:(0,q.cn)("px-lg py-default text-right text-sm font-medium text-content-secondary","whitespace-nowrap select-none","first:pl-[calc(var(--spacing-2xl)+var(--spacing-xl))] first:text-left",l),style:(0,U.A)((0,U.A)({},n),{},{backgroundColor:o.color.gray1,borderBottom:"1px solid ".concat(o.color.gray3)})}),t)},eRe=$d.s.table(KDe||(KDe=(0,wc.A)(["w-full min-w-300 table-fixed border-spacing-0"]))),tRe=$d.s.td(qDe||(qDe=(0,wc.A)(["\n  bg-background-primary px-lg py-default\n  first:pl-[calc(var(--spacing-2xl)+var(--spacing-xs))]\n"]))),nRe=(0,$d.s)(Y3.g)($De||($De=(0,wc.A)(["-mr-xs"]))),aRe=(0,$d.s)(V3)(ZDe||(ZDe=(0,wc.A)(["-mr-xs"]))),lRe=e=>{var t;const n=(0,u.useTheme)(),l=[vt.Ee.color.chart.fill.yellow({theme:n}),vt.Ee.color.chart.fill.green({theme:n}),vt.Ee.color.chart.fill.teal({theme:n}),vt.Ee.color.chart.fill.purple({theme:n})],r=(0,a.useState)(null!==(t=null===e||void 0===e?void 0:e.initialColors)&&void 0!==t?t:l),i=(0,o.A)(r,2),s=i[0],c=i[1],d=(0,a.useState)([]),m=(0,o.A)(d,2),p=m[0],g=m[1],h=(0,a.useState)(null),v=(0,o.A)(h,2),f=v[0],E=v[1],y=(0,a.useCallback)((e=>{const t=e.id,n=e.ticker,a=e.name,l=p.find((e=>e.id===t));if(l){const e=l.color;c([...s,e]),g(p.filter((e=>{let n=e.id;return t!==n})))}else if(s.length>0){const e=(0,Sn.A)(s),l=e[0],r=(0,kn.A)(e).slice(1);c(r),g([...p,{id:t,color:l,ticker:n,name:a,dataKey:t,isBenchmark:!1}])}}),[s,c,p,g]),b=(0,a.useCallback)((e=>{if(e){const t=e.id,a=e.ticker,l=e.name;E({id:t,color:vt.Ee.color.chart.fill.blue({theme:n}),ticker:a,name:l,dataKey:(0,lDe.tM)(t),isBenchmark:!0})}else E(null)}),[n]);return{portfolioColor:vt.Ee.color.chart.fill.orange({theme:n}),comparisonBenchmarkColor:vt.Ee.color.chart.fill.blue({theme:n}),selectHolding:y,selectBenchmarkHolding:b,selectedAggregateHoldingInfos:p,selectedBenchmarks:f?[f]:[],availableHoldingLineColors:s,setAvailableHoldingLineColors:c,setSelectedAggregateHoldingInfos:g}},rRe=e=>({currentValue:tAe(e),positionCost:eAe(e),hasTaxLots:QCe(e)}),oRe=e=>(0,a.useMemo)((()=>(e=>{const t=e.reduce(((e,t)=>{let n=t.currentValue,a=t.positionCost,l=t.hasTaxLots;const r=(0,Tp.n)(n),o=(0,Tp.n)(a);return r&&(e.currentValues.push(n),o?(e.costBases.push(a),e.matchedCurrentValues.push(n)):e.isMissingCostBasis=!0,l||(e.isMissingTaxLots=!0)),e}),{currentValues:[],costBases:[],matchedCurrentValues:[],isMissingCostBasis:!1,isMissingTaxLots:!1}),n=(0,De.Eb)(t.currentValues),a=(0,De.Eb)(t.costBases),l=(0,De.Eb)(t.matchedCurrentValues),r=(0,De.Eb)([l,-a]);return{totalCurrentValue:n,totalCostBasis:a,gainLossDollars:r,gainLossPercent:a>0?r/a*100:0,isMissingCostBasis:t.isMissingCostBasis,isMissingTaxLots:t.isMissingTaxLots}})(e.map(rRe))),[e]),iRe=e=>{var t;return{draftId:OTe(),acquisitionDate:null!==(t=e.acquisitionDate)&&void 0!==t?t:"",acquisitionQuantity:void 0===e.quantity||isNaN(e.quantity)?"":String(e.quantity),costBasisPerUnit:void 0===e.costBasisPerUnit||isNaN(e.costBasisPerUnit)?void 0:e.costBasisPerUnit,totalCostBasis:void 0}},sRe=e=>{let t=e.holdings,n=e.onMagicImported,l=e.onBulkDraftsCreated;const r=(0,a.useState)(void 0),i=(0,o.A)(r,2),s=i[0],c=i[1],d=e_e(s),u=d.importTaxLots,m=d.isImporting,p=(0,a.useCallback)((e=>{if(e.importedTaxLotIds.length>0&&n(e.importedTaxLotIds),e.incompleteLots.length>0){const t=e.incompleteLots.filter((e=>(e=>void 0!==e.acquisitionDate&&""!==e.acquisitionDate.trim()||void 0!==e.quantity&&!isNaN(e.quantity)&&0!==e.quantity||void 0!==e.costBasisPerUnit&&!isNaN(e.costBasisPerUnit))(e.lot))),n=e.incompleteLots.length-t.length;if(n>0&&(0,C.oR)({title:"Couldn't import ".concat(n," ").concat((0,De.td)("tax lot",n)),description:"Some rows had no recognizable data and were skipped."}),t.length>0){const e=t.reduce(((e,t)=>{var n;let a=t.holdingId,l=t.lot;return(0,U.A)((0,U.A)({},e),{},{[a]:[...null!==(n=e[a])&&void 0!==n?n:[],iRe(l)]})}),{});l(e)}}}),[n,l]),g=(0,a.useCallback)((async(e,n)=>{const a=null!==n&&void 0!==n?n:s;if(0===e.length)return(0,C.oR)({title:"No tax lots found in the uploaded documents"}),{unmatchedLots:[]};const l=e.filter(QTe);if(0===l.length)return(0,C.oR)({title:"No tax lots found in the uploaded documents"}),{unmatchedLots:[]};const r=JTe(l,t,a),o=r.matched,i=r.unmatched,d=(e=>{let t=e.matched,n=e.actionableLots,a=e.accountHoldings;const l=0===t.length&&1===a.length;return{importMatches:l?[{holding:a[0],lots:n}]:t,isSingleHoldingFallback:l}})({matched:o,actionableLots:l,accountHoldings:a?t.filter((e=>{var t;return(null===(t=e.account)||void 0===t?void 0:t.id)===a})):t}),m=d.importMatches,g=d.isSingleHoldingFallback;if(m.length>0){const e=m.map((e=>({holdingId:e.holding.id,lots:e.lots}))),t=await u(e);p(t)}const h=g?[]:i;return 0===h.length&&c(void 0),{unmatchedLots:h}}),[s,t,u,p]),h=(0,a.useCallback)((async e=>{const t=e.map((e=>{let t=e.lot;return{holdingId:e.holdingId,lots:[t]}})),n=await u(t);p(n),c(void 0)}),[u,p]),v=(0,a.useCallback)((e=>c(e)),[]);return{accountId:s,setAccountId:c,isImporting:m,onOpen:v,onParsed:g,onFinalizeUnmatched:h}},cRe=(e,t,n)=>{const l=(0,bZ.D)(V_e,{forceMockData:n,variables:{portfolioInput:{accountIds:e.length>
10?e:void 0,startDate:t.startDate,endDate:t.endDate,includeHiddenHoldings:void 0,topMoversLimit:void 0}}}),r=l.data,o=l.isLoadingInitialData,i=l.error,s=l.refetch,c=(0,a.useMemo)((()=>{var e;return(0,K_e.B)(null!==(e=null===r||void 0===r?void 0:r.portfolio.aggregateHoldings.edges)&&void 0!==e?e:[])}),[r]),d=(0,a.useContext)(zq);(0,a.useEffect)((()=>{null===d||void 0===d||d.addAccountAddedListener(s)}),[]);const u=(0,a.useMemo)((()=>{const t=e.length>0?c.filter((t=>t.holdings.some((t=>{var n,a;return e.includes(null!==(n=null===(a=t.account)||void 0===a?void 0:a.id)&&void 0!==n?n:"")})))):c;return(0,cAe.aT)(t)}),[c,e]),m=(0,a.useMemo)((()=>u.some((e=>e.holdings.some((t=>{var n;return null!==ONe(t,null===(n=e.security)||void 0===n?void 0:n.type)}))))),[u]),p=(0,a.useMemo)((()=>(0,Fo.A)([(0,U_e.A)((e=>{var t,n;return null!==(t=null===(n=e.account)||void 0===n?void 0:n.order)&&void 0!==t?t:Number.MAX_SAFE_INTEGER})),(0,U_e.A)((e=>{var t;return(0,DV.A)(null!==(t=e.type)&&void 0!==t?t:"other",cAe.Sy)})),(0,U_e.A)((e=>{var t,n,a;return null!==(t=null!==(n=null===(a=e.security)||void 0===a?void 0:a.ticker)&&void 0!==n?n:e.ticker)&&void 0!==t?t:""}))],u.flatMap((e=>{var t;return(null!==(t=e.holdings)&&void 0!==t?t:[]).map((t=>(0,U.A)((0,U.A)({},t),{},{security:e.security})))})))),[u]);return{holdingsData:r,isLoadingHoldings:o,holdingsError:i,refetch:s,aggregateHoldings:c,holdingAggregates:u,hasMismatchedTaxLots:m,individualHoldings:p}},dRe=e=>{let t=e.activeAccountIds,n=e.dateRange,l=e.useMockData,r=e.groupBy,i=e.setGroupBy;const s=(0,a.useState)(null),c=(0,o.A)(s,2),d=c[0],m=c[1],p=cRe(t,n,l),g=p.holdingsData,h=p.isLoadingHoldings,v=p.individualHoldings,f=p.aggregateHoldings,E=p.holdingAggregates,y=p.hasMismatchedTaxLots,b=((e,t)=>{const n=(0,u.useTheme)(),l=[vt.Ee.color.chart.fill.yellow({theme:n}),vt.Ee.color.chart.fill.green({theme:n}),vt.Ee.color.chart.fill.orange({theme:n}),vt.Ee.color.chart.fill.purple({theme:n})],r=lRe({initialColors:l}),i=r.selectedAggregateHoldingInfos,s=r.availableHoldingLineColors,c=r.setAvailableHoldingLineColors,d=r.setSelectedAggregateHoldingInfos,m=(0,a.useMemo)((()=>{const t=e.flatMap((e=>e.holdings.map((t=>{var n,a;return[t.id,"".concat(e.id,"-").concat(null!==(n=null===(a=t.account)||void 0===a?void 0:a.id)&&void 0!==n?n:"")]}))));return new Map(t)}),[e]),p=(0,a.useMemo)((()=>e.flatMap((e=>e.holdings.map((e=>e.id))))),[e]),g=(0,a.useCallback)(((e,t)=>{const n=t.ticker,a=t.name,l=m.get(e);if(!l)return;const r=i.find((e=>e.id===l));if(r){const e=r.color;c([...s,e]),d(i.filter((e=>{let t=e.id;return l!==t})))}else if(s.length>0){const t=(0,Sn.A)(s),r=t[0],o=(0,kn.A)(t).slice(1);c(o),d([...i,{id:l,color:r,ticker:null!==n&&void 0!==n?n:null,name:a,dataKey:e,isBenchmark:!1}])}}),[i,s,c,d,m]);return(0,a.useEffect)((()=>{if(t)return;const n=new Set(e.flatMap((e=>e.holdings.map((t=>{var n,a;return"".concat(e.id,"-").concat(null!==(n=null===(a=t.account)||void 0===a?void 0:a.id)&&void 0!==n?n:"")}))))),a=i.filter((e=>{let t=e.id;return!n.has(t)}));if(a.length>0){const e=a.map((e=>e.color));c([...s,...e]),d(i.filter((e=>{let t=e.id;return n.has(t)})))}}),[t,e,i,s,c,d]),{allHoldingIds:p,selectedHoldingInfos:(0,a.useMemo)((()=>i.flatMap((e=>Array.from(m.entries()).filter((t=>{let n=(0,o.A)(t,2);return n[0],n[1]===e.id})).map((e=>(0,o.A)(e,1)[0])).map((t=>(0,U.A)((0,U.A)({},e),{},{id:t})))))),[i,m]),selectedAggregateHoldingInfos:i,handleClickHolding:g}})(f,h),x=b.allHoldingIds,w=b.selectedHoldingInfos,C=b.handleClickHolding,A=oRe(v),I=(()=>{const e=(0,a.useState)(new Set),t=(0,o.A)(e,2),n=t[0],l=t[1];return{ids:n,add:(0,a.useCallback)((e=>{l((t=>new Set([...t,...e])))}),[]),remove:(0,a.useCallback)((e=>{l((t=>{const n=new Set(t);return n.delete(e),n}))}),[])}})(),k=(()=>{const e=(0,a.useState)({}),t=(0,o.A)(e,2),n=t[0],l=t[1],r=(0,a.useState)([]),i=(0,o.A)(r,2),s=i[0],c=i[1];return{byHolding:n,autoExpand:s,addForHolding:(0,a.useCallback)(((e,t)=>{l((n=>{var a;return(0,U.A)((0,U.A)({},n),{},{[e]:[...null!==(a=n[e])&&void 0!==a?a:[],...t]})}))}),[]),addBulk:(0,a.useCallback)((e=>{l((t=>Object.entries(e).reduce(((e,t)=>{var n;let a=(0,o.A)(t,2),l=a[0],r=a[1];return(0,U.A)((0,U.A)({},e),{},{[l]:[...null!==(n=e[l])&&void 0!==n?n:[],...r]})}),t))),c(Object.keys(e))}),[]),remove:(0,a.useCallback)(((e,t)=>{l((n=>{const a=n[e];if(!a)return n;const l=a.filter((e=>e.draftId!==t));return 0===l.length?Object.fromEntries(Object.entries(n).filter((t=>(0,o.A)(t,1)[0]!==e))):(0,U.A)((0,U.A)({},n),{},{[e]:l})}))}),[])}})(),S=sRe({holdings:v,onMagicImported:I.add,onBulkDraftsCreated:k.addBulk}),N=(e=>{const t=(0,a.useState)(!1),n=(0,o.A)(t,2),l=n[0],r=n[1],i=(0,a.useCallback)((()=>{r(!0)}),[]),s=(0,a.useRef)(e);return(0,a.useEffect)((()=>{e&&!s.current&&r(!1),s.current=e}),[e]),{dismissed:l,handleDismiss:i}})(y),T=N.dismissed,_=N.handleDismiss,D=(0,a.useMemo)((()=>{const e=new Map;return v.forEach((t=>{var n,a;null!==(n=t.account)&&void 0!==n&&n.id&&null!==(a=t.account)&&void 0!==a&&a.displayName&&!e.has(t.account.id)&&e.set(t.account.id,{id:t.account.id,displayName:t.account.displayName})})),Array.from(e.values())}),[v]);return{holdings:{isLoading:h,individualHoldings:v,aggregateHoldings:f,holdingAggregates:E,hasMismatchedTaxLots:y,allHoldingIds:x,selectedHoldingInfos:w,totals:A,meta:null===g||void 0===g?void 0:g.portfolio.performance,onClickHolding:C},tableState:{groupBy:r,setGroupBy:i,sortBy:d,setSortBy:m}
1,importModal:{accountId:S.accountId,setAccountId:S.setAccountId,isImporting:S.isImporting,onOpen:S.onOpen,onParsed:S.onParsed,onFinalizeUnmatched:S.onFinalizeUnmatched,magicImportedTaxLotIds:I.ids,onAddMagicImportedTaxLotIds:I.add,onRemoveMagicImportedTaxLot:I.remove,accounts:D,holdings:v},drafts:{pendingDraftsByHolding:k.byHolding,holdingsToAutoExpand:k.autoExpand,onDeleteDraft:k.remove,onAddDrafts:k.addForHolding},banner:{dismissed:T,onDismiss:_}}};var uRe=n(9348);const mRe=()=>{const e=(0,qG.e)().hasAccess,t=(0,xq.bO)("dismissedInvestmentsAdvancedWalkthroughAt"),n=(0,o.A)(t,3),l=n[0],r=n[1],i=n[2],s=mG().hasAccounts,c=(0,d.d4)(uRe.UN);return{shouldShow:e&&!i&&!l&&!0===s&&!c,dismiss:(0,a.useCallback)((()=>{r((new Date).toISOString())}),[r])}},pRe=(0,xZ.Z)((()=>n.e(8876).then(n.bind(n,38876)).then((e=>({default:e.InvestmentsAdvancedWalkthrough})))),"LazyLoadedAdvancedWalkthrough"),gRe=e=>{let t=e.activeAccountIds,n=e.dateRange,r=e.groupBy,i=e.setGroupBy,s=e.onRegisterActions,c=e.initialGnlShortcutTitle,d=e.onGnlShortcutChange,u=e.initialFundsClassification,m=e.onFundsClassificationChange;const p=(0,l.Zp)(),g=(0,l.zy)(),h=(0,nG.p)("feat-investments-allocation_manual_classification-web","off"),v=h&&g.pathname.includes(I.JZ.investments.advanced.allocation.path)?rke.Allocation:g.pathname.includes(I.JZ.investments.advanced.funds.path)?rke.Funds:rke.GainsLosses,f=(0,a.useState)(kAe.CostBasis),E=(0,o.A)(f,2),y=E[0],b=E[1],x=(0,a.useState)(TSe.Pie),w=(0,o.A)(x,2),C=w[0],A=w[1],k=(0,a.useState)(null!==c&&void 0!==c?c:"3M"),S=(0,o.A)(k,2),N=S[0],T=S[1],_=(0,a.useCallback)((e=>{T(e),null===d||void 0===d||d(e)}),[d]),D=(0,qG.e)(),R=D.hasAccess,M=D.isLoading,L=mRe(),O=L.shouldShow,P=L.dismiss,B=(0,a.useState)(null!==u&&void 0!==u?u:cSe),z=(0,o.A)(B,2),F=z[0],G=z[1],Y=(0,a.useState)(new Set),V=(0,o.A)(Y,2),W=V[0],j=V[1],H=(0,a.useCallback)((e=>{G(e),j(new Set),null===m||void 0===m||m(e)}),[m]),K=v===rke.Funds,q=function(e){let t=(arguments.length>1&&void 0!==arguments[1]?arguments[1]:{}).enabled,n=void 0===t||t;const l=(0,bZ.D)(W_e,{skip:!n,variables:{portfolioInput:{accountIds:e.length>0?e:void 0}}}),r=l.data,o=l.isLoadingInitialData,i=(0,a.useMemo)((()=>{var e;return(0,K_e.B)(null!==(e=null===r||void 0===r?void 0:r.portfolio.aggregateHoldings.edges)&&void 0!==e?e:[])}),[r]),s=(0,a.useMemo)((()=>i.filter(q_e)),[i]);return{individualHoldings:(0,a.useMemo)((()=>(0,Fo.A)([(0,U_e.A)((e=>{var t;return(0,DV.A)(null!==(t=e.type)&&void 0!==t?t:"other",cAe.Sy)})),(0,U_e.A)((e=>{var t,n,a;return null!==(t=null!==(n=null===(a=e.security)||void 0===a?void 0:a.ticker)&&void 0!==n?n:e.ticker)&&void 0!==t?t:""}))],i.filter(q_e).map((e=>{var t,n,a,l,r,o,i,s,c,d,u,m,p,g,h,v,f,E,y,b,x,w,C;return{id:e.id,type:null!==(t=null!==(n=null===(a=e.security)||void 0===a?void 0:a.type)&&void 0!==n?n:null===(l=e.holdings)||void 0===l||null===(r=l[0])||void 0===r?void 0:r.type)&&void 0!==t?t:null,typeDisplay:null!==(o=null!==(i=null===(s=e.security)||void 0===s?void 0:s.typeDisplay)&&void 0!==i?i:null===(c=e.holdings)||void 0===c||null===(d=c[0])||void 0===d?void 0:d.typeDisplay)&&void 0!==o?o:null,name:null!==(u=null!==(m=null===(p=e.security)||void 0===p?void 0:p.name)&&void 0!==m?m:null===(g=e.holdings)||void 0===g||null===(h=g[0])||void 0===h?void 0:h.name)&&void 0!==u?u:null,ticker:null!==(v=null!==(f=null===(E=e.security)||void 0===E?void 0:E.ticker)&&void 0!==f?f:null===(y=e.holdings)||void 0===y||null===(b=y[0])||void 0===b?void 0:b.ticker)&&void 0!==v?v:null,closingPrice:null!==(x=null===(w=e.security)||void 0===w?void 0:w.closingPrice)&&void 0!==x?x:null,closingPriceUpdatedAt:null,quantity:e.quantity,value:e.totalValue,costBasis:e.costBasis,account:null,taxLots:[],security:null!==(C=e.security)&&void 0!==C?C:null}})))),[i]),holdingAggregates:s,isLoading:o}}(t,{enabled:K}),$=dRe({activeAccountIds:t,dateRange:n,groupBy:r,setGroupBy:i}),Z=$.holdings,J=(0,a.useMemo)((()=>{if(0===W.size)return q.individualHoldings;const e=mSe[F];return e?q.individualHoldings.filter((t=>{var n,a;const l=null!==(n=null===(a=t.security)||void 0===a?void 0:a[e])&&void 0!==n?n:"Unclassified";return!W.has(String(l))})):q.individualHoldings}),[q.individualHoldings,W,F]);(0,a.useEffect)((()=>{(0,Ge.u4)(Ye.Vi.AdvancedPageViewed)}),[]);const X=v===rke.Allocation,Q=(0,a.useState)([]),ee=(0,o.A)(Q,2),te=ee[0],ne=ee[1],ae=(0,a.useState)(null),le=(0,o.A)(ae,2),re=le[0],oe=le[1],ie=(0,a.useState)(null),se=(0,o.A)(ie,2),ce=se[0],de=se[1],ue=(0,a.useCallback)((e=>{ne(e),de(null)}),[]),me=(0,a.useCallback)((e=>{de((t=>t===e?null:e))}),[]),pe=(0,a.useMemo)((()=>{var e;return null===(e=$.holdings.holdingAggregates)||void 0===e?void 0:e.find((e=>e.id===re))}),[$.holdings.holdingAggregates,re]),ge=(0,a.useState)(null),he=(0,o.A)(ge,2),ve=he[0],fe=he[1],Ee=(0,a.useMemo)((()=>{var e;return null===(e=$.holdings.holdingAggregates)||void 0===e?void 0:e.find((e=>e.holdings.some((e=>e.id===ve))))}),[$.holdings.holdingAggregates,ve]),ye=(0,a.useState)(null),be=(0,o.A)(ye,2),xe=be[0],we=be[1],Ce=(0,a.useMemo)((()=>{var e;return null===(e=q.holdingAggregates)||void 0===e?void 0:e.find((e=>e.id===xe))}),[q.holdingAggregates,xe]),Ae=((e,t)=>{var n;const l=null===(n=null===t||void 0===t?void 0:t.enabled)||void 0===n||n,r=(0,a.useMemo)((()=>({accountIds:e.length>0?e:null})),[e]),o=(0,et.I)(tSe,{variables:{portfolioInput:r},skip:!l}),i=o.data,s=o.isLoadingInitialData;return(0,a.useMemo)((()=>{var e,t,n,a,l,r;const o=null!==(e=null===i||void 0===i||null===(t=i.myHousehold)||void 0===t?void 0:t.allocationCategories)&&void 0!==e?e:[],c=null!==(n=null===i||void 0===i||null===(a=i.portfolio)||void 0===a||null===(l=a.aggregateHoldings)||void 0===l||null===(r=l.edges)||void 0===r?void 0:r.flatMap((e=>null!==e&&void 0!==e&&e.node?[e.node]:[])))&&void 0!==n?n:[],d=(0,De.Eb)(c.map((e=>e.totalValue))),u=0===c.length;if(s)return{tree:null,breakdown:null,portfolioTotal:d,stats:Bke,isLoading:!0,isEmpty:!1};if(u)return{tree:null,breakdown:null,portfolioTotal:d,stats:Bke,isLoading:!1,isEmpty:!0};const m=zke(c,o);return{tree:m.tree,breakdown:m.breakdown,portfolioTotal:d,stats:m.stats,isLoading:!1,isEmpty:!1}}),[i,s])})(t,{enabled:X}),Ie=(0,a.useRef)(!1);(0,a.useEffect)((()=>
1{if(!X)return void(Ie.current=!1);if(Ae.isLoading||Ie.current)return;Ie.current=!0;const e=Ae.stats;(0,Ge.u4)(Ye.Vi.AllocationBreakdownTabViewed,{total_holdings_count:e.totalHoldingsCount,unclassified_holdings_count:e.unclassifiedHoldingsCount})}),[X,Ae]);const ke={[rke.Allocation]:I.JZ.investments.advanced.allocation.path,[rke.Funds]:I.JZ.investments.advanced.funds.path,[rke.GainsLosses]:I.JZ.investments.advanced.gainsAndLosses.path}[v];(0,a.useEffect)((()=>{if(R)return null===s||void 0===s||s({openAddHolding:()=>p("".concat(ke,"/add-holding")),openImportModal:()=>{p("".concat(ke,"/add-tax-lots")),(0,Ge.u4)(Ye.Vi.TaxLotImportModalOpened,{source:"header_button"})}}),()=>{null===s||void 0===s||s(null)};null===s||void 0===s||s(null)}),[s,p,ke,R]);const Se=(0,a.useCallback)((e=>{const t=Z.individualHoldings.find(e);var n;t&&(null===(n=document.querySelector('[data-holding-id="'.concat(t.id,'"]')))||void 0===n||n.scrollIntoView({behavior:"smooth",block:"center"}))}),[Z.individualHoldings]),Ne=(0,a.useCallback)((()=>Se((e=>null!==tAe(e)&&null===eAe(e)))),[Se]),Te=(0,a.useCallback)((()=>Se((e=>!QCe(e)&&null!==tAe(e)))),[Se]),_e=(0,a.useCallback)((e=>{$.importModal.setAccountId(e),p("".concat(ke,"/add-tax-lots"))}),[$.importModal,p,ke]),Re=(0,a.useMemo)((()=>(0,U.A)((0,U.A)({},$.importModal),{},{onOpen:_e})),[$.importModal,_e]);if(M)return null;if(!R)return a.createElement(QG.N,{"data-external-id":"investments-advanced",type:"AssetAllocation",analyticsName:"AdvancedRoute",onClose:()=>p(I.JZ.investments.holdings.path,{replace:!0})});const Me=a.createElement(oke,{activeSubTab:v,onSubTabChange:e=>{e===rke.Funds?p(I.JZ.investments.advanced.funds.path):e===rke.Allocation?p(I.JZ.investments.advanced.allocation.path):p(I.JZ.investments.advanced.gainsAndLosses.path)},showAllocationBreakdownTab:h}),Le=X?{graph:a.createElement(ske,{tree:Ae.tree,portfolioTotal:Ae.portfolioTotal,isLoading:Ae.isLoading,isEmpty:Ae.isEmpty,onFocusChange:ue,selectedHoldingId:ce,onHoldingSelect:me,tabs:Me,titleAdornment:a.createElement(hRe,null)}),holdingsTable:a.createElement(a.Fragment,null,a.createElement("div",{className:"mt-2xs"},a.createElement(Ake,{breakdown:Ae.breakdown,focusPath:te,portfolioTotal:Ae.portfolioTotal,isLoading:Ae.isLoading,isEmpty:Ae.isEmpty,onHoldingClick:oe,f
1ilteredHoldingId:ce,onClearFilter:()=>de(null)})),pe&&a.createElement(QIe,{holdingAggregate:pe,onClose:()=>oe(null),showManualClassification:!0}))}:K?{graph:a.createElement(HSe,{activeAccountIds:t,fundsClassification:F,onFundsClassificationChange:H,chartType:C,onChartTypeChange:A,onHiddenCategoriesChange:j,tabs:Me}),holdingsTable:a.createElement(a.Fragment,null,a.createElement(F_e,{fundsClassification:F,onFundsClassificationChange:H,holdings:J,isLoading:q.isLoading,onClickHolding:we}),Ce&&a.createElement(QIe,{holdingAggregate:Ce,onClose:()=>we(null)}))}:{graph:a.createElement(mDe,{allHoldingIds:Z.allHoldingIds,selectedHoldingInfos:Z.selectedHoldingInfos,individualHoldings:Z.individualHoldings,isLoadingHoldings:Z.isLoading,groupBy:r,onGroupByChange:i,shortcutTitle:N,onShortcutChange:_,viewMode:y,onViewModeChange:b,onOpenImportModal:()=>p("".concat(ke,"/add-tax-lots")),totalCurrentValue:Z.totals.totalCurrentValue,totalCostBasis:Z.totals.totalCostBasis,gainLossDollars:Z.totals.gainLossDollars,gainLossPercent:Z.totals.gainLossPercent,isMissingCostBasis:Z.totals.isMissingCostBasis,isMissingTaxLots:Z.totals.isMissingTaxLots,isLoadingTotals:Z.isLoading,onScrollToMissingCostBasis:Ne,onScrollToMissingTaxLots:Te,tabs:Me}),holdingsTable:a.createElement(a.Fragment,null,a.createElement(XDe,Object.assign({},$,{importModal:Re,showSelector:y===kAe.TaxLots,onClickHoldingDetails:fe})),Ee&&a.createElement(QIe,{holdingAggregate:Ee,onClose:()=>fe(null)}))},Oe=Le.graph,Pe=Le.holdingsTable;return a.createElement(a.Fragment,null,a.createElement(Xhe.Ay,null,a.createElement("title",null,"Monarch | Investments Advanced")),a.createElement(lke,{graph:Oe,holdingsTable:Pe}),[I.JZ.investments.advanced.gainsAndLosses,I.JZ.investments.advanced.funds,I.JZ.investments.advanced.allocation].map((e=>a.createElement(XU.l,{key:e.path,path:"".concat(e.relativePath,"/add-holding")},(t=>{let n=t.close;return a.createElement(WCe.q,{onDone:n,onAddMore:()=>p("".concat(e.path,"/add-holding")),onCancel:n})})))),a.createElement(l.BV,null,[I.JZ.investments.advanced.gainsAndLosses,I.JZ.investments.advanced.funds,I.JZ.investments.advanced.allocation].map((e=>a.createElement(l.qh,{key:e.path,path:"".concat(e.relativePath,"/add-tax-lots"),element:a.createElement(eIe,{accounts:$.importModal.accounts,accountId:$.importModal.accountId,onAccountChange:$.importModal.setAccountId,holdings:$.importModal.holdings,onParsed:$.importModal.onParsed,onFinalizeUnmatched:$.importModal.onFinalizeUnmatched,onClose:()=>{$.importModal.setAccountId(void 0),p(e.path)},isImporting:$.importModal.isImporting})})))),O&&a.createElement(a.Suspense,{fallback:null},a.createElement(pRe,{onFinish:()=>(0,Ge.u4)(Ye.Vi.AdvancedWalkthroughCompleted),onDismiss:()=>(0,Ge.u4)(Ye.Vi.AdvancedWalkthroughSkipped),onClose:P})))},hRe=()=>a.createElement(JY.d,{"data-external-id":"allocation-breakdown-title-adornment",content:"See your portfolio's true asset distribution by breaking funds and ETFs down into their underlying holdings. Manually classify holdings to fine-tune the view.",maxWidth:240,place:"right"},a.createElement(ake,{type:"button","aria-label":"More information"},a.createElement(fe.ucZ,{size:"sm"})));var vRe,fRe,ERe,yRe,bRe,xRe;const wRe=e=>{let t=e.columnNames;return a.createElement(NRe,{"data-external-id":"header"},(0,jd.A)((e=>a.createElement(TRe,{key:e},e)),t))},CRe=()=>a.createElement(_Re,{"data-external-id":"sub-header-loading"},a.createElement(Rr.s,null,a.createElement("rect",{x:"24",y:"12",rx:"5",ry:"5",width:"8%",height:"16"}))),ARe=()=>a.createElement(RRe,{"data-external-id":"holding-loading"},a.createElement(Rr.s,null,a.createElement("circle",{cx:"34",cy:"28",r:"12"}),a.createElement("rect",{x:"calc(7% - 24px)",y:"20",rx:"5",ry:"5",width:"12%",height:"16"}),a.createElement("rect",{x:"calc(45% - 24px)",y:"17",rx:"5",ry:"5",width:"8%",height:"16"}),a.createElement("rect",{x:"calc(59% - 24px)",y:"17",rx:"5",ry:"5",width:"8%",height:"16"}),a.createElement("rect",{x:"calc(72% - 24px)",y:"17",rx:"5",ry:"5",width:"8%",height:"16"}),a.createElement("rect",{x:"calc(92% - 24px)",y:"17",rx:"5",ry:"5",width:"9%",height:"16"}))),IRe=()=>a.createElement(DRe,{"data-external-id":"footer-loading"},a.createElement(Rr.s,null,a.createElement("rect",{x:"calc(52% - 24px)",y:"27",rx:"5",ry:"5",width:"8%",height:"16"}),a.createElement("rect",{x:"calc(54% - 24px)",y:"52",rx:"5",ry:"5",width:"6%",height:"16"}),a.createElement("rect",{x:"calc(72% - 24px)",y:"27",rx:"5",ry:"5",width:"8%",height:"16"}),a.createElement("rect",{x:"calc(74% - 24px)",y:"52",rx:"5",ry:"5",width:"6%",height:"16"}),a.createElement("rect",{x:"calc(90% - 24px)",y:"27",rx:"5",ry:"5",width:"10%",height:"16"}),a.createElement("rect",{x:"calc(94% - 24px)",y:"52",rx:"5",ry:"5",width:"6%",height:"16"}))),kRe=e=>{let t=e.columnNames;return a.createElement(a.Fragment,null,a.createElement(SRe,null,a.createElement(wRe,{columnNames:t}),a.createElement(CRe,null),(0,db.A)(0,3).map((e=>a.createElement(ARe,{key:e}))),a.createElement(CRe,null),(0,db.A)(0,5).map((e=>a.createElement(ARe,{key:e}))),a.createElement(CRe,null),(0,db.A)(0,2).map((e=>a.createElement(ARe,{key:e})))),a.createElement(IRe,null))},SRe=$d.s.div(vRe||(vRe=(0,wc.A)(["overflow-hidden rounded-md bg-background-primary"]))),NRe=$d.s.div(fRe||(fRe=(0,wc.A)(["flex size-full flex-1 items-center justify-between"]))),TRe=$d.s.span(ERe||(ERe=(0,wc.A)(["\n  inline-block px-[2.3%] py-default text-left text-sm font-medium text-content-secondary\n  first:basis-[39%] f
1irst:pl-xl\n  last:basis-[17%] last:pr-xl last:text-right\n"]))),_Re=$d.s.div(yRe||(yRe=(0,wc.A)(["h-10 w-full bg-background-secondary"]))),DRe=$d.s.div(bRe||(bRe=(0,wc.A)(["my-6.25 h-22.5 w-full bg-background-secondary"]))),RRe=$d.s.div(xRe||(xRe=(0,wc.A)(["h-14 w-full not-last:border-b not-last:border-divider-primary"]))),MRe=e=>{let t=e.value,n=e.label,l=e.color,r=e.formatter,o=void 0===r?String:r;return a.createElement("div",{"data-external-id":"investments-table-footer-cell",className:"flex flex-col items-end font-medium"},a.createElement(JCe.Q,{className:"text-lg",color:l,value:t},o(t)),a.createElement(xt.v,{color:"textLight",size:"small",className:"mt-3xs block"},n))},LRe="\n  [--holdings-col-price:--spacing(32.5)]\n  [--holdings-col-quantity:--spacing(35)]\n  [--holdings-col-value:--spacing(37.5)]\n  [--holdings-col-weight:--spacing(30)]\n  [--holdings-col-return:--spacing(36)]\n  [--holdings-col-actions:--spacing(18)]\n";var ORe,PRe,BRe,zRe,FRe;const GRe=e=>{let t=e.id,n=e.desc;return{id:t,desc:null!==n&&void 0!==n&&n}},YRe=e=>{let t=e.holdings,n=e.groupBy,l=e.selectedAggregateHoldingInfos,r=e.meta,i=e.isLoading,s=e.selectedSecurityId,c=e.onClickHolding,d=e.onClickAddHolding,m=e.onClickHoldingChevron,p=e.onHoldingDrawerClose,g=e.showSelector,h=void 0===g||g,v=e.noHoldingsEmptyStateTitle,f=e.noHoldingsEmptyStateSubtitle,E=e.noHoldingsEmptyStateButtonText,y=e.timeFrameText,b=e.sortBy,x=e.setSortBy,w=e.onStickyChange,C=e.hideGroupRows,A=void 0!==C&&C,I=e.showFooter,k=void 0===I||I;const S=(0,u.useTheme)().color,T=(0,a.useContext)(ri.z).scrollRef,_=(0,a.useRef)(null);(0,a.useEffect)((()=>{var e;const t=_.current,n=null!==(e=null===T||void 0===T?void 0:T.current)&&void 0!==e?e:null;if(!t||!w)return;const a=new IntersectionObserver((e=>{var t,n;let a=(0,o.A)(e,1)[0];const l=null!==(t=null===(n=a.rootBounds)||void 0===n?void 0:n.top)&&void 0!==t?t:0,r=!a.isIntersecting&&a.boundingClientRect.top<l;w(r)}),{threshold:0,root:n});return a.observe(t),()=>{a.disconnect(),w(!1)}}),[T,w]);const D=(0,Pc.e)(!1),R=(0,o.A)(D,2),M=R[0],L=R[1].toggle,O=l_e("investments-holdings-collapsed",n),P=(0,o.A)(O,2),z=P[0],F=P[1].toggle,G=(0,a.useRef)(z);G.current=z;const Y=(0,a.useMemo)((()=>t?t.find((e=>e.id===s)):void 0),[t,s]),U=fTe({sortBy:b,toColumnSort:GRe,onChange:x}),V=U.sorting,W=U.onSortingChange,j=(0,a.useMemo)((()=>{const e=fDe(((e,t)=>{const a=e.groupingValue,l=t.groupingValue;if(n===lAe.O.Account){var r,o,i,s,c,d,u,m,p,g,h,v;return(null!==(r=null===(o=e.subRows[0])||void 0===o||null===(i=o.original)||void 0===i||null===(s=i.holdings)||void 0===s||null===(c=s[0])||void 0===c||null===(d=c.account)||void 0===d?void 0:d.order)&&void 0!==r?r:Number.MAX_SAFE_INTEGER)-(null!==(u=null===(m=t.subRows[0])||void 0===m||null===(p=m.original)||void 0===p||null===(g=p.holdings)||void 0===g||null===(h=g[0])||void 0===h||null===(v=h.account)||void 0===v?void 0:v.order)&&void 0!==u?u:Number.MAX_SAFE_INTEGER)}return n===lAe.O.Institution||n===lAe.O.AssetClass||n===lAe.O.Security||n===lAe.O.Holding?a.localeCompare(l):cAe.xR.indexOf(a)-cAe.xR.indexOf(l)}))(V);return[{id:"type",accessorFn:e=>{var t;let n=e.security,a=e.holdings;return null!==(t=(0,o.A)(a,1)[0].typeDisplay)&&void 0!==t?t:null===n||void 0===n?void 0:n.typeDisplay}},{id:"account",accessorFn:e=>{var t;let n=e.holdings;return null===(t=(0,o.A)(n,1)[0].account)||void 0===t?void 0:t.displayName}},{id:"institution",accessorFn:e=>{var t,n;let a=e.holdings;return(null===(t=(0,o.A)(a,1)[0].account)||void 0===t||null===(n=t.institution)||void 0===n?void 0:n.name)||"Manual Holdings"}},{id:"assetClass",accessorFn:e=>(0,cAe.AC)(e)},{id:"holding",accessorFn:e=>{var t,n;let a=e.security,l=e.holdings;const r=(0,o.A)(l,1)[0],i=null!==(t=null===a||void 0===a?void 0:a.name)&&void 0!==t?t:r.name,s=null!==(n=null===a||void 0===a?void 0:a.ticker)&&void 0!==n?n:r.ticker;return"".concat(i).concat(s?" (".concat(s,")"):"")}},{id:"security",header:"Security",accessorFn:e=>{var t,n;let a=e.security,l=e.holdings;const r=(0,o.A)(l,1)[0],i=null!==(t=null===a||void 0===a?void 0:a.name)&&void 0!==t?t:r.name,s=null!==(n=null===a||void 0===a?void 0:a.ticker)&&void 0!==n?n:r.ticker;
1return"".concat(i).concat(s?" (".concat(s,")"):"")},sortingFn:e(((e,t)=>{const n=e.getValue("security"),a=t.getValue("security");return n.localeCompare(a)})),sortDescFirst:!0,cell:e=>{var t,n;let r=e.getValue,i=e.row;const s=r();if(i.getIsGrouped()){var d,u,m,p,g,v,f,E;const e=null===(d=i.subRows)||void 0===d||null===(u=d[0])||void 0===u?void 0:u.original,t=null!==(m=null!==(p=null===e||void 0===e||null===(g=e.security)||void 0===g?void 0:g.ticker)&&void 0!==p?p:null===e||void 0===e||null===(v=e.holdings)||void 0===v||null===(f=v[0])||void 0===f?void 0:f.ticker)&&void 0!==m?m:s,n=G.current.has(String(null!==(E=i.groupingValue)&&void 0!==E?E:""));return t?a.createElement(jRe,null,a.createElement(B.L,{icon:"chevron-down",color:"content.secondary",size:"xsmall",className:(0,q.cn)("transition-transform duration-150",{"-rotate-90":n}),"aria-label":n?"Expand group":"Collapse group",onClick:e=>{var t;e.stopPropagation(),F(String(null!==(t=i.groupingValue)&&void 0!==t?t:""))}}),a.createElement(xt.v,null,t)):null}const y=null!==(t=i.original.security)&&void 0!==t?t:{},b=y.ticker,x=y.name,w=(0,o.A)(i.original.holdings,1)[0],C=w.ticker,A=w.name,I=x||A,k=b||C||I;return s?a.createElement("span",{style:{display:"flex"}},a.createElement(D_e,{primaryText:k,secondaryText:I!==k?I:void 0,color:null===(n=l.find((e=>{var t;return e.id===(null===(t=i.original)||void 0===t?void 0:t.id)})))||void 0===n?void 0:n.color,disabled:!URe(i.original),onClick:()=>{c&&URe(i.original)&&i.original.security&&c(i.original.security)},canClick:!!c&&URe(i.original),showDot:h})):null},footer:()=>a.createElement(xt.v,{weight:"medium"},"Total"),aggregatedCell:e=>{var t;let n=e.row,l=e.table;const r=(0,o.A)(l.getState().grouping,1)[0],i=n.getValue(r),s=G.current.has(String(null!==(t=n.groupingValue)&&void 0!==t?t:""));return a.createElement(jRe,null,a.createElement(B.L,{icon:"chevron-down",color:"content.secondary",size:"xsmall",className:(0,q.cn)("transition-transform duration-150",{"-rotate-90":s}),"aria-label":s?"Expand group":"Collapse group",onClick:e=>{var t;e.stopPropagation(),F(String(null!==(t=n.groupingValue)&&void 0!==t?t:""))}}),a.createElement(HRe,null,i))}},{header:"Price",accessorFn:e=>{let t=e.security,n=e.holdings;return(0,ZTe.IX)(n[0],null!==t&&void 0!==t?t:null)},sortingFn:e(((e,t)=>{var n,a;return(null!==(n=e.getValue("Price").price)&&void 0!==n?n:0)-(null!==(a=t.getValue("Price").price)&&void 0!==a?a:0)})),sortDescFirst:!0,cell:e=>{const t=(0,e.getValue)(),n=t.price,l=t.priceUpdatedAt,r=l?N.c9.fromISO(l).toRelative():null;return r?a.createElement(JY.d,{content:"Price last updated ".concat(r),place:"top",effect:"solid",hyphens:!1},a.createElement(xt.v,fl.zs,(0,rl.vv)(n))):a.createElement(xt.v,fl.zs,(0,rl.vv)(n))}},{header:"Quantity",accessorFn:e=>{var t,n,a;let l=e.quantity,r=e.costBasis,o=e.holdings,i=e.security;return{quantity:(0,pke.VZ)(l,null===i||void 0===i?void 0:i.type),costBasis:r,ticker:null!==(t=null!==(n=null===i||void 0===i?void 0:i.ticker)&&void 0!==n?n:null===(a=o[0])||void 0===a?void 0:a.ticker)&&void 0!==t?t:null}},sortingFn:e(((e,t)=>(0,cAe.su)(["original","quantity"],e,t))),sortDescFirst:!0,cell:e=>{const t=(0,e.getValue)();return null!==t&&void 0!==t&&t.costBasis&&null!==t&&void 0!==t&&t.ticker?a.createElement(JY.d,{content:"Your total cost for ".concat(t.ticker," is ").concat((0,rl.vv)(t.costBasis)),place:"top",effect:"solid",hyphens:!1},a.createElement(xt.v,fl.TN,null===t||void 0===t?void 0:t.quantity)):a.createElement(xt.v,fl.TN,null===t||void 0===t?void 0:t.quantity)}},{header:"Value",accessorFn:e=>{let t=e.totalValue;return(0,rl.vv)(t)},sortingFn:e(((e,t)=>(0,cAe.su)(["original","totalValue"],e,t))),sortDescFirst:!0,cell:e=>{let t=e.getValue;return a.createElement(xt.v,fl.zs,t())},footer:()=>{var e;return a.createElement(MRe,{value:null!==(e=null===r||void 0===r?void 0:r.totalValue)&&void 0!==e?e:0,formatter:rl.vv,color:S.text,label:""})}},{header:"Weight",accessorFn:e=>e.totalValue,sortingFn:e(((e,t)=>{var n,a;return(null!==(n=e.getValue("Weight"))&&void 0!==n?n:0)-(null!==(a=t.getValue("Weight"))&&void 0!==a?a:0)}
1)),sortDescFirst:!0,cell:e=>{const t=(0,e.getValue)(),n=null!==r&&void 0!==r&&r.totalValue&&r.totalValue>0&&(0,Tr.A)(t)?t/r.totalValue*100:null;return a.createElement(xt.v,fl.TN,(0,Tr.A)(n)?"".concat(n.toFixed(2),"%"):"-")},aggregatedCell:()=>null,footer:()=>{const e=(null===r||void 0===r?void 0:r.totalValue)&&r.totalValue>0;return a.createElement("div",{className:"flex justify-end font-book"},a.createElement(xt.v,fl.zs,e?"100.00%":"N/A"))}},{header:y,sortingFn:e(((e,t)=>(0,cAe.su)(["original","securityPriceChangePercent"],e,t))),accessorFn:e=>{let t=e.securityPriceChangePercent;return null!==t&&void 0!==t?t:null},cell:e=>{let t=e.row;if(t.getIsGrouped())return null;const n=t.original,l=n.securityPriceChangeDollars,r=n.securityPriceChangePercent;return(0,Tr.A)(l)&&M||(0,Tr.A)(r)&&!M?a.createElement(KRe,{onClick:L},M?a.createElement(Y3.g,{value:l,formatter:rl.vv}):a.createElement(V3,Object.assign({returnPercent:null!==r&&void 0!==r?r:null},fl.TN))):"-"},sortDescFirst:!0,footer:()=>{var e;const t=null!==(e=null===r||void 0===r?void 0:r.historicalChart)&&void 0!==e?e:[],n=(0,Sc.A)(t),l=null===n||void 0===n?void 0:n.returnPercent;return(0,Tr.A)(l)?a.createElement(qRe,null,a.createElement(V3,Object.assign({returnPercent:l},fl.TN))):a.createElement("div",{className:"flex justify-end"},a.createElement(xt.v,null,"-"))}},{id:"actions",enableSorting:!1,accessorFn:e=>e.id,cell:e=>{const t=(0,e.getValue)();return t?a.createElement(mke.h,{onClick:()=>null===m||void 0===m?void 0:m(t)}):null}}]}),[n,c,r,l,S,M,m,y,L,h,V,F]),H=(0,a.useMemo)((()=>(0,cAe.fS)(t,n)),[t,n]),K=(0,jd.A)((e=>{let t=e.header;return"string"===typeof t?t:void 0}),j).filter((e=>!(0,BY.A)(e))),$=(0,a.useMemo)((()=>({type:!1,account:!1,institution:!1,assetClass:!1,holding:!1})),[]),Z=(0,a.useMemo)((()=>A?[]:[n]),[A,n]),J=(0,a.useMemo)((()=>({grouping:Z,sorting:V,columnVisibility:$})),[$,Z,V]),X=(0,a.useMemo)((()=>({columns:j,data:H,empty:{title:v,subtitle:f,button:{title:E,onClick:d}},state:J,onSortingChange:W})),[j,E,f,v,d,W,J,H]);return a.createElement(a.Fragment,null,a.createElement("div",{ref:_}),i?a.createElement(kRe,{columnNames:K}):a.createElement(WRe,Object.assign({},X,{className:(0,q.cn)(LRe,!h&&"no-selector",!k&&"mb-0"),isLoading:i,collapsedGroupIds:z,onGroupRowClick:F,showFooter:k})),!!s&&a.createElement(QIe,{holdingAggregate:Y,onClose:p}))},URe=e=>{var t;return(0,Tr.A)(null===e||void 0===e?void 0:e.security)&&VRe(e)&&"cryptocurrency"!==(null===e||void 0===e||null===(t=e.security)||void 0===t?void 0:t.type)},VRe=e=>(0,Tr.A)(null===e||void 0===e?void 0:e.security)&&(0,c.A)(null===e||void 0===e?void 0:e.securityPriceChangePercent),WRe=(0,$d.s)(Jo.k1)(ORe||(ORe=(0,wc.A)(["\n  [&_tbody_tr_td:first-child]:pl-lg\n  [&_tbody_tr_td:first-child[data-mds=table-empty-cell]]:pl-0\n  [&_tbody_tr_td:nth-child(2)]:w-(--holdings-col-price)\n  [&_tbody_tr_td:nth-child(3)]:w-(--holdings-col-quantity)\n  [&_tbody_tr_td:nth-child(4)]:w-(--holdings-col-value)\n  [&_tbody_tr_td:nth-child(5)]:w-(--holdings-col-weight)\n  [&_tbody_tr_td:nth-child(6)]:w-(--holdings-col-return)\n  [&_tbody_tr_td:nth-child(7)]:w-(--holdings-col-actions) [&_tbody_tr_td:nth-child(7)]:pl-sm\n  [&_tbody_tr[data-is-group-row]_td]:h-10 [&_tbody_tr[data-is-group-row]_td]:py-0\n  [&_tbody_tr[data-is-group-row]_td:first-child]:pl-sm\n  [&_tbody_tr[role=row]_td[role=cell]]:border-b\n  [&_tbody_tr[role=row]_td[role=cell]]:border-divider-primary\n  [&_tbody_tr[role=row]_td[role=cell]]:pr-lg\n  [&_tbody_tr[role=row]_td[role=cell]:last-child]:pr-xl\n  [&_tbody_tr[role=row]:last-child_td[role=cell]]:border-b-0\n  [&_tfoot_tr_td:first-child]:pl-lg\n  [&_tfoot_tr_td:last-child]:pr-xl\n  [&_tfoot_tr_td:nth-child(7)]:w-(--holdings-col-actions) [&_tfoot_tr_td:nth-child(7)]:pl-sm\n  [&_thead_th]:sticky [&_thead_th]:top-0 [&_thead_th]:z-1 [&_thead_th]:border-b\n  [&_thead_th]:border-divider-primary [&_thead_th]:bg-background-primary\n  [&_thead_th:last-child]:pr-xl\n  [&_thead_th:nth-child(2)]:w-(--holdings-col-price)\n  [&_thead_th:nth-child(3)]:w-(--holdings-col-quantity)\n  [&_thead_th:nth-child(4)]:w-(--holdings-col-value)\n  [&_thead_th:nth-child(5)]:w-(--holdings-col-weight)\n  [&_thead_th:nth-child(6)]:w-(--holdings-col-return)\n  [&_thead_th:nth-child(7)]:w-(--holdings-col-actions) [&_thead_th:nth-child(7)]:pl-sm\n  [&_thead_tr]:select-none\n  [&.no-selector_tbody_tr[data-is-group-row
1]_td:first-child]:pl-sm\n"]))),jRe=$d.s.div(PRe||(PRe=(0,wc.A)(["relative -ml-2xs flex items-center gap-xs"]))),HRe=$d.s.div(BRe||(BRe=(0,wc.A)(["absolute left-9 max-w-175 truncate"]))),KRe=$d.s.div(zRe||(zRe=(0,wc.A)(["-mr-lg flex cursor-pointer justify-end"]))),qRe=$d.s.div(FRe||(FRe=(0,wc.A)(["-mr-lg flex justify-end font-book"])));let $Re=function(e){return e.Market="market",e.Allocation="allocation",e}({});const ZRe=Object.values($Re),JRe=e=>{let t=e.activeSubTab,n=e.onSubTabChange;const l=(0,a.useCallback)((e=>n(ZRe[e])),[n]);return a.createElement(Dc.t,{"data-external-id":"holdings-sub-tab-bar",index:ZRe.indexOf(t),onChangeIndex:l},a.createElement(MA.c,null,a.createElement(RA.Q,{index:0,$background:"card"},"Market"),a.createElement(RA.Q,{index:1,$background:"card"},"Allocation")))},XRe=e=>{let t=e.activeAccountIds,n=e.allocationOption,l=e.onAllocationOptionChange,r=e.chartType,o=e.onChartTypeChange,i=e.onHiddenCategoriesChange,s=e.onQueryStateChange,c=e.tabs;const d=jSe({filename:"allocation.png",analyticsName:"allocation"}),u=d.ref,m=d.isExporting,p=d.onExport,g=(0,a.useCallback)((e=>{o(e),(0,Ge.u4)(Ye.Vi.AllocationChartTypeChanged,{chart_type:e})}),[o]),h=(()=>{const e=DSe.find((e=>e.value===n));return e?(e=>{var t,n;return e===ISe?"By security":e===kSe?"By account":"By ".concat(null!==(t=null===(n=NSe[e])||void 0===n?void 0:n.toLowerCase())&&void 0!==t?t:"type")})(e.value):"By type"})();return a.createElement(nke,{"data-external-id":"allocation-graph-pane",ref:u,title:"Portfolio allocation",titleAdornment:a.createElement(P.D_,{content:"Investments distribution across asset classes, securities, or accounts.",maxWidth:190,place:"right"},a.createElement(ake,{type:"button","aria-label":"More information"},a.createElement(sl.ZQ,{name:"info",size:14}))),tabs:c,controls:a.createElement(a.Fragment,null,a.createElement($_e.O,{title:h},DSe.map((e=>a.createElement(Ji.xm,{key:e.value,selected:n===e.value,onClick:()=>{l(e.value),(0,Ge.u4)(Ye.Vi.AllocationGroupByChanged,{group_by:e.value,source:"chart"})}},e.label)))),a.createElement(fe.AVK,{orientation:"vertical",color:"secondary",className:"mx-2xs h-default"}),a.createElement(pW,{"aria-label":"Chart type",options:_Se,value:r,onValueChange:g}),a.createElement(fe.AVK,{orientation:"vertical",color:"secondary",className:"mx-2xs h-default"}),a.createElement("div",{className:"flex"},a.createElement(wt.Xb,{onClick:p,disabled:m,"aria-label":"Download chart"},a.createElement(sl.ZQ,{name:"download",size:12}))))},a.createElement(WSe,{activeAccountIds:t,selectedOption:n,chartType:r,onHiddenCategoriesChange:i,onQueryStateChange:s}))};var QRe=n(98986),eMe=n(40049);const tMe=e=>{let t=e.element,n=e.fileName,l=e.className,r=e.type,o=e.label;const i=(0,eMe.q)({element:t,fileName:n,type:r}),s=i.isExporting,c=i.onExport;return s?a.createElement(fe.c8D,{"data-external-id":"export-element-button",size:"inherit",weight:"medium",color:"secondary",className:l},"Shared via ",(0,Mie.Q)("landing")):o?a.createElement(fe.XZZ,{"data-external-id":"export-element-button",size:"sm",icon:a.createElement(fe.UTA,null),onClick:c,className:l},o):a.createElement(fe.SO$,{"data-external-id":"export-element-button","aria-label":"Download",onClick:c,className:l},a.createElement(fe.UTA,null))};var nMe;let aMe=function(e){return e.PickLast="pickLast",e.CalculateDifference="calculateDifference",e}({});const lMe=e=>{let t=e.data,n=e.selectedAggregateHoldingInfos,l=e.selectedBenchmarks,r=e.isLoading,o=e.portfolioLineColor,i=e.portfolioLabel,s=e.showMetricsHeader,c=void 0!==s&&s,d=e.metricsTitle,m=e.showMetricsTitleOnly,p=void 0!==m&&m,g=e.formatYAxis,h=e.exportFilePrefix,v=e.showExcludedFromPortfolioIndicator,f=void 0===v||v,E=e.metricSummaryCalculationMode,y=void 0===E?aMe.CalculateDifference:E,b=e.yAxisProps,x=e.hideCardStyles,w=void 0!==x&&x,C=e.hideHeader,A=void 0!==C&&C;const I=JSON.stringify(t),k=(0,a.useMemo)((()=>t),[I]),S=(0,u.useTheme)(),N=l.concat(n),T=N.map((e=>({lineColor:e.color}))),_=N.map((e=>e.dataKey)),D=(0,a.useRef)(null),R=(0,a.useMemo)((()=>0===k.length?{totalChange:0,percentChange:0}:y===aMe.PickLast?iMe(k):sMe(k)),[k,y]),M=R.totalChange,L=R.percentChange,O=M>0,P=M<0;return a.createElement("div",{"data-external-id":"investments-performance-graph",ref:D,className:(0,q.cn)("bg-background-primary",!w&&"mb-gutter rounded-md shadow-card")},!A&&a.createElement("div",{className:"flex w-full flex-col border-b border-divider-primary px-xl py-xs"},c?a.createElement(a.Fragment,null,a.createElement("div",{className:"mb-2xs flex w-full items-center justify-between"},a.createElement(RV.W,null,d),a.createElement(tMe,{element:D.current,fileName:"".concat(h,"-").concat((0,Ba.Fv)(new Date),".png"),type:"Investment Performance"})),!p&&a.createElement("div",{className:"mb-sm flex items-center gap-default"},a.createElement(xt.v,{size:"xxlarge",weight:"medium",color:oMe(M),className:"leading-none"},O?"+":"",(0,rl.vv)(M)),a.createElement("div",{className:(0,q.cn)("flex items-center gap-2xs leading-none",rMe(M))},a.createElement(sl.ZQ,{name:O?"arrow-up":P?"arrow-down":"minus",size:16}),a.createElement(xt.v,{size:"large",weight:"medium"},Math.abs(L).toFixed(2),"%"))),a.createElement("div",{className:"flex w-full items-center justify-start"},a.createElement(cMe,{color:o}),a.createElement(dMe,null,i),N.map((e=>a.createElement(a.Fragment,{key:e.dataKey+e.isBenchmark},a.createElement(cMe,{color:e.color}),a.createElement(dMe,null,(0,lDe.Ev)(e))))),f&&a.createElement(__e,{tooltipText:"Holdings with this icon are not included in your portfolio"}))):a.createElement("div",{className:"flex w-full items-center justify-between"},a.createElement("div",{className:"flex items-center justify-start"},a.createElement(cMe,{color:o}),a.createElement(dMe,null,i),N.map((e=>a.createElement(a.Fragment,{key:e.dataKey+e.isBenchmark},a.createElement(cMe,{color:e.color}),a.createElement(dMe,null,(0,lDe.Ev)(e))))),f&&a.createElement(__e,{tooltipText:"Holdings with this icon are not included in your portfolio",extraNode:a.createElement(dMe,null,"Holding not included")})),a.createElement("div",{className:"flex"},a.createElement(tMe,{element:D.current,fileName:"".concat(h,"-").concat((0,Ba.Fv)(new Date),".png"),type:"Investment Performance"})))),a.createElement("div",{className:"my-default w-full px-xl"},a.createElement(Do.rT,{height:373,xDataKey:"date",yDataKeys:[..._,"portfolioReturn"],lineOptions:[...T,{lineColor:o}],formatXAxis:Ba.SR,formatYAxis:g,isAnimationActive:!0,isLoadingNewData:r,data:k,yAxisProps:null!==b&&void 0!==b?b:{width:"auto"},referenceLine:a.createElement(eb.e_,{y:0,position:"start",stroke:vt.Ee.color.chart.fill.gray({theme:S}
1)}),tooltipComponent:e=>{const t=(0,lDe.wF)(N,k,e,i);return t?a.createElement(QRe.K,{active:e.active,header:t.header,data:t.data,formatter:g}):null}})))},rMe=e=>e>0?"text-content-success":e<0?"text-content-danger":"text-content-primary",oMe=e=>e>0?"content.success":e<0?"content.danger":"content.primary",iMe=e=>{var t,n,a,l;return{totalChange:Number(null!==(t=null===(n=(0,Sc.A)(e))||void 0===n?void 0:n.portfolioReturn)&&void 0!==t?t:0),percentChange:Number(null!==(a=null===(l=(0,Sc.A)(e))||void 0===l?void 0:l.portfolioReturnPercent)&&void 0!==a?a:0)}},sMe=e=>{var t,n,a,l;const r=Number(null!==(t=null===(n=(0,d5.A)(e))||void 0===n?void 0:n.portfolioReturn)&&void 0!==t?t:0),o=Number(null!==(a=null===(l=(0,Sc.A)(e))||void 0===l?void 0:l.portfolioReturn)&&void 0!==a?a:0)-r;return{totalChange:o,percentChange:0!==r?o/Math.abs(r)*100:0}},cMe=e=>{let t=e.color;return a.createElement("div",{"data-external-id":"legend-color-dot",className:"size-2 shrink-0 rounded-round",style:{backgroundColor:t}})},dMe=$d.s.span(nMe||(nMe=(0,wc.A)(["mr-default ml-xs font-medium"])));let uMe=function(e){return e.Portfolio="portfolio",e.Benchmark="benchmark",e}({});const mMe=e=>{let t=e.title,n=e.onClick,l=e.dateRangeReturn,r=e.oneDayChangePercent,o=e.checked,i=e.timeFrameText;const s=e.variant===uMe.Benchmark;return a.createElement("div",{"data-external-id":"investments-benchmark-header-card",onClick:s?n:void 0,role:s?"button":void 0,tabIndex:s?0:void 0,onKeyDown:s?e=>{"Enter"!==e.key&&" "!==e.key||(e.preventDefault(),n())}:void 0,className:(0,q.cn)("\n          flex min-w-0 flex-1 flex-col gap-default border-r border-divider-secondary px-xl\n          pt-lg pb-xl transition-colors\n          last:border-r-0\n          md:min-w-35\n        ",s?"cursor-pointer hover:bg-background-primary-hover":"cursor-default")},a.createElement("div",{className:"flex items-center gap-sm"},s&&a.createElement(hMe,{checked:o}),a.createElement("span",{className:"truncate text-sm font-medium text-content-primary md:text-lg"},t)),a.createElement("div",{className:"flex flex-col items-start gap-xs md:flex-row md:items-center md:gap-xl"},a.createElement("div",{className:"flex shrink-0 flex-col gap-2xs"},a.createElement("span",{className:"text-sm font-medium text-content-secondary"},i),a.createElement("span",{className:"text-lg font-medium text-content-primary"},pMe(l),"%")),a.createElement("div",{className:"m-0 hidden h-10 w-px shrink-0 bg-divider-secondary md:block"}),a.createElement("div",{className:"flex shrink-0 flex-col gap-2xs"},a.createElement("span",{className:"text-sm font-medium text-content-secondary"},"Today"),a.createElement("span",{className:"text-lg font-medium text-content-primary"},gMe(r)))))},pMe=e=>e.toLocaleString(void 0,{minimumFractionDigits:2,maximumFractionDigits:2}),gMe=e=>(0,Ba.iY)(N.c9.local())&&(0,Tr.A)(e)?"".concat(pMe(e),"%"):"--",hMe=e=>{let t=e.checked;return a.createElement("span",{"data-external-id":"radio-indicator",className:(0,q.cn)("flex size-4 shrink-0 items-center justify-center rounded-round border",t?"border-border-brand bg-background-brand":"border-border-primary bg-transparent")},t&&a.createElement("span",{className:"size-2 rounded-round bg-(--content-white)"}))},vMe=()=>a.createElement(a.Fragment,null,a.createElement(fMe,null),a.createElement(fMe,null),a.createElement(fMe,null),a.createElement(fMe,null)),fMe=()=>a.createElement("div",{"data-external-id":"card-loading",className:"\n      flex flex-1 flex-col gap-default border-r border-divider-secondary px-xl pt-lg\n      pb-xl\n      last:border-r-0\n      sm:min-w-35\n    "},a.createElement(M.Al,{$width:"114px",$height:"18px"}),a.createElement("div",{className:"flex items-center gap-xl"},a.createElement("div",{className:"flex shrink-0 flex-col gap-xs"},a.createElement(M.Al,{$width:"88px",$height:"18px"}),a.createElement(M.Al,{$width:"56px",$height:"18px"})),a.createElement("div",{className:"h-10 w-px shrink-0 bg-divider-secondary"}),a.createElement("div",{className:"flex shrink-0 flex-col gap-xs"},a.createElement(M.Al,{$width:"40px",$height:"18px"}),a.createElement(M.Al,{$width:"56px",$height:"18px"}))));var EMe,yMe=n(39588);const bMe=e=>{let t=e.benchmarkData,n=e.portfolioData,l=e.activeBenchmarkIndex,r=e.setActiveBenchmark,o=e.timeFrameText,i=e.isLoading;const s=(0,yMe.Dk)(t);return a.createElement(xMe,{"data-external-id":"investments-holdings-benchmarks-header"},i?a.createElement(vMe,null):a.createElement(a.Fragment,null,a.createElement(mMe,{title:"Your Portfolio",dateRangeReturn:n.dateRangeReturn,oneDayChangePercent:n.oneDayReturn,checked:!0,timeFrameText:o,onClick:RQ.l,variant:uMe.Portfolio}),s.map(((e,t)=>{let n=e.name,i=e.dateRangeReturn,s=e.oneDayChangePercent,c=e.security;return a.createElement(mMe,{key:n,title:n,dateRangeReturn:i,oneDayChangePercent:s,checked:t===l,timeFrameText:o,onClick:()=>{t===l?r(null,-1):r(c,t)},variant:uMe.Benchmark})}))))},xMe=$d.s.div(EMe||(EMe=(0,wc.A)(["\n  flex items-center overflow-x-auto rounded-default border border-divider-secondary\n  [scrollbar-width:none]\n  [&::-webkit-scrollbar]:hidden\n"]))),wMe=e=>{var t;let n=e.useMockData,l=e.marketShortcutTitle,r=e.onMarketShortcutChange,o=e.holdingsData,i=e.isLoadingHoldingsData,s=e.selectedAggregateHoldingInfos,u=e.selectedBenchmarks,m=e.portfolioColor,p=e.selectBenchmarkHolding,g=e.activeBenchmarkIndex,h=e.setActiveBenchmarkIndex,v=e.onBenchmarkSelect,f=e.onQueryStateChange,E=e.tabs;const y=jSe({filename:()=>"performance-".concat((0,Ba.Fv)(new Date),".png"),analyticsName:"Investment Performance"}),b=y.ref,x=y.isExporting,w=y.onExport,C=(0,d.d4)(gG.pk),A=(0,a.useMemo)((()=>{const e=zCe.find((e=>e.title===l));return FCe(null!==e&&void 0!==e?e:zCe[2])}),[l]),I=(0,a.useMemo)((()=>{var e;return null!==(e=null===o||void 0===o?void 0:o.portfolio.performance.historicalChart)&&void 0!==e?e:[]}),[null===o||void 0===o?void 0:o.portfolio.performance.historicalChart]),k=(0,a.useMemo)((()=>{var e;return null!==(e=null===o||void 0===o?void 0:o.portfolio.performance.benchmarks)&&void 0!==e?e:[]}),[null===o||void 0===o?void 0:o.portfolio.performance.benchmarks]),S=(0,a.useMemo)((()=>k.map((e=>{var t,n,a,l;let r=e.security,o=e.historicalChart;return{name:null!==(t=(0,yMe.Lg)(r.ticker))&&void 0!==t?t:r.name,dateRangeReturn:null!==(n=null===(a=(0,Sc.A)(o))||void 0===a?void 0:a.returnPercent)&&void 0!==n?n:0,oneDayChangePercent:r.oneDayChangePercent,security:{id:r.id,ticker:null!==(l=r.ticker)&&void 0!==l?l:null,name:r.name}}}))),[k]),N=(0,a.useMemo)((()=>{var e,t,n;return{dateRangeReturn:null!==(e=null===(t=(0,Sc.A)(I))||void 0===t?void 0:t.returnPercent)&&void 0!==e?e:0,oneDayReturn:null!==(n=null===o||void 0===o?void 0:o.portfolio.performance.oneDayChangePercent)&&void 0!==n?n:0}}),[I,o]),T=u.concat(s).some((e=>{let t=e.id;return!parseInt(t)})),_=C||T||!!n,D=(0,et.I)(j_e,{variables:{input:{securityIds:u.concat(s).map((e=>e.id)).filter((e=>
1parseInt(e))),startDate:A.startDate,endDate:A.endDate}},skip:_}),R=D.data,M=D.isNetworkRequestInFlight,L=D.isLoadingInitialData,O=D.error,B=D.refetch;(0,a.useEffect)((()=>{_?null===f||void 0===f||f(void 0):null===f||void 0===f||f({error:O,refetch:B})}),[_,O,B,f]),(0,a.useEffect)((()=>()=>null===f||void 0===f?void 0:f(void 0)),[f]);const z=null!==(t=null===R||void 0===R?void 0:R.securityHistoricalPerformance)&&void 0!==t?t:[],F=(0,lDe.fi)(I,z,k),G=(0,a.useCallback)(((e,t)=>{h(t),p(e)}),[p,h]);return(0,a.useEffect)((()=>{if(k.length>0&&g<0){const t=(0,yMe.Gl)(k);if((0,c.A)(t)){const n=null===t||void 0===t?void 0:t.security;var e;if(n)G({id:n.id,ticker:null!==(e=n.ticker)&&void 0!==e?e:null,name:n.name},0)}}}),[k,g,G]),a.createElement(nke,{"data-external-id":"market-graph-pane",ref:b,title:"Backtested performance",titleAdornment:a.createElement(P.D_,{content:"Simulated past performance of your portfolio based on current holdings.",maxWidth:190,place:"right"},a.createElement(ake,{type:"button","aria-label":"More information"},a.createElement(sl.ZQ,{name:"info",size:14}))),tabs:E,controls:a.createElement(a.Fragment,null,a.createElement($_e.O,{title:iDe(l)},cDe.map((e=>a.createElement(Ji.xm,{key:e.value,selected:l===e.value,onClick:()=>r(e.value)},e.label)))),a.createElement(wm.A,{orientation:"vertical",color:"secondary",className:"mx-2xs h-default"}),a.createElement("div",{className:"flex"},a.createElement(wt.Xb,{onClick:w,disabled:x,"aria-label":"Download chart"},a.createElement(sl.ZQ,{name:"download",size:12}))))},a.createElement("div",{className:"px-xl pt-lg pb-sm"},a.createElement(bMe,{benchmarkData:S,portfolioData:N,activeBenchmarkIndex:g,setActiveBenchmark:v,timeFrameText:iDe(l),isLoading:i})),a.createElement(lMe,{data:F,selectedAggregateHoldingInfos:s,selectedBenchmarks:u,isLoading:M||L||i,portfolioLineColor:m,portfolioLabel:"Your Portfolio",formatYAxis:e=>"".concat(e,"%"),exportFilePrefix:"performance",hideCardStyles:!0,hideHeader:!0}),F.length>0&&a.createElement("div",{className:"flex flex-wrap items-center justify-center gap-default px-xl pt-xs pb-default"},a.createElement("div",{className:"flex items-center gap-2xs"},a.createElement("div",{className:"size-2 shrink-0 rounded-round",style:{backgroundColor:m}}),a.createElement("span",{className:"text-xs font-medium text-content-secondary"},"Portfolio")),u.concat(s).map((e=>a.createElement("div",{key:e.dataKey+String(e.isBenchmark),className:"flex items-center gap-2xs"},a.createElement("div",{className:"size-2 shrink-0 rounded-round",style:{backgroundColor:e.color}}),a.createElement("span",{className:"text-xs font-medium text-content-secondary"},(0,lDe.Ev)(e)))))))},CMe=()=>{};var AMe,IMe;const kMe=Ee.lz5,SMe={[kMe.CATEGORY_GROUP]:lAe.O.AssetClass,[kMe.SECURITY_TYPE]:lAe.O.Type,[kSe]:lAe.O.Account,[ISe]:lAe.O.Security},NMe={[lAe.O.AssetClass]:kMe.CATEGORY_GROUP,[lAe.O.Type]:kMe.SECURITY_TYPE,[lAe.O.Account]:kSe,[lAe.O.Security]:ISe},TMe=(0,xZ.Z)((()=>n.e(8876).then(n.bind(n,38876)).then((e=>({default:e.InvestmentsAdvancedWalkthrough})))),"LazyLoadedAdvancedWalkthrough"),_Me=e=>{var t,n,r,i;let s=e.activeAccountIds,c=e.useMockData,d=e.marketGroupBy,u=e.setMarketGroupBy,m=e.allocationGroupBy,p=e.setAllocationGroupBy,g=e.initialMarketShortcutTitle,h=e.onMarketShortcutChange;const v=(0,l.Zp)(),f=(0,l.zy)(),E=mRe(),y=E.shouldShow,b=E.dismiss,x=f.pathname.includes(I.JZ.investments.holdings.allocation.path)?$Re.Allocation:$Re.Market,w=(0,a.useState)(void 0),C=(0,o.A)(w,2),A=C[0],k=C[1],S=(0,a.useState)(void 0),N=(0,o.A)(S,2),T=N[0],_=N[1],D=(0,a.useState)(new Set),R=(0,o.A)(D,2),M=R[0],L=R[1],O=(0,a.useState)(TSe.Pie),P=(0,o.A)(O,2),B=P[0],z=P[1],F=(0,a.useState)(-1),G=(0,o.A)(F,2),Y=G[0],V=G[1],W=(0,a.useState)(),j=(0,o.A)(W,2),H=j[0],K=j[1],$=(0,a.useState)(),Z=(0,o.A)($,2),J=Z[0],X=Z[1],Q=lRe(),ee=Q.selectedAggregateHoldingInfos,te=Q.setSelectedAggregateHoldingInfos,ne=Q.selectedBenchmarks,ae=Q.portfolioColor,le=Q.selectBenchmarkHolding,re=Q.availableHoldingLineColors,oe=Q.setAvailableHoldingLineColors,ie=Q.selectHolding,se=(0,a.useCallback)((e=>{ie(e)}),[ie]),ce=x===$Re.Allocation,de=ce?m:d,ue=ce?p:u;(0,a.useEffect)((()=>
1{if(ce&&void 0===T){const e=NMe[m];if(e)_(e);else{const e=DSe[0].value;_(e),p(SMe[e])}}}),[]);const me=(0,a.useCallback)((e=>{if((0,Ge.u4)(Ye.Vi.HoldingsVisualizationTabChanged,{tab:e}),e===$Re.Allocation){v(I.JZ.investments.holdings.allocation.path);const e=NMe[m];if(e)_(e);else{const e=DSe[0].value;_(e),p(SMe[e])}}else v(I.JZ.investments.holdings.market.path)}),[v,m,p]),pe=(0,a.useCallback)((e=>{_(e);const t=SMe[e];t&&p(t)}),[p]),ge=ce?rAe.filter((e=>void 0!==NMe[e.value])):rAe,he=(e=>{let t=e.activeAccountIds,n=e.useMockData,l=e.groupBy,r=e.setGroupBy,i=e.initialMarketShortcutTitle;const s=(0,a.useState)(null),c=(0,o.A)(s,2),d=c[0],u=c[1],m=(0,a.useState)(null!==i&&void 0!==i?i:"3M"),p=(0,o.A)(m,2),g=p[0],h=p[1],v=(0,a.useMemo)((()=>{const e=zCe.find((e=>e.title===g));return FCe(null!==e&&void 0!==e?e:zCe[2])}),[g]),f=cRe(t,v,n),E=f.holdingsData,y=f.isLoadingHoldings,b=f.holdingsError,x=f.refetch;return{holdings:{isLoading:y,data:f.holdingAggregates,rawData:E,error:b,refetch:x},tableState:{groupBy:l,setGroupBy:r,sortBy:d,setSortBy:u},market:{shortcutTitle:g,setShortcutTitle:h}}})({activeAccountIds:s,useMockData:c,groupBy:de,setGroupBy:ue,initialMarketShortcutTitle:g}),ve=he.holdings,ye=he.tableState,be=he.market,xe=ce?J:H;(e=>{var t,n;let l=e.error,r=e.retryFn,o=e.message,i=e.description,s=e.buttonText;const c=null!==(t=null===(n=(0,a.useContext)(zq))||void 0===n?void 0:n.reportChildQueryError)&&void 0!==t?t:CMe;(0,a.useLayoutEffect)((()=>{c(l?{error:l,retryFn:r,message:o,description:i,buttonText:s}:void 0)}),[l,r,o,i,s,c])})({error:null!==(t=ve.error)&&void 0!==t?t:null===xe||void 0===xe?void 0:xe.error,retryFn:(0,a.useCallback)((async()=>(e=>{var t;const n=e.filter((e=>"object"===typeof e&&null!==e));return null!==(t=n.find((e=>void 0!==e.error&&null!==e.error)))&&void 0!==t?t:n[0]})(await Promise.all([ve.refetch,null===xe||void 0===xe?void 0:xe.refetch].map((e=>{var t;return null===e||void 0===e||null===(t=e())||void 0===t?void 0:t.catch((e=>({error:e})))}))))),[ve.refetch,null===xe||void 0===xe?void 0:xe.refetch]),description:VG.U.INVESTMENTS});const we=(0,a.useMemo)((()=>0!==M.size&&ce?ve.data.filter((e=>{var t;const n=null!==(t=e.holdings)&&void 0!==t?t:[],a=(0,o.A)(n,1)[0],l=((t,n)=>{var l,r,o;if(m===lAe.O.Type)return null!==(l=null===a||void 0===a?void 0:a.typeDisplay)&&void 0!==l?l:null===(r=e.security)||void 0===r?void 0:r.typeDisplay;if(m===lAe.O.AssetClass)return(0,cAe.AC)(e);if(m===lAe.O.Account)return null===a||void 0===a||null===(o=a.account)||void 0===o?void 0:o.displayName;const i=null===(t=e.security)||void 0===t?void 0:t.name,s=null===(n=e.security)||void 0===n?void 0:n.ticker;return i&&s?"".concat(i," (").concat(s,")"):i})();return!M.has(null!==l&&void 0!==l?l:"")})):ve.data),[ve.data,M,ce,m]),Ce=(0,a.useMemo)((()=>{var e;const t=null===(e=ve.rawData)||void 0===e?void 0:e.portfolio.performance;if(!t||0===M.size||!ce)return t;const n=(0,De.Eb)(we.map((e=>{var t;return null!==(t=e.totalValue)&&void 0!==t?t:0})));return(0,U.A)((0,U.A)({},t),{},{totalValue:n})}),[null===(n=ve.rawData)||void 0===n?void 0:n.portfolio.performance,we,M,ce]),Ae=(0,a.useCallback)((e=>{be.setShortcutTitle(e),null===h||void 0===h||h(e),(0,Ge.u4)(Ye.Vi.MarketDateRangeChanged,{date_range:e,source:"chart"})}),[be.setShortcutTitle,h]);(0,a.useEffect)((()=>{(0,Ge.u4)(Ye.Vi.HoldingsPageViewed)}),[]);const Ie=(0,a.useCallback)(((e,t)=>{V(t),le(e),(0,Ge.u4)(Ye.Vi.MarketBenchmarkSelected,{action:e?"selected":"deselected"})}),[le]);(0,a.useEffect)((()=>{var e,t;if(null===(e=ve.rawData)||void 0===e||!e.portfolio.aggregateHoldings.edges)return;const n=new Set((null!==(t=ve.rawData.portfolio.aggregateHoldings.edges)&&void 0!==t?t:[]).map((e=>{var t;return null===e||void 0===e||null===(t=e.node)||void 0===t?void 0:t.id})).filter(Boolean)),a=ee.filter((e=>{let t=e.id;return!n.has(t)}));a.length>0&&(oe([...re,...a.map((e=>e.color))]),te(ee.filter((e=>{let t=e.id;return n.has(t)}))))}),[ve.rawData,s]);const ke=P_e(),Se=ke.stickyIsVisible,Ne=ke.onStickyChange,Te=ke.scrollContainerRef,_e=ke.stickyInnerRef,Re=(0,a.useCallback)((e=>{if(ye.setGroupBy(e),(0,Ge.u4)(ce?Ye.Vi.AllocationGroupByChanged:Ye.Vi.MarketGroupByChanged,{group_by:e,source:"table"}),ce){const t=NMe[e];t&&_(t)}}),[ce,ye]),Me=a.createElement(JRe,{activeSubTab:x,onSubTabChange:me}),Le=ce?a.createElement(XRe,{activeAccountIds:s,allocationOption:null!==T&&void 0!==T?T:Ee.lz5.SECURITY_TYPE,onAllocationOptionChange:pe,chartType:B,onChartTypeChange:z,onHiddenCategoriesChange:L,onQueryStateChange:X,tabs:Me}):a.createElement(wMe,{useMockData:c,marketShortcutTitle:be.shortcutTitle,onMarketShortcutChange:Ae,holdingsData:ve.rawData,isLoadingHoldingsData:ve.isLoading,selectedAggregateHoldingInfos:ee,selectedBenchmarks:ne,portfolioColor:ae,selectBenchmarkHolding:le,activeBenchmarkIndex:Y,setActiveBenchmarkIndex:V,onBenchmarkSelect:Ie,onQueryStateChange:K,tabs:Me});return a.createElement(a.Fragment,null,a.createElement(Xhe.Ay,null,a.createElement("title",null,"Monarch | Investment Holdings")),a.createElement(lke,{summaryTiles:null,graph:Le,holdingsTable:a.createElement(ANe,{title:"Holdings",controls:a.createElement(a.Fragment,null,a.createElement($_e.O,{title:null!==(r=null===(i=ge.find((e=>e.value===ye.groupBy)))||void 0===i?void 0:i.label)&&void 0!==r?r:"Group by"},ge.map((e=>a.createElement(Ji.xm,{key:e.value,selected:ye.groupBy===e.value,onClick:()=>Re(e.value)},e.label)))),a.createElement($_e.O,{title:iDe(be.shortcutTitle)},cDe.map((e=>a.createElement(Ji.xm,{key:e.value,selected:be.shortcutTitle===e.value,onClick:()=>Ae(e.value)},e.label))))),minWidth:800,stickyHideBelowPx:900,stickyIsVisible:Se,stickyInnerRef:_e,scrollC
1ontainerRef:Te,allowOverflow:!0,totals:!ve.isLoading&&we.length>0?((e,t,n,l)=>{const r=null===(e=(0,Sc.A)(null!==(t=null===Ce||void 0===Ce?void 0:Ce.historicalChart)&&void 0!==t?t:[]))||void 0===e?void 0:e.returnPercent,o=(null!==(n=null===Ce||void 0===Ce?void 0:Ce.totalValue)&&void 0!==n?n:0)>0;return a.createElement("tbody",null,a.createElement("tr",{className:LRe},a.createElement(RMe,null,a.createElement(fe.c8D,{size:"lg",weight:"medium"},"Total")),a.createElement(RMe,{className:"w-(--holdings-col-price)"}),a.createElement(RMe,{className:"w-(--holdings-col-quantity)"}),a.createElement(RMe,{className:"w-(--holdings-col-value)"},a.createElement(fe.c8D,Object.assign({size:"lg",weight:"medium"},fl.zs),(0,rl.vv)(null!==(l=null===Ce||void 0===Ce?void 0:Ce.totalValue)&&void 0!==l?l:0))),a.createElement(RMe,{className:"w-(--holdings-col-weight)"},a.createElement("div",{className:"flex justify-end"},a.createElement(fe.c8D,Object.assign({size:"lg",weight:"medium"},fl.zs),o?"100.00%":"N/A"))),a.createElement(RMe,{className:"w-(--holdings-col-return)"},a.createElement("div",{className:"-mr-lg flex justify-end"},(0,Tr.A)(r)?a.createElement(V3,{returnPercent:r,className:(0,q.cn)(fl.TN.className,"text-lg")}):a.createElement(fe.c8D,{size:"lg",weight:"medium"},"-"))),a.createElement(RMe,{className:"w-(--holdings-col-actions) pl-sm"})))})():void 0,stickyHeader:a.createElement(xNe,null,a.createElement(DMe,{className:LRe},a.createElement("thead",null,a.createElement("tr",null,a.createElement(wNe,null,"Security"),a.createElement(wNe,{className:"w-(--holdings-col-price)"},"Price"),a.createElement(wNe,{className:"w-(--holdings-col-quantity)"},"Quantity"),a.createElement(wNe,{className:"w-(--holdings-col-value)"},"Value"),a.createElement(wNe,{className:"w-(--holdings-col-weight)"},"Weight"),a.createElement(wNe,{className:"w-(--holdings-col-return)"},sDe(be.shortcutTitle)),a.createElement(wNe,{className:"w-(--holdings-col-actions)"})))))},a.createElement(YRe,{holdings:we,groupBy:ye.groupBy,hideGroupRows:ye.groupBy===lAe.O.Security,showSelector:x===$Re.Market,selectedAggregateHoldingInfos:ee,onClickHolding:x===$Re.Market?se:void 0,meta:Ce,isLoading:ve.isLoading,selectedSecurityId:A,onClickHoldingChevron:k,onHoldingDrawerClose:()=>k(void 0),showFooter:!1,onClickAddHolding:()=>v(x===$Re.Allocation?I.JZ.investments.holdings.allocation.addHolding.path:I.JZ.investments.holdings.market.addHolding.path),timeFrameText:sDe(be.shortcutTitle),noHoldingsEmptyStateTitle:_t.P2.TITLE,noHoldingsEmptyStateSubtitle:_t.P2.SUBTITLE,noHoldingsEmptyStateButtonText:_t.P2.BUTTON_TITLE,sortBy:ye.sortBy,setSortBy:ye.setSortBy,onStickyChange:Ne}))}),a.createElement(l.BV,null,a.createElement(l.qh,{path:I.JZ.investments.holdings.addHolding.relativePath,element:a.createElement(l.C5,{to:I.JZ.investments.holdings.market.addHolding.path,replace:!0})})),[I.JZ.investments.holdings.market,I.JZ.investments.holdings.allocation].map((e=>a.createElement(XU.l,{key:e.path,path:"".concat(e.relativePath,"/add-holding")},(t=>{let n=t.close;return a.createElement(WCe.q,{onDone:n,onAddMore:()=>v("".concat(e.path,"/add-holding")),onCancel:n})})))),y&&a.createElement(a.Suspense,{fallback:null},a.createElement(TMe,{onFinish:()=>{(0,Ge.u4)(Ye.Vi.AdvancedWalkthroughCompleted),v(I.JZ.investments.advanced.path)},onDismiss:()=>(0,Ge.u4)(Ye.Vi.AdvancedWalkthroughSkipped),onClose:b})))},DMe=$d.s.table(AMe||(AMe=(0,wc.A)(["\n  w-full min-w-200 table-fixed border-spacing-0\n  [&_th:last-child]:pr-3xl\n"]))),RMe=$d.s.td(IMe||(IMe=(0,wc.A)(["bg-background-primary px-lg py-default first:pl-lg last:pr-xl"]))),MMe=lAe.O.AssetClass,LMe="investments-market-group-by",OMe="investments-allocation-group-by",PMe="investments-gnl-group-by",BMe="investments-funds-classification",zMe="investments-market-shortcut",FMe="investments-gnl-shortcut",GMe="investments-last-date-range",YMe=new Set(Object.values(lAe.O)),UMe=new Set(["1W","1M","3M","6M","YTD","1Y","5Y"]),VMe=new Set(["1W","1M","3M","6M","YTD","1Y","5Y","ALL"]),WMe=new Set(uSe.map((e=>e.value))),jMe=(e,t)=>t?"".concat(e,"-").concat(t):e,HMe=(e,t)=>{try{var n;return null!==(n=localStorage.getItem(jMe(t,e)))&&void 0!==n?n:void 0}catch(a){return}},KMe=(e,t,n)=>{try{localStorage.setItem(jMe(t,e),n)}catch(a){}},qMe=(e,t)=>{const n=HMe(e,t);
1return void 0!==n&&YMe.has(n)?n:MMe};var $Me=n(7149),ZMe=n(62847);const JMe=(0,sG.Mz)((e=>e.investments),(e=>e.activeAccountIds));var XMe;const QMe=null!==(XMe=zCe.find((e=>"3M"===e.title)))&&void 0!==XMe?XMe:zCe[0],eLe=[...zCe,{title:"ALL"}],tLe=()=>{var e;const t=(0,d.wA)(),n=(0,d.d4)(JMe),r=(e=>{const t=(0,a.useState)((()=>qMe(e,LMe))),n=(0,o.A)(t,2),l=n[0],r=n[1],i=(0,a.useCallback)((t=>{r(t),KMe(e,LMe,t)}),[e]),s=(0,a.useState)((()=>qMe(e,OMe))),c=(0,o.A)(s,2),d=c[0],u=c[1],m=(0,a.useCallback)((t=>{u(t),KMe(e,OMe,t)}),[e]),p=(0,a.useState)((()=>qMe(e,PMe))),g=(0,o.A)(p,2),h=g[0],v=g[1],f=(0,a.useCallback)((t=>{v(t),KMe(e,PMe,t)}),[e]),E=(0,a.useState)((()=>{const t=HMe(e,zMe);return void 0!==t&&UMe.has(t)?t:void 0})),y=(0,o.A)(E,2),b=y[0],x=y[1],w=(0,a.useState)((()=>{const t=HMe(e,FMe);return void 0!==t&&VMe.has(t)?t:void 0})),C=(0,o.A)(w,2),A=C[0],I=C[1],k=(0,a.useState)((()=>{const t=HMe(e,BMe);return void 0!==t&&WMe.has(t)?t:void 0})),S=(0,o.A)(k,2),N=S[0],T=S[1],_=(0,a.useCallback)((t=>{KMe(e,zMe,t),x(t)}),[e]),D=(0,a.useCallback)((t=>{KMe(e,FMe,t),I(t)}),[e]),R=(0,a.useCallback)((t=>{KMe(e,BMe,t),T(t)}),[e]),M=(0,a.useState)((()=>HMe(e,GMe)));return{marketGroupBy:l,setMarketGroupBy:i,allocationGroupBy:d,setAllocationGroupBy:m,gnlGroupBy:h,setGnlGroupBy:f,initialMarketShortcut:b,onMarketShortcutChange:_,initialGnlShortcut:A,onGnlShortcutChange:D,initialFundsClassification:N,onFundsClassificationChange:R,initialLegacyDateRange:(0,o.A)(M,1)[0],onLegacyDateRangeChange:(0,a.useCallback)((t=>KMe(e,GMe,t)),[e])}})((0,d.d4)(Od.F6)),i=r.marketGroupBy,s=r.setMarketGroupBy,c=r.allocationGroupBy,u=r.setAllocationGroupBy,m=r.gnlGroupBy,p=r.setGnlGroupBy,g=r.initialMarketShortcut,h=r.onMarketShortcutChange,v=r.initialGnlShortcut,f=r.onGnlShortcutChange,E=r.initialFundsClassification,y=r.onFundsClassificationChange,b=r.initialLegacyDateRange,x=r.onLegacyDateRangeChange,w=(0,a.useState)(null),C=(0,o.A)(w,2),A=C[0],k=C[1],S=(0,a.useCallback)((e=>{k(e)}),[]),N=(0,a.useCallback)((e=>t((0,ZMe.O)(e))),[t]),T=(0,l.zy)(),_=(0,l.Zp)(),D=(0,e0.R7)({onUpdate:(e,t)=>{const n=(0,CX.iy)(e,t),a="".concat(window.location.pathname,"?").concat(tp.A.stringify(n));_(a)}}),R=(0,o.A)(D,2),M=R[0],L=R[1],O=(0,$Me.g)((e=>{var t,n;return{dateRange:null!==(t=null!==(n=e.dateRange)&&void 0!==n?n:b)&&void 0!==t?t:QMe.title}})),P=(0,o.A)(O,2),B=P[0].dateRange,z=P[1],F=T.pathname.includes(I.JZ.investments.advanced.path),G=(0,a.useMemo)((()=>{const e="ALL"===B?"5Y":B,t=zCe.find((t=>t.title===e));return FCe(null!==t&&void 0!==t?t:QMe)}),[B]),Y=(0,a.useCallback)((e=>{var t;const n=null===(t=eLe[e])||void 0===t?void 0:t.title;n&&(x(n),z({dateRange:n}))}),[x,z]),U=(0,Pc.e)(!1),V=(0,o.A)(U,2),W=V[0],j=V[1],H=j.setOn,K=j.setOff,q=()=>N([]),$=(0,et.I)(j3,{onCompleted:e=>{let t=e.accounts;(0===n.length||n.length>t.length)&&q(),W&&(q(),K())}}),Z=$.data,J=$.refetch,X=$.error,Q=Fq({error:X,retryFn:J,description:VG.U.INVESTMENTS}),ee=Q.isRetrying,te=Q.pageError,ne=null!==(e=null===Z||void 0===Z?void 0:Z.accounts)&&void 0!==e?e:[];(0,a.useEffect)((()=>{L({accounts:n})}),[n,T.pathname]);const ae=(0,Pd.h)(),le=(0,o.A)(ae,2),re=le[0],oe=le[1],ie=oe.open,se=oe.close,ce=(0,m0.t)(HQ.W1.INVESTMENTS).hasAccess,de=(0,P6.f)().isSponsored,ue=(0,d4.u)("feat-investments-allocation_manual_classification-web","off"),me=ue.isOn,pe=ue.isSplitReady,ge=ue.hasTimedout;return a.createElement(Dc.t,{"data-external-id":"investments",onChangeIndex:Y},a.createElement(Yq,{name:"Investments",pageError:te,isLoading:ee,childErrorRoutePrefix:I.JZ.investments.holdings.path,controls:a.createElement(_Ce,{accounts:ne,onApply:e=>N(e),onClear:q,activeFilters:M,showAddButton:!F,advancedActions:F?A:void 0}),tabs:a.createElement(PCe,null),emptyIcon:"trending-up",emptyTitle:_t.Ez,onAccountAdded:J,overlayEmptyComponent:ce?void 0:a.createElement(VCe,{feature:HQ.W1.INVESTMENTS,useDescriptionAsTitle:!0})},a.createElement(re,{onClose:J},a.createElement(SF.E,{onClose:se,onComplete:()=>{se(),H()},allowManualAccount:!1})),a.createElement("div",{className:"flex items-start"},a.createElement(l.BV,null,a.createElement(l.qh,{path:"",element:a.createElement(l.C5,{to:I.JZ.investments.holdings.market.path,replace:!0})}),a.createElement(l.qh,{path:I.JZ.investments.holdings.relativePath,element:a.createElement(l.C5,{to:I.JZ.investments.holdings.market.path,replace:!0})}),!de&&(pe||ge)&&a.createElement(l.qh,{path:I.JZ.investments.advanced.relativePath,element:a.createElement(l.C5,{to:me?I.JZ.investments.advanced.allocation.path:I.JZ.investments.advanced.gainsAndLosses.path,replace:!0})}),a.createElement(l.qh,{path:I.JZ.investments.allocation.relativePath,element:a.createElement(l.C5,{to:I.JZ.investments.holdings.allocation.path,replace:!0})}),!de&&a.createElement(l.qh,{path:I.JZ.investments.analysis.relativePath,element:a.createElement(l.C5,{to:I.JZ.investments.advanced.funds.path,replace:!0})}),!de&&a.createElement(l.qh,{path:I.JZ.investments.gainsAndLosses.relativePath,element:a.createElement(l.C5,{to:I.JZ.investments.advanced.gainsAndLosses.path,replace:!0})}),a.createElement(l.qh,{path:"".concat(I.JZ.investments.holdings.relativePath,"/*"),element:a.createElement(a.Fragment,null,a.createElement(rV.T,{screenName:"Investments",tab:"holdings"}),a.createElement(_Me,{activeAccountIds:n,onClickLinkAccount:ie,useMockData:!ce,marketGroupBy:i,setMarketGroupBy:s,allocationGroupBy:c,setAllocationGroupBy:u,initialMarketShortcutTitle:g,onMarketShortcutChange:h}))}),!de&&a.createElement(l.qh,{path:"".concat(I.JZ.investments.advanced.relativePath,"/*"),element:a.createElement(a.Fragment,null,a.createElement(rV.T,{screenName:"Investments",tab:"advanced"}),a.createElement(gRe,{activeAccountIds:n,dateRange:G,onClickLinkAccount:ie,groupBy:m,setGroupBy:p,onRegisterActions:S,initialGnlShortcutTitle:v,onGnlShortcutChange:f,initialFundsClassification:E,onFundsClassificationChange:y}))}
1)))))},nLe=e=>null!==e&&void 0!==e&&null!==e.value&&void 0!==e.value,aLe=e=>{if("differs"!==e.status)return!1;const t=nLe(e.aggregatorAtStatement)?e.aggregatorAtStatement:e.aggregatorNow;return nLe(t)&&nLe(e.spinwheelStored)},lLe={match:{label:"Match",color:"green",description:"Both sides agree within tolerance."},differs:{label:"Differs",color:"red",description:"Both sides have a value and they disagree."},aggregator_only:{label:"Aggregator only",color:"yellow",description:"The aggregator returned a value and Spinwheel did not."},spinwheel_only:{label:"Spinwheel only",color:"yellow",description:"Spinwheel has a value and the aggregator did not."},both_null:{label:"Both null",color:"gray-secondary",description:"Both sides offer the field and both returned nothing."},not_offered:{label:"Not offered",color:"gray-secondary",description:"Neither side has this field in its contract."},aggregator_not_fetched:{label:"Not fetched",color:"gray-secondary",description:"No aggregator pull was requested, so this side is unfetched."},declared_not_stored:{label:"Declared, not stored",color:"blue",description:"Spinwheel's contract defines this field and our mapper drops it."}},rLe={both:{label:"Both sides",color:"green"},aggregator_only:{label:"Aggregator only",color:"yellow"},spinwheel_only:{label:"Spinwheel only",color:"blue"},aggregator_not_fetched:{label:"Aggregators not fetched",color:"gray-secondary"},monarch_only:{label:"Monarch only",color:"gray-secondary"}},oLe=e=>{var t;let n=e.row,l=e.aggregatorsFetched,r=e.defaultExpanded,i=void 0!==r&&r,s=e.defaultViewed,c=void 0!==s&&s;const d=(0,a.useState)(i),u=(0,o.A)(d,2),m=u[0],p=u[1],g=(0,a.useState)(c),h=(0,o.A)(g,2),v=h[0],f=h[1],E=rLe[n.presence],y=null!==n.daysApart&&n.daysApart>7;return a.createElement(fe.xz6,{"data-external-id":"liability-comparison-row",className:(0,q.cn)("flex flex-col gap-sm p-default",v&&"opacity-60")},a.createElement(fe.X0s,{open:m,onOpenChange:p,className:"flex flex-col gap-sm"},a.createElement("div",{className:"flex flex-wrap items-start justify-between gap-xs"},a.createElement("div",{className:"flex min-w-0 flex-col gap-xs"},a.createElement("div",{className:"flex flex-wrap items-baseline gap-xs"},a.createElement(fe.c8D,{weight:"medium"},n.displayName),a.createElement(fe.CQG,{size:"sm",color:E.color},E.label),a.createElement(fe.c8D,{size:"xs",color:"secondary"},[n.institutionName,n.dataProvider,n.accountSubtype].filter(Boolean).join(" \xb7 "))),a.createElement("div",{className:"flex flex-wrap gap-x-default gap-y-2xs text-xs text-content-secondary"},a.createElement("span",null,"Statement date: ",null!==(t=n.spinwheelStatementDate)&&void 0!==t?t:"\u2014"),a.createElement("span",null,"Aggregator observed:"," ",((e,t)=>null!==e&&void 0!==e?e:t?"today":"\u2014")(n.aggregatorObservedAt,l)),null!==n.daysApart&&a.createElement("span",{className:(0,q.cn)(y&&"font-medium text-content-warning")},n.daysApart," days apart"))),a.createElement("div",{className:"flex items-center gap-xs"},a.createElement(fe.Ko1,{size:"sm",label:"Viewed",checked:v,onCheckedChange:e=>f(!0===e)}),a.createElement(fe.X0s.Trigger,{render:a.createElement(fe.XZZ,{size:"sm",variant:"default",endIcon:a.createElement(fe.D39,{className:"transition-transform in-aria-expanded:rotate-180"})},m?"Hide fields":"Show fields")}))),n.notes.map((e=>a.createElement(fe.c8D,{key:e,size:"xs",color:"secondary",className:"italic"},e))),a.createElement(fe.X0s.Content,null,a.createElement("div",{className:"flex flex-col gap-sm"},a.createElement("div",{className:"overflow-x-auto"},a.createElement("table",{className:"w-full min-w-225 border-collapse text-left text-sm"},a.createElement("thead",null,a.createElement("tr",{className:"border-b border-divider-primary"},a.createElement("th",{className:"p-xs font-medium text-content-secondary"},"Field"),a.createElement("th",{className:"p-xs font-medium text-content-secondary"},"Aggregator now"),a.createElement("th",{className:"p-xs font-medium text-content-secondary"},"Aggregator at statement"),a.createElement("th",{className:"p-xs font-medium text-content-secondary"},"Spinwheel stored"),a.createElement("th",{className:"p-xs font-medium text-content-secondary"},"Spinwheel declared"),a.createElement("th",{className:"p-xs font-medium text-content-secondary"},"Status"))),a.createElement("tbody",null,n.fields.map((e=>a.createElement(sLe,{key:e.name,field:e})))))),a.createElement("div",{className:"flex flex-col gap-xs"},a.createElement(cLe,{label:"raw aggregator payload",payload:n.rawAggregator}),a.createElement(cLe,{label:"raw Spinwheel data",payload:n.rawSpinwheel}))))))},iLe=e=>{let t=e.observation;return t&&null!==t.value?a.createElement("div",{"data-external-id":"observation-cell",className:"flex flex-col gap-3xs"},a.createElement("span",{className:"tabular-nums"},String(t.value)),t.path&&a.createElement("code",{className:"text-[10px] text-content-secondary"},t.path)):a.createElement("span",{"data-external-id":"observation-cell",className:"text-content-secondary"},"\u2014")},sLe=e=>{let t=e.field;const n=lLe[t.status];return a.createElement("tr",{"data-external-id":"field-row",className:(0,q.cn)("border-b border-divider-primary last:border-0",aLe(t)&&"bg-background-warning")},a.createElement("td",{className:"p-xs align-top"},a.createElement("div",{className:"flex flex-col gap-3xs"},a.createElement("span",null,t.label),a.createElement("code",{className:"text-[10px] text-content-secondary"},t.kind))),a.createElement("td",{className:"p-xs align-top"},a.createElement(iLe,{observation:t.aggregatorNow})),a.createElement("td",{className:"p-xs align-top"},a.createElement(iLe,{observation:t.aggregatorAtStatement})),a.createElement("td",{className:"p-xs align-top"},a.createElement(iLe,{observation:t.spinwheelStored})),a.createElement("td",{className:"p-xs align-top"},t.spinwheelDeclaredPath?a.createElement("code",{className:"text-[10px] text-content-secondary"},t.spinwheelDeclaredPath):a.createElement("span",{className:"text-content-secondary"},"\u2014")),a.createElement("td",{className:"p-xs align-top"},a.createElement("div",{className:"flex flex-col items-start gap-3xs"},a.createElement(fe.CQG,{size:"sm",color:n.color},n.label),null!==t.delta&&a.createElement("span",{className:"text-[10px] text-content-secondary tabular-nums"},"\u0394 ",t.delta,null!==t.deltaPct?" (".concat(t.deltaPct,"%)"):""))))},cLe=e=>{let t=e.label,n=e.payload;const l=(0,a.useState)(!1),r=(0,o.A)(l,2),i=r[0],s=r[1];return n?a.createElement("div",{"data-external-id":"raw-payload",className:"flex flex-col gap-2xs"},a.createElement("button",{type:"button",onClick:()=>s(!i),className:"w-fit text-left text-xs text-content-secondary underline focus-visible:outline-2"},i?"Hide":"Show"," ",t),i&&a.createElement("pre",{className:"m-0 max-h-96 overflow-auto rounded-sm bg-background-tertiary p-sm text-[11px] leading-relaxed"},JSON.stringify(n,null,2))):null},dLe=e=>({fetchLiabilities:()=>e.get("/liabilities"),fetchLiabilityComparison:function(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return e.get(function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.includeAggregators,n=void 0!==t&&t,a=e.forceRefresh,l=void 0!==a&&a;
1const r=new URLSearchParams;n&&r.set("aggregators","1"),l&&r.set("refresh","1");const o=r.toString();return"/liabilities/compare".concat(o?"?".concat(o):"")}(t))}}),uLe=()=>{const e=(0,a.useState)(null),t=(0,o.A)(e,2),n=t[0],l=t[1],r=(0,a.useState)(null),i=(0,o.A)(r,2),s=i[0],c=i[1],d=(0,a.useState)(!0),u=(0,o.A)(d,2),m=u[0],g=u[1],h=(0,a.useCallback)((async function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};g(!0),c(null);try{l(await dLe(r7.F).fetchLiabilityComparison(e))}catch(t){c(t instanceof Error?t.message:"Failed to load comparison")}finally{g(!1)}}),[]);return(0,a.useEffect)((()=>{h()}),[h]),a.createElement(rG.Y,{"data-external-id":"liabilities-dev",name:"Liability Comparison",parentRoute:null,controls:a.createElement("div",{className:"flex items-center gap-xs"},a.createElement(fe.XZZ,{size:"sm",variant:"primary",onClick:()=>h({includeAggregators:!0}),disabled:m},"Fetch aggregator data"),(null===n||void 0===n?void 0:n.aggregatorsFetched)&&a.createElement(fe.XZZ,{size:"sm",variant:"default",onClick:()=>h({includeAggregators:!0,forceRefresh:!0}),disabled:m},"Force refresh"))},a.createElement("div",{className:"flex flex-col gap-default px-xl pb-xl"},a.createElement(fe.hzW,{variant:"info"},a.createElement(fe.hzW.Title,null,"Employee tool, your household only"),a.createElement(fe.hzW.Description,null,"Spinwheel is read from stored data only, so a \u201cdeclared, not stored\u201d field means its API contract defines the field and our mapper drops it \u2014 not that Spinwheel populates it for your account. Fetching aggregator data calls Plaid\u2019s billable liabilities product, so it is opt-in; results are cached for 15 minutes.")),n&&!n.aggregatorsFetched&&a.createElement(fe.hzW,{variant:"warning"},a.createElement(fe.hzW.Title,null,"Aggregator data not fetched"),a.createElement(fe.hzW.Description,null,"Showing the Spinwheel side only. Use \u201cFetch aggregator data\u201d to call Plaid, MX and Finicity for your household.")),m&&a.createElement("div",{className:(0,q.cn)("flex items-center gap-xs",n?"py-sm":"py-xl")},a.createElement(p.i,null),a.createElement(fe.c8D,{color:"secondary"},n?"Refreshing comparison\u2026":"Loading comparison\u2026")),s&&a.createElement(fe.hzW,{variant:"error"},a.createElement(fe.hzW.Title,null,"Could not load the comparison"),a.createElement(fe.hzW.Description,null,s)),n&&a.createElement(a.Fragment,null,a.createElement("div",{className:"grid grid-cols-2 gap-sm md:grid-cols-4"},a.createElement(pLe,{label:"Accounts",value:n.summary.accounts}),a.createElement(pLe,{label:"Fields differing",value:n.summary.fieldsDiffering}),a.createElement(pLe,{label:"One side only",value:n.summary.fieldsOneSideOnly}),a.createElement(pLe,{label:"Declared, not stored",value:n.summary.fieldsDeclaredNotStored})),n.providerErrors.length>0&&a.createElement(mLe,{errors:n.providerErrors}),a.createElement("div",{className:"flex flex-wrap gap-xs"},Object.entries(lLe).map((e=>{let t=(0,o.A)(e,2),n=t[0],l=t[1];return a.createElement("div",{key:n,className:"flex items-center gap-2xs"},a.createElement(fe.CQG,{size:"sm",color:l.color},l.label),a.createElement(fe.c8D,{size:"xs",color:"secondary"},l.description))}))),0===n.rows.length&&a.createElement(fe.xz6,{className:"p-xl text-center"},a.createElement(fe.c8D,{color:"secondary"},"No liability accounts found for your household.")),n.rows.map(((e,t)=>a.createElement(oLe,{key:"".concat(e.accountId,"-").concat(e.displayName,"-").concat(e.dataProvider,"-").concat(t),row:e,aggregatorsFetched:n.aggregatorsFetched}))),a.createElement(fe.xz6,{className:"flex flex-col gap-sm p-default"},a.createElement(fe.c8D,{weight:"medium"},"Declared by Spinwheel, dropped by our mapper (",n.declaredNotStored.length,")"),a.createElement(fe.c8D,{size:"sm",color:"secondary"},"From our own type definitions. Presence in this list means the contract defines the field, not that Spinwheel returns a value for it."),a.createElement("div",{className:"overflow-x-auto"},a.createElement("table",{className:"w-full border-collapse text-left text-sm"},a.createElement("thead",null,a.createElement("tr",{className:"border-b border-divider-primary"},a.createElement("th",{className:"p-xs font-medium text-content-secondary"},"Group"),a.createElement("th",{className:"p-xs font-medium text-content-secondary"},"Field"),a.createElement("th",{className:"p-xs font-medium text-content-secondary"},"Path"))),a.createElement("tbody",null,n.declaredNotStored.map((e=>a.createElement("tr",{key:e.path,className:"border-b border-divider-primary last:border-0"},a.createElement("td",{className:"p-xs text-content-secondary"},e.group),a.createElement("td",{className:"p-xs"},e.label),a.createElement("td",{className:"p-xs"},a.createElement("code",{className:"text-xs"},e.path))))))))))))},mLe=e=>{let t=e.errors;return a.createElement(fe.hzW,{"data-external-id":"provider-errors-banner",variant:"warning"},a.createElement(fe.X0s,{defaultOpen:!1,className:"w-full min-w-0"},a.createElement(fe.X0s.Trigger,{className:"flex w-full items-center justify-between gap-xs text-left"},a.createElement(fe.hzW.Title,null,1===(n=t.length)?"There is 1 provider warning":"There are ".concat(n," provider warnings")),a.createElement(fe.D39,{size:"sm",className:"shrink-0 transition-transform in-aria-expanded:rotate-180"})),a.createElement(fe.X0s.Content,null,a.createElement(fe.hzW.Description,null,a.createElement("ul",{className:"m-0 flex list-disc flex-col gap-2xs pl-default"},t.map((e=>a.createElement("li",{key:"".concat(e.provider,"-").concat(e.credentialId)},a.createElement("span",{className:"font-medium"},e.provider),e.credentialId?" (credential ".concat(e.credentialId,")"):"",": ",a.createElement("code",{className:"text-xs"},e.message)))))))));var n}
1,pLe=e=>{let t=e.label,n=e.value;return a.createElement("div",{"data-external-id":"summary-tile",className:"flex flex-col gap-2xs rounded-sm bg-background-tertiary px-default py-sm"},a.createElement(fe.c8D,{size:"sm",color:"secondary"},t),a.createElement(fe.c8D,{size:"xl",weight:"medium",className:"tabular-nums"},n))};var gLe=n(63892),hLe=n(25251),vLe=n(68909);const fLe=_t.xB.FIXED_EXPENSES,ELe=()=>{const e=(0,vLe.L)(),t=e.settings,n=e.isLoadingInitialData,l=e.isReady,o=e.error,i=e.isSaving,s=e.saveSettings,c=(0,r.YW)({isReady:l,isLoadingInitialData:n,error:o}).with({isReady:!0},(()=>a.createElement(yLe,{settings:t,isSaving:i,saveSettings:s}))).with({isLoadingInitialData:!0},(()=>a.createElement(Ffe,null,a.createElement("div",{className:"flex items-center justify-center p-xl"},a.createElement(fe.ix7,null))))).with({error:r.P.nonNullable},(()=>a.createElement(Ffe,null,a.createElement("div",{className:"p-xl"},a.createElement(SQ.W,{message:fLe.LOAD_ERROR}))))).otherwise((()=>null));return a.createElement(rG.Y,{"data-external-id":"monarch-method-fixed-expense-settings",name:"Monarch Method Fixed Expenses",parentRoute:"Monarch Method",overrideTitle:fLe.NAV_TITLE},a.createElement("div",{className:"w-full p-lg"},a.createElement("div",{className:"mx-auto flex w-full max-w-3xl flex-col gap-lg"},a.createElement("div",{className:"flex flex-col gap-2xs"},a.createElement(fe.c8D,{size:"lg",weight:"medium"},fLe.PAGE_TITLE),a.createElement(fe.c8D,{size:"sm",color:"secondary"},fLe.PAGE_SUBTITLE)),c)))},yLe=e=>{let t=e.settings,n=e.isSaving,l=e.saveSettings;const r=(0,C.RU)(),o=(0,hLe.n)(t),i=o.includedIds,s=o.toggleCategory,c=o.getIncludedCategoryIds;return 0===t.categories.length?a.createElement(Ffe,{"data-external-id":"fixed-expense-settings-form"},a.createElement(fe.erR,{title:fLe.EMPTY_STATE})):a.createElement(a.Fragment,null,a.createElement(Ffe,null,a.createElement("div",{className:"flex flex-col gap-lg p-xl"},!t.isConfigured&&a.createElement(fe.c8D,{size:"sm",color:"secondary"},fLe.UNCONFIRMED_HINT),a.createElement(gLe.Y,{categories:t.categories,includedIds:i,onToggle:s}))),a.createElement("div",{className:"flex justify-end"},a.createElement(fe.XZZ,{variant:"primary",size:"md",isLoading:n,onClick:async()=>{try{await l({includedCategoryIds:c()}),(0,C.oR)({title:fLe.SAVE_SUCCESS})}catch(e){r({description:fLe.SAVE_ERROR})}}},t.isConfigured?fLe.SAVE_BUTTON:fLe.CONFIRM_BUTTON)))},bLe=()=>a.createElement(fe.TZm,{"data-external-id":"monarch-method-feedback-button",href:"https://app.notion.com/p/monarchmoney/d67b643baff64b6e9535247203d48c3a?pvs=106",external:!0,variant:"default",size:"sm",icon:a.createElement(fe.F6q,{size:"sm"})},_t.xB.SHARE_FEEDBACK_BUTTON),xLe=_t.xB.BANDS,wLe=_t.xB.PILLAR_STATUS_VERB,CLe=[{upToFraction:.5,textColor:"danger",fillToken:"red-11",trackToken:"red-3",label:xLe.NEEDS_FOCUS.LABEL,statusConnector:"",headline:xLe.NEEDS_FOCUS.HEADLINE,blurb:xLe.NEEDS_FOCUS.BLURB},{upToFraction:.65,textColor:"warning",fillToken:"yellow-11",trackToken:"yellow-3",label:xLe.BUILDING.LABEL,statusConnector:wLe,headline:xLe.BUILDING.HEADLINE,blurb:xLe.BUILDING.BLURB},{upToFraction:.8,textColor:"info",fillToken:"lime-11",trackToken:"lime-3",label:xLe.STEADY.LABEL,statusConnector:wLe,headline:xLe.STEADY.HEADLINE,blurb:xLe.STEADY.BLURB},{upToFraction:.9,textColor:"success",fillToken:"green-11",trackToken:"green-3",label:xLe.STRONG.LABEL,statusConnector:wLe,headline:xLe.STRONG.HEADLINE,blurb:xLe.STRONG.BLURB},{upToFraction:1,textColor:"success",fillToken:"teal-11",trackToken:"teal-3",label:xLe.THRIVING.LABEL,statusConnector:wLe,headline:xLe.THRIVING.HEADLINE,blurb:xLe.THRIVING.BLURB}],ALe=(e,t)=>(e=>{var t;const n=Number.isFinite(e)?e:0;return null!==(t=CLe.find((e=>n<=e.upToFraction)))&&void 0!==t?t:CLe[CLe.length-1]})(t>0?e/t:0),ILe=["measured","provisional","not_yet_applicable"],kLe=e=>{let t=e.score,n=e.maxScore;if("not_yet_applicable"===(e=>ILe.includes(e)?e:"measured")(e.status))return{label:_t.xB.PILLAR_NOT_SCORED_YET,color:"secondary",statusConnector:_t.xB.PILLAR_STATUS_VERB};const a=ALe(t,n);return{label:a.label,color:a.textColor,statusConnector:a.statusConnector}},SLe=e=>{let t=e.delta,n=e.label,l=void 0===n?_t.xB.GROWTH_CHIP_DEFAULT_LABEL:n,r=e.className;const o=(e=>{if(null===e||void 0===e)return null;const t=Math.round(e);return 0===t?null:{rounded:t,isPositive:t>0}})(t);if(!o)return null;
1const i=o.rounded,s=o.isPositive,c=s?fe.S99:fe.$x6;return a.createElement("div",{"data-external-id":"monarch-method-growth-chip",className:(0,q.cn)("flex items-center gap-3xs",s?"text-content-success":"text-content-danger",r)},a.createElement(c,{size:"xs"}),a.createElement(fe.c8D,{size:"xs",weight:"medium",color:"inherit"},s?"+":"\u2212",Math.abs(i).toLocaleString()," ",l))},NLe=CLe.map((e=>(0,U.A)((0,U.A)({},e),{},{fill:"var(--".concat(e.fillToken,")"),track:"var(--".concat(e.trackToken,")")}))),TLe={score:{segments:5,trackClassName:"stroke-chart-event-background-teal",fillClassName:"stroke-chart-fill-teal",dotClassName:"fill-chart-fill-teal",showDot:!0,showDelta:!0,numberClassName:"font-secondary",numberFontRatio:50/220,defaultSize:220,defaultMaxScore:1e3},pillar:{segments:1,trackClassName:"stroke-chart-event-background-green",fillClassName:"stroke-chart-fill-green",dotClassName:"fill-chart-fill-green",showDot:!1,showDelta:!1,numberClassName:"font-primary",numberFontRatio:30/134,defaultSize:134,defaultMaxScore:100}},_Le=e=>{let t=e.score,n=e.variant,l=void 0===n?"score":n,r=e.maxScore,o=e.scale,i=e.delta,s=e.deltaLabel,c=void 0===s?_t.xB.GROWTH_CHIP_DEFAULT_LABEL:s,d=e.size,u=e.animate,m=void 0===u||u,p=e.animationDurationMs,g=void 0===p?1200:p,h=e.className;const v=TLe[l],f=null!==r&&void 0!==r?r:v.defaultMaxScore,E=null!==d&&void 0!==d?d:v.defaultSize,y=RL(E),b=v.segments>1,x=(0,a.useMemo)((()=>o||NLe.map((e=>({upTo:e.upToFraction*f,fill:e.fill,track:"pillar"===l?"var(--gray-2)":e.track})))),[o,l,f]),w=(0,a.useMemo)((()=>DLe(t,x)),[t,x]),C=w?{stroke:w.track}:void 0,A=w?{stroke:w.fill}:void 0,I=w?{fill:w.fill}:void 0,k=w?void 0:v.trackClassName,S=w?void 0:v.fillClassName,N=w?void 0:v.dotClassName,T=f>0?(_=t/f,Math.min(1,Math.max(0,_))):0;var _;const D=ML({target:T,animate:m,durationMs:g}),R="mm-score-gauge-reveal-".concat((0,a.useId)().replace(/:/g,"")),M=D*SL,L=T>0?Math.round(D/T*t):Math.round(t),O=void 0===i?0:Math.round(i),P=v.showDelta&&0!==O?", ".concat(O>0?"up":"down"," ").concat(Math.abs(O).toLocaleString()," ").concat(c):"";return a.createElement("div",{"data-external-id":"monarch-method-score-gauge",role:"img","aria-label":"Score ".concat(Math.round(t).toLocaleString()," out of ").concat(f.toLocaleString()).concat(P),className:(0,q.cn)("relative inline-flex shrink-0 overflow-visible select-none",h),style:{width:E,height:y}},a.createElement("div",{className:"absolute top-0 left-0 overflow-visible",style:{width:E,height:E}},a.createElement("svg",{"aria-hidden":!0,className:"absolute inset-0 overflow-visible",width:E,height:E,viewBox:"0 0 ".concat(wL," ").concat(wL),fill:"none"},a.createElement("defs",null,a.createElement("mask",{id:R},a.createElement("path",{d:_L,stroke:"white",strokeWidth:13,strokeLinecap:"round",pathLength:1,strokeDasharray:"".concat(D," 2")}))),a.createElement("path",{d:_L,className:k,style:C,strokeWidth:IL,strokeLinecap:"round",pathLength:b?v.segments-NL:1,strokeDasharray:b?"".concat(.8," ").concat(NL):void 0}),a.createElement("path",{d:_L,className:S,style:A,strokeWidth:IL,strokeLinecap:"round",pathLength:b?v.segments-NL:1,strokeDasharray:b?"".concat(.8," ").concat(NL):void 0,mask:"url(#".concat(R,")")}),v.showDot&&a.createElement("g",{transform:"rotate(".concat(M," ").concat(CL," ").concat(CL,")")},a.createElement("circle",{cx:DL.x,cy:DL.y,r:9,className:"fill-background-primary"}),a.createElement("circle",{cx:DL.x,cy:DL.y,r:6,className:N,style:I}))),a.createElement("div",{"aria-hidden":!0,className:"absolute inset-0 flex flex-col items-center justify-center"},a.createElement("span",{className:(0,q.cn)("leading-none font-medium text-content-primary tabular-nums",v.numberClassName),style:{fontSize:E*v.numberFontRatio}},L.toLocaleString()),a.createElement(fe.c8D,{size:"sm",color:"secondary",className:"mt-2xs"},_t.xB.GAUGE_MAX_SUFFIX(f)),v.showDelta&&a.createElement(SLe,{delta:i,label:c,className:"mt-md"}))))},DLe=(e,t)=>{var n;if(0===t.length)return;const a=[...t].sort(((e,t)=>e.upTo-t.upTo));return null!==(n=a.find((t=>e<=t.upTo)))&&void 0!==n?n:a[a.length-1]},RLe=e=>{let t=e.pillar;const n=kLe(t);return a.createElement(l.k2,{"data-external-id":"monarch-method-pillar-summary-card",to:I.JZ.monarchMethodPillar({pillarKey:t.key}),className:"block rounded-default transition-shadow outline-none hover:shadow-lg focus-visible:ring-2 focus-visible:ring-input-focus-border"},a.createElement(fe.xz6,null,a.createElement("div",{className:"flex flex-col items-center gap-sm px-default py-lg"},a.createElement(fe.c8D,{size:"sm",weight:"medium"},t.label),a.createElement(_Le,{variant:"pillar",score:t.score,maxScore:t.maxScore}),a.createElement(fe.c8D,{size:"base",weight:"medium",color:n.color},n.label),t.message?a.createElement(fe.c8D,{size:"sm",color:"secondary",className:"text-center"},t.message):null)))},MLe=Ee.sOw,LLe=(e,t)=>e.isProjected?(0,Ba.SR)(e.date):e.date===t?N.c9.fromISO(e.date).toFormat("MMMM"):(0,Ba.jY)(e.date),OLe="var(--chart-fill-green)",PLe=["actualScore","projectedScore"],BLe=()=>{const e=(()=>{var e;const t=N.c9.now().minus({months:6}).toISODate(),n=(0,et.I)(MLe,{variables:{startDate:t},fetchPolicy:"cache-and-network",nextFetchPolicy:"cache-first"}),a=n.data,l=n.isLoadingInitialData,r=n.error;return{snapshots:null!==(e=null===a||void 0===a?void 0:a.monarchMethodScoreHistory)&&void 0!==e?e:[],isLoadingInitialData:l,error:r}})(),t=e.snapshots,n=e.isLoadingInitialData,l=e.error;return a.createElement(zLe,{"data-external-id":"monarch-method-score-history-chart",snapshots:t,isLoading:n,error:l})},zLe=e=>{let t=e.snapshots,n=e.isLoading,l=e.error;return a.createElement("div",{"data-external-id":"monarch-method-score-history-chart-view",className:"flex flex-1 flex-col gap-default"},a.createElement(fe.c8D,{size:"lg",weight:"medium"},_t.xB.SCORE_PROJECTION_HEADING),a.createElement(FLe,{snapshots:t,isLoading:n,error:l}))},FLe=e=>{let t=e.snapshots,n=e.isLoading,l=e.error;return n?a.createElement("div",{"data-external-id":"score-history-body",className:"flex min-h-52.5 flex-1 items-center justify-center"},a.createElement(fe.ix7,null)):l?a.createElement(SQ.W,{"data-external-id":"score-history-body",message:"We couldn't load your score history."}):0===t.length?a.createElement("div",{"data-external-id":"score-history-body",className:"flex min-h-52.5 flex-1 items-center justify-center"},a.createElement(fe.c8D,{size:"sm",color:"secondary"},"No score history yet \u2014 snapshots appear once your score has been captured.")):a.createElement("div",{"data-external-id":"score-history-body",className:"mt-auto min-h-0"},a.createElement(GLe,{snapshots:t}))},GLe=e=>{let t=e.snapshots;const n=(0,a.useMemo)((()=>function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:6;if(0===e.length||t<1)return[];const n=[...e].sort(((e,t)=>e.date.localeCompare(t.date))).slice(-t),a=t-n.length,l=n[n.length-1],r=l.totalScore,o=n.map(((e,t)=>{const l=t===n.length-1;return{date:e.date,actualScore:e.totalScore,projectedScore:l&&a>0?r:null,isProjected:!1}}));if(0===a)return o;const i=N.c9.fromISO(l.date).startOf("month"),s=Array.from({length:a},((e,t)=>{const n=i.plus({months:t+1}).toISODate();return{date:null!==n&&void 0!==n?n:l.date,actualScore:null,projectedScore:r,isProjected:!0}}));return[...o,...s]}(t)),[t]),l=n.some((e=>e.isProjected)),r=(0,a.useMemo)((()=>{var e,t;return null!==(e=null===(t=[...n].reverse().find((e=>!e.isProjected)))||void 0===t?void 0:t.date)&&void 0!==e?e:null}),[n]),o=(0,a.useMemo)((()=>YLe(n)),[n]),i=(0,a.useMemo)((()=>{const e=(e=>{var t,n;return null!==(n=null===(t=e.find((e=>e.isProjected)))||void 0===t?void 0:t.date)&&void 0!==n?n:null})(n);if(!e)return null;const t=n.filter((e=>e.isProjected)),a=t[Math.floor((t.length-1)/2)],l=null===a||void 0===a?void 0:a.projectedScore;return null===l||void 0===l?null:{x:a.date,y:l,label:_t.xB.SCORE_NEXT_RECALCULATION((0,Ba.SR)(e))}}),[n]);return a.createElement(Do.rT,{"data-external-id":"score-history-chart",data:n,xDataKey:"date",yDataKeys:PLe,lineOptions:[{lineColor:OLe,strokeWidth:3,showDots:!0,hasArea:!l,areaColor:OLe,hideActiveDot:!0},{lineColor:OLe,strokeWidth:3,isDashed:!0,hasArea:l,areaColor:OLe,hideActiveDot:!0,hideUntilAnimationStart:!0}],height:248,margin:{top:28,bottom:28},formatXAxis:e=>{var t;return null!==(t=o.get(String(e)))&&void 0!==t?t:String(e)},formatYAxis:e=>String(Math.round(Number(e))),hideLegend:!0,smoothGradient:!0,showAllTicks:!0,isAnimationActive:!0,xAxisProps:{interval:0,padding:{left:8,right:8},tick:e=>a.createElement(ULe,Object.assign({},e,{latestActualDate:r,labelByDate:o}))}},i?a.createElement(Ky.r,{x:i.x,y:i.y,r:0,fill:"transparent",stroke:"none",label:{value:i.label,position:"top",offset:14,fill:"var(--content-primary)",fontSize:12,fontWeight:500}}):null)},YLe=e=>{var t,n;const a=null!==(t=null===(n=[...e].reverse().find((e=>!e.isProjected)))||void 0===n?void 0:n.date)&&void 0!==t?t:null;return new Map(e.map((e=>[e.date,LLe(e,a)])))},ULe=e=>{var t;let n=e.x,l=void 0===n?0:n,r=e.y,o=void 0===r?0:r,i=e.payload,s=e.latestActualDate,c=e.labelByDate;if(!i)return null;const d=i.value===s;return a.createElement("text",{"data-external-id":"score-history-x-tick",x:l,y:o,dy:12,textAnchor:"middle",className:d?"fill-content-primary text-xs font-medium":"fill-content-secondary text-xs"},null!==(t=c.get(i.value))&&void 0!==t?t:i.value)},VLe=e=>{let t=e.totalScore,n=e.maxScore,l=e.totalScoreChangeThisMonth,r=e.trend;const o=null!==l&&void 0!==l?l:void 0,i=ALe(t,n);return a.createElement(fe.xz6,{"data-external-id":"monarch-method-score-summary-card",className:"overflow-visible"},a.createElement("div",{className:"flex flex-col md:flex-row"},a.createElement("div",{className:"flex flex-col items-center overflow-visible bg-background-secondary px-xl py-2xl md:w-105"},a.createElement(fe.c8D,{size:"sm",weight:"medium",className:"mb-default text-center"},_t.xB.HERO_TITLE),a.createElement(_Le,{variant:"score",size:210,score:t,maxScore:n,delta:o,deltaLabel:_t.xB.HERO_DELTA_LABEL,className:"mb-default"}),a.createElement(fe.c8D,{size:"xl",weight:"medium",className:"text-center"},i.headline),a.createElement(fe.c8D,{size:"sm",color:"secondary",className:"mt-xs max-w-75 text-center"},i.blurb)),a.createElement("div",{className:"flex flex-1 flex-col px-xl pt-xl pb-md md:min-
1h-70"},null!==r&&void 0!==r?r:a.createElement("div",{className:"flex flex-1 items-center justify-center"},a.createElement(fe.c8D,{size:"sm",color:"secondary"},_t.xB.TREND_PLACEHOLDER)))))},WLe=(0,Qt.J)('\n  query Common_MonarchMethodScore {\n    monarchMethodScore {\n      totalScore\n      maxScore\n      # Month-to-date change in the total. Nullable: null = no baseline snapshot\n      # yet this calendar month (new households) \u2014 the header omits the chip.\n      totalScoreChangeThisMonth\n      pillars {\n        key\n        label\n        score\n        maxScore\n        status\n        # One generic, actionable "what to do next" tip. Nullable \u2014 hide when null.\n        message\n        # Per-pillar month-to-date delta; same semantics/nullability as the total.\n        pointsChangeThisMonth\n      }\n    }\n  }\n'),jLe=()=>{var e;const t=(()=>{var e;const t=(0,et.I)(WLe,{fetchPolicy:"cache-and-network",nextFetchPolicy:"cache-first"}),n=t.data,a=t.isLoadingInitialData,l=t.isNetworkRequestInFlight,r=t.error,o=t.refetch;return{score:null!==(e=null===n||void 0===n?void 0:n.monarchMethodScore)&&void 0!==e?e:null,isLoadingInitialData:a,isRefreshing:l,error:r,refetch:o}})(),n=t.score,o=t.isLoadingInitialData,i=t.error,s=null!==(e=null===n||void 0===n?void 0:n.pillars)&&void 0!==e?e:[];return a.createElement(rG.Y,{"data-external-id":"monarch-method",name:"Monarch Method",parentRoute:null,overrideTitle:"Method",controls:a.createElement("div",{className:"flex items-center gap-sm"},a.createElement(fe.XZZ,{variant:"default",size:"sm",icon:a.createElement(fe.bQo,{size:"sm"}),render:a.createElement(l.k2,{to:I.JZ.monarchMethodQuestionnaire.path}),nativeButton:!1},_t.xB.UPDATE_PROFILE_BUTTON),a.createElement(bLe,null))},a.createElement("div",{className:"grid w-full grid-cols-1 gap-lg p-lg"},a.createElement("div",{className:"flex flex-col"},(0,r.YW)({isLoadingInitialData:o,error:i,score:n}).with({isLoadingInitialData:!0},(()=>a.createElement("div",{className:"flex flex-1 items-center justify-center py-3xl"},a.createElement(fe.ix7,null)))).with({error:r.P.nonNullable},(()=>a.createElement(SQ.W,{message:_t.xB.SCORE_LOAD_ERROR}))).with({score:r.P.nullish},(()=>a.createElement(fe.c8D,{size:"sm",color:"secondary"},_t.xB.SCORE_EMPTY_STATE))).otherwise((()=>a.createElement(a.Fragment,null,a.createElement(VLe,{totalScore:n.totalScore,maxScore:n.maxScore,totalScoreChangeThisMonth:n.totalScoreChangeThisMonth,trend:a.createElement(BLe,null)}),a.createElement("div",{className:"mt-2xl mb-xl flex flex-col gap-3xs"},a.createElement(fe.c8D,{size:"lg",weight:"medium"},_t.xB.PILLARS_SECTION_TITLE(s.length)),a.createElement(fe.c8D,{size:"sm",color:"secondary"},_t.xB.PILLARS_SECTION_SUBTITLE)),a.createElement("div",{className:"grid grid-cols-1 gap-x-default gap-y-lg sm:grid-cols-2 lg:grid-cols-3"},s.map((e=>a.createElement(RLe,{key:e.key,pillar:e}))))))))))},HLe="https://monarch-static-assets-us-east-2.s3.us-east-2.amazonaws.com/found-money",KLe=[{image:"".concat(HLe,"/find-money-you-didnt-know-you-had.png"),title:"Built from your real data",description:"Your accounts, cash flow, and debts add up to one score across 9 pillars of your financial life."},{image:"".concat(HLe,"/switch-to-the-standard-plan.png"),title:"Watch it climb",description:"Monarch keeps scoring as your finances improve, so you can watch the number rise over time."},{image:"".concat(HLe,"/never-miss-a-chance-to-save.png"),title:"Never miss a chance to save",description:"We\u2019ll keep checking for cost savings over time so you never miss a chance to save."}],qLe=()=>a.createElement(rG.Y,{"data-external-id":"monarch-method-landing",name:"Monarch Method",parentRoute:null,overrideTitle:"Method"},a.createElement("div",{className:"flex flex-col gap-default px-default pb-default"},a.createElement(fe.xz6,{className:"items-center overflow-clip py-4xl shadow-lg"},a.createElement("div",{className:"flex max-w-190 flex-col items-center justify-center gap-xl px-default"},a.createElement("div",{className:"flex flex-col items-center justify-center gap-sm text-center"},a.createElement("h1",{className:"font-secondary text-[32px] leading-[1.3] font-book tracking-[-0.05em] text-content-primary sm:text-[48px]"},"See where you stand, ",a.createElement("em",{className:"font-medium"},"and")," the one move that matters most"),a.createElement(fe.c8D,{size:"base",color:"secondary",className:"max-w-135"},"Monarch turns your synced accounts into a single financial health score\u2014then ranks what to do next.")),a.createElement(p1.E,{to:I.JZ.monarchMethodQuestionnaire.path,variant:"primary",size:"lg"},"Unlock your score"))),a.createElement("div",{className:"grid grid-cols-1 items-stretch gap-default md:grid-cols-3"},KLe.map((e=>a.createElement(fe.xz6,{key:e.title,className:"h-full items-center justify-end gap-xl px-xl pt-xl pb-2xl shadow-lg"},a.createElement("div",{className:" flex min-h-55 w-full flex-1 items-center justify-center overflow-clip rounded-default border border-divider-primary bg-background-secondary p-default "},a.createElement("img",{src:e.image,alt:"",className:"h-auto w-full max-w-75 object-contain"})),a.createElement("div",{className:"flex w-full flex-col gap-2xs text-center"},a.createElement(fe.c8D,{size:"lg",weight:"medium"},e.title),a.createElement(fe.c8D,{size:"base",color:"secondary"},e.description))))))));var $Le=n(37330);const ZLe=e=>{let t=e.children,n=e.fallback;const l=(()=>{var e,t;const n=(0,et.I)($Le.tv,{fetchPolicy:"cache-and-network",nextFetchPolicy:"cache-first",n
1otifyOnNetworkStatusChange:!0}),a=n.data,l=n.isLoadingInitialData,r=n.isNetworkRequestInFlight,o=n.error,i=n.refetch;return{hasCompletedOnboarding:null!==(t=null===(e=null===a||void 0===a?void 0:a.householdProfile)||void 0===e?void 0:e.hasCompletedMonarchMethodOnboarding)&&void 0!==t&&t,isLoadingInitialData:l,isNetworkRequestInFlight:r,error:o,refetch:i}})(),r=l.hasCompletedOnboarding,o=l.isLoadingInitialData,i=l.isNetworkRequestInFlight,s=l.error;return r?a.createElement(a.Fragment,null,t):o||i?a.createElement(rG.Y,{"data-external-id":"monarch-method-onboarding-boundary",name:"Monarch Method",parentRoute:null,overrideTitle:"Method"},a.createElement("div",{className:"flex flex-1 items-center justify-center py-3xl"},a.createElement(fe.ix7,null))):s?a.createElement(rG.Y,{"data-external-id":"monarch-method-onboarding-boundary",name:"Monarch Method",parentRoute:null,overrideTitle:"Method"},a.createElement(SQ.W,{message:_t.xB.ONBOARDING_STATUS_LOAD_ERROR})):a.createElement(a.Fragment,null,n)},JLe=()=>a.createElement(ZLe,{"data-external-id":"monarch-method-gate",fallback:a.createElement(qLe,null)},a.createElement(jLe,null));const XLe=n.p+"static/media/banking.418bae04.svg";const QLe=n.p+"static/media/cash-flow.51009e92.svg";const eOe=n.p+"static/media/debt-credit.ece247e7.svg";const tOe=n.p+"static/media/housing.72398b40.svg";const nOe=n.p+"static/media/income.c1785819.svg";const aOe=n.p+"static/media/investing.f5dad168.svg";const lOe=n.p+"static/media/protection.ba460156.svg";const rOe=n.p+"static/media/retirement.66d6978a.svg";const oOe=n.p+"static/media/taxes.b152dfdb.svg",iOe={[Ee.CJN.BANKING]:XLe,[Ee.CJN.CASH_FLOW]:QLe,[Ee.CJN.DEBT_CREDIT]:eOe,[Ee.CJN.HOUSING]:tOe,[Ee.CJN.INCOME]:nOe,[Ee.CJN.INVESTING]:aOe,[Ee.CJN.PROTECTION]:lOe,[Ee.CJN.RETIREMENT]:rOe,[Ee.CJN.TAXES]:oOe},sOe=e=>{let t=e.pillarKey,n=e.label,l=e.description;return a.createElement(fe.xz6,{"data-external-id":"monarch-method-pillar-about-card"},a.createElement("div",{className:"flex flex-col gap-default p-lg"},a.createElement("img",{src:iOe[t],alt:_t.xB.PILLAR_IMAGE_ALT(n),className:"h-40 w-full rounded-default object-contain object-center"}),a.createElement("div",{className:"flex flex-col gap-2xs"},a.createElement(fe.c8D,{size:"lg",weight:"medium"},n),a.createElement(fe.c8D,{size:"base",color:"secondary"},l)),t===Ee.CJN.CASH_FLOW&&a.createElement(p1.E,{variant:"default",to:I.JZ.monarchMethodFixedExpenses()},_t.xB.FIXED_EXPENSES.MANAGE_LINK)))};var cOe=n(45201);const dOe=(e,t)=>{if(0!==t.length&&Number.isFinite(e))return t.reduce(((t,n)=>e>=n.minValue?n:t),t[0])},uOe=(e,t)=>{const n=dOe(e,t);return n?t.findIndex((e=>e.key===n.key)):-1},mOe=e=>Array.from({length:e.length+1},((e,t)=>t)),pOe=(e,t)=>t<=0||!Number.isFinite(e)?-1:Math.min(t-1,Math.max(0,Math.floor(e))),gOe=e=>{var t,n;let l=e.data,r=e.zones,o=e.topZoneCap,i=e.bottomZoneFloor,s=e.height,c=void 0===s?312:s,d=e.formatValue,u=void 0===d?String:d,m=e.interactive,p=void 0===m||m;const g=(0,a.useId)(),h="health-zone-".concat(g.replace(/:/g,"")),v="".concat(h,"-line"),f=(0,cOe.g)().getLineProps,E=null!==o&&void 0!==o?o:(e=>{const t=e[e.length-1];if(!t)return 1;const n=Number.isFinite(t.minValue)?t.minValue:0;return Math.max(1.5*n,n+.05)})(r),y=[0,r.length],b=(0,a.useMemo)((()=>{var e,t;const n=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:6;if(0===e.length||t<1)return[];const n=[...e].sort(((e,t)=>e.date.localeCompare(t.date))).slice(-t),a=t-n.length,l=n[n.length-1],r=n.map((e=>(0,U.A)((0,U.A)({},e),{},{isProjected:!1})));if(0===a)return r;const o=N.c9.fromISO(l.date).startOf("month"),i=Array.from({length:a},((e,t)=>{const n=o.plus({months:t+1}).toISODate();return{date:null!==n&&void 0!==n?n:l.date,value:l.value,isProjected:!0}}));return[...r,...i]}(l),a=n.some((e=>e.isProjected)),o=null!==(e=null===(t=[...n].reverse().find((e=>!e.isProjected)))||void 0===t?void 0:t.date)&&void 0!==e?e:null;let s=-1;for(let l=n.length-1;l>=0;l-=1)if(!n[l].isProjected){s=l;break}return n.map(((e,t)=>{const n=((e,t,n,a)=>{if(0===t.length||!Number.isFinite(e))return 0;const l=uOe(e,t);if(l<0)return 0;const r=t[l].minValue,o=Number.isFinite(r)?r:null!==a&&void 0!==a?a:Math.min(e,0),i=((e,t,n)=>e<0||e>=t.length||e===t.length-1?n:t[e+1].minValue)(l,t,n),s=i-o;return l+(s<=0?.5:Math.min(1,Math.max(0,(e-o)/s)))})(e.value,r,E,i),l=a&&t===s;return{date:e.date,value:e.value,isProjected:e.isProjected,formattedDate:LLe(e,o),plotY:n,actualPlotY:e.isProjected?null:n,projectedPlotY:e.isProjected||l?n:null}}))}),[i,E,l,r]),x=b.some((e=>e.isProjected)),w=null!==(t=null===(n=[...b].reverse().find((e=>!e.isProjected)))||void 0===n?void 0:n.formattedDate)&&void 0!==t?t:null,C=(0,a.useMemo)((()=>r.map(((e,t)=>({minValue:t,color:xOe(e.color)})))),[r]),A=(0,a.useMemo)((()=>(e=>e.map(((e,t)=>t+.5)))(r)),[r]),I=(0,a.useMemo)((()=>mOe(r).slice(0,-1)),[r]);if(0===b.length||0===r.length)return null;
1const k="url(#".concat(v,")");return a.createElement(ya.u,{"data-external-id":"health-zone-time-series-chart",width:"100%",height:c},a.createElement(B1.X,{data:b,margin:{top:12,right:12,left:0,bottom:28}},I.map((e=>a.createElement(eb.e_,{key:e,y:e,stroke:"var(--chart-axis)",strokeOpacity:.9,ifOverflow:"visible",shape:e=>a.createElement(EOe,e)}))),a.createElement(kR.f,{id:v,yAxisId:0,domain:y,bands:C}),a.createElement(vOe,{idBase:h,data:b,zones:r}),a.createElement(Gy.N1,Object.assign({type:"linear",dataKey:"actualPlotY",stroke:k,strokeWidth:3,strokeLinecap:"round",connectNulls:!1,dot:!!x&&(e=>a.createElement(hOe,Object.assign({},e,{zones:r}))),activeDot:!x&&void 0,legendType:"none",isAnimationActive:!0},f("actualPlotY",!0))),x?a.createElement(Gy.N1,Object.assign({type:"linear",dataKey:"projectedPlotY",stroke:k,strokeWidth:3,strokeLinecap:"round",strokeDasharray:"0 5 4 0",connectNulls:!1,dot:!1,activeDot:!1,legendType:"none",isAnimationActive:!0},f("projectedPlotY",!0))):null,a.createElement(xa.W,{dataKey:"formattedDate",type:"category",tick:e=>a.createElement(yOe,Object.assign({},e,{latestActualLabel:w})),tickLine:!1,axisLine:!1,interval:0,padding:{left:8,right:8}}),a.createElement(wa.h,{domain:y,ticks:A,tick:a.createElement(fOe,{zones:r}),tickLine:!1,axisLine:!1,width:118,interval:0}),p?a.createElement(Aa.m,{content:e=>a.createElement(bOe,Object.assign({},e,{formatValue:u,formatTooltipDate:Ba.jY,zones:r}))}):null))},hOe=e=>{let t=e.cx,n=e.cy,l=e.payload,r=e.zones;if(void 0===t||void 0===n||!l||l.isProjected||null===l.actualPlotY)return null;const o=dOe(l.value,r);return o?a.createElement("circle",{"data-external-id":"actual-point-dot",cx:t,cy:n,r:4,fill:xOe(o.color),stroke:"var(--background-primary)",strokeWidth:2}):null},vOe=e=>{let t=e.idBase,n=e.data,l=e.zones;const r=(0,q_.Ph)(0),o=(0,q_.AD)(0),i=(0,a.useMemo)((()=>{if(!r||!o||n.length<2||0===l.length)return[];const e=o(0);if(void 0===e)return[];const a=((e,t)=>{var n;if(e.length<2||0===t.length)return[];const a=mOe(t).slice(1,-1),l=[];for(let r=0;r<e.length-1;r+=1){const o=e[r],i=e[r+1],s=i-o,c=[{t:0,y:o}];0!==s&&a.forEach((e=>{if(!(o<e&&i>e||o>e&&i<e))return;const t=(e-o)/s;t>0&&t<1&&c.push({t:t,y:e})})),c.push({t:1,y:i}),c.sort(((e,t)=>e.t-t.t));for(let e=0;e<c.length-1;e+=1){const a=c[e],o=c[e+1];if(a.t===o.t)continue;const i=(a.y+o.y)/2,s=pOe(i,t.length),d=null===(n=t[Math.max(0,s)])||void 0===n?void 0:n.color;d&&l.push({leftIndex:r,t0:a.t,t1:o.t,plotY0:a.y,plotY1:o.y,color:d})}}return l})(n.map((e=>e.plotY)),l);return a.flatMap(((a,l)=>{const i=n[a.leftIndex],s=n[a.leftIndex+1],c=r(i.formattedDate,{position:"middle"}),d=r(s.formattedDate,{position:"middle"});if(void 0===c||void 0===d)return[];const u=c+a.t0*(d-c),m=c+a.t1*(d-c),p=o(a.plotY0),g=o(a.plotY1);return void 0===p||void 0===g?[]:[{key:"".concat(i.date,"-").concat(s.date,"-").concat(a.t0,"-").concat(a.t1),gradientId:"".concat(t,"-seg-").concat(l),color:xOe(a.color),x0:u,y0:p,x1:m,y1:g,lineTopY:Math.min(p,g),baselineY:e}]}))}),[n,t,r,o,l]);return 0===i.length?null:a.createElement("g",{"data-external-id":"zone-segment-area-fills","aria-hidden":!0},a.createElement("defs",null,i.map((e=>a.createElement("linearGradient",{key:e.gradientId,id:e.gradientId,gradientUnits:"userSpaceOnUse",x1:0,y1:e.lineTopY,x2:0,y2:e.baselineY},a.createElement("stop",{offset:"0%",stopColor:e.color,stopOpacity:.12}),a.createElement("stop",{offset:"70%",stopColor:e.color,stopOpacity:.03}),a.createElement("stop",{offset:"100%",stopColor:e.color,stopOpacity:0}))))),i.map((e=>a.createElement("polygon",{key:e.key,fill:"url(#".concat(e.gradientId,")"),points:"".concat(e.x0,",").concat(e.y0," ").concat(e.x1,",").concat(e.y1," ").concat(e.x1,",").concat(e.baselineY," ").concat(e.x0,",").concat(e.baselineY)}))))},fOe=e=>{let t=e.x,n=void 0===t?0:t,l=e.y,r=void 0===l?0:l,o=e.payload,i=e.zones;if(void 0===o)return null;const s=i[Math.floor(o.value)];return s?a.createElement("g",{"data-external-id":"zone-axis-tick",transform:"translate(".concat(n,",").concat(r,")")},a.createElement("line",{x1:-96,y1:-12,x2:-96,y2:12,stroke:xOe(s.color),strokeWidth:4,strokeLinecap:"round"}),a.createElement("text",{x:-82,y:0,dy:4,textAnchor:"start",className:"fill-content-secondary text-sm"},s.label)):null},EOe=e=>{let t=e.x1,n=void 0===t?0:t,l=e.y1,r=void 0===l?0:l,o=e.x2,i=void 0===o?0:o,s=e.y2,c=void 0===s?0:s;return a.createElement("line",{"data-external-id":"zone-grid-line",x1:n-118,y1:r,x2:i,y2:c,stroke:"var(--chart-axis)",strokeOpacity:.9})},yOe=e=>{let t=e.x,n=void 0===t?0:t,l=e.y,r=void 0===l?0:l,o=e.payload,i=e.latestActualLabel;if(!o)return null;const s=o.value===i;return a.createElement("text",{"data-external-id":"health-zone-x-tick",x:n,y:r,dy:12,textAnchor:"middle",fontSize:14,className:s?"fill-content-primary font-medium":"fill-content-secondary"},o.value)},bOe=e=>{var t;let n=e.active,l=e.formatValue,r=e.formatTooltipDate,o=e.zones,i=e.payload;const s=null===i||void 0===i||null===(t=i[0])||void 0===t?void 0:t.payload;if(!n||!s||s.isProjected)return null;const c=dOe(s.value,o);return a.createElement(Sa.II,{"data-external-id":"health-zone-tooltip-content",active:n},a.createElement("div",{className:"flex flex-col gap-2xs"},a.createElement(fe.c8D,{size:"sm",color:"secondary"},r(s.date)),a.createElement("div",{className:"flex items-baseline gap-xs"},a.createElement(fe.c8D,{size:"lg",weight:"medium"},l(s.value)),c?a.createElement(fe.c8D,{size:"sm",className:"text-content-secondary"},c.label):null)))},xOe=e=>"var(--".concat(e,")"),wOe="over_time",COe=e=>{let t=e.insight,n=e.series,l=e.isLoading,r=e.error,i=e.zones,s=e.topZoneCap,c=e.bottomZoneFloor,d=e.headline,u=void 0===d?null:d,m=e.goalCopy,p=void 0===m?null:m,g=e.fallbackHeadline,h=void 0===g?null:g,v=e.formatTooltipValue;const f=(0,a.useState)(wOe),E=(0,o.A)(f,2),y=E[0],b=E[1];let x=u;x||l||(x=null!==h&&void 0!==h?h:null);const w=(0,a.useMemo)((()=>[{value:wOe,label:_t.xB.COMPONENT_CHART_VIEW_OVER_TIME},{value:"compare",label:_t.xB.COMPONENT_CHART_VIEW_COMPARE,disabled:!0}]),[]);return a.createElement("div",{"data-external-id":"health-zone-component-chart-panel",className:"mt-sm flex flex-col gap-md"},a.createElement("div",{className:"flex flex-col gap-2xs"},x?a.createElement(fe.c8D,{size:"xl",weight:"medium"},x):null,t?a.createElement(fe.c8D,{size:"base",color:"secondary"},t):null,p?a.createElement(fe.c8D,{size:"sm",color:"secondary"},p):null),a.createElement(fe.T36,{className:"self-end",variant:"pill",fitContent:!0,value:y,onValueChange:e=>b(e),items:w,"aria-label":_t.xB.COMPONENT_CHART_VIEW_ARIA}),y===wOe?a.createElement(AOe,{series:n,isLoading:l,error:r,zones:i,topZoneCap:s,bottomZoneFloor:c,formatTooltipValue:v}):a.createElement("div",{className:"flex min-h-52.5 items-center justify-center rounded-default bg-background-secondary"},a.createElement(fe.c8D,{size:"sm",color:"secondary"},_t.xB.COMPONENT_CHART_COMPARE_COMING_SOON)))},AOe=e=>
1{let t=e.series,n=e.isLoading,l=e.error,r=e.zones,o=e.topZoneCap,i=e.bottomZoneFloor,s=e.formatTooltipValue;if(n)return a.createElement("div",{"data-external-id":"over-time-body",className:"flex min-h-52.5 items-center justify-center"},a.createElement(fe.ix7,null));if(l)return a.createElement(SQ.W,{"data-external-id":"over-time-body",message:_t.xB.COMPONENT_CHART_LOAD_ERROR});if(0===t.length)return a.createElement("div",{"data-external-id":"over-time-body",className:"flex min-h-52.5 items-center justify-center rounded-default bg-background-secondary"},a.createElement(fe.c8D,{size:"sm",color:"secondary"},_t.xB.COMPONENT_CHART_EMPTY));const c=t.map((e=>e.value)),d=((e,t)=>{const n=t.filter((e=>Number.isFinite(e)));return 0===n.length?e:Math.max(e,...n)})(o,c),u=void 0===i?void 0:((e,t)=>{const n=t.filter((e=>Number.isFinite(e)));return 0===n.length?e:Math.min(e,...n)})(i,c);return a.createElement(gOe,{"data-external-id":"over-time-body",data:t,zones:r,topZoneCap:d,bottomZoneFloor:u,formatValue:s})},IOe={at_risk:"credit-score-line-poor",needs_work:"credit-score-line-fair",fair:"credit-score-line-good",good:"credit-score-line-great",excellent:"credit-score-line-excellent"},kOe=e=>{let t=e.chart,n=e.insight,l=e.fallbackHeadline,r=void 0===l?null:l;return a.createElement(SOe,{"data-external-id":"monarch-method-component-health-zone-chart",chart:t,insight:n,fallbackHeadline:r})},SOe=e=>{var t,n,l,r;let o=e.chart,i=e.insight,s=e.fallbackHeadline,c=void 0===s?null:s;const d=(e=>(null!==e&&void 0!==e?e:[]).map((e=>{var t,n;return{key:e.key,label:e.label,minValue:null!==(t=e.minValue)&&void 0!==t?t:Number.NEGATIVE_INFINITY,color:null!==(n=IOe[e.key])&&void 0!==n?n:IOe.at_risk}})))(o.zones),u=(null!==(t=o.series)&&void 0!==t?t:[]).map((e=>({date:e.date,value:e.value,displayValue:e.displayValue}))),m=new Map(u.map((e=>[e.value,e.displayValue])));return a.createElement(COe,{"data-external-id":"monarch-method-component-health-zone-chart-view",metricValue:o.metricValue,insight:i,series:u,isLoading:!1,error:null,zones:d,topZoneCap:o.topZoneCap,bottomZoneFloor:null!==(n=o.bottomZoneFloor)&&void 0!==n?n:void 0,headline:null!==(l=o.headline)&&void 0!==l?l:null,goalCopy:null!==(r=o.goalCopy)&&void 0!==r?r:null,fallbackHeadline:c,formatTooltipValue:e=>{var t;return null!==(t=m.get(e))&&void 0!==t?t:"".concat(e)}})},NOe=e=>{var t,n,l,r;let o=e.component;const i=null!==(t=null!==(n=o.driver)&&void 0!==n?n:o.bandLabel)&&void 0!==t?t:null,s=null!==(l=o.detail)&&void 0!==l?l:o.insight,c=null!==(r=o.chart)&&void 0!==r?r:null;return a.createElement(fe.xz6,{"data-external-id":"monarch-method-pillar-component-card"},a.createElement(fe.xz6.Header,null,a.createElement(fe.xz6.Title,null,o.label),s?a.createElement(fe.Yvj,{content:s},a.createElement(fe.SO$,{"aria-label":_t.xB.COMPONENT_INFO_ARIA(o.label),variant:"default",size:"xs"},a.createElement(fe.ucZ,{size:"sm"}))):null,a.createElement(fe.xz6.Action,null,a.createElement(fe.c8D,{size:"sm",weight:"medium",color:"secondary"},_t.xB.COMPONENT_POINTS_SUMMARY(o.points,o.maxPoints)))),a.createElement(fe.xz6.Content,{className:"gap-sm"},c?a.createElement(kOe,{chart:c,insight:o.insight,fallbackHeadline:i}):a.createElement(a.Fragment,null,i?a.createElement(fe.c8D,{size:"xl",weight:"medium"},i):null,o.insight?a.createElement(fe.c8D,{size:"base",color:"secondary"},o.insight):null,a.createElement("div",{className:"mt-sm flex h-52 items-center justify-center rounded-default bg-background-secondary"},a.createElement(fe.c8D,{size:"sm",color:"secondary"},_t.xB.COMPONENT_CHART_PLACEHOLDER)))))},TOe=e=>{let t=e.dataPoints;return a.createElement(fe.xz6,{"data-external-id":"monarch-method-pillar-data-card"},a.createElement(fe.xz6.Header,null,a.createElement(fe.xz6.Title,null,_t.xB.DATA_BEHIND_TITLE)),a.createElement(fe.xz6.Content,{className:"gap-default"},0===t.length?a.createElement(fe.c8D,{size:"sm",color:"secondary"},_t.xB.DATA_BEHIND_EMPTY):t.map((e=>a.createElement("div",{key:e.label,className:"flex items-center gap-default"},a.createElement(fe.c8D,{size:"sm",color:"secondary",className:"flex-1"},e.label),a.createElement(fe.c8D,{size:"base",weight:"medium",className:"text-right"},e.displayValue))))))},_Oe=e=>{let t=e.pillar;const n=kLe(t),l=n.label.toLowerCase(),r=[t.label,n.statusConnector,l].filter(
1Boolean).join(" ");return a.createElement(fe.xz6,{"data-external-id":"monarch-method-pillar-detail-header"},a.createElement("div",{className:"flex flex-col gap-lg p-xl md:flex-row md:items-center md:gap-xl"},a.createElement(_Le,{variant:"pillar",size:180,score:t.score,maxScore:t.maxScore,className:"shrink-0"}),a.createElement("div",{className:"flex flex-1 flex-col gap-2xs"},a.createElement(fe.c8D,{size:"xl",weight:"medium","aria-label":r},t.label,n.statusConnector?" ".concat(n.statusConnector):""," ",a.createElement(fe.c8D,{render:a.createElement("span",null),size:"xl",weight:"medium",color:n.color},l)),a.createElement(fe.c8D,{size:"base",color:"secondary"},t.description),a.createElement(SLe,{delta:t.pointsChangeThisMonth,className:"mt-xs"})),a.createElement(fe.SO$,{"aria-label":_t.xB.PILLAR_SHARE_ARIA,variant:"default",size:"sm",className:"self-start"},a.createElement(fe.pIK,null))))},DOe=(0,Qt.J)('\n  query Common_MonarchMethodPillarScore($key: MonarchMethodPillarKeyEnum!) {\n    monarchMethodPillarScore(key: $key) {\n      key\n      label\n      score\n      maxScore\n      status\n      # Fixed one-liner describing what the pillar measures \u2014 always present.\n      description\n      # Month-to-date delta; null = no baseline snapshot yet this month.\n      pointsChangeThisMonth\n      # Curated "data behind this score". Render displayValue verbatim; may be empty.\n      dataPoints {\n        label\n        displayValue\n      }\n      components {\n        key\n        label\n        points\n        maxPoints\n        bandLabel\n        # Pre-formatted, render-verbatim strings: driver is the headline figure,\n        # insight the supporting sentence, detail an optional explanation. All nullable.\n        driver\n        insight\n        detail\n        chart {\n          pillarKey\n          componentKey\n          metricValue\n          topZoneCap\n          bottomZoneFloor\n          headline\n          goalCopy\n          zones {\n            key\n            label\n            minValue\n          }\n          series {\n            date\n            value\n            displayValue\n          }\n        }\n      }\n    }\n  }\n'),ROe=new Set(Object.values(Ee.CJN)),MOe="Monarch Method",LOe=()=>{var e,t;const n=(0,l.g)().pillarKey,o=void 0!==(i=n)&&ROe.has(i)?i:null;var i;const s=(e=>{var t;const n=(0,et.I)(DOe,{skip:null===e,variables:{key:null!==e&&void 0!==e?e:Ee.CJN.CASH_FLOW},fetchPolicy:"cache-and-network",nextFetchPolicy:"cache-first"}),a=n.data,l=n.isLoadingInitialData,r=n.isNetworkRequestInFlight,o=n.error,i=n.refetch;return{pillar:null!==(t=null===a||void 0===a?void 0:a.monarchMethodPillarScore)&&void 0!==t?t:null,isLoadingInitialData:l,isRefreshing:r,error:o,refetch:i}})(o),c=s.pillar,d=s.isLoadingInitialData,u=s.error;return a.createElement(rG.Y,{"data-external-id":"monarch-method-pillar-detail",name:"Monarch Method Pillar",parentRoute:MOe,overrideTitle:null!==(e=null===c||void 0===c?void 0:c.label)&&void 0!==e?e:MOe,overrideHtmlTitle:null!==(t=null===c||void 0===c?void 0:c.label)&&void 0!==t?t:MOe},a.createElement("div",{className:"w-full p-lg"},(0,r.YW)({pillarKey:o,isLoadingInitialData:d,error:u,pillar:c}).with({pillarKey:r.P.nullish},(()=>a.createElement(SQ.W,{message:_t.xB.PILLAR_NOT_FOUND}))).with({isLoadingInitialData:!0},(()=>a.createElement("div",{className:"flex flex-1 items-center justify-center py-3xl"},a.createElement(fe.ix7,null)))).with({error:r.P.nonNullable},(()=>a.createElement(SQ.W,{message:_t.xB.SCORE_LOAD_ERROR}))).with({pillar:r.P.nonNullable},(e=>{let t=e.pillar;return a.createElement("div",{className:"flex flex-col gap-lg"},a.createElement(_Oe,{pillar:t}),a.createElement("div",{className:"grid grid-cols-1 gap-lg lg:grid-cols-[minmax(0,1fr)_20rem]"},a.createElement("div",{className:"flex flex-col gap-lg"},t.components.map((e=>a.createElement(NOe,{key:e.key,component:e})))),a.createElement("div",{className:"flex flex-col gap-lg"},a.createElement(sOe,{pillarKey:t.key,label:t.label,description:t.description}),a.createElement(TOe,{dataPoints:t.dataPoints}))))}
1)).otherwise((()=>a.createElement(SQ.W,{message:_t.xB.PILLAR_NOT_FOUND})))))},OOe=e=>{let t=e.onCompleted;const n="dark"===(0,lm.a)()?"https://monarch-static-assets-us-east-2.s3.amazonaws.com/animations/budgeting-animation-dark.webm":"https://monarch-static-assets-us-east-2.s3.amazonaws.com/animations/budgeting-animation.webm";return a.createElement(Rc.L,{"data-external-id":"budget-creation-success-card",title:"Your plan has been created",description:"Here's how you can use your historical spending to set your planned amounts for each category:"},a.createElement("div",{className:"p-xl"},a.createElement("video",{key:n,className:"w-full rounded-md",src:n,autoPlay:!0,loop:!0,muted:!0,playsInline:!0,preload:"auto"})),a.createElement(Cq.R,null,a.createElement(cu.WT,{onClick:t},"Okay")))};var POe;const BOe=e=>{let t=e.showProgressColumn;return a.createElement(a.Fragment,null,t&&a.createElement("rect",{x:"40%",y:"30",rx:"4",ry:"4",width:"100",height:"8"}),a.createElement("rect",{x:"57%",y:"24",rx:"5",ry:"5",width:"50",height:"20"}),a.createElement("rect",{x:"72%",y:"24",rx:"5",ry:"5",width:"50",height:"20"}),a.createElement("rect",{x:"87%",y:"24",rx:"5",ry:"5",width:"50",height:"20"}))},zOe=e=>{let t=e.showProgressColumn;return a.createElement(UOe,{"data-external-id":"category-row-loading"},a.createElement(Rr.s,null,a.createElement("circle",{cx:"34",cy:"34",r:"12"}),a.createElement("rect",{x:"64",y:"24",rx:"5",ry:"5",width:"23%",height:"20"}),a.createElement(BOe,{showProgressColumn:t})))},FOe=e=>{let t=e.showProgressColumn;return a.createElement(VOe,{"data-external-id":"category-group-header-loading"},a.createElement(Rr.s,null,a.createElement("rect",{x:"64",y:"20",rx:"5",ry:"5",width:"23%",height:"28"}),a.createElement(BOe,{showProgressColumn:t})))},GOe=()=>a.createElement(WOe,{"data-external-id":"category-group-footer-loading"},a.createElement(Rr.s,null,a.createElement(BOe,{showProgressColumn:!1}))),YOe=e=>{let t=e.showProgressColumn;return a.createElement(jOe,{"data-external-id":"category-group-loading"},a.createElement(FOe,{showProgressColumn:t}),Dr().range(3).map((e=>a.createElement(zOe,{key:e,showProgressColumn:t}))),a.createElement(GOe,null))},UOe=u.default.div.withConfig({displayName:"BudgetListLoading__CategoryRowRoot",componentId:"sc-4kjwih-0"})(["height:68px;border-bottom:1px solid ",";"],vt.Ee.color.divider.primary),VOe=u.default.div.withConfig({displayName:"BudgetListLoading__CategoryGroupHeaderRoot",componentId:"sc-4kjwih-1"})(["height:68px;border-bottom:1px solid ",";"],vt.Ee.color.divider.primary),WOe=$d.s.div(POe||(POe=(0,wc.A)(["h-17"]))),jOe=(0,u.default)(Xl.AM).withConfig({displayName:"BudgetListLoading__CategoryGroupRoot",componentId:"sc-4kjwih-2"})([":not(:last-child){margin-bottom:",";}"],(e=>e.theme.spacing.gutter)),HOe=u.default.div.withConfig({displayName:"BudgetListLoading__Root",componentId:"sc-4kjwih-3"})(["margin-top:",";"],(e=>e.theme.spacing.gutter));var KOe=n(36488);const qOe=e=>{let t=e.date,n=e.onCompleted,l=e.budgetStatus;const r=(0,i.n)(p8.fG,{variables:{input:{startDate:t.toISODate(),timeframe:Ee.SPj.MONTH}},onCompleted:n}),s=(0,o.A)(r,2),c=s[0],d=s[1].loading;return a.createElement(jpe,{"data-external-id":"create-budget-card",icon:"map",title:"Create a budget",subtitle:(0,KOe.O8)(l),button:{text:"Create my budget",onClick:c,loading:d}})};var $Oe=n(43238),ZOe=n(77656),JOe=n(23651);const XOe=e=>{let t=e.onDone,n=void 0===t?RQ.l:t;const r=(0,a.useState)(!1),s=(0,o.A)(r,2),c=s[0],d=s[1],u=(0,a.useState)(!1),m=(0,o.A)(u,2),p=m[0],g=m[1],h=(0,JOe.w)(),v=h.budgetSystem,f=h.budgetApplyToFutureMonthsDefault,E=h.loading,y=h.error,b=h.updateBudgetSettings,x=h.updateLoading,w=(0,l.Zp)(),C=(0,i.n)(lPe,{refetchQueries:[ZOe.f],awaitRefetchQueries:!0}),A=(0,o.A)(C,2),k=A[0],S=A[1].loading,T=(0,i.n)(rPe,{refetchQueries:[ZOe.f],awaitRefetchQueries:!0}),_=(0,o.A)(T,2),D=_[0],R=_[1].loading;if(y)return tPe;if(E)return ePe;const M={budgetSystem:v,budgetApplyToFutureMonthsDefault:f};return a.createElement(Eu.lV,{"data-external-id":"budget-settings-form",initialValues:M,onSubmit:async e=>{await b(e,{onDone:n})}},a.createElement(QOe,null,a.createElement("div",{className:"mb-default flex flex-col gap-default"},a.createElement($Oe.c,{name:"budgetSystem",label:"System",options:[{value:Ee.Zmn.FIXED_AND_FLEX,label:"Flex Budget",description:"Simplify your budget by focusing on your flexible expense number.",rightAccessory:a.createElement(Oc.D,{color:"orange"},"Recommended")},{value:Ee.Zmn.GROUPS_AND_CATEGORIES,label:"Category Budget",description:"Budget every category individually, the traditional way."}]}),a.createElement($Oe.c,{name:"budgetApplyToFutureMonthsDefault",label:"By default, apply budget changes to",options:[{value:!1,label:_t.o3.CHANGE_OPTIONS.THIS_MONTH.LABEL,description:_t.o3.CHANGE_OPTIONS.THIS_MONTH.DESCRIPTION},{value:!0,label:_t.o3.CHANGE_OPTIONS.ALL_FUTURE_MONTHS.LABEL,description:_t.o3.CHANGE_OPTIONS.ALL_FUTURE_MONTHS.DESCRIPTION}]})),a.createElement(aPe,null,"More options"),a.createElement("div",{className:"flex flex-col gap-default"},a.createElement(aye.Nx,{rightAccessory:a.createElement(nPe,{onClick:()=>d(!0)},"Recalculate"),title:"Recalculate default budgets",subtitle:a.createElement(a.Fragment,null,"Use your historical averages to automatically generate a new default budget. This will override all existing budget amounts.")}),a.createElement(aye.Nx,{rightAccessory:a.createElement(nPe,{onClick:()=>g(!0)},"Clear all"),title:"Clear all budget values",subtitle:a.createElement(a.Fragment,null,"Clear all budget values going back to the starting month and start over from scratch.")}),a.createElement(aye.Nx,{rightAccessory:a.createElement(nPe,{onClick:()=>w(I.JZ.budget.onboarding())},"Start setup"),title:"Budget walkthrough",subtitle:a.createElement(a.Fragment,null,"Modify your budget step by step with explanations for how budgeting works in Monarch.")})),c&&a.createElement(um.b,{onClose:()=>d(!1)},(e=>{let t=e.close;
1return a.createElement(xC.$,{title:"Are you sure you want to recalculate?",confirm:"Recalculate",onCancel:t,onConfirm:async()=>{await k({variables:{input:{startDate:N.c9.local().toISODate(),filters:void 0,overwriteExisting:void 0}}}),t(),n()},useDangerButton:!0,isLoading:S},"This will override all existing budget amounts and cannot be undone.")})),p&&a.createElement(um.b,{onClose:()=>g(!1)},(e=>{let t=e.close;return a.createElement(xC.$,{title:"Are you sure you want to clear all?",confirm:"Clear all",onCancel:t,onConfirm:async()=>{await D({variables:{input:{startDate:N.c9.local().toISODate()}}}),t(),n()},useDangerButton:!0,isLoading:R},"This will clear all existing budget amounts and cannot be undone.")}))),a.createElement(Cq.R,null,a.createElement(wt.Xb,{onClick:n},"Cancel"),a.createElement(CJ.I,{size:"small",pending:x},"Save")))},QOe=u.default.div.withConfig({displayName:"BudgetSettingsForm__Root",componentId:"qq4qy7-0"})(["padding:",";"],vt.YK.xlarge),ePe=a.createElement(QOe,null,a.createElement(p.i,{className:"mx-auto block"})),tPe=a.createElement(QOe,null,"Sorry, there was an error loading the settings."),nPe=(0,u.default)(wt.Xb).withConfig({displayName:"BudgetSettingsForm__StyledButton",componentId:"qq4qy7-1"})(["text-wrap:nowrap;"]),aPe=(0,u.default)(xt.v).attrs({size:"small"}).withConfig({displayName:"BudgetSettingsForm__SectionLabel",componentId:"qq4qy7-2"})(["display:block;font-weight:",";margin-bottom:",";"],(e=>e.theme.fontWeight.medium),vt.YK.xsmall),lPe=Ee.kQg,rPe=Ee.kRj;var oPe=n(52337);const iPe=e=>{let t=e.className,n=e.onLeft,l=e.onRight;return a.createElement("div",{"data-external-id":"left-right-switcher",className:(0,q.cn)("flex items-center gap-2xs",t)},a.createElement(fe.SO$,{"aria-label":"Previous",onClick:n},a.createElement(fe.qzE,null)),a.createElement(fe.SO$,{"aria-label":"Next",onClick:l},a.createElement(fe.Fug,null)))},sPe=[f8.s.SingleMonth,f8.s.Monthly,f8.s.Yearly],cPe={[f8.s.SingleMonth]:"Month",[f8.s.Monthly]:"Year",[f8.s.Yearly]:"Decade"},dPe=e=>{let t=e.timeframe,n=e.onChangeTimeframe;return a.createElement(Vi.Md,{"data-external-id":"plan-header-timeframe-toggle",attached:!0,"aria-label":"Plan timeframe",value:[t],onValueChange:e=>{const a=e[0];a&&a!==t&&n(a)}},sPe.map((e=>a.createElement(Vi.H7,{key:e,value:e},cPe[e]))))},uPe=a.memo(dPe),mPe=["onClickToday","timeframe"],pPe=e=>{let t=e.onClickToday,n=e.timeframe,r=(0,En.A)(e,mPe);const i=(0,l.Zp)(),s=(0,f8.g)(),c=(0,o.A)(s,2),d=c[0],u=c[1];return a.createElement("div",{"data-external-id":"plan-header-controls",className:"flex items-center"},a.createElement(iPe,Object.assign({className:"mx-xs"},r)),a.createElement(fe.XZZ,{variant:"default",onClick:t},"Today"),a.createElement(fe.AVK,{orientation:"vertical",color:"secondary",className:"mx-sm h-default"}),a.createElement(uPe,{timeframe:n,onChangeTimeframe:e=>u.setTimeframe(e,{pushHistory:!0})}),a.createElement(fe.AVK,{orientation:"vertical",color:"secondary",className:"mx-sm h-default"}),a.createElement(fe.XZZ,{variant:"default",icon:a.createElement(fe.z79,null),onClick:()=>i(I.JZ.plan.settings({queryParams:{date:d.highlightedDate.toISODate()}}))},"Settings"))},gPe=e=>{let t=e.title,n=e.timeframe,l=e.onClickToday,r=e.onPanLeft,o=e.onPanRight;return a.createElement(uS.Y9,{"data-external-id":"plan-header"},a.createElement("div",{className:"flex flex-1 items-center justify-between"},a.createElement("div",{className:"flex flex-1 items-center"},t),a.createElement("div",{className:"flex flex-1 justify-end"},a.createElement(pPe,{onClickToday:l,onLeft:r,onRight:o,timeframe:n}))))};var hPe=n(92423),vPe=n(55099);const fPe=e=>{let t=e.fieldCellProps,n=e.toggleFieldProps,l=e.className,r=e.children;const o=t.title,i=t.subtitle,s=t.rightAccessory,c=(0,hu.x)(),d=c.values,u=c.getFieldMeta,m=c.setFieldValue,p=c.handleChange,g=c.handleBlur,h=n.name,v=(0,a.useCallback)((e=>{const t=u(h).value;m(h,!t),p(e),g(e)}),[u,h,m,p,g]);return a.createElement(yPe,{"data-external-id":"field-cell-with-toggle"},a.createElement(EPe,{title:a.createElement(bPe,{role:"button",tabIndex:0,onClick:e=>{e.stopPropagation(),v(e)},onKeyDown:e=>{"Enter"!==e.key&&" "!==e.key||(e.stopPropagation(),v(e))}},o),subtitle:i&&a.createElement(xPe,null,i),rightAccessory:null!==s&&void 0!==s?s:a.createElement(vPe.Y,Object.assign({id:h},n,{hideLabel:!0})),className:l},!!d[h]&&r))},EPe=(0,u.default)(aye.Nx).attrs({"data-sc-tw":"FieldCellWithToggle__StyledFieldCell"}).withConfig({displayName:"FieldCellWithToggle__StyledFieldCell",componentId:"schn0m-0"})([""]),yPe=u.default.div.withConfig({displayName:"FieldCellWithToggle__Root",componentId:"schn0m-1"})(["cursor:default;&:hover [data-sc-tw~='FieldCellWithToggle__StyledFieldCell']{","}[data-sc-tw~='FieldCell__GroupLeft']{flex-grow:1;}&:not(:last-child){border-bottom:1px solid ",";}"],Pxe.UO,vt.Ee.color.divider.primary),bPe=u.default.span.withConfig({displayName:"FieldCellWithToggle__Title",componentId:"schn0m-2"})(["cursor:pointer;display:block;width:100%;"]),xPe=u.default.div.withConfig({displayName:"FieldCellWithToggle__Subtitle",componentId:"schn0m-3"})([""]);var wPe=n(87683);const CPe=(0,Xe._)("PlanContext"),APe=(0,o.A)(CPe,2),IPe=APe[0],kPe=APe[1],SPe=e=>{let t=e.onClose;const n=kPe().refetch,l=(0,a.useMemo)((()=>(0,wPe.Cx)()),[]),r=(0,a.useMemo)((()=>(0,Ba.EY)()),[]),s=(0,et.I)(TPe,{fetchPolicy:"cache-first"}),c=s.data,d=s.isLoadingInitialData,u=null!==c&&void 0!==c?c:{},m=u.budgetSystem,g=u.flexExpenseRolloverPeriod,h=null!==g&&void 0!==g?g:{},v=h.startMonth,f=h.startingBalance,E=(0,i.n)(_Pe),y=(0,o.A)(E,2),b=y[0],x=y[1].loading,w=(0,a.useMemo)((()=>({rolloverEnabled:(0,Tr.A)(g),rolloverStartMonth:null!==v&&void 0!==v?v:r,rolloverStartingBalance:null!==f&&void 0!==f?f:0})),[g,v,f,r]),C=(0,a.useCallback)((async e=>{await b({variables:{input:{budgetSystem:m,budgetApplyToFutureMonthsDefault:void 0,rolloverEnabled:e.rolloverEnabled,rolloverStartMonth:e.rolloverStartMonth,rolloverStartingBalance:e.rolloverStartingBalance}},updateQueries:{Web_GetFlexibleGroupRolloverSettings:(e,t)=>{var n,a;let l=t.mutationResult;return(0,U.A)((0,U.A)({},e),{},{flexExpenseRolloverPeriod:null===(n=l.data)||void 0===n||null===(a=n.updateBudgetSettings)||void 0===a?void 0:a.budgetRolloverPeriod})}},onCompleted:()=>{n(),t()}})}),[m,b,t,n]);return a.createElement(Rc.L,{"data-external-id":"edit-flexible-group-modal-card",title:"Flexible budget",hideBottomBorder:!0},d?a.createElement("div",{className:"flex items-center justify-center p-4xl"},a.createElement(p.i,null)):a.createElement(Eu.lV,{initialValues:w,onSubmit:C,preventSubmitWhileSubmitting:!0},a.createElement(NPe,null,a.createElement(fPe,{toggleFieldProps:{name:"rolloverEnabled"},fieldCellProps:{title:_t.o3.ROLLOVER.TOGGLE.LABEL,subtitle:a.createElement(xt.v,null,_t.o3.ROLLOVER.TOGGLE.DESCRIPTION," ",a.createElement(wb.gz,{href:VF.t0,target:"_blank"},"Learn more"),".")}},a.createElement("div",{className:"flex flex-col gap-default"},a.createElement(tC.zB.Select,{name:"rolloverStartMonth",label:_t.o3.ROLLOVER.STARTING_MONTH.LABEL,description:_t.o3.ROLLOVER.STARTING_MONTH.DESCRIPTION,options:l}),a.createElement(tC.zB.Currency,{name:"rolloverStartingBalance",label:_t.o3.ROLLOVER.STARTING_BALANCE.LABEL,description:_t.o3.ROLLOVER.STARTING_BALANCE.DESCRIPTION,min:0})))),a.createElement(Cq.R,null,a.createElement(wt.Xb,{onClick:t},"Cancel"),a.createElement(CJ.I,{size:"small",pending:x}
1,"Save"))))},NPe=(0,u.default)(m.g).withConfig({displayName:"EditFlexibleGroupModalCard__Root",componentId:"sc-1ow176f-0"})(["padding:",";padding-top:0;"],(e=>e.theme.spacing.xlarge)),TPe=Ee.xmu,_Pe=Ee.USo;var DPe=n(69987);const RPe=(0,u.default)(DPe.n).withConfig({displayName:"PlanRowTitleUnplanned__PlanRowTitleGray",componentId:"sc-1xemz1j-0"})(["color:",";position:relative;height:100%;"],vt.yW.textLight),MPe=u.default.div.withConfig({displayName:"PlanRowTitleUnplanned__TriangleArrow",componentId:"sc-1xemz1j-1"})(["--size:12px;content:'';position:absolute;width:var(--size);height:var(--size);left:18px;top:calc(var(--size) / 2 * -1);transform:rotate(45deg);background:",";border-bottom:1px solid ",";border-right:1px solid ",";"],vt.yW.gray1,vt.Ee.color.divider.primary,vt.Ee.color.divider.primary),LPe=e=>{let t=e.unplannedCount,n=e.isExpanded,l=e.onClick;return a.createElement(RPe,{"data-external-id":"plan-row-title-unplanned",onClick:l,icon:a.createElement(sl.ZQ,{size:16,name:n?"eye-off":"eye"}),className:"overflow-visible",size:"sm"},n&&a.createElement(MPe,null),n?"Collapse":"Show"," ",t," unbudgeted")},OPe=a.memo(LPe);var PPe=n(63953),BPe=n(6545),zPe=n(54338),FPe=n(41228);const GPe=e=>{var t;let n=e.accountId,l=e.value,r=e.appliedToFuture,o=e.onCheckApplyToFuture;const i=(0,Wbe.C)({id:"DebtPaydownMonthlyBudgetAmounts:".concat(n),fragment:FPe.xF,fragmentName:"DebtPaydownMonthlyBudgetAmountsFields"});if(null===i||void 0===i||!i.account)return null;const s=i.account,c=null!==(t=s.interestRate)&&void 0!==t?t:s.apr;return a.createElement(fe.xz6,{"data-external-id":"debt-paydown-budget-popover",className:"w-88 border border-divider-primary"},a.createElement(gm.n,{onMouseDown:!0,preventDefault:!0},a.createElement(fe.xz6.Content,{className:"gap-default"},a.createElement("div",{className:"flex items-center gap-sm"},a.createElement(Gl.v,{size:36,logoUrl:s.logoUrl,icon:s.icon}),a.createElement("div",{className:"flex flex-1 flex-col gap-2xs"}
1,a.createElement(xt.v,{size:"small",weight:"medium",clampLines:1},s.displayName),a.createElement("div",{className:"flex items-center gap-xs"},a.createElement(xt.v,{size:"xsmall",color:"content.secondary"},a.createElement(hl.t,{value:s.displayBalance,round:!0}))))),a.createElement("div",{className:"flex gap-xs"},(0,Tr.A)(s.minimumPayment)&&a.createElement("div",{className:"flex flex-1 gap-xs"},a.createElement(YPe,{label:"Min. monthly payment"},a.createElement("span",null,(0,rl.vv)(s.minimumPayment)))),(0,Tr.A)(c)&&a.createElement("div",{className:"flex flex-1 gap-xs"},a.createElement(YPe,{label:"Interest rate"},a.createElement("span",null,nb(c))))),a.createElement(z7.P,{height:1,text:""}),a.createElement(zPe.X,{appliedToFuture:r,onCheckApplyToFuture:o,value:l}))))},YPe=e=>{let t=e.label,n=e.children;return a.createElement("div",{"data-external-id":"stat-box",className:"flex flex-1 flex-col gap-2xs rounded-md bg-background-secondary p-xs"},a.createElement(xt.v,{size:"xsmall",weight:"medium"},n),a.createElement(xt.v,{size:"xsmall",color:"content.secondary"},t))};var UPe=n(21691);const VPe=u.default.div.withConfig({displayName:"DividerLine__DEPRECATEDDividerLine",componentId:"sc-1o8scoc-0"})(["height:16px;width:1px;background-color:",";align-self:center;margin-inline:",";"],vt.Ee.color.border.secondary,vt.YK.xxsmall),WPe=e=>{let t=e.goal,n=e.totalPlannedAmount;const l=t.targetAmount?(0,rl.T3)(t.targetAmount):"No target amount",r=t.targetDate&&t.targetAmount?(0,Ba.Tf)(t.targetDate):void 0,o=HPe(n,t),i=(0,a.useMemo)((()=>[l,r,o].filter(Tr.A)),[l,r,o]);return a.createElement("div",{"data-external-id":"savings-goal-budget-popover-goal-data",className:"flex flex-1 items-center justify-start gap-2xs"},i.map(((e,t)=>a.createElement(a.Fragment,{key:t},a.createElement(xt.v,{size:"xsmall",color:"content.secondary"},e),t<i.length-1&&a.createElement(VPe,{style:{backgroundColor:"var(--color-divider-secondary)"}})))))},jPe=e=>"".concat((0,rl.T3)(e)," / mo."),HPe=(e,t)=>
1void 0!==e?jPe(e):t.plannedMonthlyContribution?jPe(t.plannedMonthlyContribution):void 0;var KPe=n(48632),qPe=n(81941),$Pe=n(58381),ZPe=n(99197);const JPe="general",XPe=e=>null!==e&&void 0!==e?e:JPe,QPe=e=>e.amount!==e.initialAmount||e.applyToFuture!==e.initialApplyToFuture,eBe=e=>{let t=e.accountBudgetAmounts,n=e.initialAmountsByBucket,a=e.initialApplyToFutureByBucket,l=e.budgetApplyToFutureMonthsDefault,r=e.inFlightSaves;return(null!==t&&void 0!==t?t:[]).reduce(((e,t)=>{var o,i,s;const c=XPe(t.accountId);if(r.has(c))return e;const d=(0,De.qh)(t.amount),u=null!==(o=n[c])&&void 0!==o?o:0,m=null!==(i=a[c])&&void 0!==i?i:l,p=null!==(s=t.applyToFuture)&&void 0!==s?s:l;return QPe({amount:d,initialAmount:u,applyToFuture:p,initialApplyToFuture:m})?[...e,{accountId:t.accountId,amount:d,applyToFuture:p}]:e}),[])},tBe=(e,t,n)=>{const l=(0,a.useRef)(),r=(0,a.useRef)(!1);(0,a.useEffect)((()=>{if(clearTimeout(l.current),null===e||void 0===e||!e.length)return;if(!r.current){if(!e.some((e=>{var n,a,l;const r=null!==(n=e.accountId)&&void 0!==n?n:"general";return e.amount!==(null!==(a=null===(l=t.current)||void 0===l?void 0:l[r])&&void 0!==a?a:0)})))return;r.current=!0}const a=(e=>e.map((e=>({accountId:e.accountId,amount:(0,De.qh)(e.amount)}))))(e);return l.current=setTimeout((()=>{n((e=>(0,Tce.A)(e,a)?e:a))}),300),()=>clearTimeout(l.current)}),[e,t,n])},nBe=e=>{let t=e.goalId,n=e.contributions,l=e.budgetApplyToFutureMonthsDefault,r=e.setBudgetContribution,o=e.date,i=e.onClose,s=e.onSaveError,c=e.setPlannedContributionOverrides;const d=(0,hu.x)().values,u=(0,$Pe.Q)().optimisticUpdateCacheForSavingsGoal,m=(0,a.useRef)({}),p=(0,a.useRef)({});(0,a.useEffect)((()=>{0!==n.length&&(Object.keys(m.current).length>0||(m.current=(e=>Object.fromEntries(e.map((e=>{var t;return[XPe(e.accountId),null!==(t=e.plannedAmount)&&void 0!==t?t:0]}))))(n),p.current=((e,t)=>Object.fromEntries(e.map((e=>[XPe(e.accountId),t]))))(n,l)))}),[n,l]);const g=(0,a.useRef)(d);g.current=d;const h=(0,a.useRef)(r);h.current=r;const v=(0,a.useRef)(o);v.current=o;const f=(0,a.useRef)(i);f.current=i;const E=(0,a.useRef)(s);E.current=s;const y=(0,a.useRef)(!1),b=(0,a.useMemo)((()=>({valuesRef:g,initialAmountsRef:m,initialApplyToFutureRef:p,hasSuccessfulSaveRef:y,setBudgetContributionRef:h,dateRef:v,onSaveErrorRef:E,onCloseRef:f,budgetApplyToFutureMonthsDefault:l})),[l]),x=(0,a.useRef)(b);x.current=b;const w=(0,ZPe.A)(t),C=(0,ZPe.A)(u);tBe(d.accountBudgetAmounts,m,c),(0,a.useEffect)((()=>()=>{const e=x.current,t=e.valuesRef.current.accountBudgetAmounts;if(eBe({accountBudgetAmounts:t,initialAmountsByBucket:e.initialAmountsRef.current,initialApplyToFutureByBucket:e.initialApplyToFutureRef.current,budgetApplyToFutureMonthsDefault:e.budgetApplyToFutureMonthsDefault,inFlightSaves:new Map}).length>0&&t&&t.length>0){var n;const e=t.find((e=>null===e.accountId)),a=(0,De.qh)(null!==(n=null===e||void 0===e?void 0:e.amount)&&void 0!==n?n:0),l=(0,De.Eb)(t.map((e=>(0,De.qh)(e.amount)))),r=t.some((e=>e.applyToFuture));C.current({startDate:v.current,savingsGoalId:w.current,amount:a,totalAmount:l,applyToFuture:r})}(e=>{const t=new Map,n=()=>eBe({accountBudgetAmounts:e.valuesRef.current.accountBudgetAmounts,initialAmountsByBucket:e.initialAmountsRef.current,initialApplyToFutureByBucket:e.initialApplyToFutureRef.current,budgetApplyToFutureMonthsDefault:e.budgetApplyToFutureMonthsDefault,inFlightSaves:t}),a=n=>{const a=XPe(n.accountId),l=(0,De.qh)(n.amount),r=e.setBudgetContributionRef.current({amount:l,month:e.dateRef.current,accountId:n.accountId,applyToFuture:n.applyToFuture,shouldRefetch:!1}).then((()=>{e.hasSuccessfulSaveRef.current=!0,e.initialAmountsRef.current[a]=l,e.initialApplyToFutureRef.current[a]=n.applyToFuture})).catch((()=>{var t,n;null===(t=(n=e.onSaveErrorRef).current)||void 0===t||t.call(n)})).finally((()=>{t.delete(a)}));return t.set(a,r),r},l=n().map(a);0!==l.length&&Promise.all(l).catch((()=>{})).then((()=>{const e=n();if(e.length>0)return Promise.all(e.map(a)).catch((()=>{}))})).then((()=>{var t,n;e.hasSuccessfulSaveRef.current&&Promise.resolve(null===(t=(n=e.onCloseRef).current)||void 0===t?void 0:t.call(n)).catch((()=>{}))}))})(e)}),[w,C]);return{computedTotalPlanned:(0,a.useMemo)((()=>{return e=d.accountBudgetAmounts,(0,De.Eb)((null!==e&&void 0!==e?e:[]).map((e=>(0,De.qh)(e.amount))));var e}),[d.accountBudgetAmounts]),hasContributions:n.length>0}},aBe=e=>{let t=e.goal,n=e.contributions,l=e.percent,o=e.contributionSaveOptions,i=e.growthRatePortalContainer;const s=nBe((0,U.A)({contributions:n},o)),c=s.computedTotalPlanned,d=s.hasContributions,u=(0,a.useContext)(UPe.t).close;return a.createElement("div",{"data-external-id":"savings-goal-budget-popover-form-content",className:"flex min-h-0 flex-1 flex-col gap-default"},a.createElement("div",{className:"flex items-center gap-sm"},a.createElement("div",{className:"relative shrink-0",style:{width:36,height:36}},a.createElement(oQ.s,{imageStorageProvider:t.imageStorageProvider,imageStorageProviderId:t.imageStorageProviderId,size:"small"})),a.createElement("div",{className:"flex flex-1 flex-col gap-2xs"},a.createElement("div",{className:"flex items-center justify-between"}
1,a.createElement(xt.v,{size:"small",clampLines:1},t.name),!!t.targetAmount&&a.createElement("div",{className:"flex flex-1 items-center justify-end gap-2xs",style:{maxWidth:90}},a.createElement(xt.v,{size:"xsmall",color:"content.secondary"},l,"%"),a.createElement(qPe.m,{goal:t,progress:l}))),a.createElement(WPe,{goal:t,totalPlannedAmount:d?c:void 0}))),a.createElement(z7.P,{height:1,text:""}),a.createElement("div",{className:"min-h-0 flex-1 overflow-y-auto"},(0,r.YW)({hasContributions:d}).with({hasContributions:!1},(()=>a.createElement(xt.v,{size:"small",color:"content.secondary"},_t.$.MONTHLY_CONTRIBUTIONS.NO_CONTRIBUTIONS_FOR_MONTH))).otherwise((()=>a.createElement(KPe.i,{contributions:n,totalPlannedAmount:c,isLoading:!1,showApplyToFuture:!0,compact:!0,autoFocus:!0,onSubmit:u,growthRatePortalContainer:i,formatGeneralRecommendation:_t.$.MONTHLY_CONTRIBUTIONS.GENERAL_CONTRIBUTION_RECOMMENDATION_BUDGET})))))};var lBe=n(29103),rBe=n(51524);const oBe=e=>{let t=e.goalId,n=e.date,l=e.onClose;const i=(0,a.useState)([]),s=(0,o.A)(i,2),c=s[0],d=s[1],u=(0,a.useState)(null),m=(0,o.A)(u,2),g=m[0],h=m[1],v=(0,a.useCallback)((e=>{h(e)}),[]),f=(0,et.I)(Io.H4,{variables:{id:t},fetchPolicy:"cache-first"}),E=f.data,y=f.isLoadingInitialData,b=(null!==E&&void 0!==E?E:{}).savingsGoal,x=(0,lBe.s)({goal:b}),w=(0,rBe.H)({goalId:t,isNewGoal:!1,month:n,fetchPolicy:"no-cache",plannedContributionOverrides:c}),A=w.contributions,I=w.setBudgetContribution,k=w.isLoading,S=w.error,N=(0,JOe.w)().budgetApplyToFutureMonthsDefault,T=(0,C.RU)(),_=(0,a.useMemo)((()=>({accountBudgetAmounts:A.map((e=>{var t;return{accountId:e.accountId,amount:null!==(t=e.plannedAmount)&&void 0!==t?t:0,applyToFuture:N}}))})),[A,N]),D=(0,a.useState)(!1),R=(0,o.A)(D,2),M=R[0],L=R[1],O=y||k;(0,a.useEffect)((()=>{O||L(!0)}),[O]);const P=O&&!M;return a.createElement(fe.xz6,{"data-external-id":"savings-goal-budget-popover",className:"max-h-(--popper-available-height,60vh) w-120 border border-divider-primary",ref:v},a.createElement(gm.n,{className:"flex min-h-0 flex-1 flex-col",onMouseDown:!0},a.createElement(fe.xz6.Content,{className:"min-h-0 p-default pb-lg"},(0,r.YW)({isPopoverLoading:P,goal:b,hasError:!!S}).with({isPopoverLoading:!0},(()=>a.createElement("div",{className:"flex items-center justify-center p-lg"},a.createElement(p.i,null)))).with({hasError:!0},(()=>a.createElement(SQ.W,{message:VG.U.BUDGET}))).with({goal:r.P.nonNullable},(e=>{let r=e.goal;return a.createElement(Eu.lV,{className:"flex min-h-0 flex-1 flex-col",initialValues:_,onSubmit:async()=>{},enableReinitialize:!1},a.createElement(aBe,{goal:r,contributions:A,percent:x,growthRatePortalContainer:g,contributionSaveOptions:{goalId:t,setBudgetContribution:I,budgetApplyToFutureMonthsDefault:N,date:n,onClose:l,onSaveError:T,setPlannedContributionOverrides:d}}))})).otherwise((()=>a.createElement(SQ.W,{message:VG.U.BUDGET}))))))},iBe=e=>{let t=e.goalId,n=e.value,l=e.appliedToFuture,o=e.onCheckApplyToFuture;const i=(0,et.I)(Io.H4,{variables:{id:t},fetchPolicy:"cache-first"}),s=i.data,c=i.isLoadingInitialData,d=(null!==s&&void 0!==s?s:{}).savingsGoal,u=(0,lBe.s)({goal:d});return a.createElement(fe.xz6,{"data-external-id":"savings-goal-budget-popover-legacy",className:"w-89"},a.createElement(gm.n,{onMouseDown:!0,preventDefault:!0},a.createElement(fe.xz6.Content,{className:"px-default py-sm"},(0,r.YW)({isLoadingInitialData:c,goal:d}).with({isLoadingInitialData:!0},(()=>a.createElement("div",{className:"flex items-center justify-center p-lg"},a.createElement(p.i,null)))).with({goal:r.P.nonNullable},(e=>{let t=e.goal;return a.createElement("div",{className:"flex flex-col items-stretch justify-between gap-default"},a.createElement("div",{className:"flex items-center justify-start gap-sm"},a.createElement("div",{className:"relative shrink-0",style:{width:36,height:36}},a.createElement(oQ.s,{imageStorageProvider:t.imageStorageProvider,imageStorageProviderId:t.imageStorageProviderId,size:"small"})),a.createElement("div",{className:"flex flex-1 flex-col gap-2xs"},a.createElement("div",{className:"flex items-center justify-between"}
1,a.createElement(xt.v,{size:"small",clampLines:1},t.name),!!t.targetAmount&&a.createElement("div",{className:"flex flex-1 items-center justify-end gap-2xs",style:{maxWidth:90}},a.createElement(xt.v,{size:"xsmall",color:"content.secondary"},u,"%"),a.createElement(qPe.m,{goal:t,progress:u}))),a.createElement(WPe,{goal:t}))),a.createElement(z7.P,{height:1,text:""}),a.createElement("div",{className:"flex items-center justify-start"},a.createElement(zPe.X,{appliedToFuture:l,onCheckApplyToFuture:o,value:n})))})).otherwise((()=>null)))))},sBe=e=>{let t=e.itemId,n=e.children;const l=a.createElement(BPe.V,{itemId:t});return a.createElement(P.D_,{"data-external-id":"budget-historical-amounts-tooltip",delayShow:300,content:l,side:"bottom",align:"end",unstyled:!0,clickable:!0,matchAppTheme:!0},a.createElement("div",null,n))},cBe=e=>{let t=e.budgetedAmount,n=e.budgetedIncome,l=e.canEnableGroupBudgeting,r=e.openEditGroupModal,i=e.children;const s=a.useState(0),c=(0,o.A)(s,2),d=c[0],u=c[1],m=n>0?t/n:0,p=a.createElement("div",{className:"flex flex-col items-center gap-xs p-sm"},a.createElement(fe.c8D,{size:"xs",weight:"medium"},(0,De.gj)(m)," of budgeted income"),l&&r&&a.createElement(a.Fragment,null,a.createElement("div",{className:"-mx-[calc(var(--spacing-sm)+1px)] self-stretch border-t border-divider-secondary",role:"presentation"}),a.createElement(wb.gz,{onClick:()=>{u((e=>e+1)),null===r||void 0===r||r()},color:"blue"},"Enable group budgeting")));return a.createElement(P.D_,{"data-external-id":"budgeted-income-share-tooltip",key:d,delayShow:300,maxWidth:320,content:p,side:"top",clickable:!0},a.createElement("div",{className:"-mr-sm pr-sm"},i))};var dBe=n(53940);const uBe=a.forwardRef(((e,t)=>{var n;let l=e.children,r=e.amounts,o=e.warningText,i=e.showTooltip,s=e.itemIcon,c=e.itemName,d=e.sectionType;const u=(0,EA.Ve)(null!==(n=null===s||void 0===s?void 0:s.toString())&&void 0!==n?n:"")?s:"",m=i&&r?a.createElement(mBe,{amounts:r,title:"".concat(u," ").concat(c),warningText:o,sectionType:d}):null;return a.createElement(P.D_,{"data-external-id":"plan-amounts-tooltip",content:m},a.createElement("div",{ref:t},l))})),mBe=e=>{var t,n;let l=e.amounts,r=e.title,o=e.warningText,i=e.sectionType;const s=(0,a.useMemo)((()=>{if(l.rolloverType!==dBe.eI.NonMonthly){var e;const t=null!==(e=w8(l,"remaining"))&&void 0!==e?e:0;return HX(i,t)?{title:"Over plan",value:Math.abs(t),type:"income",emphasis:!0}:{title:"Remaining",value:t,type:"income",emphasis:!0}}return{component:a.createElement(pBe,l)}}),[l,i]);return a.createElement(U5.R,{"data-external-id":"plan-amounts-tooltip-content",title:r,rows:[...o?[{component:a.createElement(gBe,null,o)}]:[],...(0,Tr.A)(l.rolloverType)||l.rollover?[...(0,Tr.A)(l.rolloverStartingBalance)&&(0,BX.A)(l.rolloverStartingBalance)?[{title:"Starting balance",value:null!==(t=l.rolloverStartingBalance)&&void 0!==t?t:0,type:"income",emphasis:!0}]:[],{title:"Rollover from last month",value:null!==(n=l.rollover)&&void 0!==n?n:0,type:"income",emphasis:!0}]:[],{title:"Planned",value:w8(l,"budgeted")},{title:"Actual",value:w8(l,"actual")},s]})},pBe=e=>{let t=e.cumulativeActualAmount,n=e.rollover,l=e.remaining,r=e.budgeted,o=e.rolloverTargetAmount;if((0,BY.A)(t)||(0,BY.A)(n)||(0,BY.A)(l))return null;const i=o?t/o:t/zX(r,n),s=null!==o&&void 0!==o?o:zX(r,n);return a.createElement("div",{"data-external-id":"non-monthly-footer",className:"flex size-full flex-1 flex-col gap-xs"},a.createElement("div",{className:"flex items-center justify-between"},a.createElement(xt.v,null,"Remaining"),a.createElement(xt.v,{color:l>0?"content.success":"content.danger"},(0,rl.T3)(l))),a.createElement(fe.yDW,{value:i>1?s:t,max:s,color:i>1?"content-danger":"content-success"}),a.createElement("div",{className:"flex items-center justify-between"},a.createElement(xt.v,{weight:"book",size:"xsmall"},(0,De.gj)(i)," of rollover spent"),(0,Tr.A)(o)&&a.createElement(xt.v,{weight:"book",size:"xsmall"},(0,rl.T3)(o)," target")))},gBe=(0,u.default)(fu.g).attrs({type:"warning"}).withConfig({displayName:"PlanAmountsTooltip__Warning",componentId:"zwm5pw-0"})(["font-size:",";font-weight:",";line-height:150%;"],(e=>e.theme.fontSize.xsmall),(e=>e.theme.fontWeight.medium)),hBe=a.memo((e=>{let t=e.sectionType,n=e.isAggregate,l=void 0!==n&&n,r=e.isCategoryGroup,o=void 0!==r&&r,i=e.isMovable,s=e.showRolloverIcon,c=e.active,d=e.onClick,u=e.value,m=e.hideBackgroun
1d,p=void 0!==m&&m,g=e.hasWarning,h=void 0!==g&&g,v=e.className;const f=(0,R3.F)().isOn,E=p||!i&&(o||l);let y;return t===E8&&!f&&(y=(null!==u&&void 0!==u?u:0)>0?"info":"neutral"),a.createElement(Y3.g,{"data-external-id":"plan-cell-amount-pill",value:u,formatter:rl.T3,onClick:d,icon:s?a.createElement(fe.pyX,null):void 0,active:c,hideBackground:E,colorScheme:y,className:(0,q.cn)("-mr-sm",l?"text-lg":"text-base",v,h&&(null!==u&&void 0!==u?u:0)<0&&"text-content-warning")})})),vBe=e=>{let t=e.itemId,n=e.itemDate,l=e.itemName,r=e.itemHref,o=e.itemIcon,i=e.isAggregate,s=e.isUnplannedAggregate,c=e.groupLevelBudgetingEnabled,d=e.isRemainingAmountType,u=e.isBudgetType,m=e.availableDisplayAmount,p=e.sectionType,g=e.value,h=e.isCategoryGroup,v=e.isFlexSection,f=e.openEditGroupModal,E=e.warningText,y=e.showRolloverIcon,b=e.isPlanSummary,x=e.amounts,w=e.showPlanAmountsTooltip,C=e.isActualAmountType;const A=kPe().getBudgetedIncomeForDate,k=null===n||void 0===n?void 0:n.toISODate(),S=p===E8,N="expense"===p&&!c,T=u&&!!t&&!!n&&(N&&!!h||S&&i),_=v&&!d&&!i&&!!t,D=(0,a.useMemo)((()=>{if(C)return r&&t&&k&&!S?h?I.JZ.categoryGroups({id:t,queryParams:{date:k}}):I.JZ.categories({id:t,queryParams:{date:k}}):r}),[C,h,r,t,k,S]),R=a.createElement(fBe,{sectionType:p,isRemainingAmountType:d,availableDisplayAmount:m,value:g,isUnplannedAggregate:s,isAggregate:i,hasWarning:!!E,showRolloverIcon:!!y,isPlanSummary:b,itemHref:D});return T?a.createElement(cBe,{"data-external-id":"plan-cell-amount",budgetedAmount:null!==g&&void 0!==g?g:0,budgetedIncome:A(n),canEnableGroupBudgeting:N&&!!f,openEditGroupModal:f},R):_?a.createElement(sBe,{"data-external-id":"plan-cell-amount",itemId:t},R):w?a.createElement(uBe,{"data-external-id":"plan-cell-amount",amounts:x,showTooltip:w,itemName:l,itemIcon:o,warningText:E,sectionType:p},R):R},fBe=e=>{let t,n=e.sectionType,l=e.isRemainingAmountType,r=e.availableDisplayAmount,o=e.value,i=e.isUnplannedAggregate,s=e.isAggregate,c=e.hasWarning,d=e.showRolloverIcon,u=e.isPlanSummary,m=e.itemHref;if(m)return a.createElement(Vl.W,{"data-external-id":"amount",to:m,stealthy:!0},(0,rl.T3)(o));u?t="text-content-white":l?i&&r>0&&(t="text-content-secondary"):t="text-content-primary";const p=l?r:o;return a.createElement(hBe,{"data-external-id":"amount",sectionType:n,value:p,isAggregate:s,showRolloverIcon:!!d,isMovable:!1,hideBackground:!0,hasWarning:c,className:(0,q.cn)(l||s?"font-medium":"font-book",t)})},EBe=a.memo(vBe);var yBe=n(71664),bBe=n(65898),xBe=n(3293),wBe=n(94879);const CBe=(e,t,n)=>{var a,l;const r=(0,rK.A)("id",t),o=n?[]:e.details.byCategoryGroups.flatMap((e=>{let t=e.unbudgetedCategories;return void 0===t?[]:t})).concat(e.details.byCategory);return n?null===(a=e.details.byCategoryGroups.find(r))||void 0===a?void 0:a.budgetedAmounts:null===(l=o.find(r))||void 0===l?void 0:l.amounts},ABe=(e,t,n,a)=>{var l;if(!e||!t)return;const r=(0,xBe.A)((0,rK.A)("type",a),e.displayTypes),o=null!==(l=null===r||void 0===r?void 0:r.displayGroups)&&void 0!==l?l:[];if(n){const e=(0,xBe.A)((0,rK.A)("id",t),o);return null===e||void 0===e?void 0:e.budgetedAmounts}const i=(0,wBe.A)((e=>{var t,n;return(0,AK.A)(null!==(t=e.budgetedCategories)&&void 0!==t?t:[],null!==(n=e.unbudgetedCategories)&&void 0!==n?n:[])}),o),s=(0,xBe.A)((0,rK.A)("id",t),i);return null===s||void 0===s?void 0:s.amounts},IBe=(e,t,n,a,l)=>{var r,o,i;const s=(null!==(r=CBe(e,t,a))&&void 0!==r?r:{}).available||0,c=s>0?Math.floor(s):Math.round(s),d=TBe(e,n,!0,l),u=TBe(e,n,!1,l),m=e=>e===t?void 0:e;return c<0?kBe(m,c,t,d):c>0?SBe(m,c,t,u,d):{toCategoryId:t,fromCategoryId:m(null===d||void 0===d?void 0:d.id),amount:null!==(i=null===(o=null===d||void 0===d?void 0:d.amounts)||void 0===o?void 0:o.available)&&void 0!==i?i:0}},kBe=(e,t,n,a)=>{var l,r;const o=Math.abs(null!==(r=null===(l=null===a||void 0===a?void 0:a.amounts)||void 0===l?void 0:l.available)&&void 0!==r?r:0),i=Math.abs(t);return{toCategoryId:n,fromCategoryId:e(null===a||void 0===a?void 0:a.id),amount:Math.min(i,o)}},SBe=(e,t,n,a,l)=>{var r,o;if(n===(null===a||void 0===a?void 0:a.id))return{toCategoryId:n,fromCategoryId:e(null===l||void 0===l?void 0:l.id),amount:0};const i=NBe(null!==(o=null===(r=null===a||void 0===a?void 0:a.amounts)||void 0===r?void 0:r.available)&&void 0!==o?o:0);return{fromCategoryId:n,toCategoryId:e(null===a||void 0===a?void 0:a.id),amount:Math.min(t,i)}},NBe=e=>Math.floor(Math.max(0,-1*e)),TBe=(e,t,n,a)=>{const l=[...e.details.byCategory.filter((e=>{let n=e.groupType,l=e.groupLevelBudgetingEnabled,r=e.budgetVariability;return n===t&&!l&&(!a||r!==Ee.Iaz.FLEXIBLE)})).map((e=>({id:e.id,amounts:e.amounts}))),...e.details.byCategoryGroups.filter((e=>{let n=e.id,l=e.type,r=e.groupLevelBudgetingEnabled;
1return l===t&&(a&&n===Ee.Iaz.FLEXIBLE||r)})).map((e=>({id:e.id,amounts:e.budgetedAmounts})))];return l.reduce(((e,t)=>{var a,l,r,o,i,s,c,d;return n&&(null!==(l=null===(a=t.amounts)||void 0===a?void 0:a.available)&&void 0!==l?l:0)>(null!==(o=null===(r=e.amounts)||void 0===r?void 0:r.available)&&void 0!==o?o:0)||!n&&(null!==(s=null===(i=t.amounts)||void 0===i?void 0:i.available)&&void 0!==s?s:0)<(null!==(d=null===(c=e.amounts)||void 0===c?void 0:c.available)&&void 0!==d?d:0)?t:e}),l[0])};var _Be=n(39242);const DBe=e=>{let t=e.budget,n=e.categoryType,l=e.isPending,r=e.excludeCategories,o=e.isFlexBudgetSystem;const i=(0,hu.x)(),s=i.getFieldMeta,c=i.setFieldValue,d=i.values,u=(0,_Be.Y)().categoryGroups,m=(0,a.useMemo)((()=>new Set([...u.map((e=>e.id)),"flexible"])),[u]),p=(0,a.useCallback)(((e,n)=>t&&CBe(t,e,n)),[t]),g=e=>{var t;let l=e.value,r=e.label;const o=m.has(l),i=(null!==(t=p(l,o))&&void 0!==t?t:{}).available,s=o?"All categories":r;return a.createElement(RBe,null,a.createElement(MBe,null,s),a.createElement(LBe,null,a.createElement(Yl.t,{className:"mr-3xs ml-xs min-w-15 shrink-0",value:FX(i,n),type:"income",round:!0,emphasis:!0}," ","left")))},h=e=>{var t;let l=e.value;const r=(null!==(t=p(l,m.has(l)))&&void 0!==t?t:{}).available;return a.createElement(LBe,{className:"shrink-0 whitespace-nowrap"},a.createElement(Yl.t,{className:"ml-xs",value:FX(r,n),type:"income",round:!0,emphasis:!0}," ","left"))},v=(0,a.useCallback)((e=>{if(!e||!t)return;const a=s("fromCategoryId").value,l=((e,t,n,a)=>{var l,r;if(!e||!n||!a)return 0;const o=!!e.details.byCategoryGroups.find((e=>e.id===n)),i=!!e.details.byCategoryGroups.find((e=>e.id===a)),s=(null!==(l=CBe(e,n,o))&&void 0!==l?l:{}).available,c=(null!==(r=IBe(e,a,t,i))&&void 0!==r?r:{}).amount,d=Math.min(null!==s&&void 0!==s?s:0,null!==c&&void 0!==c?c:0);return Math.floor(Math.max(0,d))})(t,n,a,e);c("amount",l)}),[t,n,c,s]),f=(0,a.useMemo)((()=>{const e=s("toCategoryId").value;return[...null!==r&&void 0!==r?r:[],...e?[e]:[]]}),[r,s]),E=(0,a.useMemo)((()=>{const e=s("fromCategoryId").value;return[...null!==r&&void 0!==r?r:[],...e?[e]:[]]}),[r,s]),y=(0,a.useMemo)((()=>n===Ee.wNk.EXPENSE&&o?[{label:"Flexible",options:[{value:"flexible",label:"Flexible"}]}]:[]),[n,o]);return a.createElement("div",{"data-external-id":"move-money-inner-form",className:"flex flex-col gap-default"},a.createElement(yBe.A,{size:"sm",name:"fromCategoryId",label:"From",isCreatable:!1,filters:{type:n,excludeCategories:f},extraOptions:y,renderOption:g,renderSelectedTrailing:h,afterChange:v,placeholder:"Select a category or group",collapseGroupBasedOnBudgeting:!0}),a.createElement(yBe.A,{size:"sm",name:"toCategoryId",label:"To",isCreatable:!1,filters:{type:n,excludeCategories:E},extraOptions:y,renderOption:g,renderSelectedTrailing:h,afterChange:v,placeholder:"Select a category or group",collapseGroupBasedOnBudgeting:!0}),a.createElement(tC.zB.Currency,{name:"amount",placeholder:"$0",size:"sm",inputClassName:"text-base/6",precision:0,required:!0}),a.createElement(OBe,{size:"small",disabled:d.amount<=0,disableWhenValuesUnchanged:!1,pending:l},"Save"))},RBe=u.default.div.withConfig({displayName:"MoveMoneyInnerForm__CategoryOption",componentId:"sc-1euuyhu-0"})(["display:flex;align-items:center;justify-content:space-between;width:100%;"]),MBe=u.default.div.withConfig({displayName:"MoveMoneyInnerForm__CategoryLabel",componentId:"sc-1euuyhu-1"})(["flex-shrink:1;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;"]),LBe=u.default.div.withConfig({displayName:"MoveMoneyInnerForm__CategoryAmount",componentId:"sc-1euuyhu-2"})(["color:",";"],(e=>e.theme.color.textLight)),OBe=(0,u.default)(CJ.I).withConfig({displayName:"MoveMoneyInnerForm__SubmitButton",componentId:"sc-1euuyhu-3"})(["width:auto;margin-left:auto;margin-top:",";"],(e=>e.theme.spacing.default)),PBe=e=>{let t=e.budgetStartDate,n=e.onDone,l=e.categoryType,r=e.initialCategoryId,s=e.isGroup;const c=(0,C.RU)(),d=(0,a.useState)(!1),u=(0,o.A)(d,2),m=u[0],p=u[1],g=v8(t,{}),h=g.budgetListData,v=g.budgetSummaryData,f=g.isFlexBudgetSystem,E=(0,a.useMemo)((()=>h&&((e,t)=>{if(t){const t=(0,Ri.A)(e.displayTypes.map((e=>e.displayGroups))),n=(0,Ri.A)(t.map((e=>e.budgetedCategories))),a=n.filter((e=>"category"===e.itemType)),l=[];return l.push(...n.filter((e=>"category_group"===e.itemType)).map((e=>{var t;return(0,U.A)((0,U.A)({},e),{},{type:e.groupType,budgetedAmounts:null!==(t=e.amounts)&&void 0!==t?t:q5.YB,unbudgetedCategories:[],budgetedCategories:[]})}))),l.push(...t),{details:{byCategory:a,byCategoryGroups:l}}}return{details:{byCategory:e.displayTypes.flatMap((e=>e.displayGroups.flatMap((e=>e.budgetedCategories)))),byCategoryGroups:e.displayTypes.flatMap((e=>e.displayGroups))}}})(h,f)),[h,v]),y=(0,a.useMemo)((()=>f?h&&(e=>{var t,n;const a=e.displayTypes.find((e=>e.type===Ee.wNk.EXPENSE)),l=null===a||void 0===a?void 0:a.displayGroups.find((e=>e.budgetVariability===Ee.Iaz.FLEXIBLE)),r=[...null!==(t=null===l||void 0===l?void 0:l.budgetedCategories)&&void 0!==t?t:[],...null!==(n=null===l||void 0===l?void 0:l.unbudgetedCategories)&&void 0!==n?n:[]];return null===r||void 0===r?void 0:r.map((e=>e.id))})(h):[]),[h,f]),b=(0,i.n)(GBe,{refetchQueries:[ZOe.I],onCompleted:n}),x=(0,o.A)(b,1)[0],w=(0,$Pe.Q)().optimisticUpdateCacheForCategoryOrGroup,A=(0,a.useCallback)((async e=>{p(!0);const t=((e,t,n)=>{var a,l,r,o;if(!t)return;const i=null!==(a=e.fromCategoryGroupId)&&void 0!==a?a:e.fromCategoryId,s=null!==(l=e.toCategoryGroupId)&&void 0!==l?l:e.toCategoryId,c=!!e.fromCategoryGroupId,d=!!e.toCategoryGroupId,u=ABe(t,i,c,n),m=ABe(t,s,d,n);return u&&i&&m&&s?{fromUpdate:{id:i,amount:(null!==(r=u.budgeted)&&void 0!==r?r:0)-e.amount,isGroup:c,applyToFuture:!1,startDate:N.c9.fromISO(e.startDate)}
1,toUpdate:{id:s,amount:(null!==(o=m.budgeted)&&void 0!==o?o:0)+e.amount,isGroup:d,applyToFuture:!1,startDate:N.c9.fromISO(e.startDate)}}:void 0})(e,h,l);t&&(w(t.fromUpdate),w(t.toUpdate)),await x({variables:{input:e}}).catch((()=>{c()})).finally((()=>p(!1)))}),[x,w,h,l,c]),I=(0,a.useMemo)((()=>{var e,t;return r&&E?(0,U.A)((0,U.A)({},IBe(E,r,l,s,f)),{},{startDate:null!==(e=null===h||void 0===h?void 0:h.startDate)&&void 0!==e?e:void 0,timeframe:"month"}):{startDate:null!==(t=null===h||void 0===h?void 0:h.startDate)&&void 0!==t?t:void 0,timeframe:"month"}}),[E,h,r,l,s,f]);return a.createElement(gm.n,{"data-external-id":"move-money-popover",onClick:!0},a.createElement(BBe,{title:a.createElement(FBe,null,"Move Budget"),small:!0},a.createElement(zBe,null,a.createElement(Eu.lV,{onSubmit:A,initialValues:I,transformValuesBeforeSubmit:e=>{const t=e.fromCategoryId,n=e.toCategoryId;return(e=>{let t=e.timeframe,n=e.amount,a=e.startDate,l=e.fromCategoryId,r=e.toCategoryId,o=e.budget;const i={timeframe:t,amount:n,startDate:a,fromCategoryGroupId:void 0,fromCategoryId:void 0,toCategoryGroupId:void 0,toCategoryId:void 0,fromBudgetTarget:void 0,toBudgetTarget:void 0};if(!o||!l||!r)return i;const s="flexible"===r;return"flexible"===l?i.fromBudgetTarget=Ee.VwA.FLEX_EXPENSE:(null===o||void 0===o?void 0:o.details.byCategoryGroups.find((e=>e.id===l)))?i.fromCategoryGroupId=l:i.fromCategoryId=l,s?i.toBudgetTarget=Ee.VwA.FLEX_EXPENSE:(null===o||void 0===o?void 0:o.details.byCategoryGroups.find((e=>e.id===r)))?i.toCategoryGroupId=r:i.toCategoryId=r,i})({timeframe:e.timeframe,amount:e.amount,startDate:e.startDate,fromCategoryId:t,toCategoryId:n,budget:E})},validate:e=>E?((e,t)=>{var n;const a=!!t.details.byCategoryGroups.find((t=>t.id===e.fromCategoryId)),l=(e.fromCategoryId&&null!==(n=CBe(t,e.fromCategoryId,a))&&void 0!==n?n:{available:0}).available,r=null!==l&&void 0!==l?l:0,o=I1.Ik().shape({fromCategoryId:I1.Yj().required("Please select a category."),toCategoryId:I1.Yj().required("Please select a category."),amount:I1.ai().required("Please enter an amount.").moreThan(0,"Please enter an amount greater than $0.").lessThan(r+1,r>0?"Please ensure the amount is lower than or equal to $".concat(r,"."):'Please ensure the "From" category has a balance greater than $0.')});try{o.validateSync(e)}catch(i){return(0,bBe.Tz)(i)}return{}})(e,E):void 0},a.createElement(DBe,{budget:E,categoryType:l,isPending:m,excludeCategories:y,isFlexBudgetSystem:f})))))},BBe=(0,u.default)(Xl.AM).withConfig({displayName:"MoveMoneyPopover__StyledCard",componentId:"sc-1sl3npt-0"})(["width:","px;"],304),zBe=u.default.div.withConfig({displayName:"MoveMoneyPopover__CardBody",componentId:"sc-1sl3npt-1"})(["padding:",";"],(e=>e.theme.spacing.default)),FBe=u.default.span.withConfig({displayName:"MoveMoneyPopover__Title",componentId:"sc-1sl3npt-2"})(["color:",";"],(e=>e.theme.color.textLight)),GBe=Ee.BN$,YBe=e=>{let t=e.date,n=e.amounts,l=e.sectionType,r=e.itemId,o=e.itemName,i=e.itemIcon,s=e.showPlanAmountsTooltip,c=e.isAggregate,d=void 0!==c&&c,u=e.isCategoryGroup,m=void 0!==u&&u,p=e.availableDisplayAmount,g=e.isMovable,h=e.showRolloverIcon,v=e.warningText;return a.createElement(Qi.Az,{"data-external-id":"plan-cell-move-money-pill",placement:"bottom-end",overlay:e=>{let n=e.close;return a.createElement(Qi.j7,null,a.createElement(PBe,{budgetStartDate:t,onDone:n,initialCategoryId:r,isGroup:m,categoryType:l===E8||l===y8?Ee.wNk.INCOME:l}))}},(e=>{let t=e.toggleOpen,r=e.isOpen;return a.createElement(uBe,{amounts:n,showTooltip:s,itemName:o,itemIcon:i,warningText:v,sectionType:l},a.createElement(hBe,{value:p,onClick:g?t:void 0,showRolloverIcon:h,active:r,isAggregate:d,isMovable:g,isCategoryGroup:m,sectionType:l,hasWarning:!!v,className:"font-medium"}))}))},UBe=a.memo(YBe);var VBe=n(31878),WBe=n(66844);const jBe=["isHeader","hasError","hideBorder","isReadOnly","hasGroupHover","value","onValueChange","className","disabled"];let HBe=function(e){return e.FlexibleBudgetExceeded="FLEXIBLE_BUDGET_EXCEEDED",e}({});const KBe=u.default.div.withConfig({displayName:"PlanCell__Root",componentId:"ubpe1q-0"})(["position:relative;"]),qBe=a.forwardRef(((e,t)=>{let n=e.isHeader,l=e.hasError,r=e.hideBorder,o=e.isReadOnly,i=e.hasGroupHover,s=e.value,c=e.onValueChange,d=e.className,u=e.disabled,m=(0,En.A)(e,jBe);return a.createElement(fe.K$5.Root,{"data-external-id":"amount-input",value:s,format:{maximumFractionDigits:0},allowNegative:!0,disabled:u,onValueChange:c}
1,a.createElement(fe.i9A,{variant:"cell",align:"end",invalid:l,disabled:u,className:(0,q.cn)("-mr-3.25 h-8 w-25 transition-colors",r&&!l&&"border-transparent",r&&!n&&"not-focus-within:text-transparent",o&&"pointer-events-none",i&&"group-hover:border-border-brand group-hover:not-focus-within:text-content-secondary")},a.createElement(fe.K$5.Input,Object.assign({ref:t,disabled:u,readOnly:o,placeholder:r&&!n?void 0:"$"},m,{className:(0,q.cn)(n&&"text-lg font-medium",r&&!n&&"not-focus:text-transparent",d)}))))})),$Be=(e,t)=>{let n=e.date,l=e.canEdit,i=e.amounts,s=e.amountType,c=e.sectionType,d=e.rowType,u=e.itemId,m=e.itemName,p=e.itemIcon,g=e.itemHasRolloverEnabled,h=e.isCategoryGroup,v=void 0!==h&&h,f=e.isAggregate,E=void 0!==f&&f,y=e.isUnplannedAggregate,b=void 0!==y&&y,x=e.isLoading,w=e.showPlanAmountsTooltip,C=void 0!==w&&w,A=e.groupLevelBudgetingEnabled,I=void 0!==A&&A,k=e.allowMoveMoney,S=e.error,N=e.budgetVariability,T=e.isOverspentButCoveredByFlexibleAmount,_=e.onChangeValue,D=e.openEditGroupModal,R=e.updateFlexBudgetValue,M=e.isPlanSummary,L=e.itemHref;const O=kPe(),P=O.budgetApplyToFutureMonthsDefault,B=O.refetch,z=(0,lt.L7)().isFlexBudgeting,F=(0,R3.F)().isGrowthRatesEnabled,G="remaining"===s,Y="budgeted"===s,U="actual"===s,V=w8(i,s),W=FX(V,c),j=(0,a.useState)(null!==V&&void 0!==V?V:0),H=(0,o.A)(j,2),K=H[0],q=H[1],$=(0,a.useState)(P),Z=(0,o.A)($,2),J=Z[0],X=Z[1],Q=(0,VBe.n)(J);(0,bu.w)((()=>{q(null!==V&&void 0!==V?V:0)}),[V]),(0,bu.w)((()=>{X(P)}),[P]);const ee=(0,a.useRef)(null),te=(0,a.useCallback)((()=>{var e;const t=null!==(e=null!==K&&void 0!==K?K:V)&&void 0!==e?e:0;null===K&&q(t),t===V&&J===Q||null===_||void 0===_||_(t,J)}),[V,_,K,J,Q]),ne=(0,a.useCallback)((()=>{var e;null===(e=ee.current)||void 0===e||e.blur()}),[ee]),ae=(0,a.useCallback)((e=>{q(e),setTimeout((()=>{var e;return null===(e=ee.current)||void 0===e?void 0:e.blur()}),0)}),[q,ee]);(0,a.useImperativeHandle)(t,(()=>({setValue:(e,t)=>{q(e),null===_||void 0===_||_(e,t)}}))),(0,Ku.D)("Escape",ee.current,{onKeyDown:()=>{var e;return null===(e=ee.current)||void 0===e?void 0:e.blur()}}),(0,Ku.D)("Enter",ee.current,{onKeyDown:ne}),(0,Ku.D)("Tab",ee.current,{onKeyDown:ne});const le=(g||(0,Tr.A)(null===i||void 0===i?void 0:i.rolloverType))&&"remaining"===s&&"savings"!==c,re=z&&(0,KOe.n4)(N,Ee.Iaz.FLEXIBLE)&&c===Ee.wNk.EXPENSE,oe=(0,a.useMemo)((()=>((0,PPe.A)(K)?0===K:(0,BY.A)(K))&&re),[K,re]),ie=c!==E8&&c!==y8&&!!u,se=G&&z&&u===Ee.Iaz.FLEXIBLE,ce=(0,KOe.IY)(c),de=d===WBe.T6.SavingsGoal,ue=d===WBe.T6.DebtAccount,me=k||ce&&G&&!E,pe=F&&de&&Y&&l&&!E&&!!u,ge=(0,a.useCallback)((()=>{null===R||void 0===R||R(),setTimeout((()=>{var e;return null===(e=ee.current)||void 0===e?void 0:e.blur()}),0)}),[R]);return a.createElement(KBe,{"data-external-id":"plan-cell"},(0,r.YW)({isLoading:x,canEdit:l,shouldShowMoveMoneyPill:me,shouldShowSavingsGoalPopover:pe}).with({isLoading:!0},(()=>a.createElement(e8,null))).with({shouldShowSavingsGoalPopover:!0},(()=>a.createElement(Qi.Az,{overlay:a.createElement(oBe,{goalId:u,date:n,onClose:B}),placement:"top-end",computeAvailableHeight:!0,recomputeOnContentResize:!0,offsetSkidding:13},(e=>{let t=e.toggleOpen;return a.createElement("div",{className:"group cursor-pointer",onClick:t,onKeyDown:e=>{"Enter"!==e.key&&" "!==e.key||(e.preventDefault(),t())},tabIndex:0,role:"button","aria-label":"Open savings goal budget details"},a.createElement(qBe,Object.assign({},fl.TN,{className:fl.TN.className,disabled:!0,name:"budgeted",value:null!==V&&void 0!==V?V:0,autoComplete:"off",isHeader:E,hideBorder:!1,isReadOnly:!0,hasGroupHover:!0})))})))).with({canEdit:!0},(()=>a.createElement(Qi.Az,{overlay:(0,r.YW)({showBudgetAmountPopover:ie,isBudgetType:Y,isSavingsGoalRow:de,isDebtPaydownRow:ue,itemId:u}).with({isSavingsGoalRow:!0,isBudgetType:!0,itemId:r.P.select(r.P.nonNullable)},(e=>a.createElement(iBe,{goalId:e,value:null!==K&&void 0!==K?K:0,appliedToFuture:J,onCheckApplyToFuture:X}))).with({isDebtPaydownRow:!0,isBudgetType:!0,itemId:r.P.select(r.P.nonNullable)},(e=>a.createElement(GPe,{accountId:e,value:null!==K&&void 0!==K?K:0,appliedToFuture:J,onCheckApplyToFuture:X}))).with({showBudgetAmountPopover:!0,itemId:r.P.select(r.P.nonNullable)},(e=>a.createElement(BPe.V,{header:!!R&&!!S&&a.createElement(pze,{onClickUpdateFlexBudget:ge}),itemId:e,appliedToFuture:J,onCheckApplyToFuture:X,isCategoryGroup:v,isIncome:c===Ee.wNk.INCOME,onClickBar:ae,value:null!==K&&void 0!==K?K:0}))).otherwise((()=>null)),placement:ce?"top-end":"bottom-end"},(e=>{let t=e.open,n=e.close;return a.createElement(qBe,Object.assign({ref:ee,tabIndex:0,name:"budgeted",value:K,onValueChange:q,onBlur:e=>{var t;null!==(t=e.relatedTarget)&&void 0!==t&&t.closest("[data-popper-placement]")?setTimeout((()=>{var e;return null===(e=ee.current)||void 0===e?void 0:e.focus()}),0):(n(),te())},onFocus:e=>{(0,ix.X)(e),t()},autoComplete:"off"},fl.TN,{isHeader:E,hasError:!!S,hideBorder:oe}))})))).with({shouldShowMoveMoneyPill:!0},(()=>a.createElement(UBe,{date:n,amounts:i,availableDisplayAmount:W,sectionType:c,itemId:u,itemName:m,showPlanAmountsTooltip:C,isAggregate:E,showRolloverIcon:le,itemIcon:se?p:void 0,isCategoryGroup:se?void 0:v,isMovable:k}))).otherwise((()=>a.createElement(EBe,{amounts:i,showPlanAmountsTooltip:C,itemId:u,itemDate:n,itemName:m,itemHref:L,itemIcon:se?p:void 0,isAggregate:E,isUnplannedAggregate:b,groupLevelBudgetingEnabled:I,isRemainingAmou
1ntType:G,value:V,availableDisplayAmount:W,isBudgetType:Y,isActualAmountType:U,sectionType:c,openEditGroupModal:D,isCategoryGroup:v,showRolloverIcon:le,isFlexSection:re,warningText:T?"This category is overspent, but the Flexible budget amount covers it.":void 0,isPlanSummary:M}))))},ZBe=a.memo(a.forwardRef($Be)),JBe=e=>{let t=e.numColumns,n=e.getDateForColumn,l=e.children,r=e.leadingCell;return a.createElement(a.Fragment,null,null!==r&&void 0!==r?r:a.createElement(XBe,null),(0,db.A)(0,t).map((e=>a.createElement(a.Fragment,{key:e},l(e,n(e))))))},XBe=u.default.div.withConfig({displayName:"PlanColumns__Grow",componentId:"tqum0e-0"})(["flex:1;"]),QBe="flex min-w-37 flex-1 justify-end px-xl",eze="w-full max-w-62.5",tze=e=>{var t,n,l;let r=e.amounts,o=e.color,i=e.ticks;const s=jX({budgeted:(0,De.hj)(null!==(t=r.budgeted)&&void 0!==t?t:0),actual:(0,De.hj)(null!==(n=r.actual)&&void 0!==n?n:0),rollover:(0,De.hj)(null!==(l=r.rollover)&&void 0!==l?l:0)});return a.createElement("div",{"data-external-id":"plan-progress-cell",className:(0,q.cn)(QBe,"items-center")},a.createElement(fe.yDW,{value:100*s,max:100,color:o,size:"md",className:eze},a.createElement(fe.yDW.Track,null,a.createElement(fe.yDW.Fill,null)),null===i||void 0===i?void 0:i.map(((e,t)=>a.createElement(fe.yDW.Tick,{key:t,value:100*e.percent})))))},nze=()=>a.createElement("div",{"data-external-id":"plan-progress-spacer",className:QBe});var aze=n(53766);const lze=(0,u.default)(sl.ZQ).attrs({name:"grid",size:16}).withConfig({displayName:"PlanUnallocatedBudgetRow__GridIcon",componentId:"sc-1rzohyq-0"})(["color:",";"],vt.yW.textLight),rze=u.default.div.withConfig({displayName:"PlanUnallocatedBudgetRow__UnallocatedBudgetText",componentId:"sc-1rzohyq-1"})(["color:",";font-style:italic;padding-right:",";transform:translateX(",");"],(e=>{let t=e.theme;return e.$isNegative?t.color.redText:t.color.textLight}),vt.YK.xsmall,vt.YK.xsmall),oze=(0,u.default)(DPe.n).withConfig({displayName:"PlanUnallocatedBudgetRow__HorizontalPlanRowTitle",componentId:"sc-1rzohyq-2"})(["color:",";display:flex;align-items:center;cursor:default;"],vt.yW.textLight),ize=(0,u.default)(xt.v).attrs({italic:!0}).withConfig({displayName:"PlanUnallocatedBudgetRow__UnallocatedBudgetTextContainer",componentId:"sc-1rzohyq-3"})(["margin-right:",";"],vt.YK.xsmall),sze=(0,u.default)(sl.ZQ).attrs({name:"info",size:12}).withConfig({displayName:"PlanUnallocatedBudgetRow__InfoIcon",componentId:"sc-1rzohyq-4"})([""]),cze=u.default.div.withConfig({displayName:"PlanUnallocatedBudgetRow__TooltipContent",componentId:"sc-1rzohyq-5"})(["margin:"," ",";line-height:150%;"],vt.YK.xsmall,vt.YK.small),dze=()=>a.createElement(oPe.ci,{"data-external-id":"plan-unallocated-budget-row-title"},a.createElement(oze,{icon:a.createElement(lze,null)},a.createElement(ize,null,"Unallocated Flexible Budget")),a.createElement(P.D_,{content:_t.o3.FLEXIBLE_BUDGET.TOOLTIP_TEXT,maxWidth:290},a.createElement("div",{className:"inline-flex shrink-0"},a.createElement(sze,null)))),uze=a.memo((e=>{let t=e.amount,n=e.numColumns,l=e.error,r=e.categoryBudgetAmount,i=e.flexibleBudgetAmount,s=e.getDateForColumn,c=e.onClickUpdateFlexBudget;const d=kPe().showProgressColumn,u=void 0!==d&&d,m=(0,a.useState)(!1),p=(0,o.A)(m,2),g=p[0],h=p[1],v=(0,a.useCallback)((()=>{h(!0),c()}),[c]),f=(0,aze.Z)(l);return(0,a.useEffect)((()=>{l&&f!==l&&g&&h(!1)}),[l,f,g]),a.createElement(oPe.ci,{"data-external-id":"plan-unallocated-budget-row-amount"},a.createElement(JBe,{numColumns:n,getDateForColumn:s,leadingCell:u?a.createElement(nze,null):void 0},(e=>0===e?a.createElement(P.D_,{content:g||l!==HBe.FlexibleBudgetExceeded?void 0:a.createElement(cze,null,"Your category budgets (",(0,rl.T3)(r),") are greater than your Flexible budget (",(0,rl.T3)(i),"). Click"," ",a.createElement(wb.gz,{onClick:v},"here")," to set your Flexible budget to the sum of your category budgets."),maxWidth:340,delayShow:200,clickable:!0},a.createElement(rze,{$isNegative:t<0},(0,rl.T3)(t))):a.createElement(oPe.sP,null))))})),mze=(0,u.default)(fu.g).attrs({type:"error"}).withConfig({displayName:"PlanUnallocatedBudgetRow__UnallocatedBudgetErrorBanner",componentId:"sc-1rzohyq-6"})(["font-size:",";padding:"," ",";line-height:150%;[data-sc-tw~='Link__Link']{text-decoration:underline;font-weight:",";color:",";&:hover{color:",";}}"],vt.J.xsmall,vt.YK.xsmall,vt.YK.small,vt.Wy.medium,vt.yW.redText,vt.yW.redDark),pze=e=>{let t=e.onClickUpdateFlexBudget;return a.createElement(mze,{"data-external-id":"plan-unallocated-error-banner"},"Your category budgets are greater than your flex budget. Click"," ",a.createElement(wb.gz,{onClick:t},"here")," to set your flex budget to the sum of your category budgets.")};var gze=n(81102);const hze=e=>{let t=e.goalId,n=e.afterSave;const l=(0,et.I)(Io.H4,{variables:{id:t}}),o=l.data,i=l.isLoadingInitialData,s=l.error,c=(null!==o&&void 0!==o?o:{}).savingsGoal;return(0,r.YW)({isLoadingInitialData:i,error:s,goal:c}).with({isLoadingInitialData:!0}
1,(()=>a.createElement("div",{className:"flex items-center justify-center p-3xl"},a.createElement(p.i,null)))).with({error:r.P.nonNullable},(()=>a.createElement(Rc.L,{title:_t.$.GOAL_SETTINGS.TITLE,hideBottomBorder:!0},a.createElement(txe.m,{iconName:"x",title:"Unable to load goal",description:"Sorry, something went wrong. The Monarch team has been notified and will get started on a fix."})))).with({goal:r.P.nonNullable},(e=>{let t=e.goal;return a.createElement(gze.G,{data:t,afterSave:n})})).otherwise((()=>a.createElement(Rc.L,{title:_t.$.GOAL_SETTINGS.TITLE,hideBottomBorder:!0},a.createElement(txe.m,{iconName:"x",title:"Goal not found",description:"This goal may have been deleted."}))))},vze=e=>{let t=e.goalId,n=e.onClose,l=e.afterSave;return a.createElement(um.b,{"data-external-id":"savings-goal-edit-modal",onClose:n},a.createElement(hze,{goalId:t,afterSave:l}))};var fze=n(85505),Eze=n(15374);const yze=e=>{let t=e.group,n=t.name,l=t.unplannedCount,i=t.rows,s=t.id,c=t.groupLevelBudgetingEnabled,u=t.showSettingsButton,m=t.href,p=e.sectionType,h=e.unallocatedFlexibleBudgetAmount,v=void 0===h?0:h;const f=(0,d.wA)(),E=(0,a.useCallback)((e=>f((0,g.$f)(e))),[f]),y=i.length>0,b=kPe(),x=b.actions,w=b.timeframe,C=b.openEditCategoryGroup,k=b.refetch,S=(0,lt.L7)().isFlexBudgeting,N=(0,d.d4)((e=>(0,A.zt)(e,s))),T=(0,d.d4)((e=>(0,A.tm)(e,s))),_=(0,a.useCallback)((()=>x.toggleIsGroupCollapsed(s)),[s,x]),D=(0,a.useCallback)((()=>x.toggleIsUnplannedExpandedForGroup(s)),[s,x]),R=(0,a.useState)(void 0),M=(0,o.A)(R,2),L=M[0],O=M[1],P=(0,a.useState)(void 0),B=(0,o.A)(P,2),z=B[0],F=B[1],G=(0,fze.N)(z,{skip:!z}).goal,Y=(0,a.useState)(void 0),U=(0,o.A)(Y,2),V=U[0],W=U[1],j=(0,a.useState)(void 0),H=(0,o.A)(j,2),K=H[0],q=H[1],$=(0,Pd.h)(),Z=(0,o.A)($,2),J=Z[0],X=Z[1],Q=X.open,ee=X.close,te=(0,a.useCallback)((()=>{ee(),q(void 0)}),[ee]),ne=(0,a.useMemo)((()=>C8(w,l,N,c,i.length)),[N,w,l,i.length,c]),ae=(0,KOe.IY)(p),le=ae&&s===V5.NY,re=s===V5.L4,oe=(0,a.useCallback)((e=>[WBe.T6.SavingsGoal,WBe.T6.GoalV2].includes(e)),[]),ie=(0,a.useCallback)((e=>e===WBe.T6.DebtAccount),[]),se=(0,a.useCallback)((e=>oe(e.rowType)||ie(e.rowType)||(0,Tr.A)(e.settingsButtonAction)),[ie,oe]),ce=(0,a.useCallback)((e=>{if(e.rowType!==WBe.T6.SavingsGoal)return e.rowType===WBe.T6.DebtAccount?(q(e.id),void Q()):void(e.rowType!==WBe.T6.GoalV2?e.settingsButtonAction&&(0,r.YW)(e.settingsButtonAction).with(WBe.wg.OPEN_CATEGORY_EDIT_MODAL,(()=>O(e.id))).with(WBe.wg.OPEN_CATEGORY_GROUP_EDIT_MODAL,(()=>C(e.id))).exhaustive():F(e.id));W(e.id)}),[Q,C]),de=s===Ee.Iaz.FLEXIBLE,ue=(0,Pd.h)(),me=(0,o.A)(ue,2),pe=me[0],ge=me[1],he=ge.open,ve=ge.close;return a.createElement(a.Fragment,null,a.createElement(oPe.ir,{$hasBottomPadding:ne},a.createElement(Ize,null,a.createElement(DPe.n,{icon:a.createElement($H.V,{onClick:_,expanded:!N})},m?a.createElement(Vl.W,{to:m,stealthy:!0,truncate:!0},a.createElement(Sze,null,n)):a.createElement(Sze,null,n)),(0,r.YW)({isFlexibleGroup:de,showSettingsButton:u}).with({isFlexibleGroup:!0},(()=>a.createElement(wze,null,a.createElement(Cze,{onClick:he})))).with({showSettingsButton:!0},(()=>a.createElement(wze,null,a.createElement(Cze,{onClick:()=>C(s)})))).otherwise((()=>null))),a.createElement(oPe.aW,{open:!N,shouldAnimateOnMount:!1},y?a.createElement(a.Fragment,null,(0,Tr.A)(v)&&a.createElement(dze,null),i.map(((e,t)=>a.createElement(bze,{key:e.id,onClickIcon:()=>e.id?E(e.id):null,hasBottomBorder:ne&&t===i.length-1,onClickSettings:se(e)?()=>ce(e):void 0,isUnplannedExpanded:T,isFlexibleGroup:de,householdUsesFlexibleBudgeting:S,rowData:e}))),l>0&&a.createElement(oPe.ci,null,a.createElement(OPe,{unplannedCount:l,isExpanded:T,onClick:D}))):a.createElement(Nze,null,(0,r.YW)({isGoals:ae,isSaveUpGoals:le,isDebtPaydown:re}).with({isDebtPaydown:!0},(()=>a.createElement(kD.c,{color:"secondary",size:"sm"},"None of your liability accounts are included in the budget."," ",a.createElement(wb.gz,{href:VF.ey,target:"_blank"},"Learn more")))).with({isSaveUpGoals:!0},(()=>a.createElement(kD.c,{color:"secondary",size:"sm"},"No Save up goals in your budget."," ",a.createElement(Vl.W,{to:I.JZ.goals.savings()},"Create a goal")," to start setting money aside."))).with({isGoals:!0},(()=>a.createElement(kD.c,{color:"secondary",size:"sm"}
1,"No goals in your budget."," ",a.createElement(Vl.W,{to:I.JZ.goalsV2()},"Create a goal")," to start setting money aside."))).otherwise((()=>a.createElement(kD.c,{color:"secondary",size:"sm"},"No categories in this section")))))),!!L&&a.createElement(um.b,{onClose:()=>O(void 0)},(e=>{let t=e.close;return a.createElement(ZX.K,{categoryId:L,onDone:()=>{t(),k()}})})),G&&a.createElement(um.b,{onClose:()=>F(void 0)},(()=>a.createElement(xbe.O,{data:G}))),V&&a.createElement(vze,{goalId:V,onClose:()=>W(void 0),afterSave:k}),K&&a.createElement(J,{onClose:te},a.createElement(XY.r,{accountId:K,onClose:te,onDone:()=>{te(),k()}})),a.createElement(pe,null,a.createElement(SPe,{onClose:ve})))},bze=e=>{let t=e.rowData,n=e.isUnplannedExpanded,l=e.hasBottomBorder,r=e.isFlexibleGroup,o=e.householdUsesFlexibleBudgeting,i=e.onClickSettings,s=e.onClickIcon;const c=t.id,u=t.parentGroupId,m=t.name,p=t.icon,g=t.href,h=t.height,v=t.isUnplanned,f=t.rolloverPeriod,E=null===f||void 0===f?void 0:f.frequency,y=o&&E&&t.budgetVariability===Ee.Iaz.NON_MONTHLY&&E!==Ee.Dxo.MONTHLY,b=(0,d.d4)((e=>(0,A.PY)(e,null!==u&&void 0!==u?u:""))),x=(0,d.d4)((e=>(0,A.PY)(e,null!==c&&void 0!==c?c:"")));if(u&&!b)return null;if(v&&!n)return null;const w=v||!!u;return a.createElement(kze,{"data-external-id":"plan-group-left-row","data-goal-row-id":c,$grayBackground:w,$hasPadding:r&&!!u,$hasBottomBorder:l,$height:h},a.createElement(DPe.n,{icon:"chevron"===p?a.createElement($H.V,{expanded:x}):p,href:g,onClickIcon:s},a.createElement("div",{className:"flex flex-col"},a.createElement(Aze,{title:"string"===typeof p?"".concat(p," ").concat(m):m},m),y&&E&&a.createElement(xt.v,{size:"xsmall",color:"textLight"},(0,hPe.sentenceCase)(E)))),t.rightHandContent&&a.createElement(xze,null,t.rightHandContent),i&&a.createElement(wze,{$grayBackground:w},a.createElement(Cze,{$grayBackground:w,onClick:i})))},xze=u.default.div.attrs({"data-sc-tw":"PlanGroupLeft__RightHandContent"}).withConfig({displayName:"PlanGroupLeft__RightHandContent",componentId:"sc-5i2xi3-0"})(["opacity:1;margin-left:auto;transition:",";flex-shrink:0;"],(e=>e.theme.transition.createDefaultTransition(["opacity"]))),wze=u.default.div.attrs({"data-sc-tw":"PlanGroupLeft__SettingsButtonFade"}).withConfig({displayName:"PlanGroupLeft__SettingsButtonFade",componentId:"sc-5i2xi3-1"})(["position:absolute;right:",";top:0;bottom:0;display:flex;align-items:center;opacity:0;transition:",";pointer-events:none;&::before{content:'';position:absolute;right:100%;top:0;bottom:0;width:",";background:linear-gradient( to right,transparent,"," );}"],vt.YK.xlarge,(e=>e.theme.transition.createDefaultTransition(["opacity"])),vt.YK.xxlarge,(e=>{let t=e.theme;return e.$grayBackground?(0,oPe.HR)({theme:t}):vt.Ee.color.background.primary({theme:t})})),Cze=(0,u.default)(B.L).attrs({icon:"settings"}).withConfig({displayName:"PlanGroupLeft__SettingsButton",componentId:"sc-5i2xi3-2"})(["pointer-events:auto;background-color:",";"],(e=>{let t=e.theme;return e.$grayBackground?(0,oPe.HR)({theme:t}):vt.Ee.color.background.primary({theme:t})})),Aze=u.default.span.withConfig({displayName:"PlanGroupLeft__CategoryOrGroupName",componentId:"sc-5i2xi3-3"})(["",""],(0,xb.gO)()),Ize=(0,u.default)(oPe.bw).withConfig({displayName:"PlanGroupLeft__GroupHeaderLeft",componentId:"sc-5i2xi3-4"})(["border-bottom-left-radius:",";padding-right:",";",";:hover{[data-sc-tw~='PlanGroupLeft__SettingsButtonFade']{opacity:1;}}"],vt.r8.medium,vt.YK.xlarge,(e=>{let t=e.theme;return(0,Eze.z)({theme:t,topLeft:!0})})),kze=(0,u.default)(oPe.ci).withConfig({displayName:"PlanGroupLeft__GridRow",componentId:"sc-5i2xi3-5"})(["padding-right:",";padding-left:",";position:relative;> *:first-child{flex:1;min-width:0;}:hover [data-sc-tw~='PlanGroupLeft__RightHandContent']{opacity:0;}:hover [data-sc-tw~='PlanGroupLeft__SettingsButtonFade']{opacity:1;}"],vt.YK.xlarge,(e=>{let t=e.theme;return e.$hasPadding?t.spacing.xlarge:0})),Sze=(0,u.default)(oPe.HM).withConfig({displayName:"PlanGroupLeft__GroupName",componentId:"sc-5i2xi3-6"})(["margin-top:",";"],vt.YK.xxsmall),Nze=(0,u.default)(oPe.ci).withConfig({displayName:"PlanGroupLeft__PlanEmptyRow",componentId:"sc-5i2xi3-7"})(["padding-left:",";"],vt.YK.xlarge),Tze=a.memo(yze);var _ze=n(95940);const Dze=e=>{let t=e.amounts,n=e.numColumns,l=e.sectionType,r=e.itemId,o=e.itemName,i=e.itemHref,s=e.itemIcon,c=e.itemHasRolloverEnabled,d=e.isAggregate,u=void 0!==d&&d,m=e.isUnplannedAggregate,p=void 0!==m&&m,g
1=e.groupLevelBudgetingEnabled,h=void 0!==g&&g,v=e.excludeFromBudget,f=void 0!==v&&v,E=e.canBeBudget,y=e.canMoveBudget,b=e.rowType,x=e.hasParentRow,w=void 0!==x&&x,C=e.error,A=e.budgetVariability,I=e.flexibleBudgetCellRef,k=e.isOverspentButCoveredByFlexibleAmount,S=e.openEditGroupModal,N=e.updateFlexBudgetValue,T=e.isPlanSummary,_=e.leadingCell;const D=kPe(),R=D.getIsColumnLoading,M=D.updateCellValue,L=D.getDateForColumn,O=D.getAmountTypeForColumn,P=D.getCanEditColumn,B=(0,lt.L7)().isFlexBudgeting,z=b===WBe.T6.CategoryGroup,F=B&&(0,KOe.n4)(A,Ee.Iaz.FLEXIBLE),G=(0,a.useCallback)(((e,t,n)=>{var a;if(f)return!1;const l="remaining"===e,r=(0,De.fS)(null===n||void 0===n?void 0:n.budgeted),o=(null!==(a=null===n||void 0===n?void 0:n.remaining)&&void 0!==a?a:0)>=0,i=(0,BY.A)(null===n||void 0===n?void 0:n.rolloverType);return!(F&&l&&r&&i)&&((!p||"budgeted"!==e)&&(!(!u&&!t)||("actual"===e||!(l&&r&&o&&i)&&!h)))}),[f,h,u,p,w,F]),Y=(0,a.useCallback)((e=>null===M||void 0===M?void 0:M(null!==r&&void 0!==r?r:"",e,l,z,b)),[M,r,l,z,b]);return a.createElement(JBe,{"data-external-id":"plan-column-amounts",numColumns:n,getDateForColumn:L,leadingCell:_},((e,n)=>{var d;const m=t[n.toISODate()],g=R(e)||(null===m||void 0===m?void 0:m.loadingGroupBudget),v=O(e);if(!G(v,z,m))return a.createElement(oPe.sP,null);const f="remaining"===v,x=f&&l!==E8&&E,w=f&&y,_=null!==(d=E&&(null===P||void 0===P?void 0:P(e)))&&void 0!==d&&d,D=u&&"budgeted"===v&&"expense"===l&&"flexible"===r;return a.createElement(oPe.sP,null,a.createElement(ZBe,{ref:D?I:void 0,showPlanAmountsTooltip:x,date:n,canEdit:_,amountType:v,amounts:m,onChangeValue:Y(n),isCategoryGroup:z,isAggregate:u,isUnplannedAggregate:p,sectionType:l,rowType:b,itemId:r,itemName:o,itemHref:i,itemIcon:s,itemHasRolloverEnabled:c,isLoading:g,groupLevelBudgetingEnabled:h,openEditGroupModal:S,allowMoveMoney:w,error:C,updateFlexBudgetValue:N,budgetVariability:A,isOverspentButCoveredByFlexibleAmount:k,isPlanSummary:T}))}))},Rze=a.memo(Dze,kc()),Mze=(0,u.default)(m.g).withConfig({displayName:"PlanGroupRight__Root",componentId:"sc-1awdk8y-0"})(["flex:1;"]),Lze=(0,u.default)(oPe.bw).withConfig({displayName:"PlanGroupRight__GroupHeaderRight",componentId:"sc-1awdk8y-1"})(["transition:",";transition-delay:",";border-bottom-right-radius:",";",";font-weight:",";font-size:",";"],(e=>e.theme.transition.default),(e=>e.$isCollapsed?"150ms":0),(e=>{let t=e.theme;return e.$isCollapsed?t.radius.medium:0}),(e=>{let t=e.theme;return(0,Eze.z)({theme:t,topRight:!0})}),(e=>e.theme.fontWeight.medium),(e=>e.theme.fontSize.large)),Oze=(0,u.default)(oPe.ci).withConfig({displayName:"PlanGroupRight__StyledPlanGridRow",componentId:"sc-1awdk8y-2"})(["position:relative;"]),Pze=u.default.div.withConfig({displayName:"PlanGroupRight__GroupContainer",componentId:"sc-1awdk8y-3"})(["padding-bottom:","px;"],(e=>e.$hasBottomPadding?oPe.sr:0)),Bze=e=>{let t=e.amounts,n=e.group,l=e.numColumns,r=e.sectionType,o=e.unallocatedFlexibleBudgetAmount;const i=kPe(),s=i.timeframe,c=i.openEditCategoryGroup,u=i.getDateForColumn,m=i.getAmountTypeForColumn,p=i.showProgressColumn,g=void 0!==p&&p,h=n.id,v=n.name,f=n.rows,E=n.unplannedCount,y=n.groupLevelBudgetingEnabled,b=n.rolloverPeriod,x=n.canBeBudget,w=n.canMoveBudget,C=n.href,I=t.aggregate,k=t.aggregateUnplanned,S=(0,a.useMemo)((()=>(0,rj.A)((e=>{const t=k[u(e).toISODate()];return!!w8(t,m(e))}),(0,db.A)(0,l))),[l,u,m,k]),N=(0,d.d4)((e=>(0,A.zt)(e,h))),T=(0,d.d4)((e=>(0,A.tm)(e,h))),_=(0,a.useMemo)((()=>u(0)),[u]),D=(0,a.useMemo)((()=>u8(_)),[_]),R=(0,a.useMemo)((()=>C8(s,E,N,y,f.length)),[N,s,E,f.length,y]),M=(0,_ze.A)(Number(h))?WBe.T6.CategoryGroup:void 0,L=(0,a.useMemo)((()=>{if((0,Tr.A)(o)&&o<0)return HBe.FlexibleBudgetExceeded}),[o]),O=(0,a.useMemo)((()=>{var e;return(null===(e=t.rowsAggregate[_.toISODate()])||void 0===e?void 0:e.budgeted)||0}),[t,_]),P=h===Ee.Iaz.FLEXIBLE,B=(0,a.useMemo)((()=>{var e;return(null===(e=t.aggregate[_.toISODate()])||void 0===e?void 0:e.budgeted)||0}),[t,_]),z=(0,a.useRef)(null),F=(0,a.useCallback)((()=>{o&&z.current&&z.current.setValue(O,!1)}),[o,z,O]),G=(0,a.useMemo)((()=>{if(!(s===f8.s.SingleMonth&&(y||P)))return g?a.createElement(nze,null):null;const e=I[_.toISODate()],t=jX(null!==e&&void 0!==e?e:{}),n=Z5(VX(e,r));return g?a.createElement(tze,{amounts:null!==e&&void 0!==e?e:{},color:n,ticks:D}):a.createElement(fe.yDW,{value:t,max:1,color:n,size:"xs",variant:"squared",className:"absolute inset-x-0 bottom-0 z-1"},a.createElement(fe.yDW.Track,null,a.createElement(fe.yDW.Fill,null)),null===D||void 0===D?void 0:D.map(((e,t)=>a.createElement(fe.yDW.Tick,{key:t,value:e.percent,className:"h-3 w-px"}))))}),[s,y,P,_,D,I,r,g]),Y=f.length>0;return a.createElement(Mze,{"data-external-id":"plan-group-right",column:!0},a.createElement(Lze,{$isCollapsed:N},a.createElement(Rze,{numColumns:l,amounts:I,itemHasRolloverEnabled:(0,Tr.A)(b)&&(0,wPe.sg)(_,b),sectionType:r,itemId:h,itemName:v,itemHref:null!==C&&void 0!==C?C:void 0,groupLevelBudgetingEnabled:null!==y&&void 0!==y&&y,openEditGroupModal:()=>c(h),canBeBudget:x,canMoveBudget:w,rowType:M,error:L,flexibleBudgetCellRef:z,updateFlexBudgetValue:L===HBe.FlexibleBudgetExceeded?F:void 0,leadingCell:g?G:void 0,isAggregate:!0}),!g&&G),Y&&a.createElement(oPe.aW,{open:!N,shouldAnimateOnMount:!1},a.createElement(Pze,{$hasBottomPadding:R},(0,Tr.A)(o)&&a.createElement(uze,{amount:o,numColumns:l,getDateForColumn:u,onClickUpdateFlexBudget:F,categoryBudgetAmount:O,flexibleBudgetAmount:B,error:L}),f.map((e=>a.createElement(zze,{key:e.id,rowData:e,isUnplannedExpanded:T,groupLevelBudgetingEnabled:y,numColumns:l,amounts:t,sectionType:r,firstColumnDate:_,timeframe:s,progressTicks:D,showProgressColumn:g,isFlexibleGroup:P,unallocatedFlexibleBudgetAmount:o}))),E>0&&a.createElement(oPe.ci,null,S&&a.createElement(Rze,{numColumns:l,amounts:k,sectionType:r,canBeBudget:!1,canMoveBudget:!1,isUnplannedAggregate:!0,isAggregate:!0,leadingCell:g?a.createElement(nze,null):void 0})))))},zze=e=>{var t;const n=e.isUnplannedExpanded,l=e.rowData,r=e.sectionType,o=e.amounts,i=e.numColumns,s=e.firstColumnDate,c=e.timeframe,u=e.progressTicks,m=e.isFlexibleGroup,p=e.unallocatedFlexibleBudgetAmount,g=e.showProgressColumn,h=l.id,v=l.isUnplanned,f=l.name,E=l.icon,y=l.he
1ight,b=l.rolloverPeriod,x=l.canBeBudgeted,w=l.canMoveBudget,C=l.parentGroupId,I=l.rowType,k=l.groupLevelBudgetingEnabled,S=l.excludeFromBudget,N=l.budgetVariability,T=l.href,_=c===f8.s.SingleMonth,D=I===WBe.T6.CategoryGroup,R=null===(t=o[h])||void 0===t?void 0:t[s.toISODate()],M=(0,a.useMemo)((()=>(0,KOe.Bd)(null===R||void 0===R?void 0:R.remaining,p)),[null===R||void 0===R?void 0:R.remaining,p]),L=(0,a.useMemo)((()=>{const e=m&&(null===R||void 0===R?void 0:R.budgeted)&&(null===R||void 0===R?void 0:R.budgeted)>0;if(!v&&_&&(!k||D)&&(e||!m)){const e=jX(null!==R&&void 0!==R?R:{}),t=Z5(M?"yellow":VX(R,r));return g?a.createElement(tze,{amounts:null!==R&&void 0!==R?R:{},color:t,ticks:u}):a.createElement(fe.yDW,{value:e,max:1,color:t,size:"xs",variant:"squared",className:"absolute inset-x-0 bottom-0 z-1"},a.createElement(fe.yDW.Track,null,a.createElement(fe.yDW.Fill,null)),null===u||void 0===u?void 0:u.map(((e,t)=>a.createElement(fe.yDW.Tick,{key:t,value:e.percent,className:"h-3 w-px"}))))}return g?a.createElement(nze,null):void 0}),[m,R,v,_,k,D,M,r,u,g]),O=(0,d.d4)((e=>(0,A.PY)(e,null!==C&&void 0!==C?C:"")));return C&&!O||v&&!n?null:a.createElement(Oze,{"data-external-id":"plan-group-right-row",key:h,"data-goal-row-id":h,$grayBackground:v||!!C,$height:y},a.createElement(Rze,{groupLevelBudgetingEnabled:null!==k&&void 0!==k&&k,excludeFromBudget:S,numColumns:i,amounts:o[h],itemId:h,itemHref:T,itemName:f,itemIcon:E,itemHasRolloverEnabled:(0,Tr.A)(b)&&(0,wPe.sg)(s,b),sectionType:r,canBeBudget:x,canMoveBudget:w,rowType:I,hasParentRow:!!C,budgetVariability:N,isOverspentButCoveredByFlexibleAmount:M,leadingCell:g?L:void 0}),!g&&L)},Fze=a.memo(Bze,kc());var Gze=n(27845);const Yze=e=>{let t=e.amounts,n=e.group,l=e.numColumns,r=e.sectionType;const i=kPe(),s=i.timeframe,c=i.getDateForColumn,d=(0,a.useMemo)((()=>c(0)),[c]).toISODate(),u=s===f8.s.SingleMonth&&n.id===Ee.Iaz.FLEXIBLE,m=(0,a.useMemo)((()=>(0,Gze.n8)(t,d,u,r)),[t,u,r,d]),p=(0,a.useMemo)((()=>{if(n.id!==Ee.Iaz.FLEXIBLE)return n;const e=(e,n)=>{var a,l,r,o,i,s;const c=null!==(a=null===(l=t[e.id])||void 0===l||null===(r=l[d])||void 0===r?void 0:r.actual)&&void 0!==a?a:0;return(null!==(o=null===(i=t[n.id])||void 0===i||null===(s=i[d])||void 0===s?void 0:s.actual)&&void 0!==o?o:0)-c},a=(t,n)=>(0,sU.A)(e,t).reduce(((t,a)=>{if(a.groupLevelBudgetingEnabled){const l=n.filter((e=>e.parentGroupId===a.id)),r=(0,sU.A)(e,l);return[...t,a,...r]}return[...t,a]}),[]),l=(0,vj.A)((e=>!e.parentGroupId),n.rows),r=(0,o.A)(l,2),i=r[0],s=r[1],c=(0,vj.A)((e=>!e.isUnplanned),i),u=(0,o.A)(c,2),m=u[0],p=u[1],g=(0,vj.A)((e=>!e.isUnplanned),s),h=(0,o.A)(g,2),v=h[0],f=h[1],E=a(m,v),y=a(p,f);return(0,U.A)((0,U.A)({},n),{},{rows:[...E,...y]})}),[t,d,n]);return a.createElement(oPe.JE,{"data-external-id":"plan-group"},a.createElement("div",{className:"flex"},a.createElement(Tze,{group:p,sectionType:r,unallocatedFlexibleBudgetAmount:m}),a.createElement(Fze,{amounts:t,group:p,numColumns:l,sectionType:r,unallocatedFlexibleBudgetAmount:m})))},Uze=a.memo(Yze,kc()),Vze=(0,u.default)(oPe.JE).withConfig({displayName:"PlanSectionFooter__Root",componentId:"sc-1f84t62-0"})(["font-weight:",";font-size:",";"],vt.Wy.medium,vt.J.large),Wze=(0,u.default)(oPe.ci).withConfig({displayName:"PlanSectionFooter__Row",componentId:"sc-1f84t62-1"})(["",""],(e=>{let t=e.$backgroundColor;return t&&(0,u.css)(["background:",";transition:background 0.3s cubic-bezier(0.65,0.05,0.36,1);color:",";border-top-right-radius:",";border-bottom-right-radius:",";"],t,(e=>e.theme.color.textWhite),(e=>e.theme.radius.medium),(e=>e.theme.radius.medium))})),jze=(0,u.default)(DPe.n).withConfig({displayName:"PlanSectionFooter__Title",componentId:"sc-1f84t62-2"})(["",""],(e=>{let t=e.$backgroundColor;
1return t&&(0,u.css)(["height:100%;background:",";transition:background 0.3s cubic-bezier(0.65,0.05,0.36,1);border-top-left-radius:",";border-bottom-left-radius:",";"],t,(e=>e.theme.radius.medium),(e=>e.theme.radius.medium))})),Hze=u.default.div.attrs((0,Ex.p)("plan-section-footer-separator")).withConfig({displayName:"PlanSectionFooter__Separator",componentId:"sc-1f84t62-3"})(["width:100%;height:2px;background:",";margin-bottom:",";"],vt.yW.grayLight,vt.YK.gutter),Kze=e=>{var t;let n=e.name,l=e.amounts,r=e.numColumns,o=e.sectionType,i=e.showSeparator,s=e.isPlanSummary;const c=s?1:r,d=(0,u.useTheme)(),m=kPe(),p=m.getDateForColumn,g=m.getAmountTypeForColumn,h=m.showProgressColumn,v=void 0!==h&&h,f=s&&l?GX(null===(t=l[p(0).toISODate()])||void 0===t?void 0:t[g(0)],d):void 0,E=(0,a.useMemo)((()=>{if(!v)return;if(s)return a.createElement(nze,null);const e=p(0),t=null===l||void 0===l?void 0:l[e.toISODate()];return t?a.createElement(tze,{amounts:t,color:Z5(VX(t,o)),ticks:u8(e)}):a.createElement(nze,null)}),[v,s,p,l,o]);return a.createElement(a.Fragment,null,i&&a.createElement(Hze,null),a.createElement(Vze,null,a.createElement(Wze,{$backgroundColor:f},a.createElement(oPe.ir,{$backgroundColor:f},a.createElement(jze,{$backgroundColor:f,size:"lg",weight:"medium"},n)),a.createElement(Rze,{numColumns:c,amounts:null!==l&&void 0!==l?l:{},isAggregate:!0,sectionType:o,canBeBudget:!1,canMoveBudget:!1,isPlanSummary:s,leadingCell:E}),c!==r&&(0,db.A)(c,r).map((e=>a.createElement(oPe.sP,{key:e}))))))},qze=a.memo(Kze,kc()),$ze=u.default.div.withConfig({displayName:"PlanHeaderPastSeparator__Root",componentId:"kwieff-0"})(["width:0;height:100%;position:relative;"]),Zze=u.default.div.withConfig({displayName:"PlanHeaderPastSeparator__Inner",componentId:"kwieff-1"})(["position:absolute;left:0;top:0;bottom:0;transform:translateX(-50%);"]),Jze=u.default.div.withConfig({displayName:"PlanHeaderPastSeparator__LineContainer",componentId:"kwieff-2"})(["position:relative;width:3px;margin:0 ",";"],(e=>e.theme.spacing.xlarge)),Xze=u.default.div.withConfig({displayName:"PlanHeaderPastSeparator__Line",componentId:"kwieff-3"})(["position:absolute;top:0;left:0;right:0;bottom:calc(-100vh + "," + ",");background:",";"],uS.uF,(e=>e.theme.spacing.xxlarge),(e=>e.theme.color.grayLight)),Qze=e=>{let t=e.className;return a.createElement($ze,{"data-external-id":"plan-header-past-separator",className:t},a.createElement(Zze,null,a.createElement(Jze,null,a.createElement(Xze,null))))},eFe=a.memo(Qze);var tFe=n(57171);const nFe=(0,u.default)(m.g).withConfig({displayName:"PlanSectionHeader__Root",componentId:"sc-1p9p4c9-0"})(["align-items:flex-start;position:sticky;top:0;width:100%;height:","px;padding-right:",";background:",";z-index:",";"],oPe.F$,(e=>e.theme.spacing.xlarge),vt.Ee.color.background.page,oPe.c),aFe=u.default.div.withConfig({displayName:"PlanSectionHeader__V2Background",componentId:"sc-1p9p4c9-1"})(["position:absolute;top:0;left:0;right:0;height:calc(","px - ",");z-index:-1;display:block;"],oPe.F$,vt.YK.small),lFe=(0,u.default)(aFe).withConfig({displayName:"PlanSectionHeader__V2BackgroundLeft",componentId:"sc-1p9p4c9-2"})(["",""],(e=>{let t=e.theme;return(0,Eze.z)({theme:t,backgroundColor:vt.Ee.color.background.page({theme:t}),fillColor:t.color.gray4,topLeft:!0,bottomLeft:!0})})),rFe=(0,u.default)(aFe).withConfig({displayName:"PlanSectionHeader__V2BackgroundRight",componentId:"sc-1p9p4c9-3"})(["",""],(e=>{let t=e.theme;return(0,Eze.z)({theme:t,backgroundColor:vt.Ee.color.background.page({theme:t}),fillColor:t.color.gray4,topRight:!0,bottomRight:!0})})),oFe=u.default.div.withConfig({displayName:"PlanSectionHeader__BottomPadding",componentId:"sc-1p9p4c9-4"})(["padding-bottom:",";"],(e=>e.theme.spacing.default)),iFe=(0,u.default)(oPe.Xi).withConfig({displayName:"PlanSectionHeader__StyledLeftSticky",componentId:"sc-1p9p4c9-5"})(["background:none;"]),sFe=(0,u.default)(oFe).withConfig({displayName:"PlanSectionHeader__Left",componentId:"sc-1p9p4c9-6"})(["display:flex;align-items:center;padding-right:",";height:calc(","px - ",");padding-bottom:0;"],(e=>e.theme.spacing.xlarge),oPe.F$,vt.YK.small),cFe=u.default.div.withConfig({displayName:"PlanSectionHeader__Title",componentId:"sc-1p9p4c9-7"})(["font-size:",";color:",";font-weight:",";margin-left:",";"],vt.J.small,vt.Ee.color.content.secondary,(e=>e.theme.fontWeight.medium),(e=>e.theme.spacing.xsmall)),dFe=(0,u.default)(oFe).withConfig({displayName:"PlanSectionHeader__ColumnTitle",componentId:"sc-1p9p4c9-8"})(["font-size:",";font-weight:",";color:",";text-align:right;transition:",";padding-top:6px;",""],vt.J.small,(e=>e.theme.fontWeight.medium),(e=>{let t=e.theme;return e.isActive?t.color.text:t.color.textLight}),(e=>e.theme.transition.default),(e=>e.clickable&&(0,u.css)(["cursor:pointer;:hover{color:",";}"],(e=>e.theme.color.blue)))),uFe=(0,u.default)(eFe).withConfig({displayName:"PlanSectionHeader__StickyPlanHeaderPastSeparator",componentId:"sc-1p9p4c9-9"})(["position:sticky;left:calc(var(--plan-left-width,","px) + 5px);right:-5px;margin-left:30px;margin-right:-30px;display:block;"],oPe.Mh),mFe=e=>{let t=e.name,n=e.sectionType,l=e.isCollapsed,r=e.timeframe,o=e.numColumns,i=e.onClickColumn;const s=kPe(),c=s.getDateForColumn,d=s.getAmountTypeForColumn,u=s.actions,m=s.showProgressColumn,p=void 0!==m&&m,g
1=(0,v.D)((()=>{u.toggleIsSectionCollapsed(n)})),h=c8(c(0)),f=a.createElement(kD.c,{size:"sm",weight:"medium",color:"secondary"},"Progress");return a.createElement(nFe,{"data-external-id":"plan-section-header"},a.createElement(rFe,null),a.createElement(iFe,null,a.createElement(lFe,null),a.createElement(sFe,null,a.createElement($H.V,{className:"ml-xs text-content-secondary",expanded:!l,onClick:g}),a.createElement(cFe,null,t))),a.createElement(JBe,{numColumns:o,getDateForColumn:c,leadingCell:p?a.createElement("div",{className:(0,q.cn)(QBe,"items-start")},a.createElement("div",{className:(0,q.cn)(eze,"flex items-center pt-1.5")},h?a.createElement(tFe.c,{label:f,icon:a.createElement(fe.ucZ,{size:"xs",className:"translate-y-px"}),triggerClassName:"text-content-secondary",content:x8(n)}):f)):void 0},((e,t)=>a.createElement(a.Fragment,null,a.createElement(oPe.sP,null,a.createElement(dFe,{onClick:()=>i(e),clickable:r!==f8.s.SingleMonth},r===f8.s.SingleMonth?{budgeted:"Planned",actual:"Actual",remaining:"Remaining"}[d(e)]:t.toFormat(r===f8.s.Yearly?"y":"MMM y"))),r!==f8.s.Yearly&&e+1<o&&"actual"===d(e)&&"budgeted"===d(e+1)&&c(e+1)&&a.createElement(uFe,null)))))},pFe=a.memo(mFe),gFe=e=>{let t=e.section,n=t.name,l=t.groups,r=t.type,o=t.aggregateRows,i=e.amounts,s=e.timeframe,c=e.numColumns,d=e.isCollapsed,u=e.onClickColumn;return a.createElement("div",{"data-external-id":"plan-section",className:"flex flex-col"},a.createElement(pFe,{name:n,sectionType:r,isCollapsed:d,timeframe:s,numColumns:c,onClickColumn:u}),!d&&l.map((e=>a.createElement(Uze,{key:e.id,amounts:i[e.id],group:e,numColumns:c,sectionType:r}))),null===o||void 0===o?void 0:o.map(((e,t)=>{let n=e.title,l=e.key,o=e.sectionType,d=e.isLeftoverRow;return a.createElement(qze,{key:l,name:n,amounts:i[l],numColumns:c,sectionType:null!==o&&void 0!==o?o:r,showSeparator:t>0,isPlanSummary:d&&s===f8.s.SingleMonth})})))},hFe=a.memo(gFe,kc()),vFe=["animate-highlight","rounded-xs"];var fFe=n(1324),EFe=n(63140),yFe=n(94527);const bFe=Bq((()=>{const e=(0,f8.g)(),t=(0,o.A)(e,2),n=t[0],l=t[1],r=(0,EFe.d)(n),i=r.data,s=r.refetch,c=r.fetchedDateRange,u=r.doesNotHaveBudget,m=r.budgetStatus,p=r.refetchBudgetStatus,h=r.updateCellValue,v=r.error,f=Fq({error:v,retryFn:s}),y=f.isRetrying,b=f.pageError,x=(0,fFe.m)(i,n,c),w=x.isLoadingInitialData,C=x.gridDisplayData,k=x.numColumns,S=x.getDateForColumn,N=x.getAmountTypeForColumn,T=x.getCanEditColumn,_=x.getIsColumnLoading,D=x.gridAmounts,R=x.budgetSummaryData,M=x.initialScrollOffset,L=n.timeframe,O=n.highlightedDate,P=n.thisMonth,B=n.columnDisplayInterval,z=n.collapsedSections,F=(0,d4.u)("feat-budget-progress-column-web","off").isOn&&L===f8.s.SingleMonth,G=l.setTimeframe,Y=l.setHighlightedDate,U=l.moveHighlightedDate;(e=>{const t=(0,E.pE)("highlightGoal"),n=(0,d.wA)(),l=(0,d.Pj)(),r=(0,a.useRef)(null);(0,a.useEffect)((()=>{var a,o;if(!t)return;if(e)return;if(r.current===t)return;const i=l.getState();(0,A.po)(i)[V5.hT]&&n((0,g.QS)(V5.hT));const s=i;[V5.NY,V5.VA].forEach((e=>{(0,A.zt)(s,e)&&n((0,g.AG)(e)),(0,A.tm)(s,e)||n((0,g.XK)(e))}));let c,d,u=0,m=[];const p=null!==(a=null===(o=window.CSS)||void 0===o?void 0:o.escape)&&void 0!==a?a:e=>e,h='[data-goal-row-id="'.concat(p(t),'"]'),v=()=>{u+=1;const e=Array.from(document.querySelectorAll(h));if(0!==e.length)r.current=t,m=e,e[0].scrollIntoView({behavior:"smooth",block:"center"}),e.forEach((e=>e.classList.add(...vFe))),d=setTimeout((()=>{e.forEach((e=>e.classList.remove(...vFe)))}),2400);else{if(u>=20)return;c=setTimeout(v,100)}};return c=setTimeout(v,100),()=>{c&&clearTimeout(c),d&&clearTimeout(d),m.forEach((e=>e.classList.remove(...vFe)))}}),[t,e,n,l])})(w);const V=(0,a.useState)(null),W=(0,o.A)(V,2),j=W[0],H=W[1],K=(0,Pd.h)(),q=(0,o.A)(K,2),$=q[0],Z=q[1],J=Z.open,X=Z.close,Q=(0,a.useCallback)((e=>{H(e),J()}),[J]),ee=(0,JOe.w)().budgetApplyToFutureMonthsDefault,te=(0,a.useCallback)((e=>{var t,n,a,l;return Math.round(null!==(t=null===D||void 0===D||null===(n=D.income)||void 0===n||null===(a=n.aggregate)||void 0===a||null===(l=a[e.toISODate()])||void 0===l?void 0:l.budgeted)&&void 0!==t?t:0)}),[D]),ne=(0,a.useMemo)((()=>({refetch:s,getIsColumnLoading:_,timeframe:L,openEditCategoryGroup:Q,actions:l,getDateForColumn:S,getAmountTypeForColumn:N,getCanEditColumn:T,updateCellValue:h,budgetApplyToFutureMonthsDefault:ee,getBudgetedIncomeForDate:te,
1showProgressColumn:F})),[F,s,_,L,Q,l,S,N,T,h,ee,te]),ae=(0,a.useCallback)((e=>{Y(S(e)),G(L===f8.s.Yearly?f8.s.Monthly:f8.s.SingleMonth,{pushHistory:!0})}),[Y,S,G,L]),le=(0,a.useMemo)((()=>{if(L===f8.s.SingleMonth)return(0,Ba.z9)(O);{const e=B.start.toFormat("y"),t=B.end.toFormat("y");return e===t?e:"".concat(e," - ").concat(t)}}),[L,B,O]),re=(0,a.useMemo)((()=>c8(O)?[{name:b8,percent:d8(O)}]:void 0),[O]),oe=(0,E.pE)("introModal"),ie=(0,Pd.h)(!!oe),se=(0,o.A)(ie,2),ce=se[0],de=se[1],ue=de.open,me=de.close,pe=(0,yFe._)(),ge=(0,o.A)(pe,2),he=ge[0],ve=ge[1];return a.createElement(IPe.Provider,{"data-external-id":"plan",value:ne},a.createElement(Yq,{name:"Budget",emptyIcon:"map",emptyTitle:_t.qO,shouldScroll:!1,pageError:b,isLoading:y,header:a.createElement(gPe,{title:le,timeframe:L,onClickToday:()=>Y(P),onPanLeft:()=>U(!1),onPanRight:()=>U(!0)}),overlayEmptyComponent:m&&u?a.createElement(qOe,{date:B.start,onCompleted:()=>{s(),p(),ue()},budgetStatus:m}):void 0,overrideTitle:le},a.createElement(xFe,{initialOffset:null!==he&&void 0!==he?he:M,onScroll:ve},a.createElement(rV.T,{screenName:"Budget"}),a.createElement(wFe,{className:F?oPe.xV:void 0},a.createElement(CFe,null,w?a.createElement(kFe,{showProgressColumn:F}):C.map((e=>a.createElement(hFe,{key:e.id,section:e,amounts:D[e.id],timeframe:L,numColumns:k,isCollapsed:!!z[e.type],onClickColumn:ae})))),L===f8.s.SingleMonth&&a.createElement(AFe,null,a.createElement(IFe,null),a.createElement(t8,{data:R,ticks:re,isLoading:w})),a.createElement($,null,a.createElement(c0.x,{onDone:()=>{s(),X()},onDeleted:s,categoryGroupId:null!==j&&void 0!==j?j:""})))),a.createElement(ce,null,a.createElement(OOe,{onCompleted:me})),a.createElement(XU.l,{path:I.JZ.plan.settings.relativePath},(e=>{let t=e.close;return a.createElement(Rc.L,{title:"Budget Settings"},a.createElement(XOe,{onDone:()=>{t()}}))}))))})),xFe=(0,u.default)(_m.O).withConfig({displayName:"Plan__ScrollRoot",componentId:"sc-1myvuyp-0"})(["position:relative;margin-left:",";transform:scale(1);"],vt.YK.gutter),wFe=(0,u.default)(m.g).withConfig({displayName:"Plan__Container",componentId:"sc-1myvuyp-1"})(["position:absolute;left:0;top:0;min-width:100%;padding-right:",";"],vt.YK.gutter),CFe=u.default.div.attrs((0,Ex.p)("plan-sections-container")).withConfig({displayName:"Plan__SectionsContainer",componentId:"sc-1myvuyp-2"})(["flex:1;"]),AFe=u.default.div.withConfig({displayName:"Plan__Sticky",componentId:"sc-1myvuyp-3"})(["min-width:25vw;position:sticky;top:0;height:100%;"]),IFe=u.default.div.withConfig({displayName:"Plan__StickyCover",componentId:"sc-1myvuyp-4"})(["background:",";height:0;width:100%;"],vt.Ee.color.background.page),kFe=(0,u.default)((e=>{let t=e.className,n=e.showProgressColumn,l=void 0!==n&&n;return a.createElement(HOe,{"data-external-id":"budget-list-loading",className:t},Dr().range(3).map((e=>a.createElement(YOe,{key:e,showProgressColumn:l}))))})).withConfig({displayName:"Plan__StyledBudgetListLoading",componentId:"sc-1myvuyp-5"})(["margin-top:","px;"],oPe.F$);var SFe=n(59998);const NFe=()=>{var e;const t=(0,SFe.h)("billSyncPausedBanner"),n=t.dismissedAt,l=t.dismissComponent,r=(0,et.I)(RFe,{fetchPolicy:"cache-first"}).data,o=null===r||void 0===r||null===(e=r.spinwheelUser)||void 0===e?void 0:e.isBillSyncTrackingEnabled;return!!(null===r||void 0===r||!r.spinwheelUser)||o||n?null:a.createElement("div",{"data-external-id":"bill-sync-paused-banner",className:"mb-default flex w-full shrink-0 px-default"},a.createElement(TFe,null,a.createElement("div",{className:"flex items-center gap-sm"},a.createElement(sl.ZQ,{name:"alert-triangle",size:16}),a.createElement("span",null,"Bill syncing is paused, so automatically synced accounts will no longer update. You can still manage manually added merchants."),a.createElement(_Fe,null,a.createElement(DFe,{onClick:()=>l(!0)})))))},TFe=(0,u.default)(fu.g).attrs({type:"warning"}).withConfig({displayName:"BillSyncPausedBanner__WarningBanner",componentId:"sc-1gbcach-0"})(["width:100%;padding:"," ",";"],vt.YK.small,vt.YK.default),_Fe=u.default.div.withConfig({displayName:"BillSyncPausedBanner__IconContainer",componentId:"sc-1gbcach-1"})(["cursor:pointer;margin-left:auto;"]),DFe=(0,u.default)(sl.ZQ).attrs({name:"x",size:16}
1).withConfig({displayName:"BillSyncPausedBanner__CloseIcon",componentId:"sc-1gbcach-2"})(["padding:",";&:hover{color:",";}"],vt.YK.xxsmall,vt.Ee.color.content.warningHover),RFe=Ee.ygN;var MFe=n(43371);const LFe=(e,t,n)=>{if(!e)return[];const a=(n||{}).renderAccountLogo,l=e.categoryGroups,r=void 0===l?[]:l,i=e.accounts,s=void 0===i?[]:i,c=(0,LD.A)((0,nj.A)("",["type","display"]),s),d=Object.entries(MFe.se).map((e=>{let t=(0,o.A)(e,2);return{id:t[0],name:t[1]}}));return[{id:"recurringTypes",name:"Type",hideSelectAll:!0,options:[{id:Ee.kjN.INCOME,name:"Income",isSelected:(0,tj.co)(null===t||void 0===t?void 0:t.recurringTypes)(Ee.kjN.INCOME)},{id:Ee.kjN.EXPENSE,name:"Expense",isSelected:(0,tj.co)(null===t||void 0===t?void 0:t.recurringTypes)(Ee.kjN.EXPENSE)},{id:Ee.kjN.CREDIT_CARD,name:"Credit card",isSelected:(0,tj.co)(null===t||void 0===t?void 0:t.recurringTypes)(Ee.kjN.CREDIT_CARD)}]},{id:"accounts",name:"Payment account",options:Object.entries(c).map((e=>{let n=(0,o.A)(e,2),l=n[0];return{id:l,name:l,options:n[1].map((e=>({id:e.id,name:(0,nj.A)("",["displayName"],e),isSelected:(0,tj.co)(null===t||void 0===t?void 0:t.accounts)(e.id),icon:null===a||void 0===a?void 0:a(e)})))}}))},hj(r,t),{id:"frequencies",name:"Frequency",hideSelectAll:!0,options:d.map((e=>({id:e.id,name:e.name,isSelected:(0,tj.co)(null===t||void 0===t?void 0:t.frequencies)(e.id)}
1)))}]},OFe=Ee.ARy,PFe=e=>e.recurring,BFe=(0,sG.Mz)(PFe,(e=>e.filters)),zFe=(0,sG.Mz)(PFe,(e=>e.collapsedGroupsMap)),FFe=e=>{let t=e.toggleOpen;const n=(0,pG.w)(),l=(e=>{const t=e.page,n=e.onApplyFilters,a=e.filters,l=e.renderAccountLogo,r=(0,et.I)(OFe,{}),o=r.data,i=r.isLoadingInitialData,s=Ij({data:o,filters:a,renderAccountLogo:l,getFilterSectionsFromQuery:LFe,onApplyFilters:(e,a)=>{n(e),a&&gj(t,a)},adaptSelectedOptionsToFilters:hQ});return{sections:s.sections,isLoading:i,onChangeSections:s.onChangeSections,resetUnappliedChanges:s.resetUnappliedChanges,handleApply:s.handleApply}})({page:"recurring",filters:(0,d.d4)(BFe),onApplyFilters:e=>{n((0,g.TR)(e)),t()},renderAccountLogo:e=>a.createElement(GFe,{logoUrl:e.logoUrl,icon:e.icon})}),r=l.sections,o=l.isLoading,i=l.onChangeSections,s=l.handleApply;return a.createElement(xH,{"data-external-id":"recurring-filters",isLoading:o,onClickApply:s,onClickCancel:t,sections:r,onChange:i,options:{filtersColumnWidth:150}})},GFe=(0,u.default)(Gl.v).attrs({size:14}).withConfig({displayName:"RecurringFilters__SmallAccountLogo",componentId:"jvx9xk-0"})(["margin-right:",";"],vt.YK.xxsmall);var YFe=n(81853);const UFe=[{value:yr.RR.Type,label:"By status"},{value:yr.RR.Category,label:"By category"},{value:yr.RR.Frequency,label:"By frequency"}],VFe=e=>{var t;let n=e.filters,l=e.onChangeFilters,r=e.onClickAddRecurring;const i=(0,YFe.W)(I.JZ.recurring.all),s=(0,a.useState)(!1),d=(0,o.A)(s,2),u=d[0],m=d[1];return a.createElement("div",{"data-external-id":"recurring-header-controls",className:"flex items-center justify-end gap-xs"},i?a.createElement(fe.hGA,{options:UFe,value:null!==(t=null===n||void 0===n?void 0:n.groupBy)&&void 0!==t?t:yr.RR.Type,size:"sm",align:"end",classNames:{trigger:"w-auto text-sm font-medium"},onValueChange:e=>l((0,U.A)((0,U.A)({},n),{},{groupBy:e}))}):null,a.createElement(fe.k_P.Root,{open:u,onOpenChange:m,size:"2xl"},a.createElement(fe.qN2,{show:(0,c.A)((0,XX.A)(["groupBy"],n))},a.createElement(fe.k_P.Trigger,{render:a.createElement(fe.XZZ,{icon:a.createElement(fe.evG,null),variant:"default"},"Filters")})),a.createElement(fe.k_P.Content,{side:"bottom",align:"end",className:"p-0"},u?a.createElement(FFe,{toggleOpen:()=>m(!1)}):null)),a.createElement(fe.AVK,{orientation:"vertical",color:"tertiary",className:"mx-2xs h-4"}),a.createElement(fe.XZZ,{variant:"primary",icon:a.createElement(fe.z79,null),onClick:r},"Manage recurring"))};var WFe;const jFe=()=>a.createElement("div",{"data-external-id":"header-tabs",className:"ml-xl flex items-stretch gap-lg pr-lg"},a.createElement(HFe,{to:I.JZ.recurring.upcoming.path},"Monthly"),a.createElement(HFe,{to:I.JZ.recurring.all.path},"All recurring")),HFe=(0,$d.s)(MCe)(WFe||(WFe=(0,wc.A)(["flex items-center"])));var KFe=n(77569),qFe=n(31065);const $Fe=e=>{let t=e.name,n=e.transactionCount,l=e.logoUrl,r=e.onClick;return a.createElement(ZFe,{"data-external-id":"merchant-search-list-item",onClick:r},a.createElement(Wl._,{url:l}),a.createElement(JFe,null,a.createElement(xt.v,{weight:"medium"},a.createElement($j.M,null,t)),a.createElement(xt.v,{size:"small"},n," ",nie()("transaction",n))))},ZFe=(0,u.default)(m.g).attrs({alignCenter:!0,justifyStart:!0}).withConfig({displayName:"MerchantSearchListItem__Root",componentId:"sc-3zobav-0"})(["gap:",";padding:",";&:not(:last-child){border-bottom:1px solid ",";}&:last-child{border-bottom-left-radius:",";border-bottom-right-radius:",";}&:hover{background-color:",";cursor:pointer;}"],(e=>e.theme.spacing.default),(e=>e.theme.spacing.xlarge),(e=>e.theme.color.grayBackground),(e=>e.theme.radius.medium),(e=>e.theme.radius.medium),(e=>e.theme.color.grayBackground)),JFe=(0,u.default)(m.g).attrs({column:!0}).withConfig({displayName:"MerchantSearchListItem__MerchantInfo",componentId:"sc-3zobav-1"})(["flex:1;gap:",";align-items:flex-start;"],(e=>e.theme.spacing.xxxsmall)),XFe=u.default.div.withConfig({displayName:"MerchantSearchModalCard__MerchantInputContainer",componentId:"utnnyj-0"})(["padding:",";"],(e=>e.theme.spacing.xlarge)),QFe=(0,u.default)(qFe.d).withConfig({displayName:"MerchantSearchModalCard__StyledEmpty",componentId:"utnnyj-1"})(["margin:"," auto ",";"],(e=>e.theme.spacing.xlarge),(e=>e.theme.spacing.xxxlarge)),eGe=(0,u.default)((e=>{let t=e.className;return a.createElement(Rr.s,{"data-external-id":"merchant-search-list-loading",className:t,height:56},a.createElement("circle",{cx:"30",cy:"28",r:"27"}),a.createElement("rect",{x:"70",y:"6",rx:"5",ry:"5",width:"175",height:"22"}),a.createElement("rect",{x:"70",y:"33",rx:"5",ry:"5",width:"130",height:"18"}))})).withConfig({displayName:"MerchantSearchModalCard__StyledLoadingItem",componentId:"utnnyj-2"})(["padding:",";&:not(:last-child){border-bottom:1px solid ",";}"],(e=>e.theme.spacing.xlarge),(e=>
1e.theme.color.grayBackground)),tGe=(0,KFe.A)(3),nGe=e=>{let t=e.title,n=void 0===t?"Search merchant":t,l=e.initialValues,r=e.next;const i=(0,a.useState)(""),s=(0,o.A)(i,2),c=s[0],d=s[1],u=(0,xy.d)(c,RIe.N),m=(0,et.I)(aGe,{variables:{search:u},skip:!tGe(u)}),p=m.data,g=m.isNetworkRequestInFlight,h=(0,nj.A)([],["merchants"],p);return a.createElement(Rc.L,{"data-external-id":"merchant-search-modal",title:n},a.createElement(XFe,null,a.createElement(Ry.X,{className:"w-full",name:"merchant",placeholder:"Enter 3 characters or more...",value:c,onChange:e=>{const t=e.target;d(t.value)},autoFocus:!0})),a.createElement(Ul.w,null,a.createElement(Ul.d,{when:g},(0,db.A)(0,3).map((e=>a.createElement(eGe,{key:e})))),a.createElement(Ul.d,{when:(0,Gj.A)(h)},a.createElement(sH.j.Provider,{value:{searchWords:u?[u]:[]}},h.map((e=>{let t=e.id,n=e.name,o=e.transactionCount,i=e.logoUrl;return a.createElement($Fe,{key:t,name:n,transactionCount:o,logoUrl:i,onClick:()=>r({merchantId:t,initialValues:l})})})))),a.createElement(Ul.d,{when:!tGe(u)},a.createElement(QFe,{icon:"search",title:"Search for a merchant",subtitle:"Enter a search term above to find merchants with recurring transactions."})),a.createElement(Ul.d,{when:(0,PY.A)(h)&&(0,Gj.A)(c)&&!g},a.createElement(QFe,{icon:"search",title:"Couldn't find any merchants matching \"".concat(c,'"'),subtitle:"Enter a search term above to find merchants with recurring transactions."})),a.createElement(Ul.d,{default:!0},a.createElement(QFe,{icon:"search",title:"Search for a merchant",subtitle:"Enter a search term above to find merchants with recurring transactions."}))))},aGe=Ee.gao,lGe=e=>{let t=e.initialValues,n=e.onComplete;return a.createElement(h7.n,{"data-external-id":"merchant-search-flow",initialProps:{title:"Add recurring",initialValues:t},steps:[nGe,rGe],onComplete:n})},rGe=e=>a.createElement(N7._,Object.assign({"data-external-id":"edit-merchant-modal-from-recurring-v1"},e,{recurrenceSource:"v1"})),oGe=e=>{let t=e.icon,n=e.text,l=e.disabled,r=void 0!==l&&l,o=e.onClick;return a.createElement(fe.XZZ,{"data-external-id":"modal-card-button",variant:"unstyled",type:"button",onClick:r?void 0:o,"aria-disabled":r,className:" group flex w-full flex-col items-stretch justify-normal gap-default rounded-md bg-background-secondary p-xl text-content-primary hover:bg-background-secondary-hover aria-disabled:cursor-not-allowed aria-disabled:text-input-disabled-text aria-disabled:hover:bg-background-secondary "},a.createElement("div",{className:"flex items-center justify-between"},a.createElement("span",{className:"text-[22px] text-content-brand group-aria-disabled:text-input-disabled-text"},t)),a.createElement(xt.v,{weight:"medium"},n))},iGe=e=>{let t=e.searchDisabledTooltip,n=e.onClickSearch,l=e.onClickAddManual,r=e.onClickAddBills,o=e.hasAlreadySyncedWithSpinwheel;return a.createElement(sGe,{"data-external-id":"add-recurring-modal-card",title:"Add recurring",$large:!0},a.createElement(cGe,null,a.createElement(dGe,null,a.createElement(oGe,{icon:a.createElement(sl.ZQ,{name:"refresh"}),text:o?"Manage your synced accounts":"Sync your liability accounts",onClick:r})),a.createElement(dGe,null,a.createElement(oGe,{icon:a.createElement(sl.ZQ,{name:"plus-circle"}),text:"Add a recurring merchant manually",onClick:l})),a.createElement(JY.d,{content:t,maxWidth:194,place:"top"},a.createElement(dGe,null,a.createElement(oGe,{icon:a.createElement(sl.ZQ,{name:"search"}),text:"Find recurring merchants in your accounts",onClick:t?void 0:n,disabled:!!t})))))},sGe=(0,u.default)(Rc.L).withConfig({displayName:"AddRecurringModalCard__ModalCardRoot",componentId:"vn0jwp-0"})(["width:",";margin:auto;"],(e=>e.$large?"".concat(832,"px"):"auto")),cGe=(0,u.default)(m.g).withConfig({displayName:"AddRecurringModalCard__Root",componentId:"vn0jwp-1"})(["gap:",";padding:",";cursor:pointer;"],vt.YK.xlarge,vt.YK.xlarge),dGe=(0,u.default)(m.g).withConfig({displayName:"AddRecurringModalCard__TooltipChildren",componentId:"vn0jwp-2"})(["flex:1;"]);var uGe=n(84498),mGe=n(21795);const pGe=["children"],gGe=e=>{let t=e.children,n=(0,En.A)(e,pGe);return a.createElement(hGe,Object.assign({"data-external-id":"deprecated-tag"},n),t)},hGe=u.default.div.withConfig({displayName:"Tag__Root",componentId:"sc-1f34u2o-0"})(["font-size:",";font-weight:",";color:",";background:",";padding:0 ",";border-radius:500px;"],(e=>e.theme.fontSize.xsmall),(e=>e.theme.fontWeight.medium),(e=>e.theme.color.textLight),(e=>e.theme.color.grayFocus),(e=>e.theme.spacing.xsmall)),vGe=e=>{let t=e.id,n=e.queryParams,r=e.children;return a.createElement(l.N_,{"data-external-id":"merchant-link",to:I.JZ.merchants({id:t,queryParams:n}),className:"text-inherit hover:text-content-link-hover"},r)},fGe=e=>{let t=e.id,n=e.name,l=e.description,r=e.logoUrl,o=e.account,i=e.logoSize,s=void 0===i?40:i,c=e.className,d=e.startDate,u=e.isMerchant;const m=d?{date:d.startOf("month").toISODate()}:{},p=u?vGe:a.Fragment;if(!t)throw new Error("Entity id is required for link");return a.createElement(bGe,{"data-external-id":"recurring-review-info-card",className:c},a.createElement(p,{queryParams:m,id:t},a.createElement(EGe,null,a.createElement(Wl._,{url:r,size:s}),!!o&&a.createElement(yGe,{logoUrl:o.logoUrl,icon:o.icon,size:16}))),a.createElement("div",{className:"flex flex-col"},a.createElement(p,{queryParams:m,id:t},a.createElement(xt.v,{weight:"medium"},n)),l&&a.createElement(xt.v,{color:"textLight"},l)))},EGe=u.default.div.withConfig({displayName:"RecurringReviewInfoCard__ComboAvatar",componentId:"sc-1i3u09m-0"})(["padding:",";position:relative;"],(e=>e.theme.spacing.xxsmall)),yGe=(0,u.default)(Gl.v).withConfig({displayName:"RecurringReviewInfoCard__StyledAccountLogo",componentId:"sc-1i3u09m-1"})(["outline:4px solid ",";position:absolute;right:0;bottom:0;"],(e=>e.theme.color.white)),bGe=(0,u.default)(m.g).attrs({alignCenter:!0}).withConfig({displayName:"RecurringReviewInfoCard__Root",componentId:"sc-1i3u09m-2"})(["gap:",";"],(e=>e.theme.spacing.default)),xGe=e=>{let t=e.creditReportLiabilityAccountId,n=e.limit,a=void 0===n?1:n;var l;const r=(0,et.I)(wGe,{variables:{filters:{creditReportLiabilityAccountId:t},limit:a},skip:!t}),o=r.data,i=r.isLoadingInitialData;return{statements:null!==(l=null===o||void 0===o?void 0:o.creditReportLiabilityStatements)&&void 0!==l?l:[],isLoadingStatements:i}},wGe=(0,Qt.J)("\n  query Common_GetReviewedAccountLastStatements(\n    $filters: LiabilityStatementFilterInput!\n    $limit: Int!\n  ) {\n    creditReportLiabilityStatements(filters: $filters, limit: $limit) {\n      id\n      dueDate\n      billAmount\n    }\n  }\n"),CGe=["data"],AGe=(0,Qt.J)("\n  query Common_GetReviewedMerchantLastTransactions(\n    $merchantId: UUID!\n    $endDate: Date!\n    $isMerchant: Boolean!\n  ) {\n    allTransactions(filters: { merchants: [$merchantId], endDate: $endD
1ate })\n      @include(if: $isMerchant) {\n      totalCount\n      results(limit: 3) {\n        id\n        date\n        amount\n        isRecurring\n        category {\n          id\n          name\n          icon\n        }\n      }\n    }\n  }\n");var IGe,kGe;const SGe=e=>{var t;let n=e.stream;const l=n.merchant,r=n.creditReportLiabilityAccount,o=n.name,i=n.logoUrl,s=(null!==(t=null!==l&&void 0!==l?l:r)&&void 0!==t?t:{}).id,c=(e=>{var t;const n=(0,et.I)(AGe,{fetchPolicy:"cache-first",skip:!e,variables:{endDate:N.c9.local().toISODate(),isMerchant:!0,merchantId:null!==e&&void 0!==e?e:""}}),l=n.data,r=(0,En.A)(n,CGe),o=null===(t=null===l||void 0===l?void 0:l.allTransactions)||void 0===t?void 0:t.totalCount,i=(0,a.useMemo)((()=>{var e,t;return null!==(t=null===(e=null===l||void 0===l?void 0:l.allTransactions)||void 0===e?void 0:e.results)&&void 0!==t?t:[]}),[null===l||void 0===l?void 0:l.allTransactions]);return(0,U.A)((0,U.A)({},r),{},{totalCount:o,lastTransactions:i})})(null===l||void 0===l?void 0:l.id),d=c.lastTransactions,u=c.totalCount,m=c.isLoadingInitialData,g=xGe({creditReportLiabilityAccountId:null===r||void 0===r?void 0:r.id}),h=g.statements,v=g.isLoadingStatements,f=m||v,E=(0,a.useMemo)((()=>f?a.createElement(OGe,null,a.createElement(p.i,null)):(0,LV.A)(d)&&(0,LV.A)(h)?a.createElement(MGe,null,a.createElement(LGe,null,"There are no transactions yet for this ",l?"merchant":"account",".")):r?a.createElement(a.Fragment,null,a.createElement(_Ge,null,_t._E.LIABILITY_RECENT_BALANCES_HEADER),h.map((e=>{let t=e.id,n=e.dueDate,l=e.billAmount;return a.createElement(DGe,{key:t},a.createElement(xt.v,{size:"small"},(0,Ba.AO)(n)),a.createElement(PGe,{$isIncome:!!l&&l>0,size:"small"},l?(0,jQ.s_)(l):"-"))}))):a.createElement(a.Fragment,null,a.createElement(_Ge,null,"Recent transactions"),d.map((e=>{let t=e.id,n=e.date,l=e.amount,r=e.category,o=e.isRecurring;return a.createElement(DGe,{key:t},a.createElement(zGe,{to:I.JZ.transactions.details({id:t})},a.createElement(RGe,null,null===r||void 0===r?void 0:r.icon),a.createElement(xt.v,{size:"small"},(0,Ba.AO)(n))),!!o&&a.createElement(JY.d,{content:"Recurring"},a.createElement("span",null,a.createElement(BGe,null))),a.createElement(PGe,{$isIncome:l>0,size:"small"},(0,jQ.s_)(l)))})))),[f,d,h,null===n||void 0===n?void 0:n.id]),y=l?"MERCHANT":"ACCOUNT";return a.createElement(NGe,{"data-external-id":"review-summary-card"},a.createElement(TGe,null,a.createElement(fGe,{id:s,name:o,logoUrl:i,logoSize:48,description:l?"".concat(u," ").concat(nie()("transaction",u)):"Synced via credit report"}),a.createElement("div",{className:"flex items-center justify-end"},a.createElement(JY.d,{content:n.isApproximate?_t._E.AMOUNT_ESTIMATE_TOOLTIP:void 0},a.createElement(gGe,null,y)))),E)},NGe=u.default.div.withConfig({displayName:"ReviewSummaryCard__Root",componentId:"sc-17hk9su-0"})(["border:1px solid ",";border-radius:",";background:",";"],(e=>e.theme.color.grayFocus),(e=>e.theme.radius.medium),(e=>e.theme.color.white)),TGe=(0,u.default)(m.g).attrs({justifyBetween:!0,alignCenter:!0}).withConfig({displayName:"ReviewSummaryCard__Header",componentId:"sc-17hk9su-1"})(["padding:",";"],(e=>e.theme.spacing.default)),_Ge=(0,$d.s)(H3.X)(IGe||(IGe=(0,wc.A)(["px-default py-2xs text-xs font-bold tracking-widest uppercase"]))),DGe=(0,u.default)(m.g).attrs({alignCenter:!0,justifyBetween:!0}).withConfig({displayName:"ReviewSummaryCard__TransactionRow",componentId:"sc-17hk9su-2"})(["padding:",";border-bottom:1px solid ",";&:last-child{border-bottom:none;}"],(e=>e.theme.spacing.default),vt.Ee.color.divider.primary),RGe=u.default.div.withConfig({displayName:"ReviewSummaryCard__CategoryIcon",componentId:"sc-17hk9su-3"})(["font-size:14px;margin-right:",";transform:translateY(-1px);"],(e=>e.theme.spacing.small)),MGe=(0,u.default)(m.g).attrs({center:!0}).withConfig({displayName:"ReviewSummaryCard__EmptyTransactionContainer",componentId:"sc-17hk9su-4"})(["padding:"," ",";border-top:1px solid ",";"],(e=>e.theme.spacing.xlarge),(e=>e.theme.spacing.xsmall),(e=>e.theme.color.grayBackground)),LGe=(0,u.default)(xt.v).attrs({color:"grayDark"}).withConfig({displayName:"ReviewSummaryCard__EmptyTransactionText",componentId:"sc-17hk9su-5"})(["width:60%;display:block;text-align:center;"]),OGe=(0,u.default)(m.g).attrs({center:!0}).withConfig({displayName:"ReviewSummaryCard__SpinnerContainer",componentId:"sc-17hk9su-6"})(["margin:"," 0;"],(e=>e.theme.spacing.xlarge)),PGe=(0,u.default)(xt.v).attrs((0,U.A)({weight:"medium"},fl.zs)).withConfig({displayName:"ReviewSummaryCard__Amount",componentId:"sc-17hk9su-7"})(["color:",";margin-right:",";cursor:default;"],(e=>{let t=e.$isIncome,n=e.theme;return t?n.color.green:n.color.text}),(e=>e.theme.spacing.default)),BGe=(0,u.default)(sl.ZQ).attrs({name:"calendar",size:12}).withConfig({displayName:"ReviewSummaryCard__RecurringIcon",componentId:"sc-17hk9su-8"})(["margin:0 ",";display:block;cursor:default;color:",";"],(e=>e.theme.spacing.default),(e=>e.theme.color.textLight)),zGe=(0,$d.s)(l.N_)(kGe||(kGe=(0,wc.A)(["flex flex-1 text-inherit hover:text-content-link-hover"]))),FGe=e=>{var t,n,l,r,s,c,d,u,m;let p=e.streamsToReview,g=e.close;const h=(0,i.n)(UGe,{refetchQueries:[lce,Yr.Op]}),v=(0,o.A)(h,1)[0],f=(0,a.useMemo)((()=>(0,yr.Ft)()),[]),E=(0,a.useState)({}),y=(0,o.A)(E,2),b=y[0],x=y[1],w=(0,a.useMemo)((()=>p.filter((e=>{let t=e.stream;return!b[t.id]}))),[b,p]),C=null===(t=w[0])||void 0===t?void 0:t.stream,A=(0,kJ.X)({queryFilters:MFe.i4}
1),I=(0,o.A)(A,3),k=I[0],S=I[1],T=I[2],_=T.refetch,D=T.isNetworkRequestInFlight;(0,a.useEffect)((()=>{0===w.length&&g()}),[g,w.length]);const R=(0,a.useCallback)((()=>{C&&(x((e=>(0,U.A)((0,U.A)({},e),{},{[C.id]:!0}))),(0,Ge.u4)(Ye.ER.ItemSkipped,{id:C.id}))}),[C]);if(!C)return null;const M={type:(0,yr.f7)(null!==(n=C.amount)&&void 0!==n?n:0),amount:C.amount,frequency:C.frequency,accountId:null===(l=C.creditReportLiabilityAccount)||void 0===l||null===(r=l.account)||void 0===r?void 0:r.id,baseDate:C.baseDate,dayOfTheMonth:null!==(s=null===(c=C.dayOfTheMonth)||void 0===c?void 0:c.toString())&&void 0!==s?s:null!==C&&void 0!==C&&C.creditReportLiabilityAccount?yr.US:void 0};return a.createElement(Rc.L,{"data-external-id":"review-stream-modal-card",title:"Is this ".concat(null!==C&&void 0!==C&&C.merchant?"merchant":"account"," recurring?"),hideBottomBorder:!0,description:w.length-1>0?a.createElement("div",null,"There are ",w.length-1," more recurring items to review."):null},a.createElement(GGe,null,a.createElement(Eu.lV,{initialValues:M,enableReinitialize:!0,mutation:v,transformValuesBeforeSubmit:e=>(0,XX.A)(["type"],(0,U.A)((0,U.A)({},e),{},{amount:e.amount?(0,yr.Yi)(e.amount,e.type):void 0,streamId:C.id,reviewStatus:Ee._1Q.APPROVED})),onSubmitSuccess:async e=>{_()}},a.createElement(qY.S,null,a.createElement(SGe,{stream:C}),a.createElement("div",{className:"flex flex-col gap-default"},C.merchant?a.createElement(a.Fragment,null,a.createElement(tC.zB.Currency,{name:"amount",autoComplete:"off",required:!0,className:fl.zs.className}),a.createElement(tC.zB.Select,{name:"type",label:"Recurring type",required:!0,options:yr.W0}),a.createElement(tC.zB.Select,{name:"frequency",label:"Recurring frequency",required:!0,options:f})):null,C.creditReportLiabilityAccount&&!D?a.createElement(a.Fragment,null,a.createElement(uGe.o,{key:C.id,label:"Link to Monarch Account",accountName:"accountId",options:S,isLoading:k,onAccountCreated:_,hideIgnoreOption:!0}),a.createElement("div",null,a.createElement(Ey._J,{htmlFor:"dayOfTheMonth"},"Payment Due Date"),a.createElement(mGe.b,{name:"dayOfTheMonth",lastStatementDueDateDay:N.c9.fromISO(null!==(d=null===(u=C.creditReportLiabilityAccount)||void 0===u||null===(m=u.lastStatement)||void 0===m?void 0:m.dueDate)&&void 0!==d?d:"").day}))):null)),a.createElement(Cq.R,null,a.createElement(wt.Xb,{className:"mr-auto",onClick:R},"Skip"),a.createElement(wt.Xb,{onClick:()=>{v({variables:{input:{streamId:C.id,reviewStatus:Ee._1Q.IGNORED,amount:void 0,frequency:void 0,accountId:void 0,baseDate:void 0,isActive:void 0,dayOfTheMonth:void 0}}})}},"Not recurring"),a.createElement(YGe,{disableWhenValuesUnchanged:!1},"Save as recurring")))))},GGe=(0,u.default)(m.g).attrs({column:!0}).withConfig({displayName:"ReviewStreamModalCard__Root",componentId:"sc-161c1qy-0"})(["gap:",";"],vt.YK.xlarge),YGe=(0,u.default)(CJ.I).withConfig({displayName:"ReviewStreamModalCard__SubmitButton",componentId:"sc-161c1qy-1"})(["font-size:",";"],vt.J.small),UGe=Ee.zYI;var VGe=n(54021);const WGe=e=>{let t=e.flow;const n=t.AddManualRecurringModal,l=t.AddRecurringModal,r=t.ConnectionModal,o=t.ReviewStreamModal;return a.createElement(a.Fragment,null,a.createElement(l,{full:!0},a.createElement(iGe,{searchDisabledTooltip:t.searchDisabledTooltip,onClickSearch:t.startRecurringSearch,onClickAddManual:t.onClickAddManual,onClickAddBills:t.onClickAddBills,hasAlreadySyncedWithSpinwheel:t.hasAlreadySyncedWithSpinwheel})),a.createElement(o,{onClose:()=>t.setReviewOpen(void 0)},a.createElement(FGe,{streamsToReview:t.pendingStreams,close:t.closeReviewStreamModal})),a.createElement(n,null,a.createElement(lGe,{onComplete:t.refetchAll,initialValues:{isRecurring:!0}})),a.createElement(r,{onClose:t.handleCloseConnectionModal},a.createElement(VGe.C,{isLoading:t.isSyncingCreditReport,hasFraudError:t.connectionStatus.hasFraudError,hasManualReviewError:t.connectionStatus.hasManualReviewError,hasGenericError:t.connectionStatus.hasGenericError,onComplete:t.handleCloseConnectionModal})))};var jGe=n(86397),HGe=n(25863),KGe=n(77253),qGe=n(98455),$Ge=n(89332);const ZGe=e=>{let t=e.columnType;if(e.isMerchant)return a.createElement(xt.v,{"data-external-id":"not-selected-help"},"-");const n="To select a default payment ".concat(t," for this bill, click the three dots on the right and edit account");return a.createElement(JY.d,{"data-external-id":"not-selected-help",portal:!0,content:n},a.createElement(JGe,null,"Not selected"))},JGe=(0,u.default)(xt.v).withConfig({displayName:"NotSelectedHelp__NotSelectedText",componentId:"sc-1xkm18l-0"})(["color:",";"],(e=>e.theme.color.textLight)),XGe=e=>{let t=e.account;return a.createElement(Vl.W,{"data-external-id":"recurring-account",to:I.JZ.accounts.accountDetails({id:t.id}),icon:a.createElement(Gl.v,{logoUrl:null===t||void 0===t?void 0:t.logoUrl,icon:null===t||void 0===t?void 0:t.icon,size:16}),className:"min-w-30 gap-xs overflow-hidden",tone:"neutral-primary",weight:"inherit",truncate:!0},null===t||void 0===t?void 0:t.displayName)},QGe=e=>{let t=e.amount,n=e.isPast,l=e.isApproximate;return a.createElement("div",{"data-external-id":"recurring-amount-cell",className:"flex min-w-50 cursor-default items-center justify-end"},!!n&&a.createElement("div",{className:"mr-default flex size-lg items-center justify-center rounded-round bg-(--green-4) text-content-success"},a.createElement(fe.GdR,{size:"xs"})),a.createElement(fe.Yvj,{content:l?_t._E.AMOUNT_ESTIMATE_TOOLTIP:void 0},a.createElement(fe.c8D,Object.assign({size:"base",weight:"medium"},fl.zs,{className:(0,q.cn)(t>0?"text-(--green-9)":"text-(--gray-12)",fl.zs.className)}),l?"\u2248":"",(0,jQ.s_)(t))))},eYe=e=>{let t=e.category,n=e.startDate;return t?a.createElement(Vl.W,{"data-external-id":"recurring-category",to:I.JZ.categories({id:t.id,queryParams:{date:n.toISODate()}}),stealthy:!0,truncate:!0,className:"min-w-30",title:"".concat(null===t||void 0===t?void 0:t.icon," ").concat(null===t||void 0===t?void 0:t.name)},a.createElement(tYe,null,null===t||void 0===t?void 0:t.icon),a.createElement(nYe,null,null===t||void 0===t?void 0:t.name)):a.createElement(nYe,{"data-external-id":"recurring-category"},"No recurring transactions")},tYe=u.default.span.withConfig({displayName:"RecurringCategory__Icon",componentId:"sc-1scl65y-0"})(["flex-shrink:0;margin-right:",";"],(e=>e.theme.spacing.small)),nYe=u.default.span.withConfig({displayName:"RecurringCategory__Name",componentId:"sc-1scl65y-1"})(["flex-grow:1;"]);var aYe=n(76367);const lYe=()=>{const e=(0,i.n)(Yr.ME),t=(0,o.A)(e,1)[0],n=(0,i.n)(Yr.Cd),l=(0,o.A)(n,2),r=l[0],s=l[1].loading,c=(0,a.useCallback)((async e=>{let t=e.creditReportLiabilityStatementId,n=e.isPaid,a=e.onSuccess,l=e.onError,o=e.refetchQueries;var i,s;const c=await r({variables:{creditReportLiabilityStatementId:t,isPaid:n},refetchQueries:o});return(null===(s=null===(i=c.data)||void 0===i?void 0:i.updateBillPaid)||void 0===s?void 0:s.errors)?null===l||void 0===l||l():null===a||void 0===a||a(),c}),[r]),d=(0,a.useCallback)((async e=>{let n=e.creditReportLiabilityStatementId,a=e.userBillAmount,l=e.revertToOriginal,r=e.onSuccess,o=e.onError,i=e.refetchQueries;var s,c;const d=await t({variables:{creditReportLiabilityStatementId:n,userBillAmount:a,revertToOriginal:l},refetchQueries:i});return(null===(c=null===(s=d.data)||void 0===s?void 0:s.updateBillAmount)||void 0===c?void 0:c.errors)?null===o||void 0===o||o():null===r||void 0===r||r(),d}),[t]),u=(0,a.useCallback)((async e=>{let t=e.creditReportLiabilityStatementId,n=e.userBillAmount,a=e.onSuccess,l=e.onError,r=e.refetchQueries;return d({creditReportLiabilityStatementId:t,userBillAmount:n,onSuccess:a,onError:l,refetchQueries:r})}),[d]),m=(0,a.useCallback)((async e=>{let t=e.creditReportLiabilityStatementId,n=e.onSuccess,a=e.onError,l=e.refetchQueries;return d({creditReportLiabilityStatementId:t,revertToOriginal:!0,onSuccess:n,onError:a,refetchQueries:l})}),[d]);return{updateLiabilityUserBillAmount:u,revertLiabilityBillAmountToOriginal:m,updateLiabilityStatementPaymentStatus:c,isLoadingUpdatePaymentStatus:s}};var rYe=n(13746);const oYe=[...aYe.Y$,"Web_GetAllRecurringTransactionItems"],iYe=e=>{let t=e.merchantId,n=e.creditReportLiabilityStatementId,r=e.accountId,i=e.name,s=e.className,c=e.startDate,d=e.isPaid,u=e.setIsMenuOpen,m=e.refetch,p=e.setAmountValue,g=e.streamId,h=e.setIsEditStatementVisible,v=e.isAmountDifferentThanOriginal;const f=(0,C.RU)(),E=(0,a.useState)(!1),y=(0,o.A)(E,2),b=y[0],x=y[1],w=(0,a.useState)(!1),A=(0,o.A)(w,2),k=A[0],S=A[1];(0,a.useEffect)((()=>{null===u||void 0===u||u(k||b)}),[k,b,u]);const N=(0,rYe.B)(),T=(0,o.A)(N,1)[0],_=lYe(),D=_.revertLiabilityBillAmountToOriginal,R=_.updateLiabilityStatementPaymentStatus,M=c?{date:c.startOf("month").toISODate()}:{};return a.createElement(a.Fragment,null,b&&a.createElement(um.b,{onClose:()=>{x(!1)}},(e=>{let n=e.close;return a.createElement(a.Fragment,null,t&&a.createElement(N7._,{merchantId:t,recurrenceSource:"v1",afterUpdate:m,afterDelete:m}),r&&a.createElement(XY.r,{accountId:r,onDone:()=>{m(),n()},onClose:n}))}
1)),a.createElement(Qi.Az,{disableClickOutside:b,isOpen:k,onOpenChange:S,overlay:a.createElement(Ji.SP,null,a.createElement(Ul.w,null,a.createElement(Ul.d,{when:!!t},a.createElement(vGe,{id:t,queryParams:M},a.createElement(Ji.xm,{icon:"eye"},"View merchant")),a.createElement(Ji.xm,{onClick:()=>{x(!0)},icon:"edit"},"Edit merchant details")),a.createElement(Ul.d,{when:!!r},a.createElement(l.N_,{to:I.JZ.accounts.accountDetails({id:r}),className:"text-inherit"},a.createElement(Ji.xm,{icon:"eye"},"View account")),a.createElement(Ji.xm,{onClick:()=>{x(!0)},icon:"edit"},"Edit account details"),n?a.createElement(a.Fragment,null,h?a.createElement(Ji.xm,{onClick:()=>{h(!0)},icon:"dollar-sign"},"Edit statement amount"):null,v&&a.createElement(Ji.xm,{onClick:()=>{(async()=>{var e,t,a;if(!n)return;const l=null===(e=(await D({creditReportLiabilityStatementId:n,onSuccess:()=>{(0,C.oR)({title:"Success",description:"Amount reverted to original."}),m()},onError:()=>f()})).data)||void 0===e||null===(t=e.updateBillAmount)||void 0===t||null===(a=t.creditReportLiabilityStatement)||void 0===a?void 0:a.billAmount;null===p||void 0===p||p(Number(l))})()},icon:"undo"},"Revert to original amount"),a.createElement(Ji.xm,{onClick:()=>{(async()=>{n&&await R({creditReportLiabilityStatementId:n,isPaid:!d,onSuccess:()=>{(0,C.oR)({title:d?"Marked as unpaid":"Marked as paid",description:"Statement payment status updated."}),m()},onError:()=>f()})})()},icon:d?"x":"check"},d?"Mark as unpaid":"Mark as paid")):null)),a.createElement(Ji.xm,{type:"danger",onClick:()=>{(async()=>{try{T({refetchQueries:oYe,variables:{streamId:g}}),(0,C.oR)({title:"Marked ".concat(i," as not recurring"),description:"It will no longer show up on your recurring calendar and in the all recurring list."})}catch(e){f()}})()},icon:"x"},"Mark ",t?"merchant":"account"," as not recurring")),placement:"bottom-end"},(e=>{let t=e.toggleOpen,n=e.isOpen;return a.createElement(sYe,{icon:"more-horizontal",onClick:t,active:n,className:s})})))},sYe=(0,u.default)(B.L).withConfig({displayName:"RecurringMenu__StyledIconButton",componentId:"f9dsg2-0"})(["min-height:35px;min-width:35px;"]),cYe={name:["stream","name"],date:["nextForecastedTransaction","date"],account:["account","displayName"],category:["category","name"],amount:["nextForecastedTransaction","amount"]},dYe=e=>{const t=e.startDate,n=e.items,l=e.title,r=e.refetch,i=e.isLoading,s=void 0!==i&&i,c=e.isCollapsed,d=e.toggleCollapsed,u=(0,a.useState)(null),m=(0,o.A)(u,2),p=m[0],g=m[1],h=(0,a.useMemo)((()=>{if(!p)return null!==n&&void 0!==n?n:[];const e=(null===p||void 0===p?void 0:p.direction)===tr.ASC?U_e.A:Go.A,t=(0,nj.A)("",cYe[p.property]);return(0,Fo.A)([e((0,HGe.A)((0,KGe.A)(PPe.A,Math.abs,qGe.A),t))])(null!==n&&void 0!==n?n:[])}),[n,p]),v=(0,a.useCallback)((0,$Ge.A)(((e,t)=>{(null===p||void 0===p?void 0:p.property)!==e||(null===p||void 0===p?void 0:p.direction)!==tr.DESC?g({property:e,direction:(null===p||void 0===p?void 0:p.property)===e&&(null===p||void 0===p?void 0:p.direction)===tr.ASC?tr.DESC:tr.ASC}):g(null)})),[g,p]);return s?a.createElement(Mr,{"data-external-id":"recurring-all-list"}):0===(null===h||void 0===h?void 0:h.length)?null:a.createElement(nr,{"data-external-id":"recurring-all-list"},a.createElement(ar,null,a.createElement(sr,{$marginRight:!0},a.createElement("div",{className:"flex items-center gap-xs"},a.createElement($H.V,{expanded:!c,onClick:d}),a.createElement(dr,null,l))),a.createElement(sr,null,a.createElement(ur,{onClick:v("date")},"Next Due Date ",a.createElement(lr,{property:"date",sortedBy:p}
1))),a.createElement(sr,null,a.createElement(ur,{onClick:v("account")},"Payment Account ",a.createElement(lr,{property:"account",sortedBy:p}))),a.createElement(sr,null,a.createElement(ur,{onClick:v("category")},"Category ",a.createElement(lr,{property:"category",sortedBy:p}))),a.createElement(sr,{$align:"right"},a.createElement(ur,{$marginRight:52,onClick:v("amount")},"Amount ",a.createElement(lr,{property:"amount",sortedBy:p})))),a.createElement(rr,{open:!c},a.createElement("div",{className:"flex flex-col"},h.map((e=>{var n,l,o,i,s,c,d,u,m,p,g;let h=e.stream,v=e.account,f=e.category,E=e.nextForecastedTransaction;return a.createElement(cr,{key:h.id},a.createElement(sr,null,a.createElement(Hl,{id:null!==(n=null!==(l=null===(o=h.merchant)||void 0===o?void 0:o.id)&&void 0!==l?l:null===(i=h.creditReportLiabilityAccount)||void 0===i||null===(s=i.account)||void 0===s?void 0:s.id)&&void 0!==n?n:"",name:null!==(c=null===h||void 0===h?void 0:h.name)&&void 0!==c?c:"",frequency:(0,yr.Bp)(h.frequency),logoUrl:h.logoUrl,startDate:t,isMerchant:!!h.merchant})),a.createElement(sr,null,a.createElement(mr,null,a.createElement(Er,null,null===(d=(0,yr.fj)(E.date,!0))||void 0===d?void 0:d.nextPaymentDateFormatted),a.createElement(xt.v,{color:"textLight"},"(",null===(u=(0,yr.fj)(E.date,!0))||void 0===u?void 0:u.daysUntilNextPaymentLabel,")"))),a.createElement(sr,null,v?a.createElement(XGe,{account:v}):a.createElement(ZGe,{columnType:"account",isMerchant:!!h.merchant})),a.createElement(sr,null,f?a.createElement(eYe,{category:f,startDate:t}):a.createElement(ZGe,{columnType:"category",isMerchant:!!h.merchant})),a.createElement(sr,null,a.createElement("div",{className:"flex items-center justify-end gap-default"},a.createElement(QGe,{amount:E.amount,isPast:!1,isApproximate:h.isApproximate}),a.createElement(iYe,{merchantId:null===h||void 0===h||null===(m=h.merchant)||void 0===m?void 0:m.id,name:h.name,startDate:t,refetch:r,streamId:h.id,accountId:null===h||void 0===h||null===(p=h.creditReportLiabilityAccount)||void 0===p||null===(g=p.account)||void 0===g?void 0:g.id}))))})))))},uYe=(e,t)=>{var n;t!==e&&(n={tab:"monthly",view:t},(0,Ge.u4)(Ye.ER.ViewViewed,n))},mYe=e=>{(0,p4.n)(Ye.ER.ViewViewed,e)},pYe=e=>{var t;let n=e.filters,l=e.startDate;const r=(0,d.wA)();mYe({tab:"all"});const i=(0,d.d4)(zFe),s=(0,a.useCallback)((e=>{r((0,g.wx)(e))}),[r]),c=(0,et.I)(Yr.dB,{variables:{filters:(0,Ur.fj)(n),includeLiabilities:!0,includePending:void 0}}),u=c.data,m=c.isLoadingInitialData,p=c.refetch,h=(0,nj.A)([],["recurringTransactionStreams"],u),v=null!==(t=n.groupBy)&&void 0!==t?t:yr.RR.Type,f=(0,a.useMemo)((()=>{const e=(0,yr.UA)(h).active,t=v===yr.RR.Type?h:e,n=(0,LD.A)((e=>{var t,n,a;return v===yr.RR.Category?null!==e&&void 0!==e&&e.category?"".concat(null===e||void 0===e||null===(t=e.category)||void 0===t?void 0:t.icon," ").concat(null===e||void 0===e||null===(n=e.category)||void 0===n?void 0:n.name):"No category":v===yr.RR.Frequency?(0,yr.Bp)(null===(a=e.stream)||void 0===a?void 0:a.frequency):e.stream.isActive?"Active":"Canceled"}),t),a=(0,VW.A)((0,jGe.A)(0,""),(0,zne.A)(n));return(0,Fo.A)([(0,U_e.A)((e=>{let t=(0,o.A)(e,2),n=t[0];t[1];return n}))])(a)}),[v,h]);return a.createElement(a.Fragment,null,a.createElement(rG.X,null,"All"),a.createElement("div",{className:"mb-gutter flex w-full flex-col px-gutter"},m&&a.createElement(Mr,null),f.map(((e,t)=>{let n=(0,o.A)(e,2),r=n[0],c=n[1];return a.createElement(dYe,{key:t,title:r,startDate:l,isLoading:m,items:c,refetch:p,isCollapsed:null===i||void 0===i?void 0:i[r],toggleCollapsed:()=>s(r)})}))))};var gYe=n(20636);const hYe=e=>{const t=null!==e&&void 0!==e?e:{},n=t.count,a=t.pendingAmountCount;return{isAllPending:!!n&&n===a&&n>0,somePending:!!a&&a>0}};var vYe,fYe,EYe,yYe;const bYe=$d.s.div(vYe||(vYe=(0,wc.A)(["flex flex-col lg:flex-row"]))),xYe=e=>{let t=e.title,n=e.tooltipText;return a.createElement("div",{"data-external-id":"aggregated-summary-item-title",className:"flex"},a.createElement(fe.cIj,{size:"3xs",content:n,iconSize:"xs",label:a.createElement(fe.c8D,null,t)}))},wYe=e=>{let t=e.title,n=e.tooltipText,l=e.completedText,r=void 0===l?"paid":l,o=e.aggregatedSummary,i=e.isLoading,s=e.isEmpty,c=e.emptyText,d=e.onEmptyAction;const u=null!==o&&void 0!==o?o:{},m=u.total,p=u.completed,g=u.remaining,h=hYe(o).isAllPending;return i?a.createElement(CYe,{"data-external-id":"aggregate-summary-item"}):s?a.createElement(AYe,{"data-external-id":"aggregate-summary-item"},a.createElement("div",null,a.createElement(xYe,{title:t,tooltipText:n}),a.createElement(kYe,{onClick:d}
1,c))):a.createElement(AYe,{"data-external-id":"aggregate-summary-item"},a.createElement("div",null,a.createElement("div",{className:"flex items-center justify-between gap-xs"},a.createElement(xYe,{title:t,tooltipText:n}),a.createElement(fe.c8D,{color:"secondary",size:"sm"},(e=>{const t=null!==e&&void 0!==e?e:{},n=t.count,a=t.pendingAmountCount,l=t.total;return a&&a>0?"".concat(a," / ").concat(n," ").concat((0,De.td)("statement",null!==n&&void 0!==n?n:0)," pending"):"".concat((0,gYe.ne)(Math.abs(null!==l&&void 0!==l?l:0))," total")})(o))),a.createElement(fe.cqk,{value:Math.abs(null!==p&&void 0!==p?p:0),max:Math.abs(null!==m&&void 0!==m?m:0)||1,color:"progress-info",className:"mt-xs"})),a.createElement("div",{className:"flex justify-between"},a.createElement(fe.c8D,{weight:"medium",size:"sm"},(0,rl.vv)(Math.abs(null!==p&&void 0!==p?p:0))," ",r),a.createElement(fe.c8D,{weight:"medium",size:"sm"},h?"Remaining pending":a.createElement(a.Fragment,null,(0,rl.vv)(Math.abs(null!==g&&void 0!==g?g:0))," remaining"))))},CYe=()=>a.createElement(AYe,{"data-external-id":"aggregate-summary-item-loading"},a.createElement("div",{className:"flex justify-between"},a.createElement(IYe,null,a.createElement("rect",{x:"0%",y:"5",rx:"5",ry:"5",width:"80",height:"15"}),a.createElement("rect",{x:"70%",y:"5",rx:"5",ry:"5",width:"80",height:"15"}))),a.createElement(IYe,null,a.createElement("rect",{x:"0",y:"10",rx:"5",ry:"5",width:"100%",height:"10"})),a.createElement("div",{className:"flex justify-between"},a.createElement(IYe,null,a.createElement("rect",{x:"0",y:"0",rx:"5",ry:"5",width:"80",height:"15"}),a.createElement("rect",{x:"70%",y:"0",rx:"5",ry:"5",width:"80",height:"15"})))),AYe=$d.s.div(fYe||(fYe=(0,wc.A)(["\n  flex flex-1 flex-col justify-start gap-sm border-t border-t-divider-primary px-lg\n  py-xl\n  first:border-t-0\n  lg:border-t-0 lg:border-l lg:border-l-divider-primary\n  lg:first:border-l-0\n"]))),IYe=(0,$d.s)(Rr.s)(EYe||(EYe=(0,wc.A)(["h-5"]))),kYe=(0,$d.s)(fe.XZZ).attrs({variant:"text",colorScheme:"link"})(yYe||(yYe=(0,wc.A)(["px-0"])));var SYe=n(72116);const NYe=e=>{let t=e.startDate,n=e.setStartDate,l=e.recurringView,r=e.setRecurringView,i=e.aggregatedSummary,s=e.isLoadingSummary,c=e.openAddManualRecurringModal,d=e.onClickAddBills;const u=ace(),m=u.hasExpenses,p=u.hasIncome,g=(0,SYe.P)().connectionStatus,h=(e,a)=>{e.hasSame(t,"month")||(0,Ge.u4)(Ye.ER.MonthChanged,{tab:"monthly",view:l,direction:a,monthOffset:(0,yr.Pq)(e)}),n(e.toISODate())},v=t.toFormat("LLLL yyyy");return a.createElement(fe.xz6,{"data-external-id":"recurring-actions",className:"mb-default"},a.createElement(fe.xz6.Header,null,a.createElement(fe.xz6.Title,{className:"m-0",render:a.createElement("h1",null)},v),a.createElement(fe.xz6.Action,{className:"gap-xs"},a.createElement("div",{className:"flex items-center gap-2xs"},a.createElement(fe.SO$,{"aria-label":"Previous month",onClick:()=>h(t.minus({months:1}),"previous")},a.createElement(fe.qzE,null)),a.createElement(fe.SO$,{"aria-label":"Next month",onClick:()=>h(t.plus({months:1}),"next")},a.createElement(fe.Fug,null))),a.createElement(fe.XZZ,{onClick:()=>h(N.c9.local().startOf("month"),"today")},"Today"),a.createElement(fe.AVK,{orientation:"vertical",color:"secondary",className:"h-default"}),a.createElement(fe.Mdh,{attached:!0,"aria-label":"Recurring view",value:[l],onValueChange:e=>{let t=(0,o.A)(e,1)[0];if(t){const e=t;uYe(l,e),r(e)}}},a.createElement(fe.H7j,{value:VUe.List,icon:a.createElement(fe.RN,null)},"List"),a.createElement(fe.H7j,{value:VUe.Calendar,icon:a.createElement(fe.cKU,null)},"Calendar")))),a.createElement(bYe,null,a.createElement(wYe,{title:"Income",aggregatedSummary:null===i||void 0===i?void 0:i.income,completedText:"received",isLoading:s,isEmpty:!p,onEmptyAction:c,emptyText:_t._E.SUMMARY.EMPTY_INCOME,tooltipText:_t._E.NO_TRANSFER_IN_SUMMARY_DESCRIPTION}),a.createElement(wYe,{title:"Expenses",aggregatedSummary:null===i||void 0===i?void 0:i.expense,isLoading:s,isEmpty:!m,onEmptyAction:c,emptyText:_t._E.SUMMARY.EMPTY_EXPENSES,tooltipText:_t._E.NO_TRANSFER_IN_SUMMARY_DESCRIPTION}),a.createElement(wYe,{title:"Credit cards",aggregatedSummary:null===i||void 0===i?void 0:i.creditCard,isLoading:s,isEmpty:!g.isConnected,onEmptyAction:d,emptyText:_t._E.SUMMARY.EMPTY_CREDIT_CARDS,tooltipText:_t._E.INCLUDES_SPINWHEEL_CREDIT_CARDS})))};var TYe=n(23707);const _Ye=e=>{let t=e.date,n=e.label;const l=(0,a.useMemo)((()=>
1(0,Ba.ro)(N.c9.local(),N.c9.fromJSDate(t))),[t]);return a.createElement(DYe,{"data-external-id":"date-header"},a.createElement(RYe,{$isToday:l,color:l?"textLight":"text",weight:l?"medium":void 0,size:"xsmall"},parseInt(n,10)))},DYe=u.default.div.withConfig({displayName:"DateHeader__Root",componentId:"sc-1qf3qqc-0"})(["display:flex;align-items:center;margin-top:",";margin-left:",";margin-bottom:",";"],(e=>e.theme.spacing.xsmall),(e=>e.theme.spacing.xsmall),(e=>e.theme.spacing.xxxsmall)),RYe=(0,u.default)(xt.v).withConfig({displayName:"DateHeader__Day",componentId:"sc-1qf3qqc-1"})(["height:",";width:",";display:flex;justify-content:center;align-items:center;",""],(e=>e.theme.spacing.xlarge),(e=>e.theme.spacing.xlarge),(e=>{let t=e.$isToday,n=e.theme;return t&&"\n  border-radius: ".concat(n.radius.round,";\n  background-color: ").concat(n.color.orange,";\n  color: ").concat(n.color.textWhite,";\n  ")})),MYe=e=>{let t=e.expectedAmount,n=e.isIncome,l=e.amountDiff;const r=(0,u.useTheme)();let o;return o=n?l<0?"lower":"higher":l>0?"lower":"higher",a.createElement(LYe,{"data-external-id":"amount-warning-banner",$backgroundColor:l>0?r.color.greenBackground:r.color.yellowBackground},a.createElement(xt.v,{color:l>0?"greenText":"yellowText"},"This transaction was"," ",a.createElement(xt.v,{weight:"medium"},(0,rl.vv)(Math.abs(l))," ",o)," ","than the expected amount of"," ",a.createElement(xt.v,{weight:"medium"},(0,jQ.s_)(t))," ","for this merchant"))},LYe=u.default.div.withConfig({displayName:"AmountWarningBanner__Root",componentId:"sc-1s810bb-0"})(["background-color:",";margin:"," ",";margin-top:0;padding:"," ",";flex:1;border-radius:",";"],(e=>e.$backgroundColor),(e=>e.theme.spacing.default),(e=>e.theme.spacing.large),(e=>e.theme.spacing.xsmall),(e=>e.theme.spacing.default),(e=>e.theme.radius.small));var OYe,PYe;const BYe=e=>{var t,n,l,r,o,i,s,c,d,u,m,g,h,v,f;let E=e.stream,y=e.amount,b=e.amountDiff,x=e.startDate,w=e.date,C=e.setIsMenuOpen,A=e.refetch;const k=!!E.creditReportLiabilityAccount,S=(0,et.I)(ZYe,{variables:{merchantId:null!==(t=null===(n=E.merchant)||void 0===n?void 0:n.id)&&void 0!==t?t:"",endDate:w},skip:!(null!==E&&void 0!==E&&null!==(l=E.merchant)&&void 0!==l&&l.id)}),N=S.data,T=S.isLoadingInitialData,_=xGe({creditReportLiabilityAccountId:null===E||void 0===E||null===(r=E.creditReportLiabilityAccount)||void 0===r?void 0:r.id,limit:3}),D=_.statements,R=_.isLoadingStatements,M=T||R,L=(null!==(o=E.amount)&&void 0!==o?o:0)>0,O=(0,a.useMemo)((()=>{var e;return null!==(e=null===N||void 0===N?void 0:N.allTransactions.results)&&void 0!==e?e:[]}),[null===N||void 0===N?void 0:N.allTransactions]),P=null===N||void 0===N?void 0:N.allTransactions.totalCount,B=k?"ACCOUNT":"MERCHANT",z=(0,a.useMemo)((()=>{var e;return M?a.createElement(HYe,null,a.createElement(p.i,null)):(0,LV.A)(O)&&(0,LV.A)(D)?a.createElement(WYe,null,a.createElement(jYe,null,k?_t._E.LIABILITY_RECENT_BALANCES_EMPTY:_t._E.MERCHANT_TRANSACTIONS_EMPTY)):k?a.createElement(a.Fragment,null,a.createElement(GYe,null,_t._E.LIABILITY_RECENT_BALANCES_HEADER),D.map((e=>{let t=e.id,n=e.dueDate,l=e.billAmount;return a.createElement(YYe,{key:t},a.createElement(xt.v,{size:"small"},(0,Ba.AO)(n)),a.createElement(KYe,{$isIncome:!!l&&l>0,size:"small",className:"mr-4"},l?(0,jQ.s_)(null!==l&&void 0!==l?l:0):"-"))}))):a.createElement(a.Fragment,null,a.createElement(GYe,null,"Recent transactions"),O.map((e=>{let t=e.id,n=e.date,l=e.amount,r=e.category,o=e.isRecurring;return a.createElement(YYe,{key:n},a.createElement($Ye,{to:I.JZ.transactions.details({id:t})},a.createElement(UYe,null,null===r||void 0===r?void 0:r.icon),a.createElement(xt.v,{size:"small"},(0,Ba.AO)(n))),!!o&&a.createElement(JY.d,{content:"Recurring"},a.createElement("span",null,a.createElement(qYe,null))),a.createElement(KYe,{$isIncome:l>0,size:"small",className:"mr-4"},(0,jQ.s_)(l)))})),a.createElement(VYe,null,a.createElement(Vl.W,{to:I.JZ.merchants({id:(null===E||void 0===E||null===(e=E.merchant)||void 0===e?void 0:e.id)||""})},a.createElement(xt.v,{size:"small"},"View all ",P," ",(0,De.td)("transaction",P)))))}),[k,M,P,O,D,E]);return a.createElement(zYe,{"data-external-id":"event-popover"},a.createElement(FYe,{className:"gap-4"},a.createElement(Hl,{id:null!==(i=null!==(s=null===(c=E.merchant)||void 0===c?void 0:c.id)&&void 0!==s?s:null===E||void 0===E||null===(d=E.creditReportLiabilityAccount)||void 0===d||null===(u=d.account)||void 0===u?void 0:u.id)&&void 0!==i?i:"",name:null!==(m=null===E||void 0===E?void 0:E.name)&&void 0!==m?m:"-",frequency:(0,yr.Bp)(E.frequency),logoUrl:E.logoUrl,logoSize:48,
1startDate:x,isMerchant:!!E.merchant,className:"min-w-0 flex-1"}),a.createElement("div",{className:"flex shrink-0 items-center justify-end gap-4"},a.createElement(JY.d,{content:E.isApproximate?_t._E.AMOUNT_ESTIMATE_TOOLTIP:void 0},a.createElement(Ul.w,null,a.createElement(Ul.d,{when:!!E.merchant},a.createElement(KYe,{$isIncome:!!y&&y>0},E.isApproximate?"\u2248":"",(0,jQ.s_)(y||0))),a.createElement(Ul.d,{when:!!E.creditReportLiabilityAccount},a.createElement(gGe,null,B)))),a.createElement(iYe,{streamId:E.id,merchantId:null===(g=E.merchant)||void 0===g?void 0:g.id,accountId:null===(h=E.creditReportLiabilityAccount)||void 0===h||null===(v=h.account)||void 0===v?void 0:v.id,name:null===E||void 0===E?void 0:E.name,setIsMenuOpen:C,refetch:A}))),!!b&&a.createElement(MYe,{expectedAmount:null!==(f=E.amount)&&void 0!==f?f:0,amountDiff:b,isIncome:L}),z)},zYe=u.default.div.withConfig({displayName:"EventPopover__Root",componentId:"xd2xv4-0"})(["border-radius:",";background:",";width:420px;"],(e=>e.theme.radius.medium),(e=>e.theme.color.white)),FYe=(0,u.default)(m.g).attrs({justifyBetween:!0,alignCenter:!0}).withConfig({displayName:"EventPopover__Header",componentId:"xd2xv4-1"})(["padding:",";"],(e=>e.theme.spacing.default)),GYe=(0,$d.s)(H3.X)(OYe||(OYe=(0,wc.A)(["px-default py-2xs text-xs font-bold tracking-widest uppercase"]))),YYe=(0,u.default)(m.g).attrs({alignCenter:!0,justifyBetween:!0}).withConfig({displayName:"EventPopover__TransactionRow",componentId:"xd2xv4-2"})(["padding:",";border-bottom:1px solid ",";"],(e=>e.theme.spacing.default),(e=>e.theme.color.grayBackground)),UYe=u.default.div.withConfig({displayName:"EventPopover__CategoryIcon",componentId:"xd2xv4-3"})(["font-size:14px;margin-right:",";transform:translateY(-1px);"],(e=>e.theme.spacing.small)),VYe=(0,u.default)(m.g).attrs({alignCenter:!0,justifyCenter:!0}).withConfig({displayName:"EventPopover__Footer",componentId:"xd2xv4-4"})(["padding:",";"],(e=>e.theme.spacing.default)),WYe=(0,u.default)(m.g).attrs({center:!0}).withConfig({displayName:"EventPopover__EmptyTransactionContainer",componentId:"xd2xv4-5"})(["padding:"," ",";border-top:1px solid ",";"],(e=>e.theme.spacing.xlarge),(e=>e.theme.spacing.xsmall),(e=>e.theme.color.grayBackground)),jYe=(0,u.default)(xt.v).attrs({color:"grayDark"}).withConfig({displayName:"EventPopover__EmptyTransactionText",componentId:"xd2xv4-6"})(["width:60%;display:block;text-align:center;"]),HYe=(0,u.default)(m.g).attrs({center:!0}).withConfig({displayName:"EventPopover__SpinnerContainer",componentId:"xd2xv4-7"})(["margin:"," 0;"],(e=>e.theme.spacing.xlarge)),KYe=(0,u.default)(xt.v).attrs((0,U.A)({weight:"medium"},fl.zs)).withConfig({displayName:"EventPopover__Amount",componentId:"xd2xv4-8"})(["color:",";cursor:default;"],(e=>{let t=e.$isIncome,n=e.theme;return t?n.color.green:n.color.text})),qYe=(0,u.default)(sl.ZQ).attrs({name:"calendar",size:12}).withConfig({displayName:"EventPopover__RecurringIcon",componentId:"xd2xv4-9"})(["margin:0 ",";display:block;cursor:default;color:",";"],(e=>e.theme.spacing.default),(e=>e.theme.color.textLight)),$Ye=(0,$d.s)(l.N_)(PYe||(PYe=(0,wc.A)(["flex flex-1 text-inherit hover:text-content-link-hover"]))),ZYe=Ee.xX2;var JYe,XYe,QYe,eUe;const tUe=e=>{let t=e.event,n=e.refetch;const l=(0,a.useState)(!1),r=(0,o.A)(l,2),i=r[0],s=r[1],c=t.resource,d=c.isPast,u=void 0!==d&&d,m=c.amount,p=c.amountDiff,g=c.stream,h=c.date,v=c.isCompleted,f=c.isMissed,E=t.title,y=t.start,b=null!==p&&void 0!==p?p:0,x=y?N.c9.fromJSDate(y):void 0,w=(0,a.useCallback)((e=>{let t=e?"tag-blue":"background-info",n="content-info",a="content-success";const l=!(null===g||void 0===g||!g.creditReportLiabilityAccount);return f?(t=e?"tag-red":"background-danger",a="content-danger",n="content-danger"):u&&!l?b<0?(t=e?"tag-yellow":"background-warning",a="content-warning",n="content-warning"):(t=e?"tag-green":"background-success",a="content-success",n="content-success"):u&&l&&(v?(t=e?"tag-green":"background-success",a="content-success",n="content-success"):(t=e?"tag-red":"background-danger",a="content-danger",n="content-danger")),e&&(a="content-white"),{backgroundColor:t,iconColor:a,titleColor:n}}),[u,b,v,f,g]);return a.createElement(Qi.Az,{"data-external-id":"event-wrapper",placement:"bottom-start",closeOnEscape:!1,disableClickOutside:i,overlay:()=>a.createElement(Qi.j7,null,a.createElement(BYe,{date:h,amount:m,stream:g,startDate:x,setIsMenuOpen:s,refetch:n,amountDiff:b}))},(e=>{let t=e.toggleOpen,n=e.isOpen;const l=w(n),r=l.backgroundColor,o=l.iconColor,i=l.titleColor,s=n?"content-white":i,c=!(null===g||void 0===g||!g.merchant),d=!(null===g||void 0===g||!g.creditReportLiabilityAccount),p=(0,yr.wK)({isPast:u,isMissed:!!f,isCompleted:v,isMerchant:c,isAccount:d}),h=p.shouldShowCheck,y=p.shouldShowX;return a.createElement(nUe,{onClick:t,style:(0,y5.A)({"--event-bg-color":(0,qy.f)(r)})},a.createElement(lUe,null,h?a.createElement(aUe,{name:"check",style:(0,y5.A)({"--event-icon-color":(0,qy.f)(o)})}):null,y?a.createElement(aUe,{name:"x",style:(0,y5.A)({"--event-icon-color":(0,qy.f)(o)})}):null,a.createElement(rUe,{weight:"medium",size:"xsmall",style:(0,y5.A)({"--event-title-color":(0,qy.f)(s)})},E)),(0,Tr.A)(m)&&a.createElement(xt.v,{weight:"medium",size:"xsmall",className:(0,q.cn)("text-(--event-text-color)",fl.zs.className),style:(0,y5.A)({"--event-text-color":(0,qy.f)(s)})},null!==g&&void 0!==g&&g.isApproximate?"\u2248":"",(0,jQ.s_)(m)))}))},nUe=$d.s.div(JYe||(JYe=(0,wc.A)(["\n  m-2xs mt-3xs mb-0 flex cursor-pointer items-center justify-between rounded-sm\n  bg-(--event-bg-color) p-2xs\n"]))),aUe=(0,$d.s)(sl.ZQ).attrs({size:12})(XYe||(XYe=(0,wc.A)(["mt-0.5 mr-3xs text-(--event-icon-color)"]))),lUe=$d.s.div(QYe||(QYe=(0,wc.A)(["flex w-3/5 items-center"]))),rUe=(0,$d.s)(xt.v)(eUe||(eUe=(0,wc.A)(["truncate text-(--event-title-color)"]))),oUe=e=>{let t=e.date;return a.createElement(xt.v,{"data-external-id":"header",color:"textLight"}
1,t.toLocaleString("en-US",{weekday:"long"}))},iUe=(0,TYe.AW)(N.c9),sUe=e=>{let t=e.items,n=void 0===t?[]:t,l=e.startDate,r=e.setStartDate,o=e.refetch;const i=(0,a.useMemo)((()=>({calendarDate:l.toJSDate(),getNow:()=>N.c9.local().toJSDate(),components:{toolbar:()=>null,header:oUe,eventWrapper:e=>a.createElement(tUe,Object.assign({refetch:o},e)),month:{dateHeader:_Ye}}})),[l,r,o]),s=i.calendarDate,c=i.getNow,d=i.components,u=(0,a.useMemo)((()=>n.map((e=>{var t,n;return{title:null!==(t=null===e||void 0===e||null===(n=e.stream)||void 0===n?void 0:n.name)&&void 0!==t?t:"",start:N.c9.fromISO((null===e||void 0===e?void 0:e.date)||"").toJSDate(),end:N.c9.fromISO((null===e||void 0===e?void 0:e.date)||"").toJSDate(),id:null===e||void 0===e?void 0:e.stream.id,resource:e}}))),[n]),m=(0,_r.groupBy)(n,(e=>null===e||void 0===e?void 0:e.date)),p=48+27*Math.max(...Object.values(m).map((e=>e.length)));return a.createElement(cUe,{"data-external-id":"recurring-calendar",$monthHeight:p},a.createElement(TYe.Vv,{components:d,date:s,getNow:c,events:u,localizer:iUe,showMultiDayTimes:!0,showAllEvents:!0}))},cUe=u.default.div.withConfig({displayName:"RecurringCalendar__Root",componentId:"qqjt8p-0"})(["background-color:",";margin-bottom:",";border-radius:",";"," padding-bottom:",";.rbc-calendar{min-height:612px;}.rbc-header,.rbc-month-row,.rbc-month-view{border:none;}.rbc-month-header{padding:"," 0;border-bottom:1px solid ",";}.rbc-month-view{padding:0 ",";}.rbc-today{background-color:",";}.rbc-row-content{z-index:unset;}.rbc-month-row{border-right:1px solid ",";border-left:1px solid ",";min-height:","px;}.rbc-month-row + .rbc-month-row{border-top:1px solid ",";}.rbc-month-row:last-child{border-bottom:1px solid ",";}.rbc-off-range{opacity:0;}.rbc-off-range-bg{background-color:",";}.rbc-day-bg + .rbc-day-bg{border-left:1px solid ",";}.rbc-header + .rbc-header{border-left-color:transparent;}"],(e=>e.theme.color.white),(e=>e.theme.spacing.gutter),(e=>e.theme.radius.medium),wn.M.medium,(e=>e.theme.spacing.xlarge),(e=>e.theme.spacing.default),vt.Ee.color.divider.primary,(e=>e.theme.spacing.xlarge),(e=>e.theme.color.white),vt.Ee.color.divider.primary,vt.Ee.color.divider.primary,(e=>e.$monthHeight),vt.Ee.color.divider.primary,vt.Ee.color.divider.primary,(e=>e.theme.color.white),vt.Ee.color.divider.primary),dUe=e=>{let t=e.onClickPrimary;return a.createElement(Xl.AM,{"data-external-id":"recurring-empty-period"},a.createElement(cU.vx,{emptyTheme:cU.dO.NEW,title:g4._E.EMPTY_PERIOD.TITLE,subtitle:g4._E.EMPTY_PERIOD.SUBTITLE,button:{title:"Manage recurring",onClick:t,isPrimary:!0}}))},uUe=()=>{var e;const t=u4(),n=(0,ht.S)().isAiFeaturesEnabled,a=(0,lt.L7)().householdPreferences,l=null!==(e=null===a||void 0===a?void 0:a.continuousFinancialMonitoringEnabled)&&void 0!==e&&e;return t&&n&&l},mUe=e=>{var t;let n=e.insight,r=e.merchant;const o=(0,l.Zp)(),i=uUe(),s=(0,l4.E)().isAdviceSunsetOn;if(!i||s)return null;const c=b4(n),d=c/12,u=n.currentAnnualCost/12,m=Math.max(0,n.currentAnnualCost-c),p=m/12,g=_t.V4.SAVE_PER_YEAR((0,rl.T3)(c)),h=_t.V4.SAVE_PER_MONTH((0,rl.T3)(d)),v=e=>{e.stopPropagation(),o({pathname:I.JZ.advice.insightDetail({insightId:n.id}),search:"?source=".concat(Ye.xD.Recurring)})},f=e=>{"Enter"!==e.key&&" "!==e.key||(" "===e.key&&e.preventDefault(),v(e))},E=a.createElement("div",{className:"flex flex-col gap-sm pt-sm pb-lg text-left",style:{width:298}},a.createElement("div",{className:"flex cursor-pointer items-center gap-xs px-default",role:"button",tabIndex:0,onClick:v,onKeyDown:f},a.createElement(Wl._,{url:null!==(t=r.logoUrl)&&void 0!==t?t:null,size:20}),a.createElement("span",{className:"min-w-0 flex-1 truncate text-sm font-medium text-content-primary"},n.description),a.createElement(sl.ZQ,{name:"chevron-right",size:12,className:"shrink-0 text-content-primary"})),a.createElement("div",{className:"h-px w-full bg-divider-primary"}),a.createElement("p",{className:"px-default text-xs/4.5 text-content-secondary"},n.reasoning),a.createElement(pUe,{label:_t.V4.MONTHLY,newPrice:(0,rl.T3)(p),oldPrice:_t.V4.MONTHLY_COST((0,rl.T3)(u)),chipLabel:h}),a.createElement(pUe,{label:_t.V4.YEARLY,newPrice:(0,rl.T3)(m),oldPrice:_t.V4.ANNUAL_COST((0,rl.T3)(n.currentAnnualCost)),chipLabel:g}));return a.createElement(P.D_,{"data-external-id":"recurring-insight-tag",interactive:!0,place:"top",content:E,className:"rounded-lg"},a.createElement("span",{role:"button",tabIndex:0,onClick:v,onKeyDown:f,className:" mr-default hidden min-w-0 cursor-pointer items-center gap-2xs rounded-sm bg-background-info px-xs py-3xs text-content-info md:inline-flex "},a.createElement(sl.ZQ,{name:"info",size:12,className:"shrink-0"}),a.createElement("span",{className:"truncate text-xs font-medium text-content-info"},g)))},pUe=e=>{let t=e.label,n=e.newPrice,l=e.oldPrice,r=e.chipLabel;return a.createElement("div",{"data-external-id":"insight-breakdown-row",className:"flex items-center gap-xs px-default"},a.createElement("span",{className:"w-12.5 text-xs/4.5 text-content-secondary"},t),a.createElement("div",{className:"flex min-w-0 flex-1 items-baseline justify-end gap-2xs"},a.createElement("span",{className:"text-xs/4.5 font-medium text-content-primary"},n),a.createElement("span",{className:"text-xs/4.5 text-content-secondary line-through"},l)),a.createElement("span",{className:"inline-flex items-center rounded-sm bg-background-info px-xs py-3xs"},a.createElement("span",{className:"text-xs/4.5 font-medium text-content-info"},r)))},gUe=e=>{var t;let n=e.children,l=e.logoUrl,r=e.name,o=e.itemDate,i=e.updatedAmount,s=e.paymentTransactions,c=e.paymentStatus,d=e.liabilityType,u=e.remainingBalance,m=e.showCheckmark,p=e.minimumPaymentAmount,g=e.creditReportLiabilityStatementId,h=e.isPaid,v=e.refetch;const f=(0,C.RU)(),E="credit_card"===d,y=c===Ee.hHu.PARTIALLY_PAID,b=(0,yr.gP)(s),x=b.payments,w=b.credits,A=lYe(),I=A.updateLiabilityStatementPaymentStatus,k=A.isLoadingUpdatePaymentStatus,S=h?DUe:_Ue;return a.createElement(P.D_,{"data-external-id":"payment-status-tooltip",clickable:!0,maxWidth:312,align:"end",content:a.createElement(EUe,null,a.createElement(vUe,null,a.createElement("div",{className:"flex justify-between"},a.createElement(NUe,null,a.createElement(Wl._,{url:l,size:16}),a.createElement(SUe,{weight:"medium"},r)),a.createElement(kUe,null,(0,Ba.AO)(o)))),a.createElement(vUe,null,a.createElement("div",{className:"flex justify-between"},a.createElement("div",null,"Amount due"),a.createElement(xt.v,{weight:"medium"},(0,rl.vv)(-1*(null!==i&&void 0!==i?i:0)))),a.createElement(fUe,null,E?_t._E.CREDIT_CARD_NO_CENTS:void 0)),a.createElement(vUe,{$verticalPaddingBigger:!0},a.createElement(yUe,null,"Payments"),a.createElement("div",null,(0,T9.A)(x).map((e=>a.createElement(TUe,{key:e.id},a.createElement("div",null,e.category.icon," ",(0,Ba.AO)(e.date)),a.createElement(wUe,{$isIncome:e.amount>0},(0,jQ.s_)(null===e||void 0===e?void 0:e.amount)))))),(0,PY.A)(x)&&a.createElement(bUe,null,"No payments yet"),a.createElement(yUe,null,"Credits"),a.createElement("div",null,(0,T9.A)(w).map((e=>a.createElement(TUe,{key:e.id},a.createElement("div",null,e.category.icon," ",(0,Ba.AO)(e.date)),a.createElement(wUe,{$isIncome:e.amount>0},(0,jQ.s_)(null===e||void 0===e?void 0:e.amount)))))),(0,PY.A)(w)&&a.createElement(bUe,null,"No credits")),a.createElement(vUe,null,a.createElement("div",{className:"flex justify-between"},a.createElement(xt.v,{weight:"medium"},"Remaining Balance"),a.createElement(xt.v,{weight:"medium"},(0,rl.vv)(-1*(null!==u&&void 0!==u?u:0)))),a.createElement(CUe,null,a.createElement("div",null,"Status"),a.createElement("div",{className:"flex items-center justify-end gap-2xs"},a.createElement(hUe,{showCheckmark:m,isPartiallyPaid:y,small:!0}),a.createElement(xt.v,{weight:"medium"},(0,_r.capitalize)(null!==(t=null===c||void 0===c?void 0:c.replace("_"," "))&&void 0!==t?t:""))))),E?a.createElement(vUe,null,a.createElement(AUe,null,"Minimum payment due:"," ",a.createElement(IUe,null,(0,rl.vv)(null!==p&&void 0!==p?p:0)))):null,a.createElement(vUe,{$verticalPaddingBigger:!0},a.createElement(S,{onClick:async()=>{g&&await I({creditReportLiabilityStatementId:g,isPaid:!h,onSuccess:()=>{(0,C.oR)({title:h?"Marked as unpaid":"Marked as paid",description:"Statement payment status updated."}),null===v||void 0===v||v()},onError:()=>f()})},disabled:k},a.createElement("div",{className:"flex items-center gap-xs"},a.createElement(sl.ZQ,{name:"check-circle",size:12}),a.createElement("div",null,"Mark as ",h?"unpaid":"paid")))))},n)},hUe=e=>{let t=e.showCheckmark,n=e.isPartiallyPaid,l=e.small;const r=(0,u.useTheme)();if(!t&&!n)return null;const o={partiallyPaid:{backgroundColor:r.variables.color.background.info,color:r.variables.color.content.info},paid:{backgroundColor:r.variables.color.background.success,color:r.variables.color.content.success}};return a.createElement(RUe,{"data-external-id":"paid-icon",$backgroundColor:n?o.partiallyPaid.backgroundColor:o.paid.backgroundColor,$color:n?o.partiallyPaid.color:o.paid.color,$small:l,$noMargin:l},a.createElement(sl.ZQ,{name:"check",size:l?8:10}))},vUe=u.default.div.withConfig({displayName:"PaymentStatusTooltip__TooltipRow",componentId:"sc-1agr6fs-0"})(["--border-color:",";&:not(:last-child){border-bottom:1px solid var(--border-color);}font-weight:",";padding:"," ",";",""],vt.Ee.color.divider.primary,(e=>e.theme.fontWeight.book),(e=>e.theme.spacing.small),(e=>e.theme.spacing.default),(e=>e.$verticalPaddingBigger&&(0,u.css)(["padding:",";"],(e=>e.theme.spacing.default)))),fUe=u.default.div.withConfig({displayName:"PaymentStatusTooltip__CreditCardNote",componentId:"sc-1agr6fs-1"})(["color:",";font-style:italic;margin-top:",";line-height:",";font-size:",";"],vt.Ee.color.content.secondary,(e=>e.theme.spacing.xsmall),(e=>e.theme.fontSize.large),(e=>e.theme.fontSize.xsmall)),EUe=u.default.div.withConfig({displayName:"PaymentStatusTooltip__TooltipContent",componentId:"sc-1agr6fs-2"})(["font-weight:",";text-align:left;font-size:",";"],(e=>e.theme.fontWeight.medium),(e=>e.theme.fontSize.small)),yUe=(0,u.default)(RV.W).withConfig({displayName:"PaymentStatusTooltip__PaymentsTitle",componentId:"sc-1agr6fs-3"})(["display:block;font-size:11px;margin-bottom:",";margin-top:",";&:first-child{margin-top:0;}"],(e=>e.theme.spacing.xsmall),(e=>e.theme.spacing.large)),bUe=(0,u.default)(xt.v).attrs({weight:"book"}).withConfig({displayName:"PaymentStatusTooltip__NoPaymentsYetLabel",componentId:"sc-1agr6fs-4"})(["color:",";margin-bottom:",";font-style:italic;"],vt.Ee.color.content.secondary,(e=>e.theme.spacing.xsmall)),xUe=(0,u.default)(xt.v).attrs((0,U.A)({weight:"medium"},fl.zs)).withConfig({displayName:"PaymentStatusTooltip__Amount",componentId:"sc-1agr6fs-5"})(["color:",";margin-right:",";"],(e=>{let t=e.$isIncome,n=e.theme;return t?n.variables.color.content.success:n.variables.color.content.primary}),(e=>e.theme.spacing.default)),wUe=(0,u.default)(xUe).withConfig({displayName:"PaymentStatusTooltip__TransactionAmount",componentId:"sc-1agr6fs-6"})(["margin-right:0;"]),CUe=(0,u.default)(ZY.B).attrs({justifyBetween:!0}).withConfig({displayName:"PaymentStatusTooltip__StatusContainer",componentId:"sc-1agr6fs-7"})(["margin-top:",";"],(e=>e.theme.spacing.small)),AUe=(0,u.default)(xt.v).withConfig({displayName:"PaymentStatusTooltip__MinimumPaymentText",componentId:"sc-1agr6fs-8"})(["display:block;color:",";text-align:center;"],vt.Ee.color.content.secondary),IUe=(0,u.default)(xt.v).attrs({weight:"medium"}).withConfig({displayName:"PaymentStatusTooltip__MinimumPaymentAmount",componentId:"sc-1agr6fs-9"})(["color:",";"],vt.Ee.color.content.secondary),kUe=(0,u.default)(xt.v).withConfig({displayName:"PaymentStatusTooltip__DateText",componentId:"sc-1agr6fs-10"})(["color:",";margin-left:",";text-align:right;text-wrap:nowrap;flex-grow:1;"],vt.Ee.color.content.secondary,(e=>e.theme.spacing.small)),SUe=(0,u.default)(xt.v).withConfig({displayName:"PaymentStatusTooltip__AccountName",componentId:"sc-1agr6fs-11"})(["white-space:nowrap;overflow:hidden;text-overflow:ellipsis;flex-grow:2;"]),NUe=(0,u.default)(ZY.B).attrs({alignCenter:!0}).withConfig({displayName:"PaymentStatusTooltip__ItemNameAndLogoWrapper",componentId:"sc-1agr6fs-12"})(["gap:",";flex-grow:1;max-width:180px;"],(e=>e.theme.spacing.xsmall)),TUe=(0,u.default)(ZY.B).attrs({justifyBetween:!0}).withConfig({displayName:"PaymentStatusTooltip__PaymentTransaction",componentId:"sc-1agr6fs-13"})(["margin-top:",";&:first-child{margin-top:0;}"],(e=>e.theme.spacing.xsmall)),_Ue=(0,u.default)(cu.WT).attrs({size:"small"}).withConfig({displayName:"PaymentStatusTooltip__MarkAsPaidButton",componentId:"sc-1agr6fs-14"})(["width:100%;"]),DUe=(0,u.default)(wt.Xb).attrs({size:"small"}).withConfig({displayName:"PaymentStatusTooltip__MarkAsUnpaidButton",componentId:"sc-1agr6fs-15"})(["width:100%;"]),RUe=u.default.div.withConfig({displayName:"PaymentStatusTooltip__IconWrapper",componentId:"sc-1agr6fs-16"})(["display:flex;align-items:center;justify-content:center;border-radius:",";background-color:",";color:",";width:",";height:",";margin-right:",";"],(e=>e.theme.radius.round),(e=>e.$backgroundColor),(e=>e.$color),(e=>{let t=e.theme;return e.$small?t.spacing.small:t.spacing.default}),(e=>{let t=e.theme;return e.$small?t.spacing.small:t.spacing.default}),(e=>{let t=e.theme;return e.$noMargin?0:t.spacing.xsmall})),MUe=e=>{var t,n,l,r,i,s,c,d,u,m;let p=e.amount,g=e.refetch,h=e.item,v=e.startDate;const f=h.creditReportLiabilityStatementId,E=h.isAmountDifferentThanOriginal,y=h.date,b=h.isCompleted,x=h.isMissed,w=null===h||void 0===h||null===(t=h.stream)||void 0===t?void 0:t.isApproximate,A=null===h||void 0===h||null===(n=h.stream)||void 0===n?void 0:n.merchant,I=null===h||void 0===h||null===(l=h.stream)||void 0===l?void 0:l.creditReportLiabilityAccount,k=null===h||void 0===h||null===(r=h.stream)||void 0===r||null===(i=r.creditReportLiabilityAccount)||void 0===i||null===(s=i.account)||void 0===s?void 0:s.id,S=null===h||void 0===h||null===(c=h.stream)||void 0===c||null===(d=c.creditReportLiabilityAccount)||void 0===d?void 0:d.liabilityType,N=h.stream,T=N.logoUrl,_=N.merchant,D=N.name,R=N.id,M=null===_||void 0===_?void 0:_.id,L=null===_||void 0===_||null===(u=_.financialInsights)||void 0===u?void 0:u.find((e=>!!e&&E4.az.includes(e.status))),O=null!==(m=null===h||void 0===h?void 0:h.liabilityStatement)&&void 0!==m?m:{},P=O.paymentsInformation,B=O.minimumPaymentAmount,z=null!==P&&void 0!==P?P:{},F=z.remainingBalance,G=z.status,Y=z.transactions,U=G===Ee.hHu.PARTIALLY_PAID,V=lYe().updateLiabilityUserBillAmount,W=(0,C.RU)(),j=(0,BY.A)(p)?null:Math.abs(p),H=a.useState(j),K=(0,o.A)(H,2),q=K[0],$=K[1],Z=a.useState(!1),J=(0,o.A)(Z,2),X=J[0],Q=J[1],ee=(0,a.useRef)(null);(0,Ku.D)("Enter",ee.current,{onKeyDown:()=>{var e;return null===(e=ee.current)||void 0===e?void 0:e.blur()}});const te=I&&!(0,BY.A)(p)&&!!f&&X,ne=!!b,ae=a.useState(p),le=(0,o.A)(ae,2),re=le[0],oe=le[1],ie=I&&(0,BY.A)(p),se=!ie&&!te,ce=!x&&(b||U),de=Boolean(p&&p>0&&A||re&&I&&re>0);return a.createElement(OUe,{"data-external-id":"recurring-amount-and-menu",justifyEnd:!0,alignCenter:!0},L&&_&&a.createElement(mUe,{insight:L,merchant:_}),a.createElement(Ul.w,null,a.createElement(Ul.d,{when:!!I},se&&a.createElement(gUe,{creditReportLiabilityStatementId:f,logoUrl:T,name:D,itemDate:y,updatedAmount:re,paymentTransactions:Y,paymentStatus:G,liabilityType:S,showCheckmark:!!ce,remainingBalance:F,minimumPaymentAmount:B,isPaid:ne,refetch:g},a.createElement("div",{className:"flex items-center justify-end"},a.createElement(hUe,{showCheckmark:!!ce,isPartiallyPaid:U}),a.createElement(zUe,null),a.createElement(LUe,{$isIncome:de},(0,Tr.A)(re)&&(0,rl.is)(-1*re))))),a.createElement(Ul.d,{default:!0},se&&a.createElement(JY.d,{portal:!0,content:w?_t._E.AMOUNT_ESTIMATE_TOOLTIP:void 0},a.createElement("div",{className:"flex items-center"},a.createElement(hUe,{showCheckmark:!!ce}),a.createElement(LUe,{$isIncome:de},w?"\u2248":"",re&&(0,jQ.s_)(re)))))),te&&a.createElement("div",null,a.createElement(fe.K$5.Root,{value:null!==q&&void 0!==q?q:null,min:0,step:"any",onValueChange:$},a.createElement(fe.i9A,{variant:"cell",align:"end",className:"mr-default w-30"}
1,a.createElement(fe.K$5.Input,{ref:ee,autoFocus:!0,tabIndex:0,name:"amount",placeholder:"$",onFocus:ix.X,onBlur:async()=>{if((0,BY.A)(q))return $(j),void Q(!1);if(q===j||!f)return void Q(!1);const e=-q;oe(e),await V({creditReportLiabilityStatementId:f,userBillAmount:e,onSuccess:()=>{Q(!1),(0,C.oR)({title:"Success",description:"Amount updated."}),null===g||void 0===g||g()},onError:()=>W({title:"Error",description:"Something went wrong. Please try again later or submit a ticket."})})}})))),ie&&a.createElement(JY.d,{portal:!0,content:ie?_t._E.AWAITING_BALANCE:void 0},a.createElement("div",null,a.createElement(PUe,null,"Awaiting balance"))),D&&g&&a.createElement(BUe,{streamId:R,creditReportLiabilityStatementId:f,accountId:k,isPaid:ne,merchantId:M,name:D,startDate:v,refetch:g,setAmountValue:oe,setIsEditStatementVisible:Q,isAmountDifferentThanOriginal:null!==E&&void 0!==E&&E}))},LUe=(0,u.default)(xt.v).attrs((0,U.A)({weight:"medium"},fl.zs)).withConfig({displayName:"RecurringAmountAndMenu__Amount",componentId:"sc-1m8qy0y-0"})(["color:",";margin-right:",";"],(e=>{let t=e.$isIncome,n=e.theme;return t?n.color.green:n.color.text}),(e=>e.theme.spacing.default)),OUe=(0,u.default)(m.g).withConfig({displayName:"RecurringAmountAndMenu__Container",componentId:"sc-1m8qy0y-1"})(["&:hover{cursor:default;}"]),PUe=(0,u.default)(xt.v).attrs({weight:"medium",size:"small"}).withConfig({displayName:"RecurringAmountAndMenu__AwaitingBalance",componentId:"sc-1m8qy0y-2"})(["color:",";margin-right:",";"],(e=>e.theme.color.textLight),(e=>e.theme.spacing.default)),BUe=(0,u.default)(iYe).withConfig({displayName:"RecurringAmountAndMenu__StyledRecurringMenu",componentId:"sc-1m8qy0y-3"})([""]),zUe=(0,u.default)(sl.ZQ).attrs({name:"file-text",size:12}).withConfig({displayName:"RecurringAmountAndMenu__FileTextIcon",componentId:"sc-1m8qy0y-4"})(["color:",";margin-right:",";"],(e=>e.theme.color.textLight),(e=>e.theme.spacing.xsmall)),FUe=["stream","date","account","category","isLate","isMissed","amount","transactionId"],GUe={name:["stream","name"],date:["date"],account:["account","displayName"],category:["category","name"],amount:["amount"]},YUe=e=>{var t,n,l,r,i,s,c,d;const u=e.startDate,m=e.refetch,p=e.items,g=e.title,h=e.isLoading,v=void 0!==h&&h,f=e.summary,E=e.isCollapsed,y=e.toggleCollapsed,b=(0,a.useState)(null),x=(0,o.A)(b,2),w=x[0],C=x[1],A=(0,a.useMemo)((()=>{if(!w)return null!==p&&void 0!==p?p:[];const e=(null===w||void 0===w?void 0:w.direction)===tr.ASC?U_e.A:Go.A,t=(0,nj.A)("",GUe[w.property]);return(0,Fo.A)([e((0,HGe.A)((0,KGe.A)(PPe.A,Math.abs,qGe.A),t))])(null!==p&&void 0!==p?p:[])}),[p,w]),I=(0,a.useCallback)((e=>{(null===w||void 0===w?void 0:w.property)!==e||(null===w||void 0===w?void 0:w.direction)!==tr.DESC?C({property:e,direction:(null===w||void 0===w?void 0:w.property)===e&&(null===w||void 0===w?void 0:w.direction)===tr.ASC?tr.DESC:tr.ASC}):C(null)}),[w]);return v?a.createElement(Mr,{"data-external-id":"recurring-upcoming-list"}):0===(null===A||void 0===A?void 0:A.length)?null:a.createElement("div",{"data-external-id":"recurring-upcoming-list"},a.createElement(nr,null,a.createElement(ar,null,a.createElement(sr,{$marginRight:!0},a.createElement("div",{className:"flex items-center gap-xs"},a.createElement($H.V,{expanded:!E,onClick:y}),a.createElement(dr,null,g))),a.createElement(sr,null,a.createElement(ur,{onClick:()=>I("date")},"Date ",a.createElement(lr,{property:"date",sortedBy:w}))),a.createElement(sr,null,a.createElement(ur,{onClick:()=>I("account")},"Payment Account ",a.createElement(lr,{property:"account",sortedBy:w}))),a.createElement(sr,null,a.createElement(ur,{onClick:()=>I("category")},"Category ",a.createElement(lr,{property:"category",sortedBy:w}))),a.createElement(sr,{$align:"right"},a.createElement(ur,{$marginRight:52,onClick:()=>I("amount")},"Amount ",a.createElement(lr,{property:"amount",sortedBy:w})))),a.createElement(rr,{open:!E},a.createElement("div",{className:"flex flex-col"},A.map((e=>{var t,n,l,r,o,i,s,c;let d=e.stream,p=e.date,g=e.account,h=e.category,v=e.isLate,f=e.isMissed,E=e.amount,y=e.transactionId,b=(0,En.A)(e,FUe);const x=(0,yr.Jd)({isMissed:f,isLate:v,hasCreditReportLiabilityAccount:!!d.creditReportLiabilityAccount});return a.createElement(cr,{key:"".concat(d.id,"-").concat(p,"-").concat(y)},a.createElement(sr,null,a.createElement(Hl,{id:null!==(t=null!==(n=null===(l=d.merchant)||void 0===l?void 0:l.id)&&void 0!==n?n:null===(r=d.creditReportLiabilityAccount)||void 0===r||null===(o=r.account)||void 0===o?void 0:o.id)&&void 0!==t?t:"",name:null!==(i=null===d||void 0===d?void 0:d.name)&&void 0!==i?i:"",frequency:(0,yr.Bp)(d.frequency),logoUrl:d.logoUrl,
1startDate:u,isMerchant:!!d.merchant})),a.createElement(sr,null,a.createElement(mr,{$late:x},a.createElement(Er,null,null===(s=(0,yr.fj)(p))||void 0===s?void 0:s.nextPaymentDateFormatted),a.createElement(xt.v,{color:x?"orange":"textLight"},"(",null===(c=(0,yr.fj)(p))||void 0===c?void 0:c.daysUntilNextPaymentLabel,")"))),a.createElement(sr,null,g?a.createElement(XGe,{account:g}):a.createElement(ZGe,{columnType:"account",isMerchant:!!d.merchant})),a.createElement(sr,null,h?a.createElement(eYe,{category:h,startDate:u}):a.createElement(ZGe,{columnType:"category",isMerchant:!!d.merchant})),a.createElement(sr,null,a.createElement(MUe,{amount:null!==E&&void 0!==E?E:void 0,item:(0,U.A)({stream:d,date:p,account:g,category:h,isLate:v,isMissed:f,amount:E,transactionId:y},b),refetch:m,startDate:u})))}))))),f?a.createElement(pr,null,a.createElement(gr,{$align:"left"},a.createElement(hr,null,g),a.createElement(vr,null,"Total")),a.createElement(fr,null,a.createElement(gr,null,a.createElement(hr,null,"Income"),a.createElement(vr,{$isIncome:(null!==(t=null===f||void 0===f||null===(n=f.income)||void 0===n?void 0:n.total)&&void 0!==t?t:0)>0},(0,jQ.s_)(Math.abs(null!==(l=null===f||void 0===f||null===(r=f.income)||void 0===r?void 0:r.total)&&void 0!==l?l:0)))),a.createElement(gr,null,a.createElement(hr,null,"Credit cards"),a.createElement(vr,null,(0,rl.vv)(Math.abs(null!==(i=null===f||void 0===f||null===(s=f.creditCard)||void 0===s?void 0:s.total)&&void 0!==i?i:0)))),a.createElement(gr,null,a.createElement(hr,null,"Expenses"),a.createElement(vr,null,(0,rl.vv)(Math.abs(null!==(c=null===f||void 0===f||null===(d=f.expense)||void 0===d?void 0:d.total)&&void 0!==c?c:0)))))):null)};var UUe;let VUe=function(e){return e.Calendar="calendar",e.List="list",e}({});const WUe=e=>{var t,n;let l=e.currentStartDate,r=e.endDate,i=e.filters,s=e.setStartDate,c=e.streamsToReview,u=e.onClickToReviewStreams,m=e.openAddRecurringModal,p=e.openAddManualRecurringModal,h=e.onClickAddBills;const v=(0,d.wA)(),f=(0,d.d4)(zFe),E=(0,a.useCallback)((e=>{v((0,g.wx)(e))}),[v]),y=(0,a.useState)(VUe.List),b=(0,o.A)(y,2),x=b[0],w=b[1];mYe({tab:"monthly",view:x});const C=x===VUe.Calendar,A=x===VUe.List,I=c.length,k=(e=>{var t;let n=e.currentStartDate,l=e.endDate,r=e.filters;const o=uUe(),i=(0,bZ.D)(Yr.Op,{variables:{startDate:n.toISODate(),endDate:l.toISODate(),filters:(0,Ur.fj)(r),includeFinancialInsights:o}}),s=i.data,c=i.isNetworkRequestInFlight,d=i.refetch,u=(0,a.useMemo)((()=>{var e;return!c&&(0,PY.A)(null===s||void 0===s||null===(e=s.aggregatedRecurringItems)||void 0===e?void 0:e.groups)}),[c,s]),m=null!==(t=null===s||void 0===s?void 0:s.aggregatedRecurringItems)&&void 0!==t?t:{},p=m.groups,g=m.aggregatedSummary,h=(0,a.useMemo)((()=>(0,yr.mF)(null!==p&&void 0!==p?p:[])),[p]),v=(0,a.useMemo)((()=>{var e;return(0,Ri.A)(null!==(e=null===p||void 0===p?void 0:p.map((e=>e.results)))&&void 0!==e?e:[])}),[p]),f=(0,a.useCallback)((()=>{d()}),[d]);return{aggregatedSummary:g,isLoadingAggregated:c,sortedGroups:h,calendarItems:v,shouldShowEmptyState:u,refetchAll:f}})({currentStartDate:l,endDate:r,filters:i}),S=k.aggregatedSummary,N=k.isLoadingAggregated,T=k.sortedGroups,_=k.calendarItems,D=k.shouldShowEmptyState,R=k.refetchAll;return a.createElement(a.Fragment,null,a.createElement(rG.X,null,"Monthly"),a.createElement(jUe,null,I>0?a.createElement(HUe,null,a.createElement(Ul.w,null,a.createElement(Ul.d,{when:I>1},"There are ",I," new recurring merchants and accounts for you to review"),a.createElement(Ul.d,{when:1===I},"There is 1 new recurring"," ",null!==(t=c[0])&&void 0!==t&&null!==(n=t.stream)&&void 0!==n&&n.merchant?"merchant":"account"," for you to review")),a.createElement(KUe,{onClick:u},"Review now")):null,a.createElement(NYe,{startDate:l,setStartDate:s,recurringView:x,setRecurringView:w,aggregatedSummary:S,isLoadingSummary:N,openAddManualRecurringModal:p,onClickAddBills:h}),a.createElement(Ul.w,null,a.createElement(Ul.d,{when:A},N&&a.createElement(Mr,null),N?null:T.map(((e,t)=>{var n,r,o,i;return a.createElement(YUe,{key:t,title:(0,EA.ZH)(null!==(n=null===(r=e.groupBy)||void 0===r?void 0:r.status)&&void 0!==n?n:""),items:e.results,startDate:l,refetch:R,isLoading:!1,summary:e.summary,isCollapsed:null===f||void 0===f?void 0:f[null!==(o=null===(i=e.groupBy)||void 0===i?void 0:i.status)&&void 0!==o?o:""],toggleCollapsed:()=>{var t,n;return E(null!==(t=null===(n=e.groupBy)||void 0===n?void 0:n.status)&&void 0!==t?t:"")}})}))),a.createElement(Ul.d,{when:C},a.createElement(sUe,{items:_,startDate:l,setStartDate:s,refetch:R}))),D&&a.createElement(dUe,{onClickPrimary:m})))},jUe=$d.s.div(UUe||(UUe=(0,wc.A)(["mb-gutter flex w-full flex-col px-gutter pt-0 pb-gutter"]))),HUe=(0,u.default)(ZY.B).attrs({row:!0,justifyBetween:!0}).withConfig({displayName:"RecurringUpcoming__StreamsToReviewBanner",componentId:"sc-1hqs7qd-0"})(["padding:"," ",";margin-bottom:",";background:",";color:",";border-radius:",";font-size:",";font-weight:",";"],vt.YK.xsmall,vt.YK.small,vt.YK.gutter,vt.yW.orange,vt.yW.textWhite,vt.r8.small,vt.J.small,vt.Wy.medium),KUe=(0,u.default)(bn.v).withConfig({displayName:"RecurringUpcoming__ReviewButton",componentId:"sc-1hqs7qd-1"})(["color:",";text-decoration:underline;:hover{color:",";background-color:transparent;}"],vt.yW.textWhite,vt.yW.textWhite),qUe=I.JZ.recurring.upcoming.path,$Ue=e=>{let t=e.modalFlow,n=e.sharedState;return a.createElement("div",{"data-external-id":"recurring-tab-routes",className:"flex min-h-0 w-full flex-1 flex-col"},a.createElement(l.BV,null,a.createElement(l.qh,{element:a.createElement(l.C5,{to:{pathname:qUe,search:n.locationSearch},replace:!0}),path:""}),a.createElement(l.qh,{path:I.JZ.recurring.upcoming.relativePath,element:a.createElement(a.Fragment,null,a.createElement(rV.T,{screenName:"Recurring",tab:"monthly"}
1),a.createElement(WUe,{currentStartDate:n.currentStartDate,endDate:n.endDate,filters:n.filters,setStartDate:n.setStartDate,streamsToReview:t.pendingStreams,onClickToReviewStreams:t.openReviewStreamModal,openAddRecurringModal:t.openAddRecurringModal,openAddManualRecurringModal:t.openAddManualRecurringModal,onClickAddBills:t.onClickAddBills}))}),a.createElement(l.qh,{path:I.JZ.recurring.all.relativePath,element:a.createElement(a.Fragment,null,a.createElement(rV.T,{screenName:"Recurring",tab:"all"}),a.createElement(pYe,{filters:n.filters,startDate:n.currentStartDate}))}),a.createElement(l.qh,{path:I.JZ.recurring.playground.relativePath,element:a.createElement(l.C5,{to:{pathname:I.JZ.recurringV2.playground.path,search:n.locationSearch},replace:!0})}),a.createElement(l.qh,{path:I.JZ.recurring.recurringv2.relativePath,element:a.createElement(l.C5,{to:{pathname:I.JZ.recurringV2.monthly.path,search:n.locationSearch},replace:!0})})))},ZUe=5*iC.K5,JUe=3*iC.EM,XUe=(0,Qt.J)("\n  query RecurringMerchantSearch {\n    recurringMerchantSearch {\n      startedAt\n      nextAt\n      finishedAt\n      createdCount\n    }\n    recurringTransactionStreams {\n      stream {\n        id\n      }\n    }\n  }\n"),QUe=(0,Qt.J)("\n  mutation Common_TriggerRecurringMerchantSearch {\n    triggerRecurringMerchantSearch {\n      success\n    }\n  }\n"),eVe=()=>{const e=(0,l.Zp)(),t="true"===(0,b.pE)("reviewOpen"),n=(0,b.cn)("reviewOpen"),r=(0,Pd.h)(),s=(0,o.A)(r,2),c=s[0],d=s[1],u=d.open,m=d.close,p=(0,Pd.h)(t),g=(0,o.A)(p,2),h=g[0],v=g[1],f=v.open,E=v.close,y=(0,Pd.h)(),x=(0,o.A)(y,2),w=x[0],A=x[1].open,k=(0,Pd.h)(),S=(0,o.A)(k,2),N=S[0],T=S[1],_=T.open,D=T.close,R=ace(),M=R.pendingStreams,L=R.refetchHouseholdHasRecurring,O=(0,SYe.P)(),P=O.syncCreditReport,B=O.isSyncingCreditReport,z=O.resetTimeout,F=O.connectionStatus,G=(0,a.useState)(),Y=(0,o.A)(G,2),U=Y[0],V=Y[1],W=()=>L(),j=(0,a.useCallback)((()=>{m(),A()}),[m,A]),H=(0,a.useCallback)((()=>{m(),F.isDisconnected?(P(),_()):e(I.JZ.recurring.mapLiabilities())}),[m,F.isDisconnected,e,_,P]),K=(e=>{const t=null!==e&&void 0!==e?e:{},n=t.onDidStartSearch,l=t.onDidFinishSearch,r=t.onTimeoutReached,s=t.onError,c=(0,PH.p)(XUe,{pollUntil:e=>{var t,n;return(null!==(n=null===(t=null===e||void 0===e?void 0:e.recurringMerchantSearch)||void 0===t?void 0:t.createdCount)&&void 0!==n?n:0)>0},onComplete:l,pollIntervalMs:ZUe,skipWhenNotPolling:!1,pollTimeoutMs:JUe,onTimeoutReached:r}),d=(0,o.A)(c,2),u=d[0],m=d[1],p=m.data,g=m.refetch,h=(null!==p&&void 0!==p?p:{}).recurringMerchantSearch,v=null!==h&&void 0!==h?h:{},f=v.startedAt,E=v.finishedAt,y=v.nextAt,b=v.createdCount,x=(0,a.useMemo)((()=>({searchStartedAt:f,searchFinishedAt:E,searchNextAt:y,createdStreamCount:b})),[h]),w=(0,i.n)(QUe,{optimisticResponse:{__typename:"Mutation",triggerRecurringMerchantSearch:{__typename:"TriggerRecurringMerchantSearchMutation",success:!0}}}),C=(0,o.A)(w,1)[0],A=(0,a.useCallback)((async()=>{try{await C(),await g(),null===n||void 0===n||n()}catch(e){null===s||void 0===s||s(e)}}),[n,C,g,s]);return(0,a.useEffect)((()=>{f&&u()}),[f,u]),[A,{isInProgress:(0,Tr.A)(h)&&(0,BY.A)(E),currentSearch:x}]})({onDidStartSearch:()=>{m();const e=(0,C.oR)({title:_t._E.SEARCH.TOAST_TITLE,description:_t._E.SEARCH.TOAST_SUBTITLE,duration:MFe.yz,accessory:a.createElement(vG.W,null,a.createElement(fe.FWg,null))});V(e)},onDidFinishSearch:()=>{C.oR.dismiss(U),W()},onTimeoutReached:()=>{C.oR.dismiss(U),W()}}),q=(0,o.A)(K,2),$=q[0],Z=q[1].currentSearch,J=Z.searchStartedAt,X=Z.searchNextAt,Q=(0,a.useMemo)((()=>(0,yr.XD)(J,X)),[J,X]);return{AddManualRecurringModal:w,AddRecurringModal:c,ConnectionModal:N,ReviewStreamModal:h,closeReviewStreamModal:E,connectionStatus:F,handleCloseConnectionModal:()=>{z(),D()},hasAlreadySyncedWithSpinwheel:F.isConnected,isSyncingCreditReport:B,onClickAddBills:H,onClickAddManual:j,openAddManualRecurringModal:A,openAddRecurringModal:u,openReviewStreamModal:f,pendingStreams:M,refetchAll:W,searchDisabledTooltip:Q,setReviewOpen:n,startRecurringSearch:$}},tVe=()=>{const e=(0,b.Bb)("startDate"),t=(0,o.A)(e,2),n=t[0],l=t[1],r=(0,a.useMemo)((()=>n?N.c9.fromISO(n):N.c9.local().startOf("month")),[n]),i=(0,a.useMemo)((()=>r.endOf("month")),[r]);return{currentStartDate:r,endDate:i,setStartDate:l}};var nVe=n(36574);const aVe=()=>{const e=(0,d.wA)(),t=(0,d.d4)(BFe),n=(0,l.zy)(),r=tVe(),o=r.currentStartDate,i=r.endDate,s=r.setStartDate;(()=>{const e=(0,b.cn)("markAsPaid"),t=(0,b.pE)("markAsPaid"),n=lYe().updateLiabilityStatementPaymentStatus;(0,a.useEffect)((()=>{t&&n({creditReportLiabilityStatementId:t,isPaid:!0,onSuccess:()=>{e(void 0),(0,C.oR)({title:"Statement successfully marked as paid"})}})}),[t,n])})();const c=(0,a.useCallback)((t=>{var n;const a=0===(null===(n=t.accounts)||void 0===n?void 0:n.length)?(0,XX.A)(["accounts"],t):t;e((0,nVe.T)(a))}),[e]);return{currentStartDate:o,endDate:i,filters:t,locationSearch:n.search,setStartDate:s,updateFilters:c}},lVe=["startDate","markAsPaid","reviewOpen"],rVe=()=>{const e=aVe(),t=eVe();return a.createElement(Yq,{"data-external-id":"recurring",name:"Recurring",ignoredTrackingQueryParams:lVe,tabs:a.createElement(jFe,null),emptyIcon:"calendar",emptyTitle:_t._E.EMPTY_STATE_TITLE,emptyButtonText:_t._E.EMPTY_ACCOUNTS_BUTTON_TEXT,controls:a.createElement(VFe,{filters:e.filters,onChangeFilters:e.updateFilters,onClickAddRecurring:t.openAddRecurringModal})},a.createElement("div",{className:"flex min-h-0 flex-1 flex-col items-start"}
1,a.createElement(NFe,null),a.createElement($Ue,{modalFlow:t,sharedState:e})),a.createElement(WGe,{flow:t}))};var oVe=n(87316),iVe=n(60192);const sVe=iVe.p.NOT_RECURRING_MODAL,cVe=e=>sVe.MERGE.KIND_NOUN[e],dVe=e=>e?sVe.TOAST.DETECTION_ERROR:sVe.TOAST.ERROR,uVe=iVe.p.NOT_RECURRING_MODAL,mVe=e=>{let t=e.open,n=e.onClose,l=e.merchantName,r=e.groupName,i=e.sectionKind,s=e.siblingCount,c=e.isActive,d=e.canMerge,u=e.onConfirm;const m=(0,a.useState)(null),p=(0,o.A)(m,2),g=p[0],h=p[1],v=(0,a.useState)(!0),f=(0,o.A)(v,2),E=f[0],y=f[1],b=(0,a.useState)(!1),x=(0,o.A)(b,2),w=x[0],C=x[1],A=(0,a.useState)(!1),I=(0,o.A)(A,2),k=I[0],S=I[1];(0,a.useEffect)((()=>{t&&(h(null),y(!0),C(!1),S(!1))}),[t]);const N=r||l||"",T=(e=>{let t=e.hasMerchant,n=e.siblingCount,a=e.isActive,l=e.canMerge;return["not_this_pattern",...t?["never"]:[],...t&&(void 0===l?n>0:l)?["merge"]:[],...a?["no_longer"]:[]]})({hasMerchant:!(0,BY.A)(l),siblingCount:s,isActive:c,canMerge:d}),_="never"===g,D=E&&s>0,R=(e=>{let t=e.reason;return"never"===t?sVe.NEVER.BUTTON:"merge"===t?sVe.MERGE.BUTTON:"no_longer"===t?sVe.NO_LONGER.BUTTON:sVe.NOT_THIS_PATTERN.BUTTON})({reason:g});return a.createElement(fe.hg1.Root,{"data-external-id":"mark-group-not-recurring-modal",open:t,onOpenChange:e=>!e&&!k&&n(),size:"md"},a.createElement(fe.hg1.Content,null,a.createElement(fe.hg1.Header,{className:"gap-xs border-b-0 px-xl pt-xl pb-0"},a.createElement(fe.hg1.Title,{className:"truncate"},N),a.createElement(fe.c8D,{size:"sm",color:"secondary"},uVe.INTRO)),a.createElement(fe.hg1.Body,{className:"flex flex-col px-xl pt-sm pb-2xs"},a.createElement(fe.GsR.Group,{value:g,onValueChange:h,className:"-mx-sm flex flex-col gap-3xs"},T.map((e=>{const t=pVe(e,l,i);return a.createElement(hVe,{key:e,value:e,label:t.label,description:t.description,selected:g===e})}))),_&&a.createElement(a.Fragment,null,a.createElement(fe.AVK,{color:"secondary",className:"mt-sm"}),a.createElement("div",{className:"flex flex-col gap-3xs pt-xs"},a.createElement(gVe,{label:uVe.NEVER.DISABLE_DETECTION,checked:E,onCheckedChange:e=>{y(e),e||C(!1)}}),s>0&&a.createElement(gVe,{label:uVe.NEVER.DELETE_SIBLINGS(s),checked:w,disabled:!D,onCheckedChange:C})))),a.createElement(fe.hg1.Footer,{className:"border-t-0 px-xl pt-default pb-lg"},a.createElement(fe.hg1.Close,{render:a.createElement(fe.XZZ,{disabled:k})},"Cancel"),a.createElement(fe.XZZ,{variant:"primary",disabled:(0,BY.A)(g)||k,onClick:async()=>{if(!(0,BY.A)(g)&&!k){S(!0);try{if("never"===g)return void await u({reason:g,disableDetection:E,deleteSiblings:D&&w});await u({reason:g})}finally{S(!1)}}}},R))))},pVe=(e,t,n)=>"not_this_pattern"===e?{label:uVe.NOT_THIS_PATTERN.LABEL,description:uVe.NOT_THIS_PATTERN.DESCRIPTION}:"never"===e?{label:uVe.NEVER.LABEL(null!==t&&void 0!==t?t:""),description:uVe.NEVER.DESCRIPTION}:"merge"===e?{label:uVe.MERGE.LABEL(cVe(n)),description:uVe.MERGE.DESCRIPTION}:{label:uVe.NO_LONGER.LABEL,description:uVe.NO_LONGER.DESCRIPTION},gVe=e=>{let t=e.label,n=e.checked,l=e.disabled,r=e.onCheckedChange;const o=(0,a.useId)();return a.createElement("span",{"data-external-id":"never-extras-checkbox",className:"inline-flex items-center gap-xs py-xs"},a.createElement(fe.Ko1,{id:o,size:"sm",checked:n,disabled:l,onCheckedChange:e=>r(!0===e)}),a.createElement(fe.Ko1.Label,{htmlFor:o,disabled:l},a.createElement(fe.c8D,{size:"sm",weight:"book",color:l?"secondary":"primary"},t)))},hVe=e=>{let t=e.value,n=e.label,l=e.description,r=e.selected;return a.createElement(fe.StI.Root,{"data-external-id":"reason-option",value:t,size:"sm",variant:"subtle",className:(0,q.cn)(r&&"bg-background-brand-subtle")},a.createElement(fe.StI.Header,{className:(0,q.cn)("items-start gap-sm p-sm active:shadow-none",r&&"hover:bg-background-brand-subtle")},a.createElement(fe.StI.Radio,null),a.createElement(fe.StI.HeaderText,{className:"gap-3xs"},a.createElement(fe.StI.Label,null,n),a.createElement(fe.StI.Description,{className:"text-xs text-content-secondary"},l))))};var vVe=n(38053),fVe=n(58570);const EVe=e=>{let t=e.intervals;const n=Math.max(...t.flatMap((e=>"charged"===e.kind?[e.amount]:[])),1),l=96/Math.max(t.length,fVe.T9);return a.createElement(vVe.B,{"data-external-id":"amount-history-sparkline",delay:fVe.uQ,closeDelay:0},a.createElement("div",{"data-testid":"amount-history-sparkline",className:"flex cursor-default items-stretch justify-end border-b border-chart-axis",style:{width:96,height:24},onClick:e=>e.stopPropagation()},t.map((e=>"charged"===e.kind?a.createElement("div",{key:e.anchorDate,"data-testid":"amount-history-sparkline-slot",className:"h-full min-w-0 shrink-0",style:{width:l}},a.createElement(Wi.Y,{content:(0,fVe.Wl)(e),side:"top",delay:fVe.uQ,closeDelay:0},a.createElement("div",{"data-testid":"amount-history-sparkline-charged-month",className:"group/sparkbar relative size-full cursor-default"},a.createElement("div",{className:"absolute bottom-0 left-1/2 shrink-0 -translate-x-1/2 bg-chart-event-border-gray group-hover/sparkbar:bg-content-secondary",style:{width:5,height:"".concat(Math.max(e.amount/n*100,12),"%")}})))):a.createElement("div",{key:e.anchorDate,"data-testid":"amount-history-sparkline-stub",className:"h-full min-w-0 shrink-0",style:{width:l}})))))},yVe=e=>{let t=e.badge,n=e.explanation,l=e.actions,r=e.shouldShowActions,o=void 0===r||r;return a.createElement(fe.k_P.Root,{"data-external-id":"indicator-popover",variant:"panel"},a.createElement(fe.k_P.Trigger,{render:t,hoverOnly:!0,delay:200,nativeButton:!1,onClick:bVe}),a.createElement(fe.k_P.Content,{side:"bottom",align:"start",className:"w-80 max-w-none",onClick:bVe},a.createElement(fe.k_P.Description,{className:"text-content-primary"},n),o&&l&&l.length>0&&a.createElement("div",{className:"-mx-default -mb-default flex gap-xs border-t border-t-divider-secondary px-default py-sm"},l.map((e=>a.createElement(fe.XZZ,{key:e.label,size:"xs",variant:"default",disabled:e.disabled,onClick:e.onClick},e.label))))))},bVe=e=>e.stopPropagation();var xVe=n(27091),wVe=n(12241);const CVe={weekly:"wk",monthly:"mo",yearly:"yr"},AVe=["Zero","One","Two","Three","Four","Five","Six","Seven","Eight","Nine","Ten"],IVe=new Set(["yearly","semiyearly"]),kVe=(e,t,n)=>{var a,l;const r=new Map;for(const o of e){const e=t(o);r.set(e,(null!==(a=r.get(e))&&void 0!==a?a:0)+1)}let i=t(n),s=null!==(l=r.get(i))&&void 0!==l?l:0;for(const d of r){var c=(0,o.A)(d,2);const e=c[0],t=c[1];t>s&&(i=e,s=t)}return i},SVe=(e,t,n,a)=>{const l=((e,t,n)=>{const a=Math.min(e,t),l=Math.max(e,t);return{within:l-a,wrap:n-l+a}})(e,t,a),r=l.within,o=l.wrap;return Math.min(r,o)>4?n:o<r?Math.max(e,t):Math.min(e,t)},NVe=(e,t)=>{var n;if((e=>(0,xVe.Qm)(e).detectionDays<xVe.br.monthly.detectionDays)(e))return"";const a=t.map((e=>N.c9.fromISO(e.date))).filter((e=>e.isValid)),l=(0,wVe.O1)(t);if(!l||0===a.length)return"";const r=N.c9.fromISO(l);
1if(!r.isValid)return"";if(IVe.has(e)){const e=kVe(a,(e=>e.toFormat("LL-dd")),r),t=null!==(n=a.find((t=>t.toFormat("LL-dd")===e)))&&void 0!==n?n:r;return"on ".concat(t.toFormat("LLL d"))}const o=((e,t)=>{var n;const a=kVe(e,(e=>e.day),t),l=e.map((e=>e.day)),r=[...new Set(l)];if(2!==r.length)return a;const o=r[0],i=r[1];if(l.filter((e=>e===o)).length!==l.filter((e=>e===i)).length)return a;const s=Math.max(o,i),c=null!==(n=e.find((e=>e.day===s)))&&void 0!==n?n:t;return SVe(o,i,t.day,c.daysInMonth)})(a,r);return"on the ".concat(o).concat((0,Ba.Ny)(o))},TVe=(e,t)=>{const n=(e=>{var t;return null!==(t=AVe[e])&&void 0!==t?t:String(e)})(e.length),a=(0,De.td)(yr.cs[t],e.length),l=e.map((e=>{let t=e.amount;return(0,De.Ym)(Math.abs(t))})),r=Math.min(...l),o=Math.max(...l);if(r===o)return"".concat(n," ").concat((0,jt.vv)(r)," ").concat(a);if((o-r)/o<=.05){const e=l.reduce(((e,t)=>e+t),0)/l.length;return"".concat(n," ").concat(a," around ").concat((0,jt.T3)(e))}return"".concat(n," ").concat(a," ranging ").concat((0,jt.vv)(r)," to ").concat((0,jt.vv)(o))},_Ve=e=>{let t=e.sectionKind,n=e.merchantName,a=e.accountName,l=e.frequency,r=e.frequencyDescription,o=e.createdAt,i=e.transactions;const s=r.toLowerCase(),c=NVe(l,i),d=c?"".concat(s," ").concat(c):s,u=(e=>{var t;if(!e)return"";const n=N.c9.fromISO(e,{zone:"utc"}).toUTC();return n.isValid?" Detected ".concat((0,wVe.Yq)(null!==(t=n.toISODate())&&void 0!==t?t:e),"."):""})(o),m=[n&&"from ".concat(n),a&&"on ".concat(a)].filter(Boolean).join(" "),p=e=>m?"".concat(e," ").concat(m):e;if(0===i.length){const e="No ".concat((0,De.td)(yr.cs[t],0)," yet");return"".concat(p(e)," \u2014 expected ").concat(d,".").concat(u)}const g=TVe(i,t);return"".concat(p(g)," \u2014 looks like it repeats ").concat(d,".").concat(u)},DVe={[Ee.kjN.EXPENSE]:"If the charge is over, mark it inactive.",[Ee.kjN.INCOME]:"If the deposits have stopped, mark it inactive.",[Ee.kjN.TRANSFER]:"If the transfers have stopped, mark it inactive.",[Ee.kjN.CREDIT_CARD]:"If the payments have stopped, mark it inactive."},RVe=e=>{let t=e.sectionKind,n=e.overdueSince;const a=yr.cs[t],l=n?(0,wVe.qn)(n,"today"):void 0,r=n&&l?"Expected ".concat((0,wVe.Yq)(n)," \u2014 ").concat(l,", and no matching ").concat(a," has posted."):"No matching ".concat(a," has posted.");return"".concat(r," ").concat(DVe[t])},MVe="Inactive?",LVe=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:N.c9.local();if(!e)return"Inactive";const n=N.c9.fromISO(e,{zone:"utc"}).toUTC();return n.isValid?"Inactive since ".concat(n.toFormat(n.year===t.year?"LLL":"LLL yyyy")):"Inactive"},OVe=(e,t)=>{const n=(0,wVe.O1)(e);return n?"Marked inactive after its ".concat((0,wVe.Yq)(n)," ").concat(yr.cs[t],"."):"Marked inactive."},PVe=e=>{let t=e.sectionKind,n=e.transactions;return"".concat(OVe(n,t)," History is kept and it doesn't count toward your totals \u2014 make it active again and we'll start expecting the ").concat(yr.cs[t],".")},BVe="Mark inactive",zVe="Mark still active",FVe=e=>{let t=e.amount,n=e.frequency,a=e.sectionKind,l=e.transactions;const r=(0,wVe.O1)(l),o=r?"No transactions since ".concat((0,wVe.Yq)(r),"."):"We have not seen a transaction for this in a while.";return"".concat(o," Marking it inactive keeps the history and drops ").concat(((e,t)=>{const n=CVe[t],a=(0,jt.vv)(Math.abs(e));return n?"".concat(a,"/").concat(n):a})(t,n)," from ").concat(yr.Tq[a],".")},GVe=6*iC.K5,YVe=()=>{const e=(0,i.n)(aYe.mw,{refetchQueries:aYe.Y$}),t=(0,o.A)(e,1)[0],n=(0,C.RU)(),l=(0,a.useCallback)((e=>{let n=e.id,a=e.isActive;return t({variables:{input:{recurrenceGroupId:n,isActive:a}}})}),[t]);return(0,a.useCallback)((async e=>{let t=e.id,a=e.name,r=e.sectionKind,o=e.isActive,i=e.skipUndo;try{await l({id:t,isActive:o})}catch(s){return n({description:o?"We couldn't reactivate this group. Please try again.":"We couldn't mark this group inactive. Please try again."}),!1}return(0,C.oR)({title:o?"".concat(a," marked as an active ").concat(yr.rB[r].toLowerCase()):"".concat(a," marked inactive"),description:o?void 0:"History kept. It won't count toward your totals.",duration:GVe,actions:i?void 0:[{text:"Undo",onClick:()=>{l({id:t,isActive:!o}).catch((()=>{n({description:"We couldn't undo that. Please try again."})}))}}]}),!0}),[l,n])},UVe=e=>{let t=e.id,n=e.name,l=e.sectionKind,r=e.endedAt,o=e.transactions,i=e.shouldShowActions,s=void 0===i||i;const c=YVe();return a.createElement(yVe,{"data-external-id":"inactive-indicator",shouldShowActions:s,badge:a.createElement(fe.CQG,{size:"sm",rounded:"pill",color:"gray-secondary",variant:"subtle",className:"shrink-0"},LVe(r)),explanation:PVe({sectionKind:l,transactions:o}),actions:[{label:"Make active",onClick:()=>{c({id:t,name:n,sectionKind:l,isActive:!0})}}]})},VVe=(0,Qt.J)("\n  mutation Common_ApproveRecurrenceGroup($input: ApproveRecurrenceGroupInput!) {\n    approveRecurrenceGroup(input: $input) {\n      success\n      changed\n    }\n  }\n"),WVe=6*iC.K5,jVe=iVe.p.NEW_BADGE,HVe=["Common_RecurrenceGroups","Common_AggregatedRecurrenceGroups","Common_RecurrenceGroupDetail"],KVe=()=>{const e=(e=>{const t=(0,i.n)(VVe,e),n=(0,o.A)(t,2),a=n[0],l=n[1];return[(0,v.D)((e=>a({variables:{input:{recurrenceGroupId:e}}}))),l]})({refetchQueries:HVe}),t=(0,o.A)(e,2),n=t[0],l=t[1].loading,r=(0,C.RU)(),s=(0,a.useRef)(!1);return{approveRecurrenceGroup:(0,a.useCallback)((async e=>{let t=e.id,a=e.name;if(s.current)return!1;s.current=!0;try{var l;const e=null===(l=(await n(t)).data)||void 0===l?void 0:l.approveRecurrenceGroup;return null!==e&&void 0!==e&&e.success?(e.changed&&(0,C.oR)({title:jVe.TOAST.CONFIRMED(a),duration:WVe}),!0):(r({description:jVe.TOAST.ERROR}),!1)}catch(o){return r({description:jVe.TOAST.ERROR}),!1}finally{s.current=!1}}),[n,r]),isApproving:l}},qVe=(0,a.createContext)((()=>{})),$Ve=["shouldShowActions"],ZVe=e=>{let t=e.shouldShowActions,n=void 0===t||t,l=(0,En.A)(e,$Ve);const r=(e=>{const t=(0,a.useContext)(qVe),n=(0,a.useCallback)((()=>t(e)),[t,e]);return(0,iq.$)(n)})(l.id);return a.createElement("div",{"data-external-id":"new-indicator",ref:r,className:"flex min-w-0"},n?a.createElement(XVe,l):a.createElement(JVe,l))},JVe=e=>a.createElement(yVe,{"data-external-id":"new-hover-preview",shouldShowActions:!1,badge:QVe(),explanation:eWe(e)}),XVe=e=>{var t;const n=KVe(),l=n.approveRecurrenceGroup,r=n.isApproving,o=DWe({id:e.id,name:e.name,sectionKind:e.sectionKind,isActive:e.isActive,merchantId:e.merchantId,merchantName:null!==(t=e.merchantName)&&void 0!==t?t:null}),i=o.openNotRecurring,s=o.dialogs;return a.createElement(a.Fragment,null,a.createElement(yVe,{badge:QVe(),explanation:eWe(e),actions:[{label:iVe.p.NEW_BADGE.LOOKS_RIGHT,disabled:r,onClick:()=>{l({id:e.id,name:e.name})}},{label:iVe.p.NOT_RECURRING_MODAL.MENU_ITEM,onClick:i}]}),s)},QVe=()=>a.createElement(fe.CQG,{size:"sm",rounded:"pill",color:"blue",className:"shrink-0"},"New"),eWe=e=>{let t=e.sectionKind,n=e.merchantName,a=e.accountName,l=e.frequency,r=e.frequencyDescription,o=e.createdAt,i=e.transactions;return _Ve({sectionKind:t,merchantName:null!==n&&void 0!==n?n:null,accountName:null!==a&&void 0!==a?a:null,frequency:l,frequencyDescription:r,createdAt:o,transactions:i})},tWe=e=>{let t=e.id,n=e.name,l=e.sectionKind,r=e.overdueSince,o=e.shouldShowActions,i=void 0===o||o;const s=YVe();return a.createElement(yVe,{"data-external-id":"overdue-indicator",shouldShowActions:i,badge:a.createElement(fe.CQG,{size:"sm",rounded:"pill",color:"brand",className:"shrink-0"},wVe.oV[Ee.G8P.OVERDUE]),explanation:RVe({sectionKind:l,overdueSince:r}),actions:[{label:"Mark inactive",onClick:()=>{s({id:t,name:n,sectionKind:l,isActive:!1})}}]})},nWe=e=>{let t=e.id,n=e.name,l=e.amount,r=e.frequency,o=e.sectionKind,i=e.transactions,s=e.shouldShowActions,c=void 0===s||s;const d=YVe();return a.createElement(yVe,{"data-external-id":"possibly-inactive-indicator",shouldShowActions:c,badge:a.createElement(fe.CQG,{size:"sm",rounded:"pill",color:"yellow",className:"shrink-0"},MVe),explanation:FVe({amount:l,frequency:r,sectionKind:o,transactions:i}),actions:[{label:BVe,onClick:()=>{d({id:t,name:n,sectionKind:o,isActive:!1})}},{label:zVe,onClick:()=>{d({id:t,name:n,sectionKind:o,isActive:!0,skipUndo:!0})}}]})},aWe=e=>{let t=e.enabled,n=e.surface,a=e.isCurrentMonth;return!!t&&("list"!==n||void 0!==a&&a)},lWe=Object.freeze({isNew:!1,isPossiblyInactive:!1,isOverdue:!1}),rWe=e=>{let t=e.group,n=e.surface,a=e.isCurrentMonth;if(!t.isActive)return lWe;const l=e=>aWe({enabled:e,surface:n,isCurrentMonth:a});return{isNew:l(t.isNew),isPossiblyInactive:l(t.status===Ee.G8P.POSSIBLY_INACTIVE),isOverdue:l(t.
1status===Ee.G8P.OVERDUE)}},oWe=e=>{let t=e.id,n=e.name,l=e.status,r=e.isNew,o=e.createdAt,i=e.isActive,s=e.endedAt,c=e.merchantId,d=e.merchantName,u=e.accountName,m=e.amount,p=e.frequency,g=e.frequencyDescription,h=e.sectionKind,v=e.transactions,f=e.overdueSince,E=e.isCurrentMonth,y=e.alertSurface,b=void 0===y?"list":y,x=e.shouldShowActions,w=void 0===x||x;if(!i)return a.createElement(UVe,{"data-external-id":"row-indicator",id:t,name:n,sectionKind:h,endedAt:s,transactions:v,shouldShowActions:w});const C=rWe({group:{isNew:r,isActive:i,status:l},surface:b,isCurrentMonth:E}),A=C.isNew,I=C.isPossiblyInactive,k=C.isOverdue;return A||I||k?a.createElement("div",{"data-external-id":"row-indicator",className:"flex items-center gap-1.5"},A&&a.createElement(ZVe,{id:t,name:n,sectionKind:h,isActive:i,merchantId:null!==c&&void 0!==c?c:null,merchantName:d,accountName:u,frequency:p,frequencyDescription:g,createdAt:o,transactions:v,shouldShowActions:w}),k&&a.createElement(tWe,{id:t,name:n,sectionKind:h,overdueSince:f,shouldShowActions:w}),I&&a.createElement(nWe,{id:t,name:n,amount:m,frequency:p,sectionKind:h,transactions:v,shouldShowActions:w})):null},iWe=(0,a.createContext)(null),sWe=()=>{const e=(0,a.useContext)(iWe);if(!e)throw new Error("useRecurrenceGroupSelection must be used within a RecurrenceGroupSelectionContext provider");return e},cWe=()=>(0,a.useContext)(iWe);var dWe=n(69565),uWe=n(53296),mWe=n(61178),pWe=n(95941);const gWe={no_fitting_frequency:"The transactions in this group have an incompatible frequency",no_transactions:"No transactions in this group",not_enough_groups:"Cannot merge with less than 2 groups",opposite_signs:"Cannot merge expense and income groups",different_merchant:"Cannot merge groups from different merchants"},hWe=e=>{let t=e.open,n=e.onClose,l=e.onMerged,r=e.baseGroup,o=e.allMerchantGroups,i=e.loadError,s=void 0!==i&&i;return a.createElement("div",{"data-external-id":"merge-recurring-groups-modal",className:"contents",onClick:e=>e.stopPropagation(),onKeyDown:e=>e.stopPropagation()},a.createElement(fe.hg1.Root,{open:t,onOpenChange:e=>!e&&n(),size:"4xl"},r?a.createElement(vWe,{open:t,onClose:n,onMerged:l,baseGroup:r,allMerchantGroups:o,loadError:s}):a.createElement(fe.hg1.Content,null,a.createElement(fe.hg1.CloseTrigger,null),a.createElement(fe.hg1.Header,null,a.createElement(fe.hg1.Title,null,"Merge recurring groups")),a.createElement(fe.hg1.Body,{className:"flex min-h-32 items-center justify-center px-xl"},s?a.createElement(SQ.W,{message:"Couldn't load this merchant's recurring groups. Please try again."}):a.createElement(fe.ix7,{"aria-label":"Loading recurring groups"})),a.createElement(fe.hg1.Footer,null,a.createElement(fe.hg1.Close,{render:a.createElement(fe.XZZ,{variant:"default",onClick:n},"Cancel")})))))},vWe=e=>{var t,n,l,r;let s=e.open,c=e.onClose,d=e.onMerged,u=e.baseGroup,m=e.allMerchantGroups,p=e.loadError,g=void 0!==p&&p;const h=(0,C.RU)(),v=cWe(),f=(0,i.n)(aYe.Zb,{refetchQueries:[aYe.BT,aYe.TL,aYe.oq,aYe.JN,aYe.EH]}),E=(0,o.A)(f,2),y=E[0],b=E[1].loading,x=(0,a.useState)((()=>new Set([u.id]))),w=(0,o.A)(x,2),A=w[0],I=w[1],k=(0,a.useState)(u.name),S=(0,o.A)(k,2),N=S[0],T=S[1];(0,a.useEffect)((()=>{s&&(I(new Set([u.id])),T(u.name))}),[s,u.id,u.name]);const _=(0,a.useMemo)((()=>m.filter((e=>e.id!==u.id))),[m,u.id]),D=(0,a.useMemo)((()=>[...A].filter((e=>e!==u.id))),[A,u.id]),R=(0,a.useMemo)((()=>m.filter((e=>A.has(e.id))).flatMap((e=>e.transactions)).sort(((e,t)=>new Date(e.date).getTime()-new Date(t.date).getTime()))),[m,A]),M=(0,a.useMemo)((()=>_.filter((e=>!A.has(e.id))).map((e=>e.id))),[_,A]),L=(0,et.I)(aYe.b,{variables:{input:{baseGroupId:u.id,alreadyMergedGroupIds:D,possibleGroupIdsToMerge:M}},skip:!s,fetchPolicy:"network-only"}),O=L.data,P=L.isNetworkRequestInFlight,B=L.error,z=(0,a.useMemo)((()=>{var e,t;return new Map((null!==(e=null===O||void 0===O||null===(t=O.recurrenceGroupMergeEligibility)||void 0===t?void 0:t.nonMergedGroupEligibilities)&&void 0!==e?e:[]).map((e=>[e.recurrenceGroup.id,e.eligibility])))}),[O]),F=(0,a.useState)(!1),G=(0,o.A)(F,2),Y=G[0],U=G[1],V=(0,a.useMemo)((()=>_.filter((e=>{const t=z.get(e.id);return!A.has(e.id)&&!!t&&!t.isEligible}))),[_,z,A]),W=(0,a.useMemo)((()=>[u,..._.filter((e=>!V.some((t=>
1t.id===e.id))))]),[u,_,V]),j=D.length>0,H=null===O||void 0===O||null===(t=O.recurrenceGroupMergeEligibility)||void 0===t?void 0:t.alreadyMergedEligibility,K=j&&(!!B||!P&&!0===(null===H||void 0===H?void 0:H.isEligible)),q=j&&null!==(n=null===H||void 0===H?void 0:H.mergedGroupFrequency)&&void 0!==n?n:null,$=null!==(l=null===H||void 0===H?void 0:H.mergedLatestAmount)&&void 0!==l?l:null,Z=null!==(r=null===H||void 0===H?void 0:H.isWeakFit)&&void 0!==r&&r,J=(0,a.useCallback)((async()=>{try{var e,t,n;const a=null===(e=(await y({variables:{input:{baseGroupId:u.id,groupIdsToMerge:D,newGroupName:N!==u.name?N:null}}})).data)||void 0===e||null===(t=e.mergeRecurrenceGroups)||void 0===t||null===(n=t.errors)||void 0===n?void 0:n.message;if(a)h({description:a});else{const e=null!==v&&void 0!==v?v:{},t=e.selectedGroupId,n=e.clearSelection;t&&(D.includes(t)||t===u.id)&&(null===n||void 0===n||n()),c(),null===d||void 0===d||d()}}catch(a){h({description:"Failed to merge groups. Please try again."})}}),[y,u.id,u.name,D,N,h,v,c,d]),X=(0,a.useCallback)((e=>{const t=A.has(e);I((n=>{const a=new Set(n);return t?a.delete(e):a.add(e),a}))}),[A]);return a.createElement(fe.hg1.Content,{"data-external-id":"merge-recurring-groups-content",className:"max-h-[85vh]"},a.createElement(fe.hg1.CloseTrigger,null),a.createElement(fe.hg1.Header,null,a.createElement(fe.hg1.Title,null,"Merge recurring groups")),a.createElement(fe.hg1.Body,{className:"flex flex-1 flex-col gap-default p-0"},a.createElement("div",{className:"px-xl"},a.createElement("div",{className:"pt-default pb-xs"},a.createElement(fe.c8D,{size:"sm",color:"secondary"},"Choose one or more recurring groups to merge:")),g&&a.createElement(SQ.W,{message:"Couldn't load all of this merchant's recurring groups. Some may be missing."}),B&&a.createElement(SQ.W,{message:"Couldn't load merge eligibility. You can still attempt to merge."}),a.createElement("div",{className:"flex flex-col overflow-hidden rounded-default border border-divider-secondary"},W.map((e=>{const t=e.id===u.id,n=A.has(e.id);return a.createElement(fWe,{key:e.id,group:e,isBase:t,isSelected:n,isEligibilityLoading:!B&&P&&!n&&!t,onToggle:X})})),!B&&V.length>0&&a.createElement("button",{type:"button",className:" flex w-full items-center gap-sm rounded-b-default border-x-0 border-t border-b-0 border-solid border-t-divider-primary bg-background-primary px-default py-sm text-left hover:bg-background-primary-hover focus-visible:ring-2 focus-visible:ring-input-focus-border focus-visible:outline-none focus-visible:ring-inset ",onClick:()=>U((e=>!e))},Y?a.createElement(mWe.MdsEyeOffIcon,{size:"sm",className:"shrink-0 text-content-secondary"}):a.createElement(uWe.MdsEyeIcon,{size:"sm",className:"shrink-0 text-content-secondary"}),a.createElement(fe.c8D,{size:"sm",color:"secondary"},Y?"Hide":"Show"," ",V.length," ineligible recurring group",1!==V.length?"s":"")),!B&&Y&&V.map((e=>{var t,n;const l=null!==(t=null===(n=z.get(e.id))||void 0===n?void 0:n.mergeIneligibilityReason)&&void 0!==t?t:null;return a.createElement(fWe,{key:e.id,group:e,ineligibilityReason:l})})))),a.createElement("div",{className:"flex flex-col gap-sm px-xl pb-default"},a.createElement(fe.c8D,{size:"sm",weight:"medium"},"Result"),a.createElement("div",{className:" flex min-h-14 items-center gap-sm rounded-default border border-divider-secondary px-xl py-sm "},j?a.createElement(a.Fragment,null,a.createElement("div",{className:"size-5 shrink-0"}),a.createElement(fe.a6p,{src:u.logoUrl,name:N,size:"md",className:"shrink-0"}),a.createElement("div",{className:"flex min-w-0 flex-1 flex-col gap-2xs"},a.createElement(xA.D,{value:N,onChange:e=>T(e.target.value),"aria-label":"Merged group name",className:"h-7 text-sm"}),q&&a.createElement(fe.c8D,{size:"sm",color:"secondary",className:"pl-sm"},(0,pWe.H)(q))),a.createElement(EWe,{transactions:R,intervals:(0,fVe.x1)(R,null!==q&&void 0!==q?q:u.frequency),amount:null!==$&&void 0!==$?$:u.amount})):a.createElement(fe.c8D,{size:"sm",color:"secondary"},"Select another group to merge into ",u.name)),j&&Z&&a.createElement("div",{className:"flex items-start gap-sm rounded-default bg-background-warning px-default py-sm"},a.createElement(dWe.MdsAlertTriangleFilledIcon,{size:"sm",className:"mt-0.5 shrink-0 text-content-warning"}),a.createElement(fe.c8D,{size:"sm",color:"warning"},"These groups have a weak frequency match \u2014 transactions may not align perfectly after merging.")))),a.createElement(fe.hg1.Footer,null,a.createElement(fe.hg1.Close,{render:a.createElement(fe.XZZ,{variant:"default",onClick:c},"Cancel")}),a.createElement(fe.XZZ,{variant:"primary",disabled:!K,isLoading:b,onClick:J},"Merge")))},fWe=e=>{let t=e.group,n=e.ineligibilityReason,l=e.isBase,o=void 0!==l&&l,i=e.isSelected,s=void 0!==i&&i,c=e.isEligibilityLoading,d=void 0!==c&&c,u=e.onToggle;const m=void 0!==n,p=(0,r.YW)({isIneligible:m,isEligibilityLoading:d}).with({isIneligible:!0},(()=>a.createElement(dWe.MdsAlertTriangleFilledIcon,{size:"lg",className:"shrink-0 text-content-warning"}))).with({isEligibilityLoading:!0},(()=>a.createElement("div",{className:"flex size-4 items-center justify-center"},a.createElement(fe.ix7,{size:"xs"})))).otherwise((()=>a.createElement(fe.Ko1.Root,{checked:s,disabled:o,onCheckedChange:()=>!o&&(null===u||void 0===u?void 0:u(t.id)),onClick:e=>e.stopPropagation(),"aria-label":"Select ".concat(t.name),className:o?"cursor-default":void 0},a.createElement(fe.Ko1.Indicator,null))));return a.createElement("div",{"data-external-id":"group-row",className:(0,q.cn)("flex items-center gap-sm border-t border-t-divider-primary px-xl py-sm first:border-t-0",m?"opacity-60":"cursor-pointer",s&&"bg-background-primary-select"),onClick:m||d?void 0:()=>!o&&(null===u||void 0===u?void 0:u(t.id))},p,a.createElement(fe.a6p,{src:t.logoUrl,name:t.name,size:"md",className:(0,q.cn)("shrink-0",m&&"grayscale")}
1),a.createElement("div",{className:"flex min-w-0 flex-1 flex-col"},a.createElement("div",{className:"flex min-w-0 items-center gap-1.5"},a.createElement(fe.c8D,{size:"base",weight:"bold",className:"truncate"},t.name),!m&&a.createElement(oWe,{id:t.id,name:t.name,status:t.status,isNew:t.isNew,createdAt:t.createdAt,isActive:t.isActive,endedAt:t.endedAt,merchantId:t.merchantId,merchantName:t.merchantName,accountName:t.accountName,amount:t.amount,frequency:t.frequency,frequencyDescription:t.frequencyDescription,sectionKind:t.sectionKind,transactions:t.transactions,overdueSince:t.overdueSince,isCurrentMonth:!0,shouldShowActions:!1})),m?n&&a.createElement(fe.c8D,{size:"sm",color:"warning"},gWe[n]):a.createElement(fe.c8D,{size:"sm",color:"secondary"},t.frequencyDescription)),a.createElement(EWe,{transactions:t.transactions,intervals:(0,fVe.Mp)(t.historyIntervals),amount:t.amount}))},EWe=e=>{let t=e.transactions,n=e.intervals,l=e.amount;return a.createElement("div",{"data-external-id":"group-meta",className:"flex shrink-0 items-center gap-sm"},a.createElement(EVe,{intervals:n}),a.createElement(fe.c8D,{size:"sm",color:"secondary",className:"shrink-0"},t.length," transaction",1!==t.length?"s":""),a.createElement(fe.c8D,{size:"base",weight:"medium",className:"w-16 text-right whitespace-nowrap"},a.createElement(fe.PED,{value:Math.abs(l),style:"currency"})))},yWe=(0,a.createContext)(null),bWe=yWe.Provider,xWe=e=>{let t=e.open;const n=(0,a.useContext)(yWe),l=t&&null!==n,r=(0,a.useState)(!1),i=(0,o.A)(r,2),s=i[0],c=i[1],d=(0,a.useRef)(null);return(0,a.useEffect)((()=>{var e,t,n;if(l)return void c(!0);const a=null!==(e=null===(t=d.current)||void 0===t||null===(n=t.getAnimations)||void 0===n?void 0:n.call(t))&&void 0!==e?e:[];if(0===a.length)return void c(!1);let r=!1;return Promise.all(a.map((e=>e.finished))).then((()=>!r&&c(!1)),(()=>{})),()=>{r=!0}}),[l]),n&&(l||s)?(0,R.createPortal)(a.createElement("div",{ref:d,"aria-hidden":!0,"data-testid":"recurring-stacked-dialog-scrim",className:(0,q.cn)("pointer-events-none fixed inset-0 bg-background-modal-overlay",l?"animate-in fade-in-0":"animate-out fade-out-0 fill-mode-forwards")}),n):null},wWe=e=>{var t,n,a,l,r,o,i,s,c,d,u,m,p,g,h,v,f,E,y,b,x,w,C,A,I,k,S,N;return{id:e.id,name:null!==(a=null!==(t=e.name)&&void 0!==t?t:null===(n=e.merchant)||void 0===n?void 0:n.name)&&void 0!==a?a:"",merchantName:null!==(r=null===(l=e.merchant)||void 0===l?void 0:l.name)&&void 0!==r?r:null,merchantId:null!==(i=null===(o=e.merchant)||void 0===o?void 0:o.id)&&void 0!==i?i:null,merchantLogoUrl:null!==(c=null===(s=e.merchant)||void 0===s?void 0:s.logoUrl)&&void 0!==c?c:null,logoUrl:null!==(d=e.logoUrl)&&void 0!==d?d:null,sectionKind:null!==(u=e.recurringType)&&void 0!==u?u:Ee.kjN.EXPENSE,frequencyDescription:(0,pWe.H)(e.frequency),frequency:e.frequency,amount:null!==(m=e.amount)&&void 0!==m?m:0,isApproximate:e.isApproximate,isNew:e.isNew,createdAt:e.createdAt,isActive:e.isActive,endedAt:null!==(p=e.endedAt)&&void 0!==p?p:null,lastDate:null,lastDateIsPaid:null,nextDate:null!==(h=null===(g=e.nextForecastedTransaction)||void 0===g?void 0:g.date)&&void 0!==h?h:null,category:e.category?{name:e.category.name,icon:e.category.icon}:null,categoryId:null!==(f=null===(v=e.category)||void 0===v?void 0:v.id)&&void 0!==f?f:null,accountName:null!==(y=null===(E=e.account)||void 0===E?void 0:E.displayName)&&void 0!==y?y:null,accountLogoUrl:null!==(x=null===(b=e.account)||void 0===b?void 0:b.logoUrl)&&void 0!==x?x:null,accountIcon:null!==(C=null===(w=e.account)||void 0===w?void 0:w.icon)&&void 0!==C?C:null,accountId:null!==(I=null===(A=e.account)||void 0===A?void 0:A.id)&&void 0!==I?I:null,status:e.status,overdueSince:null!==(k=e.overdueSince)&&void 0!==k?k:null,periodStatus:null,previousAmount:null,periodDate:null,periodOccurrences:[],statement:null!==(S=e.statement)&&void 0!==S?S:null,transactions:e.transactions.map((e=>({id:e.id,date:e.date,amount:e.amount}))),historyIntervals:(null!==(N=e.historyIntervals)&&void 0!==N?N:[]).map((e=>{var t;return{date:e.date,isPaid:e.isPaid,amount:null!==(t=e.amount)&&void 0!==t?t:null,transactions:e.transactions.map((e=>({id:e.id,date:e.date,amount:e.amount})))}}))}},CWe=e=>{let t=e.enabled,n=void 0===t||t,l=e.timeWindow,r=e.filters,o=e.includeHistory,i=void 0!==o&&o,s=e.includeOccurrences,c=void 0!==s&&s;const d=(0,et.I)(aYe.BT,{variables:{includeInactive:Ur.tQ,startDate:null===l||void 0===l?void 0:l.currentStartDate.toISODate(),endDate:null===l||void 0===l?void 0:l.endDate.toISODate(),filters:(0,Ur.gm)(null!==r&&void 0!==r?r:{}),includeHistory:i,includeOccurrences:c},fetchPolicy:"cache-and-network",skip:!n}
1),u=d.data,m=d.isNetworkRequestInFlight,p=d.isDataAvailable,g=d.error,h=d.refetch,v=void 0!==l,f=(0,a.useMemo)((()=>{var e;return(null!==(e=null===u||void 0===u?void 0:u.recurrenceGroupsForPeriod)&&void 0!==e?e:[]).map((e=>{var t,n,a,l,r,o,i,s,c,d,u,m,p,g,h,f,E;const y=wWe(e.recurrenceGroup);return(0,U.A)((0,U.A)({},y),{},{lastDate:null!==(t=e.lastDate)&&void 0!==t?t:null,lastDateIsPaid:null!==(n=e.lastDateIsPaid)&&void 0!==n?n:null,nextDate:v?y.nextDate:null!==(a=e.nextDate)&&void 0!==a?a:null,periodStatus:e.status,periodDate:null!==(l=e.date)&&void 0!==l?l:null,periodOccurrences:(null!==(r=e.occurrences)&&void 0!==r?r:[]).map((e=>{var t,n,a,l,r,o,i,s,c,d,u,m,p,g;return{transactionId:null!==(n=null===(t=e.transaction)||void 0===t?void 0:t.id)&&void 0!==n?n:null,date:e.date,status:e.status,amount:e.amount,accountName:null!==(l=null===(a=e.account)||void 0===a?void 0:a.displayName)&&void 0!==l?l:null,accountLogoUrl:null!==(o=null===(r=e.account)||void 0===r?void 0:r.logoUrl)&&void 0!==o?o:null,accountIcon:null!==(s=null===(i=e.account)||void 0===i?void 0:i.icon)&&void 0!==s?s:null,accountId:null!==(d=null===(c=e.account)||void 0===c?void 0:c.id)&&void 0!==d?d:null,category:e.category?{name:e.category.name,icon:e.category.icon}:null,categoryId:null!==(m=null===(u=e.category)||void 0===u?void 0:u.id)&&void 0!==m?m:null,statement:null!==(g=null===(p=e.transaction)||void 0===p?void 0:p.dataProviderDescription)&&void 0!==g?g:null}})),amount:null!==(o=e.amount)&&void 0!==o?o:0,previousAmount:null!==(i=e.previousAmount)&&void 0!==i?i:null,category:e.category?{name:e.category.name,icon:e.category.icon}:null,categoryId:null!==(c=null===(s=e.category)||void 0===s?void 0:s.id)&&void 0!==c?c:null,accountName:null!==(u=null===(d=e.account)||void 0===d?void 0:d.displayName)&&void 0!==u?u:null,accountLogoUrl:null!==(p=null===(m=e.account)||void 0===m?void 0:m.logoUrl)&&void 0!==p?p:null,accountIcon:null!==(h=null===(g=e.account)||void 0===g?void 0:g.icon)&&void 0!==h?h:null,accountId:null!==(E=null===(f=e.account)||void 0===f?void 0:f.id)&&void 0!==E?E:null})}))}),[u,v]);return{recurrenceGroups:f,isLoading:m&&!p,isResultAvailable:p||void 0!==g,error:0===f.length&&null!==g&&void 0!==g?g:null,refetch:()=>{h()}}};var AWe=n(4689);const IWe=(0,a.createContext)(null),kWe=e=>{let t=e.enabled,n=void 0===t||t,l=e.timeWindow,r=e.filters,o=e.children;const i=CWe((0,U.A)({enabled:n,timeWindow:l,filters:r},AWe.F));return a.createElement(IWe.Provider,{"data-external-id":"recurrence-groups-provider",value:i},o)},SWe=()=>(0,a.useContext)(IWe),NWe=(0,Qt.J)("\n  mutation Common_MarkRecurrenceGroupNotRecurring($input: MarkRecurrenceGroupNotRecurringInput!) {\n    markRecurrenceGroupNotRecurring(input: $input) {\n      success\n    }\n  }\n"),TWe=["Common_RecurrenceGroups","Common_AggregatedRecurrenceGroups","Common_RecurrenceGroupFilterMerchants","Common_RecurrenceGroupMerchantSiblingCount"],_We=e=>{var t;let n=e.id,a=e.name,l=e.merchantId,r=e.merchantName,s=e.sectionKind;const c=(0,V.m)(),d=(e=>{const t=(0,i.n)(NWe,e),n=(0,o.A)(t,2),a=n[0],l=n[1];return[(0,v.D)((e=>a({variables:{input:{recurrenceGroupId:e}}}))),l]})(),u=(0,o.A)(d,1)[0],m=(0,i.n)(aYe.yk),p=(0,o.A)(m,1)[0],g=YVe(),h=cWe(),f=(null!==(t=SWe())&&void 0!==t?t:{}).recurrenceGroups,E=void 0===f?[]:f,y=(0,C.RU)();return(0,v.D)((async e=>{const t=((e,t)=>{let n=t.id,a=t.merchantId;return"merge"===e.reason?"merge":"no_longer"===e.reason?[{action:"markInactive",id:n}]:"never"===e.reason&&e.deleteSiblings&&a?[{action:"ignoreMerchant",merchantId:a,deleteExistingGroups:!0}]:[{action:"mark",id:n},..."never"===e.reason&&e.disableDetection&&a?[{action:"ignoreMerchant",merchantId:a,deleteExistingGroups:!1}]:[]]})(e,{id:n,merchantId:l});if("merge"===t)return"merge";let o=0,i=!1;try{for(const e of t){if("markInactive"===e.action){return await g({id:e.id,name:a,sectionKind:s,isActive:!1})?"done":"error"}if("ignoreMerchant"===e.action){var d,m,v,f,b;const t=await p({variables:{input:(0,U.A)({merchantId:e.merchantId,ignored:!0},e.deleteExistingGroups?{deleteExistingGroups:!0}:{})}}),n=null===(d=t.data)||void 0===d||null===(m=d.updateMerchantRecurrenceDetection)||void 0===m?void 0:m.errors;var x;if(n)return y({description:null!==(x=n.message)&&void 0!==x?x:dVe(i)}),"error";o=null!==(v=null===(f=t.data)||void 0===f||null===(b=f.updateMerchantRecurrenceDetection)||void 0===b?void 0:b.deletedGroupCount)&&void 0!==v?v:0}if("mark"===e.action){var w,A;if(null===(w=(await u(e.id)).data)||void 0===w||null===(A=w.markRecurrenceGroupNotRecurring)||void 0===A||!A.success)return y({description:dVe(i)}),"error";i=!0}}}catch(_){return y({description:dVe(i)}),"error"}const I=null!==h&&void 0!==h?h:{},k=I.selectedGroupId,S=I.clearSelection,N=E.find((e=>e.id===k));(e=>{let t=e.selectedGroupId,n=e.currentGroupId,a=e.currentMerchantId,l=e.deleteSiblings,r=e.selectedMerchantId;return!!t&&(t===n||!!l&&(void 0===r||!(0,BY.A)(a)&&r===a))})({selectedGroupId:k,currentGroupId:n,currentMerchantId:l,deleteSiblings:"never"===e.reason&&e.deleteSiblings,selectedMerchantId:null===N||void 0===N?void 0:N.merchantId})&&(null===S||void 0===S||S());try{await c.refetchQueries({include:TWe})}catch(D){}const T=((e,t)=>{let n=t.name,a=t.merchantName,l=t.deletedGroupCount;return"merge"===e.reason||"no_longer"===e.reason?null:"never"===e.reason&&e.deleteSiblings?{title:sVe.TOAST.REMOVED_GROUPS(Math.max(l,1)),description:a?sVe.TOAST.DET
1ECTION_OFF(a):void 0}:"never"===e.reason&&e.disableDetection?{title:sVe.TOAST.REMOVED(n),description:a?sVe.TOAST.DETECTION_OFF(a):sVe.TOAST.FEEDBACK_SENT}:{title:sVe.TOAST.REMOVED(n),description:sVe.TOAST.FEEDBACK_SENT}})(e,{name:a,merchantName:r,deletedGroupCount:o});return T&&(0,C.oR)({title:T.title,description:T.description}),"done"}))},DWe=e=>{var t,n;let l=e.id,r=e.name,i=e.sectionKind,s=e.isActive,c=e.merchantId,d=e.merchantName,u=e.onCommitted;const m=(0,a.useState)(!1),p=(0,o.A)(m,2),g=p[0],h=p[1],v=(0,a.useState)(!1),f=(0,o.A)(v,2),E=f[0],y=f[1],b=((e,t,n)=>{var l;let r=n.loadCandidates;const o=(null!==(l=SWe())&&void 0!==l?l:{}).recurrenceGroups,i=void 0===o?[]:o,s=(0,et.I)(aYe.JN,{variables:{includeInactive:Ur.tQ},skip:!t}).data,c=(0,a.useMemo)((()=>i.filter((e=>e.merchantId===t&&e.isActive))),[i,t]),d=(0,a.useMemo)((()=>{if(!t)return!1;const n=s?s.recurrenceGroupsForPeriod.map((e=>e.recurrenceGroup)).filter((e=>{var n;return(null===(n=e.merchant)||void 0===n?void 0:n.id)===t&&e.isActive})).map((e=>e.id)):null,a=n?[...new Set([...n,...c.map((e=>e.id))])]:c.map((e=>e.id));return a.length>=2&&a.includes(e)}),[s,c,t,e]),u=(0,et.I)(aYe.EH,{variables:(0,U.A)({merchantId:null!==t&&void 0!==t?t:""},AWe.v),skip:!r||!d||!t,fetchPolicy:"cache-and-network"}),m=u.data,p=u.error,g=u.isNetworkRequestInFlight,h=(0,a.useMemo)((()=>{var e;return null!==(e=null===m||void 0===m?void 0:m.recurrenceGroupsForPeriod.map((e=>wWe(e.recurrenceGroup))))&&void 0!==e?e:null}),[m]),v=(0,a.useMemo)((()=>(e=>{var t;let n=e.candidates,a=e.listGroups,l=e.baseGroupId,r=e.requestInFlight,o=e.requestFailed;return null!==(t=null===n||void 0===n?void 0:n.some((e=>e.id===l)))&&void 0!==t&&t&&n?{groups:n,settledWithoutBase:!1}:r||o||!n?{groups:a,settledWithoutBase:!1}:{groups:[],settledWithoutBase:!0}})({candidates:h,listGroups:c,baseGroupId:e,requestInFlight:g,requestFailed:!!p})),[h,c,e,g,p]),f=v.groups,E=v.settledWithoutBase,y=(0,a.useMemo)((()=>{if(!d)return null;const t=f.find((t=>t.id===e));return t?{baseGroup:t,allMerchantGroups:f}:null}),[d,f,e]);return{canMerge:d,target:y,loadError:!!p||E}})(l,c,{loadCandidates:E}),x=b.canMerge,w=b.target,C=b.loadError,A=(0,et.I)(aYe.JN,{variables:{includeInactive:Ur.tQ},skip:!g||!c}).data,I=c?null!==d&&void 0!==d?d:r:null,k=(0,a.useMemo)((()=>c&&A?((e,t)=>(0,BY.A)(t)?0:Math.max(0,(0,oVe.li)(e,t)-1))(A.recurrenceGroupsForPeriod,c):0),[A,c]),S=_We({id:l,name:r,merchantId:c,merchantName:I,sectionKind:i});return{openNotRecurring:()=>h(!0),openMerge:x?()=>y(!0):void 0,canMerge:x,dialogs:a.createElement(a.Fragment,null,a.createElement(xWe,{open:g||E}),a.createElement(mVe,{open:g,onClose:()=>h(!1),merchantName:I,groupName:r,sectionKind:i,siblingCount:k,isActive:s,canMerge:x,onConfirm:async e=>{const t=await S(e);"error"!==t&&(h(!1),"merge"===t&&x?y(!0):null===u||void 0===u||u("not_recurring"))}}),x&&a.createElement(hWe,{open:E,onClose:()=>y(!1),onMerged:()=>null===u||void 0===u?void 0:u("merged"),baseGroup:null!==(t=null===w||void 0===w?void 0:w.baseGroup)&&void 0!==t?t:null,allMerchantGroups:null!==(n=null===w||void 0===w?void 0:w.allMerchantGroups)&&void 0!==n?n:[],loadError:C}))}},RWe=iVe.p.NOT_RECURRING_MODAL,MWe=e=>{let t=e.id,n=e.name,l=e.sectionKind,r=e.isActive,o=e.merchantId,i=e.merchantName,s=e.triggerVariant,c=e.triggerSize,d=void 0===c?"xs":c,u=e.onRename,m=e.onEditMerchant,p=e.onDecided;const g=YVe(),h=DWe({id:t,name:n,sectionKind:l,isActive:r,merchantId:o,merchantName:i,onCommitted:p}),v=h.openNotRecurring,f=h.openMerge,E=h.dialogs,y=[...u?[{label:"Rename",onClick:u}]:[],{label:RWe.MENU_ITEM,onClick:v},{label:r?"Mark inactive":"Make active",onClick:()=>{g({id:t,name:n,sectionKind:l,isActive:!r}).then((e=>{e&&(null===p||void 0===p||p(r?"mark_inactive":"still_active"))}))}},...f?[{label:"Merge\u2026",onClick:f}]:[],...o&&m?[{label:"Edit merchant",onClick:()=>m()}]:[]];return a.createElement(a.Fragment,null,a.createElement(fe.u$N,{align:"end",trigger:a.createElement(fe.SO$,{"aria-label":"More options",size:d,variant:s},a.createElement(fe.V_g,null)),items:y}),E)},LWe=[...aYe.Y$,"Common_RecurrenceGroupDetail"],OWe=e=>{let t=e.id,n=e.name,l=e.sectionKind,r=e.isActive,i=e.merchantId,s=e.merchantName,c=e.onClose,d=e.onRename,u=e.onDecided;const m=(e=>{const t=(0,V.m)(),n=(0,Pd.h)(),l=(0,o.A)(n,2),r=l[0],i=l[1],s=i.open,c=i.close,d=(0,a.useRef)(!1),u=(0,a.useCallback)((e=>{t.refetchQueries({include:e})}),[t]),m=(0,a.useCallback)((()=>{d.current=!1,e(),u(aYe.Y$)}),[e,u]),p=(0,a.useCallback)((()=>
1{if(d.current)return d.current=!1,e(),void u(aYe.Y$);u(LWe)}),[e,u]),g=(0,a.useCallback)((()=>{d.current=!0}),[]),h=(0,a.useCallback)((()=>{c(),d.current&&(d.current=!1,e(),u(aYe.Y$))}),[c,e,u]);return{EditMerchantModal:r,handleEditMerchant:(0,a.useCallback)((()=>{d.current=!1,s()}),[s]),handleModalClose:h,handleMerchantUpdated:p,handleMerchantDeleted:m,handleWillDeleteRecurrenceGroups:g}})(c),p=m.EditMerchantModal,g=m.handleEditMerchant,h=m.handleModalClose,v=m.handleMerchantUpdated,f=m.handleMerchantDeleted,E=m.handleWillDeleteRecurrenceGroups;return a.createElement(a.Fragment,null,a.createElement(MWe,{id:t,name:n,sectionKind:l,isActive:r,merchantId:i,merchantName:s,triggerVariant:"overlay",triggerSize:"sm",onRename:d,onEditMerchant:g,onDecided:u}),i&&a.createElement(p,{onClose:h},a.createElement(N7._,{merchantId:i,recurrenceSource:"v2",afterUpdate:v,afterDelete:f,onWillDeleteRecurrenceGroups:E})))};var PWe=n(43018);const BWe=e=>{var t;let n=e.logoUrl,l=e.merchantLogoUrl,r=e.className;const o=(0,PWe.fj)(null!==(t=null!==n&&void 0!==n?n:l)&&void 0!==t?t:void 0);return a.createElement("div",{"data-external-id":"recurrence-group-gradient-backdrop","aria-hidden":!0,className:(0,q.cn)("pointer-events-none absolute inset-x-0 top-0 h-32.5",r),style:{backgroundImage:o}})},zWe=iVe.p.REVIEW_MODAL,FWe={reviewed:{title:zWe.CAUGHT_UP_TITLE,description:zWe.CAUGHT_UP_REVIEWED},nothing:{title:zWe.CAUGHT_UP_TITLE,description:zWe.CAUGHT_UP_NOTHING},filtered:{title:zWe.FILTERED_EMPTY_TITLE,description:zWe.FILTERED_EMPTY}},GWe=(0,a.forwardRef)(((e,t)=>{let n=e.reason,l=e.onDone;return a.createElement(fe.erR,{"data-external-id":"recurring-review-all-caught-up",ref:t,tabIndex:-1,variant:"filtered"===n?"secondary":"success",className:"min-h-0 flex-1 px-xl py-3xl outline-none",title:FWe[n].title,description:FWe[n].description,actions:a.createElement(fe.XZZ,{variant:"primary",size:"sm",onClick:l},zWe.DONE)})}));GWe.displayName="RecurringReviewAllCaughtUp";const YWe=()=>a.createElement(a.Fragment,null,a.createElement(fe.c8D,{weight:"bold",size:"xs",className:"text-content-secondary"},iVe.p.MULTIPLE_GROUPS_TIP.LABEL," "),iVe.p.MULTIPLE_GROUPS_TIP.HINT," ",a.createElement(Vl.W,{to:I.JZ.transactions.receipts.settings(),className:"inline align-baseline"},iVe.p.MULTIPLE_GROUPS_TIP.LEARN_MORE));var UWe,VWe,WWe,jWe=n(71507);const HWe=$d.s.div(UWe||(UWe=(0,wc.A)(["mb-lg rounded-default border border-border-primary bg-background-primary shadow-lg"]))),KWe=$d.s.div(VWe||(VWe=(0,wc.A)(["px-default pt-sm pb-xs"]))),qWe=$d.s.div(WWe||(WWe=(0,wc.A)(["flex items-center gap-2xs border-t border-t-divider-primary px-sm py-xs"]))),$We=["statement","category","account"],ZWe={statement:{label:"Original statement",track:"minmax(0,1.2fr)"},category:{label:"Category",track:"minmax(0,1.05fr)"},account:{label:"Account",track:"minmax(0,1fr)"}},JWe={statement:!1,category:!0,account:!0},XWe=e=>e<=0?"0":1===e?"1":e<=5?"2-5":e<=10?"6-10":e<=29?"11-29":"30+",QWe={looksRight:"looks_right",notRecurring:"not_recurring",markInactive:"mark_inactive",stillActive:"still_active",stillActiveAndApprove:"still_active_and_approve"},eje=(e,t,n)=>(0,Ge.u4)(Ye.aq.ReviewOpened,{entry_point:e,queue_size_bucket:XWe(t),filter:n}),tje=["needs","month","all"],nje=e=>tje.some((t=>t===e)),aje={new:0,[Ee.G8P.POSSIBLY_INACTIVE]:1,[Ee.G8P.OVERDUE]:2},lje=e=>{const t=rWe({group:e,surface:"panel"});return t.isNew?"new":t.isPossiblyInactive?Ee.G8P.POSSIBLY_INACTIVE:t.isOverdue?Ee.G8P.OVERDUE:null},rje=e=>null!==lje(e),oje=function(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:N.c9.local();return(0,r.YW)(t).with("needs",(()=>rje(e))).with("all",(()=>e.isActive)).with("month",(()=>e.isActive&&((e,t)=>{const n=e=>null!==e&&N.c9.fromISO(e).hasSame(t,"month");return n(e.nextDate)||e.transactions.some((e=>{let t=e.date;return n(t)}))||e.historyIntervals.some((e=>{let t=e.date;return n(t)}))})(e,n))).exhaustive()},ije=function(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:N.c9.local();return e.filter((e=>oje(e,t,n))).length},sje=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"needs",n=arguments.length>
12&&void 0!==arguments[2]?arguments[2]:N.c9.local();return e.flatMap((e=>{if(!oje(e,t,n))return[];const a=lje(e);return[{id:e.id,priority:a?aje[a]:3}]})).sort(((e,t)=>e.priority-t.priority)).map((e=>e.id))},cje=e=>{let t=e.order,n=e.groups,a=e.cursor,l=e.filter,r=void 0===l?"needs":l,o=e.now,i=void 0===o?N.c9.local():o;const s=new Map(n.map((e=>[e.id,e]))),c=e=>{const t=s.get(e);return void 0!==t&&oje(t,r,i)},d=t.filter(c);let u=Math.max(0,a);for(;u<t.length&&!c(t[u]);)u+=1;const m=u<t.length?t[u]:null;return{queue:d,currentGroupId:m,position:null===m?0:d.indexOf(m)+1,total:d.length}},dje={entryPoint:null,order:[],cursor:0,filter:"needs",decided:0,skipped:0},uje=(0,a.createContext)(null),mje="reviewFilter",pje="reviewGroup",gje=e=>{const t=new URLSearchParams(e);return t.delete(mje),t.delete(pje),t},hje=e=>null!==e&&nje(e)?e:null,vje=e=>{let t=e.children,n=e.enabled,r=void 0===n||n;const i=(0,a.useState)(dje),s=(0,o.A)(i,2),c=s[0],d=s[1],u=(0,a.useRef)(!1),m=(0,a.useState)(null),p=(0,o.A)(m,2),g=p[0],h=p[1],v=(0,a.useState)(JWe),f=(0,o.A)(v,2),E=f[0],y=f[1],b=function(){let e=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}).enabled,t=void 0===e||e;const n=mG().hasAccounts,a=CWe((0,U.A)({enabled:t&&Boolean(n)},AWe.F));return(0,U.A)((0,U.A)({},a),{},{isLoading:t&&(void 0===n||a.isLoading)})}({enabled:r}),x=b.recurrenceGroups,w=b.isLoading,C=b.error,A=N.c9.local().startOf("day").toMillis(),I=(0,a.useMemo)((()=>N.c9.fromMillis(A)),[A]),k=r&&!w&&null===C,S=(0,l.ok)(),T=(0,o.A)(S,2),_=T[0],D=T[1],R=(0,a.useRef)(D);R.current=D;const M=(0,a.useRef)(!1);(0,a.useEffect)((()=>{if(!k||M.current)return;M.current=!0;const e=(e=>{var t;const n=e.get(pje);return{groupId:n,filter:null!==(t=hje(e.get(mje)))&&void 0!==t?t:null!==n?"all":null}})(_),t=e.groupId,n=e.filter;if(!n)return;const a=sje(x,n,I),l=null!==t?Math.max(0,a.indexOf(t)):0;u.current=!1,F.current=0,eje("url_restore",a.length,n),d({entryPoint:"url_restore",order:a,cursor:l,filter:n,decided:0,skipped:0})}),[k,x,_,I]),(0,a.useEffect)((()=>{M.current&&null!==c.entryPoint&&R.current((e=>{const t=new URLSearchParams(e);t.set(mje,c.filter);const n=c.order[c.cursor];return void 0!==n?t.set(pje,n):t.delete(pje),t}),{replace:!0})}),[c.entryPoint,c.filter,c.cursor,c.order]);const L=(0,yu.X)(((e,t)=>{if(!k)return;const n="all",a=sje(x,n,I),l=a.indexOf(t);G("replaced"),u.current=!1,F.current=0,eje(e,a.length,n);d({entryPoint:e,order:a,cursor:l>=0?l:0,filter:n,decided:0,skipped:0})})),O=(0,yu.X)((e=>{if(!k)return;const t="needs",n=sje(x,t,I);G("replaced"),u.current=!1,F.current=0,eje(e,n.length,t),d({entryPoint:e,order:n,cursor:0,filter:t,decided:0,skipped:0})})),P=(0,yu.X)((e=>{if(e===c.filter)return;const t=sje(x,e,I);var n,a,l;n=c.filter,a=e,l=t.length,(0,Ge.u4)(Ye.aq.ReviewFilterChanged,{from:n,to:a,to_count_bucket:XWe(l)}),d((n=>(0,U.A)((0,U.A)({},n),{},{order:t,cursor:0,filter:e})))})),B=(0,a.useMemo)((()=>cje({order:c.order,groups:x,cursor:c.cursor,filter:c.filter,now:I})),[c.order,c.cursor,c.filter,x,I]),z=null===B.currentGroupId?0:B.total-B.position+1,F=(0,a.useRef)(0);(0,a.useEffect)((()=>{B.position>0&&(F.current=B.position)}),[B.position]);const G=(0,yu.X)((e=>{null!==c.entryPoint&&(e=>{let t=e.reason,n=e.remaining,a=e.decided,l=e.skipped;(0,Ge.u4)(Ye.aq.ReviewClosed,{reason:t,remaining_bucket:XWe(n),decided_bucket:XWe(a),skipped_bucket:XWe(l)})})({reason:e,remaining:z,decided:c.decided,skipped:c.skipped})})),Y=(0,yu.X)((e=>{G(e),d((e=>(0,U.A)((0,U.A)({},e),{},{entryPoint:null}))),"switched_to_sidebar"!==e&&R.current(gje,{replace:!0})})),V=(0,yu.X)(((e,t)=>{((e,t)=>{let n=t.flags,a=t.position,l=t.filter;(0,Ge.u4)(Ye.aq.ReviewGroupDecided,{action:e,flags:n,position_bucket:XWe(a),filter:l})})(e,{flags:t,position:F.current,filter:c.filter}),d((e=>(0,U.A)((0,U.A)({},e),{},{decided:e.decided+1})))})),W=(0,yu.X)((e=>{(e=>{let t=e.flags,n=e.position,a=e.filter;(0,Ge.u4)(Ye.aq.ReviewGroupSkipped,{flags:t,position_bucket:XWe(n),filter:a})})({flags:e,position:F.current,filter:c.filter}),d((e=>(0,U.A)((0,U.A)({},e),{},{skipped:e.skipped+1})))}));(0,a.useEffect)((()=>{null===c.entryPoint||0===c.order.length||z>0||u.current||(u.current=!0,(e=>{(0,Ge.u4)(Ye.aq.ReviewCompleted,{filter:e})})(c.filter))}),[c.entryPoint,c.order.length,c.filter,z]);const j=(0,a.useMemo)((()=>x.filter(rje)),[x]),H=k&&j.length>0&&(null===g||j.some((e=>{let t=e.id;return!g.has(t)}))),K=(0,yu.X)((()=>h(new Set(j.map((e=>e.id)))))),q=(0,a.useCallback)((e=>d((t=>(0,U.A)((0,U.A)({},t),{},{cursor:e})))),[]),$=(0,a.useMemo)((()=>({needs:j.length,month:ije(x,"month",I),all:ije(x,"all",I)})),[x,j.length,I]),Z=(0,a.useCallback)(((e,t)=>y((n=>(0,U.A)((0,U.A)({},n),{},{[e]:t})))),[]),J=(0,a.useMemo)((()=>({isOpen:null!==c.entryPoint,entryPoint:c.entryPoint,groups:x,isLoadingGroups:w,groupsError:C,canOpen:k,reviewableCount:$.needs,isBannerVisible:H,dismissBanner:K,order:c.order,curs
1or:c.cursor,filter:c.filter,today:I,setFilter:P,filterCounts:$,columns:E,setColumn:Z,open:O,close:Y,setCursor:q,openAt:L,recordDecision:V,recordSkip:W})),[c.entryPoint,c.order,c.cursor,c.filter,x,w,C,k,$,H,K,I,P,E,Z,O,Y,q,L,V,W]);return a.createElement(uje.Provider,{"data-external-id":"recurring-review-session-provider",value:J},t)},fje=()=>(0,a.useContext)(uje),Eje=()=>{const e=(()=>{const e=(0,a.useContext)(uje);if(!e)throw new Error("useRecurringReviewSession must be used within a RecurringReviewSessionProvider");return e})(),t=e.order,n=e.cursor,l=e.setCursor,o=e.groups,i=e.filter,s=e.today,c=(0,a.useMemo)((()=>cje({order:t,groups:o,cursor:n,filter:i,now:s})),[t,o,n,i,s]),d=c.queue,u=c.currentGroupId,m=c.position,p=c.total,g=(0,a.useMemo)((()=>{var e;return null!==(e=o.find((e=>e.id===u)))&&void 0!==e?e:null}),[o,u]),h=(0,a.useMemo)((()=>{return null===g?"none":(e=rWe({group:g,surface:"panel"})).isNew&&e.isPossiblyInactive?"new_possibly_inactive":e.isNew&&e.isOverdue?"new_overdue":e.isNew?"new":e.isPossiblyInactive?"possibly_inactive":e.isOverdue?"overdue":"none";var e}),[g]),v=(0,a.useMemo)((()=>{var e;if(null===u)return null;const t=d[d.indexOf(u)+1];return void 0===t?null:null!==(e=o.find((e=>e.id===t)))&&void 0!==e?e:null}),[o,d,u]),f=(0,r.YW)({filter:i,snapshot:t.length}).with({snapshot:0,filter:r.P.not("needs")},(()=>"filtered")).with({snapshot:0},(()=>"nothing")).otherwise((()=>"reviewed")),E=null===u,y=E?p+1:m,b=(0,a.useCallback)((e=>{const n=(e=>{let t=e.order;const n=e.queue[e.position-1];if(void 0===n)return null;const a=t.indexOf(n);return-1===a?null:a})({order:t,queue:d,position:e});null!==n&&l(n)}),[t,d,l]),x=(0,a.useCallback)((e=>{const n=(e=>{let t=e.order,n=e.groupId;const a=t.indexOf(n);return-1===a?null:a+1})({order:t,groupId:e});null!==n&&l(n)}),[t,l]),w=(0,a.useCallback)((()=>b(y+1)),[b,y]),C=(0,a.useCallback)((()=>{E||b(y-1)}),[b,y,E]),A=(0,a.useCallback)((()=>{null!==u&&x(u)}),[x,u]);return{isOpen:e.isOpen,entryPoint:e.entryPoint,isLoadingGroups:e.isLoadingGroups,groupsError:e.groupsError,canOpen:e.canOpen,reviewableCount:e.reviewableCount,isBannerVisible:e.isBannerVisible,dismissBanner:e.dismissBanner,filter:i,setFilter:e.setFilter,filterCounts:e.filterCounts,today:s,open:e.open,currentGroup:g,currentFlagShape:h,nextGroup:v,position:m,total:p,emptyReason:f,hasNext:!E&&m<p,hasPrevious:!E&&y>1,next:w,previous:C,skip:A,recordDecision:e.recordDecision,recordSkip:e.recordSkip,advancePast:x,close:e.close,openAt:e.openAt}},yje=iVe.p.REVIEW_MODAL,bje={looksRight:iVe.p.NEW_BADGE.LOOKS_RIGHT,notRecurring:iVe.p.NOT_RECURRING_MODAL.MENU_ITEM,markInactive:BVe,stillActive:zVe,stillActiveAndApprove:zVe},xje=e=>{let t=e.group,n=e.plan,l=e.flagShape,i=e.onSkip,s=e.onResolved;const c=fje(),d=KVe().approveRecurrenceGroup,u=YVe(),m=DWe({id:t.id,name:t.name,sectionKind:t.sectionKind,isActive:t.isActive,merchantId:t.merchantId,merchantName:t.merchantName,onCommitted:e=>{null===c||void 0===c||c.recordDecision(e,l),s()}}),p=m.openNotRecurring,g=m.dialogs,h=(0,a.useState)(!1),v=(0,o.A)(h,2),f=v[0],E=v[1],y=()=>d({id:t.id,name:t.name}),b=e=>u({id:t.id,name:t.name,sectionKind:t.sectionKind,isActive:e,skipUndo:e}),x=async e=>{if("notRecurring"!==e){E(!0);try{await(e=>(0,r.YW)(e).with("looksRight",(()=>y())).with("markInactive",(()=>b(!1))).with("stillActive",(()=>b(!0))).with("stillActiveAndApprove",(async()=>await y()&&b(!0))).with("notRecurring",(()=>Promise.resolve(!1))).exhaustive())(e)&&(null===c||void 0===c||c.recordDecision(QWe[e],l),s())}finally{E(!1)}}else p()},w=e=>null===e?null:a.createElement(fe.XZZ,{variant:"default",size:"sm",disabled:f,onClick:()=>{x(e)}},bje[e]);return a.createElement(a.Fragment,null,a.createElement(qWe,null,a.createElement(fe.XZZ,{variant:"text",size:"sm",className:"text-content-secondary",disabled:f,onClick:()=>{null===c||void 0===c||c.recordSkip(l),i()}},yje.SKIP),a.createElement("span",{className:"flex-1"}),w(n.affirm),w(n.correct),w(n.extra)),g)};var wje=n(94782),Cje=n(42413);const Aje=e=>{let t=e.linkTo,n=e.value,l=e.icon,r=e.size,o=void 0===r?"md":r,i=e.layout,s=void 0===i?"cell":i,c=e.fit,d=void 0!==c&&c,u=e.ariaLabel,m=e.iconOnly,p=void 0!==m&&m;const g=(0,Cje.E)(n),h=g.isOverflowing,v=g.ref,f=p||h?n:void 0,E=kje({size:o,layout:s,iconOnly:p});return a.createElement("div",{"data-external-id":"recurring-link-cell",className:Ije({size:o,layout:s,fit:d,iconOnly:p}),onClick:e=>e.stopPropagation(),onKeyDown:e=>{"Enter"!==e.key&&" "!==e.key||e.stopPropagation()}},a.createElement(fe.Yvj,{content:f,delay:300},p?a.createElement(wje.y,{to:t,"aria-label":null!==u&&void 0!==u?u:n,icon:l,endIcon:a.createElement(fe.Fug,{size:"xs"}),className:E}):a.createElement(wje.y,{to:t,"aria-label":u,endIcon:a.createElement(fe.Fug,null),className:E},a.createElement("span",{className:"flex min-w-0 items-center gap-1.25"},l?a.createElement("span",{className:"flex shrink-0 items-center leading-0"},l):null,a.createElement("span",{ref:v,className:"min-w-0 truncate"},n)))))},Ije=(0,y0.tv)({base:"flex min-w-0",variants:{fit:{true:"",false:""},layout:{cell:"",chip:""},size:{xs:"",sm:"",md:""}
1,iconOnly:{true:"shrink-0",false:"-mx-[calc(var(--spacing-xs)+1px)]"}},compoundVariants:[{fit:!0,layout:"chip",class:"-my-0.75"},{fit:!0,layout:"cell",size:"xs",class:"-my-0.75"},{fit:!0,layout:"cell",size:"sm",class:"-my-1.25"},{fit:!0,layout:"cell",size:"md",class:"-my-2"}]}),kje=(0,y0.tv)({variants:{size:{xs:"h-7 min-h-7 text-xs",sm:"h-8 min-h-8 text-sm",md:""},layout:{cell:"w-full",chip:"h-7 min-h-7 w-auto"},iconOnly:{true:"h-6 min-h-6 gap-2xs px-xs [&_[data-mds=button-icon]:last-child]:size-3",false:""}}});var Sje;const Nje=iVe.p.REVIEW_CARD,Tje=e=>{let t=e.sectionKind,n=e.frequencyDescription,l=e.merchantName,r=e.merchantId,o=e.merchantLogoUrl,i=e.amount;return a.createElement("div",{"data-external-id":"recurring-review-facts",className:"@container/reviewfacts flex items-end justify-between gap-md"},a.createElement(Dje,null,a.createElement(_je,{label:Nje.TYPE},a.createElement(fe.c8D,{size:"sm"},yr.rB[t])),a.createElement(_je,{label:Nje.FREQUENCY},a.createElement(fe.c8D,{size:"sm"},n)),null!==l&&a.createElement(_je,{label:Nje.MERCHANT},null===r?a.createElement("div",{className:"flex min-w-0 items-center gap-1.25"},a.createElement(Wl._,{url:o,size:16}),a.createElement(fe.c8D,{size:"sm",className:"truncate"},l)):a.createElement(Aje,{linkTo:I.JZ.transactions({queryParams:{merchants:[r]}}),value:l,icon:a.createElement(Wl._,{url:o,size:16}),ariaLabel:Nje.MERCHANT_LINK(l),size:"sm",layout:"chip",fit:!0}))),a.createElement(fe.c8D,{size:"lg",weight:"medium",color:(0,jQ.iR)(i)?"success":"primary"},(0,jQ.s_)(i)))},_je=e=>{let t=e.label,n=e.children;return a.createElement("div",{"data-external-id":"fact",className:"flex min-w-0 flex-col gap-3xs"},a.createElement(fe.c8D,{size:"xs",color:"secondary"},t),n)},Dje=$d.s.div(Sje||(Sje=(0,wc.A)(["\n  flex min-w-0 flex-col gap-xs\n  @min-[420px]/reviewfacts:flex-row @min-[420px]/reviewfacts:items-stretch\n  @min-[420px]/reviewfacts:gap-0 @min-[420px]/reviewfacts:divide-x\n  @min-[420px]/reviewfacts:divide-divider-primary\n  @min-[420px]/reviewfacts:*:px-md\n  @min-[420px]/reviewfacts:[&>*:first-child]:pl-0\n  @min-[420px]/reviewfacts:[&>*:last-child]:pr-0\n"]))),Rje={new:{label:"New",color:"blue"},[Ee.G8P.POSSIBLY_INACTIVE]:{label:MVe,color:"yellow"},[Ee.G8P.OVERDUE]:{label:wVe.oV[Ee.G8P.OVERDUE],color:"brand"}},Mje=e=>{let t=e.group,n=e.flags,l=e.children;return a.createElement(HWe,{"data-external-id":"recurring-review-flag-callout",className:"mb-0 shrink-0 overflow-hidden"},a.createElement("div",{className:"grid grid-cols-[auto_1fr] gap-x-2.25 gap-y-md px-default py-sm"},n.map((e=>a.createElement(a.Fragment,{key:e},a.createElement("span",{className:"inline-flex h-5.25 items-center"},a.createElement(fe.CQG,{size:"sm",rounded:"pill",color:Rje[e].color},Rje[e].label)),a.createElement(fe.c8D,{size:"sm",className:"min-w-0 text-pretty"},Lje(t,e)))))),l)},Lje=(e,t)=>"new"===t?_Ve({sectionKind:e.sectionKind,merchantName:e.merchantName,accountName:e.accountName,frequency:e.frequency,frequencyDescription:e.frequencyDescription,createdAt:e.createdAt,transactions:e.transactions}):t===Ee.G8P.POSSIBLY_INACTIVE?FVe({amount:e.amount,frequency:e.frequency,sectionKind:e.sectionKind,transactions:e.transactions}):RVe({sectionKind:e.sectionKind,overdueSince:e.overdueSince});var Oje=n(81069),Pje=n(90149);const Bje=(e,t)=>{const n=Math.abs(e)-Math.abs(t);return 0===n?null:{magnitude:Math.abs(n),direction:n>0?"up":"down"}},zje=(e,t)=>e.direction===(t?"up":"down")?"favorable":"unfavorable",Fje=e=>{const t=new Map;return e.forEach(((n,a)=>{const l=e[a+1];if(!l)return;const r=Bje(n.amount,l.amount);r&&t.set(n.id,r)})),t},Gje={favorable:"text-content-success",unfavorable:"text-content-danger"},Yje=e=>{let t=e.amountLabel,n=e.income,l=e.delta,r=e.size,o=void 0===r?"sm":r,i=e.muted,s=void 0!==i&&i;return a.createElement("div",{"data-external-id":"recurring-amount-with-delta",className:"text-right"},a.createElement(fe.c8D,{size:o,weight:"medium",color:Uje({income:n,muted:s})},t),l&&a.createElement("div",{"data-testid":"recurring-amount-delta",className:(0,q.cn)("mt-px flex items-center justify-end gap-3xs text-xs font-medium",Gje[zje(l,n)])},"up"===l.direction?a.createElement(Pje.MdsArrowUpRightIcon,{size:"xs","aria-hidden":!0}):a.createElement(Oje.MdsArrowDownRightIcon,{size:"xs","aria-hidden":!0}),(0,rl.vv)(l.magnitude)))},Uje=e=>{let t=e.income;return e.muted?"secondary":t?"success":"primary"};var Vje;const Wje=$d.s.span(Vje||(Vje=(0,wc.A)(["flex size-3.75 shrink-0 items-center justify-center rounded-full"]))),jje=e=>{let t=e.status,n=e.calendarTestId,l=e.testId;return t===Ee.G8P.PAID?a.createElement(Wje,{"data-external-id":"occurrence-mark",className:"bg-background-success text-content-success","data-testid":l},a.createElement(fe.GdR,{size:9})):t===Ee.G8P.OVERDUE?a.createElement(Wje,{"data-external-id":"occurrence-mark",className:"bg-background-brand-subtle text-content-brand","data-testid":l},a.createElement(fe.CQs,{size:9})):a.createElement(fe.cKU,{"data-external-id":"occurrence-mark",size:"sm",className:"shrink-0 text-content-secondary","aria-hidden":!0,"data-testid":null!==n&&void 0!==n?n:l})},Hje=2*Math.PI*5.5,Kje={cx:8,cy:8,r:5.5,fill:"none",strokeWidth:3},qje=e=>{let t=e.paid,n=e.overdue,l=e.total;const r=e=>"".concat(Hje*(e/l)," ").concat(Hje);return a.createElement("svg",{"data-external-id":"progress-ring",viewBox:"0 0 16 16","aria-hidden":!0,
1className:"size-3.75 shrink-0 -rotate-90"},a.createElement("circle",Object.assign({},Kje,{className:"stroke-divider-primary"})),t>0?a.createElement("circle",Object.assign({},Kje,{strokeDasharray:r(t),className:"stroke-tag-green"})):null,n>0?a.createElement("circle",Object.assign({},Kje,{strokeDasharray:r(n),strokeDashoffset:t/l*-Hje,className:"stroke-tag-orange"})):null)},$je=e=>{let t=e.label,n=e.color,l=e.weight,r=e.mark;return a.createElement("div",{"data-external-id":"status-copy-text",className:"flex min-w-0 items-center gap-1.5"},r,a.createElement(fe.c8D,{size:"base",weight:l,color:n,className:"min-w-0 truncate"},t))},Zje=e=>{let t=e.status;const n={status:t,recurringType:e.sectionKind,periodDate:e.periodDate,nextDate:e.nextDate,transactions:e.transactions,occurrences:e.occurrences},l=(0,wVe.fk)(n),r=(0,wVe.e)(n);if(r){const e=t===Ee.G8P.OVERDUE;return a.createElement($je,{"data-external-id":"status-cell",label:l,color:e?"brand":void 0,weight:e?"medium":void 0,mark:a.createElement(qje,r)})}return t===Ee.G8P.PAID?a.createElement($je,{"data-external-id":"status-cell",label:l,color:"primary",weight:"medium",mark:a.createElement(jje,{status:t})}):t===Ee.G8P.OVERDUE?a.createElement($je,{"data-external-id":"status-cell",label:l,color:"brand",weight:"medium",mark:a.createElement(jje,{status:t})}):t===Ee.G8P.POSSIBLY_INACTIVE?a.createElement($je,{"data-external-id":"status-cell",label:l,color:"secondary",mark:a.createElement(fe.t$O,{size:"sm",className:"shrink-0 text-content-warning"})}):t===Ee.G8P.ENDED?a.createElement($je,{"data-external-id":"status-cell",label:l,color:"secondary"}):a.createElement($je,{"data-external-id":"status-cell",label:l,mark:a.createElement(jje,{status:t})})},Jje=e=>{let t=e.name,n=e.logoUrl;return a.createElement("span",{"data-external-id":"recurring-value-logo","aria-hidden":!0},a.createElement(fe.a6p,{src:n,name:t,size:"xs",className:"size-4 shrink-0"}))};var Xje=n(47597),Qje=n(40453),eHe=n(37125);const tHe=iVe.p.REVIEW_CARD,nHe={posted:"font-medium text-content-primary",next:"text-content-secondary italic",due:"text-content-brand"},aHe=e=>{var t;let n=e.row,l=e.dateLabel,r=e.enrichment,o=e.delta,i=e.isLoading,s=e.columns,c=e.labelHost,d=e.gridTemplateColumns,u=e.onOpen;const m="posted"===n.kind,p="posted"===n.kind?null:a.createElement(lHe,{kind:n.kind}),g=m&&i&&!r;return a.createElement("div",{"data-external-id":"recurring-review-transaction-row",role:"row",className:(0,q.cn)("grid min-h-15 items-center gap-default px-sm py-2.25 text-sm",m&&"hover:bg-background-primary-hover"),style:{gridTemplateColumns:d}},a.createElement("span",{role:"cell",className:(0,q.cn)("truncate",nHe[n.kind])},l),null===c&&a.createElement("div",{role:"cell",className:"min-w-0"},p),s.statement&&a.createElement(rHe,{isLoading:g},"statement"===c&&p,a.createElement(fe.c8D,{size:"sm",color:"secondary",className:"truncate"},null===r||void 0===r?void 0:r.plaidName)),s.category&&a.createElement(rHe,{isLoading:g},"category"===c&&p,(null===r||void 0===r?void 0:r.category)&&a.createElement(Aje,{linkTo:I.JZ.categories({id:r.category.id}),value:r.category.name,icon:a.createElement("span",{"aria-hidden":!0,className:"leading-none"},r.category.icon),size:"sm",layout:"chip",fit:!0})),s.account&&a.createElement(rHe,{isLoading:g},"account"===c&&p,(null===r||void 0===r?void 0:r.account)&&a.createElement(Aje,{linkTo:I.JZ.accounts.accountDetails({id:r.account.id}),value:r.account.displayName,icon:a.createElement(Jje,{name:r.account.displayName,logoUrl:r.account.logoUrl}),size:"sm",layout:"chip",fit:!0})),a.createElement("div",{role:"cell",className:"flex min-w-0 items-center justify-end gap-xs"},null===r||void 0===r||null===(t=r.tags)||void 0===t?void 0:t.map((e=>a.createElement(fe.Yvj,{key:e.id,content:e.name},a.createElement("span",{"aria-label":e.name,className:"inline-flex size-2.25 shrink-0 rounded-full",style:{backgroundColor:e.color}})))),!(null===r||void 0===r||!r.notes)&&a.createElement(Xje.j,{notes:r.notes}),(null===r||void 0===r?void 0:r.pending)&&a.createElement(Qje.n,{isEditingDisabled:!1}),m?a.createElement(Yje,{amountLabel:(0,jQ.s_)(n.amount),income:(0,jQ.iR)(n.amount),delta:o}):a.createElement(fe.c8D,{size:"sm",color:"secondary",className:"next"===n.kind?"italic":""},"due"===n.kind?tHe.NO_AMOUNT:(0,jQ.s_)(n.amount))),a.createElement("div",{role:"cell",className:"flex items-center justify-center"},u&&a.createElement(fe.SO$,{variant:"minimal",size:"3xs","aria-label":tHe.OPEN_TRANSACTION(l),onClick:u},a.createElement(eHe.MdsChevronRightIcon,{size:"sm"}))))},lHe=e=>{const t="due"===e.kind;return a.createElement("span",{"data-external-id":"occurrence-marker",className:(0,q.cn)("inline-flex shrink-0 items-center",t?"gap-2xs font-medium text-content-brand":"gap-1.5 text-content-secondary italic")},a.createElement(jje,{status:t?Ee.G8P.OVERDUE:Ee.G8P.UPCOMING}),t?tHe.OVERDUE_BADGE:tHe.NEXT_BADGE)},rHe=e=>{let t=e.isLoading,n=e.children;return a.createElement("div",{"data-external-id":"cell",role:"cell",className:"flex min-w-0 items-center gap-2xs"},t?a.createElement(fe.wME,{className:"h-3.5 w-3/4 rounded-sm"}):n)},oHe=Ee.bDV,iHe=e=>{var t;const n=(0,E.wA)(),l=(0,a.useState)(null),r=(0,o.A)(l,2),i=r[0],s=r[1],c=(0,a.useMemo)((()=>[...e]),[e]),d=(0,et.I)(oHe,{variables:{filters:{ids:c},limit:c.length,offset:0},skip:0===c.length}),u=d.data,m=d.isLoadingInitialData,p=(0,a.useMemo)((()=>{var e,t;return new Map((null!==(e=null===u||void 0===u||null===(t=u.allTransactions)||void 0===t?void 0:t.results)&&void 0!==e?e:[]).map((e=>[e.id,e])))}),[null===u||void 0===u||null===(t=u.allTransactions)||void 0===t?void 0:t.results]),h=(0,a.useCallback)((()=>{n((0,g.fV)(!1)),n((0,g.VC)(null)),s(null)}),[n]),v=(0,a.useRef)(i);v.current=i,(0,a.useEffect)((()=>()=>{null!==v.current&&h()}),[h]);const f=null===i?-1:c.indexOf(i),y=null===i?null:a.createElement(po.K,null,a.createElement(go.TT,{id:i,previousTransactionId:f>0?c[f-1]:null,nextTransactionId:-1!==f&&f<c.length-1?c[f+1]:null,
1setId:s,onClose:h}));return{enrichmentById:p,isEnrichmentLoading:m,openDrawer:s,drawer:y}},sHe={type:{menuLabel:"Type",headerLabel:a.createElement(fe.c8D,{size:"sm",weight:"medium",color:"secondary"},"Type"),minWidthPx:96,flex:.9},category:{menuLabel:"Category",headerLabel:a.createElement(fe.c8D,{size:"sm",weight:"medium",color:"secondary"},"Category"),minWidthPx:152,flex:1},merchant:{menuLabel:"Merchant",headerLabel:a.createElement(fe.c8D,{size:"sm",weight:"medium",color:"secondary"},"Merchant"),minWidthPx:162,flex:1},statement:{menuLabel:"Original statement",headerLabel:a.createElement(fe.c8D,{size:"sm",weight:"medium",color:"secondary",className:"truncate"},"Original statement"),minWidthPx:150,flex:1.2},account:{menuLabel:"Account",headerLabel:a.createElement(fe.c8D,{size:"sm",weight:"medium",color:"secondary"},"Account"),minWidthPx:172,flex:1.1},status:{menuLabel:"Status",headerLabel:a.createElement(fe.c8D,{size:"sm",weight:"medium",color:"secondary"},"Status"),minWidthPx:156,flex:1.2},lastDate:{menuLabel:"Last date",headerLabel:a.createElement(fe.c8D,{size:"sm",weight:"medium",color:"secondary"},"Last date"),minWidthPx:156,flex:1.2},nextDate:{menuLabel:"Next date",headerLabel:a.createElement(fe.c8D,{size:"sm",weight:"medium",color:"secondary"},"Next date"),minWidthPx:140,flex:1.2},history:{menuLabel:"History",headerLabel:a.createElement(fe.c8D,{size:"sm",weight:"medium",color:"secondary",className:"text-center"},"History"),minWidthPx:110,flex:1},amount:{menuLabel:"Amount",headerLabel:a.createElement(fe.c8D,{size:"sm",weight:"medium",color:"secondary",className:"text-right"},"Amount"),minWidthPx:96,flex:.8}},cHe=Object.keys(sHe),dHe="minmax(".concat(72,"px,2.2fr)"),uHe=a.createElement(fe.c8D,{size:"sm",weight:"medium",color:"secondary"},"V1 \u2192 V2"),mHe="\n  [&_[data-mds=menu-group-label]]:static [&_[data-mds=menu-group-label]]:z-auto\n  [&_[data-mds=menu-group-label]]:mt-0 [&_[data-mds=menu-group-label]]:bg-none\n  [&_[data-mds=menu-group-label]]:px-sm [&_[data-mds=menu-group-label]]:pt-2xs\n  [&_[data-mds=menu-group-label]]:pb-3xs\n  [&_[data-mds=menu-group-label]>span]:rounded-none [&_[data-mds=menu-group-label]>span]:bg-transparent\n  [&_[data-mds=menu-group-label]>span]:px-0 [&_[data-mds=menu-group-label]>span]:py-0\n",pHe=function(e){let t=e.transactions,n=e.historyIntervals,a=e.nextDate,l=e.amount;const r=(arguments.length>1&&void 0!==arguments[1]?arguments[1]:N.c9.local()).startOf("day"),o=e=>N.c9.fromISO(e).startOf("day")>=r,i=t.map((e=>({key:"posted:".concat(e.id),kind:"posted",transactionId:e.id,date:e.date,amount:e.amount}))),s=new Set;return n.forEach((e=>{var t;s.add(e.date),e.isPaid||e.transactions.length>0||i.push({key:"occurrence:".concat(e.date),kind:o(e.date)?"next":"due",transactionId:null,date:e.date,amount:null!==(t=e.amount)&&void 0!==t?t:l})})),null===a||s.has(a)||i.push({key:"occurrence:".concat(a),kind:o(a)?"next":"due",transactionId:null,date:a,amount:l}),i.sort(((e,t)=>t.date.localeCompare(e.date)))},gHe=e=>e.flatMap((e=>{let t=e.transactionId;return null===t?[]:[t]})),hHe=iVe.p.REVIEW_CARD,vHe="112px",fHe="90px",EHe="20px",yHe="recurring-review-transactions-caption",bHe=e=>{var t;let n=e.transactions,l=e.historyIntervals,r=e.nextDate,i=e.amount;const s=xHe(),c=(0,o.A)(s,2),d=c[0],u=c[1],m=null!==(t=N.c9.local().startOf("day").toISO())&&void 0!==t?t:"",p=(0,a.useMemo)((()=>pHe({transactions:n,historyIntervals:l,nextDate:r,amount:i},N.c9.fromISO(m))),[n,l,r,i,m]),g=(0,a.useMemo)((()=>gHe(p)),[p]),h=iHe(g),v=h.enrichmentById,f=h.isEnrichmentLoading,E=h.openDrawer,y=h.drawer,b=(0,a.useMemo)((()=>Fje(p.flatMap((e=>null===e.transactionId?[]:[{id:e.transactionId,amount:e.amount}])))),[p]),x=$We.filter((e=>d[e])),w=(e=>{var t;return null!==(t=$We.find((t=>e[t])))&&void 0!==t?t:null})(d),C=[vHe,...null===w?["minmax(0,1fr)"]:[],...x.map((e=>ZWe[e].track)),fHe,EHe].join(" ");return a.createElement("section",{"data-external-id":"recurring-review-transactions","aria-labelledby":yHe,className:"flex min-h-0 flex-1 flex-col overflow-hidden rounded-default border border-divider-primary"},a.createElement("div",{className:" flex shrink-0 items-center justify-between gap-sm border-b border-divider-primary bg-background-secondary py-2xs pr-xs pl-sm "},a.createElement(fe.c8D,{id:yHe,size:"xs",weight:"medium",color:"secondary"}
1,hHe.TRANSACTIONS),a.createElement(fe.u$N,{align:"end",trigger:a.createElement(fe.XZZ,{variant:"text",size:"xs",className:"h-5.5 gap-2xs rounded-xs px-xs text-xs text-content-secondary hover:bg-background-tertiary",icon:a.createElement(fe.tUC,{size:"xs"})},hHe.COLUMNS),classNames:{content:mHe},items:[{type:"group",label:hHe.COLUMNS_VISIBLE(x.length,$We.length),items:[]},...$We.map((e=>({type:"checkbox",control:"switch",label:ZWe[e].label,checked:d[e],onCheckedChange:t=>u(e,t)})))]})),0===p.length?a.createElement(fe.c8D,{size:"sm",color:"secondary",className:"px-default pb-default"},hHe.NO_TRANSACTIONS):a.createElement("div",{className:"min-h-0 flex-1 overflow-y-auto bg-background-primary"},a.createElement("div",{role:"table","aria-labelledby":yHe},a.createElement("div",{role:"rowgroup",className:"sr-only"},a.createElement("div",{role:"row"},a.createElement("span",{role:"columnheader"},hHe.DATE),null===w&&a.createElement("span",{role:"columnheader"}),x.map((e=>a.createElement("span",{key:e,role:"columnheader"},ZWe[e].label))),a.createElement("span",{role:"columnheader"},hHe.AMOUNT),a.createElement("span",{role:"columnheader"}))),a.createElement("div",{role:"rowgroup",className:"divide-y divide-divider-primary"},p.map((e=>a.createElement(aHe,{key:e.key,row:e,dateLabel:(0,Ba.AO)(e.date),enrichment:null===e.transactionId?void 0:v.get(e.transactionId),delta:null===e.transactionId?void 0:b.get(e.transactionId),isLoading:f,columns:d,labelHost:w,gridTemplateColumns:C,onOpen:null===e.transactionId?void 0:()=>E(e.transactionId)})))))),y)},xHe=()=>{const e=fje(),t=(0,a.useState)(JWe),n=(0,o.A)(t,2),l=n[0],r=n[1];return null===e?[l,(e,t)=>r((n=>(0,U.A)((0,U.A)({},n),{},{[e]:t})))]:[e.columns,e.setColumn]},wHe=e=>{var t;const n=(0,Xo.IT)(aYe.oq,{variables:{merchantId:e},skip:null===e,fetchPolicy:"cache-and-network"}).data;return(null!==(t=null===n||void 0===n?void 0:n.recurrenceGroupsForPeriod)&&void 0!==t?t:[]).length>1};var CHe=n(10320);const AHe=["ref","onKeyDown"],IHe=e=>{let t=e.id,n=e.name,l=e.logoUrl;const r=(0,C.RU)(),s=(0,i.n)(Yr.VP),c=(0,o.A)(s,1)[0],d=(0,a.useState)(!1),u=(0,o.A)(d,2),m=u[0],p=u[1],g=(0,a.useState)(void 0),h=(0,o.A)(g,2),v=h[0],f=h[1],E=null!==v&&void 0!==v?v:l,y=(0,a.useRef)(void 0);(0,a.useEffect)((()=>{y.current=v}),[v]),(0,a.useEffect)((()=>()=>{y.current&&URL.revokeObjectURL(y.current)}),[]),(0,a.useEffect)((()=>{f((e=>{if(!e)return;if(!l)return void URL.revokeObjectURL(e);const t=new Image,n=e,a=()=>{URL.revokeObjectURL(n),f((e=>e===n?void 0:e))};return t.onload=a,t.onerror=a,t.src=l,e}))}),[l]);const b=(0,a.useCallback)((async(e,t,n)=>{var a;if(!n)throw new Error("Recurrence group ID is required");if(null!==(a=(await c({variables:{input:{id:n,logoUrl:t}}})).errors)&&void 0!==a&&a.length)throw new Error("Failed to persist logo.")}),[c]),x=(0,CHe.K)("recurrenceGroup",b),w=(0,a.useCallback)((async e=>{var n;const a=null===(n=e.target.files)||void 0===n?void 0:n[0];if(!a)return;e.target.value="";const l=URL.createObjectURL(a);f(l),p(!0);try{await x(a,t)}catch(o){URL.revokeObjectURL(l),f(void 0),r({description:"Failed to upload logo. Please try again."})}finally{p(!1)}}),[r,t,x]),A=pb({canonicalValue:n,onCommit:async e=>{try{await c({variables:{input:{id:t,name:e}}})}catch(n){r({description:"Failed to save name. Please try again."})}}}).inputProps,I=A.ref,k=A.onKeyDown,S=(0,En.A)(A,AHe),N=(0,a.useCallback)((e=>{"Escape"===e.key&&e.stopPropagation(),k(e)}),[k]);return{displayLogoUrl:E,isUploadingLogo:m,handleLogoFileChange:w,nameInputRef:I,nameFieldProps:(0,U.A)((0,U.A)({},S),{},{onKeyDown:N})}},kHe=["new",Ee.G8P.POSSIBLY_INACTIVE,Ee.G8P.OVERDUE],SHe={affirm:null,correct:null,extra:null},NHe=e=>{const t=e.isNew&&(e.isPossiblyInactive||e.isOverdue);return e.isNew?{affirm:e.isPossiblyInactive?"stillActiveAndApprove":"looksRight",correct:"notRecurring",extra:t?"markInactive":null}:e.isPossiblyInactive?{affirm:"markInactive",correct:"stillActive",extra:null}:e.isOverdue?{affirm:"markInactive",correct:null,extra:null}:SHe},THe=e=>{let t=e.group,n=e.flagShape,l=e.onSkip,r=e.onResolved;const o=IHe(t),i=o.displayLogoUrl,s=o.isUploadingLogo,c=o.handleLogoFileChange,d=o.nameInputRef,u=o.nameFieldProps,m=wHe(t.merchantId),p=rWe({group:t,surface:"panel"}),g=(e=>kHe.filter((t=>"new"===t?e.isNew:t===Ee.G8P.POSSIBLY_INACTIVE?e.isPossiblyInactive:e.isOverdue)))(p);return a.createElement("div",{"data-external-id":"recurring-review-card",className:" flex min-h-0 flex-1 flex-col gap-lg motion-safe:animate-in motion-safe:duration-160 motion-safe:ease-out motion-safe:fade-in motion-safe:slide-in-from-bottom-2 "},a.createElement(jWe.j,Object.assign({logoSrc:i,logoName:t.name,isU
1ploadingLogo:s,onLogoFileChange:c,accept:".jpg,.jpeg,.png,.heif",className:"max-w-100 min-w-0",inputRef:d,description:m?a.createElement(YWe,null):void 0},u)),a.createElement(Tje,{sectionKind:t.sectionKind,frequencyDescription:t.frequencyDescription,merchantName:t.merchantName,merchantId:t.merchantId,merchantLogoUrl:t.merchantLogoUrl,amount:t.amount}),a.createElement(bHe,{transactions:t.transactions,historyIntervals:t.historyIntervals,nextDate:t.nextDate,amount:t.amount}),g.length>0&&a.createElement(Mje,{group:t,flags:g},a.createElement(xje,{group:t,plan:NHe(p),flagShape:n,onSkip:l,onResolved:r})))},_He=iVe.p.REVIEW_MODAL,DHe=e=>{let t=e.filter,n=e.counts,l=e.onChange;const r=(0,a.useState)(!1),i=(0,o.A)(r,2),s=i[0],c=i[1];return a.createElement(fe.u$N,{"data-external-id":"recurring-review-filter-menu",align:"start",open:s,onOpenChange:c,trigger:a.createElement(fe.XZZ,{variant:"overlay",size:"sm",rounded:"pill",icon:a.createElement(fe.evG,{size:"sm",className:"text-content-secondary"}),endIcon:a.createElement(fe.D39,{size:"sm",className:"text-content-secondary"})},_He.FILTER_LABELS[t]),items:[{type:"radio-group",value:t,onValueChange:e=>{nje(e)&&l(e),c(!1)},items:tje.map((e=>({value:e,label:_He.FILTER_LABELS[e],trailing:a.createElement(fe.c8D,{size:"sm",color:"secondary"},n[e])})))}]})},RHe=iVe.p.REVIEW_MODAL,MHe=e=>{let t=e.position,n=e.total,l=e.hasPrevious,r=e.hasNext,o=e.onPrevious,i=e.onNext,s=e.filter,c=e.filterCounts,d=e.onFilterChange,u=e.onSwitchToSidebar;return a.createElement("div",{"data-external-id":"recurring-review-modal-header",className:"flex items-center gap-sm"},a.createElement(fe.SO$,{variant:"overlay",size:"sm","aria-label":RHe.SIDEBAR,disabled:!u,onClick:u},a.createElement(fe.NI3,null)),a.createElement(DHe,{filter:s,counts:c,onChange:d}),a.createElement("div",{className:"flex items-center gap-2xs"},a.createElement(fe.SO$,{variant:"overlay",size:"sm","aria-label":RHe.PREVIOUS,disabled:!l,onClick:o},a.createElement(fe.CY1,null)),a.createElement(fe.SO$,{variant:"overlay",size:"sm","aria-label":RHe.NEXT,disabled:!r,onClick:i},a.createElement(fe.D39,null))),t>0&&a.createElement(fe.c8D,{size:"sm",color:"secondary"},RHe.COUNTER(t,n)))},LHe=(e,t)=>{const n=(0,V.m)(),l=(0,a.useMemo)((()=>((e,t)=>null===e?"":gHe(pHe({transactions:e.transactions,historyIntervals:e.historyIntervals,nextDate:e.nextDate,amount:e.amount},t)).join(","))(e,t)),[e,t]);(0,a.useEffect)((()=>{if(""===l)return;const e=l.split(",");n.query({query:oHe,variables:{filters:{ids:e},limit:e.length,offset:0},fetchPolicy:"cache-first"}).catch((()=>{}))}),[n,l])};var OHe;const PHe=iVe.p.REVIEW_MODAL,BHe=e=>{let t=e.onSelectGroup;const n=Eje(),l=n.isOpen,r=n.currentGroup,i=n.position,s=n.total,c=n.emptyReason,d=n.hasNext,u=n.hasPrevious,m=n.next,p=n.previous,g=n.close,h=n.filter,v=n.setFilter,f=n.filterCounts,E=n.skip,y=n.advancePast,b=n.nextGroup,x=n.today,w=n.recordDecision,C=n.currentFlagShape;LHe(b,x);const A=null!==r?()=>{g("switched_to_sidebar"),t(r.id)}:void 0,I=(0,a.useRef)(null),k=(()=>{const e=(0,a.useState)(null),t=(0,o.A)(e,2),n=t[0],l=t[1];return{popupRef:(0,a.useCallback)((e=>{var t;l(null!==(t=null===e||void 0===e?void 0:e.closest('[data-mds="dialog-viewport"]'))&&void 0!==t?t:null)}),[]),host:n}})(),S=k.popupRef,N=k.host,T=(0,a.useRef)({next:m,previous:p});T.current={next:m,previous:p},(0,a.useEffect)((()=>{if(!l)return;const e=e=>{e.ctrlKey&&e.shiftKey&&!e.metaKey&&!e.altKey&&(zHe(e.target)||("KeyJ"===e.code?(e.preventDefault(),T.current.next()):"KeyK"===e.code&&(e.preventDefault(),T.current.previous())))};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)}),[l]);const _=0===i;return(0,a.useEffect)((()=>{var e;l&&_&&(null===(e=I.current)||void 0===e||e.focus())}),[l,_]),a.createElement(fe.hg1.Root,{"data-external-id":"recurring-review-modal",open:l,onOpenChange:e=>!e&&g("dismissed"),size:"4xl"},a.createElement(fe.hg1.Content,{ref:S},a.createElement(bWe,{value:N},a.createElement(BWe,{logoUrl:null===r||void 0===r?void 0:r.logoUrl,merchantLogoUrl:null===r||void 0===r?void 0:r.merchantLogoUrl,className:"rounded-t-default"}),a.createElement("div",{className:"relative flex min-h-0 flex-col"},a.createElement("div",{className:"flex items-center gap-xs px-default py-sm"},a.createElement(MHe,{position:i,total:s,hasPrevious:u,hasNext:d,onPrevious:p,onNext:m,filter:h,filterCounts:f,onFilterChange:v,onSwitchToSidebar:A}),a.createElement(fe.hg1.Title,{className:"sr-only"},PHe.TITLE),a.createElement("span",{className:"ml-auto"}),null!==r&&a.createElement(OWe,{key:r.id,id:r.id,name:r.name,sectionKind:r.sectionKind,isActive:r.isActive,merchantId:r.merchantId,merchantName:r.merchantName,onClose:()=>g("dismissed"),onDecided:e=>w(e,C)}),a.createElement(fe.hg1.Close,{render:a.createElement(fe.TU1,{variant:"overlay","aria-label":PHe.CLOSE})})),a.createElement(FHe,null,_||null===r?a.createElement(GWe,{ref:I,reason:c,onDone:()=>g("dismissed")}):a.createElement(fe.hg1.Body,{className:"flex min-h-0 flex-1 flex-col"},a.createElement(THe,{key:r.id,group:r,flagShape:C,onSkip:E,onResolved:()=>y(r.id)})))))))},zHe=e=>e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement||e instanceof HTMLElement&&e.isContentEditable,FHe=$d.s.div(OHe||(OHe=(0,wc.A)(["flex h-150 max-h-[calc(100vh-140px)] flex-col overflow-hidden"])));var GHe=n(14727);const YHe=()=>n.e(7687).then(n.bind(n,37687)).then((e=>({default:e.RecurringV2Tour}))),UHe=(0,xZ.Z)(YHe,"LazyRecurringV2Tour"),VHe=e=>{let t=e.shouldShow,n=e.showCover,l=e.onDismiss;return t?a.createElement(a.Suspense,{"data-external-id":"recurring-v2-tour-host",fallback:a.createElement(WHe,null)},a.createElement(UHe,{onDismiss:l})):n?a.createElement(WHe,{"data-external-id":"recurring-v2-tour-host"}):null},WHe=()=>a.createElement("div",{"data-external-id":"recurring-v2-tour-cover","data-testid":"recurring-v2-tour-cover",className:"absolute inset-0 z-docked flex items-center justify-center bg-background-page"},a.createElement("div",{className:"absolute top-4.5 right-6"},a.createElement(GHe.p,null)),a.createElement(p.i,null)),jHe=e=>{let t=e.isLoadingFlag,n=e.dismissedAt,a=e.isLoadingGroups,l=e.isResultAvailable;return t||null===n&&(a||!l)},HHe=e=>{let t=e.isLoadingFlag,n=e.dismissedAt,a=e.isLoadingGroups,l=e.groupCount;return!t&&null===n&&!a&&l>0},KHe={},qHe=[{value:"monthly",label:"Monthly",path:I.JZ.recurringV2.monthly.path},{value:"all",label:"All",path:I.JZ.recurringV2.all.path},{value:"calendar",label:"Calendar",path:I.JZ.recurringV2.calendar.path}],$He={value:"playground",label:"Playground",path:I.JZ.recurringV2.playground.path},ZHe=[...qHe,$He],JHe=e=>{let t=e.isEnrollmentLoading,n=e.isEnrolled,a=e.pathname;return t||n||(e=>(0,ma.gQ)(e,I.JZ.recurringV2.playground.path))(a)},XHe=e=>{var t,n;return null!==(t=null===(n=ZHe.find((t=>{let n=t.path;return(0,ma.gQ)(e,n)})))||void 0===n?void 0:n.value)&&void 0!==t?t:"monthly"},QHe=()=>{const e=(0,l.zy)().pathname,t=(0,d4.u)("feat-recurring-playground","off").isOn,n=(0,Sse.x)(),r=n.isOn,o=n.isLoading,i=XHe(e),s=(e=>{let t=e.isPlaygroundEnabled,n=e.isPlaygroundPath,a=e.isEnrolled;const l=e.isEnrollmentLoading||a?qHe:[];return t||n?[...l,$He]:l})({isPlaygroundEnabled:t,isPlaygroundPath:"playground"===i,isEnrolled:r,isEnrollmentLoading:o});return a.createElement(fe.T36.Root,{"data-external-id":"recurring-v2-header-tabs",className:"ml-xl pr-lg",value:i,fitContent:!0},a.createElement(fe.T36.List,{"aria-label":"Recurring 2.0 views",className:"gap-lg"},s.map((e=>{let t=e.value,n=e.label,r=e.path;return a.createElement(fe.T36.Tab,{key:t,value:t,render:a.createElement(l.k2,{to:r}),nativeButton:!1,className:"h-8 pb-0 text-base font-normal hover:text-content-primary data-active:hover:text-content-brand"},n)})),a.createElement(fe.T36.Indicator,{className:"left-0 will-change-transform",style:{transform:"translateX(var(--active-tab-left))"}})))};var eKe=n(51122),tKe=n(29749);const nKe=()=>{const e=(0,d.wA)(),t=(0,d.d4)(tKe.OO);return a.createElement(fe.ENt,{"data-external-id":"recurring-summary-toggle","aria-label":"Show summary",pressed:t,onPressedCh
1ange:t=>e((0,eKe.MN)(t))},a.createElement(fe.OfV,null))},aKe=["onCancel","onChangeSections"],lKe=e=>{let t=e.onCancel,n=e.onChangeSections,l=(0,En.A)(e,aKe);return a.createElement(xH,Object.assign({"data-external-id":"recurring-v2-filters",onChange:n,onClickCancel:t,options:{filtersColumnWidth:150}},l))};var rKe=n(78338);const oKe=["statuses"],iKe=(e,t)=>{if("all"!==e)return t;t.statuses;return(0,En.A)(t,oKe)},sKe=e=>{let t=e.filters,n=e.onApplyFilters,l=e.tab,r=void 0===l?"monthly":l,i=e.renderAccountLogo,s=e.renderMerchantLogo;const c=(0,et.I)(OFe,{}),d=c.data,u=c.isLoadingInitialData,m=(0,et.I)(aYe.JN,{variables:{includeInactive:Ur.tQ},fetchPolicy:"cache-and-network"}),p=m.data,g=m.isLoadingInitialData,h=(0,a.useMemo)((()=>({filterQuery:d,groups:null===p||void 0===p?void 0:p.recurrenceGroupsForPeriod})),[d,p]),v=Ij({data:h,filters:t,renderAccountLogo:i,renderMerchantLogo:s,getFilterSectionsFromQuery:(e,t,n)=>((e,t,n)=>{var a;if(null===e||void 0===e||!e.filterQuery)return[];const l=n||{},r=l.renderAccountLogo,i=l.renderMerchantLogo,s=l.includeStatus,c=void 0===s||s,d=e.filterQuery,u=d.categoryGroups,m=void 0===u?[]:u,p=d.accounts,g=void 0===p?[]:p,h=(0,LD.A)((0,nj.A)("",["type","display"]),g),v=Object.entries(rKe.fi).map((e=>{let t=(0,o.A)(e,2);return{id:t[0],name:t[1]}})),f=(0,Mu.A)((e=>e.id),(null!==(a=e.groups)&&void 0!==a?a:[]).flatMap((e=>e.recurrenceGroup.merchant?[e.recurrenceGroup.merchant]:[]))),E=[{id:"recurringTypes",name:"Type",hideSelectAll:!0,options:[{id:Ee.kjN.INCOME,name:"Income",isSelected:(0,tj.co)(null===t||void 0===t?void 0:t.recurringTypes)(Ee.kjN.INCOME)},{id:Ee.kjN.EXPENSE,name:"Expense",isSelected:(0,tj.co)(null===t||void 0===t?void 0:t.recurringTypes)(Ee.kjN.EXPENSE)},{id:Ee.kjN.TRANSFER,name:"Transfer",isSelected:(0,tj.co)(null===t||void 0===t?void 0:t.recurringTypes)(Ee.kjN.TRANSFER)}]},{id:"accounts",name:"Account",options:Object.entries(h).map((e=>{let n=(0,o.A)(e,2),a=n[0];return{id:a,name:a,options:n[1].map((e=>({id:e.id,name:(0,nj.A)("",["displayName"],e),isSelected:(0,tj.co)(null===t||void 0===t?void 0:t.accounts)(e.id),icon:null===r||void 0===r?void 0:r(e)})))}}))},hj(m,t),{id:"frequencies",name:"Frequency",hideSelectAll:!0,options:v.map((e=>({id:e.id,name:e.name,isSelected:(0,tj.co)(null===t||void 0===t?void 0:t.frequencies)(e.id)}
1)))},{id:"merchants",name:"Merchant",options:f.map((e=>({id:e.id,name:e.name,isSelected:(0,tj.co)(null===t||void 0===t?void 0:t.merchants)(e.id),icon:null===i||void 0===i?void 0:i(e)})))},{id:"statuses",name:"Status",hideSelectAll:!0,options:[Ee.G8P.PAID,Ee.G8P.UPCOMING,Ee.G8P.OVERDUE,Ee.G8P.POSSIBLY_INACTIVE,Ee.G8P.ENDED].map((e=>({id:e,name:wVe.oV[e],isSelected:(0,tj.co)(null===t||void 0===t?void 0:t.statuses)(e)})))}];return c?E:E.filter((e=>"statuses"!==e.id))})(e,t,(0,U.A)((0,U.A)({},n),{},{includeStatus:"all"!==r})),sectionsResetKey:r,onApplyFilters:(e,t)=>{n(e),t&&gj("recurring-v2",t)},adaptSelectedOptionsToFilters:hQ});return{sections:v.sections,isLoading:u||g,onChangeSections:v.onChangeSections,resetUnappliedChanges:v.resetUnappliedChanges,handleApply:v.handleApply}},cKe=()=>{const e=(0,pG.w)(),t=(0,l.zy)(),n=(0,d.d4)(tKe.Ze),r=(0,a.useState)(!1),i=(0,o.A)(r,2),s=i[0],u=i[1],m="all"===XHe(t.pathname)?"all":"monthly",p=iKe(m,n),h=sKe({tab:m,filters:n,onApplyFilters:t=>{e((0,g.lA)(((e,t,n)=>"all"===e&&n.statuses?(0,U.A)((0,U.A)({},t),{},{statuses:n.statuses}):t)(m,t,n)))},renderAccountLogo:e=>a.createElement(Gl.v,{logoUrl:e.logoUrl,icon:e.icon,size:14,className:"mr-2xs"}),renderMerchantLogo:e=>a.createElement(Wl._,{url:e.logoUrl,size:14,className:"mr-2xs"})}),v=h.sections,f=h.isLoading,E=h.onChangeSections,y=h.resetUnappliedChanges,b=h.handleApply;return a.createElement(fe.k_P.Root,{"data-external-id":"recurring-v2-filters-control",open:s,onOpenChange:e=>{u(e),y()},size:"2xl"},a.createElement("div",{className:"relative inline-flex"},a.createElement(fe.k_P.Trigger,{description:"Filter recurring items",render:a.createElement(fe.XZZ,{icon:a.createElement(fe.evG,null),variant:"default"},"Filters")}),(0,c.A)(p)?a.createElement("span",{className:"pointer-events-none absolute -top-1 -right-1 size-3 rounded-full bg-tag-orange","aria-hidden":!0}):null),a.createElement(fe.k_P.Content,{side:"bottom",align:"end",className:"p-0"},a.createElement(lKe,{sections:v,isLoading:f,onChangeSections:E,onCancel:()=>{y(),u(!1)},onClickApply:e=>{b(e),u(!1)}})))};var dKe=n(35414),uKe=n(40007);const mKe=()=>a.createElement(uKe.DW,{"data-external-id":"add-recurring-group-header-button"},a.createElement(pKe,null)),pKe=()=>{var e;const t=(0,uKe.z3)().onOpenChange,n=(0,V.m)(),l=(0,Xo.IT)(aYe.VZ),r=l.data,s=l.startPolling,c=l.stopPolling,d=null===r||void 0===r?void 0:r.recurrenceGroupDetectionStatus,u=null!==(e=null===d||void 0===d?void 0:d.isRunning)&&void 0!==e&&e,m=(0,a.useRef)(u);(0,a.useEffect)((()=>{u?s(1e4):(c(),m.current&&(n.refetchQueries({include:aYe.Y$}),null!==d&&void 0!==d&&d.failedAt&&C.oR.error({title:"Automatic search failed. Please try again."}))),m.current=u}),[n,u,s,null===d||void 0===d?void 0:d.failedAt,c]);let p=null;u?p="Searching\u2026":null!==d&&void 0!==d&&d.failedAt?p="Search failed ".concat(N.c9.fromISO(d.failedAt).toRelative(),". Please try again."):null!==d&&void 0!==d&&d.lastDetectedAt&&(p="Checked ".concat(N.c9.fromISO(d.lastDetectedAt).toRelative()));const g=(0,i.n)(aYe.Qo,{refetchQueries:[aYe.VZ]}),h=(0,o.A)(g,1)[0],v=(0,a.useMemo)((()=>[{label:a.createElement("span",{className:"flex flex-col gap-0.5"},a.createElement("span",null,"Automatic search"),p&&a.createElement("span",{className:"flex items-center gap-1.5"},a.createElement(fe.sKi,{size:"sm",className:"text-content-secondary ".concat(u?"animate-spin":"")}),a.createElement("span",{className:"text-xs text-content-secondary"},p))),disabled:u,onClick:()=>{(async()=>{try{var e;const l=(await h()).data;if(null!==l&&void 0!==l&&null!==(e=l.triggerRecurrenceGroupDetection)&&void 0!==e&&e.success)(0,C.oR)({title:"Finding recurring groups\u2026",description:"This may take a few minutes. Feel free to leave this page and come back later.",accessory:a.createElement(fe.sKi,{size:"md",className:"animate-spin"})});else{var t,n;const e=null===l||void 0===l||null===(t=l.triggerRecurrenceGroupDetection)||void 0===t||null===(n=t.errors)||void 0===n?void 0:n.message;C.oR.error({title:null!==e&&void 0!==e?e:"Could not start detection. Try again."})}}catch(l){C.oR.error({title:"Could not start detection. Try again."})}})()}},{label:"Add manually",onClick:()=>{t(!0)}}]),[h,t,u,p]);return a.createElement(a.Fragment,null,a.createElement(fe.u$N,{trigger:a.createElement(fe.XZZ,{variant:"primary",icon:a.createElement(fe.Wa3,null)},"Add recurring"),items:v}),a.createElement(dKe.q,null))};var gKe=n(67128),hKe=n(46407);const vKe=()=>a.createElement(fe.hg1.Root,{"data-external-id":"recurring-v2-beta-notes-modal",size:"5xl",scroll:"outside"},a.createElement(fe.hg1.Trigger,{render:a.createElement(fe.XZZ,{variant:"text",colorScheme:"link",size:"sm",className:"pr-2xs"},hKe.Ss.BETA_NOTES)}),a.createElement(fe.hg1.Content,null,a.createElement(fe.hg1.CloseTrigger,null),a.createElement(fe.hg1.Body,null,a.createElement("div",{className:"flex flex-row items-center gap-6 p-6"},a.createElement("div",{className:"flex items-center justify-center"},a.createElement("img",{src:hKe.bq,alt:hKe.Ss.STEP_4_IMAGE_ALT,className:"h-full w-auto max-w-full object-contain"})),a.createElement("div",{className:"min-w-0 flex-1"},a.createElement(fe.hg1.Title,{className:"mb-4 text-2xl font-bold"},hKe.Ss.STEP_4_TITLE),a.createElement(gKe.j,null)))))),fKe=e=>{let t=e.activeTab;return a.createElement("div",{"data-external-id":"recurring-v2-page-control
1s",className:"flex items-center gap-xs"},a.createElement(vKe,null),a.createElement(GHe.p,null),a.createElement(wm.A,{orientation:"vertical",color:"tertiary",className:"mx-2xs h-default"}),a.createElement(cKe,null),a.createElement(mKe,null),"monthly"===t&&a.createElement(nKe,null))};var EKe=n(60276);const yKe=e=>{let t=e.hasStalled,n=void 0!==t&&t;const l=(0,a.useState)(!1),r=(0,o.A)(l,2),s=r[0],c=r[1],d=(0,i.n)(aYe.Qo,{refetchQueries:[aYe.VZ],awaitRefetchQueries:!0}),u=(0,o.A)(d,1)[0];return a.createElement("div",{"data-external-id":"recurring-v2-scanning-screen",className:"flex min-h-0 flex-1 flex-col px-gutter pb-gutter"},a.createElement(fe.xz6,{className:"flex-1"},a.createElement(fe.xz6.Content,{className:"flex-1 items-center justify-center"},a.createElement(fe.erR.Root,null,a.createElement(fe.erR.Icon,{variant:"unstyled"},a.createElement("div",{className:"flex size-17 items-center justify-center rounded-full bg-background-secondary text-content-secondary"},a.createElement("div",{className:"relative flex items-center justify-center"},a.createElement(Rne.MdsCalendarIcon,{size:"2xl"}),a.createElement("div",{className:"\n                      absolute -right-4 -bottom-4 flex size-5 items-center justify-center\n                      rounded-full bg-background-brand text-content-white\n                    "},a.createElement(EKe.MdsRefreshIcon,{size:"xs"}))))),a.createElement(fe.erR.Title,{size:"xl",weight:"bold",className:"md:whitespace-nowrap"},n?_t._E.SCANNING.STALLED_TITLE:_t._E.SCANNING.TITLE),a.createElement(fe.erR.Description,null,a.createElement("div",{className:"flex flex-col gap-2"},n?a.createElement(fe.c8D,{color:"secondary",size:"sm"},_t._E.SCANNING.STALLED_DESCRIPTION):a.createElement(a.Fragment,null,a.createElement(fe.c8D,{color:"secondary",size:"sm"},_t._E.SCANNING.DESCRIPTION_1),a.createElement(fe.c8D,{color:"secondary",size:"sm"},_t._E.SCANNING.DESCRIPTION_2)))),n&&a.createElement(fe.erR.Actions,null,a.createElement(fe.XZZ,{variant:"primary",isLoading:s,onClick:async()=>{c(!0);try{var e;const a=(await u()).data;if(null===a||void 0===a||null===(e=a.triggerRecurrenceGroupDetection)||void 0===e||!e.success){var t,n;const e=null===a||void 0===a||null===(t=a.triggerRecurrenceGroupDetection)||void 0===t||null===(n=t.errors)||void 0===n?void 0:n.message;C.oR.error({title:null!==e&&void 0!==e?e:_t._E.SCANNING.RETRY_ERROR})}}catch(a){C.oR.error({title:_t._E.SCANNING.RETRY_ERROR})}finally{c(!1)}}},_t._E.SCANNING.RETRY),a.createElement(GHe.p,null))))))};var bKe=n(54267),xKe=n(51144);const wKe="merchants",CKe={merchants:[]},AKe=(e,t)=>"".concat(e).concat("::").concat(t),IKe=e=>AKe(e.recurrenceStreamCategoryType,e.name),kKe=(e,t)=>{var n;const a=null!==(n=null===e||void 0===e?void 0:e.merchants)&&void 0!==n?n:[],l=null!==t&&void 0!==t?t:CKe,r=(0,tj.co)(l.merchants.map((e=>IKe(e)))),o=a.reduce(((e,t)=>{var n;const a=t.recurrenceStreamCategoryType;if(!xKe._f.includes(a))return e;const l=null!==(n=e[a])&&void 0!==n?n:[];return e[a]=[...l,t.name],e}),{});return[{id:wKe,name:"Merchants",options:xKe._f.flatMap((e=>{var t;const n=(e=>[...new Set(e)].sort(((e,t)=>e.localeCompare(t))))(null!==(t=o[e])&&void 0!==t?t:[]);return 0===n.length?[]:[{id:e,name:xKe.wj[e],options:n.map((t=>({id:AKe(e,t),name:t,isSelected:r(AKe(e,t))})))}]}))}]},SKe=e=>({merchants:e.filter((e=>e.path[0]===wKe&&e.path.length>=3&&e.path[1])).map((e=>({recurrenceStreamCategoryType:e.path[1],name:e.name})))}),NKe=(0,a.createContext)(null),TKe=e=>{let t=e.children;const n=(0,a.useState)([]),l=(0,o.A)(n,2),r=l[0],i=l[1],s=(0,a.useState)([]),c=(0,o.A)(s,2),d=c[0],u=c[1],m=(0,a.useCallback)((e=>{i(e),u((t=>((e,t)=>{const n=new Set(t.map(IKe));return e.filter((e=>n.has(IKe(e))))})(t,(e=>{const t=new Set,n=[];for(const a of e){const e=IKe(a);t.has(e)||(t.add(e),n.push(a))}return n})(e))))}),[]),p=(0,a.useCallback)((e=>{u(e.merchants)}),[]),g=(0,a.useCallback)((()=>{u([])}),[]),h=(0,a.useMemo)((()=>({merchants:r,setMerchants:m,filters:{merchants:d},setFilters:p,clearFilters:g,hasActiveFilters:d.length>0})),[g,r,d,p,m]);return a.createElement(NKe.Provider,{"data-external-id":"playground-filters-provider",value:h},t)},_Ke=()=>{const e=(0,a.useContext)(NKe);if(!e)throw new Error("usePlaygroundFilters must be used within PlaygroundFiltersProvider");return e},DKe=e=>{let t=e.toggleOpen;const n=_Ke(),l=n.merchants,r=n.filters,o=n.setFilters,i=(e=>{let t=e.data,n=e.filters,a=e.onApplyFilters;const l=Ij({data:t,filters:n,getFilterSectionsFromQuery:kKe,adaptSelectedOptionsToFilters:SKe,onApplyFilters:a});return{sections:l.sections,onChangeSections:l.onChangeSections,resetUnappliedChanges:l.resetUnappliedChanges,handleApply:l.handleApply}})({data:(0,a.useMemo)((()=>({merchants:l})),[l]),filters:r,onApplyFilters:e=>{var n;o({merchants:null!==(n=e.merchants)&&void 0!==n?n:[]}),u(),t()}}),s=i.sections,c=i.onChangeSections,d=i.handleApply,u=i.resetUnappliedChanges;return a.createElement(xH,{"data-external-id":"playground-recurring-filters",onClickApply:d,onClickCancel:()=>{u(),t()},sections:s,onChange:c,options:{filtersColumnWidth:150}})};var RKe=n(94208);const MKe=()=>{const e=_Ke().hasActiveFilters;return a.createElement(Qi.Az,{"data-external-id":"playground-filters-control",placement:"bottom-end",closeOnEscape:!1,overlay:e=>{let t=e.toggleOpen;return a.createElement(Qi.j7,{className:"overflow-hidden rounded-md border border-border-primary"},a.createElement(DKe,{toggleOpen:t}))}},(t=>{let n=t.toggleOpen,l=t.isOpen;return a.createElement(fe.qN2,{show:e},a.createElement(Wb.X,{variant:"default",size:"sm",icon:a.createElement(RKe.MdsFilterIcon,{size:"xs"}),onClick:n,className:l?"border-border-primary-hover bg-background-secondary shadow-inset":void 0},"Filters"))}))};var LKe=n(83662);const OKe=e=>{let t=e.transactions,n=e.enrichmentById,l=e.totalCount;const r=(0,E.wA)(),i=(0,a.useState)(null),s=(0,o.A)(i,2),c=s[0],d=s[1],u=(0,a.useState)([]),m=(0,o.A)(u,2),p=m[0],h=m[1],v=(0,a.useCallback)((()=>{r((0,g.fV)(!1)),r((0,g.VC)(null)),d(null),h([])}),[r]),f=(0,a.useRef)(c);f.current=c,(0,a.useEffect)((()=>()=>{null!==f.current&&v()}),[v]);const y=(0,a.useCallback)((e=>{const n=[...t].sort(((e,t)=>t.date.localeCompare(e.date)));h(n),d(e)}),[t]),b=(0,a.useCallback)((e=>{d(e)}),[]),x=(0,a.useMemo)((()=>[...t].sort(((e,t)=>t.date.localeCompare(e.date)))),[t]),w=p.findIndex((e=>e.id===c)),C=w>0?p[w-1].id:null,A=-1!==w&&w<p.length-1?p[w+1].id:null;return a.createElement(a.Fragment,null,a.createElement("div",{className:"flex flex-col gap-sm"},a.createElement(kD.c,{size:"xs",color:"secondary"},"Showing ",t.length," of ",l," transactions"),a.createElement("div",{className:"overflow-hidden rounded-default border border-divider-primary bg-background-primary"},a.createElement("div",{className:"flex items-center gap-sm border-b border-divider-primary bg-background-secondary px-md py-sm"},a.createElement("span",{className:"w-32 shrink-0"},a.createElement(kD.c,{size:"2xs",color:"secondary",weight:"medium"},"TRANSACTION ID")),a.createElement("span",{className:"w-32 shrink-0"},a.createElement(kD.c,{size:"2xs",color:"secondary",weight:"medium"},"EXTERNAL ID")),a.createElement("span",{className:"min-w-0 flex-[1.2]"},a.createElement(kD.c,{size:"2xs",color:"secondary",weight:"medium"},"MERCHANT")),a.createElement("span",{className:"min-w-0 flex-1"},a.createElement(kD.c,{size:"2xs",color:"secondary",weight:"medium"},"CATEGORY")),a.createElement("span",{className:"min-w-0 flex-1"},a.createElement(kD.c,{size:"2xs",color:"secondary",weight:"medium"},"ACCOUNT")),a.createElement("span",{className:"w-24 shrink-0"},a.createElement(kD.c,{size:"2xs",color:"secondary",weight:"medium"},"DATE")),a.createElement("span",{className:"w-36 shrink-0 text-right"},a.createElement(kD.c,{size:"2xs",color:"secondary",weight:"medium"},"AMOUNT")),a.createElement("span",{className:"w-6 shrink-0","aria-hidden":!0})),x.map((e=>{var t,l,r,o,i,s;const c=n.get(e.id),d=e.notes?(0,EA.xv)(e.notes.trim(),40):"";return a.createElement("div",{key:e.id,className:"\n                  flex cursor-pointer items-center gap-sm border-b border-divider-primary px-md\n                  py-sm\n                  last:border-b-0\n                  hover:bg-background-primary-hover\n                ",onClick:()=>y(e.id)},a.createElement("span",{className:"flex w-32 shrink-0 items-center gap-2xs font-mono"},a.createElement(Wi.Y,{content:e.id,side:"top"},a.createElement(kD.c,{size:"xs",render:a.createElement("span",null)},(0,EA.Lt)(e.id,13))),a.createElement(PKe,{value:e.id,label:"Copy transaction ID"})),a.createElement("span",{className:"flex w-32 shrink-0 items-center gap-2xs font-mono"},a.createElement(Wi.Y,{content:e.externalId,side:"top"},a.createElement(kD.c,{size:"xs",color:"secondary",render:a.createElement("span",null)},(0,EA.Lt)(e.externalId,13))),a.createElement(PKe,{value:e.externalId,label:"Copy external ID"})),a.createElement("span",{className:"min-w-0 flex-[1.2]"},a.createElement(kD.c,{size:"xs",render:a.createElement("span",{className:"block truncate"})},null!==(t=null===c||void 0===c||null===(l=c.merchant)||void 0===l?void 0:l.name)&&void 0!==t?t:"\u2014"),d?a.createElement(kD.c,{size:"2xs",color:"secondary",render:a.createElement("span",{className:"mt-3xs block truncate"})},d):null),a.createElement("span",{className:"min-w-0 flex-1"},a.createElement(kD.c,{size:"xs",color:"secondary",render:a.createElement("span",{className:"block truncate"})},null!==(r=null===c||void 0===c||null===(o=c.category)||void 0===o?void 0:o.name)&&void 0!==r?r:"\u2014")),a.createElement("span",{className:"min-w-0 flex-1"},a.createElement(kD.c,{size:"xs",color:"secondary",render:a.createElement("span",{className:"block truncate"})},null!==(i=null===c||void 0===c||null===(s=c.account)||void 0===s?void 0:s.displayName)&&void 0!==i?i:"\u2014")),a.createElement("span",{className:"w-24 shrink-0"},a.createElement(kD.c,{size:"xs",color:"secondary"},e.date)),a.createElement("span",{className:"flex w-36 shrink-0 items-center justify-end gap-2xs"},null!==c&&void 0!==c&&c.pending?a.createElement(Qje.n,{isEditingDisabled:!1}):null,e.hideFromReports&&a.createElement(Wi.Y,{content:g4.Fk,side:"left"},a.createElement(mWe.MdsEyeOffIcon,{size:"xs","aria-label":g4.Fk,className:"text-content-secondary"})),!!e.notes&&a.createElement(Xje.j,{notes:e.notes}),a.createElement(kD.c,{size:"xs",color:(0,jQ.iR)(e.amount)?"success":"primary",weight:"medium"},(0,jQ.s_)(e.amount))),a.createElement("span",{className:"flex w-6 shrink-0 justify-end"},a.createElement(eHe.MdsChevronRightIcon,{size:"sm",className:"text-content-secondary","aria-hidden":!0})))})))),!!c&&a.createElement(po.K,null,a.createElement(go.TT,{id:c,previousTransactionId:C,nextTransactionId:A,setId:b,onClose:v})))},PKe=e=>{let t=e.value,n=e.label;
1return a.createElement(Yi.S,{"data-external-id":"copy-button","aria-label":n,size:"3xs",onClick:e=>{e.stopPropagation(),(0,Bd.l)(t)}},a.createElement(LKe.MdsCopyIcon,{size:"2xs"}))};var BKe=n(63861),zKe=n(89334),FKe=n(30332),GKe=n(26025),YKe=n(76134),UKe=n(49879);const VKe=e=>{let t=e.group,n=e.detectionContext,l=e.displayedGroupCount,r=e.rating,i=e.onSubmit;const s=a.useState(!1),c=(0,o.A)(s,2),d=c[0],u=c[1],m=a.useState(null),p=(0,o.A)(m,2),g=p[0],h=p[1],v=a.useState([]),f=(0,o.A)(v,2),E=f[0],y=f[1],b=a.useState(""),x=(0,o.A)(b,2),w=x[0],C=x[1],A=void 0!==r,I=w.trim(),k="thumbs_up"===g||"thumbs_down"===g&&E.length>0,S=()=>{h(null),y([]),C("")},N=(e,t)=>{e.stopPropagation(),A||(h(t),y([]),C(""),u(!0))},T="thumbs_up"===g?"Thanks for the feedback!":"What looks wrong?";return a.createElement(fS.k.Root,{"data-external-id":"recurrence-group-feedback",open:d,onOpenChange:e=>{e||(u(!1),S())}},a.createElement(fS.k.Trigger,{render:a.createElement("div",{className:"\n              inline-flex items-center gap-0 rounded-full border border-divider-primary\n              bg-background-primary px-xs py-2xs\n              hover:border-divider-secondary\n            ",onClick:e=>e.stopPropagation()})},a.createElement(Yi.S,{"aria-label":"thumbs_up"===(null===r||void 0===r?void 0:r.feedback)?"Positive feedback given":"Give positive feedback",size:"2xs",disabled:A,onClick:e=>N(e,"thumbs_up")},"thumbs_up"===(null===r||void 0===r?void 0:r.feedback)?a.createElement(YKe.MdsThumbsUpFilledIcon,{size:"xs"}):a.createElement(GKe.MdsThumbsUpIcon,{size:"xs"})),a.createElement("span",{className:"h-3 w-px bg-divider-primary"}),a.createElement(Yi.S,{"aria-label":"thumbs_down"===(null===r||void 0===r?void 0:r.feedback)?"Negative feedback given":"Give negative feedback",size:"2xs",disabled:A,onClick:e=>N(e,"thumbs_down")},"thumbs_down"===(null===r||void 0===r?void 0:r.feedback)?a.createElement(FKe.MdsThumbsDownFilledIcon,{size:"xs"}):a.createElement(zKe.MdsThumbsDownIcon,{size:"xs"}))),a.createElement(fS.k.Content,{side:"left",align:"center",className:"w-72",onClick:e=>e.stopPropagation()},a.createElement("div",{className:"flex flex-col gap-sm p-sm"},a.createElement(kD.c,{size:"sm",weight:"medium"},T),"thumbs_down"===g?a.createElement(BKe.R.Root,{size:"sm"},a.createElement(BKe.R.Label,null,"Reason"," ",a.createElement("span",{"aria-hidden":"true",className:"text-content-danger"},"*")),a.createElement("div",{className:"flex flex-col gap-2xs"},xKe.fu.map((e=>a.createElement(LIe.K,{key:e.value,size:"sm",label:e.label,checked:E.includes(e.value),onCheckedChange:t=>{((e,t)=>{y((n=>t?[...n,e]:n.filter((t=>t!==e))))})(e.value,t)}}))))):null,a.createElement(BKe.R.Root,{size:"sm",optional:!0},a.createElement(BKe.R.Label,null,"Additional context"),a.createElement(UKe.L,{size:"sm",placeholder:"Optional details\u2026",value:w,onChange:e=>C(e.target.value),minRows:1,maxRows:3})),a.createElement("div",{className:"flex justify-end"},a.createElement(Wb.X,{size:"sm",variant:"primary",disabled:!k,onClick:e=>{if(e.stopPropagation(),!g)return;if("thumbs_down"===g&&0===E.length)return;const a=(0,U.A)({feedback:g,reasons:"thumbs_down"===g?E:[]},I?{reasonFreeForm:I}:{});(0,Ge.u4)(Ye.ER.PlaygroundFeedback,(0,U.A)((0,U.A)({feedback:g,reasons:a.reasons},I?{reasonFreeForm:I}:{}),{},{groupId:t.id,merchantName:t.merchant,length:t.length,avgAmount:Math.round(t.avgAmount),interval:t.interval,avgInterval:Math.round(t.avgInterval),confidenceBucket:(0,XTe.v0)(t.confidence),displayedGroupCount:l},(0,xKe.fs)(n))),i(a),u(!1),S()}},"Submit")))))};var WKe=n(11669),jKe=n(84852),HKe=n(92508);const KKe=(0,qy.f)("chart-label"),qKe=(0,qy.f)("chart-axis"),$Ke=(0,qy.f)("content-info"),ZKe=(0,qy.f)("content-success"),JKe=(0,qy.f)("content-danger"),XKe={top:8,right:16,bottom:0,left:8},QKe=160-XKe.bottom-24,eqe=e=>{let t=e.transactions,n=e.expectedInterval,l=e.forecastedDates,r=e.avgInterval,i=e.avgAmount;const s=a.useState(null),c=(0,o.A)(s,2),d=c[0],u=c[1],m=a.useMemo((()=>{const e=t.map((e=>({date:N.c9.fromISO(e.date),amount:Math.abs(e.amount)}))).filter((e=>e.date.isValid)).sort(((e,t)=>e.date.toMillis()-t.date.toMillis()));return e.map(((t,n)=>
1({ts:t.date.toMillis(),amount:t.amount,dateLabel:t.date.toFormat("MMM d, yyyy"),daysSincePrevious:n>0?Math.round(t.date.diff(e[n-1].date,"days").days):void 0})))}),[t]);if(0===m.length)return null;const p=m[0].ts,g=m[m.length-1].ts,h=N.c9.fromMillis(p),v=N.c9.fromMillis(g),f=Math.max(Math.round(v.diff(h,"days").days),1),E=Math.abs(i),y=1.15*Math.max(E,...m.map((e=>e.amount))),b=tqe({forecastedDates:l,expectedInterval:n,firstDate:h,lastDate:v}),x={fontSize:11,fill:KKe,fontWeight:500};return a.createElement("div",{"data-external-id":"recurrence-timeline",className:"rounded-default border border-divider-primary bg-background-primary p-lg"},a.createElement("div",{className:"mb-md flex flex-wrap items-center justify-between gap-md"},a.createElement(kD.c,{size:"sm",weight:"medium"},"Transaction Timeline"),a.createElement("div",{className:"flex flex-wrap items-center gap-md"},a.createElement(kD.c,{size:"xs",color:"secondary"},m.length," transactions over ",f," days"),n>0&&a.createElement(kD.c,{size:"xs",color:"secondary"},"Expected interval:"," ",a.createElement(kD.c,{size:"xs",weight:"medium",render:a.createElement("span",null)},n.toFixed(1)," days")),r>0&&a.createElement(kD.c,{size:"xs",color:"secondary"},"Actual avg:"," ",a.createElement(kD.c,{size:"xs",weight:"medium",render:a.createElement("span",null)},r.toFixed(1)," days")))),a.createElement("div",{className:"relative"},a.createElement(ya.u,{width:"100%",height:160},a.createElement(WKe.t,{margin:XKe},a.createElement(xa.W,{type:"number",dataKey:"ts",scale:"time",domain:[p,g],height:24,tick:x,stroke:qKe,tickLine:!1,axisLine:!1,tickCount:5,padding:{left:12,right:12},tickFormatter:e=>N.c9.fromMillis(e).toFormat("MMM d")}),a.createElement(wa.h,{type:"number",dataKey:"amount",domain:[0,y],tick:x,stroke:qKe,tickLine:!1,axisLine:!1,width:48,tickCount:4,tickFormatter:e=>"$".concat(Math.round(e))}),b.map((e=>a.createElement(eb.e_,{key:"expected-".concat(e),x:e,stroke:JKe,strokeDasharray:"6 3",strokeWidth:2}))),a.createElement(Aa.m,{cursor:{strokeDasharray:"3 3"},content:nqe}),a.createElement(jKe.Xl,{data:m,shape:e=>{let t=e.cx,n=e.cy;return void 0===t||void 0===n?a.createElement("g",null):a.createElement("rect",{x:t-4,y:n,width:8,height:Math.max(QKe-n,0),rx:4,fill:$Ke})},isAnimationActive:!1}),E>0&&a.createElement(eb.e_,{y:E,stroke:ZKe,strokeDasharray:"4 4",strokeWidth:1,ifOverflow:"extendDomain"}),a.createElement(HKe.Y,{component:e=>{const t=e.xAxisMap&&Object.values(e.xAxisMap)[0],n=e.yAxisMap&&Object.values(e.yAxisMap)[0],l=e.offset;return t&&n&&l?a.createElement("g",null,b.map((e=>{const n=t.scale(e);return a.createElement("rect",{key:"expected-hit-".concat(e),x:n-6,y:l.top,width:12,height:l.height,fill:"transparent",onMouseEnter:()=>u({left:n,top:l.top,header:"Expected transaction",label:"Expected on",value:N.c9.fromMillis(e).toFormat("MMM d, yyyy")}),onMouseLeave:()=>u(null)})})),E>0&&(()=>{const e=n.scale(E);return a.createElement("rect",{x:l.left,y:e-6,width:l.width,height:12,fill:"transparent",onMouseEnter:()=>u({left:l.left+l.width/2,top:e,header:"Average amount",label:"Amount",value:"$".concat(E.toFixed(2))}),onMouseLeave:()=>u(null)})})()):a.createElement("g",null)}}))),d&&a.createElement("div",{className:"pointer-events-none absolute z-10 -translate-x-1/2 -translate-y-[calc(100%+8px)]",style:{left:d.left,top:d.top}},a.createElement(Sa.II,{active:!0,header:d.header},a.createElement(Na.B,{label:d.label,value:d.value})))),a.createElement("div",{className:"mt-sm flex flex-wrap items-center gap-md"},a.createElement("span",{className:"flex items-center gap-2xs"},a.createElement("span",{className:"inline-block h-0 w-4 border-t-2 border-dashed",style:{borderColor:ZKe}}),a.createElement(kD.c,{size:"2xs",color:"secondary"},"Average amount",E>0?" ($".concat(E.toFixed(2),")"):"")),b.length>0&&a.createElement("span",{className:"flex items-center gap-2xs"},a.createElement("span",{className:"inline-block h-0 w-4 border-t-2 border-dashed",style:{borderColor:JKe}}),a.createElement(kD.c,{size:"2xs",color:"secondary"},"Expected transaction"))))},tqe=e=>{let t=e.forecastedDates,n=e.expectedInterval,a=e.firstDate,l=e.lastDate;if(Array.isArray(t))return(e=>e.map((e=>N.c9.fromISO(e))).filter((e=>e.isValid)).map((e=>e.toMillis())))(t);if(n<=0)return[];const r=[];let o=a.plus({days:n});for(;o<=l;)r.push(o.toMillis()),o=o.plus({days:n});return r},nqe=e=>{const t=(0,_a.WS)(e);return t?a.createElement(Sa.II,{"data-external-id":"timeline-tooltip",active:e.active,header:t.dateLabel},a.createElement(Na.B,{label:"Amount",value:"$".concat(t.amount.toFixed(2))}),void 0!==t.daysSincePrevious&&a.createElement(Na.B,{label:"Since previous",value:"".concat(t.daysSincePrevious," days")})):null};var aqe=n(358),lqe=n(97087),rqe=n(75462);const oqe={left:"text-left",center:"text-center",right:"text-right"},iqe={left:"",center:"flex justify-center",right:"flex justify-end"},sqe={expand:{className:"w-10 shrink-0",align:"left"},merchant:{className:"max-w-56 whitespace-nowrap",align:"left"},recurrence:{className:"whitespace-nowrap",align:"center"},history:{className:"whitespace-nowrap",align:"left"},length:{className:"whitespace-nowrap",align:"center"},confidence:{className:"whitespace-nowrap",align:"center"},lastSeen:{className:"whitespace-nowrap",align:"center"},interval:{className:"whitespace-nowrap",align:"center"},amount:{className:"whitespace-nowrap",align:"right"},feedback:{className:"w-24 shrink-0",align:"center"}},cqe=Object.keys(sqe).length,dqe=e=>{var t;let n=e.groups,l=e.detectionContext,i=e.ratings,s=e.onFeedbackSubmit,c=e.showFilteredEmpty,d=void 0!==c&&c,u=e.headerAction;const m=a.useState(new Set),p=(0,o.A)(m,2),g=p[0],h=p[1],v=a.useState((()=>uqe(n))),f=(0,o.A)(v,2),E=f[0],y=f[1],b=a.useState({key:"length",direction:"desc"}),x=(0,o.A)(b,2),w=x[0],C=x[1],A=a.useMemo((()=>[...new Set(n.flatMap((e=>e.transactions.map((e=>e.id)))))]),[n]),I=(0,et.I)(V8.ZS,{variables:{filters:{ids:A},limit:A.length,offset:0},skip:0===A.length}).data,k=a.useMemo((()=>{var e,t;return new Map((null!==(e=null===I||void 0===I||null===(t=I.allTransactions)||void 0===t?void 0:t.results)&&void 0!==e?e:[]).map((e=>[e.id,e])))}),[null===I||void 0===I||null===(t=I.allTransactions)||void 0===t?void 0:t.results]);a.useEffect((()=>{y(uqe(n)),h(new Set)}),[n]),a.useEffect((()=>{h(new Set)}),[l.sessionKey]);const S=a.useMemo((()=>{const e="desc"===w.direction?-1:1;return[...n].sort(((t,n)=>(0,r.YW)(w.key).with("merchant",(()=>e*t.merchant.localeCompare(n.merchant))).with("recurrence",(()=>e*(t.interval-n.interval))).with("interval",(()=>e*(t.avgInterval-n.avgInterval))).with("amount",(()=>e*(t.avgAmount-n.avgAmount))).with("lastSeen",(()=>{var a,l;const r=null!==(a=(0,xKe.DF)(t.transactions))&&void 0!==a?a:"",o=null!==(l=(0,xKe.DF)(n.transactions))&&void 0!==l?l:"";return e*r.localeCompare(o)})).with("length","confidence",(a=>e*(t[a]-n[a]))).exhaustive()))}),[n,w]),N=a.useMemo((()=>new Map(S.map((e=>{var t;return[e.id,(0,fVe.x1)(e.transactions,null!==(t=(0,rqe.w8)(e.interval))&&void 0!==t?t:"monthly")]})))),[S]),T=a.useMemo((()=>(0,xKe._y)(S)),[S]),_=T.reduce(((e,t)=>e+t.groups.length),0),D=e=>C((t=>t.key===e?{key:e,direction:"desc"===t.direction?"asc":"desc"}:{key:e,direction:"desc"}));return a.createElement(RP.x,{"data-external-id":"detected-recurrence-groups"},a.createElement(RP.x.Header,null,a.createElement("div",{className:"flex flex-col gap-2xs"},a.createElement(RP.x.Title,null,"Detected Recurrence Groups"),a.createElement(RP.x.Description,null,"Expand each row to see the group ID and individual transactions.")),a.createElement(RP.x.Action,null,a.createElement("div",{className:"flex items-center gap-sm"},u,a.createElement(c5.C,{color:"brand",variant:"subtle"},_," ",1===_?"group":"groups")))),d?a.createElement(RP.x.Content,null,a.createElement(MP.e,{variant:"secondary",title:"No groups match these filters",description:"Clear or adjust the Merchants filter to see results again."})):a.createElement(RP.x.Content,{className:"flex flex-col gap-0 p-0"},T.map((e=>{const t=E.has(e.type);return a.createElement("div",{key:e.type,className:"flex flex-col"},a.createElement("button",{type:"button",onClick:()=>{return t=e.type,void y((e=>{const n=new Set(e);return n.has(t)?n.delete(t):n.add(t),n}));var t},className:" flex w-full cursor-pointer appearance-none items-center gap-xs border-0 border-b border-divider-primary bg-background-secondary px-md py-sm text-left hover:bg-background-tertiary ","aria-expanded":t},t?a.createElement(aqe.MdsChevronDownIcon,{size:"xs",className:"text-content-secondary"}):a.createElement(eHe.MdsChevronRightIcon,{size:"xs",className:"text-content-secondary"}),a.createElement(kD.c,{size:"sm",weight:"medium",render:a.createElement("span",null)},e.label),a.createElement(c5.C,{color:"gray-secondary",variant:"subtle",rounded:"pill",size:"md",preferCircle:!0},e.groups.length)),t&&a.createElement("table",{className:"w-full border-collapse text-left"},a.createElement("thead",null,a.createElement("tr",{className:"border-b border-divider-primary"},a.createElement("th",{className:pqe("expand")}),a.createElement(gqe,{align:sqe.merchant.align,className:sqe.merchant.className,sortDirection:"merchant"===w.key?w.direction:null,onSort:()=>D("merchant")}
1,"Merchant"),a.createElement(gqe,{align:sqe.recurrence.align,className:sqe.recurrence.className,sortDirection:"recurrence"===w.key?w.direction:null,onSort:()=>D("recurrence")},"Recurrence"),a.createElement(gqe,{align:sqe.history.align,className:sqe.history.className},"History"),a.createElement(gqe,{align:sqe.length.align,className:sqe.length.className,sortDirection:"length"===w.key?w.direction:null,onSort:()=>D("length")},"Length"),a.createElement(gqe,{align:sqe.confidence.align,className:sqe.confidence.className,sortDirection:"confidence"===w.key?w.direction:null,onSort:()=>D("confidence")},"Confidence"),a.createElement(gqe,{align:sqe.lastSeen.align,className:sqe.lastSeen.className,sortDirection:"lastSeen"===w.key?w.direction:null,onSort:()=>D("lastSeen")},"Last seen"),a.createElement(gqe,{align:sqe.interval.align,className:sqe.interval.className,sortDirection:"interval"===w.key?w.direction:null,onSort:()=>D("interval")},"Interval"),a.createElement(gqe,{align:sqe.amount.align,className:sqe.amount.className,sortDirection:"amount"===w.key?w.direction:null,onSort:()=>D("amount")},"Amount"),a.createElement(gqe,{align:sqe.feedback.align,className:sqe.feedback.className},"Feedback"))),a.createElement("tbody",null,e.groups.map(((e,t)=>{var n,r;const o=g.has(e.id);return a.createElement(a.Fragment,{key:e.id},a.createElement("tr",{className:"cursor-pointer border-b border-divider-primary hover:bg-background-secondary",onClick:()=>{return t=e.id,void h((e=>{const n=new Set(e);return n.has(t)?n.delete(t):n.add(t),n}));var t}},a.createElement("td",{className:"".concat(pqe("expand")," text-content-secondary")},o?a.createElement(aqe.MdsChevronDownIcon,{size:"xs"}):a.createElement(eHe.MdsChevronRightIcon,{size:"xs"})),a.createElement("td",{className:pqe("merchant")},a.createElement("span",{className:"flex min-w-0 items-center gap-xs"},a.createElement("span",{className:"size-2 shrink-0 rounded-full",style:{backgroundColor:(0,xKe.Ws)(t)}}),a.createElement(kD.c,{size:"sm",render:a.createElement("span",{className:"min-w-0 truncate"})},e.merchant))),a.createElement("td",{className:pqe("recurrence")},a.createElement(kD.c,{size:"sm"},(0,xKe.pG)(e.interval))),a.createElement("td",{className:pqe("history")},a.createElement(EVe,{intervals:null!==(n=N.get(e.id))&&void 0!==n?n:[]})),a.createElement("td",{className:pqe("length")},a.createElement(kD.c,{size:"sm"},e.length)),a.createElement("td",{className:pqe("confidence")},a.createElement(kD.c,{size:"sm",weight:"medium",color:(0,xKe.rf)(e.confidence)},(100*e.confidence).toFixed(0),"%")),a.createElement("td",{className:pqe("lastSeen")},a.createElement(kD.c,{size:"sm",color:"secondary"},null!==(r=(0,xKe.DF)(e.transactions))&&void 0!==r?r:"\u2014")),a.createElement("td",{className:pqe("interval")},a.createElement(kD.c,{size:"sm"},(0,xKe.CU)(e.avgInterval))),a.createElement("td",{className:pqe("amount")},a.createElement(kD.c,{size:"sm",color:(0,jQ.iR)(e.avgAmount)?"success":"primary",weight:"medium"},(0,jQ.s_)(e.avgAmount))),a.createElement("td",{className:pqe("feedback"),onClick:e=>e.stopPropagation()},a.createElement("div",{className:"flex justify-center"},a.createElement(VKe,{group:e,detectionContext:l,displayedGroupCount:_,rating:i[e.id],onSubmit:t=>s(e.id,t)})))),o&&a.createElement("tr",{className:"border-b border-divider-primary bg-background-secondary"},a.createElement("td",{colSpan:cqe,className:"p-lg"},a.createElement("div",{className:"flex flex-col gap-md"},a.createElement("div",{className:"flex items-center gap-xs"},a.createElement(kD.c,{size:"xs",color:"secondary",weight:"medium"},"Group ID"),a.createElement(kD.c,{size:"xs",weight:"medium",render:a.createElement("span",{className:"font-mono"})},e.id),a.createElement(mqe,{value:e.id,label:"Copy group ID"})),a.createElement(eqe,{transactions:e.transactions,expectedInterval:e.interval,forecastedDates:e.forecastedDates,avgInterval:e.avgInterval,avgAmount:e.avgAmount}),a.createElement(OKe,{transactions:e.transactions,enrichmentById:k,totalCount:e.length})))))})))))}))))},uqe=e=>{var t,n,a;const l=(0,xKe._y)(e),r=null!==(t=null===(n=l.find((e=>"expense"===e.type)))||void 0===n?void 0:n.type)&&void 0!==t?t:null===(a=l[0])||void 0===a?void 0:a.type;return new Set([null!==r&&void 0!==r?r:"expense"])},mqe=e=>{let t=e.value,n=e.label;
1return a.createElement(Yi.S,{"data-external-id":"copy-button","aria-label":n,size:"3xs",onClick:e=>{e.stopPropagation(),(0,Bd.l)(t)}},a.createElement(LKe.MdsCopyIcon,{size:"2xs"}))},pqe=e=>"px-md py-sm align-middle ".concat(oqe[sqe[e].align]," ").concat(sqe[e].className),gqe=e=>{let t=e.children,n=e.align,l=void 0===n?"left":n,r=e.className,o=e.sortDirection,i=e.onSort;const s="asc"===o||"desc"===o,c=a.createElement(kD.c,{size:"xs",color:s?"primary":"secondary",weight:"medium",render:a.createElement("span",null)},t),d=()=>"asc"===o?a.createElement(lqe.MdsChevronUpIcon,{size:"2xs"}):"desc"===o?a.createElement(aqe.MdsChevronDownIcon,{size:"2xs"}):a.createElement(aqe.MdsChevronDownIcon,{size:"2xs",className:"opacity-0 group-hover:opacity-40"});return a.createElement("th",{"data-external-id":"header-cell",className:"px-md py-sm ".concat(oqe[l]," ").concat(null!==r&&void 0!==r?r:"")},i?a.createElement("div",{className:iqe[l]},a.createElement("button",{type:"button",onClick:i,className:"\n              group inline-flex cursor-pointer appearance-none items-center gap-2xs border-0\n              bg-transparent p-0 transition-colors\n              ".concat(s?"text-content-primary":"text-content-secondary hover:text-content-primary")},"right"===l?a.createElement(a.Fragment,null,d(),c):a.createElement(a.Fragment,null,c,d()))):c)};var hqe=n(1761),vqe=n(8778),fqe=n(88122);const Eqe=e=>{let t=e.outcomes;return a.createElement(RP.x,{"data-external-id":"incoming-transaction-outcome-list"},a.createElement(RP.x.Header,null,a.createElement("div",{className:"flex flex-col gap-2xs"},a.createElement(RP.x.Title,null,"Incoming Transaction Outcomes"),a.createElement(RP.x.Description,null,"What each replayed transaction did on arrival: attached to an existing stream, formed a new one, or had no impact.")),a.createElement(RP.x.Action,null,a.createElement(c5.C,{color:"brand",variant:"subtle"},t.length," ",1===t.length?"transaction":"transactions"))),a.createElement(RP.x.Content,{className:"flex flex-col gap-0 p-0"},t.map((e=>a.createElement(yqe,{key:e.outcome.transactionId,resolved:e})))))},yqe=e=>{let t=e.resolved;const n=t.outcome,l=t.was,r=t.became,o=t.hasUnresolvedReference,i=n.outcome,s=(0,xKe.kj)({kind:i,hasUnresolvedReference:o,apiReason:null});return a.createElement(hqe.X,{"data-external-id":"outcome-row",defaultOpen:!1,className:"border-b border-divider-primary last:border-b-0"},a.createElement("div",{className:"flex items-stretch hover:bg-background-secondary"},a.createElement(hqe.X.Trigger,{"aria-label":"Toggle outcome details",className:(0,q.cn)("\n            flex min-w-0 flex-1 cursor-pointer appearance-none items-center gap-sm border-0\n            bg-transparent p-md text-left\n          ")},a.createElement(eHe.MdsChevronRightIcon,{size:"xs",className:"shrink-0 text-content-secondary transition-transform in-aria-expanded:rotate-90"}),a.createElement(bqe,{resolved:t})),a.createElement("div",{className:"flex shrink-0 items-center pr-md"},a.createElement(Cqe,{value:n.transactionId,label:"Copy transaction ID"}))),a.createElement(hqe.X.Content,null,a.createElement("div",{className:"flex flex-col gap-sm px-md pb-md"},s&&a.createElement("div",{className:"flex items-start gap-2xs"},o&&a.createElement(vqe.MdsAlertTriangleIcon,{size:"2xs",className:"mt-3xs shrink-0 text-content-warning"}),a.createElement(kD.c,{size:"xs",color:o?"warning":"secondary"},s)),a.createElement(xqe,{kind:i,was:l,became:r}))))},bqe=e=>{const t=e.resolved.outcome,n=t.outcome;return a.createElement("div",{"data-external-id":"outcome-row-header",className:"flex min-w-0 flex-1 flex-wrap items-center gap-sm"},a.createElement(c5.C,{color:xKe.Hb[n],variant:"subtle"},xKe.AX[n]),a.createElement("span",{className:"flex min-w-0 items-center gap-2xs"},a.createElement(kD.c,{size:"xs",color:"secondary"},"Txn"),a.createElement(kD.c,{size:"xs",weight:"medium",render:a.createElement("span",{className:"truncate font-mono"})},t.transactionId)),a.createElement(kD.c,{size:"xs",color:"secondary",render:a.createElement("span",{className:"truncate"})},t.externalId))},xqe=e=>{let t=e.kind,n=e.was,l=e.became;return t===Ee.HHU.NO_IMPACT?null:t===Ee.HHU.CREATED_NEW?l?a.createElement(wqe,{"data-external-id":"outcome-streams",label:"New stream",group:l}):null:a.createElement("div",{"data-external-id":"outcome-streams",className:"flex flex-col items-stretch gap-sm md:flex-row md:items-start"},n&&a.createElement("div",{className:"min-w-0 flex-1"},a.createElement(wqe,{label:"Was (seed)",group:n})),n&&l&&a.createElement("div",{className:"flex shrink-0 items-center justify-center pt-lg text-content-secondary md:self-center md:pt-0"},a.createElement(fqe.MdsArrowRightIcon,{size:"xs"})),l&&a.createElement("div",{className:"min-w-0 flex-1"},a.createElement(wqe,{label:"Became (final)",group:l})))},wqe=e=>{let t=e.label,n=e.group;const l=a.useMemo((()=>[...n.transactions].sort(((e,t)=>e.date.localeCompare(t.date)))),[n.transactions]);return a.createElement("div",{"data-external-id":"stream-summary",className:"flex flex-col gap-xs rounded-sm border border-divider-primary bg-background-secondary p-sm"},a.createElement("div",{className:"flex flex-wrap items-center gap-xs"},a.createElement(kD.c,{size:"xs",color:"secondary",weight:"medium"},t),a.createElement(kD.c,{size:"sm",weight:"medium",render:a.createElement("span",{className:"min-w-0 truncate"})},n.merchant),a.createElement(c5.C,{color:"gray-secondary",variant:"subtle"},n.transactions.length," ",1===n.transactions.length?"txn":"txns"),a.createElement(Cqe,{value:n.id,label:"Copy stream ID"})),a.createElement("div",{className:"flex flex-col gap-2xs"},l.map((e=>a.createElement("div",{key:e.id,className:"flex items-center justify-between gap-md"},a.createElement(kD.c,{size:"xs",color:"secondary"},e.date),a.createElement(kD.c,{size:"xs",color:(0,jQ.iR)(e.amount)?"success":"primary"},(0,jQ.s_)(e.amount)))))))},Cqe=e=>{let t=e.value,n=e.label;
1return a.createElement(Yi.S,{"data-external-id":"copy-button","aria-label":n,size:"3xs",onClick:e=>{e.stopPropagation(),(0,Bd.l)(t)}},a.createElement(LKe.MdsCopyIcon,{size:"2xs"}))},Aqe=(e,t)=>{const n=e.date.localeCompare(t.date);return 0!==n?n:e.externalId.localeCompare(t.externalId)},Iqe=Ee.oix,kqe=Ee._p_,Sqe=Ee.mIG,Nqe=a.memo((e=>{var t,n,l;let r=e.startDate,o=e.endDate,i=e.merchantIds,s=e.selectedTransactionIds,c=e.onSelectionChange,d=e.onStatusChange,u=e.disabled,m=void 0!==u&&u;const g=a.useMemo((()=>({startDate:r,endDate:o,merchantIds:i})),[r,o,i]),h=(0,xy.d)(g,RIe.N),v=g.startDate!==h.startDate||g.endDate!==h.endDate||g.merchantIds!==h.merchantIds,f=(0,et.I)(Iqe,{variables:{filters:{startDate:h.startDate,endDate:h.endDate,merchants:h.merchantIds.length>0?[...h.merchantIds]:void 0},limit:500,offset:0},fetchPolicy:"cache-and-network"}),E=f.data,y=f.isNetworkRequestInFlight,b=null!==(t=null===E||void 0===E||null===(n=E.allTransactions)||void 0===n?void 0:n.totalCount)&&void 0!==t?t:0,x=null===E||void 0===E||null===(l=E.allTransactions)||void 0===l?void 0:l.results,w=b>500,C=v||y,A=a.useMemo((()=>x?(e=>{const t=new Map;return e.forEach((e=>{var n,a,l;if(!e.merchant)return;const r=t.get(e.merchant.id),o=null!==r&&void 0!==r?r:{merchantId:e.merchant.id,merchantName:e.merchant.name,transactions:[],displayRows:[]},i=(null===(n=e.plaidName)||void 0===n?void 0:n.trim())||(null===(a=e.dataProviderDescription)||void 0===a?void 0:a.trim())||null,s=(null===(l=e.externalId)||void 0===l?void 0:l.trim())||e.id,c={id:e.id,externalId:s,date:e.date,amount:e.amount,dateLabel:N.c9.fromISO(e.date).toFormat("MMM d"),amountLabel:(0,jQ.s_)(e.amount),isIncomeAmount:(0,jQ.iR)(e.amount),name:i};o.transactions=[...o.transactions,c],t.set(e.merchant.id,o)})),[...t.values()].map((e=>{const t=[...e.transactions].sort(Aqe);return(0,U.A)((0,U.A)({},e),{},{transactions:t,displayRows:[...t].reverse()})})).sort(((e,t)=>e.merchantName.localeCompare(t.merchantName)))})(x):[]),[x]),I=a.useMemo((()=>A.map((e=>e.transactions.length))),[A]),k=a.useMemo((()=>A.flatMap((e=>{const t=e.transactions.map((e=>e.id));return e.displayRows.map(((n,a)=>({merchantId:e.merchantId,orderedIds:t,displayRows:e.displayRows,txn:n,displayIndex:a})))}))),[A]),S=a.useMemo((()=>((e,t)=>{const n=new Map;return e.forEach((e=>{n.set(e.merchantId,(0,xKe.it)(e.transactions.map((e=>e.id)),t))})),n})(A,s)),[A,s]),T=a.useMemo((()=>A.flatMap((e=>e.transactions.map((e=>e.id))))),[A]),_=a.useRef(s);_.current=s,a.useLayoutEffect((()=>{if(!x)return;const e=new Set(T),t=new Set([...s].filter((t=>e.has(t))));A.forEach((e=>{const n=e.transactions.map((e=>e.id)),a=(0,xKe.EY)(n,t);n.forEach((e=>t.delete(e))),a.forEach((e=>t.add(e)))}));t.size===s.size&&[...t].every((e=>s.has(e)))||c(t)}),[x,T,A,s,c]),a.useLayoutEffect((()=>{null===d||void 0===d||d({isLoadingCandidates:C,isTruncated:w,totalAvailable:b})}),[C,w,b,d]);const D=a.useCallback(((e,t)=>{const n=_.current,a=new Set(e),l=new Set([...n].filter((e=>a.has(e)))),r=(0,xKe.ud)(e,l,t),o=new Set(n);e.forEach((e=>o.delete(e))),r.forEach((e=>o.add(e))),c(o)}),[c]),R=a.useCallback((e=>{c(((e,t)=>{const n=new Set(e);return t.forEach((e=>n.add(e))),n})(_.current,e.transactions.map((e=>e.id))))}),[c]),M=a.useCallback((()=>{c(new Set(T))}),[T,c]),L=a.useCallback((()=>{c(new Set)}),[c]),O=s.size>0,P=a.useCallback((e=>{var t;const n=A[e];if(!n)return null;const l=null!==(t=S.get(n.merchantId))&&void 0!==t?t:0;return a.createElement(Tqe,{merchant:n,selectedCount:l,disabled:m,onSelectAllMerchant:R})}),[m,R,A,S]),B=a.useCallback((e=>{var t;const n=k[e];if(!n)return null;const l=null!==(t=S.get(n.merchantId))&&void 0!==t?t:0,r=((e,t,n)=>{if(n<=0||0===e.length)return!1;const a=n-1,l=n;if(t!==a&&t!==l)return!1;const r=e[a],o=e[l];return!(!r||!o)&&r.date===o.date})(n.displayRows,n.displayIndex,l);return a.createElement(_qe,{txn:n.txn,displayIndex:n.displayIndex,selectedCount:l,isSelected:s.has(n.txn.id),disabled:m,orderedIds:n.orderedIds,sameDateAcrossBoundary:r,onToggle:D})}),[m,k,D,S,s]);return a.createElement(RP.x,{"data-external-id":"incremental-replay-picker"},a.createElement(RP.x.Header,null,a.createElement("div",{className:"flex flex-col gap-2xs"}
1,a.createElement(RP.x.Title,null,"Transactions to replay as new"),a.createElement(RP.x.Description,null,"Only selected transactions are fed as newly arrived. Per merchant, only the newest tail is selectable \u2014 older transactions form the seed (the world before the arrivals)."))),a.createElement(RP.x.Content,{className:"flex flex-col gap-md"},C&&0===A.length&&a.createElement("div",{className:"flex flex-col items-center gap-md py-xl"},a.createElement(p.i,null),a.createElement(kD.c,{size:"sm",color:"secondary"},"Loading transactions\u2026")),!C&&0===A.length&&a.createElement(MP.e,{variant:"secondary",title:"No transactions to replay",description:"Widen the date range or clear the merchant filter to find candidates."}),A.length>0&&a.createElement(a.Fragment,null,a.createElement("div",{className:"flex flex-col gap-sm"},w&&a.createElement(gme.h,{variant:"warning"},"Showing ",500," of ",b," transactions. Narrow the date range or pick a merchant to load everything, then run detection."),!O&&!w&&a.createElement(gme.h,{variant:"warning"},"Nothing selected \u2014 Run detection stays disabled until you select at least one transaction."),a.createElement("div",{className:"flex items-center justify-between gap-md"},a.createElement(kD.c,{size:"sm",color:"secondary"},((e,t)=>"".concat(e," of ").concat(t))(s.size,b),w?" \xb7 truncated":""),a.createElement("div",{className:"flex items-center gap-xs"},a.createElement(Wb.X,{variant:"default",size:"sm",disabled:m||0===T.length,onClick:M},"Select all"),a.createElement(Wb.X,{variant:"default",size:"sm",disabled:m||!O,onClick:L},"Clear")))),a.createElement("div",{className:"overflow-hidden rounded-default border border-divider-primary bg-background-primary",style:{height:448}},a.createElement(Ac.kN,{style:{height:"100%"},groupCounts:I,groupContent:P,itemContent:B})))))})),Tqe=a.memo((e=>{let t=e.merchant,n=e.selectedCount,l=e.disabled,r=e.onSelectAllMerchant;const o=t.transactions.length,i=n===o;return a.createElement("div",{"data-external-id":"merchant-section-header",className:" flex items-center justify-between gap-sm border-b border-divider-primary bg-background-secondary px-md py-sm "},a.createElement("div",{className:"flex min-w-0 items-center gap-xs"},a.createElement(kD.c,{size:"sm",weight:"medium",render:a.createElement("span",{className:"min-w-0 truncate"})},t.merchantName),a.createElement(kD.c,{size:"sm",color:"secondary"},"\xb7 ",o)),a.createElement(Wb.X,{variant:"default",size:"sm",disabled:l||i,onClick:()=>r(t)},"Select all ",t.merchantName))})),_qe=a.memo((e=>{let t=e.txn,n=e.displayIndex,l=e.selectedCount,r=e.isSelected,o=e.disabled,i=e.orderedIds,s=e.sameDateAcrossBoundary,c=e.onToggle;const d=((e,t)=>e<t?"replay":e===t?"next":"seed")(n,l),u="next"===d,m="seed"===d,p=o||m,g=s?"Same date as a neighbor across the seed/tail boundary \u2014 order matches backend arrival order (external id tiebreak).":void 0;let h="primary";t.isIncomeAmount?h="success":m&&(h="secondary");const v=(0,q.cn)("flex items-center gap-md border-b border-b-divider-primary px-md py-sm",!m&&"cursor-pointer hover:bg-background-secondary",{"bg-background-brand-subtle":r,"border-l-2 border-l-border-warning":s}),f=a.createElement(a.Fragment,null,a.createElement(LIe.K,{checked:r,disabled:p,onCheckedChange:()=>{p||c(i,t.id)}}),a.createElement(kD.c,{size:"sm",color:"secondary",render:a.createElement("span",{className:"w-24 shrink-0"})},t.dateLabel,s?" \xb7 same day":""),t.name?a.createElement(kD.c,{size:"sm",color:m?"secondary":"primary",render:a.createElement("span",{className:"min-w-0 flex-1 truncate",title:t.name})},t.name):a.createElement("span",{className:"min-w-0 flex-1"}),a.createElement(kD.c,{size:"sm",color:h,render:a.createElement("span",{className:"shrink-0 text-right"})},t.amountLabel),a.createElement("span",{className:"w-16 shrink-0 text-right"},r&&a.createElement(c5.C,{color:"brand",variant:"subtle"},"Replay"),m&&a.createElement(Wi.Y,{content:"Part of the seed (the world before the replay suffix). Select Next to grow the suffix and include this transaction.",side:"left"},a.createElement(c5.C,{color:"gray-secondary",variant:"subtle"},"Seed")),u&&a.createElement(kD.c,{size:"xs",color:"secondary"},"Next")));return m?a.createElement("div",{"data-external-id":"transaction-row",title:g,className:v},f):a.createElement("label",{"data-external-id":"transaction-row",title:g,className:v},f)})),Dqe=(e,t)=>
1e.filter((e=>e.status===t)),Rqe=e=>e.some((e=>e.status===Ee.hlJ.TIMED_OUT||e.status===Ee.hlJ.ERROR||e.status===Ee.hlJ.MERCHANT_NOT_FOUND)),Mqe=e=>0===e.length?"":e.length<=3?e.join(", "):"".concat(e.slice(0,3).join(", ")," and ").concat(e.length-3," more"),Lqe=e=>{let t=e.statuses;const n=Dqe(t,Ee.hlJ.TIMED_OUT),l=Dqe(t,Ee.hlJ.ERROR),r=Dqe(t,Ee.hlJ.MERCHANT_NOT_FOUND);return a.createElement("div",{"data-external-id":"merchant-status-banners",className:"flex flex-col gap-md"},n.length>0&&a.createElement(gme.h,{variant:"warning"},"Detection timed out for ",Mqe(n.map((e=>e.merchant))),". Results below may be incomplete \u2014 try a shorter date range or fewer merchants."),l.length>0&&a.createElement(gme.h,{variant:"error"},"Detection failed for ",Mqe(l.map((e=>e.merchant))),"."),r.length>0&&a.createElement(gme.h,{variant:"info"},Mqe(r.map((e=>e.merchant)))," could not be found."))};var Oqe=n(62946);const Pqe=["value","formatOptions","onChange","placeholder"],Bqe=e=>{var t;let n=e.value,l=e.formatOptions,r=void 0===l?zqe:l,i=e.onChange,s=e.placeholder,c=void 0===s?"Search merchants...":s,d=(0,En.A)(e,Pqe);const u=(0,a.useState)(""),m=(0,o.A)(u,2),p=m[0],g=m[1],h=(0,Xo.IT)(ei.mR,{fetchPolicy:"network-only",variables:{includeIds:n,limit:Math.max(20,null!==(t=null===n||void 0===n?void 0:n.length)&&void 0!==t?t:0),search:""}}),v=h.data,f=h.loading,E=(0,a.useMemo)((()=>{var e;return r((null!==(e=null===v||void 0===v?void 0:v.merchants)&&void 0!==e?e:[]).filter(Boolean))}),[r,null===v||void 0===v?void 0:v.merchants]),y=(0,Oqe.IK)({formatOptions:r,search:p,seedOptions:E}),b=y.options,x=y.loading,w=(0,a.useMemo)((()=>b.map(Oqe.Id)),[b]),C=(0,a.useMemo)((()=>(null!==n&&void 0!==n?n:[]).map((e=>{var t;const n=b.find((t=>t.value===e));return{value:e,label:null!==(t=null===n||void 0===n?void 0:n.label)&&void 0!==t?t:e}}))),[b,n]),A=(0,a.useCallback)((e=>{null===i||void 0===i||i((null!==e&&void 0!==e?e:[]).map((e=>{var t;return null!==(t=b.find((t=>t.value===e.value)))&&void 0!==t?t:{value:e.value,label:"string"===typeof e.label?e.label:e.value}})))}),[b,i]);return a.createElement(U7.O,Object.assign({"data-external-id":"multi-merchant-search-select",multiple:!0,clearable:!0,placeholder:c,options:w,value:C,onValueChange:A,inputValue:p,onInputValueChange:g,filter:()=>!0,loading:x||f,openOnInputClick:!0},d))},zqe=e=>e.map((e=>{let t=e.id,n=e.name,a=e.transactionCount;return{value:t,label:n,transactionCount:null!==a&&void 0!==a?a:0}})),Fqe=(0,sG.Mz)((e=>e.recurringPlaygroundResults),(e=>e.results)),Gqe=(0,sG.Mz)((e=>e.recurringPlaygroundRatings),(e=>e.groupRatings)),Yqe=1.5*iC.K5,Uqe=10*iC.EM,Vqe="yyyy-MM-dd",Wqe=()=>{var e;const t=(0,d.wA)(),n=(0,d.d4)(Fqe),l=(0,d.d4)(Gqe),r=a.useState((()=>{var e;return null!==(e=null===n||void 0===n?void 0:n.detectionContext.startDate)&&void 0!==e?e:N.c9.now().minus({months:6}).toFormat(Vqe)})),s=(0,o.A)(r,2),c=s[0],u=s[1],m=a.useState((()=>{var e;return null!==(e=null===n||void 0===n?void 0:n.detectionContext.endDate)&&void 0!==e?e:N.c9.now().toFormat(Vqe)})),h=(0,o.A)(m,2),v=h[0],f=h[1],E=a.useState((()=>{var e;return null!==(e=null===n||void 0===n?void 0:n.detectionContext.merchantIds)&&void 0!==e?e:[]})),y=(0,o.A)(E,2),b=y[0],x=y[1],w=a.useState(Ee.N$B.BATCH),C=(0,o.A)(w,2),A=C[0],I=C[1],k=a.useState((()=>new Set)),S=(0,o.A)(k,2),T=S[0],_=S[1],D=a.useState({isLoadingCandidates:!1,isTruncated:!1,totalAvailable:0}),R=(0,o.A)(D,2),M=R[0],L=R[1],O=a.useState((()=>{var e;return null!==(e=null===n||void 0===n?void 0:n.lastRunReplayTransactionIds)&&void 0!==e?e:[]})),P=(0,o.A)(O,2),B=P[0],z=P[1],F=a.useRef(B);F.current=B;const G=A===Ee.N$B.INCREMENTAL,Y=_Ke(),V=Y.filters.merchants,W=Y.setMerchants,j=Y.hasActiveFilters,H=a.useState(),K=(0,o.A)(H,2),q=K[0],$=K[1],Z=a.useState(0),J=(0,o.A)(Z,2),X=J[0],Q=J[1],ee=a.useState(null),te=(0,o.A)(ee,2),ne=te[0],ae=te[1],le=a.useState(null),re=(0,o.A)(le,2),oe=re[0],ie=re[1],se=(0,Pc.e)(!1),ce=(0,o.A)(se,2),de=ce[0],ue=ce[1],me=ue.setOn,pe=ue.setOff,ge=a.useRef(0),he=a.useRef(!1),ve=a.useRef(),fe=a.useRef(null),ye=a.useRef(),be=a.useCallback((()=>{he.current=!1,pe()}),[pe]),xe=a.useCallback(((e,n)=>{n&&ye.current!==e.sessionKey&&(ye.current=e.sessionKey,t((0,g.rU)({completedSession:e,detectionContext:n,lastRunReplayTransactionIds:F.current}))),ie(null)}),[t]),we=a.useCallback((e=>{ie(e)}),[]),Ce=a.useCallback((e=>{ae(e)}),[]),Ae=(0,i.n)(kqe),Ie=(0,o.A)(Ae,1)[0],ke=a.useCallback((async()=>
1{if(he.current)return;if(null!==(0,xKe.P2)({isIncremental:G,isRunning:!1,isLoadingCandidates:M.isLoadingCandidates,isTruncated:M.isTruncated,selectedCount:T.size}))return;const e=ge.current+1;ge.current=e,he.current=!0,ae(null),ie(null),ye.current=void 0,me();const t={startDate:c,endDate:v,merchantIds:[...b]},n=G?[...T]:[];F.current=G?n:[],z(F.current);try{var a;const l=(await Ie({variables:{input:{startDate:t.startDate,endDate:t.endDate,merchantIds:t.merchantIds.length>0?[...t.merchantIds]:void 0,mode:A,transactionIds:G?n:void 0}}})).data;if(e!==ge.current)return;const r=null===l||void 0===l||null===(a=l.startPreviewRecurrenceDetection)||void 0===a?void 0:a.sessionKey;if(!r)return be(),void ae(new Error("Missing session key"));const o=(0,U.A)((0,U.A)({},t),{},{sessionKey:r});(0,Ge.u4)(Ye.ER.PlaygroundDetectionRunStarted,(0,U.A)((0,U.A)({},(0,xKe.fs)(o)),{},{mode:A,replayTransactionCount:n.length})),fe.current=o,ve.current=r,$(r),Q((e=>e+1))}catch(Me){if(e!==ge.current)return;be(),ae(Me instanceof Error?Me:new Error("Failed to start detection"))}}),[v,be,G,b,A,M.isLoadingCandidates,M.isTruncated,T,me,c,Ie]),Se=ne?void 0:null!==oe&&void 0!==oe?oe:null===n||void 0===n?void 0:n.completedSession,Ne=null===Se||void 0===Se?void 0:Se.status,Te=a.useMemo((()=>{var e;return Ne===Dq.A2.Completed&&null!==(e=null===Se||void 0===Se?void 0:Se.recurrenceGroups)&&void 0!==e?e:[]}),[null===Se||void 0===Se?void 0:Se.recurrenceGroups,Ne]),_e=Ne===Dq.A2.Completed&&null!==(e=null===Se||void 0===Se?void 0:Se.merchantStatuses)&&void 0!==e?e:[],De=(e=>{return e?e.status===Dq.A2.Unknown?"Detection session was not found or is unavailable.":e.status===Dq.A2.Errored?(null===(t=e.errorMessage)||void 0===t?void 0:t.trim())||"Detection failed on the server. Try again.":null:null;var t})(Se),Re=ne?"DetectionPollTimeout"===(Me=ne).name?"Detection timed out before finishing. Try a shorter date range or fewer merchants.":(e=>{if("AbortError"===e.name)return!0;const t=e.message.toLowerCase();return t.includes("abort")||t.includes("timeout")||t.includes("failed to fetch")||t.includes("network error")})(Me)?"Could not start detection. Check your connection and try again.":"Something went wrong while starting detection. Try again or narrow the date range.":De;var Me;const Le=Ne===Dq.A2.Completed,Oe=a.useMemo((()=>{var e,t,n;return Le?(0,xKe.Ks)(null!==(e=null===Se||void 0===Se?void 0:Se.incomingTransactionOutcomes)&&void 0!==e?e:[],null!==(t=null===Se||void 0===Se?void 0:Se.baselineRecurrenceGroups)&&void 0!==t?t:[],null!==(n=null===Se||void 0===Se?void 0:Se.recurrenceGroups)&&void 0!==n?n:[]):[]}),[Le,null===Se||void 0===Se?void 0:Se.incomingTransactionOutcomes,null===Se||void 0===Se?void 0:Se.baselineRecurrenceGroups,null===Se||void 0===Se?void 0:Se.recurrenceGroups]),Pe=a.useMemo((()=>{var e;if(!Le)return null;const t=null!==(e=null===Se||void 0===Se?void 0:Se.incomingTransactionOutcomes)&&void 0!==e?e:[];return 0===t.length&&0===B.length?null:(0,xKe.Ss)((0,xKe.rk)(t,B))}),[null===Se||void 0===Se?void 0:Se.incomingTransactionOutcomes,Le,B]),Be=(0,xKe.P2)({isIncremental:G,isRunning:de,isLoadingCandidates:M.isLoadingCandidates,isTruncated:M.isTruncated,selectedCount:T.size}),ze=de||null!==Be,Fe=(0,xKe._y)(Te).reduce(((e,t)=>e+t.groups.length),0),Ue=Le&&(Ve=_e,!(Fe>0)&&!Rqe(Ve));var Ve;const We=a.useMemo((()=>Te.map((e=>({name:e.merchant,recurrenceStreamCategoryType:e.categoryType})))),[Te]);a.useEffect((()=>{Le&&W(We)}),[Le,We,W]);const je=a.useMemo((()=>(0,xKe.E4)(Te,V)),[Te,V]),He=(0,xKe._y)(je).reduce(((e,t)=>e+t.groups.length),0),Ke=Le&&Fe>0&&0===He&&j;return a.createElement("div",{"data-external-id":"recurrence-playground",className:"flex w-full flex-col gap-lg p-xl"},a.createElement(jqe,{sessionKey:q,pollRequestId:X,activeSessionKeyRef:ve,isRunningRef:he,runDetectionContextRef:fe,finishRun:be,onCompletedSession:xe,onTransientSession:we,onTimeoutError:Ce}),a.createElement(gme.h,{variant:"info"},"This is an employee-only tool and is not visible to members."),a.createElement(RP.x,null,a.createElement(RP.x.Header,null,a.createElement("div",{className:"flex flex-col gap-2xs"},a.createElement(RP.x.Title,null,"Recurrence Playground"),a.createElement(RP.x.Description,null,"Run recurrence detection as a dry-run on your own household. Nothing is saved \u2014 this does not affect your real Recurring setup."))),a.createElement(RP.x.Content,{className:"gap-lg"},a.createElement("div",{className:"flex flex-col gap-2xs"},a.createElement("div",{className:"flex flex-wrap items-end gap-md"},a.createElement("div",{className:"flex min-w-60 flex-1 flex-col gap-2xs"},a.createElement(kD.c,{size:"sm",color:"secondary"},"Merchants"),a.createElement(Bqe,{placeholder:"All merchants",value:[...b],onChange:e=>x(e.map((e=>e.value)))})),a.createElement("div",{className:"flex flex-col gap-2xs"},a.createElement(kD.c,{size:"sm",color:"secondary"},"Start date"),a.createElement(Kce.J,{size:"sm",value:c,max:v,onValueChange:e=>e&&u(e)})),a.createElement("div",{className:"flex flex-col gap-2xs"},a.createElement(kD.c,{size:"sm",color:"secondary"},"End date"),a.createElement(Kce.J,{size:"sm",value:v,min:c,onValueChange:e=>e&&f(e)})),a.createElement("div",{className:"flex shrink-0 flex-col gap-2xs"},a.createElement(kD.c,{size:"sm",color:"secondary"},"Mode"),a.createElement(hP.T,{variant:"pill",value:A,onValueChange:e=>(e=>{const t=e===Ee.N$B.INCREMENTAL;
1if(I(e),!t)return _(new Set),void L({isLoadingCandidates:!1,isTruncated:!1,totalAvailable:0});L({isLoadingCandidates:!0,isTruncated:!1,totalAvailable:0})})(e),items:[{value:Ee.N$B.BATCH,label:"Batch"},{value:Ee.N$B.INCREMENTAL,label:"Incremental"}]})),a.createElement("div",{className:"flex shrink-0 flex-col gap-2xs"},a.createElement(Wb.X,{variant:"primary",disabled:ze,onClick:()=>{ke()}},de?"Running\u2026":"Run detection"))),Be&&a.createElement(kD.c,{size:"sm",color:"secondary"},Be)))),G&&a.createElement(Nqe,{startDate:c,endDate:v,merchantIds:b,selectedTransactionIds:T,onSelectionChange:_,onStatusChange:L,disabled:de}),Re&&a.createElement(gme.h.Root,{variant:"error"},a.createElement(gme.h.Title,null,"Detection failed"),a.createElement(gme.h.Description,null,Re),a.createElement(gme.h.Actions,null,a.createElement(Wb.X,{variant:"default",size:"sm",disabled:ze,onClick:()=>{ke()}},"Try again"))),de&&a.createElement("div",{className:"flex flex-col items-center gap-md p-xl"},a.createElement(p.i,null),a.createElement(kD.c,{size:"sm",color:"secondary"},"Running detection\u2026")),!de&&Le&&Rqe(_e)&&a.createElement(Lqe,{statuses:_e}),!de&&Ue&&!Pe&&0===Oe.length&&a.createElement(MP.e,{variant:"secondary",title:"No recurring streams detected",description:"Try widening the date range and running detection again."}),!de&&Le&&(Pe||Oe.length>0)&&a.createElement("div",{className:"flex flex-col gap-sm"},Pe&&a.createElement(kD.c,{size:"sm",color:"secondary"},Pe),Oe.length>0&&a.createElement(Eqe,{outcomes:Oe})),!de&&Le&&Fe>0&&(null===n||void 0===n?void 0:n.detectionContext)&&a.createElement(dqe,{groups:je,showFilteredEmpty:Ke,headerAction:a.createElement(MKe,null),detectionContext:n.detectionContext,ratings:l,onFeedbackSubmit:(e,n)=>{t((0,g.WN)({groupId:e,rating:n}))}}))},jqe=e=>{let t=e.sessionKey,n=e.pollRequestId,l=e.activeSessionKeyRef,r=e.isRunningRef,i=e.runDetectionContextRef,s=e.finishRun,c=e.onCompletedSession,d=e.onTransientSession,u=e.onTimeoutError;const m=a.useRef((()=>{})),p=(0,PH.p)(Sqe,{variables:{sessionKey:null!==t&&void 0!==t?t:""},pollUntil:e=>{const t=null===e||void 0===e?void 0:e.previewRecurrenceDetectionSession;if(!t||t.sessionKey!==l.current)return!1;const n=t.status;return n===Dq.A2.Completed||n===Dq.A2.Errored||n===Dq.A2.Unknown},onComplete:e=>{const t=null===e||void 0===e?void 0:e.previewRecurrenceDetectionSession;if(t&&t.sessionKey===l.current){s();const e=i.current;var n,a,o,u;t.status===Dq.A2.Completed?c(t,e):d(t),t.status===Dq.A2.Completed&&(null===e||void 0===e?void 0:e.sessionKey)===t.sessionKey&&(0,Ge.u4)(Ye.ER.PlaygroundDetectionRunCompleted,(0,U.A)((0,U.A)({},(0,xKe.fs)(e)),{},{groupCount:null!==(n=null===(a=t.recurrenceGroups)||void 0===a?void 0:a.length)&&void 0!==n?n:0,incomingTransactionOutcomeCount:null!==(o=null===(u=t.incomingTransactionOutcomes)||void 0===u?void 0:u.length)&&void 0!==o?o:0}))}else r.current&&l.current&&m.current()},onTimeoutReached:()=>{if(!r.current)return;s();const e=new Error("Detection poll timed out");e.name="DetectionPollTimeout",u(e)},pollIntervalMs:Yqe,pollTimeoutMs:Uqe,fetchPolicy:"network-only"}),g=(0,o.A)(p,1)[0];return m.current=g,a.useEffect((()=>{t&&0!==n&&g()}),[t,n,g]),null},Hqe=()=>a.createElement(fe.xz6.Content,{"data-external-id":"recurring-coming-soon-content",className:"min-h-64 items-center justify-center"},a.createElement(fe.erR,{variant:"secondary",title:"Coming soon"}));var Kqe,qqe;!function(e){e.Group="group",e.Orphan="orphan"}(Kqe||(Kqe={})),function(e){e.Neutral="neutral",e.NeedsReview="needsReview",e.Dropped="dropped"}(qqe||(qqe={}));const $qe=(e,t,n)=>({labelSegments:e,description:t,scope:Kqe.Group,tone:n}),Zqe=(e,t,n)=>({labelSegments:e,description:t,scope:Kqe.Orphan,tone:n}),Jqe="Not detected in V2",Xqe="Approved in V1",Qqe="Pending in V1",e$e="Merchant dismissed in V1",t$e="Stream dismissed in V1",n$e={[qqe.Neutral]:null,[qqe.NeedsReview]:"Could surface for review",[qqe.Dropped]:"Should ignore in V2"};var a$e;!function(e){e.Neutral="neutral",e.Approved="approved",e.Dismissed="dismissed",e.Pending="pending"}(a$e||(a$e={}));
1const l$e={[Ee.Wy1.V2_DETECTED_V1_NO_STREAMS]:$qe([null,"No stream in V1"],"V2 detected this on a merchant that had no V1 stream at all. There is no decision to carry \u2014 it's simply new.",qqe.Neutral),[Ee.Wy1.V2_DETECTED_V1_APPROVED_MERCHANT]:$qe([null,Xqe],"V2 detected it and V1 had it approved, so it carries over as a normal, unflagged item.",qqe.Neutral),[Ee.Wy1.V2_DETECTED_V1_PENDING_MERCHANT]:$qe([null,Qqe],"V2 detected it and the V1 stream was still pending, so there was no decision to carry. It simply shows up as detected.",qqe.Neutral),[Ee.Wy1.V2_DETECTED_V1_DISMISSED_MERCHANT]:$qe([null,e$e],"V1 marked the merchant not-recurring, but V2 detected it because V2 doesn't honour the legacy flag. It needs a keep-or-drop decision.",qqe.NeedsReview),[Ee.Wy1.V2_DETECTED_V1_DISMISSED_STREAM]:$qe([null,t$e],"The user dismissed this merchant\u2019s stream in V1 while the merchant stayed live, and V2 detected it again. Shown as a normal item rather than flagged for review \u2014 if V2\u2019s version isn\u2019t wanted, the user can dismiss it there like any other item.",qqe.Neutral),[Ee.Wy1.V2_DETECTED_USER_IGNORED]:$qe([null,"Dismissed in V2"],"The household already marked this V2 group as not recurring. That current dismiss outranks any matching V1 decision.",qqe.Dropped),[Ee.Wy1.V2_NOT_DETECTED_V1_APPROVED_MERCHANT]:Zqe([Jqe,Xqe],"An approved V1 stream that V2 did not re-detect. This used to be split by who created the stream \u2014 carrying the hand-built ones and dropping the detector-built ones \u2014 but `created_by_type` is not trustworthy, so the two are indistinguishable. Both are treated as a live decision the user has to make rather than one we make for them.",qqe.NeedsReview),[Ee.Wy1.V2_NOT_DETECTED_V1_PENDING_MERCHANT]:Zqe([Jqe,Qqe],"A pending V1 stream V2 did not re-detect. No decision was made, so nothing is lost.",qqe.Dropped),[Ee.Wy1.V2_NOT_DETECTED_V1_STREAM_NO_TRANSACTIONS]:Zqe([Jqe,"No transactions in V1"],"An approved V1 stream with no transactions behind it. A V2 group is defined by its assigned transactions, so this cannot exist in V2 at all.",qqe.Dropped),[Ee.Wy1.V2_NOT_DETECTED_V1_DISMISSED_MERCHANT]:Zqe([Jqe,e$e],"The merchant was marked not-recurring in V1, so V2 did not detect it. A surviving V1 stream carries the row details; without one, amount, frequency and type are unknown and the row lands in a default section. It should be ignored in V2.",qqe.Dropped),[Ee.Wy1.V2_NOT_DETECTED_V1_DISMISSED_STREAM]:Zqe([Jqe,t$e],"A stream the user dismissed in V1, with no V2 group to reconcile against. Nothing to carry.",qqe.Dropped)},r$e=[Ee.Wy1.V2_DETECTED_V1_NO_STREAMS,Ee.Wy1.V2_DETECTED_V1_APPROVED_MERCHANT,Ee.Wy1.V2_DETECTED_V1_PENDING_MERCHANT,Ee.Wy1.V2_DETECTED_V1_DISMISSED_MERCHANT,Ee.Wy1.V2_DETECTED_V1_DISMISSED_STREAM,Ee.Wy1.V2_DETECTED_USER_IGNORED,Ee.Wy1.V2_NOT_DETECTED_V1_APPROVED_MERCHANT,Ee.Wy1.V2_NOT_DETECTED_V1_PENDING_MERCHANT,Ee.Wy1.V2_NOT_DETECTED_V1_STREAM_NO_TRANSACTIONS,Ee.Wy1.V2_NOT_DETECTED_V1_DISMISSED_MERCHANT,Ee.Wy1.V2_NOT_DETECTED_V1_DISMISSED_STREAM],o$e=e=>[...l$e[e].labelSegments,n$e[l$e[e].tone]].filter((e=>Boolean(e))).join(" \xb7 "),i$e={[qqe.Neutral]:{count:"bg-content-secondary text-content-white",label:"bg-background-secondary text-content-secondary"},[qqe.NeedsReview]:{count:"bg-content-warning text-content-white",label:"bg-background-warning text-content-warning"},[qqe.Dropped]:{count:"bg-content-danger text-content-white",label:"bg-background-danger text-content-danger"}},s$e=e=>{let t=e.counts,n=e.liabilityStreamsExcluded,l=void 0===n?0:n,r=e.isLoading,i=void 0!==r&&r;const s=(0,a.useState)(!0),c=(0,o.A)(s,2),d=c[0],u=c[1],m=new Map(t.map((e=>[e.case,e.count]))),p=r$e.filter((e=>Boolean(m.get(e)))),g=p.reduce(((e,t)=>{var n;return e+(null!==(n=m.get(t))&&void 0!==n?n:0)}),0);return a.createElement(fe.xz6,{"data-external-id":"recurring-migration-legend",elevation:"none",className:"bg-background-info"},a.createElement("div",{className:"flex items-center gap-2xs px-default py-sm"},a.createElement(fe.SO$,{"aria-label":d?"Expand migration preview":"Collapse migration preview",size:"xs",onClick:()=>u((e=>!e))},a.createElement(fe.D39,{className:(0,q.cn)("transition-transform",d&&"-rotate-90")})),a.createElement(fe.c8D,{size:"base",weight:"medium"},"V1 \u2192 V2 migration preview"),g>0&&a.createElement(fe.c8D,{size:"xs",color:"secondary"},g," classified"),a.createElement(fe.cIj,{content:"Employee only. This is a read-only dry run of the V1 \u2192 V2 migration for this household \u2014 nothing here is saved, and no V1 stream or V2 group is modified by viewing it."},a.createElement(fe.SO$,{"aria-label":"About the migration preview",size:"xs",variant:"minimal",className:"size-3 min-h-0 min-w-0 shrink-0 p-0 text-content-secondary"},a.createElement(fe.ucZ,{size:"xs"})))),a.createElement(fe.X0s,{open:!d},a.createElement(fe.X0s.Content,{className:"flex flex-col gap-xs px-default pb-sm"},i&&a.createElement(fe.c8D,{size:"xs",color:"secondary"},"Classifying this household\u2026"),!i&&0===p.length&&0===l&&a.createElement(fe.c8D,{size:"xs",color:"secondary"},"Nothing to migrate \u2014 no V1 streams and no V2 groups for this household."),!i&&p.length>0&&a.createElement("div",{className:"flex flex-wrap items-center gap-xs"},p.map((e=>{const t=l$e[e],n=t.tone,l=t.description,r=i$e[n];return a.createElement("span",{key:e,className:"inline-flex shrink-0 cursor-default items-stretch overflow-hidden rounded-pill text-xs font-medium"},a.createElement("span",{className:(0,q.cn)("inline-flex items-center gap-2xs px-xs",r.label)},a.createElement(fe.cIj,{content:l},a.createElement(fe.SO$,{"aria-label":"About ".concat(o$e(e)),size:"xs",variant:"minimal",className:"size-3 min-h-0 min-w-0 shrink-0 cursor-pointer p-0 text-current"},a.createElement(fe.ucZ,{size:"xs"}))),o$e(e)),a.createElement("span",{className:(0,q.cn)("inline-flex items-center px-xs tabular-nums",r.count)},m.get(e)))}))),l>0&&a.createElement(fe.c8D,{size:"xs",color:"secondary"},l," liability stream",1===l?"":"s"," not classified \u2014 V2 doesn't model liability-backed groups yet, so they'd drop out entirely and need their own path.")))
1)},c$e=iVe.p.REVIEW_BANNER,d$e=e=>{let t=e.count,n=e.onReview,l=e.onDismiss;return a.createElement(fe.hzW.Root,{"data-external-id":"recurring-review-banner-view",variant:"info",className:"rounded-default text-sm"},a.createElement(fe.hzW.Icon,null,a.createElement(fe.aRL,{size:"sm"})),a.createElement(fe.hzW.Title,{className:"font-medium"},c$e.TITLE(t)),a.createElement(fe.hzW.Actions,{className:"gap-xs"},a.createElement(fe.XZZ,{variant:"text",size:"xs",onClick:n},c$e.REVIEW),a.createElement(fe.TU1,{size:"xs","aria-label":c$e.DISMISS,onClick:l})))};var u$e;const m$e=()=>{var e,t;const n=fje(),l=null!==(e=null===n||void 0===n?void 0:n.isBannerVisible)&&void 0!==e&&e,r=null!==(t=null===n||void 0===n?void 0:n.reviewableCount)&&void 0!==t?t:0,o=(0,a.useRef)(!1);return(0,a.useEffect)((()=>{l&&!o.current&&(o.current=!0,(e=>{(0,Ge.u4)(Ye.aq.ReviewEntryPointSeen,{count_bucket:XWe(e)})})(r))}),[l,r]),n?a.createElement(p$e,{"data-external-id":"recurring-review-banner","aria-hidden":!l,inert:l?void 0:"",className:(0,q.cn)("grid transition-[grid-template-rows] duration-50 ease-out",l?"grid-rows-[1fr]":"grid-rows-[0fr]")},a.createElement("div",{className:"overflow-hidden"},a.createElement("div",{className:"pb-default"},a.createElement(d$e,{count:n.reviewableCount,onReview:()=>n.open("banner"),onDismiss:n.dismissBanner})))):null},p$e=$d.s.div(u$e||(u$e=(0,wc.A)([""]))),g$e=e=>{let t=e.items,n=e.isShowing,l=e.genericNoun,r=void 0!==l&&l,o=e.onToggle;return a.createElement("button",{"data-external-id":"recurring-section-inactive-footer",type:"button",className:" flex w-full items-center gap-sm rounded-b-default border-x-0 border-t border-b-0 border-solid border-t-divider-primary bg-background-primary px-default py-sm text-left hover:bg-background-primary-hover focus-visible:ring-2 focus-visible:ring-input-focus-border focus-visible:outline-none focus-visible:ring-inset ",onClick:o},n?a.createElement(fe.yhH,{className:"text-content-secondary"}):a.createElement(fe.N9s,{className:"text-content-secondary"}),a.createElement(fe.c8D,{size:"sm",color:"secondary"},(0,yr.qF)(t,n,{genericNoun:r})))},h$e={[qqe.Neutral]:{color:"gray-secondary",variant:"subtle"},[qqe.NeedsReview]:{color:"yellow",variant:"subtle"},[qqe.Dropped]:{color:"red",variant:"subtle"}},v$e={[a$e.Neutral]:{color:"gray-secondary",variant:"subtle"},[a$e.Approved]:{color:"green",variant:"subtle"},[a$e.Dismissed]:{color:"red",variant:"subtle"},[a$e.Pending]:{color:"gray-secondary",variant:"solid"}},f$e=e=>{let t=e.migrationCase,n=e.matchedSiblingCount,l=void 0===n?1:n,r=e.hasMatchedStream,i=void 0!==r&&r;const s=l$e[t];if(!s)return null;const c=(0,o.A)(s.labelSegments,2),d=c[0],u=c[1],m=n$e[s.tone],p=(e=>{let t=e.hasMatchedStream,n=e.siblingCount;return n<=1?null:t?"Split into ".concat(n," groups from V1"):null})({hasMatchedStream:i,siblingCount:l});return a.createElement("span",{"data-external-id":"recurring-migration-badge",className:"flex min-w-0 flex-wrap items-center gap-x-2xs gap-y-3xs"},a.createElement(fe.cIj,{content:s.description},a.createElement(fe.SO$,{"aria-label":"What this migration label means",size:"xs",variant:"minimal",className:"size-3 min-h-0 min-w-0 shrink-0 p-0 text-content-secondary",onClick:e=>{e.stopPropagation()}},a.createElement(fe.ucZ,{size:"xs"}))),d&&a.createElement(fe.CQG,{size:"xs",color:"gray-secondary",variant:"subtle",rounded:"pill",className:"max-w-full min-w-0"},a.createElement(fe.CQG.Label,{className:"min-w-0 truncate"},d)),a.createElement(fe.CQG,Object.assign({size:"xs",rounded:"pill",className:"max-w-full min-w-0"},v$e[(e=>e===Xqe?a$e.Approved:e===Qqe?a$e.Pending:e.toLowerCase().includes("dismissed")?a$e.Dismissed:a$e.Neutral)(u)]),a.createElement(fe.CQG.Label,{className:"min-w-0 truncate"},u)),m&&a.createElement(fe.CQG,Object.assign({size:"xs",rounded:"pill",className:"max-w-full min-w-0"},h$e[s.tone]),a.createElement(fe.CQG.Label,{className:"min-w-0 truncate"},m)),p&&a.createElement(fe.CQG,{size:"xs",color:"blue",variant:"subtle",rounded:"pill",className:"max-w-full min-w-0"},a.createElement(fe.CQG.Label,{className:"min-w-0 truncate"},p)))},E$e=e=>{let t=e.amount,n=e.previousAmount,l=e.isMuted,r=void 0!==l&&l,o=e.isFutureMonth;const i=void 0!==o&&o||null===n?null:Bje(t,n);return a.createElement(Yje,{"data-external-id":"amount-cell",amountLabel:(0,jQ.s_)(t),income:(0,jQ.iR)(t),delta:i,size:"base",muted:r})},y$e=()=>a.createElement(fe.c8D,{"data-external-id":"dash-cell",size:"base",color:"secondary"},"\u2014"),b$e=e=>{let t=e.lastDate,n=e.lastDateIsPaid,l=e.recurringType,r=e.quiet,o=void 0!==r&&r;if((0,BY.A)(t))return a.createElement(y$e,{"data-external-id":"last-date-cell"});const i=!0===n,s=i?Ee.G8P.PAID:Ee.G8P.OVERDUE,c=(0,wVe.EO)(s,l,t,{receivedForIncome:!0});return o?a.createElement($je,{"data-external-id":"last-date-cell",label:c,color:"secondary"}):a.createElement($je,{"data-external-id":"last-date-cell",label:c,color:i?"primary":"brand",weight:"medium",mark:a.createElement(jje,{status:s,testId:"recurring-last-date-mark"})})},x$e=e=>{let t=e.nextDate,n=e.status;if((0,BY.A)(t))return a.createElement(y$e,{"data-external-id":"next-date-cell"});const l=n===Ee.G8P.POSSIBLY_INACTIVE;return a.createElement($je,{"data-external-id":"next-date-cell",label:(0,wVe.Yq)(t),color:l?"secondary":void 0,mark:l?a.createElement(fe.t$O,{size:"sm",className:"shrink-0 text-content-warning","aria-hidden":!0,"data-testid":"recurring-next-date-unknown"}):a.createElement(jje,{status:Ee.G8P.UPCOMING,calendarTestId:"recurring-next-date-calendar"})})},w$e=e=>(0,U.A)((0,U.A)({},e?{date:e}:{}),{},{timeframe:"month"}),C$e=(e,t)=>
1I.JZ.categories({id:e,queryParams:w$e(t)}),A$e=(e,t)=>I.JZ.merchants({id:e,queryParams:w$e(t)});var I$e,k$e;const S$e=e=>{let t=e.occurrence,n=e.sectionKind,l=e.gridTemplateColumns,r=e.visibleColumns,o=e.showMigrationColumn,i=void 0!==o&&o,s=e.selectedMonthStartDate;const c=n===Ee.kjN.INCOME,d=t.status===Ee.G8P.PAID,u={type:a.createElement(N$e,{text:yr.rB[n]}),category:t.category&&t.categoryId?a.createElement(Aje,{linkTo:C$e(t.categoryId,s),value:"".concat(t.category.icon," ").concat(t.category.name),size:"sm"}):a.createElement(N$e,{text:null}),merchant:a.createElement("div",null),statement:a.createElement(N$e,{text:t.statement,color:"secondary",className:"font-mono text-xs"}),account:t.accountName&&t.accountId?a.createElement(Aje,{linkTo:I.JZ.accounts.accountDetails({id:t.accountId}),value:t.accountName,icon:a.createElement("span",{"aria-hidden":!0},a.createElement(Gl.v,{logoUrl:t.accountLogoUrl,icon:t.accountIcon,size:16})),size:"sm"}):a.createElement(N$e,{text:null}),status:a.createElement("div",{className:"flex min-w-0 items-center gap-1.5"},a.createElement(jje,{status:t.status}),a.createElement(fe.c8D,{size:"sm",color:t.status===Ee.G8P.OVERDUE?"brand":"primary",className:"min-w-0 truncate"},(0,wVe.EO)(t.status,n,t.date))),lastDate:a.createElement("div",null),nextDate:a.createElement("div",null),history:a.createElement("div",null),amount:a.createElement(Yje,{amountLabel:"".concat(c?"+":"").concat((0,rl.vv)(Math.abs(t.amount))),income:c,muted:!d})};return a.createElement(_$e,{"data-external-id":"recurring-section-occurrence-row",style:{gridTemplateColumns:l}},a.createElement("div",{className:"flex min-w-0 items-center gap-sm"},a.createElement(T$e,null),a.createElement("div",{className:"size-8 shrink-0"}),a.createElement(fe.c8D,{size:"sm",className:"min-w-0 truncate"},(0,wVe.ll)(t.date))),i&&a.createElement("div",null),cHe.filter((e=>r[e])).map((e=>a.createElement(a.Fragment,{key:e},u[e]))),a.createElement("div",null))},N$e=e=>{let t=e.text,n=e.color,l=e.className;return a.createElement("div",{"data-external-id":"truncated-cell",className:"flex min-w-0"},a.createElement(fe.Yvj,{content:t||null,description:t||"",delay:300},a.createElement("span",{className:"min-w-0"},a.createElement(fe.c8D,{size:"sm",color:n,className:(0,q.cn)("block truncate",l)},t||"\u2014"))))},T$e=$d.s.div(I$e||(I$e=(0,wc.A)(["size-6 shrink-0"]))),_$e=$d.s.div(k$e||(k$e=(0,wc.A)(["grid items-center gap-lg px-default py-2.5 last:rounded-b-default"]))),D$e=e=>{let t=e.id,n=e.name,l=e.sectionKind,r=e.isActive,i=e.merchantId,s=e.merchantName,c=e.onMerchantUpdated,d=e.onWillDeleteRecurrenceGroups;const u=(0,Pd.h)(),m=(0,o.A)(u,2),p=m[0],g=m[1],h=g.open,v=g.close,f=cWe(),E=(0,a.useCallback)((()=>{null===d||void 0===d||d(),null===c||void 0===c||c()}),[c,d]);return a.createElement("div",{"data-external-id":"recurring-section-row-menu",onClick:e=>e.stopPropagation(),onKeyDown:e=>e.stopPropagation()},a.createElement(MWe,{id:t,name:n,sectionKind:l,isActive:r,merchantId:i,merchantName:s,onRename:f?()=>{f.selectGroup(t),f.setNameFocus()}:void 0,onEditMerchant:h}),i&&a.createElement(p,{onClose:v},a.createElement(N7._,{merchantId:i,recurrenceSource:"v2",afterUpdate:c,afterDelete:E,onWillDeleteRecurrenceGroups:d})))};var R$e,M$e;const L$e=a.memo((e=>{let t=e.id,n=e.name,l=e.logoUrl,r=e.merchantName,i=e.merchantId,s=e.merchantLogoUrl,c=e.sectionKind,d=e.frequencyDescription,u=e.frequency,m=e.amount,p=e.isNew,g=void 0!==p&&p,h=e.createdAt,v=e.isActive,f=e.endedAt,E=e.lastDate,y=e.lastDateIsPaid,b=e.nextDate,x=e.category,w=e.categoryId,C=e.accountName,A=e.accountLogoUrl,k=e.accountIcon,S=e.accountId,N=e.status,T=e.overdueSince,_=e.periodStatus,D=e.previousAmount,R=e.periodDate,M=e.periodOccurrences,L=void 0===M?[]:M,O=e.statement,P=e.transactions,B=e.historyIntervals,z=e.onMerchantUpdated,F=e.onWillDeleteRecurrenceGroups,G=e.migrationCase,Y=e.matchedSiblingCount,U=e.hasMatchedStream,V=e.isV1Ghost,W=void 0!==V&&V,j=e.visibleColumns,H=e.showMigrationColumn,K=void 0!==H&&H,$=e.isSelected,Z=void 0!==$&&$,J=e.selectedMonthStartDate,X=e.isCurrentMonth,Q=void 0!==X&&X,ee=e.alertSurface,te=void 0===ee?"list":ee,ne=e.isFutureMonth,ae=void 0!==ne&&ne,le=e.onSelect;const re=(0,a.useState)(!1),oe=(0,o.A)(re,2),ie=oe[0],se=oe[1],ce=L.length>1,de=O$e(j,K),ue=!W,me=()=>{ue&&(null===le||void 0===le||le(t))},pe=a.useMemo((()=>(0,fVe.Mp)(B)),[B]),ge={type:a.createElement(z$e,null,yr.rB[c]),category:x&&w?a.
1createElement(Aje,{linkTo:C$e(w,J),value:"".concat(x.icon," ").concat(x.name)}):a.createElement(z$e,null,"\u2014"),merchant:r&&i?a.createElement(Aje,{linkTo:A$e(i,J),value:r,icon:a.createElement(Wl._,{url:s,size:18})}):a.createElement(z$e,null,"\u2014"),statement:a.createElement("div",{className:"flex min-w-0"},a.createElement(fe.Yvj,{content:O||null,description:O||"",delay:300},a.createElement("span",{className:"min-w-0"},a.createElement(z$e,{color:"secondary",className:"block font-mono text-xs"},O||"\u2014")))),account:C&&S?a.createElement(Aje,{linkTo:I.JZ.accounts.accountDetails({id:S}),value:C,icon:a.createElement(Gl.v,{logoUrl:A,icon:k,size:16})}):a.createElement(z$e,null,"\u2014"),status:N?a.createElement(Zje,{status:null!==_&&void 0!==_?_:N,sectionKind:c,periodDate:R,nextDate:b,transactions:P,occurrences:L}):a.createElement(fe.c8D,{size:"sm",color:"secondary"},"Not in V2"),lastDate:"all"===te?a.createElement(b$e,{lastDate:E,lastDateIsPaid:y,recurringType:c,quiet:!v}):a.createElement(z$e,null,"\u2014"),nextDate:"all"===te&&v?a.createElement(x$e,{nextDate:b,status:N}):a.createElement(z$e,null,"\u2014"),history:a.createElement("div",{className:"justify-self-center"},a.createElement(EVe,{intervals:pe})),amount:null===m?a.createElement(z$e,{className:"text-right"},"\u2014"):a.createElement(E$e,{amount:m,previousAmount:D,isMuted:!v,isFutureMonth:ae})};return a.createElement(a.Fragment,null,a.createElement(B$e,{style:{gridTemplateColumns:de},className:(0,q.cn)(!v&&"bg-background-secondary",W&&"cursor-default border border-dashed border-content-primary bg-background-tertiary"),role:ue?"button":void 0,tabIndex:ue?0:void 0,"aria-pressed":ue?Z:void 0,"data-selected":Z,"data-v1-ghost":W||void 0,onClick:me,onKeyDown:e=>{e.target===e.currentTarget&&("Enter"!==e.key&&" "!==e.key||(e.preventDefault(),me()))}},a.createElement("div",{className:"flex min-w-0 items-center gap-sm"},a.createElement(T$e,null,ce&&a.createElement(fe.SO$,{"aria-label":"".concat(ie?"Hide":"Show"," each payment for ").concat(n),"aria-expanded":ie,variant:"minimal",size:"3xs",onClick:e=>{e.stopPropagation(),se((e=>!e))}},a.createElement(fe.D39,{className:(0,q.cn)("transition-transform",!ie&&"-rotate-90")}))),a.createElement(P$e,{logoUrl:l,name:n}),a.createElement("div",{className:"flex min-w-0 flex-col"},a.createElement("div",{className:"flex min-w-0 items-center gap-1.5"},a.createElement(fe.Yvj,{content:n,description:n,delay:300},a.createElement("span",{className:"min-w-0"},a.createElement(fe.c8D,{size:"base",className:"block truncate"},n))),void 0!==N&&null!==m&&a.createElement(oWe,{id:t,name:n,status:N,isNew:g,createdAt:h,isActive:v,endedAt:f,merchantId:i,merchantName:r,accountName:C,amount:m,frequency:u,frequencyDescription:d,sectionKind:c,transactions:P,overdueSince:T,isCurrentMonth:Q,alertSurface:te})),a.createElement(fe.c8D,{size:"sm",color:"secondary",className:"truncate"},d))),K&&a.createElement("div",{className:"min-w-0 overflow-hidden pr-sm"},G?a.createElement(f$e,{migrationCase:G,matchedSiblingCount:Y,hasMatchedStream:U}):a.createElement(z$e,null,"\u2014")),cHe.filter((e=>j[e])).map((e=>a.createElement(a.Fragment,{key:e},ge[e]))),W?a.createElement("div",null):a.createElement(D$e,{id:t,name:n,sectionKind:c,isActive:v,merchantId:null!==i&&void 0!==i?i:null,merchantName:null!==r&&void 0!==r?r:null,onMerchantUpdated:z,onWillDeleteRecurrenceGroups:F})),ce&&ie&&L.map((e=>{var t;return a.createElement(S$e,{key:null!==(t=e.transactionId)&&void 0!==t?t:e.date,occurrence:e,sectionKind:c,gridTemplateColumns:de,visibleColumns:j,showMigrationColumn:K,selectedMonthStartDate:J})})))}));L$e.displayName="RecurringSectionRow";const O$e=(e,t)=>["minmax(".concat(316,"px,").concat(2.4,"fr)"),...t?[dHe]:[],...cHe.filter((t=>e[t])).map((e=>"minmax(".concat(sHe[e].minWidthPx,"px,").concat(sHe[e].flex,"fr)"))),"".concat(32,"px")].join(" "),P$e=e=>{let t=e.logoUrl,n=e.name;return t?a.createElement("img",{"data-external-id":"avatar",src:t,alt:"",className:"size-8 shrink-0 rounded-full border border-divider-primary bg-background-primary object-contain"}):a.createElement("div",{"data-external-id":"avatar","aria-hidden":!0,
1className:"flex size-8 shrink-0 items-center justify-center rounded-full bg-background-tertiary"},a.createElement(fe.c8D,{size:"sm",weight:"medium",color:"secondary"},n.charAt(0).toUpperCase()))},B$e=$d.s.div(R$e||(R$e=(0,wc.A)(["\n  grid cursor-pointer items-center gap-lg border-t border-t-divider-primary px-default py-sm\n  first:border-t-0\n  hover:bg-background-primary-hover\n  focus-visible:ring-2 focus-visible:ring-input-focus-border focus-visible:outline-none\n  focus-visible:ring-inset\n  data-[selected=true]:bg-background-primary-hover\n"]))),z$e=(0,$d.s)(fe.c8D).attrs({size:"base"})(M$e||(M$e=(0,wc.A)(["min-w-0 truncate"]))),F$e=e=>{let t=e.title,n=e.titleTooltipText,l=e.itemCount,r=e.isCollapsed,o=void 0!==r&&r,i=e.visibleColumns,s=e.showMigrationColumn,c=void 0!==s&&s,d=e.toggleCollapsed,u=e.trackRef,m=e.minWidth;return a.createElement(fe.xz6.Header,{"data-external-id":"recurring-section-list-header","data-testid":"recurring-section-header-".concat(t),className:(0,q.cn)("items-center p-0",o&&"rounded-b-default border-b-0")},a.createElement("div",{className:"w-full overflow-hidden"},a.createElement("div",{ref:u,className:(0,q.cn)("items-center px-default py-sm will-change-transform",o?"flex":"grid gap-lg"),style:o||!i?void 0:{minWidth:m,gridTemplateColumns:O$e(i,c)}},a.createElement("div",{className:"flex min-w-0 items-center gap-sm"},a.createElement(fe.SO$,{"aria-label":o?"Expand ".concat(t):"Collapse ".concat(t),size:"xs",onClick:d},a.createElement(fe.D39,{className:(0,q.cn)("transition-transform",o&&"-rotate-90")})),a.createElement("div",{className:"flex min-w-0 items-baseline gap-1.5"},n?a.createElement(fe.cIj,{size:"3xs",iconSize:"sm",content:n,triggerClassName:"text-content-secondary",label:a.createElement(fe.xz6.Title,{className:"truncate"},t)}):a.createElement(fe.xz6.Title,{className:"truncate"},t),a.createElement(fe.c8D,{size:"sm",color:"secondary"},l))),!o&&i&&a.createElement(a.Fragment,null,c&&uHe,cHe.filter((e=>i[e])).map((e=>a.createElement(a.Fragment,{key:e},sHe[e].headerLabel))),a.createElement("div",null)))))},G$e=()=>a.createElement(fe.xz6,{"data-external-id":"recurring-section-list-loading",className:"p-md"},a.createElement(fe.wME,{className:"h-8 w-full"}));var Y$e,U$e=n(37243);const V$e=e=>{var t;let n=e.title,l=e.items,r=e.inactiveItems,i=e.inactiveFooterGenericNoun,s=void 0!==i&&i,c=e.visibleColumns,d=e.showMigrationColumn,u=void 0!==d&&d,m=e.selectedStreamId,p=e.onSelectStream,g=e.selectedMonthStartDate,h=e.isCurrentMonth,v=void 0!==h&&h,f=e.alertSurface,E=void 0===f?"list":f,y=e.isFutureMonth,b=void 0!==y&&y,x=e.onMerchantUpdated,w=e.onWillDeleteRecurrenceGroups,C=e.isLoading,A=void 0!==C&&C,I=e.isCollapsed,k=e.toggleCollapsed,S=e.registerHorizontalScroller,N=e.emptyState,T=e.titleTooltipText,_=e.stickyOffset,D=e.stickyZ;const R=((e,t)=>{const n=cHe.filter((t=>e[t])),a=n.length+2+(t?1:0);return 316+(t?72:0)+n.reduce(((e,t)=>e+sHe[t].minWidthPx),0)+32+20*(a-1)+32})(c,u),M=(e=>{let t=e.registerHorizontalScroller,n=e.isCollapsed,l=void 0!==n&&n;const r=(0,a.useState)(null),i=(0,o.A)(r,2),s=i[0],c=i[1],d=(0,a.useRef)(null);return(0,a.useLayoutEffect)((()=>{const e=d.current;if(!s||!e||l)return;const t=()=>{e.style.transform="translateX(-".concat(s.scrollLeft,"px)")};return t(),s.addEventListener("scroll",t,{passive:!0}),()=>{s.removeEventListener("scroll",t),e.style.transform=""}}),[s,l]),(0,a.useEffect)((()=>s?null===t||void 0===t?void 0:t(s):void 0),[t,s]),{setScroller:c,headerTrackRef:d}})({registerHorizontalScroller:S,isCollapsed:I}),L=M.setScroller,O=M.headerTrackRef,P=(0,a.useState)(!1),B=(0,o.A)(P,2),z=B[0],F=B[1],G=(null!==(t=null===r||void 0===r?void 0:r.length)&&void 0!==t?t:0)>0;return A?a.createElement(G$e,{"data-external-id":"recurring-section-list"}):0!==l.length||G?a.createElement(fe.xz6,{"data-external-id":"recurring-section-list",sticky:!0,stickyObserveParent:!0,stickyOffset:_,stickyZ:D,"data-testid":"recurring-section-card-".concat(n)},a.createElement(F$e,{title:n,titleTooltipText:T,itemCount:l.length,isCollapsed:I,visibleColumns:c,showMigrationColumn:u,toggleCollapsed:k,trackRef:O,minWidth:R}),a.createElement(W$e,{title:n,isCollapsed:I},a.createElement("div",{ref:L,"data-testid":"recurring-section-scroll-".concat(n),className:(0,q.cn)("overflow-x-auto overscroll-x-none","\n              [scrollbar-color:var(--border-primary)_transparent] [scrollbar-width:thin]\n              [&::-webkit-scrollbar]:h-1\n              [&::-webkit-scrollbar-thumb]:rounded-full\n              [&::-webkit-scrollbar-thumb]:bg-border-primary\n            ",!G&&"rounded-b-default")},a.createElement("div",{style:{minWidth:R}},[...l,...z&&null!==r&&void 0!==r?r:[]].map((e=>a.createElement(L$e,Object.assign({key:e.id},e,{visibleColumns:c,showMigrationColumn:u,isSelected:e.id===m,selectedMonthStartDate:g,isCurrentMonth:v,alertSurface:E,isFutureMonth:b,onSelect:p,onMerchantUpdated:x,onWillDeleteRecurrenceGroups:w})))))),G&&a.createElement(g$e,{items:null!==r&&void 0!==r?r:[],isShowing:z,genericNoun:s,onToggle:()=>F((e=>!e))}))):N?a.createElement(fe.xz6,{"data-external-id":"recurring-section-list"},a.createElement("div",{className:"flex items-center px-default py-sm"},T?a.createElement(fe.cIj,{size:"3xs",iconSize:"sm",content:T,triggerClassName:"text-content-secondary",label:a.createElement(fe.xz6.Title,null,n)}):a.createElement(fe.xz6.Title,null,n)),N):null},W$e=e=>{let t=e.title,n=e.isCollapsed,l=void 0!==n&&n,r=e.children;return a.createElement(j$e,{"data-external-id":"section-panel","data-testid":"recurring-section-panel-".concat(t),initial:!1,animate:{height:l?0:"auto",opacity:l?0:1},transition:U$e.s,inert:l?"":void 0},r)},j$e=(0,$d.s)(D.PY1.div)(Y$e||(Y$e=(0,wc.A)(["overflow-hidden"]))),H$e=e=>{let t=e.startDate,n=e.setStartDate;return{currentMonthLabel:t.toFormat("LLLL yyyy"),onClickPrev:()=>n(t.minus({months:1}).toISODate()),onClickNext:()=>n(t.plus({months:1}).toISODate()),onClickToday:()=>n(N.c9.local().startOf("month").toISODate())}},K$e=e=>{let t=e.children;return a.createElement(fe.c8D,{"data-external-id":"recurring-list-title",size:"lg",weight:"medium",className:"m-0 min-w-0 tracking-[-0.005em] whitespace-nowrap",render:a.createElement("h1",null)},t)},q$e=e=>{let t=e.startDate,n=e.setStartDate;const l=H$e({startDate:t,setStartDate:n}).currentMonthLabel;return a.createElement(K$e,{"data-external-id":"recurring-month-label"},l)},$$e=e=>{let t=e.startDate,n=e.setStartDate;const l=H$e({startDate:t,setStartDate:n}),r=l.onClickPrev,o=l.onClickNext,i=l.onClickToday;return a.createElement("div",{"data-external-id":"recurring-month-nav-buttons",className:"flex items-center gap-1.5"},a.createElement(fe.SO$,{size:"xs","aria-label":"Previous month",onClick:r},a.createElement(fe.qzE,null)),a.createElement(fe.SO$,{size:"xs","aria-label":"Next month",onClick:o},a.createElement(fe.Fug,null)),a.createElement(fe.XZZ,{size:"xs",onClick:i},"Today"))};var Z$e=n(86501);const J$e={[Z$e.s4.Type]:"By type",[Z$e.s4.Category]:"By category",[Z$e.s4.Merchant]:"By merchant",[Z$e.s4.Account]:"By account",[Z$e.s4.Status]:"By 
1status",[Z$e.s4.Frequency]:"By frequency"},X$e=e=>{let t=e.month,n=e.tab,l=e.groupBy,r=e.onGroupByChange,i=e.columns,s=e.onColumnToggle;const c="all"===n,d=(e=>"all"===e?cHe.filter((e=>"status"!==e)):cHe.filter((e=>"lastDate"!==e&&"nextDate"!==e)))(n),u=(0,Z$e.at)(n),m=d.filter((e=>i[e])).length,p=(0,a.useState)(!1),g=(0,o.A)(p,2),h=g[0],v=g[1];return a.createElement("div",{"data-external-id":"recurring-sectioned-list-toolbar",className:"@container/recurringtoolbar w-full","data-testid":"recurring-sectioned-list-toolbar"},a.createElement("div",{className:" flex flex-col gap-sm rounded-default bg-background-primary px-lg py-md shadow-md @min-[640px]/recurringtoolbar:flex-row @min-[640px]/recurringtoolbar:items-center @min-[640px]/recurringtoolbar:justify-between "},c||!t?a.createElement(K$e,null,"All recurring"):a.createElement(q$e,t),a.createElement("div",{className:"-m-2xs flex min-w-0 flex-nowrap items-center gap-1.5 overflow-x-auto p-2xs"},a.createElement(fe.u$N,{align:"start",open:h,onOpenChange:v,trigger:a.createElement(fe.XZZ,{variant:"default",size:"xs",endIcon:a.createElement(fe.D39,{size:"md"})},J$e[l]),items:[{type:"radio-group",value:l,onValueChange:e=>{r(e),v(!1)},items:u.map((e=>({value:e,label:J$e[e]})))}]}),a.createElement(fe.u$N,{align:"end",trigger:a.createElement(fe.XZZ,{variant:"default",size:"xs",icon:a.createElement(fe.tUC,{size:"sm"})},"Columns"),classNames:{content:mHe},items:[{type:"group",label:"".concat(m," of ").concat(d.length," visible"),items:[]},...d.map((e=>({type:"checkbox",control:"switch",label:sHe[e].menuLabel,checked:i[e],onCheckedChange:t=>s(e,t)})))]}),!c&&t&&a.createElement($$e,t))))},Q$e=Ee.IF$,eZe={isEnabled:!1,annotationByGroupId:new Map,ghostRows:[],counts:[],liabilityStreamsExcluded:0,isLoading:!1},tZe=e=>{var t,n,a,l,r,o,i,s;return{id:"v1-stream-".concat(e.id),name:e.name,merchantName:null!==(t=null===(n=e.merchant)||void 0===n?void 0:n.name)&&void 0!==t?t:null,merchantId:null!==(a=null===(l=e.merchant)||void 0===l?void 0:l.id)&&void 0!==a?a:null,merchantLogoUrl:null,logoUrl:null!==(r=e.logoUrl)&&void 0!==r?r:null,sectionKind:null!==(o=e.recurringType)&&void 0!==o?o:Ee.kjN.EXPENSE,frequencyDescription:null!==(i=(0,yr.Bp)(e.frequency))&&void 0!==i?i:e.frequency,frequency:e.frequency,amount:null!==(s=e.amount)&&void 0!==s?s:null,isNew:!1,createdAt:null,isActive:!0,endedAt:null,overdueSince:null,lastDate:null,lastDateIsPaid:null,nextDate:null,periodStatus:null,previousAmount:null,periodDate:null,periodOccurrences:[],category:null,categoryId:null,isApproximate:!1,accountName:null,accountId:null,accountLogoUrl:null,accountIcon:null,statement:null,transactions:[],historyIntervals:[],migrationCase:e.case,isV1Ghost:!0}},nZe=e=>({id:"v1-merchant-".concat(e.merchant.id),name:e.merchant.name,merchantName:e.merchant.name,merchantId:e.merchant.id,merchantLogoUrl:null,logoUrl:null,sectionKind:Ee.kjN.EXPENSE,frequencyDescription:"Frequency unknown",frequency:"",amount:null,isNew:!1,createdAt:null,isActive:!0,endedAt:null,overdueSince:null,lastDate:null,lastDateIsPaid:null,nextDate:null,periodStatus:null,previousAmount:null,periodDate:null,periodOccurrences:[],category:null,categoryId:null,isApproximate:!1,accountName:null,accountId:null,accountLogoUrl:null,accountIcon:null,statement:null,transactions:[],historyIntervals:[],migrationCase:Ee.Wy1.V2_NOT_DETECTED_V1_DISMISSED_MERCHANT,isV1Ghost:!0}),aZe=Ee.kjN.CREDIT_CARD,lZe=[Ee.kjN.EXPENSE,Ee.kjN.INCOME,Ee.kjN.TRANSFER],rZe=e=>{var t,n,l;let i=e.month,s=e.tab,u=e.onMerchantUpdated;const m=(0,d.wA)(),p=(0,d.d4)(zFe),h=(0,d.d4)((0,tKe.ce)(s)),v=(0,d.d4)((0,tKe.dB)(s)),f=(0,a.useDeferredValue)(v),E=(0,d.d4)(tKe.Ze),y=iKe(s,E),b=sWe(),x=b.selectedGroupId,w=b.selectGroup,C=b.clearSelection,A=(()=>{const e=(0,a.useRef)(new Set),t=(0,a.useRef)(0);return(0,a.useCallback)((n=>{const a=e.current;a.add(n),n.scrollLeft=t.current,t.current=n.scrollLeft;const l=()=>{const e=n.scrollLeft;e!==t.current&&(t.current=e,a.forEach((t=>{t!==n&&t.scrollLeft!==e&&(t.scrollLeft=e)})))};return n.addEventListener("scroll",l,{passive:!0}),()=>{n.removeEventListener("scroll",l),a.delete(n)}}),[])})(),I=null!==(t=null===(n=fje())||void 0===n?void 0:n.isBannerVisible)&&void 0!==t&&t,k=(0,a.useRef)(null),S=(0,a.useState)(0),T=(0,o.A)(S,2),_=T[0],D=T[1];(0,a.useLayoutEffect)((()=>{const e=k.current;if(null===e)return;const t=()=>D(e.getBoundingClientRect().height);t();const n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()}),[I]);const R=_||72,M=(0,a.useCallback)((e=>{m((0,g.wx)(e))}),[m]),L=(0,a.useCallback)((e=>{m((0,g.gj)({tab:s,groupBy:e}))}),[m,s]),O=(0,a.useCallback)(((e,t)=>{m((0,g._y)({tab:s,column:e,visible:t}))}),[m,s]),P=(()=>{const e=(0,a.useContext)(IWe);if(!e)throw new Error("useRecurrenceGroupsContext must be used within a <RecurrenceGroupsProvider>");return e})(),B=P.recurrenceGroups,z=P.isLoading,F=P.error,G=P.refetch,Y=(0,a.useCallback)((()=>{G(),null===u||void 0===u||u()}),[u,G]),V=(()=>{const e=(0,d.d4)(tKe.ZD),t=(0,et.I)(Q$e,{skip:!e}),n=t.data,l=t.isLoadingInitialData,r=t.error;return(0,a.useMemo)((()=>{var t,a,o,i,s;if(!e||r)return eZe;const c=null===n||void 0===n?void 0:n.recurringMigrationPreview,d=new Map;(null!==(t=null===c||void 0===c?void 0:c.groups)&&void 0!==t?t:[]).forEac
1h((e=>{var t,n;d.set(e.group.id,{migrationCase:e.case,matchedSiblingCount:e.matchedSiblingCount,matchedStreamName:null!==(t=null===(n=e.matchedStream)||void 0===n?void 0:n.name)&&void 0!==t?t:null})}));const u=[...(null!==(a=null===c||void 0===c?void 0:c.orphanStreams)&&void 0!==a?a:[]).map(tZe),...(null!==(o=null===c||void 0===c?void 0:c.ignoredMerchants)&&void 0!==o?o:[]).filter((e=>e.isOnlyVisibleHere)).map(nZe)];return{isEnabled:e,annotationByGroupId:d,ghostRows:u,counts:null!==(i=null===c||void 0===c?void 0:c.counts)&&void 0!==i?i:[],liabilityStreamsExcluded:null!==(s=null===c||void 0===c?void 0:c.liabilityStreamsExcluded)&&void 0!==s?s:0,isLoading:l}}),[n,r,e,l])})(),W=(0,a.useMemo)((()=>{if(!V.isEnabled)return B;return[...B.map((e=>{const t=V.annotationByGroupId.get(e.id);return t?(0,U.A)((0,U.A)({},e),{},{migrationCase:t.migrationCase,matchedSiblingCount:t.matchedSiblingCount,hasMatchedStream:null!==t.matchedStreamName}):e})),...V.ghostRows]}),[V,B]),j=(0,a.useMemo)((()=>(0,r.YW)(h).with(Z$e.s4.Merchant,(()=>(0,yr.lD)(W,yr.uQ))).with(Z$e.s4.Type,(()=>(0,yr.lD)(W,yr.K3).filter((e=>e.kind!==aZe)))).with(Z$e.s4.Category,(()=>(0,yr.lD)(W,yr.Q5))).with(Z$e.s4.Account,(()=>(0,yr.lD)(W,yr.X_))).with(Z$e.s4.Status,(()=>(0,yr.Qp)(W.filter(iZe),yr.Om))).with(Z$e.s4.Frequency,(()=>(0,yr.lD)(W,(e=>(0,yr.Qp)(e,yr.G8))))).exhaustive()),[h,W]),H=(0,a.useMemo)((()=>"all"===s&&h!==Z$e.s4.Type&&h!==Z$e.s4.Status?(0,yr.aZ)(j):j),[j,h,s]),K=(0,a.useMemo)((()=>"all"===s?(0,yr.IO)(H):(0,yr.lM)(H)),[H,s]),q=N.c9.local().startOf("month"),$=null!==(l=null===i||void 0===i?void 0:i.startDate.startOf("month"))&&void 0!==l?l:q,Z=$.hasSame(q,"month"),J=$>q,X="all"===s?"all":"list",Q=h!==Z$e.s4.Type,ee=K.length>0;return F?a.createElement(fe.hzW.Root,{"data-external-id":"recurring-sectioned-list",variant:"error"},a.createElement(fe.hzW.Title,null,"Couldn't load recurring data"),a.createElement(fe.hzW.Description,null,F.message),a.createElement(fe.hzW.Actions,null,a.createElement(fe.XZZ,{variant:"default",size:"sm",onClick:G},"Try again"))):a.createElement(a.Fragment,null,a.createElement("div",{className:"flex min-w-0 flex-1 flex-col"},V.isEnabled&&a.createElement("div",{className:"mb-default"},a.createElement(s$e,{counts:V.counts,liabilityStreamsExcluded:V.liabilityStreamsExcluded,isLoading:V.isLoading})),a.createElement("div",{ref:k,"data-testid":"recurring-sectioned-list-toolbar-band",className:"sticky top-0 z-2 -mx-xs bg-background-page px-xs"},a.createElement("div",{className:"pb-default"},a.createElement(X$e,{month:i,tab:s,groupBy:h,onGroupByChange:L,columns:v,onColumnToggle:O})),a.createElement(m$e,null)),a.createElement("div",{className:"flex flex-col gap-default pb-gutter"},z?lZe.map((e=>a.createElement(V$e,{key:e,title:yr.Tq[e],items:[],visibleColumns:f,showMigrationColumn:V.isEnabled,isFutureMonth:J,isLoading:!0}))):a.createElement(a.Fragment,null,!ee&&a.createElement(fe.erR,{variant:"secondary",title:(0,c.A)(y)?"No matching recurring items":"No recurring items yet",description:(0,c.A)(y)?"Try adjusting your filters.":"Once we detect recurring transactions, they'll show up here."}),K.map((e=>{var t;return a.createElement(V$e,{key:e.kind,title:e.label,items:e.items,inactiveItems:e.inactiveItems,inactiveFooterGenericNoun:Q,visibleColumns:f,showMigrationColumn:V.isEnabled,selectedStreamId:x,onSelectStream:w,selectedMonthStartDate:null!==(t=null===i||void 0===i?void 0:i.startDate.startOf("month").toISODate())&&void 0!==t?t:void 0,isCurrentMonth:Z,alertSurface:X,isFutureMonth:J,onMerchantUpdated:Y,onWillDeleteRecurrenceGroups:C,registerHorizontalScroller:A,isCollapsed:null===p||void 0===p?void 0:p[oZe(h,e.kind)],toggleCollapsed:()=>M(oZe(h,e.kind)),stickyOffset:R,stickyZ:1})}))),h===Z$e.s4.Type&&ee&&a.createElement(V$e,{title:yr.Tq[aZe],titleTooltipText:iVe.p.SUMMARY.STATEMENTS_TOOLTIP,items:[],visibleColumns:f,isFutureMonth:J,emptyState:a.createElement(Hqe,null)}))))},oZe=(e,t)=>"v2:".concat(e,":").concat(t),iZe=e=>void 0!==e.status;var sZe=n(48919);const cZe=72,dZe=sZe.g+4,uZe=e=>{let t=e.intervals,n=e.frequency,l=e.showMeanLine,r=void 0===l||l;const o=a.useMemo((()=>(0,fVe.RE)(t)),[t]),i=t.length>0?Math.max(0,fVe.T9-t.length):0,s=t[0]&&(0,fVe.pT)(t[0].anchorDate,n),c=t.at(-1),d=c&&(0,fVe.pT)(c.anchorDate,n),u=e=>{if(null===o.lowerBound)return 40;return 1+71*((e-o.lowerBound)/(o.max-o.lowerBound))},m=r&&o.hasPriceChanges,p=m?cZe-u(o.mean):0,g=m&&p<12,h=m&&p>60,v=(()=>{const e=s&&d?" ".concat(s," to ").concat(d):"";return 0===o.chargedCount?"Amount history".concat(e,": no charges"):o.hasPriceChanges?"Amount history".concat(e,": ").concat((0,rl.T3)(o.min)," to ").concat((0,rl.T3)(o.max),", average ").concat((0,rl.T3)(o.mean)):"Amount history".concat(e,": ").concat((0,rl.T3)(o.max)," per charge")}
1)();return a.createElement("section",{"data-external-id":"amount-history-chart","data-testid":"amount-history-chart"},a.createElement(fe.c8D,{size:"base",weight:"medium"},"Amount history"),a.createElement("div",{className:"mt-sm flex gap-xs"},a.createElement("div",{className:"min-w-0 flex-1"},a.createElement(vVe.B,{delay:fVe.uQ,closeDelay:0},a.createElement("div",{role:"img","aria-label":v,className:"relative flex items-end border-b border-chart-axis",style:{height:cZe,gap:3}},Array.from({length:i},((e,t)=>a.createElement("div",{key:"pad-".concat(t),"aria-hidden":!0,className:"h-full min-w-0 flex-1"}))),t.map((e=>{return a.createElement("div",{key:e.anchorDate,className:"h-full min-w-0 flex-1"},"charged"===e.kind&&e.amount>0?a.createElement("div",{"data-testid":"amount-history-chart-column",className:"group/historybar relative size-full cursor-default"},a.createElement(Wi.Y,{content:(0,fVe.Wl)(e),side:"top",sideOffset:dZe,delay:fVe.uQ,closeDelay:0},a.createElement("div",{"data-testid":"amount-history-chart-bar",className:(0,q.cn)("absolute bottom-0 w-full",(t=e,t===c?"bg-background-brand group-hover/historybar:bg-background-brand-hover":"bg-chart-event-border-gray group-hover/historybar:bg-content-secondary")),style:{height:u(e.amount),borderTopLeftRadius:2,borderTopRightRadius:2}}))):a.createElement("div",{"data-testid":"amount-history-chart-stub",className:"size-full"}));var t})),m&&a.createElement("div",{"aria-hidden":!0,"data-testid":"amount-history-chart-mean-line",className:"pointer-events-none absolute inset-x-0 text-divider-tertiary",style:{top:p,height:1,backgroundImage:"repeating-linear-gradient(to right, currentColor 0 4px, transparent 4px 8px)"}}))),s&&d&&a.createElement("div",{className:"mt-2xs flex justify-between"},a.createElement("span",{className:"text-2xs text-chart-label"},s),a.createElement("span",{className:"text-2xs text-chart-label"},d))),o.chargedCount>0&&a.createElement("div",{className:"relative w-10 shrink-0",style:{height:cZe}},o.hasPriceChanges?a.createElement(a.Fragment,null,!g&&a.createElement("span",{className:"absolute top-0 left-0 text-2xs leading-none whitespace-nowrap text-chart-label"},(0,rl.T3)(o.max)),m&&a.createElement("span",{"data-testid":"amount-history-chart-mean-label",className:"absolute left-0 -translate-y-1/2 text-2xs leading-none whitespace-nowrap text-chart-label",style:{top:p}},"avg ",(0,rl.T3)(o.mean)),!h&&a.createElement("span",{className:"absolute bottom-0 left-0 text-2xs leading-none whitespace-nowrap text-chart-label"},(0,rl.T3)(o.min))):a.createElement("span",{className:"absolute left-0 -translate-y-1/2 text-2xs leading-none whitespace-nowrap text-chart-label",style:{top:32}},(0,rl.T3)(o.max)))))},mZe=e=>{let t=e.id,n=e.name,l=e.sectionKind,r=e.endedAt,o=e.transactions;const i=YVe();return a.createElement(HWe,{"data-external-id":"recurrence-group-inactive-callout"},a.createElement(KWe,null,a.createElement(fe.CQG,{size:"sm",rounded:"pill",color:"gray-secondary",variant:"subtle"},LVe(r)),a.createElement(fe.c8D,{size:"base",className:"mt-sm block"},(e=>{let t=e.sectionKind,n=e.transactions;return"".concat(OVe(n,t)," If you want to resume tracking this recurring ").concat(yr.rB[t].toLowerCase(),", you can mark it as active.")})({sectionKind:l,transactions:o}))),a.createElement(qWe,null,a.createElement(fe.XZZ,{size:"sm",variant:"default",onClick:()=>{i({id:t,name:n,sectionKind:l,isActive:!0})}},"Make active")))},pZe=iVe.p.NEW_BADGE,gZe=iVe.p.NOT_RECURRING_MODAL,hZe=e=>{let t=e.id,n=e.name,l=e.sectionKind,r=e.isActive,o=e.merchantId,i=e.merchantName,s=e.accountName,c=e.frequency,d=e.frequencyDescription,u=e.createdAt,m=e.transactions;return a.createElement(HWe,{"data-external-id":"recurrence-group-new-callout"},a.createElement(KWe,null,a.createElement(fe.CQG,{size:"sm",rounded:"pill",color:"blue"},"New"),a.createElement(fe.c8D,{size:"base",className:"mt-sm block"},_Ve({sectionKind:l,merchantName:i,accountName:s,frequency:c,frequencyDescription:d,createdAt:u,transactions:m}))),a.createElement(qWe,null,a.createElement(vZe,{id:t,name:n}),a.createElement(fZe,{id:t,name:n,sectionKind:l,isActive:r,merchantId:o,merchantName:i})))},vZe=e=>{let t=e.id,n=e.name;const l=KVe(),r=l.approveRecurrenceGroup,o=l.isApproving;return a.createElement(fe.XZZ,{"data-external-id":"new-looks-right-button",variant:"default",size:"sm",disabled:o,onClick:()=>{r({id:t,name:n})}},pZe.LOOKS_RIGHT)},fZe=e=>{let t=e.id,n=e.name,l=e.sectionKind,r=e.isActive,o=e.merchantId,i=e.merchantName;const s=DWe({id:t,name:n,sectionKind:l,isActive:r,merchantId:o,merchantName:i}),c=s.openNotRecurring,d=s.dialogs;return a.createElement(a.Fragment,null,a.createElement(fe.XZZ,{variant:"default",size:"sm",onClick:c},gZe.MENU_ITEM),d)},EZe=e=>{let t=e.id,n=e.name,l=e.sectionKind,r=e.overdueSince;const o=YVe();return a.createElement(HWe,{"data-external-id":"recurrence-group-overdue-callout"},a.createElement(KWe,null,a.createElement(fe.CQG,{size:"sm",rounded:"pill",color:"brand"},wVe.oV[Ee.G8P.OVERDUE]),a.createElement(fe.c8D,{size:"base",className:"mt-sm block"},RVe({sectionKind:l,overdueSince:r}))),a.createElement(qWe,null,a.createElement(fe.XZZ,{size:"sm",variant:"default",onClick:()=>{o({id:t,name:n,sectionKind:l,isActive:!1})}},"Mark inactive")))},yZe=e=>{let t=e.id,n=e.name,l=e.amount,r=e.frequency,o=e.sectionKind,i=e.transactions;const s=YVe();return a.createElement(HWe,{"data-external-id":"recurrence-group-possibly-inactive-callout"},a.createElement(KWe,null,a.createElement(fe.CQG,{size:"sm",rounded:"pill",color:"yellow"},MVe),a.createElement(fe.c8D,{size:"base",className:"mt-sm block"},FVe({amount:l,frequency:r,sectionKind:o,transactions:i}))),a.createElement(qWe,null,a.createElement(fe.XZZ,{variant:"default",size:"sm",onClick:()=>{s({id:t,name:n,sectionKind:o,isActive:!1})}},BVe),a.createElement(fe.XZZ,{variant:"default",size:"sm",onClick:()=>{s({id:t,name:n,sectionKind:o,isActive:!0,skipUndo:!0})}},zVe)))};var bZe;const xZe=e=>{var t;let n=e.dateLabel,l=e.amount,r=e.enrichment,o=e.delta,i=e.isLoading,s=void 0!==i&&i,c=e.onOpen;return a.createElement(CZe,{"data-external-id":"recurring-stream-transaction-row",onClick:c},a.createElement("button",{className:" absolute inset-0 cursor-pointer rounded-sm border-0 bg-transparent p-0 focus-visible:ring-2 focus-visible:ring-input-focus-border focus-visible:outline-none focus-visible:ring-inset ","aria-label":wZe({dateLabel:n,amount:l,enrichment:r,delta:o}),onClick:e=>{e.stopPropagation(),c()}}),a.createElement("div",{className:"relative flex min-w-0 flex-1 items-center gap-sm"},a.createElement(fe.c8D,{size:"sm",weight:"medium",className:"w-[6.5rem] shrink-0"},n),s&&!r?a.createElement(fe.wME,{className:"size-3.5 shrink-0 rounded-full"}):a.createElement(a.Fragment,null,(null===r||void 0===r?void 0:r.category)&&a.createElement(Aje,{linkTo:I.JZ.categories({id:r.category.id}),value:r.category.name,icon:a.createElement("span",{"aria-hidden":!0,
1className:"text-sm leading-none"},r.category.icon),size:"sm",layout:"chip",iconOnly:!0}),(null===r||void 0===r?void 0:r.account)&&a.createElement(Aje,{linkTo:I.JZ.accounts.accountDetails({id:r.account.id}),value:r.account.displayName,icon:a.createElement(Jje,{name:r.account.displayName,logoUrl:r.account.logoUrl}),size:"sm",layout:"chip",iconOnly:!0}))),a.createElement("div",{className:"relative flex shrink-0 items-center gap-sm"},null===r||void 0===r||null===(t=r.tags)||void 0===t?void 0:t.map((e=>a.createElement(fe.Yvj,{key:e.id,content:e.name},a.createElement("span",{"aria-label":e.name,className:"inline-flex size-2.25 shrink-0 rounded-full",style:{backgroundColor:e.color}})))),!(null===r||void 0===r||!r.notes)&&a.createElement(Xje.j,{notes:r.notes}),(null===r||void 0===r?void 0:r.pending)&&a.createElement(Qje.n,{isEditingDisabled:!1}),a.createElement(Yje,{amountLabel:(0,jQ.s_)(l),income:(0,jQ.iR)(l),delta:o}),a.createElement(fe.hPJ,{size:"sm"})))},wZe=e=>{var t,n,a;let l=e.dateLabel,r=e.amount,o=e.enrichment,i=e.delta;return(0,T9.A)(["View transaction from ".concat(l),(0,jQ.s_)(r),i&&"".concat(i.direction," ").concat((0,rl.vv)(i.magnitude)),null===o||void 0===o||null===(t=o.category)||void 0===t?void 0:t.name,null===o||void 0===o||null===(n=o.account)||void 0===n?void 0:n.displayName,(null===o||void 0===o||null===(a=o.tags)||void 0===a?void 0:a.length)&&"tagged ".concat(o.tags.map((e=>e.name)).join(", ")),(null===o||void 0===o?void 0:o.pending)&&"pending",(null===o||void 0===o?void 0:o.notes)&&"note: ".concat(o.notes)]).join(", ")},CZe=$d.s.div(bZe||(bZe=(0,wc.A)(["\n  relative -mx-default flex min-h-15 cursor-pointer items-center gap-2.5 px-default\n  py-2xs\n"])));var AZe,IZe;const kZe=e=>{let t=e.transactions,n=e.nextDate,l=e.expectedAmount,o=e.historyIntervals,i=e.status;const s=(0,a.useMemo)((()=>{const e=N.c9.local().startOf("day");return pHe({transactions:t,historyIntervals:o,nextDate:null!==n&&void 0!==n?n:null,amount:l},e)}),[t,o,n,l]),c=(0,a.useMemo)((()=>s.flatMap((e=>{let t=e.transactionId;return null===t?[]:[t]}))),[s]),d=iHe(c),u=d.enrichmentById,m=d.isEnrichmentLoading,p=d.openDrawer,g=d.drawer,h=(0,a.useMemo)((()=>Fje(s.flatMap((e=>null===e.transactionId?[]:[{id:e.transactionId,amount:e.amount}])))),[s]);return 0===t.length?null:a.createElement(_Ze,{"data-external-id":"recurring-stream-transaction-list"},a.createElement(fe.c8D,{size:"base",weight:"medium"},"Transactions"),a.createElement("div",{className:"-mx-default mt-sm border-t border-t-divider-primary"}),s.map((e=>(0,r.YW)(e).with({kind:"due"},(e=>{let t=e.date;return a.createElement(SZe,{key:"due:".concat(t),dateLabel:(0,Ba.AO)(t)})})).with({kind:"next"},(e=>{let t=e.date,n=e.amount;return i===Ee.G8P.OVERDUE||i===Ee.G8P.ENDED?null:a.createElement(NZe,{key:"next:".concat(t),dateLabel:(0,Ba.AO)(t),amount:n})})).with({kind:"posted"},(e=>{let t=e.transactionId,n=e.date,l=e.amount;return a.createElement(xZe,{key:t,dateLabel:(0,Ba.AO)(n),amount:l,enrichment:u.get(t),isLoading:m,delta:h.get(t),onOpen:()=>p(t)})})).exhaustive())),g)},SZe=e=>{let t=e.dateLabel;return a.createElement(TZe,{"data-external-id":"overdue-transaction-row"},a.createElement("div",{className:"flex min-w-0 flex-1 items-center gap-sm"},a.createElement(fe.c8D,{size:"sm",weight:"medium",color:"brand",className:"w-[6.5rem] shrink-0"},t),a.createElement("div",{className:"flex items-center gap-1 pl-1"},a.createElement("div",{className:"flex size-4 items-center justify-center rounded-full bg-background-brand-subtle"},a.createElement(fe.CQs,{size:"2xs",className:"text-content-brand"})),a.createElement(fe.c8D,{size:"sm",color:"brand",weight:"medium"},iVe.p.DETAIL_PANEL.OVERDUE_LABEL))),a.createElement("div",{className:"flex shrink-0 items-center gap-sm"},a.createElement(fe.c8D,{size:"sm",color:"secondary",className:"italic"},"\u2013"),a.createElement("div",{className:"size-3 shrink-0"})))},NZe=e=>{let t=e.dateLabel,n=e.amount;return a.createElement(TZe,{"data-external-id":"upcoming-transaction-row"},a.createElement("div",{className:"flex min-w-0 flex-1 items-center gap-sm"},a.createElement(fe.c8D,{size:"sm",color:"secondary",className:"w-[6.5rem] shrink-0 italic"},t),a.createElement("div",{className:"flex items-center gap-1 pl-1"},a.createElement(fe.cKU,{size:"xs",className:"text-content-secondary"}),a.createElement(fe.c8D,{size:"sm",color:"secondary",className:"italic"},iVe.p.DETAIL_PANEL.UPCOMING_LABEL))),a.createElement("div",{className:"flex shrink-0 items-center gap-sm"},void 0!==n&&a.createElement(fe.c8D,{size:"sm",color:"secondary",className:"italic"},(0,jQ.s_)(n)),a.createElement("div",{className:"size-3 shrink-0"})))},TZe=$d.s.div(AZe||(AZe=(0,wc.A)(["\n  -mx-default flex min-h-15 items-center justify-between gap-2.5 px-default py-2xs\n"]))),_Ze=$d.s.div(IZe||(IZe=(0,wc.A)(["-mx-default px-default"])));var DZe,RZe,MZe,LZe,OZe;const PZe=e=>{let t=e.group,n=e.onClose,l=e.autoFocusName,r=e.onNameFocused;return a.createElement(VZe,{"data-external-id":"recurrence-group-detail-panel-view","aria-label":"".concat(t.name," details")},a.createElement(BZe,{group:t,onClose:n,autoFocusName:l,onNameFocused:r}))},BZe=e=>{let t=e.group,n=e.onClose,l=e.autoFocusName,r=e.onNameFocused;const o=(0,a.useMemo)((()=>(0,fVe.Mp)(t.historyIntervals)),[t.historyIntervals]),i=wHe(t.merchantId),s=IHe(t),c=s.displayLogoUrl,d=s.isUploadingLogo,u=s.handleLogoFileChange,m=s.nameInputRef,p=s.nameFieldProps,g=(e=>{let t=e.inputRef,n=e.autoFocus,l=e.onFocused;const r=(0,a.useCallback)((()=>{window.setTimeout((()=>{var e,n;null===(e=t.current)||void 0===e||e.focus(),null===(n=t.current)||void 0===n||n.select()}),0)}),[t]);return(0,a.useEffect)((()=>{n&&(r(),null===l||void 0===l||l())}),[n,r,l]),r})({inputRef:m,autoFocus:l,onFocused:r}),h=fje();return a.createElement(a.Fragment,null,a.createElement(BWe,{logoUrl:c,merchantLogoUrl:t.merchantLogoUrl}),a.createElement(WZe,null,a.createElement(jZe,null,(null===h||void 0===h?void 0:h.canOpen)&&t.isActive&&a.createElement(fe.SO$,{variant:"overlay","aria-label":"Review this group",onClick:()=>null===h||void 0===h?void 0:h.openAt("detail",t.id)},a.createElement(fe.uGt,null)),a.createElement("div",{className:"ml-auto flex shrink-0 items-center gap-xs"},a.createElement(OWe,{id:t.id,name:t.name,sectionKind:t.sectionKind,isActive:t.isActive,merchantId:t.merchantId,merchantName:t.merchantName,onClose:n,onRename:g}),a.createElement(fe.TU1,{variant:"overlay","aria-label":"Close detail panel",onClick:n}))),a.createElement(HZe,null,a.createElement("div",{className:"mb-2xl flex flex-col gap-md"},a.createElement(jWe.j,Object.assign({logoSrc:c,logoName:t.name,isU
1ploadingLogo:d,onLogoFileChange:u,accept:".jpg,.jpeg,.png,.heif",className:"min-w-0",inputRef:m,description:i?a.createElement(YWe,null):void 0},p)),a.createElement("div",{className:"divide-y divide-divider-primary"},a.createElement(UZe,{label:"Type"},a.createElement(fe.c8D,{size:"sm"},yr.rB[t.sectionKind])),a.createElement(UZe,{label:"Frequency"},a.createElement(fe.c8D,{size:"sm"},t.frequencyDescription)),t.merchantName&&t.merchantId?a.createElement(UZe,{label:"Merchant"},a.createElement(Aje,{linkTo:I.JZ.merchants({id:t.merchantId}),value:t.merchantName,icon:a.createElement("span",{"aria-hidden":!0,"data-testid":"recurrence-detail-merchant-avatar"},a.createElement(Wl._,{url:t.merchantLogoUrl,size:16})),size:"sm",layout:"chip"})):null)),!t.isActive&&a.createElement(mZe,{id:t.id,name:t.name,sectionKind:t.sectionKind,endedAt:t.endedAt,transactions:t.transactions}),t.isActive&&aWe({enabled:t.isNew,surface:"panel"})&&a.createElement(hZe,{id:t.id,name:t.name,sectionKind:t.sectionKind,isActive:t.isActive,merchantId:t.merchantId,merchantName:t.merchantName,accountName:t.accountName,frequency:t.frequency,frequencyDescription:t.frequencyDescription,createdAt:t.createdAt,transactions:t.transactions}),t.isActive&&aWe({enabled:t.status===Ee.G8P.POSSIBLY_INACTIVE,surface:"panel"})&&a.createElement(yZe,{id:t.id,name:t.name,amount:t.amount,frequency:t.frequency,sectionKind:t.sectionKind,transactions:t.transactions}),t.isActive&&aWe({enabled:t.status===Ee.G8P.OVERDUE,surface:"panel"})&&a.createElement(EZe,{id:t.id,name:t.name,sectionKind:t.sectionKind,overdueSince:t.overdueSince}),a.createElement("div",{className:"mb-2xl"},a.createElement(uZe,{intervals:o,frequency:t.frequency})),t.transactions.length>0&&a.createElement(KZe,null),a.createElement(kZe,{key:t.id,transactions:t.transactions,historyIntervals:t.historyIntervals,expectedAmount:t.amount,nextDate:t.nextDate,status:t.status}))))},zZe=e=>{let t=e.onClose;return a.createElement(VZe,{"data-external-id":"recurrence-group-detail-panel-loading-view","aria-label":"Loading details","aria-busy":!0},a.createElement(YZe,{onClose:t}))},FZe=e=>{let t=e.onClose,n=e.onRetry;return a.createElement(VZe,{"data-external-id":"recurrence-group-detail-panel-error-view","aria-label":"Couldn't load details"},a.createElement(GZe,{onClose:t,onRetry:n}))},GZe=e=>{let t=e.onClose,n=e.onRetry;return a.createElement(a.Fragment,null,a.createElement(BWe,null),a.createElement(WZe,null,a.createElement(jZe,{className:"justify-end"},a.createElement(fe.TU1,{variant:"overlay","aria-label":"Close detail panel",onClick:t})),a.createElement(HZe,{className:"flex flex-col items-center justify-center gap-xl pb-4xl"},a.createElement(SQ.W,{className:"py-0",message:VG.U.RECURRING_DETAIL}),a.createElement(fe.XZZ,{variant:"default",size:"sm",onClick:n},"Try again"))))},YZe=e=>{let t=e.onClose;return a.createElement(WZe,{"data-external-id":"recurrence-group-detail-loading-content"},a.createElement(jZe,null,a.createElement("div",{className:"ml-auto flex shrink-0 items-center gap-xs"},a.createElement(fe.SO$,{variant:"overlay","aria-label":"More options"},a.createElement(fe.V_g,null)),a.createElement(fe.TU1,{variant:"overlay","aria-label":"Close detail panel",onClick:t}))),a.createElement(HZe,null,a.createElement("div",{className:"mb-lg flex flex-col gap-lg"},a.createElement("div",{className:"flex items-start gap-2.5"},a.createElement(fe.wME.Circle,{className:"size-10 shrink-0"}),a.createElement(fe.wME,{className:"h-10 min-w-0 flex-1"})),a.createElement("div",{className:"flex flex-col gap-sm"},a.createElement(fe.wME,{className:"h-5 w-full"}),a.createElement(fe.wME,{className:"h-5 w-full"}),a.createElement(fe.wME,{className:"h-5 w-full"}))),a.createElement(fe.wME,{className:"h-40 w-full rounded-default"}),a.createElement(KZe,null),a.createElement("div",{className:"flex flex-col gap-default"},a.createElement(fe.wME,{className:"h-8 w-full"}),a.createElement(fe.wME,{className:"h-8 w-full"}),a.createElement(fe.wME,{className:"h-8 w-full"}))))},UZe=e=>{let t=e.label,n=e.children;return a.createElement("div",{"data-external-id":"meta-row",className:"flex h-8 min-w-0 items-center gap-sm"},a.createElement(fe.c8D,{size:"xs",weight:"bold",color:"secondary",className:"w-24 shrink-0"},t),a.createElement("div",{className:"min-w-0 flex-1"},n))},VZe=$d.s.div(DZe||(DZe=(0,wc.A)(["\n  relative flex min-h-0 w-full flex-col overflow-hidden rounded-default bg-background-primary\n  shadow-card\n"]))),WZe=$d.s.div(RZe||(RZe=(0,wc.A)(["relative flex min-h-0 flex-auto flex-col overflow-y-auto"]))),jZe=$d.s.div(MZe||(MZe=(0,wc.A)(["flex h-15 shrink-0 items-center justify-between px-default"]))),HZe=$d.s.div(LZe||(LZe=(0,wc.A)(["flex-auto rounded-b-default px-default pt-default"]))),KZe=$d.s.div(OZe||(OZe=(0,wc.A)(["-mx-default my-lg border-t border-t-divider-primary"]))),qZe=()=>
1{const e=sWe(),t=e.selectedGroupId,n=e.clearSelection,l=e.focusNameRequested,r=e.clearNameFocus,o=function(e){let t=(arguments.length>1&&void 0!==arguments[1]?arguments[1]:{}).includeHistory,n=void 0!==t&&t;const l=(0,et.I)(aYe.KL,{variables:{id:null!==e&&void 0!==e?e:"",includeHistory:n},fetchPolicy:"cache-and-network",skip:!e}),r=l.data,o=l.isLoadingInitialData,i=l.error,s=l.refetch;return{recurrenceGroup:(0,a.useMemo)((()=>(null===r||void 0===r?void 0:r.recurrenceGroup)?wWe(r.recurrenceGroup):null),[r]),isLoading:o,error:null!==i&&void 0!==i?i:null,refetch:()=>{s()}}}(t,AWe.v),i=o.recurrenceGroup,s=o.error,c=o.refetch,d=(null===i||void 0===i?void 0:i.id)===t?i:null;return d?a.createElement(PZe,{"data-external-id":"recurrence-group-detail-panel",key:d.id,group:d,onClose:n,autoFocusName:l,onNameFocused:r}):t&&!s?a.createElement(zZe,{"data-external-id":"recurrence-group-detail-panel",onClose:n}):s?a.createElement(FZe,{"data-external-id":"recurrence-group-detail-panel",onClose:n,onRetry:c}):null};var $Ze,ZZe,JZe,XZe;const QZe=e=>{let t=e.sidebarContent,n=e.children;const l=(0,d.d4)(tKe.OO),r=void 0!==t&&l,o=sWe().selectedGroupId,i=Boolean(o),s=r||i;return a.createElement(eJe,{"data-external-id":"recurring-v2-tab-frame"},a.createElement("div",{className:(0,q.cn)("flex w-full flex-1 items-start transition-[gap] duration-150 ease-in-out",s&&"gap-lg")},a.createElement(tJe,{"data-testid":"recurring-tab-main"},n),a.createElement(nJe,{"data-testid":"recurring-tab-sidebar",inert:s?void 0:"",className:s?"w-90 overflow-visible opacity-100":"w-0 overflow-hidden opacity-0"},t&&a.createElement(aJe,{inert:i||!r?"":void 0,className:(0,q.cn)(i&&"absolute inset-0 overflow-hidden",!r&&"invisible")},t),i&&a.createElement("div",{className:"relative z-1 flex h-full flex-col pb-gutter"},a.createElement(qZe,null)))))},eJe=$d.s.div($Ze||($Ze=(0,wc.A)(["flex w-full flex-1 flex-col px-gutter pt-0"]))),tJe=$d.s.div(ZZe||(ZZe=(0,wc.A)(["flex min-w-(--breakpoint-sm) flex-1 flex-col"]))),nJe=$d.s.div(JZe||(JZe=(0,wc.A)(["\n  sticky top-0 h-[calc(100dvh-var(--root-top)-var(--app-header-height))]\n  shrink-0\n  transition-all\n  duration-150 ease-in-out max-md:h-[calc(100dvh-var(--root-top)-var(--app-header-height)-var(--app-tabs-row-height))]\n"]))),aJe=$d.s.div(XZe||(XZe=(0,wc.A)(["overflow-visible"]))),lJe=e=>{let t=e.groupSelection;const n=(0,d.d4)(tKe.Ze),l=iKe("all",n);return a.createElement(kWe,{"data-external-id":"recurring-v2-all",filters:l},a.createElement(iWe.Provider,{value:t},a.createElement(QZe,null,a.createElement(rZe,{tab:"all"}))))},rJe=()=>a.createElement("div",{"data-external-id":"recurring-v2-coming-soon",className:"w-full px-gutter"},a.createElement(fe.xz6,null,a.createElement(Hqe,null)));var oJe,iJe,sJe=n(88571),cJe=n(43306);const dJe={success:{token:"progress-success",fill:"bg-progress-success"},danger:{token:"progress-danger",fill:"bg-progress-danger"},info:{token:"progress-info",fill:"bg-progress-info"}},uJe=e=>{var t,n,l,r,o,i,s,c,d;let u=e.startDate,m=e.aggregatedSummary,p=e.isLoadingSummary;const g=null===m||void 0===m?void 0:m.expense,h=null===m||void 0===m?void 0:m.income,v=null===m||void 0===m?void 0:m.transfer,f=Math.abs(null!==(t=null===g||void 0===g?void 0:g.completed)&&void 0!==t?t:0),E=Math.abs(null!==(n=null===h||void 0===h?void 0:h.completed)&&void 0!==n?n:0),y=Math.abs(null!==(l=null===v||void 0===v?void 0:v.completed)&&void 0!==l?l:0),b=(null!==(r=null===g||void 0===g?void 0:g.count)&&void 0!==r?r:0)>0,x=Math.abs(null!==(o=null===h||void 0===h?void 0:h.total)&&void 0!==o?o:0)>0,w=(null!==(i=null===v||void 0===v?void 0:v.count)&&void 0!==i?i:0)>0;return a.createElement(pJe,{"data-external-id":"recurring-summary-sidebar"},a.createElement(fe.c8D,{size:"base",weight:"medium",className:"mb-md"},u.toFormat("LLLL yyyy")),a.createElement(mJe,{title:"Expenses",total:Math.abs(null!==(s=null===g||void 0===g?void 0:g.total)&&void 0!==s?s:0),paid:f,overdue:0,totalSuffix:"due",doneVerb:"paid",meterColor:"danger",isLoading:p,isEmpty:!b,emptyText:iVe.p.SUMMARY.NO_EXPENSES_YET,isAllPending:hYe(g).isAllPending}),a.createElement(mJe,{title:"Income",total:Math.abs(null!==(c=null===h||void 0===h?void 0:h.total)&&void 0!==c?c:0),paid:E,overdue:0,totalSuffix:"expected",doneVerb:"received",valuePrefix:"+",remainColorOverride:"success",isLoading:p,isEmpty:!x,emptyText:iVe.p.SUMMARY.NO_INCOME_YET}),a.createElement(mJe,{title:"Transfers",total:Math.abs(null!==(d=null===v||void 0===v?void 0:v.total)&&void 0!==d?d:0),paid:y,overdue:0,totalSuffix:"scheduled",doneVerb:"sent",meterColor:"info",isLoading:p,isEmpty:!w,emptyText:iVe.p.SUMMARY.NO_TRANSFERS_YET}),a.createElement(mJe,{title:yr.Tq[Ee.kjN.CREDIT_CARD],total:0,paid:0,overdue:0,totalSuffix:"due",doneVerb:"paid",isLoading:p,isEmpty:!0,emptyText:"Coming soon",tooltipText:iVe.p.SUMMARY.STATEMENTS_TOOLTIP}))},mJe=e=>{let t=e.title,n=e.tooltipText,l=e.total,r=e.paid,o=e.overdue,i=e.totalSuffix,s=e.doneVerb,c=e.meterColor,d=void 0===c?"success":c,u=e.valuePrefix,m=void 0===u?"":u,p=e.remainColorOverride,g=e.isLoading,h=e.isEmpty,v=e.emptyText,f=e.isAllPending;if(g)return a.createElement(gJe,{"data-external-id":"recurring-summary-sidebar-row"},a.createElement(fe.wME,{className:"h-4 w-24"}),a.createElement(fe.wME,{className:"mt-2xs h-2 w-full"}),a.createElement(fe.wME,{className:"mt-2xs h-3 w-32"}));if(h)return a.createElement(gJe,{"data-external-id":"recurring-summary-sidebar-row"},a.createElement("div",{className:"flex flex-col items-start gap-xs"},n?a.createElement(fe.cIj,{size:"3xs",iconSize:"xs",content:n,triggerClassName:"text-content-secondary",label:a.createElement(fe.c8D,{size:"sm",weight:"medium"},t)}):a.createElement(fe.c8D,{size:"sm",weight:"medium"},t),a.createElement(fe.c8D,{size:"sm",color:"secondary"},v)));const E=l||1,y=Math.max(0,Math.min(r,E)),b=Math.max(0,Math.min(o,E-y)),x=Math.max(0,l-y-b),w=(0,cJe.us)((0,sJe.q)(y,0,E),2),C=Math.min((0,cJe.us)((0,sJe.q)(b,0,E),2),100-w);return a.createElement(gJe,{"data-external-id":"recurring-summary-sidebar-row"},a.createElement("div",{className:"flex items-baseline justify-between gap-xs"},n?a.createElement(fe.cIj,{size:"3xs",iconSize:"xs",content:n,triggerClassName:"text-content-secondary",label:a.createElement(fe.c8D,{size:"sm",weight:"medium"},t)}):a.createElement(fe.c8D,{size:"sm",weight:"medium"},t),a.createElement(fe.c8D,{size:"sm",weight:"medium",color:"secondary"},m,(0,rl.T3)(l)," ",i)),a.createElement(fe.yDW,{value:(0,De.Eb)([y,b]),max:E,size:"sm",color:dJe[d].token,className:"mt-2xs"},a.createElement(fe.yDW.Track,{className:"flex"},y>0&&a.createElement("div",{className:(0,q.cn)("h-full shrink-0",dJe[d].fill),style:{width:"".concat(w,"%")}}),b>0&&a.createElement("div",{className:"h-full shrink-0 bg-progress-brand",style:{width:"".concat(C,"%")}}))),f?a.createElement(fe.c8D,{size:"sm",weight:"medium",color:"secondary",className:"mt-2xs"},"Remaining pending"):a.createElement("div",{className:"mt-2xs flex items-center justify-between gap-xs text-sm font-medium"},a.createElement(fe.c8D,{size:"sm",weight:"medium"},(0,rl.T3)(r)," ",s),a.createElement(fe.c8D,{size:"sm",weight:"medium",color:null!==p&&void 0!==p?p:o>0?"danger":"secondary"},o>0&&"".concat((0,rl.T3)(o)," overdue \xb7 "),(0,rl.T3)(x)," left")))},pJe=$d.s.div(oJe||(oJe=(0,wc.A)(["flex w-90 flex-col rounded-default bg-background-primary p-lg shadow-md"]))),gJe=$d.s.div(iJe||(iJe=(0,wc.A)(["-mx-lg border-b border-b-divider-primary px-lg py-sm first:pt-0 last:border-b-0 last:pb-0"]))),hJe=e=>{let t=e.currentStartDate,n=e.endDate,l=e.setStartDate,r=e.groupSelection;const o=(0,d.d4)(tKe.Ze),i=(e=>{let t=e.currentStartDate,n=e.endDate,a=e.filters;const l=(0,et.I)(aYe.TL,{variables:{startDate:t.toISODate(),endDate:n.toISODate(),filters:(0,Ur.gm)(a),includeInactive:Ur.tQ},fetchPolicy:"cache-and-network"}
1),r=l.data,o=l.isNetworkRequestInFlight,i=l.isDataAvailable,s=l.refetch;return{aggregatedSummary:null===r||void 0===r?void 0:r.aggregatedRecurrenceGroups,isLoadingSummary:o&&!i,refetchSummary:s}})({currentStartDate:t,endDate:n,filters:o}),s=i.aggregatedSummary,c=i.isLoadingSummary,u=i.refetchSummary,m=(0,a.useMemo)((()=>({currentStartDate:t,endDate:n})),[t,n]),p=(0,a.useMemo)((()=>({startDate:t,setStartDate:l})),[t,l]);return a.createElement(kWe,{"data-external-id":"recurring-v2-monthly",timeWindow:m,filters:o},a.createElement(iWe.Provider,{value:r},a.createElement(QZe,{sidebarContent:a.createElement(uJe,{startDate:t,aggregatedSummary:s,isLoadingSummary:c})},a.createElement(rZe,{tab:"monthly",month:p,onMerchantUpdated:u}))))},vJe="Recurring V2",fJe=e=>{let t=e.monthRange,n=e.v2State;const r=(0,l.zy)();return a.createElement("div",{"data-external-id":"recurring-v2-tab-routes",className:"flex min-h-0 w-full flex-1 flex-col"},a.createElement(l.BV,null,a.createElement(l.qh,{path:"*",element:a.createElement(l.C5,{to:{pathname:I.JZ.recurringV2.monthly.path,search:r.search},replace:!0})}),a.createElement(l.qh,{path:"".concat(I.JZ.recurringV2.monthly.relativePath,"/:groupId?"),element:a.createElement(a.Fragment,null,a.createElement(rV.T,{screenName:vJe,tab:"monthly"}),a.createElement(hJe,{currentStartDate:t.currentStartDate,endDate:t.endD
1ate,setStartDate:t.setStartDate,groupSelection:n.groupSelection}))}),a.createElement(l.qh,{path:"".concat(I.JZ.recurringV2.all.relativePath,"/:groupId?"),element:a.createElement(a.Fragment,null,a.createElement(rV.T,{screenName:vJe,tab:"all"}),a.createElement(lJe,{groupSelection:n.groupSelection}))}),a.createElement(l.qh,{path:I.JZ.recurringV2.calendar.relativePath,element:a.createElement(a.Fragment,null,a.createElement(rV.T,{screenName:vJe,tab:"calendar"}),a.createElement(rJe,null))}),a.createElement(l.qh,{path:I.JZ.recurringV2.playground.relativePath,element:a.createElement(bKe.m,{name:"feat-recurring-playground",defaultOnTimeout:"off",redirectTo:I.JZ.recurringV2.monthly.path},a.createElement(TKe,null,a.createElement(rV.T,{screenName:vJe,tab:"playground"}),a.createElement(Wqe,null)))})))},EJe=e=>void 0!==e&&null!==e,yJe=()=>{var e,t;const n=(0,et.I)(aYe.VZ),l=n.data,r=n.isLoadingInitialData,o=n.startPolling,i=n.stopPolling,s=null===l||void 0===l?void 0:l.recurrenceGroupDetectionStatus,c=null!==(e=null===s||void 0===s?void 0:s.isFirstRun)&&void 0!==e&&e,d=null!==(t=null===s||void 0===s?void 0:s.isRunning)&&void 0!==t&&t,u=(e=>Boolean((null===e||void 0===e?void 0:e.isFirstRun)&&e.isRunning&&!EJe(e.failedAt)))(s);return(0,a.useEffect)((()=>(u?o(1e4):i(),()=>i())),[u,o,i]),{isLoading:r,isFirstRun:c,isRunning:d,hasFailed:EJe(null===s||void 0===s?void 0:s.failedAt),isFirstRunInProgress:u}},bJe=()=>{const e=(0,l.zy)(),t=tVe(),n=(()=>{var e,t,n,r;const i=(0,l.Zp)(),s=(0,l.zy)(),c=(0,l.RQ)(I.JZ.recurringV2.monthly.group.path),d=(0,l.RQ)(I.JZ.recurringV2.all.group.path),u=null!==(e=null!==(t=null===c||void 0===c||null===(n=c.params)||void 0===n?void 0:n.groupId)&&void 0!==t?t:null===d||void 0===d||null===(r=d.params)||void 0===r?void 0:r.groupId)&&void 0!==e?e:null,m=(0,a.useState)(!1),p=(0,o.A)(m,2),g=p[0],h=p[1],v=(0,a.useCallback)((()=>h(!0)),[]),f=(0,a.useCallback)((()=>h(!1)),[]),E=(0,a.useRef)(s);E.current=s;const y=(0,a.useCallback)((e=>{const t=E.current,n=t.pathname,a=t.search,l=(0,ma.gQ)(n,I.JZ.recurringV2.all.path)?I.JZ.recurringV2.all.path:I.JZ.recurringV2.monthly.path,r=gje(new URLSearchParams(a)),o=r.size>0?"?".concat(r.toString()):"";i({pathname:"".concat(l,"/").concat(e),search:o}),h(!1)}),[i]),b=(0,a.useCallback)((()=>{const e=E.current,t=e.pathname,n=e.search,a=(0,ma.gQ)(t,I.JZ.recurringV2.all.path)?I.JZ.recurringV2.all.path:I.JZ.recurringV2.monthly.path;i({pathname:a,search:n},{replace:!0}),h(!1)}),[i]);return{groupSelection:(0,a.useMemo)((()=>({selectedGroupId:u,selectGroup:y,clearSelection:b,focusNameRequested:g,setNameFocus:v,clearNameFocus:f})),[u,y,b,g,v,f])}})(),i=yJe(),s=i.isLoading,c=i.isFirstRun,d=i.isRunning,u=i.hasFailed,m=c&&(!d||u),g=s||c,h=(e=>{let t=e.currentStartDate,n=e.endDate,l=e.skip,r=void 0!==l&&l;const i=(0,xq.bO)("dismissedRecurringV2WalkthroughAt"),s=(0,o.A)(i,3),c=s[0],d=s[1],u=s[2],m=(e=>{let t=e.isLoadingFlag,n=e.dismissedAt;return!t&&null===n})({isLoadingFlag:u,dismissedAt:c}),p=CWe((0,U.A)({enabled:m&&!r,timeWindow:{currentStartDate:t,endDate:n},filters:KHe},AWe.F)),g=p.recurrenceGroups,h=p.isLoading,v=p.isResultAvailable;return(0,a.useEffect)((()=>{m&&!r&&YHe().catch((()=>{}))}),[m,r]),{isPending:!r&&jHe({isLoadingFlag:u,dismissedAt:c,isLoadingGroups:h,isResultAvailable:v}),shouldShow:HHe({isLoadingFlag:u,dismissedAt:c,isLoadingGroups:h,groupCount:g.length}),dismiss:()=>d((new Date).toISOString())}}
1)({currentStartDate:t.currentStartDate,endDate:t.endDate,skip:g}),v=h.isPending,f=XHe(e.pathname),E="monthly"===f||"all"===f,y=(0,r.YW)({hideChrome:v,isBusy:g,shouldShowGroupListControls:E}).with({hideChrome:!0},(()=>{})).with({isBusy:!0},(()=>a.createElement(GHe.p,null))).with({shouldShowGroupListControls:!0},(()=>a.createElement(fKe,{activeTab:f}))).otherwise((()=>{}));return a.createElement(vje,{"data-external-id":"recurring-v2-page",enabled:!g},a.createElement(Yq,{name:"Recurring V2",overrideTitle:"Recurring 2.0",shouldScroll:!g,showHeader:!v,tabs:v||g?void 0:a.createElement(QHe,null),emptyIcon:"calendar",emptyTitle:_t._E.EMPTY_STATE_TITLE,emptyButtonText:_t._E.EMPTY_ACCOUNTS_BUTTON_TEXT,controls:y},s&&a.createElement("div",{className:"flex flex-1 items-center justify-center"},a.createElement(p.i,null)),!s&&c&&a.createElement("div",{className:"flex min-h-0 flex-1 flex-col"},a.createElement(yKe,{hasStalled:m})),!g&&!v&&a.createElement("div",{className:"flex min-h-0 flex-1 flex-col items-start"},a.createElement(fJe,{monthRange:t,v2State:n})),a.createElement(VHe,{shouldShow:h.shouldShow,showCover:h.isPending,onDismiss:h.dismiss})),a.createElement(BHe,{onSelectGroup:n.groupSelection.selectGroup}))},xJe=e=>{let t=e.children;const n=(0,l.zy)().pathname,r=(0,Sse.x)(),o=r.isOn,i=r.isLoading;return JHe({isEnrollmentLoading:i,isEnrolled:o,pathname:n})?t:a.createElement(l.C5,{"data-external-id":"recurring-v2-route",to:I.JZ.recurring.upcoming.path,replace:!0})},wJe=e=>{let t=e.summary,n=e.hasData,l=e.filters,r=e.isLoading,i=void 0!==r&&r,s=e.dateRangeLabel,c=e.empty,d=e.onClickDownloadPng;const u=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:300;const n=(0,a.useState)(!1),l=(0,o.A)(n,2),r=l[0],i=l[1];return(0,a.useEffect)((()=>{if(!e)return void i(!1);const n=setTimeout((()=>i(!0)),t);return()=>clearTimeout(n)}),[e,t]),r}(i)||!n,m=VQ({filters:l}),p=a.createElement(HK,{insightTheme:"TRANSACTIONS",content:m,tooltipPlacement:"bottom",tooltipDescription:UQ,source:Ye.rP.Reports,isLoading:u});return u||0!==t.sumIncome||0!==t.sumExpense?a.createElement(TQ,{"data-external-id":"reports-cash-flow-summary-card",controls:p,footerClassName:"justify-center",footer:d&&a.createElement(Wb.X,{variant:"text",colorScheme:"link",onClick:d},"Download PNG")},s&&a.createElement("div",{className:"flex items-center gap-2xs text-content-primary"},a.createElement(Rne.MdsCalendarIcon,{size:"sm"}),a.createElement(kD.c,{size:"sm",weight:"medium"},s)),a.createElement(TQ.Rows,null,a.createElement(CJe,{label:"Total income",value:t.sumIncome,color:"success",signDisplay:"exceptZero",isLoading:u,weight:"medium"}),a.createElement(CJe,{label:"Total spending",value:Math.abs(t.sumExpense),isLoading:u}),a.createElement(CJe,{label:"Net cash flow",value:t.savings,isLoading:u}),a.createElement(CJe,{label:"Savings rate",value:Math.max(0,t.savingsRate),format:"percent",isLoading:u}))):a.createElement(TQ,{"data-external-id":"reports-cash-flow-summary-card",controls:p},c)},CJe=e=>{let t=e.label,n=e.value,l=e.color,r=e.format,o=void 0===r?"currency":r,i=e.signDisplay,s=e.isLoading,c=e.weight;return a.createElement(TQ.Row,{"data-external-id":"summary-row",label:t},s?a.createElement(NQ.w,{className:"h-6 w-32"}):a.createElement(PX.P,{value:n,style:o,signDisplay:i,weight:c,color:l}))};var AJe=n(51923),IJe=n(96606);const kJe=e=>{let t=e.value,n=e.neutralIfZero,l=e.color,r=void 0===l?"text":l,o=e.formatter,i=void 0===o?AJe.A:o;return a.createElement(xt.v,{"data-external-id":"reports-cash-flow-value",color:n&&0===t?"text":r},(0,IJe.A)(t)&&(0,Tr.A)(t)?i(t):"-")},SJe=[{value:"transactions",label:"Transactions",description:"Every transaction in the range",thumbnail:"transactions"},{value:"rankedBars",label:"Breakdown",description:"Income & expenses, biggest to smallest",thumbnail:"rankedBars"}],NJe=e=>{let t=e.activityView,n=e.onChangeActivityView;return a.createElement(pW,{"data-external-id":"reports-cash-flow-view-select","aria-label":"Activity view",options:SJe,value:t,onValueChange:n})},TJe=e=>e===Ee.DB0.CATEGORY_GROUP||e===Ee.DB0.MERCHANT?e:Ee.DB0.CATEGORY;var _Je=n(94069),DJe=n(30424),RJe=n(76034);const MJe={category:"By category",group:"By group",both:"By category & group"};var LJe,OJe;const PJe="cash-flow-entity-view-toggle",BJe=e=>{let t=e.isShareDisabled,n=e.chartType,l=e.onChangeChartType,r=e.spendingIncomeGroupBy,o=e.showBusinessEntityGroupBy,i=e.showBudgetVariabilityGroupBy,s=e.showOwnerGroupBy,c=e.onCh
1angeSpendingIncomeGroupBy,d=e.treemapNodeCount,u=e.onChangeTreemapNodeCount,m=e.cashFlowGroupMode,p=e.onChangeCashFlowGroupMode,g=e.cashFlowBusinessEntityView,h=e.onChangeCashFlowBusinessEntityView,v=e.groupByTimeframe,f=e.onChangeGroupByTimeframe,E=e.onClickShare;const y=(0,a.useCallback)((e=>n&&e.includes(n)),[n]),b=(0,a.useMemo)((()=>[y([V1.Gi.CashFlowChart,V1.Gi.StackedCashFlowChart,V1.Gi.BarChart,V1.Gi.StackedBarChart])&&a.createElement(FJe,{timeframe:v,onChangeTimeframe:f}),y([V1.Gi.TreemapChart])&&"number"===typeof d&&void 0!==u&&a.createElement(VJe,{nodeCount:d,groupBy:r,onChangeNodeCount:u}),r&&a.createElement(UJe,{groupBy:r,onChangeGroupBy:c,showBusinessEntityGroupBy:o,showBudgetVariabilityGroupBy:i,showOwnerGroupBy:s}),y([V1.Gi.StackedBarChart,V1.Gi.BarChart])&&a.createElement(a.Fragment,null,a.createElement(wm.A,{orientation:"vertical",color:"secondary",className:"mx-2xs h-default"}),a.createElement(WJe,{chartType:n,onChangeChartType:l,groupedChartType:V1.Gi.BarChart,stackedChartType:V1.Gi.StackedBarChart})),o&&y([V1.Gi.SankeyCashFlowChart])&&a.createElement(YJe,{businessEntityView:g,onChangeCashFlowBusinessEntityView:h}),y([V1.Gi.SankeyCashFlowChart,V1.Gi.ProfitLossTable])&&a.createElement(GJe,{groupMode:m,onChangeCashFlowGroupMode:p}),y([V1.Gi.CashFlowChart,V1.Gi.StackedCashFlowChart])&&a.createElement(a.Fragment,null,a.createElement(wm.A,{orientation:"vertical",color:"secondary",className:"mx-2xs h-default"}),a.createElement(WJe,{chartType:n,onChangeChartType:l,groupedChartType:V1.Gi.CashFlowChart,stackedChartType:V1.Gi.StackedCashFlowChart})),a.createElement(a.Fragment,null,a.createElement(wm.A,{orientation:"vertical",color:"secondary",className:"mx-2xs h-default"}),a.createElement(wt.Xb,{onClick:E,disabled:t},a.createElement(KJe,{name:"download"})))].filter(a.isValidElement)),[y,v,f,r,o,i,s,c,d,u,n,l,m,p,g,h,t,E]);return a.createElement(jJe,{"data-external-id":"reports-chart-card-controls"},b.map(((e,t)=>a.createElement(a.Fragment,{key:t},e))))},zJe=e=>{if(!e)return"Items shown";const t=Vo.Li[e];return"category"===t?"Categories shown":"fixed / flexible"===t?"Fixed / flexible shown":"business"===t?"Businesses shown":"".concat(t.charAt(0).toUpperCase()).concat(t.slice(1),"s shown")},FJe=e=>{let t=e.timeframe,n=e.onChangeTimeframe;const l=(0,a.useMemo)((()=>Object.entries(RJe.aV).map((e=>{let t=(0,o.A)(e,2);return{value:t[0],label:t[1]}}))),[]);return a.createElement(qV.h,{"data-external-id":"timeframes-dropdown",size:"sm",options:l,value:t,onValueChange:n,classNames:{trigger:"w-auto font-medium"}})},GJe=e=>{let t=e.groupMode,n=void 0===t?"both":t,l=e.onChangeCashFlowGroupMode;const r=(0,a.useMemo)((()=>Object.entries(MJe).map((e=>{let t=(0,o.A)(e,2);return{value:t[0],label:t[1]}}))),[]);return a.createElement(qV.h,{"data-external-id":"cash-flow-group-mode-dropdown",size:"sm",options:r,value:n,onValueChange:l,classNames:{trigger:"w-auto font-medium"}})},YJe=e=>{let t=e.businessEntityView,n=void 0===t?"byBusiness":t,l=e.onChangeCashFlowBusinessEntityView;return a.createElement("div",{"data-external-id":"cash-flow-business-entity-view-toggle",className:"mr-sm flex items-center gap-xs"},a.createElement(ox.k,{id:PJe,checked:"byBusiness"===n,onChange:e=>l(e.target.checked?"byBusiness":"combined")}),a.createElement(kD.c,{size:"sm",weight:"medium",render:a.createElement("label",{htmlFor:PJe})},"Split by business"))},UJe=e=>{let t=e.groupBy,n=e.onChangeGroupBy,l=e.showBusinessEntityGroupBy,r=e.showBudgetVariabilityGroupBy,i=e.showOwnerGroupBy;const s=(0,a.useMemo)((()=>Object.entries(Vo.Li).filter((e=>{let n=(0,o.A)(e,1)[0];return(n!==Ee.DB0.BUSINESS_ENTITY||l||n===t)&&(n!==Ee.DB0.BUDGET_VARIABILITY||r||n===t)&&(n!==Ee.DB0.OWNER||i||n===t)})).map((e=>{let t=(0,o.A)(e,2),n=t[0],a=t[1];return{value:n,label:"By ".concat(a)}}))),[t,l,r,i]);return a.createElement(qV.h,{"data-external-id":"spending-income-group-mode-dropdown",size:"sm",options:s,value:t,placeholder:"Group by",onValueChange:n,classNames:{trigger:"w-auto font-medium"}})},VJe=e=>{let t=e.nodeCount,n=e.groupBy,l=e.onChangeNodeCount;return a.createElement(fA.A,{"data-external-id":"treemap-node-count-dropdown",placement:"bottom-end",overlay:a.createElement(qJe,null,a.createElement($Je,null,zJe(n)),Vo.lj.map((e=>a.createElement(Ji.xm,{key:e,onClick:()=>l(e),selected:e===t},"Top ",e))))},(e=>{let n=e.toggleOpen,l=e.isOpen;return a.createElement(wt.Xb,{onClick:n,active:l},"Top ",t," ",a.createElement(HJe,null))}))},WJe=e=>
1{let t=e.chartType,n=e.onChangeChartType,l=e.groupedChartType,r=e.stackedChartType;const o=(0,a.useMemo)((()=>[{value:l,label:"Grouped",leading:a.createElement(_Je.MdsBarChartIcon,{size:"md"})},{value:r,label:"Stacked",leading:a.createElement(DJe.MdsBarChart2Icon,{size:"md"})}]),[l,r]);return a.createElement(qV.h,{"data-external-id":"grouped-stacked-chart-type-dropdown",size:"sm",options:o,value:t,onValueChange:n,classNames:{trigger:"w-auto font-medium"}})},jJe=(0,u.default)(m.g).attrs({gap:"xsmall",alignStretch:!0}).withConfig({displayName:"ReportsChartCardControls__Root",componentId:"sc-1w5c9v1-0"})(["height:36px;"]),HJe=(0,u.default)(sl.ZQ).attrs({name:"chevron-down",size:12}).withConfig({displayName:"ReportsChartCardControls__ChevronDownIcon",componentId:"sc-1w5c9v1-1"})(["transform:translateY(0px);margin-left:",";"],vt.YK.xsmall),KJe=(0,u.default)(sl.ZQ).attrs({size:16}).withConfig({displayName:"ReportsChartCardControls__ButtonGroupIcon",componentId:"sc-1w5c9v1-2"})([""]),qJe=(0,$d.s)(Ji.SP)(LJe||(LJe=(0,wc.A)(["min-w-55.5"]))),$Je=$d.s.div(OJe||(OJe=(0,wc.A)(["px-default py-xs text-sm text-content-secondary"])));var ZJe=n(86235);const JJe=["description"],XJe=e=>{const t=(0,E.wA)(),n=(0,d.d4)(ZJe.TE),l=(0,a.useCallback)((()=>t((0,g.lo)({maintainDateFilters:!0}))),[t]),r=e.description,o=(0,En.A)(e,JJe);return a.createElement(txe.m,Object.assign({"data-external-id":"reports-chart-card-empty"},o,{description:null!==r&&void 0!==r?r:a.createElement(xt.v,{size:"small"},"Try updating your date range, or",a.createElement("br",null),n?a.createElement(cl.M,{onClick:l},"clearing your filters"):a.createElement(Vl.W,{to:I.JZ.accounts.addAccount()},"add more accounts"),".")}))};var QJe=n(73405);const eXe=["colors","className"],tXe=e=>{let t=e.colors,n=(e.className,(0,En.A)(e,eXe));const l=(0,u.useTheme)();return a.createElement(QJe.i,Object.assign({"data-external-id":"deprecated-color-field"},n),(e=>{let r=e.id,o=e.value,i=e.handleBlur,s=e.setFieldValue;return a.createElement(m.g,{gap:"small"},t.map((e=>a.createElement(nXe,{key:e},a.createElement(aXe,{tabIndex:0,onKeyPress:t=>{"Enter"!==t.key&&" "!==t.key||(s(n.name,e),i(t))},id:r,$color:e,onClick:t=>{s(n.name,e),i(t)}}),o===e&&a.createElement(lXe,{color:(0,xb.W0)(e,l.color.black,l.color.white,!0)})))))}))},nXe=u.default.div.withConfig({displayName:"ColorField__SquareContainer",componentId:"sc-1ue568h-0"})(["position:relative;cursor:pointer;"]),aXe=u.default.div.withConfig({displayName:"ColorField__Square",componentId:"sc-1ue568h-1"})(["width:","px;height:","px;background-color:",";border-radius:",";box-shadow:inset 0 0 0 1px ",";"],40,40,(e=>e.$color),vt.r8.small,(e=>{let t=e.theme;return(0,xb.No)(.9,t.color.textWhite)})),lXe=(0,u.default)(sl.ZQ).attrs({name:"check"}).withConfig({displayName:"ColorField__CheckedIcon",componentId:"sc-1ue568h-2"})(["color:",";position:absolute;user-select:none;top:50%;left:50%;transform:translate(-50%,-50%);"],(e=>e.color));var rXe=n(51296);const oXe=["grayBackground","orange","blue","green","yellow","purple","pink","lime"],iXe=e=>{let t=e.background,n=e.theme;return(0,r.YW)({background:t,uiTheme:n.uiTheme}).with({uiTheme:"light",background:n.color.grayBackground},{background:r.P.union(n.color.yellow,n.color.lime)},(()=>"dark")).otherwise((()=>"allWhite"))},sXe=(0,u.default)(Rc.L).withConfig({displayName:"ReportsChartShareModal__Root",componentId:"sc-9949tp-0"})(["width:","px;margin:auto;"],840),cXe=(0,u.default)(m.g).attrs({column:!0,gap:"gutter"}).withConfig({displayName:"ReportsChartShareModal__Content",componentId:"sc-9949tp-1"})(["padding:",";padding-top:0;"],vt.YK.xlarge),dXe=u.default.div.withConfig({displayName:"ReportsChartShareModal__ChartContainerWithMargin",componentId:"sc-9949tp-2"})(["margin:0 "," ",";"],vt.YK.xlarge,vt.YK.xlarge),uXe=(0,u.default)(Qw.X).withConfig({displayName:"ReportsChartShareModal__TextFieldWithoutMargin",componentId:"sc-9949tp-3"})(["&&{margin-bottom:0;}"]),mXe=e=>{let t=e.chart,n=e.header,l=e.initialValues,r=e.displayProperties,o=e.tab;const i=(0,u.useTheme)(),s=i.color,c=(0,a.useMemo)((()=>(e=>oXe.map((t=>({color:e[t],label:t}))))(s).map((e=>e.color))),[s]),d=(0,a.useRef)(null),m=(null===r||void 0===r?void 0:r.chartType)===V1.Gi.SankeyCashFlowChart,p=(0,a.useCallback)((e=>{var t,n,a,l;let o=e.title;const i=m?null===(t=d.current)||void 0===t?void 0:t.querySelector("[".concat(rXe.D,"]")):null,s=i?i.offsetWidth:null===(n=d.current)||void 0===n?void 0:n.offsetWidth,c=null!==(a=null===(l=d.current)||void 0===l?void 0:l.offsetHeight)&&void 0!==a?a:0,u=i?c+i.scrollHeight-i.offsetHeight:c;return(0,_a.ov)({element:d.current,fileName:o,height:u,width:s,includeWatermark:!1,qual
1ity:1,scale:2,chartType:null===r||void 0===r?void 0:r.chartType})}),[r,m]),g=(0,a.useCallback)((async e=>{const t=await p(e);t&&r&&(0,_a.Xs)(t,e.title,{chart:r.chartType,view:(0,RJe.jd)(r),tab:o})}),[p,r,o]);return a.createElement(sXe,{"data-external-id":"reports-chart-share-modal",title:"Download Chart",hideBottomBorder:!0},a.createElement(Eu.lV,{onSubmit:g,initialValues:(0,U.A)({title:"",hideAmounts:!1,background:c[0]},l||{}),isInitialValid:!0},a.createElement(cXe,null,a.createElement(uXe,{name:"title",label:"Chart Name",required:!0}),a.createElement(fPe,{toggleFieldProps:{name:"hideAmounts",label:"Hide dollar amounts"},fieldCellProps:{title:"Hide dollar amounts",subtitle:"This will hide dollar amounts so that actual values are not visible. This is great if you want to keep the amounts private, but still share the trends."}}),a.createElement(tXe,{name:"background",label:"Background",colors:c})),a.createElement(dXe,null,a.isValidElement(t)&&a.createElement(hu.c.Consumer,null,(e=>{let l=e.values;return a.createElement("div",{ref:d},a.createElement(rXe.a,{title:l.title,chart:t,cardHeader:n,background:l.background,logoAppearance:iXe({background:l.background,theme:i}),hideAmounts:l.hideAmounts,scale:m?.5:void 0}))}))),a.createElement(Cq.R,null,a.createElement(CJ.I,{size:"small",disableWhenValuesUnchanged:!1},"Download"))))},pXe=a.memo(mXe),gXe="trends",hXe=[V1.Gi.BarChart,V1.Gi.StackedBarChart,V1.Gi.TreemapChart,V1.Gi.CashFlowChart,V1.Gi.StackedCashFlowChart],vXe=e=>{let t=e.currentTab,n=e.chartType,l=e.showProfitLossTable,r=void 0!==l&&l,o=e.showTreemapChart,i=void 0!==o&&o,s=e.onChangeChartType,c=e.onChangeViewMode;const d=(0,a.useMemo)((()=>{if("cashFlow"===t)return[{value:V1.Gi.SankeyCashFlowChart,label:"Sankey",description:"Visualize your cash flow streams",thumbnail:"sankey"},{value:gXe,label:"Trend bars",description:"Track your behavior over time",thumbnail:"trendBars"},...r||n===V1.Gi.ProfitLossTable?[{value:V1.Gi.ProfitLossTable,label:"Profit & Loss",description:"Accountant-friendly breakdown",thumbnail:"profitLoss"}]:[]];const e="income"===t;return[{value:V1.Gi.PieChart,label:"Pie",description:e?"Your income breakdown at a glance":"Your expense breakdown at a glance",thumbnail:"pie"},{value:V1.Gi.HorizontalBarChart,label:"Breakdown",description:e?"Income streams, biggest to smallest":"Expenses, biggest to smallest",thumbnail:"rankedBars"},...i?[{value:V1.Gi.TreemapChart,label:"Treemap",description:"Proportional category breakdown",thumbnail:"treemap"}]:[],{value:gXe,label:"Trend bars",description:e?"Your income over time":"Your spending behavior over time",thumbnail:"trendBars"}]}),[t,r,i,n]),u=(0,a.useMemo)((()=>{var e,t;const a=n&&d.find((e=>e.value===n));if(a)return a.value;const l=n&&hXe.includes(n)?gXe:n,r=l&&d.find((e=>e.value===l));return null!==(e=null===r||void 0===r?void 0:r.value)&&void 0!==e?e:null===(t=d[0])||void 0===t?void 0:t.value}),[n,d]),m=(0,a.useCallback)((e=>{e!==gXe?s(e):c("changeOverTime")}),[s,c]);return a.createElement(pW,{"data-external-id":"reports-chart-type-select","aria-label":"Chart type",options:d,value:u,onValueChange:m})};var fXe=n(61095);const EXe=(e,t,n,a)=>{var l,r,o,i;const s=N.c9.fromISO(e).startOf(t),c=s.endOf(t),d=null!==(l=(0,Ba.M7)(s,n,"earliest").toISODate())&&void 0!==l?l:e,u=null!==(r=(0,Ba.M7)(c,a,"latest").toISODate())&&void 0!==r?r:e;return d>u?{startDate:null!==(o=s.toISODate())&&void 0!==o?o:e,endDate:null!==(i=c.toISODate())&&void 0!==i?i:e}:{startDate:d,endDate:u}},yXe=e=>e?{businessEntityIds:[e],includeUnassigned:!1}:{businessEntityIds:[],includeUnassigned:!0},bXe=(e,t)=>{let n=t.businessEntityContext;var a;if(e.isBusinessScoped)return{businessEntitySet:yXe(e.businessEntityId)};return!!n&&(!!(null===(a=n.businessEntityIds)||void 0===a?void 0:a.length)||!!n.includeUnassigned)?{businessEntitySet:n}:{}},xXe=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return(0,r.YW)(e).with({kind:"category"},(e=>(0,U.A)({categories:[e.categoryId]},bXe(e,t)))).with({kind:"categoryGroup"},(e=>(0,U.A)({categoryGroups:[e.categoryGroupId]},bXe(e,t)))).with({kind:"merchant"},(e=>(0,U.A)({merchants:[e.merchantId]},bXe({},t)))).with({kind:"budgetVariability"},(e=>(0,U.A)({budgetVariability:e.budgetVariability},bXe({},t)))).with({kind:"businessEntity"},(e=>({businessEntitySet:yXe(e.businessEntityId)}))).with({kind:"owner"},(e=>({ownershipSet:e.ownerUserId?{userIds:[e.ownerUserId],includeJointlyOwned:!1}:{userIds:[],includeJointlyOwned:!0}}))).exhaustive()},wXe=e=>{if("businessEntity"===e.kind){if(!e.isBusinessScoped)return;return{interaction:"click",node_type:e.businessEntityId?"business_entity":"household"}}if(("category"===e.kind||"categoryGroup"===e.kind)&&e.isBusinessScoped){const t=e.businessEntityId?"business_entity":"household",n="category"===e.kind?"category":"category_group";return{interaction:"click",node_type:"".concat(t,"_").concat(n)}}},CXe=e=>{const t=(0,d.Pj)();return(0,a.useCallback)((()=>{(0,Ge.u4)(Ye.m2.ReportsViewChanged,(0,ZJe.YY)(t.getState(),e))}),[t,e])};var AXe,IXe;const kXe=["startDate","endDate"],SXe=(0,xZ.Z)((()=>n.e(4784).then(n.bind(n,4784)).then((e=>({default:e.ReportsPieChart})))),"ReportsPieChart"),NXe=(0,xZ.Z)((()=>n.e(1556).then(n.bind(n,21556)).then((e=>({default:e.ReportsHorizontalBarChart})))),"ReportsHorizontalBarChart"),TXe=(0,xZ.Z)((()=>n.e(3293).then(n.bind(n,33293)).then((e=>({default:e.ReportsBarChartConnected})))),"ReportsBarChart"),_Xe=(0,xZ.Z)((()=>n.e(2129).then(n.bind(n,32129)).then((e=>({default:e.ReportsCashFlowBarChartConnected})))),"ReportsCashFlowBarChart"),DXe=(0,xZ.Z)((()=>Promise.all([n.e(5665),n.e(9506)]).then(n.bind(n,99506)).then((e=>({default:e.ReportsSankeyConnected})))),"ReportsSankey"),RXe=(0,xZ.Z)((()=>Promise.all([n.e(5665),n.e(5437)]).then(n.bind(n,15437)).then((e=>({default:e.BusinessEntityReportsSankey})))),"BusinessEntityReportsSankey"),MXe=(0,xZ.Z)((()=>n.e(4830).then(n.bind(n,34830)).then((e=>({default:e.ReportsProfitLossTable})))),"ReportsProfitLossTable"),LXe=(0,xZ.Z)((()=>n.e(89).then(n.bind(n,90089)).then((e=>({default:e.ReportsTreemapChart})))),"ReportsTreemapChart"),OXe={isEmpty:!1,isLoading:!0},PXe=e=>{var t,n,l;let i=e.currentTab,c=e.data,m=e.isLoading,h=e.summary,v=e.title,f=e.total,y=e.groupByTimeframe,b=e.showAllEntities,x=e.onChangeShowAllEntities,w=e.onCh
1angeView,C=e.onSelectDatum,A=e.onClearDatumSelection,I=e.selectedDatumId,k=e.onSelectDateRange,S=e.selectedDateRange,N=e.treemapDrillStack,T=void 0===N?[]:N,_=e.treemapRootBreadcrumbLabel,D=void 0===_?"All":_,R=e.treemapSeedFocusPath,M=void 0===R?[]:R,L=e.onTreemapSelectDatum,O=e.onTreemapNavigateToStackIndex,P=e.onTreemapClearScope,B=e.onTreemapFocusPathChange;const z=(0,u.useTheme)(),F=(0,a.useMemo)((()=>(0,Vo.uK)(z.color)),[z.color]),G=(0,E.wA)(),Y=CXe(i),V=(0,qG.e)(),W=V.hasAccess,j=V.isLoading,H=(0,Tj.Rq)(),K=H.businessEntities,q=H.isLoadingInitialData,$=K.length>0,Z=!j&&!q,J=W&&$,X=Z&&W&&$,Q=(0,nG.p)("feat-reports-treemap-web","off"),ee=(0,lt.L7)(),te=ee.budgetSystem,ne=ee.householdPreferences,ae=te===Ee.Zmn.FIXED_AND_FLEX,le=(0,nC.xd)(),re=(0,o.A)(le,1)[0].users,oe=!(null===ne||void 0===ne||!ne.collaborationToolsEnabled)&&re.length>1,ie=(0,d.d4)((e=>(0,ZJe.Cp)(e,i))),se=(0,a.useState)(void 0),ce=(0,o.A)(se,2),de=ce[0],ue=ce[1],me=(0,d.d4)(ZJe.xB),pe=me.startDate,ge=me.endDate,he=(0,En.A)(me,kXe),ve=(0,d.d4)(ZJe.Fy),fe=(0,d.d4)(ZJe.ZB),ye=(0,d.d4)(ZJe.W$),be=(0,d.d4)(ZJe.TP),xe=(null===ie||void 0===ie?void 0:ie.chartType)===V1.Gi.ProfitLossTable,we=(null===ie||void 0===ie?void 0:ie.chartType)===V1.Gi.SankeyCashFlowChart&&W&&$&&"byBusiness"===fe,Ce=xe?"profitLossTable":we?"businessEntitySankey":null,Ae=null!==Ce,Ie=null!==de&&void 0!==de?de:OXe,ke=Ae?Ie.isEmpty:(0,LV.A)(null===c||void 0===c?void 0:c[0]),Se=Ae?Ie.isLoading:m,Ne=Se||ke,Te=(0,a.useState)(Ce),_e=(0,o.A)(Te,2),De=_e[0],Re=_e[1];Ce!==De&&(Re(Ce),ue(void 0)),(0,a.useEffect)((()=>{"cashFlow"===i&&xe&&Z&&!X&&(G((0,g.VT)({tab:i,chartType:V1.Gi.SankeyCashFlowChart})),null===w||void 0===w||w())}),[i,G,xe,Z,w,X]),(0,a.useEffect)((()=>{("spending"===i||"income"===i)&&(null===ie||void 0===ie?void 0:ie.chartType)===V1.Gi.TreemapChart&&!Q&&(G((0,g.VT)({tab:i,chartType:V1.Gi.PieChart})),null===w||void 0===w||w())}),[i,G,null===ie||void 0===ie?void 0:ie.chartType,Q,w]),(0,a.useEffect)((()=>{"cashFlow"===i&&(null===ie||void 0===ie?void 0:ie.chartType)===V1.Gi.HorizontalBarChart&&(G((0,g.VT)({tab:"cashFlow",chartType:V1.Gi.SankeyCashFlowChart})),null===w||void 0===w||w())}),[i,G,null===ie||void 0===ie?void 0:ie.chartType,w]);const Me=(0,fXe.Bu)({startDate:pe,endDate:ge,timeframeUnit:null===(t=he.timeframePeriod)||void 0===t?void 0:t.unit,timeframeValue:null===(n=he.timeframePeriod)||void 0===n?void 0:n.value,includeCurrentPeriod:null===(l=he.timeframePeriod)||void 0===l?void 0:l.includeCurrent}),Le=(0,a.useCallback)((e=>{G((0,g.hf)({tab:i,view:e})),Y(),null===w||void 0===w||w()}),[i,G,w,Y]),Oe=(0,a.useCallback)((e=>{G((0,g.VT)({tab:i,chartType:e})),Y(),null===w||void 0===w||w()}),[i,G,w,Y]),Pe=(0,a.useCallback)((e=>{G((0,g.tJ)(e)),Y(),null===w||void 0===w||w()}),[G,w,Y]),Be=(0,a.useCallback)((e=>{G((0,g.L$)(e)),I&&A(),null===w||void 0===w||w()}),[G,w,A,I]),ze=(0,a.useCallback)((e=>{G((0,g.UX)(e)),Y()}),[G,Y]),Fe=(0,a.useCallback)((e=>{G((0,g.q7)(e)),Y()}),[G,Y]),Ge=(0,a.useCallback)((e=>{G((0,g.xV)(e)),Y()}),[G,Y]),Ye=(0,a.useCallback)((e=>{const t=EXe(e.date,y,pe,ge);k(t.startDate,t.endDate)}),[k,y,pe,ge]),Ue=(0,a.useCallback)((e=>((e,t,n)=>{if(!t)return;const a=e.findIndex((e=>{const a=EXe(e.date,n),l=a.startDate,r=a.endDate;return t>=l&&t<=r}));return-1===a?void 0:a})(e,null===S||void 0===S?void 0:S.startDate,y)),[y,null===S||void 0===S?void 0:S.startDate]),Ve=(0,a.useMemo)((()=>{let e=null===ie||void 0===ie?void 0:ie.chartType;return e!==V1.Gi.TreemapChart||Q?"cashFlow"===i&&e===V1.Gi.HorizontalBarChart&&(e=V1.Gi.SankeyCashFlowChart):e=V1.Gi.PieChart,(0,r.YW)(e).with(V1.Gi.PieChart,(()=>a.createElement(SXe,{colors:F,data:c,pieChartTitle:f?(0,rl.vv)(f):void 0,pieChartSubtitle:"Total",showAllEntities:b,onChangeShowAllEntities:x,onSelectDatum:C,selectedDatumId:I}))).with(V1.Gi.HorizontalBarChart,(()=>a.createElement(NXe,{data:c,currentTab:i,onSelectDatum:C}))).with(V1.Gi.TreemapChart,(()=>a.createElement(LXe,{data:c,onSelectDatum:null!==L&&void 0!==L?L:(e,t)=>{C(e,t)},selectedDatumId:I,drillStack:T,rootBreadcrumbLabel:D,seedFocusPath:M,onNavigateToStackIndex:null!==O&&void 0!==O?O:()=>{},onClearScope:null!==P&&void 0!==P?P:A,maxVisibleTiles:be,onFocusPathChange:B}))).with(r.P.union(V1.Gi.StackedBarChart,V1.Gi.BarChart),(()=>a.createElement(TXe,{data:c,colors:F,timeframe:y,tab:i,isStacked:e===V1.Gi.StackedBarChart,onSelectDateRangeFromBarData:Ye,getSelectedIndexFromBarData:Ue}))).with(r.P.union(V1.Gi.CashFlowChart,V1.Gi.StackedCashFlowChart),(()=>a.createElement(_Xe,{data:c[0],timeframe:y,stacked:e===V1.Gi.StackedCashFlowChart,onSelectDateRangeFromBarData:Ye,getSelectedIndexFromBarData:Ue}))).with(V1.Gi.SankeyCashFlowChart,(()=>we?a.createElement(RXe,{filters:(0,U.A)({startDate:pe,endDate:ge},he),groupMode:ve,onSelectNode:C,onDataStateChange:ue,selectedNodeId:I}):a.createElement(DXe,{data:c[0],summary:h,onSelectNode:C,selectedNodeId:I,navigateToEntity:!1,groupMode:ve}))).with(V1.Gi.ProfitLossTable,(()=>Z&&!X?null:a.createElement(MXe,{filters:(0,U.A)({startDate:pe,endDate:ge},he),groupMode:ve,onSelectNode:C,selectedNodeId:I,onDataStateChange:ue}))).otherwise((()=>null))}),[F,c,ie,Q,i,C,b,x,I,h,f,ve,we,Z,X,pe,ge,he,T,D,M,L,O,P,B,A,y,Ye,Ue,be]),We=(0,Pd.h)(),je=(0,o.A)(We,2),He=je[0],Ke=je[1].open,qe=(0,V1.hm)(i),$e="spending"===i||"income"===i,Ze=a.createElement(BJe,{isShareDisabled:Ne,chartType:null===ie||void 0===ie?void 0:ie.chartType,spendingIncomeGroupBy:$e?ye:void 0,showBusinessEntityGroupBy:J,showBudgetVariabilityGroupBy:ae,showOwnerGroupBy:oe,cashFlowGroupMode:ve,cashFlowBusinessEntityView:fe,groupByTimeframe:y,onChangeCashFlowGroupMode:Pe,onChangeCashFlowBusinessEntityView:Be,onCh
1angeSpendingIncomeGroupBy:ze,treemapNodeCount:be,onChangeTreemapNodeCount:Fe,onChangeChartType:Oe,onChangeGroupByTimeframe:Ge,onClickShare:Ke}),Je=(0,a.useMemo)((()=>a.createElement("div",{className:"flex flex-col"},v&&a.createElement(BXe,null,v),a.createElement(zXe,null,Me))),[v,Me]);return a.createElement(a.Fragment,null,a.createElement(Xl.AM,{title:qe?void 0:Je,controls:qe?void 0:Ze},qe&&a.createElement(GXe,null,a.createElement(zXe,null,Me),a.createElement(YXe,null,a.createElement("div",{className:"inline-flex shrink-0"},a.createElement(vXe,{currentTab:i,chartType:null===ie||void 0===ie?void 0:ie.chartType,showProfitLossTable:X,showTreemapChart:Q,onChangeChartType:Oe,onChangeViewMode:Le})),Ze)),a.createElement(yn.t,{onError:s.Cp,errorComponent:a.createElement(XJe,{iconName:"x",title:"Something went wrong",description:"An unexpected error occurred. We have been notified and will get started on a fix.",width:210},a.createElement(wt.Xb,{onClick:()=>location.reload(),size:"small"},"Refresh the page"))},!Ae&&Se?a.createElement(FXe,null,a.createElement(p.i,null)):!Ae&&ke?a.createElement(XJe,{iconName:"pie-chart"}):a.createElement(a.Suspense,{fallback:a.createElement(FXe,null,a.createElement(p.i,null))},Ve))),a.createElement(He,{maxWidth:"840px"},a.createElement(pXe,{chart:Ve,header:Je,initialValues:{title:v},displayProperties:ie,tab:i})))},BXe=(0,u.default)(RV.W).withConfig({displayName:"ReportsChartCard__Title",componentId:"fyfjt8-0"})(["display:flex;align-items:center;"]),zXe=u.default.span.withConfig({displayName:"ReportsChartCard__Subtitle",componentId:"fyfjt8-1"})(["font-size:",";font-weight:",";margin-top:",";line-height:150%;"],vt.J.large,vt.Wy.medium,vt.YK.xxsmall),FXe=(0,u.default)(m.g).attrs({center:!0}).withConfig({displayName:"ReportsChartCard__LoadingContainer",componentId:"fyfjt8-2"})(["padding:",";"],vt.YK.xxxxlarge),GXe=$d.s.div(AXe||(AXe=(0,wc.A)(["flex flex-col gap-sm border-b border-divider-primary px-xl py-default"]))),YXe=$d.s.div(IXe||(IXe=(0,wc.A)(["flex items-center justify-between"]))),UXe=()=>{var e;const t=(0,hu.x)(),n=t.values,l=t.setFieldValue,r=t.validateForm,o=(0,a.useMemo)((()=>({value:n.timeframeUnit})),[n.timeframeUnit]);return a.createElement(a.Fragment,null,a.createElement(tC.zB.Number,{label:"Number",name:"timeframeValue","data-external-id":"numeric-input",placeholder:"Enter number",format:{maximumFractionDigits:0},min:0}),a.createElement(jXe,{label:"Unit",name:"timeframeUnit",fieldId:"timeframeUnit"},a.createElement(eH.FD,{RowComponent:HXe,value:o,options:VXe(null!==(e=n.timeframeValue)&&void 0!==e?e:1),onChange:async e=>{var t;if(!e)return;const n=(0,RY.A)(e)?null===(t=e[0])||void 0===t?void 0:t.value:e.value;await l("timeframeUnit",n),await l("includeCurrentPeriod",n===vW.QD),await r()}})))},VXe=e=>[{label:(0,De.td)("Day",e),value:vW.QD},{label:(0,De.td)("Week",e),value:vW.KT},{label:(0,De.td)("Month",e),value:vW.MD},{label:(0,De.td)("Quarter",e),value:vW.Q2},{label:(0,De.td)("Year",e),value:vW.Ho}],WXe=(0,u.default)(m.g).withConfig({displayName:"DateRangeWithTimeframesLastFields__TimeframeUnitRow",componentId:"luqb8w-0"})(["align-items:center;padding:"," 0;"],vt.YK.xxsmall),jXe=(0,u.default)(Ey.oP).withConfig({displayName:"DateRangeWithTimeframesLastFields__RadioContainer",componentId:"luqb8w-1"})(["[data-sc-tw~='FormItemContainer__LabelContainer']{margin-bottom:0;}"]),HXe=(0,u.default)(WXe).withConfig({displayName:"DateRangeWithTimeframesLastFields__TimeframeUnitRadioRow",componentId:"luqb8w-2"})(["cursor:pointer;font-size:",";[data-sc-tw~='Radio__CircleIndicator']{margin-right:",";width:","px;height:","px;}"],vt.J.small,vt.YK.xsmall,16,16),KXe=()=>{const e=(0,hu.x)(),t=e.values,n=e.setFieldValue;return a.createElement("div",{"data-external-id":"date-range-with-timeframes-range-fields",className:"flex flex-col gap-xs"},a.createElement(tC.zB.Date,{label:"Start date",name:"startDate",placeholder:"Earliest",labelRight:a.createElement(wne,{disabled:(0,BY.A)(t.startDate),onClick:()=>n("startDate",void 0)})}),a.createElement(tC.zB.Date,{label:"End date",name:"endDate",placeholder:"Latest",labelRight:a.createElement(wne,{disabled:(0,BY.A)(t.endDate),onClick:()=>n("endDate",void 0)})}))},qXe=e=>{let t=e.selectedShortcutId;const n=(0,fXe.ZK)(t);return n?a.createElement($Xe,{"data-external-id":"date-range-with-timeframes-shortcut-content"},a.createElement(ZXe,null),a.createElement(JXe,null,n.description)):null},$Xe=(0,u.default)(m.g).attrs({column:!0,justifyCenter:!0,alignCenter:!0}).withConfig({displayName:"DateRangeWithTimeframesShortcutContent__ShortcutContent",componentId:"sc-1byj7hz-0"})(["gap:",";margin-top:","px;"],vt.YK.xxsmall,40),ZXe=(0,u.default)(sl.ZQ).attrs({name:"calendar",size:24}).withConfig({displayName:"DateRangeWithTimeframesShortcutContent__CalendarIcon",componentId:"sc-1byj7hz-1"})(["color:",";"],vt.yW.textLight),JXe=(0,u.default)(xt.v).attrs({align:"center",color:"textLight",weight:"book",size:"small"}).withConfig({displayName:"DateRangeWithTimeframesShortcutContent__ShortcutDescription",componentId:"sc-1byj7hz-2"}
1)(["max-width:200px;"]),XXe=e=>{let t=e.selectedShortcutId;const n=(0,hu.x)(),l=n.setValues,r=n.submitForm;return a.createElement(xne,{"data-external-id":"date-range-with-timeframes-shortcuts",shortcuts:fXe.Au,selectedShortcutId:t,className:"h-auto min-w-0 border-r-0",onSelectDateRange:async e=>{await l(e),await r()}})},QXe=e=>{let t=e.contentId,n=e.onSetContentId,l=e.onClear,r=e.toggleOpen;const o=(0,hu.x)(),i=o.initialValues,s=o.values,c=o.setValues,d=o.validateForm,u=t===sQe.LAST,m=t===sQe.RANGE,p=(0,Tr.A)(s.timeframeUnit)&&(0,Tr.A)(s.timeframeValue)&&(0,Tr.A)(s.includeCurrentPeriod),g=(0,a.useCallback)((()=>{c({startDate:void 0,endDate:void 0,timeframeUnit:void 0,timeframeValue:void 0,includeCurrentPeriod:void 0}),n(sQe.LAST),d()}),[c,n,d]),h=(0,a.useCallback)((()=>{c((0,U.A)((0,U.A)({},i),{},{timeframeUnit:void 0,timeframeValue:void 0,includeCurrentPeriod:void 0})),n(sQe.RANGE),d()}),[c,i,n,d]);return a.createElement(a.Fragment,null,a.createElement(eQe,null,a.createElement(nQe,null,a.createElement(oQe,null,a.createElement(lQe,null,"Date Range")),a.createElement(Tm,{role:"menu",className:"gap-3xs p-xs"},a.createElement(Tm.Item,{selected:u,role:"menuitemradio","aria-checked":u,onClick:g,className:"text-sm"},"Last"),a.createElement(Tm.Item,{selected:m,role:"menuitemradio","aria-checked":m,onClick:h,className:"text-sm"},"Range")),a.createElement(tQe,{text:""}),a.createElement(XXe,{selectedShortcutId:t})),a.createElement(aQe,null,a.createElement(oQe,null,a.createElement(lQe,null,u&&!p?"":(0,fXe.Bu)(s))),a.createElement(iQe,null,a.createElement(Ul.w,null,a.createElement(Ul.d,{when:u},a.createElement(UXe,null)),a.createElement(Ul.d,{when:m},a.createElement(KXe,null)),a.createElement(Ul.d,{default:!0},a.createElement(qXe,{selectedShortcutId:t})))))),a.createElement(rQe,null,a.createElement(wt.Xb,{size:"xsmall",onClick:()=>{l(),null===r||void 0===r||r()}},"Clear"),a.createElement(wt.Xb,{size:"xsmall",onClick:r},"Cancel"),a.createElement(CJ.I,{size:"xsmall"},"Apply")))},eQe=u.default.div.withConfig({displayName:"DateRangeWithTimeframesFormContent__Row",componentId:"l943sa-0"})(["display:grid;grid-template-columns:","px 1fr;"],140),tQe=(0,u.default)(z7.P).withConfig({displayName:"DateRangeWithTimeframesFormContent__StyledDivider",componentId:"l943sa-1"})(["padding:0 ",";height:1px;"],vt.YK.xsmall),nQe=u.default.div.withConfig({displayName:"DateRangeWithTimeframesFormContent__OptionsColumn",componentId:"l943sa-2"})(["border-right:1px solid ",";overflow:clip;min-width:","px;"],vt.Ee.color.divider.primary,140),aQe=u.default.div.withConfig({displayName:"DateRangeWithTimeframesFormContent__ContentColumn",componentId:"l943sa-3"})(["min-width:","px;min-height:","px;"],280,344),lQe=(0,u.default)(xt.v).withConfig({displayName:"DateRangeWithTimeframesFormContent__Title",componentId:"l943sa-4"})(["display:flex;align-items:center;border-bottom:1px solid ",";padding:0 ",";height:100%;width:100%;"],vt.Ee.color.divider.primary,vt.YK.default),rQe=(0,u.default)(Cq.R).attrs({$size:"small"}).withConfig({displayName:"DateRangeWithTimeframesFormContent__Footer",componentId:"l943sa-5"})(["[data-sc-tw~='DefaultButton__DefaultButton']:first-child{margin-right:auto;}"]),oQe=(0,u.default)(m.g).attrs({alignCenter:!0,justifyStart:!0}).withConfig({displayName:"DateRangeWithTimeframesFormContent__Header",componentId:"l943sa-6"})(["height:","px;font-weight:",";font-size:",";width:100%;"],40,vt.Wy.medium,vt.J.small),iQe=(0,u.default)(m.g).attrs({column:!0,justifyCenter:!0}).withConfig({displayName:"DateRangeWithTimeframesFormContent__InputContainer",componentId:"l943sa-7"})(["flex:1;gap:",";padding:",";"],vt.YK.xlarge,vt.YK.default);let sQe=function(e){return e.LAST="last",e.RANGE="range",e}({});const cQe=(0,I1.Ik)().shape({startDate:(0,I1.Yj)().nullable().test("startBeforeEnd","Start date must be before end date",(function(e){const t=this.parent.endDate;return!(!(0,BY.A)(e)&&!(0,BY.A)(t))||N.c9.fromISO(e)<=N.c9.fromISO(t)})),endDate:(0,I1.Yj)().nullable(),timeframeUnit:(0,I1.Yj)().nullable().notOneOf([""],"Timeframe unit is required."),timeframeValue:(0,I1.ai)().nullable().min(1,"Timeframe value must be greater than 0.").test("max-timeframe","Maximum is 10 years.",(function(e){if(!e)return!0;return e<=(0,fXe.o9)(this.parent.timeframeUnit)})),includeCurrentPeriod:(0,I1.zM)().nullable()}).test("timeframe-period","Timeframe unit and value are required.",(function(e){var t;const n=e.startDate,a=e.endDate,l=e.timeframeUnit,r=e.timeframeValue,o=e.includeCurrentPeriod,i=(null!==(t=this.options.context)&&void 0!==t?t:{}).isLast,s=(0,Tr.A)(n)||(0,Tr.A)(a),c=(0,Tr.A)(l)||(0,Tr.A)(r)||(0,Tr.A)(o);return s||c?s&&c?this.createError({message:"Cannot select both range and timeframe."}):!(i&&c&&((0,BY.A)(l)||(0,BY.A)(r)||(0,BY.A)(o)))||this.createError({path:"timeframeUnit",message:"Timeframe unit and value must both be provided."}):!i||this.createError({path:"timeframeUnit",message:"Timeframe unit and value must both be provided."})})),dQe=e=>
1{let t=e.dateRange,n=e.onChange,l=e.onClear,r=e.toggleOpen;const i=(0,a.useState)((()=>(e=>{const t=(0,fXe.Td)(e);return t?t.id:(0,BY.A)(e.startDate)&&(0,BY.A)(e.endDate)?sQe.LAST:sQe.RANGE})(t))),s=(0,o.A)(i,2),c=s[0],d=s[1];return a.createElement(Eu.lV,{"data-external-id":"date-range-with-timeframes-form",initialValues:t,validate:(u=c===sQe.LAST,async e=>{try{return await cQe.validate(e,{context:{isLast:u},abortEarly:!1}),{}}catch(t){return(0,bBe.Tz)(t)}}),enableReinitialize:!0,onSubmit:e=>{n(e),null===r||void 0===r||r()}},a.createElement(QXe,{contentId:c,onSetContentId:d,onClear:l,toggleOpen:r}));var u},uQe=a.memo(dQe),mQe=["value"],pQe=e=>{let t=e.value,n=(0,En.A)(e,mQe);const l=(0,a.useState)(!1),r=(0,o.A)(l,2),i=r[0],s=r[1];return a.createElement(fS.k.Root,{"data-external-id":"date-range-with-timeframes-popover",open:i,onOpenChange:s},a.createElement(fS.k.Trigger,{render:a.createElement(Wb.X,{variant:"default",icon:a.createElement(Rne.MdsCalendarIcon,null),"data-pressed":i?"":void 0},t)}),a.createElement(fS.k.Content,{side:"bottom",align:"end",className:"max-w-none p-0"},a.createElement(uQe,Object.assign({toggleOpen:()=>s((e=>!e))},n))))},gQe=e=>{let t=e.dateRange,n=e.defaultRange,l=e.onChangeDateRange;const r=(0,a.useMemo)((()=>!(0,fXe.rX)(t,n)),[t,n]),o=(0,a.useMemo)((()=>r?(0,fXe._K)(t):"Date"),[t,r]),i=(0,a.useCallback)((()=>l(fXe.OY)),[l]);return a.createElement(fe.qN2,{"data-external-id":"date-range-with-timeframes-picker-button",show:r},a.createElement(pQe,{dateRange:t,value:o,onChange:l,onClear:i}))};var hQe=n(61676);const vQe=15*iC.K5,fQe={id:"ai-create-report",label:"Create a report with AI",hideLabel:!0,group:"actions",component:()=>{const e=(0,mce.WB)().toggleCommandPalette,t=(0,i.n)(wQe),n=(0,o.A)(t,2),r=n[0],s=n[1].loading,c=a.useRef(null),d=(0,l.Zp)(),u=(0,E.wA)();a.useEffect((()=>{var e;null===(e=c.current)||void 0===e||e.focus()}),[]);const m=(0,a.useCallback)((async t=>{let n=t.report_description;try{var a,l,o;u((0,g.lo)({}));const t=(await r({variables:{reportDescription:n}})).data;if(null!==t&&void 0!==t&&null!==(a=t.createAiReport)&&void 0!==a&&a.errors){const e=t.createAiReport.errors.message||"An error occurred while creating the AI report";return C.oR.error({description:e}),void(0,Ge.u4)(Ye.m2.ReportGenerationFailed,{errorMessage:e})}const i=null===t||void 0===t||null===(l=t.createAiReport)||void 0===l?void 0:l.filters,s=null===t||void 0===t||null===(o=t.createAiReport)||void 0===o?void 0:o.reportType,c="cash_flow"===s?"cashFlow":s;if(!i||!c)return(0,Ge.u4)(Ye.m2.ReportGenerationFailed,{errorMessage:"Invalid report generated. Missing filters or report type.",filters:i,reportType:c}),void C.oR.error({description:"An unexpected error occurred"});const m=(0,CX.WD)((0,XX.A)(["__typename"])(i));(0,Tr.A)(m.timeframePeriod)&&(m.timeframePeriod=(0,XX.A)(["__typename"])(m.timeframePeriod));const p=(0,e0.sO)(m),h=I.JZ.reports[c]({queryParams:p});(0,Ge.u4)(Ye.m2.ReportGenerated,{reportDescription:n,reportType:c,filters:i}),d(h),e(),(0,C.oR)({title:"Report Feedback",description:"Does this report look correct?",duration:vQe,actions:[{text:"Yes",onClick:()=>{(0,Ge.u4)(Ye.m2.ReportFeedbackProvided,{reportDescription:n,reportType:c,filters:i,correct:!0})}},{text:"No",onClick:()=>{(0,Ge.u4)(Ye.m2.ReportFeedbackProvided,{reportDescription:n,reportType:c,filters:i,correct:!1})}}]})}catch(i){(0,Ge.u4)(Ye.m2.ReportGenerationFailed,{errorMessage:i instanceof Error?i.message:String(i)}),C.oR.error({description:"An unexpected error occurred"})}}),[r,u,d,e]);return a.createElement(bQe,{"data-external-id":"ai-report-view",alignCenter:!0},a.createElement(EQe,{initialValues:{report_description:""},onSubmit:m},s?a.createElement("div",{className:"flex flex-col items-center justify-center gap-default pb-2xl"},a.createElement(hQe.T,null),a.createElement(xQe,null,"Generating report\xa0\u2026")):a.createElement(yQe,{autoComplete:"off",hideLabel:!0,name:"report_description",disabled:s,innerRef:c,placeholder:"Describe what you\u2019d like to see (e.g., \u2018coffee spending this year\u2019)",onKeyDown:e=>{"Enter"===e.key&&(e.preventDefault(),m({report_description:e.currentTarget.value}))}})))},analyticsMetadata:{analyticsId:"ai-create-report"},isAi:!0},EQe=(0,u.default)(Eu.lV).withConfig({displayName:"AICommands__CommandForm",componentId:"sc-1v7d7d2-0"})(["width:100%;"]),yQe=(0,u.default)(Qw.X).withConfig({displayName:"AICommands__Input",componentId:"sc-1v7d7d2-1"})(["& input{border:none;background:none;flex-grow:1;font-size:",";color:",";padding:0;margin:0;::placeholder{color:",";}:focus:not(:disabled){outline:none;border-color:none;box-shadow:none;}}"],vt.J.large,vt.yW.text,vt.yW.textLight),bQe=(0,u.default)(m.g).withConfig({displayName:"AICommands__SearchContainer",componentId:"sc-1v7d7d2-2"})(["padding:",";"],vt.YK.default),xQe=(0,u.default)(xt.v).withConfig({displayName:"AICommands__LoadingText",componentId:"sc-1v7d7d2-3"})(["margin-right:",";"],vt.YK.small),wQe=Ee.xls,CQe=e=>{e.className;const t=(0,mce.WB)().openCommandView;return a.createElement(wt.Xb,{"data-external-id":"ai-reports-button",size:"small",onClick:()=>t(fQe)},a.createElement(fe.bQo,{className:"mr-xs"}),a.createElement("span",null,"Ask AI"))},AQe=e=>{let t=e.reportConfigurations,n=e.selectedReportConfigurationId,l=e.onSelectReportConfiguration,o=e.onEditReportConfiguration;const i=(0,a.useMemo)((()=>(0,sU.A)(((e,t)=>e.displayName.localeCompare(t.displayName)),t)),[t]),s=(0,a.useMemo)((()=>(0,Tr.A)(n)?i.find((e=>e.id===n)):void 0),[i,n]);return a.createElement(Qi.Az,{"data-external-id":"reports-configurations-menu-button",placement:"bottom-end",overlay:()=>a.createElement(kQe,null,a.createElement(SQe,null,(0,r.YW)(i.length).with(r.P.when((e=>e<1)),(()=>a.createElement("div",{className:"flex items-center justify-center"},a.createElement("div",{className:"my-2xl flex max-w-55 flex-col items-center gap-default"},a.createElement(fe.CWN,{shape:"circle",color:"blue",className:"size-16",icon:a.createElement(fe.ucZ,{size:"2xl"})}),a.createElement("div",{className:"flex flex-col items-center gap-2xs"},a.createElement(xt.v,{weight:"medium"},"No reports saved yet"),a.createElement(xt.v,{size:"small",color:"content.primary",align:"center"},"Your saved reports will show up here after you create them.")))))).otherwise((()=>i.map((e=>a.createElement(_Qe,{key:e.id,onClick:()=>l(e),selected:e.id===n},a.createElement("span",{title:e.displayName.length>30?e.displayName:void 0},IQe(e.displayName)),a.createElement(NQe,{icon:"edit",size:"xxsmall",onClick:t=>{o(e),t.stopPropagation()}}))))))))},(e=>{var t;let n=e.toggleOpen,l=e.isOpen;return a.createElement(fe.qN2,{show:!!s},a.createElement("div",{title:null===s||void 0===s?void 0:s.displayName},a.createElement(wt.Xb,{onClick:n,active:l},a.createElement("span",null,null!==(t=IQe(null===s||void 0===s?void 0:s.displayName))&&void 0!==t?t:"Reports"),a.createElement(Yo.r,{name:"chevron-down"}
1))))}))},IQe=e=>e?(0,EA.xv)(e,30):void 0,kQe=(0,u.default)(Qi.j7).withConfig({displayName:"ReportsConfigurationsMenuButton__StyledPopover",componentId:"sc-1l4fbfp-0"})(["min-width:260px;padding:"," ",";"],vt.YK.xsmall,vt.YK.xsmall),SQe=u.default.div.withConfig({displayName:"ReportsConfigurationsMenuButton__DropdownMenuList",componentId:"sc-1l4fbfp-1"})(["max-height:500px;overflow-y:auto;"]),NQe=(0,u.default)(B.L).attrs({"data-sc-tw":"ReportsConfigurationsMenuButton__StyledIconButton"}).withConfig({displayName:"ReportsConfigurationsMenuButton__StyledIconButton",componentId:"sc-1l4fbfp-2"})(["opacity:0;transition:opacity ",";margin-left:",";"],vt.kY.default,vt.YK.xsmall),TQe=(0,u.default)(Ji.xm).withConfig({displayName:"ReportsConfigurationsMenuButton__StyledDropdownMenuItem",componentId:"sc-1l4fbfp-3"})(["margin:0 0 4px 0;&:last-child{margin-bottom:0;}"]),_Qe=(0,u.default)(TQe).withConfig({displayName:"ReportsConfigurationsMenuButton__ReportConfigurationDropdownMenuItem",componentId:"sc-1l4fbfp-4"})(["display:flex;justify-content:space-between;align-items:center;padding-right:",";&:hover{[data-sc-tw~='ReportsConfigurationsMenuButton__StyledIconButton']{opacity:1;}}"],vt.YK.xsmall),DQe=e=>{let t=e.toggleOpen;const n=(0,pG.w)(),l=(0,d.d4)(ZJe.xB);return a.createElement(bQ,{"data-external-id":"reports-filter-menu-popover",page:"reports",filters:l,onClickCancel:t,onApplyFilters:e=>{n((0,g.lo)({filters:(0,U.A)((0,U.A)({},e),{},{businessEntitySet:l.businessEntitySet}),maintainDateFilters:!0})),t()}})},RQe=()=>{const e=(0,d.d4)(ZJe.qA);return a.createElement(Qi.Az,{"data-external-id":"reports-filter-menu-button",placement:"bottom-end",overlay:e=>{let t=e.toggleOpen;return a.createElement(Qi.j7,null,a.createElement(DQe,{toggleOpen:t}))}},(t=>{let n=t.toggleOpen,l=t.isOpen;return a.createElement(fe.qN2,{show:e},a.createElement(wt.Xb,{onClick:n,active:l},a.createElement(Yo.r,{name:"filter"}),a.createElement("span",null,"Filters")))}))},MQe=e=>{let t=e.disabled,n=void 0!==t&&t,l=e.onSaveReportConfiguration;return a.createElement(JY.d,{"data-external-id":"reports-save-configuration-menu-button",portal:!0,place:"left",maxWidth:180,content:n?"Select filters and/or a date range to save a report.":void 0},a.createElement(cu.WT,{onClick:l,disabled:n},a.createElement(Yo.r,{name:"bookmark"}),a.createElement("span",null,"Save")))};var LQe=n(73813);const OQe=(0,_V.A)(["startDate","endDate","timeframePeriod"],LQe.N_.filters),PQe=e=>{let t=e.currentTab,n=e.paychecksOwnerIds,l=void 0===n?[]:n,r=e.onChangePaychecksOwnerIds,o=e.paychecksEmployerId,i=void 0===o?"":o,s=e.onChangePaychecksEmployerId,c=e.reportConfigurations,u=e.selectedReportConfigurationId,m=e.onSelectReportConfiguration,p=e.onSaveReportConfiguration,h=e.onEditReportConfiguration;const v="paychecks"===t,f=(0,E.wA)(),y=(0,nG.p)("feat-ai-reports-web-back","off"),b=(0,qG.e)().hasAccess,x=(0,Tj.Rq)(),w=x.businessEntities,C=x.isLoadingInitialData,A=b&&(C||w.length>0),I=(0,d.d4)(ZJe.TE),k=(0,d.d4)(ZJe.xB),S=k.startDate,T=k.endDate,_=k.timeframePeriod,D=k.businessEntitySet,R=(0,a.useCallback)((()=>{f((0,g.lo)({}))}),[f]),M=(0,a.useMemo)((()=>[{id:"reports.clear-filters",group:"actions",label:"Clear filters",icon:a.createElement(sl.ZQ,{name:"x"}),action:R,shouldRegister:I,analyticsMetadata:{analyticsId:"reports.clear-filters"}}]),[R,I]);(0,mce.m4)(M);const L=(0,a.useCallback)(((e,t)=>{const n=e?N.c9.fromISO(e):void 0,a=t?N.c9.fromISO(t):void 0;let l=!0;(0,Tr.A)(a)&&(0,Tr.A)(n)?l=a.diff(n,"months").months>1:(0,Tr.A)(n)&&(l=Math.abs(n.diffNow("months").months)>1),f((0,g.xV)(l?Ee.aIQ.MONTH:Ee.aIQ.DAY))}),[f]),O=(0,a.useCallback)((e=>{const t=(0,Ba.aR)(e.startDate,e.endDate,e.timeframeUnit,e.timeframeValue,e.includeCurrentPeriod),n=t.startDate,a=t.endDate;L(n,a),f((0,g.lo)({filters:BQe(e),maintainNonDateFilters:!0}))}),[f,L]),P=(0,One.d)().options,B=(0,a.useMemo)((()=>(0,Y7.W)(P,{allowShared:!1})),[P]),z=(0,a.useMemo)((()=>B.filter((e=>l.includes(e.value)))),[B,l]),F="__all__",G=(0,a.useMemo)((()=>({value:F,label:"All employers"})),[]),Y=(0,et.I)(yee,{skip:!v}).data,U=(0,a.useMemo)((()=>{var e;const t=null!==(e=null===Y||void 0===Y?void 0:Y.paycheckEmployers)&&void 0!==e?e:[];return[G,...t.map((e=>({value:e.id,label:e.name})))]}),[null===Y||void 0===Y?void 0:Y.paycheckEmployers,G]),V=(0,a.useMemo)((()=>{var e;return null!==(e=U.find((e=>e.value===i)))&&void 0!==e?e:G}),[U,i,G]),W=(0,a.useCallback)((e=>{f((0,g.lo)({filters:{businessEntitySet:e},maintainDateFilters:!0,maintainNonDateFilters:!0}))}),[f]);return a.createElement("div",{"data-external-id":"reports-header-control
1s",className:"flex items-center justify-end gap-xs"},I&&a.createElement(bn.v,{onClick:R},"Clear"),!v&&y&&a.createElement(a.Fragment,null,a.createElement(CQe,null),a.createElement(wm.A,{orientation:"vertical",color:"tertiary",className:"mx-2xs h-default"})),a.createElement(gQe,{dateRange:{startDate:S,endDate:T,timeframeUnit:null===_||void 0===_?void 0:_.unit,timeframeValue:null===_||void 0===_?void 0:_.value,includeCurrentPeriod:null===_||void 0===_?void 0:_.includeCurrent},defaultRange:OQe,onChangeDateRange:O}),v&&a.createElement(a.Fragment,null,a.createElement("div",{className:"min-w-45"},a.createElement(U7.O,{multiple:!0,options:B,value:z,onValueChange:e=>{null===r||void 0===r||r(e.map((e=>e.value)))},clearable:!0,placeholder:"All owners"})),a.createElement("div",{className:"min-w-55"},a.createElement(U7.O,{options:U,value:V,onValueChange:e=>{var t;const n=null!==(t=null===e||void 0===e?void 0:e.value)&&void 0!==t?t:F;null===s||void 0===s||s(n===F?"":n)},placeholder:"All employers"}))),!v&&a.createElement(a.Fragment,null,A&&a.createElement(OH.O,{businessEntitySet:null!==D&&void 0!==D?D:void 0,onChangeBusinessEntitySet:W,source:Ye.rP.Reports}),a.createElement(RQe,null),a.createElement(wm.A,{orientation:"vertical",color:"tertiary",className:"mx-2xs h-default"}),a.createElement(AQe,{reportConfigurations:c,selectedReportConfigurationId:u,onSelectReportConfiguration:m,onEditReportConfiguration:h}),a.createElement(MQe,{disabled:!I,onSaveReportConfiguration:p})))},BQe=e=>{let t=e.startDate,n=e.endDate,a=e.timeframeUnit,l=e.timeframeValue,r=e.includeCurrentPeriod;return(0,BY.A)(a)||(0,BY.A)(l)||(0,BY.A)(r)?{startDate:t,endDate:n,timeframePeriod:void 0}:{startDate:void 0,endDate:void 0,timeframePeriod:{unit:a,value:l,includeCurrent:r}}};var zQe=n(37166);const FQe={[Ee.DB0.CATEGORY]:[Ee.DB0.MERCHANT],[Ee.DB0.CATEGORY_GROUP]:[Ee.DB0.CATEGORY,Ee.DB0.MERCHANT],[Ee.DB0.BUDGET_VARIABILITY]:[Ee.DB0.CATEGORY,Ee.DB0.MERCHANT],[Ee.DB0.OWNER]:[Ee.DB0.CATEGORY,Ee.DB0.MERCHANT],[Ee.DB0.BUSINESS_ENTITY]:[Ee.DB0.CATEGORY,Ee.DB0.MERCHANT],[Ee.DB0.MERCHANT]:[Ee.DB0.CATEGORY]},GQe=(e,t)=>{var n;return null!==(n=FQe[e][t])&&void 0!==n?n:null},YQe=e=>e.filter((e=>"entity"===e.kind)),UQe=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return YQe(e).reduce(((e,n)=>n.selection?(0,RZ.A)(e,xXe(n.selection,{businessEntityContext:t.businessEntityContext})):e),{})},VQe={[Ee.DB0.CATEGORY]:"All categories",[Ee.DB0.CATEGORY_GROUP]:"All groups",[Ee.DB0.MERCHANT]:"All merchants",[Ee.DB0.BUSINESS_ENTITY]:"All businesses",[Ee.DB0.BUDGET_VARIABILITY]:"All fixed / flexible",[Ee.DB0.OWNER]:"All owners"},WQe="treemapDrill",jQe=new Set(Object.values(Ee.DB0)),HQe=e=>{const t={id:e.id,label:e.label,groupBy:e.groupBy};return e.selection&&(t.selection=e.selection),e.sourceFocusPath&&e.sourceFocusPath.length>0&&(t.sourceFocusPath=e.sourceFocusPath),t},KQe=e=>{if(!e||"object"!==typeof e)return!1;const t=e.kind;return"category"===t||"categoryGroup"===t||"merchant"===t||"budgetVariability"===t||"businessEntity"===t||"owner"===t},qQe=e=>{if(!e||"object"!==typeof e)return null;const t=e;if("string"!==typeof t.id||"string"!==typeof t.label)return null;if("string"!==typeof t.groupBy||!jQe.has(t.groupBy))return null;const n={id:t.id,label:t.label,groupBy:t.groupBy,kind:"entity"};if(void 0!==t.selection){if(!KQe(t.selection))return null;n.selection=t.selection}return Array.isArray(t.sourceFocusPath)&&t.sourceFocusPath.every((e=>"string"===typeof e))&&(n.sourceFocusPath=t.sourceFocusPath),n},$Qe=e=>Array.isArray(e)&&e.every((e=>"string"===typeof e))?e:[],ZQe={stack:[],focusPath:[]},JQe=e=>{const t=[];for(const n of e){const e=qQe(n);if(!e)return null;t.push(e)}return t},XQe=e=>{var t;const n=Array.isArray(e)?{stack:e,focusPath:[]}:e,a=YQe(n.stack).map(HQe),l=null!==(t=n.focusPath)&&void 0!==t?t:[],r=n.tip;if(0===a.length&&0===l.length&&!r)return;const o={stack:a,focusPath:l};return r&&(o.tip=r),JSON.stringify(o)},QQe=e=>{if("string"!==typeof e||0===e.length)return ZQe;try{const t=JSON.parse(e);if(Array.isArray(t)){const e=JQe(t);return e?{stack:e,focusPath:[]}:ZQe}if(!t||"object"!==typeof t)return ZQe;const n=t;if(!Array.isArray(n.stack))return ZQe;const a=JQe(n.stack);if(!a)return ZQe;const l=(e=>{if(!e||"object"!==typeof e)return;const t=e;return"string"===typeof t.id&&"string"===typeof t.label&&KQe(t.selection)?{id:t.id,label:t.label,selection:t.selection}:void 0})(n.tip);return void 0!==n.tip&&void 0===l?ZQe:l?{stack:a,focusPath:$Qe(n.focusPath),tip:l}:{stack:a,focusPath:$Qe(n.focusPath)}}catch(t){return ZQe}};var e0e,t0e;const n0e=()=>{const e=window.location,t=e.pathname,n=e.search,l=(0,nG.p)("feat-paychecks-web","off"),r=(0,qG.e)().hasAccess,o=(0,zQe.Rq)().businessEntities.length>0;return a.createElement(l0e,{"data-external-id":"reports-header-tabs"},a.createElement(r0e,{to:{pathname:I.JZ.reports.cashFlow.path,search:a0e(n,t,I.JZ.reports.cashFlow.path)}},"Cash flow"),a.createElement(r0e,{to:{pathname:I.JZ.reports.spending.path,search:a0e(n,t,I.JZ.reports.spending.path)}},"Spending"),a.createElement(r0e,{to:{pathname:I.JZ.reports.income.path,search:a0e(n,t,I.JZ.reports.income.path)}},"Income"),l&&a.createElement(r0e,{to:{pathname:I.JZ.reports.paychecks.path,search:a0e(n,t,I.JZ.reports.paychecks.path)}},"Paychecks"),r&&o&&a.createElement(r0e,{to:{pathname:I.JZ.reports.taxForms.path,search:a0e(n,t,I.JZ.reports.taxForms.path)}},"Business tax prep"))},a0e=(e,t,n)=>{if(t===n)return e;const a=tp.A.parse(e),l=(0,XX.A)([...Object.values(RJe.pE),WQe],a),r=tp.A.stringify(l);return r?"?".concat(r):""},l0e=(0,$d.s)(m.g).attrs((0,U.A)((0,U.A)({},(0,Ex.p)("reports-header-tabs")),{},{alignStretch:!0}))(e0e||(e0e=(0,wc.A)(["ml-xl min-w-0"]))),r0e=(0,$d.s)(MCe)(t0e||(t0e=(0,wc.A)(["mr-lg block min-w-0 truncate leading-8"])));var o0e=n(725);const i0e="gross_pay",s0e="net_pay",c0e="total_deductions";let d0e=function(e){return e.GrossPay="grossPay",e.NetPay="netPay",e.TotalDeductions="totalDeductions",e.DeductionGroup="deductionGroup",e.Deduction="deduction",e}({});function u0e(e){const t=e.totalGross,n=e.totalNet,a=e.deductionsByType;if(t<=0||0===a.length)return{nodes:[],links:[]};const l=[],r=[],o=t-n;l.push({id:i0e,label:"Gross Pay",value:t,rawValue:t,fixedValue:t,type:d0e.GrossPay,isClickable:!1}),n>0&&(l.push({id:s0e,label:"Net Pay",value:n,rawValue:n,type:d0e.NetPay,isClickable:!1}),r.push({source:i0e,target:s0e,value:n})),l.push({id:c0e,label:"Deductions",value:o,rawValue:o,type:d0e.TotalDeductions,isClickable:!1}),r.push({source:i0e,target:c0e,value:o});const i=function(e){const t=new Map;for(const l of e){var n;const e=H7.get(l.deductionType),r=null!==(n=null===e||void 0===e?void 0:e.category)&&void 0!==n?n:"other",o=W7.get(r);var a;t.has(r)||t.set(r,{category:r,label:null!==(a=null===o||void 0===o?void 0:o.label)&&void 0!==a?a:r,total:0,deductions:[]});const i=t.get(r);i.total+=l.totalAmount,i.deductions.push(l)}return Array.from(t.values()).sort(((e,t)=>t.total-e.total))}(a);for(const c of i){const e="group_".concat(c.category);l.push({id:e,label:c.label,value:c.total,rawValue:c.total,type:d0e.DeductionGroup}),r.push({source:c0e,target:e,value:c.total});const t=[...c.deductions].sort(((e,t)=>t.totalAmount-e.totalAmount));for(const n of t){var s;const t=H7.get(n.deductionType),a="deduction_".concat(n.deductionType);l.push({id:a,label:null!==(s=null===t||void 0===t?void 0:t.label)&&void 0!==s?s:n.deductionType,value:n.totalAmount,rawValue:n.totalAmount,type:d0e.Deduction}),r.push({source:e,target:a,value:n.totalAmount})}}return{nodes:l,links:r}}const m0e=(e,t)=>{var n;return null!==(n={taxes:t.color.red,retirement:t.color.blue,retirement_loan:t.color.indigo,health_insurance:t.color.pink,spending_accounts:t.color.purple,equity:t.color.teal,voluntary:t.color.teal,garnishments:t.color.orange,repayments:t.color.yellow,other:t.color.gray}[e])&&void 0!==n?n:t.color.gray},p0e=(e,t,n)=>{e.forEach((e=>{if(e.type===d0e.GrossPay||e.type===d0e.NetPay||e.type===d0e.TotalDeductions)e.color=n.color.green;else if(e.type===d0e.DeductionGroup){const t=e.id.replace("group_","");e.color=m0e(t,n)}else if(e.type===d0e.Deduction&&((0,o0e.z0)(e,t),!e.color)){var a;const t=H7.get(e.id.replace("deduction_","")),l=null!==(a=null===t||void 0===t?void 0:t.category)&&void 0!==a?a:"other";e.color=m0e(l,n)}}))},g0e=(e,t)=>WJ.kb(e,t),h0e=(e,t)=>{var n,a;if(e.id===s0e)return-1;if(t.id===s0e)return 1;const l=v0e(e),r=v0e(t);var o,i;return l&&r&&l.id!==r.id?(null!==(o=r.value)&&void 0!==o?o:0)-(null!==(i=l.value)&&void 0!==i?i:0):(null!==(n=t.value)&&void 0!==n?n:0)-(null!==(a=e.value)&&void 0!==a?a:0)};function v0e(e){var t,n;if("string"!==typeof e.id||!e.id.startsWith("deduction_"))return;const a=null===(t=e.targetLinks)||void 0===t||null===(n=t[0])||void 0===n?void 0:n.source;return"object"===typeof a&&null!==a&&"string"===typeof a.id&&a.id.startsWith("group_")?a:void 0}const f0e=(e,t)=>{const n="object"===typeof e.target&&"id"in e.target?e.target.id:"",a="object"===typeof t.target&&"id"in t.target?t.target.id:"";return n===s0e?-1:a===s0e?1:t.value-e.value},E0e=e=>{let t=e.summary,n=e.isLoading,l=e.paycheckCount,r=void 0===l?0:l;const i=(0,qd.W)(),s=(0,o.A)(i,2),c=s[0],d=s[1].width,u=void 0===d?0:d,m=(0,xy.d)(u,150),g=(0,a.useState)(!0),h=(0,o.A)(g,2),v=h[0],f=h[1],E=(0,a.useMemo)((()=>t?u0e(t):{nodes:[],links:[]}),[t]);(0,a.useEffect)((()=>
1{if(u>0){const e=setTimeout((()=>f(!1)),400);return()=>clearTimeout(e)}}),[u]);const y=(0,a.useCallback)((()=>n||v?a.createElement(x0e,null,a.createElement(p.i,null)):(0,PY.A)(E.links)?a.createElement(w0e,null,a.createElement(xt.v,{color:"textLight"},0===r?"No paychecks found for the selected period.":"No deductions found for the selected paychecks.")):a.createElement(aX.uq,{width:m,data:E,formatValue:y0e,onAlignNode:g0e,onSortNodes:h0e,onSortLinks:f0e,customNodesColorDeterminer:p0e,highlightOnHover:!0})),[n,v,E,m,r]);return a.createElement(pX.f,{"data-external-id":"paycheck-sankey",padding:0},a.createElement(mX.V,{md:12},a.createElement(b0e,{ref:c},y())))},y0e=e=>{let t=e.value,n=e.rawValue,a=e.percent,l=e.type;return l===d0e.GrossPay?(0,rl.vv)(null!==n&&void 0!==n?n:t):l===d0e.NetPay||l===d0e.TotalDeductions?(0,rl.vv)(t):"-".concat((0,rl.vv)(t)).concat(a?" (".concat((0,De.l9)(a),")"):"")},b0e=(0,u.default)(m.g).withConfig({displayName:"PaycheckSankey__Content",componentId:"vxz6jw-0"})(["overflow:hidden;position:relative;"]),x0e=(0,u.default)(m.g).attrs({center:!0,column:!0}).withConfig({displayName:"PaycheckSankey__LoadingContainer",componentId:"vxz6jw-1"})(["padding:",";"],(e=>e.theme.spacing.xxxxlarge)),w0e=(0,u.default)(m.g).attrs({center:!0,column:!0}).withConfig({displayName:"PaycheckSankey__EmptyContainer",componentId:"vxz6jw-2"})(["padding:",";"],(e=>e.theme.spacing.xxxlarge));var C0e;const A0e=e=>{var t,n,l,r;let i=e.startDate,s=e.endDate,c=e.ownerIds,d=void 0===c?[]:c,m=e.employerId;const p=(0,u.useTheme)(),g=(0,a.useMemo)((()=>(0,Vo.uK)(p.color)),[p.color]),h=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};var t;const n=e.startDate,a=e.endDate,l=e.ownerIds,r=e.employerId,o=(0,et.I)(Pee,{variables:{startDate:null!==n&&void 0!==n?n:null,endDate:null!==a&&void 0!==a?a:null,ownerIds:(null===l||void 0===l?void 0:l.length)?l:null,employerId:null!==r&&void 0!==r?r:null}}),i=o.data,s=o.isLoadingInitialData,c=o.refetch;return{summary:null!==(t=null===i||void 0===i?void 0:i.paychecksSummary)&&void 0!==t?t:null,isLoadingInitialData:s,refetch:c}}({startDate:i,endDate:s,ownerIds:d,employerId:m}),v=h.summary,f=h.isLoadingInitialData,E=1===d.length?d[0]:void 0,y=Bee({startDate:i,endDate:s,ownerId:E,employerId:m}),b=y.paychecks,x=y.isLoadingInitialData,w=(0,a.useState)("sankey"),C=(0,o.A)(w,2),A=C[0],I=C[1],k=(0,a.useState)(null),S=(0,o.A)(k,2),N=S[0],T=S[1],_=(0,a.useMemo)((()=>{var e;return null!==(e=b.find((e=>e.id===N)))&&void 0!==e?e:null}),[b,N]),D=(0,a.useCallback)((e=>{(0,Ge.u4)(Ye.i0.ReportsDetailsOpened,{paycheck_id:e}),T(e)}),[]),R=(0,a.useCallback)((()=>{T(null)}),[]),L=(0,a.useMemo)((()=>{if(!v)return[];const e=new Map;for(const a of v.deductionsByType){var t,n;const l=K7(a.deductionType),r=null!==(t=null===l||void 0===l?void 0:l.category)&&void 0!==t?t:"other";e.set(r,(null!==(n=e.get(r))&&void 0!==n?n:0)+a.totalAmount)}return Array.from(e.entries()).sort(((e,t)=>{let n=(0,o.A)(e,2)[1];return(0,o.A)(t,2)[1]-n})).map(((e,t)=>{var n;let a=(0,o.A)(e,2),l=a[0],r=a[1];const i=W7.get(l);return{id:l,label:null!==(n=null===i||void 0===i?void 0:i.label)&&void 0!==n?n:l,value:r,color:g[t%g.length],formattedValue:(0,rl.vv)(r),percent:v.totalDeductions>0?r/v.totalDeductions:0}}))}),[v,g]),O=(0,a.useMemo)((()=>{if(!v)return[];const e=v.deductionsByType.filter((e=>e.totalAmount>0)).sort(((e,t)=>t.totalAmount-e.totalAmount)).map(((e,t)=>{var n;const a=K7(e.deductionType);return{id:e.deductionType,label:null!==(n=null===a||void 0===a?void 0:a.label)&&void 0!==n?n:e.deductionType,value:e.totalAmount,color:g[t%g.length]}}));return[{id:"net-pay",label:"Net Pay",value:v.totalNet,color:p.color.greenText},...e]}),[v,g,p.color.greenText]),P=(0,a.useMemo)((()=>Math.max(200,40*O.length+80)),[O.length]),B=f;let z,F;if(B)z=a.createElement("div",{className:"flex items-center justify-center p-10"},a.createElement(M.Al,{$width:"200px",$height:"200px",$borderRadius:"round"}));else if(0===L.length){var G;z=a.createElement(S0e,null,a.createElement(xt.v,{color:"textLight"},0===(null!==(G=null===v||void 0===v?void 0:v.count)&&void 0!==G?G:0)?"No paychecks found for the selected period.":"No deductions foun
1d for the selected paychecks."))}else{var Y;z=a.createElement(Uo.el,{data:L,pieChartTitle:(0,rl.vv)(null!==(Y=null===v||void 0===v?void 0:v.totalDeductions)&&void 0!==Y?Y:0),pieChartSubtitle:"Total Deductions"})}var U;if("sankey"===A)F=a.createElement(E0e,{summary:v?{totalGross:v.totalGross,totalNet:v.totalNet,deductionsByType:v.deductionsByType}:null,isLoading:B,paycheckCount:null!==(U=null===v||void 0===v?void 0:v.count)&&void 0!==U?U:0});else if(B)F=a.createElement("div",{className:"flex items-center justify-center p-10"},a.createElement(M.Al,{$width:"100%",$height:"200px"}));else if(0===O.length){var V;F=a.createElement(S0e,null,a.createElement(xt.v,{color:"textLight"},0===(null!==(V=null===v||void 0===v?void 0:v.count)&&void 0!==V?V:0)?"No paychecks found for the selected period.":"No breakdown data available."))}else F=a.createElement(xSe,{data:O,height:P,xDataKey:"value",yDataKey:"label",labelFormatter:e=>(0,rl.vv)(e),xAxisFormatter:e=>(0,rl.vv)(e)});return a.createElement(a.Fragment,null,a.createElement(k0e,null,a.createElement(I0e,{label:"Total gross",value:a.createElement(kJe,{formatter:rl.vv,value:null!==(t=null===v||void 0===v?void 0:v.totalGross)&&void 0!==t?t:0,color:"greenText"}),isLoading:B}),a.createElement(I0e,{label:"Total deductions",value:a.createElement(kJe,{formatter:rl.vv,value:null!==(n=null===v||void 0===v?void 0:v.totalDeductions)&&void 0!==n?n:0,color:"redText"}),isLoading:B}),a.createElement(I0e,{label:"Total net pay",value:a.createElement(kJe,{formatter:rl.vv,value:null!==(l=null===v||void 0===v?void 0:v.totalNet)&&void 0!==l?l:0}),isLoading:B}),a.createElement(I0e,{label:"Deduction rate",value:a.createElement(kJe,{formatter:De.l9,value:null!==(r=null===v||void 0===v?void 0:v.deductionRate)&&void 0!==r?r:0}),isLoading:B})),a.createElement(N0e,{title:"Deductions Breakdown"},z),a.createElement(T0e,{title:"Paycheck Breakdown",controls:a.createElement(Gk,null,a.createElement(wt.Xb,{onClick:()=>{(0,Ge.u4)(Ye.i0.ReportsChartTypeChanged,{chart_type:"sankey"}),I("sankey")},active:"sankey"===A},a.createElement(_0e,{name:"sankey"})),a.createElement(wt.Xb,{onClick:()=>{(0,Ge.u4)(Ye.i0.ReportsChartTypeChanged,{chart_type:"bar"}),I("bar")},active:"bar"===A},a.createElement(_0e,{name:"bar-chart"})))},F),a.createElement(D0e,null,a.createElement(Xl.AM,{title:"Paychecks"},a.createElement(lae,{paychecks:b,isLoading:x,activePaycheckId:N,onPaycheckClick:D,onAddPaycheck:RQ.l,hasActiveFilters:!!(i||s||m)})),a.createElement(oae,{paychecks:b,isLoading:x})),_&&a.createElement(Yee,{paycheck:_,onClose:R}))},I0e=(0,u.default)(MZ).attrs({"data-sc-tw":"ReportsPaychecksContent__StatisticCardGrow"}).withConfig({displayName:"ReportsPaychecksContent__StatisticCardGrow",componentId:"sc-6jmwkc-0"})(["flex:1;"]),k0e=(0,u.default)(m.g).attrs({justifyBetween:!0,alignCenter:!0,gap:"gutter"}).withConfig({displayName:"ReportsPaychecksContent__SummaryCardsContainer",componentId:"sc-6jmwkc-1"})(["margin-bottom:",";@media (max-width:","px){flex-flow:row wrap;gap:",";margin-bottom:",";> [data-sc-tw~='ReportsPaychecksContent__StatisticCardGrow']{flex-basis:33%;}}@media (max-width:","px){> [data-sc-tw~='ReportsPaychecksContent__StatisticCardGrow']{flex-basis:50%;}}"],vt.YK.gutter,(e=>e.theme.breakPoints.md),(e=>e.theme.spacing.small),vt.YK.small,vt.nm.xs),S0e=(0,u.default)(m.g).attrs({alignCenter:!0,justifyCenter:!0,column:!0}).withConfig({displayName:"ReportsPaychecksContent__EmptyStateContainer",componentId:"sc-6jmwkc-2"})(["padding:",";"],vt.YK.xxxlarge),N0e=(0,$d.s)(Xl.AM)(C0e||(C0e=(0,wc.A)(["overflow-visible"]))),T0e=(0,u.default)(Xl.AM).withConfig({displayName:"ReportsPaychecksContent__BreakdownCard",componentId:"sc-6jmwkc-3"})(["margin-top:",";overflow:visible;"],vt.YK.gutter),_0e=(0,u.default)(sl.ZQ).attrs({size:16}).withConfig({displayName:"ReportsPaychecksContent__ButtonGroupIcon",componentId:"sc-6jmwkc-4"})([""]),D0e=u.default.div.withConfig({displayName:"ReportsPaychecksContent__UnderlyingDataGrid",componentId:"sc-6jmwkc-5"})(["display:grid;grid-template-columns:1fr 320px;gap:",";margin-top:",";@media (max-width:","px){grid-template-columns:1fr;}"],vt.YK.gutter,vt.YK.gutter,vt.nm.md),R0e=e=>{let t=e.reportName,n=e.onDelete,l=e.goBack;const r=(0,u7.$)().skipToComplete;return a.createElement(Rc.L,{"data-external-id":"delete-report-modal",title:"Delete saved report"},a.createElement(qY.S,null,a.createElement(xt.v,{className:"wrap-anywhere"},"The saved report ",a.createElement("strong",null,t)," will be removed from your saved list.")),a.createElement(Cq.R,null,a.createElement(wt.Xb,{onClick:l},"Cancel"),a.createElement(G7.jI,{onClick:()=>{n(),r()}},"Delete saved report")))},M0e={[V1.Gi.CashFlowChart]:"Bar Chart (Grouped)",[V1.Gi.StackedCashFlowChart]:"Bar Chart (Stacked)",[V1.Gi.SankeyCashFlowChart]:"Sankey",[V1.Gi.ProfitLossTable]:"Profit & Loss",[V1.Gi.PieChart]:"Donut Chart",[V1.Gi.HorizontalBarChart]:"Bar Chart",[V1.Gi.TreemapChart]:"Treemap",[V1.Gi.BarChart]:"Bar Chart (Grouped)",[V1.Gi.StackedBarChart]:"Bar Chart (Stacked)"},L0e=e=>{let t=e.reportView,n=e.editingReportConfiguration;const l=(0,a.useMemo)((()=>n?n.reportView?(0,RJe.jU)(n.reportView):void 0:(0,RJe.jU)(t)),[n,t]),r=(0,a.useMemo)((()=>
1{if(!l)return;const e=l.tab,t=l.chartType,n=l.calculationViewMode,a=l.cashFlowGroupMode,r=l.groupByEntity,o=l.groupByTimeframe,i="cashFlow"===e&&t===V1.Gi.HorizontalBarChart,s=i?"Breakdown":t?M0e[t]:void 0,c=a?MJe[a]:void 0,d=r?"By ".concat(Vo.Li[r]):void 0,u=["spending","income"].includes(e)||i,m=null!==c&&void 0!==c?c:u?d:void 0,p=o?RJe.aV[o]:void 0,g=n&&(0,V1.hm)(e)?RJe.rs[n]:void 0;return[(0,Wie.capitalCase)(e),g,s,p,m].filter(Boolean)}),[l]),o=a.createElement(B0e,null,null===r||void 0===r?void 0:r.map((e=>a.createElement(z0e,{key:e},a.createElement(F0e,null,e)))));return r?a.createElement(O0e,{"data-external-id":"report-view-overview"},(0,Tr.A)(n)?a.createElement(a.Fragment,null,a.createElement(P0e,null,"Chart view"),o):a.createElement(eC.J,{name:"includeReportView",label:"Include report chart settings",subtext:o})):null},O0e=(0,u.default)(m.g).attrs({gap:"xsmall",column:!0}).withConfig({displayName:"ReportViewOverview__ReportViewSectionContainer",componentId:"sc-1p7sbmy-0"})(["[data-sc-tw~='ToggleWithText__ToggleFieldSubText']{max-width:unset;}"]),P0e=(0,u.default)(xt.v).attrs({size:"small"}).withConfig({displayName:"ReportViewOverview__ReportViewSectionTitle",componentId:"sc-1p7sbmy-1"})(["font-weight:",";"],vt.Wy.bold),B0e=(0,u.default)(m.g).attrs({justifyStart:!0,gap:"xsmall",wrap:!0}).withConfig({displayName:"ReportViewOverview__ReportViewSectionItemsContainer",componentId:"sc-1p7sbmy-2"})([""]),z0e=(0,u.default)(m.g).attrs({justifyBetween:!0,alignCenter:!0,gap:"xsmall"}).withConfig({displayName:"ReportViewOverview__ReportViewSectionItemContainer",componentId:"sc-1p7sbmy-3"})(["background-color:",";padding:"," ",";border-radius:",";"],vt.Ee.color.background.secondary,vt.YK.xxsmall,vt.YK.xsmall,vt.YK.xxsmall),F0e=(0,u.default)(xt.v).attrs({size:"small"}).withConfig({displayName:"ReportViewOverview__ReportViewSectionItemText",componentId:"sc-1p7sbmy-4"})([""]);var G0e=n(37074);const Y0e=e=>{let t=e.className,n=e.filters;const l=(0,CX.WD)(n),o=(0,vQ.N)().preferredVersion,i=MQ(l).transactionFiltersMetadata,s=null!==i&&void 0!==i?i:{},d=s.categories,u=s.categoryGroups,m=s.merchants,p=s.accounts,g=s.tags,h=s.goals,v=s.savingsGoals,f=s.needsReviewByUser,E=s.ownershipSet,y=s.businessEntitySet,b=n.amountFilter,x=l.search,w=l.startDate,C=l.endDate,A=l.timeframePeriod,I=l.creditsOnly,k=l.debitsOnly,S=l.needsReview,N=l.isRecurring,T=l.isSplit,_=l.isPending,D=l.isUncategorized,R=l.isFlexSpending,M=l.isInvestmentAccount,L=l.hasAttachments,O=l.hasNotes,P=l.importedFromMint,B=l.syncedFromInstitution,z=l.isUntagged,F=l.transactionVisibility,G=l.deletedTransactionVisibility,Y=(0,a.useMemo)((()=>{var e,t;const l=a.createElement(U0e,{title:"Dates",key:"dates"},a.createElement(K0e,null,a.createElement(q0e,null,(0,fXe._K)({startDate:w,endDate:C,timeframeUnit:null===A||void 0===A?void 0:A.unit,timeframeValue:null===A||void 0===A?void 0:A.value,includeCurrentPeriod:null===A||void 0===A?void 0:A.includeCurrent})))),i=(0,c.A)(d)?a.createElement(U0e,{title:"Categories",key:"categories"},null===d||void 0===d?void 0:d.map((e=>{let t=e.name,n=e.icon;return a.createElement(K0e,{key:t},a.createElement(q0e,null,n),a.createElement(q0e,null,t))}))):null,s=(0,c.A)(u)?a.createElement(U0e,{title:"Category groups",key:"categoryGroups"},null===u||void 0===u?void 0:u.map((e=>{let t=e.name;return a.createElement(K0e,{key:t},a.createElement(q0e,null,t))}))):null,Y=(0,c.A)(m)?a.createElement(U0e,{title:"Merchants",key:"merchants"},null===m||void 0===m?void 0:m.map((e=>{let t=e.name,n=e.logoUrl;return a.createElement(K0e,{key:t},a.createElement(Wl._,{url:n,size:16}),a.createElement(q0e,null,t))}))):null,U=(0,c.A)(p)?a.createElement(U0e,{title:"Accounts",key:"accounts"},null===p||void 0===p?void 0:p.map((e=>{let t=e.displayName,n=e.logoUrl,l=e.icon;return a.createElement(K0e,{key:t},a.createElement(Gl.v,{icon:l,logoUrl:n,size:16}),a.createElement(q0e,null,t))}))):null,V=(0,c.A)(E)?a.createElement(U0e,{title:"Owners",key:"ownership"},(null===E||void 0===E?void 0:E.includeJointlyOwned)&&a.createElement(K0e,null,a.createElement(Pw.n,{textSize:"small",userId:null,userName:null})),null===E||void 0===E||null===(e=E.users)||void 0===e?void 0:e.map((e=>{let t=e.id,n=e.displayName,l=e.profilePictureUrl;return a.createElement(K0e,{key:t},a.createElement(Pw.n,{userId:t,userName:n,userProfilePictureUrl:l,textSize:"small"}))}))):null,W=(0,c.A)(y)?a.createElement(U0e,{title:"Businesses",key:"businessEntities"},(null===y||void 0===y?void 0:y.includeUnassigned)&&a.createElement(K0e,null,a.createElement(G0e.l,{businessEntity:null,size:"small",textColor:"text"})),null===y||void 0===y||null===(t=y.businessEntities)||void 0===t?void 0:t.map((e=>a.createElement(K0e,{key:e.id},a.createElement(G0e.l,{businessEntity:e,size:"small",textColor:"text"}))))):null,j=(0,c.A)(g)||z?a.createElement(U0e,{title:"Tags",key:"tags"},z&&a.createElement(K0e,null,a.createElement(q0e,null,"Is untagged")),null===g||void 0===g?void 0:g.map((e=>{let t=e.name,n=e.color;return a.createElement(K0e,{key:t}
1,a.createElement(Ta.c,{color:n,size:12}),a.createElement(q0e,null,t))}))):null,H="v2"===o&&(0,c.A)(h)?a.createElement(U0e,{title:"Goals",key:"goals"},null===h||void 0===h?void 0:h.map((e=>a.createElement(K0e,{key:e.id},a.createElement(aQ,{goal:e}),a.createElement(q0e,null,e.name))))):null,K="v3"===o&&(0,c.A)(v)?a.createElement(U0e,{title:"Goals",key:"savingsGoals"},null===v||void 0===v?void 0:v.map((e=>a.createElement(K0e,{key:e.id},a.createElement(iQ,{savingsGoal:e}),a.createElement(q0e,null,e.name))))):null;let q=null;const $=(0,c.A)(b),Z=(0,Tr.A)(I)||(0,Tr.A)(k);if($||Z){const e=(0,tj.rs)(n).find((e=>e.isSelected));q=a.createElement(U0e,{title:"Amount",key:"amount"},$&&a.createElement(K0e,null,a.createElement(q0e,null,null===e||void 0===e?void 0:e.formatLabel({}))),n.creditsOnly&&a.createElement(K0e,null,a.createElement(q0e,null,"Credits only")),n.debitsOnly&&a.createElement(K0e,null,a.createElement(q0e,null,"Debits only")))}const J=[S&&{key:"needsReview",child:a.createElement(q0e,null,"Needs review by ",f?f.name:"anyone")},(0,c.A)(x)&&{key:"search",child:a.createElement(q0e,null,"Searching for '",x,"'")},(0,Tr.A)(N)&&{key:"isRecurring",child:a.createElement(q0e,null,N?"Recurring":"Not recurring")},(0,Tr.A)(T)&&{key:"isSplit",child:a.createElement(q0e,null,T?"Split":"Not split")},(0,Tr.A)(_)&&{key:"isPending",child:a.createElement(q0e,null,_?"Pending":"Not pending")},(0,Tr.A)(D)&&{key:"isUncategorized",child:a.createElement(q0e,null,D?"Uncategorized":"Categorized")},(0,Tr.A)(R)&&{key:"isFlexSpending",child:a.createElement(q0e,null,R?"Flex spending":"Not flex spending")},(0,Tr.A)(M)&&{key:"isInvestmentAccount",child:a.createElement(q0e,null,M?"In an investment account":"Not in an investment account")},(0,Tr.A)(L)&&{key:"hasAttachments",child:a.createElement(q0e,null,L?"Has attachments":"No attachments")},(0,Tr.A)(O)&&{key:"hasNotes",child:a.createElement(q0e,null,O?"Has notes":"No notes")},(0,Tr.A)(P)&&{key:"importedFromMint",child:a.createElement(q0e,null,P?"Imported from CSV":"Not imported from CSV")},(0,Tr.A)(F)&&{key:"transactionVisibility",child:a.createElement(q0e,null,(0,r.YW)(F).with(Ee.h1.ALL_TRANSACTIONS,(()=>"Hidden and not hidden transactions")).with(Ee.h1.HIDDEN_TRANSACTIONS_ONLY,(()=>"Hidden transactions only")).with(Ee.h1.NON_HIDDEN_TRANSACTIONS_ONLY,(()=>"Non-hidden transactions only")).otherwise((()=>null)))},G===Ee.SrA.DELETED_ONLY&&{key:"deletedTransactionVisibility",child:a.createElement(q0e,null,"Deleted transactions only")},G===Ee.SrA.ALL_INCLUDING_DELETED&&{key:"deletedTransactionVisibility",child:a.createElement(q0e,null,"Deleted and not deleted transactions")},(0,Tr.A)(B)&&{key:"syncedFromInstitution",child:a.createElement(q0e,null,B?"Synced from institution":"Created manually")}].filter(Boolean);return[l,i,s,Y,U,V,W,j,H,K,q,J.length>0?a.createElement(U0e,{title:"Other",key:"other"},J.map((e=>{let t=e.key,n=e.child;return a.createElement(K0e,{key:t},n)}))):null].filter(Tr.A)}),[w,C,null===A||void 0===A?void 0:A.unit,null===A||void 0===A?void 0:A.value,null===A||void 0===A?void 0:A.includeCurrent,d,u,m,p,E,y,g,z,h,v,o,b,I,k,S,f,x,N,T,_,D,R,M,L,O,P,F,G,B,n]);return a.createElement(V0e,{"data-external-id":"transaction-filters-overview",className:t},Y)},U0e=e=>{let t=e.title,n=e.children;return a.createElement(W0e,{"data-external-id":"filter-section"},a.createElement(j0e,null,t),a.createElement(H0e,null,n))},V0e=(0,u.default)(m.g).attrs({column:!0,gap:"xlarge"}).withConfig({displayName:"TransactionFiltersOverview__Root",componentId:"sc-1pxv556-0"})(["overflow:hidden;"]),W0e=(0,u.default)(m.g).attrs({gap:"xsmall",column:!0}).withConfig({displayName:"TransactionFiltersOverview__FilterSectionContainer",componentId:"sc-1pxv556-1"})([""]),j0e=(0,u.default)(xt.v).attrs({size:"small"}).withConfig({displayName:"TransactionFiltersOverview__FilterSectionTitle",componentId:"sc-1pxv556-2"})(["font-weight:",";"],vt.Wy.bold),H0e=(0,u.default)(m.g).attrs({justifyStart:!0,gap:"xsmall",wrap:!0}).withConfig({displayName:"TransactionFiltersOverview__FilterSectionItemsContainer",componentId:"sc-1pxv556-3"})([""]),K0e=(0,u.default)(m.g).attrs({justifyBetween:!0,alignCenter:!0,gap:"xsmall"}).withConfig({displayName:"TransactionFiltersOverview__FilterSectionItemContainer",componentId:"sc-1pxv556-4"})(["background-color:",";padding:"," ",";border-radius:",";overflow:hidden;"],vt.Ee.color.background.secondary,vt.YK.xxsmall,vt.YK.xsmall,vt.YK.xxsmall),q0e=(0,u.default)(xt.v).attrs({size:"small"}).withConfig({displayName:"TransactionFiltersOverview__FilterSectionItemText",componentId:"sc-1pxv556-5"})([""]),$0e=e=>{let t=e.reportView,n=e.filters,l=e.editingReportConfigurationId,r=e.reportConfigurations,o=e.onDeleteReportConfiguration,i=e.onSubmit;(0,p4.n)(l?Ye.m2.ReportConfigurationUpdateStarted:Ye.m2.ReportConfigurationCreationStarted);const s=(0,u7.$)().skipToComplete,c=(0,a.useMemo)((()=>r.find((e=>e.id===l))),[r,l]);return a.createElement(Rc.L,{"data-external-id":"save-report-configuration-modal",title:"".concat(l?"Edit":"Create"," saved report")},a.createElement(Eu.lV,{initialValues:{displayName:null===c||void 0===c?void 0:c.displayName,includeReportView:!0},onSubmit:i,onSubmitSuccess:s},a.createElement(X0e,{reportView:t,filters:n,reportConfigurations:r,editingReportConfiguration:c,onDeleteReportConfiguration:o})))},Z0e=e=>{let t=e.reportName;return a.createElement(fu.g,{"data-external-id":"same-report-configuration-banner",type:"error"},a.createElement(t1e,null,"This report has the same configuration as your existing saved report"," ",a.createElement("strong",null,t),"."),a.createElement(t1e,null,"Change the date range, filters, or chart view to save."))},J0e=()=>a.createElement(fu.g,{"data-external-id":"existing-report-name-banner",type:"error"},a.createElement(t1e,null,"This report uses the same name as an existing saved report."),a.createElement(t1e,null,"Use a different name to save.")),X0e=e=>{var t,n,l;let r=e.reportView,o=e.filters,i=e.reportConfigurations,c=e.editingReportConfiguration,d=e.onDeleteReportConfiguration;const u=(0,u7.$)(),m=u.next,g=u.skipToComplete,h=(0,hu.x)(),v=h.initialValues,f=h.values,E=h.isSubmitting,y=h.setFieldValue,b=h.touched,x=h.setFieldTouched,w=(0,nG.p)("feat-ai-saved-report-name-web-back","off"),C=(0,et.I)(n1e,{variables:{transactionFilters:(0,CX.WD)(o),reportView:f.includeReportView?(0,RJe.qf)(r):void 0}
1,skip:!!c||b.displayName||!w,onError:e=>{s.Cp(e)}}),A=C.data,I=C.isNetworkRequestInFlight,k=null===A||void 0===A||null===(t=A.generatedReportName)||void 0===t?void 0:t.trim();(0,a.useEffect)((()=>{k&&!b.displayName&&f.displayName!==k&&(y("displayName",k),y("generatedName",k))}),[k,y,f.displayName,b.displayName]);const S=(0,a.useMemo)((()=>c?void 0:i.find((e=>(0,tj.y6)((0,CX.WD)(o),e.transactionFilterSet)&&(0,RJe.hz)(f.includeReportView?r:void 0,e.reportView)))),[c,i,o,f.includeReportView,r]),N=null!==(n=null===(l=f.displayName)||void 0===l?void 0:l.trim())&&void 0!==n?n:"",T=(0,a.useMemo)((()=>i.some((e=>e.displayName===N&&e.displayName!==v.displayName))),[i,N,v]),_=(0,a.useMemo)((()=>c?(0,RJe.$H)(c.transactionFilterSet):o),[c,o]);return a.createElement(a.Fragment,null,a.createElement(Q0e,null,!!S&&a.createElement(Z0e,{reportName:S.displayName}),T&&a.createElement(J0e,null),a.createElement(e1e,{name:"displayName",label:"Report name",placeholder:I?"Generating report name...":"Enter report name",disabled:I,labelRight:I&&a.createElement(p.i,{size:"sm"}),onFocus:e=>{x(e.target.name,!0)}}),a.createElement(Y0e,{filters:_}),a.createElement(L0e,{reportView:r,editingReportConfiguration:c})),a.createElement(Cq.R,{justifyEnd:!0},c&&a.createElement(G7.jI,{onClick:()=>{m({reportName:null===c||void 0===c?void 0:c.displayName,onDelete:()=>{c&&d(c)}})}},"Delete"),a.createElement(wt.Xb,{onClick:g},"Cancel"),a.createElement(CJ.I,{size:"small",pending:E,disableWhenValuesUnchanged:!w,disabled:(0,Tr.A)(S)||T||""===N||I},"Save")))},Q0e=(0,u.default)(qY.S).withConfig({displayName:"SaveReportConfigurationModal__StyledCardBody",componentId:"sc-1qzgekq-0"})(["gap:",";"],vt.YK.xlarge),e1e=(0,u.default)(Qw.X).withConfig({displayName:"SaveReportConfigurationModal__StyledTextField",componentId:"sc-1qzgekq-1"})([":not(:last-child){margin-bottom:0;}"]),t1e=(0,u.default)(xt.v).withConfig({displayName:"SaveReportConfigurationModal__BannerText",componentId:"sc-1qzgekq-2"})(["display:block;overflow-wrap:break-word;:not(:last-child){margin-bottom:",";}"],vt.YK.xsmall),n1e=Ee.J4Z,a1e=e=>{const t=(0,Sq.k)().close;return a.createElement(h7.n,{"data-external-id":"save-report-configuration-flow",initialProps:e,steps:[$0e,R0e],onComplete:t})};var l1e=n(79167);const r1e=e=>{let t=e.lineItems,n=e.currentLineItemKey,l=e.onSelect,r=e.onUnmap;const o=(0,Qi.rL)().close,i=t.filter((e=>"income"===e.lineType)),s=t.filter((e=>"expense"===e.lineType)),c=e=>{l(e),o()};return 0===i.length&&0===s.length?null:a.createElement(o1e,{"data-external-id":"line-item-selector-popover"},a.createElement(i1e,null,i.length>0&&a.createElement(a.Fragment,null,a.createElement(s1e,null,"Part I: Income"),i.map((e=>a.createElement(pm.sR,{key:e.key,selected:e.key===n,onClick:()=>c(e.key)},"Line ",e.lineNumber,": ",e.description)))),s.length>0&&a.createElement(a.Fragment,null,i.length>0&&a.createElement(pm.oo,null),a.createElement(s1e,null,"Part II: Expenses"),s.map((e=>a.createElement(pm.sR,{key:e.key,selected:e.key===n,onClick:()=>c(e.key)},"Line ",e.lineNumber,": ",e.description)))),!!r&&a.createElement(a.Fragment,null,a.createElement(pm.oo,null),a.createElement(c1e,{onClick:()=>{null===r||void 0===r||r(),o()}},a.createElement(sl.ZQ,{name:"x",size:14}),"Remove from Schedule C"))))},o1e=(0,u.default)(Qi.j7).withConfig({displayName:"LineItemSelectorPopover__Root",componentId:"sc-1vllulj-0"})(["width:","px;overflow:hidden;"],360),i1e=u.default.div.withConfig({displayName:"LineItemSelectorPopover__ScrollArea",componentId:"sc-1vllulj-1"})(["max-height:","px;overflow-y:auto;padding:"," 0;"],480,vt.YK.xxsmall),s1e=u.default.div.withConfig({displayName:"LineItemSelectorPopover__SectionHeader",componentId:"sc-1vllulj-2"})(["padding:"," ",";margin:0 ",";color:",";font-size:",";font-weight:",";"],vt.YK.xsmall,vt.YK.default,vt.YK.xsmall,vt.Ee.color.content.secondary,vt.J.xsmall,vt.Wy.medium),c1e=(0,u.default)(pm.sR).attrs({type:"danger"}).withConfig({displayName:"LineItemSelectorPopover__UnmapOption",componentId:"sc-1vllulj-3"})(["gap:",";"],vt.YK.xsmall);var d1e=n(62230);const u1e="schedule_c",m1e=[{value:"schedule-c",label:"Schedule C"}],p1e=()=>(0,d1e.tz)().map((e=>({value:String(e),label:String(e)}))),g1e=[{value:"full",label:"Full tax year"},{label:"IRS tax quarters",options:[{value:"q1",label:"Q1"},{value:"q2",label:"Q2"},{value:"q3",label:"Q3"},{value:"q4",label:"Q4"}]}],h1e=new Set(["3","4","5"]),v1e={q1:{firstMonth:1,lastMonth:3},q2:{firstMonth:4,lastMonth:5},q3:{firstMonth:6,lastMonth:8},q4:{firstMonth:9,lastMonth:12}},f1e={firstMonth:1,lastMonth:12},E1e="yyyy-MM-dd",y1e=e=>e in v1e,b1e=(e,t)=>{const n=y1e(t)?v1e[t]:f1e,a=n.firstMonth,l=n.lastMonth;return{startDate:N.c9.fromObject({year:e,month:a}).toFormat(E1e),endDate:N.c9.fromObject({year:e,month:l}).endOf("month").toFormat(E1e)}},x1e=(e,t)=>y1e(t)?"".concat(t.toUpperCase()," ").concat(e):String(e),w1e=(e,t)=>{if(!y1e(t))return;const n=b1e(e,t),a=n.startDate,l=n.endDate;return"IRS ".concat(t.toUpperCase()," is ").concat((0,Ba.SR)(a),"\u2013").concat((0,Ba.SR)(l),".")},C1e=e=>e<0?"Net loss":"Net profit",A1e=e=>{const t=Math.abs(e);
1return"$".concat(t.toLocaleString("en-US",{minimumFractionDigits:0,maximumFractionDigits:0}))},I1e=Ee.kYz,k1e=Ee.ApE;var S1e,N1e;const T1e=u.default.div.attrs((0,Ex.p)("business-tax-prep-root")).withConfig({displayName:"shared__Root",componentId:"sc-1uil23-0"})(["padding:",";padding-top:0;padding-bottom:","px;display:flex;flex-direction:column;"],vt.YK.gutter,36),_1e=u.default.div.withConfig({displayName:"shared__TopCard",componentId:"sc-1uil23-1"})([""," background:",";border-radius:",";margin-bottom:",";"],wn.M.medium,vt.Ee.color.background.primary,vt.r8.medium,vt.YK.default),D1e=u.default.div.withConfig({displayName:"shared__TopCardTitleRow",componentId:"sc-1uil23-2"})(["display:flex;align-items:center;justify-content:space-between;padding:"," ",";border-bottom:1px solid ",";"],vt.YK.default,vt.YK.large,vt.Ee.color.divider.primary),R1e=(0,u.default)(xt.v).attrs({as:"div",size:"large",weight:"medium"}).withConfig({displayName:"shared__PageTitle",componentId:"sc-1uil23-3"})([""]),M1e=u.default.div.withConfig({displayName:"shared__FilterBar",componentId:"sc-1uil23-4"})(["display:flex;align-items:center;gap:",";"],vt.YK.xsmall),L1e=u.default.div.withConfig({displayName:"shared__SectionDivider",componentId:"sc-1uil23-5"})(["width:100%;height:0;border-bottom:1px solid ",";"],vt.Ee.color.divider.secondary),O1e=u.default.div.withConfig({displayName:"shared__SectionContent",componentId:"sc-1uil23-6"})(["padding:"," 0 ",";padding-left:calc("," + ",");> ",":last-child ","{border-bottom:none;}"],vt.YK.xxsmall,vt.YK.default,vt.YK.xxlarge,vt.YK.xsmall,(()=>n2e),(()=>a2e)),P1e=u.default.div.withConfig({displayName:"shared__HeaderSection",componentId:"sc-1uil23-7"})(["padding:"," ",";"],vt.YK.default,vt.YK.large),B1e=u.default.div.withConfig({displayName:"shared__HeaderTitle",componentId:"sc-1uil23-8"})(["font-size:",";line-height:","px;font-weight:",";color:",";margin-bottom:",";"],vt.J.xlarge,36,vt.Wy.medium,vt.Ee.color.content.primary,vt.YK.xsmall),z1e=u.default.span.withConfig({displayName:"shared__HeaderTitleYear",componentId:"sc-1uil23-9"})(["font-weight:",";color:",";"],350,vt.Ee.color.content.secondary),F1e=(0,u.default)(xt.v).attrs({as:"div",size:"base",weight:"medium"}).withConfig({displayName:"shared__FormSubtitle",componentId:"sc-1uil23-10"})(["margin-bottom:",";"],vt.YK.xxsmall),G1e=(0,u.default)(xt.v).attrs({as:"div",size:"small"}).withConfig({displayName:"shared__FormDescription",componentId:"sc-1uil23-11"})(["color:",";line-height:",";margin-bottom:",";max-width:800px;"],vt.Ee.color.content.primary,vt.YK.large,vt.YK.xsmall),Y1e=(0,u.default)(wb.gz).withConfig({displayName:"shared__FormLink",componentId:"sc-1uil23-12"})([""]),U1e=u.default.div.withConfig({displayName:"shared__ContentLayout",componentId:"sc-1uil23-13"})(["display:flex;gap:",";align-items:flex-start;"],vt.YK.default),V1e=u.default.div.withConfig({displayName:"shared__LeftSidebar",componentId:"sc-1uil23-14"})(["width:","px;flex-shrink:0;"," background:",";border-radius:",";padding:"," "," ",";position:sticky;top:",";"],320,wn.M.medium,vt.Ee.color.background.primary,vt.r8.medium,vt.YK.large,vt.YK.large,vt.YK.default,vt.YK.default),W1e=(0,u.default)(xt.v).attrs({as:"div",size:"large",weight:"bold"}).withConfig({displayName:"shared__SidebarStepTitle",componentId:"sc-1uil23-15"})(["margin-bottom:",";"],vt.YK.default),j1e=(0,u.default)(xt.v).attrs({as:"p",size:"small",color:"content.secondary"}).withConfig({displayName:"shared__SidebarDescription",componentId:"sc-1uil23-16"})(["line-height:1.5;margin:0;"]),H1e=(0,u.default)(xt.v).attrs({as:"div",size:"small",weight:"medium",color:"content.secondary"}).withConfig({displayName:"shared__JumpToLabel",componentId:"sc-1uil23-17"})(["margin-top:",";margin-bottom:",";"],vt.YK.xlarge,vt.YK.small),K1e=(0,u.default)(pm.sR).attrs({highlightOnHover:!1}).withConfig({displayName:"shared__JumpToItem",componentId:"sc-1uil23-18"})(["margin:"," 0;transition:background-color 0.1s ease;&:hover{background:",";}",""],vt.YK.xxsmall,vt.Ee.color.background.primaryHover,(e=>e.$active&&(0,u.css)(["background:",";"],vt.Ee.color.background.secondary))),q1e=u.default.div.withConfig({displayName:"shared__RightContent",componentId:"sc-1uil23-19"})(["flex:1;min-width:0;display:flex;flex-direction:column;"]),$1e=(0,u.default)(YDe).withConfig({displayName:"shared__StyledDismissibleBanner",componentId:"sc-1uil23-20"})(["margin:",";margin-bottom:0;max-width:calc(100% - 2 * ",");"],vt.YK.large,vt.YK.large),Z1e=(0,$d.s)(l.N_)(S1e||(S1e=(0,wc.A)(["\n  cursor-pointer font-medium text-content-warning underline transition-colors\n  hover:opacity-80\n"]))),J1e=u.default.div.withConfig({displayName:"shared__C
1ontrolsRow",componentId:"sc-1uil23-21"})(["display:flex;align-items:center;justify-content:space-between;padding:"," ",";"],vt.YK.default,vt.YK.large),X1e=u.default.div.withConfig({displayName:"shared__DataCard",componentId:"sc-1uil23-22"})([""," background:",";border-radius:",";overflow:hidden;"],wn.M.medium,vt.Ee.color.background.primary,vt.r8.medium),Q1e=u.default.div.withConfig({displayName:"shared__SectionRow",componentId:"sc-1uil23-23"})(["display:flex;align-items:center;justify-content:space-between;padding:"," ",";cursor:",";&:hover{background:",";}"],vt.YK.default,vt.YK.large,(e=>e.$clickable?"pointer":"default"),(e=>{let t=e.$clickable,n=e.theme;return t?n.variables.color.background.primaryHover:"transparent"})),e2e=u.default.div.withConfig({displayName:"shared__SectionRowLeft",componentId:"sc-1uil23-24"})(["display:flex;align-items:center;gap:",";min-width:0;"],vt.YK.xsmall),t2e=u.default.div.withConfig({displayName:"shared__LoadingContainer",componentId:"sc-1uil23-25"})(["display:flex;align-items:center;justify-content:center;padding:",";"],vt.YK.xxxlarge),n2e=u.default.div.withConfig({displayName:"shared__LineItemBlock",componentId:"sc-1uil23-26"})(["background:",";border-radius:",";overflow:hidden;margin:"," ",";"],vt.Ee.color.background.secondary,vt.r8.medium,vt.YK.xsmall,vt.YK.default),a2e=u.default.div.withConfig({displayName:"shared__LineItemHeader",componentId:"sc-1uil23-27"})(["display:flex;align-items:center;justify-content:space-between;padding:"," "," "," ",";border-bottom:1px solid ",";cursor:",";"],vt.YK.small,vt.YK.default,vt.YK.small,vt.YK.xsmall,vt.Ee.color.divider.secondary,(e=>e.onClick?"pointer":"default")),l2e=u.default.div.withConfig({displayName:"shared__LineItemHeaderLeft",componentId:"sc-1uil23-28"})(["display:flex;align-items:center;gap:",";"],vt.YK.xsmall),r2e=u.default.div.withConfig({displayName:"shared__CategoryRowsArea",componentId:"sc-1uil23-29"})(["display:flex;flex-direction:column;gap:",";padding:",";padding-left:",";"],vt.YK.small,vt.YK.default,vt.YK.xxxlarge),o2e=u.default.div.withConfig({displayName:"shared__CategoryRowContainer",componentId:"sc-1uil23-30"})(["background:",";border-radius:",";"," overflow:hidden;"],vt.Ee.color.background.primary,vt.r8.small,wn.M.small),i2e=u.default.div.withConfig({displayName:"shared__CategoryDragRow",componentId:"sc-1uil23-31"})(["display:flex;align-items:center;justify-content:space-between;padding:"," ",";cursor:",";&:hover{background:",";}"],vt.YK.xsmall,vt.YK.small,(e=>e.onClick?"pointer":"default"),(e=>e.onClick?vt.Ee.color.background.primaryHover:"transparent")),s2e=u.default.div.withConfig({displayName:"shared__CategoryDragRowLeft",componentId:"sc-1uil23-32"})(["display:flex;align-items:center;gap:",";"],vt.YK.xsmall),c2e=u.default.div.withConfig({displayName:"shared__CategoryContent",componentId:"sc-1uil23-33"})(["display:flex;align-items:center;gap:",";"],vt.YK.xsmall),d2e=u.default.div.withConfig({displayName:"shared__CategoryDragRowRight",componentId:"sc-1uil23-34"})(["display:flex;align-items:center;gap:",";"],vt.YK.default),u2e=u.default.div.withConfig({displayName:"shared__SwapIcon",componentId:"sc-1uil23-35"})(["width:",";height:",";display:flex;align-items:center;justify-content:center;border-radius:",";border:1px solid transparent;cursor:pointer;color:",";transform:rotate(90deg);transition:border-color 0.15s ease,box-shadow 0.15s ease;&:hover{border-color:",";box-shadow:0px 1px 2px ",";}"],vt.YK.xxlarge,vt.YK.xxlarge,vt.r8.small,vt.Ee.color.content.primary,vt.Ee.color.border.primary,vt.Ee.color.shadow.small),m2e=u.default.div.withConfig({displayName:"shared__ComputedLineHeader",componentId:"sc-1uil23-36"})(["display:flex;align-items:center;justify-content:space-between;padding:"," ",";padding-left:",";color:",";"],vt.YK.small,vt.YK.default,vt.YK.xxxlarge,vt.Ee.color.content.secondary),p2e=u.default.div.withConfig({displayName:"shared__NotTrackedLabel",componentId:"sc-1uil23-37"})(["display:flex;align-items:center;gap:",";color:",";font-size:",";"],vt.YK.xxsmall,vt.Ee.color.content.secondary,vt.J.small),g2e=(0,u.default)(xt.v).withConfig({displayName:"shared__SectionAmount",componentId:"sc-1uil23-38"})(["color:",";font-weight:",";"],(e=>e.$isPositive?vt.Ee.color.content.success:vt.Ee.color.content.primary),(e=>{let t=e.$isTotal,n=e.theme;return t?n.fontWeight.bold:n.fontWeight.book})),h2e=(0,$d.s)(xt.v)(N1e||(N1e=(0,wc.A)(["whitespace-nowrap"]))),v2e=u.default.span.withConfig({displayName:"shared__C
1ollapseAllLink",componentId:"sc-1uil23-39"})(["color:",";font-size:",";font-weight:",";cursor:pointer;margin-left:",";white-space:nowrap;&:hover{color:",";}"],vt.Ee.color.content.link,vt.J.small,vt.Wy.medium,vt.YK.default,vt.Ee.color.content.linkHover),f2e=u.default.span.withConfig({displayName:"shared__CategoryIcon",componentId:"sc-1uil23-40"})(["font-size:",";line-height:",";"],vt.J.base,vt.YK.xlarge),E2e=(0,u.default)(xt.v).attrs({as:"div",size:"small",color:"content.secondary"}).withConfig({displayName:"shared__FormNote",componentId:"sc-1uil23-41"})(["line-height:",";"],vt.YK.large),y2e=(0,u.default)(E2e).withConfig({displayName:"shared__TransactionsLinkNote",componentId:"sc-1uil23-42"})(["margin-top:",";"],vt.YK.xsmall),b2e=(0,u.default)(xt.v).attrs({size:"large",weight:"bold"}).withConfig({displayName:"shared__NetProfitLabel",componentId:"sc-1uil23-43"})(["padding-left:",";"],vt.YK.large),x2e=u.default.div.withConfig({displayName:"shared__TransactionListArea",componentId:"sc-1uil23-44"})(["display:flex;flex-direction:column;border-top:1px solid ",";"],vt.Ee.color.divider.primary),w2e=u.default.div.withConfig({displayName:"shared__UnmappedSectionRow",componentId:"sc-1uil23-45"})(["display:flex;align-items:center;gap:",";padding:"," ",";color:",";cursor:",";&:hover{background:",";}"],vt.YK.xsmall,vt.YK.default,vt.YK.large,vt.Ee.color.content.warning,(e=>e.$clickable?"pointer":"default"),(e=>{let t=e.$clickable,n=e.theme;return t?n.variables.color.background.primaryHover:"transparent"})),C2e=(0,u.default)(xt.v).attrs({size:"large",weight:"bold"}).withConfig({displayName:"shared__UnmappedSectionTitle",componentId:"sc-1uil23-46"})(["color:",";"],vt.Ee.color.content.warning),A2e=(0,u.default)(xt.v).attrs({size:"small"}).withConfig({displayName:"shared__UnmappedSectionDescription",componentId:"sc-1uil23-47"})(["color:",";display:block;padding:0 ",";margin-bottom:",";"],vt.Ee.color.content.primary,vt.YK.large,vt.YK.default),I2e=u.default.div.withConfig({displayName:"shared__UnmappedSectionBody",componentId:"sc-1uil23-48"})(["background:",";border-radius:",";margin:0 "," ",";padding:",";display:flex;flex-direction:column;gap:",";"],vt.Ee.color.background.warning,vt.r8.medium,vt.YK.default,vt.YK.default,vt.YK.default,vt.YK.small),k2e=u.default.button.withConfig({displayName:"shared__MoveToButton",componentId:"sc-1uil23-49"})(["display:flex;align-items:center;gap:",";padding:0 ",";height:","px;background:",";color:",";border:1px solid ",";border-radius:",";font-size:",";font-weight:",";cursor:pointer;white-space:nowrap;flex-shrink:0;"," &:hover{background:",";}"],vt.YK.xsmall,vt.YK.small,36,vt.Ee.color.background.primary,vt.Ee.color.content.primary,vt.Ee.color.divider.primary,vt.r8.small,vt.J.small,vt.Wy.medium,wn.M.small,vt.Ee.color.background.primaryHover),S2e=u.default.div.withConfig({displayName:"shared__ExportPageRoot",componentId:"sc-1uil23-50"})(["padding:",";padding-top:0;display:flex;flex-direction:column;"],vt.YK.gutter),N2e=u.default.div.withConfig({displayName:"shared__ExportBackBar",componentId:"sc-1uil23-51"})(["padding:"," "," "," ",";"],vt.YK.default,vt.YK.default,vt.YK.default,vt.YK.large),T2e=u.default.div.withConfig({displayName:"shared__ExportContentLayout",componentId:"sc-1uil23-52"})(["display:flex;gap:",";align-items:flex-start;>:first-child{flex:1;min-width:0;display:flex;flex-direction:column;gap:",";}"],vt.YK.default,vt.YK.small),_2e=u.default.div.withConfig({displayName:"shared__ExportPreviewCard",componentId:"sc-1uil23-53"})([""," background:",";border-radius:",";overflow:hidden;"],wn.M.medium,vt.Ee.color.background.primary,vt.r8.medium),D2e=u.default.div.withConfig({displayName:"shared__ExportSectionRow",componentId:"sc-1uil23-54"})(["display:flex;align-items:center;justify-content:space-between;padding:"," ",";"],vt.YK.default,vt.YK.large),R2e=u.default.div.withConfig({displayName:"shared__ExportLineItemRow",componentId:"sc-1uil23-55"})(["display:flex;align-items:center;justify-content:space-between;padding:"," ",";border:1px solid ",";border-radius:",";margin:0 "," ",";&:last-of-type{margin-bottom:0;}"],vt.YK.default,vt.YK.large,vt.Ee.color.divider.secondary,vt.r8.medium,vt.YK.large,vt.YK.small),M2e=u.default.span.withConfig({displayName:"shared__ExportLineItemRowLabel",componentId:"sc-1uil23-56"})(["font-size:",";font-weight:",";color:",";",""],vt.J.base,vt.Wy.medium,(e=>e.$secondary?vt.Ee.color.content.secondary:vt.Ee.color.content.primary),(e=>e.$secondary&&(0,u.css)(["font-weight:",";"],vt.Wy.book))),L2e=u.default.span.withConfig({displayName:"shared__ExportLineItemRowValue",componentId:"sc-1uil23-57"})(["font-size:",";font-weight:",";color:",";white-space:nowrap;"],vt.J.base,vt.Wy.medium,(e=>{let t=e.$secondary,n=e.$positive;return t?vt.Ee.color.content.secondary:n?vt.Ee.color.content.success:vt.Ee.color.content.primary})),O2e=u.default.span.withConfig({displayName:"shared__ExportNotTrackedLabel",componentId:"sc-1uil23-58"})(["display:inline-flex;align-items:center;gap:",";font-size:",";color:",";white-space:nowrap;"],vt.YK.xxsmall,vt.J.small,vt.Ee.color.content.secondary),P2e=u.default.div.withConfig({displayName:"shared__ExportSidebarCard",componentId:"sc-1uil23-59"})(["width:","px;flex-shrink:0;"," background:",";border-radius:",";padding:"," "," ",";position:sticky;top:",";display:flex;flex-direction:column;gap:",";"],280,wn.M.medium,vt.Ee.color.background.primary,vt.r8.medium,vt.YK.large,vt.YK.large,vt.YK.default,vt.YK.default,vt.YK.default),B2e=u.default.div.withConfig({displayName:"shared__ExportSidebarSection",componentId:"sc-1uil23-60"})(["display:flex;flex-direction:column;gap:",";"],vt.YK.xsmall),z2e=u.default.button.withConfig({displayName:"shared__ExportSidebarDownloadButton",componentId:"sc-1uil23-61"})(["display:flex;align-items:center;justify-content:center;width:100%;height:40px;background:",";color:",";border:none;border-radius:",";font-size:",";font-weight:",";cursor:pointer;&:disabled{background:",";cursor:default;}&:hover:not(:disabled){opacity:0.9;}"],vt.Ee.color.background.brand,vt.Ee.color.content.white,vt.r8.small,vt.J.base,vt.Wy.medium,vt.Ee.color.background.brandDisabled);var F2e;const G2e=e=>{var t,n;
1let l=e.category,r=e.startDate,s=e.endDate,c=e.selectedEntityId,d=e.allLineItems,u=e.taxYear;const m=(0,a.useState)(!1),g=(0,o.A)(m,2),h=g[0],v=g[1],f=(0,a.useState)(null),E=(0,o.A)(f,2),y=E[0],b=E[1],x=(0,C.RU)(),w=(0,i.n)(k1e,{refetchQueries:["Web_GetTaxScheduleCategoryMappings"],onCompleted:e=>{var t;const n=null===e||void 0===e||null===(t=e.assignTaxScheduleCategoryMapping)||void 0===t?void 0:t.errors;null!==n&&void 0!==n&&n.message&&x({description:n.message})},onError:()=>x()}),A=(0,o.A)(w,1)[0],k=(0,i.n)(I1e,{refetchQueries:["Web_GetTaxScheduleCategoryMappings"],onCompleted:e=>{var t;const n=null===e||void 0===e||null===(t=e.deleteTaxScheduleCategoryMapping)||void 0===t?void 0:t.errors;null!==n&&void 0!==n&&n.message&&x({description:n.message})},onError:()=>x()}),S=(0,o.A)(k,1)[0],N=(0,a.useCallback)((e=>{(0,Ge.u4)(Ye.TR.CategoryMapped,{was_unmapped:!1,category_name:l.name,target_line_item:e,form_type:u1e}),A({variables:{input:{categoryId:l.id,schedule:Ee.jE1.SCHEDULE_C,taxYear:u,lineItem:e}}})}),[A,l.id,u]),T=(0,a.useCallback)((()=>{S({variables:{input:{categoryId:l.id,schedule:Ee.jE1.SCHEDULE_C,taxYear:u}}})}),[S,l.id,u]),_=l.transactionCount>0,D=(0,a.useCallback)((()=>v((e=>!e))),[]),R=(0,et.I)(K2e,{variables:{filters:(0,U.A)({categories:[l.id],startDate:r,endDate:s},c?{businessEntitySet:{businessEntityIds:[c],includeUnassigned:!1}}:{}),orderBy:Ee.RPX.DATE,limit:5},skip:!h}),M=R.data,L=R.isLoadingInitialData,O=R.error,P=null!==(t=null===M||void 0===M||null===(n=M.allTransactions)||void 0===n?void 0:n.results)&&void 0!==t?t:[],z=l.transactionCount-5,F=I.JZ.transactions({queryParams:(0,U.A)({categories:[l.id],startDate:r,endDate:s},c?{businessEntitySet:[c]}:{})}),G=P.findIndex((e=>e.id===y)),Y=G>0?P[G-1].id:null,V=-1!==G&&G<P.length-1?P[G+1].id:null;return a.createElement(a.Fragment,null,a.createElement(o2e,null,a.createElement(i2e,{onClick:_?D:void 0},a.createElement(s2e,null,_?a.createElement(B.L,{icon:h?"chevron-down":"chevron-right",size:"xsmall",color:"content.secondary"}):a.createElement("div",{style:{width:32}}),a.createElement(c2e,null,a.createElement(f2e,null,l.icon),a.createElement(xt.v,{size:"base"},l.name),a.createElement(h2e,{size:"xsmall",color:"content.secondary"},l.transactionCount," ",1===l.transactionCount?"transaction":"transactions"))),a.createElement(d2e,null,a.createElement(xt.v,{size:"base",color:l.amount>0?"content.success":void 0},A1e(l.amount)),a.createElement(Qi.Az,{placement:"bottom-end",overlay:a.createElement(r1e,{lineItems:d,currentLineItemKey:l.currentLineItemKey,onSelect:N,onUnmap:T})},(e=>{let t=e.toggleOpen;return a.createElement(u2e,{onClick:e=>{e.stopPropagation(),t()}},a.createElement(sl.ZQ,{name:"arrow-left-right",size:16}))})))),a.createElement(fe.X0s,{open:h},a.createElement(fe.X0s.Content,null,a.createElement(x2e,null,L&&a.createElement(Y2e,null,a.createElement(p.i,null)),!!O&&a.createElement(SQ.W,{message:"Could not load transactions."}),!L&&!O&&P.map((e=>{var t,n,l,r;return a.createElement(U2e,{key:e.id,onClick:()=>b(e.id)},a.createElement(V2e,null,a.createElement(Wl._,{url:null!==(t=null===(n=e.merchant)||void 0===n?void 0:n.logoUrl)&&void 0!==t?t:null,size:28}
1),a.createElement(xt.v,{size:"small",clampLines:1},null!==(l=null===(r=e.merchant)||void 0===r?void 0:r.name)&&void 0!==l?l:"Unknown")),a.createElement(W2e,null,a.createElement(j2e,{size:"base",$positive:e.amount>=0},(0,rl.vv)(Math.abs(e.amount))),a.createElement(B.L,{icon:"chevron-right",size:"xsmall",color:"content.primary"})))})),!L&&!O&&z>0&&a.createElement(H2e,{to:F},"See ",z," more ",1===z?"transaction":"transactions"))))),!!y&&a.createElement(po.K,null,a.createElement(go.TT,{id:y,previousTransactionId:Y,nextTransactionId:V,setId:b,onClose:()=>b(null)})))},Y2e=u.default.div.withConfig({displayName:"CategoryRow__LoadingRow",componentId:"sc-1coeqft-0"})(["display:flex;justify-content:center;padding:",";"],vt.YK.default),U2e=u.default.div.withConfig({displayName:"CategoryRow__TransactionRow",componentId:"sc-1coeqft-1"})(["display:flex;align-items:center;justify-content:space-between;height:","px;padding:0 ",";cursor:pointer;& + &{border-top:1px solid ",";}&:hover{background:",";}"],50,vt.YK.xxxlarge,vt.Ee.color.divider.primary,vt.Ee.color.background.primaryHover),V2e=u.default.div.withConfig({displayName:"CategoryRow__TransactionInfo",componentId:"sc-1coeqft-2"})(["display:flex;align-items:center;gap:",";flex:1;min-width:0;"],vt.YK.xsmall),W2e=u.default.div.withConfig({displayName:"CategoryRow__TransactionRightSide",componentId:"sc-1coeqft-3"})(["display:flex;align-items:center;gap:",";flex-shrink:0;"],vt.YK.small),j2e=(0,u.default)(xt.v).withConfig({displayName:"CategoryRow__TransactionAmount",componentId:"sc-1coeqft-4"})(["color:",";white-space:nowrap;"],(e=>e.$positive?vt.Ee.color.content.success:vt.Ee.color.content.primary)),H2e=(0,$d.s)(l.N_)(F2e||(F2e=(0,wc.A)(["\n  flex cursor-pointer items-center border-t border-divider-primary py-sm pr-default pl-3xl\n  text-sm leading-[inherit] font-medium text-content-link no-underline transition-colors\n  visited:text-content-link\n  hover:bg-background-primary-hover hover:text-content-link-hover\n"]))),K2e=Ee.m_0,q2e=e=>{let t=e.line,n=e.isExpanded,l=e.onToggle,r=e.startDate,o=e.endDate,i=e.selectedEntityId,s=e.allLineItems,c=e.taxYear;const d=t.categories.length>0;return a.createElement(n2e,{"data-external-id":"line-item-row"},a.createElement(a2e,{onClick:d?l:void 0},a.createElement(l2e,null,d?a.createElement(B.L,{icon:n?"chevron-down":"chevron-right",size:"xsmall",color:"content.secondary"}):a.createElement("div",{style:{width:32}}),a.createElement(xt.v,{size:"base",weight:"medium"},"Line ",t.lineNumber,": ",t.description),t.displayInfo&&a.createElement(fe.cIj,{size:"3xs",content:t.displayInfo,iconSize:"sm"})),a.createElement(xt.v,{size:"base",weight:"medium",color:t.amount>0?"content.success":void 0},A1e(t.amount))),a.createElement(fe.X0s,{open:n&&d},a.createElement(fe.X0s.Content,null,a.createElement(r2e,null,t.categories.map((e=>a.createElement(G2e,{key:e.id,category:e,startDate:r,endDate:o,selectedEntityId:i,allLineItems:s,taxYear:c})))))))};var $2e;const Z2e=e=>{var t,n;let l=e.category,r=e.startDate,s=e.endDate,c=e.selectedEntityId,d=e.allLineItems,u=e.taxYear;const m=(0,a.useState)(!1),g=(0,o.A)(m,2),h=g[0],v=g[1],f=(0,a.useState)(null),E=(0,o.A)(f,2),y=E[0],b=E[1],x=(0,C.RU)(),w=(0,i.n)(k1e,{refetchQueries:["Web_GetTaxScheduleCategoryMappings"],onCompleted:e=>{var t;const n=null===e||void 0===e||null===(t=e.assignTaxScheduleCategoryMapping)||void 0===t?void 0:t.errors;null!==n&&void 0!==n&&n.message&&x({description:n.message})},onError:()=>x()}),A=(0,o.A)(w,1)[0],k=(0,a.useCallback)((e=>{(0,Ge.u4)(Ye.TR.CategoryMapped,{was_unmapped:!0,category_name:l.name,target_line_item:e,form_type:u1e}),A({variables:{input:{categoryId:l.id,schedule:Ee.jE1.SCHEDULE_C,taxYear:u,lineItem:e}}})}),[A,l.id,u]),S=l.transactionCount>0,N=(0,a.useCallback)((()=>v((e=>!e))),[]),T=(0,et.I)(l4e,{variables:{filters:(0,U.A)({categories:[l.id],startDate:r,endDate:s},c?{businessEntitySet:{businessEntityIds:[c],includeUnassigned:!1}}:{}),orderBy:Ee.RPX.DATE,limit:5},skip:!h}),_=T.data,D=T.isLoadingInitialData,R=T.error,M=null!==(t=null===_||void 0===_||null===(n=_.allTransactions)||void 0===n?void 0:n.results)&&void 0!==t?t:[],L=l.transactionCount-5,O=I.JZ.transactions({queryParams:(0,U.A)({categories:[l.id],startDate:r,endDate:s},c?{businessEntitySet:[c]}:{})}),P=M.findIndex((e=>e.id===y)),z=P>0?M[P-1].id:null,F=-1!==P&&P<M.length-1?M[P+1].id:null;return a.createElement(a.Fragment,null,a.createElement(o2e,null,a.createElement(i2e,{onClick:S?N:void 0},a.createElement(s2e,null,S?a.createElement(B.L,{icon:h?"chevron-down":"chevron-right",size:"xsmall",color:"content.secondary"}):a.createElement("div",{style:{width:32}}),a.createElement(c2e,null,a.createElement(f2e,null,l.icon),a.createElement(xt.v,{size:"base"},l.name),a.createElement(h2e,{size:"xsmall",color:"content.secondary"},l.transactionCount," ",1===l.transactionCount?"transaction":"transactions"))),a.createElement(d2e,null,a.createElement(xt.v,{size:"base",color:l.amount>0?"content.success":void 0},A1e(l.amount)),a.createElement(Qi.Az,{placement:"bottom-end",overlay:a.createElement(r1e,{lineItems:d,currentLineItemKey:"",onSelect:k})},(e=>{let t=e.toggleOpen;return a.createElement(k2e,{onClick:e=>{e.stopPropagation(),t()}},a.createElement(J2e,null,a.createElement(sl.ZQ,{name:"arrow-left-right",size:12})),"Move to...")})))),a.createElement(fe.X0s,{open:h},a.createElement(fe.X0s.Content,null,a.createElement(x2e,null,D&&a.createElement(X2e,null,a.createElement(p.i,null)),!!R&&a.createElement(SQ.W,{message:"Could not load transactions."}),!D&&!R&&M.map((e=>{var t,n,l,r;return a.createElement(Q2e,{key:e.id,onClick:()=>b(e.id)},a.createElement(e4e,null,a.createElement(Wl._,{url:null!==(t=null===(n=e.merchant)||void 0===n?void 0:n.logoUrl)&&void 0!==t?t:null,size:28}
1),a.createElement(xt.v,{size:"small",clampLines:1},null!==(l=null===(r=e.merchant)||void 0===r?void 0:r.name)&&void 0!==l?l:"Unknown")),a.createElement(t4e,null,a.createElement(n4e,{size:"base",$positive:e.amount>=0},(0,rl.vv)(Math.abs(e.amount))),a.createElement(B.L,{icon:"chevron-right",size:"xsmall",color:"content.primary"})))})),!D&&!R&&L>0&&a.createElement(a4e,{to:O},"See ",L," more ",1===L?"transaction":"transactions"))))),!!y&&a.createElement(po.K,null,a.createElement(go.TT,{id:y,previousTransactionId:z,nextTransactionId:F,setId:b,onClose:()=>b(null)})))},J2e=u.default.span.withConfig({displayName:"UnmappedCategoryRow__MoveToIcon",componentId:"j70iux-0"})(["display:flex;align-items:center;transform:rotate(90deg);"]),X2e=u.default.div.withConfig({displayName:"UnmappedCategoryRow__LoadingRow",componentId:"j70iux-1"})(["display:flex;justify-content:center;padding:",";"],vt.YK.default),Q2e=u.default.div.withConfig({displayName:"UnmappedCategoryRow__TransactionRow",componentId:"j70iux-2"})(["display:flex;align-items:center;justify-content:space-between;height:","px;padding:0 ",";cursor:pointer;& + &{border-top:1px solid ",";}&:hover{background:",";}"],50,vt.YK.xxxlarge,vt.Ee.color.divider.primary,vt.Ee.color.background.primaryHover),e4e=u.default.div.withConfig({displayName:"UnmappedCategoryRow__TransactionInfo",componentId:"j70iux-3"})(["display:flex;align-items:center;gap:",";flex:1;min-width:0;"],vt.YK.xsmall),t4e=u.default.div.withConfig({displayName:"UnmappedCategoryRow__TransactionRightSide",componentId:"j70iux-4"})(["display:flex;align-items:center;gap:",";flex-shrink:0;"],vt.YK.small),n4e=(0,u.default)(xt.v).withConfig({displayName:"UnmappedCategoryRow__TransactionAmount",componentId:"j70iux-5"})(["color:",";white-space:nowrap;"],(e=>e.$positive?vt.Ee.color.content.success:vt.Ee.color.content.primary)),a4e=(0,$d.s)(l.N_)($2e||($2e=(0,wc.A)(["\n  flex cursor-pointer items-center border-t border-divider-primary py-sm pr-default pl-3xl\n  text-sm leading-[inherit] font-medium text-content-link no-underline transition-colors\n  visited:text-content-link\n  hover:bg-background-primary-hover hover:text-content-link-hover\n"]))),l4e=Ee.GGD,r4e=Ee.ZF5,o4e=Ee.v1Q,i4e=Ee.TP5,s4e=Ee.DM9,c4e=Ee.sLi,d4e=Ee.THF,u4e=Ee.z5z,m4e=e=>{let t=e.taxYear,n=e.period,l=e.selectedEntityId,r=e.showAllCategories,o=void 0!==r&&r;const i=(0,et.I)(s4e,{variables:{taxYear:t}}),s=i.data,c=i.isLoadingInitialData,d=(0,et.I)(c4e,{variables:{schedule:Ee.jE1.SCHEDULE_C,taxYear:t}}),u=d.data,m=d.isLoadingInitialData,p=b1e(t,n),g=(0,et.I)(o4e,{variables:{filters:(0,U.A)((0,U.A)({},p),l?{businessEntitySet:{businessEntityIds:[l],includeUnassigned:!1}}:{})}}),h=g.data,v=g.isLoadingInitialData,f=(0,a.useMemo)((()=>{var e;return(null!==(e=null===h||void 0===h?void 0:h.aggregates)&&void 0!==e?e:[]).reduce(((e,t)=>{var n;const a=null===(n=t.groupBy.category)||void 0===n?void 0:n.id;return a&&(e[a]={sum:t.summary.sum,count:t.summary.count}),e}),{})}),[h]),E=(0,a.useMemo)((()=>{var e;return(null!==(e=null===u||void 0===u?void 0:u.taxScheduleCategoryMappings)&&void 0!==e?e:[]).filter((e=>e.category)).map((e=>e.category.id))}),[u]),y=(0,a.useMemo)((()=>{var e,t;const n=null!==(e=null===s||void 0===s?void 0:s.scheduleCLineItems)&&void 0!==e?e:[],a=null!==(t=null===u||void 0===u?void 0:u.taxScheduleCategoryMappings)&&void 0!==t?t:[],l=(0,LD.A)((e=>{var t,n;return null!==(t=null===(n=e.lineItemInfo)||void 0===n?void 0:n.key)&&void 0!==t?t:e.lineItem}),a),r=e=>{const t=n.filter((t=>t.lineType===e&&!t.isNotTracked));return(0,Nc.A)((e=>e.sortOrder),t).map((e=>{var t;const n=(null!==(t=l[e.key])&&void 0!==t?t:[]).filter((e=>e.category&&(o||void 0!==f[e.category.id]))).map((t=>{var n,a;const l=f[t.category.id];return{id:t.category.id,name:t.category.name,icon:t.category.icon,amount:null!==(n=null===l||void 0===l?void 0:l.sum)&&void 0!==n?n:0,transactionCount:null!==(a=null===l||void 0===l?void 0:l.count)&&void 0!==a?a:0,currentLineItemKey:e.key}})).sort(((e,t)=>e.name.localeCompare(t.name)));return{key:e.key,lineNumber:e.lineNumber,description:e.description,sortOrder:e.sortOrder,amount:(0,De.Eb)(n.map((e=>e.amount))),categories:n,displayInfo:e.displayInfo}}))};return{incomeLines:r("income"),expenseLines:r("expense"),notTrackedExpenseLines:n.filter((e=>"expense"===e.lineType&&e.isNotTracked))}}),[s,u,f,o]),b=y.incomeLines,x=y.expenseLines,w=y.notTrackedExpenseLines,C=(0,a.useMemo)((()=>{var e,t;const n=b.reduce(((e,t)=>(e[t.lineNumber]=t.amount,e)),{}),a=b.reduce(((e,t)=>(h1e.has(t.lineNumber)||(parseInt(t.lineNumber,10)<3?e.early.push(t):e.late.push(t)),e)),{early:[],late:[]}),l=a.early,r=a.late,o=(null!==(e=n[1])&&void 0!==e?e:0)+(null!==(t=n[2])&&void 0!==t?t:0);return{earlyIncomeLines:l,lateIncomeLines:r,computedIncomeAmounts:{line3:o,line5:o}}}),[b]),A=C.earlyIncomeLines,I=C.lateIncomeLines,k=C.computedIncomeAmounts,S=(0,a.useMemo)((()=>(0,De.Eb)([k.line5,...I.map((e=>e.amount))])),[k,I]),N=(0,a.useMemo)((()=>(0,De.Eb)(x.map((e=>e.amount)))),[x]),T=(0,a.useMemo)((()=>{const e=[...x.map((e=>({type:"tracked",line:e,sortKey:e.sortOrder}))),...w.map((e=>({type:"not-tracked",lineNumber:e.lineNumber,description:e.description,sortKey:e.sortOrder,displayInfo:e.displayInfo})))];return(0,Nc.A)((e=>e.sortKey),e)}),[x,w]);return{lineItemsData:s,aggregatesData:h,categoryAmounts:f,mappedCategoryIds:E,incomeLines:b,expenseLines:x,notTrackedExpenseLines:w,earlyIncomeLines:A,lateIncomeLines:I,computedIncomeAmounts:k,incomeTotal:S,expenseTotal:N,allExpenseRows:T,dateRangeFilters:p,isLoading:c||m||v}};var p4e=n(24802),g4e=n(53621);const h4e="uncategorized",v4e=()=>{var e,t,n,r,s;const c=(0,l.Zp)(),d=(0,p4e.h)({includeNoneOption:!1}).options,u=(0,a.useMemo)((()=>(0,l1e.g)(d,{noneLabel:_j.Jd})),[d]),m=(0,pG.w)(),h=(0,g4e.g)([ZJe.He]),v=(0,o.A)(h,1)[0],f=v.entityId,E=v.taxYear,y=v.period,b=v.showAllCategories,x=null!==E&&void 0!==E?E:(0,d1e.Ow)(),w=p1e(),C=(0,a.useRef)(null),A=(0,a.useRef)(null),k=(0,a.useRef)(null),S=(0,a.useRef)(null),N=(0,a.useCallback)((e=>{var t;null===(t=e.current)||void 0===t||t.scrollIntoView({behavior:"smooth",block:"start"})}),[]),T=(0,a.useState)((()=>{var e;return!JSON.parse(null!==(e=localStorage.getItem("tax-prep-banner-dismissed-years"))&&void 0!==e?e:"[]").includes((0,d1e.Ow)())})),_=(0,o.A)(T,2),D=_[0],R=_[1],M=(0,a.useState)(!0),L=(0,o.A)(M,2),O=L[0],P=L[1],z=(0,a.useState)(!0),F=(0,o.A)(z,2),G=F[0],Y=F[1],V=(0,a.useState)(!0),W=(0,o.A)(V,2),j=W[0],H=W[1],K=(0,a.useCallback)((()=>{var e;R(!1);const t=JSON.parse(null!==(e=localStorage.getItem("tax-prep-banner-dismissed-years"))&&void 0!==e?e:"[]");localStorage.setItem("tax-prep-banner-dismissed-years",JSON.stringify([...new Set([...t,x])]))}),[x]),q=(0,a.useState)(new Set),$=(0,o.A)(q,2),Z=$[0],J=$[1];(0,a.useEffect)((()=>{(0,Ge.u4)(Ye.TR.ReviewPageViewed,{tax_year:x,period:y,form_type:u1e})}),[]),(0,a.useEffect)((()=>{var e;const t=JSON.parse(null!==(e=localStorage.getItem("tax-prep-banner-dismissed-years"))&&void 0!==e?e:"[]");R(!t.includes(x))}),[x]),(0,a.useEffect)((()=>{J(new Set)}),[x,y]),(0,a.useEffect)((()=>{var e;!d.some((e=>e.value===f))&&null!==(e=d[0])&&void 0!==e&&e.value&&m((0,g.D8)({entityId:d[0].value}))}),[f,d,m]);const X=(0,a.useCallback)((e=>{J((t=>t.has(e)?new Set([...t].filter((t=>t!==e))):new Set([...t,e])))}),[]),Q=(0,i.n)(i4e),ee=(0,o.A)(Q,2),te=ee[0],ne=ee[1].loading;(0,a.useEffect)((()=>{te({variables:{input:{taxYear:x}},refetchQueries:[{query:c4e,variables:{schedule:Ee.jE1.SCHEDULE_C,taxYear:x}}]})}),[te,x]);const ae=(0,et.I)(r4e,{skip:!b}).data,le=m4e({taxYear:x,period:y,selectedEntityId:f,showAllCategories:b}),re=le.lineItemsData,oe=le.aggregatesData,ie=le.categoryAmounts,se=le.mappedCategoryIds,ce=le.earlyIncomeLines,de=le.lateIncomeLines,ue=le.computedIncomeAmounts,me=le.expenseLines,pe=le.allExpenseRows,ge=le.incomeTotal,he=le.expenseTotal,ve=le.dateRangeFilters,ye=le.isLoading,be=ve.startDate,xe=ve.endDate,we=ge+he,Ce=C1e(we),Ae=null!==(e=null===(t=d.find((e=>e.value===f)))||void 0===t?void 0:t.label)&&void 0!==e?e:"Schedule C",Ie=w1e(x,y),ke=(0,a.useMemo)((()=>{var e;return(null!==(e=null===oe||void 0===oe?void 0:oe.aggregates)&&void 0!==e?e:[]).reduce(((e,t)=>{var n;return e+(null!==(n=t.summary.count)&&void 0!==n?n:0)}),0)}),[oe]),Se=(0,a.useMemo)((()=>null===oe||void 0===oe?void 0:oe.aggregates.find((e=>{var t;return(null===(t=e.groupBy.category)||void 0===t?void 0:t.systemCategory)===h4e}))),[oe]),Ne=null===Se||void 0===Se||null===(n=Se.groupBy.category)||void 0===n?void 0:n.id,Te=null!==(r=null===Se||void 0===Se?void 0:Se.summary.count)&&void 0!==r?r:0,_e=(0,a.useMemo)((()=>{var e;const t=new Set(se);var n;return b?(null!==(n=null===ae||void 0===ae?void 0:ae.categories)&&void 0!==n?n:[]).filter((e=>
1!t.has(e.id)&&e.systemCategory!==h4e)).map((e=>{var t,n,a,l;return{id:e.id,name:e.name,icon:e.icon,amount:null!==(t=null===(n=ie[e.id])||void 0===n?void 0:n.sum)&&void 0!==t?t:0,transactionCount:null!==(a=null===(l=ie[e.id])||void 0===l?void 0:l.count)&&void 0!==a?a:0}})).sort(((e,t)=>e.name.localeCompare(t.name))):(null!==(e=null===oe||void 0===oe?void 0:oe.aggregates)&&void 0!==e?e:[]).filter((e=>e.groupBy.category&&!t.has(e.groupBy.category.id)&&e.groupBy.category.systemCategory!==h4e)).map((e=>({id:e.groupBy.category.id,name:e.groupBy.category.name,icon:e.groupBy.category.icon,amount:e.summary.sum,transactionCount:e.summary.count}))).sort(((e,t)=>e.name.localeCompare(t.name)))}),[oe,ae,se,ie,b]),Re=ne||ye;return a.createElement(T1e,{"data-external-id":"tax-forms"},a.createElement(_1e,null,a.createElement(D1e,null,a.createElement("div",{className:"flex items-center gap-sm"},a.createElement(R1e,null,"Business tax prep"),a.createElement($G,null)),a.createElement(M1e,null,a.createElement(fe.hGA,{classNames:{trigger:"w-[225px]"},options:u,value:null!==f&&void 0!==f?f:null,onValueChange:e=>{m((0,g.D8)({entityId:null!==e&&void 0!==e?e:void 0})),(0,Ge.u4)(Ye.TR.FilterChanged,{filter_type:"entity",has_entity:!!e,form_type:u1e})},placeholder:"Select business"}),a.createElement(fe.hGA,{classNames:{trigger:"w-[140px]"},placeholder:fe.L2e,options:m1e,value:m1e[0].value,onValueChange:()=>{}}),a.createElement(fe.hGA,{classNames:{trigger:"w-[140px]"},placeholder:fe.L2e,options:w,value:String(x),onValueChange:e=>{const t=e?Number(e):(0,d1e.Ow)();m((0,g.D8)({taxYear:t})),(0,Ge.u4)(Ye.TR.FilterChanged,{filter_type:"year",tax_year:t,form_type:u1e})}}),a.createElement(fe.hGA,{placeholder:fe.L2e,options:g1e,value:y,onValueChange:e=>{const t=null!==e&&void 0!==e?e:"full";m((0,g.D8)({period:t})),(0,Ge.u4)(Ye.TR.FilterChanged,{filter_type:"period",period:t,form_type:u1e})},classNames:{trigger:"w-[140px]",content:"min-w-[184px]"}}))),a.createElement(P1e,null,a.createElement("div",{className:"mb-xs flex items-center justify-between"},a.createElement("div",{className:"flex items-center gap-xs"},a.createElement(B1e,{className:"mb-0"},Ae," ",a.createElement(z1e,null,x1e(x,y))),Ie&&a.createElement(fe.cIj,{"aria-label":Ie,size:"3xs",iconSize:"md",triggerClassName:"text-content-secondary",content:Ie})),a.createElement(wt.Xb,{onClick:()=>window.open(VF.Yq,"_blank","noopener,noreferrer")},a.createElement(Yo.r,{name:"play"}),a.createElement("span",null,"Watch walkthrough"))),a.createElement(F1e,null,"Schedule C Prep Sheet"),a.createElement(G1e,null,"This report is for informational purposes only. Use of this report is acknowledgement that nothing herein is to be construed as tax advice; Monarch is not a tax advisor. Consult a licensed tax professional for any advice or support in filing your taxes."),a.createElement(E2e,null,"See Part I and Part II (Lines 1\u201332) of"," ",a.createElement(Y1e,{href:"https://www.irs.gov/forms-pubs/about-schedule-c-form-1040",target:"_blank",rel:"noopener noreferrer"},"IRS Form 1040, Schedule C"),"."),f&&ke>0&&a.createElement(y2e,null,a.createElement(Vl.W,{to:I.JZ.transactions({queryParams:{businessEntitySet:[f],startDate:be,endDate:xe}})},a.createElement(xt.v,{size:"small",weight:"bold"},"See all ",ke," ",(0,De.td)("transaction",ke)),a.createElement(fe.hPJ,{size:"sm"}))))),a.createElement(U1e,null,a.createElement(V1e,null,a.createElement(W1e,null,"Organize categories"),a.createElement(j1e,null,"Arrange your Monarch transaction categories into IRS sections and lines. These mappings will apply to all businesses."),a.createElement(H1e,null,"Jump to..."),a.createElement("div",null,_e.length>0&&a.createElement(K1e,{onClick:()=>{P(!0),N(C)}},"Unmapped categories"),a.createElement(K1e,{onClick:()=>N(A)},"Part I: Income"),a.createElement(K1e,{onClick:()=>N(k)},"Part II: Expenses"),a.createElement(K1e,{onClick:()=>N(S)},Ce))),a.createElement(q1e,null,a.createElement(X1e,null,a.createElement($1e,{type:"info",dismissed:!D,onDismiss:()=>{K(),(0,Ge.u4)(Ye.TR.BannerDismissed,{tax_year:x,form_type:u1e})}},"We've automatically mapped any category with a business transaction to the most appropriate Schedule C lines. Click on \u201cMove to\u201d on the right of each row to reorganize categories as needed. You can also adjust the transactions' category assignments."),a.createElement(J1e,null,a.createElement("div",{className:"flex items-center gap-sm"},a.createElement(ox.k,{checked:b,onChange:e=>{m((0,g.D8)({showAllCategories:e.target.checked})),(0,Ge.u4)(Ye.TR.ShowAllCategoriesToggled,{enabled:e.target.checked,form_type:u1e})}}),a.createElement(xt.v,{size:"small"},"Include categories without business transactions")),a.createElement(cu.WT,{size:"small",style:{gap:8},onClick:()=>{(0,Ge.u4)(Ye.TR.ExportPreviewClicked,{tax_year:x,period:y,form_type:u1e}),c(I.JZ.reports.taxForms.export())}},"Preview export",a.createElement(fe.Fug,{size:"sm"}))),Re?a.createElement(t2e,null,a.createElement(p.i,null)):a.createElement(a.Fragment,null,Te>0&&!!f&&a.createElement(w2e,null,a.createElement(fe.WU2,{size:"md"}),a.createElement(C2e,null,"You have ",Te," uncategorized"," ",1===Te?"transaction":"transactions"," tied to a business entity."," ",a.createElement(Z1e,{to:I.JZ.transactions({queryParams:(0,U.A)((0,U.A)({},Ne?{categories:[Ne]}:{}),{}
1,{startDate:be,endDate:xe,businessEntitySet:[f]})})},"Click here to recategorize ",1===Te?"it":"them","."))),_e.length>0&&a.createElement(a.Fragment,null,a.createElement(L1e,null),a.createElement(w2e,{$clickable:!0,ref:C,onClick:()=>P((e=>!e))},a.createElement(B.L,{icon:O?"chevron-down":"chevron-right",size:"xsmall",color:"content.primary"}),a.createElement(fe.WU2,{size:"md"}),a.createElement(C2e,null,"Unmapped categories")),a.createElement(fe.X0s,{open:O},a.createElement(fe.X0s.Content,null,a.createElement(O1e,{style:{paddingTop:16}},a.createElement(A2e,null,"Any categories that remain unmapped will not appear in your export summary."),a.createElement(I2e,null,_e.map((e=>{var t;return a.createElement(Z2e,{key:e.id,category:e,startDate:be,endDate:xe,selectedEntityId:f,allLineItems:(null!==(t=null===re||void 0===re?void 0:re.scheduleCLineItems)&&void 0!==t?t:[]).filter((e=>!e.isNotTracked)),taxYear:x})}))))))),a.createElement(L1e,null),a.createElement(Q1e,{$clickable:!0,ref:A,onClick:()=>Y((e=>!e))},a.createElement(e2e,null,a.createElement(B.L,{icon:G?"chevron-down":"chevron-right",size:"xsmall",color:"content.secondary"}),a.createElement(xt.v,{size:"large",weight:"bold"},"Part I: Income"),G&&a.createElement(v2e,{onClick:e=>{e.stopPropagation();const t=[...ce,...de].map((e=>e.key)),n=t.every((e=>Z.has(e)));J((e=>{const a=new Set(t);return n?new Set([...e].filter((e=>!a.has(e)))):new Set([...e,...t])}))}},[...ce,...de].every((e=>Z.has(e.key)))?"Collapse all":"Expand all")),a.createElement(g2e,{size:"large",$isTotal:!0,$isPositive:ge>0},A1e(ge))),a.createElement(fe.X0s,{open:G},a.createElement(fe.X0s.Content,null,a.createElement(O1e,null,ce.map((e=>{var t;return a.createElement(q2e,{key:e.key,line:e,isExpanded:Z.has(e.key),onToggle:()=>X(e.key),startDate:be,endDate:xe,selectedEntityId:f,allLineItems:(null!==(t=null===re||void 0===re?void 0:re.scheduleCLineItems)&&void 0!==t?t:[]).filter((e=>!e.isNotTracked)),taxYear:x})})),a.createElement(n2e,null,a.createElement(m2e,null,a.createElement(xt.v,{size:"base",color:"content.secondary"},"Line 3: Subtract line 2 from line 1"),a.createElement(xt.v,{size:"base",color:"content.secondary"},A1e(ue.line3)))),a.createElement(n2e,null,a.createElement(m2e,null,a.createElement(xt.v,{size:"base",color:"content.secondary"},"Line 4: Cost of goods sold"),a.createElement(p2e,null,null!==re&&void 0!==re&&null!==(s=re.scheduleCLineItems.find((e=>"4"===e.lineNumber)))&&void 0!==s&&s.displayInfo?a.createElement(fe.cIj,{size:"3xs",content:re.scheduleCLineItems.find((e=>"4"===e.lineNumber)).displayInfo,iconSize:"sm",label:"Not tracked"}):"Not tracked"))),a.createElement(n2e,null,a.createElement(m2e,null,a.createElement(xt.v,{size:"base",color:"content.secondary"},"Line 5: Gross profit (subtract line 4 from line 3)"),a.createElement(xt.v,{size:"base",color:"content.secondary"},A1e(ue.line5)))),de.map((e=>{var t;return a.createElement(q2e,{key:e.key,line:e,isExpanded:Z.has(e.key),onToggle:()=>X(e.key),startDate:be,endDate:xe,selectedEntityId:f,allLineItems:(null!==(t=null===re||void 0===re?void 0:re.scheduleCLineItems)&&void 0!==t?t:[]).filter((e=>!e.isNotTracked)),taxYear:x})}))))),a.createElement(L1e,null),a.createElement(Q1e,{$clickable:!0,ref:k,onClick:()=>H((e=>!e))},a.createElement(e2e,null,a.createElement(B.L,{icon:j?"chevron-down":"chevron-right",size:"xsmall",color:"content.secondary"}),a.createElement(xt.v,{size:"large",weight:"bold"},"Part II: Expenses"),j&&a.createElement(v2e,{onClick:e=>{e.stopPropagation();const t=me.map((e=>e.key)),n=t.every((e=>Z.has(e)));J((e=>{const a=new Set(t);return n?new Set([...e].filter((e=>!a.has(e)))):new Set([...e,...t])}))}},me.every((e=>Z.has(e.key)))?"Collapse all":"Expand all")),a.createElement(g2e,{size:"large",$isTotal:!0,$isPositive:he>0},A1e(he))),a.createElement(fe.X0s,{open:j},a.createElement(fe.X0s.Content,null,a.createElement(O1e,null,pe.map((e=>{var t;return"not-tracked"===e.type?a.createElement(n2e,{key:"not-tracked-".concat(e.lineNumber)},a.createElement(m2e,null,a.createElement(xt.v,{size:"base",color:"content.secondary"},"Line ",e.lineNumber,": ",e.description),a.createElement(p2e,null,e.displayInfo?a.createElement(fe.cIj,{size:"3xs",content:e.displayInfo,iconSize:"sm",label:"Not tracked"}):"Not tracked"))):a.createElement(q2e,{key:e.line.key,line:e.line,isExpanded:Z.has(e.line.key),onToggle:()=>
1X(e.line.key),startDate:be,endDate:xe,selectedEntityId:f,allLineItems:(null!==(t=null===re||void 0===re?void 0:re.scheduleCLineItems)&&void 0!==t?t:[]).filter((e=>!e.isNotTracked)),taxYear:x})}))))),a.createElement(L1e,null),a.createElement(Q1e,{ref:S},a.createElement(e2e,null,a.createElement(b2e,null,Ce)),a.createElement(g2e,{size:"large",$isTotal:!0,$isPositive:we>0},A1e(we))))))))},f4e=iC.K5;var E4e;const y4e=[{value:"csv",label:"CSV"},{value:"pdf",label:"PDF"}],b4e=()=>{var e,t;const n=(0,l.Zp)(),r=(0,p4e.h)({includeNoneOption:!1}).options,s=(0,a.useMemo)((()=>(0,l1e.g)(r,{noneLabel:_j.Jd})),[r]),c=(0,pG.w)(),d=(0,g4e.g)([ZJe.He]),u=(0,o.A)(d,1)[0],m=u.entityId,h=u.taxYear,v=u.period,f=null!==h&&void 0!==h?h:(0,d1e.Ow)(),E=p1e(),y=a.useState(y4e[0].value),b=(0,o.A)(y,2),x=b[0],w=b[1],C=a.useState(!1),A=(0,o.A)(C,2),k=A[0],S=A[1],N=a.useState(!1),T=(0,o.A)(N,2),_=T[0],D=T[1],R=a.useState(!0),M=(0,o.A)(R,2),L=M[0],O=M[1],P=(()=>{const e=(0,a.useState)(void 0),t=(0,o.A)(e,2),n=t[0],l=t[1],r=(0,Pc.e)(!1),s=(0,o.A)(r,2),c=s[0],d=s[1],u=d.setOn,m=d.setOff,p=(0,a.useState)(void 0),g=(0,o.A)(p,2),h=g[0],v=g[1],f=(0,a.useRef)(void 0),E=(null!==n&&void 0!==n?n:{}).sessionKey,y=(0,PH.p)(u4e,{variables:{sessionKey:null!==E&&void 0!==E?E:""},pollUntil:e=>{var t;const n=null===e||void 0===e||null===(t=e.downloadScheduleCSession)||void 0===t?void 0:t.status;return n===Dq.A2.Completed||n===Dq.A2.Errored},onComplete:e=>{m();const t=null===e||void 0===e?void 0:e.downloadScheduleCSession;if(!t)return;const n=f.current?{tax_year:f.current.taxYear,period:f.current.period,format:f.current.format,include_transactions:f.current.includeTransactions,include_totals:f.current.includeTotals,include_categories:f.current.includeCategories,form_type:u1e}:void 0;if(t.status===Dq.A2.Completed&&t.url)(0,Ge.u4)(Ye.TR.DownloadCompleted,n),window.location.href=t.url;else if(t.status===Dq.A2.Errored){var a;(0,Ge.u4)(Ye.TR.DownloadFailed,n),v(null!==(a=t.errorMessage)&&void 0!==a?a:"Something went wrong. Please try again.")}l((e=>(0,U.A)((0,U.A)({},e),t)))},skipWhenNotPolling:!0,pollIntervalMs:f4e}),b=(0,o.A)(y,1)[0],x=(0,i.n)(d4e,{onCompleted:e=>{let t=e.startDownloadScheduleCSession;if(!t)return m(),void v("Something went wrong. Please try again.");l({sessionKey:t.sessionKey,status:t.status}),b()}}),w=(0,o.A)(x,1)[0];return{downloadScheduleC:(0,a.useCallback)((async e=>{f.current=e,v(void 0),u();try{await w({variables:e})}catch(t){m(),v("Something went wrong. Please try again.")}}),[w,u]),isLoading:c,errorMessage:h}})(),B=P.downloadScheduleC,z=P.isLoading,F=P.errorMessage;(0,a.useEffect)((()=>{var e;!r.some((e=>e.value===m))&&null!==(e=r[0])&&void 0!==e&&e.value&&c((0,g.D8)({entityId:r[0].value}))}),[m,r,c]),(0,a.useEffect)((()=>{(0,Ge.u4)(Ye.TR.ExportPageViewed,{tax_year:f,period:v,form_type:u1e})}),[]);const G=m4e({taxYear:f,period:v,selectedEntityId:m}),Y=G.earlyIncomeLines,V=G.lateIncomeLines,W=G.computedIncomeAmounts,j=G.allExpenseRows,H=G.incomeTotal,K=G.expenseTotal,q=G.aggregatesData,$=G.dateRangeFilters,Z=G.isLoading,J=$.startDate,X=$.endDate,Q=null!==(e=null===(t=r.find((e=>e.value===m)))||void 0===t?void 0:t.label)&&void 0!==e?e:"Schedule C",ee=w1e(f,v),te=(0,a.useMemo)((()=>{var e;return(null!==(e=null===q||void 0===q?void 0:q.aggregates)&&void 0!==e?e:[]).reduce(((e,t)=>{var n;return e+(null!==(n=t.summary.count)&&void 0!==n?n:0)}),0)}),[q]),ne=H+K;return a.createElement(S2e,{"data-external-id":"tax-forms-export-preview"},a.createElement(_1e,null,a.createElement(D1e,null,a.createElement("div",{className:"flex items-center gap-sm"},a.createElement(R1e,null,"Business tax prep"),a.createElement($G,null)),a.createElement(M1e,null,a.createElement(fe.hGA,{classNames:{trigger:"w-[225px]"},options:s,value:null!==m&&void 0!==m?m:null,onValueChange:e=>c((0,g.D8)({entityId:null!==e&&void 0!==e?e:void 0})),placeholder:"Select business"}),a.createElement(fe.hGA,{classNames:{trigger:"w-[140px]"},placeholder:fe.L2e,options:m1e,value:m1e[0].value,onValueChange:()=>{}}),a.createElement(fe.hGA,{classNames:{trigger:"w-[140px]"},placeholder:fe.L2e,options:E,value:String(f),onValueChange:e=>c((0,g.D8)({taxYear:e?Number(e):(0,d1e.Ow)()}))}),a.createElement(fe.hGA,{placeholder:fe.L2e,options:g1e,value:v,onValueChange:e=>c((0,g.D8)({period:null!==e&&void 0!==e?e:"full"})),classNames:{trigger:"w-[140px]",content:"min-w-[184px]"}}))),a.createElement(P1e,null,a.createElement("div",{className:"mb-xs flex items-center gap-xs"},a.createElement(B1e,{className:"mb-0"},Q," ",a.createElement(z1e,null,x1e(f,v))),ee&&a.createElement(tFe.c,{"aria-label":ee,size:"3xs",iconSize:"md",triggerClassName:"text-content-secondary",content:ee})),a.createElement(F1e,null,"Schedule C Prep Sheet"),a.createElement(G
11e,null,"This report is for informational purposes only. Use of this report is acknowledgement that nothing herein is to be construed as tax advice; Monarch is not a tax advisor. Consult a licensed tax professional for any advice or support in filing your taxes."),a.createElement(E2e,null,"See Part I and Part II (Lines 1\u201332) of"," ",a.createElement(Y1e,{href:"https://www.irs.gov/forms-pubs/about-schedule-c-form-1040",target:"_blank",rel:"noopener noreferrer"},"IRS Form 1040, Schedule C"),"."),m&&te>0&&a.createElement(y2e,null,a.createElement(Vl.W,{to:I.JZ.transactions({queryParams:{businessEntitySet:[m],startDate:J,endDate:X}})},a.createElement(xt.v,{size:"small",weight:"bold"},"See all ",te," ",(0,De.td)("transaction",te)),a.createElement(fe.hPJ,{size:"sm"}))))),a.createElement(T2e,null,a.createElement("div",null,a.createElement(_2e,null,a.createElement(N2e,null,a.createElement(wt.Xb,{size:"small",style:{gap:8},onClick:()=>n(I.JZ.reports.taxForms())},a.createElement(fe.qzE,{size:"2xs"}),"Back to review")),a.createElement(L1e,null),Z?a.createElement(t2e,null,a.createElement(p.i,null)):a.createElement(a.Fragment,null,a.createElement(D2e,null,a.createElement(xt.v,{size:"large",weight:"bold"},"Part I: Income"),a.createElement(g2e,{size:"large",$isTotal:!0,$isPositive:H>0},A1e(H))),Y.map((e=>a.createElement(R2e,{key:e.key},a.createElement(M2e,null,"Line ",e.lineNumber,": ",e.description),a.createElement(L2e,{$positive:e.amount>0},A1e(e.amount))))),a.createElement(R2e,null,a.createElement(M2e,{$secondary:!0},"Line 3: Subtract line 2 from line 1"),a.createElement(L2e,{$secondary:!0},A1e(W.line3))),a.createElement(R2e,null,a.createElement(M2e,{$secondary:!0},"Line 4: Cost of goods sold"),a.createElement(O2e,null,"Not tracked ",a.createElement(fe.ucZ,{size:"sm"}))),a.createElement(R2e,null,a.createElement(M2e,{$secondary:!0},"Line 5: Gross profit (subtract line 4 from line 3)"),a.createElement(L2e,{$secondary:!0},A1e(W.line5))),V.map((e=>a.createElement(R2e,{key:e.key},a.createElement(M2e,null,"Line ",e.lineNumber,": ",e.description),a.createElement(L2e,{$positive:e.amount>0},A1e(e.amount))))),a.createElement(L1e,null),a.createElement(D2e,null,a.createElement(xt.v,{size:"large",weight:"bold"},"Part II: Expenses"),a.createElement(g2e,{size:"large",$isTotal:!0,$isPositive:K>0},A1e(K))),j.map((e=>"not-tracked"===e.type?a.createElement(R2e,{key:"not-tracked-".concat(e.lineNumber)},a.createElement(M2e,{$secondary:!0},"Line ",e.lineNumber,": ",e.description),a.createElement(O2e,null,"Not tracked ",a.createElement(fe.ucZ,{size:"sm"}))):a.createElement(R2e,{key:e.line.key},a.createElement(M2e,null,"Line ",e.line.lineNumber,": ",e.line.description),a.createElement(L2e,{$positive:e.line.amount>0},A1e(e.line.amount))))),a.createElement(L1e,null),a.createElement(D2e,null,a.createElement(xt.v,{size:"large",weight:"bold"},C1e(ne)),a.createElement(g2e,{size:"large",$isTotal:!0,$isPositive:ne>0},A1e(ne)))))),a.createElement(P2e,null,a.createElement(xt.v,{size:"large",weight:"medium"},"Export summary"),a.createElement(B2e,null,a.createElement(xt.v,{size:"small",weight:"medium"},"File format"),a.createElement(fe.hGA,{placeholder:fe.L2e,options:y4e,value:x,onValueChange:e=>w(null!==e&&void 0!==e?e:y4e[0].value)})),a.createElement(x4e,null,a.createElement(w4e,{checked:k,onChange:()=>S((e=>!e))},"Include transaction details"),k&&a.createElement(a.Fragment,null,a.createElement(w4e,{checked:L,onChange:()=>O((e=>!e))},"Include totals"),L&&a.createElement(w4e,{checked:_,onChange:()=>D((e=>!e))},"Include Monarch categories"))),F&&a.createElement(xt.v,{size:"small",color:"red"},F),a.createElement(z2e,{disabled:Z||z,onClick:()=>{(0,Ge.u4)(Ye.TR.DownloadStarted,{tax_year:f,period:v,format:x,include_transactions:k,include_totals:!k||L,include_categories:k&&L&&_,form_type:u1e}),B({taxYear:f,period:v,entityId:m,includeCategories:k&&L&&_,includeTransactions:k,includeTotals:!k||L,format:x,entityLabel:Q})}},z?"Preparing download...":"Download prep sheet"))))},x4e=$d.s.div(E4e||(E4e=(0,wc.A)(["flex flex-col gap-xs"]))),w4e=(0,u.default)(fz.hm).withConfig({displayName:"TaxFormsExportPreview__ExportCheckbox",componentId:"rlwyo6-0"})(["[data-sc-tw~='Checkbox__Text']{font-size:",";font-weight:",";}"],vt.J.base,vt.Wy.book);
1var C4e=n(17325),A4e=n(82101),I4e=n(13178),k4e=n(18680);const S4e=["businessEntitySet"],N4e=e=>{let t=e.groupBy,n=e.filters,l=e.isExpense,r=e.skip;const o=(0,a.useMemo)((()=>[t]),[t]),i=(0,a.useMemo)((()=>{const e=(0,CX.WD)(n),a=e.businessEntitySet,r=(0,En.A)(e,S4e);return{includeCategory:t===Ee.DB0.CATEGORY,includeCategoryGroup:t===Ee.DB0.CATEGORY_GROUP,includeMerchant:t===Ee.DB0.MERCHANT,groupBy:o,sortBy:l?Ee.ZOj.SUM_EXPENSE:Ee.ZOj.SUM_INCOME,fillEmptyValues:t!==Ee.DB0.MERCHANT,filters:(0,U.A)((0,U.A)({},r),{},{businessEntitySet:a,categoryType:l?Ee.hMm.EXPENSE:Ee.hMm.INCOME})}}),[t,o,n,l]),s=(0,et.I)(I4e.VF,{variables:i,skip:r}),c=s.data,d=s.isLoadingInitialData,u=s.isNetworkRequestInFlight,m=(0,a.useMemo)((()=>(0,Vo.yh)({reportsData:c,filters:n,groupBy:o,isSpendingReport:l,includeAllGroups:!0})),[c,n,o,l]),p=(0,a.useMemo)((()=>m[0].map((e=>{var t;let n=e.entities,a=e.total;const l=(0,k4e.KQ)(n),r=l.id,o=l.label,i=l.selection,s=l.entity,c="Category"===(null===s||void 0===s?void 0:s.__typename)?s.icon:void 0,d="Merchant"===(null===s||void 0===s?void 0:s.__typename),u=d?s.logoUrl:void 0;return{id:null!==r&&void 0!==r?r:"",name:s&&"displayName"in s&&s.displayName?s.displayName:null!==(t=null===s||void 0===s?void 0:s.name)&&void 0!==t?t:o,icon:c,isMerchant:d,logoUrl:u,value:a,selection:i}})).filter((e=>0!==e.value))),[m]),g=(0,a.useRef)([]);u||(g.current=p);return{data:u&&0===p.length?g.current:p,isLoading:d}},T4e=e=>{let t=e.filters,n=e.quickViewFilters,l=e.onRemoveQuickViewFilters,r=e.groupBy,o=e.onChangeGroupBy,i=e.onSelectDatum,s=e.title,c=e.onDataStateChange;return a.createElement(RP.x,{"data-external-id":"reports-cash-flow-ranked-bars"},a.createElement(RP.x.Header,null,null!==s&&void 0!==s?s:a.createElement(RP.x.Title,null,"Income & expenses"),a.createElement(RP.x.Description,null,a.createElement(A4e.J,{quickViewFilters:n,onRemoveQuickViewFilters:l,hideWhenEmpty:!0})),a.createElement(RP.x.Action,null,a.createElement(UJe,{groupBy:r,onChangeGroupBy:o,showBusinessEntityGroupBy:!1,showBudgetVariabilityGroupBy:!1,showOwnerGroupBy:!1}))),a.createElement(RP.x.Content,null,a.createElement(D4e,{filters:t,groupBy:r,onSelectDatum:i,onDataStateChange:c})))},_4e=()=>{},D4e=e=>{let t=e.filters,n=e.groupBy,l=e.onSelectDatum,r=void 0===l?_4e:l,o=e.onDataStateChange;const i=(0,vSe.Nb)({strict:!1}).hideAmounts,s=(e=>{let t=e.groupBy,n=e.filters,a=e.enabled,l=void 0===a||a;const r=N4e({groupBy:t,filters:n,isExpense:!1,skip:!l}),o=N4e({groupBy:t,filters:n,isExpense:!0,skip:!l}),i=r.isLoading||o.isLoading;return{income:r.data,expense:o.data,isLoading:i,isEmpty:!i&&0===r.data.length&&0===o.data.length}})({groupBy:n,filters:t}),c=s.income,d=s.expense,u=s.isLoading,m=s.isEmpty;return(0,a.useEffect)((()=>{null===o||void 0===o||o({isEmpty:m,isLoading:u})}),[m,u,o]),u?a.createElement("div",{"data-external-id":"reports-cash-flow-ranked-bars-chart",className:"flex items-center justify-center p-4xl"},a.createElement(p.i,null)):m?a.createElement(XJe,{"data-external-id":"reports-cash-flow-ranked-bars-chart"}):a.createElement(a.Fragment,null,a.createElement(C4e.l,{title:"Income",section:"income",bars:c,hideAmounts:i,onSelectDatum:r}),a.createElement("br",null),a.createElement(C4e.l,{title:"Expenses",section:"expense",bars:d,hideAmounts:i,onSelectDatum:r}))},R4e=["businessEntitySet"],M4e=e=>{let t=e.currentTab,n=e.groupBy,l=e.groupByTimeframe,o=e.filters,i=e.showAllEntities,s=e.skipQuery,c=void 0!==s&&s,u=e.onCompletedQuerySuccessfully;const m=(0,d.d4)((e=>t&&(0,ZJe.Cp)(e,t))),p=(null===m||void 0===m?void 0:m.chartType)===V1.Gi.SankeyCashFlowChart,g=(0,d.d4)(ZJe.Fy),h=(0,a.useMemo)((()=>p?(0,r.YW)(g).with("category",(()=>[Ee.DB0.CATEGORY])).with("group",(()=>[Ee.DB0.CATEGORY_GROUP])).with("both",(()=>[Ee.DB0.CATEGORY,Ee.DB0.CATEGORY_GROUP])).otherwise((()=>{})):n),[n,g,p]),v=(0,a.useMemo)((()=>(0,RJe.JG)(t,null===m||void 0===m?void 0:m.chartType,null===m||void 0===m?void 0:m.viewMode)),[t,m]),f=(0,a.useMemo)((()=>{if(!v)return"spending"===t?Ee.ZOj.SUM_EXPENSE:"income"===t?Ee.ZOj.SUM_INCOME:void 0}),[t,v]),E=(0,a.useMemo)((()=>"spending"===t||"income"!==t&&void 0),[t]),y=L4e({filters:o?(0,CX.WD)(o):{},groupBy:h,groupByTimeframe:l,isTimeBasedReport:v,isSpendingReport:E,sortBy:f}),b=(0,et.I)(I4e.VF,{variables:y,skip:c,onCompleted:()=>null===u||void 0===u?void 0:u()}
1),x=b.data,w=b.isDataAvailable,C=b.isNetworkRequestInFlight,A=b.refetch,I=b.error,k=(0,Vo.yh)({reportsData:x,filters:o,groupBy:h,isSpendingReport:E,includeAllGroups:p||v,maxVisibleEntities:i||(null===m||void 0===m?void 0:m.chartType)===V1.Gi.HorizontalBarChart||(null===m||void 0===m?void 0:m.chartType)===V1.Gi.TreemapChart?void 0:Vo.qu});return{refetch:A,hasData:!!x,summary:(0,Vo.bF)(x),isLoading:!w&&C,result:k,queryVariables:y,error:I}},L4e=e=>{const t=e.filters,n=e.isTimeBasedReport,a=e.groupBy,l=e.groupByTimeframe,r=e.sortBy,o=e.isSpendingReport,i=O4e(a),s=t.businessEntitySet,c=(0,En.A)(t,R4e);return(0,U.A)((0,U.A)({},i),{},{filters:(0,U.A)((0,U.A)({},c),{},{businessEntitySet:s,categoryType:(()=>{if(void 0!==o)return o?Ee.hMm.EXPENSE:Ee.hMm.INCOME})()}),groupBy:a,groupByTimeframe:n?l:void 0,fillEmptyValues:!(null!==a&&void 0!==a&&a.includes(Ee.DB0.MERCHANT)),sortBy:r})},O4e=e=>({includeCategory:!(null===e||void 0===e||!e.includes(Ee.DB0.CATEGORY)),includeCategoryGroup:!(null===e||void 0===e||!e.includes(Ee.DB0.CATEGORY_GROUP)),includeMerchant:!(null===e||void 0===e||!e.includes(Ee.DB0.MERCHANT)),includeBusinessEntity:!(null===e||void 0===e||!e.includes(Ee.DB0.BUSINESS_ENTITY)),includeBudgetVariability:!(null===e||void 0===e||!e.includes(Ee.DB0.BUDGET_VARIABILITY)),includeOwner:!(null===e||void 0===e||!e.includes(Ee.DB0.OWNER))}),P4e=["initialView","cashFlowActivityView"],B4e=["spending","income","cashFlow"],z4e=e=>{const t=(0,E.wA)(),n=(0,l.Zp)(),r=(0,l.zy)();(0,a.useLayoutEffect)((()=>{const a=r.state,l=null===a||void 0===a?void 0:a.initialView;if(!l||(o=l.tab,!B4e.includes(o)))return;var o;(0,RJe.kv)(t,l),"cashFlow"===l.tab&&a.cashFlowActivityView&&t((0,g.rH)(a.cashFlowActivityView));const i=l.tab!==e?I.JZ.reports[l.tab].path:r.pathname,s=(a.initialView,a.cashFlowActivityView,(0,En.A)(a,P4e)),c=Object.keys(s).length>0?s:{};n({pathname:i,search:r.search},{replace:!0,state:c})}),[e,r.state,r.pathname,r.search,t,n])};var F4e=n(84401);const G4e=(0,Qt.J)("\n  query Common_GetReportConfigurations {\n    reportConfigurations {\n      ...ReportConfigurationFields\n    }\n  }\n"),Y4e=(0,Qt.J)("\n  mutation Common_CreateReportConfiguration($input: CreateReportConfigurationInput!) {\n    createReportConfiguration(input: $input) {\n      reportConfiguration {\n        ...ReportConfigurationFields\n      }\n      errors {\n        ...PayloadErrorFields\n      }\n    }\n  }\n"),U4e=(0,Qt.J)("\n  mutation Common_UpdateReportConfiguration($input: UpdateReportConfigurationInput!) {\n    updateReportConfiguration(input: $input) {\n      reportConfiguration {\n        ...ReportConfigurationFields\n      }\n      errors {\n        ...PayloadErrorFields\n      }\n    }\n  }\n"),V4e=(0,Qt.J)("\n  mutation Common_DeleteReportConfiguration($id: ID!) {\n    deleteReportConfiguration(id: $id) {\n      deleted\n      errors {\n        ...PayloadErrorFields\n      }\n    }\n  }\n");(0,Qt.J)("\n  fragment ReportConfigurationFields on ReportConfiguration {\n    id\n    displayName\n    transactionFilterSet {\n      ...TransactionFilterSetFields\n    }\n    reportView {\n      analysisScope\n      chartType\n      chartCalculation\n      chartLayout\n      chartDensity\n      dimensions\n      timeframe\n    }\n  }\n"),(0,Qt.J)("\n  fragment TransactionFilterSetFields on TransactionFilterSet {\n    id\n    displayName\n    categories {\n      id\n      name\n      icon\n    }\n    categoryGroups {\n      id\n      name\n      type\n    }\n    accounts {\n      id\n      displayName\n      logoUrl\n      icon\n    }\n    merchants {\n      id\n      name\n      logoUrl\n    }\n    tags {\n      id\n      name\n      color\n    }\n    isUntagged\n    goals {\n      id\n      name\n      imageStorageProvider\n      imageStorageProviderId\n    }\n    savingsGoals {\n      id\n      name\n      imageStorageProvider\n      imageStorageProviderId\n    }\n    searchQuery\n    systemCategories\n    systemCategoryGroups\n    categoryType\n    isUncategorized\n    budgetVariability\n    isFlexSpending\n    startDate\n    endDate\n    timeframePeriod {\n      unit\n      value\n      includeCurrent\n    }\n    createdBefore\n    createdAfter\n    absAmountGte\n    absAmountLte\n    isSplit\n    isRecurring\n    isInvestmentAccount\n    isPending\n    creditsOnly\n    debitsOnly\n    hasNotes\n    hasAttachments\n    hiddenFromReports\n    importedFromMint\n    syncedFromInstitution\n    needsReview\n    needsReviewUnassigned\n    needsReviewByUser {\n      id\n      name\n    }\n    ownershipSet {\n      includeJointlyOwned\n      users {\n        id\n        name\n        profilePictureUrl\n      }\n    }\n    businessEntitySet {\n      includeUnassigned\n      businessEntities {\n        id\n        name\n        logoUrl\n        color\n      }\n    }\n  }\n");var W4e=n(94469);const j4e={day:Ee.aIQ.DAY,week:Ee.aIQ.WEEK,month:Ee.aIQ.MONTH,quarter:Ee.aIQ.QUARTER,year:Ee.aIQ.YEAR}
1,H4e=(e,t,n)=>{var a,l,r;const o=N.c9.fromISO(e).startOf(n),i=(null!==(a=o.toISODate())&&void 0!==a?a:e)<e?o.plus({[n]:1}):o,s=null!==(l=i.toISODate())&&void 0!==l?l:e,c=null!==(r=i.endOf(n).toISODate())&&void 0!==r?r:t;return s>=e&&c<=t?s:e},K4e=(e,t,n,a)=>{var l;if(e.groupByTimeframe===t)return;const r=null!==(l=e.quickViewFilters)&&void 0!==l?l:{},o=r.startDate,i=r.endDate;if(!o||!i)return;const s=(e=>Object.keys(j4e).find((t=>j4e[t]===e)))(t);let c=H4e(o,i,s);const d=EXe(c,s);return(n&&d.endDate<n||a&&d.startDate>a)&&n&&a&&(c=H4e(n,a,s)),(0,U.A)((0,U.A)({},e.quickViewFilters),EXe(c,s,n,a))},q4e={},$4e=e=>{var t,n,r;let i=e.currentTab,s=e.filters,c=e.groupByTimeframe,u=e.analyticsMetadata;const m=(0,pG.w)(),p=(0,l.zy)().pathname,h=(0,d.d4)((e=>(e=>{var t;return null!==(t=e.reportsDrilldown)&&void 0!==t?t:{}})(e)[i])),v=p===I.JZ.reports.path?void 0:h,f=null!==(t=null===v||void 0===v?void 0:v.quickViewFilters)&&void 0!==t?t:q4e,E=null!==(n=null===v||void 0===v?void 0:v.selectedDatum)&&void 0!==n?n:null,y=(0,a.useCallback)((e=>{m((0,g.LC)({tab:i,persistedSelection:(0,U.A)((0,U.A)({},e),{},{groupByTimeframe:c})}))}),[i,m,c]),b=(0,a.useCallback)((e=>y({quickViewFilters:e})),[y]),x=(0,a.useCallback)((e=>y({selectedDatum:null!==e&&void 0!==e?e:null})),[y]),w=(0,a.useCallback)((function(e){let t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];b(e?((e,t)=>{let n=(0,U.A)({},e);const a=e=>(0,XX.A)([e],n);for(const d of Object.entries(t)){var l=(0,o.A)(d,2);const e=l[0],t=l[1],u=n[e];if(null!==u&&void 0!==u)if("businessEntitySet"!==e)if("ownershipSet"!==e)if(Array.isArray(u)&&Array.isArray(t)){const l=new Set(t),r=u.filter((e=>!l.has(e)));n=r.length>0?(0,U.A)((0,U.A)({},n),{},{[e]:r}):a(e)}else u===t&&(n=a(e));else{var r,i;const e=u,l=t;if(!e||!l){n=a("ownershipSet");continue}const o=null!==(r=e.userIds)&&void 0!==r?r:[],s=new Set(null!==(i=l.userIds)&&void 0!==i?i:[]),c=o.filter((e=>!s.has(e))),d=!l.includeJointlyOwned&&e.includeJointlyOwned;n=0!==c.length||d?(0,U.A)((0,U.A)({},n),{},{ownershipSet:{userIds:c,includeJointlyOwned:d}}):a("ownershipSet")}else{var s,c;const e=u,l=t;if(!e||!l){n=a("businessEntitySet");continue}const r=null!==(s=e.businessEntityIds)&&void 0!==s?s:[],o=null!==(c=l.businessEntityIds)&&void 0!==c?c:[],i=new Set(o),d=r.filter((e=>!i.has(e))),m=!l.includeUnassigned&&e.includeUnassigned;n=0!==d.length||m?(0,U.A)((0,U.A)({},n),{},{businessEntitySet:{businessEntityIds:d,includeUnassigned:m}}):a("businessEntitySet")}else n=a(e)}return n})(f,e):q4e),t&&(0,Ge.u4)(Ye.m2.ReportsChartDataSelectionReset,u)}),[u,f,b]);(0,a.useEffect)((()=>{if(!v)return;const e=K4e(v,c,s.startDate,s.endDate);e&&y({quickViewFilters:e})}),[y,s.endDate,s.startDate,c,v]);const C=f.startDate,A=f.endDate,k=(0,a.useMemo)((()=>C&&A?{startDate:C,endDate:A}:null),[C,A]);return{quickViewFilters:f,setQuickViewFilters:b,selectedDatum:E,setSelectedDatum:x,selectedDatumId:null!==(r=null===E||void 0===E?void 0:E.id)&&void 0!==r?r:null,selectedDateRange:k,hasQuickViewFilters:!(0,PY.A)(f),removeQuickViewFilters:w}};var Z4e=n(2862);const J4e=e=>{var t;let n=e.currentTab;const r=(0,pG.w)(),i=(0,d.Pj)(),s=(0,l.zy)(),c=(0,l.Zp)(),u=(0,l.wQ)(),m=(0,a.useState)(!1),p=(0,o.A)(m,2),h=p[0],v=p[1],f=(0,Z4e.n)(),E=(0,g4e.g)([ZJe.xB,ZJe.W$,ZJe.GU,ZJe.Ri]),y=(0,o.A)(E,4),b=y[0],x=y[1],w=y[2],C=y[3],A=(0,g4e.g)([e=>(0,ZJe.Cp)(e,n),e=>(0,ZJe.Cz)(e,n)]),k=(0,o.A)(A,2),S=k[0],N=S.chartType,T=S.groupMode,_=S.viewMode,D=k[1];return(e=>{const t=(0,pG.w)(),n=(0,l.zy)(),r=(0,d.d4)((t=>(0,ZJe.Cz)(t,e))),o=(0,a.useRef)(r),i=(0,d.d4)(ZJe.Bc),s=(0,a.useMemo)((()=>tp.A.parse(n.search)),[n.search]),c=(0,a.useMemo)((()=>Object.values(RJe.pE).some((e=>e in s))),[s]),u=(0,a.useMemo)((()=>(0,RJe.RH)(s,e)),[s,e]),m=(0,a.useMemo)((()=>(0,F4e._X)(n.search)),[n.search]);o.current=r,(0,a.useLayoutEffect)((()=>{if(!(0,V1.hm)(e)||!c)return;if(m&&i)return;const n=(0,RJe.jU)(o.current);var a,l;l=u,((a=n).tab!==l.tab||a.chartType!==l.chartType||a.calculationViewMode!==l.calculationViewMode||a.cashFlowGroupMode!==l.cashFlowGroupMode||a.groupByEntity!==l.groupByEntity||a.groupByTimeframe!==l.groupByTimeframe)&&(0,RJe.kv)(t,u)}),[e,t,c,i,m,u])})(n),(0,a.useEffect)((()=>{const e=(0,e0.sO)(b),t=(0,e0.sO)(f);if((0,Tce.A)(e,t))return;if((0,PY.A)(t))return void r("POP"===u&&h?(0,g.lo)({filters:{}}):(0,g.UO)({filters:b}));const n=(0,VW.A)((e=>(0,e0.p6)(e)),f);r(((0,PY.A)(e)?g.UO:g.lo)({filters:n}))}),[s]),(0,a.useEffect)((()=>
1{if(!h)return void v(!0);if(s.pathname!==I.JZ.reports[n]())return;if("undefined"!==typeof window&&window.location.pathname!==s.pathname)return;if("taxForms"===n)return;const e=(0,e0.sO)(f),t=tp.A.parse(s.search),a=(0,V1.hm)(n)?(0,RJe.Fb)((0,RJe.RH)(t,n)):{},l=(0,e0.sO)(b),r=(0,V1.hm)(n)?(0,RJe.Fb)((0,RJe.jU)(D)):{};if((0,Tce.A)(l,e)&&(0,Tce.A)(r,a))return;const o=new Set([...Object.keys(e),...Object.values(RJe.pE)]),i=(0,XX.A)([...o],t),d=(0,U.A)((0,U.A)((0,U.A)({},i),l),r),u=I.JZ.reports[n]((0,PY.A)(d)?{}:{queryParams:d});c(u,{replace:(0,Tce.A)(l,e)})}),[n,b,h,D]),xX(null===(t=b.businessEntitySet)||void 0===t?void 0:t.businessEntityIds,(e=>{const t=(0,ZJe.xB)(i.getState()),n=t.businessEntitySet;if(!n)return;const a=0!==e.length||n.includeUnassigned?(0,U.A)((0,U.A)({},t),{},{businessEntitySet:(0,U.A)((0,U.A)({},n),{},{businessEntityIds:e})}):(0,XX.A)(["businessEntitySet"],t);r((0,g.UO)({filters:a}))})),{filters:b,reportView:D,groupBy:x,groupByTimeframe:w,sortTransactionsBy:C,chartType:N,groupMode:T,viewMode:_}},X4e=e=>{let t=e.currentTab;const n=J4e({currentTab:t}),l=n.filters,r=n.reportView,i=n.groupBy,s=n.groupByTimeframe,c=n.sortTransactionsBy,d=n.chartType,u=n.groupMode,m=n.viewMode,p=(e=>{const t=(0,g4e.g)([ZJe.W$,ZJe.GU,ZJe.TP,ZJe.BV]),n=(0,o.A)(t,4),l=n[0],r=n[1],i=n[2],s=n[3],c=(0,g4e.g)([t=>(0,ZJe.Cp)(t,e)]),d=(0,o.A)(c,1)[0],u=d.chartType,m=d.groupMode,p=d.viewMode;return(0,a.useMemo)((()=>
1(0,ZJe.sh)({tab:e,chartType:u,viewMode:p,groupMode:m,groupBy:l,groupByTimeframe:r,treemapNodeCount:i,activityView:s})),[u,e,p,m,l,r,i,s])})(t),g=$4e({currentTab:t,filters:l,groupByTimeframe:s,analyticsMetadata:p}),h=(0,a.useState)(!1),v=(0,o.A)(h,2),f=v[0],E=v[1];(0,a.useEffect)((()=>{E(!1)}),[t,l]);const y=(0,a.useMemo)((()=>{const e=(0,RZ.A)(l,g.quickViewFilters),n=(0,CX.mY)(e);return"spending"===t?(0,U.A)((0,U.A)({},n),{},{categoryType:Ee.hMm.EXPENSE}):"income"===t?(0,U.A)((0,U.A)({},n),{},{categoryType:Ee.hMm.INCOME}):n}),[l,g.quickViewFilters,t]);return(0,U.A)((0,U.A)({showAllEntities:f,setShowAllEntities:E,reportView:r,filters:l,allFilters:y,groupBy:i,groupByTimeframe:s,sortTransactionsBy:c,chartType:d,groupMode:u,viewMode:m},g),{},{analyticsMetadata:p})};var Q4e=n(68221);const e3e=(e,t)=>e.length===t.length&&e.every(((e,n)=>e===t[n])),t3e=e=>{return"string"===typeof e?e:Array.isArray(e)&&null!==(t=e[0])&&void 0!==t?t:void 0;var t},n3e=e=>{let t=e.enabled,n=e.rootGroupBy,r=e.pageFilters,i=e.businessEntityContext,s=e.selectedDatum,c=e.setSelectedDatum,d=e.setQuickViewFilters,u=e.removeQuickViewFilters;const m=(0,l.zy)(),p=(0,l.Zp)(),g=(0,l.wQ)(),h=(0,Z4e.n)(),v=(0,a.useState)([]),f=(0,o.A)(v,2),E=f[0],y=f[1],b=(0,a.useState)([]),x=(0,o.A)(b,2),w=x[0],C=x[1],A=(0,a.useRef)(E);A.current=E;const I=(0,a.useRef)(w);I.current=w;const k=(0,a.useRef)([]),S=(0,a.useRef)(void 0),N=(0,a.useRef)(m);N.current=m;const T=(0,a.useRef)(p);T.current=p;const _=(0,a.useRef)(!0),D=(0,a.useRef)(t),R=(0,a.useRef)(n),M=(0,a.useRef)((0,e0.sO)(null!==r&&void 0!==r?r:{})),L=(0,a.useRef)(!1),O=(0,a.useRef)(void 0),P=(0,a.useCallback)(((e,t)=>{const n=window.location,a=n.pathname,l=n.search,r=tp.A.parse(l),o=XQe(e),i=t3e(r[WQe]);if(o===i||!o&&!i)return;const s=o?(0,U.A)((0,U.A)({},r),{},{[WQe]:o}):(0,XX.A)([WQe],r),c=tp.A.stringify(s),d=c?"".concat(a,"?").concat(c):a;O.current=a,T.current(d,{replace:"replace"===t})}),[]),B=(0,a.useCallback)((()=>"undefined"===typeof window?N.current:window.location),[]),z=(0,a.useCallback)((()=>{const e=B().search;return t3e(tp.A.parse(e)[WQe])}),[B]),F=(0,a.useCallback)((()=>{const e=z();return"string"===typeof e&&e.length>0}),[z]),G=(0,a.useCallback)((()=>{y([]),C([]),k.current=[],S.current=void 0,c(null),u(),P({stack:[],focusPath:[]},"replace")}),[u,c,P]),Y=(0,a.useCallback)((e=>{if(O.current=B().pathname,L.current=!0,y(e.stack),C(e.focusPath),k.current=e.focusPath,S.current=e.tip,e.tip){const t=UQe(e.stack,{businessEntityContext:i}),n=xXe(e.tip.selection,{businessEntityContext:i}),a=(0,RZ.A)(t,n);c({id:e.tip.id,appliedFilters:a}),d(a)}else c(null),0===e.stack.length?u():d(UQe(e.stack,{businessEntityContext:i}));queueMicrotask((()=>{L.current=!1}))}),[i,B,u,d,c]);(0,a.useEffect)((()=>{const e=z(),n="string"===typeof e&&e.length>0;if(!t)return void(n&&P({stack:[],focusPath:[]},"replace"));const a=QQe(e),l=(0,U.A)({stack:A.current,focusPath:k.current},S.current?{tip:S.current}:{}),r=O.current===B().pathname,o=(i=l,XQe(a)===XQe(i));var i;if(!o||!r&&void 0!==O.current){if("POP"===g||!r){const e=!r&&void 0!==O.current&&o,t=e?{stack:[],focusPath:[]}:a;return Y(t),void(e&&P(t,"replace"))}P(l,"replace")}}),[Y,t,m.pathname,m.search,g,z,B,P]),(0,a.useEffect)((()=>{const e=D.current!==t,a=R.current!==n;D.current=t,R.current=n;const l=(0,e0.sO)(null!==r&&void 0!==r?r:{}),o=(0,e0.sO)(h),i=M.current;if(M.current=l,_.current)return _.current=!1,void(!t&&F()&&P({stack:[],focusPath:[]},"replace"));!e||t?t&&(a?G():e||(0,Tce.A)(l,i)||(0,Tce.A)(l,o)||G()):G()}),[G,t,r,h,F,n,P]);const V=YQe(E).length;const W=n?((e,t)=>{var n,a;if(t<=0)return e;const l=FQe[e];return null!==(n=null!==(a=l[t-1])&&void 0!==a?a:l[l.length-1])&&void 0!==n?n:e})(n,V):void 0,j=(0,a.useMemo)((()=>UQe(E,{businessEntityContext:i})),[E,i]),H=(0,a.useMemo)((()=>(0,RZ.A)(null!==r&&void 0!==r?r:{},j)),[r,j]),K=t&&V>0,q=t&&(V>0||!!s),$=n?(e=>{var t;return null!==(t=VQe[e])&&void 0!==t?t:"All ".concat(Vo.Li[e],"s")})(n):"All",Z=(0,a.useCallback)((e=>{if(!t)return;const n=k.current,a=e3e(n,e);if(k.current=e,L.current){if(!e3e(I.current,e)){C(e),S.current=void 0,c(null);const t=UQe(A.current,{businessEntityContext:i});0===Object.keys(t).length?u():d(t)}return}if(a)return;C(e),S.current=void 0,c(null);const l=UQe(A.current,{businessEntityContext:i});0===Object.keys(l).length?u():d(l);const r=e.length>n.length?"push":"replace";P({stack:A.current,focusPath:e},r)}),[i,t,u,d,c,P]),J=(0,a.useCallback)(((e,t)=>{const n=void 0!==t?t:((e,t)=>{var n,a;const l=YQe(e),r=t+1;return r<0||r>=l.length?[]:null!==(n=null===(a=l[r])||void 0===a?void 0:a.sourceFocusPath)&&void 0!==n?n:[]})(E,e),a=e<0?[]:YQe(E).slice(0,e+1);L.current=!0,C(n),k.current=n,S.current=void 0,y(a),c(null),e<0?u():d(UQe(a,{businessEntityContext:i})),P({stack:a,focusPath:n},"replace"),queueMicrotask((()=>{L.current=!1}))}),[i,E,u,d,c,P]),X=(0,a.useCallback)((function(e,a,l){let r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:[];if(!t||!n)return;if(e===Q4e.qy||e.startsWith("".concat(Q4e.qy,"_")))return;if(!a)return;if(!GQe(n,V)){const t=k.current,n={stack:E,focusPath:t};if(e===(null===s||void 0===s?void 0:s.id)){S.current=void 0,c(null);const e=UQe(E,{businessEntityContext:i});return 0===Object.keys(e).length?u():d(e),void P(n,"replace")}const r=UQe(E,{businessEntityContext:i}),o=xXe(a,{businessEntityContext:i}),m=(0,RZ.A)(r,o),p={id:e,label:l,selection:a};return S.current=p,c({id:e,appliedFilters:m}),d(m),void P((0,U.A)((0,U.A)({},n),{},{tip:p}),"push")}const o={id:e,label:l,selection:a,groupBy:null!==W&&void 0!==W?W:n,kind:"entity",sourceFocusPath:r},m=[...YQe(E),o];
1L.current=!0,S.current=void 0,y(m),C([]),k.current=[];const p=UQe(m,{businessEntityContext:i});d(p),c(null),P({stack:m,focusPath:[]},"push"),queueMicrotask((()=>{L.current=!1}))}),[i,W,E,t,V,u,n,null===s||void 0===s?void 0:s.id,d,c,P]);return{drillStack:E,entityDepth:V,chartGroupBy:W,chartFilters:H,isDrilling:K,isScoping:q,rootBreadcrumbLabel:$,seedFocusPath:w,clearDrillAndSelection:G,navigateToStackIndex:J,onTreemapSelectDatum:X,onTreemapFocusPathChange:Z}};var a3e;const l3e=I.JZ.reports.cashFlow.path,r3e=()=>{var e,t,n,r,s,c,u,m,p;const h=(0,E.wA)(),v=(0,l.Zp)(),f=(()=>{const e=(0,l.zy)().pathname;return(0,a.useMemo)((()=>{const t=e.split("/").filter(Boolean),n=t.indexOf("reports"),a=n>=0?t[n+1]:void 0,l=a?(0,W4e.camelCase)(a):"spending";return(0,V1.kL)(l)?l:"spending"}),[e])})(),y=CXe(f),b="paychecks"===f,x=(0,d.d4)(ZJe.BV);z4e(f);const w=(0,qG.e)(),C=w.hasAccess,A=w.isLoading,k=(0,zQe.Rq)(),S=k.businessEntities,N=k.isLoadingInitialData,T=S.length>0,_=(0,a.useRef)(null),D=(0,a.useState)([]),R=(0,o.A)(D,2),M=R[0],L=R[1],O=(0,a.useState)(""),P=(0,o.A)(O,2),B=P[0],z=P[1],F=(0,Pd.h)(),G=(0,o.A)(F,2),Y=G[0],V=G[1].open,W=(0,Pd.h)(),j=(0,o.A)(W,2),H=j[0],K=j[1].open,q=X4e({currentTab:f}),$=q.showAllEntities,Z=q.setShowAllEntities,J=q.reportView,X=q.filters,Q=q.groupBy,ee=q.groupByTimeframe,te=q.sortTransactionsBy,ne=q.quickViewFilters,ae=q.setQuickViewFilters,le=q.selectedDatum,re=q.setSelectedDatum,oe=q.selectedDatumId,ie=q.selectedDateRange,se=q.allFilters,ce=q.hasQuickViewFilters,de=q.removeQuickViewFilters,ue=q.analyticsMetadata,me=q.chartType,pe=(0,a.useMemo)((()=>{const e=null!==X&&void 0!==X?X:{},t=e.startDate,n=e.endDate,a=e.timeframePeriod;return(0,Ba.aR)(t,n,null===a||void 0===a?void 0:a.unit,null===a||void 0===a?void 0:a.value,null===a||void 0===a?void 0:a.includeCurrent)}),[X]),ge=(0,a.useMemo)((()=>{var e,t,n;return(0,fXe.Bu)(ie?{startDate:ie.startDate,endDate:ie.endDate}:{startDate:null===X||void 0===X?void 0:X.startDate,endDate:null===X||void 0===X?void 0:X.endDate,timeframeUnit:null===X||void 0===X||null===(e=X.timeframePeriod)||void 0===e?void 0:e.unit,timeframeValue:null===X||void 0===X||null===(t=X.timeframePeriod)||void 0===t?void 0:t.value,includeCurrentPeriod:null===X||void 0===X||null===(n=X.timeframePeriod)||void 0===n?void 0:n.includeCurrent})}),[ie,X]),he=(0,a.useCallback)((e=>{var t;if(!e)return;const n=null!==(t=null===ie||void 0===ie?void 0:ie.startDate)&&void 0!==t?t:null===pe||void 0===pe?void 0:pe.startDate,a=n?RJ(ee,n):void 0,l=(0,oX.WF)((0,U.A)((0,U.A)({},a?{date:a}:{}),{},{timeframe:ee}));"category"===e.kind?v(I.JZ.categories({id:e.categoryId,queryParams:l})):"categoryGroup"===e.kind?v(I.JZ.categoryGroups({id:e.categoryGroupId,queryParams:l})):"merchant"===e.kind&&v(I.JZ.merchants({id:e.merchantId,queryParams:l}))}),[ee,v,pe,ie]),ve=["spending","income"].includes(f),fe=me===V1.Gi.TreemapChart,ye="cashFlow"===f,be=ye&&"rankedBars"===x;let xe='"chart chart" "transactions summary" / 1fr 30%',we='"chart" "summary" "transactions"';b&&(xe='"chart" / 1fr',we='"chart"');const Ce=n3e({enabled:fe&&ve,rootGroupBy:Q,pageFilters:X,businessEntityContext:null===X||void 0===X?void 0:X.businessEntitySet,selectedDatum:le,setSelectedDatum:re,setQuickViewFilters:ae,removeQuickViewFilters:de}),Ae=Ce.drillStack,Ie=Ce.chartGroupBy,ke=Ce.chartFilters,Se=Ce.isDrilling,Ne=Ce.isScoping,Te=Ce.rootBreadcrumbLabel,_e=Ce.seedFocusPath,Re=Ce.clearDrillAndSelection,Me=Ce.navigateToStackIndex,Le=Ce.onTreemapSelectDatum,Oe=Ce.onTreemapFocusPathChange;let Pe=null,Be=null;if(!A&&!N){const e=C&&T;Pe=e?a.createElement(a.Fragment,null,a.createElement(rV.T,{screenName:"Reports",tab:"taxForms"}),a.createElement(v4e,null)):a.createElement(l.C5,{to:l3e,replace:!0}),Be=e?a.createElement(b4e,null):a.createElement(l.C5,{to:l3e,replace:!0})}const ze=(()=>{var e;const t=(0,Xo.IT)(G4e),n=t.data,l=t.refetch,r=null!==(e=null===n||void 0===n?void 0:n.reportConfigurations)&&void 0!==e?e:[],s=(0,i.n)(Y4e),c=(0,o.A)(s,1)[0],d=(0,i.n)(U4e),u=(0,o.A)(d,1)[0],m=(0,i.n)(V4e),p=(0,o.A)(m,1)[0];return{reportConfigurations:r,createReportConfiguration:(0,a.useCallback)((async(e,t,n)=>{await c({variables:{input:{displayName:e,transactionFilters:t,reportView:n}}}),l()}),[c,l]),updateReportConfiguration:(0,a.useCallback)((async(e,t)=>
1{await u({variables:{input:{id:e,displayName:t}}}),l()}),[u,l]),deleteReportConfiguration:(0,a.useCallback)((async e=>{await p({variables:{id:e}}),l()}),[p,l])}})(),Fe=ze.reportConfigurations,Ue=ze.createReportConfiguration,Ve=ze.updateReportConfiguration,We=ze.deleteReportConfiguration,je=(0,a.useState)(null),He=(0,o.A)(je,2),Ke=He[0],qe=He[1],$e=(0,a.useMemo)((()=>{if((0,BY.A)(X))return;const e=Fe.filter((e=>(0,tj.y6)((0,CX.WD)(X),e.transactionFilterSet)));if(0===e.length)return;const t=e.find((e=>(0,RJe.hz)(J,e.reportView)));if(t)return t.id;const n=e.find((e=>(0,RJe.hz)(void 0,e.reportView)));return n?n.id:void 0}),[J,Fe,X]),Ze=(0,a.useMemo)((()=>{var e,t;if(!b)return{startDate:void 0,endDate:void 0};const n=null!==X&&void 0!==X?X:{},a=n.startDate,l=n.endDate,r=n.timeframePeriod,o=(0,Ba.aR)(a,l,null===r||void 0===r?void 0:r.unit,null===r||void 0===r?void 0:r.value,null===r||void 0===r?void 0:r.includeCurrent);return{startDate:null!==(e=o.startDate)&&void 0!==e?e:void 0,endDate:null!==(t=o.endDate)&&void 0!==t?t:void 0}}),[b,X]),Je=Se?Ie:Q,Xe=Se?ke:X,Qe=M4e({groupBy:ve?(0,Vo.PA)(Je):void 0,groupByTimeframe:ee,currentTab:f,filters:Xe,showAllEntities:$,skipQuery:b}),et=Qe.result,tt=Qe.summary,nt=Qe.isLoading,at=Qe.hasData,lt=Qe.queryVariables,rt=Qe.refetch,ot=Qe.error,it=(0,a.useRef)(et);!nt&&null!==et&&void 0!==et&&null!==(e=et[0])&&void 0!==e&&e.length&&(it.current=et);const st=fe&&Se&&!(null===(t=it.current)||void 0===t||null===(n=t[0])||void 0===n||!n.length),ct=nt&&st?it.current:et,dt=nt&&!st,ut=Fq({error:ot,retryFn:rt}),mt=ut.isRetrying,pt=ut.pageError,gt=M4e({groupBy:ve?(0,Vo.PA)(Q):void 0,currentTab:f,filters:se,showAllEntities:$,skipQuery:b||!ce,onCompletedQuerySuccessfully:()=>{!fe&&_.current&&ce&&function(e){let t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];const n=window.getComputedStyle(e),a=parseFloat(n.scrollMarginBottom)||0,l=e.getBoundingClientRect(),r=window.innerHeight||document.documentElement.clientHeight;return l.bottom+(t?a:0)>r}(_.current)&&_.current.scrollIntoView({behavior:"smooth",block:"end"})}}),ht=gt.summary,vt=gt.isLoading,ft=gt.hasData,Et=gt.refetch,yt=(0,a.useCallback)((async()=>{rt(),Et()}),[rt,Et]),bt=(0,a.useCallback)((e=>h((0,g.M4)(e))),[h]),wt=(0,a.useMemo)((()=>(0,RJe.lE)(Je,f)),[f,Je]),Ct=(0,a.useCallback)(((e,t)=>{if(e===(null===le||void 0===le?void 0:le.id))return void de();if(!t)return;const n=xXe(t,{businessEntityContext:null===X||void 0===X?void 0:X.businessEntitySet});re({id:e,appliedFilters:n}),ae(n),(0,Ge.u4)(Ye.m2.ReportsChartDataSelected,(0,U.A)((0,U.A)({},ue),wXe(t)))}),[null===le||void 0===le?void 0:le.id,ue,de,null===X||void 0===X?void 0:X.businessEntitySet,ae,re]),At=(0,a.useCallback)((()=>{fe?Re():(re(null),de())}),[Re,fe,de,re]),It=(0,a.useCallback)(((e,t,n,a)=>{e!==(null===le||void 0===le?void 0:le.id)?(Le(e,t,n,a),t&&(0,Ge.u4)(Ye.m2.ReportsChartDataSelected,(0,U.A)((0,U.A)({},ue),wXe(t)))):Le(e,t,n,a)}),[ue,Le,null===le||void 0===le?void 0:le.id]),kt=(0,a.useCallback)(((e,t)=>{(null===ie||void 0===ie?void 0:ie.startDate)!==e||(null===ie||void 0===ie?void 0:ie.endDate)!==t?(ae({startDate:e,endDate:t}),(0,Ge.u4)(Ye.m2.ReportsChartDataSelected,ue)):de()}),[null===ie||void 0===ie?void 0:ie.startDate,null===ie||void 0===ie?void 0:ie.endDate,ue,de,ae]);(0,a.useEffect)((()=>{le&&(((e,t)=>Object.entries(e).every((e=>{let n=(0,o.A)(e,2),a=n[0],l=n[1];var r,i,s,c;if(null===l||void 0===l)return!0;const d=t[a];if("businessEntitySet"===a){const e=l,t=d;if(!t)return!1;const n=null!==(r=t.businessEntityIds)&&void 0!==r?r:[],a=(null!==(i=e.businessEntityIds)&&void 0!==i?i:[]).every((e=>n.includes(e))),o=!e.includeUnassigned||!!t.includeUnassigned;return a&&o}if("ownershipSet"===a){const e=l,t=d;if(!t)return!1;const n=null!==(s=t.userIds)&&void 0!==s?s:[],a=(null!==(c=e.userIds)&&void 0!==c?c:[]).every((e=>n.includes(e))),r=!e.includeJointlyOwned||!!t.includeJointlyOwned;return a&&r}return Array.isArray(l)?Array.isArray(d)&&l.every((e=>d.includes(e))):d===l})))(le.appliedFilters,ne)||re(null))}),[le,ne,re]);const St=(0,a.useCallback)((e=>{h((0,g.lo)({filters:e}))}),[h]),Nt=(0,a.useCallback)((e=>{h((0,g.rH)(e)),y()}),[h,y]),Tt=(0,a.useCallback)((e=>{h((0,g.UX)(e)),y()}),[h,y]),Dt=(0,a.useCallback)((e=>{(0,Ge.u4)(Ye.m2.ReportConfigurationSelected,{name:e.displayName});const t=(0,RJe.$H)(e.transactionFilterSet);if(h((0,g.lo)({filters:t})),(0,BY.A)(e.reportView))return void(0,RJe.kv)(h,(0,RJe.vx)(f));const n=(0,RJe.jU)(e.reportView);(0,RJe.kv)(h,n),n.tab!==f&&v(I.JZ.reports[n.tab]({queryParams:(0,e0.sO)(t)}))}),[f,h,v]);(e=>{let t=e.reportConfigurations,n=e.onSelectReportConfiguration,r=e.selectedReportConfigurationId;const o=(0,pG.w)(),i=(0,d.d4)(ZJe.Bc),s=(0,l.zy)();(0,a.useEffect)((()=>{const e=(0,F4e._X)(s.search);e&&o((0,g.Dq)(e))}),[o,s.search]),(0,a.useEffect)((()=>
1{if(i){const e=(0,F4e.mX)(t,i);e&&r!==e.id&&(n(e),o((0,g.Dq)(null)))}}),[i,t,r,n,o,s])})({reportConfigurations:Fe,onSelectReportConfiguration:Dt,selectedReportConfigurationId:$e});const Rt=(0,a.useCallback)((async e=>{let t=e.displayName,n=e.includeReportView,a=e.generatedName;const l=t.trim();if(Ke)return void Ve(Ke,l);(null===a||void 0===a?void 0:a.toLowerCase())===l.toLowerCase()&&(0,Ge.u4)(Ye.m2.ReportConfigurationUsedGeneratedName,{name:a});const r=(0,CX.WD)(X),o=n?(0,RJe.qf)(J):void 0;await Ue(l,r,o)}),[Ke,X,J,Ue,Ve]),Mt=(0,a.useCallback)((e=>a.createElement(PXe,Object.assign({data:ct,isLoading:dt,title:wt,currentTab:f,groupByTimeframe:ee,summary:tt},(0,XX.A)(["total"],e),{total:(0,RJe.yZ)(e.total),showAllEntities:$,onChangeShowAllEntities:Z,selectedDatumId:oe,onSelectDatum:Ct,onClearDatumSelection:At,onSelectDateRange:kt,selectedDateRange:ie,treemapDrillStack:Ae,treemapRootBreadcrumbLabel:Te,treemapSeedFocusPath:_e,onTreemapSelectDatum:It,onTreemapNavigateToStackIndex:Me,onTreemapClearScope:Re,onTreemapFocusPathChange:Oe}))),[ct,dt,wt,f,ee,tt,$,oe,ie,Z,Ct,At,kt,Ae,Te,_e,It,Me,Re,Oe]),Lt=(0,QQ.j)({filters:se,onParseSuccess:e=>{e.url&&window.open(e.url,"_self","noopener,noreferrer")}}),Ot=Lt.currentSession,Pt=Lt.downloadTransactions,Bt=Lt.isLoading,zt=a.createElement(NJe,{activityView:x,onChangeActivityView:Nt}),Ft=a.createElement("div",{className:"inline-flex shrink-0"},zt),Gt=a.createElement(kQ.j,{transactionFilters:null!==(r=lt.filters)&&void 0!==r?r:{},quickViewFilters:ne,onRemoveQuickViewFilters:de,hideQuickViewFilterPills:Ne,emptyComponent:a.createElement(XJe,null),sortBy:te,onChangeSortBy:bt,overrideTitle:ye?Ft:a.createElement(xt.v,{size:"large",weight:"medium"},"Transactions"),refetchSummary:yt,headerShouldHaveSortControls:!0});return a.createElement(Dc.t,{"data-external-id":"reports"},a.createElement(Yq,{name:"Reports",tabs:a.createElement(n0e,null),controls:"taxForms"!==f?a.createElement(PQe,{currentTab:f,paychecksOwnerIds:M,onChangePaychecksOwnerIds:L,paychecksEmployerId:B,onChangePaychecksEmployerId:z,reportConfigurations:Fe,selectedReportConfigurationId:$e,onSelectReportConfiguration:Dt,onSaveReportConfiguration:V,onEditReportConfiguration:e=>{let t=e.id;qe(t),V()}}):void 0,emptyIcon:"pie-chart",emptyTitle:_t.zZ.EMPTY_STATE_TITLE,emptyButtonText:_t.zZ.EMPTY_STATE_BUTTON,scrollKey:f,pageError:pt,isLoading:mt},a.createElement(l.BV,null,a.createElement(l.qh,{path:I.JZ.reports.taxForms.relativePath,element:Pe}),a.createElement(l.qh,{path:I.JZ.reports.taxForms.export.path.replace(I.JZ.reports.path,"").replace(/^\//,""),element:Be})),"taxForms"!==f&&a.createElement(o3e,{template:xe,md:we},a.createElement(QU.E,{area:"chart"},a.createElement(l.BV,null,a.createElement(l.qh,{path:"",element:a.createElement(l.C5,{to:l3e,replace:!0})}),a.createElement(l.qh,{path:I.JZ.reports.cashFlow.relativePath,element:a.createElement(a.Fragment,null,a.createElement(rV.T,{screenName:"Reports",tab:"cashFlow",isInfiniteScroll:!0}),a.createElement(d3e,null,a.createElement(c3e,{label:"Total income",value:a.createElement(kJe,{formatter:rl.vv,value:null!==(s=null===tt||void 0===tt?void 0:tt.sumIncome)&&void 0!==s?s:0,color:"greenText"}),isLoading:nt}),a.createElement(c3e,{label:"Total expenses",value:a.createElement(kJe,{formatter:rl.vv,value:-1*(null!==(c=null===tt||void 0===tt?void 0:tt.sumExpense)&&void 0!==c?c:0),color:"redText"}),isLoading:nt}),a.createElement(c3e,{label:"Total net income",value:a.createElement(kJe,{formatter:rl.vv,value:null!==(u=null===tt||void 0===tt?void 0:tt.savings)&&void 0!==u?u:0}),isLoading:nt}),a.createElement(c3e,{label:"Savings rate",value:a.createElement(kJe,{formatter:De.l9,value:Math.max(0,null!==(m=null===tt||void 0===tt?void 0:tt.savingsRate)&&void 0!==m?m:0)}),isLoading:nt})),Mt({title:"Cash flow"}))}),a.createElement(l.qh,{path:I.JZ.reports.spending.relativePath,element:a.createElement(a.Fragment,null,a.createElement(rV.T,{screenName:"Reports",tab:"spending",isInfiniteScroll:!0}),Mt({total:null===tt||void 0===tt?void 0:tt.sumExpense}))}),a.createElement(l.qh,{path:I.JZ.reports.income.relativePath,element:a.createElement(a.Fragment,null,a.createElement(rV.T,{screenName:"Reports",tab:"income",isInfiniteScroll:!0}),Mt({total:null===tt||void 0===tt?void 0:tt.sumIncome}))}),a.createElement(l.qh,{path:I.JZ.reports.paychecks.relativePath,element:a.createElement(a.Fragment,null,a.createElement(rV.T,{screenName:"Reports",tab:"paychecks"}
1),a.createElement(A0e,{startDate:Ze.startDate,endDate:Ze.endDate,ownerIds:M,employerId:B||void 0}))}))),!b&&a.createElement(QU.E,{area:"transactions"},be?a.createElement(T4e,{filters:se,quickViewFilters:ne,onRemoveQuickViewFilters:de,groupBy:TJe(null!==Q&&void 0!==Q?Q:Ee.DB0.CATEGORY),onChangeGroupBy:Tt,onSelectDatum:he,title:Ft}):a.createElement(s3e,null,Gt)),!b&&a.createElement(QU.E,{area:"summary",sticky:!0},a.createElement(i3e,{ref:_},be?a.createElement(wJe,{summary:ce?ht:tt,hasData:ce?ft:at,filters:se,isLoading:ce?vt:nt,dateRangeLabel:ge,empty:a.createElement(XJe,null),onClickDownloadPng:K}):a.createElement(KQ,{empty:a.createElement(XJe,null),errorMessage:null!==(p=null===Ot||void 0===Ot?void 0:Ot.errorMessage)&&void 0!==p?p:void 0,filters:se,insightsSource:Ye.rP.Reports,isDownloadingCsv:Bt,isLoading:ce?vt:nt,onChangeFilters:St,onClickDownloadCsv:Pt,transactionsSummary:ce?ht:tt}))),a.createElement(Y,{onClose:()=>qe(null)},a.createElement(a1e,{reportView:J,filters:X,editingReportConfigurationId:Ke,reportConfigurations:Fe,onDeleteReportConfiguration:async e=>{await We(e.id)},onSubmit:Rt})),be&&a.createElement(H,{maxWidth:"840px"},a.createElement(pXe,{chart:a.createElement("div",{className:"p-lg"},a.createElement(D4e,{filters:se,groupBy:TJe(null!==Q&&void 0!==Q?Q:Ee.DB0.CATEGORY)})),header:a.createElement("div",{className:"flex flex-col"},a.createElement(xt.v,{weight:"medium"},"Income & expenses"),a.createElement(xt.v,{size:"small",color:"textLight"},ge)),initialValues:{title:"Cash flow breakdown"},displayProperties:{chartType:V1.Gi.CashFlowChart}})))))},o3e=(0,$d.s)(QU.a)(a3e||(a3e=(0,wc.A)(["pt-0"]))),i3e=u.default.div.withConfig({displayName:"Reports__TransactionsSummaryRefContainer",componentId:"sc-1pq3niv-0"})(["scroll-margin-bottom:",";"],vt.YK.gutter),s3e=u.default.div.withConfig({displayName:"Reports__WithShadow",componentId:"sc-1pq3niv-1"})([""," background-color:",";border-radius:",";"],wn.M.medium,vt.yW.white,vt.r8.medium),c3e=(0,u.default)(MZ).attrs({"data-sc-tw":"Reports__StatisticCardGrow"}).withConfig({displayName:"Reports__StatisticCardGrow",componentId:"sc-1pq3niv-2"})(["flex:1;"]),d3e=(0,u.default)(m.g).attrs({justifyBetween:!0,alignCenter:!0,gap:"gutter"}).withConfig({displayName:"Reports__SummaryCardsContainer",componentId:"sc-1pq3niv-3"})(["margin-top:0;margin-bottom:",";@media (max-width:","px){flex-flow:row wrap;gap:",";margin:"," 0 ",";> [data-sc-tw~='Reports__StatisticCardGrow']{flex-basis:33%;}}@media (max-width:","px){> [data-sc-tw~='Reports__StatisticCardGrow']{flex-basis:50%;}}"],vt.YK.gutter,vt.nm.md,vt.YK.small,vt.YK.gutter,vt.YK.small,vt.nm.xs),u3e={slug:"under_consideration",title:"Under consideration",statusSlugs:["under_consideration","backlog"]},m3e=[u3e,{slug:"up_next",title:"Up Next",statusSlugs:["up_next"]},{slug:"in_progress",title:"In Progress",statusSlugs:["in_progress"]},{slug:"released",title:"Released",statusSlugs:["released"]}],p3e=e=>{var t;return null!==(t=m3e.find((t=>t.statusSlugs.includes(e))))&&void 0!==t?t:u3e},g3e=(0,Qt.J)("\n  query Common_ProductRoadmap {\n    productRoadmap {\n      projects {\n        id\n        title\n        description\n        productArea\n        status\n        icon\n        blogPostUrl\n      }\n    }\n  }\n"),h3e={tile:"bg-background-tertiary",icon:"text-content-secondary"},v3e={under_consideration:h3e,up_next:{tile:"bg-background-info",icon:"text-content-info"},in_progress:{tile:"bg-background-warning",icon:"text-content-warning"},released:{tile:"bg-background-success",icon:"text-content-success"}},f3e=e=>{var t;return null!==(t=v3e[e])&&void 0!==t?t:h3e},E3e={dashboard:"layout",accounts:"institution",transactions:"credit-card","cash flow":"sankey",reports:"bar-chart",budget:"pie-chart",goals:"target",investments:"trending-up",recurring:"calendar",forecasting:"gauge"},y3e=e=>{var t,n;return null!==(t=null!==(n=e.icon?(0,fe.lSP)(e.icon):void 0)&&void 0!==n?n:E3e[e.productArea])&&void 0!==t?t:"sparkles"},b3e={under_consideration:"bg-divider-tertiary",up_next:"bg-progress-info",in_progress:"bg-progress-warning",released:"bg-progress-success"},x3e=()=>{const e=(0,et.I)(g3e,{fetchPolicy:"network-only"}),t=e.data,n=e.isLoadingInitialData,l=e.error,r=(0,a.useState)(!1),i=(0,o.A)(r,2),s=i[0],c=i[1],d=(0,a.useState)(),u=(0,o.A)(d,2),m=u[0],p=u[1],g=(0,a.useMemo)((()=>{var e;return(e=>{const t=new Map;return e.forEach((e=>{var n;const a=p3e(e.status),l=null!==(n=t.get(a.slug))&&void 0!==n?n:[];l.push(e),t.set(a.slug,l)})),m3e.map((e=>{var n;return(0,U.A)((0,U.A)({},e),{},{projects:null!==(n=t.get(e.slug))&&void 0!==n?n:[]})}))})(null!==(e=null===t||void 0===t?void 0:t.productRoadmap.projects)&&void 0!==e?e:[])}),[t]);return a.createElement(a.Fragment,null,a.createElement(rG.Y,{name:"Product Roadmap",parentRoute:null,isLoading:n,pageError:Boolean(l),controls:a.createElement(fe.XZZ,{variant:"primary",size:"sm",className:"self-center",onClick:()=>c(!0)},"Share your ideas or feedback")},a.createElement("div",{className:"w-full overflow-x-auto p-default"},a.createElement("div",{className:"grid min-w-296 grid-cols-4 items-start gap-default"},g.map((e=>a.createElement(w3e,{key:e.slug,section:e,projects:e.projects,onShareFeedback:p})))))),a.createElement(Sre,{mode:"general",open:s,onOpenChange:c,source:"roadmap_page"}),m&&a.createElement(Sre,{mode:"released"===p3e(m.status).slug?"released":"project",open:!0,projectExternalId:m.id,projectName:m.title,projectDescription:m.description,projectIcon:y3e(m),projectIconClasses:f3e(p3e(m.status).slug),source:"roadmap_project",onOpenChange:e=>{e||p(void 0)}}))},w3e=e=>{let t=e.section,n=e.projects,l=e.onShareFeedback;return a.createElement("section",{"data-external-id":"roadmap-column","aria-labelledby":"roadmap-".concat(t.slug),className:"flex flex-col gap-sm"},a.createElement("div",{className:"flex items-center gap-xs rounded-sm bg-background-tertiary px-default py-xs"}
1,a.createElement("span",{"aria-hidden":!0,className:(0,q.cn)("size-2 rounded-full",b3e[t.slug])}),a.createElement(fe.c8D,{id:"roadmap-".concat(t.slug),size:"base"},t.title),"released"===t.slug&&a.createElement(fe.c8D,{className:"ml-auto",size:"xs",color:"secondary"},"Last 3 months")),n.map((e=>a.createElement(C3e,{key:e.id,section:t,project:e,onShareFeedback:l}))))},C3e=e=>{let t=e.section,n=e.project,l=e.onShareFeedback;const r=f3e(t.slug),o="released"===t.slug&&Boolean(n.blogPostUrl),i=(0,a.useId)();return a.createElement(fe.xz6,{"data-external-id":"roadmap-card",className:"flex flex-col gap-2xs shadow-sm transition-colors hover:bg-background-primary-hover"},a.createElement("button",{type:"button","aria-label":"Share feedback on ".concat(n.title),"aria-describedby":i,className:(0,q.cn)("\n            flex w-full cursor-pointer flex-col items-start gap-sm rounded-default border-none\n            bg-transparent p-default text-left\n          ",o&&"pb-0"),onClick:()=>l(n)},a.createElement("span",{"aria-hidden":!0,className:(0,q.cn)("flex size-8 items-center justify-center rounded-sm",r.tile)},a.createElement(fe.jeH,{name:y3e(n),className:r.icon})),a.createElement("div",{className:"flex flex-col gap-3xs"},a.createElement(fe.c8D,{size:"base",weight:"medium"},n.title),a.createElement(fe.c8D,{id:i,size:"sm",className:"leading-5"},n.description))),o&&a.createElement(fe.liZ,{href:n.blogPostUrl,external:!0,size:"sm","aria-label":"Learn more about ".concat(n.title),className:"mx-default mb-default"},"Learn more"))};var A3e=n(16235),I3e=n(27276);const k3e=e=>{let t=e.account,n=e.className,l=e.isLast,o=e.isNeverAmortizing,i=e.onEditAccount;const s=t.displayName,c=t.displayBalance,d=t.displayLastUpdatedAt,u=t.type,p=t.minimumPayment,g=t.apr,h=t.interestRate,v=t.plannedPayment,f=(0,A3e.W)({refetchQueries:[FPe.wq]}),E=(0,I3e.Le)({accountTypeName:u.name,minimumPayment:p,apr:g,interestRate:h,plannedPayment:v}),y=E.missingRequiredInfoLabel,b=E.interestRateLabel,x=E.minPaymentLabel;return a.createElement(S3e,{"data-external-id":"debt-account-list-item",className:n,$isLast:l},a.createElement(_3e,null,a.createElement(Gl.v,{logoUrl:t.logoUrl,icon:t.icon,size:40}),a.createElement(ZY.B,{column:!0,full:!0},a.createElement("div",{className:"flex items-center gap-2xs"},a.createElement(xt.v,fl.TN,s)),(0,r.YW)({missingRequiredInfoLabel:y,isNeverAmortizing:o}).with({missingRequiredInfoLabel:r.P.string},(e=>{let n=e.missingRequiredInfoLabel;return a.createElement("div",{className:"flex items-center gap-sm"},a.createElement(bn.v,{onClick:()=>i(t.id),className:"pl-0"},n))})).with({isNeverAmortizing:!0},(()=>a.createElement(bn.v,{onClick:()=>i(t.id),className:"self-start pl-0"},_t.RU.NEVER_AMORTIZING_ACCOUNT_LABEL))).otherwise((()=>a.createElement("div",{className:"flex items-center gap-sm"},b&&a.createElement(a.Fragment,null,a.createElement(N3e,null,b),a.createElement(R3e,null)),!b&&a.createElement(R3e,null),a.createElement(N3e,null,x)))))),a.createElement(D3e,null,a.createElement(ZY.B,{column:!0,alignEnd:!0,justifyCenter:!0},a.createElement(xt.v,Object.assign({size:"large"},fl.zs),(0,BY.A)(c)?"?":(0,rl.vv)(c)),a.createElement(T3e,null,a.createElement(ZY.B,{alignCenter:!0},a.createElement(m.g,{justifyCenter:!0},a.createElement(xt.v,null,a.createElement(roe.T,{date:d})))))),a.createElement(M3e,null,a.createElement(fA.A,{overlay:a.createElement(Ji.SP,null,a.createElement(Ji.xm,{onClick:()=>i(t.id)},"Edit account details"),a.createElement(Ji.xm,{onClick:()=>{f(t.id,!t.excludeFromDebtPaydown)}},t.excludeFromDebtPaydown?_t.RU.INCLUDE_ACCOUNT_ACTION:_t.RU.EXCLUDE_ACCOUNT_ACTION)),placement:"bottom-end"},(e=>{let t=e.toggleOpen,n=e.isOpen;return a.createElement(B.L,{icon:"more-horizontal",size:"small",onClick:()=>{t()},active:n})})))))},S3e=u.default.div.withConfig({displayName:"DebtAccountListItem__Root",componentId:"sc-1nqs4s8-0"})(["display:flex;flex-flow:row nowrap;align-items:center;justify-content:space-between;gap:",";border-bottom:1px solid ",";padding:"," ",";color:inherit;background-color:",";transition:",";",""],vt.YK.small,vt.Ee.color.divider.primary,vt.YK.default,vt.YK.large,vt.Ee.color.background.primary,(e=>e.theme.transition.default),(e=>{let t=e.theme;return e.$isLast&&(0,u.css)(["border-bottom:none;border-radius:0 0 "," ",";
1"],t.radius.medium,t.radius.medium)})),N3e=u.default.span.withConfig({displayName:"DebtAccountListItem__SubText",componentId:"sc-1nqs4s8-1"})(["font-size:",";color:",";margin-top:0;"],(e=>e.theme.fontSize.small),(e=>e.theme.color.textLight)),T3e=u.default.span.withConfig({displayName:"DebtAccountListItem__StatusSubText",componentId:"sc-1nqs4s8-2"})(["font-size:",";color:",";margin-top:0;display:flex;flex-direction:column;align-items:flex-end;"],(e=>e.theme.fontSize.small),(e=>e.theme.color.textLight)),_3e=(0,u.default)(m.g).attrs({gap:"default",alignCenter:!0}).withConfig({displayName:"DebtAccountListItem__AccountInfo",componentId:"sc-1nqs4s8-3"})(["flex:1;"]),D3e=(0,u.default)(m.g).attrs({justifyEnd:!0,alignCenter:!0,gap:"small"}).withConfig({displayName:"DebtAccountListItem__AccountBalanceCell",componentId:"sc-1nqs4s8-4"})(["width:150px;"]),R3e=u.default.div.withConfig({displayName:"DebtAccountListItem__DividerLine",componentId:"sc-1nqs4s8-5"})(["height:16px;width:1px;background-color:",";align-self:center;"],vt.Ee.color.divider.secondary),M3e=u.default.div.withConfig({displayName:"DebtAccountListItem__MoreButtonWrapper",componentId:"sc-1nqs4s8-6"})(["flex-shrink:0;"]),L3e=e=>{let t=e.accounts,n=e.neverAmortizingAccountIds,l=e.onEditAccount;const r=(0,I3e._V)(t),i=(0,o.A)(r,2),s=i[0],c=i[1];return a.createElement("div",{"data-external-id":"debt-account-group-list"},s.map(((e,t)=>a.createElement(k3e,{key:e.id,account:e,isLast:(0,PY.A)(c)&&t===s.length-1,isNeverAmortizing:null===n||void 0===n?void 0:n.includes(e.id),onEditAccount:l}))),c.length>0&&a.createElement(oK,{showText:"Show ".concat(O3e(c.length)),hideText:"Hide ".concat(O3e(c.length))},c.map((e=>a.createElement(P3e,{key:e.id,account:e,onEditAccount:l})))))},O3e=e=>(0,De.td)("excluded account",e,{inclusive:!0}),P3e=(0,u.default)(k3e).withConfig({displayName:"DebtAccountGroupList__HiddenAccountListItem",componentId:"dqvpvs-0"})(["background:",";&:hover{background:inherit;}&&{border-bottom:1px solid ",";border-radius:0;}"],vt.Ee.color.background.secondary,vt.Ee.color.divider.secondary),B3e=e=>{let t=e.accounts,n=e.className,l=e.neverAmortizingAccountIds,r=e.onAccountUpdated;const i=(0,a.useState)(null),s=(0,o.A)(i,2),c=s[0],d=s[1],u=(0,I3e.W0)(t),m=e=>{d(e)},p=()=>{d(null)};return a.createElement(z3e,{"data-external-id":"debt-accounts-list",className:n},u.map((e=>{let t=e.accounts,n=e.type,r=e.displayName;return a.createElement(F3e,{key:n},a.createElement(Xl.AM,{title:r},a.createElement(L3e,{groupName:r,accounts:t,neverAmortizingAccountIds:l,onEditAccount:m})))})),c&&a.createElement(um.b,{onClose:p},a.createElement(XY.r,{accountId:c,onDone:()=>{p(),r()},onClose:p})))},z3e=u.default.div.withConfig({displayName:"DebtAccountsList__Root",componentId:"blsoel-0"})(["display:flex;flex-direction:column;"]),F3e=u.default.div.withConfig({displayName:"DebtAccountsList__DebtAccountGroup",componentId:"blsoel-1"})(["padding-bottom:",";"],(e=>e.theme.spacing.gutter)),G3e=()=>{var e;const t=(0,Sq.k)().close,n=(0,A3e.W)(),l=(0,et.I)(FPe.Df,{fetchPolicy:"cache-first"}),o=l.data,i=l.isLoadingInitialData,s=null!==(e=null===o||void 0===o?void 0:o.debtAccounts)&&void 0!==e?e:[],c=(0,I3e.W0)(s);return a.createElement(Rc.L,{"data-external-id":"edit-paydown-accounts-modal-card",title:_t.$.EDIT_PAY_DOWN_ACCOUNTS_MODAL.TITLE},a.createElement(Y3e,null,a.createElement(U3e,null,a.createElement(xt.v,{size:"20",weight:"medium"},_t.$.EDIT_PAY_DOWN_ACCOUNTS_MODAL.PROMPT),a.createElement(xt.v,{size:"base",color:"content.secondary"},_t.$.EDIT_PAY_DOWN_ACCOUNTS_MODAL.DESCRIPTION)),(0,r.YW)({isLoadingInitialData:i,hasAccounts:s.length>0}).with({isLoadingInitialData:!0},(()=>a.createElement(m.g,{center:!0,margin:"xlarge"},a.createElement(p.i,null)))).with({hasAccounts:!1},(()=>a.createElement(cU.vx,{title:"No debt accounts"}))).otherwise((()=>c.map((e=>a.createElement(V3e,{key:e.type},a.createElement(xt.v,{size:"large",weight:"medium",color:"content.primary"},e.displayName),e.accounts.map((e=>a.createElement(W3e,{key:e.id},a.createElement(Gl.v,{logoUrl:e.logoUrl,icon:e.icon,size:40}),a.createElement(j3e,null,a.createElement(H3e,null,e.displayName),a.createElement(xt.v,{size:"small",color:"content.secondary"},"Account balance: ",(0,rl.vv)(e.displayBalance))),a.createElement(K3e,{checked:!e.excludeFromDebtPaydown,onChange:()=>{n(e.id,!e.excludeFromDebtPaydown)}})))))))))),a.createElement(Cq.R,null,a.createElement(cu.WT,{onClick:t},"Done")))},Y3e=(0,u.default)(m.g).attrs({column:!0,padding:"xlarge",gap:"xlarge"}).withConfig({displayName:"EditPaydownAccountsModalCard__ContentContainer",componentId:"sc-1n80r9e-0"})([""]),U3e=(0,u.default)(m.g).attrs({column:!0,gap:"xsmall"}).withConfig({displayName:"EditPaydownAccountsModalCard__HeaderContainer",componentId:"sc-1n80r9e-1"})([""]),V3e=(0,u.default)(m.g).attrs({column:!0,gap:"default"}).withConfig({displayName:"EditPaydownAccountsModalCard__GroupContainer",componentId:"sc-1n80r9e-2"})([""]),W3e=(0,u.default)(m.g).attrs({alignCenter:!0}).withConfig({displayName:"EditPaydownAccountsModalCard__ItemContainer",componentId:"sc-1n80r9e-3"})(["padding:"," ",";gap:",";border:1px solid ",";border-radius:",";",""],vt.YK.large,vt.YK.xlarge,vt.YK.small,vt.Ee.color.border.primary,vt.r8.default,wn.M.medium),j3e=(0,u.default)(m.g).attrs({column:!0,overflow:"hidden"}).withConfig({displayName:"EditPaydownAccountsModalCard__AccountInfoContainer",componentId:"sc-1n80r9e-4"})(["flex:1;"]),H3e=(0,u.default)(xt.v).attrs({size:"large"}).withConfig({displayName:"EditPaydownAccountsModalCard__AccountName",componentId:"sc-1n80r9e-5"})(["overflow:hidden;text-overflow:ellipsis;white-space:nowrap;"]),K3e=(0,u.default)(ox.k).attrs({large:!0}).withConfig({displayName:"EditPaydownAccountsModalCard__StyledToggle",componentId:"sc-1n80r9e-6"})(["margin-left:auto;flex-shrink:0;"]),q3e=e=>{let t=e.accounts,n=e.onSave,l=e.onClose;const r=Object.fromEntries(t.map((e=>[e.id,!0])));return a.createElement(Eu.Op,{"data-external-id":"save-projection-to-budget-modal",initialValues:r,onSubmit:e=>{const a=t.map((e=>e.id)),l=a.filter((t=>e[t])),r=a.filter((t=>!e[t]));n(l,r)}},a.createElement($3e,{accounts:t,onClose:l}))},$3e=e=>{let t=e.accounts,n=e.onClose;const l=(0,hu.x)().handleSubmit;return a.createElement(xC.$,{"data-external-id":"modal-content",title:"Ap
1ply pay down plan to budget",confirm:"Save",onConfirm:()=>l(),onCancel:n},a.createElement("div",{className:"flex flex-col gap-sm"},a.createElement(kD.c,null,"Your planned budget contributions for the accounts below will be updated to match your current min/planned payments and savings calculator configuration, starting this month."," ",a.createElement(wb.gz,{href:VF.ey,target:"_blank"},"Learn more")),a.createElement("div",{className:"flex flex-col gap-xs p-sm"},t.map((e=>a.createElement(tC.zB.Checkbox,{key:e.id,name:e.id,label:a.createElement("div",{className:"flex items-center gap-xs"},a.createElement(Gl.v,{logoUrl:e.logoUrl,icon:e.icon,size:24}),a.createElement(xt.v,{size:"base",weight:"book"},e.displayName))}))))))},Z3e=e=>{let t=e.src,n=e.iframeTitle,l=e.trackEvent,r=e.label,i=void 0===r?"Share beta feedback":r;const s=(0,Pd.h)(),c=(0,o.A)(s,2),d=c[0],u=c[1],m=u.open,p=u.close;return a.createElement(a.Fragment,null,a.createElement(wt.Xb,{onClick:m},a.createElement(Yo.r,{name:"message-circle"}),a.createElement("span",null,i)),a.createElement(d,{onClose:p},a.createElement(J3e,{src:t,iframeTitle:n,trackEvent:l})))},J3e=e=>{let t=e.src,n=e.iframeTitle,l=e.trackEvent;return(0,a.useEffect)((()=>{l&&(0,Ge.u4)(l)}),[]),a.createElement(X3e,{"data-external-id":"feedback-modal-content",title:n,src:t,width:"100%",height:"600"})},X3e=u.default.iframe.withConfig({displayName:"InAppFeedbackButton__BorderlessIframe",componentId:"zrzvbd-0"})(["border:none;border-radius:",";"],vt.r8.medium),Q3e=()=>a.createElement(Z3e,{"data-external-id":"savings-goals-in-app-feedback-button",src:D3.nJ,iframeTitle:"Savings Goals In App Feedback",trackEvent:Ye.Y5.GoalsV3FeedbackModalViewed}),e5e=()=>{const e=(0,R3.F)().isOn,t=Nse();return e&&t?a.createElement(a.Fragment,null,a.createElement(Q3e,null),a.createElement(vCe,null)):null},t5e=e=>{let t=e.input,n=e.skip,l=void 0!==n&&n,r=e.showMockData,s=void 0!==r&&r,c=e.onSaveProjectionToBudgetError,d=e.onSaveProjectionToBudgetSuccess;var u;const m=(0,pZ._)(FPe.wq,s,{errorPolicy:"all",variables:{input:t},skip:l}),p=m.data,g=m.error,h=m.isLoadingInitialData,v=m.refetch,f=(0,i.n)(FPe.ve),E=(0,o.A)(f,1)[0],y=(0,a.useCallback)((async(e,n)=>{var a,l;try{const r=null===(l=null===(a=(await E({variables:{input:(0,U.A)((0,U.A)({},t),{},{accountIdsToInclude:e,accountIdsToExclude:n})}})).data)||void 0===a?void 0:a.saveDebtPaydownProjectionToBudget)||void 0===l?void 0:l.errors;(null===r||void 0===r?void 0:r.message)?null===c||void 0===c||c(new Error(r.message)):null===d||void 0===d||d()}catch(g){null===c||void 0===c||c(g instanceof Error?g:new Error(String(g)))}}),[t,c,d,E]);return{debtAccounts:null!==(u=null===p||void 0===p?void 0:p.debtAccounts)&&void 0!==u?u:[],debtPaydownPlan:null===p||void 0===p?void 0:p.debtPaydownPlan,debtProjectionForecastLimit:null===p||void 0===p?void 0:p.debtProjectionForecastLimit,error:g,isLoadingInitialData:h,refetch:v,saveCurrentDebtPaydownProjectionToBudget:y}},n5e=e=>{var t,n;const r=e.debtPaydownPlan,i=e.debtProjectionForecastLimit,s=(0,l.Zp)(),c=(0,d.d4)(A.bk),u=(0,Pd.h)(),m=(0,o.A)(u,2),p=m[0],g=m[1],h=g.open,f=g.close,E=(0,C.RU)(),y=(0,a.useCallback)((e=>{E({title:"Failed to save debt pay down projection to budget.",description:e.message})}),[E]),b=(0,a.useCallback)((()=>{(0,C.oR)({title:"Projection saved to budget!",actions:[{text:"Go to budget",onClick:()=>s(I.JZ.budget())}]})}),[s]),x=(0,Pd.h)(),w=(0,o.A)(x,2),k=w[0],S=w[1],N=S.open,T=S.close,_=(0,R3.F)().isDebtPaydownInBudgetEnabled,D=t5e({input:c,onSaveProjectionToBudgetError:y,onSaveProjectionToBudgetSuccess:b,skip:!0}),R=D.saveCurrentDebtPaydownProjectionToBudget,M=D.refetch,L=(0,I3e.zu)({debtPaydownPlan:r,debtProjectionForecastLimit:i}),O=L.areAllProjectionsBeyondForecastLimit,P=L.hasInsufficientData,B=(0,v.D)((()=>{M(),f()}));return a.createElement(uU.f,{"data-external-id":"debt-paydown-header-controls"},a.createElement(e5e,null),a.createElement(wt.Xb,{onClick:h},a.createElement(Yo.r,{name:"settings"}),a.createElement("span",null,"Manage")),_&&!O&&!P&&a.createElement(cu.WT,{onClick:N},"Save to budget"),a.createElement(p,{onClose:B},a.createElement(G3e,null)),a.createElement(k,null,a.createElement(q3e,{accounts:null!==(t=null===r||void 0===r||null===(n=r.debtAccountProjections)||void 0===n?void 0:n.map((e=>e.account)))&&void 0!==t?t:[],onSave:(e,t)=>
1{R(e,t),T()},onClose:T})))},a5e=e=>{var t,n;let l=e.active,r=e.payload,o=e.accountNames,i=e.accountColors,s=e.hasComparisonData;if(!l||!r||0===r.length)return null;const c=null===(t=r[0])||void 0===t||null===(n=t.payload)||void 0===n?void 0:n.date;if(!c)return null;const d=(0,Mu.A)((e=>e.dataKey),r);let u=0;const m=d.map((e=>{const t=String(e.dataKey),n="number"===typeof e.value?e.value:0;return u+=n,{accountId:t,name:o[t]||"Unknown Account",value:n,color:i[t]||"#000"}})),p=(0,sU.A)(((e,t)=>t.value-e.value),m);return a.createElement(Sa.II,{"data-external-id":"debt-paydown-timeline-chart-tooltip",active:l,header:(0,Ba.Tf)(c),footer:s?void 0:a.createElement(l5e,null,a.createElement(o5e,null,"Debt Balance"),(0,rl.vv)(u))},a.createElement(a.Fragment,null,p.map((e=>{const t=0===e.value;return a.createElement(l5e,{key:e.accountId,$isPaidOff:t},a.createElement(r5e,null,a.createElement(mie.FiCircle,{fill:e.color,fillOpacity:1,stroke:e.color})),a.createElement(o5e,null,e.name),(0,rl.vv)(e.value))}))))},l5e=(0,u.default)(ZY.B).withConfig({displayName:"DebtPaydownTimelineChartTooltip__Row",componentId:"sc-1y8d96b-0"})(["justify-content:space-between;font-weight:",";font-size:",";opacity:",";"],(e=>e.theme.fontWeight.medium),(e=>e.theme.fontSize.xsmall),(e=>e.$isPaidOff?.5:1)),r5e=u.default.span.withConfig({displayName:"DebtPaydownTimelineChartTooltip__RowIcon",componentId:"sc-1y8d96b-1"})(["margin-right:8px;position:relative;top:2px;font-size:",";"],(e=>e.theme.fontSize.xxsmall)),o5e=u.default.span.withConfig({displayName:"DebtPaydownTimelineChartTooltip__RowLabel",componentId:"sc-1y8d96b-2"})(["flex-grow:1;text-align:left;margin-right:",";"],(e=>e.theme.spacing.large)),i5e={top:10,right:10,bottom:10,left:10},s5e=e=>{let t=e.debtAccountProjections,n=e.className,l=e.maxDebtPaydownChartDataWithoutAdditionalPayments,r=e.isDebtFreeDateBeyondForecastLimit,o=e.debtProjectionForecastLimit,i=e.hasInsufficientData,s=e.hasNeverAmortizingDebt,c=e.areAllProjectionsNeverAmortizing;const d=(0,u.useTheme)(),p=(0,a.useRef)(null),g=(0,I3e.eq)({debtAccountProjections:t,maxDebtPaydownChartDataWithoutAdditionalPayments:l,isDebtFreeDateBeyondForecastLimit:r,hasInsufficientData:!1,theme:d}),h=g.chartData,v=g.accountColors,f=g.accountNames,E=g.sortedProjections,y=g.hasComparisonData,b=t.length>0&&!r&&!i&&!s,x=(0,a.useMemo)((()=>{if(!b)return{yDataKeys:[],lineOptions:[]};const e=E.map((e=>e.account.id)),t=y?[...e,I3e.ak]:e,n=E.map((e=>({lineColor:v[e.account.id],hasArea:!0,legendName:e.account.displayName,strokeWidth:4}))),a={lineColor:v[I3e.ak],hasArea:!1,strokeWidth:4,isDashed:!0};return{yDataKeys:t,lineOptions:y?[...n,a]:n}}),[b,E,v,y]),w=x.yDataKeys,C=x.lineOptions,A=a.createElement(m.g,{gap:"default",alignCenter:!0,justifyBetween:!0,style:{width:"100%"}},a.createElement(MA.c,null,a.createElement(RA.Q,{index:0,$background:"card"},"Timeline"),a.createElement(RA.Q,{index:1,$background:"card"},"Principal & Interest")),b&&a.createElement(a.Fragment,null,a.createElement(tMe,{element:p.current,fileName:"debt-paydown-timeline-".concat((0,Ba.Fv)(new Date),".png"),type:"Debt Paydown Timeline",label:"Export"})));return a.createElement(Dc.t,{"data-external-id":"debt-paydown-timeline-chart",initialIndex:0},a.createElement(Xl.AM,{ref:p,className:n,title:"Overview",controls:A},a.createElement(_c.K,{index:0},a.createElement(u5e,null,a.createElement(p5e,null,a.createElement(Do.rT,{height:300,data:h,legendIconType:"circle",xDataKey:"date",yDataKeys:w,lineOptions:C,formatXAxis:Ba.Tf,formatYAxis:rl.Ig,margin:i5e,isAnimationActive:b,smoothGradient:!0,domain:b?["auto","auto"]:[0,1e6],tooltipComponent:e=>a.createElement(a5e,Object.assign({},e,{accountNames:f,accountColors:v,hasComparisonData:y}))}),!b&&a.createElement(m5e,null,a.createElement(d5e,{isDebtFreeDateBeyondForecastLimit:r,debtProjectionForecastLimit:o,hasNeverAmortizingDebt:s,areAllProjectionsNeverAmortizing:c}))))),a.createElement(_c.K,{index:1},a.createElement(g5e,null,a.createElement(c5e,{debtAccountProjections:t,isDebtFreeDateBeyondForecastLimit:r,debtProjectionForecastLimit:o,hasNeverAmortizingDebt:s,areAllProjectionsNeverAmortizing:c,hasData:b})))))},c5e=e=>{let t=e.debtAccountProjections,n=e.isDebtFreeDateBeyondForecastLimit,l=e.debtProjectionForecastLimit,r=e.hasNeverAmortizingDebt,o=e.areAllProjectionsNeverAmortizing,i=e.hasData;const s=(0,u.useTheme)(),c=(0,a.useMemo)((()=>
1{if(!t||0===t.length)return{principalData:[],interestData:[],totalPrincipal:0,totalInterest:0};const e=(0,I3e.af)(t),n=(0,I3e.Tw)(e,s);let a=0,l=0;return{principalData:e.map((e=>{const t=e.principal||0;return a+=t,{id:e.account.id,label:e.account.displayName,value:t,color:n[e.account.id],formattedValue:(0,rl.vv)(t)}})),interestData:e.map((e=>{const t=e.projectedInterest||0;return l+=t,{id:e.account.id,label:e.account.displayName,value:t,color:n[e.account.id],formattedValue:(0,rl.vv)(t)}})),totalPrincipal:a,totalInterest:l}}),[t,s]),d=c.principalData,p=c.interestData,g=c.totalPrincipal,h=c.totalInterest;return i?a.createElement(QU.a,{"data-external-id":"principal-interest-view",template:'"principal interest" / 1fr 1fr',md:'"principal" "interest"'},a.createElement(QU.E,{area:"principal"},a.createElement(Uo.el,{data:d,pieChartTitle:(0,rl.vv)(g),pieChartSubtitle:"Current Debt Principal",pieChartSize:280,isAnimationActive:!0,legendTitle:"Current Principal"})),a.createElement(QU.E,{area:"interest"},a.createElement(Uo.el,{data:p,pieChartTitle:(0,rl.vv)(h),pieChartSubtitle:"Projected Interest",pieChartSize:280,isAnimationActive:!0,legendTitle:"Projected Interest"}))):a.createElement(m.g,{"data-external-id":"principal-interest-view",column:!0,alignCenter:!0,justifyCenter:!0,height:300},a.createElement(d5e,{isDebtFreeDateBeyondForecastLimit:n,debtProjectionForecastLimit:l,hasNeverAmortizingDebt:r,areAllProjectionsNeverAmortizing:o}))},d5e=e=>{let t=e.isDebtFreeDateBeyondForecastLimit,n=e.debtProjectionForecastLimit,l=e.hasNeverAmortizingDebt,r=e.areAllProjectionsNeverAmortizing;const o=(0,I3e.Yw)({isDebtFreeDateBeyondForecastLimit:t,debtProjectionForecastLimit:n,hasNeverAmortizingDebt:l,areAllProjectionsNeverAmortizing:r}),i=o.icon,s=o.message;return a.createElement(h5e,{"data-external-id":"empty-message-pill"},a.createElement(sl.ZQ,{name:i,size:16}),s)},u5e=u.default.div.withConfig({displayName:"DebtPaydownTimelineChart__ChartContainer",componentId:"lr1fzh-0"})(["padding:",";padding-top:",";.recharts-legend-item-text{margin-top:16px;}"],vt.YK.xlarge,vt.YK.default),m5e=u.default.div.withConfig({displayName:"DebtPaydownTimelineChart__EmptyMessage",componentId:"lr1fzh-1"})(["position:absolute;top:calc(50% - 25px);left:50%;transform:translate(-50%,-50%);display:flex;align-items:center;gap:",";font-size:",";color:",";pointer-events:none;"],vt.YK.xsmall,vt.J.small,vt.Ee.color.content.secondary),p5e=u.default.div.withConfig({displayName:"DebtPaydownTimelineChart__ChartWrapper",componentId:"lr1fzh-2"})(["position:relative;"]),g5e=u.default.div.withConfig({displayName:"DebtPaydownTimelineChart__PrincipalInterestContainer",componentId:"lr1fzh-3"})(["padding:",";"],vt.YK.large),h5e=(0,u.default)(m.g).attrs({alignCenter:!0,gap:"xsmall"}).withConfig({displayName:"DebtPaydownTimelineChart__Pill",componentId:"lr1fzh-4"})(["color:",";padding:"," ",";border-radius:",";border:1px solid ",";font-weight:",";background-color:",";font-size:",";",";"],vt.Ee.color.content.primary,vt.YK.xsmall,vt.YK.default,vt.r8.pill,vt.Ee.color.border.primary,vt.Wy.medium,vt.Ee.color.background.primary,vt.J.xsmall,wn.M.medium);var v5e=n(27070);const f5e=e=>{var t,n,l,r,o;let i=e.onClear;const s=(0,d.wA)(),c=(0,d.d4)(ft.bk),u=(0,xy.d)(c,3e3),m=(0,a.useCallback)((e=>{const t=e.debtPaydownMethod===Ee.xfn.PLANNED?(0,U.A)((0,U.A)({},e),{},{additionalMonthlyPayment:void 0,additionalOneTimePayment:void 0}):e;s((0,g.hl)(t))}),[s]);(0,a.useEffect)((()=>{b5e(u)}),[u]);const p=(null!==(t=c.additionalMonthlyPayment)&&void 0!==t?t:0)>0||(null!==(n=c.additionalOneTimePayment)&&void 0!==n?n:0)>0,h=(0,a.useMemo)((()=>p?a.createElement(OK,{onClick:i},"Clear"):null),[p,i]);return a.createElement(Xl.AM,{"data-external-id":"savings-calculator",title:"Savings Calculator",controls:h},a.createElement(Eu.lV,{onSubmit:m,initialValues:{additionalMonthlyPayment:null!==(l=c.additionalMonthlyPayment)&&void 0!==l?l:void 0,additionalOneTimePayment:null!==(r=c.additionalOneTimePayment)&&void 0!==r?r:void 0,debtPaydownMethod:null!==(o=c.debtPaydownMethod)&&void 0!==o?o:Ee.xfn.PLANNED},submitOnChange:!0,submitOnChangeDebounceMs:1e3},a.createElement(x5e,{name:"debtPaydownMethod",hideLabel:!0,options:[{value:Ee.xfn.PLANNED,label:"Planned payments",description:a.createElement(xt.v,{size:"small"},_t.RU.DEBT_PAYDOWN_METHOD_DESCRIPTION.PLANNED_PAYMENTS)},{value:Ee.xfn.AVALANCHE,label:"Avalanche",description:a.createElement(xt.v,{size:"small"},_t.RU.DEBT_PAYDOWN_METHOD_DESCRIPTION.AVALANCHE," ",a.createElement(wb.gz,{href:VF.$B,target:"_blank",rel:"noopener noreferrer"},_t.Hk)),bottomAccessory:a.createElement(y5e,null)},{value:Ee.xfn.SNOWBALL,label:"Snowball",description:a.createElement(xt.v,{size:"small"},_t.RU.DEBT_PAYDOWN_METHOD_DESCRIPTION.SNOWBALL," ",a.createElement(wb.gz,{href:VF.Sy,target:"_blank",rel:"noopener noreferrer"},_t.Hk)),bottomAccessory:a.createElement(y5e,null)}]})))},E5e=e=>{let t=e.name,n=e.label;return a.createElement(tC.zB,{"data-external-id":"steppable-payment-field",name:t,label:n,className:fl.TN.className},(e=>{var t;return a.createElement(fe.K$5.Root,{value:null!==(t=e.value)&&void 0!==t?t:null,format:{maximumFractionDigits:0},onValueChange:t=>e.onChange(t),onBlur:e.onBlur,min:0},a.createElement(fe.i9A,{invalid:e.invalid},a.createElement(fe.K$5.Input,Object.assign({name:e.name,placeholder:"$0"},(0,Ex.p)("numeric-input"))),a.createElement(fe.i9A.Addon,{align:"inline-end"},a.createElement(fe._CU.Decrement,null),a.createElement(fe._CU.Increment,null))))}))},y5e=()=>a.createElement("div",{"data-external-id":"additional-payment-fields",className:"flex w-full flex-col gap-default pt-xs"},a.createElement(E5e,{name:"additionalMonthlyPayment",label:"Additional monthly payment"}),a.createElement(E5e,{name:"additionalOneTimePayment",label:"Additional one-time payment"})),b5e=e=>{var t,n;(e.additionalMonthlyPayment||e.additionalOneTimePayment)&&(0,Ge.u4)(Ye.sk.CalculatorUsed,{additional_monthly_payment:null!==(t=e.additionalMonthlyPayment)&&void 0!==t?t:0,additional_one_time_payment:null!==(n=e.additionalOneTimePayment)&&void 0!==n?n:0,debt_paydown_method:e.debtPaydownMethod,client_platform:v5e.B})},x5e=(0,u.default)($Oe.c).withConfig({displayName:"SavingsCalculator__StyledRadioGroupField",componentId:"sc-6abw0t-0"})(["& > * > *{border-left-width:0px;border-right-width:0px;&:first-child{border-top-width:0px;}}"]),w5e=e=>{let t=e.className;return a.createElement("div",{"data-external-id":"goals-legal-disclaimer",className:(0,q.cn)("px-gutter pb-gutter",t)},a.createElement(fe.c8D,{className:"text-xs text-content-secondary"},_t.h0))},C5e=()=>{const e=(0,vQ.N)().path;return a.createElement("div",{"data-external-id":"goals-header-tabs",className:"ml-sm flex items-center gap-default"},a.createElement(A5e,{to:{pathname:e}},"Save up"),a.createElement(A5e,{to:{pathname:I.JZ.goals.debtPaydown.path}},"Pay down"))},A5e=(0,u.default)(MCe).withConfig({displayName:"GoalsHeaderTabs__StyledTab",componentId:"zufsx8-0"})(["font-size:",";align-items:center;display:flex;"],vt.J.base),I5e=["children","scrollDepthTab"],k5e=e=>{let t=e.children,n=e.scrollDepthTab,l=(0,En.A)(e,I5e);return a.createElement(Yq,Object.assign({"data-external-id":"savings-goals-page-shell",parentRoute:null,name:"Goals",emptyIcon:"target",emptyTitle:_t.DX,tabs:a.createElement(C5e,null)},l),a.createElement(rV.T,{screenName:"Goals",tab:n}),t)};var S5e;const N5e=()=>{const e=(0,d.d4)(gG.pk),t=(0,d.d4)(ft.bk),n=t5e({input:t,showMockData:e}),l=n.debtAccounts,r=n.debtPaydownPlan,o=n.debtProjectionForecastLimit,i=n.isLoadingInitialData,s=n.refetch;return a.createElement(k5e,{"data-external-id":"debt-paydown",scrollDepthTab:"debt-paydown",controls:a.createElement(n5e,{debtPaydownPlan:r,debtProjectionForecastLimit:o})},a.createElement(T5e,{debtAccounts:l,debtPaydownPlan:r,debtProjectionForecastLimit:o,isLoadingInitialData:i,refetch:s}))},T5e=e=>{var t;const n=e.debtAccounts,o=e.debtPaydownPlan,i=e.debtProjectionForecastLimit,s=e.isLoadingInitialData,c=e.refetch,u=(0,l.Zp)(),m=(0,d.wA)(),h=(0,d.d4)(ft.bk),v=(0,a.useCallback)((()=>{var e,t;(0,Ge.u4)(Ye.sk.CalculatorResultCleared,{additional_monthly_payment:null!==(e=h.additionalMonthlyPayment)&&void 0!==e?e:0,additional_one_time_payment:null!==(t=h.additionalOneTimePayment)&&void 0!==t?t:0,debt_paydown_method:h.debtPaydownMethod,client_platform:v5e.B}),m((0,g.w)())}),[m,h]),f=(0,I3e.zu)({debtPaydownPlan:o,debtProjectionForecastLimit:i}),E=f.currentDebtPrincipal,y=f.projectedInterest,b=f.projectedTotal,x=f.debtFreeDate,w=f.projectedInterestSavings,C=f.projectedTotalSavings,A=f.debtFreeDateSavings,k=f.areAllProjectionsBeyondForecastLimit,S=f.hasInsufficientData,N=f.hasNeverAmortizingDebt,T=f.areAllProjectionsNeverAmortizing,_=f.neverAmortizingAccountIds,D=!!h.additionalMonthlyPayment||!!h.additionalOneTimePayment,R=!!h.debtPaydownMethod&&I3e.jf.includes(h.debtPaydownMethod),M=!!h.additionalMonthlyPayment&&h.additionalMonthlyPayment>0,L=!!h.additionalOneTimePayment&&h.additionalOneTimePayment>0;return s?a.createElement(a.Fragment,null,a.createElement(p.i,{label:"Loading debt accounts..."}),a.createElement(w5e,null)):a.createElement(a.Fragment,null,a.createElement(_5e,{template:"".concat(R?'"banner banner "':"",' "highlight highlight" "chart chart" "accounts calculator" / 2fr 1fr'),md:"".concat(R?'"banner" ':"",'"highlight" "chart" "accounts" "calculator"')},R&&a.createElement(QU.E,{area:"banner"},a.createElement(fu.g,{type:"gradient"},a.createElement("div",{className:"flex items-center justify-between"},a.createElement(xt.v,{size:"small"},M&&a.createElement(a.Fragment,null,"Additional monthly payment of"," ",a.createElement(B5e,null,(0,rl.vv)(h.additionalMonthlyPayment))," ","applied,"," "),L&&a.createElement(a.Fragment,null,M?"additional":"Additional"," one time payment of"," ",a.createElement(B5e,null,(0,rl.vv)(h.additionalOneTimePayment))," ","applied,"," "),a.createElement(a.Fragment,null,D?"utilizing the ":"Utilizing the ",a.createElement(B5e,null,h.debtPaydownMethod===Ee.xfn.AVALANCHE?"Avalanche":"Snowball"," ","Method"))),a.createElement(P5e,{size:"small",onClick:v},"Clear")))),a.createElement(QU.E,{area:"highlight"},a.createElement(M5e,null,a.createElement(R5e,{value:a.createElement(Y5,{value:E}),label:a.createElement(D5e,null,"Current Debt Principal"),tooltipText:"This is the current sum of the debt accounts you've chosen to include",isLoading:s,subtitle:D?a.createElement(O5e,null):void 0}),a.createElement(R5e,{value:null===y?I3e.dv:a.createElement(Y5,{value:y}),label:a.createElement(D5e,null,"Projected Interest"),tooltipText:"This is the total remaining interest you will pay in the process of paying off your loans",isLoading:s,subtitle:(0,r.YW)({projectedInterestSavings:w,hasAdditionalPayments:D}).with({projectedInterestSavings:r.P.string},(e=>{let t=e.projectedInterestSavings;return a.createElement(L5e,null,t)})).with({hasAdditionalPayments:!0},(()=>a.createElement(O5e,null))).otherwise((()=>{}))}),a.createElement(R5e,{value:null===b?I3e.dv:a.createElement(Y5,{value:b}),label:a.createElement(D5e,null,"Total Principal & Interest"),isLoading:s,subtitle:(0,r.YW)({projectedTotalSavings:C,hasAdditionalPayments:D}).with({projectedTotalSavings:r.P.string},(e=>{let t=e.projectedTotalSavings;return a.createElement(L5e,null,t)})).with({hasAdditionalPayments:!0},(()=>a.createElement(O5e,null))).otherwise((()=>{}))}),a.createElement(R5e,{value:x,label:a.createElement(D5e,null,"Debt Free Date"),isLoading:s,subtitle:(0,r.YW)({debtFreeDateSavings:A,hasAdditionalPayments:D}).with({debtFreeDateSavings:r.P.string},(e=>{let t=e.debtFreeDateSavings;return a.createElement(L5e,null,t)})).with({hasAdditionalPayments:!0},(()=>a.createElement(O5e,null))).otherwise((()=>{}))}))),a.createElement(QU.E,{area:"chart"},a.createElement(s5e,{debtAccountProjections:null!==(t=null===o||void 0===o?void 0:o.debtAccountProjections)&&void 0!==t?t:[],maxDebtPaydownChartDataWithoutAdditionalPayments:null===o||void 0===o?void 0:o.maxDebtPaydownChartWithoutAdditionalPayments,isDebtFreeDateBeyondForecastLimit:k,debtProjectionForecastLimit:i,hasInsufficientData:S,hasNeverAmortizingDebt:N,areAllProjectionsNeverAmortizing:T})),n.length>0?a.createElement(QU.E,{area:"accounts"},a.createElement(B3e,{accounts:n,neverAmortizingAccountIds:_,onAccountUpdated:()=>c()})):a.createElement(QU.E,{area:"accounts",style:{gridColumn:"1 / -1"}},a.createElement(Xl.AM,null,a.createElement(cU.vx,{icon:a.createElement(d7.r,{iconSizePx:32,className:"size-16 bg-background-success text-content-success"}),title:"No debt accounts",subtitle:"Congratulations on being debt free! If you haven't added all of your debt accounts, click the button below to add them.",button:{title:"Add account",onClick:()=>u(I.JZ.accounts.addAccount()),isPrimary:!1}}))),n.length>0&&a.createElement(QU.E,{area:"calculator"},a.createElement(f5e,{onClear:v}))),a.createElement(w5e,null))}
1,_5e=(0,$d.s)(QU.a)(S5e||(S5e=(0,wc.A)(["py-0"]))),D5e=(0,u.default)(xt.v).withConfig({displayName:"DebtPaydown__StatisticCardLabel",componentId:"sc-1g7wn0m-0"})(["text-transform:none;font-size:",";font-weight:",";color:",";"],vt.J.small,vt.Wy.medium,vt.Ee.color.content.secondary),R5e=(0,u.default)(MZ).attrs({"data-sc-tw":"DebtPaydown__StatisticCardGrow"}).withConfig({displayName:"DebtPaydown__StatisticCardGrow",componentId:"sc-1g7wn0m-1"})(["flex:1;"]),M5e=(0,u.default)(m.g).attrs({justifyBetween:!0,alignStretch:!0,gap:"gutter"}).withConfig({displayName:"DebtPaydown__SummaryCardsContainer",componentId:"sc-1g7wn0m-2"})(["@media (max-width:","px){flex-flow:row wrap;gap:",";> [data-sc-tw~='DebtPaydown__StatisticCardGrow']{flex-basis:33%;}}@media (max-width:","px){> [data-sc-tw~='DebtPaydown__StatisticCardGrow']{flex-basis:50%;}}"],vt.nm.md,vt.YK.small,vt.nm.xs),L5e=(0,u.default)(xt.v).withConfig({displayName:"DebtPaydown__SummaryCardFooter",componentId:"sc-1g7wn0m-3"})(["font-size:",";font-weight:",";color:",";"],vt.J.small,vt.Wy.medium,vt.Ee.color.content.success),O5e=u.default.div.withConfig({displayName:"DebtPaydown__Divider",componentId:"sc-1g7wn0m-4"})(["width:46px;height:2px;margin:"," 0;background:",";"],vt.YK.xsmall,vt.Ee.color.divider.secondary),P5e=(0,u.default)(cu.WT).withConfig({displayName:"DebtPaydown__BannerClearButton",componentId:"sc-1g7wn0m-5"})(["background-color:rgba(255,255,38,0.15);"]),B5e=u.default.span.withConfig({displayName:"DebtPaydown__UnderLineText",componentId:"sc-1g7wn0m-6"})(["text-decoration:underline;font-weight:",";"],vt.Wy.medium),z5e=e=>{let t=e.option,n=e.listType,a=e.fromGoalId,l=e.isSelected;var o,i;const s=a&&"account"===t.type?null===(i=null===(o=t.balancesByGoal)||void 0===o?void 0:o.get(a))||void 0===i?void 0:i.amount:void 0;return(0,r.YW)({option:t,selectListType:n,goalAllocation:s}).with({option:{type:"goal"},selectListType:"from"},{option:{type:"goal",targetAmount:r.P.nullish}},(e=>{let t=e.option;return"".concat((0,gYe.ne)(t.netContribution)," total saved")})).with({option:{type:"goal",targetAmount:r.P.nonNullable},selectListType:"to"},(e=>{let t=e.option;const n=t.targetAmount-t.netContribution;return"".concat((0,gYe.ne)(n)," left to save")})).with({option:{type:"account"},selectListType:"to",goalAllocation:r.P.nonNullable},(e=>{let t=e.goalAllocation;return"".concat((0,gYe.ne)(t)," ").concat(l?"available to withdraw":"available")})).with({option:{type:"account"}},(e=>{let t=e.option;return"".concat((0,gYe.ne)(Math.max(t.currentBalance,0))," ").concat(l?"available to contribute":"available")})).otherwise((()=>""))},F5e=(e,t)=>(0,r.YW)({type:e,listType:t}).with({listType:"from"},(()=>"Select account or goal")).with({type:"goal"},(()=>"Select account")).with({type:"account"},(()=>"Select goal")).otherwise((()=>"Select account or goal")),G5e=(0,I1.Ik)().shape({from:(0,I1.gl)().required(_t.$.GOAL_ALLOCATION.ERRORS.FROM_REQUIRED),to:(0,I1.gl)().required(_t.$.GOAL_ALLOCATION.ERRORS.TO_REQUIRED),amount:(0,I1.ai)().required(_t.$.GOAL_ALLOCATION.ERRORS.AMOUNT_REQUIRED).min(.01,_t.$.GOAL_ALLOCATION.ERRORS.AMOUNT_REQUIRED).test("amount-validation","Invalid amount",(function(e){var t;const n=this.parent;if(!e||!n.from||!n.to)return!0;const a=n.from,l=n.to;if("goal"===a.type&&"account"===l.type){const n=V5e(a.value);if(n){const a=null===(t=l.balancesByGoal)||void 0===t?void 0:t.get(n);if(a&&e>a.amount)return this.createError({message:_t.$.GOAL_ALLOCATION.ERRORS.AMOUNT_TOO_LARGE_FOR_ALLOCATION})}}return!(e>a.currentBalance)||this.createError({message:"goal"===a.type?_t.$.GOAL_ALLOCATION.ERRORS.AMOUNT_TOO_LARGE_FOR_GOAL:_t.$.GOAL_ALLOCATION.ERRORS.AMOUNT_TOO_LARGE_FOR_ACCOUNT})})),date:(0,I1.Yj)().required(_t.$.GOAL_ALLOCATION.ERRORS.DATE_REQUIRED),includeInBudget:(0,I1.zM)().required()}),Y5e=(e,t)=>"".concat(t,":").concat(e),U5e=e=>e.split(":"),V5e=e=>U5e(e)[1],W5e=e=>e?U5e(e)[0]:null,j5e=e=>Boolean(e&&"goal"===W5e(e)),H5e=e=>Boolean(e&&"account"===W5e(e)),K5e=e=>{let t=e.goalId,n=e.accountId;var l,r;const o=(0,et.I)(Io.H4,{variables:{id:t}}),i=(0,et.I)(Io.d5,{variables:{id:n}}),s=null===(l=o.data)||void 0===l?void 0:l.savingsGoal,c=null===(r=i.data)||void 0===r?void 0:r.account,d=(0,a.useMemo)((()=>s&&c?(e=>{let t=e.goal;var n;const a=e.account.availableBalanceForGoalsUnmemoized,l=e=>{if(e&&!(e>a))return e},r=N.c9.local().toFormat("MMM"),o=t.currentMonthPlannedContributionAmount-t.currentMonthActualBudgetAmount,i=t.targetAmount?t.targetAmount-(null!==(n=t.currentBalance)&&void 0!==n?n:0):void 0;return[{label:"Remaining ".concat(r," budget"),amount:l(o)},{label:"Left to save",amount:l(i)},{label:"Total available",amount:a}].filter((e=>!!e.amount&&e.amount>0))})({goal:s,account:c}):[]),[s,c]);
1return{options:d,isLoading:o.isNetworkRequestInFlight||i.isNetworkRequestInFlight}},q5e=e=>{let t=e.goalId,n=e.accountId,l=e.onSelect;const r=K5e({goalId:t,accountId:n}),o=r.options;return r.isLoading?a.createElement(M.Al,{"data-external-id":"goal-allocation-quick-select",$height:"32px"}):a.createElement(m.g,{"data-external-id":"goal-allocation-quick-select",gap:"small"},o.map((e=>a.createElement($5e,{key:e.label,onClick:()=>l(e.amount),size:"xsmall"},a.createElement(xt.v,{size:"small",weight:"medium",color:"content.secondary"},e.label,":"),a.createElement(xt.v,{size:"small",weight:"medium",color:"content.primary"},(0,rl.vv)(e.amount))))))},$5e=(0,u.default)(wt.Xb).withConfig({displayName:"GoalAllocationQuickSelect__Button",componentId:"wn5n4f-0"})(["gap:",";"],vt.YK.xxxsmall);var Z5e=n(37123),J5e=n(35505),X5e=n(77401),Q5e=n(43203);const e8e=[Io.Dx,Io.pn,Io.jF,Io.l0,Io.H4,Io.iO],t8e=e=>{let t=e.onSuccess,n=e.enableCrypto;const l=(0,et.I)(Io.iO),s=l.data,c=l.error,d=l.isLoadingInitialData,u=(0,et.I)(Io.EJ,{variables:{filters:(0,U.A)((0,U.A)({},(0,D3.QV)(n)),{},{isIncludedInGoalContributions:!0})}}),m=u.data,p=u.error,g=u.isLoadingInitialData,h=(0,a.useMemo)((()=>{var e;return(null!==(e=null===s||void 0===s?void 0:s.savingsGoals)&&void 0!==e?e:[]).filter((e=>!e.archivedAt))}),[null===s||void 0===s?void 0:s.savingsGoals]),v=(0,a.useMemo)((()=>h.map((e=>{var t,n;return{type:"goal",value:Y5e(e.id,"goal"),label:e.name,displayName:e.name,imageStorageProvider:e.imageStorageProvider,imageStorageProviderId:e.imageStorageProviderId,currentBalance:null!==(t=e.currentBalance)&&void 0!==t?t:0,netContribution:null!==(n=e.netContribution)&&void 0!==n?n:0,targetAmount:e.targetAmount}}))),[h]),f=(0,a.useMemo)((()=>new Map(h.map((e=>{var t,n,a;const l=new Set(null!==(a=null===(n=null===(t=e.allocationAmountsByAccount)||void 0===t?void 0:t.filter((e=>{var t,n;return(null!==(t=null===e||void 0===e?void 0:e.totalAmount)&&void 0!==t?t:0)>0&&!(null===(n=null===e||void 0===e?void 0:e.account.linkedGoal)||void 0===n?void 0:n.id)})))||void 0===n?void 0:n.map((e=>null===e||void 0===e?void 0:e.account.id)).filter(Tp.n))&&void 0!==a?a:[]);return[e.id,l]})))),[h]),E=(0,a.useMemo)((()=>{const e=new Map;return h.forEach((t=>{var n,a,l,r;(null!==(r=null===(l=null===(a=null===(n=t.allocationAmountsByAccount)||void 0===n?void 0:n.filter(Tp.n))||void 0===a?void 0:a.filter((e=>{let t=e.totalAmount;return(null!==t&&void 0!==t?t:0)>0})))||void 0===l?void 0:l.map((e=>e.account.id)))&&void 0!==r?r:[]).forEach((n=>{var a;e.has(n)||e.set(n,new Set),null===(a=e.get(n))||void 0===a||a.add(t.id)}))})),e}),[h]),y=(0,a.useMemo)((()=>{var e;return new Map(null!==(e=null===v||void 0===v?void 0:v.map((e=>[e.value,e])))&&void 0!==e?e:[])}),[v]),b=(0,a.useMemo)((()=>{const e=new Map;return h.forEach((t=>{var n;null===(n=f.get(t.id))||void 0===n||n.forEach((n=>{e.has(n)||e.set(n,new Set),e.get(n).add(t.id)}))})),e}),[h,f]),x=(0,a.useMemo)((()=>{const e=(0,wBe.A)((e=>{var t;return(null!==(t=e.allocationAmountsByAccount)&&void 0!==t?t:[]).filter((e=>{var t;return Boolean(null===(t=null===e||void 0===e?void 0:e.account)||void 0===t?void 0:t.id)})).map((t=>{var n;return{accountId:t.account.id,goal:{id:e.id,name:e.name},amount:null!==(n=t.totalAmount)&&void 0!==n?n:0}}))}),h),t=(0,LD.A)((0,mo.A)("accountId"),e);return new Map(Object.entries((0,Q5e.A)((e=>new Map(e.map((e=>[e.goal.id,{goal:e.goal,amount:e.amount}])))),t)))}),[h]),w=(0,a.useMemo)((()=>{var e,t;return(null!==(t=null===(e=null===m||void 0===m?void 0:m.accounts)||void 0===e?void 0:e.filter((e=>{var t;return!(null===(t=e.linkedGoal)||void 0===t?void 0:t.id)})))&&void 0!==t?t:[]).map((e=>{var t,n,a;const l=null!==(t=b.get(e.id))&&void 0!==t?t:new Set,r=null!==(n=x.get(e.id))&&void 0!==n?n:new Map;return{type:"account",value:Y5e(e.id,"account"),label:"".concat(e.displayName," (").concat((0,jt.vv)(e.availableBalanceForGoalsUnmemoized)," available)"),displayName:e.displayName,goalIds:l,currentBalance:null!==(a=e.availableBalanceForGoalsUnmemoized)&&void 0!==a?a:0,balancesByGoal:r,account:e}}))}),[null===m||void 0===m?void 0:m.accounts,b,x]),C=(0,a.useMemo)((()=>new Map(w.map((e=>[e.value,e])))),[w]),A=(0,a.useMemo)((()=>{var e;const t=(null!==(e=null===v||void 0===v?void 0:v.filter((e=>{var t,n;return(null!==(n=null===(t=f.get(V5e(e.value)))||void 0===t?void 0:t.size)&&void 0!==n?n:0)>0})))&&void 0!==e?e:[]).map((e=>y.get(e.value))).filter(Tp.n);return[{label:"Accounts",options:null!==w&&void 0!==w?w:[]},{label:"Goals",options:t}]}),[v,w,f,y]),I=(0,a.useMemo)((()=>[{label:"Accounts",options:null!==w&&void 0!==w?w:[]},{label:"Goals",options:null!==v&&void 0!==v?v:[]}]),[w,v]),k=(0,i.n)(Io.m2,{refetchQueries:e8e}),S=(0,o.A)(k,1)[0],N=(0,i.n)(Io.cs,{refetchQueries:e8e}),T=(0,o.A)(N,1)[0],_=(0,a.useCallback)((async e=>{var n;if(!(e.to&&e.from&&e.amount))throw new Error("Invalid values");const a=U5e(e.to.value),l=(0,o.A)(a,2),i=l[0],s=l[1],c=U5e(e.from.value),d=(0,o.A)(c,2),u=d[0],m=d[1],p=await(0,r.YW)({fromType:u,toType:i}).with({fromType:"goal",toType:"account"},(()=>{var t,n;return S({variables:{input:{id:m,amount:null!==(t=e.amount)&&void 0!==t?t:0,accountId:s,date:null!==(n=e.date)&&void 0!==n?n:void 0,includeInBudget:e.includeInBudget,notes:void 0}}})})).with({fromType:"account",toType:"goal"},(()=>{var t,n;return T({variables:{input:{id:s,amount:null!==(t=e.amount)&&void 0!==t?t:0,accountId:m,date:null!==(n=e.date)&&void 0!==n?n:void 0,includeInBudget:e.includeInBudget,notes:void 0}}})})).otherwise((()=>Promise.reject(new Error("Invalid values"))));t();return{userNotice:p.data&&"createSavingsGoalContribution"in p.data?null===(n=p.data.createSavingsGoalContribution)||void 0===n?void 0:n.userNotice:void 0}}),[S,T,t]),D=(0,a.useCallback)((e=>(0,r.YW)(e).with({type:"goal",listType:"to"},(e=>{let t=e.goalId;var n,a;return null!==(a=[...new Set([...null!==(n=f.get(t))&&void 0!==n?n:[],t])].map((e=>C.get(Y5e(e,"account")))).filter(Tp.n))&&void 0!==a?a:[]})).with({type:"goal"},(()=>w)).with({type:"account",listType:"from",accountId:r.P.nonNullable},(e=>{let t=e.accountId;var n;const a=null!==(n=E.get(t))&&void 0!==n?n:new Set;return v.filter((e=>a.has(V5e(e.value))))})).with({type:"account"},(()=>v)).with({listType:"from"},(()=>A)).otherwise((()=>I))),[w,E,f,C,v,A,I]);return{handleSubmit:_,getOptionsForType:D,getGoalOption:(0,a.useCallback)((e=>{if(e)return y.get(e)}),[y]),getAccountOption:(0,a.useCallback)((e=>{if(e)return C.get(e)}),[C]),isLoading:d||g,error:c||p}},n8e=["leading","description"],a8e=e=>{let t=e.listType,n=e.allowFilteringFromValues,l=e.name,o=e.label,i=e.emptyMessage,s=void 0===i?"No options":i;const c=(0,nG.p)("feat-savings-goals-enable-crypto-accounts","on"),d=(0,hu.x)().values,u=t8e({onSuccess:RQ.l,enableCrypto:c}).getOptionsForType,m=(0,a.useMemo)((()=>
1{if("from"===t){var e,a;const l=null!==(e=null===(a=d.to)||void 0===a?void 0:a.value)&&void 0!==e?e:null;let r=F5e(null,t),o=u({type:null,listType:t});if(n&&H5e(l)){const e=V5e(l);o=u({type:"account",accountId:e,listType:t}),r=F5e("account","to")}return{filteredOptions:o,placeholder:r,fromGoalId:null}}{var l,o;const e=null!==(l=null===(o=d.from)||void 0===o?void 0:o.value)&&void 0!==l?l:null,n=(0,r.YW)(e).when(j5e,(e=>{const n=V5e(e);return{type:"goal",options:u({type:"goal",goalId:n,listType:t}),fromGoalId:n}})).when(H5e,(()=>({type:"account",options:u({type:"account",listType:t}),fromGoalId:null}))).otherwise((()=>({type:null,options:u({type:null,listType:t}),fromGoalId:null}))),a=n.type,i=n.options,s=n.fromGoalId;return{filteredOptions:i,placeholder:F5e(a,t),fromGoalId:s}}}),[n,t,d.from,d.to,u]),p=m.filteredOptions,g=m.placeholder,h=m.fromGoalId,v=(0,a.useMemo)((()=>p.map((e=>"options"in e?{label:e.label,options:e.options.map((e=>r8e(e,{listType:t,fromGoalId:h})))}:r8e(e,{listType:t,fromGoalId:h})))),[p,t,h]),f=(0,a.useMemo)((()=>v.map((e=>"options"in e?{key:"group:".concat(e.label),label:e.label,items:e.options}:{key:"item:".concat(e.value),label:"",items:[e],anonymous:!0}))),[v]);return a.createElement(tC.zB,{"data-external-id":"goal-allocation-select-field",name:l,label:o,className:"min-w-0"},(e=>{const n=e.value?r8e(e.value,{listType:t,fromGoalId:h}):null;return a.createElement(U7.O.Root,{items:f,value:n,onValueChange:t=>{if(!t)return void e.onChange(null);t.leading,t.description;const n=(0,En.A)(t,n8e);e.onChange(n)},filter:(e,t)=>{var n,a;const l=t.toLowerCase(),r=e;return(null===(n=r.displayName)||void 0===n?void 0:n.toLowerCase().includes(l))||String(null!==(a=r.description)&&void 0!==a?a:"").toLowerCase().includes(l)},isItemEqualToValue:(e,t)=>(null===e||void 0===e?void 0:e.value)===(null===t||void 0===t?void 0:t.value),invalid:e.invalid,disabled:e.disabled},a.createElement(fb.M,{render:a.createElement("button",{type:"button",className:(0,Eb.X)({mode:"button",className:"group relative flex w-full min-w-0 items-center gap-xs p-default text-left"})})},a.createElement(l8e,{option:e.value,listType:t,fromGoalId:h,placeholder:g}),a.createElement(X5e.r,null)),a.createElement(U7.O.Content,{className:"min-w-72"},a.createElement(U7.O.PopupInput,{placeholder:"Search"}),a.createElement(U7.O.Empty,null,s),a.createElement(U7.O.List,null,(e=>a.createElement(U7.O.Group,{key:e.key,items:e.items},e.anonymous?null:a.createElement(U7.O.GroupLabel,null,e.label),a.createElement(Z5e.u,null,(e=>a.createElement(U7.O.Option,{key:e.value,value:e,disabled:e.disabled,leading:e.leading},a.createElement("span",null,a.createElement("span",null,e.displayName)," ",e.description?a.createElement("span",{className:"text-content-secondary"},"(",e.description,")"):null)))))))))}))},l8e=e=>{let t=e.option,n=e.listType,l=e.fromGoalId,r=e.placeholder;if(!t)return a.createElement(a.Fragment,null,a.createElement("span",{"aria-hidden":!0,className:"shrink-0"},a.createElement(J5e.X,{icon:"building",size:40})),a.createElement("span",{className:"min-w-0 flex-1 truncate text-left text-content-secondary"},r));const o=z5e({option:t,listType:n,fromGoalId:l,isSelected:!0});return a.createElement(a.Fragment,null,a.createElement("span",{"aria-hidden":!0,className:"shrink-0"},"account"===t.type?a.createElement(Gl.v,{logoUrl:t.account.logoUrl,size:40}):a.createElement("div",{className:"relative size-10 overflow-hidden rounded-sm"},a.createElement(vl.b,{imageStorageProvider:t.imageStorageProvider,imageStorageProviderId:t.imageStorageProviderId,size:"small",showGradient:!1}))),a.createElement("span",{className:"flex min-w-0 flex-1 flex-col text-left"},a.createElement("span",{className:"truncate"},t.displayName),a.createElement("span",{className:"truncate text-sm text-content-secondary"},o)))},r8e=(e,t)=>{let n=t.listType,l=t.fromGoalId;return(0,U.A)((0,U.A)({},e),{},{label:e.displayName,description:z5e({option:e,listType:n,fromGoalId:l}),leading:"account"===e.type?a.createElement(Gl.v,{logoUrl:e.account.logoUrl,size:20}):a.createElement("div",{className:"relative size-5 overflow-hidden rounded-sm","aria-hidden":!0},a.createElement(vl.b,{imageStorageProvider:e.imageStorageProvider,imageStorageProviderId:e.imageStorageProviderId,size:"small",showGradient:!1}))})},o8e=e=>{let t=e.onOpenEditAccounts;return a.createElement(m.g,{"data-external-id":"empty-accounts-notice",column:!0,gap:"small",paddingHorizontal:"small",paddingVertical:"xsmall"},a.createElement(xt.v,{size:"xsmall",color:"content.secondary",weight:"medium",transform:"uppercase"},"Accounts"),a.createElement(m.g,{column:!0,gap:"xsmall",paddingHorizontal:"small",paddingVertical:"xsmall",backgroundColor:"input.disabled.background",border:"1px solid input.disabled.border",borderRadius:"small"},a.createElement(xt.v,{size:"base"},_t.$.GOAL_ALLOCATION.EMPTY.TITLE,". Check your"," ",a.createElement(i8e,{onClick:e=>{e.stopPropagation(),null===t||void 0===t||t()}},"goal accounts")," and turn on the account(s) you'd like to use."),a.createElement(xt.v,{size:"base"},_t.$.GOAL_ALLOCATION.EMPTY.NOTE)))},i8e=u.default.span.withConfig({displayName:"GoalAllocationSelectOption__TextLink",componentId:"sc-71yv2q-0"})(["color:",";cursor:pointer;text-decoration-line:underline;text-underline-offset:25%;text-underline-position:from-font;"],vt.Ee.color.content.link);var s8e,c8e=n(72150),d8e=n(56537),u8e=n(78393);const m8e=e=>{var t;let n=e.account,l=e.onSuccess,r=e.onCancel;const s=(0,nG.p)("feat-savings-goals-enable-crypto-accounts","on"),c=(0,R3.F)().isGrowthRatesEnabled,d=(0,i.n)(Io.E4,{refetchQueries:[{query:Io.EJ,variables:{filters:(0,D3.QV)(s)}},Io.Dx,Io.iO]}),u=(0,o.A)(d,2),m=u[0],p=u[1].loading,g=null===(t=(0,et.I)(Io.Dx).data)||void 0===t?void 0:t.goalAccountsAllocationSummary.find((e=>(null===e||void 0===e?void 0:e.account.id)===n.id)),h=(0,pQ.up)(null===g||void 0===g?void 0:g.balancesByGoal),v=(0,a.useCallback)((async()=>{await m({variables:{input:{accountId:n.id,includeInBudget:!1}},optimisticResponse:{__typename:"Mutation",withdrawAllGoalContributionsFromAccount:{__typename:"WithdrawAllGoalContributionsFromAccount",account:{__typename:"Account",id:n.id,goalAllocatedAmount:0,includeInGoalContributions:!1},errors:null}}}),l()}),[n.id,l,m]);return a.createElement(Rc.L,{"data-external-id":"savings-goals-edit-accounts-modal-card-withdraw-confirmation-card",title:_t.$.TURN_OF
1F_ACCOUNT_MODAL.TITLE,fullHeight:!0},a.createElement(p8e,null,a.createElement("div",{className:"flex flex-col gap-xs border-b border-divider-primary pb-xl"},a.createElement(xt.v,{size:"20",weight:"medium"},_t.$.TURN_OFF_ACCOUNT_MODAL.PROMPT),a.createElement(xt.v,{size:"base"},_t.$.TURN_OFF_ACCOUNT_MODAL.DESCRIPTION),a.createElement(fe.xz6,{className:"border border-border-primary"},a.createElement(fe.xz6.Content,{className:"p-default"},a.createElement("div",{className:"flex items-center gap-sm"},a.createElement(Gl.v,{logoUrl:n.logoUrl,icon:n.icon,size:40}),a.createElement("div",{className:"flex flex-1 items-center justify-between"},a.createElement("div",{className:"flex flex-col gap-3xs"},a.createElement("div",{className:"flex items-center"},a.createElement(xt.v,{size:"large"},n.displayName)),a.createElement("div",{className:"flex items-center gap-xs"},a.createElement(xt.v,{size:"small",color:"content.secondary"},n.subtype.display))),a.createElement("div",{className:"flex flex-col items-end gap-3xs"},a.createElement(xt.v,{size:"large"},(0,rl.vv)(n.goalAllocatedAmount)),a.createElement(xt.v,{size:"small",color:"content.secondary"},"Total allocated"))))))),a.createElement("div",{className:"flex flex-col overflow-hidden"},a.createElement(_m.O,null,a.createElement("div",{className:"mt-xl flex flex-col gap-default"},a.createElement(xt.v,{size:"20",weight:"medium"},_t.$.TURN_OFF_ACCOUNT_MODAL.WITHDRAWN_FUNDS),h.map((e=>{if(!e)return null;const t=(0,D3.hJ)(e.goal,{isGrowthRatesEnabled:c}).shouldShowPill;return a.createElement(fe.xz6,{key:e.goal.id,className:"border border-border-primary"},a.createElement(fe.xz6.Content,{className:"p-default"},a.createElement("div",{className:"flex items-center gap-sm"},a.createElement(d8e.YI,{imageStorageProvider:e.goal.imageStorageProvider,imageStorageProviderId:e.goal.imageStorageProviderId,size:"small",$width:"48px"}),a.createElement("div",{className:"flex flex-1 items-center justify-between"},a.createElement("div",{className:"flex flex-col gap-3xs"},a.createElement("div",{className:"flex items-center"},a.createElement(xt.v,{size:"large"},e.goal.name)),a.createElement("div",{className:"flex items-center gap-xs"},t&&a.createElement(u8e.C,{goal:e.goal}),a.createElement(xt.v,{size:"small",color:"content.secondary"},e.goal.targetDate?(0,Ba.aX)(N.c9.fromISO(e.goal.targetDate)):"No target date"))),a.createElement("div",{className:"flex flex-col items-end gap-3xs"},a.createElement(xt.v,{size:"large"},(0,rl.vv)(e.amount)),a.createElement(xt.v,{size:"small",color:"content.secondary"},"Allocated"))))))})))))),a.createElement(Cq.R,null,a.createElement(wt.Xb,{onClick:r,size:"small"},"Cancel"),a.createElement(cu.gs,{onClick:v,size:"small",pending:p},"Turn off and withdraw funds")))},p8e=(0,$d.s)(qY.S)(s8e||(s8e=(0,wc.A)(["gap-0"]))),g8e=e=>{let t=e.enableCrypto;const n=(0,i.n)(h8e),l=(0,o.A)(n,2),r=l[0],s=l[1],c=(0,a.useCallback)((async(e,n)=>{let a=n.accountIdsToLink,l=n.accountIdsToUnlink;const o=(null!==a&&void 0!==a?a:[]).filter(Boolean).map((e=>({__typename:"Account",id:e})));await r({variables:{input:{id:e,accountIdsToLink:a,accountIdsToUnlink:l}},optimisticResponse:{__typename:"Mutation",updateSavingsGoal:{__typename:"UpdateSavingsGoal",savingsGoal:{__typename:"SavingsGoal",id:e,linkedAccounts:o},errors:null}},refetchQueries:[{query:Io.EJ,variables:{filters:(0,D3.QV)(t)}},{query:Io.j1,variables:{filters:(0,D3.QV)(t)}},Io.Dx,Io.iO]})}),[t,r]);return(0,U.A)({updateGoalAccountLink:c},s)},h8e=(0,Qt.J)("\n  mutation Common_UpdateSavingsGoalAccountLink($input: UpdateSavingsGoalInput!) {\n    updateSavingsGoal(input: $input) {\n      savingsGoal {\n        id\n        linkedAccounts {\n          id\n        }\n      }\n      errors {\n        ...PayloadErrorFields\n      }\n    }\n  }\n"),v8e=e=>{var t,n;let l=e.account;const r=(0,nG.p)("feat-savings-goals-enable-crypto-accounts","on"),s=(0,i.n)(Io.Xn),c=(0,o.A)(s,1)[0],d=g8e({enableCrypto:r}).updateGoalAccountLink,u=(0,Pd.h)(),m=(0,o.A)(u,2),p=m[0],g=m[1],h=g.open,v=g.close,f=(e=>{let t=e.account,n=e.enableCrypto;var l,r,i,s,c,d;const u=(0,a.useState)(!!(null===(l=t.linkedGoal)||void 0===l?void 0:l.id)),m=(0,o.A)(u,2),p=m[0],g=m[1],h=null===(r=t.linkedGoalCandidate)||void 0===r?void 0:r.id,v=t.goalAllocatedAmount>
10,f=v&&!p&&!(null===(i=t.linkedGoal)||void 0===i?void 0:i.id)&&!(null===(s=t.linkedGoalCandidate)||void 0===s?void 0:s.id);(0,a.useEffect)((()=>{var e;g(!!(null===(e=t.linkedGoal)||void 0===e?void 0:e.id))}),[null===(c=t.linkedGoal)||void 0===c?void 0:c.id]);const E=g8e({enableCrypto:n}).updateGoalAccountLink,y=(0,a.useCallback)((e=>{var n;!e&&(null===(n=t.linkedGoal)||void 0===n?void 0:n.id)&&E(t.linkedGoal.id,{accountIdsToUnlink:[t.id]}),g(e)}),[t.id,null===(d=t.linkedGoal)||void 0===d?void 0:d.id,E]),b=(0,a.useCallback)((e=>!!h&&e!==h),[h]);return(0,a.useMemo)((()=>({isUseEntireAccountChecked:p,accountHasGoalContributions:v,setUseEntireAccountChecked:g,shouldDisableUseEntireAccountBalanceCheckbox:f,linkedGoalCandidateId:h,handleUseEntireAccountCheckedChange:y,isOptionDisabled:b})),[v,h,f,p,y,b])})({account:l,enableCrypto:r}),E=f.isUseEntireAccountChecked,y=f.handleUseEntireAccountCheckedChange,b=f.linkedGoalCandidateId,x=f.setUseEntireAccountChecked,w=f.shouldDisableUseEntireAccountBalanceCheckbox,C=f.accountHasGoalContributions,A=f.isOptionDisabled,I=(0,a.useCallback)((async e=>{let t=e.account,n=e.includeInGoalContributions;return c({variables:{input:{accountId:t.id,includeInGoalContributions:n}},optimisticResponse:{__typename:"Mutation",updateAccountIncludeInGoals:{__typename:"UpdateAccountIncludeInGoals",account:{__typename:"Account",id:t.id,includeInGoalContributions:n}}}})}),[c]),k=(0,a.useCallback)((e=>{!e.target.checked&&C?h():I({account:l,includeInGoalContributions:e.target.checked})}),[l,C,I,h]),S=(0,a.useCallback)((()=>{x(!1),v()}),[v,x]),N=(0,a.useCallback)((e=>{const t=e.target.checked;y(t)}),[y]),T=(0,a.useCallback)((e=>{var t;e?d(e,{accountIdsToLink:[l.id]}):null!==(t=l.linkedGoal)&&void 0!==t&&t.id&&(d(l.linkedGoal.id,{accountIdsToUnlink:[l.id]}),x(!1))}),[null===(t=l.linkedGoal)||void 0===t?void 0:t.id,l.id,d,x]),_=(0,a.useCallback)((e=>((e,t,n)=>{if(!e)return t;const a=e instanceof Set?e:new Set(e),l="function"===typeof n?n:e=>e[n];return[...t].sort(((e,t)=>{const n=a.has(l(e));return n===a.has(l(t))?0:n?-1:1}))})([b],e.map((e=>(0,U.A)((0,U.A)({},e),{},{isDisabled:A(e.value),trailing:t=>{return t.selected||e.value!==b?void 0:a.createElement(xt.v,{className:"shrink-0",color:"content.secondary"},(n=l.goalAllocatedAmount,"(".concat((0,jt.vv)(n)," saved from account)")));var n}}))),"value")),[b,A,l.goalAllocatedAmount]);return a.createElement(a.Fragment,null,a.createElement(fe.xz6,{className:"overflow-visible border border-border-primary"},a.createElement(fe.xz6.Content,null,a.createElement("div",{className:"flex flex-col gap-sm"},a.createElement("div",{className:"flex items-center justify-between"},a.createElement("div",{className:"flex items-center gap-sm"},a.createElement(Gl.v,{logoUrl:l.logoUrl,icon:l.icon,size:40}),a.createElement("div",{className:"flex flex-col gap-3xs"},a.createElement(xt.v,{size:"large"},l.displayName),a.createElement(xt.v,{size:"small",color:"content.secondary"},"Account balance: ",(0,rl.vv)(l.displayBalance)))),a.createElement(ox.k,{onChange:k,checked:l.includeInGoalContributions})),l.includeInGoalContributions&&a.createElement(a.Fragment,null,a.createElement(z7.P,{text:""}),a.createElement(P.D_,{content:w?"This account is already used in other goals. Withdraw funds before enabling.":void 0,maxWidth:280},a.createElement("div",{className:"flex flex-col gap-sm"},a.createElement(fz.hm,{checked:E,onChange:N,disabled:w},a.createElement("div",{className:(0,q.cn)("flex items-center gap-2xs",w?"text-content-secondary":"text-content-primary")},a.createElement(xt.v,{size:"small",weight:"book"},_t.$.EDIT_ACCOUNTS_MODAL.USE_ENTIRE_ACCOUNT_BALANCE_AND_GROWTH),a.createElement(P.D_,{maxWidth:280,content:w?void 0:"This account's entire balance and all future activity will be applied to the selected goal."},a.createElement("div",{className:"flex"},a.createElement(sl.ZQ,{name:"info",size:16}))))))),E&&a.createElement("div",{className:"flex flex-col gap-2xs"},a.createElement(xt.v,{size:"small",weight:"medium"},"Linked goal"),a.createElement(c8e.B,{onSelectGoal:T,value:null===(n=l.linkedGoal)||void 0===n?void 0:n.id,transformOptions:_})))))),a.createElement(p,null,a.createElement(m8e,{account:l,onCancel:v,onSuccess:S})))};var f8e=n(77547);const E8e=()=>{const e=(0,Sq.k)().close,t=(0,nG.p)("feat-savings-goals-enable-crypto-accounts","on"),n=(0,et.I)(Io.j1,{variables:{filters:(0,D3.QV)(t)}}),l=n.data,i=n.isLoadingInitialData,s=n.error,c=(0,a.useMemo)((()=>{var e,t,n;const a=(0,LD.A)((e=>
1e.type.name),null!==(e=null===l||void 0===l?void 0:l.accounts)&&void 0!==e?e:[]);return[{title:"Cash",accounts:null!==(t=a[oV.fC.DEPOSITORY])&&void 0!==t?t:[]},{title:"Brokerage",accounts:null!==(n=a[oV.fC.BROKERAGE])&&void 0!==n?n:[]},{title:"Assets",accounts:D3.Ox.flatMap((e=>{var t;return null!==(t=a[e])&&void 0!==t?t:[]}))}].filter((e=>e.accounts.length>0))}),[null===l||void 0===l?void 0:l.accounts]);return a.createElement(Rc.L,{"data-external-id":"savings-goals-edit-accounts-modal-card",title:_t.$.EDIT_ACCOUNTS_MODAL.TITLE,hideBottomBorder:!1,fullHeight:!0},a.createElement(_m.O,null,a.createElement("div",{className:"flex flex-col gap-xl p-xl"},a.createElement("div",{className:"flex flex-col gap-xs"},a.createElement(xt.v,{size:"20",weight:"medium"},_t.$.EDIT_ACCOUNTS_MODAL.PROMPT),a.createElement(xt.v,{size:"base"},_t.$.EDIT_ACCOUNTS_MODAL.DESCRIPTION)),(0,r.YW)({isLoadingInitialData:i,error:s}).with({isLoadingInitialData:!0},(()=>a.createElement("div",{className:"my-3xl flex items-center justify-center"},a.createElement(p.i,null)))).with({error:r.P.nonNullable},(()=>a.createElement(SQ.W,{message:VG.U.ACCOUNTS}))).otherwise((()=>a.createElement(a.Fragment,null,c.map((e=>{const t=y8e(e.accounts),n=(0,o.A)(t,2),l=n[0],r=n[1],i=nie()("account",r.length);return a.createElement("div",{key:e.title,className:"relative flex flex-col gap-default"},a.createElement(xt.v,{weight:"medium",size:"large"},e.title),a.createElement("div",{className:"flex flex-col gap-default"},l.map((e=>a.createElement(v8e,{account:e,key:e.id}))),r.length>0&&a.createElement(oK,{showText:"Show ".concat(r.length," hidden ").concat(i),hideText:"Collapse ".concat(r.length," hidden ").concat(i),showArrow:!1,drawerBackgroundColor:"transparent",className:"mx-0"},a.createElement("div",{className:"mb-default flex flex-col gap-default pb-sm"},r.map((e=>a.createElement(v8e,{account:e,key:e.id})))))))}))))))),a.createElement(Cq.R,null,a.createElement(cu.WT,{onClick:e},"Done")))},y8e=e=>(0,vj.A)((e=>!(0,f8e.c1)(e)),e),b8e=e=>{let t=e.onClose,n=e.toId,l=e.allowFilteringFromValues;const i=(0,nG.p)("feat-savings-goals-enable-crypto-accounts","on"),s=t8e({onSuccess:t,enableCrypto:i}),c=s.handleSubmit,d=s.getGoalOption,u=s.getAccountOption,m=(0,Pd.h)(),p=(0,o.A)(m,2),g=p[0],h=p[1].open,v=(0,a.useState)(0),f=(0,o.A)(v,2),E=f[0],y=f[1],b=(0,r.YW)(null!==n&&void 0!==n?n:null).when(j5e,d).when(H5e,u).otherwise((()=>null));return a.createElement(a.Fragment,null,a.createElement(Rc.L,{title:_t.$.ALLOCATE_FUNDS,hideBottomBorder:!1},a.createElement(Eu.lV,{initialValues:{from:null,to:b,amount:void 0,date:N.c9.local().toISODate(),includeInBudget:!0},onSubmit:async e=>{const t=await c(e);null!==t&&void 0!==t&&t.userNotice&&(0,C.oR)({title:t.userNotice})},overrideValidationSchema:G5e},a.createElement(x8e,{key:E,allowFilteringFromValues:l,onOpenEditAccounts:h}),a.createElement(Cq.R,null,a.createElement(wt.Xb,{size:"small",onClick:t},"Cancel"),a.createElement(CJ.I,{size:"small",disabled:!1},"Save")))),a.createElement(g,{onClose:()=>{y((e=>e+1))}},a.createElement(E8e,null)))},x8e=e=>{var t;let n=e.allowFilteringFromValues,l=e.onOpenEditAccounts;const o=(0,hu.x)(),i=o.values,s=o.setFieldValue,c=o.setFieldTouched,d=(0,a.useRef)(i.from);(0,a.useEffect)((()=>{if(i.from!==d.current&&null!==i.from){var e,t,a,l;const r=W5e(null!==(e=null===(t=i.to)||void 0===t?void 0:t.value)&&void 0!==e?e:null),o=W5e(null!==(a=null===(l=i.from)||void 0===l?void 0:l.value)&&void 0!==a?a:null);"goal"===r&&"account"===o||n&&r!==o||(s("to",null),c("to",!1))}d.current&&i.from&&i.from!==d.current&&c("amount",!0),d.current=i.from}),[i.from,i.to,n,s,c]);const u=(e=>(0,r.YW)(e).with({to:{type:"goal",value:r.P.select("goalValue")},from:{type:"account",value:r.P.select("accountValue")}},(e=>{let t=e.goalValue,n=e.accountValue;return{goalId:V5e(t),accountId:V5e(n)}})).otherwise((()=>null)))(i);return a.createElement(w8e,{"data-external-id":"goal-allocation-modal-inner-form"},a.createElement(a8e,{name:"from",label:"From",listType:"from",allowFilteringFromValues:n,emptyMessage:a.createElement(o8e,{onOpenEditAccounts:l})}),a.createElement(a8e,{name:"to",label:"To",listType:"to"}),a.createElement(m.g,{column:!0,gap:"small"},a.createElement(tC.zB.Currency,{name:"amount",placeholder:"Enter amount"}),u&&a.createElement(C8e,null,a.createElement(q5e,Object.assign({},u,{onSelect:e=>s("amount",e)}
1)))),a.createElement(z7.P,{text:"",height:"1px"}),a.createElement(tC.zB.Date,{name:"date",label:"Date",placeholder:"Enter date",max:null!==(t=N.c9.local().toISODate())&&void 0!==t?t:void 0}),a.createElement(aye.Nx,{rightAccessory:a.createElement(vPe.Y,{name:"includeInBudget",hideLabel:!0}),title:_t.$.INCLUDE_IN_BUDGET.TITLE,subtitle:a.createElement(xt.v,{color:"content.secondary"},_t.$.INCLUDE_IN_BUDGET.SUBTITLE)}))},w8e=(0,u.default)(qY.S).withConfig({displayName:"GoalAllocationModalCard__StyledCardBody",componentId:"sc-1i3ojcq-0"})(["gap:",";"],vt.YK.xlarge),C8e=u.default.div.withConfig({displayName:"GoalAllocationModalCard__QuickSelectScroller",componentId:"sc-1i3ojcq-1"})(["margin-left:",";margin-right:",";padding-left:",";padding-right:",";overflow-x:auto;scrollbar-width:none;-ms-overflow-style:none;&::-webkit-scrollbar{display:none;}& button{flex-shrink:0;}& > div::after{content:'';flex-shrink:0;min-width:",";}"],vt.YK["-xlarge"],vt.YK["-xlarge"],vt.YK.xlarge,vt.YK.xlarge,vt.YK.small),A8e=e=>{let t=e.children,n=e.className,l=e.id;return a.createElement(Vl.W,{"data-external-id":"account-link-text",to:I.JZ.accounts.accountDetails({id:l}),stealthy:!0,truncate:!0,className:n},t)};var I8e,k8e,S8e=n(80751);const N8e=e=>{let t=e.allocationAmount;const n=t.account,l=(0,Pc.e)(!1),r=(0,o.A)(l,2),i=r[0],s=r[1],c=(0,S8e.am)(t),d=c.totalAmount,u=c.contributionsAmount,m=c.withdrawalsAmount,p=c.spendingAmount,g=c.adjustmentAmount;return a.createElement("div",{"data-external-id":"savings-goal-details-allocation-card-row",className:"flex flex-col"},a.createElement("div",{className:"flex items-center gap-xs"},a.createElement("div",{className:"-ml-2xs flex items-center gap-2xs"},a.createElement(B.L,{icon:i?"chevron-down":"chevron-right",onClick:s.toggle,size:"xxsmall","aria-label":"Toggle ".concat(n.displayName," allocation")}),a.createElement(Gl.v,{logoUrl:n.logoUrl,size:24})),a.createElement("div",{className:"flex flex-1 items-center justify-between gap-2xs overflow-hidden"},a.createElement(xt.v,{clampLines:1},a.createElement(A8e,{id:n.id},n.displayName)),a.createElement(D8e,Object.assign({"data-open":i},0!==d?{weight:"medium",color:(0,S8e.E8)(d)}:{},{color:(0,S8e.E8)(d)}),(0,rl.PN)(d)))),a.createElement(Ql.$,{open:i,onClosed:s.setOff},a.createElement("div",{className:"flex flex-col gap-sm pt-default",style:{paddingLeft:"56px"}},a.createElement("div",{className:"flex flex-col gap-sm"},a.createElement(R8e,null,a.createElement(T8e,null,"Contributions"),a.createElement(_8e,{weight:"medium",color:"content.success"},(0,rl.PN)(u))),a.createElement(R8e,null,a.createElement(T8e,null,"Withdrawals"),a.createElement(_8e,null,(0,rl.PN)(m))),a.createElement(R8e,null,a.createElement(T8e,null,"Spending"),a.createElement(_8e,null,(0,rl.PN)(p))),a.createElement(R8e,null,a.createElement(T8e,null,"Adjustments"),a.createElement(_8e,{weight:(0,S8e.L8)(g),color:(0,S8e.E8)(g,"content.primary")},(0,rl.PN)(g)))),a.createElement(z7.P,{text:"",height:"1px"}),a.createElement("div",{className:"flex items-center justify-between"},a.createElement(xt.v,{as:"span",size:"small",id:"available-label-".concat(n.id),weight:"medium"},"Total"),a.createElement(xt.v,{size:"small",as:"span",weight:"medium","aria-labelledby":"available-label-".concat(n.id),color:(0,S8e.E8)(d)},(0,rl.PN)(d))))))},T8e=e=>a.createElement(xt.v,Object.assign({"data-external-id":"amount-row-label",size:"small",clampLine
1s:1},e)),_8e=e=>a.createElement(xt.v,Object.assign({"data-external-id":"amount-row-amount",size:"small"},e)),D8e=(0,$d.s)(xt.v)(I8e||(I8e=(0,wc.A)(["opacity-0 transition-opacity data-[open=false]:opacity-100"]))),R8e=$d.s.div(k8e||(k8e=(0,wc.A)(["flex justify-between"])));var M8e,L8e,O8e;const P8e=(0,$d.s)(fe.xz6.Header)(M8e||(M8e=(0,wc.A)(["justify-between px-xl"]))),B8e=(0,$d.s)(fe.xz6.Content)(L8e||(L8e=(0,wc.A)(["\n  p-0\n  *:p-sm\n  [&>*:not(:last-child)]:border-b [&>*:not(:last-child)]:border-b-divider-primary\n"]))),z8e=(0,$d.s)(fe.xz6.Footer)(O8e||(O8e=(0,wc.A)(["flex-col items-stretch py-lg"])));var F8e;const G8e=e=>{let t=e.goal;const n=(0,a.useMemo)((()=>(0,pQ.Gc)(null===t||void 0===t?void 0:t.allocationAmountsByAccount)),[null===t||void 0===t?void 0:t.allocationAmountsByAccount]),l=n.active,r=n.inactive,i=0===l.length&&0===r.length,s=0===l.length&&r.length>0,c=r.length>0&&!s,d=(0,Pc.e)(!1),u=(0,o.A)(d,2),m=u[0],p=u[1].toggle,g=(0,Pd.h)(),h=(0,o.A)(g,2),v=h[0],f=h[1],E=f.open,y=f.close,b=(0,a.useCallback)((()=>{(0,Ge.u4)(Ye.Y5.CreateGoalsAllocationClicked,{path:"goals/savings/".concat(null===t||void 0===t?void 0:t.id)}),E()}),[null===t||void 0===t?void 0:t.id,E]);return a.createElement(a.Fragment,null,a.createElement(fe.xz6,null,a.createElement(P8e,null,a.createElement(fe.xz6.Title,null,"Allocation")),a.createElement(B8e,null,i?a.createElement(txe.m,{marginVertical:"gutter",title:_t.$.GOAL_ACCOUNTS_EMPTY.TITLE,description:_t.$.GOAL_ACCOUNTS_EMPTY.SUBTITLE}):a.createElement(a.Fragment,null,(s?r:l).map((e=>a.createElement(N8e,{key:e.account.id,allocationAmount:e}))),c&&a.createElement(a.Fragment,null,a.createElement(Ql.$,{open:m,shouldAnimateOnMount:!1,className:"[&&]:p-0"},a.createElement(Y8e,null,r.map((e=>a.createElement(N8e,{key:e.account.id,allocationAmount:e}))))),a.createElement("div",{role:"button",tabIndex:0,"aria-label":m?"Hide inactive accounts":"Show inactive accounts","aria-expanded":m,onClick:p,onKeyDown:e=>{"Enter"!==e.key&&" "!==e.key||(e.preventDefault(),p())},className:"flex cursor-pointer items-center gap-sm p-sm"},a.createElement(sl.ZQ,{name:m?"eye-off":"eye",size:16,className:"text-content-secondary"}),a.createElement(xt.v,{size:"small",color:"content.secondary",weight:"book"},m?"Hide":"Show"," ",(0,De.td)("inactive account",r.length,{inclusive:!0})))))),a.createElement(z8e,null,a.createElement(wt.Xb,{onClick:b},a.createElement(Yo.r,{name:"arrow-left-right"}),a.createElement("span",null,_t.$.ALLOCATE_FUNDS)))),a.createElement(v,null,a.createElement(b8e,{onClose:y,toId:null!==t&&void 0!==t&&t.id?Y5e(t.id,"goal"):void 0})))},Y8e=$d.s.div(F8e||(F8e=(0,wc.A)(["\n  bg-background-primary\n  *:p-sm\n  [&>*:not(:last-child)]:border-b [&>*:not(:last-child)]:border-b-divider-primary\n"])));var U8e,V8e;const W8e=(0,$d.s)(fe.xz6.Header)(U8e||(U8e=(0,wc.A)(["justify-between px-xl"]))),j8e=(0,$d.s)(fe.xz6.Content)(V8e||(V8e=(0,wc.A)(["gap-default p-xl"]))),H8e=e=>a.createElement(m.g,Object.assign({"data-external-id":"savings-goal-detail-row-container",justifyBetween:!0,alignCenter:!0},e)),K8e=e=>a.createElement(xt.v,Object.assign({"data-external-id":"savings-goal-detail-row-text",size:"small",color:"content.secondary"},e)),q8e=e=>{let t=e.title,n=e.subtitle;const l=(0,a.useId)();return a.createElement(H8e,{"data-external-id":"savings-goal-detail-row"},a.createElement(K8e,{id:l},t),"string"===typeof n?a.createElement(xt.v,{"aria-labelledby":l},n):n)},$8e=()=>a.createElement(fe.xz6,{"data-external-id":"savings-goal-details-card-loading"},a.createElement(W8e,null,a.createElement(fe.xz6.Title,null,a.createElement(M.Qp,null,"Details"))),a.createElement(j8e,null,Array.from({length:5}).map(((e,t)=>a.createElement(H8e,{key:t},a.createElement(K8e,null,a.createElement(M.Qp,null,"Detail ",t+1)),a.createElement(M.Qp,null,"Detail ",t+1))))));var Z8e=n(33853);var J8e=n(28841);const X8e=e=>{let t=e.goal,n=e.onClickEdit;const l=null!==t&&void 0!==t?t:{},r=l.id,o=l.targetAmount,i=l.targetDate,s=(0,J8e.q)(t).shouldShowPill,c=(e=>{const t=(0,Z8e.o)(),n=t.totalPlannedAmountByGoalId,a=t.isLoading,l=t.isNetworkRequestInFlight,r=e in n;return{totalPlannedAmount:r?n[e]:null,isLoading:a||l&&!r}})(r),d=c.totalPlannedAmount,u=c.isLoading;return a.createElement(fe.xz6,{"data-external-id":"savings-goal-details-card"},a.createElement(W8e,null,a.createElement(fe.xz6.Title,null,"Details"),a.createElement(bn.v,{onClick:n},"Edit")),a.createElement(j8e,null,a.createElement(q8e,{title:"Status",subtitle:s?a.createElement(u8e.C,{goal:t}):"-"}),a.createElement(q8e,{title:"Target amount",subtitle:(0,rl.vv)(o)}
1),a.createElement(q8e,{title:"Target date",subtitle:i?(0,Ba.Tf)(i):"-"}),a.createElement(q8e,{title:"Budget contribution",subtitle:a.createElement(fe.wME.Text,{isLoading:u},Q8e(d))})))},Q8e=e=>"".concat((0,rl.T3)(null!==e&&void 0!==e?e:0)," / mo."),e6e=390,t6e=24,n6e={left:t6e,right:t6e},a6e=(e,t)=>{const n=N.c9.fromISO(t),a=e instanceof N.c9?e:N.c9.fromISO(e);return n.hasSame(a,"year")?a<n?[a.startOf("year"),n.minus({days:1})]:a>n?[n.plus({days:1}),a.endOf("year")]:[n,n]:[a.startOf("year"),a.endOf("year")]},l6e=e=>{const t=(e instanceof N.c9?e:N.c9.fromISO(e)).month;return Math.floor((t-1)/6)},r6e=(e,t)=>{const n=N.c9.fromISO(t),a=e instanceof N.c9?e:N.c9.fromISO(e),l=l6e(a),r=l6e(n),o=a.startOf("year").plus({months:6*l}),i=o.plus({months:5}).endOf("month");return l===r&&n.hasSame(a,"year")?a<n?[o,n.minus({days:1})]:a>n?[n.plus({days:1}),i]:[n,n]:[o,i]},o6e=e=>{const t=(e instanceof N.c9?e:N.c9.fromISO(e)).month;return Math.floor((t-1)/2)},i6e=(e,t)=>{const n=N.c9.fromISO(t),a=e instanceof N.c9?e:N.c9.fromISO(e),l=o6e(a),r=o6e(n),o=a.startOf("year").plus({months:2*l}),i=o.plus({months:1}).endOf("month");return l===r&&n.hasSame(a,"year")?a<n?[o,n.minus({days:1})]:a>n?[n.plus({days:1}),i]:[n,n]:[o,i]},s6e=(e,t)=>{const n=N.c9.fromISO(t),a=e instanceof N.c9?e:N.c9.fromISO(e);return n.hasSame(a,"month")?a<n?[a.startOf("month"),n.minus({days:1})]:a>n?[n.plus({days:1}),a.endOf("month")]:[n,n]:[a.startOf("month"),a.endOf("month")]},c6e={annual:e=>t=>{const n=N.c9.fromISO(e),a=N.c9.fromISO(t);return!n.hasSame(a,"year")||a<n?a.startOf("year").toISODate():a>n?n.plus({days:1}).toISODate():t},biannual:e=>t=>{const n=N.c9.fromISO(e),a=N.c9.fromISO(t),l=l6e(a),r=l6e(n),i=r6e(a,e),s=(0,o.A)(i,1)[0];return!(a.hasSame(n,"year")&&l===r)||a<n?s.toISODate():a>n?n.plus({days:1}).toISODate():t},bimonthly:e=>t=>{const n=N.c9.fromISO(t),a=N.c9.fromISO(e),l=n.hasSame(a,"year")&&o6e(n)===o6e(a),r=i6e(n,e),i=(0,o.A)(r,1)[0];return!l||n<a?i.toISODate():n>a?a.plus({days:1}).toISODate():t},monthly:e=>t=>{const n=N.c9.fromISO(t),a=N.c9.fromISO(e);return!a.hasSame(n,"month")||n<a?n.startOf("month").toISODate():n>a?a.plus({days:1}).toISODate():t},day:(e,t)=>e=>{if(null===t||void 0===t?void 0:t.isProjection){return N.c9.fromISO(e).startOf("month").toISODate()}return e}},d6e=e=>{let t=e.today,n=e.grouping,a=e.isProjection;return(0,c6e[n])(t,{isProjection:a})},u6e={annual:{years:1},biannual:{months:6},bimonthly:{months:2},monthly:{months:1},day:{months:1}},m6e={date:"",projectedContribution:null,timestamp:0,totalSavings:null,totalSpending:null,previousTotalSavings:null,projection:null,contributions:null,withdrawals:null,spending:null},p6e=e=>N.c9.fromISO(e).endOf("day").toMillis(),g6e=(e,t)=>{var n,a,l;if(e.length>=t)return e;const r=(null===(n=(0,Sc.A)(e))||void 0===n?void 0:n.month)?N.c9.fromISO(null!==(l=null===(a=(0,Sc.A)(e))||void 0===a?void 0:a.month)&&void 0!==l?l:""):N.c9.local(),o=t-e.length,i=(0,jd.A)((e=>{var t;return{month:null!==(t=r.plus({months:e+1}).toISODate())&&void 0!==t?t:"",contributions:0,withdrawals:0,total:0}}),(0,db.A)(0,o));return(0,AK.A)(e,i)},h6e=e=>{let t=e.contributionPoints,n=e.goal,l=e.minMonthCount;const r=n.plannedMonthlyContribution,o=(0,a.useMemo)((()=>(e=>{var t,n,a,l;if(e.length<=1)return e;const r=(0,Nc.A)((e=>e.month),e),o=N.c9.fromISO(null!==(n=null===(t=r[0])||void 0===t?void 0:t.month)&&void 0!==n?n:""),i=N.c9.fromISO(null!==(l=null===(a=r[r.length-1])||void 0===a?void 0:a.month)&&void 0!==l?l:"");if(!o.isValid||!i.isValid)return e;const s=new Map(r.map((e=>[e.month,e])));return(0,mte.A)((e=>{if(e>i)return!1;const t=e.toFormat("yyyy-MM-dd");return[s.get(t)||{month:t,contributions:0,withdrawals:0,total:0},e.plus({months:1})]}),o)})(t)),[t]),i=(0,a.useMemo)((()=>l?g6e(o,l):o),[o,l]),s=(0,a.useMemo)((()=>(e=>{if(0===e.length)return[0,0];const t=e.map((e=>e.contributions)),n=e.map((e=>e.withdrawals)),a=Math.max(0,...t);return[Math.min(0,...n),a]})(i)),[i]),c=(0,a.useMemo)((()=>((e,t)=>[Math.min(0,e[0]),Math.max(1,null!==t&&void 0!==t?t:0,e[1])])(s,r)),[s,r]),d=(0,a.useMemo)((()=>function(e,t,n){let a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},l=a.placeholderPercent,r=void 0===l?.07:l,o=a.showAllMonthLabels,i=void 0!==o&&o;const s=N.c9.fromISO(n);return e.map((e=>{const n=N.c9.fromISO(e.month),a=n<=s,l=0!==e.total&&((0,Ba.tF)(n,s)||i&&a);return(0,U.A)((0,U.A)({},e),{},{label:l?(0,jt.T3)(e.total):"",placeholder:e.contributions||e.withdrawals?void 0:t[1]*r})}))}(i,c,N.c9.local().toISODate(),{showAllMonthLabels:!0})),[i,c]),u=(0,a.useMemo)((()=>((e,t)=>{var n,a,l,r,o,i,s;const c=(0,Nc.A)((e=>e.month),e),d=N.c9.fromISO(null!==(a=null===(n=c[0])||void 0===n?void 0:n.month)&&void 0!==a?a:"").startOf("month"),u=N.c9.fromISO(t).startOf("month");if(!d.isValid||!u.isValid||d>u)return;const m=new Map(c.map((e=>[e.month,e.total]))),p=[];let g=d;for(;g<=u;)p.push(null!==(r=m.get(null!==(l=g.toISODate())&&void 0!==l?l:""))&&void 0!==r?r:0),g=g.plus({months:1});const h=(0,sU.A)(((e,t)=>e-t),p),v=Math.floor(h.length/2),f=h.length%2===0?(0,De.Eb)([null!==(o=h[v-1])&&void 0!==o?o:0,null!==(i=h[v])&&void 0!==i?i:0])/2:null!==(s=h[v])&&void 0!==s?s:0;return{average:(0,De.Eb)(p)/p.length,median:f}})(o,N.c9.local().toISODate())),[o]),m=c[0]<0;return{chartData:d,domain:c,range:s,hasWithdrawals:m,summaryStats:u}},v6e=e=>{let t=e.contributionPoints,n=e.goal,l=e.height,o=e.width;const i=(0,u.useTheme)(),s=i.variables.color,c=o-48,d=n.plannedMonthlyContribution,m=(0,a.useMemo)((()=>Math.floor((c-2*PU.g_)/90)),[c]),p=h6e({contributionPoints:t,goal:n,minMonthCount:m}),g=p.chartData,h=p.domain,v=p.hasWithdrawals,f=p.summaryStats,E=(0,a.useMemo)((()=>(0,EJ.uu)(g.map((e=>({startDate:e.month}))))),[g]);return a.createElement(f6e,{"data-external-id":"savings-goal-contributions-chart",$height:l},a.createElement(PU.vD,{data:g,showSummaryLine:void 0!==f,summaryStats:f,heightPx:l,widthPx:c,barWidthPx:60,minBarWidthPx:60,xAxisDataKey:"month",labelDataKey:"label",totalDataKey:v?"total":void 0,margin:n6e,formatXAxis:Ba.jY,formatYAxis:rl.T3,xAxisReferenceLines:E,barDataKeys:[{name:"withdrawals",color:s.chart.expensesActive},{name:"contributions",color:s.chart.incomeActive},{name:"placeholder",color:s.content.secondary}
1],hideGrid:!0,roundBarCorners:!0,yAxis:a.createElement(wa.h,{domain:h,axisLine:!1,tick:!1}),yAxisReferenceLines:d?[{y:0,labels:[]},{y:d,labels:["Budget",(0,rl.T3)(d)],dashed:!0}]:void 0,xAxisProps:{height:57,axisLine:!1,tickLine:!1,tick:e=>{var t;let n=e.x,l=e.y;const o=e.payload.value,c=g[o],u=null===c||void 0===c?void 0:c.month,m=null!==(t=null===c||void 0===c?void 0:c.contributions)&&void 0!==t?t:0;return u?a.createElement("g",{transform:"translate(".concat(n,",").concat(l,")")},a.createElement("text",{x:0,y:0,fill:i.variables.color.content.secondary,fontWeight:i.fontWeight.medium,fontSize:i.fontSize.small},a.createElement("tspan",{dy:"16",textAnchor:"middle"},(0,Ba.jY)(u))),(0,r.YW)({contributions:m,plannedMonthlyContribution:d}).when((e=>{let t=e.contributions,n=e.plannedMonthlyContribution;return t>=(null!==n&&void 0!==n?n:0)&&(null!==n&&void 0!==n?n:0)>0}),(()=>a.createElement(fe.cyv,{className:"text-chart-income-active",x:"".concat(-12),y:"30",size:24}))).when((e=>!!e.plannedMonthlyContribution),(()=>a.createElement(fe.C14,{className:"text-chart-fill-gray",x:"".concat(-12),y:"30",size:24}))).otherwise((()=>a.createElement("circle",{cx:"0",cy:"42",r:"".concat(4),fill:s.content.secondary})))):null}},tooltipComponent:e=>{const t=e.active,n=(0,_a.WS)(e);if(!n)return null;const l=n.month,r=n.contributions,o=n.withdrawals,i=n.total;return a.createElement(Sa.II,{active:t,header:(0,Ba.Rc)(l)},a.createElement(Na.B,{label:"Contributions",value:a.createElement(hl.t,{value:r}),dotFillColor:s.chart.incomeActive}),a.createElement(Na.B,{label:"Withdrawals",value:a.createElement(hl.t,{value:Math.abs(o)}),dotFillColor:s.chart.expensesActive}),a.createElement(Na.B,{label:"Total",value:a.createElement(hl.t,{value:i})}))}}))},f6e=u.default.div.withConfig({displayName:"SavingsGoalContributionsChart__Container",componentId:"yrpgv0-0"})(["height:","px;"],(e=>e.$height));var E6e,y6e;const b6e=fe.xz6,x6e=e=>a.createElement(m.g,Object.assign({"data-external-id":"savings-goal-details-chart-header-tabs",alignCenter:!0,gap:"xxsmall"},e)),w6e=()=>a.createElement(b6e,{"data-external-id":"savings-goal-details-chart-loading"},a.createElement(C6e,null,a.createElement(fe.xz6.Title,null,a.createElement(M.Qp,null,"Timeline")),a.createElement(Dc.t,null,a.createElement(x6e,null,a.createElement(RA.Q,{index:0,$background:"card"},a.createElement(M.Qp,null,"Timeline")),a.createElement(RA.Q,{index:1,$background:"card"},a.createElement(M.Qp,null,"Contributions"))))),a.createElement(A6e,null,a.createElement("div",{style:{paddingLeft:t6e,paddingRight:t6e}},a.createElement(M.Al,{$width:"100%",$height:"".concat(e6e,"px")})))),C6e=(0,$d.s)(fe.xz6.Header)(E6e||(E6e=(0,wc.A)(["justify-between px-xl py-default"]))),A6e=(0,$d.s)(fe.xz6.Content)(y6e||(y6e=(0,wc.A)(["px-0 pt-2xl pb-default"]))),I6e=e=>{const t=(0,u.useTheme)();return a.createElement("svg",Object.assign({"data-external-id":"target",xmlns:"http://www.w3.org/2000/svg",width:"38",height:"38",fill:"none"},e),a.createElement("g",{filter:"url(#a)"},a.createElement("path",{fill:t.variables.color.background.primary,d:"M7 16C7 9.373 12.373 4 19 4s12 5.373 12 12-5.373 12-12 12S7 22.627 7 16Z",shapeRendering:"crispEdges"}),a.createElement("path",{stroke:t.variables.color.border.primary,d:"M19 3.5c6.904 0 12.5 5.596 12.5 12.5S25.904 28.5 19 28.5 6.5 22.904 6.5 16 12.096 3.5 19 3.5Z",shapeRendering:"crispEdges"}),a.createElement("g",{fill:t.variables.color.chart.fill.purple,clipPath:"url(#b)"},a.createElement("path",{d:"M19 17a1 1 0 1 0 0-2 1 1 0 0 0 0 2Z"}),a.createElement("path",{fillRule:"evenodd",d:"M15.5 16a3.5 3.5 0 1 1 7 0 3.5 3.5 0 0 1-7 0Zm3.5-2.5a2.5 2.5 0 1 0 0 5 2.5 2.5 0 0 0 0-5Z",clipRule:"evenodd"}),a.createElement("path",{fillRule:"evenodd",d:"M13 16a6 6 0 1 1 12 0 6 6 0 0 1-12 0Zm6-5a5 5 0 1 0 0 10 5 5 0 0 0 0-10Z",clipRule:"evenodd"}))),a.createElement("defs",null,a.createElement("clipPath",{id:"b"},a.createElement("path",{fill:"#fff",d:"M13 10h12v12H13z"})),a.createElement("filter",{id:"a",width:"38",height:"38",x:"0",y:"0",colorInterpolationFilters:"sRGB",filterUnits:"userSpaceOnUse"}
1,a.createElement("feFlood",{floodOpacity:"0",result:"BackgroundImageFix"}),a.createElement("feColorMatrix",{in:"SourceAlpha",result:"hardAlpha",values:"0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0"}),a.createElement("feOffset",{dy:"3"}),a.createElement("feGaussianBlur",{stdDeviation:"3"}),a.createElement("feComposite",{in2:"hardAlpha",operator:"out"}),a.createElement("feColorMatrix",{values:"0 0 0 0 0.133333 0 0 0 0 0.12549 0 0 0 0 0.113725 0 0 0 0.1 0"}),a.createElement("feBlend",{in2:"BackgroundImageFix",result:"effect1_dropShadow_9497_14645"}),a.createElement("feBlend",{in:"SourceGraphic",in2:"effect1_dropShadow_9497_14645",result:"shape"}))))},k6e=e=>{let t=(0,o.A)(e,2),n=t[0],a=t[1];return(0,Ba.li)(n.toISODate(),a.toISODate())},S6e={annual:a6e,biannual:r6e,bimonthly:i6e,monthly:s6e,day:s6e},N6e={annual:a6e,biannual:r6e,bimonthly:i6e,monthly:s6e},T6e=["active","goal","grouping","today"],_6e=e=>{var t,n,l,r;let o=e.active,i=e.goal,s=e.grouping,c=e.today,d=void 0===c?N.c9.local().toISODate():c,u=(0,En.A)(e,T6e);const p=i.isSinkingFund,g=(0,_a.WS)((0,U.A)({active:o},u));if(!g||!o)return null;const h=g.date,v=null!==(t=g.totalSavings)&&void 0!==t?t:0,f=null!==(n=g.projection)&&void 0!==n?n:0,E=null!==(l=g.totalSpending)&&void 0!==l?l:0,y=null!==(r=g.previousTotalSavings)&&void 0!==r?r:0;if("projection"===g.type){const e=(e=>{let t=e.date,n=e.grouping,a=e.today;const l=N.c9.fromISO(t),r=S6e[n];return k6e(r(l,a))})({date:h,grouping:s,today:d});return a.createElement(Sa.II,{"data-external-id":"savings-goal-timeline-chart-tooltip",active:o,header:e},a.createElement(m.g,{column:!0,gap:"xxsmall"},a.createElement(Na.B,{label:a.createElement(Na.U,null,"Projected balance"),value:a.createElement(hl.t,{value:f})}),!!g.projectedContribution&&a.createElement(m.g,{justifyEnd:!0},a.createElement(El.H,{endAmount:f,startAmount:f-g.projectedContribution,className:"text-content-primary"}))))}const b=(e=>{let t=e.date,n=e.grouping,a=e.today;const l=N.c9.fromISO(t),r=N6e[n];return r?k6e(r(l,a)):(0,Ba.AO)(t)})({date:h,grouping:s,today:d});return a.createElement(Sa.II,{"data-external-id":"savings-goal-timeline-chart-tooltip",active:o,header:b,footer:"historical"!==g.type||p?null:a.createElement(Na.B,{label:a.createElement(Na.U,null,"Spending"),value:a.createElement(hl.t,{value:E})})},a.createElement(m.g,{column:!0,gap:"xxsmall"},a.createElement(Na.B,{label:a.createElement(Na.U,null,"Goal balance"),value:a.createElement(hl.t,{value:v})}),"historical"===g.type&&a.createElement(m.g,{justifyEnd:!0},a.createElement(El.H,{endAmount:v,startAmount:y}))))},D6e=e=>{let t=e.historicalPoints,n=e.goal,l=e.today,r=e.grouping,i=e.isGrowthRatesEnabled;var s,c,d;const u=null!==(s=null!==l&&void 0!==l?l:N.c9.local().toISODate())&&void 0!==s?s:"",m=n.targetDate,p=n.targetAmount,g=n.forecastedCompletionDate,h=(0,a.useMemo)((()=>d6e({today:u,grouping:r})),[u,r]),v=i?"monthly":r,f=(0,a.useMemo)((()=>d6e({today:u,grouping:v})),[u,v]),E=N.c9.fromISO(u).startOf("month").toISODate(),y=null!==g&&void 0!==g?g:m,b=y?N.c9.fromISO(y).startOf("month").plus({months:1}).toISODate():"",x=(0,et.I)(Io.pn,{variables:{goalId:n.id,startMonth:E,endMonth:null!==b&&void 0!==b?b:""},skip:!y}),w=(0,pQ.Mj)(n),C=(0,a.useMemo)((()=>{var e,a,l;const s=((e,t,n)=>{var a,l,r,o,i,s,c,d,u,m,p;if(0===e.length)return e;const g=N.c9.fromISO(t);let h=(0,Nc.A)((e=>e.date),e);const v=g.minus({days:1}).toISODate(),f=d6e({today:t,grouping:n})(v),E=h.findIndex((e=>e.date===f)),y=N.c9.fromISO(v);if("day"!==n&&-1===E){const e=(0,yd.A)((e=>N.c9.fromISO(e.date)<y&&null!==e.totalSavings),h);h=(0,Nc.A)((e=>e.date),[...h,(0,U.A)((0,U.A)({},m6e),{},{type:"synthetic",date:f,timestamp:p6e(f),totalSavings:null!==(a=null===e||void 0===e?void 0:e.totalSavings)&&void 0!==a?a:null,totalSpending:null!==(l=null===e||void 0===e?void 0:e.totalSpending)&&void 0!==l?l:null,contributions:null!==(r=null===e||void 0===e?void 0:e.contributions)&&void 0!==r?r:null,withdrawals:null!==(o=null===e||void 0===e?void 0:e.withdrawals)&&void 0!==o?o:null,spending:null!==(i=null===e||void 0===e?void 0:e.spending)&&void 0!==i?i:null})])}const b=h.findIndex((e=>e.date===t));if(-1!==b){const e=h[b];return null!==(null===e||void 0===e?void 0:e.totalSavings)?h.map(((e,t)=>t===b?(0,U.A)((0,U.A)({},e),{},{projection:e.totalSavings}):e)):h}const x=(0,yd.A)((e=>N.c9.fromISO(e.date)<g&&null!==e.totalSavings),h),w=(0,U.A)((0,U.A)({},m6e),{},{type:"synthetic",date:t,timestamp:p6e(t),totalSavings:null!==(s=null===x||void 0===x?void 0:x.totalSavings)&&void 0!==s?s:null,totalSpending:null!==(c=null===x||void 0===x?void 0:x.totalSpending)&&void 0!==c?c:null,contributions:null!==(d=null===x||void 0===x?void 0:x.contributions)&&void 0!==d?d:null,withdrawals:null!==(u=null===x||void 0===x?void 0:x.withdrawals)&&void 0!==u?u:null,spending:null!==(m=null===x||void 0===x?void 0:x.spending)&&void 0!==m?m:null,projection:null!==(p=null===x||void 0===x?void 0:x.totalSavings)&&void 0!==p?p:null});return[...h,w]})(t,u,r),c=s[s.length-1],d=null!==(e=null===c||void 0===c?void 0:c.totalSavings)&&void 0!==e?e:0,m=(null===c||void 0===c?void 0:c.date)?f(N.c9.fromISO(c.date).plus({days:1}).toISODate()):E,p=null===(l=null===(a=x.data)||void 0===a?void 0:a.savingsGoal)||void 0===l?void 0:l.monthlyBudgetAmounts,h=f(E),y=(null!==(b=n.allocationAmountsByAccount)&&void 0!==b?b:[]).filter(Tp.n).reduce(((e,t)=>{var n,a;const l=null===(n=t.account)||void 0===n?void 0:n.id;return l?(e[l]=null!==(a=t.account.displayBalance)&&void 0!==a?a:0,e):e}),{});var b;const C=(e=>{let t=e.monthlyBudgetAmounts,n=e.groupingIdentifier,a=e.startMonthId;const l=t.reduce(((e,t)=>{var a,l;
1const r=n(t.month),o=null!==(a=t.remainingAmount)&&void 0!==a?a:0;return e[r]=(0,De.Eb)([null!==(l=e[r])&&void 0!==l?l:0,o]),e}),{}),r=l[a];return{remainingContribution:void 0===r?0:r,plannedContributions:(0,En.A)(l,[a].map(nf.A))}})({monthlyBudgetAmounts:null!==p&&void 0!==p?p:[],groupingIdentifier:f,startMonthId:h}),A=C.remainingContribution,I=C.plannedContributions,k=(e=>{let t=e.monthlyBudgetAmounts,n=e.groupingIdentifier,a=e.accountStartingBalances,l=e.startMonthId;const r=t.reduce(((e,t)=>{const a=n(t.month);return t.accountBreakdown.forEach((t=>{var n,l,r,o,i;const s=t.account.id,c=e[s],d=null!==(n=null===c||void 0===c?void 0:c.contributionsByGrouping[a])&&void 0!==n?n:0,u=null!==(r=null!==(l=t.account.growthRate)&&void 0!==l?l:null===c||void 0===c?void 0:c.growthRate)&&void 0!==r?r:0;e[s]={growthRate:u,contributionsByGrouping:(0,U.A)((0,U.A)({},null!==(o=null===c||void 0===c?void 0:c.contributionsByGrouping)&&void 0!==o?o:{}),{},{[a]:(0,De.Eb)([d,null!==(i=t.remainingAmount)&&void 0!==i?i:0])})}})),e}),{});return Object.entries(r).map((e=>{let t=(0,o.A)(e,2),n=t[0],r=t[1];var i;const s=r.contributionsByGrouping,c=s[l],d=void 0===c?0:c,u=(0,En.A)(s,[l].map(nf.A));return{growthRate:r.growthRate,initialBalance:Math.max(null!==(i=a[n])&&void 0!==i?i:0,0),remainingContribution:Math.max(d,0),contributions:u}}))})({monthlyBudgetAmounts:null!==p&&void 0!==p?p:[],groupingIdentifier:f,accountStartingBalances:y,startMonthId:h}),S=(e=>{let t=e.remainingContribution,n=e.plannedContributions,a=e.accountProjections,l=e.isGrowthRatesEnabled;const r=Object.values(n).some((e=>e>0)),o=a.some((e=>Object.values(e.contributions).some((e=>e>0)))),i=a.some((e=>e.remainingContribution>0)),s=a.some((e=>{var t;return e.growthRate>0&&(null!==(t=e.initialBalance)&&void 0!==t?t:0)>0}));return t>0||r||!!l&&(o||i||s)})({remainingContribution:A,plannedContributions:I,accountProjections:k,isGrowthRatesEnabled:i}),T=!!m&&S&&(!w||i)&&!!g?(e=>{let t=e.grouping,n=e.startingBalance,a=e.startDate,l=e.plannedContributions,r=e.accountProjections,o=void 0===r?[]:r,i=e.remainingContribution,s=e.forecastedCompletionDate,c=e.today;var d;if(!s)return[];const u=N.c9.fromISO(a),m=N.c9.fromISO(s);if(m<=u)return[];const p=null!==(d=l[a])&&void 0!==d?d:0,g=o.map((e=>{var t;return e.remainingContribution+(null!==(t=e.contributions[a])&&void 0!==t?t:0)})),h=o.map(((e,t)=>{var n,a;return(0,De.Eb)([null!==(n=e.initialBalance)&&void 0!==n?n:0,null!==(a=g[t])&&void 0!==a?a:0])})),v=(0,De.Eb)(o.map((e=>{var t;return null!==(t=e.initialBalance)&&void 0!==t?t:0}))),f=(0,De.Eb)([n,-v]),E=(0,De.Eb)([i,p,...g]),y=(0,De.Eb)([f,i,p,...h]),b=(0,U.A)((0,U.A)({},m6e),{},{projectedContribution:E,type:"projection",date:a,timestamp:p6e(a),projection:y}),x=u6e[t],w=d6e({today:c,grouping:t,isProjection:!0}),C=w(u.plus(x).toISODate()),A=N.c9.fromISO(C),I=(0,mte.A)((e=>{var t;if(e.currentPoint>m)return!1;const n=w(e.currentPoint.toISODate()),a=null!==(t=l[n])&&void 0!==t?t:0,r=o.map((e=>{var t;return null!==(t=e.contributions[n])&&void 0!==t?t:0})),i=o.map(((t,n)=>{return(0,De.Eb)([e.accountBalances[n]*(a=t.growthRate,Math.pow(1+a/100,1/12)),r[n]]);var a})),s=(0,De.Eb)([f,e.cumulativeGeneralContribution,a,...i]),c=(0,De.Eb)([a,...r]),d=e.currentPoint.toISODate();return[(0,U.A)((0,U.A)({},m6e),{},{type:"projection",date:d,timestamp:p6e(d),projection:s,projectedContribution:c}),{currentPoint:N.c9.fromISO(w(e.currentPoint.plus(x).toISODate())),cumulativeGeneralContribution:(0,De.Eb)([e.cumulativeGeneralContribution,a]),accountBalances:i}]}),{currentPoint:A,cumulativeGeneralContribution:(0,De.Eb)([i,p]),accountBalances:h});return[b,...I]})({today:u,grouping:v,startingBalance:d,remainingContribution:Math.max(A,0),startDate:m,plannedContributions:I,accountProjections:i?k:void 0,forecastedCompletionDate:g}):[];return[...s,...T]}),[t,r,v,u,f,E,null===(d=null===(c=x.data)||void 0===c?void 0:c.savingsGoal)||void 0===d?void 0:d.monthlyBudgetAmounts,n.allocationAmountsByAccount,g,w,i]),A=(0,a.useMemo)((()=>{const e=C.flatMap((e=>[e.totalSavings,e.projection])).filter(Tp.n),t=Math.max(...e,null!==p&&void 0!==p?p:0),n=Math.min(...e,0);return[Math.floor(1.1*n),Math.ceil(1.1*t)]}),[C,p]),I=(0,a.useMemo)((()=>m?p6e(N.c9.fromISO(m).startOf("month").minus({day:1}).toISODate()):void 0),[m]),k=(0,a.useMemo)((()=>g?p6e(g):void 0),[g]),S=(0,a.useMemo)((()=>
1{if(0===C.length)return;const e=C.map((e=>e.timestamp)),t=Math.min(...e),n=N.c9.fromMillis(t).startOf("month").toMillis(),a=Math.max(...e,null!==k&&void 0!==k?k:0,null!==I&&void 0!==I?I:0),l=N.c9.fromMillis(n),o=N.c9.fromMillis(a),i=h(o.toISODate()),s=h(l.toISODate()),c=u6e[r];return[n,i===s||i===u?o.plus(c).toMillis():a]}),[C,k,I,h,r,u]),T=(0,a.useMemo)((()=>((e,t)=>{if(!t)return;const n=e.find((e=>e.date===t));if(n)return n;const a=N.c9.fromISO(t),l=e.filter((e=>null!==e.projection)).filter((e=>N.c9.fromISO(e.date)<=a)),r=(0,Nc.A)((e=>e.date),l);return(0,Sc.A)(r)})(C,m)),[C,m]),_=null!==S&&void 0!==S?S:[],D=(0,o.A)(_,2),R=D[0],M=D[1],L=(0,a.useMemo)((()=>0!==C.length&&R&&M?(e=>{let t=e.minTimestamp,n=e.maxTimestamp,a=e.dayOfMonth,l=void 0===a?1:a,r=e.grouping;const o=N.c9.fromMillis(t).startOf("month"),i=N.c9.fromMillis(n),s=e=>{if(e>i)return[];const a=e.set({day:l}).endOf("day").toMillis(),o=u6e[r],c=e.plus(o);return a>=t&&a<=n?[a,...s(c)]:s(c)};return s(o)})({minTimestamp:R,maxTimestamp:M,grouping:r}):[]),[C.length,R,M,r]);return{loading:x.isLoadingInitialData,chartData:C,domain:A,targetDatePoint:T,today:u,xDomain:S,targetDateTimestamp:I,xAxisTicks:L,grouping:r}},R6e=["totalSavings","projection"],M6e=["totalSavings","projection","totalSpending"],L6e=e=>{let t=e.historicalPoints,n=e.grouping,l=e.height,i=e.goal,s=e.today;const c=(0,u.useTheme)(),d=i.targetAmount,m=i.isSinkingFund,p=(0,R3.F)().isGrowthRatesEnabled,g=D6e({historicalPoints:t,goal:i,today:s,grouping:n,isGrowthRatesEnabled:p}),h=g.chartData,v=g.domain,f=g.xDomain,E=g.targetDateTimestamp,y=g.xAxisTicks,b=g.loading,x=(0,a.useMemo)((()=>(e=>{let t=e.grouping,n=e.today,a=e.mobile;return e=>{const l=N.c9.fromMillis(e),i=a?Ba.Ex:Ba.Tf,s=a?Ba.qY:Ba.Fl;return(0,r.YW)(t).with("annual",(()=>l.toFormat("yyyy"))).with("biannual",(()=>{const e=r6e(l,n),t=(0,o.A)(e,2),a=t[0],r=t[1];return s(a.toISODate(),r.toISODate())})).with("bimonthly",(()=>{const e=i6e(l,n),t=(0,o.A)(e,2),a=t[0],r=t[1];return s(a.toISODate(),r.toISODate())})).otherwise((()=>{var e;return i(null!==(e=l.toISODate())&&void 0!==e?e:"")}))}})({grouping:n,today:s})),[n,s]),w=(0,a.useState)(1),C=(0,o.A)(w,2),A=C[0],I=C[1];return(0,a.useLayoutEffect)((()=>{const e=setTimeout((()=>{I((e=>e+1))}));return()=>{clearTimeout(e)}}),[]),a.createElement(Do.rT,{"data-external-id":"savings-goal-timeline-chart",key:A,isLoadingNewData:b,height:l,data:h,yDataKeys:m?R6e:M6e,tooltipComponent:e=>a.createElement(_6e,(0,U.A)((0,U.A)({},e),{},{goal:i,grouping:n,today:s})),lineOptions:[{lineColor:c.variables.color.chart.incomeActive,hasArea:!0,areaColor:c.variables.color.chart.income,legendName:"Savings",strokeWidth:3,type:"stepAfter"},{lineColor:c.variables.color.border.secondary,hasArea:!0,areaColor:c.variables.color.border.secondary,isDashed:!0,strokeWidth:3},...m?[]:[{lineColor:c.variables.color.content.primary,hasArea:!0,areaColor:c.variables.color.content.primary,legendName:"Spending",strokeWidth:3,type:"stepAfter"}]],xDataKey:"timestamp",formatYAxis:rl.fw,formatXAxis:x,domain:v,smoothGradient:!0,xAxisProps:{height:24,ticks:y,domain:f,type:"number",scale:"time",interval:"preserveStartEnd"},yAxisProps:{width:"auto"}},!!d&&a.createElement(eb.e_,{key:"target",y:null!==d&&void 0!==d?d:0,stroke:c.variables.color.chart.fill.purple,strokeWidth:2}),!!d&&!!E&&a.createElement(Ky.r,{x:E,y:d,r:12,shape:e=>{let t=e.cx,n=e.cy;return void 0!==t&&void 0!==n?a.createElement(I6e,{x:(t-12).toString(),y:(n-16).toString()}):a.createElement("g",null)}}))},O6e=e=>{var t,n,a,l,r,o;return{type:"historical",date:e.date,timestamp:p6e(e.date),contributions:null!==(t=e.contributions)&&void 0!==t?t:0,withdrawals:null!==(n=e.withdrawals)&&void 0!==n?n:0,spending:null!==(a=e.spending)&&void 0!==a?a:0,totalSavings:null!==(l=e.totalSavings)&&void 0!==l?l:0,totalSpending:null!==(r=e.totalSpending)&&void 0!==r?r:0,previousTotalSavings:null!==(o=e.previousTotalSavings)&&void 0!==o?o:0,projection:null}},P6e=e=>{var t,n;const a=null!==(t=e.contributions)&&void 0!==t?t:0,l=-(null!==(n=e.withdrawals)&&void 0!==n?n:0);return{month:e.date,contributions:a,withdrawals:l,total:a+l}},B6e=(e,t)=>{var n,l,r,o,i,s;const c=null!==(l=null!==(n=null===t||void 0===t?void 0:t.today)&&void 0!==n?n:N.c9.local().toISODate())&&void 0!==l?l:"",d=(0,et.I)(Io.l0,(0,U.A)({variables:{id:e,today:c},skip:!e||!c},null===t||void 0===t?void 0:t.queryOptions)),u=null===(o=null===(r=d.data)||void 0===r?void 0:r.savingsGoal)||void 0===o?void 0:o.timeline,m=null===(s=null===(i=d.data)||void 0===i?void 0:i.savingsGoal)||void 0===s?void 0:s.contributions,p=(0,a.useMemo)((()=>{return(null!==(e=null===u||void 0===u?void 0:u.dataByPeriod)&&void 0!==e?e:[]).filter(Tr.A).map(O6e);var e}),[null===u||void 0===u?void 0:u.dataByPeriod]),g=(0,a.useMemo)((()=>(e=>{var t;const n=new Map;for(const a of(null!==e&&void 0!==e?e:[]).filter(Tr.A)){const e=P6e(a),l=null!==(t=N.c9.fromISO(e.month).startOf("month").toISODate())&&void 0!==t?t:e.month,r=n.get(l);if(!r){n.set(l,{month:l,contributions:e.contributions,withdrawals:e.withdrawals,total:e.contributions+e.withdrawals});continue}const o=r.contributions+e.contributions,i=r.withdrawals+e.withdrawals;n.set(l,{month:l,contributions:o,withdrawals:i,total:o+i})}return[...n.values()].sort(((e,t)=>e.month.localeCompare(t.month)))})(null===m||void 0===m?void 0:m.dataByPeriod)),[null===m||void 0===m?void 0:m.dataByPeriod]);return{today:c,grouping:(0,a.useMemo)((()=>(e=>{switch(e){case Ee.QVK.DAY:return"day";case Ee.QVK.BIMONTHLY:return"bimonthly";case Ee.QVK.BIANNUAL:return"biannual";case Ee.QVK.ANNUAL:return"annual";case Ee.QVK.MONTHLY:default:return"monthly"}}
1)(null===u||void 0===u?void 0:u.groupingPeriod)),[null===u||void 0===u?void 0:u.groupingPeriod]),timelinePoints:p,contributionPoints:g,timelineAggregation:u,contributionsAggregation:m,isLoading:d.isLoadingInitialData,error:d.error,refetch:d.refetch}},z6e=[{label:"Timeline",value:"timeline"},{label:"Contributions",value:"contributions"}],F6e=e=>{var t,n;let l=e.goal,i=e.today;const s=(e=>{let t=e.goalId,n=e.goal,l=e.today;var r,o;const i=null!==(r=null!==l&&void 0!==l?l:N.c9.local().toISODate())&&void 0!==r?r:"",s=B6e(t,{today:i}),c=(0,a.useMemo)((()=>{const e=N.c9.fromISO(i);return s.timelinePoints.filter((t=>N.c9.fromISO(t.date).hasSame(e,"month"))).reduce(((e,t)=>{var n,a;return e+((null!==(n=t.totalSavings)&&void 0!==n?n:0)-(null!==(a=t.previousTotalSavings)&&void 0!==a?a:0))}),0)}),[s.timelinePoints,i]),d=(null!==(o=n.netContribution)&&void 0!==o?o:0)-c;return{today:i,grouping:s.grouping,timelinePoints:s.timelinePoints,contributionPoints:s.contributionPoints,startAmount:d,isLoading:s.isLoading,error:s.error}})({goalId:l.id,goal:l,today:null!==(t=null!==i&&void 0!==i?i:N.c9.local().toISODate())&&void 0!==t?t:void 0}),c=(0,a.useState)(0),d=(0,o.A)(c,2),u=d[0],p=d[1],g=(0,qd.W)(),h=(0,o.A)(g,2),v=h[0],f=h[1].width,E=void 0===f?0:f,y=z6e[u];return a.createElement(b6e,{"data-external-id":"savings-goal-details-chart"},a.createElement(C6e,null,a.createElement(m.g,{gap:"small"},a.createElement(fe.xz6.Title,{className:"text-20"},y.label),0===u&&a.createElement(El.H,{className:"text-base",startAmount:s.startAmount,endAmount:null!==(n=l.netContribution)&&void 0!==n?n:0,timeframeDisplay:"this month"})),a.createElement(Dc.t,{onChangeIndex:p,index:u},a.createElement(x6e,null,z6e.map(((e,t)=>{let n=e.label;return a.createElement(RA.Q,{key:t,index:t,$background:"card"},n)}))))),a.createElement(A6e,null,a.createElement(G6e,{ref:v},a.createElement(Y6e,null,(0,r.YW)(y.value).with("timeline",(()=>a.createElement(U6e,null,a.createElement(L6e,{historicalPoints:s.timelinePoints,grouping:s.grouping,goal:l,height:e6e,today:s.today})))).with("contributions",(()=>a.createElement(v6e,{contributionPoints:s.contributionPoints,goal:l,height:e6e,width:E}))).exhaustive()))))},G6e=u.default.div.withConfig({displayName:"SavingsGoalDetailsChart__ChartRoot",componentId:"ain77m-0"})(["position:relative;height:","px;"],e6e),Y6e=u.default.div.withConfig({displayName:"SavingsGoalDetailsChart__ChartContainer",componentId:"ain77m-1"})(["position:absolute;top:0;left:0;right:0;bottom:0;"]),U6e=u.default.div.withConfig({displayName:"SavingsGoalDetailsChart__LineChartContainer",componentId:"ain77m-2"})(["padding:0 ","px;"],t6e);var V6e,W6e=n(1163);const j6e=e=>{var t;let n=e.goal,l=e.isLoading,r=e.onClose,o=e.onArchive;const i=(null!==(t=n.allocationAmountsByAccount)&&void 0!==t?t:[]).filter(Tp.n).filter((e=>{let t=e.totalAmount;return(0,Tp.n)(t)&&t>0}));return a.createElement(Rc.L,{"data-external-id":"archive-goal-confirmation-modal-card",title:_t.$.ARCHIVE_CONFIRMATION.TITLE,fullHeight:!0},a.createElement(_m.O,null,a.createElement("div",{className:"flex flex-col gap-xl p-xl"},a.createElement(K6e,{goal:n}),a.createElement($6e,null),a.createElement("div",{className:"flex flex-col gap-default"},a.createElement(xt.v,{size:"large",weight:"medium"},_t.$.ARCHIVE_CONFIRMATION.WHAT_HAPPENS_HEADING),a.createElement("div",{className:"flex flex-col gap-sm"},_t.$.ARCHIVE_CONFIRMATION.WHAT_HAPPENS_POINTS.map(((e,t)=>{const n=(0,fe.lSP)(e.icon);return a.createElement("div",{key:t,className:"flex items-center gap-sm"},n&&a.createElement(fe.CWN,{shape:"circle",icon:a.createElement(fe.jeH,{name:n,size:16})}),a.createElement(xt.v,{size:"base"},e.text))})))),a.createElement($6e,null),a.createElement("div",{className:"flex flex-col gap-default"},a.createElement(xt.v,{size:"large",weight:"medium"},_t.$.ARCHIVE_CONFIRMATION.FUNDS_HEADING),i.length>0?i.map((e=>a.createElement(q6e,{key:e.account.id,allocation:e}))):a.createElement(xt.v,{size:"base",color:"content.secondary"},_t.$.ARCHIVE_CONFIRMATION.EMPTY_ALLOCATIONS)))),a.createElement(Cq.R,null,a.createElement(wt.Xb,{onClick:r,size:"small"},_t.$.ARCHIVE_CONFIRMATION.CANCEL),a.createElement(cu.gs,{onClick:o,size:"small",pending:l}
1,_t.$.ARCHIVE_CONFIRMATION.CONFIRM)))},H6e=e=>{let t=e.children;return a.createElement(fe.xz6,{"data-external-id":"card-container",className:"border border-border-primary"},a.createElement(fe.xz6.Content,{className:"flex-row items-center gap-sm p-default"},t))},K6e=e=>{let t=e.goal;const n=(0,J8e.q)(t).shouldShowPill;return a.createElement(H6e,{"data-external-id":"goal-summary-card"},a.createElement(d8e.YI,{imageStorageProvider:t.imageStorageProvider,imageStorageProviderId:t.imageStorageProviderId,size:"small"}),a.createElement("div",{className:"flex w-full flex-col gap-2xs"},a.createElement("div",{className:"flex flex-1 items-center justify-between"},a.createElement("div",{className:"flex items-center gap-xs"},a.createElement(xt.v,{size:"large"},t.name),a.createElement(W6e.v,{goalId:t.id})),a.createElement(xt.v,{size:"large"},(0,rl.vv)(t.currentBalance))),a.createElement("div",{className:"flex flex-1 items-center justify-between"},a.createElement("div",{className:"flex items-center gap-xs"},n&&a.createElement(u8e.C,{goal:t}),a.createElement(xt.v,{size:"small",color:"content.secondary"},t.targetDate?(0,Ba.aX)(N.c9.fromISO(t.targetDate)):"No target date")),a.createElement(xt.v,{size:"small",color:"content.secondary"},"Total allocated"))))},q6e=e=>{let t=e.allocation;return a.createElement(H6e,{"data-external-id":"account-allocation-card"},a.createElement(Gl.v,{logoUrl:t.account.logoUrl,icon:t.account.icon,size:40}),a.createElement("div",{className:"flex w-full flex-col gap-3xs"},a.createElement("div",{className:"flex flex-1 items-center justify-between"},a.createElement(xt.v,{size:"large"},t.account.displayName),a.createElement(xt.v,{size:"large"},(0,rl.vv)(t.totalAmount))),a.createElement("div",{className:"flex flex-1 items-center justify-between"},a.createElement(xt.v,{size:"small",color:"content.secondary"},t.account.subtype.display),a.createElement(xt.v,{size:"small",color:"content.secondary"},"Allocated"))))},$6e=$d.s.div(V6e||(V6e=(0,wc.A)(["flex h-px bg-divider-primary"])));var Z6e=n(45714);const J6e=e=>{let t=e.goal,n=e.onClickEdit;const r=(null!==t&&void 0!==t?t:{}).id,s=(0,l.Zp)(),c=(0,Pd.h)(),d=(0,o.A)(c,2),u=d[0],m=d[1],p=m.open,g=m.close,h=(0,Pd.h)(),v=(0,o.A)(h,2),f=v[0],E=v[1],y=E.open,b=E.close,x=(0,Pd.h)(),w=(0,o.A)(x,2),C=w[0],A=w[1],k=A.open,S=A.close,T=(0,Pd.h)(),_=(0,o.A)(T,2),D=_[0],R=_[1].open,M=(e=>{const t=(0,i.n)(Io.oh,e),n=(0,o.A)(t,2),l=n[0],r=n[1];return[(0,a.useCallback)((e=>l({variables:{input:{id:e}}})),[l]),r]})({refetchQueries:[{query:Io.H4,variables:{id:r}}]}),L=(0,o.A)(M,2),O=L[0],P=L[1].loading,B=(e=>{const t=(0,i.n)(Io.Rm,e),n=(0,o.A)(t,2),l=n[0],r=n[1];return[(0,a.useCallback)((e=>l({variables:{input:{id:e}},optimisticResponse:{__typename:"Mutation",archiveSavingsGoal:{__typename:"ArchiveSavingsGoal",savingsGoal:{__typename:"SavingsGoal",id:e,archivedAt:N.c9.local().toISO(),status:Ee.O4p.ARCHIVED},errors:null}}})),[l]),r]})({refetchQueries:[{query:Io.H4,variables:{id:r}},{query:Io.jF,variables:{id:r}},Io.l0],onCompleted:()=>{S(),s(I.JZ.goals.savings.path)}}),z=(0,o.A)(B,2),F=z[0],G=z[1].loading,Y=(0,Z6e.Z)({onCompleted:()=>{b(),s(I.JZ.goals.savings.path)}}),U=(0,o.A)(Y,2),V=U[0],W=U[1].loading,j=(0,a.useCallback)((()=>{(0,Ge.u4)(Ye.Y5.CreateGoalsAllocationClicked,{path:"goals/savings/".concat(r)}),p()}),[r,p]);return a.createElement(a.Fragment,null,a.createElement(uU.f,null,a.createElement(e5e,null),a.createElement(Qi.Az,{overlay:a.createElement(Ji.SP,null,a.createElement(Ji.xm,{onClick:n},_t.$.GOAL_DETAILS_CONTROLS.EDIT),a.createElement(Ji.xm,{onClick:R},_t.$.GOAL_DETAILS_CONTROLS.EDIT_ACCOUNTS),t.status===Ee.O4p.ARCHIVED?a.createElement(Ji.xm,{onClick:()=>O(r),disabled:P},_t.$.GOAL_DETAILS_CONTROLS.UNARCHIVE):a.createElement(Ji.xm,{onClick:k},_t.$.GOAL_DETAILS_CONTROLS.ARCHIVE),a.createElement(Ji.xm,{type:"danger",onClick:y},_t.$.GOAL_DETAILS_CONTROLS.DELETE)),placement:"bottom-end"},(e=>{let t=e.toggleOpen,n=e.isOpen;return a.createElement(wt.Xb,{size:"small",onClick:t,active:n},a.createElement("span",null,"Manage"),a.createElement(Yo.r,{name:"chevron-down"}))})),a.createElement(vCe,null),a.createElement(cu.WT,{onClick:j},a.createElement(Yo.r,{name:"arrow-left-right"}),a.createElement("span",null,_t.$.ALLOCATE_FUNDS))),a.createElement(D,null,a.createElement(E8e,null)),a.createElement(u,null,a.createElement(b8e,{onClose:g,toId:Y5e(r,"goal")})),a.createElement(f,null,a.createElement(xC.$,{title:_t.$.DELET
1E_CONFIRMATION.TITLE,confirm:"Delete",useDangerButton:!0,onCancel:b,onConfirm:()=>V(r),isLoading:W},_t.$.DELETE_CONFIRMATION.DESCRIPTION)),a.createElement(C,null,a.createElement(j6e,{goal:t,onClose:S,onArchive:()=>F(r),isLoading:G})))};var X6e,Q6e;const e9e=e=>a.createElement(t9e,Object.assign({"data-external-id":"savings-goal-details-grid",template:'"image image" "stats stats" "chart chart" "list summary" / 1fr 30%',md:'"image" "stats" "chart" "summary" "list"'},e)),t9e=(0,$d.s)(QU.a)(X6e||(X6e=(0,wc.A)(["pt-0"]))),n9e=e=>a.createElement(QU.E,Object.assign({"data-external-id":"savings-goal-details-image-grid-item",area:"image"},e)),a9e=e=>a.createElement(i9e,Object.assign({"data-external-id":"savings-goal-details-chart-grid-item",area:"chart"},e)),l9e=e=>a.createElement(i9e,Object.assign({"data-external-id":"savings-goal-details-list-grid-item",area:"list"},e)),r9e=e=>a.createElement(i9e,Object.assign({"data-external-id":"savings-goal-details-summary-grid-item",area:"summary"},e)),o9e=e=>a.createElement(i9e,Object.assign({"data-external-id":"savings-goal-details-stats-grid-item",area:"stats"},e)),i9e=(0,$d.s)(QU.E)(Q6e||(Q6e=(0,wc.A)(["[&>*:not(:last-child)]:mb-(--grid-spacing)"])));var s9e,c9e;const d9e=(0,$d.s)(fe.xz6.Header)(s9e||(s9e=(0,wc.A)(["px-xl py-sm"]))),u9e=(0,$d.s)(fe.xz6.Content)(c9e||(c9e=(0,wc.A)(["px-0 pt-0"]))),m9e=e=>a.createElement(m.g,Object.assign({"data-external-id":"savings-goal-details-transactions-card-row-group",justifyBetween:!0,alignCenter:!0,backgroundColor:"background.secondary",paddingHorizontal:"xlarge",paddingVertical:"xsmall"},e)),p9e=e=>a.createElement(xt.v,Object.assign({"data-external-id":"savings-goal-details-transactions-card-row-group-date",color:"content.secondary",weight:"medium",size:"small"},e)),g9e=e=>a.createElement(xt.v,Object.assign({"data-external-id":"savings-goal-details-transactions-card-row-group-total",color:"content.secondary",weight:"medium",size:"small"},e)),h9e=e=>a.createElement(m.g,Object.assign({"data-external-id":"savings-goal-details-transactions-card-entity",gap:"xsmall",alignCenter:!0},e)),v9e=((0,u.default)(sl.ZQ).attrs({name:"arrow-right",size:16}).withConfig({displayName:"SavingsGoalDetailsTransactionsCardShell__RightArrowIcon",componentId:"idodxg-0"})(["color:",";"],vt.Ee.color.content.secondary),e=>a.createElement(m.g,Object.assign({"data-external-id":"savings-goal-details-transactions-card-row",borderBottom:"1px solid divider.primary",paddingVertical:"xsmall",paddingLeft:"xlarge",paddingRight:"default",gap:"small",alignCenter:!0,justifyBetween:!0},e))),f9e=e=>a.createElement(m.g,Object.assign({"data-external-id":"savings-goal-details-transactions-card-row-left",alignCenter:!0,gap:"small"},e)),E9e=()=>a.createElement(fe.xz6,{"data-external-id":"savings-goal-details-transactions-card-loading"},a.createElement(d9e,null,a.createElement(fe.xz6.Title,null,a.createElement(M.Qp,null,"Transactions"))),a.createElement(u9e,null,Array.from({length:4}).map(((e,t)=>a.createElement(a.Fragment,{key:t},a.createElement(m9e,null,a.createElement(p9e,null,a.createElement(M.Qp,null,"Jul 2025")),a.createElement(g9e,null,a.createElement(M.Qp,null,"$100"))),Array.from({length:t+1}).map(((e,t)=>a.createElement(v9e,{key:t},a.createElement(f9e,null,a.createElement(h9e,null,a.createElement(M.Al,{$width:"".concat(20,"px"),$height:"".concat(20,"px")}),a.createElement(M.Qp,null,"Some name")),a.createElement(M.Qp,null,"Some type")),a.createElement(M.Qp,null,"+$100"))))))))),y9e=e=>a.createElement(b9e,Object.assign({"data-external-id":"savings-goal-progress-card-shell",padding:"xlarge",position:"relative",borderRadius:"default",column:!0,justifyBetween:!0,alignEnd:!0},e)),b9e=(0,u.default)(m.g).withConfig({displayName:"SavingsGoalProgressCardShell__StyledFlexContainer",componentId:"j1vcno-0"})(["background-image:url(",");background-size:cover;background-position:center;background-repeat:no-repeat;height:400px;width:100%;"," & > button{transition:",";opacity:0;}&:hover{& > button{opacity:1;}}"],(e=>e.$backgroundImage),wn.M.medium,(e=>e.theme.transition.default));var x9e=n(46549);const w9e=()=>a.createElement(e9e,{"data-external-id":"savings-goal-details-loading"},a.createElement(n9e,null,a.createElement(y9e,null,a.createElement(m.g,{position:"absolute",top:0,left:0,right:0,bottom:0},a.createElement(M.Al,{$width:"100%",$height:"100%"})),a.createElement("div",null),a.createElement(fe.xz6,{className:"w-full"},a.createElement(x9e.t8,{variant:"header"})))),a.createElement(l9e,null,a.createElement(w6e,null),a.createElement(E9e,null)),a.createElement(r9e,null,a.createElement(fe.xz6,null,a.createElement(P8e,null,a.createElement(fe.xz6.Title,null,a.createElement(M.Qp,null,"Accounts"))),a.createElement(B8e,null,a.createElement(C9e,null),a.createElement(C9e,null),a.createElement(C9e,{borderBottom:"none"})),a.createElement(z8e,null,a.createElement(M.Al,{$width:"100%",$height:"40px"}
1,a.createElement(M.aU,null,a.createElement(wt.Xb,null,"Loading"))))),a.createElement($8e,null))),C9e=e=>a.createElement(m.g,Object.assign({"data-external-id":"allocation-row",paddingVertical:"small",paddingHorizontal:"default",borderBottom:"1px solid divider.primary",justifyBetween:!0},e),a.createElement(m.g,{justifyBetween:!0,paddingHorizontal:"xxsmall",width:"100%"},a.createElement(M.Qp,null,"Account"),a.createElement(M.Qp,null,"$100")));var A9e=n(97380);const I9e=e=>{let t=e.event,n=e.afterDelete;const l=t.type,r=t.date,o=t.account;return(0,A9e.A2)(l)?a.createElement(k9e,{"data-external-id":"savings-goal-details-event-drawer-form",type:l,date:r,account:o}):a.createElement(S9e,{"data-external-id":"savings-goal-details-event-drawer-form",event:t,afterDelete:n})},k9e=e=>{var t;let n=e.type,l=e.date,r=e.account;return a.createElement(m.g,{"data-external-id":"read-only-fields",gap:"xlarge",column:!0},a.createElement(N9e,{label:"Type",value:a.createElement(Oc.D,{color:"grayLight"},(0,A9e.I8)({type:n}))}),a.createElement(N9e,{label:"Account",value:a.createElement(m.g,{alignCenter:!0,gap:"xsmall"},a.createElement(aq.i,{size:16,logo:null!==(t=null===r||void 0===r?void 0:r.logoUrl)&&void 0!==t?t:null}),a.createElement(A8e,{id:r.id},null===r||void 0===r?void 0:r.displayName))}),a.createElement(N9e,{label:"Date",value:a.createElement(xt.v,null,(0,Ba.AO)(l))}))},S9e=e=>{var t,n;let l=e.event,r=e.afterDelete;const s=l.id,c=l.type,d=l.date,u=l.account,p=l.canDelete,g=l.includeInBudget,h=l.notes,v=(0,R3.F)().isTransactionLinkingEnabled,f=(0,C.RU)(),E=(0,i.n)(Io.R7,{variables:{input:{eventId:s}},update:e=>{e.evict({id:e.identify({__typename:"GoalEvent",id:s})}),e.gc()},onCompleted:()=>{r(),(0,C.oR)({title:"Goal allocation deleted",description:"The goal allocation has been deleted successfully."})},onError:e=>{f({description:(0,nj.A)("We could not delete the goal allocation.",["message"],e)})},refetchQueries:[Io.jF,Io.l0,Io.H4]}),y=(0,o.A)(E,2),b=y[0],x=y[1].loading,w=(0,Pd.h)(),A=(0,o.A)(w,2),I=A[0],k=A[1],S=k.open,T=k.close,_=(0,i.n)(Io.Hr,{refetchQueries:[Io.jF,Io.l0,Io.H4]}),D=(0,o.A)(_,1)[0],R=(0,a.useCallback)((async e=>{await D({variables:{input:{eventId:s,date:e.date,includeInBudget:e.includeInBudget,notes:e.notes}}})}),[s,D]);return a.createElement(Eu.lV,{"data-external-id":"editable-fields",initialValues:{date:d,includeInBudget:null!==g&&void 0!==g&&g,notes:null!==h&&void 0!==h?h:""},onSubmit:R,submitOnChangeDebounceMs:350,submitOnChange:!0},a.createElement(m.g,{gap:"xlarge",column:!0},a.createElement(N9e,{label:"Type",value:a.createElement(Oc.D,{color:"grayLight"},(0,A9e.I8)({type:c}))}),a.createElement(N9e,{label:"Account",value:a.createElement(m.g,{alignCenter:!0,gap:"xsmall"},a.createElement(aq.i,{size:16,logo:null!==(t=null===u||void 0===u?void 0:u.logoUrl)&&void 0!==t?t:null}),a.createElement(A8e,{id:u.id},null===u||void 0===u?void 0:u.displayName))}),a.createElement(N9e,{label:"Date",value:a.createElement(tC.zB.Date,{name:"date",label:null,dateFormat:iC.yP,placeholder:"Select a date...",max:null!==(n=N.c9.local().toISODate())&&void 0!==n?n:void 0})}),a.createElement(N9e,{label:"Notes",value:a.createElement(vu.Q,{name:"notes",hideLabel:!0,hideResizeHandle:!0,placeholder:"Add notes...",minRows:2})}),(!v||!(0,A9e.A2)(c))&&a.createElement(fPe,{toggleFieldProps:{name:"includeInBudget"},fieldCellProps:{title:_t.$.INCLUDE_IN_BUDGET.TITLE,subtitle:a.createElement(xt.v,{color:"content.secondary"},_t.$.INCLUDE_IN_BUDGET.SUBTITLE)}}),p&&a.createElement(a.Fragment,null,a.createElement(z7.P,{text:"",height:1}),a.createElement(G7.xO,{onClick:S,pending:x},"Delete goal allocation"),a.createElement(I,null,a.createElement(xC.$,{title:_t.$.GOAL_ALLOCATION.DELETE.CONFIRM,confirm:"Delete allocation",useDangerButton:!0,onCancel:T,onConfirm:()=>{b(),T()}},a.createElement(xt.v,null,_t.$.GOAL_ALLOCATION.DELETE.DESCRIPTION))))))},N9e=e=>{let t=e.label,n=e.value;return a.createElement(m.g,{"data-external-id":"savings-goal-details-event-drawer-field",gap:"xsmall",column:!0},a.createElement(xt.v,{weight:"medium",size:"small"},t),a.createElement("div",null,n))};var T9e,_9e=n(63796);const D9e=e=>{let t=e.goalName,n=e.imageStorageProvider,l=e.imageStorageProviderId,r=e.amount;return a.createElement(R9e,{"data-external-id":"savings-goal-details-event-drawer-header",template:'"image content" / '.concat(48,"px 1fr")},a.createElement(QU.E,{area:"image"},a.createElement(M9e,null,a.createElement(L9e,{imageStorageProvider:n,imageStorageProviderId:l,size:"small"}))),a.createElement(QU.E,{area:"content"},a.createElement(m.g,{column:!0},a.createElement(xt.v,{size:"20"},t),a.createElement(_9e.o,{className:"font-medium",value:r}
1))))},R9e=(0,$d.s)(QU.a)(T9e||(T9e=(0,wc.A)(["items-center p-0"]))),M9e=u.default.div.withConfig({displayName:"SavingsGoalDetailsEventDrawerHeader__ImageContainer",componentId:"sc-1uz96qb-0"})(["width:","px;height:","px;position:relative;"],48,48),L9e=(0,u.default)(oQ.s).withConfig({displayName:"SavingsGoalDetailsEventDrawerHeader__StyledSavingsGoalImage",componentId:"sc-1uz96qb-1"})(["border-radius:",";"],vt.r8.medium),O9e=e=>{let t=e.goalId,n=e.eventId,l=e.overrideAmount,o=e.onClose;const i=((e,t,n)=>{var a,l;const r=(0,et.I)(Io.aQ,(0,U.A)({variables:{goalId:e,eventId:t}},null===n||void 0===n?void 0:n.queryOptions)),o=null===(a=r.data)||void 0===a?void 0:a.savingsGoal;return{goal:o,event:null!==(l=null===o||void 0===o?void 0:o.goalEvent)&&void 0!==l?l:void 0,isLoading:r.isLoadingInitialData,error:r.error,refetch:r.refetch}})(t,n,{queryOptions:{fetchPolicy:"cache-first"}}),s=i.goal,c=i.event,d=i.isLoading,u=i.error;return a.createElement(P9e,{"data-external-id":"savings-goal-details-event-drawer",title:a.createElement(xt.v,{size:"large",weight:"medium"},"Allocation details"),onClose:()=>o(),showBorder:!0},(0,r.YW)({isLoading:d,error:u,goal:s,event:c}).with({isLoading:!0},(()=>a.createElement("div",{className:"flex items-center justify-center p-xl"},a.createElement(p.i,null)))).with({error:r.P.nonNullable},(()=>a.createElement("div",{className:"p-xl"},a.createElement(SQ.W,{message:VG.U.GOAL_DETAIL})))).with({goal:r.P.nonNullable,event:r.P.nonNullable},(e=>{let t=e.goal,n=e.event;return a.createElement("div",{className:"flex flex-col gap-xl p-xl"},a.createElement(D9e,{goalName:t.name,imageStorageProvider:t.imageStorageProvider,imageStorageProviderId:t.imageStorageProviderId,amount:null!==l&&void 0!==l?l:n.amount}),a.createElement(I9e,{event:n,afterDelete:()=>o({replace:!0})}))})).otherwise((()=>a.createElement(txe.m,{title:"No event found",description:"Sorry, we were unable to find this event."}))))},P9e=(0,u.default)(F7.v).withConfig({displayName:"SavingsGoalDetailsEventDrawer__StyledSideDrawer",componentId:"sc-9rqv0w-0"})(["[data-sc-tw~='SideDrawer__SideDrawerNavigationHeader']{padding:"," ",";}"],vt.YK.small,vt.YK.xlarge),B9e=24,z9e=e=>{var t,n,l,r;let o=e.event,i=e.onEventClick,s=e.onAggregatedEventClick,c=e.amountTextColor,u=e.amountTextWeight,p=e.showPlusSign,g=e.useAbsoluteValue,h=e.showDrawerToggleClass;const v=(0,d.d4)(Od.$Y),f=g?Math.abs(null!==(t=o.amount)&&void 0!==t?t:0):null!==(n=o.amount)&&void 0!==n?n:0,E="".concat(p?"+":"").concat((0,rl.vv)(f)),y=(0,A9e.X4)(o),b=(0,A9e.yw)(o),x=v&&b;return a.createElement(v9e,{"data-external-id":"goal-event-row",key:o.id},a.createElement(f9e,null,a.createElement(h9e,null,a.createElement(aq.i,{size:20,logo:null!==(l=o.account.logoUrl)&&void 0!==l?l:null}),a.createElement(A8e,{id:o.account.id},o.account.displayName)),y?a.createElement(P.D_,{content:y,maxWidth:196},a.createElement(m.g,{cursor:"default"},a.createElement(Oc.D,{color:"grayLight"},(0,A9e.I8)(o)))):a.createElement(Oc.D,{color:"grayLight"},(0,A9e.I8)(o)),x&&a.createElement(P.D_,{content:"Aggregated from ".concat(null===(r=o.aggregatedFrom)||void 0===r?void 0:r.length," events (click to view breakdown)")},a.createElement(V9e,{onClick:()=>null===s||void 0===s?void 0:s(o),onKeyDown:e=>(0,mde.l)(e,(()=>null===s||void 0===s?void 0:s(o))),role:"button",tabIndex:0},a.createElement(F9e,{name:"layers",size:12})))),a.createElement(m.g,{flexGrow:1,justifyEnd:!0,alignCenter:!0,gap:"xxsmall"},a.createElement(m.g,{alignCenter:!0,gap:"xsmall"},o.includeInBudget&&a.createElement(P.D_,{content:"Included in budget"},a.createElement(Y9e,null,a.createElement(F9e,{name:"map",size:12}))),o.notes&&a.createElement(P.D_,{content:a.createElement(W9e,null,o.notes)},a.createElement(U9e,null,a.createElement(F9e,{name:"file",size:12}))),a.createElement(xt.v,{color:c,weight:u}
1,E)),a.createElement(G9e,null,a.createElement(B.L,{className:h?"drawer-toggle":void 0,icon:"chevron-right",onClick:()=>i(o.id),size:"xsmall"}))))},F9e=(0,u.default)(sl.ZQ).withConfig({displayName:"GoalEventRow__StyledIcon",componentId:"sc-13qtp6h-0"})(["color:",";"],vt.Ee.color.content.secondary),G9e=(0,u.default)(gm.n).attrs({onClick:!0}).withConfig({displayName:"GoalEventRow__ChevronPropagationBoundary",componentId:"sc-13qtp6h-1"})(["flex:0;"]),Y9e=u.default.div.withConfig({displayName:"GoalEventRow__BudgetIconWrapper",componentId:"sc-13qtp6h-2"})(["display:flex;align-items:center;justify-content:center;flex-shrink:0;width:","px;height:","px;border-radius:",";"],B9e,B9e,vt.r8.round),U9e=u.default.div.withConfig({displayName:"GoalEventRow__NotesIconWrapper",componentId:"sc-13qtp6h-3"})(["display:flex;align-items:center;justify-content:center;flex-shrink:0;width:","px;height:","px;border-radius:",";"],B9e,B9e,vt.r8.round),V9e=u.default.div.withConfig({displayName:"GoalEventRow__AggregatedIconWrapper",componentId:"sc-13qtp6h-4"})(["display:flex;align-items:center;justify-content:center;flex-shrink:0;width:","px;height:","px;border-radius:",";cursor:pointer;background-color:",";&:hover{background-color:",";}"],B9e,B9e,vt.r8.round,vt.Ee.color.background.secondary,vt.Ee.color.background.tertiary),W9e=(0,u.default)(JY.e).withConfig({displayName:"GoalEventRow__TooltipContent",componentId:"sc-13qtp6h-5"})(["white-space:pre-wrap;word-wrap:break-word;text-align:left;"]);var j9e=n(69106);const H9e=["children","style"],K9e=e=>{var t;let n=e.isLoadingEvents,l=e.eventsByDate,i=e.onTransactionClick,s=e.onEventClick,c=e.onAggregatedEventClick,d=e.updateTransaction,u=e.onEndReached,m=e.stickyHeaderHeight,g=void 0===m?0:m;const h=(0,R3.F)().isTransactionLinkingEnabled,v=(0,a.useContext)(ri.z).scrollRef,f=(0,G.U)("only screen and (max-width: ".concat(yD.w.breakPoints.md,"px)")),E=(0,a.useMemo)((()=>Object.entries(l).map((e=>{let t=(0,o.A)(e,2),n=t[0],a=t[1];return{date:n,events:a,total:a.reduce(((e,t)=>{var n;return e+(null!==(n=t.amount)&&void 0!==n?n:0)}),0)}}))),[l]),y=(0,a.useMemo)((()=>E.flatMap((e=>e.events))),[E]),b=(0,a.useMemo)((()=>E.map((e=>e.events.length))),[E]),x=(0,a.useMemo)((()=>({Group:e=>{let t=e.children,n=e.style,l=(0,En.A)(e,H9e);return a.createElement("div",Object.assign({style:(0,U.A)((0,U.A)({},n),{},{zIndex:1,top:"".concat(g,"px")})},l),t)},Footer:()=>n?a.createElement("div",{className:"flex items-center justify-center p-xl"},a.createElement(p.i,null)):null})),[n,g]),w=(0,a.useMemo)((()=>({showAccountColumn:!0,refetchAll:()=>Promise.resolve()})),[]);return a.createElement(j8.pB.Provider,{"data-external-id":"savings-goal-details-transactions-list",value:w},a.createElement(Ac.kN,{style:{height:"100%"},customScrollParent:null!==(t=null===v||void 0===v?void 0:v.current)&&void 0!==t?t:void 0,groupCounts:b,components:x,endReached:u,groupContent:e=>{const t=E[e],n=t.date,l=t.total;return a.createElement(m9e,null,a.createElement(p9e,null,(0,Ba.AO)(n)),a.createElement(g9e,{color:l>0?"content.success":"content.secondary"},l<0?(0,rl.vv)(Math.abs(l)):(0,rl.PN)(l)))},itemContent:e=>{const t=y[e];return(0,r.YW)({event:t,isTransactionLinkingEnabled:h}).with({event:{type:Ee.WrU.SPENDING,transaction:r.P.nonNullable}},(e=>{let n=e.event.transaction;return a.createElement(q9e,{key:t.id,transaction:n,onChevronClick:i,updateTransaction:d,isSavingsGoalsEnabled:!0,isNarrowScreen:f})})).with({event:{type:r.P.union(Ee.WrU.CONTRIBUTION,Ee.WrU.WITHDRAWAL),transaction:r.P.nonNullable},isTransactionLinkingEnabled:!0},(e=>{let t=e.event;return a.createElement(q9e,{key:t.id,transaction:t.transaction,onChevronClick:i,updateTransaction:d,isSavingsGoalsEnabled:!0,isNarrowScreen:f})})).with({event:{type:Ee.WrU.CONTRIBUTION}},{event:{type:r.P.union(Ee.WrU.REBALANCE,Ee.WrU.PRICE_CHANGE,Ee.WrU.TRANSACTION_ADJUSTMENT),amount:r.P.when(BX.A)}},(()=>a.createElement(z9e,{event:t,onEventClick:s,onAggregatedEventClick:c,amountTextColor:"content.success",amountTextWeight:"medium",showPlusSign:!0,useAbsoluteValue:!1,showDrawerToggleClass:!0}))).with({event:{type:Ee.WrU.WITHDRAWAL}},{event:{type:r.P.union(Ee.WrU.REBALANCE,Ee.WrU.PRICE_CHANGE,Ee.WrU.TRANSACTION_ADJUSTMENT),amount:r.P.when(gSe.A)}},(()=>a.createElement(z9e,{event:t,onEventClick:s,onAggregatedEventClick:c,showPlusSign:!1,useAbsoluteValue:!0,showDrawerToggleClass:!1}
1))).otherwise((()=>null))}}))},q9e=(0,u.default)(j9e.q).withConfig({displayName:"SavingsGoalDetailsTransactionsList__TransactionRow",componentId:"btna8d-0"})(["width:100%;padding:"," ",";border-bottom:1px solid ",";& > div{padding:0;}"],vt.YK.xxsmall,vt.YK.default,vt.Ee.color.divider.primary),$9e=e=>{const t=(0,a.useState)(null),n=(0,o.A)(t,2),l=n[0],r=n[1],s=(0,i.n)(Y8.r,e);return{setDrawerTransactionId:r,drawerTransactionId:l,updateTransaction:(0,o.A)(s,1)[0]}},Z9e=["fetchMore"],J9e=(e,t)=>{var n,a;const l=e.savingsGoal,r=t.savingsGoal;if(!l||!r)return e;if(l.id!==r.id)return e;const o=(0,Mu.A)((0,mo.A)("id"),[...null!==(n=l.goalEventsPaginated.events)&&void 0!==n?n:[],...null!==(a=r.goalEventsPaginated.events)&&void 0!==a?a:[]]);return(0,U.A)((0,U.A)({},e),{},{savingsGoal:(0,U.A)((0,U.A)({},l),{},{goalEventsPaginated:(0,U.A)((0,U.A)({},r.goalEventsPaginated),{},{events:o})})})},X9e=(0,xZ.Z)((()=>n.e(4616).then(n.bind(n,54616)).then((e=>({default:e.AggregatedEventBreakdownModalCard})))),"AggregatedEventBreakdownModalCardLazy"),Q9e=e=>{let t=e.goalId;const n=(0,d.wA)(),r=(0,d.d4)(A.$Y),i=(0,R3.F)().isTransactionLinkingEnabled,s=(0,d.d4)(ft.Jd),c=((e,t)=>{var n,l,r,o;const i=null!==t&&void 0!==t?t:{},s=i.queryOptions,c=i.aggregateAdjustments,d=void 0!==c&&c,u=i.hideAdjustments,m=void 0!==u&&u,p=i.pageSize,g=null!==p&&void 0!==p?p:50,h=(0,a.useMemo)((()=>({id:e,limit:g,offset:0})),[e,g]),v=(0,et.I)(Io.jF,(0,U.A)({variables:h,notifyOnNetworkStatusChange:!0},s)),f=v.fetchMore,E=(0,En.A)(v,Z9e),y=null===(n=E.data)||void 0===n?void 0:n.savingsGoal,b=null===y||void 0===y?void 0:y.goalEventsPaginated,x=(0,a.useMemo)((()=>{var e;return null===(e=null===b||void 0===b?void 0:b.events)||void 0===e?void 0:e.filter(Tr.A)}),[null===b||void 0===b?void 0:b.events]),w=(0,a.useMemo)((()=>null===x||void 0===x?void 0:x.filter(A9e.pn)),[x]),C=(0,a.useMemo)((()=>{if(w)return d?(0,A9e.A4)(w).filter((e=>0!==e.amount)):w}),[w,d]),A=(0,a.useMemo)((()=>(0,A9e.o2)(null!==C&&void 0!==C?C:[])),[C]),I=null!==(l=null===b||void 0===b?void 0:b.hasMoreEvents)&&void 0!==l&&l,k=null!==(r=null===b||void 0===b?void 0:b.nextOffset)&&void 0!==r?r:0,S=(0,a.useRef)(!1),N=(0,a.useCallback)((()=>{if(I&&!S.current)return S.current=!0,f({variables:{offset:k},updateQuery:(e,t)=>{let n=t.fetchMoreResult;return n?J9e(e,n):e}}).finally((()=>{S.current=!1}))}),[f,I,k]),T=(0,a.useMemo)((()=>C&&m?C.filter((e=>!(0,A9e.A2)(e.type))):C),[C,m]);return(0,a.useEffect)((()=>{void 0!==T&&0===T.length&&I&&!E.isNetworkRequestInFlight&&N()}),[T,I,E.isNetworkRequestInFlight,N]),{goal:y,allEvents:x,events:C,eventsByDate:A,totalEventCount:null!==(o=null===b||void 0===b?void 0:b.totalEventCount)&&void 0!==o?o:0,hasNextPage:I,fetchNextPage:N,isLoading:E.isLoadingInitialData,isFetchingMore:E.isNetworkRequestInFlight&&!E.isLoadingInitialData,error:E.error,refetch:E.refetch}})(t,{aggregateAdjustments:i,hideAdjustments:!s}),u=c.events,h=c.eventsByDate,v=c.isLoading,f=c.isFetchingMore,E=c.hasNextPage,y=c.fetchNextPage,b=$9e(),x=b.drawerTransactionId,w=b.setDrawerTransactionId,C=b.updateTransaction,k=(e=>{var t;const n=(0,l.Zp)(),a=(0,l.RQ)(I.JZ.goals.savings.detail.event.path);return{drawerEventId:(null===a||void 0===a?void 0:a.params.id)===e&&null!==(t=a.params.eventId)&&void 0!==t?t:null,openEventDrawer:t=>{n(I.JZ.goals.savings.detail.event({id:e,eventId:t}))},closeEventDrawer:t=>{n(I.JZ.goals.savings.detail({id:e}),{replace:null===t||void 0===t?void 0:t.replace})}}})(t),S=k.drawerEventId,N=k.openEventDrawer,T=k.closeEventDrawer,_=(0,a.useMemo)((()=>{if(!S||!u)return;const e=u.find((e=>e.id===S));return e&&(0,A9e.yw)(e)?e.amount:void 0}),[S,u]),D=(0,Pd.h)(),R=(0,o.A)(D,2),M=R[0],L=R[1].open,O=(0,a.useState)(null),P=(0,o.A)(O,2),B=P[0],z=P[1],F=(0,a.useRef)(null),G=(0,a.useState)(0),Y=(0,o.A)(G,2),V=Y[0],W=Y[1];(0,a.useEffect)((()=>{const e=F.current;if(!e)return;const t=()=>W(e.offsetHeight);if(t(),"undefined"===typeof ResizeObserver)return;const n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()}),[]);const j=(0,a.useMemo)((()=>s?h:Object.fromEntries(Object.entries(h).map((e=>{let t=(0,o.A)(e,2);return[t[0],t[1].filter((e=>!(0,A9e.A2)(e.type)))]})).filter((e=>(0,o.A)(e,2)[1].length>0)))),[h,s]),H=0===Object.keys(j).length&&!E&&!f;return a.createElement(po.K,{"data-external-id":"savings-goal-details-transactions-card"},a.createElement(fe.xz6,{sticky:!0},a.createElement(d9e,{ref:F,className:"justify-between"},a.createElement(fe.xz6.Title,null,"Activity"),a.createElement(m.g,{alignCenter:!0,gap:"small"},a.createElement(xt.v,{color:"content.primary",size:"small"},"Show adjustments"),a.createElement(ox.k,{checked:s,onChange:()=>n((0,g.Zn)(!s))}))),a.createElement(u9e,null,H&&!v?a.createElement(txe.m,{marginVertical:"gutter",title:_t.$.GOAL_EVENTS_EMPTY.TITLE,description:_t.$.GOAL_EVENTS_EMPTY.SUBTITLE}):a.createElement(K9e,{eventsByDate:j,onTransactionClick:w,onEventClick:e=>{e&&N(e)},onAggregatedEventClick:e=>{z(e),L(e)},updateTransaction:C,isLoadingEvents:v||f,onEndReached:E?y:void 0,stickyHeaderHeight:V}))),!!x&&a.createElement(go.TT,{id:x,onClose:()=>w(null),setId:w,previousTransactionId:null,nextTransactionId:null}),(0,Tr.A)(S)&&a.createElement(O9e,{goalId:t,eventId:S,overrideAmount:_,onClose:T}),a.createElement(M,null,(null===B||void 0===B?void 0:B.aggregatedFrom)&&r&&a.createElement(a.Suspense,{fallback:a.createElement(p.i,null)},a.createElement(X9e,{aggregatedEvent:B,originalEvents:B.aggregatedFrom}))))};var e7e=n(65828),t7e=n(56796),n7e=n(32760);const a7e=e=>{let t=e.goal;const n=t.imageStorageProvider,l=t.imageStorageProviderId,r=(0,Pd.h)(),i=(0,o.A)(r,2),s=i[0],c=i[1],d=c.open,u=c.close,m=(0,e7e.r)(t).updateGoal,p=(0,t7e.y)({imageStorageProvider:n,imageStorageProviderId:l,size:"large",cloudinaryUrlBuilder:(e,t)=>n7e.L.url(e,t)});return a.createElement(a.Fragment,null,a.createElement(y9e,{$backgroundImage:p},a.createElement(wt.Xb,{onClick:d},"Customize image"),a.createElement(fe.xz6,{className:"w-full"},a.createElement(yo.p,{goal:t,variant:"header"}))),a.createElement(s,null,a.createElement(vbe.n,{GoalImage:oQ.s,onSelect:e=>{m({imageStorageProvider:"unsplash",imageStorageProviderId:e.urls.raw})},onClose:u})))}
1,l7e=e=>{let t=e.goal;const n=(0,pQ.I4)(t),l=n.totalSaved,r=n.totalSpent,o=n.availableToSpend,i=n.leftToSave;return a.createElement(i7e,{"data-external-id":"savings-goal-stats"},a.createElement(o7e,{value:a.createElement(xt.v,{color:(0,S8e.E8)(l)},(0,rl.PN)(l)),label:a.createElement(r7e,null,"Total saved")}),a.createElement(o7e,{value:a.createElement(xt.v,{color:"content.primary"},(0,rl.vv)(r)),label:a.createElement(r7e,null,"Total spent")}),a.createElement(o7e,{value:a.createElement(xt.v,{color:(0,S8e.E8)(o)},(0,rl.PN)(o)),label:a.createElement(r7e,null,"Available to spend")}),a.createElement(o7e,{value:a.createElement(xt.v,{color:"content.primary"},(0,rl.vv)(i)),label:a.createElement(r7e,null,"Left to save")}))},r7e=(0,u.default)(xt.v).withConfig({displayName:"SavingsGoalStats__StatisticCardLabel",componentId:"sc-14w9xwq-0"})(["font-size:",";font-weight:",";color:",";"],vt.J.small,vt.Wy.medium,vt.Ee.color.content.secondary),o7e=(0,u.default)(MZ).attrs({"data-sc-tw":"SavingsGoalStats__StatisticCardGrow"}).withConfig({displayName:"SavingsGoalStats__StatisticCardGrow",componentId:"sc-14w9xwq-1"})(["flex:1;"]),i7e=(0,u.default)(m.g).attrs({justifyBetween:!0,alignStretch:!0,gap:"gutter"}).withConfig({displayName:"SavingsGoalStats__SummaryCardsContainer",componentId:"sc-14w9xwq-2"})(["@media (max-width:","px){flex-flow:row wrap;gap:",";> [data-sc-tw~='SavingsGoalStats__StatisticCardGrow']{flex-basis:33%;}}@media (max-width:","px){> [data-sc-tw~='SavingsGoalStats__StatisticCardGrow']{flex-basis:50%;}}"],vt.nm.md,vt.YK.small,vt.nm.xs),s7e=()=>{var e,t;const n=(0,lV.L)().id,o=(0,l.Zp)(),i=(0,et.I)(Io.H4,{variables:{id:n}}),s=(null!==(e=i.data)&&void 0!==e?e:{}).savingsGoal,c=null!==(t=null===s||void 0===s?void 0:s.name)&&void 0!==t?t:"",d=()=>o(I.JZ.goals.savings.detail.settings({id:n}));return a.createElement(rG.Y,{"data-external-id":"savings-goal-details",name:"Savings Goal Details",parentRoute:"Savings Goals",overrideTitle:c,controls:s?a.createElement(J6e,{goal:s,onClickEdit:d}):void 0},a.createElement(rV.T,{screenName:"Savings Goal Details",isInfiniteScroll:!0}),(0,r.YW)({loading:i.isLoadingInitialData,goal:s}).with({loading:!0},(()=>a.createElement(w9e,null))).with({goal:r.P.nonNullable},(e=>{let t=e.goal;return a.createElement(e9e,null,a.createElement(n9e,null,t&&a.createElement(a7e,{goal:t})),a.createElement(o9e,null,t&&a.createElement(l7e,{goal:t})),a.createElement(a9e,null,t&&a.createElement(F6e,{goal:t})),a.createElement(l9e,null,a.createElement(Q9e,{goalId:n})),a.createElement(r9e,{sticky:!0},a.createElement("div",{className:"flex flex-col gap-gutter"},a.createElement(G8e,{goal:t}),a.createElement(X8e,{goal:t,onClickEdit:d}))))})).otherwise((()=>a.createElement(eV.M,null))),a.createElement(XU.l,{path:I.JZ.goals.savings.detail.settings.relativePath},a.createElement(hze,{goalId:n})))};var c7e,d7e;const u7e=[{icon:fe.i01,text:"This reconciliation record will be deleted"},{icon:fe.$OE,text:"The external spending transactions associated with this record will no longer be reconciled"},{icon:fe.$OE,text:"External spending will re-appear on the account in available for goals"},{icon:fe.N9s,text:"The transaction used to cover will re-appear when trying to reconcile"}],m7e=e=>{let t=e.open,n=e.onOpenChange,l=e.onConfirm;return a.createElement(fe.V0Z,{"data-external-id":"delete-reconciliation-modal",open:t,onOpenChange:n,tone:"destructive",title:"Delete reconciliation",confirmLabel:"Delete reconciliation",size:"xl",onConfirm:l},a.createElement("div",{className:"flex flex-col gap-sm"},a.createElement(fe.c8D,{weight:"medium"},"What will happen..."),u7e.map((e=>{let t=e.icon,n=e.text;return a.createElement(g7e,{key:n},a.createElement(p7e,null,a.createElement(t,{className:"text-content-secondary"})),a.createElement(fe.c8D,null,n))}))))},p7e=$d.s.div(c7e||(c7e=(0,wc.A)(["\n  mr-sm flex min-h-8 min-w-8 shrink-0 items-center justify-center rounded-round\n  bg-background-secondary\n"]))),g7e=$d.s.div(d7e||(d7e=(0,wc.A)(["flex items-center"])));var h7e,v7e;const f7e=e=>{var t;let n=e.record,l=e.viewMode;return a.createElement(E7e,{"data-external-id":"reconciliation-card"},a.createElement("div",{className:"flex items-center gap-sm"},a.createElement(aq.i,{size:40,logo:null!==(t=n.account.logoUrl)&&void 0!==t?t:null}),a.createElement("div",{className:"flex flex-col items-start"},a.createElement(fe.c8D,{color:"primary"},n.account.displayName),a.createElement(fe.c8D,{color:"secondary",size:"sm"},"detail"===l?"Reconciled on ":"",(0,Ba.HN)(n.createdAt)))),a.createElement("div",{className:"flex items-center gap-sm"},a.createElement(fe.PED,{style:"currency",value:n.amount,color:"primary"}),"list"===l&&a.createElement(y7e,{size:"md"})))},E7e=$d.s.div(h7e||(h7e=(0,wc.A)(["\n  flex items-center justify-between rounded-md border\n  border-border-primary p-default\n"]))),y7e=(0,$d.s)(fe.hPJ)(v7e||(v7e=(0,wc.A)(["mx-xs text-content-secondary"]))),b7e=[{value:"all",label:"All time"},{value:"30",label:"Last 30 days"},{value:"90",label:"Last 90 days"},{value:"180",label:"Last 180 days"}];var x7e,w7e;const C7e=e=>{var t,n,l,r;let i=e.onSelectRecord;const s=(0,a.useState)("all"),c=(0,o.A)(s,2),d=c[0],u=c[1],m=(0,a.useState)("all"),p=(0,o.A)(m,2),g=p[0],h=p[1],v=(0,a.useMemo)((()=>(e=>{if("all"!==e)return N.c9.now().minus({days:parseInt(e,10)}).toISODate()})(g)),[g]),f=(0,et.I)(Io.eX,{variables:{accountId:"all"===d?void 0:d,startDate:v}}),E=f.data,y=f.isLoadingInitialData,b=f.error,x=null!==(t=null===E||void 0===E?void 0:E.goalReconciliationHistory)&&void 0!==t?t:[],w=(0,a.useMemo)((()=>{var e;return(e=>{const t=new Set,n=[{value:"all",label:"All accounts"}];return e.forEach((e=>{t.has(e.account.id)||(t.add(e.account.id),n.push({value:e.account.id,label:e.account.displayName}))})),n})(null!==(e=null===E||void 0===E?void 0:E.goalReconciliationHistory)&&void 0!==e?e:[])}),[E]);return b?a.createElement(SQ.W,{"data-external-id":"reconciliation-history-list",message:"Failed to load reconciliation history."}):a.createElement("div",{"data-external-id":"reconciliation-history-list",className:"flex flex-col"},a.createElement("div",{className:"flex gap-sm p-default px-xl"},a.createElement("div",{className:"min-w-0 flex-1"},a.createElement(fe.hGA,{size:"sm",options:w,value:null!==(n=null===(l=w.find((e=>e.value===d)))||void 0===l?void 0:l.value)&&void 0!==n?n:null===(r=w[0])||void 0===r?void 0:r.value,onValueChange:e=>u(null!==e&&void 0!==e?e:"all"),classNames:{trigger:"w-full"}})),a.createElement("div",{className:"min-w-0 flex-1"},a.createElement(fe.hGA,{size:"sm",options:b7e,value:g,onValueChange:e=>h(null!==e&&void 0!==e?e:"all"),classNames:{trigger:"w-full"}}
1))),y?a.createElement(a.Fragment,null,[1,2,3,4,5].map((e=>a.createElement(I7e,{key:e})))):a.createElement(a.Fragment,null,0===x.length?a.createElement("div",{className:"flex justify-center p-xl"},a.createElement(fe.c8D,{color:"secondary",size:"sm"},"No reconciliations match the selected filters.")):x.map((e=>a.createElement(A7e,{key:e.id,type:"button",onClick:()=>i(e.id)},a.createElement(f7e,{viewMode:"list",record:e}))))))},A7e=$d.s.button(x7e||(x7e=(0,wc.A)(["\n  mx-xl mt-default cursor-pointer rounded-md border-0\n  bg-transparent p-0\n  hover:bg-background-secondary\n"]))),I7e=(0,$d.s)(fe.wME)(w7e||(w7e=(0,wc.A)(["mx-xl my-xs h-14 rounded-sm"])));var k7e,S7e,N7e;const T7e=e=>{let t=e.label,n=e.transactions;const l=(0,a.useMemo)((()=>(e=>(0,Wd.A)((0,LD.A)((e=>e.date)),zne.A,(0,sU.A)(((e,t)=>{let n=(0,o.A)(e,1)[0];return(0,o.A)(t,1)[0].localeCompare(n)})))(e))(null!==n&&void 0!==n?n:[])),[n]);return n?a.createElement("div",{"data-external-id":"reconciliation-record-transaction-list",className:"mt-2xl"},a.createElement("div",{className:"mb-default"},a.createElement(fe.c8D,{color:"secondary",weight:"medium"},t)),a.createElement(_7e,null,l.map((e=>{let t=(0,o.A)(e,2),n=t[0],l=t[1];return a.createElement("div",{className:"contents",key:n},a.createElement("div",{className:" col-span-full flex justify-between bg-background-secondary px-default py-xs "},a.createElement(fe.c8D,{color:"secondary",size:"sm",weight:"medium"},(0,Ba.HN)(n)),a.createElement(fe.PED,{style:"currency",value:Math.abs((0,De.Eb)(l.map((e=>e.amount)))),color:"secondary",size:"sm",weight:"medium"})),l.map(((e,t)=>a.createElement("div",{key:e.id,className:(0,q.cn)("col-span-full grid grid-cols-subgrid items-center",t<l.length-1&&"border-b border-divider-primary")},a.createElement(D7e,null,a.createElement(Wl._,{url:e.merchant.logoUrl,size:20}),a.createElement(R7e,null,e.merchant.name)),a.createElement(D7e,null,a.createElement("span",{className:"shrink-0 text-lg"},e.category.icon),a.createElement(R7e,null,e.category.name)),a.createElement(D7e,null,a.createElement(Gl.v,{icon:e.account.icon,logoUrl:e.account.logoUrl,size:20}),a.createElement(R7e,null,e.account.displayName)),a.createElement(D7e,{className:"justify-end"},a.createElement(fe.lGO,{size:"xs",className:"text-content-secondary"}),a.createElement(fe.PED,{style:"currency",value:Math.abs(e.amount),className:"whitespace-nowrap"}))))))})))):null},_7e=$d.s.div(k7e||(k7e=(0,wc.A)(["\n  grid grid-cols-[2fr_2fr_2fr_auto] overflow-hidden rounded-md border\n  border-border-primary\n"]))),D7e=$d.s.div(S7e||(S7e=(0,wc.A)(["flex min-w-0 items-center gap-xs p-sm px-default"]))),R7e=(0,$d.s)(fe.c8D)(N7e||(N7e=(0,wc.A)(["max-w-40 truncate"])));var M7e,L7e,O7e;const P7e=e=>{let t=e.error,n=e.isLoadingInitialData,l=e.onRequestDelete,r=e.record;return n?a.createElement("div",{"data-external-id":"reconciliation-record-detail",className:"flex flex-col px-xl pb-xl"},(0,db.A)(0,3).map((e=>a.createElement(F7e,{key:e})))):t?a.createElement(SQ.W,{"data-external-id":"reconciliation-record-detail",message:"Failed to load reconciliation details."}):r?a.createElement(B7e,{"data-external-id":"reconciliation-record-detail"},a.createElement("div",{className:"mt-xl"},a.createElement(f7e,{viewMode:"detail",record:r})),a.createElement(T7e,{label:"External spending transactions",transactions:r.spendingTransactions}),a.createElement(T7e,{label:"Transaction used to reconcile",transactions:null!==r&&void 0!==r&&r.transaction?[r.transaction]:void 0}),a.createElement("div",{className:"mt-2xl p-default px-xl"},a.createElement(z7e,{onClick:l},"Delete reconciliation"))):a.createElement(SQ.W,{"data-external-id":"reconciliation-record-detail",message:"Reconciliation record not found."})},B7e=$d.s.div(M7e||(M7e=(0,wc.A)(["flex flex-col px-xl pb-xl"]))),z7e=(0,$d.s)(bn.v)(L7e||(L7e=(0,wc.A)(["w-full text-content-danger hover:text-content-danger-hover"]))),F7e=$d.s.div(O7e||(O7e=(0,wc.A)(["\n  mx-xl my-xs h-14 animate-pulse rounded-sm\n  bg-background-secondary\n"]))),G7e=e=>{var t;let n=e.onClose;const l=(0,a.useState)(null),r=(0,o.A)(l,2),s=r[0],c=r[1],d=(0,a.useState)(!1),u=(0,o.A)(d,2),m=u[0],p=u[1],g=()=>p(!0),h=(0,C.RU)(),v=(0,et.I)(Io.B_,{variables:{id:null!==s&&void 0!==s?s:""},skip:!s}
1),f=v.data,E=v.isLoadingInitialData,y=v.isNetworkRequestInFlight,b=v.error,x=(0,i.n)(Io.V0,{refetchQueries:[Io.Dx,Io.eX]}),w=(0,o.A)(x,1)[0],A=(null===f||void 0===f||null===(t=f.goalReconciliationTransactionInfo)||void 0===t?void 0:t.id)===s?f.goalReconciliationTransactionInfo:void 0,I=null===A||void 0===A?void 0:A.transaction,k=E||y&&!A,S=!k&&!b&&!!A,N=()=>{p(!1),c(null)};return a.createElement(F7.v,{"data-external-id":"savings-goal-reconciliation-history-drawer",title:a.createElement(fe.c8D,{size:"20",weight:"medium"},s?"Reconciliation Details":"Reconciliation History"),onClose:n,showBorder:!0,onClickBack:s?N:void 0,widthPx:s?900:void 0,hideCloseButton:!!s,headerClassName:"px-xl py-sm",extraNode:S?a.createElement(fe.SO$,{"aria-label":"Delete reconciliation",onClick:g,size:"md"},a.createElement(fe.i01,null)):void 0},s?a.createElement(P7e,{error:b,isLoadingInitialData:k,onRequestDelete:g,record:A}):a.createElement(C7e,{onSelectRecord:c}),a.createElement(m7e,{open:m,onOpenChange:p,onConfirm:async()=>{try{var e,t;if(null===I||void 0===I||!I.id)throw new Error("Missing reconciliation transaction");if(null!==(e=(await w({variables:{transactionId:I.id}})).data)&&void 0!==e&&null!==(t=e.deleteGoalReconciliationRecordsForTransaction)&&void 0!==t&&t.errors)throw new Error("Failed to delete reconciliation records")}catch(b){throw h({description:"Failed to delete reconciliation. Please try again."}),b}N()}}))},Y7e=()=>{const e=(0,l.Zp)(),t=(0,Pd.h)(),n=(0,o.A)(t,2),i=n[0],s=n[1].open,c=(0,Pd.h)(),d=(0,o.A)(c,2),u=d[0],m=d[1],p=m.open,g=m.close,h=(0,a.useState)(!1),v=(0,o.A)(h,2),f=v[0],E=v[1],y=Nse(),b=(0,R3.F)().isOn,x=(0,a.useMemo)((()=>a.createElement(Qi.Az,{overlay:a.createElement(Ji.SP,null,a.createElement(Ji.xm,{onClick:s},"Edit goal accounts"),a.createElement(Ji.xm,{onClick:()=>E(!0)},"Reconciliation history")),placement:"bottom-end"},(e=>{let t=e.toggleOpen,n=e.isOpen;return a.createElement(wt.Xb,{size:"small",onClick:t,active:n},a.createElement(Yo.r,{name:"settings"}),a.createElement("span",null,"Manage"))}))),[s]),w=(0,a.useMemo)((()=>a.createElement(cu.WT,{size:"small",onClick:()=>e(I.JZ.goals.savings.new())},a.createElement(Yo.r,{name:"plus"}),a.createElement("span",null,"Add goal"))),[e]);return a.createElement(uU.f,{"data-external-id":"savings-goals-header-controls"},(0,r.YW)({showBetaTag:y,isSavingsGoalsEnabled:b}).with({showBetaTag:!0,isSavingsGoalsEnabled:!0},(()=>a.createElement(a.Fragment,null,a.createElement(Q3e,null),a.createElement(vCe,null),x,a.createElement(vCe,null),w))).otherwise((()=>a.createElement(a.Fragment,null,x,a.createElement(vCe,null),a.createElement(wt.Xb,{onClick:p},a.createElement(Yo.r,{name:"arrow-left-right"}),a.createElement("span",null,_t.$.ALLOCATE_FUNDS)),w))),a.createElement(i,null,a.createElement(E8e,null)),a.createElement(u,null,a.createElement(b8e,{onClose:g})),f&&a.createElement(G7e,{onClose:()=>E(!1)}))},U7e=()=>a.createElement(pxe,{"data-external-id":"goals-v3-table-loading"},a.createElement(gxe,null,a.createElement(j7e,{title:"Save up"})),a.createElement(hxe,{column:!0,gap:"gutter",flex:1},a.createElement(V7e,null))),V7e=()=>a.createElement(fe.xz6,{"data-external-id":"goals-v3-allocation-card-loading"},a.createElement(Nxe,null,a.createElement(M.Al,{$width:"100%",$height:"110px",$borderRadius:"default"})),a.createElement(Txe,null,a.createElement(_xe,null,a.createElement(W7e,null),a.createElement(W7e,null),a.createElement(W7e,{borderBottom:"none"}))),a.createElement(Dxe,{className:"py-lg"},a.createElement(M.Al,{$width:"100%",$height:"40px",$borderRadius:"default"}),a.createElement(M.Al,{$width:"100%",$height:"40px",$borderRadius:"default"}))),W7e=e=>a.createElement(m.g,Object.assign({"data-external-id":"row",paddingVertical:"small",paddingHorizontal:"default",borderBottom:"1px solid divider.primary",justifyBetween:!0},e),a.createElement(M.Al,{$width:"45%",$height:"16px"}),a.createElement(M.Al,{$width:"20%",$height:"16px"})),j7e=e=>{let t=e.title;return a.createElement(Sxe,{"data-external-id":"goals-group",defaultOpen:!0,title:t},a.createElement(Exe,null,a.createElement(yxe,null,a.createElement(fe.xz6.Title,null,t)),a.createElement(M.Al,{$width:"200px",$height:"16px"}),a.createElement(bxe,null,a.createElement(M.Al,{$width:"200px",$height:"16px"}))),a.createElement(Axe,null,a.createElement(xxe,null,a.createElement(H7e,null),a.createElement(H7e,null),a.createElement(H7e,null))))},H7e=()=>a.createElement(m.g,{"data-external-id":"goal-row",padding:"xlarge",gap:"default",alignCenter:!0,borderBottom:"1px solid divider.primary"},a.createElement(M.Al,{$width:"72px",$height:"72px",$borderRadius:"default"}),a.createElement(m.g,{column:!0,gap:"small",width:"100%"},a.createElement(m.g,{column:!0,gap:"xsmall"},a.createElement(m.g,{justifyBetween:!0},a.createElement(M.Al,{$width:"25%",$height:"16px"}),a.createElement(M.Al,{$width:"12%",$height:"16px"})),a.createElement(m.g,{justifyBetween:!0},a.createElement(M.Al,{$width:"12%",$height:"16px"}),a.createElement(M.Al,{$width:"25%",$height:"16px"}))),a.createElement(m.g,null,a.createElement(M.Al,{$width:"100%",$height:"8px",$minHeight:"8px",$borderRadius:"xxsmall"})))),K7e=(0,a.createContext)(null),q7e=()=>{const e=(0,a.useContext)(K7e);
1if(!e)throw new Error("useReconciliationModalContext must be used within SavingsGoalReconciliationModalProvider");return e};var $7e,Z7e,J7e,X7e,Q7e=n(19025);const eet=()=>{const e=q7e(),t=e.account,n=e.balanceNeedingReconciliation,l=e.isDrawerOpen,r=e.setIsDrawerOpen,o=e.isLoading;return a.createElement("div",{"data-external-id":"reconciliation-account-card",className:"flex flex-col gap-default"},a.createElement("div",{className:"flex items-center gap-xs"},a.createElement(kD.c,{size:"lg",weight:"medium"},"External spending"),a.createElement(tFe.c,{side:"right",iconSize:"md",size:"3xs",content:a.createElement("div",{className:"flex flex-col items-center gap-2xs"},a.createElement(kD.c,{size:"sm",weight:"medium"},"Spending from a goal using an account that doesn't have funds in the goal, like a credit card."),a.createElement(Hme.l,{href:VF.nD,external:!0,size:"sm",weight:"medium"},"Learn more"))})),a.createElement(ret,null,a.createElement("div",{className:"flex items-center justify-between p-xs pr-default"},a.createElement("div",{className:"flex items-center gap-xs"},a.createElement(Yi.S,{onClick:()=>r(!l),size:"sm","aria-label":"Toggle spending events",disabled:o},l?a.createElement(aqe.MdsChevronDownIcon,null):a.createElement(eHe.MdsChevronRightIcon,null)),a.createElement(tet,{isLoading:o,logoUrl:null===t||void 0===t?void 0:t.logoUrl}),a.createElement(NQ.w.Text,{isLoading:o,className:o?"h-5 w-40":void 0},a.createElement(kD.c,{weight:"medium",className:"line-clamp-1"},null===t||void 0===t?void 0:t.displayName))),a.createElement(NQ.w.Text,{isLoading:o,className:o?"h-5 w-16":void 0},a.createElement(kD.c,{weight:"medium"},(0,rl.vv)(n)))),a.createElement(Ql.$,{open:l,shouldAnimateOnMount:!1,onClosed:()=>r(!1)},a.createElement(_m.O,{className:"max-h-[40vh] flex-1"},a.createElement("div",{className:"flex flex-col"},o?a.createElement(net,null):a.createElement(aet,null))))))},tet=e=>{let t=e.isLoading,n=e.logoUrl;return t?a.createElement(NQ.w.Circle,{"data-external-id":"account-logo-or-skeleton",className:"size-5"}):n?a.createElement(Gl.v,{"data-external-id":"account-logo-or-skeleton",logoUrl:n,size:20}):null},net=()=>a.createElement(a.Fragment,null,a.createElement(oet,null,a.createElement(NQ.w.Text,{className:"h-4 w-28"}),a.createElement(NQ.w.Text,{className:"h-4 w-14"})),(0,db.A)(0,2).map((e=>a.createElement("div",{key:e,className:"flex h-12.5 items-center gap-xs border-b border-divider-primary px-default"},a.createElement(NQ.w,{className:"size-5 shrink-0 rounded-2xs"}),a.createElement(NQ.w.Circle,{className:"size-5 shrink-0"}),a.createElement(NQ.w.Text,{className:"h-4 w-28"}),a.createElement(NQ.w.Text,{className:"h-4 w-32"}),a.createElement(NQ.w.Text,{className:"ml-auto h-4 w-14"}))))),aet=()=>{const e=q7e(),t=e.spendingEvents,n=e.selectedIds,l=e.toggle,r=e.setDrawerTransactionId,i=e.updateTransaction,s=(0,G.U)("only screen and (max-width: ".concat(yD.w.breakPoints.md,"px)")),c=(0,a.useMemo)((()=>(e=>{const t=e.filter((e=>(0,Tp.n)(e)&&(0,Tp.n)(e.transaction)));return(0,Wd.A)((0,LD.A)((e=>e.transaction.date)),zne.A,(0,sU.A)(((e,t)=>{let n=(0,o.A)(e,1)[0];return(0,o.A)(t,1)[0].localeCompare(n)})))(t).map((e=>{let t=(0,o.A)(e,2),n=t[0],a=t[1];return{date:n,events:a,amount:(0,De.Eb)(a.map((e=>e.transaction.amount)))}}))})(t)),[t]);return 0===c.length?a.createElement("div",{"data-external-id":"drawer-content",className:"flex flex-col items-center justify-center p-default pb-3xl"},a.createElement(kD.c,{size:"sm",color:"secondary",className:"text-center"},"No spending events found")):a.createElement(a.Fragment,null,c.map((e=>{let t=e.date,o=e.events,c=e.amount;return a.createElement(a.Fragment,{key:t},a.createElement(oet,null,a.createElement(kD.c,{size:"sm",weight:"medium",color:"secondary"},(0,Ba.HN)(t)),a.createElement(kD.c,{size:"sm",weight:"medium",color:"secondary"},c>0?"+":"",(0,rl.vv)(Math.abs(c)))),o.map((e=>null!==e&&void 0!==e&&e.transaction?a.createElement(Q7e.h,{key:e.id},a.createElement(set,{onClick:!0},a.createElement(LIe.K,{className:"mx-auto",checked:n.includes(e.id),onCheckedChange:()=>e.transaction&&l(e.id)})),a.createElement(iet,{isSavingsGoalsEnabled:!0,key:e.transaction.id,transaction:e.transaction,onChevronClick:r,updateTransaction:i,isNarrowScreen:s})):null)))})))},ret=(0,$d.s)(RP.x)($7e||($7e=(0,wc.A)(["border border-border-primary shadow-none"]))),oet=$d.s.div(Z7e||(Z7e=(0,wc.A)(["flex h-9 items-center justify-between bg-background-secondary px-default"]))),iet=(0,$d.s)(j9e.q)(J7e||(J7e=(0,wc.A)(["-mx-px -mt-px mb-0 w-4/5 flex-1 transition-[border-color] duration-100 ease-out"]))),set=(0,$d.s)(gm.n)(X7e||(X7e=(0,wc.A)(["ml-default flex w-5 flex-[unset] items-center"]))),cet=()=>{const e=(0,Sq.k)().close,t=q7e(),n=t.selectedIds,l=t.selectedReconciliationTransaction,r=t.isSpendingFullyCovered,c=(e=>{let t=e.selectedSpendingEventIds,n=e.reconciliationTransactionId;const a=(0,Sq.k)().close,l=(0,C.RU)(),r=(0,i.n)(Io.U4,{refetchQueries:[Io.Dx,Io.xK,Io.m7,Io.Cy],awaitRefetchQueries:!0}),c=(0,o.A)(r,2),d=c[0];return{save:async()=>{try{var e,r,o;if(!n)throw new Error("No reconciliation transaction selected");const i=await d({variables:{input:{spendingEventIds:t,reconciliationTransactionId:n}}});if((null===(e=i.data)||void 0===e||null===(r=e.reconcileExternalSpending)||void 0===r||null===(o=r.errors)||void 0===o?void 0:o.code)===Ee.O4y.RECONCILIATION_EXCEEDS_AVAILABLE)return void l({title:"This transfer can't cover the selected spending",description:"The selected transfer no longer has enough available to re
1concile this spending. Pick a different transfer or reduce the spending you selected."});(0,_we.K_)(i.data),a()}catch(i){s.Cp(i),l()}},isSaving:c[1].loading}})({selectedSpendingEventIds:n,reconciliationTransactionId:l.transactionId}),d=c.save,u=c.isSaving;return a.createElement(Cq.R,{"data-external-id":"reconciliation-modal-footer"},a.createElement(Wb.X,{variant:"default",onClick:e,disabled:u},"Cancel"),a.createElement(Wb.X,{variant:"primary",disabled:!r,onClick:d,isLoading:u},"Save"))},det=()=>{const e=q7e(),t=e.isSpendingFullyCovered,n=e.selectedAmount,l=e.isLoading,i=(0,a.useState)(!1),s=(0,o.A)(i,2),c=s[0],d=s[1];(0,a.useEffect)((()=>{l||d(!0)}),[l]);const u=(0,r.YW)({isLoading:l,canAnimate:c}).with({isLoading:!0},(()=>a.createElement(NQ.w.Text,{className:"h-5 w-16"}))).with({canAnimate:!0},(()=>a.createElement(Y5,{value:n,mantissa:2}))).otherwise((()=>a.createElement("span",null,(0,rl.vv)(n))));return a.createElement("div",{"data-external-id":"reconciliation-overview",className:"flex flex-col gap-xl"},a.createElement("div",{className:"flex flex-col gap-2xs"},a.createElement(kD.c,{size:"lg",weight:"medium"},"Select which transfer covered external spending"),a.createElement(kD.c,{color:"secondary"},"Select the transaction that was transferred out of your account intended to cover spending outside of your goal. Learn more with our"," ",a.createElement(Hme.l,{href:VF.nD,external:!0,className:"underline underline-offset-5"},"help article"),".")),a.createElement("div",{className:(0,q.cn)("flex items-center justify-between rounded-default border p-default",t?"border-chart-income bg-background-success":"border-divider-secondary bg-background-secondary")},a.createElement(kD.c,{weight:"medium",color:t?"success":"primary"},"Amount to reconcile"),a.createElement("div",{className:(0,q.cn)("font-medium",t?"text-content-success":"text-content-primary")},u)))},uet=()=>{const e=q7e(),t=e.drawerTransactionId,n=e.setDrawerTransactionId;return t?a.createElement(go.TT,{"data-external-id":"reconciliation-transaction-drawer",id:t,onClose:()=>n(null),setId:n,previousTransactionId:null,nextTransactionId:null}):null},met=e=>{let t=e.transaction;const n=t.amount,l=t.goalReconciliationUsedAmount,r=t.goalReconciliationAvailableAmount,o=l>0,i=Math.abs(n),s=Math.abs(l),c=(0,G.U)("only screen and (max-width: ".concat(yD.w.breakPoints.md,"px)")),d=o&&!c;return a.createElement("div",{"data-external-id":"reconciliation-transfer-amount-cell",className:"flex flex-[0_0_auto] items-center justify-end gap-xs"},o&&a.createElement(tFe.c,{iconSize:"xs",triggerClassName:"text-content-primary","aria-label":"Reconciliation usage breakdown",content:"".concat((0,rl.vv)(s)," of this ").concat((0,rl.vv)(i)," transfer has already been used to reconcile other spending.")}),a.createElement(kD.c,null,(0,rl.vv)(r),d&&a.createElement(kD.c,{color:"secondary"}," / ".concat((0,rl.vv)(i)))))};var pet=n(44229);const get=e=>{let t=e.transactionFilters,n=e.emptyComponent,l=e.onSelectedTransactionsChange,r=e.showAccountColumn,o=void 0===r||r,i=e.sortBy,s=void 0===i?Ee.RPX.DATE:i,c=e.unstyled,d=void 0!==c&&c,u=e.singleSelectionMode,m=void 0!==u&&u,p=e.query,g=e.renderAmount,h=e.amountSelector;const v=(0,pet.Y)({transactionFilters:t,quickViewFilters:{},sortBy:null!==s&&void 0!==s?s:Ee.RPX.DATE,pageSize:20,showAccountColumn:o,singleSelectionMode:m,hideHeader:!0,query:p}),f=v.sections,E=v.totalCount,y=v.transactions,b=v.drawerTransactionId,x=v.setDrawerTransactionId,w=v.previousTransactionId,C=v.nextTransactionId,A=v.isLoadingTransactions,I=v.isFetchingMore,k=v.onFetchMore,S=v.bulkUpdateState,N=v.context,T=v.LoadingComponent,_=S.selectedTransactions,D=(0,a.useMemo)((()=>(0,Xn.A)((0,mo.A)("id"),y)),[y]),R=(0,a.useMemo)((()=>(0,De.Eb)(_.map((e=>{const t=D[e];return t?h?h(t):t.amount:0})))),[_,D,h]),M=(0,yu.X)(l);return(0,a.useEffect)((()=>{M(_,R)}),[_,R,M]),a.createElement(j8.pB.Provider,{"data-external-id":"selectable-transactions-list-container",value:N},A?a.createElement(T,null):a.createElement(Y8.n,{sections:f,totalCount:E,setDrawerTransactionId:x,previousTransactionId:w,nextTransactionId:C,drawerTransactionId:b,allowBulkUpdate:!0,onDrawerClose:()=>x(null),emptyComponent:n,hasNextPage:y.length<E,filters:t,isLoadingTransactions:A,isFetchingMore:I,onRequestNextPage:k,hideHeader:!0,bulkUpdateState:S,unstyled:d,editMultipleAlwaysActive:!0,singleSelectionMode:m,renderAmount:g}))};var het,vet;const fet=()=>{const e=q7e(),t=e.accountId,n=e.selectedReconciliationTransaction,l=(0,a.useMemo)((()=>function(e){let t=(arguments.length>1&&void 0!==arguments[1]?arguments[1]:{}).includePartiallyUsed,n=void 0!==t&&t;return(0,U.A)({startDate:(0,Ba.Pb)().minus({months:12}).toISODate(),goalReconciliationForAccountId:e},n?{hasGoalReconciliationAvailable:!0}:{hasGoalReconciliationRecord:!1})}(t,{includePartiallyUsed:!0})),[t]);return a.createElement(yet,{"data-external-id":"reconciliation-transaction-select-card"},a.createElement(_m.O,{className:"max-h-[40vh] min-h-[10vh] flex-1"},a.createElement(get,{query:Io.Cy,transactionFilters:l,emptyComponent:a.createElement(Eet,null),sortBy:Ee.RPX.DATE,singleSelectionMode:!0,onSelectedTransactionsChange:n.onSelectionChange,amountSelector:e=>
1e.goalReconciliationAvailableAmount,renderAmount:e=>a.createElement(met,{transaction:e}),unstyled:!0})))},Eet=()=>a.createElement(MP.e.Root,{"data-external-id":"reconciliation-transaction-select-card-empty"},a.createElement(MP.e.Icon,{variant:"unstyled"},a.createElement(bet,{role:"img","aria-label":"No eligible transfer transactions found"},"\ud83d\udd01")),a.createElement(MP.e.Title,{size:"base"},"No eligible transfer transactions found"),a.createElement(MP.e.Description,{color:"secondary"},"If you haven't transferred funds out of this account yet, go ahead and do so and check back here once they post in Monarch."),a.createElement(MP.e.Actions,null,a.createElement(Hme.l,{href:VF.nD,external:!0,size:"sm",endIcon:a.createElement(eHe.MdsChevronRightIcon,null)},"Learn more"))),yet=(0,$d.s)(RP.x)(het||(het=(0,wc.A)(["flex-1 border border-border-primary shadow-none"]))),bet=$d.s.span(vet||(vet=(0,wc.A)(["text-[2.5rem] leading-none"]))),xet=e=>e.filter(Tp.n).map((e=>e.id)),wet=e=>{const t=(0,a.useState)((()=>xet(e))),n=(0,o.A)(t,2),l=n[0],r=n[1],i=(0,a.useState)(!0),s=(0,o.A)(i,2),c=s[0],d=s[1],u=(0,a.useRef)(e.length>0);(0,a.useLayoutEffect)((()=>{e.length>0&&!u.current&&(r(xet(e)),u.current=!0)}),[e]);const m=(0,a.useCallback)((e=>{r((t=>t.includes(e)?t.filter((t=>t!==e)):[...t,e]))}),[]),p=(0,a.useMemo)((()=>((e,t)=>{const n=e.filter((e=>!!e&&t.includes(e.id))).map((e=>{var t,n;return null!==(n=null===(t=null===e||void 0===e?void 0:e.transaction)||void 0===t?void 0:t.amount)&&void 0!==n?n:0}));return-1*(0,De.Eb)(n)})(e,l)),[e,l]);return{selectedIds:l,toggle:m,selectedAmount:p,isDrawerOpen:c,setIsDrawerOpen:d}},Cet=e=>{let t=e.accountId,n=e.children;const l=(e=>{var t,n;const l=(0,et.I)(Io.m7,{variables:{id:e},skip:!e}),r=l.data,o=l.isLoadingInitialData,i=(0,a.useMemo)((()=>{var e;return null!==(e=null===r||void 0===r?void 0:r.unreconciledSpendingEventsForAccount)&&void 0!==e?e:[]}),[null===r||void 0===r?void 0:r.unreconciledSpendingEventsForAccount]);return{account:null===r||void 0===r?void 0:r.account,spendingEvents:i,balanceNeedingReconciliation:null!==(n=null===(t=null===r||void 0===r?void 0:r.account)||void 0===t?void 0:t.balanceNeedingReconciliation)&&void 0!==n?n:0,isLoading:o}})(t),r=l.account,i=l.spendingEvents,s=l.balanceNeedingReconciliation,c=l.isLoading,d=wet(i),u=d.selectedIds,m=d.toggle,p=d.selectedAmount,g=d.isDrawerOpen,h=d.setIsDrawerOpen,v=(()=>{const e=(0,a.useState)(null),t=(0,o.A)(e,2),n=t[0],l=t[1],r=(0,a.useState)(0),i=(0,o.A)(r,2),s=i[0],c=i[1],d=(0,a.useCallback)(((e,t)=>{l(e[0]),c(Math.abs(t))}),[]);return(0,a.useMemo)((()=>({transactionId:n,amount:s,onSelectionChange:d})),[n,s,d])})(),f=(e=>{let t=e.selectedIds,n=e.reconciliationTransactionId,a=e.reconciliationAmount,l=e.selectedSpendingAmount;return!(0===t.length||!n)&&a>=l})({selectedIds:u,reconciliationTransactionId:v.transactionId,reconciliationAmount:v.amount,selectedSpendingAmount:p}),E=$9e({refetchQueries:[Io.xK],awaitRefetchQueries:!0}),y=E.drawerTransactionId,b=E.setDrawerTransactionId,x=E.updateTransaction,w=(0,a.useMemo)((()=>({accountId:t,account:r,spendingEvents:i,balanceNeedingReconciliation:s,isLoading:c,selectedIds:u,toggle:m,selectedAmount:p,isDrawerOpen:g,setIsDrawerOpen:h,selectedReconciliationTransaction:v,isSpendingFullyCovered:f,drawerTransactionId:y,setDrawerTransactionId:b,updateTransaction:x})),[t,r,i,s,c,u,m,p,g,h,v,f,y,b,x]);return a.createElement(K7e.Provider,{"data-external-id":"savings-goal-reconciliation-modal-provider",value:w},n)},Aet=e=>{let t=e.accountId;return a.createElement(po.K,{"data-external-id":"savings-goal-reconciliation-modal"},a.createElement(Cet,{accountId:t},a.createElement(Rc.L,{title:"Reconcile external spending",titleFontSize:yD.w.fontSize[20]},a.createElement("div",{className:"flex flex-1 flex-col gap-2xl overflow-hidden p-xl"},a.createElement(eet,null),a.createElement("div",{className:"flex flex-1 flex-col gap-default"},a.createElement(det,null),a.createElement(fet,null))),a.createElement(cet,null)),a.createElement(uet,null)))};var Iet,ket,Net;const Tet=e=>{var t;let n=e.account,i=e.summary;const s=(0,Pc.e)(!1),c=(0,o.A)(s,2),d=c[0],u=c[1],m=(0,Pd.h)(),p=(0,o.A)(m,2),g=p[0],h=p[1].open,v=(0,Pd.h)(),f=(0,o.A)(v,2),E=f[0],y=f[1],b=y.open,x=y.close,w=(0,d4.u)("feat-disable-goal-alternative-calculation-web","on").isOn?n.availableBalanceForGoalsUnmemoized:(0,pQ.Yr)({availableBalanceForGoalsUnmemoized:n.availableBalanceForGoalsUnmemoized,balanceNeedingReconciliation:null!==(t=null===i||void 0===i?void 0:i.account.balanceNeedingReconciliation)&&void 0!==t?t:0}),C=(0,S8e.Bk)(w),A=null===i||void 0===i?void 0:i.account.balanceNeedingReconciliation,k=!!A,S=(0,pQ.up)(null===i||void 0===i?void 0:i.balancesByGoal);return a.createElement("div",{"data-external-id":"savings-goals-allocation-card-row",className:"flex flex-col"},a.createElement("div",{className:"flex items-center gap-xs pr-2xs"},a.createElement("div",{className:"-ml-2xs flex items-center gap-2xs"},a.createElement(B.L,{icon:d?"chevron-down":"chevron-right",onClick:u.toggle,size:"xxsmall","aria-label":"Toggle ".concat(n.displayName," allocation")}),a.createElement(l.N_,{to:I.JZ.accounts.accountDetails({id:n.id})}
1,a.createElement(Gl.v,{logoUrl:n.logoUrl,size:24}))),a.createElement("div",{className:"flex flex-1 items-center justify-between gap-2xs overflow-hidden"},a.createElement(xt.v,{clampLines:1},a.createElement(Vl.W,{to:I.JZ.accounts.accountDetails({id:n.id}),stealthy:!0,truncate:!0},n.displayName)),a.createElement(Ret,Object.assign({"data-open":d},0!==w?{weight:"medium",color:(0,S8e.E8)(w)}:{color:"content.secondary"}),(0,rl.PN)(w)))),a.createElement(Ql.$,{open:d,onClosed:u.setOff},a.createElement("div",{className:"flex flex-col gap-sm pt-xs",style:{paddingLeft:"60px"}},a.createElement("div",{className:"flex items-center justify-between"},a.createElement(xt.v,{size:"small",id:"account-balance-".concat(n.id)},"Account balance"),a.createElement(xt.v,{"aria-labelledby":"account-balance-".concat(n.id),size:"small"},(0,rl.vv)(n.displayBalance))),S.length>0&&a.createElement(a.Fragment,null,a.createElement(z7.P,{text:"",height:"1px"}),a.createElement("div",{className:"flex flex-col gap-xs"},S.map((e=>{if(!e)return null;const t=e.goal,n=t.imageStorageProvider,l=t.imageStorageProviderId,r=(0,t7e.y)({imageStorageProvider:n,imageStorageProviderId:l,size:"small",width:16,cloudinaryUrlBuilder:(e,t)=>n7e.L.url(e,t)});return a.createElement("div",{key:t.id,className:"flex justify-between gap-3xs"},a.createElement("div",{className:"flex items-center gap-xs overflow-hidden"},a.createElement(_et,null,a.createElement(Det,{src:r})),a.createElement(xt.v,{size:"small",id:"goal-name-".concat(t.id),clampLines:1},t.name)),a.createElement(xt.v,{size:"small","aria-labelledby":"goal-name-".concat(t.id)},(0,rl.vv)(e.amount)))}))),a.createElement(z7.P,{text:"",height:"1px"})),a.createElement("div",{className:"flex items-center justify-between"},a.createElement(xt.v,{as:"span",size:"small",id:"available-label-".concat(n.id),weight:"medium"},"Available"),a.createElement(xt.v,Object.assign({size:"small",as:"span","aria-labelledby":"available-label-".concat(n.id)},(0,r.YW)(C).with("has-funds",(()=>({weight:"medium",color:"content.success"}))).with("over-allocated",(()=>({weight:"medium",color:"content.danger"}))).otherwise((()=>({color:"content.primary"})))),(0,rl.PN)(w))))),"over-allocated"===C&&a.createElement("div",{className:"flex w-full flex-col items-stretch pt-default pl-xl"},a.createElement("div",{className:" flex w-full flex-col items-stretch rounded-default bg-background-secondary px-default pt-sm pb-default "},a.createElement("div",{className:"flex items-center pb-sm"},a.createElement(fe.cIj,{size:"3xs",iconSize:"xs",label:a.createElement(fe.c8D,{weight:"medium",size:"sm"},"Account over-allocated"),content:a.createElement("div",{className:"flex flex-col px-sm py-xs"},a.createElement(xt.v,{size:"xsmall",weight:"medium"},_t.$.ACCOUNT_OVER_ALLOCATED),a.createElement(wb.gz,{href:VF._G,target:"_blank"},"Learn more."))})),a.createElement(wt.Xb,{onClick:b},a.createElement(Yo.r,{name:"arrow-left-right"}),_t.$.WITHDRAW_FUNDS_FROM_GOAL))),a.createElement(E,null,a.createElement(b8e,{allowFilteringFromValues:!0,onClose:x,toId:Y5e(n.id,"account")})),k&&a.createElement("div",{className:"flex w-full flex-col items-stretch pt-default pl-xl"},a.createElement("div",{className:" flex w-full flex-col items-stretch rounded-default bg-background-secondary px-default pt-sm pb-default "},a.createElement("div",{className:"flex justify-between pb-sm"},a.createElement(xt.v,{weight:"medium",size:"small"},"External spending"),a.createElement(xt.v,{weight:"medium",size:"small"},(0,rl.vv)(A))),a.createElement(wt.Xb,{onClick:h},"Reconcile account"))),a.createElement(g,{large:!0},a.createElement(Aet,{accountId:n.id})))},_et=$d.s.div(Iet||(Iet=(0,wc.A)(["flex size-4 shrink-0 grow-0 overflow-hidden rounded-xs"]))),Det=$d.s.img(ket||(ket=(0,wc.A)(["size-full object-cover"]))),Ret=(0,$d.s)(xt.v)(Net||(Net=(0,wc.A)(["opacity-0 transition-opacity data-[open=false]:opacity-100"]))),Met=()=>{var e,t,n,l,i;const s=(0,d.d4)(gG.pk),c=(0,nG.p)("feat-savings-goals-enable-crypto-accounts","on"),u=(0,et.I)(Io.EJ,{variables:{filters:(0,D3.QV)(c)},skip:s}),p=(0,pZ._)(Io.Dx,s),g=(null!==(e=null===(t=p.data)||void 0===t?void 0:t.goalAccountsAllocationSummary)&&void 0!==e?e:[]).flatMap((e=>e?[e]:[])),h=Object.fromEntries(null!==(n=g.map((e=>[null===e||void 0===e?void 0:e.account.id,e])))&&void 0!==n?n:[]),v=s?g.map((e=>(0,U.A)((0,U.A)({},e.account),{},{__typename:"Account",includeInGoalContributions:!0,availableBalanceForGoalsUnmemoized:e.availableBalance,displayBalance:e.totalBalance,goalAllocatedAmount:e.totalBalance-e.availableBalance,hideFromList:!1,deactivatedAt:null,dataProvider:null,subtype:{__typename:"AccountSubtype",name:"savings",display:"Savings"},type:{__typename:"AccountType",name:"depository",display:"Depository"},institution:null,linkedGoal:null}))):(null!==(l=null===(i=u.data)||void 0===i?void 0:i.accounts)&&void 0!==l?l:[]).filter((e=>e.includeInGoalContributions)),f=(0,d4.u)("feat-disable-goal-alternative-calculation-web","on").isOn,E=v.map((e=>{var t,n;return f?e.availableBalanceForGoalsUnmemoized:(0,pQ.Yr)({availableBalanceForGoalsUnmemoized:e.availableBalanceForGoalsUnmemoized,balanceNeedingReconciliation:null!==(t=null===(n=h[e.id])||void 0===n?void 0:n.account.balanceNeedingReconciliation)&&void 0!==t?t:0})})),y=(0,MK.A)(E),b=(0,r.YW)((0,S8e.E8)(y)).with("content.success",(()=>"success")).with("content.danger",(()=>"danger")).otherwise((()=>"secondary")),x=(0,Pd.h)(),w=(0,o.A)(x,2),C=w[0],A=w[1],I=A.open,k=A.close,S=(0,Pd.h)(),N=(0,o.A)(S,2),T=N[0],_=N[1].open,D=(0,a.useCallback)((()=>{(0,Ge.u4)(Ye.Y5.CreateGoalsAllocationClicked,{path:"goals/savings"}),I()}),[I]);return u.isLoadingInitialData||p.isLoadingInitialData?a.createElement(V
17e,{"data-external-id":"savings-goals-allocation-card"}):a.createElement(a.Fragment,null,a.createElement(fe.xz6,{role:"article",className:"max-h-full min-h-0"},a.createElement(Nxe,null,a.createElement(m.g,{width:"100%",borderRadius:"default",center:!0,paddingVertical:"large",column:!0,gap:"xxxsmall",backgroundColor:(0,S8e.cC)(y),color:(0,S8e.E8)(y)},a.createElement(xt.v,{size:"xxlarge",weight:"medium","aria-labelledby":"available-to-allocate"},(0,rl.vv)(y)),a.createElement(m.g,{alignCenter:!0,gap:"xxsmall"},a.createElement(fe.cIj,{size:"3xs",side:"bottom",content:_t.$.AVAILABLE_FOR_GOALS_TOOLTIP,label:a.createElement(fe.c8D,{weight:"medium",color:b,id:"available-to-allocate"},_t.$.AVAILABLE_FOR_GOALS)})))),a.createElement(Txe,null,a.createElement(_xe,null,v.map((e=>a.createElement(Tet,{key:e.id,account:e,summary:h[e.id]}))))),a.createElement(Dxe,null,a.createElement(cu.WT,{onClick:D},a.createElement(Yo.r,{name:"arrow-left-right"}),a.createElement("span",null,_t.$.ALLOCATE_FUNDS)),a.createElement(wt.Xb,{onClick:_},_t.$.GOAL_DETAILS_CONTROLS.EDIT_ACCOUNTS))),a.createElement(C,null,a.createElement(b8e,{onClose:k})),a.createElement(T,null,a.createElement(E8e,null)))},Let=()=>{const e=(0,l.Zp)(),t=(0,lm.a)(),n=D3.i9[t].hero,r=(0,M3.n)("".concat("goals","/").concat(n));return a.createElement(pxe,{"data-external-id":"savings-goals-empty-state"},a.createElement(fe.xz6,{className:"w-full"},a.createElement(fe.xz6.Content,{className:"items-center justify-center gap-0 py-4xl"},a.createElement("img",{className:"h-auto w-full max-w-container-md object-contain",src:r,alt:"Plan for your future"}),a.createElement(fe.c8D,{className:"m-0 mt-xl",render:a.createElement("h2",null),size:"2xl",weight:"medium",color:"primary"},_t.$.EMPTY_STATE.TITLE),a.createElement(fe.c8D,{className:"m-0 mt-xs max-w-container-md text-center",render:a.createElement("p",null),size:"base",color:"secondary"},_t.$.EMPTY_STATE.SUBTITLE," Visit our"," ",a.createElement(fe.liZ,{href:VF.aP,external:!0,className:"underline"},"help center")," ","to learn more."),a.createElement(fe.XZZ,{className:"mt-xl",variant:"primary",size:"lg",icon:a.createElement(fe.Wa3,null),onClick:()=>e(I.JZ.goals.savings.new())},_t.$.EMPTY_STATE.BUTTON_TITLE))))},Oet=e=>{let t=e.goal;return a.createElement(Pet,{"data-external-id":"savings-goals-table-section-sortable-item",id:t.id,customDragHandle:!0},a.createElement(qH.v,{className:"absolute top-1/2 left-0 z-docked -translate-y-1/2 focus-visible:bg-background-secondary",revealOnHover:!0}),a.createElement(hwe,{to:I.JZ.goals.savings.detail({id:t.id})},a.createElement(yo.p,{goal:t})))},Pet=(0,u.default)(Hk.U).withConfig({displayName:"SavingsGoalsTableSectionSortableItem__StyledSortableItem",componentId:"sc-1mblbn3-0"})(["position:relative;&[aria-pressed='true'] > a > div{transform:scale(1.01) translateX(2px);}"]),Bet=e=>t=>(null===t||void 0===t?void 0:t.savingsGoals)?(0,U.A)((0,U.A)({},t),{},{savingsGoals:[...t.savingsGoals].sort(((t,n)=>{var a,l,r,o;return(null!==(l=null!==(a=e.get(t.id))&&void 0!==a?a:t.priority)&&void 0!==l?l:0)-(null!==(o=null!==(r=e.get(n.id))&&void 0!==r?r:n.priority)&&void 0!==o?o:0)}))}):t,zet=e=>{let t=e.goals;const n=(0,Bk.FR)((0,Bk.MS)(Bk.AN),(0,Bk.MS)(Bk.uN,{coordinateGetter:Fk.JR})),l=(()=>{const e=(0,i.n)(Io.wO),t=(0,o.A)(e,1)[0];return(0,a.useCallback)((async e=>{const n=e.map((e=>({id:e.id,priority:e.priority})));t({variables:{input:{goals:n}},optimisticResponse:{__typename:"Mutation",updateSavingsGoalsPriorities:{__typename:"UpdateSavingsGoalsPriorities",goals:e,errors:null}},update:t=>{const n=new Map(e.map((e=>[e.id,e.priority]))),a=Bet(n);t.updateQuery({query:Io.IH},a),t.updateQuery({query:Io.iO},a)}})}),[t])})();return{handleDragEnd:async e=>{const n=e.active,a=e.over;if(n&&a&&n.id!==a.id){const e=t.findIndex((e=>e.id===n.id)),r=t.findIndex((e=>e.id===a.id));if(-1===e||-1===r)return;const o=(0,Fk.be)(t,e,r).map(((e,t)=>(0,U.A)((0,U.A)({},e),{},{priority:t+1})));l(o)}},sensors:n}},Fet=e=>{let t=e.goals,n=e.defaultOpen,l=void 0===n||n,r=e.headerRight,i=e.description,s=e.title,c=e.getArchivedTitle;const d=(e=>{const t=(0,vj.A)((e=>!!e.archivedAt),e),n=(0,o.A)(t,2),a=n[0],l=n[1];return{archivedGoals:(0,sU.A)((0,Go.A)((e=>{var t;return null!==(t=e.archivedAt)&&void 0!==t?t:""})),a),activeGoals:l}})(t),u=d.archivedGoals,m=d.activeGoals,p=zet({goals:m}),g=p.handleDragEnd,h=p.sensors;return a.createElement(Sxe,{"data-external-id":"savings-goals-table-section",defaultOpen:l,title:null!==s&&void 0!==s?s:""},a.createElement(Exe,null,a.createElement(yxe,null,a.createElement(fe.xz6.Title,null,s)),i,a.createElement(bxe,null,r)),a.createElement(Axe,null,a.createElement(Bk.Mp,{sensors:h,collisionDetection:Bk.fp,onDragEnd:g,modifiers:[zk.FN]},a.createElement(xxe,null,a.createElement(Fk.gB,{items:m,strategy:Fk._G},m.map((e=>a.createElement(Oet,{key:e.id,goal:e})))))),u.length>0&&a.createElement(oK,{showText:"Show ".concat(c(u.length)),hideText:"Collapse ".concat(c(u.length))},u.map((e=>a.createElement(hwe,{key:e.id,to:I.JZ.goals.savings.detail({id:e.id}),"data-archived":!0},a.createElement(yo.p,{goal:e})))))))},Get=e=>{let t=e.goals,n=e.isLoading;const l=t.filter((e=>!e.archivedAt)),o=(0,S8e.Kw)(l),i=t.length>0;return(0,r.YW)({hasGoals:i,isLoading:n}).with({isLoading:!0},(()=>a.createElement(a.Fragment,null,a.createElement(U7e,null),a.createElement(w5e,null)))).with({hasGoals:!1},(()=>a.createElement(a.Fragment,null,a.createElement(Let,null),a.createElement(w5e,null)))).otherwise((()=>a.createElement(pxe,null,a.createElement(gxe,null,a.createElement(Fet,{title:"Save up",getArchivedTitle:e=>(0,De.td)("goal",e,{inclusive:!0,modifier:"archived savings"}),headerRight:a.createElement(xt.v,{size:"large",weight:"medium","aria-label":"Savings total"},(0,rl.vv)(o)),goals:t}),a.createElement(w5e,{className:"px-0 pb-0"})),a.createElement(hxe,null,a.createElement(Met,null)))))},Yet=()=>{const e=(0,d.d4)(gG.pk),t=(0,pZ._)(Io.iO,e),n=t.data,l=t.isLoadingInitialData,r=t.refetch,o=(null!==n&&void 0!==n?n:{}).savingsGoals,i=(0,a.useMemo)((()=>null!==o&&void 0!==o?o:[]),[o]);return a.createElement(ixe,{"data-external-id":"savings-goals",refetchGoals:r},a.createElement(k5e,{scrollDepthTab:"savings",controls:a.createElement(Y7e,null)},a.createElement(Get,{goals:i,isLoading:l})))},Uet=e=>{let t=e.title,n=e.children,l=e.controls,r=e.className,o=e.anchorId;const i=(0,Qhe.x)(o);return a.createElement(Vet,Object.assign({"data-external-id":"billing-row",className:r},i),a.createElement("div",{className:"flex items-center justify-between"},a.createElement(Wet,null,t),l),a.createElement(jet,null,n))},Vet=u.default.div.withConfig({displayName:"BillingRow__Root",componentId:"sc-1ogbjbh-0"})(["padding:",";:not(:last-child){border-bottom:1px solid ",";}"],(e=>e.theme.spacing.xlarge),vt.Ee.color.divider.primary),Wet=u.default.div.withConfig({displayName:"BillingRow__Title",componentId:"sc-1ogbjbh-1"})(["font-size:",";font-weight:",";color:",";"],(e=>e.theme.fontSize.small),(e=>e.theme.fontWeight.medium),(e=>
1e.theme.color.textLight)),jet=u.default.div.withConfig({displayName:"BillingRow__Content",componentId:"sc-1ogbjbh-2"})(["display:flex;align-items:center;margin-top:",";"],(e=>e.theme.spacing.small)),Het={color:"grayLight",label:"No plan"},Ket=e=>{var t,n,l;let r=e.activeSponsorship,o=e.hasPremium,i=e.billingPeriod,s=e.entitlements,c=e.willCancelAtPeriodEnd,d=e.paymentSource,u=e.accessExpirationDate,m=e.isOnFreeTrial,p=e.eligibleForTrial,g=e.canceledPlusTrialAt,h=e.plusTrialEndsAt,v=e.onClickManageSubscription;const f=o&&(null!==i||(null!==(t=null===s||void 0===s?void 0:s.length)&&void 0!==t?t:0)>0)?(0,Q8.He)({entitlements:null!==s&&void 0!==s?s:[],billingPeriod:i,canceledPlusTrialAt:g}):"",E=(0,Q8.O)({entitlements:null!==s&&void 0!==s?s:[],billingPeriod:i,isOnFreeTrial:m,canceledPlusTrialAt:g,plusTrialEndsAt:h}),y=(0,Q8.YY)(null!==s&&void 0!==s?s:[],o,h,u),b=null!==(n=Q8.Eo[null!==(l=y.tier)&&void 0!==l?l:""])&&void 0!==n?n:"Core",x=(0,Q8.Zd)({hasPremium:o,eligibleForTrial:p,paymentSource:d})?Het:(0,Q8.HY)({hasPremium:o,willCancelAtPeriodEnd:c,isOnFreeTrial:m,entitlements:null!==s&&void 0!==s?s:[]}),w=y.expiresAt&&N.c9.fromISO(y.expiresAt).toLocal(),C=d!==Ee.vtX.STRIPE&&c,A=i===Ee.YHE.LIFETIME,I=o&&d===Ee.vtX.STRIPE&&(0,BY.A)(r)&&!A,k=o&&d&&[Ee.vtX.APP_STORE,Ee.vtX.PLAY_STORE,Ee.vtX.TEST_STORE].includes(d);return a.createElement(Uet,{"data-external-id":"billing-status-row",title:"Current plan",anchorId:"current-plan",controls:I&&(c?a.createElement(Wb.X,{variant:"primary",onClick:v},_t.se.MANAGE_SUBSCRIPTION.REACTIVATE_SUBSCRIPTION_CTA):a.createElement(Wb.X,{variant:"text",className:"ml-2.5 font-medium",onClick:v},_t.se.MANAGE_SUBSCRIPTION.MANAGE_SUBSCRIPTION_CTA))},a.createElement("div",{className:"flex flex-1 flex-col"},a.createElement("div",{className:"flex flex-1 items-center justify-between"},a.createElement("div",{className:"flex items-center gap-xs"},f&&o&&a.createElement("span",{className:"block min-[36rem]:inline"},f),a.createElement(Oc.D,{color:x.color},x.label)),(!o||C&&m)&&a.createElement(Wb.X,{variant:"primary",onClick:v},p?_t.se.UPGRADE_CTA.TRIAL_AVAILABLE:_t.se.MANAGE_SUBSCRIPTION.REACTIVATE_SUBSCRIPTION_CTA)),E&&o&&!c&&a.createElement("div",{className:"mt-default"},E),o&&c&&a.createElement("div",{className:"mt-default"},"Your subscription has been canceled."," ",!!w&&"You will have access to ".concat(b," until ").concat(w.toLocaleString(N.c9.DATE_FULL),".")),k&&a.createElement(fu.g,{type:"info",className:"mt-default"},"To manage your subscription, please visit the ",(0,Wie.capitalCase)(d),".")))};var qet=n(84832);const $et=(0,u.default)(xt.v).withConfig({displayName:"TaxLabel__Root",componentId:"egg92p-0"})(["color:",";font-size:",";font-weight:",";text-transform:lowercase;"],(e=>e.theme.color.textLight),(e=>e.theme.fontSize.xsmall),(e=>e.theme.fontWeight.book)),Zet=e=>{var t,n;let l=e.amount,r=e.date,o=e.activeSponsorship,i=e.onRevokeSponsorAccess;return a.createElement(Uet,{"data-external-id":"next-payment-row",title:"Next Payment",anchorId:"next-payment"},a.createElement(Xet,{column:!0},a.createElement(Xet,{alignCenter:!0,justifyBetween:!0,marginBottom:"large"},a.createElement("div",null,"".concat((0,rl.vv)(l)," on ").concat(N.c9.fromISO(r).toLocaleString(N.c9.DATE_FULL)),a.createElement(Jet,{text:_t.se.IN_PRODUCT_TAX_DISCLAIMER}))),(0,Tr.A)(o)&&a.createElement(qet.z,{sponsorName:null===o||void 0===o||null===(t=o.sponsor)||void 0===t?void 0:t.name,sponsorProfilePictureUrl:null===o||void 0===o||null===(n=o.sponsor)||void 0===n?void 0:n.profilePictureUrl,onRevokeAccess:i})))},Jet=(0,u.default)((e=>{let t=e.className,n=e.text;return a.createElement($et,{"data-external-id":"tax-label",className:t},n)})).withConfig({displayName:"NextPaymentRow__StyledTaxLabel",componentId:"sc-1hagaxo-0"})(["display:block;text-transform:none;"]),Xet=(0,u.default)(m.g).withConfig({displayName:"NextPaymentRow__Flex",componentId:"sc-1hagaxo-1"})(["flex:1;"]),Qet=e=>{let t=e.paymentSource,n=e.onClickUpdatePaymentMethod,l=e.paymentMethod,o=e.hasBillingIssue,i=e.isSponsored,s=void 0!==i&&i,c="";c=t===Ee.vtX.STRIPE&&(0,BY.A)(l)?"Missing payment method":t===Ee.vtX.STRIPE?(0,Xie._M)(l,((e,t)=>
1"".concat((0,Wie.capitalCase)(e)," ending in ").concat(t))):(0,Wie.capitalCase)(t||"");const d="Your payment method failed. ".concat(t===Ee.vtX.STRIPE?"Please update it to keep using Monarch.":"Please update it in the ".concat((0,Wie.capitalCase)(t||"")," to keep using Monarch")),u="Your payment method is missing. ".concat(t===Ee.vtX.STRIPE?"Please update it to keep using Monarch.":"Please update it in the ".concat((0,Wie.capitalCase)(t||"")," to keep using Monarch"));return a.createElement(Uet,{"data-external-id":"payment-method-row",anchorId:"payment-method",title:t===Ee.vtX.APP_STORE||t===Ee.vtX.PLAY_STORE||t===Ee.vtX.TEST_STORE?"Billed Through":"Payment Method",controls:t===Ee.vtX.STRIPE&&!s&&a.createElement(Wb.X,{variant:"text",className:"ml-2.5",onClick:n},"Update payment method")},(0,r.YW)({paymentSource:t,isSponsored:s}).with({isSponsored:!0},(()=>a.createElement(c5.C,{color:"gray-secondary",variant:"subtle",size:"sm"},"Sponsored"))).with({paymentSource:r.P.nullish},(()=>a.createElement(a.Fragment,null,"None",a.createElement(Wb.X,{variant:"text",className:"ml-2.5",onClick:n},"Add payment method")))).otherwise((()=>a.createElement("div",{className:"flex flex-col"},a.createElement("div",{className:"flex items-center"},(o||(0,Tr.A)(t)&&(0,BY.A)(l))&&a.createElement(vqe.MdsAlertTriangleIcon,{"aria-label":"Payment method warning",className:"mr-xs text-content-danger"}),t&&c),(0,Tr.A)(l)&&o&&a.createElement("p",{className:"mt-default text-sm text-content-danger"},d),(0,BY.A)(l)&&o&&a.createElement("p",{className:"mt-default text-sm text-content-danger"},u)))))},ett=e=>{var t;let n=e.promoCode,l=e.nextCyclePromoCode,r=e.paymentSource;const o=!!n||!!l;if(!o&&r===Ee.vtX.STRIPE)return a.createElement(a.Fragment,null);const i=n?(0,Q8.j0)(n):"",s=l?(0,Q8.j0)(l):"",d=null===(t=null!==n&&void 0!==n?n:l)||void 0===t?void 0:t.description,u=(0,c.A)(d)&&d!==(n?i:s);return a.createElement(Uet,{"data-external-id":"promo-code-row",title:"Discount",anchorId:"discount",className:"block"},a.createElement("div",null,o&&a.createElement(a.Fragment,null,a.createElement("div",null,i,s&&(n?", then ".concat(s," at renewal"):"".concat(s," starting at renewal"))),u&&a.createElement("div",{className:"mt-2xs text-xs text-content-secondary"},d)),r!==Ee.vtX.STRIPE&&!o&&a.createElement("div",{className:"mb-xs"},"To apply a promo code, you'll need to switch to direct billing.",a.createElement(Hme.l,{className:"mt-2xs block",href:VF.l2,external:!0},"Learn how to switch"))))},ttt=e=>{let t=e.plans,n=e.billingPeriod,l=e.entitlements,r=e.hasChargedForLifetime,o=e.accessExpirationDate,i=e.paymentSource,s=e.paymentMethod,c=e.promoCode,d=e.nextCyclePromoCode,u=e.nextPaymentDate,m=e.nextPaymentAmount,p=e.activeSponsorship,g=e.creditBalance,h=e.hasPremium,v=e.hasBillingIssue,f=e.willCancelAtPeriodEnd,E=e.isOnFreeTrial,y=e.monthlyPriceDollars,b=e.hasStripeSubscriptionId,x=e.eligibleForTrial,w=e.canceledPlusTrialAt,C=e.plusTrialEndsAt,A=e.onClickRevokeSponsorAccess,k=e.onClickUpdatePaymentMethod,S=e.onClickManageSubscription;const N=n===Ee.YHE.LIFETIME,T=null===t||void 0===t?void 0:t.find((e=>e.period===Ee.YHE.LIFETIME)),_=N&&!r?null===T||void 0===T?void 0:T.pricePerPeriodDollars:m;return a.createElement(a.Fragment,null,a.createElement(Ket,{hasPremium:h,billingPeriod:n,entitlements:l,willCancelAtPeriodEnd:f,paymentSource:i,accessExpirationDate:o,onClickManageSubscription:S,activeSponsorship:p,isOnFreeTrial:E,eligibleForTrial:x,canceledPlusTrialAt:w,plusTrialEndsAt:C}),h&&(0,Tr.A)(g)&&g>0&&a.createElement(Uet,{title:"Credits",anchorId:"credits",controls:a.createElement(Vl.W,{to:I.JZ.settings.referrals(),size:"sm"},"Learn more")},(0,rl.vv)(g)),(b||i===Ee.vtX.STRIPE)&&a.createElement(a.Fragment,null,a.createElement(Qet,{paymentSource:i,paymentMethod:s,hasBillingIssue:v,onClickUpdatePaymentMethod:k,isSponsored:(0,Tr.A)(p)}),a.createElement(ett,{promoCode:c,nextCyclePromoCode:d,paymentSource:i})),(0,Xie.J5)(i)&&a.createElement(Uet,{title:"Billed Through",anchorId:"billed-through"},Xie.WO[i]),!!u&&!f&&(0,Tr.A)(_)&&a.createElement(Zet,{date:u,amount:_,monthlyPriceDollars:y,activeSponsorship:p,hasLifetimeSubscription:N,onRevokeSponsorAccess:A}))};var ntt,att=n(81037);const ltt=e=>{let t=e.onDone;const n=(0,C.RU)(),l=(0,a.useState)(""),r=(0,o.A)(l,2),s=r[0],c=r[1],d=(0,a.useState)(null),u=(0,o.A)(d,2),m=u[0],p=u[1],g=(0,a.useState)(!1),h=(0,o.A)(g,2),v=h[0],f=h[1],E=(0,i.n)(ott),y=(0,o.A)(E,1)[
10],b=async()=>{if((0,att.e)(s)){p(null),f(!0);try{var e;const l=(await y({variables:{input:{postalCode:s.trim()}}})).data,r=null===l||void 0===l||null===(e=l.updateBillingPostalCode)||void 0===e?void 0:e.errors;var a;if(r)return void n({description:null!==(a=r.message)&&void 0!==a?a:"Something went wrong. Please try again."});(0,Ge.u4)(Ye.ZT.BillingZipSubmitted),t()}catch(l){n({description:"Something went wrong. Please try again."})}finally{f(!1)}}else p("Please enter a valid zip code (e.g. 90210)")};return a.createElement(Rc.L,{"data-external-id":"billing-zip-modal",title:"Verify your billing ZIP code"},a.createElement("div",{className:"px-lg py-xs"},a.createElement("p",{className:"my-0 text-base text-content-secondary"},"Enter the ZIP code associated with your payment method."),a.createElement("div",{className:"mt-lg flex flex-col gap-xs"},a.createElement("label",{className:"text-sm font-medium text-content-primary"},"Zip code"),a.createElement(rtt,{type:"text",placeholder:"Enter your ZIP code",value:s,className:(0,q.cn)(m&&"border-border-danger"),onChange:e=>{c(e.target.value),p(null)},onKeyDown:e=>{"Enter"===e.key&&b()},autoFocus:!0}),m&&a.createElement("p",{className:"mt-xs text-sm text-content-danger"},m))),a.createElement(Cq.R,null,a.createElement(cu.gs,{onClick:b,pending:v},"Save")))},rtt=$d.s.input(ntt||(ntt=(0,wc.A)(["\n  w-full rounded-md border border-divider-primary bg-transparent px-default py-sm text-base\n  text-content-primary outline-none\n  focus:border-border-brand\n"]))),ott=Ee.d_G;var itt=n(64055);const stt=e=>{let t=e.onConfirm,n=e.onCancel,l=e.isLoading;return a.createElement(xC.$,{"data-external-id":"revoke-sponsor-access-confirmation",title:"Revoke professional access",confirm:"Revoke access",isLoading:l,onCancel:n,onConfirm:t},a.createElement(xt.v,null,"Are you sure you want to revoke access to your account? This action cannot be undone."))};var ctt=n(7924),dtt=n(72790),utt=n(42034);const mtt=()=>{var e,t,n,r,s,c,d,u,m,g,h,v,f,E,y,b;const x=(0,C.RU)(),w=(0,Tse._)(),A=w.isDemoHousehold,k=w.blockActionForDemoHousehold,S=(0,l.Zp)(),N=(0,e$.L)(),T=(0,Pd.h)(),_=(0,o.A)(T,2),D=_[0],R=_[1],M=R.open,L=R.close,O=(0,Xo.IT)(ctt.b),P=O.data,B=O.refetch,z=(0,Xo.IT)(htt).data,F="US"===(null===z||void 0===z||null===(e=z.myHousehold)||void 0===e?void 0:e.country);(0,Xo.IT)(Vie.FS,{variables:{promoCode:null,stripePriceId:""},skip:!P});const G=(0,utt.n)().plans,Y=null===P||void 0===P?void 0:P.subscription,V=Y?(0,Q8.YB)(Y.entitlements,Y.canceledPlusTrialAt):null,W=(0,Q8.tm)(null===Y||void 0===Y?void 0:Y.currentPeriodEndsAt,null===Y||void 0===Y?void 0:Y.plusTrialEndsAt,null===Y||void 0===Y?void 0:Y.canceledPlusTrialAt),j=G.find((e=>e.tier===V&&e.period===(null===Y||void 0===Y?void 0:Y.billingPeriod))),H=(0,Q8._U)(null===Y||void 0===Y?void 0:Y.nextPaymentAmount,j),K=(0,use.H)().createSubscription,q=(0,i.n)(gtt),$=(0,o.A)(q,1)[0],Z=(0,i.n)(dtt.F8),J=(0,o.A)(Z,1)[0],X=(0,i.n)(vtt),Q=(0,o.A)(X,2),ee=Q[0],te=Q[1].loading,ne=(0,mse.l)().reactivateSubscriptionWithPriceId,ae=(0,dse.f)().changeSubscription,le=(0,Pd.h)(),re=(0,o.A)(le,2),oe=re[0],ie=re[1],se=ie.open,ce=ie.close,de=()=>{S(I.JZ.settings.billing())},ue=(0,Pd.h)(),me=(0,o.A)(ue,2),pe=me[0],ge=me[1],he=ge.open,ve=ge.close,fe=(null!==(t=null===P||void 0===P||null===(n=P.subscription)||void 0===n?void 0:n.activeSponsorship)&&void 0!==t?t:{}).id,Ee=(0,Tr.A)(fe),ye=(0,a.useCallback)((async()=>{if((0,Tr.A)(fe)){const e=(await ee({variables:{input:{id:fe}}})).data,t=(0,DJ.A)(["cancelSubscriptionSponsorship","errors"],e);t&&x({description:t.message}),B(),ce()}}),[ee,B,fe,ce,x]),be=(0,a.useCallback)((async e=>{var t,n,a,l;let r=e.id;const o=(await $({variables:{input:{paymentMethodId:r}}})).data,i=(0,DJ.A)(["updateOrCreateStripePaymentMethod","errors"],o);if(i)return x({title:"Couldn't update payment method",description:i.message}),!1;B();const s=null===o||void 0===o||null===(t=o.updateOrCreateStripePaymentMethod)||void 0===t||null===(n=t.subscription)||void 0===n?void 0:n.postalCode,c=null===o||void 0===o||null===(a=o.updateOrCreateStripePaymentMethod)||void 0===a||null===(l=a.subscription)||void 0===l?void 0:l.activeSponsorship;return!F||c||s||M(),!0}),[$,B,F,M,x]);return a.createElement(mX.V,{"data-external-id":"billing-settings",md:9},a.createElement(Xhe.Ay,null,a.createElement("title",null,"Billing Settings")),a.createElement(Ffe,{title:"Billing",anchorId:"billing",isDemo:A},P?a.createElement(ttt,{plans:G,hasStripeSubscriptionId:null===(r=P.subscription)||void 0===r?void 0:r.hasStripeSubscriptionId,hasChargedForLifetime:null===(s=P.subscription)||void 0===s?void 0:s.hasChargedForLifetime,billingPeriod:null===(c=P.subscription)||void 0===c?void 0:c.billingPeriod,entitlements:null!==(d=null===(u=P.subscription)||void 0===u?void 0:u.entitlements)&&void 0!==d?d:[],paymentMethod:null===(m=P.subscription)||void 0===m?void 0:m.paymentMethod,paymentSource:null!==(g=null===(h=P.subscription)||void 0===h?void 0:h.paymentSource)&&void 0!==g?g:null,promoCode:P.subscription.activePromoCode,nextCyclePromoCode:P.subscription.nextCyclePromoCode,accessExpirationDate:P.subscription.currentPeriodEndsAt,nextPaymentAmount:H,nextPaymentDate:W,hasPremium:P.subscription.hasPremiumEntitlement,hasBillingIssue:P.subscription.hasBillingIssue,willCancelAtPeriodEnd:P.subscription.willCancelAtPeriodEnd,eligibleForTrial:P.subscription.eligibleForTrial,monthlyPriceDollars:P.constants.monthlyPriceDollars,activeSponsorship:null===(v=P.subscription)||void 0===v?void 0:v.activeSponsorship,onClickRevokeSponsorAccess:se,onClickManageSubscription:()=>k((()=>S(I.JZ.settings.billing.subscribe())),!1),onClickUpdatePaymentMethod:he,creditBalance:P.creditBalance,isOnFreeTrial:null!==(f=null===(E=P.subscription)||void 0===E?void 0:E.isOnFreeTrial)&&void 0!==f&&f,canceledPlusTrialAt:null===(y=P.subscription)||void 0===y?void 0:y.canceledPlusTrialAt,plusTrialEndsAt:null===(b=P.subscription)||void 0===b?void 0:b.plusTrialEndsAt}):a.createElement("div",{className:"my-lg flex size-full flex-1 items-center justify-center"},a.createElement(p.i,null))),(null===P||void 0===P?void 0:P.invoices)&&P.invoices.length>0&&a.createElement(ptt,null,a.createElement(eve,{invoices:P.invoices})),!Ee&&a.createElement(XU.l,{path:I.JZ.settings.billing.subscribe.relativePath}
1,a.createElement(itt.v,{subscriptionDetails:P?(0,U.A)((0,U.A)({},P.subscription),{},{plusUpgradeProratedAmount:null}):void 0,createSubscription:K,reactivateSubscription:ne,changeSubscription:ae,onDone:()=>{de(),S(I.JZ.settings.billing()),setTimeout((()=>B()),1500)},cancelMutation:J,onCancelSuccess:de,onCancelClick:de})),a.createElement(XU.l,{path:I.JZ.settings.billing.upgrade.relativePath},(e=>{let t=e.close;return a.createElement(GCe.E,{context:"upgrade",analyticsName:HQ.RG.Billing,onBack:()=>N(),onComplete:t})})),a.createElement(XU.l,{path:I.JZ.settings.billing.subscriptionEnded.relativePath},(e=>{let t=e.close;return a.createElement(GCe.E,{context:"subscription_ended",onComplete:t})})),a.createElement(pe,null,a.createElement(ive,{onSuccess:be,onDone:ve})),a.createElement(oe,null,a.createElement(stt,{onConfirm:ye,onCancel:ce,isLoading:te})),a.createElement(D,null,a.createElement(ltt,{onDone:L})),a.createElement(XU.l,{path:I.JZ.settings.billing.premium.relativePath},(e=>{let t=e.close;return a.createElement(GCe.E,{context:"upgrade",analyticsName:HQ.RG.Billing,onBack:t,onComplete:t})})))},ptt=u.default.div.withConfig({displayName:"BillingSettings__InvoicesContainer",componentId:"sc-7rvw4u-0"})(["margin-top:",";"],vt.YK.xlarge),gtt=Ee.zQw,htt=Ee.e0W,vtt=Ee.L2r;var ftt=n(12523),Ett=n(78654);const ytt=[{icon:"split",title:"Keep business and personal finances separate",subtitle:"Track business income and expenses without mixing them into your household."},{icon:"bar-chart",title:"Reporting that keeps you ready",subtitle:"See clear profit and loss at a glance, and get ready for taxes in a few clicks."},{icon:"sankey",title:"Stay connected to your full financial picture",subtitle:"See how business income rolls into your household automatically."}],btt=()=>{const e=(0,Tj.Rq)(),t=e.businessEntities,n=e.isLoadingInitialData,l=e.refetch,r=(0,lt.L7)(),i=r.householdPreferences,s=r.updateHouseholdPreferences,c=(0,qG.e)(),d=c.hasAccess,u=c.isLoading,m=!d,g=(0,a.useState)(null),h=(0,o.A)(g,2),v=h[0],f=h[1],E=(0,a.useState)(!1),y=(0,o.A)(E,2),b=y[0],x=y[1],w=(0,a.useState)(!1),C=(0,o.A)(w,2),A=C[0],k=C[1],S=(0,a.useState)(!1),N=(0,o.A)(S,2),T=N[0],_=N[1],D=(0,eY.z)(),R=(0,Qhe.x)("include-in-budgeting"),M=!0!==(null===i||void 0===i?void 0:i.excludeBusinessFromBudget),L=(0,a.useCallback)((e=>{s({excludeBusinessFromBudget:!e})}),[s]);(0,a.useEffect)((()=>
1{l()}),[l]);const O=(0,a.useCallback)((()=>{x(!0)}),[]),P=(0,a.useCallback)((e=>{f(e)}),[]),B=(0,a.useCallback)((e=>{f(e)}),[]),z=(0,a.useCallback)((()=>{f(null),x(!1)}),[]),F=(0,a.useCallback)((()=>{l()}),[l]),G=(0,a.useCallback)((()=>{f(null),x(!1),_(!0)}),[]),Y=(0,a.useCallback)((()=>{_(!1),l()}),[l]);return n||u?a.createElement(mX.V,{"data-external-id":"business-entities-settings",md:9},a.createElement(Ffe,{title:a.createElement(xtt,null)},a.createElement(Ltt,null,a.createElement(p.i,null)))):m?a.createElement(mX.V,{"data-external-id":"business-entities-settings",md:9},a.createElement(Ffe,{title:a.createElement(xtt,null),anchorId:"businesses"},a.createElement(Xhe.Ay,null,a.createElement("title",null,"Businesses")),a.createElement(wtt,null,a.createElement(Ctt,null,"Track a small business or side hustle alongside your household. Upgrade to the"," ",a.createElement(wb.gz,{href:"#",onClick:e=>{e.preventDefault(),D("BusinessEntitiesSettings"),k(!0)}},"Plus Tier")," ","to try this feature free."),a.createElement(Att,null,ytt.map((e=>{let t=e.icon,n=e.title,l=e.subtitle;return a.createElement(Itt,{key:n},a.createElement(ktt,{name:t,size:24}),a.createElement(Stt,null,a.createElement(Ntt,{weight:"medium",size:"base"},n),a.createElement(Ttt,{size:"small",color:"textLight"},l)))}))),a.createElement(_tt,null,a.createElement(Dtt,{onClick:()=>{D("BusinessEntitiesSettings"),k(!0)}},"Try business tracking")))),A&&a.createElement(QG.N,{type:"BusinessEntities",analyticsName:"BusinessEntitiesSettings",onClose:()=>k(!1)})):a.createElement(mX.V,{"data-external-id":"business-entities-settings",md:9},a.createElement(Ffe,{title:a.createElement(xtt,null),anchorId:"businesses",controls:a.createElement("div",{className:"flex items-center gap-xs"},a.createElement(wt.Xb,{onClick:()=>window.open(VF.e3,"_blank","noopener,noreferrer")},a.createElement(Yo.r,{name:"play"}),a.createElement("span",null,"Watch walkthrough")),t.length>0&&a.createElement(a.Fragment,null,a.createElement(wt.Xb,{onClick:()=>_(!0)},"Edit account assignments"),a.createElement(cu.WT,{onClick:O},"Add a business")))},a.createElement(Xhe.Ay,null,a.createElement("title",null,"Businesses")),a.createElement(Rtt,null,"Business activity currently rolls up into your overall household view.",t.length>0&&a.createElement(a.Fragment,null,a.createElement("br",null),a.createElement("br",null),"You can make the most out of business tracking by picking up where you left off in our"," ",a.createElement(Vl.W,{to:I.JZ.businesses.setup({queryParams:{step:"Education"}}),state:{returnTo:I.JZ.settings.businesses()}},"setup guide"),".")," "),t.length>0&&a.createElement(Ott,R,a.createElement(Ptt,null,a.createElement(xt.v,{weight:"medium"},"Include in budgeting"),a.createElement(xt.v,{size:"small",color:"textLight"},"When turned on, income and expenses from your businesses will be included in your household budget. Turn this off to keep business activity separate from your personal spending plan.")),a.createElement(ox.k,{checked:M,onChange:e=>L(e.target.checked)})),a.createElement(Mtt,null,a.createElement(ftt.Q,{onEntityClick:P,onEntityEdit:B}))),(b||v)&&a.createElement(um.b,{onClose:z},a.createElement(Ett.j,{businessEntity:v,onSave:F,onNext:v?void 0:G})),T&&a.createElement(um.b,{onClose:Y,maxWidth:"768px"},a.createElement(Nq,{preserveEdits:!0,scrollable:!0})))},xtt=()=>a.createElement("span",{"data-external-id":"businesses-title",className:"inline-flex items-center gap-sm"},"Businesses",a.createElement($G,null)),wtt=u.default.div.withConfig({displayName:"BusinessEntitiesSettings__CardContent",componentId:"sc-1t0fc30-0"})(["padding:",";"],vt.YK.xlarge),Ctt=u.default.p.withConfig({displayName:"BusinessEntitiesSettings__Subtitle",componentId:"sc-1t0fc30-1"})(["color:",";margin:0 0 ",";"],vt.Ee.color.content.primary,vt.YK.small),Att=(0,u.default)(m.g).attrs({column:!0}).withConfig({displayName:"BusinessEntitiesSettings__FeatureList",componentId:"sc-1t0fc30-2"})(["gap:",";margin-bottom:",";"],vt.YK.large,vt.YK.xlarge),Itt=(0,u.default)(m.g).attrs({alignCenter:!0}).withConfig({displayName:"BusinessEntitiesSettings__FeatureItem",componentId:"sc-1t0fc30-3"})(["gap:",";"],vt.YK.default),ktt=(0,u.default)(sl.ZQ).withConfig({displayName:"BusinessEntitiesSettings__FeatureItemIcon",componentId:"sc-1t0fc30-4"})(["color:",";flex-shrink:0;"],vt.Ee.color.content.secondary),Stt=(0,u.default)(m.g).attrs({column:!0}).withConfig({displayName:"BusinessEntitiesSettings__FeatureItemContent",componentId:"sc-1t0fc30-5"})(["gap:",";"],vt.YK.xxxsmall),Ntt=(0,u.default)(xt.v).withConfig({displayName:"BusinessEntitiesSettings__FeatureItemTitle",componentId:"sc-1t0fc30-6"})([""]),Ttt=(0,u.default)(xt.v).withConfig({displayName:"BusinessEntitiesSettings__FeatureItemSubtitle",componentId:"sc-1t0fc30-7"})([""]),_tt=u.default.div.withConfig({displayName:"BusinessEntitiesSettings__TryButtonWrapper",componentId:"sc-1t0fc30-8"})([""]),Dtt=(0,u.default)(cu.WT).attrs({size:"medium"}).withConfig({displayName:"BusinessEntitiesSettings__TryButton",componentId:"sc-1t0fc30-9"})(["@media (max-width:","px){width:100%;}"],vt.nm.md),Rtt=u.default.div.withConfig({displayName:"BusinessEntitiesSettings__InfoText",componentId:"sc-1t0fc30-10"})(["padding:"," ",";border-bottom:1px solid ",";"],vt.YK.default,vt.YK.large,vt.Ee.color.divider.primary),Mtt=u.default.div.withConfig({displayName:"BusinessEntitiesSettings__EntitiesListWrapper",componentId:"sc-1t0fc30-11"})([""]),Ltt=(0,u.default)(m.g).attrs({center:!0}).withConfig({displayName:"BusinessEntitiesSettings__LoadingContainer",componentId:"sc-1t0fc30-12"})(["padding:",";"],vt.YK.xxxlarge),Ott=(0,u.default)(m.g).attrs({alignStart:!0,justifyBetween:!0}).withConfig({displayName:"BusinessEntitiesSettings__PreferenceRow",componentId:"sc-1t0fc30-13"})(["padding:",";gap:",";border-bottom:1px solid ",";"],vt.YK.xlarge,vt.YK.xlarge,vt.Ee.color.divider.primary),Ptt=(0,u.default)(m.g).attrs({column:!0}).withConfig({displayName:"BusinessEntitiesSettings__PreferenceContent",componentId:"sc-1t0fc30-14"})(["gap:",";flex:1;"],vt.YK.xxsmall);var Btt=n(59676),ztt=n(77216);const Ftt="https://monarch-static-assets-us-east-2.s3.amazonaws.com/categories",Gtt=[{title:_t.a0.INCOME.TITLE,subtitle:_t.a0.INCOME.SUBTITLE,image:{url:"".concat(Ftt,"/[email protected]"),height:227}},{title:_t.a0.EXPENSE.TITLE,subtitle:_t.a0.EXPENSE.SUBTITLE,image:{url:"".concat(Ftt,"/[email protected]"),height:180}},{title:_t.a0.TRANSFER.TITLE,subtitle:_t.a0.TRANSFER.SUBTITLE,image:{url:"".concat(Ftt,"/[email protected]"),height:135}}],Ytt=Math.max(...Gtt.map((e=>e.image.height))),Utt=()=>{const e=(0,xq.bO)("hasSeenCategoriesManagementTour"),t=(0,o.A)(e,2),n=t[0],l=t[1],r=(0,Pd.h)(),i=(0,o.A)(r,2),s=i[0],c=i[1],d=c.open,u=c.isOpen,m=c.close,p=(0,a.useState)(0),g=(0,o.A)(p,2),h=g[0],v=g[1],f=Gtt[h],E=f.title,y=f.subtitle,b=f.image;(0,a.useEffect)((()=>{!1===n&&d()}),[n,d]);const x=(0,a.useCallback)((()=>h===Gtt.length-1?m():v((0,Btt.A)(1))),[h,v,m]);return u?a.createElement(s,{"data-external-id":"categories-tour-overlay",onClose:()=>l(!0)},a.createElement(Vtt,{title:E,description:a.createElement(jtt,null,y)},a.createElement(Wtt,null,a.createElement(Htt,null,a.createElement(Ktt,{alt:E,src:b.url,$height:b.height}))),a.createElement(Cq.R,{justifyBetween:!0},a.createElement(wt.Xb,{onClick:m},"Skip"),a.createElement(ztt.k,{count:Gtt.length,currentIndex:h,onChangeIndex:v}),a.createElement(cu.WT,{onClick:x},"Next")))):null}
1,Vtt=(0,u.default)(Rc.L).withConfig({displayName:"CategoriesTourOverlay__ModalCardWithPadding",componentId:"sc-159jrbv-0"})(["padding-top:",";"],(e=>e.theme.spacing.xsmall)),Wtt=u.default.div.withConfig({displayName:"CategoriesTourOverlay__ModalBody",componentId:"sc-159jrbv-1"})(["padding:",";padding-top:0;"],(e=>e.theme.spacing.xlarge)),jtt=u.default.div.withConfig({displayName:"CategoriesTourOverlay__Subtitle",componentId:"sc-159jrbv-2"})(["color:",";font-size:",";margin-top:-",";"],(e=>e.theme.color.text),(e=>e.theme.fontSize.base),(e=>e.theme.spacing.xxsmall)),Htt=(0,u.default)(m.g).attrs({center:!0}).withConfig({displayName:"CategoriesTourOverlay__ImageContainer",componentId:"sc-159jrbv-3"})(["height:","px;margin:"," 0;@media (max-width:","px){height:calc(","px * ",");margin:"," 0;}"],Ytt,(e=>e.theme.spacing.xlarge),(e=>e.theme.breakPoints.sm),Ytt,.65,(e=>e.theme.spacing.xsmall)),Ktt=u.default.img.withConfig({displayName:"CategoriesTourOverlay__Image",componentId:"sc-159jrbv-4"})(["flex-shrink:0;width:","px;@media (max-width:","px){height:calc(","px * ",");width:auto;}"],516,(e=>e.theme.breakPoints.sm),(e=>e.$height),.65);var qtt=n(80143),$tt=n(62320);const Ztt="categories-",Jtt=e=>"category-".concat(e),Xtt=e=>"category-group-".concat(e),Qtt=e=>e.slice(11),ent=e=>{let t=e.category,n=t.icon,l=t.name,r=t.id,o=t.order,i=t.isSystemCategory,s=t.isDisabled,c=t.group,d=e.onClick;const u=!s,m=a.createElement(a.Fragment,null,a.createElement(lnt,null,n),a.createElement(rnt,null,l),a.createElement(ont,null,!i&&"Custom",s&&a.createElement(mWe.MdsEyeOffIcon,{size:"md",className:"text-content-secondary"})));return u?a.createElement(nnt,{"data-external-id":"manage-category-row",id:r,data:{dragType:Jtt(c.type),order:o},onClick:d,customDragHandle:!0},a.createElement(qH.v,null),m):a.createElement(ant,{"data-external-id":"manage-category-row",onClick:d},m)},tnt=e=>{let t=e.theme;return"\n  padding: 10px 12px;\n  background: ".concat(t.color.white,";\n  border-radius: ").concat(t.radius.small,";\n  box-shadow: 0px 2px 4px ").concat((0,xb.B3)(t.color.black,.04),";\n  font-size: ").concat(t.fontSize.small,";\n  display: flex;\n  align-items: center;\n  margin-bottom: ").concat(t.spacing.xsmall,";\n  && {\n    cursor: pointer;\n  }\n")},nnt=(0,u.default)(Hk.U).withConfig({displayName:"ManageCategoryRow__StyledSortableItem",componentId:"sc-7pevrc-0"})(["",""],tnt),ant=(0,u.default)(ZY.B).withConfig({displayName:"ManageCategoryRow__StyledNonDraggable",componentId:"sc-7pevrc-1"})(["opacity:0.5;",""],tnt),lnt=u.default.span.withConfig({displayName:"ManageCategoryRow__Icon",componentId:"sc-7pevrc-2"})(["flex-shrink:0;margin-right:",";margin-left:",";"],(e=>e.theme.spacing.small),(e=>e.theme.spacing.default)),rnt=u.default.span.withConfig({displayName:"ManageCategoryRow__Name",componentId:"sc-7pevrc-3"})(["flex-grow:1;"]),ont=u.default.span.withConfig({displayName:"ManageCategoryRow__Label",componentId:"sc-7pevrc-4"})(["color:",";font-size:",";font-weight:",";display:flex;"],(e=>e.theme.color.textLight),(e=>e.theme.fontSize.xsmall),(e=>e.theme.fontWeight.medium));var int,snt=n(22492);const cnt=e=>{let t=e.group,n=e.onClickEditGroup,l=e.onClickCreateCategory,r=e.onClickEditCategory,o=e.categories,i=void 0===o?[]:o;const s=(0,Qhe.x)("category-group-".concat(t.id)),c=i.filter((e=>e.isDisabled)),d=i.filter((e=>!e.isDisabled)),u=(m=t.id,"".concat(Ztt).concat(m));var m;return a.createElement(dnt,Object.assign({"data-external-id":"manage-category-group-card",id:t.id,customDragHandle:!0,data:{dragType:Xtt(t.type),order:t.order}},s),a.createElement(Fk.gB,{id:u,items:d.map((e=>e.id)),strategy:Fk._G},a.createElement(snt.g,{id:u,data:{dragType:Jtt(t.type)},className:"rounded-default"},a.createElement(unt,null,a.createElement(qH.v,{className:"mr-xs",revealOnHover:!0}),t.name,a.createElement(fnt,{onClick:n},"Edit")),c.length+d.length===0?a.createElement(gnt,null,a.createElement(hnt,null,"No categories in this group"),a.createElement(vnt,null,"Drag categories into this group or create new ones"),a.createElement(cu.WT,{onClick:l},"Create category")):a.createElement(mnt,null,d.map((e=>a.createElement(ent,{key:e.id,category:e,onClick:()=>r(e)}))),c.map((e=>a.createElement(ent,{key:e.id,category:e,onClick:()=>r(e)}))),a.createElement(pnt,null,a.createElement(DQ.s,{feature:HQ.W1.CUSTOM_CATEGORIES,side:"right"},(e=>{let t=e.hasAccess;return a.createElement("div",{className:"flex items-center"},a.createElement(fnt,{onClick:t?l:RQ.l},"Create Category"),!t&&a.createElement(_Q.J,null))})))))))},dnt=(0,u.default)(Hk.U).withConfig({displayName:"ManageCategoryGroupCard__StyledSortableItem",componentId:"pfsp36-0"})(["margin-top:",";background:",";border-radius:",";"],(e=>e.theme.spacing.default),(e=>
1e.theme.color.grayBackground),(e=>e.theme.radius.medium)),unt=$d.s.div.attrs((0,U.A)({},(0,Ex.p)("manage-category-group-card-header")))(int||(int=(0,wc.A)(["\n  group/category-group flex items-center border-b border-divider-secondary py-sm pr-default pl-xs\n  font-medium\n"]))),mnt=u.default.div.withConfig({displayName:"ManageCategoryGroupCard__Content",componentId:"pfsp36-1"})(["padding:",";"],(e=>e.theme.spacing.default)),pnt=u.default.div.withConfig({displayName:"ManageCategoryGroupCard__ContentFooter",componentId:"pfsp36-2"})(["display:flex;align-items:center;margin-top:",";"],(e=>e.theme.spacing.default)),gnt=u.default.div.withConfig({displayName:"ManageCategoryGroupCard__EmptyContent",componentId:"pfsp36-3"})(["flex:1;display:flex;flex-direction:column;align-items:center;padding:"," "," ",";font-size:",";"],(e=>e.theme.spacing.xlarge),(e=>e.theme.spacing.xlarge),(e=>e.theme.spacing.xxlarge),(e=>e.theme.fontSize.xsmall)),hnt=u.default.span.withConfig({displayName:"ManageCategoryGroupCard__EmptyTitle",componentId:"pfsp36-4"})(["font-weight:",";"],(e=>e.theme.fontWeight.medium)),vnt=u.default.span.withConfig({displayName:"ManageCategoryGroupCard__EmptySubtitle",componentId:"pfsp36-5"})(["color:",";margin-top:",";margin-bottom:",";"],(e=>e.theme.color.textLight),(e=>e.theme.spacing.xxsmall),(e=>e.theme.spacing.xlarge)),fnt=(0,u.default)(bn.v).withConfig({displayName:"ManageCategoryGroupCard__GrayButton",componentId:"pfsp36-6"})(["color:",";padding:0 ",";:first-child{padding-left:0;}"],(e=>e.theme.color.textLight),(e=>e.theme.spacing.small));var Ent=n(16785);const ynt=e=>{let t=e.type,n=e.groupIds,l=e.onClickCreateGroup,r=e.children;const o=(e=>"".concat("category-groups-").concat(e))(t),i=(0,Bk.zM)({id:o,data:{dragType:Xtt(t)}}).setNodeRef,s=(0,Qhe.x)(Ent.ZD[t].toLowerCase());return a.createElement(Fk.gB,{"data-external-id":"manage-category-type-section",id:o,items:n,strategy:Fk._G},a.createElement("div",Object.assign({ref:i,className:"mt-xl mb-xs"},s),a.createElement(bnt,null,Ent.ZD[t],a.createElement(xnt,{onClick:l},"Create group")),r))},bnt=u.default.div.withConfig({displayName:"ManageCategoryTypeSection__Header",componentId:"sc-1um99y0-0"})(["display:flex;align-items:center;justify-content:space-between;font-weight:",";font-size:",";"],(e=>e.theme.fontWeight.medium),(e=>e.theme.fontSize.large)),xnt=(0,u.default)(bn.v).withConfig({displayName:"ManageCategoryTypeSection__CreateButton",componentId:"sc-1um99y0-1"})(["padding:0 ",";"],(e=>e.theme.spacing.xsmall));var wnt=n(55858);const Cnt=(e,t)=>
1t+(t>e?.5:-.5);var Ant=n(44139);const Int=Ee.nMX,knt=Ee.MF8,Snt=[Ee.wNk.INCOME,Ee.wNk.EXPENSE,Ee.wNk.TRANSFER],Nnt=()=>{const e=(0,a.useState)(null),t=(0,o.A)(e,2),n=t[0],l=t[1],r=(0,a.useState)(null),s=(0,o.A)(r,2),c=s[0],d=s[1],u=(0,a.useState)(null),m=(0,o.A)(u,2),g=m[0],h=m[1],v=(0,a.useState)(null),f=(0,o.A)(v,2),E=f[0],y=f[1],b=(0,et.I)(Lnt),x=b.data,w=b.isLoadingInitialData,C=b.refetch,A=(0,a.useMemo)((()=>(0,wnt.d6)(x)),[x]),I=(0,o.A)(A,2),k=I[0],S=I[1],N=(e=>{const t=(0,V.m)(),n=(0,i.n)(knt,e),l=(0,o.A)(n,2),r=l[0],s=l[1],c=(0,a.useCallback)((async(e,n)=>{const a=e.categoryGroupId===n.categoryGroupId?Cnt(n.order,e.order):e.order-.5;return t.writeFragment({id:"Category:".concat(e.id),fragment:Ee.mLQ,data:{__typename:"Category",order:a,group:{__typename:"CategoryGroup",id:e.categoryGroupId}}}),await r({variables:e})}),[r,t]);return(0,fK.r)(c,s)})({onCompleted:()=>C()}),T=(0,o.A)(N,1)[0],_=(e=>{const t=(0,V.m)(),n=(0,i.n)(Int,(0,U.A)({update:e=>{e.evict({fieldName:Ant._.CATEGORIES}),e.evict({fieldName:Ant._.CATEGORY_GROUPS})}},e)),l=(0,o.A)(n,2),r=l[0],s=l[1],c=(0,a.useCallback)((async(e,n)=>{const a=Cnt(n.order,e.order);return t.writeFragment({id:"CategoryGroup:".concat(e.id),fragment:Ee.$Ky,data:{__typename:"CategoryGroup",order:a}}),await r({variables:e})}),[r,t]);return(0,fK.r)(c,s)})({onCompleted:()=>C()}),D=(0,o.A)(_,1)[0],R=Tnt(w),M=(0,o.A)(R,2),L=M[0],O=M[1],P=(0,hK.T)();return a.createElement(_nt,{"data-external-id":"manage-categories"},a.createElement(Utt,null),a.createElement(Rnt,null,a.createElement(Dnt,null),"Changes you make to your groups and categories here will be applied all throughout Monarch. You should customize your category structure to fit your needs."),w?a.createElement(Mnt,null,a.createElement(p.i,null)):a.createElement(Bk.Mp,{sensors:P,collisionDetection:a4,onDragEnd:(B=T,z=D,e=>{var t,n,a,l,r;const o=(0,s4.k)(e);if(!o)return;const i=Number(null!==(t=null===(n=e.active.data.current)||void 0===n?void 0:n.order)&&void 0!==t?t:0),s=Number(null!==(a=null===(l=e.over)||void 0===l||null===(r=l.data.current)||void 0===r?void 0:r.order)&&void 0!==a?a:0),c=o.insertAfter?s+1:s;o.source.containerId.startsWith(Ztt)?B({categoryGroupId:Qtt(o.destination.containerId),id:o.id,order:c},{categoryGroupId:Qtt(o.source.containerId),id:o.id,order:i}):z({id:o.id,order:c},{id:o.id,order:i})}),modifiers:[zk.FN],accessibility:{announcements:gK.n}},a.createElement(pK.Z,null),Snt.map((e=>{var t,n;return a.createElement("div",{key:e,ref:L(e)},a.createElement(ynt,{type:e,groupIds:(null!==(t=k[e])&&void 0!==t?t:[]).map((e=>e.id)),onClickCreateGroup:()=>l(e)},null===(n=k[e])||void 0===n?void 0:n.map((e=>a.createElement(cnt,{key:e.id,group:e,onClickEditGroup:()=>h(e.id),onClickCreateCategory:()=>d({group:e.id}),onClickEditCategory:e=>{let t=e.id;return y(t)},categories:S[e.id]})))))}))),n&&a.createElement(um.b,{onClose:()=>l(null)},(e=>{let t=e.close;return a.createElement(qtt.p,{categoryType:n,onDone:()=>{t(),C().then((()=>{O(n)}))}})})),c&&a.createElement(um.b,{onClose:()=>d(null)},(e=>{let t=e.close;return a.createElement($tt.A,{initialValues:c,onCreate:()=>{t(),C()}})})),!!g&&a.createElement(um.b,{onClose:()=>h(null)},(e=>{let t=e.close;return a.createElement(c0.x,{categoryGroupId:g,onDone:()=>{t(),C()}})})),!!E&&a.createElement(um.b,{onClose:()=>y(null)},(e=>{let t=e.close;return a.createElement(ZX.K,{categoryId:E,onDone:()=>{t(),C()}})})));var B,z},Tnt=e=>{const t=(0,a.useState)({}),n=(0,o.A)(t,1)[0],l=(0,a.useState)(null),r=(0,o.A)(l,2),i=r[0],s=r[1];return(0,a.useEffect)((()=>{var t;i&&!e&&(null===(t=n[i])||void 0===t||t.scrollIntoView(!1),s(null))}),[n,i,s,e]),[e=>t=>{n[e]=t},s]},_nt=u.default.div.withConfig({displayName:"ManageCategories__Root",componentId:"sc-9diu5h-0"})(["padding:"," ",";"],(e=>e.theme.spacing.default),(e=>e.theme.spacing.xlarge)),Dnt=(0,u.default)(sl.ZQ).attrs({name:"info "}).withConfig({displayName:"ManageCategories__InfoIcon",componentId:"sc-9diu5h-1"})(["width:16px;height:16px;flex-shrink:0;margin-right:",";"],(e=>e.theme.spacing.default)),Rnt=(0,u.default)(fu.g).attrs({type:"info"}).withConfig({displayName:"ManageCategories__InfoBanner",componentId:"sc-9diu5h-2"})(["font-size:",";display:flex;align-items:center;"],(e=>e.theme.fontSize.small)),Mnt=u.default.div.withConfig({displayName:"ManageCategories__LoadingContainer",componentId:"sc-9diu5h-3"})(["display:flex;align-items:center;justify-content:center;padding:",";margin-top:",";"],(e=>e.theme.spacing.xlarge),(e=>e.theme.spacing.default)),Lnt=Ee.xv1,Ont=()=>a.createElement(mX.V,{"data-external-id":"category-settings",md:9},a.createElement(Ffe,{title:"Categories",anchorId:"categories"},a.createElement(Xhe.Ay,null,a.createElement("title",null,"Category Settings")),a.createElement(Nnt,null))),Pnt=[{value:"light",label:"Light"},{value:"dark",label:"Dark"},{value:"system",label:"System preference"}],Bnt=()=>{const e=(0,d.d4)(A.XO),t=(0,Zse.L)();return a.createElement(mX.V,{"data-external-id":"preference-sett
1ings",md:9},a.createElement(Ffe,{title:"Display",anchorId:"display"},a.createElement(Xhe.Ay,null,a.createElement("title",null,"Display Settings")),a.createElement("div",{className:"m-xl"},a.createElement(Eu.lV,{initialValues:{visualAppearance:e},onSubmit:n=>{let a=n.visualAppearance;a!==e&&(ij.Ay.visualAppearancePreferenceUpdated({preference:a}),t(a))},submitOnChange:!0,submitOnChangeDebounceMs:0},a.createElement(tC.zB.Select,{name:"visualAppearance",options:Pnt,className:"mb-4"})))))};var znt=n(37750);(0,Qt.J)("\n  fragment EarlyAccessExperimentFields on EarlyAccessExperiment {\n    key\n    title\n    description\n    feedbackUrl\n    isEnabled\n    hasQuota\n    canToggle\n    unavailableReason\n  }\n");const Fnt=(0,Qt.J)("\n  query Common_GetEarlyAccessExperiments {\n    earlyAccess {\n      experiments {\n        ...EarlyAccessExperimentFields\n      }\n    }\n  }\n"),Gnt=(0,Qt.J)("\n  mutation Common_SetEarlyAccessExperimentEnabled($input: SetEarlyAccessExperimentEnabledInput!) {\n    setEarlyAccessExperimentEnabled(input: $input) {\n      success\n      enabled\n      errors {\n        message\n      }\n    }\n  }\n"),Ynt="legacy_investment_transactions",Unt=()=>{const e=(()=>{var e,t;const n=(0,et.I)(Fnt,{fetchPolicy:"cache-and-network"}),l=n.data,r=n.isLoadingInitialData,s=n.error,c=n.refetch,d=(0,i.n)(Gnt,{update:(e,t,n)=>{let a=t.data,l=n.variables;const r=null===a||void 0===a?void 0:a.setEarlyAccessExperimentEnabled,o=null===l||void 0===l?void 0:l.input.experimentKey;(null===r||void 0===r?void 0:r.success)&&o&&e.updateQuery({query:znt.S},(e=>{if(!(null===e||void 0===e?void 0:e.myHousehold))return;const t=e.myHousehold.earlyAccessEnabledKeys.filter((e=>e!==o));return(0,U.A)((0,U.A)({},e),{},{myHousehold:(0,U.A)((0,U.A)({},e.myHousehold),{},{earlyAccessEnabledKeys:r.enabled?[...t,o].sort():t})})}))}}),u=(0,o.A)(d,1)[0],m=(0,a.useState)({}),p=(0,o.A)(m,2),g=p[0],h=p[1],v=(0,a.useState)([]),f=(0,o.A)(v,2),E=f[0],y=f[1],b=(0,a.useRef)({}),x=null!==(e=E.at(-1))&&void 0!==e?e:null,w=(0,a.useMemo)((()=>{var e,t;return(null!==(t=null===(e=null===l||void 0===l?void 0:l.earlyAccess)||void 0===e?void 0:e.experiments)&&void 0!==t?t:[]).map((e=>{var t;return(0,U.A)((0,U.A)({},e),{},{isEnabled:null!==(t=g[e.key])&&void 0!==t?t:e.isEnabled})}))}),[null===(t=null===l||void 0===l?void 0:l.earlyAccess)||void 0===t?void 0:t.experiments,g]),C=(0,a.useCallback)((async(e,t)=>{var n,a,l,r,i;h((n=>(0,U.A)((0,U.A)({},n),{},{[e]:t}))),b.current[e]=(null!==(n=b.current[e])&&void 0!==n?n:0)+1,y((t=>[...t,e]));let s=!1;try{const n=null===(a=(await u({variables:{input:{experimentKey:e,enabled:t}}})).data)||void 0===a?void 0:a.setEarlyAccessExperimentEnabled;return(null===n||void 0===n?void 0:n.success)?(s=!await c().then((()=>!0)).catch((()=>!1)),{ok:!0}):{ok:!1,message:null!==(r=null===(l=null===n||void 0===n?void 0:n.errors)||void 0===l?void 0:l.message)&&void 0!==r?r:void 0}}catch(d){return{ok:!1}}finally{const t=(null!==(i=b.current[e])&&void 0!==i?i:1)-1;t>0?(b.current[e]=t,s=!0):b.current=Object.fromEntries(Object.entries(b.current).filter((t=>(0,o.A)(t,1)[0]!==e))),s||h((t=>Object.fromEntries(Object.entries(t).filter((t=>(0,o.A)(t,1)[0]!==e))))),y((t=>{const n=t.indexOf(e);return-1===n?t:[...t.slice(0,n),...t.slice(n+1)]}))}}),[c,u]);return{experiments:w,isLoadingInitialData:r,error:s,refetch:c,pendingKey:x,setExperimentEnabled:C}})(),t=e.experiments,n=e.isLoadingInitialData,l=e.error,r=e.pendingKey,s=e.setExperimentEnabled,c=(e=>{let t=e.isVisible;var n;const l=(0,lt.L7)({fetchPolicy:"cache-and-network",skip:!t}),r=l.householdPreferences,o=l.isLoadingInitialData,i=l.isUpdatingHouseholdPreferences,s=l.updateHouseholdPreferences,c=(0,a.useCallback)((async e=>{try{return await s({investmentTransactionsEnabled:e}),{ok:!0}}catch(t){return{ok:!1}}}),[s]);return{row:t?{key:Ynt,title:_t.e6.SETTINGS.INVESTMENT_TRANSACTIONS_ENABLED.TITLE,description:_t.e6.SETTINGS.INVESTMENT_TRANSACTIONS_ENABLED.SUBTITLE,feedbackUrl:null,isEnabled:null!==(n=null===r||void 0===r?void 0:r.investmentTransactionsEnabled)&&void 0!==n&&n,hasQuota:!1,canToggle:!0,unavailableReason:null}:null,isLoadingInitialData:!!t&&o,isUpdating:i,setEnabled:c}})({isVisible:(0,nG.p)("investment-transactions-enabled","on")}
1),d=c.row,u=c.isLoadingInitialData,m=c.isUpdating,g=c.setEnabled,h=t.some((e=>"investment_transactions"===e.key)),v=d&&!h?[...t,d]:t,f=(0,C.RU)(),E=(0,a.useState)(null),y=(0,o.A)(E,2),b=y[0],x=y[1],w=(0,a.useCallback)((async(e,t)=>{const n=e===Ynt?await g(t):await s(e,t);var a;n.ok||f({description:null!==(a=n.message)&&void 0!==a?a:_t.V5.ERROR_FALLBACK})}),[g,f,s]),A=(0,a.useCallback)(((e,t)=>{t||!e.hasQuota?w(e.key,t):x(e.key)}),[w]),I=v.find((e=>e.key===b));return a.createElement(mX.V,{"data-external-id":"early-access-settings",md:9},a.createElement(Xhe.Ay,null,a.createElement("title",null,"Early Access")),(n||u)&&a.createElement(Ffe,{className:"mb-gutter"},a.createElement("div",{className:"flex items-center justify-center p-2xl"},a.createElement(p.i,null))),!(n||u)&&l&&a.createElement(Ffe,{className:"mb-gutter"},a.createElement("div",{className:"p-xl"},a.createElement(SQ.W,{message:VG.U.DEFAULT}))),!(n||u)&&(v.length>0||!l)&&a.createElement(Ffe,{className:"mb-gutter overflow-hidden",anchorId:"early-access"},a.createElement("div",{className:"flex flex-col gap-xs border-b border-divider-primary p-xl"},a.createElement(fe.c8D,{size:"20",weight:"medium"},"Early Access"),a.createElement(fe.c8D,{size:"sm",color:"secondary"},_t.V5.DESCRIPTION)),v.length>0?v.map((e=>{const t=!e.canToggle||((n=e.key)===Ynt?m:r===n)||b===e.key;var n;const l=!!e.feedbackUrl&&e.isEnabled;return a.createElement(fe.Loi.Root,{key:e.key,variant:"subtle",checked:e.isEnabled,disabled:t,onCheckedChange:t=>A(e,t),className:(0,q.cn)("rounded-none border-x-0 border-t-0 border-b border-divider-primary last:border-b-0",!t&&"hover:bg-background-primary-hover")},a.createElement(fe.Loi.Header,{className:(0,q.cn)("items-start p-xl",l&&"pb-default")},a.createElement(fe.Loi.Switch,null),a.createElement(fe.Loi.HeaderText,null,a.createElement("div",{className:"flex items-center gap-xs"},a.createElement(fe.Loi.Label,null,e.title),a.createElement(fe.CQG,{color:"blue"},"Beta")),a.createElement(Ll.o,{source:e.description,className:(0,q.cn)(t&&"text-content-secondary")}),!e.canToggle&&e.unavailableReason&&a.createElement(fe.c8D,{size:"sm",color:"secondary"},e.unavailableReason))),l&&e.feedbackUrl&&a.createElement(fe.Loi.Body,{className:"border-t-0 px-xl pt-0 pb-xl"},a.createElement(fe.liZ,{href:e.feedbackUrl,external:!0,size:"sm","aria-label":_t.V5.FEEDBACK_ACCESSIBLE_NAME(e.title),onClick:e=>e.stopPropagation()},_t.V5.FEEDBACK_LINK_LABEL)))})):a.createElement("div",{className:"flex flex-col items-center gap-xs px-xl py-2xl text-center"},a.createElement(fe.nRr,{size:"xl",className:"text-content-secondary"}),a.createElement(fe.c8D,{weight:"medium"},_t.V5.EMPTY_TITLE),a.createElement(fe.c8D,{color:"secondary"},_t.V5.EMPTY_DESCRIPTION))),I&&a.createElement(fe.V0Z,{open:!0,onOpenChange:e=>{e||x(null)},title:_t.V5.CONFIRM_TITLE(I.title),description:_t.V5.CONFIRM_BODY,confirmLabel:_t.V5.CONFIRM_DISABLE_LABEL,cancelLabel:_t.V5.CANCEL,onConfirm:async()=>{await w(I.key,!1),x(null)}}))},Vnt=e=>{let t=e.employer,n=e.afterDelete,l=e.afterUpdate;const r=(0,Sq.k)().close,s=(0,C.RU)(),c=(0,a.useState)(t.name),d=(0,o.A)(c,2),u=d[0],m=d[1],p=(0,a.useState)(!1),g=(0,o.A)(p,2),h=g[0],v=g[1],f=(0,a.useState)(!1),E=(0,o.A)(f,2),y=E[0],b=E[1],x=0===t.paycheckCount,w=(0,i.n)(xee,{refetchQueries:[{query:yee}]}),A=(0,o.A)(w,1)[0],I=(0,i.n)(wee,{refetchQueries:[{query:yee}]}),k=(0,o.A)(I,1)[0],S=(0,a.useCallback)((async()=>{if(u.trim()){v(!0);try{var e,n;const o=null===(e=(await A({variables:{input:{id:t.id,name:u.trim()}}})).data)||void 0===e||null===(n=e.updatePaycheckEmployer)||void 0===n?void 0:n.errors;var a;if(o)s({description:null!==(a=o.message)&&void 0!==a?a:void 0});else(0,C.oR)({title:"Employer updated"}),null===l||void 0===l||l(),r()}catch(o){s({description:"Couldn't update employer."})}finally{v(!1)}}}),[u,t.id,A,s,l,r]),N=(0,a.useCallback)((async()=>{b(!0);try{var e;const l=null===(e=(await k({variables:{id:t.id}})).data)||void 0===e?void 0:e.deletePaycheckEmployer;var a;if(null!==l&&void 0!==l&&l.errors)s({description:null!==(a=l.errors.message)&&void 0!==a?a:void 0});else null!==l&&void 0!==l&&l.success&&((0,C.oR)({title:'Deleted "'.concat(t.name,'"')}),null===n||void 0===n||n(),r())}catch(l){s({description:"Couldn't delete employer."})}finally{b(!1)}}),[t,k,s,n,r]);return a.createElement(Rc.L,{"data-external-id":"edit-employer-modal",title:"Edit employer"},a.createElement(qY.S,null,a.createElement(jnt,null,"Employer name"),a.createElement(Wnt,{name:"name",value:u,onChange:e=>m(e.target.value),onKeyDown:e=>{"Enter"===e.key&&S()},autoFocus:!0})),a.createElement(Cq.R,null,a.createElement(G7.jI,{onClick:N,disabled:!x||y},y?"Deleting...":"Delete"),a.createElement(wt.Xb,{onClick:r},"Cancel"),a.createElement(cu.WT,{onClick:S,disabled:h||!u.trim()},h?"Saving...":"Save")))},Wnt=(0,u.default)(Ry.X).withConfig({displayName:"EditEmployerModal__StyledTextField",componentId:"pa3hl-0"})(["label{font-size:",";}"],(e=>e.theme.fontSize.small)),jnt=(0,u.default)(xt.v).attrs({size:"small",weight:"medium"}).withConfig({displayName:"EditEmployerModal__FieldLabel",componentId:"pa3hl-1"})(["margin-bottom:",";"],(e=>e.theme.spacing.xsmall)),Hnt=e=>{let t=e.employer,n=e.onClickEdit;return a.createElement(Knt,{"data-external-id":"employer-list-item"},a.createElement(qnt,null,a.createElement(xt.v,{weight:"medium",size:"large"},t.name),a.createElement(Vl.W,{to:I.JZ.paychecks({queryParams:{employerId:t.id}}),stealthy:!0},a.createElement(xt.v,{size:"small"},(0,De.LN)(t.paycheckCount)," ",(0,De.td)("paycheck",t.paycheckCount)))),a.createElement(wt.Xb,{size:"small",onClick:n},a.createElement(Yo.r,{name:"edit"}),a.createElement("span",null,"Edit")))},Knt=(0,u.default)(m.g).attrs({justifyBetween:!0,alignCenter:!0}).withConfig({displayName:"EmployerListItem__Root",componentId:"tdcpak-0"})(["padding:"," ",";border-top:1px solid ",";gap:",";"],(e=>e.theme.spacing.default),(e=>e.theme.spacing.xlarge),vt.Ee.color.divider.primary,(e=>e.theme.spacing.default)),qnt=(0,u.default)(m.g).attrs({column:!0}).withConfig({displayName:"EmployerListItem__EmployerInfo",componentId:"tdcpak-1"})(["gap:",";flex-grow:1;"],(e=>e.theme.spacing.xxsmall));var $nt;const Znt=()=>{var e;const t=(0,a.useState)(""),n=(0,o.A)(t,2),l=n[0],r=n[1],i=(0,xy.d)(l,RIe.N),s=(0,et.I)(yee,{variables:{search:i||null}}),c=s.data,d=s.isLoadingInitialData,u=s.refetch,m=(0,a.useMemo)((()=>{var e;return null!==(e=null===c||void 0===c?void 0:c.paycheckEmployers)&&void 0!==e?e:[]}),[null===c||void 0===c?void 0:c.paycheckEmployers]),g=null!==(e=null===c||void 0===c?void 0:c.paycheckEmployerCount)&&void 0!==e?e:0,h=(0,a.useState)(null),v=(0,o.A)(h,2),f=v[0],E=v[1];let y;return y=d?a.createElement(nat,null,a.createElement(p.i,null)):(0,LV.A)(m)?a.createElement(cU.vx,{title:"No employers found",subtitle:l?'No employers match "'.concat(l,'".'):"Employers will appear here once you create paychecks."}):m.map((e=>a.createElement(Hnt,{key:e.id,employer:e,onClickEdit:()=>E(e)}))),a.createElement(mX.V,{"data-external-id":"employer-settings",md:9},a.createElement(Ffe,{title:"Paycheck Employers",anchorId:"paycheck-employers"},a.createElement(Xhe.Ay,null,a.createElement("title",null,"Paycheck Employers")),a.createElement(Jnt,null,a.createElement(Xnt,null,a.createElement(xt.v,null,"These are the employers associated with your paychecks. You can rename or delete employers that are no longer needed.")),a.createElement(Qnt,{name:"search",placeholder:g?"Search ".concat(g.toLocaleStr
1ing()," ").concat((0,De.td)("employer",g),"..."):"Search for an employer...",value:l,onChange:e=>r(e.target.value)}),g>0&&a.createElement(eat,null,g.toLocaleString()," ",(0,De.td)("Employer",g))),a.createElement(tat,null,y)),f&&a.createElement(um.b,{onClose:()=>E(null)},a.createElement(Vnt,{employer:f,afterDelete:u,afterUpdate:u})))},Jnt=u.default.div.withConfig({displayName:"EmployerSettings__Header",componentId:"sc-1q01l9v-0"})(["padding:"," "," ",";padding-top:",";"],(e=>e.theme.spacing.xlarge),(e=>e.theme.spacing.xlarge),(e=>e.theme.spacing.default),(e=>e.theme.spacing.default)),Xnt=u.default.div.withConfig({displayName:"EmployerSettings__IntroContainer",componentId:"sc-1q01l9v-1"})(["margin-bottom:",";"],(e=>e.theme.spacing.default)),Qnt=(0,u.default)(Ry.X).withConfig({displayName:"EmployerSettings__SearchInput",componentId:"sc-1q01l9v-2"})(["flex:1;height:40px;min-width:240px;"]),eat=(0,u.default)(xt.v).attrs({weight:"medium",size:"large"}).withConfig({displayName:"EmployerSettings__CountText",componentId:"sc-1q01l9v-3"})(["display:inline-block;margin-top:",";"],(e=>e.theme.spacing.default)),tat=$d.s.div($nt||($nt=(0,wc.A)(["w-full"]))),nat=(0,u.default)(m.g).attrs({center:!0}).withConfig({displayName:"EmployerSettings__SpinnerContainer",componentId:"sc-1q01l9v-4"})(["margin:"," 0;"],(e=>e.theme.spacing.xlarge)),aat=()=>{const e=(0,C.RU)(),t=(0,i.n)(dat,{fetchPolicy:"no-cache"}),n=(0,o.A)(t,2),l=n[0],r=n[1].loading;return a.createElement(cat,{"data-external-id":"gifts-cta"},a.createElement(m.g,{column:!0,gap:"default",justifyCenter:!0,flexGrow:1,flexBasis:"0"},a.createElement(lat,null,"Gift a year of Monarch Core"),a.createElement(rat,null,"Gift friends or family the feeling of financial clarity and confidence with a year of Monarch Core for just $50."),a.createElement(m.g,null,a.createElement(cu.WT,{onClick:async()=>{(0,Ge.u4)(Ye.C8.PurchaseGiftButtonClicked);try{const e="".concat(window.location.origin,"/settings/gifts"),n=(await l({variables:{input:{successUrl:e}}})).data,a=(null!==n&&void 0!==n?n:{}).createPromoCodeCheckoutSession,r=null!==a&&void 0!==a?a:{},o=r.errors,i=r.url;var t;if(o)throw new Error(null!==(t=o.message)&&void 0!==t?t:"Failed to create checkout session");i&&(window.location.href=i)}catch(n){e({description:"Unable to start checkout. Please try again or contact support."})}},disabled:r},"Gift Monarch"))),a.createElement(oat,null,a.createElement(iat,null,a.createElement(sat,null,a.createElement(Xre.C,{color:"#FFFFFF",size:120})))))},lat=u.default.h2.withConfig({displayName:"GiftsCTA__Title",componentId:"h5hvcm-0"})(["font-size:",";line-height:1.2;font-weight:bold;margin:0;color:",";"],vt.J.xxlarge,vt.yW.text),rat=u.default.p.withConfig({displayName:"GiftsCTA__Subtitle",componentId:"h5hvcm-1"})(["font-size:",";color:",";margin:0;line-height:1.5;"],vt.J.base,vt.yW.textLight),oat=(0,u.default)(m.g).withConfig({displayName:"GiftsCTA__GiftCardContainerWrapper",componentId:"h5hvcm-2"})(["justify-content:flex-end;flex-grow:1;flex-basis:0;@media (max-width:","px){max-width:100%;margin-bottom:",";}"],vt.nm.md,vt.YK.medium),iat=u.default.div.withConfig({displayName:"GiftsCTA__GiftCardContainer",componentId:"h5hvcm-3"})(["width:100%;max-width:420px;aspect-ratio:8560 / 5398;padding:",";background:",";border-radius:",";display:flex;align-items:center;justify-content:center;@media (max-width:","px){width:100%;aspect-ratio:unset;min-height:100px;max-width:100%;padding:",";}"],vt.YK.xlarge,(e=>{let t=e.theme;return"dark"===t.uiTheme?"linear-gradient(135deg, ".concat(t.color.orange9," 0%, ").concat(t.color.yellow9," 100%)"):"linear-gradient(135deg, ".concat(t.color.orange6," 0%, ").concat(t.color.yellow6," 100%)")}),vt.r8.large,vt.nm.md,vt.YK.default),sat=u.default.div.withConfig({displayName:"GiftsCTA__MarkContainer",componentId:"h5hvcm-4"})(["filter:drop-shadow(0px 4px 8px rgba(0,0,0,0.15));svg{width:120px;height:120px;@media (max-width:","px){width:60px;height:60px;}}"],vt.nm.md),cat=(0,u.default)(m.g).withConfig({displayName:"GiftsCTA__ResponsiveWrapper",componentId:"h5hvcm-5"})(["gap:",";padding:",";@media (max-width:","px){flex-direction:column-reverse;}"],vt.YK.xlarge,vt.YK.xxlarge,vt.nm.md),dat=Ee.rbN,uat=e=>{let t=e.stripeCheckoutSessionId,n=e.onClose;const l=(0,a.useState)(!0),r=(0,o.A)(l,2),i=r[0],s=r[1],c=(0,a.useState)(null),d=(0,o.A)(c,2),u=d[0],m=d[1],g=(0,a.useState)(null),h=(0,o.A)(g,2),v=h[0],f=h[1],E=(0,PH.p)(fat,{fetchPolicy:"network-only",pollUntil:e=>{const n=((null===e||void 0===e?void 0:e.giftedSubscriptionsPurchasedByHousehold)||[]).find((e=>e.stripeCheckoutSessionId===t));return!(null===n||void 0===n||!n.promoCode)&&(m(n.promoCode),s(!1),!0)},pollIntervalMs:3e3,pollTimeoutMs:36e3,onComplete:()=>{}
1,onTimeoutReached:()=>{f("We're still processing your purchase, but it's taking longer than expected. Please check your Gift Monarch screen in a few minutes or contact support if the issue persists."),s(!1)},skipWhenNotPolling:!1}),y=(0,o.A)(E,1)[0];return(0,a.useEffect)((()=>{if(!t)return f("No checkout session ID provided"),void s(!1);y()}),[t,y]),v?a.createElement(um.b,{"data-external-id":"promo-code-purchase-success-modal",onClose:n,maxWidth:"540px"},a.createElement(Rc.L,{title:"Error",hideBottomBorder:!0},a.createElement(mat,null,a.createElement(gat,null,a.createElement(xt.v,{weight:"medium",size:"large"},"Something went wrong"),a.createElement(xt.v,{color:"content.secondary"},v))))):i?a.createElement(um.b,{"data-external-id":"promo-code-purchase-success-modal",onClose:n,maxWidth:"540px"},a.createElement(Rc.L,{title:"Processing purchase",hideBottomBorder:!0},a.createElement(pat,null,a.createElement(p.i,{size:"2xl"}),a.createElement(gat,null,a.createElement(xt.v,{weight:"medium",size:"large"},"Processing your purchase"),a.createElement(xt.v,{color:"content.secondary"},"Please wait while we generate your promo code..."))))):a.createElement(um.b,{"data-external-id":"promo-code-purchase-success-modal",onClose:n,maxWidth:"540px"},a.createElement(q3.N,{portal:!0}),a.createElement(Rc.L,{title:"Your gift is ready",hideBottomBorder:!0},a.createElement(mat,null,a.createElement(d7.r,{iconSizePx:40,className:"size-20"}),a.createElement(gat,null,a.createElement(xt.v,{weight:"medium",size:"xlarge"},"Your promo code is ready to share"),a.createElement(xt.v,{color:"content.secondary"},"Share this code so they can start their Monarch journey today.")),u&&a.createElement(vat,null,a.createElement(hat,null,a.createElement(xt.v,{color:"content.secondary",weight:"medium"},"Promo code:"),a.createElement(xt.v,{weight:"medium",color:"content.primary"},u)),a.createElement(cu.WT,{size:"medium",onClick:async()=>{const e="I got you a gift\u2026a year of Monarch! I use it and it's brought me total money clarity. Just use code ".concat(u," when signing up and your first year is on me: https://app.monarchmoney.com/signup?promoCode=").concat(u);if(navigator.share)try{await navigator.share({text:e})}catch(t){}else if(navigator.clipboard&&navigator.clipboard.writeText)try{await navigator.clipboard.writeText(e)}catch(n){}}},"Share")))))},mat=(0,u.default)(m.g).attrs({column:!0}).withConfig({displayName:"PromoCodePurchaseSuccessModal__Content",componentId:"obl9mz-0"})(["gap:",";padding:",";align-items:center;"],vt.YK.default,vt.YK.xlarge),pat=(0,u.default)(m.g).attrs({column:!0}).withConfig({displayName:"PromoCodePurchaseSuccessModal__LoadingContent",componentId:"obl9mz-1"})(["gap:",";padding:",";align-items:center;justify-content:center;min-height:300px;"],vt.YK.xlarge,vt.YK.xlarge),gat=(0,u.default)(m.g).attrs({column:!0}).withConfig({displayName:"PromoCodePurchaseSuccessModal__TextContainer",componentId:"obl9mz-2"})(["gap:",";text-align:center;"],vt.YK.xsmall),hat=(0,u.default)(m.g).attrs({row:!0,gap:"xxsmall"}).withConfig({displayName:"PromoCodePurchaseSuccessModal__PromoCodeContainer",componentId:"obl9mz-3"})(["flex-grow:0;padding:"," ",";border:1px solid ",";border-radius:",";box-shadow:0 2px 4px ",";"],vt.YK.xsmall,vt.YK.default,vt.Ee.color.border.primary,vt.r8.medium,vt.Ee.color.shadow.medium),vat=(0,u.default)(m.g).attrs({row:!0,gap:"xsmall"}).withConfig({displayName:"PromoCodePurchaseSuccessModal__ShareContainer",componentId:"obl9mz-4"})(["padding:"," 0 ",";"],vt.YK.medium,vt.YK.xlarge),fat=Ee.mH1,Eat=(0,gZ.J)("\n  query Common_GetGiftedSubscriptions {\n    giftedSubscriptionsPurchasedByHousehold {\n      id\n      createdAt\n      recipientName\n      promoCode\n      status\n      redeemedAt\n    }\n  }\n"),yat=e=>{let t=e.className;const n=(0,Xo.IT)(Eat),l=n.data,o=n.loading,i=n.error,s=(0,Qhe.x)("purchased-gifts"),c=(null===l||void 0===l?void 0:l.giftedSubscriptionsPurchasedByHousehold)||[];return o?a.createElement(xat,{"data-external-id":"purchased-gifts",className:t},a.createElement(wat,null,a.createElement(m.g,{justifyCenter:!0,padding:"xlarge"},a.createElement(p.i,null)))):i?a.createElement(xat,{"data-external-id":"purchased-gifts",className:t,rootProps:s},a.createElement(wat,null,a.createElement(xt.v,{color:"content.secondary"},"Failed to load purchased gifts"))):0===c.length?a.createElement(xat,{"data-external-id":"purchased-gifts",className:t,rootProps:s},a.createElement(wat,null,a.createElement(xt.v,{color:"content.secondary"},"No gifts purchased yet"))):a.createElement(xat,{"data-external-id":"purchased-gifts",className:t,rootProps:s},a.createElement(wat,null,a.createElement(xt.v,{color:"content.primary",weight:"medium"},"Purchased Gifts"),a.createElement(Cat,null,c.map((e=>{const t=e.status===Ee.DJ6.READY_TO_REDEEM||e.status===Ee.DJ6.PENDING_PROMO_CODE;return a.createElement(Aat,{key:e.id},a.createElement(m.g,{column:!0,gap:"xxsmall"},a.createElement(Iat,null,a.createElement(xt.v,{color:"content.primary",weight:"medium",clampLine
1s:1},e.recipientName||"No name provided"),a.createElement(Oc.D,{color:bat(e.status)},(l=e.status,(0,r.YW)(l).with(Ee.DJ6.READY_TO_REDEEM,(()=>"Ready to redeem")).with(Ee.DJ6.PENDING_PROMO_CODE,(()=>"Pending")).with(Ee.DJ6.REDEEMED,(()=>"Redeemed")).with(Ee.DJ6.REFUNDED,(()=>"Refunded")).with(Ee.DJ6.REVOKED,(()=>"Cancelled")).otherwise((()=>(0,EA.ZH)(l)))))),a.createElement(m.g,{column:!0,gap:"small"},a.createElement(Iat,null,a.createElement(xt.v,{color:"content.secondary",size:"small"},(n=e.createdAt,new Date(n).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"}))),a.createElement(xt.v,{color:"content.secondary",size:"small"},"Code: ",e.promoCode||"Pending")),t&&e.promoCode&&a.createElement(m.g,{column:!0,alignStart:!0},a.createElement(wt.Xb,{size:"xsmall",onClick:()=>(async e=>{const t="I got you a gift! Get 1 year of Monarch for free with promo code ".concat(e.promoCode,". Sign up here: https://app.monarchmoney.com/signup?promoCode=").concat(e.promoCode);if(navigator.share)try{await navigator.share({text:t})}catch(n){navigator.clipboard.writeText(t)}else navigator.clipboard.writeText(t)})(e)},"Share")))));var n,l})))))},bat=e=>(0,r.YW)(e).with(Ee.DJ6.REDEEMED,(()=>"green")).with(r.P.union(Ee.DJ6.READY_TO_REDEEM,Ee.DJ6.PENDING_PROMO_CODE),(()=>"orange")).otherwise((()=>"grayLight")),xat=(0,u.default)(Xl.AM).withConfig({displayName:"PurchasedGifts__CardWrapper",componentId:"xu1axy-0"})(["margin-top:",";"],vt.YK.gutter),wat=(0,u.default)(m.g).attrs({column:!0}).withConfig({displayName:"PurchasedGifts__Root",componentId:"xu1axy-1"})(["gap:",";padding:"," ",";"],vt.YK.default,vt.YK.xlarge,vt.YK.xxlarge),Cat=(0,u.default)(m.g).attrs({column:!0}).withConfig({displayName:"PurchasedGifts__GiftsList",componentId:"xu1axy-2"})(["border-bottom:1px solid ",";"],vt.Ee.color.divider.primary),Aat=(0,u.default)(m.g).attrs({column:!0}).withConfig({displayName:"PurchasedGifts__GiftItem",componentId:"xu1axy-3"})(["padding:"," 0;gap:",";border-top:1px solid ",";"],vt.YK.default,vt.YK.small,vt.Ee.color.divider.primary),Iat=(0,u.default)(m.g).attrs({alignCenter:!0,justifyStart:!0}).withConfig({displayName:"PurchasedGifts__Row",componentId:"xu1axy-4"})(["gap:",";"],vt.YK.small),kat=()=>{(0,p4.n)(Ye.C8.ScreenViewed);const e=(0,l.ok)(),t=(0,o.A)(e,1)[0],n=(0,l.Zp)(),r=t.get("stripe_checkout_session_id");return a.createElement(mX.V,{"data-external-id":"gift-monarch",md:9},a.createElement(Xhe.Ay,null,a.createElement("title",null,"Gift Monarch")),a.createElement(Ffe,{title:"Gift Monarch",anchorId:"gift-monarch"},a.createElement(aat,null)),a.createElement(yat,null),r&&a.createElement(uat,{str
1ipeCheckoutSessionId:r,onClose:()=>{n("/settings/gifts",{replace:!0})}}),a.createElement(xt.v,{as:"p",size:"xsmall",color:"content.secondary",style:{lineHeight:"1.21"}},"Gift Subscriptions cost $50 and include one year of Monarch Core (at least $99.99 per year). No expiration. Purchasers or members of the same household may not redeem their own code. Recipients must create a Monarch account and add a payment method for renewal at the then-current price plus applicable taxes after the gifted term. No cash value or refunds. Taxes collected at purchase. Monarch may modify or end this offer at any time. By purchasing, you agree to Monarch's"," ",a.createElement(cl.M,{href:VF.z5},"Terms of Use")," ","and"," ",a.createElement(cl.M,{href:VF.Cz},"Gift Subscription Terms")))},Sat=u.default.div.withConfig({displayName:"FormSection",componentId:"d56fkw-0"})(["padding:",";:not(:last-child){border-bottom:1px solid ",";}"],(e=>e.theme.spacing.xlarge),vt.Ee.color.divider.primary),Nat=[{value:"AB",label:"Alberta"},{value:"BC",label:"British Columbia"},{value:"MB",label:"Manitoba"},{value:"NB",label:"New Brunswick"},{value:"NL",label:"Newfoundland and Labrador"},{value:"NS",label:"Nova Scotia"},{value:"NT",label:"Northwest Territories"},{value:"NU",label:"Nunavut"},{value:"ON",label:"Ontario"},{value:"PE",label:"Prince Edward Island"},{value:"QC",label:"Quebec"},{value:"SK",label:"Saskatchewan"},{value:"YT",label:"Yukon"}],Tat=[{value:"AL",label:"Alabama"},{value:"AK",label:"Alaska"},{value:"AZ",label:"Arizona"},{value:"AR",label:"Arkansas"},{value:"CA",label:"California"},{value:"CO",label:"Colorado"},{value:"CT",label:"Connecticut"},{value:"DC",label:"District of Columbia"},{value:"DE",label:"Delaware"},{value:"FL",label:"Florida"},{value:"GA",label:"Georgia"},{value:"HI",label:"Hawaii"},{value:"ID",label:"Idaho"},{value:"IL",label:"Illinois"},{value:"IN",label:"Indiana"},{value:"IA",label:"Iowa"},{value:"KS",label:"Kansas"},{value:"KY",label:"Kentucky"},{value:"LA",label:"Louisiana"},{value:"ME",label:"Maine"},{value:"MD",label:"Maryland"},{value:"MA",label:"Massachusetts"},{value:"MI",label:"Michigan"},{value:"MN",label:"Minnesota"},{value:"MS",label:"Mississippi"},{value:"MO",label:"Missouri"},{value:"MT",label:"Montana"},{value:"NE",label:"Nebraska"},{value:"NV",label:"Nevada"},{value:"NH",label:"New Hampshire"},{value:"NJ",label:"New Jersey"},{value:"NM",label:"New Mexico"},{value:"NY",label:"New York"},{value:"NC",label:"North Carolina"},{value:"ND",label:"North Dakota"},{value:"OH",label:"Ohio"},{value:"OK",label:"Oklahoma"},{value:"OR",label:"Oregon"},{value:"PA",label:"Pennsylvania"},{value:"RI",label:"Rhode Island"},{value:"SC",label:"South Carolina"},{value:"SD",label:"South Dakota"},{value:"TN",label:"Tennessee"},{value:"TX",label:"Texas"},{value:"UT",label:"Utah"},{value:"VT",label:"Vermont"},{value:"VA",label:"Virginia"},{value:"WA",label:"Washington"},{value:"WV",label:"West Virginia"},{value:"WI",label:"Wisconsin"},{value:"WY",label:"Wyoming"}];var _at,Dat;const Rat=()=>{const e=(0,hu.x)(),t=e.values,n=e.initialValues,l=e.resetForm,r=(0,a.useRef)(n.country);return a.createElement(a.Fragment,null,a.createElement(Sat,null,a.createElement(Qw.X,{name:"name",label:"Household Name",required:!0})),a.createElement(Sat,null,a.createElement("div",{className:"mb-default flex flex-col gap-default"},a.createElement(tC.zB.Select,{name:"country",options:z6.gH,onValueChanged:(e,n)=>(e=>{if(r.current!==e){const n=(0,U.A)((0,U.A)({},t),{},{country:e,address:"",city:"",state:"",zipCode:""});r.current=e,l({values:n})}})(null!==n&&void 0!==n?n:void 0)}),a.createElement(Qw.X,{name:"address"}),a.createElement(Qw.X,{name:"city"})),a.createElement("div",{className:"inline-flex size-full flex-1 gap-2xl"},a.createElement(Lat,{name:"state",label:t.country===z6.TP.CANADA?"Province":"State",options:t.country===z6.TP.CANADA?Nat:Tat}),a.createElement(Mat,{name:"zipCode",label:t.country===z6.TP.CANADA?"Postal Code":"Zip Code",maxLength:t.country===z6.TP.CANADA?7:5})),a.createElement(CJ.I,null,"Update Household")))},Mat=(0,$d.s)(Qw.X)(_at||(_at=(0,wc.A)(["flex-2"]))),Lat=(0,$d.s)(tC.zB.Select)(Dat||(Dat=(0,wc.A)(["flex-3"]))),Oat=()=>{var e;const t=(0,Tse._)().isDemoHousehold,n=(0,et.I)(B6.sJ),l=n.data,r=n.refetch,s=n.isLoadingInitialData,c=(0,i.n)(B6.Dr),d=(0,o.A)(c,1)[0],u=null!==(e=null===l||void 0===l?void 0:l.myHousehold)&&void 0!==e?e:{},m=u.name,g=u.address,h=u.city,v=u.state,f=u.zipCode,E=u.country,y=void 0===E?z6.jC:E,b=(0,a.useMemo)((()=>({name:m,address:g,city:h,state:v,zipCode:f,country:y})),[g,h,y,m,v,f]);return a.createElement(mX.V,{"data-external-id":"household-settings",md:9},a.createElement(Ffe,{title:"Household",isDemo:t,anchorId:"household"},a.createElement(Xhe.Ay,null,a.createElement("title",null,"Household Settings")),s?a.createElement("div",{className:"flex items-center justify-center p-xl"},a.createElement(p.i,null)):a.createElement(Eu.lV,Object.assign({initialValues:b,onSubmit:async e=>{await d({variables:{input:e}})},onSubmitSuccess:()=>{r()}},fl.TN),a.createElement(Rat,null))))},Pat=e=>{let t=e.account,n=e.onCancel,l=e.onUndelete;const r=(0,i.n)(iG.Fc,{update(){f7.S.resetStore()}}),s=(0,o.A)(r,2),c=s[0],d=s[1].loading;return a.createElement(xC.$,{"data-external-id":"undelete-account-confirmation",title:"Are you sure you want to restore this account?",confirm:"Restore account",isLoading:d,onCancel:n,onConfirm:async()=>{var e;const a=await c({variables:{input:{id:t.id}}}),r=a.data,o=a.errors;var i;null!==r&&void 0!==r&&null!==(e=r.undeleteAccount)&&void 0!==e&&e.undeleted?l():(nEe.v.error("Account was not undeleted.",o,null===r||void 0===r||null===(i=r.undeleteAccount)||void 0===i?void 0:i.errors),n())}}
1,a.createElement(Bat,null,a.createElement(xt.v,{weight:"medium"},"What will change:"),a.createElement(Fat,null,a.createElement(Gat,null,a.createElement(zat,{name:"check",size:22}),a.createElement(xt.v,null,"Account will re-appear in list")),a.createElement(Gat,null,a.createElement(zat,{name:"check",size:22}),a.createElement(xt.v,null,"Transactions will resume syncing")),a.createElement(Gat,null,a.createElement(zat,{name:"check",size:22}),a.createElement(xt.v,null,"Balances will start being tracked again")))))},Bat=u.default.div.withConfig({displayName:"UndeleteAccountConfirmation__Content",componentId:"sc-1bo9cec-0"})(["padding:",";background-color:",";border-radius:",";"],(e=>e.theme.spacing.xlarge),(e=>e.theme.color.grayBackground),(e=>e.theme.radius.medium)),zat=(0,u.default)(sl.ZQ).withConfig({displayName:"UndeleteAccountConfirmation__StyledIcon",componentId:"sc-1bo9cec-1"})(["display:inline-block;margin-right:",";margin-top:",";"],(e=>e.theme.spacing.default),(e=>e.theme.spacing.xxxsmall)),Fat=u.default.ul.withConfig({displayName:"UndeleteAccountConfirmation__List",componentId:"sc-1bo9cec-2"})(["padding-left:0;"]),Gat=u.default.li.withConfig({displayName:"UndeleteAccountConfirmation__ListItem",componentId:"sc-1bo9cec-3"})(["display:flex;align-items:start;margin-bottom:",";"],(e=>e.theme.spacing.default));var Yat=n(25859);const Uat=e=>e.filter((e=>!e.deletedAt)).map((e=>{let t=e.id,n=e.displayName,a=e.subtype,l=e.mask;return{id:t,displayName:n,subtypeDisplay:null===a||void 0===a?void 0:a.display,mask:l}}));var Vat=n(52480),Wat=n(44813);const jat=()=>{const e=(0,l.Zp)();(()=>{const e=(0,d.wA)(),t="true"===(0,b.pE)("enableSwitchProvider");(0,a.useEffect)((()=>{t&&e((0,Wat.d0)({flag:"feat-dp-switching-web",treatment:d4.LH.On}))}),[t,e])})();const t=(0,et.I)(tlt),n=t.data,r=t.isLoadingInitialData,i=t.refetch,s=(e=>{let t=e.skip;const n=bq({skip:t}).recommendations;return(0,a.useMemo)((()=>new Map(n.map((e=>[e.credentialId,e])))),[n])})({skip:!(0,nG.p)("feat-dp-switching-institution_recommendation-web","off")}),c=(0,nC.xd)(),u=(0,o.A)(c,1)[0].users,m=1===(null===u||void 0===u?void 0:u.length),g=(0,Pd.h)(),h=(0,o.A)(g,2),v=h[0],f=h[1],E=f.open,y=f.close,x=(n||{}).subscription||{},w=x.hasPremiumEntitlement,A=x.isOnFreeTrial,k=(0,a.useState)(),S=(0,o.A)(k,2),N=S[0],T=S[1],_=(0,a.useState)(),D=(0,o.A)(_,2),R=D[0],M=D[1],L=(0,Pd.h)(),O=(0,o.A)(L,2),B=O[0],z=O[1],F=z.close,G=z.open,Y=(0,a.useMemo)((()=>[...((null===n||void 0===n?void 0:n.accounts)||[]).filter((e=>!e.deletedAt)),...((null===n||void 0===n?void 0:n.accounts)||[]).filter((e=>e.deletedAt))]),[null===n||void 0===n?void 0:n.accounts]);return a.createElement(mX.V,{"data-external-id":"institution-settings",md:9},a.createElement(Xhe.Ay,null,a.createElement("title",null,"Institutions Settings")),a.createElement(Ffe,{title:"Institutions",anchorId:"institutions",controls:a.createElement($at,null,a.createElement(YH,{source:oV.MS.WebInstitutionSettings}),(w||A)&&a.createElement(cu.WT,{onClick:()=>e(I.JZ.settings.institutions.addAccount()),size:"small"},"Add account"))},a.createElement(Hat,null)),r?a.createElement(Kat,null,a.createElement(p.i,null)):(0,Vat.tY)((null===n||void 0===n?void 0:n.credentials)||[]).map((e=>{const t=Y.filter((t=>{let n=t.credential;return(null===n||void 0===n?void 0:n.id)===e.id}));return a.createElement(Zat,{credential:e,refetch:i,key:e.id,accountCount:t.length,accounts:Uat(t),dpSwitchRecommendation:s.get(e.id)},t.map((t=>{var n,l,r,o,i,s;return a.createElement("div",{key:t.id,className:" flex size-full flex-1 items-center border-t border-divider-primary px-xl py-default "},a.createElement("div",{className:"flex flex-3 items-center"},a.createElement("div",{className:"flex flex-2 flex-col gap-3xs"},a.createElement("div",{className:"flex items-center gap-xs"},a.createElement(Jat,{$isDeleted:(0,Tr.A)(t.deletedAt),$isHidden:null!==(n=t.hideFromList)&&void 0!==n&&n},t.displayName),t.hideFromList&&a.createElement(JY.d,{content:"This account is hidden from your Accounts page"},a.createElement(Qat,null,a.createElement(elt,null)))),a.createElement(Jat,{color:"textLight",size:"small",$isDeleted:(0,Tr.A)(t.deletedAt),$isHidden:null!==(l=t.hideFromList)&&void 0!==l&&l},t.subtype.display," ",t.mask),a.createElement(Jat,{color:"textLight",size:"small",$isDeleted:(0,Tr.A)(t.deletedAt),$isHidden:null!==(r=t.hideFromList)&&void 0!==r&&r},"Added to Monarch on"," ",new Date(t.createdAt).toLocaleDateString("en-US",{month:"2-digit",day:"2-digit",year:"numeric"}))),a.createElement("div",{className:"flex flex-1"},!t.deletedAt&&!m&&a.createElement(Pw.n,{userId:null===(o=t.ownedByUser)||void 0===o?void 0:o.id,userName:null===(i=t.ownedByUser)||void 0===i?void 0:i.displayName,userProfilePictureUrl:null===(s=t.ownedByUser)||void 0===s?void 0:s.profilePictureUrl}))),a.createElement("div",{className:"flex flex-2 items-center"},!t.deletedAt&&a.createElement(P.D_,{content:a.createElement(a.Fragment,null,"The last time Monarch requested data from the Data Provider and the",a.createElement("br",null),"attempt was successful (this doesn't mean the data provider had new data)")},a.createElement(xt.v,{size:"small",color:"content.secondary"},"Monarch synced with ",(0,oq.M)(e.dataProvider)," ",a.createElement(roe.T,{short:!0,date:t.displayLastUpdatedAt})," ago")),a.createElement(Xat,null,t.deletedAt&&a.createElement(wt.Xb,{onClick:()=>{T(t),E()}},"Undelete"),!t.deletedAt&&a.createElement(a.Fragment,null,a.createElement(wt.Xb,{linkTo:I.JZ.accounts.accountDetails({id:t.id})},"View"),a.createElement(wt.Xb,{onClick:()=>{M(t.id),G()}},"Edit")))))})))})),N&&a.createElement(v,null,a.createElement(Pat,{account:N,onCancel:y,onUndelete:()=>{T(null),(0,C.oR)({title:"Undeleted account ".concat(N.displayName),description:"It will re-appear on the accounts list and start syncing again."}),i()}})),R&&a.createElement(B,null,a.createElement(XY.r,{accountId:R,onDone:()=>{F()},onClose:F})),a.createElement(XU.l,{path:I.JZ.settings.institutions.addAccount.relativePath},(e=>{let t=e.close;return a.createElement(SF.E,{onComplete:()=>{i(),t()},onClose:t})})))},Hat=()=>a.createElement(qat,{"data-external-id":"institutions-description"},"Link all of your financial accounts to get a complete view of your finances. For more information about institutions we connect to check out our"," ",a.createElement(wb.gz,{href:VF.k4,target:"_blank"},"help center"),"."),Kat=(0,u.default)(m.g).attrs({center:!0}).withConfig({displayName:"InstitutionSettings__SpinnerContainer",componentId:"am8v98-0"})(["margin:"," 0;"],vt.YK.xlarge),qat=u.default.p.withConfig({displayName:"InstitutionSettings__HeaderDescription",componentId:"am8v98-1"})(["padding:0 ",";"],vt.YK.large),$at=(0,u.default)(m.g).withConfig({displayName:"InstitutionSettings__Controls",componentId:"am8v98-2"})(["gap:",";"],vt.YK.xsmall),Zat=(0,u.default)(Yat.T).withConfig({displayName:"InstitutionSettings__StyledCredentialSettingsCard",componentId:"am8v98-3"})(["margin-top:",";min-width:768px;"],vt.YK.gutter),Jat=(0,u.default)(xt.v).withConfig({displayName:"InstitutionSettings__InstitutionAccountDetailsText",componentId:"am8v98-4"})(["opacity:",";text-decoration:",";"],(e=>{let t=e.$isDeleted,n=e.$isHidden;return t||n?.5:1}),(e=>e.$isDeleted?"line-through":"none")),Xat=(0,u.default)(m.g).withConfig({displayName:"InstitutionSettings__InstitutionAccountControls",componentId:"am8v98-5"})(["gap:",";margin-left:auto;"],vt.YK.xsmall),Qat=u.default.span.withConfig({displayName:"InstitutionSettings__IconWrapper",componentId:"am8v98-6"})(["display:inline-flex;align-items:center;margin-left:",";"],vt.YK.xxsmall),elt=(0,u.default)(sl.ZQ).attrs({name:"eye-off",size:14}).withConfig({displayName:"InstitutionSettings__HiddenAccountIcon",componentId:"am8v98-7"})(["opacity:0.5;"]),tlt=Ee.aeb;
1var nlt=n(32341);const alt=e=>{let t=e.open,n=e.hoverable,l=void 0!==n&&n,r=e.className;const o=l?(0,nlt.O9)({variant:"default",size:"sm",className:"pointer-events-none shrink-0 group-hover:border-border-primary-hover"}):"shrink-0";return a.createElement("span",{"data-external-id":"collapse-chevron",className:(0,q.cn)(o,"text-content-secondary",r)},a.createElement(fe.hPJ,{size:"md",className:(0,q.cn)("transition-transform",t&&"rotate-90")}))},llt="https://monarchmoney.notion.site/MCP-Connector-3753eb694d0f80b0a81cd26edc316325",rlt="pl-md pr-xl",olt=e=>{let t=e.title,n=e.count,l=e.color,r=e.defaultOpen,i=void 0!==r&&r,s=e.anchorId,c=e.children;const d=(0,a.useState)(i),u=(0,o.A)(d,2),m=u[0],p=u[1],g=(0,Qhe.x)(s);return a.createElement(fe.X0s,Object.assign({"data-external-id":"coverage-section",open:m,onOpenChange:p,className:"border-t border-divider-primary"},g),a.createElement(fe.X0s.Trigger,{className:"group flex w-full items-center justify-start gap-sm py-default ".concat(rlt)},a.createElement(alt,{open:m,hoverable:!0,className:"-mr-2xs"}),a.createElement(fe.c8D,{size:"lg",weight:"medium"},t),a.createElement(fe.CQG,{color:l,variant:"subtle",rounded:"pill",size:"md",preferCircle:!0},n)),a.createElement(fe.X0s.Content,null,a.createElement("div",{className:"flex flex-col"},c)))},ilt=e=>{var t;let n=e.account,l=e.logo;const r=[null===(t=n.subtype)||void 0===t?void 0:t.display,n.mask?"- ".concat(n.mask):null].filter(Boolean).join(" ");return a.createElement("div",{"data-external-id":"account-row",className:"flex items-center gap-sm border-t border-divider-primary py-xs pr-xl ".concat("pl-[110px]")},a.createElement(aq.i,{logo:l,size:20}),a.createElement(fe.c8D,{size:"sm",className:"min-w-0 flex-1 truncate"},n.displayName),r?a.createElement(fe.c8D,{size:"sm",color:"secondary",className:"shrink-0"},r):null)},slt=e=>{let t=e.compatible,n=e.canSwitchProvider,l=e.isPlaidOnly,r=e.onSwitchProvider;return t?a.createElement("span",{"data-external-id":"credential-row-trailing-action",className:"flex size-6 shrink-0 items-center justify-center rounded-round bg-background-success text-content-success"},a.createElement(fe.GdR,{size:"2xs"})):n?a.createElement(fe.XZZ,{"data-external-id":"credential-row-trailing-action",variant:"default",size:"sm",className:"shrink-0",onClick:r},"Switch provider"):l?a.createElement(fe.Yvj,{"data-external-id":"credential-row-trailing-action",content:"This institution is only available on Plaid at the moment.",side:"left",size:"3xs",sideOffset:10},a.createElement("span",{className:"shrink-0"},a.createElement(fe.XZZ,{variant:"default",size:"sm",disabled:!0},"Switch provider"))):null},clt=e=>{var t,n;let l=e.group,r=e.compatible,i=e.isMultiMemberHousehold,s=e.onSwitched;const c=(0,a.useState)(!1),d=(0,o.A)(c,2),u=d[0],m=d[1],p=l.credential,g=l.activeAccounts,h=null!==(t=p.institution.logo)&&void 0!==t?t:"",v=g.map((e=>{var t;return{id:e.id,displayName:e.displayName,subtypeDisplay:null===(t=e.subtype)||void 0===t?void 0:t.display,mask:e.mask}})),f=(0,rq.b)({credential:p,accounts:v,refetch:s,entryPoint:"mcp_coverage_row"}),E=(0,o.A)(f,2),y=E[0],b=E[1],x=b.canSwitchProvider,w=b.switchTargets,C=b.open,A=!p.institution.newConnectionsDisabled&&0===w.length,I=null===(n=p.user)||void 0===n?void 0:n.displayName;let k="".concat((0,oq.M)(p.dataProvider)," \xb7 ").concat((0,De.td)("account",g.length,{inclusive:!0}));return i&&I&&(k+=" \xb7 Connected by ".concat(I)),a.createElement(fe.X0s,{"data-external-id":"credential-row",open:u,onOpenChange:m,className:"border-t border-divider-primary"},a.createElement("div",{className:"group flex items-center gap-default py-default ".concat(rlt)},a.createElement(fe.X0s.Trigger,{className:"flex min-w-0 flex-1 items-center justify-start gap-default text-left"},a.createElement(alt,{open:u,hoverable:!0,className:"-mr-xs"}),a.createElement(aq.i,{logo:h,size:36}),a.createElement("div",{className:"flex min-w-0 flex-col"},a.createElement(fe.c8D,{className:"truncate"},p.institution.name),a.createElement(fe.c8D,{size:"sm",color:"secondary",className:"truncate"},k))),a.createElement(slt,{compatible:r,canSwitchProvider:x,isPlaidOnly:A,onSwitchProvider:C})),a.createElement(fe.X0s.Content,null,a.createElement("div",{className:"flex flex-col"},g.map((e=>a.createElement(ilt,{key:e.id,account:e,logo:h}))))),y)},dlt=e=>!e.deactivatedAt&&!e.deletedAt,ult=Ee.r$M,mlt=()=>{var e;const t=(0,nG.p)("feat-integration-mcp-dp-switching-web","off"),n=(0,nG.p)("feat-dp-switching-web","off"),l=t&&n,r=(0,et.I)(ult,{skip:!l}),i=r.data,s=r.isLoadingInitialData,c=r.error,d=r.refetch,u=(0,nC.xd)({skip:!l}),m=(0,o.A)(u,1)[0].users,p=(null!==(e=null===m||void 0===m?void 0:m.length)&&void 0!==e?e:0)>1,g=(0,a.useMemo)((()=>{var e,t;const n=new Map;(null!==(e=null===i||void 0===i?void 0:i.accounts)&&void 0!==e?e:[]).forEac
1h((e=>{var t,a;const l=null===(t=e.credential)||void 0===t?void 0:t.id;if(!l)return;const r=null!==(a=n.get(l))&&void 0!==a?a:[];r.push(e),n.set(l,r)}));const a=[],l=[],r=[];(null!==(t=null===i||void 0===i?void 0:i.credentials)&&void 0!==t?t:[]).forEach((e=>{var t;const o=null!==(t=n.get(e.id))&&void 0!==t?t:[];if(0===o.length)return;const i=o.filter(dlt),s={credential:e,activeAccounts:i,closedAccountCount:o.length-i.length};0===i.length?r.push(s):e.dataProvider!==Ee.lnV.PLAID?a.push(s):l.push(s)}));const o=a.reduce(((e,t)=>e+t.activeAccounts.length),0),s=l.reduce(((e,t)=>e+t.activeAccounts.length),0);return{compatible:a,incompatible:l,inactive:r,availableCount:o,totalCount:o+s,closedAccountCount:r.reduce(((e,t)=>e+t.closedAccountCount),0)}}),[i]);return(0,U.A)({isEnabled:l,isLoading:s,error:i?void 0:c,refetch:d,isMultiMemberHousehold:p},g)},plt=()=>{const e=mlt(),t=e.isEnabled,n=e.isLoading,l=e.error,r=e.refetch,o=e.isMultiMemberHousehold,i=e.compatible,s=e.incompatible,c=e.inactive,d=e.availableCount,u=e.totalCount,m=e.closedAccountCount;if(!t)return null;if(n)return a.createElement(Ffe,{"data-external-id":"mcp-coverage-card",className:"mb-gutter"},a.createElement("div",{className:"flex flex-col gap-xs p-xl"},a.createElement(fe.wME,{className:"h-6 w-2/3"}),a.createElement(fe.wME,{className:"h-4 w-full"}),a.createElement(fe.wME,{className:"h-4 w-1/3"})));if(l)return a.createElement(Ffe,{"data-external-id":"mcp-coverage-card",className:"mb-gutter"},a.createElement("div",{className:"p-xl"},a.createElement(SQ.W,null)));if(0===u)return null;const p=0===s.length,g=[{key:"incompatible",title:"Incompatible with MCP",anchorId:"incompatible-with-mcp",color:"yellow",groups:s,defaultOpen:!0,compatible:!1},{key:"compatible",title:"Compatible with MCP",anchorId:"compatible-with-mcp",color:"green",groups:i,defaultOpen:!1,compatible:!0}];return a.createElement(Ffe,{"data-external-id":"mcp-coverage-card",className:"mb-gutter",anchorId:"mcp-coverage"},a.createElement("div",{className:"flex flex-col gap-xs p-xl"},a.createElement("div",{className:"flex items-center gap-xs"},a.createElement(fe.c8D,{size:"20",weight:"medium"},p?"All ".concat((0,De.td)("account",u,{inclusive:!0})," ").concat(1===u?"is":"are"," available to the MCP"):"Only ".concat(d," of ").concat((0,De.td)("account",u,{inclusive:!0})," ").concat(1===d?"is":"are"," available to the MCP")),!p&&a.createElement("span",{className:"relative flex size-4 shrink-0"},a.createElement(fe.ADS,{size:"md",className:"absolute inset-0 text-background-warning"}),a.createElement(fe.WU2,{size:"md",className:"absolute inset-0 text-content-warning"}))),a.createElement(fe.c8D,{size:"sm",color:"secondary",className:"whitespace-pre-line"},p?"Every connection is compatible with the MCP.\nYour connected tools can now see all of your active accounts in Monarch.":"Some of your accounts aren\u2019t compatible with the MCP and won\u2019t be able to see data in those accounts.\nSwitch each institution to another data provider to close the gap."," ",a.createElement(fe.liZ,{href:llt,external:!0,size:"sm",weight:"medium"},"Learn more"))),g.filter((e=>e.groups.length>0)).map((e=>a.createElement(olt,{key:e.key,title:e.title,anchorId:e.anchorId,count:e.groups.length,color:e.color,defaultOpen:e.defaultOpen},e.groups.map((t=>a.createElement(clt,{key:t.credential.id,group:t,compatible:e.compatible,isMultiMemberHousehold:o,onSwitched:r})))))),c.length>0&&a.createElement("div",{className:"border-t border-divider-primary p-xl"},a.createElement(fe.c8D,{size:"sm",color:"secondary"},"".concat((0,De.td)("inactive connection",c.length,{inclusive:!0})," with ").concat((0,De.td)("closed account",m,{inclusive:!0})," ").concat(1===c.length?"isn\u2019t":"aren\u2019t"," included in MCP data.")," ",a.createElement(Vl.W,{to:I.JZ.settings.institutions(),weight:"medium"},"View inactive connections"))))},glt="https://api.monarch.com/mcp",hlt="Couldn\u2019t copy. Press ".concat(x7.Ue?"\u2318C":"Ctrl+C"," to copy manually."),vlt="https://monarch-static-assets-us-east-2.s3.us-east-2.amazonaws.com/mcp",flt=[{id:"claude-desktop",label:"Claude Desktop",logo:"".concat(vlt,"/claude-100px.png"),docsLabel:"Claude's",docsUrl:"https://support.anthropic.com/en/articles/11175166-getting-started-with-custom-connectors-using-remote-mcp"},{id:"claude-code",label:"Claude Code",logo:"".concat(vlt,"/claude-code-100px.png"),docsLabel:"Claude Code's",docsUrl:"https://docs.claude.com/en/docs/claude-code/mcp"},{id:"gemini-cli",label:"Gemini CLI",logo:"".concat(vlt,"/gemini-100px.png"),docsLabel:"Gemini's",docsUrl:"https://google-gemini.github.io/gemini-cli
1/docs/tools/mcp-server.html"},{id:"cursor",label:"Cursor",logo:"".concat(vlt,"/cursor-100px.png"),docsLabel:"Cursor's",docsUrl:"https://cursor.com/docs/mcp"},{id:"chatgpt",label:"ChatGPT",logo:"".concat(vlt,"/chatgpt-100px.png"),banner:"This connection is web only and requires ChatGPT Plus, Pro, Business, Enterprise or Education plan.",docsLabel:"ChatGPT's",docsUrl:"https://help.openai.com/en/articles/12584461-developer-mode-and-mcp-apps-in-chatgpt"}],Elt=()=>{var e;const t=(0,a.useState)("claude-desktop"),n=(0,o.A)(t,2),l=n[0],r=n[1],s=(0,a.useState)("idle"),c=(0,o.A)(s,2),d=c[0],u=c[1],m=(0,nG.p)("feat-mcp-paused","on"),p=(0,C.RU)(),g=(0,et.I)(Clt),h=g.data,v=g.refetch,f=null!==(e=null===h||void 0===h?void 0:h.connectedApps)&&void 0!==e?e:[],E=(0,qG.e)(),y=E.hasPlusAccess,b=E.isLoading,x=(0,eY.z)(),w=(0,i.n)(Alt),A=(0,o.A)(w,1)[0],k=(0,Qhe.x)("server-url"),S=(0,Qhe.x)("connect-to"),N=Math.max(0,flt.findIndex((e=>e.id===l))),T=flt[N];return a.createElement(mX.V,{"data-external-id":"integrations-settings",md:9},a.createElement(Xhe.Ay,null,a.createElement("title",null,"Integrations")),a.createElement(plt,null),a.createElement(Ffe,{title:"Integration Setup",anchorId:"integration-setup",className:"mb-gutter"},m?a.createElement($fe,null,a.createElement("div",{className:"flex w-full flex-col gap-4 text-content-primary"},a.createElement("div",{className:"flex items-center gap-xs"},a.createElement(fe.WU2,{size:"md",className:"shrink-0 text-content-warning"}),a.createElement("p",{className:"m-0"},"The Monarch MCP is temporarily paused while we work through an agreement with one of our partners related to data portability. We\u2019re working to restore access soon. As soon as the MCP is available again, you\u2019ll see instructions for connecting the MCP on this page.")),a.createElement(wb.gz,{href:"https://help.monarch.c
1om/hc/en-us/articles/50207234679956-Monarch-MCP-Connector",target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 self-start"},"Learn more",a.createElement(fe.Fug,{size:"md"})))):a.createElement(a.Fragment,null,a.createElement($fe,null,a.createElement("div",{className:"flex w-full flex-col gap-4 text-content-primary"},a.createElement("p",{className:"m-0"},"Bring your tools like Claude, ChatGPT, or Cursor into Monarch so they can access your data and help you make sense of your finances. The first time you connect a tool, you\u2019ll be asked to confirm access."),a.createElement("p",{className:"m-0"},a.createElement(wb.gz,{href:llt,target:"_blank",rel:"noopener noreferrer",underlined:!0},"Visit our Help Center")," ","for more guidance and information about Monarch Integration setup and how to use these connected tools."))),a.createElement($fe,null,a.createElement("div",{className:"flex w-full flex-col gap-4"},a.createElement("div",Object.assign({className:"flex flex-col gap-2"},k),a.createElement("div",{className:"font-medium text-content-primary"},"Monarch Server URL"),a.createElement("div",{className:"flex items-center gap-2 rounded-sm bg-background-secondary px-sm py-xs"},a.createElement("div",{className:"flex-1 overflow-x-auto font-mono text-sm whitespace-nowrap text-content-primary"},glt),a.createElement(P.D_,{open:"idle"!==d||void 0,content:ylt(d,"Copy URL","Link copied")},a.createElement(B.L,{icon:"copied"===d?"check":"copy",size:"xsmall",onClick:async()=>{const e=await(async e=>{try{return await(0,Bd.l)(e),!0}catch(t){return!1}})(glt);u(e?"copied":"error"),setTimeout((()=>u("idle")),2e3)}})))),a.createElement("div",Object.assign({className:"flex flex-col gap-2"},S),a.createElement(Dc.t,{index:N,onChangeIndex:e=>{r(flt[e].id)}},a.createElement("div",{className:"flex flex-wrap items-center gap-2"},a.createElement("div",{className:"font-medium text-content-primary"},"Connect to"),a.createElement(MA.c,null,flt.map(((e,t)=>a.createElement(RA.Q,{key:e.id,index:t,$background:"card"},e.label)))))),T.banner&&a.createElement("div",{className:" mt-4.5 flex items-center gap-sm rounded-sm bg-background-info px-default py-sm text-sm text-content-info "},a.createElement(fe.ucZ,{size:"md",className:"shrink-0"}),a.createElement("span",null,T.banner)),a.createElement(wb.gz,{href:T.docsUrl,target:"_blank",rel:"noopener noreferrer",className:"mt-4.5 inline-flex items-center gap-1 self-start"},"Visit ",T.docsLabel," setup guide for instructions",a.createElement(fe.bYN,{size:"md"}))))))),!m&&!b&&!y&&a.createElement(Ffe,{title:"Usage limits",anchorId:"usage-limits",className:"mb-gutter"},a.createElement($fe,null,a.createElement("div",{className:"flex w-full flex-col gap-2 text-content-primary"},a.createElement("p",{className:"m-0"},"Up to ",5," writes per day."," ",a.createElement(Vl.W,{to:I.JZ.settings.billing.subscribe(),className:"underline",onClick:()=>x("IntegrationsSettings")},"Upgrade to Plus")," ","to remove this restriction."),a.createElement("p",{className:"m-0 text-sm text-content-secondary"},"Other fair usage rate limits may apply.")))),a.createElement(Ffe,{title:"Connected tools",anchorId:"connected-tools"},f.map((e=>{var t;const n=!!e.revokedAt,l=n?"Revoked ".concat(blt(null!==(t=e.revokedAt)&&void 0!==t?t:null)," \xb7 Authorized ").concat(blt(e.authorizedAt)).concat(e.lastUsedAt?" \xb7 Last active ".concat(blt(e.lastUsedAt)):""):"Authorized ".concat(blt(e.authorizedAt)).concat(e.lastUsedAt?" \xb7 Last active ".concat(blt(e.lastUsedAt)):"").concat(e.scopes.length>0?" \xb7 ".concat(e.scopes.join(", ")):""),r=wlt(e.name);return a.createElement($fe,{key:e.id},a.createElement("div",{className:"flex items-center gap-4"},r?a.createElement("img",{src:r,alt:"",className:"size-12 shrink-0 rounded-full object-cover"}):a.createElement("div",{className:" flex size-12 shrink-0 items-center justify-center rounded-full bg-background-secondary text-xl font-medium text-content-secondary "},e.name.trim().charAt(0).toUpperCase()),a.createElement("span",null,a.createElement(Zfe,{title:e.name,description:l}))),a.createElement("span",null,a.createElement(G7.jI,{size:"small",onClick:()=>(async e=>{try{const t=(await A({variables:{input:{id:e}}})).data;
1(0,_we.K_)(t),v()}catch(t){p({description:"Failed to revoke app. Please try again."})}})(e.id),disabled:n},n?"Revoked":"Revoke")))})),0===f.length&&a.createElement($fe,null,a.createElement("div",{className:"flex w-full flex-col items-center py-12 text-center text-content-primary"},a.createElement("span",{className:"font-bold"},"No tools connected"),a.createElement("span",null,m?"Connecting new tools is temporarily paused. Once access is restored, you\u2019ll be able to link your first tool here.":"Choose your tool above and follow its setup guide to link your first tool to Monarch.")))))},ylt=(e,t,n)=>"copied"===e?n:"error"===e?hlt:t,blt=e=>e?new Date(e).toLocaleDateString(void 0,{month:"short",day:"numeric",year:"numeric"}):"Never",xlt=e=>e.toLowerCase().replace(/[^a-z0-9]/g,""),wlt=e=>{var t;return null===(t=(e=>{const t=xlt(e);return[...flt].sort(((e,t)=>t.label.length-e.label.length)).find((e=>t.includes(xlt(e.label))))})(e))||void 0===t?void 0:t.logo},Clt=Ee.isD,Alt=Ee.xTQ;var Ilt=n(43625),klt=n(88885),Slt=n(3660),Nlt=n(46591);const Tlt=e=>{let t=e.name,n=e.email,l=e.onCancel,o=e.disabled,i=e.isTryingToRemoveSelf;const s=(t||n||"").trim(),c=(0,hu.x)().values,d=o||(0,EA.PO)(c.memberNameConfirmation).toLowerCase()!==(0,EA.PO)(s).toLowerCase(),u=(0,r.YW)(i).with(!0,(()=>({title:_t.kH.REMOVE_SELF.TITLE,description:_t.kH.REMOVE_SELF.DESCRIPTION,listItems:_t.kH.REMOVE_SELF.LIST_ITEMS}))).otherwise((()=>({title:_t.kH.REMOVE_MEMBER.TITLE,description:_t.kH.REMOVE_MEMBER.DESCRIPTION(s),listItems:_t.kH.REMOVE_MEMBER.LIST_ITEMS}))),m=u.title,p=u.description,g=u.listItems;return a.createElement(Rc.L,{"data-external-id":"delete-member-modal-inner-form",title:m},a.createElement("div",{className:"flex flex-col gap-xl p-lg"},a.createElement(Ll.o,null,p),a.createElement(Nlt.hs,{title:_t.kH.REMOVE_MEMBER.LIST_TITLE},g.map((e=>a.createElement(Nlt.ci,{key:"string"===typeof e?e:e(s),icon:a.createElement(fe.QqB,{size:"xl"})},a.createElement(Ll.o,null,"string"===typeof e?e:e(s)))))),a.createElement(Qw.X,{name:"memberNameConfirmation",label:'Type "'.concat(s,'" to confirm deletion'),required:!0})),a.createElement(Cq.R,null,a.createElement(wt.Xb,{onClick:l,disabled:o},"Cancel"),a.createElement(CJ.I,{size:"small",disabled:d},_t.kH.REMOVE_MEMBER.SUBMIT_BUTTON)))},_lt=e=>{let t=e.memberInfo,n=t.id,r=t.name,s=t.email,c=t.isTryingToRemoveSelf,d=e.onClose,u=e.onDeleteSuccess;const m=(0,C.RU)(),p=(0,pG.w)(),h=(0,l.Zp)(),v=(0,i.n)(Dlt),f=(0,o.A)(v,2),E=f[0],y=f[1].loading,b=(0,a.useState)(!1),x=(0,o.A)(b,2),w=x[0],A=x[1];return w?a.createElement(Slt.A,{"data-external-id":"delete-member-modal",title:"",dismissText:"Done",onDismiss:d},a.createElement("div",{className:"flex size-full flex-1 flex-col items-center justify-center gap-lg"},a.createElement(f4.R,{size:80}),a.createElement(oPe.HM,null,"".concat(r||s," was removed from your household")))):a.createElement(Eu.lV,{"data-external-id":"delete-member-modal",initialValues:{memberNameConfirmation:""},onSubmit:e=>{E({variables:{input:{userId:n}},onError:()=>{m({description:_t.kH.REMOVE_MEMBER.ERROR_MESSAGE})},onCompleted:e=>{var t;null!==(t=e.deleteUserFromHousehold)&&void 0!==t&&t.deleted?(A(!0),c&&(p((0,g.ri)()),h("".concat(I.JZ.login(),"?message=userDeletedFromHousehold"))),u()):m({description:_t.kH.REMOVE_MEMBER.ERROR_MESSAGE})}})},isInitialValid:!1},a.createElement(Tlt,{name:r,email:s,isTryingToRemoveSelf:c,onCancel:d,disabled:y}))},Dlt=Ee.iLj,Rlt=e=>{let t=e.member,n=e.showMfa,l=void 0===n||n;const r=t.id,o=t.name,i=t.displayName,s=t.email,c=t.profilePictureUrl,d=t.householdRole,u=t.hasMfaOn,m=d===Ee.f0h.OWNER?"Admin":"Member";return a.createElement("div",{"data-external-id":"member-info-display",className:"flex min-w-0 items-center"},a.createElement(Pw.n,{userId:r,userName:i,userProfilePictureUrl:c,avatarSize:60,showLabel:!1}),a.createElement("div",{className:"mx-default flex min-w-0 flex-col"},a.createElement("div",{className:"flex min-w-0 items-center gap-xs"}
1,a.createElement(xt.v,{size:"large",weight:"medium",clampLines:1},o),a.createElement(Oc.D,{color:"grayLight",variant:"subtle"},m)),a.createElement(xt.v,{color:"content.secondary",clampLines:1},s),l&&u&&a.createElement("div",{className:"flex items-center"},a.createElement(Mlt,{size:"small",weight:"medium"},a.createElement(mie.FiLock,{size:12})," Multi-factor authentication enabled"))))},Mlt=(0,u.default)(xt.v).withConfig({displayName:"MemberInfoDisplay__MfaText",componentId:"sc-2nic8s-0"})(["color:",";padding-top:2px;"],vt.Ee.color.content.success),Llt=e=>{var t,n,l,r,s,c,d;let u=e.member,m=e.onClose,p=e.onDeleteMember,g=e.currentUserId,h=e.currentUserIsOwner;const v="OWNER"===u.householdRole,f=u.id===g,E=h?!f:f,y=(0,i.n)(Plt),b=(0,o.A)(y,2),x=b[0],w=b[1].loading,A=(0,C.RU)(),I={birthday:null===(t=u.financialProfile)||void 0===t?void 0:t.birthday,numberOfDependents:null===(n=u.financialProfile)||void 0===n?void 0:n.numberOfDependents,relationshipToOwner:null===(l=u.financialProfile)||void 0===l?void 0:l.relationshipToOwner,grossAnnualIncome:null===(r=u.financialProfile)||void 0===r?void 0:r.grossAnnualIncome,employmentStatus:null===(s=u.financialProfile)||void 0===s?void 0:s.employmentStatus,taxFilingStatus:null===(c=u.financialProfile)||void 0===c?void 0:c.taxFilingStatus};return a.createElement(um.b,{"data-external-id":"edit-member-modal",onClose:m},a.createElement(Rc.L,{title:_t.kH.EDIT_MEMBER.TITLE},a.createElement(Eu.lV,{initialValues:I,onSubmit:async e=>{var t,n,a,l,r,o,i,s,c;const d=null===(i=(await x({variables:{input:{userId:u.id,birthday:null!==(t=e.birthday)&&void 0!==t?t:null,numberOfDependents:null!==(n=e.numberOfDependents)&&void 0!==n?n:null,grossAnnualIncome:null!==(a=e.grossAnnualIncome)&&void 0!==a?a:null,relationshipToOwner:null!==(l=e.relationshipToOwner)&&void 0!==l?l:null,employmentStatus:null!==(r=e.employmentStatus)&&void 0!==r?r:null,taxFilingStatus:null!==(o=e.taxFilingStatus)&&void 0!==o?o:null}}})).data)||void 0===i||null===(s=i.updateUserFinancialProfile)||void 0===s||null===(c=s.errors)||void 0===c?void 0:c.message;d?A({description:d}):((0,C.oR)({title:_t.kH.EDIT_MEMBER.TOAST.SUCCESS.TITLE,description:_t.kH.EDIT_MEMBER.TOAST.SUCCESS.DESCRIPTION}),m())},onError:()=>{A({description:_t.kH.EDIT_MEMBER.TOAST.ERROR.DESCRIPTION})}},a.createElement("div",{className:"flex flex-col gap-xl p-xl"},a.createElement(Rlt,{member:u,showMfa:!1}),a.createElement(Olt,{className:"flex flex-col gap-default"},a.createElement(tC.zB.Date,{name:"birthday",label:_t.kH.EDIT_MEMBER.FIELDS.BIRTHDAY,dateFormat:iC.yP,min:aC,max:null!==(d=N.c9.now().toISODate())&&void 0!==d?d:void 0}),v&&a.createElement(tC.zB.Number,{name:"numberOfDependents","data-external-id":"numeric-input",label:_t.kH.EDIT_MEMBER.FIELDS.NUMBER_OF_DEPENDENTS,format:{maximumFractionDigits:0},min:0}),!v&&a.createElement(tC.zB.Select,{name:"relationshipToOwner",label:_t.kH.EDIT_MEMBER.FIELDS.RELATIONSHIP_TO_ADMIN,options:oC})),a.createElement("div",{className:"flex flex-col gap-lg"},a.createElement(xt.v,{size:"small",color:"content.secondary"},_t.kH.EDIT_MEMBER.FINANCIAL_PROFILE_DESCRIPTION),a.createElement("div",{className:"flex flex-col gap-default"},a.createElement(tC.zB.Currency,{name:"grossAnnualIncome",label:_t.kH.EDIT_MEMBER.FIELDS.GROSS_ANNUAL_INCOME,precision:0,min:0}),a.createElement(tC.zB.Select,{name:"employmentStatus",label:_t.kH.EDIT_MEMBER.FIELDS.EMPLOYMENT_STATUS,options:lC}),a.createElement(tC.zB.Select,{name:"taxFilingStatus",label:_t.kH.EDIT_MEMBER.FIELDS.TAX_FILING_STATUS,options:rC})))),a.createElement(Cq.R,null,E&&a.createElement(G7.jI,{onClick:p,type:"button",size:"small"},_t.kH.EDIT_MEMBER.BUTTONS.REMOVE),a.createElement(wt.Xb,{onClick:m,type:"button",size:"small",disabled:w},_t.kH.EDIT_MEMBER.BUTTONS.CANCEL),a.createElement(CJ.I,{size:"small",pending:w},_t.kH.EDIT_MEMBER.BUTTONS.SAVE)))))},Olt=(0,u.default)(m.g).withConfig({displayName:"EditMemberModal__DemographicInformation",componentId:"sc-1090b8b-0"})(["padding-bottom:",";border-bottom:1px solid ",";"],vt.YK.xlarge,vt.Ee.color.divider.secondary),Plt=Ee.THY,Blt=e=>{let t=e.onClose,n=e.onGrantSuccess;const l=(0,Mie.v)("landing","/advisors"),r=(0,a.useMemo)((()=>[zlt(l),Flt(l)]),[l]),s=(0,o.A)(r,2),c=s[0],d=s[1],u=(0,i.n)(qlt),m=(0,o.A)(u,1)[0],p=(0,Pc.e)(!1),g=(0,o.A)(p,2),h=g[0],v=g[1].setOn,f=(0,Pc.e)(!1),E=(0,o.A)(f,2),y=E[0],b=E[1].setOn;return a.createElement(um.b,{"data-external-id":"grant-access-modal",onClose:t},a.createElement(Eu.lV,{mutation:m,onSubmitSuccess:()=>{n(),v()},onError:e=>{e.errors.code===Ee.O4y.SPONSOR_NOT_FOUND&&b()}},h?a.createElement(Vlt,null,a.createElement(hu.c.Consumer,null,(e=>{let n=e.values;return a.createElement("div",{className:"flex flex-col items-center justify-center"},a.createElement(Wlt,{center:!0},a.createElement(Ult,null)),a.createElement(xt.v,{weight:"bold"},"Access granted to "),a.createElement(xt.v,{color:"orange"},n.email),a.createElement(jlt,{onClick:t},"Okay"))}))):a.createElement(Rc.L,{title:"Grant Access to Financial Professional"},a.createElement("div",{className:"flex flex-col gap-default p-lg"},y?a.createElement("div",{className:"flex flex-col gap-default"},a.createElement(Glt,null,a.createElement(xt.v,null,a.createElement(xt.v,{weight:"medium"},"This email address does not have a"," ",a.createElement(wb.gz,{target:"_blank",href:l},"Monarch for Professionals account"),".")," ","To collaborate with you, they will need to sign-up for one. Once they have signed up, you can return here to send grant them access to your household.")),a.createElement(xt.v,null,"We will send them a note, but please send them the message below:"),a.createElement(Klt,{value:c}),a.createElement(Xve,{messageToCopy:c,hypertextVersionOfMessageToCopy:d})):a.createElement(a.Fragment,null,a.createElement(Glt,null,a.createElement(Ylt,null),a.createElement(xt.v,{size:"small"},a.createElement(xt.v,{weight:"medium"},"Important: "),"Financial professionals you give access to will have full access to your household's data. You should only invite people you fully trust. For security reasons, invites expire after"," ",_t.lU.ACCESS_GRANT_DURATION_DAYS," days.")),a.createElement("div",{className:"flex flex-col gap-default"},a.createElement(Qw.X,{name:"email",label:"Grant Access via Email Address",email:!0,required:!0}),a.createElement(Hlt,null,"Send Invite")))))))},zlt=e=>"Hi there,\n\nI'd like to invite you to collaborate with me on my finances in Monarch Money.\n\nTo do this, you'll need to sign up for the Monarch for Professionals program. You can do that here:\n\n  ".concat(e,"\n\nOnce you've signed up, let me know and I'll grant you access to my household.\n"),Flt=e=>"Hi there,\n<br />\n<br />\nI'd like to invite you to collaborate with me on my finances in Monarch Money.\n<br />\n<br />\nTo do this, you'll need to sign up for the Monarch for Professionals program. You can do that here:\n<br />\n<br />\n  <a href=\"".concat(e,'" target="_blank">').concat(e,"</a>\n<br />\n<br />\nOnce you've signed up, let me know and I'll grant you access to my household.\n"),Glt=(0,u.default)(fu.g).attrs({type:"warning"}).withConfig({displayName:"GrantAccessModal__WarningContainer",componentId:"j07g4z-0"})(["display:flex;align-items:center;"]),Ylt=(0,u.default)(sl.ZQ).attrs({name:"info"}).withConfig({displayName:"GrantAccessModal__InfoIcon",componentId:"j07g4z-1"})(["width:24px;height:24px;margin-right:",";"],vt.YK.default),Ult=(0,u.default)(sl.ZQ).attrs({name:"check"}).withConfig({displayName:"GrantAccessModal__CheckIcon",componentId:"j07g4z-2"})(["color:",";width:30px;height:30px;"],vt.yW.textWhite),Vlt=(0,u.default)(Rc.L).withConfig({displayName:"GrantAccessModal__SuccessCard",componentId:"j07g4z-3"})(["width:446px;margin:auto;"]),Wlt=(0,u.default)(m.g).withConfig({displayName:"GrantAccessModal__CheckContainer",componentId:"j07g4z-4"})(["background-color:",";width:56px;height:56px;border-radius:100%;margin-top:40px;margin-bottom:24px;"],vt.yW.green),jlt=(0,u.default)(cu.WT).withConfig({displayName:"GrantAccessModal__OkayButton",componentId:"j07g4z-5"})(["margin:"," 0;"],vt.YK.xxlarge),Hlt=(0,u.default)(CJ.I).withConfig({displayName:"GrantAccessModal__SubmitButton",componentId:"j07g4z-6"})(["margin:0;"]),Klt=(0,u.default)(Jve.O).withConfig({displayName:"GrantAccessModal__StyledTextAreaInput",componentId:"j07g4z-7"})(["width:100%;background:",";font-size:",";box-sizing:border-box;pointer-events:none;
1"],vt.yW.grayBackground,vt.J.small),qlt=Ee.JBM,$lt=["birthday","grossAnnualIncome","employmentStatus","taxFilingStatus"],Zlt=["numberOfDependents"],Jlt=["relationshipToOwner"],Xlt=e=>{let t=e.member,n=e.currentUserId;const l=(0,xq.bO)("dismissedFinancialProfileBannerForMemberIds"),r=(0,o.A)(l,2),i=r[0],s=r[1],c=(0,v.D)((()=>{const e=[...null!==i&&void 0!==i?i:[],t.id];s(e)})),d=(0,a.useMemo)((()=>(e=>{const t=e.financialProfile,n=e.householdRole;return!t||(!!$lt.some((e=>(0,BY.A)(t[e])))||(n===Ee.f0h.OWNER?Zlt:Jlt).some((e=>(0,BY.A)(t[e]))))})(t)),[t]),u=null===i||void 0===i?void 0:i.includes(t.id);return!d||u?null:a.createElement(YDe,{"data-external-id":"member-details-banner",type:"info",onDismiss:c},a.createElement("div",{className:"flex items-center gap-sm"},a.createElement(sl.ZQ,{name:"info",size:16,color:"content.info"}),a.createElement(xt.v,null,_t.kH.PROFILE_BANNER.MESSAGE(t.id===n))))},Qlt=e=>{let t=e.onClose,n=e.ownerName,l=e.variant;const r=(0,a.useMemo)((()=>a.createElement(trt,null,n)),[n]);return a.createElement(um.b,{"data-external-id":"owner-restricted-action-modal",onClose:t},a.createElement(Rc.L,{title:_t.kH.OWNER_RESTRICTED[l].TITLE},a.createElement(ert,null,a.createElement(Ilt.w,{ownerNameEl:r,TextComponent:e=>{let t=e.children;return a.createElement("div",null,t)},variant:l})),a.createElement(Cq.R,null,a.createElement(cu.WT,{onClick:t},"Okay"))))},ert=(0,u.default)(qY.S).withConfig({displayName:"OwnerRestrictedActionModal__StyledCardBody",componentId:"sc-1v8vty8-0"})(["color:",";"],vt.yW.textLight),trt=u.default.strong.withConfig({displayName:"OwnerRestrictedActionModal__StyledStrong",componentId:"sc-1v8vty8-1"})(["color:",";"],vt.yW.text),nrt=e=>{let t=e.id,n=e.invitedEmail,l=e.createdAt,r=e.revokeInvite,i=e.resendInvite;const s=(0,Pc.e)(!1),c=(0,o.A)(s,2),d=c[0],u=c[1].setOn;return a.createElement("div",{"data-external-id":"pending-invitation-list-item",className:"flex size-full flex-1 items-center justify-between rounded-default bg-background-secondary p-default"},a.createElement("div",{className:"flex min-w-0"},a.createElement(art,{center:!0},a.createElement(klt.P,{size:60})),a.createElement("div",{className:"mx-default flex min-w-0 flex-col justify-center"},a.createElement(xt.v,{size:"large",weight:"medium",color:"content.secondary",clampLines:1},n),a.createElement("div",{className:"flex min-w-0 items-baseline"},a.createElement(xt.v,{color:"content.secondary",clampLines:1},"Invited ".concat(l)),a.createElement(lrt,{onClick:async()=>{await i(t),u()},disabled:d},a.createElement(xt.v,{color:d?"content.success":"content.link",size:"base"},d?"Sent!":"Resend Invite"))))),a.createElement(G7.jI,{size:"xsmall",onClick:()=>r(t)},"Remove"))},art=(0,u.default)(m.g).withConfig({displayName:"PendingInvitationListItem__EmailIconBackground",componentId:"sc-1wsg786-0"})(["width:","px;height:","px;border-radius:100%;"],60,60),lrt=(0,u.default)(bn.v).withConfig({displayName:"PendingInvitationListItem__ResendInviteButton",componentId:"sc-1wsg786-1"})(["padding:0;margin-left:",";"],vt.YK.small);var rrt=n(21153);const ort=["createdAt"];var irt;const srt=()=>{var e;const t=(0,Tse._)(),n=t.isDemoHousehold,r=t.blockActionForDemoHousehold,s=(0,l.Zp)(),c=(0,d.d4)(A.F6)||"",u=(0,yZ.B)().shouldShowBanners,m=(0,Xo.IT)(vue.sK),p=m.data,g=m.refetch,h=(0,i.n)(vue.J6),f=(0,o.A)(h,2),E=f[0],y=f[1].loading,b=(0,i.n)(vue.Hm),x=(0,o.A)(b,1)[0],w=(0,i.n)(vue._c),C=(0,o.A)(w,1)[0],k=(0,a.useState)(null),S=(0,o.A)(k,2),N=S[0],T=S[1],_=(0,a.useState)(null),D=(0,o.A)(_,2),R=D[0],M=D[1],L=(0,a.useState)(null),O=(0,o.A)(L,2),P=O[0],B=O[1],z=(0,Pd.h)(),F=(0,o.A)(z,2),G=F[0],Y=F[1],V=Y.open,W=Y.close,j=(0,Pd.h)(),H=(0,o.A)(j,2),K=H[0],q=H[1],$=q.open,Z=q.close,J=(0,Pc.e)(!1),X=(0,o.A)(J,2),Q=X[0],ee=X[1],te=ee.setOn,ne=ee.setOff,ae=(0,Pc.e)(!1),le=(0,o.A)(ae,2),re=le[0],oe=le[1],ie=oe.setOn,se=oe.setOff,ce=(0,a.useState)(null),de=(0,o.A)(ce,2),ue=de[0],me=de[1],pe=(e=>{var t;return(null!==(t=null===e||void 0===e?void 0:e.householdInvites)&&void 0!==t?t:[]).map((e=>{let t=e.createdAt,n=(0,En.A)(e,ort);return(0,U.A)((0,U.A)({},n),{},{createdAt:(0,Ba.Lu)((0,Ba.lA)(t))})}))})(p),ge=(e=>{if(!e)return e;const t=e.myHousehold.users;return(0,rrt.EK)(t).map((e=>{let t=e.name,n=e.displayName,a=e.householdRole,l=e.email,r=e.id,o=e.hasMfaOn,i=e.hasVerifiedEmail,s=e.profilePictureUrl,c=e.financialProfile;return{id:r,name:t,displayName:n,householdRole:a,hasMfaOn:o,hasVerifiedEmail:i,displayRole:(0,rrt.is)(a),profilePictureUrl:s,email:l,financialProfile:c}}))})(p),he=(ve=p)?ve.me.householdRole:Ee.f0h.MEMBER;var ve;const fe=null===p||void 0===p?void 0:p.householdAccessGrants,ye=he===Ee.f0h.OWNER,be=(0,v.D)(((e,t)=>{ye?t():me(e)})),xe=(0,v.D)((()=>{be(Ilt.z.AddMember,(()=>r(te,!1)))})),we=(0,v.D)((e=>{let t=e.id,n=e.name,a=e.email;const l=t===c;
1if(l)return T({id:t,name:n,email:a,isTryingToRemoveSelf:l}),void V();be(Ilt.z.RemoveMember,(()=>{T({id:t,name:n,email:a}),V()}))})),Ce=(0,v.D)((e=>{be(Ilt.z.RemoveInvite,(async()=>{await E({variables:{input:{inviteId:e}}}),g()}))})),Ae=(0,v.D)((()=>{be(Ilt.z.AddAccessGrant,(()=>r(ie,!1)))})),Ie=(0,v.D)((e=>{be(Ilt.z.RevokeAccessGrant,(async()=>{await x({variables:{input:{id:e}}}),g()}))})),ke=(0,a.useMemo)((()=>null===ge||void 0===ge?void 0:ge.find((e=>e.householdRole===Ee.f0h.OWNER))),[ge]),Se=1===(null===ge||void 0===ge?void 0:ge.length),Ne=!(0,PY.A)(pe),Te=Se&&!Ne,_e=(0,a.useMemo)((()=>null===ge||void 0===ge?void 0:ge.find((e=>e.id===P))),[ge,P]);return a.createElement(mX.V,{"data-external-id":"member-settings",md:9},a.createElement(Xhe.Ay,null,a.createElement("title",null,"Member Settings")),Ne&&a.createElement(crt,{title:"Invitations",anchorId:"invitations",isDemo:n},a.createElement("div",{className:"flex flex-col gap-sm p-xl"},pe.map((e=>{let t=e.invitedEmail,n=e.createdAt,l=e.id;return a.createElement(nrt,{key:l,id:l,createdAt:n,invitedEmail:t,revokeInvite:()=>{M(l),$()},resendInvite:async e=>{await C({variables:{input:{inviteId:e}}})}})})))),a.createElement(crt,{title:"Household Members",anchorId:"household-members",controls:a.createElement(bn.v,{onClick:xe},"Add another member for free"),isDemo:n},a.createElement(urt,null,a.createElement(xt.v,null,"Members you invite will be able to login with their own username/password at no extra cost.")," ",a.createElement(xt.v,null,_t.n3.MEMBER_SETTINGS.HOUSEHOLD_MEMBERS_NOTICE)),a.createElement("div",{className:"flex flex-col gap-sm p-xl"},ge&&ge.map((e=>a.createElement(mrt,{key:e.id,className:"flex-col gap-default p-default"},a.createElement("div",{className:"flex items-center justify-between"},a.createElement(Rlt,{member:e}),a.createElement(wt.Xb,{size:"xsmall",onClick:()=>B(e.id)},"Edit")),a.createElement(Xlt,{member:e,currentUserId:c}))))),a.createElement("div",{className:"flex size-full flex-1"},u?a.createElement("div",{className:"flex size-full flex-1 p-xl pt-0"},a.createElement(prt,{type:"info"},a.createElement("div",{className:"flex items-center justify-between px-xl py-lg"},a.createElement("div",{className:"flex flex-col gap-2xs"},a.createElement(xt.v,{color:"content.primary",weight:"medium",size:"large"},_t.n3.BANNER.TITLE),a.createElement(xt.v,{color:"content.primary",size:"large"},"Set account ownership to unlock new"," ",a.createElement(hrt,{onClick:()=>window.open(VF.Ds)},"personal and shared views")," ","of your finances.")),a.createElement(grt,{onClick:()=>s(I.JZ.collaboration.onboarding({queryParams:{source:oZ.Gd.MEMBERS_SETTINGS}}))},_t.n3.MEMBER_SETTINGS.BANNER.GET_STARTED_BUTTON)))):null)),Te&&a.createElement(crt,{title:"Invite another member for free",anchorId:"invite-member",controls:a.createElement(cu.WT,{onClick:xe},"Send an invite for free"),isDemo:n},a.createElement(vrt,{iconColor:"content.secondary",headingFontSize:"base",subheadingFontSize:"small"})),a.createElement(crt,{title:"Financial Professionals",anchorId:"financial-professionals",controls:a.createElement(bn.v,{onClick:()=>r(Ae,!1)},"Give Access to Financial Professional"),isDemo:n},a.createElement(urt,null,a.createElement(xt.v,{weight:"medium"},"Use this for financial professionals you work with.")," ","They will have access to your account through the Monarch for Professionals Program and you can revoke access at any time. Access will expire after"," ",_t.lU.ACCESS_GRANT_DURATION_DAYS," days."),fe&&fe.map((e=>{let t=e.toEmail,n=e.toName,l=e.id,r=e.expiresAt;return a.createElement("div",{key:l,className:"flex min-w-0 p-lg"},a.createElement(klt.P,{size:60}),a.createElement("div",{className:"mx-default flex min-w-0 flex-col justify-center"}
1,a.createElement(xt.v,{size:"large",weight:"medium",clampLines:1},n||t),a.createElement(xt.v,{color:"content.secondary"},r&&a.createElement(a.Fragment,null,"Expires ",(0,Ba.AO)(r)))),a.createElement(drt,{onClick:()=>Ie(l)}))}))),Q&&a.createElement(Z3.j,{onClose:ne,onInviteSuccess:g}),re&&a.createElement(Blt,{onClose:se,onGrantSuccess:g}),ue&&a.createElement(Qlt,{onClose:()=>me(null),ownerName:null!==(e=null===ke||void 0===ke?void 0:ke.name)&&void 0!==e?e:"your household admin",variant:ue}),a.createElement(G,null,N&&a.createElement(_lt,{memberInfo:N,onClose:()=>{T(null),W()},onDeleteSuccess:()=>{g()}})),a.createElement(K,null,a.createElement(xC.$,{title:"Are you sure you want to remove this person?",confirm:"Remove",onCancel:Z,onConfirm:()=>{R&&Ce(R),M(null),Z()},isLoading:y},"They won\u2019t be able to join your household anymore.")),_e&&a.createElement(Llt,{member:_e,currentUserId:c,currentUserIsOwner:he===Ee.f0h.OWNER,onClose:()=>{B(null),g()},onDeleteMember:()=>{B(null),we({id:_e.id,name:_e.name,email:_e.email})}}))},crt=(0,u.default)(Ffe).withConfig({displayName:"MemberSettings__StyledSettingsCard",componentId:"sc-185vkb3-0"})(["margin-bottom:",";"],(e=>e.theme.spacing.gutter)),drt=(0,u.default)(FDe).withConfig({displayName:"MemberSettings__DeleteMemberButton",componentId:"sc-185vkb3-1"})(["margin-left:auto;color:",";"],(e=>e.theme.color.textLight)),urt=u.default.div.withConfig({displayName:"MemberSettings__StyledBanner",componentId:"sc-185vkb3-2"})(["padding:"," ",";border-bottom:1px solid ",";"],(e=>e.theme.spacing.default),(e=>e.theme.spacing.large),vt.Ee.color.divider.primary),mrt=$d.s.div(irt||(irt=(0,wc.A)(["flex rounded-default border border-border-primary"]))),prt=(0,u.default)(fu.g).withConfig({displayName:"MemberSettings__StyledInfoBanner",componentId:"sc-185vkb3-3"})(["padding:0;width:100%;border-radius:",";"],vt.r8.default),grt=(0,u.default)(wt.Xb).attrs({size:"medium"}).withConfig({displayName:"MemberSettings__GetStartedButton",componentId:"sc-185vkb3-4"})(["min-width:120px;margin-left:",";"],vt.YK.xlarge),hrt=(0,u.default)(bn.v).withConfig({displayName:"MemberSettings__StyledTextButton",componentId:"sc-185vkb3-5"})(["font-size:",";display:inline;margin:0;padding:0;"],vt.J.large),vrt=(0,u.default)($3.u).withConfig({displayName:"MemberSettings__StyledInviteMemberBenefits",componentId:"sc-185vkb3-6"})(["padding:"," ",";"],vt.YK.large,vt.YK.xlarge),frt=e=>{const t=[ope.kq,ope.PI].includes(e),n=(0,Xo.IT)(Ert,{skip:!t}),a=n.data,l=n.loading,r=rpe();return l||!t||(null===a||void 0===a?void 0:a.userHasConfiguredRetailSyncExtension)||!r?void 0:ope.Vg},Ert=((0,u.default)(wb.gz).withConfig({displayName:"RetailSyncLink__StyledLink",componentId:"titxq4-0"})(["color:",";"],vt.Ee.color.content.brand),Ee.fTA);var yrt=n(74585),brt=n(33924);const xrt=e=>{let t=e.merchant,n=e.canOnlyAccessV2,r=e.recurrenceGroupCount,o=e.recurrenceGroupNames,i=e.onClickEdit;const s=(0,Tr.A)(t.recurringTransactionStream),c=(0,Tr.A)(t.recurrenceIgnoredAt),d=frt(t.name),u=(0,brt.h)().isDefaultCategoriesOn,m=t.defaultCategory,p=I.JZ.merchants({id:t.id});return a.createElement(wrt,{"data-external-id":"merchant-list-item"},a.createElement(l.N_,{to:p,"aria-label":"View ".concat(t.name)},a.createElement(Wl._,{url:t.logoUrl,size:48})),a.createElement(Crt,null,a.createElement("div",{className:"flex items-center gap-xs"},a.createElement(Vl.W,{to:p,stealthy:!0},a.createElement(xt.v,{weight:"medium",size:"large"},a.createElement($j.M,null,t.name))),u&&m?a.createElement(c5.C,{color:"gray-secondary",variant:"subtle",size:"sm",rounded:"pill"},(0,yrt.A)(m)):null,n&&c?a.createElement(c5.C,{color:"gray-secondary",variant:"subtle",size:"sm",rounded:"pill"},"Never recurring"):null,n&&r>0?a.createElement(Wi.Y,{content:o.join("\n"),contentClassName:"text-left whitespace-pre-line"},a.createElement(c5.C,{color:"gray-secondary",variant:"subtle",size:"sm",rounded:"pill"},r," recurring")):null,!1===n&&s?a.createElement(c5.C,{color:"gray-secondary",variant:"subtle",size:"sm",rounded:"pill"},"Recurring"):null),a.createElement(Vl.W,{to:I.JZ.transactions({queryParams:{merchants:[t.id]}})},a.createElement(xt.v,{size:"small",weight:"medium"},(0,De.LN)(t.transactionCount)," ",(0,De.td)("transaction",t.transactionCount)))),a.createElement("div",{className:"flex items-center gap-xs"},d?a.createElement("a",{href:d,target:"_blank",rel:"noopener noreferrer"},a.createElement(wt.Xb,{onClick:()=>{(0,Ge.u4)(Ye.Xt.MerchantSettingsLinkOpened)}},a.createElement("span",null,"Sync order details"),a.createElement(Yo.r,{name:"arrow-up-right"}))):null,a.createElement(wt.Xb,{size:"small",onClick:i},a.createElement(Yo.r,{name:"edit"}),a.createElement("span",null,"Edit"))))},wrt=(0,u.default)(m.g).attrs({justifyBetween:!0,alignCenter:!0}).withConfig({displayName:"MerchantListItem__Root",componentId:"sc-13zyezp-0"})(["padding:"," ",";border-top:1px solid ",";gap:",";"],(e=>e.theme.spacing.default),(e=>e.theme.spacing.xlarge),vt.Ee.color.divider.primary,(e=>e.theme.spacing.default)),Crt=(0,u.default)(m.g).attrs({column:!0}).withConfig({displayName:"MerchantListItem__MerchantInfo",componentId:"sc-13zyezp-1"})(["gap:",";flex-grow:1;"],(e=>e.theme.spacing.xxsmall)),Art=e=>e.hide?null:a.createElement(Irt,{"data-external-id":"table-loading-footer"},a.createElement(p.i,{size:"lg"})),Irt=(0,u.default)(m.g).attrs({center:!0}).withConfig({displayName:"TableLoadingFooter__LoadingContainer",componentId:"ihtkrg-0"})(["background-color:",";border-top:1px solid ",";padding:"," 0;"],(e=>e.theme.color.white),(e=>
1e.theme.color.grayBackground),(e=>e.theme.spacing.default)),krt=e=>{let t=e.search,n=e.hasDefaultCategory;return t?{title:"No merchants found",subtitle:"We couldn't find any merchants matching your search of \"".concat(t,'".')}:!0===n?{title:"No default categories yet",subtitle:"None of your merchants have a default category. Set one from a merchant's page."}:!1===n?{title:"Every merchant has a default",subtitle:"All of your merchants already have a default category."}:{title:"No merchants found",subtitle:"You don't have merchants assigned to transactions yet."}},Srt=e=>{var t;let n=e.merchants,l=e.isLoading,r=e.hideFooter,i=e.search,s=e.hasDefaultCategory,c=e.refetchMerchants,d=e.onFetchMore;const u=null!==n&&void 0!==n?n:[],m=(0,a.useState)(null),g=(0,o.A)(m,2),h=g[0],v=g[1],f=(0,a.useContext)(ri.z).scrollRef,E=(0,Sse.x)().canOnlyAccessV2,y=(0,et.I)(aYe.JN,{variables:{includeInactive:!1},skip:!E}).data;if(l)return a.createElement(Trt,{"data-external-id":"merchant-list"},a.createElement(p.i,null));if((0,LV.A)(u)){const e=krt({search:i,hasDefaultCategory:s}),t=e.title,n=e.subtitle;return a.createElement(cU.vx,{"data-external-id":"merchant-list",title:t,subtitle:n})}return a.createElement(Nrt,{"data-external-id":"merchant-list"},a.createElement(Ac.aY,{style:{height:"auto"},data:u,endReached:d,customScrollParent:null!==(t=null===f||void 0===f?void 0:f.current)&&void 0!==t?t:void 0,itemContent:(e,t)=>a.createElement(xrt,{key:t.id,merchant:t,canOnlyAccessV2:E,recurrenceGroupCount:(0,oVe.li)(null===y||void 0===y?void 0:y.recurrenceGroupsForPeriod,t.id),recurrenceGroupNames:(0,oVe.bK)(null===y||void 0===y?void 0:y.recurrenceGroupsForPeriod,t.id),onClickEdit:()=>v(t.id)}),components:{Footer:()=>a.createElement(Art,{hide:r})}}),(0,Tr.A)(h)&&a.createElement(um.b,{onClose:()=>v(null)},a.createElement(N7._,{merchantId:h,afterDelete:c,afterUpdate:c})))},Nrt=(0,u.default)(m.g).attrs({column:!0}).withConfig({displayName:"MerchantList__Root",componentId:"uvmb3o-0"})(["width:100%;"]),Trt=(0,u.default)(m.g).attrs({center:!0}).withConfig({displayName:"MerchantList__SpinnerContainer",componentId:"uvmb3o-1"})(["margin:"," 0;"],(e=>e.theme.spacing.xlarge));var _rt=n(49180),Drt=n(99420);var Rrt=n(21784),Mrt=n(68880),Lrt=n(22352);const Ort=e=>{var t,n;let l=e.orderBy,r=e.search;const i=(0,a.useContext)(ri.z).scrollRef,s=(0,Drt.q)({bulkUpdateRefetchQueries:[...Lrt.cP,Lrt.sP]}),c=s.setDefaultCategory,d=s.getHistoricalUpdateCount,u=s.applyToHistoricalTransactions,m=(0,V.m)().cache,p=(0,C.RU)(),g=(0,a.useState)(null),h=(0,o.A)(g,2),v=h[0],f=h[1],E=(0,et.I)(Brt,{variables:{offset:0,limit:20,minTransactionCount:Mrt.aq,orderBy:l,search:r||null}}),y=E.data,b=E.isLoadingInitialData,x=E.isDataAvailable,w=E.refetch,A=E.fetchMore,I=(0,a.useMemo)((()=>{var e;return null!==(e=null===y||void 0===y?void 0:y.merchantsWithRecommendedDefaultCategory)&&void 0!==e?e:[]}),[null===y||void 0===y?void 0:y.merchantsWithRecommendedDefaultCategory]),k=null!==(t=null===y||void 0===y?void 0:y.merchantsWithRecommendedDefaultCategoryCount)&&void 0!==t?t:0,S=I.length>=k,N=(0,a.useCallback)((()=>{if(x)return A({variables:{offset:I.length,limit:20,minTransactionCount:Mrt.aq,orderBy:l,search:r||null},updateQuery:(e,t)=>{let n=t.fetchMoreResult;return(0,U.A)((0,U.A)({},e),{},{merchantsWithRecommendedDefaultCategory:(0,mQ.SQ)(null===n||void 0===n?void 0:n.merchantsWithRecommendedDefaultCategory,(e=>e.merchant.id))(e.merchantsWithRecommendedDefaultCategory)})}})}),[A,x,I.length,l,r]),T=(0,a.useCallback)((async e=>{f(e.merchant.id);try{if(!await c(e.merchant.id,e.category.id))return void p();(0,Ge.u4)(Ye.uj.DefaultCategoryRecommendationApplied,{merchantId:e.merchant.id,merchantName:e.merchant.name,categoryId:e.category.id,categoryName:e.category.name}),(0,Rrt.K)(m),await w();const t=await d(e.merchant.id,e.category.id);if(null===t)p();else if(t>0){const n=t=>(0,Ge.u4)(Ye.uj.DefaultCategoryBulkUpdatePromptAnswered,{response:t,merchantId:e.merchant.id,merchantName:e.merchant.name,categoryId:e.category.id,categoryName:e.category.name}),l=(0,C.W7)({message:a.createElement(a.Fragment,null,_t.r_.HISTORICAL.BEFORE_MERCHANT(t,(0,yrt.A)(e.category)),a.createElement(_rt.N,{name:e.merchant.name,logoUrl:e.merchant.logoUrl}),_t.r_.HISTORICAL.AFTER_MERCHANT(t)),actions:[{text:_t.r_.HISTORICAL.CONFIRM,dismissOnClick:!1,onClick:async()=>{n("yes");const a=await u(e.merchant.id,e.category.id,t);
1C.W7.advance(l,{message:null===a?_t.r_.ERROR:_t.r_.SUCCESS.MESSAGE(a),variant:null===a?"error":"success",duration:5e3})}},{text:_t.r_.HISTORICAL.DECLINE,onClick:()=>{n("no")}}]})}else(0,C.oR)({title:a.createElement(a.Fragment,null,a.createElement(_rt.N,{name:e.merchant.name,logoUrl:e.merchant.logoUrl,stickySuffix:_t.r_.RECOMMENDED_SAVED.POSSESSIVE}),_t.r_.RECOMMENDED_SAVED.AFTER_MERCHANT((0,yrt.A)(e.category)))})}catch(t){p()}finally{f(null)}}),[u,m,d,w,c,p]);if(b)return a.createElement("div",{"data-external-id":"recommended-merchants-list",className:"flex justify-center py-xl"},a.createElement(fe.ix7,null));if((0,LV.A)(I)){const e=r?krt({search:r,hasDefaultCategory:null}):{title:_t.Kv.TITLE,subtitle:_t.Kv.SUBTITLE},t=e.title,n=e.subtitle;return a.createElement(fe.erR,{"data-external-id":"recommended-merchants-list",title:t,description:n})}return a.createElement(Ac.aY,{"data-external-id":"recommended-merchants-list",style:{height:"auto"},data:I,endReached:N,customScrollParent:null!==(n=null===i||void 0===i?void 0:i.current)&&void 0!==n?n:void 0,itemContent:(e,t)=>a.createElement(Prt,{key:t.merchant.id,item:t,isSettingDefault:v===t.merchant.id,onSetDefault:T}),components:{Footer:()=>a.createElement(Art,{hide:S})}})},Prt=e=>{let t=e.item,n=e.isSettingDefault,r=e.onSetDefault;const o=t.merchant,i=t.category,s=t.transactionCount,c=t.recommendationScopeTransactionCount,d=(0,yrt.A)(i),u=I.JZ.merchants({id:o.id});return a.createElement("div",{"data-external-id":"recommended-merchant-list-item",className:" flex items-center justify-between gap-default border-t border-divider-primary px-xl py-default "},a.createElement(l.N_,{to:u,"aria-label":"View ".concat(o.name)},a.createElement(Wl._,{url:o.logoUrl,size:48})),a.createElement("div",{className:"flex grow flex-col gap-3xs"},a.createElement(Vl.W,{to:u,stealthy:!0},a.createElement(fe.c8D,{size:"lg",weight:"medium",color:"inherit"},o.name)),a.createElement(Vl.W,{to:I.JZ.transactions({queryParams:{merchants:[o.id]}})},a.createElement(fe.c8D,{size:"sm",weight:"medium",color:"inherit"},((e,t,n)=>"".concat((0,De.LN)(e)," / ").concat((0,De.td)("transaction",t,{inclusive:!0})," in ").concat(n))(s,c,d)))),a.createElement(fe.XZZ,{isLoading:n,onClick:()=>r(t)},"Set default to ",d))},Brt=Ee.QwU,zrt=Ee.uUR,Frt=e=>!0===e||"true"===e||!1!==e&&"false"!==e&&null,Grt="recommended",Yrt=()=>{var e,t,n,l,r;const i=(0,brt.h)().isDefaultCategoriesOn,s=(0,a.useState)("all"),c=(0,o.A)(s,2),d=c[0],u=c[1],m=(0,ZH.D)("merchants"),p=m.activeFilters,g=m.hasFilterChanged,h=m.updateFilter,v=m.resetFilter,f=null!==p&&void 0!==p?p:{},E=f.order,y=f.search,b=Frt(null===p||void 0===p?void 0:p.hasDefaultCategory),x=(0,a.useState)(null!==y&&void 0!==y?y:""),w=(0,o.A)(x,2),C=w[0],A=w[1],I=(0,xy.d)(y,RIe.N);(0,a.useEffect)((()=>{y&&A(y)}),[y]),(0,a.useEffect)((()=>{h({search:I})}),[I]);const k=(0,a.useMemo)((()=>((e,t)=>{if(!e)return;const n=Frt(t);return"boolean"===typeof n?{hasDefaultCategory:n}:void 0})(i,b)),[b,i]),S=i&&d===Grt,N=(0,et.I)(Zrt,{variables:{search:I,orderBy:E,filters:k},skip:S}),T=N.data,_=N.isLoadingInitialData,D=N.isDataAvailable,R=N.refetch,M=N.fetchMore,L=(0,et.I)(zrt,{variables:{minTransactionCount:Mrt.aq},skip:!i}).data,O=_,P=(0,a.useMemo)((()=>{var e;return null!==(e=null===T||void 0===T?void 0:T.merchants)&&void 0!==e?e:[]}),[null===T||void 0===T?void 0:T.merchants]),B=null!==(e=null===T||void 0===T?void 0:T.merchantCount)&&void 0!==e?e:0,z=null!==(t=null===L||void 0===L?void 0:L.merchantsWithRecommendedDefaultCategoryCount)&&void 0!==t?t:0,F=(0,a.useCallback)((()=>{if(D)return M({variables:{offset:P.length,orderBy:E,filters:k,search:I},updateQuery:(e,t)=>{let n=t.fetchMoreResult;return(0,Ru.A)({merchants:(0,mQ.BI)(null===n||void 0===n?void 0:n.merchants)},e)}})}),[I,M,k,D,P.length,E]),G=Mrt.W7.find((e=>e.value===E)),Y=Mrt.FZ.find((e=>e.value===b));return a.createElement(mX.V,{"data-external-id":"merchant-settings",md:9},a.createElement(Ffe,{title:"Merchants",anchorId:"merchants",controls:i?a.createElement(fe.T36,{variant:"pill",value:d,onValueChange:e=>u(String(e)),items:[{value:"all",label:"All"},{value:Grt,label:z>0?"Recommended (".concat(z,")"):"Recommended"}]}):void 0},a.createElement(Xhe.Ay,null,a.createElement("title",null,"Merchants")),S?a.createElement(a.Fragment,null,a.createElement(jrt,null,a.createElement(Wrt,{className:"text-pretty"},a.createElement(xt.v,null,_t.eN)),a.createElement(Krt,null,a.createElement("div",{className:"flex items-center gap-default"},a.createElement(Urt,{activeLabel:null!==(n=null===G||void 0===G?void 0:G.label)&&void 0!==n?n:"Order by",onClickOption:e=>h({order:e})})),a.createElement("div",null,a.createElement(Hrt,{name:"merchant",placeholder:z?"Search ".concat(z.toLocaleStr
1ing()," ").concat((0,De.td)("merchant",z),"..."):"Search for a merchant...",value:y,onChange:e=>{const t=e.target;h({search:t.value})}}),g&&a.createElement($rt,{onClick:()=>v()},"Reset filter"))),z>0&&a.createElement(qrt,null,z.toLocaleString()," ",(0,De.td)("Merchant",z))),a.createElement(Ort,{orderBy:null!==E&&void 0!==E?E:Mrt.DJ,search:I})):a.createElement(a.Fragment,null,a.createElement(jrt,null,a.createElement(Wrt,null,a.createElement(xt.v,null,g4.WF)),a.createElement(Krt,null,a.createElement("div",{className:"flex items-center gap-default"},a.createElement(Urt,{activeLabel:null!==(l=null===G||void 0===G?void 0:G.label)&&void 0!==l?l:"Order by",onClickOption:e=>h({order:e})}),i?a.createElement(Vrt,{activeLabel:null!==(r=null===Y||void 0===Y?void 0:Y.label)&&void 0!==r?r:"All",activeValue:null!==b&&void 0!==b?b:null,onClickOption:e=>h({hasDefaultCategory:e})}):null),a.createElement("div",null,a.createElement(Hrt,{name:"merchant",placeholder:B?"Search ".concat(B.toLocaleString()," ").concat((0,De.td)("merchant",B),"..."):"Search for a merchant...",value:y,onChange:e=>{const t=e.target;h({search:t.value})}}),g&&a.createElement($rt,{onClick:()=>v()},"Reset filter"))),B>0&&a.createElement(qrt,null,B.toLocaleString()," ",(0,De.td)("Merchant",B))),a.createElement(sH.j.Provider,{value:{searchWords:I?[I]:[]}},a.createElement(Srt,{merchants:P,isLoading:O,refetchMerchants:R,onFetchMore:F,hideFooter:P.length+1>=B||C.length>0,search:C,hasDefaultCategory:i?b:null})))))},Urt=e=>{let t=e.activeLabel,n=e.onClickOption;return a.createElement(Qi.Az,{"data-external-id":"order-by-dropdown",placement:"bottom-start",overlay:a.createElement(Ji.SP,null,Mrt.W7.map((e=>{let l=e.value,r=e.label;return a.createElement(Ji.xm,{key:l,onClick:()=>n(l),selected:r===t},r)})))},(e=>{let n=e.toggleOpen,l=e.isOpen;return a.createElement(wt.Xb,{onClick:n,active:l},a.createElement("span",null,t),a.createElement(Yo.r,{name:"chevron-down"}))}))},Vrt=e=>{let t=e.activeLabel,n=e.activeValue,l=e.onClickOption;return a.createElement(Qi.Az,{"data-external-id":"default-category-filter-dropdown",placement:"bottom-start",overlay:a.createElement(Ji.SP,null,Mrt.FZ.map((e=>{let t=e.value,r=e.label;return a.createElement(Ji.xm,{key:String(t),onClick:()=>l(t),selected:t===n},r)})))},(e=>{let n=e.toggleOpen,l=e.isOpen;return a.createElement(wt.Xb,{onClick:n,active:l},a.createElement("span",null,t),a.createElement(Yo.r,{name:"chevron-down"}))}))},Wrt=u.default.div.withConfig({displayName:"MerchantSettings__IntroContainer",componentId:"msrgb7-0"})(["margin-bottom:",";"],(e=>e.theme.spacing.default)),jrt=u.default.div.withConfig({displayName:"MerchantSettings__Header",componentId:"msrgb7-1"})(["padding:"," "," ",";padding-top:",";"],(e=>e.theme.spacing.xlarge),(e=>e.theme.spacing.xlarge),(e=>e.theme.spacing.default),(e=>e.theme.spacing.default)),Hrt=(0,u.default)(Ry.X).withConfig({displayName:"MerchantSettings__StyledTextInput",componentId:"msrgb7-2"})(["flex:1;height:40px;min-width:240px;"]),Krt=(0,u.default)(m.g).attrs({justifyBetween:!0,alignCenter:!0}).withConfig({displayName:"MerchantSettings__OptionsContainer",componentId:"msrgb7-3"})(["gap:",";"],(e=>e.theme.spacing.xlarge)),qrt=(0,u.default)(xt.v).attrs({weight:"medium",size:"large"}).withConfig({displayName:"MerchantSettings__MerchantCountText",componentId:"msrgb7-4"})(["display:inline-block;margin-top:",";"],(e=>e.theme.spacing.default)),$rt=(0,u.default)(wt.Xb).withConfig({displayName:"MerchantSettings__ResetButton",componentId:"msrgb7-5"})(["display:inline-block;transform:translateY(-1px);margin-left:",";"],(e=>e.theme.spacing.small)),Zrt=Ee.d2n,Jrt=((0,Qt.J)("\n  fragment NotificationPreferenceFields on NotificationPreference {\n    id\n    group\n    type\n    additionalPreferences\n    additionalPreferencesMeta\n    title\n    description\n    EMAIL\n    PUSH\n    emailEnabled\n    pushEnabled\n    inAppEnabled\n  }\n"),(0,Qt.J)("\n  query Common_GetNotificationPreference($id: String!) {\n    notificationPreference(id: $id) {\n      ...NotificationPreferenceFields\n    }\n  }\n"),(0,Qt.J)("\n  query Common_GetNotificationPreferences {\n    notificationPreferences {\n      ...NotificationPreferenceFields\n    }\n  }\n")),Xrt=(0,Qt.J)("\n  mutation Common_UpdateNotificationPreferences($input
1: UpdateNotificationPreferencesInput!) {\n    updateNotificationPreferences(input: $input) {\n      errors {\n        ...PayloadErrorFields\n      }\n      notificationPreference {\n        ...NotificationPreferenceFields\n      }\n    }\n  }\n"),Qrt=(0,Qt.J)("\n  mutation Common_UpdateAllNotificationPreferencesForPlatform($input: UpdateAllNotificationPreferencesForPlatformInput!) {\n    updateAllNotificationPreferencesForPlatform(input: $input) {\n      errors {\n        ...PayloadErrorFields\n      }\n      success\n    }\n  }\n"),eot=e=>{let t=e.title,n=e.hasAnyNotificationsEnabled,l=e.platform,r=e.tooltipProps;const s=(0,i.n)(Qrt),c=(0,o.A)(s,2),d=c[0],u=c[1].loading;return a.createElement("div",{"data-external-id":"notification-settings-column-header",className:"flex flex-col items-end"},a.createElement("div",{className:"flex items-center gap-2xs"},r?a.createElement(fe.cIj,Object.assign({size:"3xs",iconSize:"xs",label:a.createElement(fe.c8D,{weight:"medium"},t)},r)):a.createElement(fe.c8D,{weight:"medium"},t)),a.createElement(tot,{onClick:async()=>{var e,t;null!==(e=(await d({variables:{input:{platform:l,enabled:!n}},refetchQueries:[Ee.$_3]})).data)&&void 0!==e&&null!==(t=e.updateAllNotificationPreferencesForPlatform)&&void 0!==t&&t.success&&(0,Ge.u4)(Ye.lb.NotificationSettingsUpdated,{type:"all",channel:l===Ee.KsQ.IN_APP?"in-app":l.toLowerCase(),previousSetting:n,newSetting:!n})},disabled:u},n?"Turn all off":"Turn all on"))},tot=(0,u.default)(bn.v).withConfig({displayName:"NotificationSettingsColumnHeader__StyledTextButton",componentId:"wmh98t-0"})(["font-size:",";"],vt.J.xsmall),not=72,aot=e=>{let t=e.notificationPreferences;const n=(0,a.useMemo)((()=>{let e=!1,n=!1,a=!1;return(null!==t&&void 0!==t?t:[]).forEach((t=>{t.pushEnabled&&(e=!0),t.emailEnabled&&(n=!0),t.inAppEnabled&&(a=!0)})),{hasAnyPushEnabled:e,hasAnyEmailEnabled:n,hasAnyInAppEnabled:a}}),[t]),l=n.hasAnyPushEnabled,r=n.hasAnyEmailEnabled,o=n.hasAnyInAppEnabled;return a.createElement(lot,{"data-external-id":"notification-settings-card-header"},a.createElement(oPe.HM,null,"Notifications"),a.createElement(eot,{title:_t.U_.inAppPlatformLabel,hasAnyNotificationsEnabled:o,platform:Ee.KsQ.IN_APP,tooltipProps:{content:_t.U_.inAppTooltip}}),a.createElement(eot,{title:_t.U_.emailPlatformLabel,hasAnyNotificationsEnabled:r,platform:Ee.KsQ.EMAIL}),a.createElement(eot,{title:_t.U_.pushPlatformLabel,hasAnyNotificationsEnabled:l,platform:Ee.KsQ.PUSH,tooltipProps:{content:_t.U_.pushTooltip,side:"left"}}))},lot=u.default.div.withConfig({displayName:"NotificationSettingsCardHeader__Root",componentId:"sc-10r5ep5-0"})(["height:","px;background-color:",";display:grid;grid-template-columns:1fr ","px ","px ","px;gap:",";align-items:center;padding:"," ",";position:relative;border-radius:"," "," 0 0;"],76,vt.Ee.color.background.primary,not,not,not,vt.YK.xxlarge,vt.YK.default,vt.YK.xlarge,vt.r8.medium,vt.r8.medium);var rot=n(58707);const oot=e=>{let t=e.notificationPreference,n=e.lastSuccessfulUpdate,l=e.onSubmit;const r=t.additionalPreferencesMeta,o=t.additionalPreferences;if((0,BY.A)(r)||(0,PY.A)(r))return null;const i=(0,Q5e.A)(((e,t)=>{var n;return null!==(n=null===o||void 0===o?void 0:o[t])&&void 0!==n?n:null===e||void 0===e?void 0:e.default}),r),s=(0,rot.A)(" ",(0,wJ.A)((0,Q5e.A)(((e,t)=>e.title),r))),c=(0,wJ.A)((0,Q5e.A)(((e,t)=>{let n=e.title,l=e.type;return((e,t,n)=>"number"===t?a.createElement(tC.zB.Currency,{key:n,name:n,label:e,precision:0,className:"w-42.25"}):a.createElement(iot,{key:n,name:n,label:e}))(n.toString(),l.toString(),t)}),r));return a.createElement(Eu.lV,{"data-external-id":"notification-additional-preferences",initialValues:i,onSubmit:l},a.createElement(sot,null,c,a.createElement(cot,{variant:"default",size:"medium"},"Save")),n===t.id&&a.createElement(dot,null,s," updated"))},iot=(0,u.default)(Qw.X).withConfig({displayName:"NotificationAdditionalPreferences__StyledTextField",componentId:"sc-1trne2f-0"})(["width:169px;"]),sot=(0,u.default)(ZY.B).withConfig({displayName:"NotificationAdditionalPreferences__FormContainer",componentId:"sc-1trne2f-1"})(["align-items:flex-end;"]),cot=(0,u.default)(CJ.I).withConfig({displayName:"NotificationAdditionalPreferences__StyledFormSubmitButton",componentId:"sc-1trne2f-2"})(["width:auto;margin-left:",";margin-top:0;"],vt.YK.default),dot=u.default.div.withConfig({displayName:"NotificationAdditionalPreferences__Success",componentId:"sc-1trne2f-3"})(["color:",";"],vt.yW.green),uot=e=>{let t=e.isSupported,n=e.name,l=e.onChange,r=e.checked,o=e.tooltipPlacement,i=void 0===o?"top":o;return a.createElement("div",{"data-external-id":"notification-type-setting-toggle",className:"flex size-full flex-1 items-center justify-end"},a.createElement(JY.d,{disable:t,place:i,content:_t.U_.disabledToggleTooltip,clickable:!1},a.createElement("div",{className:"flex"},a.createElement(ox.k,{name:n,checked:r,disabled:!t,onChange:l}))))},mot={inAppEnabled:void 0,emailEnabled:void 0,pushEnabled:void 0,additionalPreferences:void 0},pot=["Accounts","Transactions","Receipts","Investments","Budget","Bill Sync","Recurring","Goals","Other"],got=["isLastInGroup"],hot=e=>{let t=e.isLastInGroup,n=(0,En.A)(e,got);const l=n.id,r=n.title,s=n.description,c=n.inAppEnabled,d=n.emailEnabled,u=n.pushEnabled,m=n.additionalPreferencesMeta,p=n.type,g=(0,i.n)(Xrt),h=(0,o.A)(g,1)[0],v=(0,a.useState)(void 0),f=(0,o.A)(v,2),E=f[0],y=f[1],b=(0,C.RU)(),x=null!==u,w=null!==c,A=null!==d,I=async e=>{try{var t,a;const r=(0,U.A)((0,U.A)({},n),e);
1if(null===(t=(await h({variables:{input:(0,U.A)((0,U.A)({id:l},mot),e)},optimisticResponse:{__typename:"Mutation",updateNotificationPreferences:{__typename:"UpdateNotificationPreferences",notificationPreference:r,errors:null}}})).data)||void 0===t||null===(a=t.updateNotificationPreferences)||void 0===a||!a.errors){const t=((e,t)=>"emailEnabled"in e?{channel:"email",key:"emailEnabled",previousSetting:t.emailEnabled,newSetting:e.emailEnabled}:"pushEnabled"in e?{channel:"push",key:"pushEnabled",previousSetting:t.pushEnabled,newSetting:e.pushEnabled}:"inAppEnabled"in e?{channel:"in-app",key:"inAppEnabled",previousSetting:t.inAppEnabled,newSetting:e.inAppEnabled}:void 0)(e,n);if(t){const e=t.channel,n=t.previousSetting,a=t.newSetting;(0,Ge.u4)(Ye.lb.NotificationSettingsUpdated,{type:p,channel:e,previousSetting:n,newSetting:a})}}}catch(r){b()}};return a.createElement(vot,{"data-external-id":"notification-settings-row",$isLastInGroup:t},a.createElement("div",{className:"flex size-full flex-1 flex-col gap-2xs"},a.createElement(xt.v,{weight:"medium"},r),a.createElement(xt.v,{weight:"book"},s),!!m&&a.createElement(oot,{notificationPreference:n,onSubmit:async e=>{var t,a;const r=(0,U.A)((0,U.A)({},n),{},{additionalPreferences:e});return(null===(t=(await h({variables:{input:(0,U.A)((0,U.A)({},mot),{},{id:l,additionalPreferences:e})},optimisticResponse:{__typename:"Mutation",updateNotificationPreferences:{__typename:"UpdateNotificationPreferences",notificationPreference:r,errors:null}}})).data)||void 0===t||null===(a=t.updateNotificationPreferences)||void 0===a?void 0:a.errors)?(b(),Promise.reject()):(y(l),Promise.resolve())},lastSuccessfulUpdate:E})),a.createElement(uot,{isSupported:w,name:"inAppEnabled",checked:!!c,onChange:e=>{let t=e.target.checked;return I({inAppEnabled:t})}}),a.createElement(uot,{isSupported:A,name:"emailEnabled",checked:!!d,onChange:e=>{let t=e.target.checked;return I({emailEnabled:t})}}),a.createElement(uot,{isSupported:x,name:"pushEnabled",checked:!!u,onChange:e=>{let t=e.target.checked;return I({pushEnabled:t})},tooltipPlacement:"left"}))},vot=u.default.div.withConfig({displayName:"NotificationSettingsRow__Root",componentId:"sc-1owazje-0"})(["display:grid;grid-template-columns:1fr ","px ","px ","px;gap:",";padding:"," ",";",""],not,not,not,vt.YK.xxlarge,vt.YK.default,vt.YK.xlarge,(e=>{let t=e.$isLastInGroup,n=e.theme;return!t&&(0,u.css)(["border-bottom:1px solid ",";"],n.variables.color.divider.primary)})),fot=["wheel","touchmove","keydown","pointerdown"],Eot=function(e){let t,n,a=(arguments.length>1&&void 0!==arguments[1]?arguments[1]:{}).holdMs;const l=()=>{void 0!==t&&(cancelAnimationFrame(t),t=void 0),clearTimeout(d),fot.forEach((e=>window.removeEventListener(e,l)))},r=()=>e.scrollIntoView({behavior:"auto",block:"start"}),o=(e=>{for(let t=e.parentElement;t;t=t.parentElement){const e=getComputedStyle(t).overflowY;if("auto"===e||"scroll"===e)return t}return document.documentElement})(e),i=o===document.documentElement,s=()=>({offset:e.getBoundingClientRect().top-(i?0:o.getBoundingClientRect().top),scrollHeight:o.scrollHeight}),c=()=>{const e=s(),a=e.offset!==n.offset||e.scrollHeight!==n.scrollHeight;n=e,a&&Math.abs(e.offset)>2&&r(),t=requestAnimationFrame(c)};r(),n=s(),t=requestAnimationFrame(c);const d=setTimeout(l,null!==a&&void 0!==a?a:5e3);return fot.forEach((e=>window.addEventListener(e,l,{passive:!0}))),l},yot=["wheel","touchmove","keydown","pointerdown"],bot=["animate-highlight-ring"],xot=["highlight-ring-static"],wot=()=>"function"===typeof window.matchMedia&&window.matchMedia("(prefers-reduced-motion: reduce)").matches,Cot=()=>wot()?[...xot]:[...bot],Aot=(e,t)=>{var n,a;const l=null!==(n=null===(a=window.CSS)||void 0===a?void 0:a.escape)&&void 0!==n?n:e=>e;return t.querySelector("[".concat(Ue.dp,'="').concat(l(e),'"]'))},Iot=e=>{const t=Cot();e.classList.add(...t);const n=setTimeout((()=>e.classList.remove(...t)),2400);return()=>{clearTimeout(n),e.classList.remove(...t)}},kot=e=>e.toLowerCase().replace(/\s+/g,"-"),Sot=e=>{let t=e.virtuosoRef,n=e.groupCounts,r=e.topOffsetPx;const i=(0,l.zy)(),s=i.hash,c=i.state,d=null===c||void 0===c?void 0:c.settingsSectionNonce,u=(0,nG.p)(Ue.rt,"off"),m=(0,a.useState)(),p=(0,o.A)(m,2),g=p[0],h=p[1],v=(0,a.useRef)();return(0,a.useEffect)((()=>{var e,a,l;if(!u||!s)return null===(l=v.current)||void 0===l||l.teardown(),void(v.current=void 0);if(0===n.length)return;const o=(0,Ue.Cs)(s),i="".concat(null!==o&&void 0!==o?o:"","#").concat(null!==d&&void 0!==d?d:"");if(!o||(null===(e=v.current)||void 0===e?void 0:e.key)===i)return;const c=n.findIndex((e=>{let t=e.title;return kot(t)===o}));if(c<0)return;null===(a=v.current)||void 0===a||a.teardown();const m=n.slice(0,c).reduce(((e,t)=>e+t.count),0),p=()=>{var e;return null===(e=t.current)||void 0===e?void 0:e.scrollToIndex({index:m,align:"start",offset:-(r+24),behavior:wot()?"auto":"smooth"})};p();const g=setInterval((()=>{Aot(o,document)?clearInterval(g):p()}),400),f=setTimeout((()=>clearInterval(g)),1e4);let E,y;const b=((e,t)=>{let n,a=0,l=!1;const r=Date.now()+1e4,o=setInterval((()=>{const i=Aot(e,document),s=null===i||void 0===i?void 0:i.getBoundingClientRect().top,c=void 0!==s&&void 0!==n&&Math.abs(s-n)<1;a=c?a+1:0,n=s;const d=l&&document.activeElement===document.body;i&&a>=3&&(!l||d)&&(l||t(i),i.focus({preventScroll:!0}),l=!0),Date.now()>=r&&clearInterval(o)}),120);return()=>clearInterval(o)})(o,(e=>{var t;h(o);const n=null!==(t=e.firstElementChild)&&void 0!==t?t:e;y=Iot(n),E=setTimeout((()=>h(void 0)),2400)})),x=()=>{clearInterval(g),clearTimeout(f),b(),yot.forEach((e=>window.removeEventListener(e,x)))};yot.forEach((e=>window.addEventListener(e,x,{passive:!0}))),v.current={key:i,teardown:()=>{var e;x(),clearTimeout(E),null===(e=y)||void 0===e||e(),h(void 0)}}}),[u,s,d,n,r,t]),(0,a.useEffect)((()=>()=>{var e;return null===(e=v.current)||void 0===e?void 0:e.teardown()}),[]),{highlightedGroupId:g}},Not=["children","style"],Tot=["children"],_ot=e=>{var t;let n=e.notificationPreferences;const l=(0,a.useContext)(ri.z).scrollRef,i=(0,a.useRef)(null),s=(0,nG.p)(Ue.rt,"off"),c=(0,a.useMemo)((()=>(e=>{const t=Object.entries((0,LD.A)((e=>e.group?String(e.group):""),e)).map((e=>{let t=(0,o.A)(e,2),n=t[0],a=t[1];return[n,(0,Nc.A)((e=>(e.title||"").toLowerCase()),a)]}));return(0,Fo.A)([(e,t)=>{let n=(0,o.A)(e,1)[0],a=(0,o.A)(t,1)[0];const l=pot.indexOf(n),i=pot.indexOf(a);return(0,r.YW)([l,i]).with([-1,-1],(()=>0)).with([-1,r.zJ._],(()=>1)).with([r.zJ._,-1],(()=>-1)).otherwise((()=>l-i))}],t)})(n)),[n]),d=(0,a.useMemo)((()=>c.map((e=>{let t=(0,o.A)(e,2);t[0];return t[1].length}))),[c]),u=(0,a.useMemo)((()=>c.map((e=>{let t=(0,o.A)(e,2),n=t[0];return{title:null!==n&&void 0!==n?n:"",count:t[1].length}}))),[c]),m=Sot({virtuosoRef:i,groupCounts:u,topOffsetPx:76}).highlightedGroupId,p=(0,a.useMemo)((()=>c.flatMap((e=>{let t=(0,o.A)(e,2);t[0];return t[1]}))),[c]),g=(0,a.useMemo)((()=>({Group:e=>{let t=e.children,n=e.style,l=(0,En.A)(e,Not);return a.createElement("div",Object.assign({style:(0,U.A)((0,U.A)({},n),{},{zIndex:"auto"})},l),t)},TopItemList:e=>{var t;let l=e.children,r=(0,En.A)(e,Tot);return a.createElement("div",Object.assign({},r,{style:(0,U.A)((0,U.A)({},null!==(t=r.style)&&void 0!==t?t:{}),{},{marginTop:0})}),a.createElement(aot,{notificationPreferences:n}),l)},Header:()=>a.createElement("div",{style:{marginTop:76}})})),[n]);return a.createElement(Dot,{"data-external-id":"notification-settings-card"},a.createElement(Ac.kN,{ref:i,style:{height:"auto",borderRadius:"8px"},groupCounts:d,components:g,groupContent:e=>{const t=c[e]||[],n=(0,o.A)(t,1)[0];if(!n)return null;const l=kot(n);return a.createElement("div",(0,Qhe.g)(s,l),a.createElement(H3.X,{className:(0,q.cn)(l===m&&Cot())},n))},itemContent:e=>{var t,n;const l=p[e],r=(0,Tce.A)(l.id,null===(t=(0,Sc.A)((null===(n=(0,xBe.A)((e=>(0,o.A)(e,1)[0]===(l.group||"")),c))||void 0===n?void 0:n[1])||[]))||void 0===t?void 0:t.id);return a.createElement(hot,Object.assign({},l,{isLastInGroup:r}))},customScrollParent:null!==(t=null===l||void 0===l?void 0:l.current)&&void 0!==t?t:void 0}))},Dot=u.default.div.withConfig({displayName:"NotificationSettingsCard__ListContainer",componentId:"sc-1habb68-0"})(["padding-bottom:","px;"],76),Rot=()=>{const e=(0,Tse._)().isDemoHousehold,t=(0,Xo.IT)(Jrt).data,n=(0,a.useMemo)((()=>{var e;return null!==(e=null===t||void 0===t?void 0:t.notificationPreferences)&&void 0!==e?e:[]}),[null===t||void 0===t?void 0:t.notificationPreferences]);return a.createElement(mX.V,{"data-external-id":"notification-settings",md:9},a.createElement(Ffe,{isDemo:e,anchorId:"notifications"},a.createElement(Xhe.Ay,null,a.createElement("title",null,"Notification Settings")),t&&a.createElement(_ot,{notificationPreferences:n})))},Mot=e=>{let t=e.onCancel,n=e.onDelete;const l=(0,C.RU)(),r=(0,z.h)().setActiveThread,s=(0,a.useState)(!1),c=(0,o.A)(s,2),d=c[0],u=c[1],m=(0,i.n)(Qe.wt,{refetchQueries:[{query:Qe.ps},es.YV],awaitRefetchQueries:!0}),p=(0,o.A)(m,1)[0];return a.createElement(xC.$,{"data-external-id":"delete-all-chats-confirmation",title:_t.r5.AI_OPT_OUT_SETTINGS.DELETE_CHATS.TITLE,confirm:_t.r5.AI_OPT_OUT_SETTINGS.DELETE_CHATS.CONFIRM,isLoading:d,onCancel:t,onConfirm:async()=>{u(!0);try{var e;const o=(await p()).data;if(null!==o&&void 0!==o&&null!==(e=o.deleteAllMessageThreads)&&void 0!==e&&e.success){const e=o.deleteAllMessageThreads.affectedCount;r(null),(0,C.oR)({title:_t.r5.AI_OPT_OUT_SETTINGS.DELETE_CHATS.SUCCESS(e)}),n()}else{var a;const e=null===o||void 0===o||null===(a=o.deleteAllMessageThreads)||void 0===a?void 0:a.errors;l({description:(null===e||void 0===e?void 0:e.message)||_t.r5.AI_OPT_OUT_SETTINGS.DELETE_CHATS.ERROR}),t()}}catch(o){l({description:_t.r5.AI_OPT_OUT_SETTINGS.DELETE_CHATS.ERROR}),t()}finally{u(!1)}}},_t.r5.AI_OPT_OUT_SETTINGS.DELETE_CHATS.DESCRIPTION)},Lot=()=>{const e=(0,lt.L7)({fetchPolicy:"cache-and-network"}),t=e.householdPreferences,n=e.isLoadingInitialData,l=e.updateHouseholdPreferences,r=u4(),i=(0,Pd.h)(),s=(0,o.A)(i,2),c=s[0],d=s[1],u=d.open,m=d.close,g=(0,Qhe.x)("delete-chats");return a.createElement(mX.V,{"data-external-id":"preferences-settings",md:9},a.createElement(Eu.lV,{initialValues:{pendingTransactionsCanBeEdited:null===t||void 0===t?void 0:t.pendingTransactionsCanBeEdited,newTransactionsNeedReview:null===t||void 0===t?void 0:t.newTransactionsNeedReview,uncategorizedTransactionsNeedReview:null===t||void 0===t?void 0:t.uncategorizedTransactionsNeedReview,aiAssistantEnabled:null===t||void 0===t?void 0:t.aiAssistantEnabled,hiddenTransactionsBetaEnabled:null===t||void 0===t?void 0:t.hiddenTransactionsBetaEnabled,aggDataSharingEnabled:null===t||void 0===t?void 0:t.aggDataSharingEnabled,aiModelTrainingOnUserDataEnabled:null===t||void 0===t?void 0:t.aiModelTrainingOnUserDataEnabled},onSubmit:async e=>{await l(e)},enableReinitialize:!0,submitOnChange:!0,preventSubmitWhileSubmitting:!0},n?a.createElement(Pot,null,a.createElement(Bot,null,a.createElement(p.i,null))):a.createElement(a.Fragment,null,a.createElement(Pot,{title:_t.e6.SETTINGS.SECTION_HEADER,anchorId:"transactions"},a.createElement(Oot,{fieldCellProps:{title:_t.e6.SETTINGS.NEW_TRANSACTIONS_NEED_REVIEW.TITLE,subtitle:_t.e6.SETTINGS.NEW_TRANSACTIONS_NEED_REVIEW.SUBTITLE},toggleFieldProps:{name:"newTransactionsNeedReview"}}),a.createElement(Oot,{fieldCellProps:{title:_t.e6.SETTINGS.UNCATEGORIZED_NEED_REVIEW.TITLE,subtitle:_t.e6.SETTINGS.UNCATEGORIZED_NEED_REVIEW.SUBTITLE},toggleFieldProps:{name:"uncategorizedTransactionsNeedReview"}}),a.createElement(Oot,{fieldCellProps:{title:_t.e6.SETTINGS.PEND
1ING.TITLE,subtitle:a.createElement("div",{className:"mr-3xl flex flex-col"},a.createElement(xt.v,null,_t.e6.ALLOW_EDITS_TO_PENDING_SUBTITLE),a.createElement(zot,{type:"info"},a.createElement("div",{className:"flex"},a.createElement("div",{className:"mt-2xs mr-sm flex"},a.createElement(sl.ZQ,{name:"help-circle",size:16})),_t.e6.ALLOW_EDITS_TO_PENDING_DISCLAIMER)))},toggleFieldProps:{name:"pendingTransactionsCanBeEdited"}})),a.createElement(Pot,{title:r?_t.r5.AI_OPT_OUT_SETTINGS.SECTION_TITLE_WITH_FINANCIAL_AGENTS:_t.r5.AI_OPT_OUT_SETTINGS.SECTION_TITLE,anchorId:"ai-assistant"},a.createElement(Fot,null,a.createElement(xt.v,null,r?_t.r5.AI_OPT_OUT_SETTINGS.SECTION_DESCRIPTION_WITH_FINANCIAL_AGENTS:a.createElement(a.Fragment,null,_t.r5.AI_OPT_OUT_SETTINGS.SECTION_DESCRIPTION_BEFORE_ICON," ",a.createElement(fe.bQo,{size:"2xs",className:"align-middle text-content-brand"})," ",_t.r5.AI_OPT_OUT_SETTINGS.SECTION_DESCRIPTION_AFTER_ICON)," ",a.createElement(wb.gz,{href:VF.Uz,target:"_blank"},_t.r5.AI_IN_MONARCH.LEARN_MORE))),a.createElement(Got,{fieldCellProps:{title:r?_t.r5.AI_OPT_OUT_SETTINGS.TOGGLE_TITLE_WITH_FINANCIAL_AGENTS:_t.r5.AI_OPT_OUT_SETTINGS.TOGGLE_TITLE,subtitle:r?_t.r5.AI_OPT_OUT_SETTINGS.TOGGLE_SUBTITLE_WITH_FINANCIAL_AGENTS:_t.r5.AI_OPT_OUT_SETTINGS.TOGGLE_SUBTITLE},toggleFieldProps:{name:"aiAssistantEnabled"}}),a.createElement(Yot,Object.assign({padding:"xlarge",justifyBetween:!0,alignCenter:!0,gap:"large"},g),a.createElement("div",{className:"flex flex-col gap-2xs"},a.createElement(xt.v,{weight:"medium"},_t.r5.AI_OPT_OUT_SETTINGS.DELETE_CHATS.TITLE),a.createElement(xt.v,{size:"small"},_t.r5.AI_OPT_OUT_SETTINGS.DELETE_CHATS.DESCRIPTION),a.createElement(xt.v,{size:"small"},_t.r5.AI_OPT_OUT_SETTINGS.DELETE_CHATS.NOTE)),a.createElement(G7.jI,{onClick:u},_t.r5.AI_OPT_OUT_SETTINGS.DELETE_CHATS.BUTTON))),a.createElement(uX,{name:"switch-preferences-allow-agg-data-sharing-web-mobile",defaultOnTimeout:"on"},a.createElement(Pot,{title:"Trend and benchmark sharing",anchorId:"trend-and-benchmark-sharing"},a.createElement(Oot,{fieldCellProps:{title:a.createElement(xt.v,null,"Aggregated statistics"),subtitle:a.createElement(xt.v,null,"Monarch may use anonymized and aggregated data in public, non-identifiable"," ","statistics. Your information is combined with others to reveal trends"," ","like average spending or saving patterns. Enabling this gives you access to"," ","current and future features that allow you to compare your income, spending"," ","patterns, and more to people like you in a safe, privacy protected format."," ","Learn more in our"," ",a.createElement(wb.gz,{href:VF.tE,target:"_blank"},"Privacy Policy"),".")},toggleFieldProps:{name:"aggDataSharingEnabled"}}))))),a.createElement(c,null,a.createElement(Mot,{onCancel:m,onDelete:m})))},Oot=(0,u.default)(fPe).withConfig({displayName:"PreferencesSettings__StyledFieldCellWithToggle",componentId:"ru8rg8-0"})(["padding:",";border:none;border-radius:0;.title{font-size:",";}[data-sc-tw~='FieldCell__GroupHorizontalContainer']{align-items:flex-start;}"],vt.YK.xlarge,vt.J.base),Pot=(0,u.default)(Ffe).withConfig({displayName:"PreferencesSettings__StyledSettingsCard",componentId:"ru8rg8-1"})(["margin-bottom:",";"],vt.YK.gutter),Bot=(0,u.default)(m.g).attrs({center:!0}).withConfig({displayName:"PreferencesSettings__LoadingContainer",componentId:"ru8rg8-2"})(["padding:",";"],vt.YK.xxlarge),zot=(0,u.default)(fu.g).withConfig({displayName:"PreferencesSettings__StyledBanner",componentId:"ru8rg8-3"})(["margin-top:",";"],vt.YK.xlarge),Fot=(0,u.default)(m.g).attrs({column:!0}).withConfig({displayName:"PreferencesSettings__AiContentContainer",componentId:"ru8rg8-4"})(["padding:"," ",";gap:",";border-bottom:1px solid ",";"],vt.YK.large,vt.YK.xlarge,vt.YK.xlarge,vt.Ee.color.divider.primary),Got=(0,u.default)(Oot).withConfig({displayName:"PreferencesSettings__AiTrainingToggle",componentId:"ru8rg8-5"})(["padding:",";"],vt.YK.xlarge),Yot=(0,u.default)(m.g).withConfig({displayName:"PreferencesSettings__DeleteChatsSection",componentId:"ru8rg8-6"})(["border-top:1px solid ",";"],vt.Ee.color.divider.primary);var Uot=n(21941);const Vot=I1.Ik({name:I1.Yj().label("Full Name").trim().required(_t.kg),displayName:I1.Yj().label("Display Name").trim().required(_t.kg)}),Wot=Intl.supportedValuesOf("timeZone").map((e=>({value:e,label:e}))),jot=()=>{var e,t,n,l,r;const s=(0,et.I)(du.QG),c=s.data,d=s.isLoadingInitialData,u=s.refetch,m=(0,i.n)(du.Ds),p=(0,o.A)(m,1)[0],g=null!==(e=null===c||void 0===c?void 0:c.me)&&void 0!==e?e:{},h=g.profilePicture,v=void 0===h?null:h,f=g.profilePictureUrl,E=(e=>{var t;const n=(0,a.useState)(null!==e&&void 0!==e?e:null),l=(0,o.A)(n,2),r=l[0],i=l[1],s=(0,a.useRef)(!1);(0,a.useEffect)((()=>{void 0===e||s.current||i(null!==e&&void 0!==e?e:null)}),[e]);const c=(0,a.useCallback)((e=>{s.current=!0,i(e)}),[]),d=null!==(t=null!==r&&void 0!==r?r:e)&&void 0!==t?t:null;return{displayAvatarColor:d,selectAvatarColor:c,avatarColorForSubmit:d,hasColorChanged:d!==(null!==e&&void 0!==e?e:null)}})(g.avatarColor),y=E.displayAvatarColor,b=E.selectAvatarColor,x=E.avatarColorForSubmit,w=E.hasColorChanged,C=(0,_V.A)(["name","timezone","birthday","displayName"],null!==(t=null===c||void 0===c?void 0:c.me)&&void 0!==t?t:{});return a.createElement(mX.V,{"data-external-id":"profile-settings",md:9},a.createElement(Ffe,{title:"Profile",anchorId:"profile"},a.createElement(Xhe.Ay,null,a.createElement("title",null,"Profile Settings")),a.createElement("div",{className:(0,q.cn)("m-xl",fl.TN.className)},a.createElement(Uot.P,{isLoadingInitialData:d,userId:null===c||void 0===c||null===(n=c.me)||void 0===n?void 0:n.id,userName:null===c||void 0===c||null===(l=c.me)||void 0===l?void 0:l.displayName,activeProfilePictureUrl:f,profilePicture:v,selectedAvatarColor:y,onAvatarColorChange:b,refetchUser:u}),a.createElement(Eu.lV,{initialValues:C,mutation:p,overrideValidationSchema:Vot,transformValuesBeforeSubmit:e=>{var t;return(0,U.A)((0,U.A)({},e),{},{name:null===(t=e.name)||void 0===t?void 0:t.trim(),avatarColor:x})},className:"flex flex-col gap-default"},a.createElement(tC.zB.Text,{name:"name",label:"Full Name"}),a.createElement(tC.zB.Text,{name:"displayName",label:"Display Name",description:"We'll address you by this name in the app and emails"}),a.createElement(tC.zB.Date,{name:"birthday",label:"Birthday",dateFormat:iC.yP,min:aC,max:null!==(r=N.c9.now().toISODate())&&void 0!==r?r:void 0,className:"mb-0"}),a.createElement(tC.zB.Combobox,{name:"timezone",label:"Timezone",options:Wot}),a.createElement(CJ.I,{className:"mt-0",disableWhenValuesUnchanged:!w},"Update Profile")))))},Hot=["SHARE_STEP","DISCOUNT_STEP","EARNINGS_STEP"].map((e=>{const t=_t.rF.PROCESS[e];return{title:t.TITLE,description:t.DESCRIPTION,descriptionLine2:"DESCRIPTION_LINE_2"in t?t.DESCRIPTION_LINE_2:void 0,disclaimer:"DISCLAIMER"in t?t.DISCLAIMER:void 0}}));var Kot=n(19697);const qot=e=>{let t=e.className;return a.createElement($ot,{"data-external-id":"ticket-svg",className:t,viewBox:"0 0 310 233",fill:"none",xmlns:"http://www.w3.org/2000/svg"},a.createElement("g",null,a.createElement("path",{d:"M258.144 4.23389C260.677 3.55508 263.282 5.05861 263.96 7.59195L269.492 28.2348L269.489 28.2356C263.156 29.9328 259.397 36.4425 261.094 42.7759C262.791 49.109 269.301 52.8675 275.634 51.1707L275.637 51.169L279.939 67.2247L279.936 67.2254C273.603 68.9226 269.844 75.4324 271.541 81.7657C273.238 88.099 279.748 91.8574 286.082 90.1605L286.084 90.1588L290.694 107.362L290.691 107.362C284.358 109.059 280.599 115.569 282.296 121.903C283.993 128.236 290.503 131.995 296.836 130.298L296.839 130.297L302.063 149.792C302.741 152.325 301.238 154.929 298.705 155.608L52.1483 221.672C49.615 222.351 47.0116 220.847 46.3329 218.314L41.1092 198.819C47.4409 197.121 51.198 190.612 49.5012 184.28C47.8043 177.947 41.2962 174.189 34.9638 175.884L30.3543 158.681C36.686 156.983 40.4434 150.475 38.7466 144.143C37.0497 137.81 30.5416 134.052 24.2091 135.747L19.907 119.692C26.2386 117.993 29.9959 111.485 28.2993 105.153C26.6025 98.8205 20.0944 95.0623 13.7618 96.7574L8.2306 76.1145C7.55186 73.5813 9.05461 70.9774 11.5877 70.2985L258.144 4.23389Z",fill:"url(#paint0_linear_2379_4110)"}),a.createElement("g",{clipPath:"url(#clip0_2379_4110)"},a.createElement("g",{opacity:"0.08",clipPath:"url(#clip1_2379_4110)"},a.createElement("path",{d:"M265.839 170.695C257.704 175.391 248.353 175.904 237.724 172.993C222.112 168.962 208.804 158.676 200.246 144.045C194.558 134.3
113 190.38 123.178 190.734 113.452C186.742 115.006 182.676 116.935 178.572 119.305L177.793 119.755C173.688 122.124 169.978 124.67 166.646 127.345C175.214 131.892 182.785 141.083 188.375 150.885C196.777 165.605 199.015 182.27 194.706 197.816C191.703 209.265 185.884 217.553 176.803 222.002C168.861 225.905 159.722 226.031 151.092 222.383C137.085 216.717 127.893 202.091 126.5 183.267C125.476 169.354 128.926 152.273 139.458 136.42C131.967 135.803 125.397 136.394 118.228 137.053C106.409 138.128 93.022 139.342 73.1158 135.287C47.6029 130.013 28.1289 104.201 32.2848 81.1442C34.4918 68.7478 42.9059 57.3613 54.648 50.7073C66.797 43.8462 81.272 42.7414 94.3848 47.6989C97.0889 48.6155 123.156 55.8562 146.643 80.103C149.121 82.6672 149.004 86.7582 146.34 89.1033L143.688 91.4421C141.621 93.2615 138.501 93.0865 136.595 91.0826C114.9 68.4042 89.8729 61.8853 89.5982 61.7935L89.2846 61.6822C80.1531 58.1984 70.4534 58.9126 61.9959 63.6981C54.0536 68.2001 48.3659 75.7435 46.9142 83.8339C44.2178 98.8376 58.6646 117.07 76.0621 120.668C93.8054 124.288 105.517 123.22 116.839 122.195C126.881 121.283 136.729 119.506 150.115 122.106C155.708 116.58 162.404 111.407 170.331 106.83L171.109 106.38C179.047 101.797 186.865 98.592 194.446 96.5115C198.873 83.6411 205.347 75.9955 211.162 67.7379C217.71 58.4451 224.491 48.8365 230.232 31.6437C235.821 14.7889 227.244 -6.83287 212.903 -11.9996C205.252 -14.7653 196.037 -13.6906 188.183 -9.1562C188.1 -9.10819 188.007 -9.05431 187.924 -9.0063C179.54 -4.06864 174.082 3.96852 172.533 13.6187L172.473 13.9457C172.415 14.2296 165.547 39.163 174.344 69.2744C175.116 71.9327 173.701 74.7122 171.109 75.5966L167.757 76.7243C164.394 77.8584 160.782 75.9208 159.811 72.4866C150.567 40.0167 157.319 13.8274 157.877 11.0276C160.157 -2.80284 168.341 -14.7801 180.357 -21.8709C191.997 -28.7025 206.059 -30.3065 217.909 -26.026C239.95 -18.0799 252.561 11.6804 244.361 36.4183C237.915 55.7018 230.171 66.6881 223.331 76.3865C219.182 82.2758 214.884 86.8282 211.683 93.6173C230.672 92.4127 247.69 98.807 259.217 106.657C274.822 117.275 282.893 132.549 280.797 147.512C279.646 156.82 274.962 164.662 267.611 169.588C267.032 169.977 266.431 170.353 265.829 170.7L265.839 170.695ZM206.243 109.217C204.378 117.072 207.754 127.419 213.086 136.533C216.866 143.01 225.578 154.476 241.433 158.546L241.549 158.576C248.763 160.564 254.557 160.365 259.313 157.159C263.11 154.619 265.444 150.599 266.055 145.541L266.078 145.388C267.367 136.32 261.558 126.186 250.914 118.954C240.471 111.857 224.325 106.323 206.247 109.201L206.243 109.217ZM155.242 138.662C143.71 152.879 140.429 169.629 141.355 182.221C142.295 195.055 148.168 205.154 156.666 208.572L156.809 208.629C161.495 210.628 166.143 210.617 170.242 208.599C175.401 206.066 178.465 201.164 180.351 193.922L180.382 193.807C184.775 178.047 179.201 164.77 175.493 158.252C170.241 149.035 162.92 140.925 155.258 138.667L155.242 138.662Z",fill:"white"}))),a.createElement("path",{d:"M124.894 158.578C113.954 161.591 106.71 156.787 104.339 150.568L113.309 148.098C114.756 150.697 118.056 152.858 122.948 151.511C128.656 149.939 130.833 145.1 129.336 139.664C127.876 134.364 123.857 131.45 118.693 132.872C114.548 134.013 112.583 136.967 111.811 139.738L103.181 142.114L98.9442 113.455L126.329 105.914L128.275 112.98L107.617 118.669L109.717 132.931C110.787 130.443 113.857 127.258 118.41 126.005C127.651 123.46 135.297 127.861 137.991 137.646C140.517 146.819 135.631 155.621 124.894 158.578ZM167.078 146.961C156.274 149.937 146.362 143.674 141.834 127.23C137.305 110.786 142.614 100.332 153.419 97.357C164.223 94.3818 174.135 100.644 178.663 117.088C183.192 133.532 177.883 143.986 167.078 146.961ZM165.188 140.098C171.44 138.377 173.544 131.949 170.101 119.446C166.677 107.011 161.56 102.499 155.308 104.22C149.057 105.942 146.971 112.437 150.396 124.873C153.839 137.376 158.937 141.82 165.188 140.098Z",fill:"white"}),a.createElement("path",{d:"M189.948 118.541L201.974 85.4607L206.52 84.2089L194.494 117.289L189.948 118.541ZM212.52 112.793C208.844 113.805 205.085 111.736 203.583 106.281C202.081 100.826 204.251 97.1239 207.927 96.1116C211.603 95.
10993 215.351 97.1289 216.864 102.623C218.367 108.078 216.631 111.661 212.52 112.793ZM211.693 109.789C213.669 109.244 214.183 107.402 213.149 103.647C212.136 99.9705 210.72 98.532 208.743 99.0763C206.767 99.6205 206.286 101.581 207.298 105.258C208.333 109.013 209.756 110.322 211.693 109.789ZM188.301 106.534C184.624 107.547 180.865 105.477 179.363 100.022C177.861 94.5675 180.031 90.8655 183.707 89.8532C187.383 88.8409 191.132 90.8706 192.645 96.365C194.147 101.82 192.412 105.402 188.301 106.534ZM187.473 103.53C189.45 102.986 189.963 101.143 188.929 97.3882C187.917 93.7121 186.5 92.2736 184.523 92.8179C182.547 93.3621 182.066 95.3231 183.079 98.9993C184.113 102.754 185.536 104.063 187.473 103.53Z",fill:"white"}),a.createElement("path",{d:"M196.435 138.371C192.605 139.426 188.518 137.456 187.316 133.09C186.108 128.704 188.615 124.939 192.445 123.884C196.276 122.829 200.357 124.78 201.565 129.166C202.767 133.532 200.265 137.317 196.435 138.371ZM195.85 136.248C198.51 135.516 199.803 133.003 198.945 129.887C198.082 126.751 195.69 125.275 193.03 126.007C190.371 126.74 189.072 129.233 189.935 132.368C190.793 135.484 193.191 136.98 195.85 136.248ZM205.972 135.425L202.147 121.533L211.038 119.084L211.639 121.267L205.229 123.033L206.251 126.744L211.669 125.252L212.248 127.355L206.83 128.847L208.453 134.742L205.972 135.425ZM217.058 132.372L213.233 118.48L222.123 116.032L222.725 118.215L216.314 119.98L217.336 123.691L222.754 122.199L223.334 124.303L217.916 125.795L219.539 131.689L217.058 132.372Z",fill:"white"}),a.createElement("path",{d:"M130.561 91.5218C126.593 92.6146 122.867 90.3952 121.696 86.1434C120.464 81.669 122.766 77.7678 126.977 76.6082C130.844 75.5433 133.469 77.3252 134.493 79.2216L131.901 79.9353C131.063 78.9464 129.72 78.1835 127.533 78.7857C124.901 79.5105 123.421 81.9656 124.363 85.3872C125.244 88.5861 127.607 90.0483 130.482 89.2566C132.669 88.6544 134.068 86.8533 133.473 84.1418L128.614 85.4799L128.057 83.4553L135.102 81.515L137.26 89.3504L134.932 89.9915L134.463 88.2908C133.997 89.6826 132.707 90.9308 130.561 91.5218ZM140.36 88.4969L136.457 74.3244L138.988 73.6275L142.89 87.7999L140.36 88.4969ZM149.531 85.9711L140.83 73.12L143.543 72.3729L148.324 79.5295L150.479 82.7695L150.5 82.764L150.728 78.8458L151.217 70.2599L153.808 69.5462L152.791 85.0735L149.531 85.9711ZM159.518 83.2209L155.616 69.0485L165.536 66.3165L166.133 68.4829L158.743 70.5179L159.752 74.1825L166.029 72.4541L166.614 74.58L160.338 76.3084L161.453 80.3577L168.944 78.2948L169.54 80.4611L159.518 83.2209Z",fill:"white"}),a.createElement("path",{d:"M124.894 158.578C113.954 161.591 106.71 156.787 104.339 150.568L113.309 148.098C114.756 150.697 118.056 152.858 122.948 151.511C128.656 149.939 130.833 145.1 129.336 139.664C127.876 134.364 123.857 131.45 118.693 132.872C114.548 134.013 112.583 136.967 111.811 139.738L103.181 142.114L98.9442 113.455L126.329 105.914L128.275 112.98L107.617 118.669L109.717 132.931C110.787 130.443 113.857 127.258 118.41 126.005C127.651 123.46 135.297 127.861 137.991 137.646C140.517 146.819 135.631 155.621 124.894 158.578ZM167.078 146.961C156.274 149.937 146.362 143.674 141.834 127.23C137.305 110.786 142.614 100.332 153.419 97.357C164.223 94.3818 174.135 100.644 178.663 117.088C183.192 133.532 177.883 143.986 167.078 146.961ZM165.188 140.098C171.44 138.377 173.544 131.949 170.101 119.446C166.677 107.011 161.56 102.499 155.308 104.22C149.057 105.942 146.971 112.437 150.396 124.873C153.839 137.376 158.937 141.82 165.188 140.098Z",fill:"white"}),a.createElement("path",{d:"M196.435 138.371C192.605 139.426 188.518 137.456 187.316 133.09C186.108 128.704 188.615 124.939 192.445 123.884C196.276 122.829 200.357 124.78 201.565 129.166C202.767 133.532 200.265 137.317 196.435 138.371ZM195.85 136.248C198.51 135.516 199.803 133.003 198.945 129.887C198.082 126.751 195.69 125.275 193.03 126.007C190.371 126.74 189.072 129.233 189.935 132.368C190.793 135.484 193.191 136.98 195.85 136.248ZM205.972 135.425L202.147 121.533L211.038 119.084L211.639 121.267L205.229 123.033L206.251 126.744L211.669 125.252L212.248 127.355L206.83 128.847L208.453 134.742L205.972 135.425ZM217.058 
1132.372L213.233 118.48L222.123 116.032L222.725 118.215L216.314 119.98L217.336 123.691L222.754 122.199L223.334 124.303L217.916 125.795L219.539 131.689L217.058 132.372Z",fill:"white"})),a.createElement("defs",null,a.createElement("linearGradient",{id:"paint0_linear_2379_4110",x1:"258.958",y1:"-8.82462",x2:"201.595",y2:"210.947",gradientUnits:"userSpaceOnUse"},a.createElement("stop",{stopColor:"#FE682F"}),a.createElement("stop",{offset:"1",stopColor:"#E4494E"})),a.createElement("clipPath",{id:"clip0_2379_4110"},a.createElement("rect",{width:"239.82",height:"156.714",fill:"white",transform:"translate(18.4668 68.4492) rotate(-15)"})),a.createElement("clipPath",{id:"clip1_2379_4110"},a.createElement("rect",{width:"232.788",height:"232.788",fill:"white",transform:"translate(10.8828 62.5312) rotate(-30)"}))))},$ot=u.default.svg.withConfig({displayName:"TicketSVG__StyledSVG",componentId:"sc-1e8iqpj-0"})(["filter:drop-shadow(0px 3px 6px ",");"],vt.Ee.color.shadow.large),Zot=e=>{let t=e.className;return a.createElement(Jot,{"data-external-id":"gift-card30-svg",className:t,viewBox:"0 0 309 238",fill:"none",xmlns:"http://www.w3.org/2000/svg"},a.createElement("g",{clipPath:"url(#c)"},a.createElement("rect",{width:269.384,height:165.775,y:69.722,fill:"url(#d)",rx:16.578,transform:"rotate(-15 0 69.722)"}),a.createElement("path",{fill:"#fff",fillOpacity:.15,d:"M274.446 184.105c-8.776 5.066-18.859 5.629-30.317 2.504-16.828-4.325-31.167-15.39-40.379-31.138-6.123-10.476-10.617-22.464-10.224-32.94a95.722 95.722 0 0 0-13.121 6.317l-.84.485c-4.428 2.556-8.431 5.302-12.026 8.186 9.233 4.889 17.386 14.779 23.404 25.33 9.044 15.846 11.44 33.793 6.777 50.54-3.25 12.334-9.532 21.267-19.328 26.068-8.567 4.212-18.421 4.357-27.723.437-15.097-6.088-24.993-21.831-26.476-42.103-1.089-14.984 2.649-33.385 14.021-50.469-8.076-.658-15.161-.013-22.891.704-12.745 1.17-27.18 2.491-48.64-1.856-27.503-5.653-48.473-33.433-43.968-58.27 2.392-13.354 11.476-25.626 24.144-32.805 13.106-7.402 28.715-8.607 42.848-3.282 2.915.985 31.014 8.756 56.313 34.846 2.67 2.76 2.538 7.165-.336 9.694l-2.862 2.522c-2.23 1.961-5.595 1.776-7.648-.38-23.368-24.403-50.346-31.398-50.642-31.496l-.338-.12c-9.843-3.743-20.302-2.963-29.426 2.2C46.2 73.936 40.06 82.066 38.486 90.78c-2.923 16.162 12.635 35.784 31.39 39.641 19.127 3.881 31.756 2.718 43.964 1.603 10.829-.993 21.45-2.917 35.88-.131 6.036-5.957 13.261-11.537 21.813-16.474l.84-.485c8.564-4.944 16.996-8.405 25.173-10.653 4.786-13.867 11.774-22.108 18.053-31.007 7.07-10.016 14.392-20.372 20.599-38.895 6.045-18.159-3.181-41.437-18.639-46.987-8.246-2.97-18.183-1.804-26.656 3.088l-.28.162c-9.045 5.327-14.938 13.989-16.618 24.384l-.066.352c-.062.306-7.494 27.167 1.96 59.589.83 2.862-.698 5.857-3.495 6.812l-3.615 1.218c-3.627 1.225-7.519-.858-8.563-4.556-9.934-34.961-2.625-63.175-2.021-66.19 2.472-14.899 11.309-27.807 24.273-35.457 12.557-7.37 27.721-9.112 40.493-4.514 23.757 8.535 37.324 40.575 28.456 67.227-6.969 20.775-15.331 32.616-22.716 43.069-4.48 6.347-9.118 11.254-12.577 18.57 20.476-1.317 38.818 5.552 51.239 13.994 16.815 11.42 25.501 27.862 23.225 43.98-1.25 10.026-6.309 18.477-14.24 23.79-.624.42-1.273.825-1.923 1.2l.011-.006Zm-64.194-66.151c-2.019 8.462 1.61 19.602 7.35 29.413 4.069 6.972 13.451 19.312 30.542 23.678l.124.033c7.777 2.133 14.024 1.913 19.156-1.544 4.097-2.74 6.617-7.072 7.282-12.521l.024-.164c1.4-9.768-4.854-20.677-16.323-28.455-11.252-7.633-28.656-13.576-48.151-10.458l-.004.018ZM155.23 149.72c-12.448 15.324-16.003 33.368-15.018 46.929 1.001 13.821 7.322 24.692 16.481 28.365l.155.06c5.05 2.148 10.062 2.132 14.484-.046 5.565-2.734 8.874-8.016 10.915-15.817l.033-.124c4.753-16.979-1.244-31.273-5.234-38.289-5.654-9.922-13.539-18.648-21.798-21.073l-.018-.005Z"}),a.createElement("path",{fill:"#000",d:"m92.033 160.249-1.074-4.009c-6.62.791-12.306-2.655-14.384-8.672l5.795-1.553c1.476 3.383 4.068 5.328 7.282 5.347L86.78 140.64l-.982.005c-6.609.062-10.88-2.158-12.173-6.988-1.346-5.023 2.133-10.199 7.953-12.432l-1.061-3.96 4.636-1.242 1.088 4.056c6.33-.712 11.085 2.155 12.956 7.399l-5.796 1.553c-1.294-2.707-3.113-4.083-5.854-4.074l2.64 9.853.11.022c7.108.063 11.516 1.832 
112.94 7.145 1.346 5.022-1.691 10.495-7.64 13.021l1.074 4.008-4.637 1.243Zm-12.9-28.637c.62 2.318 2.174 3.093 6.08 3.184l-2.355-8.789c-2.926 1.249-4.334 3.335-3.726 5.605Zm15.182 18.604c2.887-1.394 4.099-3.634 3.413-6.194-.686-2.56-2.423-3.44-6.002-3.465l2.589 9.659Zm27.888-2.192c-7.389 1.979-12.829-.549-14.971-6.031l6.182-1.657c1.108 2.395 3.86 3.78 7.482 2.81 3.622-.971 5.835-3.531 4.878-7.105-.88-3.284-4.444-4.607-9.467-3.261l-2.318.621-1.281-4.781 2.318-.621c4.54-1.217 6.424-3.844 5.557-7.08-.751-2.801-3.455-4.199-6.546-3.37-3.187.854-4.772 3.245-4.569 5.935l-6.037 1.617c-.796-5.481 2.709-10.561 9.325-12.334 6.907-1.85 12.45 1.064 13.783 6.039 1.009 3.767-.652 7.421-3.976 9.503 4.767.017 8.225 2.299 9.364 6.549 1.462 5.458-2.19 11.147-9.724 13.166Zm30.122-8.071c-7.679 2.057-14.68-2.434-17.812-14.122-3.132-11.687.686-19.077 8.365-21.135 7.679-2.057 14.68 2.434 17.811 14.121 3.132 11.688-.685 19.078-8.364 21.136Zm-1.307-4.878c4.443-1.191 5.967-5.741 3.586-14.627-2.368-8.838-5.976-12.064-10.419-10.874-4.444 1.191-5.955 5.789-3.587 14.627 2.381 8.886 5.976 12.064 10.42 10.874Zm17.938-.355-1.786-6.665 6.568-1.76 1.786 6.665-6.568 1.76Zm23.553-5.535c-7.679 2.058-14.68-2.433-17.812-14.121-3.132-11.688.686-19.077 8.365-21.135s14.68 2.433 17.811 14.121c3.132 11.688-.685 19.078-8.364 21.135Zm-1.307-4.878c4.443-1.19 5.967-5.74 3.586-14.626-2.368-8.839-5.976-12.065-10.419-10.874-4.443 1.19-5.955 5.788-3.587 14.627 2.381 8.886 5.976 12.064 10.42 10.873Zm32.294-3.425c-7.679 2.058-14.68-2.433-17.812-14.121-3.132-11.688.686-19.077 8.365-21.135s14.68 2.433 17.811 14.121c3.132 11.688-.685 19.078-8.364 21.135Zm-1.307-4.878c4.443-1.19 5.967-5.74 3.586-14.626-2.368-8.838-5.976-12.065-10.419-10.874-4.444 1.19-5.955 5.788-3.587 14.627 2.381 8.886 5.976 12.064 10.42 10.873Z"}),a.createElement("path",{fill:"#000",d:"M132.894 94.828c-4.354 1.167-8.418-1.292-9.668-5.957-1.315-4.91 1.235-9.165 5.856-10.403 4.243-1.137 7.105.834 8.211 2.919l-2.843.762c-.911-1.09-2.376-1.935-4.775-1.292-2.888.774-4.528 3.451-3.522 7.206.94 3.51 3.517 5.13 6.672 4.284 2.399-.643 3.945-2.605 3.315-5.58l-5.332 1.43-.595-2.222 7.731-2.072 2.304 8.598-2.555.684-.5-1.866c-.521 1.521-1.944 2.878-4.299 3.51Zm10.755-3.238-4.167-15.552 10.886-2.917.637 2.378-8.109 2.172 1.077 4.021 6.887-1.845.625 2.333-6.887 1.845 1.191 4.443 8.22-2.202.637 2.377-10.997 2.947Zm16.641-4.46-3.507-13.085-4.176 1.12-.661-2.467 11.153-2.988.66 2.466-4.198 1.125 3.506 13.086-2.777.744Z",opacity:.8})),a.createElement("defs",null,a.createElement("clipPath",{id:"a",transform:"translate(173.877 173.877)"},a.createElement("rect",{width:269.384,height:165.775,y:69.722,rx:16.578,transform:"rotate(-15 0 69.722)"})),a.createElement("clipPath",{id:"c"},a.createElement("rect",{width:269.384,height:165.775,y:69.722,fill:"#fff",rx:16.578,transform:"rotate(-15 0 69.722)"})),a.createElement("linearGradient",{id:"d",x1:12.982,x2:243.364,y1:79.226,y2:241.379,gradientUnits:"userSpaceOnUse"},a.createElement("stop",{stopColor:"#FFB293"}),a.createElement("stop",{offset:1,stopColor:"#FFEA8C"})),a.createElement("filter",{id:"b",width:650.864,height:577.602,x:-173.877,y:-173.877,colorInterpolationFilters:"sRGB",filterUnits:"userSpaceOnUse"},a.createElement("feFlood",{floodOpacity:0,result:"BackgroundImageFix"}),a.createElement("feColorMatrix",{in:"SourceAlpha",result:"hardAlpha",values:"0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0"}),a.createElement("feOffset",{dx:-4,dy:4}),a.createElement("feGaussianBlur",{stdDeviation:2}),a.createElement("feComposite",{in2:"hardAlpha",operator:"out"}),a.createElement("feColorMatrix",{values:"0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.17 0"}),a.createElement("feBlend",{in2:"BackgroundImageFix",result:"effect1_dropShadow_1733_18872"}),a.createElement("feBlend",{in:"SourceGraphic",in2:"effect1_dropShadow_1733_18872",result:"shape"}))))},Jot=u.default.svg.withConfig({displayName:"GiftCard30SVG__StyledSVG",componentId:"sc-13gcern-0"})(["filter:drop-shadow(0px 3px 6px ",");"],vt.Ee.color.shadow.large),Xot=e=>{let t=e.className,n=e.variant;return a.createElement(Qot,{"data-external-id":"promo",className:t,t
1iltMaxAngleX:8,tiltMaxAngleY:8},"giftCard"===n&&a.createElement(Zot,null),"ticket"===n&&a.createElement(qot,null))},Qot=(0,u.default)(Kot.A).withConfig({displayName:"Promo__StyledTilt",componentId:"sc-77y4k8-0"})(["width:100%;"]),eit=u.default.div.withConfig({displayName:"ProcessSection__Root",componentId:"sc-1kjok6n-0"})(["display:flex;gap:",";@media (max-width:","px){flex-direction:column;}"],vt.YK.xxlarge,(e=>{let t=e.isSidebarExpanded,n=e.theme;return t?n.breakPoints.lg:n.breakPoints.sm})),tit=(0,u.default)(m.g).withConfig({displayName:"ProcessSection__Block",componentId:"sc-1kjok6n-1"})(["width:50%;@media (max-width:","px){width:100%;}"],(e=>{let t=e.isSidebarExpanded,n=e.theme;return t?n.breakPoints.lg:n.breakPoints.sm})),nit=(0,u.default)(tit).attrs({column:!0}).withConfig({displayName:"ProcessSection__ProcessBlock",componentId:"sc-1kjok6n-2"})(["gap:",";@media (max-width:","px){order:2;}"],vt.YK.xxlarge,(e=>{let t=e.isSidebarExpanded,n=e.theme;return t?n.breakPoints.lg:n.breakPoints.sm})),ait=u.default.div.withConfig({displayName:"ProcessSection__ProcessStep",componentId:"sc-1kjok6n-3"})(["display:flex;gap:",";"],vt.YK.default),lit=(0,u.default)(m.g).attrs({alignCenter:!0,justifyCenter:!0}).withConfig({displayName:"ProcessSection__ProcessNumberDot",componentId:"sc-1kjok6n-4"})(["width:32px;height:32px;background:",";border-radius:",";"],vt.Ee.color.background.secondary,vt.r8.large),rit=(0,u.default)(m.g).attrs({column:!0}).withConfig({displayName:"ProcessSection__ProcessItem",componentId:"sc-1kjok6n-5"})(["flex:1;overflow:hidden;"]),oit=(0,u.default)(xt.v).attrs({size:"xsmall",color:"content.secondary"}).withConfig({displayName:"ProcessSection__ReferralUrl",componentId:"sc-1kjok6n-6"})(["margin-top:",";overflow-wrap:break-word;"],vt.YK.xsmall),iit=(0,u.default)(xt.v).attrs({size:"small",color:"content.secondary"}).withConfig({displayName:"ProcessSection__ProcessDescription",componentId:"sc-1kjok6n-7"})(["margin-top:",";"],vt.YK.xxsmall),sit=(0,u.default)(xt.v).attrs({size:"xsmall",color:"content.secondary"}).withConfig({displayName:"ProcessSection__ProcessDisclaimer",componentId:"sc-1kjok6n-8"})(["margin-top:",";"],vt.YK.xlarge),cit=(0,u.default)(tit).attrs({justifyCenter:!0}).withConfig({displayName:"ProcessSection__PromosBlock",componentId:"sc-1kjok6n-9"})(["border-radius:",";background:",";padding:",";min-height:322px;@media (max-width:","px){order:1;}"],vt.r8.medium,(e=>{let t=e.theme;return"light"===t.uiTheme?"#FAF0E6":t.variables.color.background.secondary}),vt.YK.xxlarge,(e=>{let t=e.isSidebarExpanded,n=e.theme;return t?n.breakPoints.lg:n.breakPoints.sm})),dit=(0,u.default)(m.g).attrs({alignCenter:!0}).withConfig({displayName:"ProcessSection__PromosContainer",componentId:"sc-1kjok6n-10"})(["flex:1;position:relative;max-width:350px;"]),uit=(0,u.default)(m.g).attrs({alignCenter:!0}).withConfig({displayName:"ProcessSection__PromoContainer",componentId:"sc-1kjok6n-11"})(["position:absolute;width:100%;max-width:56%;"]),mit=(0,u.default)(uit).withConfig({displayName:"ProcessSection__PromoLeftContainer",componentId:"sc-1kjok6n-12"})(["left:0;transform:translateY(-1%);"]),pit=(0,u.default)(uit).withConfig({displayName:"ProcessSection__PromoRightContainer",componentId:"sc-1kjok6n-13"})(["right:0;transform:translateY(1%);"]),git=e=>{let t=e.color,n=void 0===t?"content.primary":t,l=e.label,r=e.value;return a.createElement(hit,{"data-external-id":"box"},a.createElement(xt.v,{size:"xxlarge",weight:"medium",color:n},r),a.createElement(vit,null,l))},hit=u.default.div.withConfig({displayName:"Box__Root",componentId:"sc-1lso5vq-0"})(["background-color:",";border-radius:",";padding:",";text-align:center;flex-grow:1;width:100%;"],vt.Ee.color.background.secondary,vt.r8.medium,vt.YK.xlarge),vit=(0,u.default)(xt.v).attrs({weight:"medium",size:"xsmall",color:"content.secondary"}).withConfig({displayName:"Box__Label",componentId:"sc-1lso5vq-1"})(["display:block;text-transform:uppercase;letter-spacing:0.08em;margin-top:",";"],vt.YK.xsmall),fit=(0,u.default)(m.g).attrs({justifyBetween:!0,alignCenter:!0}).withConfig({displayName:"Boxes",componentId:"sc-1wgnvee-0"})(["gap:",";@media (max-width:","px){flex-flow:column nowrap;}"],vt.YK.default,vt.nm.sm),Eit=((0,Qt.J)("\n  fragment ReferralConstantsFields on Constants {\n    referralAnnualRewardLimitUsd\n    referralV2ProgramLaunchDate\n  }\n"),(0,Qt.J)("\n  fragment ReferralEarningsStatisticsFields on ReferralStatistics {\n    creditsEarned\n    pendingCount\n    earnedCreditsCount\n  }\n"),(0,Qt.J)("\n  fragment ReferralEarningsRedemptionsFields on ReferralRedemption {\n    id\n    creditsEarned\n    creditsEarnedAt\n  }\n"),(0,Qt.J)("\n  fragment ReferralLegacyStatisticsFields on ReferralStatistics {\n    creditsEarned\n    subscribed\n    signedUp\n  }\n"),(0,Qt.J)("\n  query Common_GetReferralSettings(\n    $statisticsStartDate: DateTime!\n    $statisticsEndDate: DateTime!\n    $v1PayoutMethod: ReferralPayoutMethod!\n    $v2PayoutMethod: ReferralPayoutMethod!\n  ) {\n    constants {\n      ...ReferralConstantsFields\n    }\n\n    legacyReferralStatistics: referralStatistics(\n      filters: { creditPayoutMethod: $v1PayoutMethod, endDate: $statisticsEndDate }\n    ) {\n      ...ReferralLegacyStatisticsFields\n    }\n\n    referralStatistics: referralStatistics(\n      filters: {\n        creditPayoutMethod: $v2PayoutMethod\n        startDate: $
1statisticsStartDate\n        endDate: $statisticsEndDate\n      }\n    ) {\n      ...ReferralEarningsStatisticsFields\n    }\n\n    referralRedemptions(filters: { creditPayoutMethod: $v2PayoutMethod, hasEarnedCredits: true }) {\n      id\n      ...ReferralEarningsRedemptionsFields\n    }\n  }\n")),yit=((0,Qt.J)("\n  query Common_GetReferralConstants {\n    constants {\n      ...ReferralConstantsFields\n    }\n  }\n"),(0,Qt.J)("\n  mutation Common_ResendReferralRewardEmail($referralRedemptionId: ID!) {\n    resendReferralRewardEmail(referralRedemptionId: $referralRedemptionId) {\n      success\n      rewardLink\n      errors {\n        ...PayloadErrorFields\n      }\n    }\n  }\n")),bit=e=>{let t=e.redemption;const n=t.id,l=t.creditsEarned,r=t.creditsEarnedAt,s=(0,i.n)(yit),c=(0,o.A)(s,1)[0],d=(0,C.RU)(),u=(0,hm.M)((()=>c({variables:{referralRedemptionId:n},onCompleted:e=>{const t=e.resendReferralRewardEmail,n=null!==t&&void 0!==t?t:{},a=n.success,l=n.rewardLink;a?((0,C.oR)({title:_t.rF.RESEND_REWARD_EMAIL.TITLE,description:_t.rF.RESEND_REWARD_EMAIL.DESCRIPTION}),l&&window.open(l,"_blank")):d()},onError:()=>d()}))),m=(0,o.A)(u,2),p=m[0],g=m[1];return a.createElement(xit,{"data-external-id":"referral-redemption"},a.createElement(xt.v,{color:"content.primary"},r&&"".concat((0,Ba.AO)(r)," - "),(0,rl.T3)(l)," earned"),a.createElement(OK,{isLoading:p,onClick:()=>{(0,Ge.u4)(Ye.JW.ReferralRewardEmailResent,{referralRedemptionId:n}),g()}},"View gift card"))},xit=(0,u.default)(m.g).attrs({justifyBetween:!0}).withConfig({displayName:"ReferralRedemption__EarningsItem",componentId:"sc-1g37ve6-0"})(["padding:"," 0;gap:",";border-top:1px solid ",";"],vt.YK.small,vt.YK.xlarge,vt.Ee.color.divider.primary),wit=(0,u.default)(m.g).attrs({column:!0}).withConfig({displayName:"ReferralEarnings__Root",componentId:"sc-1v3tz4c-0"})(["gap:",";"],vt.YK.xlarge),Cit=(0,u.default)(m.g).attrs({column:!0}).withConfig({displayName:"ReferralEarnings__Progress",componentId:"sc-1v3tz4c-1"})(["gap:",";"],vt.YK.xsmall),Ait=(0,u.default)(m.g).attrs({column:!0}).withConfig({displayName:"ReferralEarnings__Earnings",componentId:"sc-1v3tz4c-2"})(["gap:",";"],vt.YK.default),Iit=(0,u.default)(m.g).attrs({column:!0}).withConfig({displayName:"ReferralEarnings__EarningsList",componentId:"sc-1v3tz4c-3"})(["border-bottom:1px solid ",";"],vt.Ee.color.divider.primary),kit=e=>{let t=e.constants,n=e.statistics;return a.createElement(Sit,{"data-external-id":"referral-tracker"},a.createElement(Nit,null,_t.rF.LEGACY_REFERRALS_HONORED(N.c9.fromISO(t.referralV2ProgramLaunchDate).toLocaleString(N.c9.DATE_FULL))),a.createElement(fit,null,a.createElement(git,{value:(0,De.LN)(n.signedUp),label:"Signed up"}),a.createElement(git,{value:(0,De.LN)(n.subscribed),label:"Subscribed"}),a.createElement(git,{value:(0,rl.vv)(n.creditsEarned),label:"Credits earned",color:"content.success"})))},Sit=(0,u.default)(m.g).attrs({column:!0}).withConfig({displayName:"ReferralTracker__Root",componentId:"wgr4l0-0"})(["gap:",";margin:"," ",";"],vt.YK.xlarge,vt.YK.default,vt.YK.xlarge),Nit=(0,u.default)(xt.v).attrs({color:"content.secondary",size:"small"}).withConfig({displayName:"ReferralTracker__LegacyReferralsText",componentId:"wgr4l0-1"})(["max-width:552px;"]),Tit="showPrompts",_it=(0,u.default)(m.g).attrs({justifyCenter:!0}).withConfig({displayName:"ReferralsPromptsToggle__SpinnerContainer",componentId:"sc-1ne2air-0"})(["padding:",";border:1px solid ",";border-radius:",";margin:0 "," "," ",";"],vt.YK.default,vt.yW.grayFocus,vt.r8.small,vt.YK.xlarge,vt.YK.xlarge,vt.YK.xlarge),Dit=()=>{const e=(0,d.d4)(A.fm),t=(0,et.I)(Eit,{variables:{statisticsStartDate:N.c9.local().startOf("year").toString(),statisticsEndDate:N.c9.local().endOf("year").toString(),v1PayoutMethod:Ee.Hcy.V1_SUBSCRIPTION_CREDIT,v2PayoutMethod:Ee.Hcy.V2_GIFT_CARD}}),n=t.data,l=t.isLoadingInitialData,r=null===n||void 0===n?void 0:n.legacyReferralStatistics,o=(0,P6.f)(),i=o.referralCode,s=o.isLoading,c=null!==i&&void 0!==i?i:"",u=a.useMemo((()=>Eie(c,(0,Mie.v)("landing"))),[c]),m=a.useMemo((()=>(e=>{let t=e.legacyReferralStatistics;return!!t&&(t.creditsEarned>0||t.signedUp>0||t.subscribed>0)})({legacyReferralStatistics:r})),[r]);return a.createElement(a.Fragment,null,a.createElement(Xhe.Ay,null,a.createElement("title",null,"Share Monarch")),a.createElement(mX.V,{md:9},a.createElement(Rit,{anchorId:"share-monarch",loading:s||l},a.createElement(Mit,{referralUrl:u,isSidebarExpanded:e})),a.createElement(Rit,{title:"Referrals",anchorId:"referrals",loading:l},n&&a.createElement(Lit,{constants:n.constants,statistics:n.referralStatistics,redemptions:n.referralRedemptions}
1)),a.createElement(Rit,{title:"How it works",anchorId:"how-it-works",loading:s},n&&a.createElement(Oit,{constants:n.constants,referralUrl:u,isSidebarExpanded:e}),a.createElement(Pit,null)),m&&a.createElement(a.Fragment,null,a.createElement(Bit,null,a.createElement(zit,null)),a.createElement(Rit,{title:"Referral credits",anchorId:"referral-credits",loading:l},r&&a.createElement(kit,{constants:n.constants,statistics:r})))))},Rit=(0,u.default)(Ffe).withConfig({displayName:"ReferralSettings__Card",componentId:"bv44hr-0"})(["margin-bottom:",";"],vt.YK.gutter),Mit=(0,u.default)(Aie).withConfig({displayName:"ReferralSettings__ShareLinkSectionV2",componentId:"bv44hr-1"})(["padding:",";gap:",";@media (max-width:","px){padding:",";flex-direction:column;gap:",";}"],vt.YK.xxlarge,vt.YK.gutter,(e=>{let t=e.isSidebarExpanded,n=e.theme;return t?n.breakPoints.lg:n.breakPoints.sm}),vt.YK.xlarge,vt.YK.xxlarge),Lit=(0,u.default)((e=>{let t=e.constants,n=e.className,l=e.redemptions,r=e.statistics;const o=t.referralAnnualRewardLimitUsd,i=N.c9.local().startOf("year").year;return a.createElement(wit,{"data-external-id":"referral-earnings",className:n},a.createElement(Cit,null,a.createElement("div",{className:"flex items-center justify-between"},a.createElement(xt.v,{color:"content.primary",weight:"medium"},i),a.createElement(xt.v,{color:"content.secondary",size:"small"},(0,rl.T3)(r.creditsEarned)," /"," ",(0,rl.T3)(o))),a.createElement(fe.cqk,{value:r.creditsEarned,max:o,color:"progress-success"})),a.createElement(fit,null,a.createElement(git,{value:(0,rl.T3)(r.creditsEarned),label:"Earned in ".concat(i),color:"content.success"}),a.createElement(git,{value:(0,De.LN)(r.pendingCount),label:"Pending"}),a.createElement(git,{value:(0,De.LN)(r.earnedCreditsCount),label:"Completed"})),l.length>0&&a.createElement(Ait,null,a.createElement(xt.v,{color:"content.primary",weight:"medium"},"Gift cards earned"),a.createElement(Iit,null,l.map((e=>a.createElement(bit,{key:e.id,redemption:e}))))))})).withConfig({displayName:"ReferralSettings__StyledReferralEarnings",componentId:"bv44hr-2"})(["padding:",";"],vt.YK.xlarge),Oit=(0,u.default)((e=>{let t=e.constants,n=e.className,l=e.isSidebarExpanded,r=e.referralUrl;return a.createElement(eit,{"data-external-id":"process-section",className:n,isSidebarExpanded:l},a.createElement(nit,{isSidebarExpanded:l},Hot.map(((e,n)=>a.createElement(ait,{key:n},a.createElement(lit,null,a.createElement(xt.v,{weight:"medium",color:"content.secondary",size:"small"},n+1)),a.createElement(rit,null,a.createElement(xt.v,{weight:"medium",color:"content.primary"},e.title),a.createElement(iit,null,e.description),0===n&&a.createElement(oit,null,r),e.descriptionLine2&&a.createElement(iit,null,e.descriptionLine2),e.disclaimer&&a.createElement(sit,null,e.disclaimer(t.referralAnnualRewardLimitUsd)," ",a.createElement(cl.M,{href:VF.rj,target:"_blank",rel:"noopener noreferrer"},"terms"),".")))))),a.createElement(cit,{isSidebarExpanded:l},a.createElement(dit,null,a.createElement(mit,null,a.createElement(Xot,{variant:"ticket"})),a.createElement(pit,null,a.createElement(Xot,{variant:"giftCard"})))))})).withConfig({displayName:"ReferralSettings__StyledProcessSection",componentId:"bv44hr-3"})(["padding:",";"],vt.YK.xlarge),Pit=(0,u.default)((e=>{let t=e.className;const n=(0,xq.bO)("hasHiddenReferralProgramPrompts"),l=(0,o.A)(n,3),r=l[0],i=l[1];return l[2]?a.createElement(_it,{"data-external-id":"referrals-prompts-toggle"},a.createElement(p.i,null)):a.createElement(Eu.lV,{"data-external-id":"referrals-prompts-toggle",className:t,initialValues:{[Tit]:!r},enableReinitialize:!0,onSubmit:e=>{const t=!e[Tit];i(t),(0,Ge.u4)(Ye.JW.PromptsToggled,{hasHiddenReferralProgramPrompts:t})},submitOnChange:!0},a.createElement(aye.Nx,{subtitle:_t.rF.SHOW_PROMO_SETTING_SUBTITLE,rightAccessory:a.createElement(vPe.Y,{name:Tit,hideLabel:!0})}))})).withConfig({displayName:"ReferralSettings__StyledReferralsPromptsToggle",componentId:"bv44hr-4"})(["padding:",";padding-top:0;"],vt.YK.xlarge),Bit=u.default.div.withConfig({displayName:"ReferralSettings__DividerContainer",componentId:"bv44hr-5"})(["padding:"," 0;margin-bottom:",";"],vt.YK.xsmall,vt.YK.gutter),zit=u.default.div.withConfig({displayName:"ReferralSettings__Divider",componentId:"bv44hr-6"}
1)(["height:1px;width:100%;background:",";"],vt.Ee.color.divider.secondary);var Fit=n(42009),Git=n(54034),Yit=n(1681);const Uit=e=>{let t=e.merchantCriteriaUseOriginalStatement;if(null===t||void 0===t)return null;const n=t?"original statement":"merchant name";return a.createElement(fe.r8y,{"data-external-id":"merchant-criteria-tag",size:"md"},n)};var Vit,Wit,jit=n(20770),Hit=n(12573),Kit=n(22374);const qit=e=>{var t,n,l,r,o;let i=e.rule,s=i.merchantCriteriaUseOriginalStatement,c=i.merchantCriteria,d=i.originalStatementCriteria,u=i.merchantNameCriteria,m=i.amountCriteria,p=i.categories,g=i.accounts,h=i.criteriaOwnerIsJoint,v=i.criteriaOwnerUsers,f=i.criteriaBusinessEntities,E=i.criteriaBusinessEntityIsUnassigned,y=i.setMerchantAction,b=i.setCategoryAction,x=i.sendNotificationAction,w=i.setHideFromReportsAction,C=i.addTagsAction,A=i.reviewStatusAction,I=i.recentApplicationCount,k=i.lastAppliedAt,S=i.linkGoalAction,T=i.linkSavingsGoalAction,_=i.needsReviewByUserAction,D=i.unassignNeedsReviewByUserAction,R=i.actionSetOwnerIsJoint,M=i.actionSetOwner,L=i.actionSetBusinessEntity,O=i.actionSetBusinessEntityIsUnassigned,P=i.splitTransactionsAction,B=i.setLinkToPaydownBudgetAction,z=e.onClick;const F=(0,a.useMemo)((()=>{if((0,BY.A)(k))return null;const e=N.c9.fromISO(k);return(0,Ba.fw)(e)}),[k]),G=(0,a.useMemo)((()=>(0,Hit.P)(null!==f&&void 0!==f?f:[])),[f]),Y=!!G.length||E,U=null!==P&&void 0!==P?P:{},V=U.amountType,W=U.splitsInfo;return a.createElement(a.Fragment,null,a.createElement($it,{onClick:z},a.createElement(qH.v,{className:"p-default"}),a.createElement(Zit,null,!(null===c||void 0===c||!c.length)&&a.createElement(Qit,null,"If"," ",a.createElement(Uit,{merchantCriteriaUseOriginalStatement:s}),null===c||void 0===c?void 0:c.map(((e,t)=>{let n=e.operator,l=e.value;return a.createElement(a.Fragment,{key:t},t>0&&"or ",a.createElement(est,null,(0,Kit.bY)(n)),a.createElement(est,null,l))}))),!(null===d||void 0===d||!d.length)&&a.createElement(Qit,null,"If ",a.createElement(est,null,"original statement"),null===d||void 0===d?void 0:d.map(((e,t)=>{let n=e.operator,l=e.value;return a.createElement(a.Fragment,{key:t},t>0&&"or ",a.createElement(est,null,(0,Kit.bY)(n)),a.createElement(est,null,l))}))),!(null===u||void 0===u||!u.length)&&a.createElement(Qit,null,"If ",a.createElement(est,null,"merchant name"),null===u||void 0===u?void 0:u.map(((e,t)=>{let n=e.operator,l=e.value;return a.createElement(a.Fragment,{key:t},t>0&&"or ",a.createElement(est,null,(0,Kit.bY)(n)),a.createElement(est,null,l))}))),m&&a.createElement(Qit,null,"If ",a.createElement(est,null,m.isExpense?"debit":"credit"),a.createElement(est,null,(0,Kit.az)(m.operator)),(0,BY.A)(m.valueRange)?a.createElement(est,null,(0,rl.vv)(null!==(l=m.value)&&void 0!==l?l:0)):a.createElement(a.Fragment,null,a.createElement(est,null,(0,rl.vv)(null!==(t=m.valueRange.lower)&&void 0!==t?t:0)),"and ",a.createElement(est,null,(0,rl.vv)(null!==(n=m.valueRange.upper)&&void 0!==n?n:0)))),!(null===p||void 0===p||!p.length)&&a.createElement(Qit,null,"If ",a.createElement(est,null,"category"),a.createElement(est,null,"equals"),p.map((e=>{let t=e.id,n=e.icon,l=e.name;return a.createElement(est,{key:t},n," ",l)}))),!(null===g||void 0===g||!g.length)&&a.createElement(Qit,null,"If ",a.createElement(est,null,"account"),a.createElement(est,null,"equals")," ",g.map((e=>a.createElement(est,{key:e.id},a.createElement(fe.r8y.StartElement,null,a.createElement(Gl.v,{logoUrl:e.logoUrl,icon:e.icon,size:16})),e.displayName)))),(h||!(null===v||void 0===v||!v.length))&&a.createElement(Qit,null,"If ",a.createElement(est,null,"owner"),a.createElement(est,null,"equals")," ",h&&a.createElement(est,null,a.createElement(fe.r8y.StartElement,null,a.createElement(Pw.n,{avatarSize:16,showLabel:!1,userId:null,userName:null})),bd.H),null===v||void 0===v?void 0:v.map((e=>{let t=e.id,n=e.displayName,l=e.profilePictureUrl;return a.createElement(est,{key:t},a.createElement(fe.r8y.StartElement,null,a.createElement(Pw.n,{userId:t,userName:n,userProfilePictureUrl:l,avatarSize:16,showLabel:!1})),null!==n&&void 0!==n?n:bd.H)}))),Y&&a.createElement(Qit,null,"If ",a.createElement(est,null,"business"),a.createElement(est,null,"equals")," ",E&&a.createElement(est,null,a.createElement(fe.r8y.StartElement,null,a.createElement(k1.L,{logoUrl:null,color:null,emptyStateIconName:"home-filled",size:_j._T.small.logo,iconSize:_j._T.small.icon})),_j.qq),G.map((e=>{let t=e.id,n=e.logoUrl,l=e.color,r=e.name;return a.createElement(est,{key:t},a.createElement(fe.r8y.StartElement,null,a.createElement(k1.L,{logoUrl:n,color:l,size:_j._T.small.logo,iconSize:_j._T.small.icon})),r)})))),a.createElement(Xit,null,a.createElement(fqe.MdsArrowRightIcon,null)),a.createElement(Jit,null,y&&a.createElement(Qit,null,"Rename to ",a.createElement(est,null,y.name)),b&&a.createElement(Qit,null,"Recategorize to"," ",a.createElement(est,null,b.icon," ",b.name)),(R||M)&&a.createElement(Qit,null,"Set owner to"," ",R&&a.createElement(est,null,a.createElement(fe.r8y.StartElement,null,a.createElement(Pw.n,{avatarSize:16,showLabel:!1,userId:null,userName:null})),bd.H),M&&a.createElement(est,null,a.createElement(fe.r8y.StartElement,null,a.createElement(Pw.n,{userId:M.id,userName:M.displayName,userProfilePictureUrl:M.profilePictureUrl,avatarSize:16,showLabel:!1})),null!==(r=M.displayName)&&void 0!==r?r:bd.H)),x&&a.createElement(Qit,null,a.createElement(est,null,a.createElement(fe.r8y.StartElement,null,a.createElement(jit.MdsBellIcon,{className:"text-content-link"})),"Send notification")),w&&a.createElement(Qit,null,a.createElement(est,null,a.createElement(fe.r8y.StartElement,null,a.createElement(mWe.MdsEyeOffIcon,null)),"Hide transaction")),B&&a.createElement(Qit,null,a.createElement(est,null,"Link to pay down goal")),C&&a.createElement(Qit,null,"Add ",(0,De.td)("tag",C.length)," ",C.map((e=>{let t=e.name,n=e.color;return a.createElement(est,{key:t,dotColor:n},t)}
1))),!!A&&a.createElement(Qit,null,"Set review status to ",a.createElement(est,null,(0,B2.qC)(A)),A===B2.v_.NeedsReview&&(!!_||!!D)&&a.createElement(a.Fragment,null,"by ",a.createElement(est,null,null!==(o=null===_||void 0===_?void 0:_.displayName)&&void 0!==o?o:"anyone"))),S&&a.createElement(Qit,null,"Link to goal"," ",a.createElement(est,null,a.createElement(fe.r8y.StartElement,null,a.createElement(Yit.C,S)),S.name)),T&&a.createElement(Qit,null,"Link to goal"," ",a.createElement(est,null,a.createElement(fe.r8y.StartElement,null,a.createElement(Yit.C,T)),T.name)),(O||L)&&a.createElement(Qit,null,"Set business to"," ",O&&a.createElement(est,null,a.createElement(fe.r8y.StartElement,null,a.createElement(k1.L,{logoUrl:null,color:null,emptyStateIconName:"home-filled",size:_j._T.small.logo,iconSize:_j._T.small.icon})),_j.qq),L&&a.createElement(est,null,a.createElement(fe.r8y.StartElement,null,a.createElement(k1.L,{logoUrl:L.logoUrl,color:L.color,size:_j._T.small.logo,iconSize:_j._T.small.icon})),L.name)),V&&W&&a.createElement(Qit,null,"Split into ",a.createElement(est,null,W.length," transactions"),"by"," ",a.createElement(est,null,V===Ee.z2y.PERCENTAGE?"percentage":"amount")))),(0,Tr.A)(F)&&a.createElement(tst,null,I," ",(0,De.td)("transaction",I)," updated \xb7 ",F," ago"))},$it=u.default.div.withConfig({displayName:"TransactionRule__Root",componentId:"sc-1uencrl-0"})(["border-radius:",";border:1px solid ",";background:",";min-height:90px;width:100%;display:flex;flex-direction:row;cursor:pointer;user-select:none;transition:",";:hover{background:",";}"],(e=>e.theme.radius.medium),(e=>e.theme.color.grayFocus),(e=>e.theme.color.white),(e=>e.theme.transition.default),(e=>{let t=e.theme;return(0,xb.B3)(t.color.grayBackground,.5)})),Zit=u.default.div.withConfig({displayName:"TransactionRule__Side",componentId:"sc-1uencrl-1"})(["flex:1;padding:10px "," 10px 0;"],(e=>e.theme.spacing.xsmall)),Jit=(0,u.default)(Zit).withConfig({displayName:"TransactionRule__RightSide",componentId:"sc-1uencrl-2"})(["padding-left:",";"],(e=>e.theme.spacing.xlarge)),Xit=u.default.div.withConfig({displayName:"TransactionRule__ArrowPositioner",componentId:"sc-1uencrl-3"})(["border-left:1px solid ",";border-right:1px solid ",";display:flex;align-items:center;justify-content:center;width:40px;background:",";color:",";"],(e=>e.theme.color.grayFocus),(e=>e.theme.color.grayFocus),(e=>e.theme.color.grayBackground),(e=>e.theme.color.textLight)),Qit=$d.s.div(Vit||(Vit=(0,wc.A)(["flex flex-wrap items-center gap-x-xs gap-y-2xs py-2xs"]))),est=(0,$d.s)(fe.r8y).attrs({size:"md"})(Wit||(Wit=(0,wc.A)(["shrink"]))),tst=(0,u.default)(xt.v).attrs({color:"textLight",italic:!0,size:"small"}).withConfig({displayName:"TransactionRule__RuleLastAppliedContainer",componentId:"sc-1uencrl-4"})(["display:block;margin-top:",";"],(e=>e.theme.spacing.xsmall));qit.fragments={TransactionRuleFields:Ee.YsJ};var nst,ast=n(48812),lst=n(26269);const rst=()=>{const e=(0,l.Zp)(),t=(0,l.zy)(),n=(0,b.pE)("id"),r=(0,R3.F)(),s=r.isOn,c=r.isTransactionLinkingEnabled,d=(0,C.RU)(),u=(0,a.useState)(""),m=(0,o.A)(u,2),g=m[0],h=m[1],v=(0,et.I)(ist),f=v.data,E=v.isLoadingInitialData,y=v.refetch,x=(null!==f&&void 0!==f?f:{}).transactionRules,w=void 0===x?[]:x,A=(0,a.useMemo)((()=>{const e=(0,Kit.rB)(w);return g?(0,Kit.uZ)(g)(e):e}),[w,g]),k=w.length,S=A.length,N=S>0,T=(0,lst.i)(HQ.jR.TransactionRuleLimit,S).limit,_=(0,i.n)(sst),D=(0,o.A)(_,1)[0],R=(0,i.n)(cst),M=(0,o.A)(R,2),L=M[0],O=M[1].loading,P=(0,Pd.h)(),B=(0,o.A)(P,2),z=B[0],F=B[1],G=F.open,Y=F.close,V=(0,a.useCallback)((function(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return e(I.JZ.settings.rules.transactionRule({queryParams:{id:t}}))}),[e]);return a.createElement(mX.V,{"data-external-id":"rules-settings",md:9},a.createElement(Ffe,{title:"Rules",anchorId:"rules",controls:a.createElement(fe.u$N,{align:"end",trigger:a.createElement(fe.XZZ,{variant:"default",endIcon:a.createElement(fe.D39,{size:"md"})},"Options"),items:[{label:"Delete all rules",variant:"destructive",disabled:!N,onClick:G}]})},a.createElement(Xhe.Ay,null,a.createElement("title",null,"Rules Settings")),a.createElement("div",{className:"p-xl"},a.createElement("div",{className:"mb-xl"},"Rules allow you to rename, recategorize, split your transactions, and more. If multiple rules apply to the same transaction, they will apply in the order listed here (top to bottom). You can drag and drop to edit the order as needed."),a.createElement("div",{className:"flex items-center justify-between font-medium"},a.createElement("span",null,T?"".concat(Math.min(T,S)," of ").concat((0,De.td)("Rule",T,{inclusive:!0})):(0,De.td)("Rule",S,{inclusive:!0})),a.createElement("div",{className:"flex items-center justify-end gap-default"},a.createElement(fe.i9A,{size:"sm",className:"w-64"},a.createElement(fe.i9A.Addon,null,a.createElement(fe.s$r,{size:"md"})),a.createElement(fe.D_j,{placeholder:"Search",name:"search-rules",autoComplete:"off",value:g,onChange:e=>h(e.currentTarget.value)}),!!g&&a.createElement(fe.i9A.Addon,{align:"inline-end"},a.createElement(fe.i9A.Button,{"aria-label":"Clear search",onClick:()=>h("")},a.createElement(fe.QqB,{size:"md"})))),a.createElement(Git.d,{featureLimit:HQ.jR.TransactionRuleLimit,currentValue:S},(e=>{let t=e.meetsOrExceedsLimit;return a.createElement(fe.XZZ,{variant:"primary",size:"sm",onClick:()=>!t&&V()},"Create rule")})))),E?a.createElement(ost,null,a.createElement(p.i,null)):0===S?a.createElement(ost,null,a.createElement(cU.vx,{emptyTheme:cU.dO.OLD,title:g?"No rules found":"No rules yet",subtitle:g?"Try a different search term.":"Create some to get started."})):a.createElement(Fit.b,{items:A,renderItem:e=>a.createElement(qit,{rule:e,onClick:()=>V(e.id)}),keyExtractor:e=>e.id,indexExtractor:e=>e.order,itemClassName:"mt-default",onMoveItem:e=>{let t=e.item,n=e.destination,a=e.source;return D({variables:{id:t.id,order:n},optimisticResponse:{__typename:"Mutation",updateTransactionRuleOrderV2:{__typename:"UpdateTransactionRuleOrderV2Mutation",transactionRules:[(0,U.A)((0,U.A)({},t),{},{order:Cnt(a,n)})]}}})}}),!!s&&!c&&a.createElement("div",{className:"mt-xs flex"},a.createElement(fe.c8D,{size:"sm",color:"secondary",className:"italic"},"Rules that include goals won\u2019t currently run. We will be adding improved goal automations soon."))),a.createElement(l.BV,null,a.createElement(l.qh,{path:I.JZ.settings.rules.transactionRule.relativePath,element:a.createElement(ast.Y,{editRule:n?A.find((e=>e.id===n)):void 0,onDone:()=>{const n=(0,ma._6)(t.pathname);e("".concat(n).concat(t.search)),y()}})})),a.createElement(z,null,a.createElement(xC.$,{title:"Delete ".concat((0,De.td)("rule",k,{inclusive:!0})),confirm:"Delete",useDangerButton:!0,onCancel:Y,onConfirm:()=>{L({onCompleted:e=>{var t;null!==(t=e.deleteAllTransactionRules)&&void 0!==t&&t.deleted?(Y(),y()):d({description:"An error occurred while deleting your rules. Please try again."})},onError:()=>{d({description:"An error occurred while deleting your rules. Please try again."})}})},isLoading:O},a.createElement("div",null,"Are you sure you want to permanently delete all of your transaction rules? This action cannot be undone. This action will not change any of your existing transactions.")))
1))},ost=$d.s.div(nst||(nst=(0,wc.A)(["flex items-center justify-center p-xl"]))),ist=Ee.OoY,sst=Ee.zTc,cst=Ee.d8m,dst=e=>{let t=e.tag,n=e.onConfirm;const l=(0,Sq.k)().close;return a.createElement(Rc.L,{"data-external-id":"delete-tag-modal",title:"Are you sure?"},a.createElement(ust,null,a.createElement(mst,null,a.createElement(xt.v,null,"Deleting this tag will remove it from all ",t.transactionCount," historical"," ",nie()("transaction",t.transactionCount),"."))),a.createElement(Cq.R,null,a.createElement(wt.Xb,{onClick:l},"Cancel"),a.createElement(G7.jI,{onClick:()=>{n(t.id),l()}},"Yes, I'm sure")))},ust=(0,u.default)(qY.S).withConfig({displayName:"DeleteTagModal__Content",componentId:"sc-1eomnr1-0"})(["padding-top:0;"]),mst=u.default.div.withConfig({displayName:"DeleteTagModal__TextWrapper",componentId:"sc-1eomnr1-1"})(["margin:"," 0;"],(e=>e.theme.spacing.default)),pst=e=>{let t=e.tag,n=e.className,r=e.isDragging,o=e.isDeleting,i=e.onClickEdit,s=e.onClickDelete;const c=t.id,d=t.name,u=t.color,m=t.transactionCount,p=void 0===m?0:m,g=p>0,h=(0,l.Zp)();return a.createElement(gst,{"data-external-id":"transaction-tag-settings-row",className:n,$isDeleting:o,$isDragging:r},a.createElement(qH.v,{className:"mx-xs",revealOnHover:!0}),a.createElement(vst,null,a.createElement(hst,null,a.createElement("div",{className:"flex items-center"},a.createElement(Ta.c,{color:u,className:"mr-default"}),a.createElement(fst,null,d)),a.createElement(Est,null,a.createElement(xst,{onClick:()=>g?h(I.JZ.transactions({queryParams:{tags:[c]}})):null,unstyled:!g,$disabled:!g,stealthy:!0},p," ",(0,De.td)("transaction",p)))),a.createElement(yst,null,a.createElement(wt.Xb,{size:"small",onClick:i,disabled:o},"Edit"),a.createElement(bst,{onClick:s,pending:o,disabled:o},"Delete"))))},gst=$d.s.div((e=>{let t=e.$isDeleting,n=e.$isDragging;return["group/tag-row flex items-center rounded-sm border border-border-primary","bg-background-primary p-2.5 pl-0 transition-[box-shadow,opacity] duration-200",{"shadow-lg":n,"opacity-80":t||n}]})),hst=(0,u.default)(m.g).attrs({alignCenter:!0,justifyStart:!0}).withConfig({displayName:"TransactionTagSettingsRow__ContentWrapper",componentId:"xuc5t5-0"})(["@media (max-width:","px){flex-direction:column;}"],(e=>e.theme.breakPoints.lg)),vst=(0,u.default)(m.g).attrs({alignCenter:!0,justifyBetween:!0}).withConfig({displayName:"TransactionTagSettingsRow__Content",componentId:"xuc5t5-1"})(["width:100%;@media (max-width:","px){flex-direction:column;}"],(e=>e.theme.breakPoints.lg)),fst=(0,u.default)(xt.v).withConfig({displayName:"TransactionTagSettingsRow__Name",componentId:"xuc5t5-2"})(["transform:translateY(-1px);"]),Est=(0,u.default)(xt.v).attrs({size:"xsmall",color:"textLight",weight:"bold"}).withConfig({displayName:"TransactionTagSettingsRow__Count",componentId:"xuc5t5-3"})(["text-transform:uppercase;letter-spacing:0.08em;&:before{content:'\u30fb';margin:0 ",";}@media (max-width:","px){margin:"," 0;&:before{content:unset;}}"],(e=>e.theme.spacing.xxsmall),(e=>e.theme.breakPoints.lg),(e=>e.theme.spacing.xsmall)),yst=(0,u.default)(m.g).withConfig({displayName:"TransactionTagSettingsRow__ButtonContainer",componentId:"xuc5t5-4"})(["--horizontal-spacing:","px;[data-sc-tw~='DefaultButton__DefaultButton']{padding-right:var(--horizontal-spacing);padding-left:var(--horizontal-spacing);}[data-sc-tw~='DefaultButton__DefaultButton']:not(:last-child){margin-right:var(--horizontal-spacing);}@media (max-width:","px){margin-top:",";}"],10,(e=>e.theme.breakPoints.lg),(e=>e.theme.spacing.xsmall)),bst=(0,u.default)(su.U).withConfig({displayName:"TransactionTagSettingsRow__DeleteButton",componentId:"xuc5t5-5"})(["",""],wt.CB),xst=(0,u.default)(wb.gz).withConfig({displayName:"TransactionTagSettingsRow__StyledLink",componentId:"xuc5t5-6"})(["cursor:",";"],(e=>e.$disabled?"initial":"pointer"));var wst=n(26176),Cst=n(27682);const Ast=()=>{var e;const t=(0,C.RU)(),n=(0,Cst.F)({includeTransactionCount:!0}),l=n.tags,r=n.isLoadingInitialData,s=n.refetch,c=(0,a.useState)(void 0),d=(0,o.A)(c,2),u=d[0],m=d[1],p=(0,a.useState)(void 0),g=(0,o.A)(p,2),h=g[0],v=g[1],f=(0,Pc.e)(!1),E=(0,o.A)(f,2),y=E[0],b=E[1],x=b.setOn,w=b.setOff,A=(0,Tr.A)(u)||y,I=(0,Tr.A)(h)&&(null!==(e=h.transactionCount)&&void 0!==e?e:0)>0,k=(0,i.n)(V8.YU),S=(0,o.A)(k,1)[0],N=(0,i.n)(V8.f8),T=(0,o.A)(N,1)[0],_=(0,a.useCallback)((async e=>{try{var n,a;const l=null===(n=(await S({variables:{tagId:e}})).data)||void 0===n||null===(a=n.deleteTransactionTag)||void 0===a?void 0:a.errors;
1(0,BY.A)(l)?s():t({description:l.message})}catch(l){v(void 0),(0,C.oR)({title:"Sorry, we couldn't delete this tag",description:l})}}),[S,s,t]),D=(0,m0.t)(HQ.W1.TAGS).hasAccess;return a.createElement(a.Fragment,null,a.createElement(mX.V,{className:"relative",md:9},a.createElement(Sst,{title:"Tags",anchorId:"tags",controls:a.createElement(kst,null,a.createElement(cu.WT,{onClick:()=>x()},"New tag")),loading:r,$disabled:!D},a.createElement(Ist,null,l.length>0?a.createElement(Fit.b,{items:l,keyExtractor:(0,mo.A)("id"),indexExtractor:(0,mo.A)("order"),itemClassName:"mt-xs",onMoveItem:e=>{let t=e.item,n=e.source,a=e.destination;return T({variables:{tagId:t.id,order:a},optimisticResponse:{__typename:"Mutation",updateTransactionTagOrder:{__typename:"UpdateTransactionTagOrder",householdTransactionTags:[(0,U.A)((0,U.A)({},t),{},{order:Cnt(n,a)})]}}})},renderItem:(e,t)=>a.createElement(pst,{key:e.id,tag:e,onClickDelete:()=>{var t;v(e),(null!==(t=e.transactionCount)&&void 0!==t?t:0)<=0&&_(e.id)},onClickEdit:()=>m(e),isDragging:t,isDeleting:(null===h||void 0===h?void 0:h.id)===e.id})}):a.createElement(cU.vx,{title:"No tags found in this household",subtitle:"Create a tag and start assigning it to transactions."}))),!D&&a.createElement(VCe,{className:"mt-25",feature:HQ.W1.TAGS})),A&&a.createElement(um.b,{onClose:()=>{m(void 0),w()}},a.createElement(wst.l,{tag:u,onDone:()=>s()})),I&&h&&a.createElement(um.b,{onClose:()=>v(void 0)},a.createElement(dst,{tag:h,onConfirm:_})))},Ist=u.default.div.withConfig({displayName:"TransactionTagSettings__ListContainer",componentId:"sc-13aporv-0"})(["margin:",";"],(e=>e.theme.spacing.xlarge)),kst=(0,u.default)(m.g).withConfig({displayName:"TransactionTagSettings__Controls",componentId:"sc-13aporv-1"})(["gap:",";"],(e=>e.theme.spacing.xsmall)),Sst=(0,u.default)(Ffe).withConfig({displayName:"TransactionTagSettings__StyledSettingsCard",componentId:"sc-13aporv-2"})(["position:relative;",""],(e=>e.$disabled&&(0,u.css)(["opacity:0.5;pointer-events:none;"])));const Nst=n.p+"static/media/trust-and-will-logo.2274072d.svg";var Tst,_st,Dst,Rst,Mst,Lst;const Ost=[{icon:"institution",title:"Legally valid will",description:"Create a will that meets your state's requirements, no lawyer required."}
1,{icon:"users",title:"Guardian designations",description:"Name guardians for your children and beneficiaries for your assets."},{icon:"file-text",title:"Healthcare directive",description:"Specify your medical wishes and appoint a healthcare proxy."}],Pst=()=>{var e,t;const n=(0,C.RU)(),l=(0,et.I)(Hst),r=l.data,s=l.isLoadingInitialData,c=(0,i.n)(jst),d=(0,o.A)(c,2),u=d[0],m=d[1].loading,p=null!==(e=null===r||void 0===r?void 0:r.subscription)&&void 0!==e?e:{},g=p.isOnFreeTrial,h=p.plusTrialEndsAt,v=p.trialEndsAt,f=p.entitlements,E=(null!==f&&void 0!==f?f:[]).includes(Ee.nQu.PREMIUM_PLUS),y=!!h&&(null!==(t=Bst(h))&&void 0!==t?t:0)>0,b=!!g||y,x=Bst(y?h:v);return a.createElement(mX.V,{"data-external-id":"trust-and-will-settings",md:9},a.createElement(Xhe.Ay,null,a.createElement("title",null,"Estate Planning")),a.createElement(Fst,{anchorId:"estate-planning",loading:s,title:a.createElement("div",{className:"flex items-center gap-sm"},"Estate planning",a.createElement($G,null))},a.createElement(Gst,null,a.createElement(Yst,null,a.createElement("div",{className:"flex flex-col gap-2xs"},a.createElement(xt.v,{as:"h2",size:"xlarge",weight:"medium",color:"content.primary"},"Get your free will"),a.createElement(xt.v,{size:"base",color:"content.secondary"},"Monarch has partnered with Trust & Will to give every Plus member a legally valid will. Build your complete estate plan in minutes, right from your browser."),a.createElement(xt.v,{className:"mt-sm",size:"small",color:"content.secondary"},"Will preparation is provided by Trust & Will, not Monarch. Trust & Will is not a law firm; consult an attorney to confirm your will meets your state's requirements.")),a.createElement(zst,{hasPlusEntitlement:E,isInTrial:b,daysRemaining:x,onClaim:async()=>{try{var e,t;const n=(await u()).data;(0,_we.K_)(n);const a=null===n||void 0===n||null===(e=n.redeemTrustAndWill)||void 0===e||null===(t=e.redemption)||void 0===t?void 0:t.redemptionUrl;a&&window.open(a,"_blank","noopener,noreferrer")}catch(a){n({description:"Unable to claim your Trust & Will benefit. Please try again."})}},pending:m})),a.createElement(Ust,{src:Nst,alt:"Trust & Will"}))),a.createElement(Fst,{title:"What's included",anchorId:"whats-included"},a.createElement(Wst,null,Ost.map((e=>{let t=e.icon,n=e.title,l=e.description;return a.createElement("div",{key:n,className:"flex items-center gap-default"},a.createElement(sl.ZQ,{name:t,size:20}),a.createElement("div",{className:"flex flex-col gap-3xs"},a.createElement(xt.v,{size:"small",weight:"medium",color:"content.primary"},n),a.createElement(xt.v,{size:"small",color:"content.secondary"},l)))})))))},Bst=e=>{if(!e)return null;const t=Math.ceil(N.c9.fromISO(e,{zone:"utc"}).diffNow("days").days);return t>0?t:null},zst=e=>{let t=e.hasPlusEntitlement,n=e.isInTrial,l=e.daysRemaining,r=e.onClaim,o=e.pending;return n?a.createElement("div",{"data-external-id":"claim-cta",className:"flex flex-col gap-xs"},a.createElement(Vst,{color:"grayLight"},null===(i=l)?"Available when your trial ends":"Available in ".concat((0,De.td)("day",i,{inclusive:!0})," when your trial ends")),a.createElement(xt.v,{size:"small",color:"content.secondary"},"Plus members get access once they finish their trial and become a paying subscriber.")):t?a.createElement("div",{"data-external-id":"claim-cta"},a.createElement(wt.zC,{size:"medium",onClick:r,pending:o},"Claim your free will")):a.createElement("div",{"data-external-id":"claim-cta",className:"flex flex-col gap-xs"},a.createElement(Vst,{color:"grayLight"},"Available once you've become a Plus member"),a.createElement(xt.v,{size:"small",color:"content.secondary"},"Plus members get access once they finish their trial and become a paying subscriber."));var i},Fst=(0,$d.s)(Ffe)(Tst||(Tst=(0,wc.A)(["mb-gutter"]))),Gst=$d.s.div(_st||(_st=(0,wc.A)(["\n  flex flex-col items-start gap-md px-sm pt-2xs pb-sm\n  sm:flex-row sm:gap-gutter sm:px-2xl sm:pt-2xs sm:pb-lg\n"]))),Yst=$d.s.div(Dst||(Dst=(0,wc.A)(["flex flex-1 flex-col gap-xl"]))),Ust=$d.s.img(Rst||(Rst=(0,wc.A)(["block w-56 shrink-0 pt-xl pr-xl"]))),Vst=(0,$d.s)(Oc.D)(Mst||(Mst=(0,wc.A)(["px-sm py-xs"]))),Wst=$d.s.div(Lst||(Lst=(0,wc.A)(["flex flex-col gap-default px-xl py-2xl"]))),jst=Ee.xbO,Hst=Ee.l6K,Kst="MMMM d, yyyy",qst=e=>{let t=e.beforeDate,n=e.expectedAffectedSnapshotsCount,l=e.onCancel,r=e.onDelete;const s=(0,C.RU)(),c=(0,a.useState)(!1),d=(0,o.A)(c,2),u=d[0],m=d[1],p=(0,i.n)(dZ),g=(0,o.A)(p,1)[0],h=(0,a.useState)(""),v=(0,o.A)(h,2),f=v[0],E=v[1];return a.createElement(xC.$,{"data-external-id":"delete-synced-snapshots-confirmation",title:_t.ZI.DELETE_SYNCED_SNAPSHOTS.CONFIRMATION.TITLE,confirm:"Delete",isLoading:u,onCancel:l,onConfirm:async()=>{var e;m(!0);const a=(await g({variables:{input:{beforeDate:t,expectedAffectedSnapshotsCount:n}}})).data;if(null!==a&&void 0!==a&&null!==(e=a.deleteSyncedSnapshots)&&void 0!==e&&e.success)r();else{var o;const e=null===a||void 0===a||null===(o=a.deleteSyncedSnapshots)||void 0===o?void 0:o.errors;(null===e||void 0===e?void 0:e.code)===Ee.O4y.DELETE_SNAPSHOTS_HISTORY_UNAVAILABLE?s({description:null===e||void 0===e?void 0:e.message}):s({description:"We couldn't delete the snapshots history. Please try again or report this issue."}),l()}},useDangerButton:!0,confirmEnabled:f===_t.ZI.DELETE_SYNCED_SNAPSHOTS.CONFIRMATION.TYPE_TO_CONFIRM},a.createElement("div",null,"Are you sure you want to delete your account balance snapshots before"," ",a.createElement(xt.v,{weight:"bold"},N.c9.fromISO(t).toFormat(Kst))," ","? This action impacts"," ",a.createElement(xt.v,{weight:"bold"},"all synced accounts in your household ")," and cannot be undone."),a.createElement(Qw.X,{name:"memberNameConfirmation",label:'Type "'.concat(_t.ZI.DELETE_SYNCED_SNAPSHOTS.CONFIRMATION.TYPE_TO_CONFIRM,'" to confirm deleti
1on'),required:!0,defaultValue:f,onChange:e=>E(e)}))},$st=e=>{var t,n;let l=e.setDeletedSnapshotsBeforeDate;const r=(0,Tse._)().isDemoHousehold,i=(0,Pd.h)(),s=(0,o.A)(i,2),c=s[0],d=s[1],u=d.open,m=d.close,p=(0,a.useState)(""),g=(0,o.A)(p,2),h=g[0],v=g[1],f=(0,et.I)(Zst),E=f.data,y=f.refetch,b=null!==E&&void 0!==E&&E.oldestDeletableSyncedSnapshotDate?N.c9.fromISO(E.oldestDeletableSyncedSnapshotDate):N.c9.local(),x=(0,et.I)(Jst,{variables:{beforeDate:h},skip:!h}),w=x.data,C=x.isNetworkRequestInFlight,A=h&&(null===w||void 0===w?void 0:w.previewDeleteSyncedSnapshots)||0;return a.createElement(Eu.lV,{"data-external-id":"delete-synced-snapshots-form",onSubmit:u,preventSubmitWhileSubmitting:!0},a.createElement(tC.zB.Date,{name:"deleteSnapshotsBefore",label:"Delete account balance history before...",placeholder:"Select a date...",min:null!==(t=b.toISODate())&&void 0!==t?t:void 0,max:null!==(n=N.c9.local().toISODate())&&void 0!==n?n:void 0,required:!0,onValueChanged:e=>{e&&v(e)}}),a.createElement(CJ.I,{pending:C,disabled:0===A||r},"Delete account balance snapshots"),a.createElement(hu.c.Consumer,null,(e=>{let t=e.resetForm;return a.createElement(c,null,a.createElement(qst,{beforeDate:h,expectedAffectedSnapshotsCount:A,onCancel:m,onDelete:()=>{t(),v(""),y(),l(h),m()}}))})))},Zst=Ee._MN,Jst=Ee.Zoi,Xst=e=>{let t=e.beforeDate,n=e.includeSynced,l=e.includeManual,r=e.includeUploaded,s=e.expectedAffectedTransactionsCount,c=e.onCancel,d=e.onDelete;const u=(0,C.RU)(),m=(0,a.useState)(!1),p=(0,o.A)(m,2),g=p[0],h=p[1],v=(0,i.n)(V8.oo),f=(0,o.A)(v,1)[0],E=(0,a.useState)(""),y=(0,o.A)(E,2),b=y[0],x=y[1];return a.createElement(xC.$,{"data-external-id":"delete-transaction-confirmation",title:_t.ZI.DELETE_TRANSACTION_HISTORY.CONFIRMATION.TITLE,confirm:_t.ZI.BUTTONS.DELETE,isLoading:g,onCancel:c,onConfirm:async()=>{var e;h(!0);const a=(await f({variables:{input:{beforeDate:t,includeSynced:n,includeManual:l,includeUploaded:r,expectedAffectedTransactionsCount:s}}})).data;if(null!==a&&void 0!==a&&null!==(e=a.deleteTransactions)&&void 0!==e&&e.success)d();else{var o;const e=null===a||void 0===a||null===(o=a.deleteTransactions)||void 0===o?void 0:o.errors;(null===e||void 0===e?void 0:e.code)===Ee.O4y.DELETE_TRANSACTIONS_HISTORY_UNAVAILABLE?u({description:null===e||void 0===e?void 0:e.message}):u({description:_t.ZI.ERRORS.DEFAULT}),c()}},useDangerButton:!0,confirmEnabled:b===_t.ZI.DELETE_TRANSACTION_HISTORY.CONFIRMATION.TYPE_TO_CONFIRM},a.createElement("div",null,"Are you sure you want to delete your transactions before"," ",a.createElement(xt.v,{weight:"bold"},N.c9.fromISO(t).toFormat(Kst))," ","? This action will permanently delete transactions for"," ",a.createElement(xt.v,{weight:"bold"},"all synced accounts in your household")," and cannot be undone."),a.createElement(Qw.X,{name:"transactionConfirmation",label:'Type "'.concat(_t.ZI.DELETE_TRANSACTION_HISTORY.CONFIRMATION.TYPE_TO_CONFIRM,'" to confirm deletion'),required:!0,defaultValue:b,onChange:e=>x(e)}))},Qst=e=>{var t,n;let l=e.setDeletedTransactionsCount;const r=(0,Tse._)().isDemoHousehold,i=(0,Pd.h)(),s=(0,o.A)(i,2),c=s[0],d=s[1],u=d.open,m=d.close,p=(0,a.useState)(""),g=(0,o.A)(p,2),h=g[0],v=g[1],f=(0,a.useState)(!0),E=(0,o.A)(f,2),y=E[0],b=E[1],x=(0,a.useState)(!0),w=(0,o.A)(x,2),C=w[0],A=w[1],I=(0,a.useState)(!0),k=(0,o.A)(I,2),S=k[0],T=k[1],_=(0,et.I)(V8.ac,{variables:{includeSynced:y,includeUploaded:S,includeManual:C}}),D=_.data,R=_.refetch,M=null!==D&&void 0!==D&&D.oldestDeletableTransactionDate?N.c9.fromISO(D.oldestDeletableTransactionDate):N.c9.local(),L=(0,et.I)(V8.Ot,{variables:{beforeDate:h,includeSynced:y,includeUploaded:S,includeManual:C},skip:!h||!y&&!S&&!C}),O=L.data,P=L.isNetworkRequestInFlight,B=h&&(null===O||void 0===O?void 0:O.previewDeleteTransactions.totalCount)||void 0,z=!B||0===B||r||!C&&!y&&!S;return a.createElement(Eu.lV,{"data-external-id":"delete-transactions-form",onSubmit:u,preventSubmitWhileSubmitting:!0},a.createElement("div",{className:"flex flex-col gap-default"},a.createElement(tC.zB.Date,{name:"deleteTransactionsBefore",label:_t.ZI.FIELDS.DATE.LABEL,placeholder:_t.ZI.FIELDS.DATE.PLACEHOLDER,min:null!==(t=M.toISODate())&&void 0!==t?t:void 0,max:null!==(n=N.c9.local().toISODate())&&void 0!==n?n:void 0,onValueChanged:e=>{e&&v(e)},required:!0}),a.createElement(tct,null,a.createElement(fz.hm,{checked:y,onChange:e=>{let t=e.target.checked;return b(t)}},a.createElement(ect,null,_t.ZI.FIELDS.INCLUDE_SYNCED.LABEL)),a.createElement(fz.hm,{checked:C,onChange:e=>{let t=e.target.checked;return A(t)}},a.createElement(ect,null,_t.ZI.FIELDS.INCLUDE_MANUAL.LABEL)),a.createElement(fz.hm,{checked:S,onChange:e=>{let t=e.target.checked;return T(t)}},a.createElement(ect,null,_t.ZI.FIELDS.INCLUDE_UPLOADED.LABEL)))),a.createElement(CJ.I,{pending:P,disabled:z}
1,_t.ZI.BUTTONS.SUBMIT(B)),a.createElement(hu.c.Consumer,null,(e=>{let t=e.resetForm;return a.createElement(c,null,a.createElement(Xst,{beforeDate:h,includeSynced:y,includeManual:C,includeUploaded:S,expectedAffectedTransactionsCount:B,onCancel:m,onDelete:()=>{t(),v(""),R(),l(B),m()}}))})))},ect=u.default.span.withConfig({displayName:"DeleteTransactionsForm__CheckboxText",componentId:"sc-1u1bz1k-0"})(["display:inline-block;font-weight:",";font-size:",";padding:"," 0;"],(e=>e.theme.fontWeight.medium),(e=>e.theme.fontSize.small),(e=>e.theme.spacing.xxsmall)),tct=u.default.div.withConfig({displayName:"DeleteTransactionsForm__CheckboxGroup",componentId:"sc-1u1bz1k-1"})(["padding:",";border:1px solid ",";border-radius:",";"],(e=>e.theme.spacing.default),(e=>e.theme.color.grayLight),(e=>e.theme.radius.small)),nct=()=>{const e=(0,nV.J)().downloadBalances,t=(0,Tse._)().isDemoHousehold,n=(0,kJ.X)(),l=(0,o.A)(n,2),r=l[0],i=l[1],s=(0,Pc.e)(!1),c=(0,o.A)(s,2),d=c[0],u=c[1],m=u.setOn,g=u.setOff;return a.createElement(Eu.lV,{"data-external-id":"download-accounts-balances-form",initialValues:{accounts:[]},onSubmit:async t=>{(async t=>{m(),await e(t),g()})(t.accounts)}},a.createElement(tC.zB.Combobox,{multiple:!0,name:"accounts",label:"Accounts",placeholder:"All accounts",loading:r,options:i,clearable:!0}),a.createElement(CJ.I,{disabled:d||t},"Download account balances ",d&&a.createElement(p.i,{size:"sm",className:"ml-2xs"})))},act=()=>{var e;const t=(0,Tse._)().isDemoHousehold,n=(0,QQ.j)({filters:(0,U.A)((0,U.A)({},CX.q9),{},{transactionVisibility:Ee.h1.ALL_TRANSACTIONS})}),l=n.currentSession,r=n.downloadTransactions,o=n.isLoading;return a.createElement(a.Fragment,null,(null===l||void 0===l?void 0:l.errorMessage)&&a.createElement(gme.h,{variant:"error",className:"my-sm"},l.errorMessage),a.createElement(Wb.X,{variant:"primary",size:"md",className:"w-full",onClick:r,isLoading:o,disabled:o||t},"Download transactions"),a.createElement(IQ.T,{downloadUrl:null!==(e=null===l||void 0===l?void 0:l.url)&&void 0!==e?e:void 0}))},lct=e=>{let t=e.onCancel,n=e.onRemove,l=e.isRemoving;return a.createElement(xC.$,{"data-external-id":"remove-credit-data-access-confirmation",title:_t.ZI.REMOVE_CREDIT_DATA_ACCESS.TITLE,confirm:_t.ZI.REMOVE_CREDIT_DATA_ACCESS.BUTTON,isLoading:l,onCancel:t,onConfirm:n,useDangerButton:!0},a.createElement("div",{className:"flex flex-col gap-xl"},a.createElement("div",{className:"flex flex-col"},a.createElement(xt.v,{weight:"medium"},_t.ZI.REMOVE_CREDIT_DATA_ACCESS.CONFIRMATION),a.createElement(xt.v,{size:"small"},_t.ZI.REMOVE_CREDIT_DATA_ACCESS.DISCLAIMER)),a.createElement("div",{className:"flex flex-col gap-xs rounded-default bg-background-secondary p-default text-content-primary"},a.createElement(xt.v,{weight:"medium"},"What will happen:"),["Remove synced bills for recurring transactions","Remove credit score and historical tracking"].map((e=>a.createElement("div",{className:"flex items-center gap-xs",key:e},a.createElement(sl.ZQ,{name:"x-circle",size:24}),a.createElement(xt.v,{size:"small"},e)))))))};var rct=n(9264);const oct=()=>{const e=(0,C.RU)(),t=(0,Pd.h)(),n=(0,o.A)(t,2),l=n[0],r=n[1],s=r.open,c=r.close,d=(0,Xo.IT)(sct),u=d.data,m=d.loading,g=(0,i.n)(q2.dr,{refetchQueries:[sct]}),h=(0,o.A)(g,2),v=h[0],f=h[1].loading,E=!(null!==u&&void 0!==u&&u.spinwheelUser);return a.createElement(a.Fragment,null,m?a.createElement("div",{className:"flex items-center justify-center"},a.createElement(p.i,null)):a.createElement(ict,{disabled:E,onClick:s,size:"medium"},_t.ZI.REMOVE_CREDIT_DATA_ACCESS.TITLE),a.createElement(l,null,a.createElement(lct,{onCancel:c,onRemove:async()=>{var t;const n=(await v()).data;if(null!==n&&void 0!==n&&null!==(t=n.disconnectSpinwheel)&&void 0!==t&&t.isDisconnected)c();else{var a;const t=null===n||void 0===n||null===(a=n.disconnectSpinwheel)||void 0===a?void 0:a.errors;e({description:(null===t||void 0===t?void 0:t.message)||_t.ZI.ERRORS.DEFAULT}),c()}},isRemoving:f})))},ict=(0,u.default)(cu.WT).withConfig({displayName:"RemoveCreditDataAccessButton__StyledButton",componentId:"sc-47bt0e-0"})(["width:100%;",""],rct.f),sct=Ee.M0c,cct=()=>{const e=(0,Tse._)().isDemoHousehold,t=(0,a.useState)(0),n=(0,o.A)(t,2),l=n[0],r=n[1],i=(0,a.useState)(""),s=(0,o.A)(i,2),c=s[0],d=s[1],u=(0,m4.W)();return a.createElement(mX.V,{"data-external-id":"data-settings",md:9},a.createElement(Xhe.Ay,null,a.createElement("title",null,"Monarch Settings | Data")),a.createElement(dct,{title:"Download transactions",isDemo:e,anchorId:"download-transactions"},a.createElement(uct,null,a.createElement(mct,null,"Easily download all your transactions in CSV format by clicking the button below."),a.createElement(act,null))),a.createElement(dct,{title:"Download account balances",isDemo:e,anchorId:"download-account-balances"},a.createElement(uct,null,a.createElement(mct,null,"Select accounts to download all of their account balances in a CSV format."),a.createElement(nct,null))),u&&a.createElement(dct,{title:"Remove credit data access",isDemo:e,anchorId:"remove-credit-data-access"},a.createElement(uct,null,a.createElement(mct,null,"Monarch partners with Spinwheel for access to credit reports. This allows us to provide your credit score as well as credit card statement balances and due dates on the Recurring page. Read more about this functionality in our"," ",a.createElement(wb.gz,{href:VF.vE},"help center"),"."),a.createElement(mct,null,"You can remove credit data access, but note this will disable Credit Score Tracking for your personal account, as well as re
1curring transactions synced via Bill Sync. Manual recurring transactions and other household members will not be affected."),a.createElement(oct,null))),a.createElement(dct,{title:"Delete transaction history in synced accounts",isDemo:e,anchorId:"delete-transaction-history"},a.createElement(uct,null,l>0&&a.createElement(pct,{type:"success"},"Successfully deleted ",l," transactions"),a.createElement(mct,null,"For synced accounts, the amount of historical data Monarch receives can vary. This can lead to different lengths of transaction history in your accounts."),a.createElement(mct,null,"You can give yourself a clean start date for your transactions by specifying a date below, we'll delete any transactions that occurred before the date you specify. This will affect all accounts synced in your household. Manual accounts will not be affected."),a.createElement(Qst,{setDeletedTransactionsCount:e=>{r(e)}}))),a.createElement(dct,{title:"Delete synced account balance snapshots",isDemo:e,anchorId:"delete-account-balance-snapshots"},a.createElement(uct,null,!!c&&a.createElement(pct,{type:"success"},"Successfully deleted balance snapshots before"," ",N.c9.fromISO(c).toFormat("MMM d, yyyy")),a.createElement(mct,null,"Monarch saves a snapshot of your balances in synced accounts every day to track your net worth overtime. You can delete any balance history before the date you specify below."),a.createElement(mct,null,"This is useful for cleaning up historical data when you didn\u2019t have all of your accounts synced yet. This will affect all accounts synced in your household. Manual accounts will not be affected."),a.createElement($st,{setDeletedSnapshotsBeforeDate:d}))))},dct=(0,u.default)(Ffe).withConfig({displayName:"DataSettings__StyledSettingsCard",componentId:"sc-17if580-0"})(["margin-bottom:",";"],(e=>e.theme.spacing.gutter)),uct=u.default.div.withConfig({displayName:"DataSettings__CardBody",componentId:"sc-17if580-1"})(["padding:",";"],(e=>e.theme.spacing.xlarge)),mct=u.default.div.withConfig({displayName:"DataSettings__Description",componentId:"sc-17if580-2"})(["margin-bottom:",";"],(e=>e.theme.spacing.xlarge)),pct=(0,u.default)(fu.g).withConfig({displayName:"DataSettings__StyledBanner",componentId:"sc-17if580-3"})(["margin-bottom:",";"],(e=>e.theme.spacing.xlarge));var gct=n(25845);const hct={referrerSource:"settings_breadcrumb"},vct=e=>{let t=e.isHub,n=e.sectionLabel;return a.createElement(uS.Y9,{"data-external-id":"settings-breadcrumb-header"},a.createElement("div",{className:"flex h-full items-center overflow-hidden"},a.createElement(gct.L.Root,{size:"lg",className:"[&>ol]:flex-nowrap"},a.createElement(gct.L.Item,{current:t,render:t?void 0:a.createElement(l.k2,{to:I.JZ.settings(),state:hct,end:!0})},"Settings"),n&&a.createElement(a.Fragment,null,a.createElement(gct.L.Separator,null),a.createElement(gct.L.Item,{current:!0},n)))))};var fct=n(50650);const Ect=e=>{e&&(e.scrollIntoView({behavior:"smooth",block:"start"}),e.focus({preventScroll:!0}))},yct=e=>{var t,n;return null!==(t=null===(n=e.split("/settings/")[1])||void 0===n?void 0:n.split("/")[0])&&void 0!==t?t:""},bct=e=>{let t=e.containerRef,n=e.contentTopRef,r=e.enabled,o=e.isStacked;const i=(0,l.zy)(),s=i.pathname,c=i.hash,d=i.state,u=null===d||void 0===d?void 0:d.settingsSectionNonce,m=(0,a.useRef)(),p=(0,a.useRef)(!1);(0,a.useEffect)((()=>{const e=()=>{p.current=!0};return yot.forEach((t=>window.addEventListener(t,e,{passive:!0}))),()=>{yot.forEach((t=>window.removeEventListener(t,e))),p.current=!1}}),[s,c,u]),(0,a.useEffect)((()=>{if(!r||!c)return void(m.current=void 0);const e=(0,Ue.Cs)(c),a="".concat((0,Ue.Hb)(s),"#").concat(null!==e&&void 0!==e?e:"","#").concat(null!==u&&void 0!==u?u:"");if(m.current===a)return;if(p.current&&void 0===u)return;m.current=a;const l=t.current;if(!l)return;const i=e?(0,Ue.A2)(s,e):void 0;if(null!==i&&void 0!==i&&i.virtualized)return;let d,g,h;const v=()=>{var e;null===(e=g)||void 0===e||e.disconnect(),g=void 0,clearTimeout(h),yot.forEach((e=>window.removeEventListener(e,v)))},f=()=>{const e=n.current;o&&e&&(e.scrollIntoView({behavior:"auto",block:"start"}),e.focus({preventScroll:!0}))},E=()=>{const t=e&&Aot(e,l);return!!t&&(v(),d=(e=>{const t=Eot(e);e.focus({preventScroll:!0});const n=Iot(e);return()=>{t(),n()}})(t),!0)};if(i)return E()||(g=new MutationObserver(E),g.observe(l,{childList:!0,subtree:!0}),h=setTimeout((()=>{v(),f()}),3e4),yot.forEach((e=>window.addEventListener(e,v,{passive:!0})))),()=>{var e;g&&(m.current=void 0),v(),null===(e=d)||void 0===e||e()};f()}),[s,c,u,r,o,t,n])};var xct,wct,Cct;const Act=Bq((()=>{const e=(0,P6.f)().isSponsored,t=(0,qG.e)(),n=t.hasPlusAccess,r=t.isLoading,o=(0,d.d4)(Od.T2),i=(0,fct.S)({trackFlagImpressions:!0}),s=Foe({trackImpression:!0}),c=s.isVariant,u=s.isResolved,m=s.isHub,p=s.section,g=(0,l.zy)(),h=g.pathname,v=g.search,f=g.hash,E=g.key,y=(0,nG.p)(Ue.rt,"off"),b=y&&Boolean(f),x=(0,a.useRef)(null),w=(0,a.useRef)(!1);(0,a.useEffect)((()=>
1{if(!u||w.current)return;if(w.current=!0,b||c)return;const e=new URLSearchParams(window.location.search);var t;x7.Fr&&"bottom"===e.get("scroll")&&(null===(t=x.current)||void 0===t||t.scrollIntoView({behavior:"smooth",block:"end"}))}),[b,u,c]);const C=(0,G.U)("only screen and (max-width: ".concat(yD.w.breakPoints.md,"px)")),A=(0,a.useRef)(null),k=(0,a.useRef)(null),S=(e=>{let t=e.menuTopRef,n=e.contentTopRef,l=e.pathname,r=e.enabled,o=void 0===r||r,i=e.hasBottomScrollParam,s=void 0!==i&&i,c=e.hasSubsectionHash,d=void 0!==c&&c,u=e.isDeepLinkEntry,m=void 0!==u&&u;const p=(0,a.useRef)(!1),g=(0,a.useRef)(yct(l)),h=(0,a.useRef)(!1),v=(0,a.useCallback)((e=>{if(!o)return;const t=e.target.closest("a");t&&(0!==e.button||e.metaKey||e.ctrlKey||e.shiftKey||e.altKey||(t.pathname!==l&&(p.current=!0),Ect(n.current)))}),[o,l,n]);return(0,a.useEffect)((()=>{const e=yct(l),a=g.current!==e;if(g.current=e,p.current)p.current=!1;else{if(!h.current){h.current=!0;const t=n.current;if(!o||!m||!e||s||d||!t)return;return t.focus({preventScroll:!0}),Eot(t)}a&&o&&!d&&Ect(t.current)}}),[l,o,s,d,m,t,n]),v})({menuTopRef:A,contentTopRef:k,pathname:h,enabled:C&&!c,hasBottomScrollParam:"bottom"===new URLSearchParams(v).get("scroll"),hasSubsectionHash:b,isDeepLinkEntry:"default"===E}),N=(0,a.useRef)(p);return(0,a.useLayoutEffect)((()=>{const e=N.current!==p;var t;(N.current=p,c&&e)&&(null===(t=A.current)||void 0===t||t.scrollIntoView({block:"start"}))}),[c,p]),bct({containerRef:A,contentTopRef:k,enabled:y,isStacked:C}),a.createElement(rG.Y,{"data-external-id":"settings",name:"Settings",parentRoute:null,header:c?a.createElement(vct,{isHub:m,sectionLabel:zoe(i,h)}):void 0},a.createElement("div",{ref:A,tabIndex:-1,className:"flex items-start"},a.createElement(pX.f,{className:"pt-0"},(!c||m)&&a.createElement(kct,{md:3},i.map((e=>a.createElement(Ict,{key:e.id,title:e.title},a.createElement(Tm,{as:"nav","aria-label":e.title,className:"px-2xs",onClick:S},e.items.map((e=>a.createElement(Sct,{key:e.id,to:e.route},e.badge?a.createElement("span",{className:"flex items-center gap-xs"},e.label,e.badge):e.label))))))),a.createElement("div",{ref:k,tabIndex:-1})),a.createElement(l.BV,null,a.createElement(l.qh,{path:I.JZ.settings.profile.relativePath,element:a.createElement(jot,null)}),a.createElement(l.qh,{path:I.JZ.settings.display.relativePath,element:a.createElement(Bnt,null)}),a.createElement(l.qh,{path:I.JZ.settings.notifications.relativePath,element:a.createElement(Rot,null)}),a.createElement(l.qh,{path:I.JZ.settings.security.relativePath,element:a.createElement(dye,null)}),a.createElement(l.qh,{path:I.JZ.settings.earlyAccess.relativePath,element:a.createElement(Unt,null)}),a.createElement(l.qh,{path:I.JZ.settings.legacyEarlyAccess.relativePath,element:a.createElement(l.C5,{to:I.JZ.settings.earlyAccess(),replace:!0})}),a.createElement(l.qh,{path:I.JZ.settings.integrations.relativePath,element:a.createElement(OY,{name:"feat-mcp-web",defaultOnTimeout:"off"},a.createElement(Elt,null))}),a.createElement(l.qh,{path:I.JZ.settings.household.relativePath,element:a.createElement(Oat,null)}),a.createElement(l.qh,{path:I.JZ.settings.members.relativePath,element:a.createElement(srt,null)}),a.createElement(l.qh,{path:"".concat(I.JZ.settings.institutions.relativePath,"/*"),element:a.createElement(jat,null)}),a.createElement(l.qh,{path:I.JZ.settings.preferences.relativePath,element:a.createElement(Lot,null)}),a.createElement(l.qh,{path:"".concat(I.JZ.settings.rules.relativePath,"/*"),element:a.createElement(rst,null)}),a.createElement(l.qh,{path:I.JZ.settings.data.relativePath,element:a.createElement(cct,null)}),a.createElement(l.qh,{path:I.JZ.settings.categories.relativePath,element:a.createElement(Ont,null)}),a.createElement(l.qh,{path:"".concat(I.JZ.settings.billing.relativePath,"/*"),element:o?a.createElement(l.C5,{to:I.JZ.settings.profile(),replace:!0}):a.createElement(mtt,null)}),a.createElement(l.qh,{path:I.JZ.settings.gifts.relativePath,element:a.createElement(OY,{name:"feat-settings-gift-monarch-web",defaultOnTimeout:"on"},a.createElement(kat,null))}),a.createElement(l.qh,{path:I.JZ.settings.referrals.relativePath,element:a.createElement(Dit,null)}),a.createElement(l.qh,{path:I.JZ.settings.trustAndWill.relativePath,element:r||n?a.createElement(Pst,null):a.createElement(l.C5,{to:I.JZ.settings.profile(),replace:!0})}),a.createElement(l.qh,{path:I.JZ.settings.tags.relativePath,element:a.createElement(Ast,null)}),a.createElement(l.qh,{path:I.JZ.settings.merchants.relativePath,element:a.createElement(Yrt,null)}),a.createElement(l.qh,{path:I.JZ.settings.employers.relativePath,element:a.createElement(OY,{name:"feat-paychecks-web",defaultOnTimeout:"off"},a.createElement(Znt,null))}),!e&&a.createElement(l.qh,{path:"".concat(I.JZ.settings.businesses.relativePath,"/*"),element:a.createElement(btt,null)})),a.createElement("div",{ref:x}))))}
1)),Ict=(0,$d.s)(Xl.AM)(xct||(xct=(0,wc.A)(["overflow-hidden not-first:mt-gutter"]))),kct=(0,$d.s)(mX.V)(wct||(wct=(0,wc.A)(["mb-gutter md:mb-0"]))),Sct=(0,$d.s)(Tm.ItemLink)(Cct||(Cct=(0,wc.A)(["px-lg"]))),Nct=e=>{let t=e.children;const n=(0,ot.M)(),r=n.isOn,o=n.isReady;return r||!o?t:a.createElement(l.C5,{"data-external-id":"monarch-agent-route",to:I.JZ.dashboard.path,replace:!0})},Tct=[],_ct=e=>(null===e||void 0===e?void 0:e.trim())||Re.UNTITLED_CONVERSATION,Dct=function(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:5;const a=t?e.findIndex((e=>e.id===t)):-1;if(a<=0)return e.slice(0,n);return[e[a]].concat(e.slice(0,a),e.slice(a+1)).slice(0,n)};var Rct=n(70127);const Mct=e=>{var t;let n=e.open,l=e.onOpenChange,r=e.activeThreadId,i=e.onSelectThread,s=e.onDeleted;const c=(0,et.I)(Qe.ps,{skip:!n}),d=c.data,u=c.isLoadingInitialData,m=c.error,p=ts({refetchQueries:[Qe.ps]}),g=(0,o.A)(p,1)[0],h=null!==(t=null===d||void 0===d?void 0:d.messageThreads)&&void 0!==t?t:Tct,v=(0,a.useMemo)((()=>xd(h)),[h]);let f;return f=u?a.createElement("div",{className:"flex justify-center p-sm"},a.createElement(fe.ix7,{size:"sm"})):m?a.createElement(SQ.W,{className:"p-sm",message:VG.U.DEFAULT}):0===h.length?a.createElement(fe.erR,{variant:"secondary",title:Re.CHAT_HISTORY_EMPTY}):v.map((e=>{let t=e.category,n=e.threads;return a.createElement("div",{key:t,className:"flex flex-col gap-2xs"},a.createElement(fe.c8D,{size:"xs",color:"secondary"},t),n.map((e=>a.createElement(Lct,{key:e.id,title:_ct(e.subject),onSelect:()=>((e,t)=>{const n=_ct(t);e!==r&&(0,Ge.u4)(Ye.xb.AssistantChatRevisited,{thread_id:e}),i(e,n),l(!1)})(e.id,e.subject),onDelete:()=>{(async e=>{(0,Rct.m3)(e)&&((0,Ge.u4)(Ye.xb.AssistantChatDeletedClicked,{thread_id:e}),await g({variables:{id:e}}),s(e))})(e.id)}}))))})),a.createElement(fe.hg1.Root,{"data-external-id":"today-chat-history-dialog",open:n,onOpenChange:l,size:"xl",scroll:"outside"},a.createElement(fe.hg1.Content,null,a.createElement(fe.hg1.CloseTrigger,null),a.createElement(fe.hg1.Header,null,a.createElement(fe.hg1.Title,null,Re.CHAT_HISTORY)),a.createElement(fe.hg1.Body,{className:"flex flex-col gap-lg"},f)))},Lct=e=>{let t=e.title,n=e.onSelect,l=e.onDelete;const r=(0,a.useState)(!1),i=(0,o.A)(r,2),s=i[0],c=i[1];return a.createElement("div",{"data-external-id":"today-chat-history-row",className:"group relative"},a.createElement(fe.Qey,{title:t,onClick:n,actions:a.createElement(fe.u$N,{align:"end",open:s,onOpenChange:c,trigger:a.createElement(fe.SO$,{variant:"minimal",size:"xs","aria-label":Re.CHAT_HISTORY_MORE,className:s?void 0:"opacity-0 group-focus-within:opacity-100 group-hover:opacity-100"},a.createElement(fe.V_g,null)),items:[{label:Re.DELETE_THIS_CHAT,variant:"destructive",leading:a.createElement(fe.i01,{size:"xs"}),onClick:l}]})}))},Oct=e=>{var t,n;let l=e.title,r=e.activeThreadId,i=e.onSelectThread,s=e.onDeleted;const c=(0,a.useState)(!1),d=(0,o.A)(c,2),u=d[0],m=d[1],p=(0,a.useState)(!1),g=(0,o.A)(p,2),h=g[0],v=g[1],f=(0,et.I)(Qe.ps),E=f.data,y=f.isLoadingInitialData,b=f.error,x=null!==(t=null===E||void 0===E?void 0:E.messageThreads)&&void 0!==t?t:Tct,w=(0,a.useMemo)((()=>Dct(x,r,7)),[r,x]),C=null===(n=x.find((e=>e.id===r)))||void 0===n?void 0:n.subject,A=l.trim()||_ct(C);let I;return I=y?a.createElement("div",{className:"flex justify-center p-sm"},a.createElement(fe.ix7,{size:"sm"})):b?a.createElement(SQ.W,{className:"p-sm",message:VG.U.DEFAULT}):a.createElement(a.Fragment,null,a.createElement(fe.u$N.RadioGroup,{value:null!==r&&void 0!==r?r:void 0,onValueChange:e=>{if(!e)return;const t=x.find((t=>t.id===e));((e,t)=>{const n=_ct(t);e!==r&&(0,Ge.u4)(Ye.xb.AssistantChatRevisited,{thread_id:e}),i(e,n),m(!1),v(!1)})(e,null===t||void 0===t?void 0:t.subject)}},w.map((e=>a.createElement(fe.u$N.RadioItem,{key:e.id,value:e.id,closeOnClick:!0},_ct(e.subject))))),a.createElement(fe.u$N.Item,{leading:a.createElement(fe.OBL,{size:"xs"}),onClick:()=>v(!0)},Re.VIEW_FULL_CHAT_HISTORY)),a.createElement(a.Fragment,null,a.createElement(fe.u$N.Root,{open:u,onOpenChange:m},a.createElement(fe.u$N.Trigger,{className:"max-w-full min-w-0",render:a.createElement("button",{type:"button",className:" flex max-w-full min-w-0 appearance-none items-center gap-3xs border-0 bg-transparent p-0 font-medium text-inherit "})},a.createElement("span",{className:"min-w-0 truncate"},A),a.createElement(fe.D39,{className:"shrink-0","aria-hidden":!0})),a.createElement(fe.u$N.Content,{align:"start",className:"max-w-container-2xs"}
1,I)),a.createElement(Mct,{open:h,onOpenChange:v,activeThreadId:r,onSelectThread:i,onDeleted:s}))},Pct=e=>{let t=e.sendMessage;const n=(0,d.d4)(ft.GC),l=(0,F.K)(),r=(0,on.u)("feat-smart-prompts","va-1",{trackImpression:!0}).whichExperimentVariant,o=rn(5,void 0!==r),i=o.prompts,s=o.isUsingSmartPrompts,c=o.isLoadingInitialData,u=an(),m=u.trackImpressions,p=u.trackClick,g=(0,a.useRef)(!1);(0,a.useEffect)((()=>{0===i.length||c||g.current||(g.current=!0,(0,Ge.u4)(Ye.xb.AssistantPromptShown,{source:null!==n&&void 0!==n?n:void 0,prompt_type:s?"smart":"generic"}),s&&m(i))}),[c,s,i,n,m]);const h=(0,a.useCallback)(((e,a)=>{var r;l||(s&&p(e),(0,Ge.u4)(Ye.xb.AssistantPromptSelected,{prompt_template_name:null!==(r=e.templateName)&&void 0!==r?r:void 0,prompt_position:a,source:null!==n&&void 0!==n?n:void 0,prompt_type:s?"smart":"generic"}),t({content:e.promptText,fromRecommendedPrompt:!0,triggerSource:(0,Xt.Q)(n,s?"smart":"generic")}))}),[l,s,t,n,p]);return a.createElement("div",{"data-external-id":"today-new-chat-empty",className:"mx-auto flex w-full max-w-container-md flex-col items-center pt-lg pb-xs"},a.createElement(Bt,null),a.createElement("div",{className:"mt-xl flex w-full flex-col items-center gap-sm"},i.map(((e,t)=>a.createElement(Kt,{key:"prompt-".concat(e.id),prompt:e,position:t,onClick:h,disabled:l})))))},Bct=e=>{let t=e.insightId,n=e.initialMessage,a=e.threadId,l=e.createdAt,r=e.isNewChatOrigin,o=e.newChatSessionId;return r?(0,Rct.EW)({insight:null,initialMessage:"",isNewChatOrigin:r,newChatSessionId:o}):n?(0,Rct.EW)({insight:t?{id:t}:null,initialMessage:n,createdAt:l}):a}
1,zct=(e,t,n)=>{const a=[e,t,n].find((e=>{const t=null===e||void 0===e?void 0:e.trim();return Boolean(t)&&t!==_t.zA.MESSAGE_THREAD_SUBJECT_PLACEHOLDER}));return a?a.replace(/\s+/g," ").trim():null},Fct=(e,t)=>({dx:e.left-t.left,dy:e.top-t.top,scale:t.width?e.width/t.width:1}),Gct=(e,t)=>{if((()=>{var e,t;return Boolean(null===(e=(t=window).matchMedia)||void 0===e?void 0:e.call(t,"(prefers-reduced-motion: reduce)").matches)})())return!0;const n=Fct(e,t),a=n.dx,l=n.dy;return Math.abs(a)<1&&Math.abs(l)<1},Yct=e=>{e.style.transition="",e.style.transform="",e.style.transformOrigin="",e.style.willChange=""},Uct=e=>{e.style.transition="",e.style.transform="",e.style.opacity=""},Vct=(e,t)=>{const n=(0,a.useRef)(null),l=(0,a.useRef)(!1),r=(0,a.useRef)(RQ.l),i=(0,a.useState)((()=>t&&null!==e)),s=(0,o.A)(i,2),c=s[0],d=s[1];(0,a.useLayoutEffect)((()=>(t&&e||d(!1),()=>{r.current()})),[t,e]);const u=(0,a.useCallback)((a=>{if(!a||!t||!e||l.current)return;l.current=!0;const o=function(e,t){let n=(arguments.length>2&&void 0!==arguments[2]?arguments[2]:{}).fade;const a=e.getBoundingClientRect();if(Gct(t,a))return{durationMs:0,cancel:()=>{}};const l=Fct(t,a),r=l.dx,o=l.dy,i=l.scale;e.style.transformOrigin="top left",e.style.willChange="transform",e.style.transform="translate(".concat(r.toFixed(1),"px,").concat(o.toFixed(1),"px) scale(").concat(i.toFixed(4),")"),n&&(n.style.opacity="0",n.style.transform="translateY(8px)"),e.getBoundingClientRect();let s=!1,c=0,d=0,u=0;const m=()=>{s||(s=!0,e.style.transition="transform ".concat(.44,"s ").concat("cubic-bezier(.22,.61,.36,1)"),e.style.transform="none",n&&(n.style.transition="opacity ".concat(.34,"s ease ").concat(.1,"s, transform ").concat(.34,"s ease ").concat(.1,"s"),n.style.opacity="1",n.style.transform="none"),u=window.setTimeout((()=>{Yct(e),n&&Uct(n),s=!1}),480))};return c=requestAnimationFrame(m),d=window.setTimeout(m,40),{durationMs:440,cancel:()=>{cancelAnimationFrame(c),window.clearTimeout(d),window.clearTimeout(u),Yct(e),n&&Uct(n)}}}(a,e,{fade:n.current}),i=o.durationMs,s=o.cancel;if(0===i)return r.current=s,void d(!1);const c=window.setTimeout((()=>d(!1)),i);r.current=()=>{s(),window.clearTimeout(c)}}),[t,e]);return{cardRef:u,identityRef:n,hideTurns:c}},Wct=e=>{var t;let n=e.initialMessage,l=e.initialPromptKind,r=e.initialTriggerSource,s=e.initialFromGlobalSearch,c=e.threadId,d=e.onCreateThreadSuccess,u=e.onCreateThreadError,m=e.onThreadSubject,p=e.onThreadNotFound,g=e.assistantName,h=e.assistantColor,v=e.insight,f=void 0===v?null:v,E=e.isInsightSaved,y=e.onSaveInsight,b=e.onCompleteInsight,x=e.onInsightPrimaryAction,w=e.emptyIntro,C=void 0!==w&&w,A=e.flipFrom,I=void 0===A?null:A;const k=(0,a.useState)(""),S=(0,o.A)(k,2),T=S[0],_=S[1],D=(0,a.useState)((()=>N.c9.local())),R=(0,o.A)(D,1)[0],M=(0,F.K)(),L=(0,a.useRef)(!1),P=Vct(I,Boolean(f)),B=P.cardRef,z=P.identityRef,G=P.hideTurns,Y=(e=>{const t=(0,V.m)(),n=(0,i.n)(ns,{refetchQueries:[Qe.ps]}),l=(0,o.A)(n,1)[0];return{onFirstMessageFailed:(0,a.useCallback)((n=>{e&&(0,Rct.m3)(n)&&(t.cache.modify({id:t.cache.identify({__typename:"InsightType",id:e}),fields:{messageThreadId:e=>e===n?null:e}}),l({variables:{id:n}}).catch((()=>{})))}),[e,t,l])}})(null===f||void 0===f?void 0:f.id),U=Y.onFirstMessageFailed,W=Bu({threadId:null!==c&&void 0!==c?c:void 0,onCreateThreadSuccess:e=>{let t=e.threadId,n=e.optimistic;d(t,n)},onCreateThreadError:u,insightId:null===f||void 0===f?void 0:f.id,onFirstMessageFailed:U,onThreadNotFound:p}),j=W.messages,H=W.lastMessage,K=W.isLastMessageFromUser,q=W.hasOutstandingAssistantRequests,$=W.isLastMessageStreaming,Z=W.canCancelResponse,J=W.sendMessage,X=W.cancelResponse,Q=W.retryLastErroredMessage,ee=W.messageThread,te=(e=>{var t,n;return(null===(t=e.find((e=>"UserMessage"===e.__typename)))||void 0===t||null===(n=t.content)||void 0===n?void 0:n.trim())||void 0})(j);(0,a.useEffect)((()=>{const e=zct(null===ee||void 0===ee?void 0:ee.subject,null===f||void 0===f?void 0:f.title,te);e&&(null===m||void 0===m||m(e))}),[null===f||void 0===f?void 0:f.title,null===ee||void 0===ee?void 0:ee.subject,te,m]),(0,a.useEffect)((()=>
1{if(L.current)return;L.current=!0;const e=(0,Rct.wD)(c,n,l,{triggerSource:r,fromGlobalSearch:s});e&&J(e)}),[]);const ne=q||$,ae=ne||M,le=Wu(H,ne),re=ne&&Z,oe=C&&!f&&0===j.length,ie=oe?Re.ASK_ANYTHING_PLACEHOLDER:Pe(g),se=oe?a.createElement(Pct,{sendMessage:J}):a.createElement(Gu,{assistantName:g,assistantColor:h,avatarState:le,timestamp:Fu(null===(t=j[0])||void 0===t?void 0:t.createdAt,R),identityRef:z},f?a.createElement("div",{ref:B},a.createElement(nc,{insight:f,isSaved:E,onSave:y,onComplete:b,onPrimaryAction:x})):null);return a.createElement(O,{"data-external-id":"today-conversation",value:{sendMessage:J}},a.createElement("div",{className:"flex min-h-0 flex-1 flex-col"},a.createElement("div",{className:"flex min-h-0 flex-1 flex-col"},a.createElement(Zd,{messages:G?[]:j,header:se,footer:K&&a.createElement(_u,null),isAnimationComplete:!0,overlayColor:"var(--background-page)",hideLeadingTimestamp:!0,scrollAnchor:"leading-header"})),a.createElement("div",{className:"shrink-0 border-t border-divider-secondary bg-background-secondary px-xl pt-sm pb-lg"},a.createElement("div",{className:"mx-auto w-full",style:{maxWidth:Yd.aA}},a.createElement(Vu,{value:T,placeholder:ie,isSubmitDisabled:ae,showCancelButton:re,onChange:_,onSubmit:()=>{const e=T.trim();e&&!ae&&(J({content:e,triggerSource:Ee.y3I.ASSISTANT}),_(""))},onCancel:X,onRetry:Q})))))},jct=e=>{var t;let n=e.conversation,l=e.assistantName,r=e.assistantColor,o=e.flipFrom,i=e.onCreateThreadSuccess,s=e.onCreateThreadError,c=e.onThreadSubject,d=e.onThreadNotFound,u=e.isInsightSaved,m=e.onSaveInsight,p=e.onCompleteInsight,g=e.onInsightPrimaryAction;return a.createElement("div",{"data-external-id":"today-conversation-pane",className:"flex min-h-0 w-full flex-1 flex-col px-xl"},a.createElement(Wct,{key:Bct({insightId:null===(t=n.insight)||void 0===t?void 0:t.id,initialMessage:n.initialMessage,threadId:n.threadId,createdAt:n.createdAt,isNewChatOrigin:n.isNewChatOrigin,newChatSessionId:n.newChatSessionId}),initialMessage:n.initialMessage,initialPromptKind:n.promptKind,initialTriggerSource:n.triggerSource,initialFromGlobalSearch:n.fromGlobalSearch,threadId:n.threadId,emptyIntro:Boolean(n.isNewChatOrigin),assistantName:l,assistantColor:r,onCreateThreadSuccess:i,onCreateThreadError:s,onThreadSubject:c,onThreadNotFound:d,insight:n.insight,isInsightSaved:u,onSaveInsight:m,onCompleteInsight:p,onInsightPrimaryAction:g,flipFrom:n.insight?o:null}))},Hct=()=>a.createElement(fe.xz6,{"data-external-id":"today-error-card"},a.createElement("div",{className:"flex flex-col gap-2xs p-lg"},a.createElement(fe.c8D,{weight:"medium"},Re.ERROR_TITLE),a.createElement(fe.c8D,{size:"sm",color:"secondary"},Re.ERROR_BODY))),Kct=e=>"insight"===e.type?e.insight.id:e.ask.insight.id,qct=e=>{let t=e.ask,n=e.onOpenForm,l=e.onRetire,r=e.onChangeNote,i=e.onSubmit,s=e.isSubmitting,c=void 0!==s&&s,d=e.deferTimer,u=void 0!==d&&d;const m=t.insight,p=(0,a.useState)(!1),g=(0,o.A)(p,2),h=g[0],v=g[1],f=(0,a.useRef)(4e3),E=(0,a.useRef)(null),y=(0,a.useRef)(l);y.current=l;const b=t.note.trim();return(0,a.useEffect)((()=>{if(u||"bar"!==t.phase||h)return;E.current=Date.now();const e=window.setTimeout((()=>y.current(m.id)),f.current);return()=>{var t,n,a;window.clearTimeout(e),null!==E.current&&(f.current=(t=f.current,n=E.current,a=Date.now(),Math.max(0,t-(a-n))),E.current=null)}}),[t.phase,u,m.id,h]),a.createElement("div",{"data-external-id":"dismiss-ask-row","data-testid":"dismiss-ask-row",className:"rounded-lg border border-divider-secondary bg-background-primary p-default",onMouseEnter:"bar"===t.phase?()=>v(!0):void 0,onMouseLeave:"bar"===t.phase?()=>v(!1):void 0},a.createElement("div",{className:"flex items-center gap-sm"},a.createElement(rc,{insight:m}),a.createElement(fe.c8D,{size:"sm",weight:"medium",className:"min-w-0 flex-1 truncate"},m.title),"bar"===t.phase?a.createElement(fe.XZZ,{size:"xs",rounded:"pill",onClick:()=>n(m.id)},Re.GIVE_FEEDBACK_PROMPT):null,a.createElement(fe.TU1,{variant:"minimal",size:"xs","aria-label":Re.DISMISS,onClick:()=>l(m.id)})),"form"===t.phase?a.createElement("div",{className:"mt-sm flex flex-col gap-sm pl-3xl"},a.createElement(fe.c8D,{size:"sm",color:"secondary"},m.description),a.createElement(fe.c8D,{size:"sm",weight:"medium"},Re.DISMISS_ASK_QUESTION),a.createElement(fe.LYY,{size:"sm",minRows:2,maxRows:4,value:t.note,onChange:e=>r(m.id,e.target.value)}),a.createElement(fe.XZZ,{size:"xs",rounded:"pill",className:"self-start",disabled:!b||c,onClick:()=>i(m.id)},Re.DISMISS_ASK_SUBMIT)):null)},$ct=300,Zct="cubic-bezier(0.2, 0.8, 0.2, 1)",Jct=e=>{let t=e.active,n=e.card,l=e.bar,r=e.onSettled;const i=(0,a.useRef)(null),s=(0,a.useRef)(null),c=(0,a.useRef)(r),d=(0,a.useRef)(!1),u=(0,a.useRef)(t);c.current=r;const m=(0,a.useState)(null),p=(0,o.A)(m,2),g=p[0],h=p[1];(0,a.useLayoutEffect)((()=>{var e,t,n,a;if(!u.current)return;const l=null!==(e=null===(t=i.current)||void 0===t?void 0:t.offsetHeight)&&void 0!==e?e:0,r=null!==(n=null===(a=s.current)||void 0===a?void 0:a.offsetHeight)&&void 0!==n?n:0;if(window.matchMedia("(prefers-reduced-motion: reduce)").matches)return void(d.current||(d.current=!0,
1c.current()));h({from:l,to:r,run:!1});const o=requestAnimationFrame((()=>h({from:l,to:r,run:!0})));return()=>cancelAnimationFrame(o)}),[]),(0,a.useEffect)((()=>{if(null===g||void 0===g||!g.run)return;const e=window.setTimeout((()=>{d.current||(d.current=!0,c.current())}),$ct);return()=>window.clearTimeout(e)}),[null===g||void 0===g?void 0:g.run]);const v=t&&null!==g,f=v&&g.run;return a.createElement("div",{"data-external-id":"dismiss-morph",className:"relative",style:v?{height:f?g.to:g.from,transition:f?"height ".concat($ct,"ms ").concat(Zct):void 0}:void 0},a.createElement("div",{ref:i,"aria-hidden":!0,className:(0,q.cn)("pointer-events-none",v&&"absolute inset-x-0 top-0"),style:{display:t?void 0:"none",opacity:f?0:1,transition:f?"opacity ".concat($ct,"ms ").concat(Zct):void 0}},n),a.createElement("div",{ref:s,className:(0,q.cn)(t&&"absolute inset-x-0 top-0",t&&!f&&"pointer-events-none"),style:{opacity:!t||f?1:0,transition:f?"opacity ".concat($ct,"ms ").concat(Zct):void 0}},l))},Xct=e=>{let t=e.onUndo;const n=(0,a.useState)(!1),l=(0,o.A)(n,2),r=l[0],i=l[1];return(0,a.useEffect)((()=>{const e=requestAnimationFrame((()=>i(!0)));return()=>cancelAnimationFrame(e)}),[]),a.createElement(fe.xz6,{"data-external-id":"today-complete-stub",className:(0,q.cn)("rounded-lg shadow-card transition-opacity duration-200",r?"opacity-100":"opacity-0")},a.createElement("div",{className:"flex items-center gap-sm px-default py-sm"},a.createElement(fe.GdR,{size:"sm",className:"shrink-0 text-content-secondary"}),a.createElement(fe.c8D,{size:"sm",color:"secondary",className:"min-w-0 flex-1"},Re.COMPLETE_STUB),a.createElement(fe.XZZ,{size:"xs",variant:"text",colorScheme:"link",icon:a.createElement(fe.YuY,null),onClick:t},Re.UNDO)))},Qct=e=>{let t=e.row,n=e.__segment;return a.createElement(fe.Qey.Root,{"data-external-id":"background-row",__segment:n},a.createElement(fe.Qey.Media,null,a.createElement(fe.Qey.IconTile,{color:"gray-secondary",className:"size-7 rounded-full",icon:a.createElement(Zs,{name:t.icon})}
1)),a.createElement(fe.Qey.Content,null,a.createElement(fe.c8D,{size:"sm",color:"secondary"},t.title)))},edt=e=>{let t=e.rows;return a.createElement("div",{"data-external-id":"today-feed-background-section",className:"flex flex-col gap-xs"},a.createElement(fe.Qey.Group,{className:"border border-divider-secondary"},t.map((e=>a.createElement(Qct,{key:e.id,row:e})))),a.createElement("div",{className:"flex items-center gap-xs"},a.createElement(fe.tam,{size:"sm",className:"shrink-0 text-content-secondary"}),a.createElement(fe.c8D,{size:"xs",color:"secondary"},Re.BACKGROUND_FOOTNOTE)))},tdt="section",ndt="tab",adt=new Set(["saved","completed","archived","everything_else"]),ldt=new Set([...As.map((e=>e.id)),...adt]),rdt=e=>!adt.has(e),odt=e=>{var t,n;return"saved"===e?Re.RAIL_SAVED_LABEL:"completed"===e?Re.RAIL_COMPLETED_LABEL:"archived"===e?Re.RAIL_DISMISSED_LABEL:"everything_else"===e?Re.EVERYTHING_ELSE:null!==(n=null===(t=As.find((t=>t.id===e)))||void 0===t?void 0:t.label)&&void 0!==n?n:e},idt=(e,t)=>"saved"===e?{title:Re.RAIL_SAVED_LABEL,blurb:t>0?Re.SAVED_PAGE_BLURB:Re.SAVED_PAGE_EMPTY}:"completed"===e?{title:Re.RAIL_COMPLETED_LABEL,blurb:t>0?Re.COMPLETED_PAGE_BLURB:Re.COMPLETED_PAGE_EMPTY}:"archived"===e?((e,t)=>"unhelpful"===e?{title:Re.RAIL_DISMISSED_LABEL,blurb:t>0?Re.UNHELPFUL_PAGE_BLURB:Re.UNHELPFUL_PAGE_EMPTY}:{title:Re.RAIL_DISMISSED_LABEL,blurb:t>0?Re.DISMISSED_PAGE_BLURB:Re.DISMISSED_PAGE_EMPTY})("dismissed",t):"everything_else"===e?{title:Re.EVERYTHING_ELSE,blurb:Re.EVERYTHING_ELSE_PAGE_BLURB}:{title:odt(e),blurb:Re.SECTION_PAGE_BLURBS[e]},sdt=e=>{let t=e.overviewId,n=e.itemCount,l=e.backgroundRows,r=void 0===l?[]:l,o=e.children;const i=idt(t,n);return a.createElement("section",{"data-external-id":"today-feed-focused-overview",className:"flex flex-col gap-xl"},a.createElement("div",{className:"flex flex-col gap-xs"},a.createElement(kD.c,{size:"20",weight:"medium",render:a.createElement("h1",null),className:"m-0"},i.title),a.createElement(kD.c,{color:"secondary"},i.blurb)),"in_the_background"===t?a.createElement(edt,{rows:r}):o)},cdt=e=>{let t=e.isDismissing,n=e.onAnimationEnd,l=e.children;const r=(0,a.useRef)(null),i=(0,a.useRef)(n);i.current=n;const s=(0,a.useState)("idle"),c=(0,o.A)(s,2),d=c[0],u=c[1],m=(0,a.useState)(),p=(0,o.A)(m,2),g=p[0],h=p[1];return(0,a.useEffect)((()=>{var e,n;if(!t)return u("idle"),void h(void 0);const a=null!==(e=null===(n=r.current)||void 0===n?void 0:n.getBoundingClientRect().height)&&void 0!==e?e:0;h(a),u("fade");const l=window.setTimeout((()=>{u("collapse")}),200);return()=>window.clearTimeout(l)}),[t]),(0,a.useEffect)((()=>{if("collapse"!==d)return;const e=window.setTimeout((()=>{i.current(null!==g&&void 0!==g?g:0)}),210);return()=>window.clearTimeout(e)}),[g,d]),a.createElement("div",{"data-external-id":"dismissable-insight",ref:r,className:(0,q.cn)("fade"===d&&"opacity-0 transition-opacity duration-200 ease-out","collapse"===d&&"overflow-hidden opacity-0 transition-[max-height,margin,padding,opacity] duration-210 ease-out"),style:ddt(d,g)},l)},ddt=(e,t)=>"collapse"===e?{maxHeight:0,marginTop:0,marginBottom:0,paddingTop:0,paddingBottom:0}:"fade"===e&&t?{maxHeight:t}:void 0,udt=e=>{let t=e.insight,n=e.isDismissing,l=e.isSaved,r=e.forceRestore,o=e.onDismiss,i=e.onRestore,s=e.onDismissAnimationEnd,c=e.onComplete,d=e.onUndoComplete,u=e.onSave,m=e.onPrimaryAction,p=e.onOpenConversation;return a.createElement(cdt,{"data-external-id":"today-feed-insight-card",isDismissing:n,onAnimationEnd:()=>null===s||void 0===s?void 0:s(t.id)},a.createElement(nc,{insight:t,isSaved:l,forceRestore:r,onDismiss:o,onRestore:i,onComplete:c,onUndoComplete:d,onSave:u,onPrimaryAction:m,onOpenConversation:p}))},mdt=(e,t)=>t?t.has(e.id):!!e.isSaved||void 0,pdt=e=>{let t=e.label,n=e.hasViewAll,l=void 0!==n&&n,r=e.onViewAll;return a.createElement("div",{"data-external-id":"today-feed-section-header",className:"flex items-center gap-sm"},a.createElement(fe.c8D,{size:"sm",weight:"medium",color:"secondary",render:a.createElement("h2",null),className:"m-0"},t),a.createElement(fe.AVK,{color:"secondary",className:"flex-1"}),l&&a.createElement(fe.XZZ,{size:"xs",variant:"text",endIcon:a.createElement(fe.Fug,null),className:"text-content-link",onClick:r},Re.VIEW_ALL))},gdt=()=>a.createElement("div",{"data-external-id":"today-feed-skeleton",className:"flex flex-col gap-sm","data-testid":"today-feed-skeleton"},a.createElement(fe.wME,{className:"h-5 w-40"}),Array.from({length:3},((e,t)=>a.createElement(fe.wME,{key:t,className:"h-30 w-full rounded-default"})))),hdt=e=>{let t=e.assistantName,n=e.assistantColor;const l=(e=>{const t=Fe.length;return Fe[(e%t+t)%t]})(N.c9.now().toUTC().ordinal);return a.createElement("div",{"data-external-id":"today-haiku-footer",className:"flex flex-col items-center gap-default"},a.createElement("div",{className:"flex flex-col items-center gap-sm"},a.createElement(fe.c8D,{size:"sm",weight:"medium",color:"secondary"},Re.HAIKU_DIVIDER),a.createElement(fe.c8D,{size:"xl",color:"secondary",render:a.createElement("p",null),className:"m-0 text-center font-secondary leading-[1.4] tracking-[-0.03em] text-balance"},l.map(((e,t)=>a.createElement(a.Fragment,{key:e},t>0&&a.createElement("br",null),e))))),a.createElement(he,{color:n,label:t,size:48}))},vdt=500,fdt=60,Edt=110,ydt=620,bdt=3e3,xdt=e=>{const t=[];let n=fdt;return e.forEach(((e,a)=>{a>0&&(n+=ydt),t.push(Array.from({length:e},((e,t)=>Math.min(n+t*Edt,bdt)))),n=Math.min(n+Math.max(0,e-1)*Edt,bdt)})),t},wdt="today-feed-reveal-played",Cdt=()=>{if("undefined"===typeof sessionStorage)return!1;try{return"1"===sessionStorage.getItem(wdt)}catch(e){return!1}},Adt=e=>({"--today-feed-reveal-duration":"".concat(vdt,"ms"),"--today-feed-reveal-delay":"".concat(e,"ms")}),Idt=function(e){return!(arguments.length>1&&void 0!==arguments[1])||arguments[1]?{"data-today-feed-reveal":!0,style:Adt(e)}:{}},kdt=e=>{let t=e.insights,n=e.persistedDismissedInsights,a=e.persistedUnhelpfulInsights,l=void 0===a?[]:a,r=e.sessionCompletedInsights,o=e.sessionDismissedInsights,i=e.sessionUnhelpfulInsights,s=void 0===i?[]:i,c=e.savedInsightIds,d=e.unsavedInsightIds,u=e.restoredInsightIds,m=e.feedbackByInsightId,p=void 0===m?{}:m;const g=[...new Map([...n,...o,...l,...s,...t].map((e=>[e.id,e]))).values()],h=((e,t,n)=>{const a=new Set(t);for(const l of e)l.isSaved&&!n.has(l.id)&&a.add(l.id);return a})(g,c,d),v=new Map(t.filter((e=>"completed"===e.status)).map((e=>[e.id,e])));for(const b of r)v.set(b.id,b);const f=[...new Map([...n,...o].map((e=>[e.id,e]))).values()].filter((e=>!u.has(e.id)&&!v.has(e.id))),E=new Set(f.map((e=>e.id))),y=[...new Map([...l,...s].map((e=>[e.id,e]))).values()].filter((e=>{const t=p[e.id];return"down"===t||"up"!==t&&null!==t&&!u.has(e.id)}
1));return{knownInsights:g,savedInsightIds:h,saved:g.filter((e=>h.has(e.id)&&("active"===e.status||u.has(e.id))&&!v.has(e.id)&&!E.has(e.id))),completed:[...v.values()],dismissed:f,unhelpful:y}},Sdt=(e,t)=>{const n=new Map;for(const a of[...e,...t])n.has(a.id)||n.set(a.id,a);return[...n.values()]},Ndt=new Set,Tdt=[],_dt=e=>{var t,n,l,r,i,s,c;let d=e.assistantName,u=e.assistantColor,m=e.sections,p=e.everythingElse,g=e.backgroundRows,h=void 0===g?[]:g,v=e.isLoading,f=e.hasError,E=e.focusedOverviewId,y=void 0===E?null:E,b=e.dismissingInsightIds,x=e.completedStubInsightId,w=void 0===x?null:x,C=e.savedInsightIds,A=e.savedInsights,I=void 0===A?[]:A,k=e.completedInsights,S=void 0===k?[]:k,N=e.dismissedInsights,T=void 0===N?[]:N,_=e.unhelpfulInsights,D=void 0===_?[]:_,R=e.animateReveal,M=void 0===R||R,L=e.onRevealFinished,O=e.onDismiss,P=e.onRestore,B=e.onDismissAnimationEnd,z=e.onComplete,F=e.onUndoComplete,G=e.onSave,Y=e.onSubmitDenialNote,V=e.onDismissNoteToast,W=e.onPrimaryAction,j=e.onOpenConversation;const H=y&&rdt(y)?y:null,K=(0,a.useMemo)((()=>Pdt(m,H)),[H,m]),q=(0,a.useMemo)((()=>Ms(m,"recommendations")),[m]),$=(0,a.useMemo)((()=>Ms(m,"updates")),[m]),Z=(0,a.useMemo)((()=>Ps($,q)),[q,$]),J=null!==p&&void 0!==p?p:Z,X=(0,a.useMemo)((()=>{var e,t;return"saved"===y?I:"completed"===y?S:"archived"===y?Sdt(T,D):"everything_else"===y?J:H&&null!==(e=null===(t=Pdt(m,H)[0])||void 0===t?void 0:t.insights)&&void 0!==e?e:[]}),[S,T,J,H,y,I,m,D]),Q=K.find((e=>"needs_attention"===e.id)),ee=h.length>0,te=null!==(t=null===Q||void 0===Q?void 0:Q.insights)&&void 0!==t?t:Tdt,ne=!y&&J.length>0,ae=Bs(K,ee),le=(e=>{const t=Ms(e,"needs_attention").length>0,n=Ms(e,"recommendations").length>0||Ms(e,"updates").length>0;return t&&n})(K),re=[te.length>0?1+te.length:0,ne?1+J.length:0,ee?2:0,1].filter((e=>e>0)),oe=(0,a.useRef)(0);oe.current=(e=>{var t;return(null!==(t=xdt(e).flat().at(-1))&&void 0!==t?t:0)+vdt})(re);const ie=(0,a.useState)(null),se=(0,o.A)(ie,2),ce=se[0],de=se[1],ue=((e,t,n)=>{const l=(0,a.useState)([]),r=(0,o.A)(l,2),i=r[0],s=r[1],c=(0,a.useCallback)((function(e,t,n){let a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"pending";s((l=>l.some((t=>t.insight.id===e.id))?l:[...l,{insight:e,listId:t,anchorId:n,phase:"bar",note:"",status:a}]))}),[]),d=(0,a.useCallback)((e=>{s((t=>t.filter((t=>t.insight.id!==e||"pending"!==t.status))))}),[]),u=(0,a.useCallback)((e=>{s((t=>t.map((t=>t.insight.id===e&&"pending"===t.status?(0,U.A)((0,U.A)({},t),{},{status:"open"}):t))))}),[]),m=(0,a.useCallback)((e=>{s((t=>t.filter((t=>t.insight.id!==e))))}),[]),p=(0,a.useCallback)((e=>{s((t=>t.map((t=>t.insight.id===e?(0,U.A)((0,U.A)({},t),{},{phase:"form"}):t))))}),[]),g=(0,a.useCallback)((e=>{s((t=>t.map((t=>t.insight.id===e?(0,U.A)((0,U.A)({},t),{},{phase:"bar"}):t))))}),[]),h=(0,a.useCallback)(((e,t)=>{s((n=>n.map((n=>n.insight.id===e?(0,U.A)((0,U.A)({},n),{},{note:t}):n))))}),[]);return(0,a.useEffect)((()=>{s((n=>{const a=n.filter((n=>"open"!==n.status||!!t.has(n.insight.id)||!e.has(n.insight.id)));return a.length===n.length?n:a}))}),[t,e]),(0,a.useEffect)((()=>{s((e=>0===e.length?e:[]))}),[n]),{asks:i,prime:c,cancelPrime:d,commit:u,retire:m,openForm:p,closeForm:g,setNote:h}})((0,a.useMemo)((()=>{const e=y?X:[...te,...J];return new Set(e.map((e=>e.id)))}),[J,X,y,te]),null!==b&&void 0!==b?b:Ndt,y),me=ue.asks,pe=ue.prime,ge=ue.retire,he=ue.openForm,ve=ue.setNote;if((0,a.useEffect)((()=>{if(!M||!L||v||f||y)return;const e=window.setTimeout(L,oe.current);return()=>window.clearTimeout(e)}),[M,y,f,v,L]),v)return a.createElement(gdt,{"data-external-id":"today-feed"});if(f)return a.createElement(Hct,{"data-external-id":"today-feed"});const fe={asks:me,submittingAskId:ce,onOpenAskForm:he,onRetireAsk:ge,onChangeAskNote:ve,onSubmitAsk:e=>{const t=me.find((t=>t.insight.id===e)),n=null===t||void 0===t?void 0:t.note.trim();t&&n&&Y&&(de(e),Y(t.insight,n).then((n=>{de((t=>t===e?null:t)),n&&(ge(e),null===V||void 0===V||V((()=>null===P||void 0===P?void 0:P((0,U.A)((0,U.A)({},t.insight),{},{status:"dismissed"}),"note_toast"))))})))}},Ee=(0,U.A)((0,U.A)({},fe),{},{dismissingInsightIds:b,completedStubInsightId:w,savedInsightIds:C,onDismissInsight:(e,t,n
1)=>{var a,l;const r=n.findIndex((t=>t.id===e.id));pe(e,t,null!==(a=null===(l=n[r+1])||void 0===l?void 0:l.id)&&void 0!==a?a:null,"open"),Promise.resolve(null===O||void 0===O?void 0:O(e)).then((t=>{!1===t&&ge(e.id)}))},onRestore:P,onDismissAnimationEnd:B,onComplete:z,onUndoComplete:F,onSave:G,onPrimaryAction:W,onOpenConversation:j}),ye=xdt(re),be=te.length>0&&null!==(n=ye[0])&&void 0!==n?n:[],xe=ne&&null!==(l=ye[te.length>0?1:0])&&void 0!==l?l:[],we=(te.length>0?1:0)+(ne?1:0),Ce=ee&&null!==(r=ye[we])&&void 0!==r?r:[],Ae=null!==(i=ye[ye.length-1])&&void 0!==i?i:[],Ie=(e,t)=>t>0||me.some((t=>t.listId===e&&"open"===t.status));return a.createElement("div",{"data-external-id":"today-feed",className:"flex flex-col"},y?a.createElement(sdt,{overviewId:y,itemCount:"in_the_background"===y?h.length:X.length,backgroundRows:h},"in_the_background"===y?null:a.createElement(Ldt,Object.assign({insights:H||"completed"===y?X:X.filter((e=>e.id!==w)),listId:"focused",showCompleteStub:Boolean(H),forceRestore:"archived"===y},Ee,{onComplete:"completed"===y?void 0:z}))):a.createElement(a.Fragment,null,a.createElement("div",{className:"flex flex-col gap-xl"},Ie("needs_attention",te.length)?a.createElement(Ddt,{label:null!==(s=null===Q||void 0===Q?void 0:Q.label)&&void 0!==s?s:Re.NEEDS_ATTENTION,insights:te,delays:be,animateReveal:M,showHeader:ae,cardHandlers:(0,U.A)((0,U.A)({},Ee),{},{listId:"needs_attention"})}):null,Ie("everything_else",J.length)?a.createElement(Rdt,{insights:J,delays:xe,animateReveal:M,showHeader:le,cardHandlers:(0,U.A)((0,U.A)({},Ee),{},{listId:"everything_else"})}):null,ee?a.createElement(Mdt,{label:Re.IN_THE_BACKGROUND,rows:h,delays:Ce,animateReveal:M,showHeader:ae}):null),a.createElement("div",Object.assign({className:"mt-4xl"},Idt(null!==(c=Ae[0])&&void 0!==c?c:0,M)),a.createElement(hdt,{assistantName:d,assistantColor:u}))))},Ddt=e=>{var t;let n=e.label,l=e.insights,r=e.delays,o=e.animateReveal,i=e.showHeader,s=e.cardHandlers;return a.createElement("section",{"data-external-id":"needs-attention-section",className:"flex flex-col gap-sm"},i?a.createElement("div",Idt(null!==(t=r[0])&&void 0!==t?t:0,o),a.createElement(pdt,{label:n})):null,a.createElement(Ldt,Object.assign({insights:l,delays:r.slice(1),animateReveal:o,showCompleteStub:!0},s)))},Rdt=e=>{var t;let n=e.insights,l=e.delays,r=e.animateReveal,o=e.showHeader,i=e.cardHandlers;return a.createElement("section",{"data-external-id":"everything-else-section",className:"flex flex-col gap-sm"},o?a.createElement("div",Idt(null!==(t=l[0])&&void 0!==t?t:0,r),a.createElement(pdt,{label:Re.EVERYTHING_ELSE})):null,a.createElement(Ldt,Object.assign({insights:n,delays:l.slice(1),animateReveal:r,showCompleteStub:!0},i)))},Mdt=e=>{var t,n,l;let r=e.label,o=e.rows,i=e.delays,s=e.animateReveal,c=e.showHeader;return a.createElement("section",{"data-external-id":"background-feed-section",className:"flex flex-col gap-sm"},c?a.createElement("div",Idt(null!==(t=i[0])&&void 0!==t?t:0,s),a.createElement(pdt,{label:r})):null,a.createElement("div",Idt(null!==(n=null!==(l=i[1])&&void 0!==l?l:i[0])&&void 0!==n?n:0,s),a.createElement(edt,{rows:o})))},Ldt=e=>{let t=e.insights,n=e.delays,l=void 0===n?[]:n,r=e.animateReveal,o=void 0===r||r,i=e.listId,s=e.asks,c=e.submittingAskId,d=e.dismissingInsightIds,u=e.completedStubInsightId,m=e.savedInsightIds,p=e.forceRestore,g=void 0!==p&&p,h=e.showCompleteStub,v=void 0!==h&&h,f=e.onDismissInsight,E=e.onOpenAskForm,y=e.onRetireAsk,b=e.onChangeAskNote,x=e.onSubmitAsk,w=e.onRestore,C=e.onDismissAnimationEnd,A=e.onComplete,I=e.onUndoComplete,k=e.onSave,S=e.onPrimaryAction,N=e.onOpenConversation;return a.createElement("div",{"data-external-id":"insight-card-list",className:"flex flex-col gap-sm"},((e,t)=>{const n=new Set(e.map((e=>e.id))),a=t.filter((e=>"open"===e.status)),l=e.map((e=>{const t=a.find((t=>t.insight.id===e.id));return t?{type:"morph",insight:e,ask:t}:{type:"insight",insight:e}})),r=a.filter((e=>!n.has(e.insight.id))),o=new Set;let i=r.length;for(;i>0;){let e=!1;for(const t of r){if(o.has(t.insight.id))continue;const a=t.anchorId;if(null!==a&&!n.has(a)&&!o.has(a))continue;const r=null===a?-1:l.findIndex((e=>Kct(e)===a));l.splice(-1===r?l.length:r,0,{type:"ask",ask:t}),o.add(t.insight.id),e=!0}if(!e)break;i-=1}for(const s of r)o.has(s.insight.id)||l.push({type:"ask",ask:s});return l})(t,s.filter((e=>e.listId===i))).map(((e,n)=>{const r="ask"===e.type?e.ask.insight.id:e.insight.id,s=Odt(e,{showCompleteStub:v,completedStubInsightId:u,submittingAskId:c,dismissingInsightIds:d,savedInsightIds:m,forceRestore:g,listId:i,insights:t,onOpenAskForm:E,onRetireAsk:y,onChangeAskNote:b,onSubmitAsk:x,onDismissInsight:f,onRestore:w,onDismissAnimationEnd:C,onComplete:A,onUndoComplete:I,onSave:k,onPrimaryAction:S,onOpenConversation:N}),p=l[n];return void 0===p?s:a.createElement("div",Object.assign({key:r},Idt(p,o)),s)})))},Odt=(e,t)=>
1{var n,l;if("ask"===e.type||"morph"===e.type){const n="morph"===e.type?e.insight:e.ask.insight;return a.createElement(Jct,{key:n.id,active:"morph"===e.type,onSettled:()=>{var e;return null===(e=t.onDismissAnimationEnd)||void 0===e?void 0:e.call(t,n.id)},card:"morph"===e.type?a.createElement(nc,{insight:e.insight,isSaved:mdt(e.insight,t.savedInsightIds),forceRestore:t.forceRestore,onDismiss:()=>{},onComplete:t.onComplete,onUndoComplete:t.onUndoComplete,onSave:t.onSave,onPrimaryAction:t.onPrimaryAction,onOpenConversation:t.onOpenConversation}):null,bar:a.createElement(qct,{ask:e.ask,isSubmitting:t.submittingAskId===e.ask.insight.id,onOpenForm:t.onOpenAskForm,onRetire:t.onRetireAsk,onChangeNote:t.onChangeAskNote,onSubmit:t.onSubmitAsk,deferTimer:"morph"===e.type})})}return t.showCompleteStub&&e.insight.id===t.completedStubInsightId?a.createElement(Xct,{key:e.insight.id,onUndo:()=>{var e;return null===(e=t.onUndoComplete)||void 0===e?void 0:e.call(t)}}):a.createElement(udt,{key:e.insight.id,insight:e.insight,isDismissing:null!==(n=null===(l=t.dismissingInsightIds)||void 0===l?void 0:l.has(e.insight.id))&&void 0!==n&&n,isSaved:mdt(e.insight,t.savedInsightIds),forceRestore:t.forceRestore,onDismiss:t.onDismissInsight?e=>{var n;return null===(n=t.onDismissInsight)||void 0===n?void 0:n.call(t,e,t.listId,t.insights)}:void 0,onRestore:t.onRestore,onDismissAnimationEnd:t.onDismissAnimationEnd,onComplete:t.onComplete,onUndoComplete:t.onUndoComplete,onSave:t.onSave,onPrimaryAction:t.onPrimaryAction,onOpenConversation:t.onOpenConversation})},Pdt=(e,t)=>{if(!t)return e;const n=e.find((e=>e.id===t));if(n)return[n];const a=As.find((e=>e.id===t));return a?[{id:a.id,label:a.label,insights:[]}]:[]},Bdt=e=>{let t=e.prompts,n=e.disabled,l=void 0!==n&&n,r=e.onSelect;const i=(0,a.useRef)(null),s=(0,a.useState)(!1),c=(0,o.A)(s,2),d=c[0],u=c[1],m=(0,a.useState)(!1),p=(0,o.A)(m,2),g=p[0],h=p[1],v=(0,a.useCallback)((()=>{const e=i.current;e&&(u(zdt(e)),h(Fdt(e)))}),[]);(0,a.useLayoutEffect)((()=>{const e=i.current;if(!e)return;v();const t=new ResizeObserver(v);return t.observe(e),()=>t.disconnect()}),[t,v]);const f=e=>{const t=i.current;t&&t.scrollBy({left:e*t.clientWidth*.75,behavior:"smooth"})};return a.createElement("div",{"data-external-id":"today-greeting-prompt-row",className:"relative"},a.createElement("div",{ref:i,onScroll:v,className:" -m-xs flex flex-nowrap gap-xs overflow-x-auto p-xs [scrollbar-width:none] [&::-webkit-scrollbar]:hidden "},t.map(((e,t)=>a.createElement(fe.XZZ,{key:e,size:"sm",rounded:"pill",disabled:l,onClick:()=>r(e,t),className:"shrink-0 font-book text-content-secondary shadow-card"},e)))),g?a.createElement(a.Fragment,null,a.createElement("div",{"aria-hidden":!0,className:" pointer-events-none absolute -inset-y-xs -left-xs w-24 bg-linear-to-l from-transparent to-background-page to-46% "}),a.createElement(fe.SO$,{variant:"outline",size:"3xs","aria-label":Re.PREVIOUS_SUGGESTIONS,onClick:()=>f(-1),className:"absolute top-1/2 left-0 -translate-y-1/2 border-transparent"},a.createElement(fe.qzE,{size:"md"}))):null,d?a.createElement(a.Fragment,null,a.createElement("div",{"aria-hidden":!0,className:" pointer-events-none absolute -inset-y-xs -right-xs w-24 bg-linear-to-r from-transparent to-background-page to-46% "}),a.createElement(fe.SO$,{variant:"outline",size:"3xs","aria-label":Re.MORE_SUGGESTIONS,onClick:()=>f(1),className:"absolute top-1/2 right-0 -translate-y-1/2 border-transparent"},a.createElement(fe.Fug,{size:"md"}))):null)},zdt=e=>e.scrollLeft+e.clientWidth<e.scrollWidth-1,Fdt=e=>e.scrollLeft>1,Gdt=["w-45","w-36","w-52","w-40","w-48"],Ydt=()=>a.createElement("div",{"data-external-id":"today-greeting-prompt-row-skeleton",className:"flex flex-nowrap gap-xs overflow-hidden","aria-busy":"true","data-testid":"today-greeting-prompt-row-skeleton"},Array.from({length:5},((e,t)=>a.createElement(fe.wME,{key:t,className:(0,q.cn)("h-9 shrink-0 rounded-pill",Gdt[t%Gdt.length])})))),Udt=e=>{let t=e.assistantDraft,n=e.onStartConversation,l=e.isPreOnboarding,r=void 0!==l&&l,i=e.completedAgentOnboardingAt,s=void 0===i?null:i;const c=(0,d.d4)(A.Nc),u=(0,d.d4)(ft.GC),m=Pt(new Date),p=(0,a.useState)(""),g=(0,o.A)(p,2),h=g[0],v=g[1],f=(0,F.K)(),E=(()=>{const e=(0,et.I)(Qe.q2,{variables:{limit:5}}),t=e.data,n=e.isLoadingInitialData;return{pills:(0,a.useMemo)((()=>{var e;const n=(null!==(e=null===t||void 0===t?void 0:t.assistantPromptPills)&&void 0!==e?e:[]).map((e=>e.text));return n.length>0?n:Re.FALLBACK_PROMPTS}),[null===t||void 0===t?void 0:t.assistantPromptPills]),isLoadingInitialData:n}})(),y=E.pills,b=E.isLoadingInitialData,x=t.displayName.trim()||ge.Uk,w=(0,a.useRef)(!1);(0,a.useEffect)((()=>{w.current||(w.current=!0,(0,Ge.u4)(Ye.xb.AssistantPromptShown,(0,U.A)((0,U.A)({},{prompt_type:dc}),{},{source:null!==u&&void 0!==u?u:void 0})))}),[u]);const C=(e,t)=>{const a=e.trim();a&&!f&&(n(a,t),v(""))};return a.createElement("div",{"data-external-id":"today-greeting",className:"flex flex-col items-center pt-sm"},a.createElement(he,{color:t.color,label:x,size:60}),a.createElement("div",{className:"mt-md flex w-full flex-col items-center gap-lg"},a.createElement("div",{className:"flex w-full flex-col items-center gap-xs text-center"},a.createElement("h1",{className:" m-0 font-secondary text-2xl/[1.12] font-book tracking-[-0.02em] text-content-primary "},c?"".concat(m,", ").concat(c):m),a.createElement(fe.c8D,{color:"secondary",render:a.createElement("p",null),className:"m-0 leading-[1.6]"},Oe({assistantName:x,isPreOnboarding:r,completedAgentOnboardingAt:s}))),a.createElement("div",{className:"flex w-full flex-col gap-sm"},a.createElement(Uu,{value:h,placeholder:Re.ASK_ANYTHING_PLACEHOLDER,disabled:f,onChange:v,onSubmit:()=>C(h,"generic")}),b?a.createElement(Ydt,null):a.createElement(Bdt,{prompts:y,disabled:f,onSelect:(e,t)=>
1{f||((0,Ge.u4)(Ye.xb.AssistantPromptSelected,(0,U.A)((0,U.A)({},(e=>({prompt_position:e,prompt_type:dc}))(t)),{},{source:null!==u&&void 0!==u?u:void 0})),C(e,"smart"))}}))))},Vdt="transform .72s cubic-bezier(.22,1.12,.4,1), opacity .55s ease",Wdt={p0:{transform:"translate(-50%, 0px) rotate(0.6deg)",opacity:1,zIndex:2,transition:Vdt},p1:{transform:"translate(-50%, 36px) rotate(-0.6deg)",opacity:1,zIndex:3,transition:Vdt},p2:{transform:"translate(-50%, 72px) rotate(0.6deg)",opacity:1,zIndex:4,transition:Vdt},p3:{transform:"translate(-50%, 108px) rotate(-0.6deg)",opacity:1,zIndex:5,transition:Vdt},out:{transform:"translate(calc(-50% + 400px), -24px) rotate(15deg)",opacity:0,zIndex:1,transition:"transform .5s cubic-bezier(.5,0,.9,.35), opacity .38s ease"},wait:{transform:"translate(calc(-50% - 320px), 108px) rotate(-0.6deg)",opacity:0,zIndex:0,transition:"none"}},jdt=e=>{let t=e.onGetStarted;const n=ud(),l=(e=>{const t=(0,a.useState)(0),n=(0,o.A)(t,2),l=n[0],r=n[1];(0,a.useEffect)((()=>{if(e)return;const t=setInterval((()=>{r((e=>(e+1)%Me.length))}),2600);return()=>clearInterval(t)}),[e]);const i=e?0:l;return Me.map(((e,t)=>(0,U.A)((0,U.A)({},e),{},{position:Le(t,i)})))})(n);return a.createElement("div",{"data-external-id":"today-pre-onboarding",className:"flex w-full flex-col items-center"},a.createElement(fe.xz6,{className:"w-full items-center rounded-lg border border-divider-secondary p-2xl text-center"},a.createElement("div",{"aria-hidden":!0,className:"relative mb-default h-38.25 w-full"},l.map((e=>{const t=Wdt[e.position];return a.createElement("div",{key:e.title,className:" pointer-events-none absolute top-0 left-1/2 flex h-10.5 items-center gap-3 rounded-sm border border-divider-secondary bg-background-primary px-2.25 whitespace-nowrap shadow-sm ",style:(0,U.A)((0,U.A)({},t),{},{transition:n?"none":t.transition})},a.createElement(fe.CWN,{color:e.tile,size:"md",icon:a.createElement(fe.jeH,{name:e.icon})}),a.createElement("span",{className:"text-xs font-medium text-content-primary"},e.title),a.createElement("span",{className:"ml-2.5 text-xs font-medium text-content-success"},e.figure))}))),a.createElement("h2",{className:" m-0 font-secondary text-xl font-book tracking-[-0.03em] text-balance text-content-primary "},Re.PRE_ONBOARDING_TITLE),a.createElement(fe.c8D,{size:"sm",color:"secondary",className:"mt-2xs max-w-[42ch] text-pretty"},Re.PRE_ONBOARDING_BODY),a.createElement(fe.XZZ,{variant:"primary",size:"sm",className:"mt-default",onClick:t},Re.PRE_ONBOARDING_CTA)),a.createElement(fe.c8D,{size:"xs",color:"secondary",className:"mt-default max-w-[62ch] text-center text-pretty"},Re.PRE_ONBOARDING_LLM_NOTE))},Hdt=["assistantDraft","assistantName","isPreOnboarding","completedAgentOnboardingAt","focusedOverviewId","playFeedReveal","onRevealFinished","onStartConversation","onGetStarted","onOpenConversation"],Kdt=e=>{let t=e.assistantDraft,n=e.assistantName,l=e.isPreOnboarding,r=e.completedAgentOnboardingAt,o=e.focusedOverviewId,i=e.playFeedReveal,s=e.onRevealFinished,c=e.onStartConversation,d=e.onGetStarted,u=e.onOpenConversation,m=(0,En.A)(e,Hdt);return a.createElement("div",{"data-external-id":"today-feed-column",className:"min-h-0 min-w-0 flex-1 px-xl"},a.createElement("div",{className:"mx-auto flex w-full max-w-150 flex-col gap-2xl pb-2xl"},!o&&a.createElement("div",Idt(fdt,i),a.createElement(Udt,{assistantDraft:t,isPreOnboarding:l,completedAgentOnboardingAt:r,onStartConversation:c})),l?a.createElement(jdt,{onGetStarted:d}):a.createElement(_dt,Object.assign({},m,{assistantName:n,assistantColor:t.color,focusedOverviewId:o,animateReveal:i,onRevealFinished:s,onOpenConversation:u}))))},qdt=e=>{let t=e.onSubmit;const n=(()=>{const e=(0,tV.j)(),t=(0,o.A)(e,1)[0];return(0,a.useCallback)((async e=>(await t({formName:"assistant_beta",formVersion:"v1",answers:{feedback:e}})).success),[t])})(),l=(0,C.RU)(),r=(0,a.useState)(!1),i=(0,o.A)(r,2),s=i[0],c=i[1],d=(0,a.useState)(""),u=(0,o.A)(d,2),m=u[0],p=u[1],g=(0,a.useState)(!1),h=(0,o.A)(g,2),v=h[0],f=h[1],E=(0,a.useRef)(0),y=m.trim(),b=e=>{c(e),e||(E.current+=1,p(""),f(!1))};return a.createElement(fe.hg1.Root,{"data-external-id":"today-beta-feedback-button",open:s,onOpenChange:b,size:"xl"},a.createElement(fe.hg1.Trigger,{render:a.createElement(fe.XZZ,{variant:"subtle",colorScheme:"primary",size:"sm",icon:a.createElement(fe.ghC,{size:"xs"})},Re.BETA_FEEDBACK)}),a.createElement(fe.hg1.Content,null,a.createElement(fe.hg1.CloseTrigger,null),a.createElement(fe.hg1.Header,null,a.createElement(fe.hg1.Title,null,Re.BETA_FEEDBACK_TITLE)),a.createElement(fe.hg1.Body,{className:"flex flex-col gap-lg"},a.createElement(fe.c8D,null,Re.BETA_FEEDBACK_BODY),a.createElement(fe.RVf.Root,null,a.createElement(fe.RVf.Label,null,Re.BETA_FEEDBACK_QUESTION),a.createElement(fe.LYY,{minRows:3,maxRows:8,value:m,onChange:e=>p(e.target.value)}))),a.createElement(fe.hg1.Footer,{className:"gap-sm"},a.createElement(fe.hg1.Close,{render:a.createElement(fe.XZZ,null,Re.BETA_FEEDBACK_CANCEL)}),a.createElement(fe.XZZ,{variant:"primary",disabled:!y,isLoading:v,onClick:async()=>
1{if(!y||v)return;const e=E.current;f(!0);let a=!1;try{a=await(null!==t&&void 0!==t?t:n)(y)}catch(r){a=!1}e===E.current&&(f(!1),a?(b(!1),(0,C.W7)({message:Re.BETA_FEEDBACK_SENT_TOAST,duration:pc})):l({description:Re.BETA_FEEDBACK_ERROR}))}},Re.BETA_FEEDBACK_SUBMIT))))},$dt=e=>{let t=e.isRailOpen,n=void 0===t||t,l=e.onToggleRail,r=e.railShortcut,o=e.focusedSectionLabel,i=e.currentCrumb,s=e.onClearFocusedSection,c=e.showActions,d=void 0===c||c,u=e.onOpenSettings,m=e.onNewChat,p=e.className;return a.createElement(uS.Y9,{"data-external-id":"today-header",className:p,controls:d?a.createElement(uU.f,null,a.createElement(qdt,null),m?a.createElement(fe.XZZ,{size:"sm",icon:a.createElement(fe.Ypw,null),onClick:m},Re.NEW_CHAT):null,u?a.createElement(fe.XZZ,{size:"sm",icon:a.createElement(fe.z79,null),onClick:u},Re.SETTINGS):null,l?a.createElement(a.Fragment,null,a.createElement(fe.AVK,{orientation:"vertical",color:"secondary",className:"mx-3xs h-5.5"}),a.createElement(fe.Yvj,{content:a.createElement("div",{className:"flex items-center gap-xs"},a.createElement(fe.c8D,{size:"xs",weight:"medium",color:"primary"},n?Re.RAIL_COLLAPSE:Re.RAIL_EXPAND),r?a.createElement(fe.acH,{variant:"outline",keys:r}):null),description:n?Re.RAIL_COLLAPSE:Re.RAIL_EXPAND},a.createElement(fe.ENt,{"aria-label":n?Re.RAIL_COLLAPSE:Re.RAIL_EXPAND,pressed:n,onPressedCh
1ange:l,size:"sm"},a.createElement(fe.OfV,null)))):null):void 0},i||o?a.createElement(fe.LdR,{size:"lg",className:"[&>ol]:flex-nowrap"},a.createElement(fe.LdR.Item,{render:a.createElement("button",{type:"button",className:"appearance-none border-0 bg-transparent p-0",onClick:s})},Re.PAGE_TITLE),a.createElement(fe.LdR.Separator,null),a.createElement(fe.LdR.Item,{current:!0,className:(0,q.cn)("max-w-80",i&&"[&>span]:flex [&>span]:min-w-0 [&>span]:items-center")},null!==i&&void 0!==i?i:o)):a.createElement(fe.c8D,{size:"lg",weight:"medium"},Re.PAGE_TITLE))},Zdt=function(e){let t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return{name:Ye.M9,parentRoute:null,overrideHtmlTitle:Re.PAGE_TITLE,pageProperties:e,pageTrackingReady:t}},Jdt=e=>{let t=e.tracking,n=void 0===t?Zdt():t,l=e.children;return a.createElement(rG.Y,Object.assign({"data-external-id":"today-gate-page"},n,{header:a.createElement($dt,{showActions:!1}),shouldScroll:!1}),l?a.createElement("div",{className:"min-h-0 flex-1 overflow-y-auto px-xl pb-2xl"},l):null)},Xdt=e=>{var t;let n=e.activeThreadId,l=e.onSelectThread,r=e.onDeleted,i=e.RailCard,s=e.fill,c=void 0!==s&&s;const d=(0,a.useState)(!1),u=(0,o.A)(d,2),m=u[0],p=u[1],g=(0,et.I)(Qe.ps),h=g.data,v=g.isLoadingInitialData,f=g.error,E=null!==(t=null===h||void 0===h?void 0:h.messageThreads)&&void 0!==t?t:Tct,y=(0,a.useMemo)((()=>Dct(E,n,c?12:5)),[n,c,E]),b=(0,a.useMemo)((()=>xd(y)),[y]);let x;if(v)x=a.createElement("div",{className:"flex justify-center py-sm"},a.createElement(fe.ix7,{size:"sm"}));else if(f)x=a.createElement(SQ.W,{message:VG.U.DEFAULT});else{if(0===E.length)return null;x=a.createElement("div",{className:"-mx-sm flex flex-col gap-lg"},b.map((e=>{let t=e.category,r=e.threads;return a.createElement("div",{key:t,className:"flex flex-col"},a.createElement(fe.c8D,{size:"sm",weight:"medium",color:"secondary",className:"px-sm py-2xs"},t),r.map((e=>a.createElement(fe.Qey.Root,{key:e.id,className:"rounded-default px-sm py-xs hover:bg-background-secondary",onClick:()=>{return t=e.id,a=_ct(e.subject),t!==n&&(0,Ge.u4)(Ye.xb.AssistantChatRevisited,{thread_id:t}),void l(t,a);var t,a}},a.createElement(fe.Qey.Content,null,a.createElement(fe.Qey.Title,{className:"line-clamp-1"},_ct(e.subject)))))))})))}return a.createElement(a.Fragment,null,a.createElement(i,{storageKey:"history",title:Re.RAIL_RECENT_CHATS_TITLE,fill:c},a.createElement("div",{className:"flex flex-col gap-default"},x,a.createElement(fe.XZZ,{variant:"default",size:"sm",rounded:"pill",className:"w-full",onClick:()=>p(!0)},Re.VIEW_ALL))),a.createElement(Mct,{open:m,onOpenChange:p,activeThreadId:n,onSelectThread:l,onDeleted:r}))},Qdt="monarch.today.rail.",eut="flex w-full items-center justify-start gap-sm rounded-sm px-xs py-2xs text-left",tut=e=>{let t=e.completedCount,n=e.savedCount,l=void 0===n?0:n,r=e.archivedCount,o=void 0===r?0:r,i=e.foundForYou,s=void 0===i?0:i,c=e.savedToDate,d=void 0===c?0:c,u=e.selectedOverviewId,m=void 0===u?null:u,p=e.showOverview,g=void 0===p||p,h=e.onSelectOverview,v=e.activeThreadId,f=void 0===v?null:v,E=e.onSelectRecentThread,y=e.onDeletedThread;const b={saved:l,completed:t,archived:o};return a.createElement("div",{"data-external-id":"today-rail",className:" sticky top-0 flex max-h-[calc(100dvh-var(--app-header-height))] w-88 shrink-0 flex-col gap-default overflow-y-auto overscroll-contain px-lg py-xl [scrollbar-width:none] [&::-webkit-scrollbar]:hidden "},g&&a.createElement(nut,{storageKey:"overview",title:Re.RAIL_OVERVIEW_TITLE},a.createElement("div",{className:"flex flex-col gap-default"},a.createElement("div",{className:"flex flex-col rounded-sm bg-background-primary-inset px-default py-md"},a.createElement("div",{className:"flex items-baseline justify-around gap-xl"},a.createElement("div",{className:"flex flex-col gap-3xs"},a.createElement(fe.c8D,{size:"20",weight:"medium",color:"success"},(0,rl.T3)(d)),a.createElement(fe.c8D,{size:"xs",color:"secondary"},Re.RAIL_OVERVIEW_SAVED)),a.createElement("div",{className:"flex flex-col gap-3xs"},a.createElement(fe.c8D,{size:"20",weight:"medium"},(0,rl.T3)(s)),a.createElement(fe.c8D,{size:"xs",color:"secondary"},Re.RAIL_OVERVIEW_FOUND)))),a.createElement("div",{className:"-mx-xs flex flex-col gap-3xs"},Re.RAIL_ACTIVITY_ROWS.map((e=>a.createElement(aut,{key:e.id,label:e.label,icon:e.icon,tileColor:e.tileColor,value:b[e.id],isSelected:m===e.id,onClick:()=>null===h||void 0===h?void 0:h(e.id)}
1)))))),a.createElement(Xdt,{fill:!g,RailCard:nut,activeThreadId:f,onSelectThread:E,onDeleted:y}))},nut=e=>{let t=e.storageKey,n=e.title,l=e.children,r=e.fill,i=void 0!==r&&r;const s=lut(t),c=(0,o.A)(s,2),d=c[0],u=c[1],m=d&&!i;return a.createElement(fe.xz6,{"data-external-id":"collapsible-rail-card",className:"overflow-visible"},a.createElement(fe.xz6.Header,{className:(0,q.cn)(m&&"rounded-b-default border-b-0")},a.createElement(fe.xz6.Title,null,n),!i&&a.createElement(fe.xz6.Action,null,a.createElement(fe.SO$,{variant:"minimal",size:"2xs","aria-label":m?"Expand ".concat(n):"Collapse ".concat(n),"aria-expanded":!m,onClick:u},a.createElement(fe.D39,{className:(0,q.cn)("transition-transform duration-200",m&&"-rotate-90")})))),!m&&a.createElement(fe.xz6.Content,null,l))},aut=e=>{let t=e.label,n=e.icon,l=e.tileColor,r=e.value,o=e.isSelected,i=void 0!==o&&o,s=e.onClick;const c=a.createElement(fe.Qey.IconTile,{color:l,className:"size-7 rounded-sm",icon:a.createElement(Zs,{name:n})}),d=a.createElement(fe.c8D,{size:"sm",className:"min-w-0 truncate"},t),u=a.createElement(fe.c8D,{size:"sm",weight:"medium",color:"secondary"},r);return s?a.createElement(fe.XZZ,{"data-external-id":"rail-count",variant:"unstyled","aria-current":i?"true":void 0,className:(0,q.cn)(eut,"hover:bg-background-secondary",i&&"bg-background-secondary"),onClick:s},c,d,a.createElement("span",{className:"flex-1"}),u):a.createElement("div",{"data-external-id":"rail-count",className:eut},c,d,a.createElement("span",{className:"flex-1"}),u)},lut=e=>{const t=(0,a.useState)((()=>{try{return"1"===localStorage.getItem("".concat(Qdt).concat(e))}catch(t){return!1}})),n=(0,o.A)(t,2),l=n[0],r=n[1];return[l,(0,a.useCallback)((()=>{r((t=>{const n=!t;try{localStorage.setItem("".concat(Qdt).concat(e),n?"1":"0")}catch(a){}return n}))}),[e])]};var rut=n(5594);const out=e=>{var t,n;let l=e.canRenderConversation,i=e.insights,s=e.setFocusedOverviewId;const c=(0,rut.SN)(),u=c.threadIdFromUrl,m=c.openThread,p=c.closeThread,g=(0,z.h)(),h=g.setActiveThread,v=g.setPendingInitialMessage,f=g.parkAssistantMinimized,E=g.unparkAssistant,y=g.setSourceInsightId,b=(0,d.d4)(A.MJ),x=(0,d.d4)(A.x9),w=(0,a.useState)(null),C=(0,o.A)(w,2),I=C[0],k=C[1],S=(0,a.useRef)(void 0),N=(0,a.useRef)({reduxThreadId:b,hasLocalPendingConversation:!1}),T=(0,a.useState)(null),_=(0,o.A)(T,2),D=_[0],R=_[1],M=(0,a.useState)(null),L=(0,o.A)(M,2),O=L[0],P=L[1],B=u&&null!==(t=i.find((e=>e.messageThreadId===u)))&&void 0!==t?t:null,F=null!==I&&void 0!==I?I:u?(e=>{var t,n,a,l;return{threadId:e,title:null!==(t=zct(null===D||void 0===D?void 0:D.title,null===B||void 0===B?void 0:B.title,null===D||void 0===D?void 0:D.initialMessage))&&void 0!==t?t:"",initialMessage:null!==(n=null===D||void 0===D?void 0:D.initialMessage)&&void 0!==n?n:"",promptKind:null!==(a=null===D||void 0===D?void 0:D.promptKind)&&void 0!==a?a:"generic",insight:null!==(l=null!==B&&void 0!==B?B:null===D||void 0===D?void 0:D.insight)&&void 0!==l?l:null,createdAt:null===D||void 0===D?void 0:D.createdAt,isNewChatOrigin:null===D||void 0===D?void 0:D.isNewChatOrigin,newChatSessionId:null===D||void 0===D?void 0:D.newChatSessionId}})(u):null;(0,a.useEffect)((()=>{k((e=>(e=>{let t=e.pendingThreadId,n=e.urlThreadId;return!!t&&(n?t!==n:(0,Rct.m3)(t))})({pendingThreadId:null===e||void 0===e?void 0:e.threadId,urlThreadI
1d:u})?null:e))}),[u]),(0,a.useEffect)((()=>{const e=(e=>{let t=e.urlThreadId,n=e.reduxThreadId,a=e.hasLocalPendingConversation,l=e.hasPendingInitialMessage,r=e.previousUrlThreadId,o=e.canRenderConversation;return l?!1===o?{type:"noop"}:{type:"start-from-pending"}:t?r===t&&null===n?{type:"noop"}:{type:"sync-redux",threadId:t}:r?n?{type:"clear-redux"}:{type:"noop"}:n&&(0,Rct.m3)(n)||a?{type:"noop"}:n?{type:"hydrate-optimistic",threadId:n}:{type:"noop"}})({urlThreadId:u,reduxThreadId:b,hasLocalPendingConversation:null!==I,hasPendingInitialMessage:Boolean(x),previousUrlThreadId:S.current,canRenderConversation:l});(0,r.YW)(e).with({type:"start-from-pending"},(()=>{var e;const t=x,n=null!==(e=null===t||void 0===t?void 0:t.content.trim())&&void 0!==e?e:"";v(null),n&&(p(),h(null),R(null),P(null),s(null),y(null),k({threadId:null,title:n,initialMessage:n,promptKind:"generic",insight:null,triggerSource:null===t||void 0===t?void 0:t.triggerSource,fromGlobalSearch:null===t||void 0===t?void 0:t.fromGlobalSearch,createdAt:null===t||void 0===t?void 0:t.createdAt}))})).with({type:"sync-redux"},(e=>{let t=e.threadId;b!==t&&h(t),B&&y(B.id)})).with({type:"hydrate-optimistic"},(e=>{let t=e.threadId;k({threadId:t,title:"",initialMessage:"",promptKind:"generic",insight:null})})).with({type:"clear-redux"},(()=>{h(null),P(null)})).with({type:"noop"},(()=>{})).exhaustive(),S.current=u}),[p,I,x,b,h,s,v,y,u,B,l]),N.current={reduxThreadId:b,hasLocalPendingConversation:null!==I},(0,a.useEffect)((()=>()=>{const e=N.current,t=e.reduxThreadId,n=e.hasLocalPendingConversation;(t||n)&&f()}),[f]);const G=(0,a.useCallback)((()=>{k(null),R(null),P(null),p(),h(null),v(null),y(null),E()}),[p,h,v,y,E]),Y=(0,a.useCallback)((()=>{G(),s(null)}),[G,s]),V=null!==F&&void 0!==F&&F.threadId&&(0,Rct.m3)(F.threadId)?F.threadId:null,W=(0,a.useCallback)((e=>{e===V&&Y()}),[V,Y]),j=(0,a.useCallback)(((e,t)=>{P(null),k(null),R({title:t,initialMessage:"",promptKind:"generic",insight:null}),v(null),y(null),s(null),h(e),m(e)}),[m,h,s,v,y]),H=(0,a.useRef)(0),K=(0,a.useCallback)((()=>{H.current+=1;const e={title:Re.NEW_CHAT,initialMessage:"",promptKind:"generic",insight:null,isNewChatOrigin:!0,newChatSessionId:String(H.current)};G(),s(null),R(e),k((0,U.A)({threadId:null},e))}),[G,s]),q=(0,a.useCallback)((e=>{R((t=>t?t.title===e?t:(0,U.A)((0,U.A)({},t),{},{title:e}):{title:e,initialMessage:"",promptKind:"generic",insight:null})),k((t=>t&&t.title!==e?(0,U.A)((0,U.A)({},t),{},{title:e}):t))}),[]),$=(0,a.useCallback)(((e,t)=>{P((e=>{const t=e.getBoundingClientRect();return{left:t.left,top:t.top,width:t.width,height:t.height}})(t));const n={title:e.title,initialMessage:ws(e),promptKind:"smart",insight:e};s(null);const a=(0,Rct.mw)(e);if(a)return k(null),R(n),v(null),h(a),y(e.id),void m(a);p(),h(null),v(null),y(e.id),k((0,U.A)({threadId:null},n))}),[p,m,h,s,v,y]),Z=(0,a.useCallback)(((e,t)=>{P(null),p(),h(null),v(null),y(null),k({threadId:null,title:e,initialMessage:e,promptKind:t,insight:null})}),[p,h,v,y]),J=(0,a.useCallback)(((e,t)=>{if(!F)return;const n=(0,Rct.EW)(F),a=F.insight,l=(0,Rct.m3)(e,t);h(e,{persistUpgrade:!0}),v(null),k((t=>(0,Rct.II)(t,n,e))),l&&(R({title:F.title,initialMessage:F.initialMessage,promptKind:F.promptKind,insight:a?(0,U.A)((0,U.A)({},a),{},{messageThreadId:e}):null,createdAt:F.createdAt,isNewChatOrigin:F.isNewChatOrigin,newChatSessionId:F.newChatSessionId}),m(e))}),[F,m,h,v]),X=!!F&&(e=>{let t=e.threadId,n=e.initialMessage,a=e.insightId,l=e.isNewChatOrigin;return Boolean(l)&&!t&&!n.trim()&&!a})({threadId:F.threadId,initialMessage:F.initialMessage,insightId:null===(n=F.insight)||void 0===n?void 0:n.id,isNewChatOrigin:F.isNewChatOrigin});return{threadIdFromUrl:u,conversation:F,flipFrom:O,isNewChatPage:X,activePersistableThreadId:V,closeConversation:G,leaveToFeed:Y,startNewChat:K,startComposerConversation:Z,onOpenConversation:$,onSelectHistoryThread:j,onDeletedHistoryThread:W,onThreadSubject:q,onCreateThreadSuccess:J}},iut=e=>"number"===typeof e&&e>0?e:null,sut=e=>{var t;return null!==(t=iut(e.valueCaptured))&&void 0!==t?t:iut(e.value)},cut=[],dut=(e,t)=>{const n=new Map(t.map((e=>[e.id,e]))),a=new Set(e),l=[...n.keys()].filter((e=>!a.has(e))),r=l.length>0?[...e,...l]:e,o=r.flatMap((e=>{const t=n.get(e);return t?[t]:[]}));return{ids:r,ordered:o}}
1,uut=(0,Qt.J)("\n  query Common_TodayBackgroundStats($createdAfterOrAt: DateTime!) {\n    accounts(filters: { includeHidden: false, includeManual: false }) {\n      id\n      displayLastUpdatedAt\n      syncDisabled\n    }\n    categorized: aggregates(\n      filters: { createdAfterOrAt: $createdAfterOrAt, isUncategorized: false }\n    ) {\n      summary {\n        count\n      }\n    }\n  }\n"),mut="credit-card",put="refresh",gut=e=>{var t;return null!==(t=e.minus({hours:24}).set({second:0,millisecond:0}).toUTC().toISO())&&void 0!==t?t:""},hut=e=>"Categorized ".concat((0,De.td)("transaction",e,{inclusive:!0,modifier:"new"}),"\u2014all matched your rules"),vut=e=>"Synced ".concat((0,De.td)("account",e,{inclusive:!0})," overnight"),fut=(e,t)=>{var n,a;const l=null!==(a=null===(n=e.categorized[0])||void 0===n?void 0:n.summary.count)&&void 0!==a?a:0,r=e.accounts.filter((e=>!e.syncDisabled&&((e,t)=>{const n=N.c9.fromISO(e),a=N.c9.fromISO(t);return n.isValid&&a.isValid&&n>=a})(e.displayLastUpdatedAt,t))).length,o=[];return l>0&&o.push({id:"categorized",title:hut(l),icon:mut}),r>0&&o.push({id:"synced_accounts",title:vut(r),icon:put}),o},Eut=(hut(12),vut(3),e=>{let t=e.hiddenInsightIds,n=e.savedInsightIds,l=e.unsavedInsightIds,r=e.sessionCompletedInsights,i=e.sessionDismissedInsights,s=e.sessionUnhelpfulInsights,c=e.restoredInsightIds,d=e.feedbackByInsightId,u=e.skip,m=e.resetCompletedDelta;const p=bc({hiddenInsightIds:t,sessionSavedInsightIds:n,unsavedInsightIds:l,skip:u}),g=p.insights,h=p.allInsights,v=p.sections,f=p.dismissedInsights,E=p.unhelpfulInsights,y=p.completedCount,b=p.isLoading,x=p.error,w=function(){let e=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}).skip,t=void 0!==e&&e;const n=(0,a.useState)((()=>gut(N.c9.local()))),l=(0,o.A)(n,2),r=l[0],i=l[1],s=(0,et.I)(uut,{variables:{createdAfterOrAt:r},skip:t}),c=s.data,d=s.isLoadingInitialData,u=s.error,m=s.refetch;return{backgroundRows:(0,a.useMemo)((()=>c?fut(c,r):[]),[r,c]),isLoading:d,error:u,refetch:(0,a.useCallback)((()=>{const e=gut(N.c9.local());return i(e),m({createdAfterOrAt:e})}),[m])}}({skip:u}),C=w.backgroundRows,A=w.isLoading;(0,a.useEffect)((()=>{m()}),[y,m]);const I=(0,a.useMemo)((()=>kdt({insights:g,persistedDismissedInsights:f,persistedUnhelpfulInsights:E,sessionCompletedInsights:r,sessionDismissedInsights:i,sessionUnhelpfulInsights:s,savedInsightIds:n,unsavedInsightIds:l,restoredInsightIds:c,feedbackByInsightId:d})),[g,f,E,c,n,r,i,s,l,d]),k=I.knownInsights,S=I.savedInsightIds,T=I.saved,_=I.completed,D=I.dismissed,R=I.unhelpful,M=((e,t)=>{const n=(0,a.useState)({resetKey:t,ids:cut}),l=(0,o.A)(n,2),r=l[0],i=l[1],s=r.resetKey===t?r.ids:cut,c=(0,a.useMemo)((()=>dut(s,e)),[e,s]),d=c.ids,u=c.ordered;return(0,a.useEffect)((()=>{r.resetKey===t&&d===r.ids||i({resetKey:t,ids:d})}),[d,r,t]),u})((0,a.useMemo)((()=>Ps(Ms(v,"updates"),Ms(v,"recommendations"))),[v]),null),L=(0,a.useMemo)((()=>function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:new Set;const a=new Map(e.map((e=>[e.id,e])));t.forEach((e=>{const t=a.get(e.id);"completed"!==(null===t||void 0===t?void 0:t.status)&&a.set(e.id,(0,U.A)((0,U.A)({},e),{},{status:"completed"}))}));const l=[...a.values()];return{foundForYou:(0,De.Eb)(l.filter((e=>"active"===e.status&&!n.has(e.id))).map((e=>iut(e.value))).filter((e=>null!==e))),savedToDate:(0,De.Eb)(l.filter((e=>"completed"===e.status)).map(sut).filter((e=>null!==e)))}}(h,r,t)),[h,t,r]),O=L.foundForYou,P=L.savedToDate,B=(0,a.useMemo)((()=>((e,t)=>{const n=Object.entries((0,U.A)((0,U.A)({},Object.fromEntries(e.map((e=>{var t;return[e.id,null!==(t=e.feedback)&&void 0!==t?t:null]})))),t));return Object.fromEntries(n.filter((e=>Boolean(e[1]))))})(k,d)),[k,d]);return{insights:g,allInsights:h,sections:v,everythingElse:M,backgroundRows:C,completedCount:y,isLoading:b||A,error:x,allSavedInsightIds:S,savedInsights:T,completedInsights:_,dismissedInsights:D,unhelpfulInsights:R,foundForYou:O,savedToDate:P,allFeedbackByInsightId:B}}),yut=()=>{const e=(0,l.ok)(),t=(0,o.A)(e,2),n=t[0],r=t[1],i=(s=n.get(tdt))&&ldt.has(s)?s:null;var s;
1const c="archived"===i?(e=>"unhelpful"===e?"unhelpful":"dismissed")(n.get(ndt)):"dismissed";return{focusedOverviewId:i,setFocusedOverviewId:(0,a.useCallback)((e=>{r((t=>{const n=new URLSearchParams(t);return e?n.set(tdt,e):n.delete(tdt),n.delete(rut.A_),n.delete(ndt),n}),{replace:!0})}),[r]),archivedTab:c,setArchivedTab:(0,a.useCallback)((e=>{r((t=>{const n=new URLSearchParams(t);return n.set(tdt,"archived"),"unhelpful"===e?n.set(ndt,e):n.delete(ndt),n.delete(rut.A_),n}),{replace:!0})}),[r])}};var but=n(85197);const xut=function(){let e=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}).skip,t=void 0!==e&&e;var n,l;const r=(0,et.I)(but.ST,{fetchPolicy:"cache-and-network",nextFetchPolicy:"cache-first",notifyOnNetworkStatusChange:!0,skip:t}),o=r.data,i=r.isLoadingInitialData,s=r.isNetworkRequestInFlight,c=r.error,d=r.refetch,u=null!==(l=null===(n=null===o||void 0===o?void 0:o.householdProfile)||void 0===n?void 0:n.hasCompletedTodayOnboarding)&&void 0!==l&&l,m=(0,a.useRef)(!1);s||(m.current=!0);return{hasCompletedOnboarding:u,isLoadingInitialData:i,isNetworkRequestInFlight:s,isPending:!u&&!m.current,error:c,refetch:d}},wut=()=>{const e=Je().draft,t=(0,ht.S)(),n=t.isAiFeaturesEnabled,r=t.isLoading,i=at(),s=i.assistantName,c=i.assistantColor,d=i.completedAgentOnboardingAt,u=i.isLoadingProfile,m=xut(),p=m.hasCompletedOnboarding,g=m.isPending,h=m.error,v=u||g||r,f=Boolean(h)&&!p,E=(e=>{let t=e.hasCompletedOnboarding,n=e.isLoading,r=e.hasError;const i=(0,l.ok)(),s=(0,o.A)(i,1)[0],c=(0,l.Zp)();return{isOpen:"1"===s.get("preOnboarding")||!n&&!r&&!t,start:(0,a.useCallback)((()=>{(0,Ge.u4)(Ye.xb.AssistantSetupFlowStarted),c(I.JZ.today.onboarding(),{replace:!1})}),[c])}})({hasCompletedOnboarding:p,isLoading:v,hasError:f}),y=E.isOpen,b=E.start,x=!v&&!f&&n,w=(0,a.useMemo)((()=>(0,U.A)((0,U.A)({},e),(0,ge.Pw)({draft:e,profileName:s,profileColor:c}))),[e,c,s]);return{isLoadingGate:v,hasGateError:f,isAiFeaturesEnabled:n,canRenderConversation:x,isPreOnboarding:y,startOnboarding:b,isLoadingProfile:u,assistantName:w.displayName.trim()||ge.Uk,assistantDraftWithPersona:w,completedAgentOnboardingAt:d}};var Cut=n(8851);const Aut=new Set,Iut=e=>{const t=(0,a.useRef)(null);t.current?t.current.update(e):t.current=(e=>{const t={lists:e};return Ns.push(t),{update:e=>{t.lists=e},release:()=>{const e=Ns.lastIndexOf(t);-1!==e&&Ns.splice(e,1)}}})(e),(0,a.useEffect)((()=>()=>{var e;null===(e=t.current)||void 0===e||e.release(),t.current=null}),[])},kut=["]"],Sut=[],Nut=()=>{var e,t;(0,a.useLayoutEffect)((()=>((0,uc.UM)(),uc.UM)),[]);const n=(()=>{const e=(0,Cut.B)("monarch.today.railOpen",!0),t=(0,o.A)(e,2),n=t[0],l=t[1];return{isRailOpen:n,toggleRail:(0,a.useCallback)((()=>{l((e=>!e))}),[l])}})(),l=n.isRailOpen,r=n.toggleRail,i=ut().openSettings,s=yut(),c=s.focusedOverviewId,d=s.setFocusedOverviewId,u=wut(),m=u.isLoadingGate,p=u.hasGateError,g=u.isAiFeaturesEnabled,h=u.canRenderConversation,f=u.isPreOnboarding,E=u.startOnboarding,y=u.isLoadingProfile,b=u.assistantName,x=u.assistantDraftWithPersona,w=u.completedAgentOnboardingAt,C=vc(),A=C.hiddenInsightIds,I=C.dismissingInsightIds,k=C.completedStubInsightId,S=C.savedInsightIds,N=C.unsavedInsightIds,T=C.sessionCompletedInsights,_=C.sessionDismissedInsights,D=C.sessionUnhelpfulInsights,R=C.restoredInsightIds,M=C.feedbackByInsightId,L=C.completedDelta,O=C.onComplete,P=C.onUndoComplete,B=C.onDismiss,z=C.onUndoDismiss,F=C.onDismissAnimationEnd,G=C.onSave,Y=C.submitDenialNote,V=C.showDismissNoteToast,W=C.onPrimaryAction,j=C.resetCompletedDelta,H=Eut({hiddenInsightIds:A,savedInsightIds:S,unsavedInsightIds:N,sessionCompletedInsights:T,sessionDismissedInsights:_,sessionUnhelpfulInsights:D,restoredInsightIds:R,feedbackByInsightId:M,skip:f||m||p||!g,resetCompletedDelta:j}),K=H.insights,$=H.sections,Z=H.everythingElse,J=H.backgroundRows,X=H.completedCount,Q=H.isLoading,ee=H.error,te=H.allSavedInsightIds,ne=H.savedInsights,ae=H.completedInsights,le=H.dismissedInsights,re=H.unhelpfulInsights,oe=H.foundForYou,ie=H.savedToDate,se=out({canRenderConversation:h,insights:K,setFocusedOverviewId:d}),ce=se.threadIdFromUrl,de=se.conversation,ue=se.flipFrom,me=se.isNewChatPage,pe=se.activePersistableThreadI
1d,ge=se.closeConversation,he=se.leaveToFeed,ve=se.startNewChat,Ee=se.startComposerConversation,ye=se.onOpenConversation,be=se.onSelectHistoryThread,xe=se.onDeletedHistoryThread,we=se.onThreadSubject,Ce=se.onCreateThreadSuccess,Ae=h&&!de,Ie=(e=>{var t;let n=e.showOverview,a=e.skip,l=void 0!==a&&a;const r=(0,et.I)(Qe.ps,{skip:l||n}),o=r.data,i=r.error,s=(null!==(t=null===o||void 0===o?void 0:o.messageThreads.length)&&void 0!==t?t:0)>0;return{hasRailContent:!l&&(n||s||Boolean(i))}})({showOverview:!f,skip:!Ae}),ke=Ie.hasRailContent,Se=Ae&&ke,Ne=(e=>{let t=e.toggleRail;const n=(0,mce.WB)().registerCommand,l=(0,v.D)((()=>{null===t||void 0===t||t()}));return(0,a.useEffect)((()=>{if(t)return n({group:"actions",id:"assistant.toggle-panel",label:Re.RAIL_TOGGLE_COMMAND,action:l,keys:kut,icon:a.createElement(fe.OfV,null),analyticsMetadata:{analyticsId:"assistant.toggle-panel"}})}),[n,t,l]),{toggleRailShortcut:kut}})({toggleRail:Se?r:void 0}),Te=Ne.toggleRailShortcut,_e=(e=>{let t=e.overviewId,n=e.sections,a=e.everythingElse,l=e.saved,r=e.completed,o=e.archived;return"saved"===t?[l]:"completed"===t?[r]:"archived"===t?[o]:"everything_else"===t?[a]:"in_the_background"===t?[]:t&&!Ds.has(t)?[Ms(n,t)]:[Ms(n,"needs_attention"),a]})({overviewId:c,sections:$,everythingElse:Z,saved:ne,completed:ae,archived:Sdt(le,re)}),De=(0,a.useRef)(_e);de||(De.current=_e),Iut(de?De.current:_e),((e,t)=>{const n=(0,v.D)(t);(0,a.useEffect)((()=>{for(const t of e)for(const a of t)Aut.has(a.id)||(Aut.add(a.id),n(Ye.CP.InsightViewed,(0,U.A)((0,U.A)({},Rs(a)),{},{position:_s(e,a.id)})))}),[e,n])})(de||Q?Sut:_e,Ge.u4);const Me=(e=>{if(e)return Rs(e)})(null===de||void 0===de?void 0:de.insight),Le=!ce||!y&&!Q,Oe=(0,a.useState)(Cdt),Pe=(0,o.A)(Oe,2),Be=Pe[0],ze=Pe[1],Fe=!Be&&!m&&!f&&!Q&&!de&&!c,Ue=(0,a.useCallback)((()=>{(()=>{if("undefined"!==typeof sessionStorage)try{sessionStorage.setItem(wdt,"1")}catch(e){}})(),ze(!0)}),[]);(0,a.useEffect)((()=>{(de||c)&&Ue()}),[de,c,Ue]);const Ve=de?null!==(e=zct(de.title,null===(t=de.insight)||void 0===t?void 0:t.title,de.initialMessage))&&void 0!==e?e:de.isNewChatOrigin?Re.NEW_CHAT:null:c&&odt(c)||null;return m?a.createElement(Jdt,{"data-external-id":"today",tracking:Zdt(Me,Le)}):g?p?a.createElement(Jdt,{"data-external-id":"today"},a.createElement(Hct,null)):a.createElement(rG.Y,Object.assign({"data-external-id":"today"},Zdt(Me,Le),{header:a.createElement($dt,{isRailOpen:l,onToggleRail:Se?r:void 0,railShortcut:Te,focusedSectionLabel:de?void 0:Ve,currentCrumb:de?a.createElement(Oct,{title:null!==Ve&&void 0!==Ve?Ve:Re.NEW_CHAT,activeThreadId:de.threadId&&(0,Rct.m3)(de.threadId)?de.threadId:null,onSelectThread:be,onDeleted:xe}):void 0,onClearFocusedSection:he,onOpenSettings:f?void 0:()=>{(0,Ge.u4)(Ye.xb.AssistantSettingsOpened),i()},onNewChat:de&&!me?ve:void 0}),shouldScroll:!de}),a.createElement("div",{className:(0,q.cn)("flex min-h-0 flex-1",de&&"overflow-hidden")},de?a.createElement(jct,{conversation:de,assistantName:b,assistantColor:x.color,flipFrom:ue,onCreateThreadSuccess:Ce,onCreateThreadError:ge,onThreadSubject:we,onThreadNotFound:ge,isInsightSaved:de.insight?te.has(de.insight.id):void 0,onSaveInsight:G,onCompleteInsight:O,onInsightPrimaryAction:W}):a.createElement(Kdt,{assistantDraft:x,assistantName:b,isPreOnboarding:f,completedAgentOnboardingAt:w,focusedOverviewId:c,playFeedReveal:Fe,onRevealFinished:Ue,onStartConversation:Ee,onGetStarted:E,sections:$,everythingElse:Z,backgroundRows:J,isLoading:Q,hasError:Boolean(ee),dismissingInsightIds:I,completedStubInsightId:k,savedInsightIds:te,savedInsights:ne,completedInsights:ae,dismissedInsights:le,unhelpfulInsights:re,onComplete:O,onUndoComplete:P,onDismiss:B,onRestore:z,onDismissAnimationEnd:F,onSave:G,onSubmitDenialNote:Y,onDismissNoteToast:V,onPrimaryAction:W,onOpenConversation:ye}),l&&Se&&a.createElement(tut,{completedCount:X+L,savedCount:ne.length,archivedCount:(We=le,je=re,new Set([...We,...je].map((e=>e.id))).size),foundForYou:oe,savedToDate:ie,selectedOverviewId:c,showOverview:!f,onSelectOverview:f?void 0:e=>{ge(),d(e)},activeThreadId:pe,onSelectRecentThread:be,onDeletedThread:xe}))):a.createElement(Jdt,{"data-external-id":"today",tracking:Zdt(Me,Le)},a.createElement(Dt,null));var We,je},Tut=()=>{const e=(0,ot.M)(),t=e.isOn,n=e.isReady;return t||!n?a.createElement(Nut,{"data-external-id":"today-route"}):a.createElement(DZ,{"data-external-id":"today-route"})},_ut=e=>{let t=e.nextLabel,n=e.onNext,l=e.onSaveAndClose,r=e.hasCompletedOnboarding,o=e.isLoading,i=void 0!==o&&o,s=e.disabled,c=void 0!==s&&s,d=e.saveDisabled,u=void 0!==d&&d,m=e.className;return a.createElement("div",{"data-external-id":"today-onboarding-actions",className:(0,q.cn)("flex flex-wrap items-center justify-center gap-sm",m)},a.createElement(fe.XZZ,{variant:"primary",size:"md",type:"button",className:"w-92 shrink-0",isLoading:i,disabled:c,onClick:n},t),r&&a.createElement(fe.XZZ,{variant:"default",size:"md",type:"button",isLoading:i,disabled:u,onClick:l},Re.ONBOARDING_SAVE_AND_CLOSE))},Dut=[{id:"accounts",Icon:fe.uzy,title:Re.ONBOARDING_SETUP_ACCOUNTS_TITLE},{id:"repeats",Icon:fe.$OE,title:Re.ONBOARDING_SETUP_REPEATS_TITLE,body:Re.ONBOARDING_SETUP_REPEATS_BODY},{id:"flag",Icon:fe.Ey4,title:Re.ONBOARDING_SETUP_FLAG_TITLE,body:Re.ONBOARDING_SETUP_FLAG_BODY}],Rut=e=>{let t=e.color,n=e.displayName,l=e.accountCount,r=e.onCheckItOut,o=e.preview;const i=Lut(Dut.length,o),s=i.visibleCount,c=i.isComplete,d=(e=>{const t=e>0?"your ".concat((0,De.td)("account",e,{inclusive:!0})):"your accounts";return"Learning what normal looks like across ".concat(t,".")})(l);return a.createElement("div",{"data-external-id":"today-onboarding-loading",className:"flex min-h-0 flex-1 flex-col"},a.createElement("div",{className:" flex min-h-0 flex-1 flex-col items-center justify-center gap-xl overflow-y-auto px-xl py-3xl "},a.createElement(he,{color:t,size:48,label:n}),a.createElement("div",{className:"flex flex-col items-center gap-2xs text-center"},a.createElement("h2",{"aria-live":"polite","aria-atomic":"true",className:" m-0 font-secondary text-[28px]/[1.5] font-book tracking-[-0.03em] text-content-primary "},c?Re.ONBOARDING_SETUP_DONE_TITLE:Re.ONBOARDING_SETUP_TITLE),a.createElement(fe.c8D,{color:"secondary",className:"text-pretty"},Re.ONBOARDING_SETUP_SUB)),a.createElement("div",{className:"flex w-full max-w-86 flex-col items-center gap-2xl"},Dut.map(((e,t)=>{const n="body"in e?e.body:d,l=t<s,r=e.id,o=e.Icon,i=e.title;return a.createElement("div",{key:r,"aria-hidden":!l,className:(0,q.cn)("flex w-full max-w-86 flex-col items-center transition-[opacity,transform] duration-450",l?"translate-y-0 opacity-100":"translate-y-2 opacity-0"),style:{transitionTimingFunction:"cubic-bezier(0,0,0,1)"}},a.createElement(o,{size:24,className:"text-content-brand"}),a.createElement(fe.c8D,{weight:"medium",className:"mt-xs"},i),a.createElement(fe.c8D,{color:"secondary",className:"text-center text-pretty"},n))})))),a.createElement("div",{className:"flex h-20 shrink-0 items-center justify-center border-t border-divider-secondary"},c?a.createElement(fe.XZZ,{variant:"primary",size:"md",className:"w-92 shrink-0",onClick:r},Re.ONBOARDING_SETUP_CTA):null))},Mut=()=>"undefined"!==typeof window&&"function"===typeof window.matchMedia&&window.matchMedia("(prefers-reduced-motion: reduce)").matches,Lut=(e,t)=>{const n=(0,a.useState)(Mut),l=(0,o.A)(n,2),r=l[0],i=l[1],s="complete"===t||"start"!==t&&r,c=(0,a.useState)(((e,t,n)=>"start"===n?1:"complete"===n||t?e:0)(e,r,t)),d=(0,o.A)(c,2),u=d[0],m=d[1],p=(0,a.useState)(s),g=(0,o.A)(p,2),h=g[0],v=g[1];return(0,a.useEffect)((()=>
1{if("function"!==typeof window.matchMedia)return;const e=window.matchMedia("(prefers-reduced-motion: reduce)"),t=()=>i(e.matches);return e.addEventListener("change",t),()=>e.removeEventListener("change",t)}),[]),(0,a.useEffect)((()=>{if("start"===t)return m(1),void v(!1);if("complete"===t||r)return m(e),void v(!0);m(0),v(!1);const n=[...Array.from({length:e},((e,t)=>window.setTimeout((()=>m(t+1)),ge._Q+t*ge.KK))),window.setTimeout((()=>v(!0)),ge._Q+e*ge.KK+ge.kw)];return()=>n.forEach((e=>window.clearTimeout(e)))}),[e,r,t]),{visibleCount:u,isComplete:h}},Out=e=>{let t=e.children;const n=(0,a.useRef)(null);return(0,a.useLayoutEffect)((()=>{var e;Put(document.activeElement)||null===(e=n.current)||void 0===e||e.focus({preventScroll:!0})}),[]),a.createElement("h1",{"data-external-id":"onboarding-step-title",ref:n,tabIndex:-1,className:" m-0 font-secondary text-[28px]/[normal] font-book tracking-[-0.03em] text-content-primary outline-none "},t)},Put=e=>e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement||e instanceof HTMLSelectElement||e instanceof HTMLElement&&e.isContentEditable;var But=n(12647),zut=n(48594);const Fut=new Set([oV.LZ.BROKERAGE,oV.LZ.NON_TAXABLE_BROKERAGE_ACCOUNT]),Gut=new Set([oV.LZ.CHECKING,oV.LZ.CASH_MANAGEMENT]),Yut=e=>new Map((e=>Array.isArray(e)?e.filter((e=>"object"===typeof e&&null!==e&&!Array.isArray(e))):[])(e).filter((e=>"string"===typeof e.account_id)).map((e=>[String(e.account_id),e]))),Uut=e=>{const t=null===e||void 0===e?void 0:e.interest_rate;return null===t?null:"number"===typeof t?t:void 0},Vut=e=>{let t=e.accounts,n=e.answer,a=e.savedAnswer,l=void 0===a?null:a;const r=Yut(n),o=Yut(l);return{rows:Object.fromEntries(t.map((e=>{const t=r.get(e.id),n=Array.isArray(null===t||void 0===t?void 0:t.purposes)?t.purposes.filter((e=>"string"===typeof e)):[],a=n.length>0?n:e.suggestedPurposes,l=Uut(t),i=l===Uut(o.get(e.id))?void 0:l;return[e.id,{accountId:e.id,purposes:a,interestRate:i}]})))}},Wut=(e,t)=>t.map((t=>e.rows[t.id])).filter((e=>Boolean(e)&&e.purposes.length>0)).map((e=>{let t=e.accountId,n=e.purposes,a=e.interestRate;return void 0===a?{account_id:t,purposes:n}:{account_id:t,purposes:n,interest_rate:a}})),jut=e=>Boolean(e.deactivatedAt||e.dataProviderDeactivatedAt),Hut=e=>e.isHidden||e.isClosed,Kut=e=>e.filter((e=>!Hut(e))),qut=e=>e.filter(Hut),$ut=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=t.suggestedPurposes,a=void 0===n?{}:n,l=t.fundedGoals,r=void 0===l?{}:l;return e.filter((e=>{var t,n,a,l,r,o;return!1!==e.isAsset&&(r=null!==(n=null===(t=e.type)||void 0===t?void 0:t.name)&&void 0!==n?n:"",o=null!==(l=null===(a=e.subtype)||void 0===a?void 0:a.name)&&void 0!==l?l:"",(0,zut.kc)(r)||(0,zut.f_)(r)&&Fut.has(o))})).map((e=>{var t,n,l,o,i,s,c,d,u;return{id:e.id,displayName:e.displayName,displayBalance:null!==(t=e.displayBalance)&&void 0!==t?t:null,logoUrl:null!==(n=e.logoUrl)&&void 0!==n?n:null,typeName:null!==(o=null===(l=e.type)||void 0===l?void 0:l.name)&&void 0!==o?o:"",subtypeName:null!==(s=null===(i=e.subtype)||void 0===i?void 0:i.name)&&void 0!==s?s:"",interestRate:null!==(c=e.interestRate)&&void 0!==c?c:null,suggestedPurposes:[...null!==(d=a[e.id])&&void 0!==d?d:[]],fundedGoals:[...null!==(u=r[e.id])&&void 0!==u?u:[]],linkedGoal:e.linkedGoal&&!e.linkedGoal.archivedAt?{id:e.linkedGoal.id,name:e.linkedGoal.name}:null,isHidden:Boolean(e.isHidden),isClosed:jut(e)}})).sort(((e,t)=>e.displayName.localeCompare(t.displayName)))},Zut="adult",Jut="dependent",Xut="roster_id",Qut=/^\d{4}-\d{2}-\d{2}$/,emt=1e8,tmt="Partner",nmt=()=>(0,FW.v4)(),amt=(e,t)=>{if("string"!==typeof e||!Qut.test(e))return!1;const n=e.split("-").map(Number),a=(0,o.A)(n,3),l=a[0],r=a[1],i=a[2],s=new Date(Date.UTC(l,r-1,i));return s.getUTCFullYear()===l&&s.getUTCMonth()===r-1&&s.getUTCDate()===i&&l>=1900&&l<=t},lmt=e=>"number"===typeof e&&Number.isInteger(e)&&e>=0&&e<=emt,rmt=(e,t)=>"number"===typeof e&&Number.isInteger(e)&&e>=1900&&e<=t,omt=(e,t)=>t-e,imt=(e,t)=>rmt(e,t)?omt(e,t)<18?"Child":"Adult":"Dependent",smt=(e,t)=>"string"===typeof e.id&&e.id.length>0?e.id:"string"===typeof e.user_id?cmt(e.user_id):"entry-".concat(t),cmt=e=>"member-".concat(e),dmt=e=>"number"===typeof e&&lmt(e)?e:null,umt=e=>{let t=e.members,n=e.answer,a=e.currentYear,l=e.preferAnswerIncome,r=void 0!==l&&l;const o=(e=>Array.isArray(e)?e.filter((e=>"object"===typeof e&&null!==e&&!Array.isArray(e))):[])(n).map(((e,t)=>({entry:e,id:smt(e,t)}))),i=new Map(o.filter((e=>{let t=e.entry;return t.role===Zut&&"string"===typeof t.user_id})).map((e=>{let t=e.entry,n=e.id;return[String(t.user_id),{id:n,birthDate:t.birth_date,annualGrossIncome:t.annual_gross_income,hasAnnualGrossIncome:"annual_gross_income"in t}]})));return{adults:[...t.map((e=>{let t=e.id,n=e.name,l=e.birthday,o=e.grossAnnualIncome;var s;const c=i.get(t),d="string"===typeof(null===c||void 0===c?void 0:c.birthDate)&&amt(c.birthDate,a)?c.birthDate:null,u=dmt(o),m=dmt(null===c||void 0===c?void 0:c.annualGrossIncome),p=r&&(null===c||void 0===c?void 0:c.hasAnnualGrossIncome)?m:null!==u&&void 0!==u?u:m;return{id:null!==(s=null===c||void 0===c?void 0:c.id)&&void 0!==s?s:cmt(t),userId:t,displayName:n,birthDate:amt(l,a)?l:d,annualGrossIncome:p}})),...o.filter((e=>{let t=e.entry;return t.role===Zut&&"string"!==typeof t.user_id})).map((e=>{let t=e.entry,n=e.id;const l=t.birth_date;return{id:n,userId:null,displayName:"string"===typeof t.name?t.name:tmt,birthDate:"string"===typeof l&&amt(l,a)?l:null,annualGrossIncome:dmt(t.annual_gross_income)}}))],dependents:o.filter((e=>e.entry.role===Jut)).map((e=>{let t=e.entry;return{id:e.id,birthYear:"number"===typeof t.birth_year?t.birth_year:null}}))}},mmt=(e,t)=>e.isMe?"Your ".concat(t):"".concat(e.name,"'s ").concat(t),pmt=(e,t)=>[...e.adults.map((e=>null===e.userId?{id:e.id,name:e.displayName.trim(),role:Zut,birth_date:e.birthDate,annual_gross_income:e.annualGrossIncome}:{id:e.id,user_id:e.userId,role:Zut,birth_date:e.birthDate,annual_gross_income:e.annualGrossIncome})),...e.dependents.map((e=>({id:e.id,name:imt(e.birthYear,t),role:Jut,birth_year:e.birthYear})))],gmt=e=>Array.isArray(e)?e.filter((e=>"object"===typeof e&&null!==e&&!Array.isArray(e))):[],hmt=(e,t)=>{var n;return null!==(n=gmt(e).find((e=>e[Xut]===t)))&&void 0!==n?n:{}},vmt=(e,t,n)=>{const a=gmt(e),l=a.filter((e=>e[Xut]!==t));if(null===n)return l;const r=(0,U.A)({[Xut]:t},n),o=a.findIndex((e=>e[Xut]===t));return o<0?[...a,r]:a.map(((e,t)=>t===o?r:e))},fmt=(e,t,n)=>{const a=hmt(e,t)[n];return Array.isArray(a)?a.filter((e=>"string"===typeof e)):[]},Emt=e=>{var t;return null!==(t=e.itemFields.find((e=>e!==Xut)))&&void 0!==t?t:null},ymt="matches",bmt="contributes_regardless",xmt="dollars",wmt="percent",Cmt=e=>"number"===typeof e?e:null,Amt=(e,t)=>{const n=hmt(e,t),a=n.contribution_unit;return{matchType:"string"===typeof n.match_type?n.match_type:null,matchPercent:Cmt(n.match_percent),upToPercent:Cmt(n.up_to_percent),contributionAmount:Cmt(n.contribution_amount),contributionUnit:a===xmt?a:wmt}},Imt=(e,t,n)=>vmt(e,t,(e=>e.matchType?e.matchType===ymt?{match_type:e.matchType,match_percent:e.matchPercent,up_to_percent:e.upToPercent}:e.matchType===bmt?{match_type:e.matchType,contribution_amount:e.contributionAmount,contribution_unit:e.contributionUnit}:{match_type:e.matchType}
1:null)(n)),kmt=e=>"object"!==typeof e||null===e||Array.isArray(e)?{}:e,Smt=(e,t)=>{const n=kmt(e)[t];return"string"===typeof n?n:null},Nmt=(e,t)=>{const n=kmt(e)[t];return"number"===typeof n?n:null},Tmt=(e,t,n)=>{const a=kmt(e);return null===n||void 0===n?Object.fromEntries(Object.entries(a).filter((e=>(0,o.A)(e,1)[0]!==t))):(0,U.A)((0,U.A)({},a),{},{[t]:n})},_mt="rate_type",Dmt="apr",Rmt=e=>({rateType:Smt(e,_mt),apr:Nmt(e,Dmt)}),Mmt=e=>null!==e&&"not_sure"!==e,Lmt=/^\d{5}(-\d{4})?$/,Omt=100,Pmt=(e,t,n)=>(0,r.YW)(e.questionType).with(Ee.SQ2.LIST,(()=>{const a=((e,t)=>{if(0===e.itemFields.length||!Array.isArray(t))return t;const n=new Set(e.itemFields);return gmt(t).map((e=>Object.fromEntries(Object.entries(e).filter((e=>{let t=(0,o.A)(e,1)[0];return n.has(t)})))))})(e,t);return n?((e,t,n)=>{if(!e.itemFields.includes(Xut)||!Array.isArray(t))return t;const a=new Set(n.map((e=>e.rosterId)));return gmt(t).filter((e=>{const t=e[Xut];return"string"===typeof t&&a.has(t)}))})(e,a,n):a})).with(Ee.SQ2.STRUCTURED,(()=>((e,t)=>{if(0===e.structuredFields.length)return t;const n=new Set(e.structuredFields);return Object.fromEntries(Object.entries(kmt(t)).filter((e=>{let t=(0,o.A)(e,1)[0];return n.has(t)})))})(e,t))).otherwise((()=>t)),Bmt=(e,t)=>"number"===typeof e&&Number.isInteger(e)&&e>=0&&e<=t,zmt=(e,t)=>"number"===typeof e&&Number.isFinite(e)&&e>=0&&e<=t,Fmt=(e,t)=>"string"===typeof t&&(0===e.options.length||e.options.some((e=>e.value===t))),Gmt=(e,t)=>e.length>0&&e.every((e=>t(e.rosterId))),Ymt=(e,t)=>Gmt(t,(t=>{return!!(n=Amt(e,t)).matchType&&(n.matchType===ymt?null!==n.matchPercent&&null!==n.upToPercent:n.matchType!==bmt||null!==n.contributionAmount);var n})),Umt=new Set(["id","user_id","account_id",Xut]),Vmt=e=>null===e||void 0===e||("string"===typeof e?0===e.trim().length:Array.isArray(e)?e.every(Vmt):"object"===typeof e&&Object.entries(e).every((e=>{let t=(0,o.A)(e,2),n=t[0],a=t[1];return Umt.has(n)||Vmt(a)}))),Wmt=(e,t,n)=>{if(t.dontKnow)return!0;const a=e.question,l=t.answer,o=(0,r.YW)(a.presentation).with(Ee._mz.HOUSEHOLD_ROSTER,(()=>((e,t)=>e.adults.every((e=>amt(e.birthDate,t)&&lmt(e.annualGrossIncome)&&(null!==e.userId||e.displayName.trim().length>0)))&&e.dependents.every((e=>rmt(e.birthYear,t))))(umt({members:n.members,answer:l,currentYear:n.currentYear,preferAnswerIncome:!0}),n.currentYear))).with(Ee._mz.ZIP_CODE,(()=>"string"===typeof l&&Lmt.test(l))).with(Ee._mz.CURRENCY,(()=>a.questionType===Ee.SQ2.LIST?((e,t,n)=>{const a=Emt(e);return null!==a&&Gmt(n,(e=>Bmt(hmt(t,e)[a],emt)))})(a,l,n.people):Bmt(l,emt))).with(Ee._mz.PERCENTAGE,(()=>zmt(l,Omt))).with(Ee._mz.MORTGAGE_RATE,(()=>((e,t)=>{const n=Rmt(t);return(e=>null!==e.rateType)(n)&&Fmt(e,n.rateType)&&(null===n.apr||zmt(n.apr,Omt))})(a,l))).with(Ee._mz.EMPLOYER_MATCH,(()=>Ymt(l,n.people))).with(Ee._mz.ACCOUNT_PURPOSE,(()=>(e=>Array.isArray(e)&&e.length>0&&e.every((e=>"object"===typeof e&&null!==e&&"string"===typeof e.account_id&&Array.isArray(e.purposes)&&e.purposes.length>0)))(l))).otherwise((()=>null));return null!==o?o:(0,r.YW)(a.questionType).with(Ee.SQ2.SINGLE_SELECT,(()=>((e,t)=>Fmt(e,t))(a,l))).with(Ee.SQ2.LIST,(()=>(e=>
1e.itemFields.includes(Xut))(a)?((e,t,n)=>{const a=Emt(e);return null!==a&&Gmt(n,(n=>{const l=fmt(t,n,a);return l.length>0&&l.every((t=>Fmt(e,t)))}))})(a,l,n.people):Array.isArray(l)&&l.length>0)).with(Ee.SQ2.MULTI_SELECT,(()=>Array.isArray(l)&&l.length>0&&l.every((e=>Fmt(a,e))))).with(Ee.SQ2.STRUCTURED,(()=>Object.keys(kmt(l)).length>0)).with(Ee.SQ2.TEXT,(()=>"string"===typeof l&&l.trim().length>0)).with(Ee.SQ2.NUMBER,(()=>"number"===typeof l&&Number.isFinite(l))).otherwise((()=>null!==l&&void 0!==l))},jmt="today_income_type",Hmt="today_employer_match",Kmt="not_working",qmt="working_full_time",$mt="working_part_time",Zmt={[Ee.Xns.EMPLOYED_FULL_TIME]:qmt,[Ee.Xns.EMPLOYED_PART_TIME]:$mt,[Ee.Xns.BUSINESS_OWNER]:"business_owner",[Ee.Xns.SELF_EMPLOYED]:"self_employed",[Ee.Xns.STUDENT]:"student",[Ee.Xns.RETIRED]:"retired",[Ee.Xns.UNEMPLOYED]:Kmt},Jmt=(e,t)=>{const n=e?Zmt[e]:void 0;return n&&t.includes(n)?[n]:[]},Xmt=(e,t,n)=>e.name===Hmt?t.filter((e=>(e=>e.includes(qmt)||e.includes($mt))(((e,t)=>{var n,a;return fmt(null!==(a=null===(n=e[jmt])||void 0===n?void 0:n.answer)&&void 0!==a?a:null,t,"income_types")})(n,e.rosterId)))):t,Qmt=e=>{var t,n;return null!==(n=null===(t=e.answer)||void 0===t?void 0:t.answer)&&void 0!==n?n:null},ept=(e,t)=>!e.branch||((e,t)=>{const n=t[e.parentQuestionName];return!(!n||n.dontKnow)&&("string"===typeof n.answer?e.whenAnyOf.includes(n.answer):!!Array.isArray(n.answer)&&n.answer.some((t=>"string"===typeof t&&e.whenAnyOf.includes(t))))})(e.branch,t),tpt=(e,t,n)=>{if(!ept(e,t))return!1;if(void 0===n||e.name!==Hmt)return!0;const a=t[jmt];return!(!a||a.dontKnow)&&(0===n.length||Xmt(e,n,t).length>0)},npt=(e,t,n)=>tpt(e.question,t,n)&&(e.isDue||!e.isAnswered),apt=(e,t,n)=>{var a;return(null!==(a=null===e||void 0===e?void 0:e.questions)&&void 0!==a?a:[]).filter((e=>tpt(e.question,t,n)))},lpt=(e,t,n)=>{var a;return t[jmt]?(null!==(a=null===e||void 0===e?void 0:e.questions)&&void 0!==a?a:[]).filter((e=>e.isDue&&e.question.name===Hmt&&!tpt(e.question,t,n))).map((e=>e.question.name)):[]},rpt=(e,t,n)=>{var a,l;return null!==(l=null===(a=((e,t,n)=>{var a;return(null!==(a=null===e||void 0===e?void 0:e.questions)&&void 0!==a?a:[]).filter((e=>npt(e,t,n)))})(e,t,n)[0])||void 0===a?void 0:a.question.name)&&void 0!==l?l:null},opt=(e,t,n)=>{var a,l,r;const o=null!==(a=null===e||void 0===e?void 0:e.questions)&&void 0!==a?a:[],i=o.findIndex((e=>e.question.name===t));return null!==(r=null===(l=(i>=0?o.slice(i+1):o).find(n))||void 0===l?void 0:l.question.name)&&void 0!==r?r:null},ipt=(e,t)=>!t||"object"!==typeof t||Array.isArray(t)?t:Object.fromEntries(Object.entries(t).sort(((e,t)=>{let n=(0,o.A)(e,1)[0],a=(0,o.A)(t,1)[0];return n.localeCompare(a)}))),spt=(e,t)=>JSON.stringify(null!==e&&void 0!==e?e:null,ipt)===JSON.stringify(null!==t&&void 0!==t?t:null,ipt),cpt=new Set(Object.values(Ee.kUM)),dpt=e=>{let t=e.question,n=e.accounts,l=e.value,r=e.savedAnswer,i=e.onChange;const s=(0,a.useState)((()=>({accounts:n,draft:Vut({accounts:n,answer:l,savedAnswer:r})}))),c=(0,o.A)(s,2),d=c[0],u=c[1];d.accounts!==n&&u({accounts:n,draft:Vut({accounts:n,answer:l,savedAnswer:r})});const m=d.draft,p=(0,a.useState)(!1),g=(0,o.A)(p,2),h=g[0],v=g[1],f=((e,t)=>{let n=t.tuckedRevealed,a=t.savedAnswer,l=void 0===a?null:a;const r=Kut(e),o=qut(e);if(n)return[...r,...o];const i=new Set(Yut(l).keys());return[...r,...o.filter((e=>i.has(e.id)))]})(n,{tuckedRevealed:h,savedAnswer:r}),E=(e,t)=>{var a;const l=null!==(a=m.rows[e])&&void 0!==a?a:hpt(e),r={rows:(0,U.A)((0,U.A)({},m.rows),{},{[e]:(0,U.A)((0,U.A)({},l),t)})};u({accounts:n,draft:r}),i(Wut(r,f))},y=Wut(m,f);if((0,a.useEffect)((()=>{spt(y,l)||i(y)}),[y,l,i]),0===n.length)return a.createElement(fe.c8D,{"data-external-id":"account-purpose-field",size:"base",color:"secondary",className:"block"},Re.ONBOARDING_ACCOUNT_PURPOSE_EMPTY);const b=Kut(n),x=qut(n);return a.createElement("div",{"data-external-id":"account-purpose-field",className:"flex w-full flex-col gap-xs"},a.createElement(upt,{accounts:b,draft:m,question:t,onChangeRow:E}),x.length>0&&a.createElement(mpt,{accounts:x,draft:m,question:t,onChangeRow:E,onReveal:()=>v(!0)}))},upt=e=>{let t=e.accounts,n=e.draft,l=e.question,r=e.onChangeRow;return a.createElement("div",{"data-external-id":"account-purpose-list",className:"flex w-full flex-col gap-xs"},t.map((e=>{var t;const o=null!==(t=n.rows[e.id])&&void 0!==t?t:hpt(e.id);return a.createElement(ypt,{key:e.id,account:e,row:o,options:gpt(l,e,o.purposes),onChange:t=>r(e.id,t)}
1)})))},mpt=e=>{let t=e.accounts,n=e.draft,l=e.question,r=e.onChangeRow,i=e.onReveal;const s=(0,a.useState)(!1),c=(0,o.A)(s,2),d=c[0],u=c[1];return a.createElement(fe.X0s,{"data-external-id":"hidden-closed-accounts",open:d,onOpenChange:e=>{u(e),e&&i()},className:"flex flex-col gap-xs"},a.createElement(fe.X0s.Trigger,{render:a.createElement(fe.XZZ,{variant:"text",colorScheme:"secondary",size:"sm",className:"self-start",icon:d?a.createElement(fe.yhH,null):a.createElement(fe.N9s,null)},d?Re.ONBOARDING_COLLAPSE_TUCKED_ACCOUNTS(t.length):Re.ONBOARDING_SHOW_TUCKED_ACCOUNTS(t.length))}),a.createElement(fe.X0s.Content,null,a.createElement(upt,{accounts:t,draft:n,question:l,onChangeRow:r})))},ppt=e=>e.filter((e=>cpt.has(e))),gpt=(e,t,n)=>e.options.length>0?e.options.map((e=>{let t=e.value,n=e.label,a=e.subtitle;return{value:t,label:n,description:null!==a&&void 0!==a?a:void 0}})):(0,But.oc)({accountTypeName:t.typeName,selectedPurposes:ppt(n)}).map((e=>({value:e.value,label:e.label,description:e.description}))),hpt=e=>({accountId:e,purposes:[],interestRate:void 0}),vpt=e=>{let t=e.children;return a.createElement("div",{"data-external-id":"goal-banner",className:"w-full rounded-default bg-background-secondary px-default py-sm"},a.createElement(fe.c8D,{size:"sm",color:"primary"},t))},fpt=e=>{let t=e.goals;return a.createElement(vpt,{"data-external-id":"assigned-goals-banner"},Re.ONBOARDING_GOAL_ASSIGNED_LEAD," ",t.map(((e,n)=>a.createElement(a.Fragment,{key:e.id},n>0&&(n===t.length-1?" and ":", "),a.createElement(fe.liZ,{href:I.JZ.goals.savings.detail({id:e.id}),external:!0,size:"sm",weight:"medium"},e.name))))," ","goal",t.length>1?"s":"",".")},Ept=e=>{let t=e.prompt;return a.createElement(vpt,{"data-external-id":"goal-prompt-banner"},Re.ONBOARDING_GOAL_PROMPT_LEAD," ",t.article," ",t.label," ",Re.ONBOARDING_GOAL_PROMPT_TAIL," ",a.createElement(fe.liZ,{href:I.JZ.goals.savings.new.select(),external:!0,size:"sm"},Re.ONBOARDING_GOAL_PROMPT_LINK))},ypt=e=>{let t=e.account,n=e.row,l=e.options,r=e.onChange;const i=(0,a.useState)(null),s=(0,o.A)(i,2),c=s[0],d=s[1],u=(e=>e.fundedGoals.length>0?e.fundedGoals:e.linkedGoal?[e.linkedGoal]:[])(t),m=(0,But.Zj)(ppt(null!==c&&void 0!==c?c:n.purposes));return a.createElement("div",{"data-external-id":"account-purpose-row-card",className:" flex w-full flex-col gap-default rounded-default border border-border-primary bg-background-primary px-xl py-lg text-left "},a.createElement("div",{className:"flex items-center gap-sm"},a.createElement(Gl.v,{logoUrl:t.logoUrl,size:32}),a.createElement("div",{className:"flex min-w-0 flex-col gap-3xs"},a.createElement(fe.c8D,{size:"lg",className:"block truncate"},t.displayName),null!==t.displayBalance&&a.createElement(fe.c8D,{size:"sm",color:"secondary",className:"block truncate"},(e=>"Account balance: ".concat(e))((0,rl.fw)(t.displayBalance))))),u.length>0&&a.createElement(fpt,{goals:u}),0===u.length&&m&&a.createElement(Ept,{prompt:m}),a.createElement(fe.RVf.Root,{className:"w-full"},a.createElement(fe.RVf.Label,null,Re.ONBOARDING_ACCOUNT_PURPOSE_LABEL),a.createElement(fe.hGA,{multiple:!0,options:l,value:n.purposes,onValueChange:e=>r({purposes:[...e]}),onOpenChange:e=>d(e?n.purposes:null),placeholder:Re.ONBOARDING_ACCOUNT_PURPOSE_PLACEHOLDER})),(e=>(0,zut.kc)(e.typeName)&&!Gut.has(e.subtypeName))(t)&&a.createElement(fe.RVf.Root,{className:"w-37"},a.createElement(fe.RVf.Label,null,(e=>(0,zut.f_)(e.typeName))(t)?Re.ONBOARDING_ACCOUNT_SWEEP_LABEL:Re.ONBOARDING_ACCOUNT_APY_LABEL," ",a.createElement(fe.c8D,{size:"sm",color:"secondary"},Re.ONBOARDING_OPTIONAL)),a.createElement(fe.GhL,{value:void 0===n.interestRate?t.interestRate:n.interestRate,onValueChange:e=>r({interestRate:null!==e&&void 0!==e?e:null}),min:0,max:Omt,placeholder:Re.ONBOARDING_ACCOUNT_RATE_PLACEHOLDER})))};var bpt=n(95741);const xpt=a.createElement("img",{src:bpt,alt:"",className:"size-full object-cover"}),wpt="-mt-px",Cpt=e=>{let t=e.people,n=e.members,l=e.children;return a.createElement("div",{"data-external-id":"person-rows",className:"flex w-full flex-col"},t.map(((e,r)=>a.createElement("div",{key:e.rosterId,className:Ipt(Apt(r,t.length),"px-default py-default")},a.createElement(kpt,{person:e,members:n}),a.createElement("div",{className:"flex min-w-0 flex-1 flex-col"}
1,l(e))))))},Apt=(e,t)=>1===t?"only":0===e?"first":e===t-1?"last":"middle",Ipt=(e,t)=>(0,q.cn)("flex items-center gap-default border border-border-primary bg-background-primary","only"===e&&"rounded-lg","first"===e&&"rounded-t-lg","last"===e&&"".concat("rounded-b-lg"," ").concat(wpt),"middle"===e&&wpt,t),kpt=e=>{var t;let n=e.person,l=e.members,r=e.size,o=void 0===r?"sm":r;return a.createElement(fe.a6p,{"data-external-id":"person-avatar",size:o,src:null===(t=l.find((e=>e.id===n.userId)))||void 0===t?void 0:t.profilePictureUrl,name:n.name,fallback:xpt})},Spt="flex flex-wrap items-center gap-xs",Npt="w-19",Tpt=e=>{let t=e.question,n=e.people,l=e.members,r=e.labelNoun,o=e.value,i=e.onChange;return a.createElement("div",{"data-external-id":"employer-match-field",className:"flex w-full flex-col gap-xl"},n.map((e=>a.createElement(_pt,{key:e.rosterId,question:t,person:e,members:l,labelNoun:r,value:o,onChange:i}))))},_pt=e=>{let t=e.question,n=e.person,l=e.members,r=e.labelNoun,o=e.value,i=e.onChange;const s=Amt(o,n.rosterId),c=e=>i(Imt(o,n.rosterId,(0,U.A)((0,U.A)({},s),e))),d=mmt(n,r);return a.createElement("div",{"data-external-id":"person-match",className:"flex w-full flex-col gap-xs"},a.createElement("div",{className:"flex items-center gap-xs"},a.createElement(kpt,{person:n,members:l,size:"xs"}),a.createElement(fe.c8D,{size:"sm",weight:"medium"},d)),a.createElement(fe.GsR.Group,{className:"flex w-full flex-col gap-xs",value:s.matchType,onValueChange:e=>c({matchType:e}),"aria-label":"".concat(t.title," (").concat(d,")")},t.options.map((e=>a.createElement(fe.StI.Root,{key:e.value,value:e.value,size:"md",controlPosition:"start"},a.createElement(fe.StI.Header,null,a.createElement(fe.StI.Radio,null),a.createElement(fe.StI.HeaderText,null,a.createElement(fe.StI.Label,null,e.label),e.subtitle&&a.createElement(fe.StI.Description,null,e.subtitle))),Dpt(e.value)&&a.createElement(fe.StI.Body,{className:"border-t-0 ps-13 pt-0"},a.createElement(Mpt,{matchType:e.value,draft:s,onChange:c})))))))},Dpt=e=>e===ymt||e===bmt,Rpt=e=>e.includes(xmt)?xmt:wmt,Mpt=e=>{let t=e.matchType,n=e.draft,l=e.onChange;if(t===ymt)return a.createElement("div",{"data-external-id":"match-details",className:Spt},a.createElement(fe.c8D,{size:"base"},Re.ONBOARDING_MATCH_LEAD),a.createElement(fe.RVf.Root,{className:Npt},a.createElement(fe.RVf.Label,{className:"sr-only"},Re.ONBOARDING_MATCH_LEAD),a.createElement(fe.GhL,{size:"sm",value:n.matchPercent,onValueChange:e=>l({matchPercent:null!==e&&void 0!==e?e:null}),min:0,max:Omt,placeholder:Re.ONBOARDING_MATCH_PERCENT_PLACEHOLDER})),a.createElement(fe.c8D,{size:"base"},Re.ONBOARDING_MATCH_MID),a.createElement(fe.RVf.Root,{className:Npt},a.createElement(fe.RVf.Label,{className:"sr-only"},Re.ONBOARDING_MATCH_MID),a.createElement(fe.GhL,{size:"sm",value:n.upToPercent,onValueChange:e=>l({upToPercent:null!==e&&void 0!==e?e:null}),min:0,max:Omt,placeholder:Re.ONBOARDING_MATCH_UP_TO_PLACEHOLDER})),a.createElement(fe.c8D,{size:"base"},Re.ONBOARDING_MATCH_TAIL));const r=n.contributionUnit===xmt;return a.createElement("div",{"data-external-id":"match-details",className:Spt},a.createElement(fe.c8D,{size:"base"},Re.ONBOARDING_CONTRIBUTE_LEAD),a.createElement(fe.Mdh,{attached:!0,rounded:"pill",size:"sm",value:[n.contributionUnit],onValueChange:e=>l({contributionUnit:Rpt(e)}),"aria-label":Re.ONBOARDING_UNIT_LABEL},a.createElement(fe.ENt,{value:wmt,"aria-label":Re.ONBOARDING_UNIT_PERCENT},a.createElement(fe.$yZ,null)),a.createElement(fe.ENt,{value:xmt,"aria-label":Re.ONBOARDING_UNIT_DOLLARS},a.createElement(fe.ZR6,null))),a.createElement(fe.RVf.Root,{className:r?"w-25":Npt},a.createElement(fe.RVf.Label,{className:"sr-only"},Re.ONBOARDING_CONTRIBUTE_LEAD),r?a.createElement(fe.K$5,{size:"sm",value:n.contributionAmount,onValueChange:e=>l({contributionAmount:null!==e&&void 0!==e?e:null}),precision:0,min:0,placeholder:"$0"}):a.createElement(fe.GhL,{size:"sm",value:n.contributionAmount,onValueChange:e=>l({contributionAmount:null!==e&&void 0!==e?e:null}),min:0,max:Omt,placeholder:Re.ONBOARDING_CONTRIBUTE_PERCENT_PLACEHOLDER})),!r&&a.createElement(fe.c8D,{size:"base"},Re.ONBOARDING_CONTRIBUTE_TAIL))};var Lpt=n(8717);const Opt=e=>{let t=e.members,n=e.value,l=e.onChange,r=e.currentYear;const i=t,s=(0,a.useState)((()=>({members:i,draft:umt({members:i,answer:n,currentYear:r})}))),c=(0,o.A)(s,2),d=c[0],u=c[1];d.members!==i&&u({members:i,draft:umt({members:i,answer:n,currentYear:r})});const m=d.draft,p=pmt(m,r);(0,a.useEffect)((()=>{spt(p,n)||l(p)}),[p,n,l]);const g=e=>{u({members:i,draft:e}),l(pmt(e,r))},h=(e,t)=>g((0,U.A)((0,U.A)({},m),{},{adults:m.adults.map((n=>n.id===e?(0,U.A)((0,U.A)({},n),t):n))}));return a.createElement("div",{"data-external-id":"household-roster-field",className:"flex w-full flex-col"},a.createElement("div",{className:"flex w-full flex-col gap-xs"},a.createElement("div",{className:"flex flex-col gap-3xs"},a.createElement(fe.c8D,{size:"sm",weight:"medium"},Re.ONBOARDING_ROSTER_ADULTS),a.createElement(fe.c8D,{size:"base",color:"secondary"},Re.ONBOARDING_ROSTER_ADULTS_HELP)),a.createElement("div",{className:"flex items-center gap-default px-default pr-xl"},a.createElement("span",{className:"size-6 shrink-0"}),a.createElement("span",{className:"min-w-0 flex-1"}),a.createElement(fe.c8D,{size:"sm",weight:"medium",className:"w-45 shrink-0"},Re.ONBOARDING_ROSTER_BIRTHDAY),a.createElement(fe.c8D,{size:"sm",weight:"medium",className:"w-36 shrink-0"},Re.ONBOARDING_ROSTER_YEARLY_INCOME),a.createElement("span",{className:"size-9 shrink-0"})),a.createElement("div",{className:"flex w-full flex-col"},m.adults.map(((e,n)=>a.createElement(Ppt,{key:e.id,adult:e,member:t.find((t=>
1t.id===e.userId)),position:Apt(n,m.adults.length),currentYear:r,onChangeBirthDate:t=>h(e.id,{birthDate:t}),onChangeIncome:t=>h(e.id,{annualGrossIncome:t}),onChangeName:t=>h(e.id,{displayName:t}),onRemove:null===e.userId?()=>g((0,U.A)((0,U.A)({},m),{},{adults:m.adults.filter((t=>t.id!==e.id))})):void 0}))))),a.createElement(fe.XZZ,{variant:"default",size:"xs",className:"my-default self-start",onClick:()=>g((0,U.A)((0,U.A)({},m),{},{adults:[...m.adults,{id:nmt(),userId:null,displayName:"",birthDate:null,annualGrossIncome:null}]}))},Re.ONBOARDING_ROSTER_ADD_PARTNER),a.createElement("div",{className:"flex w-full flex-col gap-xs"},a.createElement("div",{className:"flex flex-col gap-3xs"},a.createElement(fe.c8D,{size:"sm",weight:"medium"},Re.ONBOARDING_ROSTER_DEPENDENTS," ",a.createElement(fe.c8D,{size:"sm",color:"secondary"},Re.ONBOARDING_OPTIONAL)),a.createElement(fe.c8D,{size:"base",color:"secondary"},Re.ONBOARDING_ROSTER_DEPENDENTS_HELP)),m.dependents.length>0&&a.createElement("div",{className:"flex items-center justify-end gap-default px-default pr-xl"},a.createElement(fe.c8D,{size:"sm",weight:"medium",className:"w-24 shrink-0"},Re.ONBOARDING_ROSTER_BIRTH_YEAR),a.createElement("span",{className:"size-9 shrink-0"})),m.dependents.length>0&&a.createElement("div",{className:"flex w-full flex-col"},m.dependents.map(((e,t)=>a.createElement(zpt,{key:e.id,dependent:e,position:Apt(t,m.dependents.length),currentYear:r,onChange:t=>((e,t)=>g((0,U.A)((0,U.A)({},m),{},{dependents:m.dependents.map((n=>n.id===e?(0,U.A)((0,U.A)({},n),{},{birthYear:t}):n))})))(e.id,t),onRemove:()=>g((0,U.A)((0,U.A)({},m),{},{dependents:m.dependents.filter((t=>t.id!==e.id))}))}))))),a.createElement(fe.XZZ,{variant:"default",size:"xs",className:"mt-default self-start",onClick:()=>g((0,U.A)((0,U.A)({},m),{},{dependents:[...m.dependents,{id:nmt(),birthYear:null}]}))},Re.ONBOARDING_ROSTER_ADD_DEPENDENT))},Ppt=e=>{let t=e.adult,n=e.member,l=e.position,r=e.currentYear,i=e.onChangeBirthDate,s=e.onChangeIncome,c=e.onChangeName,d=e.onRemove;const u=t.birthDate?((e,t)=>{if(!amt(e,t.getFullYear()))return null;const n=e.split("-").map(Number),a=(0,o.A)(n,3),l=a[0],r=a[1],i=a[2],s=t.getMonth()+1>r||t.getMonth()+1===r&&t.getDate()>=i;return t.getFullYear()-l-(s?0:1)})(t.birthDate,new Date):null,m=null===t.userId,p=t.displayName.trim()||tmt;return a.createElement("div",{"data-external-id":"adult-row",className:Ipt(l,"items-start px-default py-default pr-xl")},a.createElement(fe.a6p,{size:"sm",src:null===n||void 0===n?void 0:n.profilePictureUrl,name:p,fallback:xpt,className:"self-center"}),a.createElement("div",{className:"flex min-w-0 flex-1 flex-col gap-3xs"},m?a.createElement(fe.D_j,{size:"sm",value:t.displayName,onChange:e=>c(e.target.value),placeholder:Re.ONBOARDING_ROSTER_PARTNER_NAME_PLACEHOLDER,"aria-label":Re.ONBOARDING_ROSTER_PARTNER_NAME_LABEL}):a.createElement(fe.c8D,{size:"lg",className:"block truncate"},p),null!==u&&a.createElement(fe.c8D,{size:"xs",color:"secondary",className:"block truncate"},ze(u))),a.createElement(fe.RVf.Root,{className:"w-45 shrink-0"},a.createElement(fe.SdJ,null,a.createElement(fe.RVf.Label,null,(e=>"Date of birth for ".concat(e))(p))),a.createElement(fe.JTR.Root,{size:"sm",value:t.birthDate,onValueChange:i,dateFormat:"MMM d, yyyy",placeholder:Re.ONBOARDING_ROSTER_DATE_PLACEHOLDER,max:"".concat(r,"-12-31"),allowPlainLanguage:!0,openOnFocus:!1},a.createElement(Bpt,null))),a.createElement(fe.RVf.Root,{className:"w-36 shrink-0"},a.createElement(fe.SdJ,null,a.createElement(fe.RVf.Label,null,(e=>"Expected income this year for ".concat(e))(p))),a.createElement(fe.K$5,{size:"sm",value:t.annualGrossIncome,onValueChange:e=>s(null!==e&&void 0!==e?e:null),precision:0,min:0,max:emt,placeholder:"$"})),d?a.createElement(fe.SO$,{variant:"minimal",size:"sm",className:"shrink-0",tabIndex:-1,"aria-label":Re.ONBOARDING_ROSTER_REMOVE,onClick:d},a.createElement(fe.i01,null)):a.createElement("span",{className:"size-9 shrink-0"}))},Bpt=()=>{const e=(0,Lpt.zM)(),t=e.api,n=e.props;return a.createElement(a.Fragment,null,a.createElement(fe.i9A,Object.assign({}
1,t.getControlProps(),{size:n.size,invalid:n.invalid,disabled:n.disabled}),a.createElement(fe.JTR.Input,{placeholder:n.placeholder,"data-date-picker-anchor":""}),a.createElement(fe.i9A.Addon,{align:"inline-end"},a.createElement(fe.JTR.Trigger,{tabIndex:-1}))),a.createElement(fe.JTR.Content,null))},zpt=e=>{let t=e.dependent,n=e.position,l=e.currentYear,r=e.onChange,i=e.onRemove;const s=(0,a.useState)(null===t.birthYear?"":String(t.birthYear)),c=(0,o.A)(s,2),d=c[0],u=c[1],m=rmt(t.birthYear,l)?omt(t.birthYear,l):null,p=imt(t.birthYear,l);return a.createElement("div",{"data-external-id":"dependent-row",className:Ipt(n,"px-default py-default pr-xl")},a.createElement(fe.a6p,{size:"sm",name:p,fallback:xpt}),a.createElement("div",{className:"flex min-w-0 flex-1 flex-col gap-3xs"},a.createElement(fe.c8D,{size:"lg",className:"block truncate"},p),a.createElement(fe.c8D,{size:"xs",color:"secondary",className:"block truncate"},null===m?Re.ONBOARDING_ROSTER_UNKNOWN_AGE:ze(m))),a.createElement(fe.D_j,{size:"sm",className:"w-24 shrink-0 text-left",value:d,onChange:e=>{const t=e.target.value.replace(/\D/g,"").slice(0,4);u(t),r(4===t.length?Number(t):null)},inputMode:"numeric",maxLength:4,placeholder:Re.ONBOARDING_ROSTER_YEAR_PLACEHOLDER,"aria-label":Be(p)}),a.createElement(fe.SO$,{variant:"minimal",size:"sm",className:"shrink-0",tabIndex:-1,"aria-label":Re.ONBOARDING_ROSTER_REMOVE,onClick:i},a.createElement(fe.i01,null)))},Fpt=e=>{let t=e.question,n=e.value,l=e.onChange;const r=Rmt(n);return a.createElement(fe.GsR.Group,{"data-external-id":"mortgage-rate-field",className:"flex w-full flex-col gap-xs",value:r.rateType,onValueChange:e=>l(((e,t)=>{const n=Tmt(e,_mt,t);return Mmt(t)?n:Tmt(n,Dmt,null)})(n,e)),"aria-label":t.title},t.options.map((e=>a.createElement(fe.StI.Root,{key:e.value,value:e.value,size:"md",controlPosition:"start"},a.createElement(fe.StI.Header,null,a.createElement(fe.StI.Radio,null),a.createElement(fe.StI.HeaderText,null,a.createElement(fe.StI.Label,null,e.label),e.subtitle&&a.createElement(fe.StI.Description,null,e.subtitle))),Mmt(e.value)&&a.createElement(fe.StI.Body,{className:"border-t-0 ps-13 pt-0"},a.createElement(Gpt,{isAdjustable:"adjustable"===e.value,value:r.apr,onChange:e=>l(((e,t)=>Tmt(e,Dmt,t))(n,e))}))))))},Gpt=e=>{let t=e.isAdjustable,n=e.value,l=e.onChange;return a.createElement(fe.RVf.Root,{"data-external-id":"apr-field",className:"w-full"},a.createElement(fe.RVf.Label,null,t?Re.ONBOARDING_CURRENT_RATE_LABEL:Re.ONBOARDING_RATE_LABEL," ",a.createElement(fe.c8D,{size:"sm",color:"secondary"},Re.ONBOARDING_OPTIONAL)),a.createElement("div",{className:"w-25"},a.createElement(fe.GhL,{size:"sm",value:n,onValueChange:e=>l(null!==e&&void 0!==e?e:null),min:0,max:Omt,placeholder:Re.ONBOARDING_RATE_PLACEHOLDER})),a.createElement(fe.RVf.Description,null,t?Re.ONBOARDING_CURRENT_RATE_HELP:Re.ONBOARDING_RATE_HELP))},Ypt=e=>{let t=e.options,n=e.value,l=e.onChange,r=e.exclusiveOptions,o=void 0===r?[]:r;return a.createElement("div",{"data-external-id":"multi-select-field",className:"flex w-full flex-col gap-sm"},t.map((e=>{var t;return a.createElement(fe.yNK,{key:e.value,checked:n.includes(e.value),onCheckedChange:t=>l(((e,t,n,a)=>{if(!n)return e.filter((e=>e!==t));if(a.includes(t))return[t];const l=e.filter((e=>!a.includes(e)));return l.includes(t)?l:[...l,t]})(n,e.value,t,o)),label:e.label,description:null!==(t=e.subtitle)&&void 0!==t?t:void 0,controlPosition:"start",className:"text-left"})})))},Upt=e=>{let t=e.question,n=e.people,l=e.members,r=e.field,o=e.labelNoun,i=e.seeded,s=e.value,c=e.onChange;const d=(0,a.useMemo)((()=>t.options.map((e=>{let t=e.value,n=e.label,a=e.subtitle;return{value:t,label:n,description:null!==a&&void 0!==a?a:void 0}}))),[t.options]),u=(0,a.useMemo)((()=>d.map((e=>e.value))),[d]);(0,a.useEffect)((()=>{const e=n.map((e=>{var t;return{person:e,seed:Jmt(null===(t=l.find((t=>t.id===e.userId)))||void 0===t?void 0:t.employmentStatus,u)}})).filter((e=>{let t=e.person;return e.seed.length>0&&!i.has(t.rosterId)&&0===fmt(s,t.rosterId,r).length}));if(e.length>0){const t=e.reduce(((e,t)=>{let n=t.person,a=t.seed;return i.add(n.rosterId),vmt(e,n.rosterId,{[r]:a})}),gmt(s));c(t)}}),[n,l,u,r,i,s,c]);return a.createElement(Cpt,{"data-external-id":"roster-multi-select-field",people:n,members:l},(e=>a.createElement(fe.RVf.Root,{className:"w-full gap-xs"},a.createElement(fe.RVf.Label,null,mmt(e,o)),a.createElement(fe.hGA,{multiple:!0,options:d,value:fmt(s,e.rosterId,r),onValueChange:n=>((e,n)=>{const a=((e,t,n)=>{const a=t.filter((t=>!e.includes(t))),l=a.find((e=>n.includes(e)));return l?[l]:a.length>0?t.filter((e=>!n.includes(e))):[...t]})(fmt(s,e,r),n,t.exclusiveOptions);c(vmt(s,e,0===a.length?null:{[r]:a}))})(e.rosterId,n),placeholder:Re.ONBOARDING_ROSTER_MULTI_SELECT_PLACEHOLDER}))))},Vpt=e=>{let t=e.options,n=e.value,l=e.onChange;return a.createElement(fe.GsR.Group,{"data-external-id":"single-select-field",value:null!==n&&void 0!==n?n:"",onValueChange:e=>l(String(e)),className:"flex w-full flex-col gap-sm"},t.map((e=>{var t;return a.createElement(fe.StI,{key:e.value,value:e.value,label:e.label,description:null!==(t=e.subtitle)&&void 0!==t?t:void 0,controlPosition:"start",className:"text-left"})})))},Wpt=e=>
1{let t=e.value,n=e.onChange;const l=(0,a.useState)((()=>t.length>0)),r=(0,o.A)(l,2),i=r[0],s=r[1],c=i&&t.length>0&&!Lmt.test(t);return a.createElement(fe.RVf.Root,{"data-external-id":"zip-code-field",className:"w-46",invalid:c},a.createElement(fe.D_j,{autoFocus:!0,value:t,onChange:e=>n(e.target.value.trim()),onBlur:()=>s(!0),inputMode:"numeric",autoComplete:"postal-code",maxLength:10,placeholder:Re.ONBOARDING_ZIP_PLACEHOLDER,"aria-label":Re.ONBOARDING_ZIP_LABEL}),c&&a.createElement(fe.RVf.Error,null,Re.ONBOARDING_ZIP_ERROR))},jpt=e=>{let t=e.entry,n=e.draft,l=e.members,r=e.people,o=e.accounts,i=e.seedLedger,s=e.currentYear,c=e.assistantColor,d=e.onChange;return a.createElement("div",{"data-external-id":"today-question-step",className:"flex w-full flex-col"},a.createElement("div",{className:"mb-2xl flex w-full flex-col items-center gap-xs text-center"},a.createElement(he,{color:c,size:60,state:"inquiring",className:"mt-3xl"}),a.createElement(Out,null,t.question.title),t.question.subtitle&&a.createElement(fe.c8D,{size:"base",color:"secondary",className:"block w-full"},t.question.subtitle)),a.createElement(qpt,{entry:t,draft:n,members:l,people:r,accounts:o,seedLedger:i,currentYear:s,assistantColor:c,onChange:d}))},Hpt=e=>"string"===typeof e?e:"",Kpt=e=>Array.isArray(e)?e.filter((e=>"string"===typeof e)):[],qpt=e=>{let t=e.entry,n=e.draft,l=e.members,o=e.people,i=e.accounts,s=e.seedLedger,c=e.currentYear,d=e.onChange;const u=t.question,m=n.answer,p=Emt(u),g=(0,a.useMemo)((()=>s.scopedTo("".concat(u.name,":").concat(null!==p&&void 0!==p?p:""))),[s,u.name,p]),h=(0,r.YW)(u.presentation).with(Ee._mz.HOUSEHOLD_ROSTER,(()=>a.createElement(Opt,{members:l,value:m,onChange:d,currentYear:c}))).with(Ee._mz.CURRENCY,(()=>a.createElement(a.Fragment,null))).with(Ee._mz.ZIP_CODE,(()=>a.createElement(Wpt,{value:Hpt(m),onChange:d}))).with(Ee._mz.MORTGAGE_RATE,(()=>a.createElement(Fpt,{question:u,value:m,onChange:d}))).with(Ee._mz.EMPLOYER_MATCH,(()=>a.createElement(Tpt,{question:u,people:o,members:l,labelNoun:Re.ONBOARDING_EMPLOYER_MATCH_NOUN,value:m,onChange:d}))).with(Ee._mz.ACCOUNT_PURPOSE,(()=>a.createElement(dpt,{question:u,accounts:i,value:m,savedAnswer:Qmt(t),onChange:d}))).otherwise((()=>null));return h||(0,r.YW)(u.questionType).with(Ee.SQ2.SINGLE_SELECT,(()=>a.createElement(Vpt,{options:u.options,value:"string"===typeof m?m:null,onChange:d}))).with(Ee.SQ2.MULTI_SELECT,(()=>a.createElement(Ypt,{options:u.options,exclusiveOptions:u.exclusiveOptions,value:Kpt(m),onChange:d}))).with(Ee.SQ2.LIST,(()=>p?a.createElement(Upt,{question:u,people:o,members:l,field:p,labelNoun:Re.ONBOARDING_INCOME_TYPE_NOUN,seeded:g,value:m,onChange:d}):null)).otherwise((()=>null))},$pt=e=>{let t=e.assistantColor,n=e.onRetry;return a.createElement("div",{"data-external-id":"today-questions-error",className:"flex w-full flex-col gap-default"},a.createElement("div",{className:"flex flex-col gap-xs"},a.createElement(he,{color:t,size:60,state:"error",className:"mt-3xl self-start"}),a.createElement(Out,null,Re.ONBOARDING_QUESTIONS_ERROR_TITLE),a.createElement(fe.c8D,{color:"secondary"},Re.ONBOARDING_QUESTIONS_ERROR_BODY)),a.createElement(fe.XZZ,{className:"mt-2xl self-start",variant:"primary",size:"md",onClick:n},Re.ONBOARDING_QUESTIONS_RETRY))},Zpt=()=>{var e;const t=(0,a.useRef)(null);return null!==(e=t.current)&&void 0!==e||(t.current=(()=>{const e=new Set;return{scopedTo:t=>({has:n=>e.has("".concat(t,":").concat(n)),add:n=>{e.add("".concat(t,":").concat(n))}})}})()),t.current},Jpt=((0,Qt.J)("\n  fragment Common_QuestionnaireQuestionEntryFields on QuestionnaireQuestionState {\n    question {\n      name\n      scope\n      questionType\n      presentation\n      itemFields\n      structuredFields\n      title\n      subtitle\n      options {\n        value\n        label\n        subtitle\n      }\n      exclusiveOptions\n      branch {\n        parentQuestionName\n        whenAnyOf\n      }\n    }\n    answer {\n      questionName\n      answer\n      dontKnow\n      answeredAt\n      expiresAt\n    }\n    isAnswered\n    isFresh\n    isDue\n  }\n"),(0,Qt.J)("\n  fragment Common_QuestionnaireStateFields on QuestionnaireState {\n    name\n    questions {\n      ...Common_QuestionnaireQuestionEntryFields\n    }\n  }\n"),(0,Qt.J)("\n  query Common_QuestionnaireState($questionnaireName: QuestionnaireNameEnum!) {\n    questionnaireState(questionnaireName: $questionnaireName) {\n      ...Common_QuestionnaireStateFields\n    }\n  }\n")),Xpt=(0,Qt.J)("\n  mutation Common_SubmitQuestionnaireAnswer($input: SubmitQuestionnaireAnswerInput!) {\n    submitQuestionnaireAnswer(input: $input) {\n      answer {\n        questionName\n        answer\n        dontKnow\n        answeredAt\n        expiresAt\n      }\n      questionnaireState {\n        ...Common_QuestionnaireStateFields\n      }\n    }\n  }\n"),Qpt=()=>!1,egt=e=>{let t=e.questionnaireName,n=e.context,l=e.isPaused,r=void 0!==l&&l,s=e.isDisabled,c=void 0!==s&&s,d=e.isOptional,u=void 0===d?Qpt:d;var m,p;const g=function(e){let t=(arguments.length>1&&void 0!==arguments[1]?arguments[1]:{}).skip,n=void 0!==t&&t;var l;const r=(0,et.I)(Jpt,{variables:{questionnaireName:e},fetchPolicy:"cache-and-network",skip:n}
1),s=r.data,c=r.isLoadingInitialData,d=r.isNetworkRequestInFlight,u=r.error,m=r.refetch,p=(0,a.useState)(null),g=(0,o.A)(p,2),h=g[0],v=g[1],f=null!==(l=null!==h&&void 0!==h?h:null===s||void 0===s?void 0:s.questionnaireState)&&void 0!==l?l:null,E=(0,i.n)(Xpt),y=(0,o.A)(E,2),b=y[0],x=y[1].loading,w=(0,a.useCallback)((async t=>{let n=t.questionName,a=t.answer;var l,r;const o=t.dontKnow?{questionnaireName:e,questionName:n,dontKnow:!0}:{questionnaireName:e,questionName:n,answer:null!==a&&void 0!==a?a:null},i=await b({variables:{input:o},update:(t,n)=>{let a=n.data;var l;const r=null===(l=null===a||void 0===a?void 0:a.submitQuestionnaireAnswer)||void 0===l?void 0:l.questionnaireState;r&&t.writeQuery({query:Jpt,variables:{questionnaireName:e},data:{__typename:"Query",questionnaireState:r}})}}),s=null===(r=null===(l=i.data)||void 0===l?void 0:l.submitQuestionnaireAnswer)||void 0===r?void 0:r.questionnaireState;if(!s)throw new Error("submitQuestionnaireAnswer returned no questionnaire state");return v(s),s}),[e,b]);return{state:f,isLoadingInitialData:c&&null===f,isNetworkRequestInFlight:d,hasSettledState:null!==h||!d&&!u,isSubmitting:x,error:u,refetch:m,submitAnswer:w}}(t,{skip:c}),h=g.state,v=g.hasSettledState,f=g.isSubmitting,E=g.error,y=g.refetch,b=g.submitAnswer,x=(0,a.useState)(null),w=(0,o.A)(x,2),C=w[0],A=w[1],I=(0,a.useState)("due"),k=(0,o.A)(I,2),S=k[0],N=k[1],T=(0,a.useState)([]),_=(0,o.A)(T,2),D=_[0],R=_[1],M=(0,a.useState)({}),L=(0,o.A)(M,2),O=L[0],P=L[1],B=(0,a.useRef)(new Set),z=Zpt(),F=(0,a.useMemo)((()=>(e=>{var t;return(null!==(t=null===e||void 0===e?void 0:e.questions)&&void 0!==t?t:[]).reduce(((e,t)=>{let n=t.question,a=t.answer;return a?(0,U.A)((0,U.A)({},e),{},{[n.name]:{answer:a.answer,dontKnow:a.dontKnow}}):e}),{})})(h)),[h]),G=(0,a.useMemo)((()=>(0,U.A)((0,U.A)({},F),O)),[F,O]),Y=(0,a.useMemo)((()=>{var e,t;const a=((e,t)=>null===e||void 0===e?void 0:e.questions.find((e=>e.question.presentation===t)))(h,Ee._mz.HOUSEHOLD_ROSTER),l=a&&null!==(t=null===(e=G[a.question.name])||void 0===e?void 0:e.answer)&&void 0!==t?t:null;return r=l,o=n.members,i=n.currentYear,umt({members:o,answer:r,currentYear:i}).adults.map((e=>({rosterId:e.id,userId:e.userId,name:e.displayName.trim()||tmt,isMe:o.some((t=>t.id===e.userId&&!0===t.isMe))})));var r,o,i}),[h,G,n.members,n.currentYear]);(0,a.useEffect)((()=>{if(null!==C||null===h||!v||r)return;const e=rpt(h,F,Y),t=null!==e&&void 0!==e?e:((e,t,n)=>{var a,l;return null!==(l=null===(a=apt(e,t,n)[0])||void 0===a?void 0:a.question.name)&&void 0!==l?l:null})(h,F,Y);N(null===e?"all":"due"),A({name:t}),R(((e,t,n,a)=>{if(!n)return[];const l=apt(e,t,a),r=l.findIndex((e=>e.question.name===n));return r<=0?[]:l.slice(0,r).map((e=>e.question.name))})(h,F,t,Y))}),[C,h,v,F,r,Y]);const V=null!==(m=null===C||void 0===C?void 0:C.name)&&void 0!==m?m:null,W=null!==(p=((e,t)=>t?null===e||void 0===e?void 0:e.questions.find((e=>e.question.name===t)):void 0)(h,V))&&void 0!==p?p:null,j=(0,a.useMemo)((()=>W?Xmt(W.question,Y,G):Y),[W,Y,G]),H=(0,a.useMemo)((()=>(0,U.A)((0,U.A)({},n),{},{people:j})),[n,j]),K=(0,a.useMemo)((()=>{var e,t,n;return W?null!==(t=null!==(e=O[W.question.name])&&void 0!==e?e:F[W.question.name])&&void 0!==t?t:{answer:(n=W.question,n.questionType===Ee.SQ2.PER_USER||n.questionType===Ee.SQ2.STRUCTURED?{}:n.questionType===Ee.SQ2.LIST||n.questionType===Ee.SQ2.MULTI_SELECT?[]:null),dontKnow:!1}:null}),[W,O,F]),q=(0,a.useCallback)((e=>{V&&P((t=>(0,U.A)((0,U.A)({},t),{},{[V]:{answer:e,dontKnow:!1}})))}),[V]),$=(0,a.useCallback)((async(e,t)=>lpt(e,t,Y).reduce((async(e,t)=>{const n=await e;return{state:await b({questionName:t,dontKnow:!0}),skipped:(0,U.A)((0,U.A)({},n.skipped),{},{[t]:{answer:null,dontKnow:!0}})}}),Promise.resolve({state:e,skipped:{}}))),[Y,b]),Z=(0,a.useCallback)((async(e,t,n)=>{const a=await $(n,t),l=a.state,r=a.skipped,o=(0,U.A)((0,U.A)({},t),r),i="all"===S?((e,t,n,a)=>opt(e,n,(e=>tpt(e.question,t,a))))(l,o,e,Y):((e,t,n,a)=>opt(e,n,(e=>npt(e,t,a))))(l,o,e,Y);P((e=>(0,U.A)((0,U.A)({},e),r))),R((t=>[...t,e])),A({name:i})}),[S,$,Y]),J=(0,a.useMemo)((()=>{return!(!W||!K)&&(Wmt(W,K,H)||u(W)&&(e=K.answer,Vmt(e)));var e}),[W,K,u,H]),X=(0,a.useCallback)((async()=>
1{if(!W||!K||f||!J)return;const e=W.question,t=e.name,n=K.dontKnow||!Wmt(W,K,H),a=n?{answer:null,dontKnow:!0}:{answer:Pmt(e,K.answer,j),dontKnow:!1},l=n?await b({questionName:t,dontKnow:!0}):await b({questionName:t,answer:a.answer});P((e=>(0,U.A)((0,U.A)({},e),{},{[t]:a}))),await Z(t,(0,U.A)((0,U.A)({},G),{},{[t]:a}),l)}),[W,K,f,J,H,b,Z,G,j]),Q=(0,a.useCallback)((()=>{R((e=>{const t=e[e.length-1];return void 0!==t&&(N("all"),A({name:t})),e.slice(0,-1)}))}),[]);(0,a.useEffect)((()=>{if(null===C||!v||r||f||null===h)return;if(null!==rpt(h,G,Y))return;const e=lpt(h,G,Y).filter((e=>!B.current.has(e)));0!==e.length&&(e.forEach((e=>B.current.add(e))),$(h,G).then((e=>{let t=e.skipped;P((e=>(0,U.A)((0,U.A)({},e),t)))})).catch((()=>{})))}),[C,v,r,f,h,G,Y,$]);const ee=(0,a.useMemo)((()=>{const e=apt(h,G,Y),t=e.findIndex((e=>e.question.name===V));return{current:t<0?e.length:t+1,total:e.length}}),[h,G,V,Y]),te=Boolean(E&&(0,Vte.sn)(E.graphQLErrors,Ee.O4y.UNAUTHORIZED)),ne=v&&null===h,ae=(0,a.useCallback)((()=>{y()}),[y]);return{entry:W,draft:K,answers:G,setAnswer:q,people:j,seedLedger:z,canSubmit:J,submit:X,goBack:Q,canGoBack:D.length>0,isLoading:!c&&(r||!v&&!E),isSubmitting:f,isFinished:null!==C&&null===C.name,isUnavailable:c||te||ne,hasLoadError:Boolean(E)&&!te,retry:ae,error:E,progress:ee}};var tgt=n(19571);const ngt=function(){let e=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}).skip,t=void 0!==e&&e;var n,l;const r=(0,et.I)(but.dI,{fetchPolicy:"cache-first",skip:t}),o=r.data,i=r.isLoadingInitialData,s=r.error,c=r.refetch,d=null===(n=null===o||void 0===o?void 0:o.myHousehold)||void 0===n?void 0:n.users,u=null===(l=null===o||void 0===o?void 0:o.me)||void 0===l?void 0:l.id,m=(0,a.useMemo)((()=>((e,t)=>e.map((e=>{let n=e.id,a=e.name,l=e.displayName,r=e.profilePictureUrl,o=e.financialProfile;var i,s,c;return{id:n,name:l||a,birthday:null!==(i=null===o||void 0===o?void 0:o.birthday)&&void 0!==i?i:null,profilePictureUrl:null!==r&&void 0!==r?r:null,isMe:n===t,grossAnnualIncome:null!==(s=null===o||void 0===o?void 0:o.grossAnnualIncome)&&void 0!==s?s:null,employmentStatus:null!==(c=null===o||void 0===o?void 0:o.employmentStatus)&&void 0!==c?c:null}})).sort(((e,t)=>Number(t.isMe)-Number(e.isMe))))(null!==d&&void 0!==d?d:[],u)),[d,u]);return{members:m,isLoading:!t&&i,error:s,refetch:c}},agt=e=>{let t=e.isEligible,n=e.isSplitReady,l=e.hasMonarchMethod;const r=n&&!t,o=n&&!r,i=ngt({skip:!o}),s=i.members,c=i.isLoading,d=i.error,u=i.refetch,m=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.skip,n=void 0!==t&&t,l=e.canReadSavedPurposes,r=void 0!==l&&l;const o=(0,et.I)(but.Ir,{fetchPolicy:"cache-and-network",skip:n}),i=o.data,s=o.isLoadingInitialData,c=o.error,d=o.refetch,u=(0,et.I)($Le.s,{fetchPolicy:"cache-and-network",skip:n||!r}),m=u.data,p=u.isLoadingInitialData,g=u.error,h=u.refetch,v=(0,et.I)($Le.Yk,{fetchPolicy:"cache-and-network",skip:n}),f=v.data,E=v.isLoadingInitialData,y=v.refetch,b=(0,a.useCallback)((()=>Promise.all([d(),r?h():null,y()])),[r,d,h,y]),x=(0,a.useMemo)((()=>{var e,t,n;const a=new Map((null!==(e=null===m||void 0===m?void 0:m.monarchMethodAccountSettings)&&void 0!==e?e:[]).map((e=>[e.accountId,e.purposes]))),l=(0,tgt.g$)(null!==(t=null===f||void 0===f?void 0:f.savingsGoals)&&void 0!==t?t:[]),r=l.purposesByAccountId,o=l.goalsByAccountId;return{suggestedPurposes:Object.fromEntries((null!==(n=null===i||void 0===i?void 0:i.accounts)&&void 0!==n?n:[]).map((e=>{var t,n;const l=null!==(t=a.get(e.id))&&void 0!==t?t:[];if(l.length>0)return[e.id,l];const o=Boolean(e.isHidden)||jut(e),i=g||o?[]:(0,But.bw)({accountTypeName:e.type.name,accountSubtypeName:e.subtype.name,derivedPurposes:(0,But.EW)(null!==(n=r[e.id])&&void 0!==n?n:[],e.linkedGoal)});return[e.id,i]}))),fundedGoals:o}}),[null===i||void 0===i?void 0:i.accounts,m,g,f]),w=x.suggestedPurposes,C=x.fundedGoals;return{accounts:(0,a.useMemo)((()=>{var e;return $ut(null!==(e=null===i||void 0===i?void 0:i.accounts)&&void 0!==e?e:[],{suggestedPurposes:w,fundedGoals:C})}),[null===i||void 0===i?void 0:i.accounts,w,C]),isLoading:!n&&(s||p||E),error:c,hasUnreadSavedPurposes:Boolean(g),refetch:b}}({skip:!o,canReadSavedPurposes:l}),p=m.accounts,g=m.isLoading,h=m.error,v=m.hasUnreadSavedPurposes,f=m.refetch,E=(0,a.useMemo)((()=>({members:s,accounts:p,currentYear:(new Date).getFullYear()})),[s,p]),y=(0,a.useCallback)((e=>function(e,t){let n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return e.presentation===Ee._mz.ACCOUNT_PURPOSE&&(0===Kut(t).length||n)}(e.question,p,v)),[p,v]),b=egt({questionnaireName:Ee.CS3.TODAY_ONBOARDING,context:E,isPaused:!n||c||g,isDisabled:r,isOptional:y}),x=b.hasLoadError,w=b.retry,C=(0,a.useCallback)((()=>{x&&w(),d&&u(),h&&f()}),[x,w,d,u,h,f]);return{runner:(0,U.A)((0,U.A)({},b),{},{hasLoadError:x||Boolean(d)||Boolean(h)&&0===p.length,retry:C}),members:s,accounts:p,refetchAccounts:f}},lgt=e=>{var t,n,i;let s=e.onClose,c=e.onComplete;const d=(0,C.RU)(),u=at(),m=u.assistantName,p=u.assistantColor,g=u.isLoadingProfile,h=xut(),v=h.hasCompletedOnboarding,f=h.isPending,E=(0,a.useState)("questions"),y=(0,o.A)(E,2),b=y[0],x=y[1],w=(()=>{const e=(0,ot.M)(),t=e.isOn,n=e.isReady,a=(0,d4.u)("feat-monarch-method-web","off").isOn;return agt({isEligible:t,isSplitReady:n,hasMonarchMethod:a})})(),A=w.runner,I=w.members,k=w.accounts;(e=>{const t=(0,l.zy)(),n=t.pathname,r=t.search,o=(0,a.useRef)(null);(0,a.useEffect)((()=>{e&&e!==o.current&&(o.current=e,(0,Ge.SB)(n,r,"Monarch | ".concat(Re.PAGE_TITLE),Ye.M9,void 0,{step:e}))}),[n,r,e])})((e=>{let t=e.phase,n=e.questionName;return"questions"===t&&n?Te(n):null})({phase:b,questionName:null===(t=A.entry)||void 0===t?void 0:t.question.name}));const S=null!==p&&void 0!==p?p:ge.fB,N=(null===m||void 0===m?void 0:m.trim())||ge.Uk,T=(0,a.useRef)(!1),_=(0,a.useRef)(null),D=(0,a.useRef)(null);D.current=((e,t,n)=>null!==e||t?e:!n)(D.current,f,v);const R=(0,a.useCallback)((()=>{T.current||(T.current=!0,null===c||void 0===c||c(),x("loading"))}),[c]);(0,a.useEffect)((()=>{"questions"===b&&(A.isFinished?R():A.isUnavailable&&s())}
1),[R,s,b,A.isFinished,A.isUnavailable]);const M=()=>{A.isSubmitting||(A.canSubmit?A.submit().then(s).catch((()=>d({description:Re.ONBOARDING_QUESTION_ERROR}))):s())},L=()=>{A.canGoBack&&A.goBack()},O="questions"===b,P=O&&!g&&!A.hasLoadError&&null!==A.entry&&null!==A.draft,B=null!==(n=null===(i=A.entry)||void 0===i?void 0:i.question.name)&&void 0!==n?n:b;(0,a.useLayoutEffect)((()=>{var e;null===(e=_.current)||void 0===e||e.scrollTo(0,0)}),[B]);const z=A.isUnavailable?0:A.progress.total,F=O&&A.canGoBack;return a.createElement(fe.hg1.Root,{"data-external-id":"today-onboarding",open:!0,onOpenChange:e=>{e||s()},size:"full"},a.createElement(fe.hg1.Content,{showBackdrop:!1,className:"flex flex-col bg-background-primary shadow-none"},a.createElement(fe.hg1.Title,{className:"sr-only"},Re.ONBOARDING_DIALOG_LABEL),(0,r.YW)({phase:b,isLoadingProfile:g}).with({phase:"loading",isLoadingProfile:!0},(()=>a.createElement(fe.ix7,{className:"mx-auto my-3xl",label:Re.ONBOARDING_PROGRESS}))).with({phase:"loading"},(()=>a.createElement(Rut,{color:S,displayName:N,accountCount:k.length,onCheckItOut:()=>{D.current&&(0,Ge.u4)(Ye.xb.AssistantSetupFlowCompleted),s()}}))).otherwise((()=>a.createElement(a.Fragment,null,a.createElement("header",{className:" relative flex h-16 shrink-0 items-center justify-between bg-background-primary px-xl shadow-lg "},F?a.createElement(fe.SO$,{variant:"minimal","aria-label":Re.ONBOARDING_BACK,disabled:A.isSubmitting,onClick:L},a.createElement(fe.qzE,{size:"lg"})):a.createElement("span",{className:"size-9"}),a.createElement(fe.TU1,{variant:"minimal","aria-label":Re.ONBOARDING_CLOSE,onClick:s}),!A.isLoading&&z>1&&a.createElement(fe.cqk,{value:A.progress.current,max:z,size:"2xs",variant:"squared",color:"content-brand","aria-label":Re.ONBOARDING_PROGRESS,trackBgColor:"transparent",className:"absolute inset-x-0 -bottom-0.5"})),a.createElement("div",{ref:_,className:"flex min-h-0 flex-1 flex-col overflow-y-auto"},O&&(g?a.createElement(fe.ix7,{className:"mx-auto my-3xl",label:Re.ONBOARDING_PROGRESS}):a.createElement("form",{className:"mx-auto flex w-full max-w-180 flex-1 flex-col px-4xl pb-3xl",onSubmit:e=>e.preventDefault()},(0,r.YW)({hasLoadError:A.hasLoadError,entry:A.entry,draft:A.draft}).with({hasLoadError:!0},(()=>a.createElement($pt,{assistantColor:S,onRetry:A.retry}))).with({entry:r.P.nonNullable,draft:r.P.nonNullable},(e=>{let t=e.entry,n=e.draft;return a.createElement(jpt,{key:t.question.name,entry:t,draft:n,members:I,people:A.people,accounts:k,seedLedger:A.seedLedger,currentYear:(new Date).getFullYear(),assistantColor:S,onChange:A.setAnswer})})).otherwise((()=>a.createElement(fe.ix7,{className:"mx-auto my-3xl",label:Re.ONBOARDING_PROGRESS})))))),P&&a.createElement("footer",{className:" flex h-20 shrink-0 items-center justify-center bg-background-primary px-default shadow-upcast "},a.createElement(_ut,{nextLabel:Re.ONBOARDING_NEXT,onNext:()=>{(0,A.submit)().catch((()=>d({description:Re.ONBOARDING_QUESTION_ERROR})))},onSaveAndClose:M,hasCompletedOnboarding:v,isLoading:A.isSubmitting,disabled:!A.canSubmit||A.isLoading,saveDisabled:A.isSubmitting})))))))},rgt=()=>{const e=(0,l.Zp)(),t=(0,C.RU)(),n=at().save,r=(0,a.useRef)(!0);(0,a.useEffect)((()=>()=>{r.current=!1}),[]);const o=(0,a.useCallback)((()=>{r.current&&e(I.JZ.today(),{replace:!0})}),[e]),i=(0,a.useCallback)((()=>{n(void 0,{completeOnboarding:!0}).catch((()=>t()))}),[n,t]);return a.createElement(lgt,{"data-external-id":"today-onboarding-route",onClose:o,onComplete:i})},ogt=()=>{const e=(0,Qm.Eo)(),t=e.isChatOpen,n=e.isChatMinimized,l=e.restoreSupportChat,r=(0,d.d4)(A.XT),o=(0,d.d4)(A.Le);return t&&n?r&&o?null:a.createElement(sm,{"data-external-id":"minimized-support-chat-button",surface:"supportChat",ariaLabel:"Restore support chat",onClick:l}):null},igt=()=>{const e=(0,Tse._)().shouldShowBanner,t=(0,R3.F)(),n=t.isOn,o=t.canToggleVersions,i=t.status,s=n||o;return a.createElement(VY.V,{"data-external-id":"in-app-routes"},a.createElement(mt,null,e&&a.createElement(S7,null),a.createElement(pce,null),a.createElement(l.BV,null,a.createElement(l.qh,{index:!0,element:a.createElement(l.C5,{to:I.JZ.dashboard(),replace:!0})}),a.createElement(l.qh,{path:"/request-feature",element:a.createElement(l.C5,{to:"".concat(I.JZ.dashboard(),"/request-feature"),replace:!0})}),a.createElement(l.qh,{path:I.JZ.roadmap.path,element:a.createElement(OY,{name:"feat-voltron-feedback-web_mobile",defaultOnTimeout:"off"},a.createElement(x3e,null))}),a.createElement(l.qh,{path:"/billing",element:a.createElement(l.C5,{to:I.JZ.settings.billing(),replace:!0})}),a.createElement(l.qh,{path:"/net-worth",element:a.createElement(l.C5,{to:I.JZ.accounts.path,replace:!0})}),a.createElement(l.qh,{path:"".concat(I.JZ.accounts.accountDetails.path,"/*"),element:a.createElement(SV,null)}),a.createElement(l.qh,{path:I.JZ.categories.path,element:a.createElement(i0,null)}),a.createElement(l.qh,{path:I.JZ.categoryGroups.path,element:a.createElement(d0,null)}),a.createElement(l.qh,{path:I.JZ.merchants.path,element:a.createElement(T7,null)}),a.createElement(l.qh,{path:"".concat(I.JZ.accounts.path,"/*"),element:a.createElement(IZ,null)}),a.createElement(l.qh,{path:I.JZ.cashFlow.path,element:a.createElement(HY,null,a.createElement(IX,null))}),a.createElement(l.qh,{path:I.JZ.budget.path,element:a.createElement(l.C5,{to:I.JZ.plan({queryParams:{timeframe:f8.s.SingleMonth}}),replace:!0})}),a.createElement(l.qh,{path:I.JZ.goalsV2.goalDetail.path,element:a.createElement(jbe,null)}),a.createElement(l.qh,{path:I.JZ.goalsV2.path,element:a.createElement(ACe,null)}),a.createElement(l.qh,{path:I.JZ.goals.path,element:(0,r.YW)({canViewV3:s,savingsGoalFeatureStatus:i}).with({savingsGoalFeatureStatus:"loading"},(()=>null)).with({canViewV3:!0},(()=>a.createElement(l.sv,null))).otherwise((()=>a.createElement(l.C5,{to:I.JZ.goalsV2.path,replace:!0})))},a.createElement(l.qh,{index:!0,element:a.createElement(l.C5,{to:I.JZ.goals.savings.path,replace:!0})}),a.createElement(l.qh,{path:I.JZ.goals.savings.path,element:a.createElement(Yet,null)}),a.createElement(l.qh,{path:"".concat(I.JZ.goals.savings.detail.path,"/*"),element:a.createElement(s7e,null)}),a.createElement(l.qh,{path:I.JZ.goals.debtPaydown.path,element:a.createElement(N5e,null)})),a.createElement(l.qh,{path:I.JZ.planning.path,element:a.createElement(l.C5,{replace:!0,to:I.JZ.plan({queryParams:{timeframe:f8.s.Monthly}})})}),a.createElement(l.qh,{path:"".concat(I.JZ.plan.path,"/*"),element:a.createElement(bFe,null)}),a.createElement(l.qh,{path:"".concat(I.JZ.transactions.path,"/*"),element:a.createElement(zpe,null)}),a.createElement(l.qh,{path:"".concat(I.JZ.paychecks.path,"/*"),element:a.createElement(OY,{name:"feat-paychecks-web",defaultOnTimeout:"off"},a.createElement(fae,null))}),a.createElement(l.qh,{path:"".concat(I.JZ.settings.path,"/*"),element:a.createElement(Act,null)}),a.createElement(l.qh,{path:"/split-test",element:a.createElement(UY,null,a.createElement(Ice,null))}),a.createElement(l.qh,{path:"/liabilities-dev",element:a.createElement(UY,{allowLocal:!0},a.createElement(uLe,null))}),a.createElement(l.qh,{path:I.JZ.today.path,element:a.createElement(Tut,null)}),a.createElement(l.qh,{path:I.JZ.today.onboarding.path,element:a.createElement(Nct,null,a.createElement(rgt,null))}),a.createElement(l.qh,{path:I.JZ.monarchMethod.path,element:a.createElement(OY,{name:"feat-monarch-method-web",defaultOnTimeout:"off"},a.createElement(JLe,null))}),a.createElement(l.qh,{path:I.JZ.monarchMethodPillar.path,element:a.createElement(OY,{name:"feat-monarch-method-web",defaultOnTimeout:"off"},a.createElement(ZLe,{fallback:a.createElement(l.C5,{to:I.JZ.monarchMethod.path,replace:!0})},a.createElement(LOe,null)))}),a.createElement(l.qh,{path:I.JZ.monarchMethodFixedExpenses.path,element:a.createElement(OY,{name:"feat-monarch-method-web",defaultOnTimeout:"off"},a.createElement(ZLe,{fallback:a.createElement(l.C5,{to:I.JZ.monarchMethod.path,replace:!0})},a.createElement(ELe,null)))}),a.createElement(l.qh,{path:"".concat(I.JZ.recurring.path,"/*"),element:a.createElement(rVe,null)}),a.createElement(l.qh,{path:"".concat(I.JZ.recurringV2.path,"/*"),element:a.createElement(xJe,null,a.createElement(bJe,null))}),a.createElement(l.qh,{path:"".concat(I.JZ.reports.path,"/*"),element:a.createElement(r3e,null)}),a.createElement(l.qh,{path:"".concat(I.JZ.investments.path,"/*"),element:a.createElement(tLe,null)}),a.createElement(l.qh,{path:"".concat(I.JZ.advisorPortal.clients.path,"/*"),element:a.createElement(GY,null,a.createElement(Mfe,null))}),a.createElement(l.qh,{path:I.JZ.advisorPortal.billing.path,element:a.createElement(GY,null,a.createElement(vve,null))}),a.createElement(l.qh,{path:I.JZ.advisorPortal.profile.path,element:a.createElement(GY,null,a.createElement(Vfe,null))}),a.createElement(l.qh,{path:I.JZ.advisorPortal.security.path,element:a.createElement(GY,null,a.createElement(yye,null))}),a.createElement(l.qh,{path:I.JZ.advice.insightDetail.path,element:a.createElement(WY.s,null,a.createElement(OY,{name:"exp-financial-agents",defaultOnTimeout:"off",onValue:["on","VA"]},a.createElement(Ghe,null)))}),a.createElement(l.qh,{path:"".concat(I.JZ.advice.path,"/*"),element:a.createElement(WY.s,null,a.createElement(khe,null))}),a.createElement(l.qh,{path:I.JZ.assistant.path,element:a.createElement(DZ,null)}),a.createElement(l.qh,{path:I.JZ.oauth.coinbase.path,element:a.createElement(k,null)}),I.yi.map((e=>a.createElement(l.qh,{key:e,path:e,element:a.createElement(DY,null)}))),a.createElement(l.qh,{path:"/forecast/:scenarioId/*",element:a.createElement(IY,null)}),a.createElement(l.qh,{path:I.JZ.protection.path,element:a.createElement(OY,{name:"feat-estate-planning",defaultOnTimeout:"off"},a.createElement(Tae,null))}),a.createElement(l.qh,{path:I.JZ.protection.results.path,element:a.createElement(OY,{name:"feat-estate-planning",defaultOnTimeout:"off"},a.createElement(Cle,null))}),a.createElement(l.qh,{path:"".concat(I.JZ.dashboard.path,"/*"),element:a.createElement(y7,null)}),a.createElement(l.qh,{path:"*",element:a.createElement(eV.M,null)})),a.createElement(ep,null),a.createElement(ogt,null)))}},14727:(e,t,n)=>{n.d(t,{p:()=>i});var a=n(36938),l=n(39368),r=n(41820),o=n(60192);const i=()=>a.createElement(l.TZm,{"data-external-id":"recurring-v2-beta-feedback-button",href:r.eI,external:!0,variant:"default",icon:a.createElement(l.F6q,null)},o.p.BETA_FEEDBACK_BUTTON)}
1,67128:(e,t,n)=>{n.d(t,{j:()=>o});var a=n(36938),l=n(39368),r=n(46407);const o=()=>a.createElement("div",{"data-external-id":"recurring-v2-tour-beta-content",className:"mt-4 flex flex-col gap-4"},a.createElement(l.c8D,{size:"base",color:"secondary",className:"leading-relaxed text-pretty"},r.Ss.STEP_4_INTRO),a.createElement("div",{className:"flex flex-col gap-1"},a.createElement(l.c8D,{size:"base",weight:"medium",className:"mb-1"},r.Ss.STEP_4_WHEN_BETA_ENDS),a.createElement(l.c8D,{size:"base",color:"secondary",className:"leading-relaxed text-pretty"},r.Ss.STEP_4_BETA_ENDS_BEFORE," ",a.createElement("span",{className:"underline"},r.Ss.STEP_4_SETUP_FRESH),r.Ss.STEP_4_BETA_ENDS_AFTER)),a.createElement("div",null,a.createElement(l.c8D,{size:"base",weight:"medium",className:"mb-1.5"},r.Ss.STEP_4_FEEDBACK_HEADING),a.createElement("ul",{className:"flex list-outside list-disc flex-col gap-1.5 pl-4 text-content-secondary"},a.createElement("li",null,a.createElement(l.c8D,{size:"base",color:"secondary",className:"leading-relaxed text-pretty"},a.createElement("strong",{className:"font-medium text-content-primary"},r.Ss.STEP_4_FEEDBACK_FORM_BOLD),r.Ss.STEP_4_FEEDBACK_FORM_BODY)),a.createElement("li",null,a.createElement(l.c8D,{size:"base",color:"secondary",className:"leading-relaxed text-pretty"},a.createElement("strong",{className:"font-medium text-content-primary"},r.Ss.STEP_4_EMAIL_SURVEY_BOLD),r.Ss.STEP_4_EMAIL_SURVEY_BODY)))))},87743:(e,t,n)=>{n.d(t,{Rt:()=>p,uu:()=>g,xD:()=>m});var a=n(68622),l=n(97920),r=n(81810),o=n(70696),i=n(92191),s=n(96725),c=n(16049),d=n(58567),u=n(36828);const m=(e,t)=>{var n;const a=(0,o.A)([e],t.groupBy);if(!a)throw new Error("Missing start date");const i=null!==(n=t.summary)&&void 0!==n?n:{},s=i.sumExpense,c=i.sumIncome,d=i.savings,u=i.savingsRate,m=r.c9.local(),p=r.c9.fromISO(a),g=m.hasSame(p,e),h=m.minus({[e]:1}).hasSame(p,e),v=g||h,f=!g;return(0,l.A)((0,l.A)({startDate:a,income:null!==c&&void 0!==c?c:0,expense:null!==s&&void 0!==s?s:0,savingsRate:null!==u&&void 0!==u?u:0},v?{currentMonthSavings:null!==d&&void 0!==d?d:0}:{}),f?{savings:null!==d&&void 0!==d?d:0}:{})},p=(e,t)=>t?e.findIndex((e=>{let n=e.startDate;return t===n})):-1,g=e=>{const t=(0,i.A)((0,s.A)((0,c.A)("startDate")),u.d)(e).map((e=>r.c9.fromISO(e)));return(0,d.A)(2,t).reduce(((e,t)=>{let n=(0,a.A)(t,2),l=n[0],r=n[1];return l.hasSame(r,"year")?e:e.concat({x:r.toISODate(),leftLabelText:"\u2190 ".concat(l.toFormat("yyyy")),rightLabelText:"".concat(r.toFormat("yyyy")," \u2192")})}),[])}},72846:(e,t,n)=>{n.d(t,{WQ:()=>m,c$:()=>g,eB:()=>p});var a=n(68622),l=n(99270),r=n(91120),o=n(61501),i=n(63953),s=n(13484),c=n(1506),d=n(725),u=n(15660);const m=(e,t,n,a)=>{const r=[n.color.blue,n.color.indigo,n.color.pink,n.color.lime],o=[n.color.orange,n.color.indigo,n.color.red,n.color.purple,n.color.pink,n.color.yellow];e=(0,l.A)((e=>{var t;return null!==(t=e.depth)&&void 0!==t?t:0}),e);const i="group"===a,s="category"===a;e.forEach(((e,a)=>{const l=e.categoryGroupType===u.wNk.EXPENSE,m=e.id&&[c.Lz,c.ns].includes(e.id),p=e.type===c.Z6.CategoryGroup,g=e.type===c.Z6.Category,h=l&&g&&s||l&&p,v=!l&&g&&!i||!l&&p&&i;m?e.color=n.color.green:h?e.color=o[a%o.length]:v?e.color=r[a%r.length]:(0,d.z0)(e,t)})),"both"===a&&e.filter((e=>0===e.depth)).forEach((e=>(0,d.Lc)(e,t)))},p=(e,t)=>{if(!t)return{nodes:[],links:[]};const n=e=>Math.abs(e),l=e.byCategoryGroup,r=void 0===l?[]:l,o=e.byCategory,i=void 0===o?[]:o,s=(0,a.A)(e.summary,1)[0].summary,d=h(r),m=h(i),p=[{id:c.Lz,label:"Income",value:s.sumIncome,rawValue:s.sumIncome,fixedValue:s.sumIncome,type:c.Z6.Generic,isClickable:!1}];let g=[],E=[];if("group"===t)g=[...g,...v(d)],E=[...E,...d.filter((e=>{var t;let n=e.groupBy;return(null===n||void 0===n||null===(t=n.categoryGroup)||void 0===t?void 0:t.type)===u.wNk.INCOME})).map((e=>{let t=e.groupBy,a=e.summary;return{source:t.categoryGroup.id,target:c.Lz,value:n(a.sum)}})),...d.filter((e=>{var t;let n=e.groupBy;return(null===n||void 0===n||null===(t=n.categoryGroup)||void 0===t?void 0:t.type)===u.wNk.EXPENSE})).map((e=>{let t=e.groupBy,a=e.summary;return{source:c.Lz,target:t.categoryGroup.id,value:n(a.sum)}}))];else if("category"===t)g=[...g,...f(m)],E=[...E,...m.filter((e=>{var t,n;let a=e.groupBy;return(null===a||void 0===a||null===(t=a.category)||void 0===t||null===(n=t.group)||void 0===n?void 0:n.type)===u.wNk.INCOME})).map((e=>{let t=e.groupBy,a=e.summary;return{source:t.category.id,target:c.Lz,value:n(a.sum)}})),...m.filter((e=>{var t,n;let a=e.groupBy;return(null===a||void 0===a||null===(t=a.category)||void 0===t||null===(n=t.group)||void 0===n?void 0:n.type)===u.wNk.EXPENSE})).map((e=>{let t=e.groupBy,a=e.summary;return{source:c.Lz,target:t.category.id,value:n(a.sum)}}))];else{if("both"!==t)throw new Error("Invalid processType: ".concat(t));g=[...g,...v(d),...f(m)],E=[...E,...m.filter((e=>{var t,n;let a=e.groupBy;return(null===a||void 0===a||null===(t=a.category)||void 0===t||null===(n=t.group)||void 0===n?void 0:n.type)===u.wNk.INCOME})).map((e=>{let t=e.groupBy,a=e.summary;return{source:t.category.id,target:t.category.group.id,value:n(a.sum)}})),...m.filter((e=>{var t,n;let a=e.groupBy;return(null===a||void 0===a||null===(t=a.category)||void 0===t||null===(n=t.group)||void 0===n?void 0:n.type)===u.wNk.EXPENSE})).map((e=>{let t=e.groupBy,a=e.summary;return{source:t.category.group.id,target:t.category.id,value:n(a.sum)}})),...d.filter((e=>{var t;let n=e.groupBy;return(null===n||void 0===n||null===(t=n.categoryGroup)||void 0===t?void 0:t.type)===u.wNk.INCOME})).map((e=>{let t=e.groupBy,a=e.summary;return{source:t.categoryGroup.id,target:c.Lz,value:n(a.sum)}})),...d.filter((e=>{var t;let n=e.groupBy;return(null===n||void 0===n||null===(t=n.categoryGroup)||void 0===t?void 0:t.type)===u.wNk.EXPENSE})).map((e=>{let t=e.groupBy,a=e.summary;return{source:c.Lz,target:t.categoryGroup.id,value:n(a.sum)}}))]}return g.length>0&&(g=[...g,...p]),s.savings>0&&(g=[...g,{id:c.ns,label:"Net Income",value:s.savings,rawValue:s.savings,type:c.Z6.Generic,isClickable:!1}],E=[...E,{source:c.Lz,target:c.ns,value:s.savings}]),{nodes:g,links:E}},g=e=>{if((0,o.A)(e)||(0,i.A)(e))throw new Error("Node must be an object");
1if(!e.id)throw new Error("Node must have an id")},h=e=>e.filter((e=>{let t=e.summary,n=e.groupBy;const a=(e=>(0,r.A)(["categoryGroup"],e))(n);return(0,s.A)(a?n.categoryGroup:n.category)&&0!==t.sum})),v=e=>e.map((e=>{let t=e.groupBy,n=e.summary;return{id:t.categoryGroup.id,label:t.categoryGroup.name,value:Math.abs(n.sum),type:c.Z6.CategoryGroup,categoryGroupType:t.categoryGroup.type,rawValue:n.sum,fixedValue:Math.abs(n.sum)}})),f=e=>e.map((e=>{let t=e.groupBy,n=e.summary;return{id:t.category.id,label:"".concat(t.category.icon," ").concat(t.category.name),value:Math.abs(n.sum),type:c.Z6.Category,categoryGroupType:t.category.group.type,rawValue:n.sum,fixedValue:Math.abs(n.sum)}}))},82904:(e,t,n)=>{n.d(t,{y6:()=>y,Xh:()=>B,d:()=>M,p8:()=>R,W5:()=>T,rs:()=>D,jV:()=>N,co:()=>O,Bg:()=>P,OX:()=>_,_E:()=>S,I5:()=>k,dN:()=>L});var a=n(97920),l=n(68622),r=n(92423),o=n(94469),i=n(33063),s=n(461),c=n(50505),d=n(95290),u=n(66808),m=n(63953),p=n(20361),g=n(35146),h=n(35151),v=n(15660);const f=(e,t)=>{if((0,h.A)(e)&&(0,h.A)(t))return!0;if((0,h.A)(e)||(0,h.A)(t))return!1;if(e.length!==t.length)return!1;const n=t.map((e=>e.id));return(0,g.A)((0,i.A)(((e,t)=>e.localeCompare(t)),e),(0,i.A)(((e,t)=>e.localeCompare(t)),n))},E=(e,t)=>!(!(0,h.A)(e)||!(0,h.A)(t))||e===t,y=(e,t)=>{var n,a,l,r,o,i,s,c,d,u,m,p,g,y,b,x,w,C;const A=null!==t&&void 0!==t?t:{},I={accounts:f(e.accounts,A.accounts),categories:f(e.categories,A.categories),categoryGroups:f(e.categoryGroups,A.categoryGroups),merchants:f(e.merchants,A.merchants),tags:f(e.tags,A.tags),isUntagged:E(e.isUntagged,A.isUntagged),categoryType:E(e.categoryType,A.categoryType),creditsOnly:E(e.creditsOnly,A.creditsOnly),debitsOnly:E(e.debitsOnly,A.debitsOnly),absAmountGte:E(e.absAmountGte,A.absAmountGte),absAmountLte:E(e.absAmountLte,A.absAmountLte),goals:f(e.goals,A.goals),savingsGoals:f(e.savingsGoals,A.savingsGoals),hasAttachments:E(e.hasAttachments,A.hasAttachments),hasNotes:E(e.hasNotes,A.hasNotes),hideFromReports:(k=e.transactionVisibility,S=A.hiddenFromReports,!(!(0,h.A)(S)||k!==v.h1.ALL_TRANSACTIONS)||!(!S||k!==v.h1.HIDDEN_TRANSACTIONS_ONLY)||!1===S&&k===v.h1.NON_HIDDEN_TRANSACTIONS_ONLY),importedFromMint:E(e.importedFromMint,A.importedFromMint),isFlexSpending:E(e.isFlexSpending,A.isFlexSpending),isInvestmentAccount:E(e.isInvestmentAccount,A.isInvestmentAccount),isPending:E(e.isPending,A.isPending),isRecurring:E(e.isRecurring,A.isRecurring),isSplit:E(e.isSplit,A.isSplit),isUncategorized:E(e.isUncategorized,A.isUncategorized),needsReview:E(e.needsReview,A.needsReview),needsReviewByUser:E(e.needsReviewByUser,null===(n=A.needsReviewByUser)||void 0===n?void 0:n.id),needsReviewUnassigned:E(e.needsReviewUnassigned,A.needsReviewUnassigned),search:E(e.search,A.searchQuery),syncedFromInstitution:E(e.syncedFromInstitution,A.syncedFromInstitution),uploadedStatement:E(e.uploadedStatement,null===(a=A.uploadedStatement)||void 0===a?void 0:a.id),startDate:E(e.startDate,A.startDate),endDate:E(e.endDate,A.endDate),timeframe:E(null===(l=e.timeframePeriod)||void 0===l?void 0:l.unit,null===(r=A.timeframePeriod)||void 0===r?void 0:r.unit)&&E(null===(o=e.timeframePeriod)||void 0===o?void 0:o.value,null===(i=A.timeframePeriod)||void 0===i?void 0:i.value)&&E(null===(s=e.timeframePeriod)||void 0===s?void 0:s.includeCurrent,null===(c=A.timeframePeriod)||void 0===c?void 0:c.includeCurrent),ownershipSet:E(null===(d=e.ownershipSet)||void 0===d?void 0:d.includeJointlyOwned,null===(u=A.ownershipSet)||void 0===u?void 0:u.includeJointlyOwned)&&f(null===(m=e.ownershipSet)||void 0===m?void 0:m.userIds,null!==(g=null===(p=A.ownershipSet)||void 0===p?void 0:p.users)&&void 0!==g?g:[]),businessEntitySet:E(null===(y=e.businessEntitySet)||void 0===y?void 0:y.includeUnassigned,null===(b=A.businessEntitySet)||void 0===b?void 0:b.includeUnassigned)&&f(null===(x=e.businessEntitySet)||void 0===x?void 0:x.businessEntityIds,null!==(C=null===(w=A.businessEntitySet)||void 0===w?void 0:w.businessEntities)&&void 0!==C?C:[])};var k,S;return Object.values(I).every(Boolean)};var b=n(5690),x=n(76788),w=n(57242),C=n(8134),A=(n(14708),n(34960));const I="not:",k=e=>(0,i.A)((0,s.A)((e=>e.order)),e),S=e=>t=>{let n=t.label,a=t.optionLabel,l=void 0===a?(0,r.sentenceCase)(n):a,i=t.negativeOptionLabel,s=void 0===i?"Not ".concat((0,x.O1)(l)):i,u=t.filterPath,m=t.hide,p=void 0!==m&&m,g
1=t.inverse,h=void 0!==g&&g;return p?void 0:{id:(0,c.A)(u),name:n,type:"radio",options:[{id:(0,o.camelCase)(n),name:l,isSelected:(0,d.A)(u,!h,e||{}),extra:{inverse:h}},{id:"".concat(I).concat((0,o.camelCase)(n)),name:s,isSelected:(0,d.A)(u,h,e||{}),extra:{inverse:h}}]}},N=e=>{const t=e.path,n=(0,l.A)(t,3),a=n[1],r=n[2];return"needsReview"===a?r===b.V6?{needsReview:!0,needsReviewByUser:void 0,needsReviewUnassigned:!0}:{needsReview:!0,needsReviewByUser:r,needsReviewUnassigned:void 0}:"transactionVisibility"===a?{transactionVisibility:r}:"deletedTransactionVisibility"===a?{deletedTransactionVisibility:r}:{[a]:T(e)}},T=e=>{const t=e.path,n=e.extra,a=void 0===n?{}:n,r=t,o=(0,l.A)(r,3)[2];return a.inverse?o.startsWith(I):!o.startsWith(I)},_=(e,t)=>{const n=e.id;return n===w.TM?{isUntagged:!0}:{tags:[...t,n]}},D=e=>{const t=e||{},n=t.absAmountLte,l=t.absAmountGte,r=t.amountFilter;return[{id:w.P8.GreaterThan,name:"Greater than...",inputs:[{type:"currency",name:"amount",placeholder:"$10",defaultValue:l}],isSelected:r===w.P8.GreaterThan,formatLabel:e=>{let t=e.amount,n=void 0===t?l:t;return(0,m.A)(n)?"Greater than ".concat((0,C.is)(n)):void 0}},{id:w.P8.LessThan,name:"Less than...",inputs:[{type:"currency",name:"amount",placeholder:"$10",defaultValue:n}],isSelected:r===w.P8.LessThan,formatLabel:e=>{let t=e.amount,a=void 0===t?n:t;return(0,m.A)(a)?"Less than ".concat((0,C.is)(a)):void 0}},{id:w.P8.EqualTo,name:"Equal to...",inputs:[{type:"currency",name:"amount",placeholder:"$10",defaultValue:l}],isSelected:r===w.P8.EqualTo,formatLabel:e=>{let t=e.amount,n=void 0===t?l:t;return(0,m.A)(n)?"Equal to ".concat((0,C.is)(n)):void 0}},{id:w.P8.Between,name:"Between...",isSelected:r===w.P8.Between,inputs:[{type:"currency",name:"min",placeholder:"$0",defaultValue:l},{type:"currency",name:"max",placeholder:"$100",defaultValue:n}],formatLabel:e=>{let t=e.min,a=void 0===t?l:t,r=e.max,o=void 0===r?n:r;return(0,m.A)(a)&&(0,m.A)(o)?"Between ".concat((0,C.is)(a)," and ").concat((0,C.is)(o)):void 0}}].map((e=>{var t;if(!e.isSelected)return e;const n=null===(t=e.inputs)||void 0===t?void 0:t.reduce(((e,t)=>(0,a.A)((0,a.A)({},e),{},{[t.name]:t.defaultValue})),{});return(0,a.A)((0,a.A)({},e),{},{inputValues:n})}))},R=(e,t)=>{if(!(0,u.A)(e)||!(0,u.A)(t))return(0,u.A)(e)?w.P8.GreaterThan:(0,u.A)(t)?w.P8.LessThan:e===t?w.P8.EqualTo:w.P8.Between},M=e=>{const t=e.inputValues,n=e.id;return(0,p.YW)(n).with(w.P8.GreaterThan,(()=>({amountFilter:n,absAmountGte:null===t||void 0===t?void 0:t.amount}))).with(w.P8.LessThan,(()=>({amountFilter:n,absAmountLte:null===t||void 0===t?void 0:t.amount}))).with(w.P8.EqualTo,(()=>({amountFilter:n,absAmountGte:null===t||void 0===t?void 0:t.amount,absAmountLte:null===t||void 0===t?void 0:t.amount}))).with(w.P8.Between,(()=>({amountFilter:n,absAmountGte:null===t||void 0===t?void 0:t.min,absAmountLte:null===t||void 0===t?void 0:t.max}))).with(w.P8.DebitsOnly,(()=>({debitsOnly:!0}))).with(w.P8.CreditsOnly,(()=>({creditsOnly:!0}))).otherwise((()=>({})))},L=(e,t)=>({id:e.id,name:"".concat(e.icon," ").concat(e.name),isSelected:t(e.id)}),O=e=>t=>!!e&&e.includes(t),P=(e,t)=>{const n=t||{includeJointlyOwned:!1,userIds:[]};if(e.id===A.u)return{ownershipSet:(0,a.A)((0,a.A)({},n),{},{includeJointlyOwned:!0})};{const t=n.userIds||[];return{ownershipSet:(0,a.A)((0,a.A)({},n),{},{userIds:[...t,e.id]})}}},B=e=>{const t=new Map;return e.forEach((e=>{const n=e.type,a=e.subtype;null!==n&&void 0!==n&&n.name&&null!==n&&void 0!==n&&n.display&&null!==n&&void 0!==n&&n.group&&(t.has(n.name)||t.set(n.name,{type:{name:n.name,display:n.display,group:n.group},subtypes:new Map}),null!==a&&void 0!==a&&a.name&&t.get(n.name).subtypes.set(a.name,a.display||a.name))})),t}},18680:(e,t,n)=>{n.d(t,{dT:()=>O,gj:()=>Z,g1:()=>V,QB:()=>$,P4:()=>K,Kp:()=>H,KQ:()=>G});var a=n(97920),l=n(68622),r=n(81810),o=n(85151),i=n(75893),s=n(63491),c=n(91323),d=n(33063),u=n(55588),m=n(18850),p=n(73616),g=n(51923),h=n(461),v=n(16049),f=n(96725),E=n(63953),y=n(20361),b=n(21327),x=n(70696),w=n(55765),C=n(66808),A=n(13484),I=n(1506);class k{constructor(e,t,n){this.data=e,this.summary=t,this.config=n,this.nodes={},this.pendingLinks={},this.links=[],this.incomeNode=this.addNode(I.Lz,"Income",Math.max(1,t.sumIncome),I.Z6.Generic)}generate(){return this.data.forEach((e=>
1this.processGroupDetails(e))),"both"===this.config.groupMode?this.addMultiDimensionLinks():this.addSingleDimensionLinks(),this.summary.savings>0&&(this.savingsNode=this.addNode(I.ns,"Net Income",this.summary.savings,I.Z6.Generic),this.addLink(this.incomeNode,this.savingsNode,this.summary.savings)),{nodes:Object.values(this.nodes).filter((e=>(0,A.A)(e)&&0!==e.value)).map((e=>e.toJson())),links:this.links.map((e=>e.toJson()))}}addNode(e,t,n,a,l,r){const o=this.nodes[e];if(o)return o.value+=n,this.nodes[e]=o,o;const i=new N(e,t,n,a,l,r);return this.nodes[e]=i,i}addLink(e,t,n){if(0===n)return;const a=new T(e,t,n);return this.links=[...this.links,a],a}addPendingLink(e,t,n){const a="".concat(e,"-").concat(t),l=this.pendingLinks[a]||[];this.pendingLinks[a]=[...l,{sourceId:e,targetId:t,sum:n}]}processGroupDetails(e){const t=(0,x.A)(["entities","category"],e),n=(0,x.A)(["entities","categoryGroup"],e);let a,l;t&&(a=this.addNode(t.id,"".concat(t.icon," ").concat(t.name),e.summary.sum,I.Z6.Category,t.group.type,t)),n&&(l=this.addNode(n.id,n.name,e.summary.sum,I.Z6.CategoryGroup,n.type,n)),a&&"category"===this.config.groupMode?this.addPendingLink(a.id,I.Lz,e.summary.sum):l&&"group"===this.config.groupMode&&this.addPendingLink(l.id,I.Lz,e.summary.sum)}addSingleDimensionLinks(){(0,w.A)((e=>{if(0===e.length)return;const t=(0,l.A)(e,2),n=t[0],a=n.sourceId,r=n.targetId,o=(t[1],this.nodes[a]),i=this.nodes[r];if((0,C.A)(o)||(0,C.A)(i))return;const s=e.reduce(((e,t)=>e+t.sum),0);s<0?this.addLink(i,o,Math.abs(s)):s>0&&this.addLink(o,i,s)}),Object.values(this.pendingLinks))}addMultiDimensionLinks(){(0,w.A)((e=>{if(e.type!==I.Z6.Category)return;const t=e.value>0,n=Math.abs(e.value),a=e.metadata.group,l="".concat(a.id).concat(t?S.inflow:S.outflow);(0,A.A)(this.nodes[a.id])&&(this.nodes=(0,m.A)([a.id],this.nodes));const r=this.addNode(l,a.name,n,I.Z6.CategoryGroup,a.type,a);t?(this.addPendingLink(e.id,r.id,n),this.addPendingLink(r.id,this.incomeNode.id,n)):(this.addPendingLink(this.incomeNode.id,r.id,n),this.addPendingLink(r.id,e.id,n))}),Object.values(this.nodes)),this.addSingleDimensionLinks()}}const S={inflow:"_INFLOW",outflow:"_OUTFLOW"};class N{constructor(e,t,n,a,l,r){this.id=e,this.label=t,this.value=n,this.type=a,this.categoryGroupType=l,this.metadata=r,this.id=e,this.label=t,this.value=n,this.type=a,this.categoryGroupType=l,this.metadata=r}get isClickable(){return!!this.categoryGroupType}get selection(){if(!(0,C.A)(this.metadata))return this.type===I.Z6.Category?{kind:"category",categoryId:this.metadata.id}:this.type===I.Z6.CategoryGroup?{kind:"categoryGroup",categoryGroupId:this.metadata.id}:void 0}toJson(){return{id:this.id,label:this.label,value:this.value,type:this.type,isClickable:this.isClickable,categoryGroupType:this.categoryGroupType,selection:this.selection}}}class T{constructor(e,t,n){this.source=e,this.target=t,this.value=n,this.source=e,this.target=t,this.value=Math.abs(n)}toJson(){return{source:this.source.id,target:this.target.id,value:this.value}}}var _=n(9758),D=n(3664),R=n(62230),M=n(69416),L=n(34960);const O=["label","date","total"],P="Everything else",B=_.I.gray,z={[M.Gi.BarChart]:6,[M.Gi.StackedBarChart]:6},F=(e,t,n)=>{if(n&&"businessEntity"===e)return{kind:"businessEntity",businessEntityId:null};if(n&&"owner"===e)return{kind:"owner",ownerUserId:null};if(!e||null===t||void 0===t||!t.id)return;const a=t.id;return(0,y.YW)(e).with("category",(()=>({kind:"category",categoryId:a}))).with("categoryGroup",(()=>({kind:"categoryGroup",categoryGroupId:a}))).with("merchant",(()=>({kind:"merchant",merchantId:a}))).with("businessEntity",(()=>({kind:"businessEntity",businessEntityId:a}))).with("budgetVariability",(()=>({kind:"budgetVariability",budgetVariability:a}))).with("owner",(()=>({kind:"owner",ownerUserId:a}))).otherwise((()=>{}))},G=e=>{var t;const n=(e=>{var t;return null===(t=Object.keys(null!==e&&void 0!==e?e:{}))||void 0===t?void 0:t[0]})(e),a=n?null===e||void 0===e?void 0:e[n]:void 0,l=!a&&"businessEntity"===n,r=!a&&"owner"===n,o=l||r;let i="";l?i="Household":r&&(i=L.H);const s=function(e){if(!e)return arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";
1const t=e.displayName||e.name;return e.icon?"".concat(e.icon," ").concat(t):t}(a,i);let c;l?c=R.w8:r&&(c=L.u);const d=null!==(t=null===a||void 0===a?void 0:a.id)&&void 0!==t?t:c;let u;if(o)u=B;else if("BusinessEntity"===(null===a||void 0===a?void 0:a.__typename)){var m;u=null!==(m=a.color)&&void 0!==m?m:void 0}return{entity:a,label:s,id:d,color:u,isHousehold:o,selection:F(n,a,o)}},Y=e=>G(e).label,U=(e,t)=>e.every((e=>(0,D.fS)(e[t]))),V=(e,t,n)=>{const a=new Set;e.forEach((e=>{Object.keys(e).filter((e=>!O.includes(e)&&e!==P)).forEach((e=>a.add(e)))}));let l=Array.from(a).filter((t=>!U(e,t)));return e.some((e=>e[P]))&&!U(e,P)&&(l=[...l,P]),l.map(((e,a)=>{var l;return{name:e,color:null!==(l=null===n||void 0===n?void 0:n.get(e))&&void 0!==l?l:t[a%t.length]}}))},W=e=>!!e.date,j=(e,t)=>(0,d.A)(((e,t)=>{let n=(0,l.A)(e,1)[0],a=(0,l.A)(t,1)[0];return n.localeCompare(a)}),Array.from(e.entries())).map((e=>{let n=(0,l.A)(e,2),r=n[0],o=n[1];return(0,a.A)({date:r,label:(0,b.cM)(r,t),total:(0,u.A)(Object.values((0,m.A)(O,o)).filter(E.A))},(0,m.A)(O,o))})),H=(e,t,n)=>{const a=(0,l.A)(e,1)[0].filter(W),r=(e=>e.reduce(((e,t)=>{var n;let a=t.entities,l=t.total;const r=Y(a),o=null!==(n=e.get(r))&&void 0!==n?n:0;return e.set(r,o+l),e}),new Map))(a),d=((e,t)=>{var n;const a=(0,o.A)([(0,i.A)((e=>(0,l.A)(e,2)[1]))],Array.from(e.entries()));return(t!==M.Gi.SankeyCashFlowChart?(0,s.A)(null!==(n=z[t])&&void 0!==n?n:b.qu,a):a).reduce(((e,t)=>{let n=(0,l.A)(t,2),a=n[0],r=n[1];return e[a]=r,e}),{})})(r,n),u=((e,t)=>e.reduce(((e,n)=>{var a;let l=n.date,r=n.entities,o=n.total;const i=Y(r),s=null!==(a=e.get(l))&&void 0!==a?a:{};var d,u;return(0,c.A)(i,t)?s[i]=(null!==(d=s[i])&&void 0!==d?d:0)+o:s[P]=(null!==(u=s[P])&&void 0!==u?u:0)+o,e.set(l,s),e}),new Map))(a,d),m=(e=>{const t=new Map;return e.forEach((e=>{let n=e.entities;const a=G(n),l=a.label,r=a.color;r&&!t.has(l)&&t.set(l,r)})),t})(a);return{chartData:j(u,t),entityColorMap:m}},K=(e,t)=>{const n=e.findIndex((e=>e.date===t));if(n<=0)return{current:e[0],previous:null};const a=e.slice((0,p.A)(0,e.length-2,n-1),n+1),r=(0,l.A)(a,2),o=r[0];return{current:r[1],previous:o}},q=(e,t,n)=>{var l,o,i,s;const c=null!==(l=e.summary.savings)&&void 0!==l?l:0;return(0,a.A)((0,a.A)({date:e.date,label:(0,b.cM)(e.date,t),income:n(null!==(o=e.summary.sumIncome)&&void 0!==o?o:0),expense:n(null!==(i=e.summary.sumExpense)&&void 0!==i?i:0),net:c},((e,t,n)=>{const l=t,o=r.c9.local(),i=r.c9.fromISO(e),s=o.hasSame(i,l),c=o.minus({[l]:1}).hasSame(i,l),d=i.startOf(l)>o.startOf(l);return(0,a.A)((0,a.A)({},s||d?{}:{completedNet:n}),s||c?{currentPeriodNet:n}:{})})(e.date,t,c)),{},{savingsRate:null!==(s=e.summary.savingsRate)&&void 0!==s?s:0,total:e.total})},$=function(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:g.A;const a=(0,d.A)((0,h.A)((0,v.A)("date")),e).filter(W);return(0,f.A)((e=>q(e,t,n)),a)},Z=(e,t,n)=>{const a=new k(e,t,{groupMode:n}).generate(),l=a.nodes,r=a.links;return{nodes:Array.from(l),links:Array.from(r)}}},62230:(e,t,n)=>{n.d(t,{Ow:()=>l,tz:()=>r,w8:()=>a,yC:()=>o});const a="__household__",l=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:new Date;const t=e.getFullYear();return e>=new Date(t,3,16)?t:t-1},r=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:new Date;const t=l(e),n=e.getFullYear();return e>=new Date(n,3,16)?[t-1,t]:[t,t+1]},o="full"},76034:(e,t,n)=>{n.d(t,{pE:()=>E,aV:()=>y,rs:()=>f,kv:()=>D,hz:()=>O,qf:()=>w,qI:()=>L,yZ:()=>b,vx:()=>R,$H:()=>T,jd:()=>M,JG:()=>x,lE:()=>v.lE,jU:()=>_,RH:()=>S,Fb:()=>N});var a=n(63825),l=n(18850),r=n(66808),o=n(35146),i=n(33063),s=n(13484),c=n(35151),d=n(20361),u=n(91770),m=n(15660);var p=n(82904),g=n(73813),h=n(69416),v=n(21327);const f={totalAmounts:"Breakdown",changeOverTime:"Trends"},E={chartType:"chartType",groupMode:"groupMode",groupByEntity:"groupByEntity",groupByTimeframe:"groupByTimeframe"},y={[m.VE7.DAY]:"Daily",[m.VE7.WEEK]:"Weekly",[m.VE7.MONTH]:"Monthly",[m.VE7.QUARTER]:"Quarterly",[m.VE7.YEAR]:"Yearly"},b=e=>e?Math.abs(e):0,x=(e,t,n)=>{const a="cashFlow"===e&&[h.Gi.CashFlowChart,h.Gi.StackedCashFlowChart].includes(t),l=!!e&&["spending","income"].includes(e);return a||l&&"changeOverTime"===n},w=e=>(0,l.A)(["__typename"])(e),C={cashFlow:[h.Gi.CashFlowChart,h.Gi.StackedCashFlowChart,h.Gi.SankeyCashFlowChart,h.Gi.HorizontalBarChart,h.Gi.ProfitLossTable],spending:[h.Gi.PieChart,h.Gi.HorizontalBarChart,h.Gi.BarChart,h.Gi.StackedBarChart,h.Gi.TreemapChart],income:[h.Gi.PieChart,h.Gi.HorizontalBarChart,h.Gi.BarChart,h.Gi.StackedBarChart,h.Gi.TreemapChart]},A=(e,t)=>
1{return n=t,Object.values(h.Gi).includes(n)&&["cashFlow","spending","income"].includes(e)&&C[e].includes(t);var n},I=e=>{var t,n,a,l;const r=null!==(t=e.calculationViewMode)&&void 0!==t?t:(0,h.dR)(e.tab,e.chartType),o=x(e.tab,e.chartType,r),i="cashFlow"===e.tab&&[h.Gi.SankeyCashFlowChart,h.Gi.ProfitLossTable].includes(e.chartType);return{tab:e.tab,chartType:e.chartType,calculationViewMode:r,cashFlowGroupMode:i?null!==(n=e.cashFlowGroupMode)&&void 0!==n?n:g.N_.cashFlow.groupMode:void 0,groupByEntity:["spending","income"].includes(e.tab)?null!==(a=e.groupByEntity)&&void 0!==a?a:g.N_.groupBy:e.groupByEntity,groupByTimeframe:o?null!==(l=e.groupByTimeframe)&&void 0!==l?l:g.N_.groupByTimeframe:void 0}},k=(e,t)=>{if(!(0,h.hm)(t))return{tab:t};const n=A(t,e[E.chartType])?e[E.chartType]:void 0,a={tab:t};n&&(a.chartType=n);const l=e[E.groupMode];"cashFlow"===t&&["category","group","both"].includes(l)&&(a.cashFlowGroupMode=l);const r=e[E.groupByEntity];(["spending","income"].includes(t)||"cashFlow"===t&&n===h.Gi.HorizontalBarChart)&&(e=>Object.values(m.DB0).includes(e))(r)&&(a.groupByEntity=r);const o=e[E.groupByTimeframe];return(e=>Object.values(m.aIQ).includes(e))(o)&&(a.groupByTimeframe=o),a},S=(e,t)=>{var n;const a=R(t),l=k(e,t);return I({tab:t,chartType:null!==(n=l.chartType)&&void 0!==n?n:a.chartType,calculationViewMode:l.calculationViewMode,cashFlowGroupMode:l.cashFlowGroupMode,groupByEntity:l.groupByEntity,groupByTimeframe:l.groupByTimeframe})},N=e=>{if(!(0,h.hm)(e.tab))return{};const t=R(e.tab),n=I(e),a={};n.chartType!==t.chartType&&(a.chartType=n.chartType),"cashFlow"===n.tab&&n.cashFlowGroupMode!==t.cashFlowGroupMode&&(0,s.A)(n.cashFlowGroupMode)&&(a.groupMode=n.cashFlowGroupMode);const l=["spending","income"].includes(n.tab)||"cashFlow"===n.tab&&n.chartType===h.Gi.HorizontalBarChart,r="cashFlow"===n.tab&&n.chartType===h.Gi.HorizontalBarChart&&(0,s.A)(n.groupByEntity)&&![m.DB0.CATEGORY,m.DB0.CATEGORY_GROUP,m.DB0.MERCHANT].includes(n.groupByEntity)?m.DB0.CATEGORY:n.groupByEntity;return l&&r!==t.groupByEntity&&(0,s.A)(r)&&(a.groupByEntity=r),x(n.tab,n.chartType,n.calculationViewMode)&&n.groupByTimeframe!==g.N_.groupByTimeframe&&(0,s.A)(n.groupByTimeframe)&&(a.groupByTimeframe=n.groupByTimeframe),a},T=e=>{var t,n,a,l,o,i,c,d,u;const g=(0,p.p8)(e.absAmountLte,e.absAmountGte);let h;var v,f,E;(0,s.A)(e.ownershipSet)&&(h={includeJointlyOwned:null===(v=e.ownershipSet)||void 0===v?void 0:v.includeJointlyOwned,userIds:null===(f=e.ownershipSet)||void 0===f||null===(E=f.users)||void 0===E?void 0:E.map((e=>e.id))});let y;var b,x,w,C;(0,s.A)(e.businessEntitySet)&&(y={includeUnassigned:null===(b=e.businessEntitySet)||void 0===b?void 0:b.includeUnassigned,businessEntityIds:null===(x=e.businessEntitySet)||void 0===x||null===(w=x.businessEntities)||void 0===w?void 0:w.map((e=>e.id))});return{accounts:null===(t=e.accounts)||void 0===t?void 0:t.map((e=>e.id)),categories:null===(n=e.categories)||void 0===n?void 0:n.map((e=>e.id)),categoryGroups:null===(a=e.categoryGroups)||void 0===a?void 0:a.map((e=>e.id)),merchants:null===(l=e.merchants)||void 0===l?void 0:l.map((e=>e.id)),tags:null===(o=e.tags)||void 0===o?void 0:o.map((e=>e.id)),goals:null===(i=e.goals)||void 0===i?void 0:i.map((e=>e.id)),savingsGoals:null===(c=e.savingsGoals)||void 0===c?void 0:c.map((e=>e.id)),isUntagged:e.isUntagged,uploadedStatement:null===(d=e.uploadedStatement)||void 0===d?void 0:d.id,amountFilter:g,absAmountGte:e.absAmountGte,absAmountLte:e.absAmountLte,categoryType:e.categoryType,creditsOnly:e.creditsOnly,debitsOnly:e.debitsOnly,hasAttachments:e.hasAttachments,hasNotes:e.hasNotes,transactionVisibility:(C=e.hiddenFromReports,(0,r.A)(C)?m.h1.ALL_TRANSACTIONS:C?m.h1.HIDDEN_TRANSACTIONS_ONLY:m.h1.NON_HIDDEN_TRANSACTIONS_ONLY),importedFromMint:e.importedFromMint,isFlexSpending:e.isFlexSpending,isInvestmentAccount:e.isInvestmentAccount,isPending:e.isPending,isRecurring:e.isRecurring,isSplit:e.isSplit,isUncategorized:e.isUncategorized,needsReview:e.needsReview,needsReviewByUser:null===(u=e.needsReviewByUser)||void 0===u?void 0:u.id,needsReviewUnassigned:e.needsReviewUnassigned,search:e.searchQuery,syncedFromInstitution:e.syncedFromInstitution,startDate:e.startDate,endD
1ate:e.endDate,timeframePeriod:e.timeframePeriod,ownershipSet:h,businessEntitySet:y}},_=e=>{var t;const n="spending"===(a=e.analysisScope)?"spending":"income"===a?"income":"cashFlow";var a;const l=(0,d.YW)(e.chartType).with("pie",(()=>h.Gi.PieChart)).with("treemap",(()=>h.Gi.TreemapChart)).with("bar",(()=>"horizontal"===e.chartLayout?h.Gi.HorizontalBarChart:"stacked"===e.chartDensity?"cashFlow"===n?h.Gi.StackedCashFlowChart:h.Gi.StackedBarChart:"cashFlow"===n?h.Gi.CashFlowChart:h.Gi.BarChart)).with("sankey",(()=>h.Gi.SankeyCashFlowChart)).with("table",(()=>h.Gi.ProfitLossTable)).otherwise((()=>"cashFlow"===n?h.Gi.SankeyCashFlowChart:h.Gi.PieChart));let r,o,i,c=(0,h.dR)(n,l);if((0,s.A)(e.chartCalculation)&&(0,h.hm)(n)){c={difference:"changeOverTime",sum:"totalAmounts"}[e.chartCalculation]}if(null!==(t=e.dimensions)&&void 0!==t&&t.length)if([h.Gi.SankeyCashFlowChart,h.Gi.ProfitLossTable].includes(l)){var u;r=null!==(u=(e=>{if(!e||0===e.length)return;const t=e.includes(m.DB0.CATEGORY),n=e.includes(m.DB0.CATEGORY_GROUP);return t&&n?"both":n?"group":t?"category":void 0})(e.dimensions))&&void 0!==u?u:"category"}else{const t=e.dimensions[0];o=Object.values(m.DB0).includes(t)?t:void 0}return(0,s.A)(e.timeframe)&&x(n,l,c)&&(i=e.timeframe),I({tab:n,chartType:l,calculationViewMode:c,cashFlowGroupMode:r,groupByEntity:o,groupByTimeframe:i})},D=(e,t)=>{const n=I(t);var a;(e((0,u.VT)({chartType:n.chartType,tab:n.tab})),"cashFlow"===n.tab)&&e((0,u.tJ)(null!==(a=n.cashFlowGroupMode)&&void 0!==a?a:"both"));(0,h.hm)(n.tab)&&n.groupByEntity&&e((0,u.UX)(n.groupByEntity)),n.groupByTimeframe&&e((0,u.xV)(n.groupByTimeframe))},R=e=>I({tab:e,chartType:g.N_[e].chartType}),M=e=>{var t,n,a;return[h.Gi.SankeyCashFlowChart,h.Gi.ProfitLossTable].includes(e.chartType)?null!==(n=null!==(a=e.groupMode)&&void 0!==a?a:e.viewMode)&&void 0!==n?n:void 0:null!==(t=e.viewMode)&&void 0!==t?t:void 0},L=(e,t)=>{const n=e[t],l=(0,a.snakeCase)(t);let r;(0,s.A)(n.viewMode)&&(0,h.hm)(t)&&(r="changeOverTime"===n.viewMode?"difference":"sum");const o=(0,d.YW)(n.chartType).with(h.Gi.PieChart,(()=>({chartType:"pie",chartLayout:void 0,chartDensity:void 0}))).with(h.Gi.TreemapChart,(()=>({chartType:"treemap",chartLayout:void 0,chartDensity:void 0}))).with(h.Gi.SankeyCashFlowChart,(()=>({chartType:"sankey",chartLayout:void 0,chartDensity:void 0}))).with(h.Gi.ProfitLossTable,(()=>
1({chartType:"table",chartLayout:void 0,chartDensity:void 0}))).with(h.Gi.BarChart,h.Gi.CashFlowChart,(()=>({chartType:"bar",chartLayout:"vertical",chartDensity:"split"}))).with(h.Gi.StackedBarChart,h.Gi.StackedCashFlowChart,(()=>({chartType:"bar",chartLayout:"vertical",chartDensity:"stacked"}))).with(h.Gi.HorizontalBarChart,(()=>({chartType:"bar",chartLayout:"horizontal",chartDensity:void 0}))).otherwise((()=>({chartType:"bar",chartLayout:void 0,chartDensity:void 0}))),i=o.chartType,c=o.chartLayout,u=o.chartDensity;let p,g=(0,s.A)(e.groupBy)?[e.groupBy]:void 0;return"cashFlow"===t&&["sankey","table"].includes(i)?g="both"===n.groupMode?[m.DB0.CATEGORY,m.DB0.CATEGORY_GROUP]:"group"===n.groupMode?[m.DB0.CATEGORY_GROUP]:[m.DB0.CATEGORY]:"cashFlow"===t&&n.chartType===h.Gi.HorizontalBarChart?g=[(0,s.A)(e.groupBy)&&[m.DB0.CATEGORY,m.DB0.CATEGORY_GROUP,m.DB0.MERCHANT].includes(e.groupBy)?e.groupBy:m.DB0.CATEGORY]:"cashFlow"===t&&(g=void 0),x(t,n.chartType,n.viewMode)&&(p=e.groupByTimeframe),{__typename:"ReportViewOutput",anal
1ysisScope:l,chartType:i,chartLayout:c,chartDensity:u,chartCalculation:r,dimensions:g,timeframe:p}},O=(e,t)=>{if((0,r.A)(e)&&(0,r.A)(t))return!0;if((0,r.A)(e)||(0,r.A)(t))return!1;const n={analysisScope:B(null===e||void 0===e?void 0:e.analysisScope,null===t||void 0===t?void 0:t.analysisScope),chartType:B(null===e||void 0===e?void 0:e.chartType,null===t||void 0===t?void 0:t.chartType),chartLayout:B(null===e||void 0===e?void 0:e.chartLayout,null===t||void 0===t?void 0:t.chartLayout),chartDensity:B(null===e||void 0===e?void 0:e.chartDensity,null===t||void 0===t?void 0:t.chartDensity),chartCalculation:B(z(e),z(t)),dimensions:P(null===e||void 0===e?void 0:e.dimensions,null===t||void 0===t?void 0:t.dimensions),timeframe:B(null===e||void 0===e?void 0:e.timeframe,null===t||void 0===t?void 0:t.timeframe)};return Object.values(n).every(Boolean)},P=(e,t)=>!(!(0,c.A)(e)||!(0,c.A)(t))||!(0,c.A)(e)&&!(0,c.A)(t)&&(e.length===t.length&&(0,o.A)((0,i.A)(((e,t)=>e.localeCompare(t)),e),(0,i.A)(((e,t)=>e.localeCompare(t)),t))),B=(e,t)=>(0,c.A)(e)&&(0,c.A)(t)||e===t,z=e=>{if(!(0,r.A)(e))return(0,s.A)(e.chartCalculation)?e.chartCalculation:(0,d.YW)(e.chartType).with("pie","treemap","sankey","table",(()=>"sum")).with("bar",(()=>"horizontal"===e.chartLayout?"sum":"difference")).otherwise((()=>{}))}},68221:(e,t,n)=>{n.d(t,{Lt:()=>h,O:()=>b,qy:()=>g});var a=n(68622),l=n(97920),r=n(86432),o=n(20361),i=n(3788),s=n(21327),c=n(9758),d=n(18680),u=n(15660);const m="var(--content-white)",p="var(--content-black)",g="everything_else",h="Everything else",v=(e,t,n)=>{if(t){const e=t===c.I.gray;return{background:t,backgroundHover:(0,r.e$)(.08,t),text:e?p:m}}const a=s.nJ[e%s.nJ.length],l=n[a],o=s.bm.has(a);return{background:l,backgroundHover:(0,r.e$)(.08,l),text:o?p:m}},f=(e,t)=>{if(!t)return e.label;const n=e.entity;return(null===n||void 0===n?void 0:n.displayName)||(null===n||void 0===n?void 0:n.name)||e.label},E=(e,t,n,a)=>{const r=(0,d.KQ)(e.entities),s=r.id,c=r.color,m=r.selection;if(!s)return null;const p=v(t,c,n),g=(e=>e.summary.sum>0&&e.categoryGroupType===u.wNk.EXPENSE)(e),h=(E=r.entity,(0,o.YW)(E).with({__typename:"Category"},(e=>{let t=e.icon;return t?{icon:t}:{}})).with({__typename:"Merchant"},(e=>{let t=e.logoUrl;return t?{logoUrl:t}:{}})).with({__typename:"BusinessEntity"},(e=>{let t=e.icon,n=e.logoUrl;return(0,l.A)((0,l.A)({},t?{icon:t}:{}),n?{logoUrl:n}:{})})).otherwise((()=>({}))));var E;return a[s]={selection:m},(0,l.A)((0,l.A)((0,l.A)({id:s,primaryLabel:[f(r,!!h.icon),i.MK.All],value:Math.abs(e.total)},g?{displayValue:e.total,isInflow:!0}:{}),h),{},{background:p.background,backgroundHover:p.backgroundHover,text:p.text})},y=(e,t,n,a,l,r)=>{const o=e.filter((e=>0!==Math.abs(e.total))).sort(((e,t)=>Math.abs(t.total)-Math.abs(e.total))),s=o.slice(0,r),c=o.slice(r),d=c.reduce(((e,t)=>e+Math.abs(t.total)),0),u=[];
1if(s.forEach(((e,l)=>{const r=E(e,t+l,n,a);r&&u.push(r)})),c.length>0&&d>0){const e=v(t+u.length,void 0,n),o=y(c,t+u.length+1,n,a,"".concat(l,"_").concat(c.length),r);u.push({id:l,primaryLabel:[h,i.MK.All],value:d,background:e.background,backgroundHover:e.backgroundHover,text:e.text,otherCount:c.length,children:o}),a[l]={selection:void 0}}return u},b=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:c.I,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:s.dD;const l=(0,a.A)(e,1)[0],r={};return{tree:{id:"reports-treemap-root",children:y(l,0,t,r,g,n)},leafMetaById:r}}},725:(e,t,n)=>{n.d(t,{Ft:()=>l.Ft,KN:()=>l.KN,Lc:()=>i,P:()=>l.P,rd:()=>s,tY:()=>r,z0:()=>o});var a=n(13484),l=n(39250);const r=(e,t)=>{e.forEach((e=>{(0,a.A)(e.color)||o(e,t)}))},o=(e,t)=>{const n=t.find((t=>t.target===e));var a;n&&(e.color=null===(a=n.source)||void 0===a?void 0:a.color)},i=(e,t)=>{if(e.color)return;const n=t.find((t=>t.source===e));var a;n&&(e.color=null===(a=n.target)||void 0===a?void 0:a.color)},s=e=>Math.max(...e.map((e=>{let t=e.y1;return null!==t&&void 0!==t?t:0})))},86235:(e,t,n)=>{n.d(t,{BV:()=>k,Bc:()=>N,Cp:()=>x,Cz:()=>S,Fy:()=>A,GU:()=>E,He:()=>M,Ri:()=>v,TE:()=>w,TP:()=>y,W$:()=>f,YY:()=>R,ZB:()=>I,li:()=>T,qA:()=>C,sh:()=>D,xB:()=>h});var a=n(97920),l=n(66808),r=n(18850),o=n(13484),i=n(43958),s=n(21327),c=n(31808),d=n(76034),u=n(62230),m=n(73813),p=n(69416);const g=e=>e.reports,h=(0,i.Mz)(g,(e=>e.filters)),v=(0,i.Mz)(g,(e=>e.sortBy)),f=(0,i.Mz)(g,(e=>e.groupBy)),E=(0,i.Mz)(g,(e=>e.groupByTimeframe)),y=(0,i.Mz)(g,(e=>{var t;return null!==(t=e.treemapNodeCount)&&void 0!==t?t:s.dD})),b=(e,t)=>t,x=(0,i.Mz)([(e,t)=>e.reports[t],b],((e,t)=>{if((0,o.A)(e.viewMode))return e;const n=(0,p.dR)(t,e.chartType);return(0,l.A)(n)?e:(0,a.A)((0,a.A)({},e),{},{viewMode:n})})),w=(0,i.Mz)(h,(e=>Object.values(e).some(c.p6))),C=(0,i.Mz)(h,(e=>Object.values((0,r.A)(["startDate","endDate","timeframePeriod","businessEntitySet"],e)).some(c.p6))),A=(0,i.Mz)(g,(e=>{var t;return null!==(t=e.cashFlow.groupMode)&&void 0!==t?t:"both"})),I=(0,i.Mz)(g,(e=>{var t;return null!==(t=e.cashFlow.businessEntityView)&&void 0!==t?t:"byBusiness"})),k=(0,i.Mz)(g,(e=>{var t,n;const a=(0,p.IN)(e.cashFlow.chartType);return null!==(t=null===(n=e.cashFlow.activityViewByChart)||void 0===n?void 0:n[a])&&void 0!==t?t:(0,p.Vq)(a)})),S=(0,i.Mz)([g,b],((e,t)=>(0,d.qI)(e,t))),N=(0,i.Mz)(g,(e=>e.pendingLoadReportConfigurationId)),T=(0,i.Mz)(g,(e=>{var t;return null!==(t=e.profitLossExpanded)&&void 0!==t?t:p.nb})),_=[p.Gi.CashFlowChart,p.Gi.StackedCashFlowChart,p.Gi.BarChart,p.Gi.StackedBarChart],D=e=>{var t;let n=e.tab,l=e.chartType,r=e.viewMode,o=e.groupMode,i=e.groupBy,s=e.groupByTimeframe,c=e.treemapNodeCount,d=e.activityView;const u=null!==(t=null!==l&&void 0!==l?l:(0,p.n5)(n,null!==r&&void 0!==r?r:"totalAmounts"))&&void 0!==t?t:m.N_[n].chartType,g="rankedBars"===d?"breakdown":"transactions";
1return(0,a.A)((0,a.A)({tab:n,chartType:u,viewMode:["spending","income","cashFlow"].includes(n)?r:void 0,grouping:null!==o&&void 0!==o?o:i,timeframe:_.includes(u)?s:void 0},"cashFlow"===n?{contentView:g}:{}),u===p.Gi.TreemapChart?{nodeCount:c}:{})},R=(e,t)=>{const n=x(e,t),a=n.chartType,l=n.groupMode,r=n.viewMode;return D({tab:t,chartType:a,viewMode:r,groupMode:l,groupBy:f(e),groupByTimeframe:E(e),treemapNodeCount:y(e),activityView:k(e)})},M=(0,i.Mz)(g,(e=>{var t,n,a,l,r,o;return{entityId:null===(t=e.taxPrep)||void 0===t?void 0:t.entityId,taxYear:null===(n=e.taxPrep)||void 0===n?void 0:n.taxYear,period:null!==(a=null===(l=e.taxPrep)||void 0===l?void 0:l.period)&&void 0!==a?a:u.yC,showAllCategories:null!==(r=null===(o=e.taxPrep)||void 0===o?void 0:o.showAllCategories)&&void 0!==r&&r}}))},46407:(e,t,n)=>{n.d(t,{BX:()=>u,CV:()=>d,Ss:()=>o,bq:()=>i,ed:()=>m,nN:()=>r,oV:()=>s});var a=n(41820),l=n(13666);const r=a.k1,o={PAGE_TITLE:"Recurring",SKIP:"Skip",BACK:"Back",NEXT:"Next",DONE:"Done",START_USING_RECURRING:"Start using Recurring",LEARN_MORE:"Learn more",REPLAY:"Replay",BETA_BADGE:"Recurring 2.0 beta",STEP_4_IMAGE_ALT:"Recurring 2.0 beta preview",NOT_RECURRING:"Not recurring",VARIES:"varies",BETA_NOTES:"Beta notes",STEP_4_TITLE:"Welcome to the beta!",STEP_4_INTRO:"You're part of a small group getting an early look at our rebuilt recurring experience. It isn't finished \u2014 we'd rather build it with you than in isolation.",STEP_4_WHEN_BETA_ENDS:"When the beta ends",STEP_4_BETA_ENDS_BEFORE:"Access turns off while we iterate on your feedback. When 2.0 reopens, you can opt in again and",STEP_4_SETUP_FRESH:"set up fresh",STEP_4_BETA_ENDS_AFTER:", with the improvements you helped shape.",STEP_4_FEEDBACK_HEADING:"Two ways to tell us what you think",STEP_4_FEEDBACK_FORM_BOLD:"The in-app feedback form.",STEP_4_FEEDBACK_FORM_BODY:" Any time. Specifics help most: which merchant, what you expected, what you got.",STEP_4_EMAIL_SURVEY_BOLD:"An email survey.",STEP_4_EMAIL_SURVEY_BODY:" Short, but very important!"},i=(0,l.L3)("tour-beta.svg"),s=[{id:"definition",title:"Monarch automatically finds recurring transactions",paragraphs:["Anything that repeats on a predictable cadence like rent, subscriptions, utility bills, and paychecks.","Habitual spending that's frequent but not scheduled, like coffee runs, restaurant visits, and rideshares, is left out."],hasLearnMore:!0},{id:"subscriptions",title:"Identify individual subscriptions with ease",paragraphs:["You can track multiple subscriptions from a single merchant separately, making it easy to track where your money is going.","For example, if you have three Apple subscriptions, you'll see three entries."],hasLearnMore:!0},{id:"attention",title:"Always know what needs your attention",paragraphs:[],hasLearnMore:!1},{id:"beta",title:"Welcome to the beta!",paragraphs:[],hasLearnMore:!1}],c=e=>{var t;return null!==(t=s[e])&&void 0!==t?t:s[0]},d=e=>({page:c(e).id,index:e}),u=e=>{const t=Math.max(0,e-1);return{from_page:c(e).id,from_index:e,to_page:c(t).id,to_index:t}},m=[{id:"new",badge:"New",line:"Review newly detected items",body:"Confirm new recurring items, or let us know if we got it wrong. Monarch learns from your feedback and improves future detection.",hasLearnMore:!0},{id:"overdue",badge:"Overdue",line:"Know when things change",body:"If a flagged item was cancelled, mark it inactive to keep its history. Some charges are missed because they post under a different merchant name.",hasLearnMore:!0},{id:"possiblyInactive",badge:"Inactive?",line:"Clean up the clutter",body:"When three or more expected payments in a row are missed, we'll suggest marking it inactive to keep the history out of your live view.",hasLearnMore:!0}]},13666:(e,t,n)=>{n.d(t,{BE:()=>u,DJ:()=>r,L3:()=>c,LS:()=>l,X8:()=>o,aZ:()=>i,rn:()=>d,sL:()=>s});var a=n(61421);const l=450,r=750,o=250,i=700,s=1400,c=e=>(0,a.v)("static","".concat("recurring/tour","/").concat(e)),d={chase:c("chase.png"),peets:c("peets.png"),gusto:c("gusto.png"),netflix:c("netflix.png"),uber:c("uber.png")}
1,u=[{id:"chase-mortgage",name:"Chase Mortgage",subtitle:"Monthly",amount:2150,amountKind:"expense",dest:"in",logoKey:"chase"},{id:"peets",name:"Peet's Coffee",subtitle:"9 this month",amount:null,amountKind:"varies",dest:"out",logoKey:"peets"},{id:"gusto",name:"Gusto Payroll",subtitle:"Every 2 weeks",amount:2400,amountKind:"income",dest:"in",logoKey:"gusto"},{id:"netflix",name:"Netflix",subtitle:"Monthly",amount:15.99,amountKind:"expense",dest:"in",logoKey:"netflix"},{id:"uber",name:"Uber",subtitle:"11 this month",amount:null,amountKind:"varies",dest:"out",logoKey:"uber"}]},1506:(e,t,n)=>{n.d(t,{Lz:()=>a,Z6:()=>r,ns:()=>l});const a="income",l="savings";var r;!function(e){e.CategoryGroup="categoryGroup",e.Category="category",e.Generic="generic"}(r||(r={}))},13178:(e,t,n)=>{n.d(t,{FL:()=>r,VF:()=>l,yY:()=>o});var a=n(95453);const l=(0,a.J)("\n  query Common_GetReportsData(\n    $filters: TransactionFilterInput!\n    $groupBy: [ReportsGroupByEntity!]\n    $groupByTimeframe: ReportsGroupByTimeframe\n    $sortBy: ReportsSortBy\n    $includeCategory: Boolean = false\n    $includeCategoryGroup: Boolean = false\n    $includeMerchant: Boolean = false\n    $includeBusinessEntity: Boolean = false\n    $includeBudgetVariability: Boolean = false\n    $includeOwner: Boolean = false\n    $fillEmptyValues: Boolean = true\n  ) {\n    reports(\n      groupBy: $groupBy\n      groupByTimeframe: $groupByTimeframe\n      filters: $filters\n      sortBy: $sortBy\n      fillEmptyValues: $fillEmptyValues\n    ) {\n      groupBy {\n        date\n        ...ReportsCategoryFields @include(if: $includeCategory)\n        ...ReportsCategoryGroupFields @include(if: $includeCategoryGroup)\n        ...ReportsMerchantFields @include(if: $includeMerchant)\n        ...ReportsBusinessEntityFields @include(if: $includeBusinessEntity)\n        ...ReportsBudgetVariabilityFields @include(if: $includeBudgetVariability)\n        ...ReportsOwnerFields @include(if: $includeOwner)\n      }\n      summary {\n        ...ReportsSummaryFields\n      }\n    }\n\n    aggregates(filters: $filters, fillEmptyValues: $fillEmptyValues) {\n      summary {\n        ...ReportsSummaryFields\n      }\n    }\n  }\n\n  fragment ReportsSummaryFields on TransactionsSummary {\n    ...TransactionSummaryFields\n    count\n    savings\n    savingsRate\n  }\n\n  fragment ReportsCategoryFields on ReportsGroupByData {\n    category {\n      id\n      name\n      icon\n      group {\n        id\n        name\n        type\n      }\n    }\n  }\n\n  fragment ReportsCategoryGroupFields on ReportsGroupByData {\n    categoryGroup {\n      id\n      name\n      type\n    }\n  }\n\n  fragment ReportsMerchantFields on ReportsGroupByData {\n    merchant {\n      id\n      name\n      logoUrl\n    }\n  }\n\n  fragment ReportsBusinessEntityFields on ReportsGroupByData {\n    businessEntity {\n      id\n      name\n      color\n      icon\n      logoUrl\n    }\n  }\n\n  fragment ReportsBudgetVariabilityFields on ReportsGroupByData {\n    budgetVariability {\n      id\n      name\n    }\n  }\n\n  fragment ReportsOwnerFields on ReportsGroupByData {\n    owner {\n      id\n      name\n      displayName\n    }\n  }\n"),r=(0,a.J)("\n  query Common_GetBusinessEntityReportsDataByCategory($filters: TransactionFilterInput!) {\n    reports(groupBy: [business_entity, category], filters: $filters, fillEmptyValues: false) {\n      groupBy {\n        businessEntity {\n          id\n          name\n          color\n          logoUrl\n        }\n        category {\n          id\n          name\n          icon\n          group {\n            id\n            name\n            type\n          }\n        }\n      }\n      summary {\n        ...ReportsSummaryFields\n      }\n    }\n\n    businessEntitySummaries(filters: $filters) {\n      businessEntity {\n        id\n        name\n        color\n        logoUrl\n      }\n      summary {\n        ...ReportsSummaryFields\n      }\n    }\n\n    aggregates(filters: $filters, fillEmptyValues: false) {\n      summary {\n        ...ReportsSummaryFields\n      }\n    }\n  }\n"),o=(0,a.J)("\n  query Common_GetBusinessEntityReportsDataByGroup($filters: TransactionFilterInput!) {\n    reports(groupBy: [business_entity, category_group], filters: $filters, fillEmptyValues: false) {\n      groupBy {\n        businessEntity {\n          id\n          name\n          color\n          logoUrl\n        }\n        categoryGroup {\n          id\n          name\n          type\n        }\n      }\n      summary {\n        ...ReportsSummaryFields\n      }\n    }\n\n    businessEntitySummaries(filters: $filters) {\n      businessEntity {\n        id\n        name\n        color\n        logoUrl\n      }\n      summary {\n        ...ReportsSummaryFields\n      }\n    }\n\n    aggregates(filters: $filters, fillEmptyValues: false) {\n      summary {\n        ...ReportsSummaryFields\n      }\n    }\n  }\n")},97380:(e,t,n)=>{n.d(t,{A2:()=>v,A4:()=>y,I8:()=>x,X4:()=>w,o2:()=>b,pn:()=>g,yw:()=>E});var a=n(97920),l=n(92621),r=n(85151),o=n(75893),i=n(16049),s=n(13484),c=n(20361),d=n(76788),u=n(14728),m=n(15660);const p=[m.WrU.SPENDING,m.WrU.CONTRIBUTION,m.WrU.REBALANCE,m.WrU.WITHDRAWAL,m.WrU.PRICE_CHANGE,m.WrU.TRANSACTION_ADJUSTMENT],g=e=>(0,s.A)(e)&&(0,s.A)(e.type)&&p.includes(e.type)&&0!==e.amount,h=[m.WrU.REBALANCE,m.WrU.PRICE_CHANGE,m.WrU.TRANSACTION_ADJUSTMENT],v=e=>(0,s.A)(e)&&h.includes(e),f=[m.WrU.REBALANCE,m.WrU.PRICE_CHANGE],E=e=>"aggregatedFrom"in e&&Array.isArray(e.aggregatedFrom)&&e.aggregatedFrom.length>1,y=e=>{const t=e.filter((e=>h.includes(e.type))),n=e.filter((e=>!h.includes(e.type))),r=(0,l.A)((e=>"".concat(e.date,"-").concat(e.account.id)),t);return[...n,...Object.values(r).filter((e=>e.some((e=>f.includes(e.type))))).map((e=>{const t=e.reduce(((e,t)=>e+t.amount),0),n=e.find((e=>f.includes(e.type)));if(n)return(0,a.A)((0,a.A)({},n),{},{amount:t,aggregatedFrom:e.length>1?e:void 0})})).filter(s.A)]},b=e=>{var t;const n=null!==(t=e.filter(s.A))&&void 0!==t?t:[],a=(0,r.A)([(0,o.A)((0,i.A)("date")),(0,o.A)((0,i.A)("createdAt"))],n);return(0,l.A)((0,i.A)("date"),a)},x=e=>
1(0,c.YW)(e).with({type:c.P.union(m.WrU.REBALANCE,m.WrU.PRICE_CHANGE,m.WrU.TRANSACTION_ADJUSTMENT)},(()=>"Adjustment")).otherwise((()=>{var t;return(0,d.ZH)(null!==(t=e.type)&&void 0!==t?t:"").replaceAll("_"," ")})),w=e=>(0,c.YW)(e).with({type:m.WrU.CONTRIBUTION},(()=>u.$.GOAL_EVENT_TOOLTIPS.CONTRIBUTION)).with({type:m.WrU.WITHDRAWAL},(()=>u.$.GOAL_EVENT_TOOLTIPS.WITHDRAWAL)).with({type:c.P.union(m.WrU.REBALANCE,m.WrU.PRICE_CHANGE,m.WrU.TRANSACTION_ADJUSTMENT)},(()=>u.$.GOAL_EVENT_TOOLTIPS.REBALANCE)).otherwise((()=>{}))},39250:(e,t,n)=>{n.d(t,{Ft:()=>s,KN:()=>u,P:()=>p,rI:()=>m});var a=n(461),l=n(85151),r=n(13484);const o=(0,a.A)((e=>{var t;return null!==(t=e.depth)&&void 0!==t?t:0})),i=(0,a.A)((e=>{var t;return null!==(t=e.y0)&&void 0!==t?t:0})),s=function(e){let t=arguments.length>3?arguments[3]:void 0;const n=(arguments.length>1&&void 0!==arguments[1]?arguments[1]:24)+(arguments.length>2&&void 0!==arguments[2]?arguments[2]:16),a=null!==t&&void 0!==t?t:{},l=a.getNodeGroup,r=a.groupPadding,o=void 0===r?0:r,i=a.getNodeGroupSortKey,s=a.applyCrossColumnSpacing,u=void 0===s||s;if(c(e,n,l,o,{getNodeGroupSortKey:i}),l&&o>0&&u){const t=new Map(e.map((e=>{var t;return[e,null!==(t=e.y0)&&void 0!==t?t:0]})));d(e,n,l,o,i,t)}},c=function(e,t,n){let s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,c=arguments.length>4?arguments[4]:void 0;var d,u,m,p,g,h,v,f;const E=null!==c&&void 0!==c?c:{},y=E.getNodeGroupSortKey,b=E.preserveNodePositions,x=void 0!==b&&b,w=E.referenceY0,C=w?(0,a.A)((e=>{var t,n;return null!==(n=null!==(t=w.get(e))&&void 0!==t?t:e.y0)&&void 0!==n?n:0})):i,A=n?(0,a.A)((e=>{const t=n(e);return y?y(t):0})):C,I=(0,l.A)([o,A,C],e),k=new Map;for(const a of I){const e=null!==(d=a.depth)&&void 0!==d?d:0,t=null!==(u=k.get(e))&&void 0!==u?u:[];t.push(a),k.set(e,t)}for(const a of k.values()){let e=null!==(p=null===(m=a[0])||void 0===m?void 0:m.y0)&&void 0!==p?p:0;for(let l=0;l<a.length;l+=1){const o=a[l],i=(null!==(g=o.y1)&&void 0!==g?g:0)-(null!==(h=o.y0)&&void 0!==h?h:0);if((0,r.A)(o.y0)&&(0,r.A)(o.y1)){const t=x?Math.max(null!==(v=o.y0)&&void 0!==v?v:0,e):e;o.y0=t,o.y1=t+i}const c=a[l+1];if(c){const a=t+(n&&n(o)!==n(c)?s:0);e=(null!==(f=o.y1)&&void 0!==f?f:0)+a}}}},d=(e,t,n,a,l,o)=>{var i,s,d,u,m,p,g,h,v,f;const E=t,y=new Map;for(const r of e){const e=null!==(i=r.depth)&&void 0!==i?i:0,t=null!==(s=y.get(e))&&void 0!==s?s:[];t.push(r),y.set(e,t)}const b=[...y.keys()].sort(((e,t)=>e-t));for(let x=0;x<b.length-1;x+=1){const e=null!==(d=y.get(b[x]))&&void 0!==d?d:[],i=null!==(u=y.get(b[x+1]))&&void 0!==u?u:[];for(const t of e){const e=n(t),a=null!==(m=null===l||void 0===l?void 0:l(e))&&void 0!==m?m:0;for(const o of i){const i=n(o);if(i===e)continue;const s=null!==(p=null===l||void 0===l?void 0:l(i))&&void 0!==p?p:0,c=null!==(g=t.y0)&&void 0!==g?g:0,d=null!==(h=t.y1)&&void 0!==h?h:0,u=null!==(v=o.y0)&&void 0!==v?v:0,m=null!==(f=o.y1)&&void 0!==f?f:0;if(u<d+E&&c<m+E)if(l&&a!==s){const e=a>s,n=e?t:o,l=e?m:d,i=e?c:u;if((0,r.A)(n.y0)&&(0,r.A)(n.y1)){const e=l+E-i;e>0&&(n.y0+=e,n.y1+=e)}}else if(u>=c){if((0,r.A)(o.y0)&&(0,r.A)(o.y1)){const e=d+E-u;e>0&&(o.y0+=e,o.y1+=e)}}else if((0,r.A)(t.y0)&&(0,r.A)(t.y1)){const e=m+E-c;e>0&&(t.y0+=e,t.y1+=e)}}}c(e,t,n,a,{getNodeGroupSortKey:l,preserveNodePositions:!0,referenceY0:o}),c(i,t,n,a,{getNodeGroupSortKey:l,preserveNodePositions:!0,referenceY0:o})}},u=e=>{e.forEach((e=>{const t=e.sourceLinks,n=e.targetLinks;t&&t.length>1&&t.sort(((e,t)=>{var n,a,l,r;return(null!==(a=null===(n=e.target)||void 0===n?void 0:n.y0)&&void 0!==a?a:0)-(null!==(r=null===(l=t.target)||void 0===l?void 0:l.y0)&&void 0!==r?r:0)})),n&&n.length>1&&n.sort(((e,t)=>{var n,a,l,r;return(null!==(a=null===(n=e.source)||void 0===n?void 0:n.y0)&&void 0!==a?a:0)-(null!==(r=null===(l=t.source)||void 0===l?void 0:l.y0)&&void 0!==r?r:0)}))}))},m=(e,t)=>{const n=e=>{var n,a;return"".concat(null!==(n=null===t||void 0===t?void 0:t(e))&&void 0!==n?n:"","::").concat(null!==(a=e.depth)&&void 0!==a?a:0)},a=e.reduce(((e,t)=>{var a,l;const r=n(t);return e[r]=(null!==(a=e[r])&&void 0!==a?a:0)+(null!==(l=t.value)&&void 0!==l?l:0),e}),{});e.forEach((e=>{var t;e.percent=(null!==(t=e.value)&&void 0!==t?t:0)/a[n(e)]}))},p=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:.5,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;const a=e.y0,l=e.y1,r=e.width,o=e.source,i=e.target;if(void 0===a||void 0===l||void 0===r||void 0===o.x1||void 0===i.x0)return null;const s=o.x1,c=i.x0,d=Math.max(.1,Math.min(.9,t)),u=c-s,m=s+u*d,p=c-u*d,g=Math.max(r,n),h=a-g/2,v=a+g/2,f
1=l-g/2,E=l+g/2;return["M".concat(s,",").concat(h),"C".concat(m,",").concat(h," ").concat(p,",").concat(f," ").concat(c,",").concat(f),"L".concat(c,",").concat(E),"C".concat(p,",").concat(E," ").concat(m,",").concat(v," ").concat(s,",").concat(v),"Z"].join(" ")}}}]);
2//# sourceMappingURL=6972.0265ac09.chunk.js.map

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.