1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[2767],{38676:(e,a,t)=>{"use strict";t.d(a,{Qn:()=>r,Zt:()=>n,vv:()=>l,zN:()=>o});let s={USD:{symbol:"$",name:"US Dollar",locale:"en-US"},EUR:{symbol:"â¬",name:"Euro",locale:"de-DE"},GBP:{symbol:"\xa3",name:"British Pound",locale:"en-GB"},CAD:{symbol:"C$",name:"Canadian Dollar",locale:"en-CA"},AUD:{symbol:"A$",name:"Australian Dollar",locale:"en-AU"}};function l(e){let a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"USD",t=arguments.length>2?arguments[2]:void 0,l=s[a],r=(null==t?void 0:t.wholeNumber)||(null==t?void 0:t.compact);return new Intl.NumberFormat(l.locale,{style:"currency",currency:a,notation:(null==t?void 0:t.compact)?"compact":"standard",minimumFractionDigits:2*!r,maximumFractionDigits:(null==t?void 0:t.compact)?1:2*!r,signDisplay:(null==t?void 0:t.showSign)?"exceptZero":"auto"}).format(e)}function r(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"USD";return s[e].symbol}function n(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"USD";return s[e].name}function o(){return Object.keys(s).map(e=>({code:e,symbol:s[e].symbol,name:s[e].name}))}},46975:e=>{e.exports={skeleton:"skeleton_skeleton__IrghC",skeletonShimmer:"skeleton_skeletonShimmer__5nQYZ"}},47054:e=>{e.exports={page:"manage_page__uRwo6",lightMode:"manage_lightMode__SblJ_",bgEffects:"manage_bgEffects__KTPEj",gridLines:"manage_gridLines__G4Xp_",glowOrb:"manage_glowOrb__FKQeQ",main:"manage_main__cU1_b",loadingContainer:"manage_loadingContainer__cdRuQ",vaultDoor:"manage_vaultDoor__PbqIg",vaultSpinner:"manage_vaultSpinner__aBsni",spin:"manage_spin__Mcu0p",header:"manage_header__0_Ewo",headerContent:"manage_headerContent__tAxbM",headerLeft:"manage_headerLeft__yPRkV",backBtn:"manage_backBtn__RkREG",title:"manage_title__aAeud",subtitle:"manage_subtitle__DAh_F",headerCenter:"manage_headerCenter__erbd2",headerRight:"manage_headerRight__bNyOu",actionBtn:"manage_actionBtn__xa8fk",content:"manage_content__W9ozy",introBanner:"manage_introBanner__ysBaH",fadeInUp:"manage_fadeInUp__uyz_v",introBannerIcon:"manage_introBannerIcon__WCLzB",introBannerText:"manage_introBannerText__nYxz0",introBannerTitle:"manage_introBannerTitle__rZTGW",introBannerDesc:"manage_introBannerDesc__GyBCT",vaultGrid:"manage_vaultGrid__siFT9",vaultCard:"manage_vaultCard___cCwJ",cardEnter:"manage_cardEnter__fvkeu",vaultCardInner:"manage_vaultCardInner__Vuumc",vaultGlow:"manage_vaultGlow__ClPjd",vaultIcon:"manage_vaultIcon__uwnI3",vaultContent:"manage_vaultContent__EsAfK",vaultTitle:"manage_vaultTitle__BKamG",vaultSubtitle:"manage_vaultSubtitle__cg519",vaultStats:"manage_vaultStats__P2rkc",vaultPrimary:"manage_vaultPrimary__OITCy",vaultSecondary:"manage_vaultSecondary__OnavU",vaultArrow:"manage_vaultArrow__r6Yw3",vaultLock:"manage_vaultLock__8PBiW",vaultCardSelected:"manage_vaultCardSelected__X6aZ6",vaultUnlock:"manage_vaultUnlock__fMy8E",unlockPulse:"manage_unlockPulse__DnWO1",vaultLockUnlocking:"manage_vaultLockUnlocking__kZ3DF",lockOpen:"manage_lockOpen__Z77OY",vaultCardFading:"manage_vaultCardFading__UM2Hj",cardFadeOut:"manage_cardFadeOut__oiakK",vaultGridExiting:"manage_vaultGridExiting__gQWGA",detailView:"manage_detailView__4SygR",detailViewVisible:"manage_detailViewVisible__cXJ0S",detailSection:"manage_detailSection__wxRdi",detailSlideUp:"manage_detailSlideUp__eA_wC",detailHeader:"manage_detailHeader__rRmJD",detailStat:"manage_detailStat__7utN3",detailStatLabel:"manage_detailStatLabel__MwLlD",detailStatValue:"manage_detailStatValue__2Ul2L",negative:"manage_negative__3Nf4t",success:"manage_success__7KiAe",detailStatSublabel:"manage_detailStatSublabel__9fWF_",detailList:"manage_detailList__rxY6e",detailRow:"manage_detailRow__DTRBQ",rowSlideIn:"manage_rowSlideIn__vyvLP",detailRowLeft:"manage_detailRowLeft__G39_U",detailRowNameWithColor:"manage_detailRowNameWithColor__O6uvi",categoryDot:"manage_categoryDot__eGHak",debtBadge:"manage_debtBadge__XKjBc",detailRowNameWithBadge:"manage_detailRowNameWithBadge__Q0CfC",focusBadge:"manage_focusBadge__JlL85",priorityRow:"manage_priorityRow__W_a2M",detailRowName:"manage_detailRowName__cJBxQ",detailRowMeta:"manage_detailRowMeta__QT9xV",detailRowRight:"manage_detailRowRight__3rkeV",detailRowAmount:"manage_detailRowAmount__nqzqH",detailRowRemaining:"manage_detailRowRemaining__3FKNg",detailRowStatus:"manage_detailRowStatus___8SxU",active:"manage_active__VVPSX",detailRowActions:"manage_detailRowActions__7NCaY",detailRowActionBtn:"manage_detailRowActionBtn__wk_Ix",deleteBtn:"manage_deleteBtn__CFgZs",disabled:"manage_disabled__lNoBm",miniProgress:"manage_miniProgress__Zr3s2",miniProgressFill:"manage_miniProgressFill__Jvi5s",over:"manage_over__vRpcp",detailAddBtn:"manage_detailAddBtn__jqLJb",emptyState:"manage_emptyState__s8d_J",emptyIcon:"manage_emptyIcon__qtXjL",createPlanBtn:"manage_createPlanBtn__kloJT",planActions:"manage_planActions__Q7QLU",planActionBtn:"manage_planActionBtn__w6d1z",planActionBtnWarning:"manage_planActionBtnWarning__M_Ima",planActionBtnPrimary:"manage_planActionBtnPrimary__75DN8",statusBanner:"manage_statusBanner__BKye5",statusPaused:"manage_statusPaused__FqHTG",statusDeferred:"manage_statusDeferred__7x3QD",statusIcon:"manage_statusIcon__mR4oC",statusInfo:"manage_statusInfo__00dK9",statusTitle:"manage_statusTitle__C
1d66S",statusText:"manage_statusText__x9sid",pulse:"manage_pulse__cVpGI"}},48003:(e,a,t)=>{Promise.resolve().then(t.bind(t,72274))},69029:e=>{e.exports={vaultGrid:"vault-card_vaultGrid__kNZSJ",vaultGridExiting:"vault-card_vaultGridExiting__DTPNi",vaultCard:"vault-card_vaultCard__u1x45",cardEnter:"vault-card_cardEnter__DIKy0",vaultCardInner:"vault-card_vaultCardInner__8h5L2",vaultGlow:"vault-card_vaultGlow__kr_a0",vaultIcon:"vault-card_vaultIcon__zbYGx",vaultContent:"vault-card_vaultContent__xh6ug",vaultTitle:"vault-card_vaultTitle__MhPo6",vaultSubtitle:"vault-card_vaultSubtitle__NuPRB",vaultStats:"vault-card_vaultStats__lnDJ9",vaultPrimary:"vault-card_vaultPrimary__jFL6y",vaultSecondary:"vault-card_vaultSecondary__EJbAx",vaultArrow:"vault-card_vaultArrow__PIJak",vaultLock:"vault-card_vaultLock__tgGy3",vaultCardSelected:"vault-card_vaultCardSelected__r73ux",vaultUnlock:"vault-card_vaultUnlock__exuUw",unlockPulse:"vault-card_unlockPulse__YnWKW",vaultLockUnlocking:"vault-card_vaultLockUnlocking__br9do",lockOpen:"vault-card_lockOpen__QqzjS",vaultCardFading:"vault-card_vaultCardFading__Mt0xR",cardFadeOut:"vault-card_cardFadeOut__8Va5C",vaultStatsLoading:"vault-card_vaultStatsLoading__8Z43F",spin:"vault-card_spin__NEBM4"}},70509:(e,a,t)=>{"use strict";t.d(a,{J:()=>c,T:()=>i});var s=t(54568),l=t(27186),r=t(95730);let n={hidden:{},visible:{transition:{staggerChildren:.18,delayChildren:.25}}},o={hidden:{opacity:0,y:18},visible:{opacity:1,y:0,transition:{duration:.75,ease:[.22,1,.36,1]}}};function c(e){let{children:a,className:t,delay:o,stagger:c}=e,i=(0,l.I)(),d=void 0!==o||void 0!==c?{...n,visible:{transition:{...n.visible.transition,...void 0!==o&&{delayChildren:o},...void 0!==c&&{staggerChildren:c}}}}:n;return(0,s.jsx)(r.P.div,{variants:d,initial:!i&&"hidden",animate:"visible",className:t,children:a})}function i(e){let{children:a,className:t}=e;return(0,s.jsx)(r.P.div,{variants:o,className:t,children:a})}},72274:(e,a,t)=>{"use strict";t.r(a),t.d(a,{default:()=>eI});var s=t(54568),l=t(7620),r=t(27541),n=t(24560),o=t(93558),c=t(47054),i=t.n(c),d=t(86383),m=t(70509),u=t(81699),x=t(93637),h=t(5530),p=t(42030),g=t(48367),y=t(41754),v=t(61811),b=t(78036),j=t(31321),f=t(74166),N=t.n(f);let w=e=>Math.round(e),C=["#3B82F6","#10B981","#F59E0B","#EF4444","#8B5CF6","#EC4899","#06B6D4","#84CC16"];function _(e){let{isOpen:a,onClose:t,editingCategory:r,existingCategories:n,budgetIncome:o,totalAllocated:c,onSave:i}=e,{symbol:d,format:m}=(0,b.H)(),u=e=>m(Math.round(e)),[x,f]=(0,l.useState)(""),[_,A]=(0,l.useState)(""),[k,S]=(0,l.useState)(C[0]),[I,R]=(0,l.useState)("tag"),[B,D]=(0,l.useState)(!1),[T,M]=(0,l.useState)(!1),[F,P]=(0,l.useState)(null),[L,E]=(0,l.useState)(!1),[W,z]=(0,l.useState)([]),H=!!r,V=parseFloat(_)||0,U=(null==r?void 0:r.allocated)||0,q=c+V,O=o-q,Y=q>o,G=Y?q-o:0,J=H&&V<U?U-V:0,Q=J>0&&O>0,K=Y&&V>0?"increase":Q?"decrease":null,Z="increase"===K?G:"decrease"===K?J:0;(0,l.useEffect)(()=>{if(a){if(r){f(r.name),A(r.allocated.toString());let e=r.color;S(e&&/^#[0-9A-Fa-f]{6}$/.test(e)?e:(0,j.zq)(e)),R((0,j.ly)(r.icon,r.name)),D(!!r.icon)}else f(""),A(""),S(C[Math.floor(Math.random()*C.length)]),R("tag"),D(!1);P(null),E(!1),z([])}},[a,r]),(0,l.useEffect)(()=>{L&&K&&z(n.filter(e=>(!r||e.id!==r.id)&&("increase"!==K||!e.isDebt)&&("increase"===K?e.allocated-e.spent>0:!e.isDebt)).map(e=>({categoryId:e.id,name:e.name,currentAllocated:e.allocated,spent:e.spent,availableToReduce:e.allocated-e.spent,adjustAmount:0})))},[L,K,n,r]);let X=(0,l.useMemo)(()=>W.reduce((e,a)=>e+a.adjustAmount,0),[W]),$=Z-X,ee=$<=.99,ea=(e,a)=>{z(t=>t.map(t=>{if(t.categoryId!==e)return t;let s=Math.max(0,a);return"increase"===K&&(s=Math.min(s,t.availableToReduce)),{...t,adjustAmount:s}}))},et=async e=>{if(e.preventDefault(),P(null),!x.trim())return void P("Category name is required");if(V<=0)return void P("Allocated amount must be greater than 0");if(H&&r&&V<r.spent)return void P("Cannot reduce below spent amount (".concat(d).concat(r.spent.toLocaleString(),")"));if(H&&r&&r.isDebt&&r.minimumPayment&&V<r.minimumPayment)return void P("Cannot reduce debt payment below minimum payment (".concat(d).concat(r.minimumPayment.toLocaleStr
1ing(),")"));if(n.some(e=>e.name.toLowerCase()===x.trim().toLowerCase()&&e.id!==(null==r?void 0:r.id)))return void P("A category with this name already exists");if(K&&!L)return void E(!0);if(L&&K&&!ee){let e="increase"===K?"free up":"allocate";P("You still need to ".concat(e," ").concat(d).concat(u($)));return}M(!0);try{let e;if(L&&W.length>0&&K){let a=W.filter(e=>e.adjustAmount>0);if(a.length>0){let t=Math.round(Z),s=0;e=a.map((e,l)=>{if(l===a.length-1){let a=t-s;return{categoryId:e.categoryId,newAllocated:"increase"===K?e.currentAllocated-a:e.currentAllocated+a}}{let a=Math.round(e.adjustAmount);return s+=a,{categoryId:e.categoryId,newAllocated:"increase"===K?e.currentAllocated-a:e.currentAllocated+a}}})}}await i({name:x.trim(),allocated:Math.round(V),color:k,icon:I,rebalanceChanges:e}),t()}catch(a){let{message:e}=(0,v.P)(a);P(e)}finally{M(!1)}},es=()=>{T||t()};return a?(0,s.jsx)("div",{className:N().overlay,onClick:e=>{e.target===e.currentTarget&&es()},children:(0,s.jsxs)("div",{className:"".concat(N().modal," ").concat(N().modalLarge),role:"dialog","aria-modal":"true",children:[(0,s.jsxs)("div",{className:N().header,children:[(0,s.jsx)("div",{className:N().headerLeft,children:(0,s.jsx)("h2",{className:N().headerTitle,children:H?"Edit Category":"Add Category"})}),(0,s.jsx)("button",{onClick:es,disabled:T,className:N().closeButton,children:(0,s.jsx)(h.A,{className:"h-6 w-6"})})]}),(0,s.jsxs)("form",{onSubmit:et,children:[(0,s.jsxs)("div",{className:L?N().contentRebalancing:N().content,children:[F&&(0,s.jsxs)("div",{className:N().errorBox,children:[(0,s.jsx)(p.A,{className:"h-5 w-5 ".concat(N().errorIcon)}),(0,s.jsx)("p",{className:N().errorText,children:F})]}),!L&&(0,s.jsxs)("div",{className:N().fieldGroup,children:[(0,s.jsx)("label",{className:N().label,children:"Category Name"}),(0,s.jsx)("input",{type:"text",value:x,onChange:e=>{let a=e.target.value;f(a),!B&&a.trim()&&R((0,j.ly)(null,a))},placeholder:"e.g., Groceries, Entertainment",className:N().input,maxLength:100,disabled:T,autoFocus:!0})]}),!L&&(0,s.jsxs)("div",{className:N().fieldGroup,children:[(0,s.jsx)("label",{className:N().label,children:"Monthly Budget"}),(0,s.jsxs)("div",{className:N().inputWrapper,children:[(0,s.jsx)("span",{className:N().inputPrefix,children:d}),(0,s.jsx)("input",{type:"number",step:"1",min:"0",value:_,onChange:e=>{A(e.target.value.replace(/[^0-9]/g,"")),E(!1),z([])},placeholder:"0",className:"".concat(N().input," ").concat(N().inputWithPrefix),disabled:T})]}),(0,s.jsx)("p",{className:N().hint,children:"Round dollar amounts only"}),(0,s.jsxs)("div",{className:N().budgetContext,children:[(0,s.jsx)("span",{children:"Budget: "}),(0,s.jsxs)("span",{className:N().budgetContextValue,children:[d,u(o)]}),(0,s.jsx)("span",{children:" \xb7 Currently allocated: "}),(0,s.jsxs)("span",{className:N().budgetContextValue,children:[d,u(c)]})]}),V>0&&(0,s.jsx)("div",{className:N().budgetContext,children:w(O)>=0?(0,s.jsxs)("span",{className:N().statusPositive,children:["After change: ",d,u(Math.abs(O))," available"]}):(0,s.jsxs)("span",{className:N().statusNegative,children:["After change: ",d,u(Math.abs(O))," over budget"]})}),H&&r&&r.spent>0&&(0,s.jsxs)("div",{className:"".concat(N().budgetContext," ").concat(N().statusWarning),style:{fontSize:"0.75rem"},children:["Already spent: ",d,u(r.spent)," (minimum you can set)"]}),K&&!L&&V>0&&(0,s.jsx)("div",{className:"".concat(N().warningBox," ").concat("increase"===K?N().warningBoxIncrease:N().warningBoxDecrease),style:{marginTop:"0.75rem"},children:(0,s.jsx)("p",{className:"".concat(N().warningText," ").concat("increase"===K?N().warningTextIncrease:N().warningTextDecrease),children:"increase"===K?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(g.A,{className:"h-4 w-4 inline mr-1"}),"This would exceed your budget by ",(0,s.jsxs)("strong",{children:[d,u(G)]}),". You'll need to reduce other categories."]}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(y.A,{className:"h-4 w-4 inline mr-1"}),"This frees up ",(0,s.jsxs)("strong",{children:[d,u(J)]}),". Every dollar needs a job - allocate it to other categories."]})})})]}),!L&&(0,s.jsxs)("div",{className:N().fieldGroup,children:[(0,s.jsx)("label",{className:N().label,children:"Color"}),(0,s.jsx)("div",{className:N().colorGrid,children:C.map(e=>(0,s.jsx)("button",{type:"button",onClick:()=>S(e),className:"".concat(N().colorButton," ").concat(k===e?N().colorButtonSelected:""),style:{backgroundColor:e},disabled:T},e))})]}),!L&&(0,s.jsxs)("div",{className:N().fieldGroup,children:[(0,s.jsx)("label",{className:N().label,children:"Icon"}),(0,s.jsx)("div",{className:N().iconGrid,children:j.Z0.map(e=>{let a=j.tS[e],t=I===e;return(0,s.jsx)("button",{type:"button",onClick:()=>{R(e),D(!0)},className:"".concat(N().iconButton," ").concat(t?N().iconButtonSelected:""),disabled:T,title:e,children:(0,s.jsx)(a,{size:18,strokeWidth:2})},e)})})]}),L&&K&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("div",{className:"".concat(N().rebalanceHeader," ").concat("increase"===K?N().rebalanceHeaderIncrease:N().rebalanceHeaderDecrease),children:[(0,s.jsxs)("div",{className:N().rebalanceSummary,children:[(0,s.jsxs)("div",{className:N().rebalanceSummaryCategory,children:[(0,s.jsx)("div",{className:N().categoryColorDot,style:{backgroundColor:k}}),(0,s.jsx)("span",{className:N().categoryName,children:x})]}),(0,s.jsxs)("span",{className:N().rebalanceSummaryAmount,children:[H?"".concat(d).concat(u(U)," â "):"",(0,s.jsxs)("span",{className:N().rebalanceSummaryAmountNew,children:[d,u(V)]})]})]}),(0,s.jsx)("h3",{className:"".concat(N().rebalanceTitle," ").concat("increase"===K?N().rebalanceTitleIncrease:N().rebalanceTitleDecrease),children:"increase"===K?"Free Up Funds":"Allocate Freed Funds"}),(0,s.jsx)("p",{className:"".concat(N().rebalanceDescription," ").concat("increase"===K?N().rebalanceDescriptionIncrease:N().rebalanceDescriptionDecrease),children:"increase"===K?"Reduce other categories to free up ".concat(d).concat(u(Z)):"Allocate the freed ".concat(d).concat(u(Z)," to other categories")}),(0,s.jsxs)("div",{className:N().progressContainer,children:[(0,s.jsx)("div",{className:N().progressTrack,children:(0,s.jsx)("div",{className:"".concat(N().progressFill," ").concat(ee?N().progressFillC
1omplete:"increase"===K?N().progressFillIncrease:N().progressFillDecrease),style:{width:"".concat(Z>0?Math.min(X/Z*100,100):0,"%")}})}),(0,s.jsxs)("span",{className:"".concat(N().progressLabel," ").concat(ee?N().progressLabelComplete:N().progressLabelPending),children:[d,u(X)," / ",d,u(Z)]})]})]}),W.length>0?(0,s.jsx)("div",{className:N().categoryList,children:W.map(e=>(0,s.jsxs)("div",{className:N().categoryRow,children:[(0,s.jsx)("div",{className:N().categoryRowHeader,children:(0,s.jsxs)("div",{className:N().categoryRowInfo,children:[(0,s.jsx)("span",{className:N().categoryRowName,children:e.name}),(0,s.jsxs)("span",{className:N().categoryRowMeta,children:["Current: ",d,u(e.currentAllocated),"increase"===K&&(0,s.jsxs)(s.Fragment,{children:[" \xb7 Available: ",d,u(e.availableToReduce)]})]})]})}),(0,s.jsxs)("div",{className:N().categoryRowControls,children:[(0,s.jsx)("input",{type:"range",min:"0",max:"increase"===K?e.availableToReduce:Z,value:e.adjustAmount,onChange:a=>ea(e.categoryId,parseFloat(a.target.value)),className:N().categorySlider}),(0,s.jsxs)("div",{className:N().categoryInputWrapper,children:[(0,s.jsxs)("span",{className:N().categoryInputPrefix,children:["increase"===K?"-":"+",d]}),(0,s.jsx)("input",{type:"number",min:"0",max:"increase"===K?e.availableToReduce:void 0,value:e.adjustAmount||"",onChange:a=>ea(e.categoryId,parseFloat(a.target.value)||0),className:N().categoryInput})]})]}),(0,s.jsx)("div",{className:N().quickAmounts,children:(()=>{let a=w($),t="increase"===K?e.availableToReduce:Z;return[...new Set([a>0&&a<=t?a:null,10,25,50,100].filter(a=>null!==a&&!(a<=0)&&("increase"!==K||!(a>e.availableToReduce))))].slice(0,4).map((t,l)=>(0,s.jsx)("button",{type:"button",onClick:()=>ea(e.categoryId,e.adjustAmount+t),className:"".concat(N().quickAmountBtn," ").concat(t===a?N().quickAmountBtnExact:N().quickAmountBtnNormal),children:t===a?"".concat(d).concat(t," (exact)"):"+".concat(d).concat(t)},"".concat(e.categoryId,"-").concat(t,"-").concat(l)))})()})]},e.categoryId))}):(0,s.jsx)("div",{className:N().errorBox,children:(0,s.jsx)("p",{className:N().errorText,children:"increase"===K?"No categories have available funds to reduce. All spending matches or exceeds allocations.":"No other categories available to receive funds."})})]})]}),(0,s.jsxs)("div",{className:N().footer,children:[(0,s.jsx)("div",{className:N().footerLeft,children:L&&(0,s.jsx)("button",{type:"button",onClick:()=>{E(!1),z([])},disabled:T,className:N().backButton,children:"â Back"})}),(0,s.jsxs)("div",{className:N().footerRight,children:[(0,s.jsx)("button",{type:"button",onClick:es,disabled:T,className:N().secondaryButton,children:"Cancel"}),(0,s.jsx)("button",{type:"submit",disabled:T||L&&!ee,className:N().primaryButton,children:T?(0,s.jsxs)("span",{className:"flex items-center gap-2",children:[(0,s.jsxs)("svg",{className:N().spinner,width:"16",height:"16",viewBox:"0 0 24 24",children:[(0,s.jsx)("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4",fill:"none"}),(0,s.jsx)("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]}),"Saving..."]}):K&&!L?"Continue to Rebalance":H?"Update Category":"Add Category"})]})]})]})]})}):null}var A=t(20445),k=t(64682),S=t(45233);let I=e=>Math.round(e).toLocaleString();function R(e){let{isOpen:a,onClose:t,category:r,existingCategories:n,onDelete:o}=e,{symbol:c}=(0,b.H)(),[i,d]=(0,l.useState)(!1),[m,u]=(0,l.useState)(null),[x,p]=(0,l.useState)(!1),[g,y]=(0,l.useState)([]),j=r?Math.max(0,r.spent):0,f=r?Math.max(0,r.allocated):0,w=j>0,C=f>0,_=(0,l.useMemo)(()=>n.filter(e=>e.id!==(null==r?void 0:r.id)&&!e.isDebt),[n,r]);(0,l.useEffect)(()=>{a&&r&&(y(_.map(e=>({categoryId:e.id,name:e.name,currentAllocated:e.allocated,addAmount:0}))),p(!1),u(null))},[a,r,_]);let R=(0,l.useMemo)(()=>g.reduce((e,a)=>e+a.addAmount,0),[g]),B=f-R,D=B<=.99,T=!C||D,M=(e,a)=>{y(t=>t.map(t=>t.categoryId!==e?t:{...t,addAmount:Math.max(0,a)}))},F=async()=>{if(r){if(w)return void u("Cannot delete category with spent funds. Delete the transactions first or wait until next month when spending resets.");if(C&&!x)return void p(!0);if(x&&!T)return void u("You still need to allocate ".concat(c).concat(I(B)," to other categories"));d(!0),u(null);try{let e=[];
1if(x&&g.length>0){let a=g.filter(e=>e.addAmount>0);if(a.length>0){let t=Math.round(f),s=0;e=a.map((e,l)=>{if(l===a.length-1){let a=t-s;return{categoryId:e.categoryId,newAllocated:e.currentAllocated+a}}{let a=Math.round(e.addAmount);return s+=a,{categoryId:e.categoryId,newAllocated:e.currentAllocated+a}}})}}await o({categoryId:r.id,rebalanceChanges:e.length>0?e:void 0}),t()}catch(a){let{message:e}=(0,v.P)(a);u(e)}finally{d(!1)}}},P=()=>{i||t()};return a&&r?r.isDebt?(0,s.jsx)("div",{className:N().overlay,onClick:e=>{e.target===e.currentTarget&&P()},children:(0,s.jsx)("div",{className:N().modal,style:{maxWidth:"28rem"},children:(0,s.jsx)("div",{className:N().content,children:(0,s.jsxs)("div",{className:N().blockedContainer,children:[(0,s.jsx)("div",{className:N().blockedIcon,children:(0,s.jsx)(A.A,{className:"h-6 w-6"})}),(0,s.jsx)("h3",{className:N().blockedTitle,children:"Cannot Delete Debt Category"}),(0,s.jsx)("p",{className:N().blockedDescription,children:"This category is linked to a debt account in your elimination plan. To remove this debt payment, go to the Debt page and manage your debt accounts there."}),(0,s.jsx)("button",{onClick:P,className:N().secondaryButton,style:{width:"100%"},children:"Got It"})]})})})}):(0,s.jsx)("div",{className:N().overlay,onClick:e=>{e.target===e.currentTarget&&P()},children:(0,s.jsxs)("div",{className:N().modal,role:"dialog","aria-modal":"true",children:[(0,s.jsxs)("div",{className:N().header,children:[(0,s.jsxs)("div",{className:N().headerLeft,children:[(0,s.jsx)(k.A,{className:"h-6 w-6 ".concat(N().headerIconDanger)}),(0,s.jsx)("h2",{className:N().headerTitle,children:x?"Reallocate Funds":"Delete Category"})]}),(0,s.jsx)("button",{onClick:P,disabled:i,className:N().closeButton,children:(0,s.jsx)(h.A,{className:"h-6 w-6"})})]}),(0,s.jsxs)("div",{className:N().content,children:[m&&(0,s.jsxs)("div",{className:N().errorBox,style:{marginBottom:"1rem"},children:[(0,s.jsx)(k.A,{className:"h-5 w-5 ".concat(N().errorIcon)}),(0,s.jsx)("p",{className:N().errorText,children:m})]}),x?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("div",{className:"".concat(N().rebalanceHeader," ").concat(N().rebalanceHeaderDecrease),children:[(0,s.jsx)("h3",{className:"".concat(N().rebalanceTitle," ").concat(N().rebalanceTitleDecrease),children:"Reallocate Funds"}),(0,s.jsxs)("p",{className:"".concat(N().rebalanceDescription," ").concat(N().rebalanceDescriptionDecrease),children:["Every dollar needs a job! Allocate ",(0,s.jsxs)("strong",{children:[c,I(f)]})," to other categories."]}),(0,s.jsxs)("div",{className:N().progressContainer,children:[(0,s.jsx)("div",{className:N().progressTrack,children:(0,s.jsx)("div",{className:"".concat(N().progressFill," ").concat(T?N().progressFillComplete:N().progressFillDecrease),style:{width:"".concat(f>0?Math.min(R/f*100,100):0,"%")}})}),(0,s.jsxs)("span",{className:"".concat(N().progressLabel," ").concat(T?N().progressLabelComplete:N().progressLabelPending),children:[c,I(R)," / ",c,I(f)]})]})]}),g.length>0?(0,s.jsx)("div",{className:N().categoryList,style:{marginTop:"1rem",maxHeight:"12rem"},children:g.map(e=>(0,s.jsxs)("div",{className:N().categoryRow,children:[(0,s.jsx)("div",{className:N().categoryRowHeader,children:(0,s.jsxs)("div",{className:N().categoryRowInfo,children:[(0,s.jsx)("span",{className:N().categoryRowName,children:e.name}),(0,s.jsxs)("span",{className:N().categoryRowMeta,children:["Current: ",c,I(e.currentAllocated)]})]})}),(0,s.jsxs)("div",{className:N().categoryRowControls,children:[(0,s.jsx)("input",{type:"range",min:"0",max:f,value:e.addAmount,onChange:a=>M(e.categoryId,parseFloat(a.target.value)),className:N().categorySlider}),(0,s.jsxs)("div",{className:N().categoryInputWrapper,children:[(0,s.jsxs)("span",{className:N().categoryInputPrefix,children:["+",c]}),(0,s.jsx)("input",{type:"number",min:"0",value:e.addAmount||"",onChange:a=>M(e.categoryId,parseFloat(a.target.value)||0),className:N().categoryInput})]})]}),(0,s.jsx)("div",{className:N().quickAmounts,children:(()=>{let a=B>0?Math.round(B):null;return[10,25,50,a].filter(e=>null!==e&&e>0).slice(0,4).map((t,l)=>(0,s.jsx)("button",{type:"button",onClick:()=>M(e.categoryId,e.addAmount+t),className:"".concat(N().quickAmountBtn," ").concat(t===a?N().quickAmountBtnExact:N().quickAmountBtnNormal),children:t===a?"+".concat(c).concat(t," (exact)"):"+".concat(c).concat(t)},"".concat(e.categoryId,"-").concat(t,"-").concat(l)))})()})]},e.categoryId))}):(0,s.jsx)("div",{className:N().warningBox,style:{marginTop:"1rem"},children:(0,s.jsx)("p",{className:N().warningText,children:"No other categories to reallocate funds to. Create another category first."})})]}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("div",{className:N().deleteC
1ategoryInfo,children:[(0,s.jsxs)("div",{className:N().deleteCategoryHeader,children:[(0,s.jsx)(S.E,{iconKey:r.icon,categoryName:r.name,color:r.color,isDebt:r.isDebt,size:"md"}),(0,s.jsx)("span",{className:N().deleteCategoryName,children:r.name})]}),(0,s.jsxs)("div",{className:N().deleteCategoryStats,children:[(0,s.jsxs)("div",{className:N().deleteCategoryStat,children:[(0,s.jsx)("span",{className:N().deleteStatLabel,children:"Allocated:"}),(0,s.jsxs)("span",{className:N().deleteStatValue,children:[c,I(r.allocated)]})]}),(0,s.jsxs)("div",{className:N().deleteCategoryStat,children:[(0,s.jsx)("span",{className:N().deleteStatLabel,children:"Spent:"}),(0,s.jsxs)("span",{className:N().deleteStatValue,children:[c,I(r.spent)]})]})]})]}),w&&(0,s.jsxs)("div",{className:N().warningBox,style:{marginTop:"1rem"},children:[(0,s.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"0.5rem",marginBottom:"0.5rem"},children:[(0,s.jsx)(k.A,{className:"h-5 w-5",style:{color:"var(--modal-warning)"}}),(0,s.jsx)("strong",{style:{color:"var(--modal-warning)"},children:"Cannot Delete - Money Spent"})]}),(0,s.jsxs)("p",{style:{color:"var(--text-secondary)",fontSize:"0.875rem",lineHeight:"1.4",marginBottom:"0.75rem"},children:["You've spent ",c,I(j)," this month. We can't pretend that didn't happen."]}),(0,s.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:"0.5rem"},children:[(0,s.jsx)("p",{style:{color:"var(--text-secondary)",fontSize:"0.875rem",fontWeight:"600"},children:"Options:"}),(0,s.jsx)("p",{style:{color:"var(--text-tertiary)",fontSize:"0.875rem"},children:"⢠Delete the transactions first (if they were mistakes)"}),(0,s.jsx)("p",{style:{color:"var(--text-tertiary)",fontSize:"0.875rem"},children:"⢠Wait until next month when spending resets"})]})]}),C&&!w&&(0,s.jsx)("div",{className:N().successBox,style:{marginTop:"1rem"},children:(0,s.jsxs)("p",{className:N().successText,children:["This will free up ",c,I(f),". You'll need to reallocate it to other categories."]})}),!w&&!C&&(0,s.jsx)("div",{className:N().successBox,style:{marginTop:"1rem"},children:(0,s.jsx)("p",{className:N().successText,children:"This category has no funds allocated. It can be deleted immediately."})})]})]}),(0,s.jsxs)("div",{className:N().footer,children:[(0,s.jsx)("div",{className:N().footerLeft,children:x&&(0,s.jsx)("button",{onClick:()=>p(!1),disabled:i,className:N().secondaryButton,children:"â Back"})}),(0,s.jsxs)("div",{className:N().footerRight,children:[(0,s.jsx)("button",{onClick:P,disabled:i,className:N().secondaryButton,children:"Cancel"}),!w&&(0,s.jsx)("button",{onClick:F,disabled:i||x&&!T,className:N().dangerButton,children:i?(0,s.jsxs)("span",{className:"flex items-center gap-2",children:[(0,s.jsxs)("svg",{className:N().spinner,width:"16",height:"16",viewBox:"0 0 24 24",children:[(0,s.jsx)("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4",fill:"none"}),(0,s.jsx)("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]}),"Deleting..."]}):"Delete Category"})]})]})]})}):null}var B=t(28055),D=t(26095),T=t(46139),M=t(99074),F=t(71156);F.A.set({precision:20,rounding:F.A.ROUND_HALF_UP});let P=e=>(e instanceof F.A?e:new F.A(e)).toDecimalPlaces(2,F.A.ROUND_HALF_UP),L={weekly:52/12,biweekly:26/12,"semi-monthly":2,monthly:1,yearly:1/12,annual:1/12,daily:30,hourly:160,per_job:1},E=(e,a)=>e*(L[a]||1),W={weekly:52/12,biweekly:26/12,monthly:1},z=["#3B82F6","#10B981","#F59E0B","#EF4444","#8B5CF6","#EC4899","#06B6D4","#84CC16","#F97316","#6366F1"];function H(e){let{isOpen:a,onClose:t,editingSource:r,existingSources:n,existingCategories:o,totalAllocated:c,totalSpentThisMonth:i,currentTotalMonthlyIncome:d,budgetId:m,activePlan:u,onSave:x}=e,{symbol:g,format:j}=(0,b.H)(),f=e=>j(Math.round(e instanceof F.A?e.toNumber():e)),[N,w]=(0,l.useState)(""),[C,_]=(0,l.useState)(""),[A,S]=(0,l.useState)(!0),[I,R]=(0,l.useState)(!1),[L,H]=(0,l.useState)(""),[V,U]=(0,l.useState)("biweekly"),[q,O]=(0,l.useState)(""),[Y,G]=(0,l.useState)("day"),[J,Q]=(0,l.useState)("5"),[K,Z]=(0,l.useState)(!1),[X,$]=(0,l.useState)(null),[ee,ea]=(0,l.useState)("details"),[et,es]=(0,l.useState)([]),[el,er]=(0,l.useState)([]),[en,eo]=(0,l.useState)(!1),[ec,ei]=(0,l.useState)({name:"",amount:""}),ed="rebalance"===ee,em=!!r,eu={color:"var(--text-secondary)",fontSize:"14px",fontWeight:500,marginBottom:"8px",display:"block"},ex={width:"100%",paddingTop:"12px",paddingBottom:"12px",paddingLeft:"16px",paddingRight:"16px",backgroundColor:"var(--modal-bg-subtle)",border:"1px solid var(--modal-border)",borderRadius:"12px",color:"var(--foreground)",fontSize:"15px",outline:"none",transition:"all 0.15s ease"},eh=e=>({padding:"6px 12px",borderRadius:"8px",border:"1px solid ".concat(e?"var(--success)":"var(--modal-border)"),backgroundColor:e?"var(--success-light)":"transparent",color:e?"var(--success)":"var(--muted-foreground)",fontSize:"13px",cursor:"pointer"}),ep={backgroundColor:"var(--error-light)",border:"1px solid var(--error-border)",borderRadius:"12px",padding:"12px"},eg={color:"var(--error)",fontSize:"14px"},ey={color:"var(--text-muted)",fontSize:"14px"},ev={color:"var(--success)",fontSize:"20px",fontWeight:700},eb={backgroundColor:"var(--success-light)",border:"1px solid var(--success-border)",borderRadius:"12px",padding:"16px"},ej={color:"var(--success)",fontSize:"14px",fontWeight:500},ef={backgroundColor:"var(--warning-light)",border:"1px solid var(--warning-border)",borderRadius:"12px",padding:"16px"},eN={color:"var(--warning)"},ew={color:"var(--foreground)",fontSize:"14px",fontWeight:500},eC={color:"var(--text-tertiary)",fontSize:"13px",marginTop:"4px"},e_={backgroundColor:"var(--modal-border)",borderRadius:"9999px",height:"8px",overflow:"hidden"},eA={background:"var(--success-gradient)",borderRadius:"9999px",height:"100%",transition:"width 0.3s ease"},ek={backgroundColor:"var(--modal-bg-subtle)",border:"1px solid var(--border-subtle)",borderRadius:"12px",padding:"12px"},eS={color:"var(--foreground)",fontWeight:500},eI={color:"var(--text-muted)",fontSize:"12px"},eR={background:"var(--success-gradient)",color:"#ffffff",padding:"10px 16px",borderRadius:"10px",fontSize:"14px",fontWeight:500,boxShadow:"0 4px 14px rgba(16, 185, 129, 0.25)",border:"none",cursor:"pointer",display:"inline-flex",alignItems:"center",gap:"8px",transition:"all 0.2s ease"},eB=parseFloat(L)||0,eD=parseFloat(q)||0,eT=parseInt(J)||0,eM=eB*W[V],eF=eD*((e,a)=>{switch(e){case"day":case"shift":return 52/12*a;case"week":return 52/12;default:return 0}})(Y,eT),eP=Math.round(eM+eF),eL=parseFloat(C)||0,eE=n.reduce((e,a)=>{let t=E(a.amount,a.frequency||"monthly");if(a.taxRate&&a.taxRate>0){let s=t-(a.retirementContributionPct||0)/100*t-(a.otherPretax
1Deductions||0),l=s*(a.taxRate/100);return e+(s-l)}return e+t},0),eW=eL-(()=>{if(!r)return 0;let e=r.amount,a=r.frequency||"monthly";if(r.taxRate&&r.taxRate>0){let t=E(e,a),s=r.retirementContributionPct||0,l=t-s/100*t-(r.otherPretaxDeductions||0),n=l*(r.taxRate/100);return l-n}return E(e,a)})(),ez=eE+eW,eH=new F.A(Math.max(0,eW)).round(),eV=eH.toNumber(),eU=eH.greaterThan(.01),eq=eW<0&&c>ez,eO=eq?c-ez:0,eY=(0,l.useMemo)(()=>el.reduce((e,a)=>e.plus(P(a.addAmount)),new F.A(0)),[el]),eG=eY.toNumber(),eJ=eH.minus(eY),eQ=eJ.toNumber(),eK=eJ.abs().lessThan(.01);(0,l.useEffect)(()=>{a&&(r?(w(r.name),_(Math.round((e=>{let a=e.amount,t=e.frequency||"monthly";if(e.taxRate&&e.taxRate>0){let s=E(a,t),l=e.retirementContributionPct||0,r=s-l/100*s-(e.otherPretaxDeductions||0),n=r*(e.taxRate/100);return r-n}return E(a,t)})(r)).toString()),S(r.isActive)):eZ(),R(!1),eX(),$(null),ea("details"),es([]),er([]),eo(!1),ei({name:"",amount:""}))},[a,r]);let eZ=()=>{w(""),_(""),S(!0)},eX=()=>{H(""),U("biweekly"),O(""),G("day"),Q("5")};(0,l.useEffect)(()=>{ed&&eq&&es(o.filter(e=>!e.isDebt&&e.allocated-e.spent>0).map(e=>({categoryId:e.id,name:e.name,currentAllocated:e.allocated,spent:e.spent,availableToReduce:e.allocated-e.spent,adjustAmount:0})))},[ed,eq,o]);let e$=u&&["active","paused","pausing_next_month","resuming_next_month"].includes(u.status);(0,l.useEffect)(()=>{if("allocate"===ee&&0===el.length){let e;if(e$){let a=o.filter(e=>!e.isDebt),t=o.filter(e=>e.isDebt).reduce((e,a)=>e+a.allocated,0);e=a.map(e=>({categoryId:e.id,name:e.name,currentAllocated:e.allocated,addAmount:0,isNew:!1,color:e.color}));let s=u.strategy.charAt(0).toUpperCase()+u.strategy.slice(1),l="paused"===u.status?" - Paused":"";e.unshift({categoryId:"__DEBT_PLAN__",name:"Debt Elimination Plan (".concat(s).concat(l,")"),currentAllocated:t,addAmount:0,isNew:!1,color:"#EF4444"})}else e=o.map(e=>({categoryId:e.id,name:e.name,currentAllocated:e.allocated,addAmount:0,isNew:!1,color:e.color}));er(e)}},[ee,o,el.length,e$,u]);let e0=(0,l.useMemo)(()=>et.reduce((e,a)=>e+a.adjustAmount,0),[et]),e1=eO-e0,e2=e1<=.99,e5=(e,a)=>{er(t=>{let s=t.reduce((a,t)=>t.categoryId===e?a:a.plus(P(t.addAmount)),new F.A(0)),l=eH.minus(s);return t.map(t=>{if(t.categoryId!==e)return t;let s=P(a);return s.lessThan(0)&&(s=new F.A(0)),s.greaterThan(l)&&(s=l),{...t,addAmount:s.toNumber()}})})},e4=(e,a)=>{es(t=>t.map(t=>{if(t.categoryId!==e)return t;let s=Math.min(Math.max(0,a),t.availableToReduce);return{...t,adjustAmount:s}}))},e3=async e=>{if(e.preventDefault(),$(null),"details"===ee){if(!N.trim())return void $("Income source name is required");if(eL<=0)return void $("Amount must be greater than 0");if(n.some(e=>e.name.toLowerCase()===N.trim().toLowerCase()&&e.id!==(null==r?void 0:r.id)))return void $("An income source with this name already exists");if(eq&&!ed)return void ea("rebalance");if(eU&&"details"===ee)return void ea("allocate")}if("allocate"===ee&&!eK)return void $("You still need to allocate ".concat(g).concat(f(eQ)));if(ed&&eq&&!e2)return void $("You still need to free up ".concat(g).concat(f(e1)," from categories"));Z(!0);try{let e,a,s;if(ed&&et.length>0&&eq&&(e=et.filter(e=>e.adjustAmount>0).map(e=>({categoryId:e.categoryId,newAllocated:Math.floor(e.currentAllocated-e.adjustAmount)}))),"allocate"===ee&&el.length>0){let e=el.find(e=>"__DEBT_PLAN__"===e.categoryId);e&&e.addAmount>0&&(s=Math.round(e.addAmount)),a=el.filter(e=>e.addAmount>0&&"__DEBT_PLAN__"!==e.categoryId).map(e=>({categoryId:e.categoryId,newAllocated:Math.round(e.currentAllocated+e.addAmount),isNew:e.isNew,name:e.isNew?e.name:void 0,color:e.isNew?e.color:void 0}))}await x({name:N.trim(),type:"fixed",amount:parseFloat(C)||0,frequency:"monthly",isActive:A,netAmount:eL,rebalanceChanges:e,allocations:a,debtPlanExtra:s}),t()}catch(a){let{message:e}=(0,v.P)(a);$(e)}finally{Z(!1)}},e6=()=>{ea("details"),er([]),eo(!1),ei({name:"",amount:""}),$(null)},e8=()=>{K||t()};return a?(0,s.jsx)("div",{className:"fixed inset-0 flex items-center justify-center z-50 p-4 overflow-y-auto",style:{backgroundColor:"rgba(0, 0, 0, 0.5)",backdropFilter:"blur(8px)",WebkitBackdropFilter:"blur(8px)"},onClick:e=>{e.target===e.currentTarget&&e8()},children:(0,s.jsxs)("div",{className:"max-w-lg w-full my-8",style:{backgroundColor:"var(--modal-bg)",border:"1px solid var(--border-subtle)",borderRadius:"20px",boxShadow:"var(--shadow-lg)"},role:"dialog","aria-modal":"true",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between",style:{borderBottom:"1px solid var(--border-subtle)",padding:"20px 24px"},children:[(0,s.jsxs)("div",{className:"flex items-center gap-3",children:["details"!==ee&&(0,s.jsx)("button",{type:"button",onClick:e6,disabled:K,style:{color:"var(--text-muted)",padding:"4px",transition:"color 0.15s ease"},children:(0,s.jsx)(B.A,{className:"h-5 w-5"})}),(0,s.jsx)("h2",{style:{color:"var(--foreground)",fontSize:"20px",fontWeight:600},children:"allocate"===ee?"Allocate Your New Income":"rebalance"===ee?"Rebalance Your Budget":em?"Edit Income Source":"Add Income Source"})]}),(0,s.jsx)("button",{onClick:e8,disabled:K,style:{color:"var(--text-muted)",padding:"8px",borderRadius:"8px",transition:"all 0.15s ease"},children:(0,s.jsx)(h.A,{className:"h-6 w-6"})})]}),(0,s.jsxs)("form",{onSubmit:e3,children:[(0,s.jsxs)("div",{style:{padding:"24px",maxHeight:"70vh",overflowY:"auto"},className:"space-y-4",children:[X&&(0,s.jsxs)("div",{className:"flex items-start gap-2",style:ep,children:[(0,s.jsx)(p.A,{className:"h-5 w-5 flex-shrink-0 mt-0.5",style:eN}),(0,s.jsx)("p",{style:eg,children:X})]}),"details"===ee&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{style:eu,children:"What should we call this income?"}),(0,s.jsx)("input",{type:"text",value:N,onChange:e=>w(e.target.value),placeholder:"e.g., Bartender, Accountant, Sales Rep",style:ex,maxLength:100,disabled:K,autoFocus:!0})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{style:eu,children:"Monthly Take-Home Amount"}),(0,s.jsxs)("div",{className:"relative flex items-center",style:{...ex,padding:0,display:"flex",overflow:"hidden"},children:[(0,s.jsx)("span",{style:{padding:"12px 12px 12px 16px",color:"var(--text-muted)",borderRight:"1px solid var(--modal-border)"},children:g}),(0,s.jsx)("input",{type:"number",step:"1",min:"0",max:0x3b9ac9ff,value:C,onChange:e=>_(e.target.value.replace(/[^0-9]/g,"")),placeholder:"0",style:{flex:1,padding:"12px 16px",background:"transparent",border:"none",outline:"none",color:"var(--foreground)",fontSize:"15px"},disabled:K}),(0,s.jsx)("span",{style:{padding:"12px 16px 12px 12px",color:"var(--text-muted)",borderLeft:"1px solid var(--modal-border)",fontSize:"14px"},children:"/month"})]}),(0,s.jsx)("p",{style:{color:"var(--text-muted)",fontSize:"12px",fontWeight:400,marginTop:"4px"},children:"Enter what actually hits your bank account after taxes and deductions. Round dollar amounts only."})]}),(0,s.jsxs)("button",{type:"button",onClick:()=>R(!I),style:{display:"flex",alignItems:"center",gap:"8px",color:"var(--success)",fontSize:"14px",fontWeight:500,cursor:"pointer",background:"none",border:"none",padding:"4px 0"},children:[(0,s.jsxs)("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:[(0,s.jsx)("rect",{x:"4",y:"2",width:"16",height:"20",rx:"2"}),(0,s.jsx)("path",{d:"M8 6h8M8 10h2M14 10h2M8 14h2M14 14h2M8 18h2M14 18h2"})]}),(0,s.jsx)("span",{children:"Not sure? Use the calculator"})]}),I&&(0,s.jsxs)("div",{style:{backgroundColor:"var(--modal-bg-subtle)",border:"1px solid var(--modal-border)",borderRadius:"12px",padding:"16px"},className:"space-y-4",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{style:eu,children:"Base Pay (Paycheck)"}),(0,s.jsxs)("div",{className:"relative",children:[(0,s.jsx)("span",{className:"absolute left-4 top-1/2 -translate-y-1/2",style:{color:"var(--text-muted)"},children:g}),(0,s.jsx)("input",{type:"number",placeholder:"0",value:L,onChange:e=>H(e.target.value),style:{...ex,paddingLeft:"32px"},disabled:K})]}),(0,s.jsx)("div",{className:"flex gap-2 mt-2",children:["weekly","biweekly","monthly"].map(e=>(0,s.jsx)("button",{type:"button",onClick:()=>U(e),style:eh(V===e),children:"biweekly"===e?"Biweekly":e.charAt(0).toUpperCase()+e.slice(1)},e))}),eB>0&&(0,s.jsxs)("p",{className:"text-sm mt-1",style:{color:"var(--success)"},children:["= ",f(Math.round(eM)),"/mo"]})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{style:eu,children:"Tips / Variable Income (optional)"}),(0,s.jsxs)("div",{className:"relative",children:[(0,s.jsx)("span",{className:"absolute left-4 top-1/2 -translate-y-1/2",style:{color:"var(--text-muted)"},children:g}),(0,s.jsx)("input",{type:"number",placeholder:"0",value:q,onChange:e=>O(e.target.value),style:{...ex,paddingLeft:"32px"},disabled:K})]}),(0,s.jsx)("div",{className:"flex gap-2 mt-2",children:[{value:"day",label:"per Day"},{value:"shift",label:"per Shift"},{value:"week",label:"per Week"}].map(e=>(0,s.jsx)("button",{type:"button",onClick:()=>G(e.value),style:eh(Y===e.value),children:e.label},e.value))}),eD>0&&"week"!==Y&&(0,s.jsxs)("div",{className:"flex items-center gap-2 mt-2",children:[(0,s.jsxs)("span",{style:{...ey,fontSize:"13px"},children:["How many ","day"===Y?"days":"shifts"," per week?"]}),(0,s.jsx)("input",{type:"number",min:"1",max:"7",value:J,onChange:e=>Q(e.target.value),style:{...ex,width:"60px",textAlign:"center",padding:"6px"}})]}),eD>0&&(0,s.jsxs)("p",{className:"text-sm mt-1",style:{color:"var(--success)"},children:["= ",f(Math.round(eF)),"/mo"]})]}),(0,s.jsxs)("div",{style:{backgroundColor:"var(--success-light)",border:"1px solid var(--success-border)",borderRadius:"12px",padding:"12px 16px",textAlign:"center"},children:[(0,s.jsx)("span",{style:{...ey,fontSize:"12px",textTransform:"uppercase",letterSpacing:"0.5px"},children:"YOUR MONTHLY TAKE-HOME"}),(0,s.jsx)("p",{style:{...ev,fontSize:"24px",marginTop:"4px"},children:f(eP)})]}),(0,s.jsx)("button",{type:"button",onClick:()=>{eP>0&&(_(eP.toString()),R(!1))},disabled:0===eP,style:{...eR,width:"100%",justifyContent:"center",opacity:0===eP?.5:1},children:"Use This Amount"})]}),eL>0&&(0,s.jsxs)("div",{style:{backgroundColor:"var(--modal-bg-subtle)",border:"1px solid var(--modal-border)",borderRadius:"12px",padding:"16px"},children:[(0,s.jsxs)("div",{className:"flex items-center justify-between mb-2",children:[(0,s.jsx)("span",{style:ey,children:"Monthly Take-Home:"}),(0,s.jsx)("span",{style:ev,children:f(eL)})]}),em&&Math.abs(eW)>0&&(0,s.jsxs)("div",{className:"flex items-center justify-between text-sm",children:[(0,s.jsx)("span",{style:ey,children:"Change from current:"}),(0,s.jsxs)("span",{style:{color:eW>0?"var(--success)":"var(--error)"},children:[eW>0?"+":"",f(eW),"/mo"]})]}),(0,s.jsx)("div",{className:"mt-2 pt-2",style:{borderTop:"1px solid var(--border-subtle)"},children:(0,s.jsxs)("div",{className:"flex items-center justify-between text-sm",children:[(0,s.jsx)("span",{style:ey,children:"New total take-home:"}),(0,s.jsx)("span",{style:{color:"var(--foreground)",fontWeight:500,color:"var(--success)",fontWeight:600},children:f(ez)})]})})]}),eL>0&&eU&&!eq&&(0,s.jsx)("div",{style:eb,children:(0,s.jsxs)("div",{className:"flex items-start gap-2",children:[(0,s.jsx)(D.A,{className:"h-5 w-5 flex-shrink-0 mt-0.5",style:{color:"var(--success)"}}),(0,s.jsxs)("div",{children:[(0,s.jsxs)("p",{style:ej,children:[g,f(eV)," will be available to add to your budget"]}),(0,s.jsx)("p",{className:"text-xs mt-1",style:{color:"var(--success)",opacity:.7},children:'Click "Add to Budget Now" to distribute these funds across your categories.'})]})]})}),eq&&"details"===ee&&eL>0&&(0,s.jsx)("div",{style:ef,children:(0,s.jsxs)("div",{className:"flex items-start gap-2",children:[(0,s.jsx)(k.A,{className:"h-5 w-5 flex-shrink-0 mt-0.5",style:eN}),(0,s.jsxs)("div",{children:[(0,s.jsxs)("p",{style:ew,children:[g,f(eO)," needs to be freed up"]}),(0,s.jsxs)("p",{style:eC,children:["Your budget is currently allocated at ",g,f(c),'. Click "Rebalance Now" to choose which categories to reduce.']})]})]})})]}),"rebalance"===ee&&eq&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("div",{style:ef,className:"mb-4",children:[(0,s.jsxs)("h3",{className:"font-medium mb-2 flex items-center gap-2",style:ew,children:[(0,s.jsx)(y.A,{className:"h-4 w-4"}),"Reduce Category Allocations"]}),(0,s.jsxs)("p",{style:eC,className:"mb-3",children:["Free up ",g,f(eO)," from your categories to match your new income."]}),(0,s.jsxs)("div",{className:"flex items-center gap-3",children:[(0,s.jsx)("div",{className:"flex-1",style:e_,children:(0,s.jsx)("div",{style:{...eA,width:"".concat(eO>0?Math.min(e0/eO*100,100):0,"%")}})}),(0,s.jsxs)("span",{className:"text-sm font-medium",style:{color:e2?"var(--success)":"var(--muted-foreground)"},children:[g,f(e0)," / ",g,f(eO)]})]})]}),et.length>0?(0,s.jsx)("div",{className:"space-y-3 max-h-60 overflow-y-auto",children:et.map(e=>(0,s.jsxs)("div",{style:ek,children:[(0,s.jsx)("div",{className:"flex items-center justify-between mb-2",children:(0,s.jsxs)("div",{children:[(0,s.jsx)("span",{style:eS,children:e.name}),(0,s.jsxs)("div",{style:eI,className:"mt-0.5",children:["Current: ",g,f(e.currentAllocated)," \xb7 Available: ",g,f(e.availableToReduce)]})]})}),(0,s.jsxs)("div",{className:"flex items-center gap-3",children:[(0,s.jsx)("input",{type:"range",min:"0",max:e.availableToReduce,value:e.adjustAmount,onChange:a=>e4(e.categoryId,parseFloat(a.target.value)),className:"flex-1 h-2 rounded-lg appearance-none cursor-pointer",style:{backgroundColor:"var(--modal-border)",accentColor:"var(--success)"}}),(0,s.jsxs)("div",{className:"flex items-center gap-1 w-24",children:[(0,s.jsxs)("span",{style:{color:"var(--text-muted)"},children:["-",g]}),(0,s.jsx)("input",{type:"number",min:"0",max:e.availableToReduce,value:e.adjustAmount||"",onChange:a=>e4(e.categoryId,parseFloat(a.target.value)||0),className:"w-16 px-2 py-1 text-sm text-right",style:{...ex,padding:"4px 8px"}})]})]}),(0,s.jsx)("div",{className:"flex flex-wrap gap-1.5 mt-2",children:(()=>{let a=Math.round(e1);return[...new Set([a>0&&a<=e.availableToReduce?a:null,10,25,50,100].filter(a=>null!==a&&!(a<=0)&&!(a>e.availableToReduce)))].slice(0,4).map((t,l)=>(0,s.jsx)("button",{type:"button",onClick:()=>e4(e.categoryId,e.adjustAmount+t),className:"px-2.5 py-1 text-xs rounded-lg font-medium transition-colors",style:{backgroundColor:t===a?"var(--success-light)":"var(--modal-bg-elevated)",color:t===a?"var(--success)":"var(--text-secondary)",border:"1px solid ".concat(t===a?"var(--success-border)":"var(--modal-border)"),cursor:"pointer"},children:t===a?"".concat(g).concat(t," (exact)"):"+".concat(g).concat(t)},"".concat(e.categoryId,"-").concat(t,"-").concat(l)))})()})]},e.categoryId))}):(0,s.jsx)("div",{style:ep,children:(0,s.jsx)("p",{style:eg,children:"No categories have available funds to reduce."})})]}),"allocate"===ee&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("div",{style:eb,children:[(0,s.jsxs)("div",{className:"flex items-center justify-between mb-2",children:[(0,s.jsxs)("span",{style:ej,children:[g,f(eV)," to distribute"]}),(0,s.jsxs)("span",{className:"text-sm",style:{color:eK?"var(--success)":"var(--muted-foreground)"},children:[g,f(eG)," / ",g,f(eV)]})]}),(0,s.jsx)("div",{style:e_,children:(0,s.jsx)("div",{style:{...eA,width:"".concat(eV>0?Math.min(eG/eV*100,100):0,"%")}})}),eK&&(0,s.jsxs)("p",{className:"text-xs mt-2 flex items-center gap-1",style:{color:"var(--success)"},children:[(0,s.jsx)(D.A,{className:"h-4 w-4"}),'All funds allocated! Click "Save Budget" to confirm.']})]}),(0,s.jsxs)("div",{className:"space-y-2 max-h-64 overflow-y-auto",children:[el.filter(e=>!e.isNew).map(e=>(0,s.jsxs)("div",{style:ek,children:[(0,s.jsxs)("div",{className:"flex items-center gap-3",children:[(0,s.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[e.color&&(0,s.jsx)("div",{className:"w-3 h-3 rounded-full flex-shrink-0",style:{backgroundColor:e.color}}),(0,s.jsx)("span",{style:eS,className:"truncate",children:e.name})]}),(0,s.jsxs)("span",{style:eI,children:["Current: ",g,f(e.currentAllocated)]})]}),(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsxs)("span",{style:{color:"var(--text-muted)"},children:["+",g]}),(0,s.jsx)("input",{type:"number",step:"1",min:"0",max:eQ+e.addAmount,value:e.addAmount||"",onChange:a
1=>e5(e.categoryId,parseFloat(a.target.value)||0),placeholder:"0",className:"w-20 text-right text-sm",style:{...ex,padding:"6px 8px"}})]})]}),(0,s.jsx)("div",{className:"flex flex-wrap gap-1.5 mt-2",children:(()=>{let a=Math.round(eQ),t=eQ+e.addAmount;return[...new Set([a>0&&a<=t?a:null,10,25,50,100].filter(e=>null!==e&&!(e<=0)&&!(e>t)))].slice(0,4).map((t,l)=>(0,s.jsx)("button",{type:"button",onClick:()=>e5(e.categoryId,e.addAmount+t),className:"px-2.5 py-1 text-xs rounded-lg font-medium transition-colors",style:{backgroundColor:t===a?"var(--success-light)":"var(--modal-bg-elevated)",color:t===a?"var(--success)":"var(--text-secondary)",border:"1px solid ".concat(t===a?"var(--success-border)":"var(--modal-border)"),cursor:"pointer"},children:t===a?"".concat(g).concat(t," (exact)"):"+".concat(g).concat(t)},"".concat(e.categoryId,"-").concat(t,"-").concat(l)))})()})]},e.categoryId)),el.filter(e=>e.isNew).map(e=>(0,s.jsxs)("div",{style:{...ek,backgroundColor:"var(--success-light)"},className:"flex items-center gap-3",children:[(0,s.jsx)("div",{className:"flex-1 min-w-0",children:(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[e.color&&(0,s.jsx)("div",{className:"w-3 h-3 rounded-full flex-shrink-0",style:{backgroundColor:e.color}}),(0,s.jsx)("span",{style:eS,className:"truncate",children:e.name}),(0,s.jsx)("span",{className:"text-xs px-1.5 py-0.5 rounded",style:{backgroundColor:"var(--success-light)",color:"var(--success)"},children:"New"})]})}),(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsxs)("span",{style:{color:"var(--success)",fontWeight:500},children:["+",g,f(e.addAmount)]}),(0,s.jsx)("button",{type:"button",onClick:()=>{var a;return a=e.categoryId,void er(e=>e.filter(e=>e.categoryId!==a))},className:"p-1",style:{color:"var(--text-muted)"},title:"Remove",children:(0,s.jsx)(h.A,{className:"h-4 w-4"})})]})]},e.categoryId))]}),en?(0,s.jsxs)("div",{style:ek,className:"space-y-3",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between",children:[(0,s.jsx)("span",{className:"text-sm font-medium",style:ey,children:"Create New Category"}),(0,s.jsx)("button",{type:"button",onClick:()=>{eo(!1),ei({name:"",amount:""})},style:{color:"var(--text-muted)"},children:(0,s.jsx)(h.A,{className:"h-5 w-5"})})]}),(0,s.jsxs)("div",{className:"grid grid-cols-2 gap-3",children:[(0,s.jsx)("input",{type:"text",value:ec.name,onChange:e=>ei(a=>({...a,name:e.target.value})),placeholder:"Category name",style:{...ex,padding:"8px 12px",fontSize:"14px"},autoFocus:!0}),(0,s.jsxs)("div",{className:"relative",children:[(0,s.jsx)("span",{className:"absolute left-3 top-1/2 -translate-y-1/2",style:{color:"var(--text-muted)"},children:g}),(0,s.jsx)("input",{type:"number",step:"1",min:"0",max:eQ,value:ec.amount,onChange:e=>ei(a=>({...a,amount:e.target.value})),placeholder:"0",className:"text-right",style:{...ex,paddingLeft:"28px",padding:"8px 12px",fontSize:"14px"}})]})]}),(0,s.jsxs)("div",{className:"flex items-center justify-between",children:[(0,s.jsxs)("span",{className:"text-xs",style:eI,children:["Max: ",g,f(eQ)]}),(0,s.jsx)("button",{type:"button",onClick:()=>{let e=(e=>{let a=parseFloat(e);return isNaN(a)?new F.A(0):P(a)})(ec.amount),a=e.toNumber();if(!ec.name.trim()||e.lessThanOrEqualTo(0))return void $("Please enter a category name and amount");if(e.greaterThan(eJ.plus(.01)))return void $("Amount cannot exceed ".concat(g).concat(f(eQ)," remaining"));if(el.some(e=>e.name.toLowerCase()===ec.name.trim().toLowerCase())||o.some(e=>e.name.toLowerCase()===ec.name.trim().toLowerCase()))return void $("A category with this name already exists");let t=el.filter(e=>e.color).map(e=>e.color),s=z.find(e=>!t.includes(e))||z[0],l={categoryId:"new_".concat(Date.now()),name:ec.name.trim(),currentAllocated:0,addAmount:a,isNew:!0,color:s};er(e=>[...e,l]),ei({name:"",amount:""}),eo(!1),$(null)},style:eR,className:"text-sm",children:"Add Category"})]})]}):(0,s.jsxs)("button",{type:"button",onClick:()=>eo(!0),disabled:eQ<1,style:{width:"100%",padding:"12px",border:"2px dashed var(--modal-border)",borderRadius:"12px",color:"var(--text-muted)",backgroundColor:"transparent",curs
1or:"pointer",display:"flex",alignItems:"center",justifyContent:"center",gap:"8px",transition:"all 0.15s ease",opacity:eQ<1?.5:1,cursor:eQ<1?"not-allowed":"pointer"},children:[(0,s.jsx)(T.A,{className:"h-5 w-5"}),(0,s.jsx)("span",{children:"New Category"})]})]})]}),(0,s.jsxs)("div",{className:"flex justify-end gap-3",style:{borderTop:"1px solid var(--border-subtle)",padding:"16px 24px"},children:[(0,s.jsx)("button",{type:"button",onClick:"details"===ee?e8:e6,disabled:K,style:{backgroundColor:"var(--modal-bg-elevated)",color:"var(--text-secondary)",border:"1px solid var(--modal-border)",padding:"10px 16px",borderRadius:"10px",fontSize:"14px",fontWeight:500,cursor:"pointer",transition:"all 0.2s ease"},children:"details"===ee?"Cancel":"â Back"}),(0,s.jsx)("button",{type:"submit",disabled:K||"rebalance"===ee&&!e2||"allocate"===ee&&!eK,style:{...eR,opacity:!K&&("rebalance"!==ee||e2)&&("allocate"!==ee||eK)?1:.5},children:K?(0,s.jsxs)("span",{className:"flex items-center gap-2",children:[(0,s.jsxs)("svg",{className:"animate-spin h-4 w-4",viewBox:"0 0 24 24",children:[(0,s.jsx)("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4",fill:"none"}),(0,s.jsx)("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]}),"Saving..."]}):"allocate"===ee||"rebalance"===ee?"Save Budget":eU?(0,s.jsxs)("span",{className:"flex items-center gap-1",children:["Add to Budget Now ",(0,s.jsx)(M.A,{className:"h-4 w-4"})]}):eq?(0,s.jsxs)("span",{className:"flex items-center gap-1",children:["Rebalance Now ",(0,s.jsx)(M.A,{className:"h-4 w-4"})]}):em?"Update Income Source":"Add Income Source"})]})]})]})}):null}var V=t(20133);let U=e=>Math.round(e).toLocaleString(),q={weekly:52/12,biweekly:26/12,"semi-monthly":2,monthly:1,annual:1/12,daily:30,hourly:160,per_job:1},O=(e,a)=>e*(q[a]||1);function Y(e){let{isOpen:a,onClose:t,deletingSource:r,existingCategories:n,totalAllocated:o,totalSpentThisMonth:c,currentTotalMonthlyIncome:i,totalIncomeSources:d,onDelete:m}=e,{symbol:u}=(0,b.H)(),[x,p]=(0,l.useState)(!1),[g,j]=(0,l.useState)(null),[f,N]=(0,l.useState)(!1),[w,C]=(0,l.useState)([]),_={color:"var(--text-secondary)"},A={color:"var(--foreground)",fontWeight:500},S={backgroundColor:"var(--modal-bg-subtle)",border:"1px solid var(--border-subtle)",borderRadius:"12px",padding:"16px"},I={color:"var(--muted-foreground)",fontSize:"14px"},R={color:"var(--foreground)",fontWeight:500},B={color:"var(--success)",fontWeight:500},D={backgroundColor:"var(--warning-light)",border:"1px solid var(--warning-border)",borderRadius:"12px",padding:"16px"},T={color:"var(--warning)"},M={color:"var(--foreground)",fontSize:"14px",fontWeight:500},F={color:"var(--muted-foreground)",fontSize:"13px",marginTop:"4px"},P={backgroundColor:"var(--error-light)",border:"1px solid var(--error-border)",borderRadius:"12px",padding:"16px"},L={backgroundColor:"var(--modal-bg-subtle)",border:"1px solid var(--border-subtle)",borderRadius:"12px",padding:"12px"},E={color:"var(--foreground)",fontWeight:500},W={color:"var(--text-muted)",fontSize:"12px"},z={backgroundColor:"var(--success-light)",color:"var(--success)",fontSize:"12px",padding:"2px 8px",borderRadius:"9999px"},H={backgroundColor:"var(--modal-bg-elevated)",border:"1px solid var(--border-subtle)",borderRadius:"8px",color:"var(--foreground)",padding:"4px 8px"},q=r?(e=>{let a=O(e.amount,e.frequency),t=e.taxRate||0;if(t>0){let s=e.retirementContributionPct||0,l=a-s/100*a-(e.otherPretax
1Deductions||0);return l-t/100*l}return a})(r):0;r&&O(r.amount,r.frequency);let Y=i-q,G=d<=1,J=Y<o,Q=J?o-Y:0;(0,l.useEffect)(()=>{a&&(j(null),N(!1),C([]))},[a]),(0,l.useEffect)(()=>{f&&J&&C(n.filter(e=>{if(e.isDebt){let a=e.minimumPayment||0;return Math.min(e.allocated-a,e.allocated-e.spent)>0}return e.allocated-e.spent>0}).map(e=>{if(e.isDebt){let a=e.minimumPayment||0,t=Math.min(e.allocated-a,e.allocated-e.spent);return{categoryId:e.id,name:e.name,currentAllocated:e.allocated,spent:e.spent,availableToReduce:Math.max(0,t),adjustAmount:0,isDebt:!0,minimumPayment:a}}return{categoryId:e.id,name:e.name,currentAllocated:e.allocated,spent:e.spent,availableToReduce:e.allocated-e.spent,adjustAmount:0,isDebt:!1,minimumPayment:void 0}}))},[f,J,n]);let K=(0,l.useMemo)(()=>w.reduce((e,a)=>e+a.adjustAmount,0),[w]),Z=Q-K,X=Z<=.99;if(!r)return null;let $=(e,a)=>{C(t=>t.map(t=>{if(t.categoryId!==e)return t;let s=Math.min(Math.max(0,a),t.availableToReduce);return{...t,adjustAmount:s}}))},ee=async()=>{if(j(null),J&&!f)return void N(!0);if(f&&J&&!X)return void j("You still need to free up ".concat(u).concat(U(Z)," from categories"));p(!0);try{let e;f&&w.length>0&&J&&(e=w.filter(e=>e.adjustAmount>0).map(e=>({categoryId:e.categoryId,newAllocated:Math.floor(e.currentAllocated-e.adjustAmount)}))),await m({sourceId:r.id,rebalanceChanges:e}),t()}catch(a){let{message:e}=(0,v.P)(a);j(e)}finally{p(!1)}},ea=()=>{x||t()};return a?(0,s.jsx)("div",{className:"fixed inset-0 flex items-center justify-center z-50 p-4 overflow-y-auto",style:{backgroundColor:"rgba(0, 0, 0, 0.6)",backdropFilter:"blur(8px)",WebkitBackdropFilter:"blur(8px)"},onClick:e=>{e.target===e.currentTarget&&ea()},children:(0,s.jsxs)("div",{className:"max-w-lg w-full my-8",style:{backgroundColor:"var(--modal-bg)",border:"1px solid var(--border-subtle)",borderRadius:"20px",boxShadow:"0 25px 50px -12px rgba(0, 0, 0, 0.25)"},role:"dialog","aria-modal":"true",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between",style:{borderBottom:"1px solid var(--border-subtle)",padding:"20px 24px"},children:[(0,s.jsxs)("h2",{className:"flex items-center gap-2",style:{color:"var(--foreground)",fontSize:"20px",fontWeight:600},children:[(0,s.jsx)(V.A,{className:"h-5 w-5",style:{color:"var(--muted-foreground)"}}),"Delete Income Source"]}),(0,s.jsx)("button",{onClick:ea,disabled:x,style:{color:"var(--text-muted)"},children:(0,s.jsx)(h.A,{className:"h-6 w-6"})})]}),(0,s.jsxs)("div",{style:{padding:"24px",maxHeight:"70vh",overflowY:"auto"},className:"space-y-4",children:[g&&(0,s.jsxs)("div",{className:"flex items-start gap-2",style:P,children:[(0,s.jsx)(k.A,{className:"h-5 w-5 flex-shrink-0 mt-0.5",style:T}),(0,s.jsx)("p",{style:_,children:g})]}),G&&(0,s.jsx)("div",{style:P,children:(0,s.jsxs)("div",{className:"flex items-start gap-3",children:[(0,s.jsx)(k.A,{className:"h-6 w-6 flex-shrink-0 mt-0.5",style:T}),(0,s.jsxs)("div",{children:[(0,s.jsx)("h3",{style:M,children:"Cannot Delete Your Only Income Source"}),(0,s.jsxs)("p",{style:F,children:["A budget requires at least one income source. You cannot delete ",(0,s.jsx)("strong",{style:A,children:r.name})," because it's your only income."]}),(0,s.jsx)("p",{style:{...F,marginTop:"12px"},children:"You can:"}),(0,s.jsxs)("ul",{style:{...F,marginLeft:"16px",listStyle:"disc"},children:[(0,s.jsxs)("li",{children:[(0,s.jsx)("strong",{style:A,children:"Edit"})," this income source to change the amount"]}),(0,s.jsxs)("li",{children:[(0,s.jsx)("strong",{style:A,children:"Add another income source first"}),", then delete this one"]})]})]})]})}),!G&&!J&&(0,s.jsxs)("div",{children:[(0,s.jsxs)("p",{style:_,children:["Are you sure you want to delete ",(0,s.jsx)("strong",{style:A,children:r.name}),"?"]}),(0,s.jsxs)("div",{className:"mt-4",style:S,children:[(0,s.jsxs)("div",{className:"flex items-center justify-between text-sm",children:[(0,s.jsx)("span",{style:I,children:"Monthly amount:"}),(0,s.jsxs)("span",{style:R,children:[u,U(q)]})]}),(0,s.jsxs)("div",{className:"flex items-center justify-between text-sm mt-2",children:[(0,s.jsx)("span",{style:I,children:"New total income:"}),(0,s.jsxs)("span",{style:R,children:[u,U(Y)]})]})]}),(0,s.jsxs)("p",{className:"mt-3 text-sm",style:{color:"var(--success)",fontSize:"14px"},children:["Your budget will have ",u,U(Y-o)," available after this change."]})]}),!G&&J&&!f&&(0,s.jsxs)("div",{children:[(0,s.jsxs)("p",{style:_,children:["Deleting ",(0,s.jsx)("strong",{style:A,children:r.name})," will cause your budget to be over-allocated."]}),(0,s.jsxs)("div",{className:"mt-4",style:S,children:[(0,s.jsxs)("div",{className:"flex items-center justify-between text-sm",children:[(0,s.jsx)("span",{style:I,children:"Removing:"}),(0,s.jsxs)("span",{style:{color:"var(--text-secondary)"},children:["-",u,U(q),"/mo"]})]}),(0,s.jsxs)("div",{className:"flex items-center justify-between text-sm mt-2",children:[(0,s.jsx)("span",{style:I,children:"New total income:"}),(0,s.jsxs)("span",{style:R,children:[u,U(Y)]})]}),(0,s.jsxs)("div",{className:"flex items-center justify-between text-sm mt-2",children:[(0,s.jsx)("span",{style:I,children:"Currently allocated:"}),(0,s.jsxs)("span",{style:R,children:[u,U(o)]})]}),(0,s.jsxs)("div",{className:"flex items-center justify-between text-sm mt-2 pt-2",style:{borderTop:"1px solid var(--border-subtle)"},children:[(0,s.jsx)("span",{style:B,children:"Over-allocation:"}),(0,s.jsxs)("span",{style:B,children:[u,U(Q)]})]})]}),(0,s.jsx)("div",{className:"mt-4",style:D,children:(0,s.jsxs)("div",{className:"flex items-start gap-2",children:[(0,s.jsx)(k.A,{className:"h-5 w-5 flex-shrink-0 mt-0.5",style:T}),(0,s.jsxs)("p",{style:F,children:["You'll need to reduce category allocations by ",u,U(Q)," to balance your budget."]})]})})]}),!G&&f&&J&&(0,s.jsxs)("div",{className:"border-t pt-4",style:{borderColor:"var(--border-subtle)"},children:[(0,s.jsxs)("div",{style:D,className:"mb-4",children:[(0,s.jsxs)("h3",{className:"font-medium mb-2 flex items-center gap-2",style:M,children:[(0,s.jsx)(y.A,{className:"h-4 w-4"}),"Reduce Category Allocations"]}),(0,s.jsxs)("p",{style:F,className:"mb-3",children:["Free up ",u,U(Q)," from your categories to complete the deletion."]}),(0,s.jsxs)("div",{className:"flex items-center gap-3",children:[(0,s.jsx)("div",{className:"flex-1",style:{backgroundColor:"var(--modal-bg-elevated)",borderRadius:"9999px",height:"8px",overflow:"hidden"},children:(0,s.jsx)("div",{style:{background:"var(--progress-gradient-success)",borderRadius:"9999px",height:"100%",transition:"width 0.3s ease",width:"".concat(Q>0?Math.min(K/Q*100,100):0,"%")}})}),(0,s.jsxs)("span",{className:"text-sm font-medium",style:{color:X?"var(--success)":"var(--text-secondary)"},children:[u,U(K)," / ",u,U(Q)]})]})]}),w.length>0?(0,s.jsx)("div",{className:"space-y-3 max-h-60 overflow-y-auto",children:w.map(e=>(0,s.jsxs)("div",{style:L,children:[(0,s.jsx)("div",{className:"flex items-center justify-between mb-2",children:(0,s.jsxs)("div",{children:[(0,s.jsx)("span",{style:E,children:e.name}),e.isDebt&&(0,s.jsx)("span",{className:"ml-2",style:z,children:"Debt"}),(0,s.jsxs)("div",{style:W,className:"mt-0.5",children:["Current: ",u,U(e.currentAllocated),e.isDebt&&void 0!==e.minimumPayment&&(0,s.jsxs)(s.Fragment,{children:[" \xb7 Min: ",u,U(e.minimumPayment)]})," \xb7 ","Available: ",u,U(e.availableToReduce)]})]})}),(0,s.jsxs)("div",{className:"flex items-center gap-3",children:[(0,s.jsx)("input",{type:"range",min:"0",max:e.availableToReduce,value:e.adjustAmount,onChange:a=>$(e.categoryId,parseFloat(a.target.value)),className:"flex-1 h-2 rounded-lg appearance-none cursor-pointer",style:{backgroundColor:"var(--modal-bg-elevated)",accentColor:"var(--success)"}}),(0,s.jsxs)("div",{className:"flex items-center gap-1 w-24",children:[(0,s.jsxs)("span",{style:{color:"var(--text-muted)"},children:["-",u]}),(0,s.jsx)("input",{type:"number",min:"0",max:e.availableToReduce,value:e.adjustAmount||"",onChange:a=>$(e.categoryId,parseFloat(a.target.value)||0),className:"w-16 text-sm text-right",style:H})]})]})]},e.categoryId))}):(0,s.jsx)("div",{style:P,children:(0,s.jsx)("p",{style:_,children:"No categories have available funds to reduce. Delete some transactions first or wait for next month."})})]})]}),(0,s.jsxs)("div",{className:"flex justify-end gap-3",style:{borderTop:"1px solid var(--border-subtle)",padding:"16px 24px"},children:[(0,s.jsx)("button",{onClick:ea,disabled:x,style:{backgroundColor:"var(--modal-bg-elevated)",color:"var(--text-secondary)",border:"1px solid var(--border-subtle)",padding:"10px 16px",borderRadius:"10px",fontSize:"14px",fontWeight:500,cursor:"pointer",transition:"all 0.2s ease"}
1,children:G?"Close":"Cancel"}),!G&&(0,s.jsx)("button",{onClick:ee,disabled:x||f&&J&&!X,style:{backgroundColor:"var(--error-light)",color:"var(--destructive)",border:"1px solid var(--error-border)",padding:"10px 16px",borderRadius:"10px",fontSize:"14px",fontWeight:500,cursor:"pointer",transition:"all 0.2s ease",opacity:x||f&&J&&!X?.5:1},children:x?(0,s.jsxs)("span",{className:"flex items-center gap-2",children:[(0,s.jsxs)("svg",{className:"animate-spin h-4 w-4",viewBox:"0 0 24 24",children:[(0,s.jsx)("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4",fill:"none"}),(0,s.jsx)("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]}),"Deleting..."]}):J&&!f?"Continue to Rebalance":"Delete Income Source"})]})]})}):null}var G=t(19609);let J=e=>Math.round(e),Q=[{value:"CREDIT_CARD",label:"Credit Card"},{value:"PERSONAL_LOAN",label:"Personal Loan"},{value:"AUTO_LOAN",label:"Auto Loan"},{value:"STUDENT_LOAN",label:"Student Loan"},{value:"MORTGAGE",label:"Mortgage"},{value:"MEDICAL",label:"Medical Debt"},{value:"OTHER",label:"Other"}];function K(e){let{isOpen:a,onClose:t,editingDebt:r,existingCategories:n,budgetIncome:o,totalAllocated:c,budgetId:i,onSave:d}=e,{symbol:m,format:u}=(0,b.H)(),x=e=>u(Math.round(e)),[g,j]=(0,l.useState)(""),[f,w]=(0,l.useState)("CREDIT_CARD"),[C,_]=(0,l.useState)(""),[A,k]=(0,l.useState)(""),[S,I]=(0,l.useState)(""),[R,B]=(0,l.useState)(""),[D,T]=(0,l.useState)(!1),[M,F]=(0,l.useState)(null),[P,L]=(0,l.useState)(!1),[E,W]=(0,l.useState)([]),[z,H]=(0,l.useState)(!1),V=!!r,U=parseFloat(S)||0,q=U>0?Math.ceil(U):0,O=(null==r?void 0:r.minimumPayment)||0,Y=c+(V?q-O:q),K=o-Y,Z=Y>o&&q>0,X=Z?Y-o:0;(0,l.useEffect)(()=>{a&&(r?(j(r.accountName),w(r.accountType),_(r.balance.toString()),k(r.apr.toString()),I(r.minimumPayment.toString()),B(r.creditor||""),H(!0)):(j(""),w("CREDIT_CARD"),_(""),k(""),I(""),B(""),H(!1)),F(null),L(!1),W([]))},[a,r]),(0,l.useEffect)(()=>{if(!V&&"CREDIT_CARD"===f){let e=parseFloat(C)||0,a=parseFloat(A)||0;e>0&&I((e<=0?0:"CREDIT_CARD"===f?Math.round(Math.round(a/100/12*e)+Math.max(.01*e,25)):0).toString())}},[C,A,f,V]),(0,l.useEffect)(()=>{P&&Z&&W(n.filter(e=>{if(e.isDebt){let a=e.minimumPayment||0;return Math.min(e.allocated-a,e.allocated-e.spent)>0}return e.allocated-e.spent>0}).map(e=>{if(e.isDebt){let a=e.minimumPayment||0,t=Math.min(e.allocated-a,e.allocated-e.spent);return{categoryId:e.id,name:e.name,currentAllocated:e.allocated,spent:e.spent,availableToReduce:t,adjustAmount:0,isDebt:!0,minimumPayment:a}}return{categoryId:e.id,name:e.name,currentAllocated:e.allocated,spent:e.spent,availableToReduce:e.allocated-e.spent,adjustAmount:0,isDebt:!1,minimumPayment:0}}))},[P,Z,n]);let $=(0,l.useMemo)(()=>E.reduce((e,a)=>e+a.adjustAmount,0),[E]),ee=X-$,ea=!Z||ee<=.99,et=(e,a)=>{W(t=>t.map(t=>{if(t.categoryId!==e)return t;let s=Math.max(0,Math.min(a,t.availableToReduce));return{...t,adjustAmount:s}}))},es=async e=>{if(e.preventDefault(),F(null),!g.trim())return void F("Account name is required");let a=parseFloat(C)||0;if(a<=0)return void F("Balance must be greater than 0");let s=parseFloat(A)||0;if(s<0||s>100)return void F("APR must be between 0% and 100%");if(q<=0)return void F("Minimum payment must be greater than 0");if(Z&&!P)return void L(!0);if(P&&Z&&!ea)return void F("You still need to free up ".concat(x(ee)));T(!0);try{let e;P&&E.length>0&&Z&&(e=E.filter(e=>e.adjustAmount>0).map(e=>({categoryId:e.categoryId,newAllocated:Math.floor(e.currentAllocated-e.adjustAmount)}))),await d({accountName:g.trim(),accountType:f,balance:a,apr:s,minimumPayment:U,creditor:R.trim()||void 0,rebalanceChanges:e,isEditing:V,debtId:null==r?void 0:r.id}),t()}catch(a){let{message:e}=(0,v.P)(a);F(e)}finally{T(!1)}},el=()=>{D||t()};return a?(0,s.jsx)("div",{className:N().overlay,onClick:e=>{e.target===e.currentTarget&&el()},children:(0,s.jsxs)("div",{className:"".concat(N().modal," ").concat(N().modalLarge),role:"dialog","aria-modal":"true",children:[(0,s.jsxs)("div",{className:N().header,children:[(0,s.jsx)("div",{className:N().headerLeft,children:(0,s.jsx)("h2",{className:N().headerTitle,children:V?"Edit Debt Account":"Add Debt Account"})}),(0,s.jsx)("button",{onClick:el,disabled:D,className:N().closeButton,children:(0,s.jsx)(h.A,{className:"h-6 w-6"})})]}),(0,s.jsxs)("form",{onSubmit:es,children:[(0,s.jsxs)("div",{className:P?N().contentRebalancing:N().content,children:[M&&(0,s.jsxs)("div",{className:N().errorBox,children:[(0,s.jsx)(p.A,{className:"h-5 w-5 ".concat(N().errorIcon)}),(0,s.jsx)("p",{className:N().errorText,children:M})]}),!P&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("div",{className:N().fieldGroup,children:[(0,s.jsx)("label",{className:N().label,children:"Account Name"}),(0,s.jsx)("input",{type:"text",value:g,onChange:e=>j(e.target.value),placeholder:"e.g., Chase Visa, Car Loan",className:N().input,maxLength:100,disabled:D,autoFocus:!0})]}),(0,s.jsxs)("div",{className:N().fieldGroup,children:[(0,s.jsx)("label",{className:N().label,children:"Account Type"}),(0,s.jsx)("select",{value:f,onChange:e=>w(e.target.value),className:"".concat(N().input," ").concat(N().inputField),disabled:D,children:Q.map(e=>(0,s.jsx)("option",{value:e.value,children:e.label},e.value))})]}),(0,s.jsxs)("div",{className:N().fieldGroup,style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"1rem"},children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{className:N().label,children:"Current Balance"}),(0,s.jsxs)("div",{className:N().inputWrapper,children:[(0,s.jsx)("span",{className:N().inputPrefix,children:m}),(0,s.jsx)("input",{type:"number",step:"0.01",min:"0",value:C,onChange:e=>_(e.target.value),placeholder:"0",className:"".concat(N().input," ").concat(N().inputWithPrefix),disabled:D})]})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{className:N().label,children:"APR (%)"}),(0,s.jsx)("input",{type:"number",step:"0.01",min:"0",max:"100",value:A,onChange:e=>k(e.target.value),placeholder:"0.00",className:N().input,disabled:D})]})]}),(0,s.jsxs)("div",{className:N().fieldGroup,children:[(0,s.jsxs)("label",{className:N().label,children:["Minimum Payment",!V&&"CREDIT_CARD"===f&&q>0&&(0,s.jsx)("span",{className:N().statusPositive,style:{marginLeft:"0.5rem",fontSize:"0.75rem",fontWeight:"normal"},children:"(estimated)"})]}),(0,s.jsxs)("div",{className:N().inputWrapper,children:[(0,s.jsx)("span",{className:N().inputPrefix,children:m}),(0,s.jsx)("input",{type:"number",step:"1",min:"0",value:S,onChange:e=>{I(e.target.value),H(!0),L(!1),W([])},placeholder:"0",className:"".concat(N().input," ").concat(N().inputWithPrefix),disabled:D})]}),q>0&&(0,s.jsxs)("div",{className:N().budgetContext,children:[(0,s.jsx)("span",{children:"Budget: "}),(0,s.jsx)("span",{className:N().budgetContextValue,children:x(o)}),(0,s.jsx)("span",{children:" \xb7 Currently allocated: "}),(0,s.jsx)("span",{className:N().budgetContextValue,children:x(c)})]}),q>0&&(0,s.jsx)("div",{className:N().budgetContext,children:J(K)>=0?(0,s.jsxs)("span",{className:N().statusPositive,children:["â ",x(Math.abs(K))," available after adding this debt"]}):(0,s.jsxs)("span",{className:N().statusNegative,children:["â Would exceed budget by ",x(X)]})}),(0,s.jsxs)("div",{className:N().infoBox,style:{marginTop:"0.75rem"},children:[(0,s.jsx)(G.A,{className:"h-5 w-5 flex-shrink-0",style:{color:"var(--modal-primary)"}}),(0,s.jsx)("p",{className:N().infoText,children:V?"Changing the minimum payment will update the linked budget category allocation.":'Adding this debt will create a new budget category "'.concat(g||"Debt",' Payment" with ').concat(x(q)," allocation.")})]}),Z&&!P&&q>0&&(0,s.jsx)("div",{className:"".concat(N().warningBox," ").concat(N().warningBoxIncrease),style:{marginTop:"0.75rem"},children:(0,s.jsxs)("p",{className:"".concat(N().warningText," ").concat(N().warningTextIncrease),children:[(0,s.jsx)(y.A,{className:"h-4 w-4 inline mr-1"}),"Budget fully allocated. You'll need to reduce other categories by ",(0,s.jsx)("strong",{children:x(X)}),"."]})})]}),(0,s.jsxs)("div",{className:N().fieldGroup,children:[(0,s.jsxs)("label",{className:N().label,children:["Creditor ",(0,s.jsx)("span",{style:{opacity:.6},children:"(optional)"})]}),(0,s.jsx)("input",{type:"text",value:R,onChange:e=>B(e.target.value),placeholder:"e.g., Chase Bank, Capital One",className:N().input,maxLength:100,disabled:D})]})]}),P&&Z&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("div",{className:"".concat(N().rebalanceHeader," ").concat(N().rebalanceHeaderIncrease),children:[(0,s.jsxs)("div",{className:N().rebalanceSummary,children:[(0,s.jsxs)("div",{className:N().rebalanceSummaryCategory,children:[(0,s.jsx)("span",{children:"\uD83D\uDCB3"}),(0,s.jsx)("span",{className:N().categoryName,children:g||"New Debt"})]}),(0,s.jsxs)("span",{className:N().rebalanceSummaryAmount,children:[x(parseFloat(C)||0)," @ ",A||0,"%"]})]}),(0,s.jsx)("h3",{className:"".concat(N().rebalanceTitle," ").concat(N().rebalanceTitleIncrease),children:"Free Up Funds"}),(0,s.jsxs)("p",{className:"".concat(N().rebalanceDescription," ").concat(N().rebalanceDescriptionIncrease),children:["Reduce other categories to free up ",x(X)," for this debt payment"]}),(0,s.jsxs)("div",{className:N().progressContainer,children:[(0,s.jsx)("div",{className:N().progressTrack,children:(0,s.jsx)("div",{className:"".concat(N().progressFill," ").concat(ea?N().progressFillC
1omplete:N().progressFillIncrease),style:{width:"".concat(X>0?Math.min($/X*100,100):0,"%")}})}),(0,s.jsxs)("span",{className:"".concat(N().progressLabel," ").concat(ea?N().progressLabelComplete:N().progressLabelPending),children:[x($)," / ",x(X)]})]})]}),E.length>0?(0,s.jsx)("div",{className:N().categoryList,children:E.map(e=>(0,s.jsxs)("div",{className:N().categoryRow,children:[(0,s.jsx)("div",{className:N().categoryRowHeader,children:(0,s.jsxs)("div",{className:N().categoryRowInfo,children:[(0,s.jsx)("span",{className:N().categoryRowName,children:e.name}),(0,s.jsxs)("span",{className:N().categoryRowMeta,children:["Current: ",x(e.currentAllocated)," \xb7 ","Available: ",x(e.availableToReduce)]})]})}),(0,s.jsxs)("div",{className:N().categoryRowControls,children:[(0,s.jsx)("input",{type:"range",min:"0",max:e.availableToReduce,value:e.adjustAmount,onChange:a=>et(e.categoryId,parseFloat(a.target.value)),className:N().categorySlider}),(0,s.jsxs)("div",{className:N().categoryInputWrapper,children:[(0,s.jsxs)("span",{className:N().categoryInputPrefix,children:["-",m]}),(0,s.jsx)("input",{type:"number",min:"0",max:e.availableToReduce,value:e.adjustAmount||"",onChange:a=>et(e.categoryId,parseFloat(a.target.value)||0),className:N().categoryInput})]})]}),(0,s.jsx)("div",{className:N().quickAmounts,children:(()=>{let a=J(ee);return[a>0&&a<=e.availableToReduce?a:null,10,25,50,100].filter(a=>null!==a&&!(a<=0)&&!(a>e.availableToReduce)).slice(0,4).map((t,l)=>(0,s.jsx)("button",{type:"button",onClick:()=>et(e.categoryId,e.adjustAmount+t),className:"".concat(N().quickAmountBtn," ").concat(t===a?N().quickAmountBtnExact:N().quickAmountBtnNormal),children:t===a?"".concat(m).concat(t," (exact)"):"+".concat(m).concat(t)},"".concat(e.categoryId,"-").concat(t,"-").concat(l)))})()})]},e.categoryId))}):(0,s.jsx)("div",{className:N().errorBox,children:(0,s.jsx)("p",{className:N().errorText,children:"No categories have available funds to reduce."})})]})]}),(0,s.jsxs)("div",{className:N().footer,children:[(0,s.jsx)("div",{className:N().footerLeft,children:P&&(0,s.jsx)("button",{type:"button",onClick:()=>{L(!1),W([])},disabled:D,className:N().backButton,children:"â Back"})}),(0,s.jsxs)("div",{className:N().footerRight,children:[(0,s.jsx)("button",{type:"button",onClick:el,disabled:D,className:N().secondaryButton,children:"Cancel"}),(0,s.jsx)("button",{type:"submit",disabled:D||P&&!ea,className:N().primaryButton,children:D?(0,s.jsxs)("span",{className:"flex items-center gap-2",children:[(0,s.jsxs)("svg",{className:N().spinner,width:"16",height:"16",viewBox:"0 0 24 24",children:[(0,s.jsx)("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4",fill:"none"}),(0,s.jsx)("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]}),"Saving..."]}):Z&&!P?"Continue to Rebalance":V?"Update Debt Account":"Add Debt Account"})]})]})]})]})}):null}var Z=t(1006);let X=e=>Math.round(e).toLocaleString();function $(e){let{isOpen:a,onClose:t,debt:r,existingCategories:n,spentThisMonth:o,blockingTransactions:c,isInPlan:i,planStatus:d,planStrategy:m,allDebts:u,onDelete:x,onDeleteTransaction:p}=e,{symbol:g}=(0,b.H)(),y="paused"===d,j=i&&!y,[f,w]=(0,l.useState)(!1),[C,_]=(0,l.useState)(!1),[S,I]=(0,l.useState)(null),[R,B]=(0,l.useState)([]),[D,T]=(0,l.useState)(!1),M=n.find(e=>e.linkedDebtId===(null==r?void 0:r.id)),F=(null==M?void 0:M.allocated)||(null==r?void 0:r.minimumPayment)||0,P=(null==M?void 0:M.spent)||o||0,L=Math.max(0,F-P),E=P>0,W=(0,l.useMemo)(()=>{if(!i||!u||!r||!m)return[];let e=u.filter(e=>e.id!==r.id&&e.balance>0);return 0===e.length?[]:[...e].sort((e,a)=>"avalanche"===m?a.apr-e.apr:"snowball"===m?e.balance-a.balance:a.apr-e.apr).map(e=>{var a,t,s;let l=n.find(a=>a.linkedDebtId===e.id),r=null!=(t=null!=(a=null==l?void 0:l.allocated)?a:e.minimumPayment)?t:0,o=Math.max(0,(null!=(s=e.balance)?s:0)-r);return{...e,currentAllocated:r,roomForMore:o,linkedCategoryId:null==l?void 0:l.id}})},[i,u,r,m,n]),z=(0,l.useMemo)(()=>
1{if(0===W.length||L<=0)return[];let e=[],a=L;for(let t of W){if(a<=0)break;if(t.roomForMore<=0)continue;let s=Math.min(a,t.roomForMore);e.push({debt:t,amount:s}),a-=s}return e},[W,L]);z.length>0&&z[0].debt,(0,l.useEffect)(()=>{a&&r&&L>0&&(B(n.filter(e=>e.linkedDebtId!==r.id&&(!e.isDebt||!!y)).map(e=>({categoryId:e.id,name:e.name,currentAllocated:e.allocated,addAmount:0,isDebt:e.isDebt}))),I(null),T(!1))},[a,r,L,n,y]);let H=(0,l.useMemo)(()=>R.reduce((e,a)=>e+a.addAmount,0),[R]),U=L-H,q=L>0&&U<=.99,O=j&&z.length>0&&L>0,Y=(e,a)=>{B(t=>t.map(t=>t.categoryId!==e?t:{...t,addAmount:Math.max(0,a)}))},J=async()=>{if(r){if(!E&&L>0&&!O&&!q)return void I("You still need to allocate ".concat(g).concat(X(U)," to other categories"));w(!0),I(null);try{let e;L>0&&!O&&R.length>0&&(e=R.filter(e=>e.addAmount>0).map(e=>({categoryId:e.categoryId,newAllocated:Math.round(e.currentAllocated+e.addAmount)})));let a=O?z.filter(e=>e.debt.linkedCategoryId&&e.amount>0).map(e=>({categoryId:e.debt.linkedCategoryId,debtId:e.debt.id,addAmount:e.amount})):void 0;await x({debtId:r.id,rebalanceChanges:e,rolloverDistribution:a,forceWithPartialReallocation:E&&q}),t()}catch(a){let{message:e}=(0,v.P)(a);I(e)}finally{w(!1)}}},Q=async e=>{_(!0),I(null);try{await p(e),t()}catch(a){let{message:e}=(0,v.P)(a);I(e)}finally{_(!1)}},K=()=>{f||C||t()};return a&&r?(0,s.jsx)("div",{className:N().overlay,onClick:e=>{e.target===e.currentTarget&&K()},children:(0,s.jsxs)("div",{className:"".concat(N().modal," ").concat(N().modalLarge),role:"dialog","aria-modal":"true",children:[(0,s.jsxs)("div",{className:N().header,children:[(0,s.jsxs)("div",{className:N().headerLeft,children:[(0,s.jsx)(k.A,{className:"h-5 w-5 ".concat(N().headerIconWarning)}),(0,s.jsx)("h2",{className:N().headerTitle,children:"Delete Debt Account"})]}),(0,s.jsx)("button",{onClick:K,disabled:f||C,className:N().closeButton,children:(0,s.jsx)(h.A,{className:"h-5 w-5"})})]}),(0,s.jsxs)("div",{className:N().content,children:[S&&(0,s.jsx)("div",{className:N().errorBox,children:(0,s.jsx)("p",{className:N().errorText,children:S})}),(0,s.jsxs)("div",{className:N().deleteCategoryInfo,children:[(0,s.jsxs)("div",{className:N().deleteCategoryHeader,children:[(0,s.jsx)("span",{style:{fontSize:"1.5rem"},children:"\uD83D\uDCB3"}),(0,s.jsx)("span",{className:N().deleteCategoryName,children:r.accountName})]}),(0,s.jsxs)("div",{className:N().deleteCategoryStats,children:[(0,s.jsxs)("div",{className:N().deleteCategoryStat,children:[(0,s.jsx)("span",{className:N().deleteStatLabel,children:"Balance:"}),(0,s.jsxs)("span",{className:N().deleteStatValue,children:[g,X(r.balance)]})]}),(0,s.jsxs)("div",{className:N().deleteCategoryStat,children:[(0,s.jsx)("span",{className:N().deleteStatLabel,children:"Monthly:"}),(0,s.jsxs)("span",{className:N().deleteStatValue,children:[g,X(F)]})]}),(0,s.jsxs)("div",{className:N().deleteCategoryStat,children:[(0,s.jsx)("span",{className:N().deleteStatLabel,children:"Spent:"}),(0,s.jsxs)("span",{className:N().deleteStatValue,children:[g,X(P)]})]}),L>0&&(0,s.jsxs)("div",{className:N().deleteCategoryStat,children:[(0,s.jsx)("span",{className:N().deleteStatLabel,children:"Available:"}),(0,s.jsxs)("span",{className:N().deleteStatValue,style:{color:"var(--modal-primary)"},children:[g,X(L)]})]})]})]}),j&&!E&&z.length>0&&(0,s.jsxs)("div",{className:N().infoBox,style:{marginTop:"1rem"},children:[(0,s.jsx)(A.A,{className:"h-4 w-4 flex-shrink-0",style:{color:"var(--modal-primary)"}}),(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:N().infoText,style:{fontWeight:500,marginBottom:"0.5rem"},children:1===z.length?"Payment rolls to next debt":"Payment splits across ".concat(z.length," debts")}),z.map((e,a)=>(0,s.jsxs)("p",{className:N().infoText,children:[0===a&&(0,s.jsx)("span",{style:{textDecoration:"line-through",opacity:.6},children:null==r?void 0:r.accountName}),0===a&&" â ",a>0&&"â ",(0,s.jsx)("span",{style:{color:"var(--modal-primary)",fontWeight:500},children:e.debt.accountName})," ",(0,s.jsxs)("span",{style:{color:"var(--modal-primary)"},children:["+",g,X(e.amount)]})]},e.debt.id))]})]}),j&&!E&&0===z.length&&(0,s.jsxs)("div",{className:N().successBox,style:{marginTop:"1rem",textAlign:"center"},children:[(0,s.jsx)("p",{className:N().successText,children:0===W.length?"\uD83C\uDF89 Last debt in your plan!":"All other debts at maximum"}),(0,s.jsxs)("p",{className:N().infoText,style:{marginTop:"0.25rem"},children:["Deleting will free ",g,X(F),"/mo for other goals."]})]}),E&&!D&&(0,s.jsxs)("div",{className:N().warningBox,style:{marginTop:"1rem"},children:[(0,s.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"0.5rem",marginBottom:"0.5rem"},children:[(0,s.jsx)(k.A,{className:"h-4 w-4",style:{color:"var(--modal-warning)"}}),(0,s.jsx)("span",{className:N().warningTitle,children:"Cannot Delete - Money Spent This Month"})]}),(0,s.jsxs)("p",{className:N().warningText,children:["You've spent ",(0,s.jsxs)("strong",{children:[g,X(P)]})," of your ",g,X(F)," budget this month."]}),(0,s.jsxs)("div",{style:{marginTop:"0.75rem",display:"flex",flexDirection:"column",gap:"0.5rem"},children:[L>0&&(0,s.jsxs)("p",{className:N().infoText,style:{color:"var(--modal-primary)"},children:[(0,s.jsx)("strong",{children:"Option 1:"})," Reallocate the ",g,X(L)," unspent portion below, then delete."]}),(0,s.jsxs)("p",{className:N().infoText,style:{color:"var(--modal-text-muted)"},children:[(0,s.jsxs)("strong",{children:["Option ",L>0?"2":"1",":"]})," Wait until next month when spending resets to ",g,"0."]}),c.length>0&&(0,s.jsxs)("button",{onClick:()=>T(!0),style:{marginTop:"0.25rem",display:"flex",alignItems:"center",gap:"0.5rem",background:"none",border:"none",color:"var(--modal-success)",cursor:"pointer",fontSize:"0.875rem",padding:0},children:[(0,s.jsx)(G.A,{className:"h-4 w-4"}),(0,s.jsxs)("span",{children:[(0,s.jsxs)("strong",{children:["Option ",L>0?"3":"2",":"]})," Delete the transaction(s) first â"]})]})]})]}),E&&D&&c.length>0&&(0,s.jsxs)("div",{className:N().infoBox,style:{marginTop:"1rem"},children:[(0,s.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"0.75rem"},children:[(0,s.jsxs)("span",{style:{display:"flex",alignItems:"center",gap:"0.5rem",color:"var(--modal-primary)",fontWeight:500},children:[(0,s.jsx)(V.A,{className:"h-4 w-4"}),"Delete Transaction"]}),(0,s.jsx)("button",{onClick:()=>T(!1),style:{background:"none",border:"none",color:"var(--modal-text-muted)",cursor:"pointer",fontSize:"0.875rem"},children:"â Back"})]}),c.map(e=>(0,s.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:"0.5rem",padding:"0.5rem",background:"var(--modal-surface-2)",borderRadius:"0.5rem",marginBottom:"0.5rem"},children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{style:{color:"var(--modal-text)",fontSize:"0.875rem"},children:e.description||"".concat(r.accountName," Payment")}),(0,s.jsxs)("p",{style:{color:"var(--modal-text-muted)",fontSize:"0.75rem"},children:[g,X(e.amount)," \xb7 ",(0,Z.TJ)(e.date)]})]}),(0,s.jsx)("button",{onClick:()=>Q(e.id),disabled:C,className:N().dangerButton,style:{padding:"0.375rem 0.75rem",fontSize:"0.75rem"},children:C?"...":"Delete"})]},e.id))]}),L>0&&(!i||y||E)&&(0,s.jsxs)("div",{style:{marginTop:"1rem"},children:[(0,s.jsxs)("div",{className:N().infoBox,style:{marginBottom:"0.75rem"},children:[(0,s.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",width:"100%"},children:[(0,s.jsxs)("span",{style:{color:"var(--modal-primary)",fontWeight:500},children:["Allocate freed ",g,X(L)]}),(0,s.jsxs)("span",{style:{color:q?"var(--modal-primary)":"var(--modal-text-muted)",fontSize:"0.875rem",fontWeight:500},children:[g,X(H)," / ",g,X(L)]})]}),(0,s.jsx)("div",{className:N().progressTrack,style:{marginTop:"0.5rem"},children:(0,s.jsx)("div",{className:"".concat(N().progressFill," ").concat(q?N().progressFillC
1omplete:N().progressFillDecrease),style:{width:"".concat(L>0?Math.min(H/L*100,100):0,"%")}})})]}),R.length>0?(0,s.jsx)("div",{className:N().categoryList,style:{maxHeight:"12rem"},children:R.map(e=>(0,s.jsxs)("div",{className:N().categoryRow,children:[(0,s.jsx)("div",{className:N().categoryRowHeader,children:(0,s.jsx)("span",{className:N().categoryRowName,children:e.name})}),(0,s.jsx)("div",{className:N().categoryRowControls,children:(0,s.jsxs)("div",{className:N().categoryInputWrapper,children:[(0,s.jsxs)("span",{className:N().categoryInputPrefix,children:["+",g]}),(0,s.jsx)("input",{type:"number",min:"0",value:e.addAmount||"",onChange:a=>Y(e.categoryId,parseFloat(a.target.value)||0),className:N().categoryInput})]})}),(0,s.jsx)("div",{className:N().quickAmounts,children:[25,50,100,U>0?Math.round(U):null].filter(e=>null!==e&&e>0).slice(0,4).map((a,t)=>(0,s.jsxs)("button",{type:"button",onClick:()=>Y(e.categoryId,e.addAmount+a),className:"".concat(N().quickAmountBtn," ").concat(a===Math.round(U)?N().quickAmountBtnExact:N().quickAmountBtnNormal),children:["+",g,a]},"".concat(e.categoryId,"-").concat(a,"-").concat(t)))})]},e.categoryId))}):(0,s.jsx)("div",{className:N().errorBox,children:(0,s.jsx)("p",{className:N().errorText,children:"No categories to reallocate to."})})]}),!E&&0===L&&!O&&(0,s.jsx)("div",{className:N().infoBox,style:{marginTop:"1rem",textAlign:"center"},children:(0,s.jsx)("p",{className:N().infoText,children:"No reallocation needed - debt can be deleted."})})]}),(0,s.jsxs)("div",{className:N().footer,children:[(0,s.jsx)("button",{onClick:K,disabled:f||C,className:N().secondaryButton,style:{flex:1},children:"Cancel"}),!(E&&D)&&(0,s.jsx)("button",{onClick:J,disabled:f||C||E&&!q||!E&&L>0&&!O&&!q,className:N().dangerButton,style:{flex:1},children:f?(0,s.jsxs)("span",{className:"flex items-center justify-center gap-2",children:[(0,s.jsxs)("svg",{className:N().spinner,width:"14",height:"14",viewBox:"0 0 24 24",children:[(0,s.jsx)("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4",fill:"none"}),(0,s.jsx)("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]}),"Deleting..."]}):E&&q?"Delete & Reallocate ".concat(g).concat(X(L)):"Delete Debt"})]})]})}):null}var ee=t(81100),ea=t(1213);let et=e=>Math.round(e).toLocaleString(),es=["#3B82F6","#10B981","#F59E0B","#EF4444","#8B5CF6","#EC4899","#06B6D4","#84CC16","#F97316","#6366F1"];function el(e){let{isOpen:a,onClose:t,planId:r,freedFunds:n,eligibleCategories:o,blocked:c,blockingInfo:i,onPause:d}=e,{symbol:m}=(0,b.H)(),[u,x]=(0,l.useState)(!1),[g,y]=(0,l.useState)(null),[j,f]=(0,l.useState)([]),[w,C]=(0,l.useState)("intro"),[_,A]=(0,l.useState)(!1),[S,I]=(0,l.useState)(""),[R,D]=(0,l.useState)("");(0,l.useEffect)(()=>{a&&(f(o.map(e=>({categoryId:e.id,name:e.name,currentAllocated:e.currentAllocated,addAmount:0,isNew:!1}))),y(null),C("intro"),A(!1),I(""),D(""))},[a,o]);let M=(0,l.useMemo)(()=>j.reduce((e,a)=>e+a.addAmount,0),[j]),F=n-M,P=F<=.99,L=(e,a)=>{f(t=>t.map(t=>t.categoryId!==e?t:{...t,addAmount:Math.max(0,a)}))},E=async()=>{if(!P&&n>0)return void y("You still need to allocate ".concat(m).concat(et(F)));x(!0),y(null);try{let e=j.filter(e=>e.addAmount>0).map(e=>({category_id:e.categoryId,amount:Math.round(100*e.addAmount)/100,isNew:e.isNew,name:e.isNew?e.name:void 0,color:e.isNew?e.color:void 0}));await d({customAllocations:e}),t()}catch(a){let{message:e}=(0,v.P)(a);y(e)}finally{x(!1)}},W=()=>{u||t()};if(!a)return null;let z="allocate"===w;return(0,s.jsx)("div",{className:N().overlay,onClick:e=>{e.target===e.currentTarget&&W()},children:(0,s.jsxs)("div",{className:"".concat(N().modal," ").concat(N().modalLarge),role:"dialog","aria-modal":"true",children:[(0,s.jsxs)("div",{className:N().header,children:[(0,s.jsxs)("div",{className:N().headerLeft,children:[z?(0,s.jsx)(ee.A,{className:"h-5 w-5 ".concat(N().headerIconSuccess)}):(0,s.jsx)(ea.A,{className:"h-5 w-5 ".concat(N().headerIconWarning)}),(0,s.jsx)("h2",{className:N().headerTitle,children:z?"Distribute Freed Funds":"Pause Your Plan"})]}),(0,s.jsx)("button",{onClick:W,disabled:u,className:N().closeButton,children:(0,s.jsx)(h.A,{className:"h-5 w-5"})})]}),(0,s.jsxs)("div",{className:z?N().contentRebalancing:N().content,children:[g&&(0,s.jsxs)("div",{className:N().errorBox,children:[(0,s.jsx)(p.A,{className:"h-5 w-5 ".concat(N().errorIcon)}),(0,s.jsx)("p",{className:N().errorText,children:g})]}),"intro"===w&&(0,s.jsxs)(s.Fragment,{children:[c&&i&&(0,s.jsxs)("div",{className:N().errorBox,style:{marginBottom:"1rem"},children:[(0,s.jsx)(k.A,{className:"h-5 w-5 flex-shrink-0",style:{color:"var(--modal-error)"}}),(0,s.jsxs)("div",{children:[(0,s.jsx)("span",{className:N().warningTitle,style:{color:"var(--modal-error)"},children:"Cannot Pause"}),(0,s.jsx)("p",{className:N().warningText,children:i.message})]})]}),(0,s.jsxs)("div",{className:N().infoBox,style:{flexDirection:"column",alignItems:"flex-start",ga
1p:"12px"},children:[(0,s.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[(0,s.jsx)(G.A,{className:"h-5 w-5 flex-shrink-0",style:{color:"var(--modal-accent)"}}),(0,s.jsx)("span",{style:{fontWeight:600,color:"var(--modal-primary)"},children:"What happens when you pause?"})]}),(0,s.jsx)("p",{style:{color:"var(--modal-secondary)",fontSize:"0.9rem",lineHeight:1.6},children:"Pausing your plan is meant to alleviate pressure. If you're tight on money right now, need to focus on other areas, or simply can't make these extra payments, pausing is for you."}),(0,s.jsx)("p",{style:{color:"var(--modal-secondary)",fontSize:"0.9rem",lineHeight:1.6},children:"Pausing will free the extra money going toward debt (if not already used this month). All debts will revert to just their minimum payments, and you'll allocate these freed funds to other budget categories."}),(0,s.jsx)("p",{style:{color:"var(--modal-secondary)",fontSize:"0.9rem",lineHeight:1.6},children:"You may resume anytime. When you do, you'll be asked to free up money from other categories to allocate back to your debt elimination plan."})]}),n>0&&(0,s.jsxs)("div",{className:N().successBox,style:{marginTop:"1rem"},children:[(0,s.jsx)(ee.A,{className:"h-5 w-5 flex-shrink-0",style:{color:"var(--modal-success)"}}),(0,s.jsxs)("div",{children:[(0,s.jsxs)("span",{style:{color:"var(--modal-success)",fontWeight:500},children:[m,et(n),"/month will be freed"]}),(0,s.jsx)("p",{className:N().infoText,children:"This is your extra payment amount above minimums that you'll reallocate."})]})]})]}),z&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("div",{className:N().infoBox,children:[(0,s.jsx)(ee.A,{className:"h-5 w-5 flex-shrink-0",style:{color:"var(--modal-success)"}}),(0,s.jsxs)("div",{children:[(0,s.jsxs)("span",{style:{color:"var(--modal-success)",fontWeight:500},children:["Funds freed: ",m,et(n),"/month"]}),(0,s.jsx)("p",{className:N().infoText,children:"Distribute across your categories. Debts will revert to minimum payments only."})]})]}),(0,s.jsxs)("div",{className:N().infoBox,style:{marginTop:"0.75rem"},children:[(0,s.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",width:"100%"},children:[(0,s.jsx)("span",{style:{color:"var(--modal-primary)",fontWeight:500},children:"Allocation progress"}),(0,s.jsxs)("span",{style:{color:P?"var(--modal-success)":"var(--modal-text-muted)",fontSize:"0.875rem",fontWeight:500},children:[m,et(M)," / ",m,et(n)]})]}),(0,s.jsx)("div",{className:N().progressTrack,style:{marginTop:"0.5rem"},children:(0,s.jsx)("div",{className:"".concat(N().progressFill," ").concat(P?N().progressFillComplete:N().progressFillIncrease),style:{width:"".concat(n>0?Math.min(M/n*100,100):0,"%")}})})]}),(0,s.jsxs)("div",{className:N().categoryList,style:{marginTop:"0.75rem"},children:[j.filter(e=>!e.isNew).map(e=>(0,s.jsxs)("div",{className:N().categoryRow,children:[(0,s.jsx)("div",{className:N().categoryRowHeader,children:(0,s.jsxs)("div",{className:N().categoryRowInfo,children:[(0,s.jsx)("span",{className:N().categoryRowName,children:e.name}),(0,s.jsxs)("span",{className:N().categoryRowMeta,children:["Current: ",m,et(e.currentAllocated)]})]})}),(0,s.jsxs)("div",{className:N().categoryRowControls,children:[(0,s.jsx)("input",{type:"range",min:"0",max:n,value:e.addAmount,onChange:a=>L(e.categoryId,parseFloat(a.target.value)),className:N().categorySlider}),(0,s.jsxs)("div",{className:N().categoryInputWrapper,children:[(0,s.jsxs)("span",{className:N().categoryInputPrefix,children:["+",m]}),(0,s.jsx)("input",{type:"number",min:"0",value:e.addAmount||"",onChange:a=>L(e.categoryId,parseFloat(a.target.value)||0),className:N().categoryInput})]})]}),(0,s.jsxs)("div",{className:N().quickAmounts,children:[[25,50,100].map(a=>(0,s.jsxs)("button",{type:"button",onClick:()=>L(e.categoryId,e.addAmount+a),className:"".concat(N().quickAmountBtn," ").concat(N().quickAmountBtnNormal),children:["+",m,a]},a)),F>0&&Math.round(F)>0&&(0,s.jsxs)("button",{type:"button",onClick:()=>L(e.categoryId,e.addAmount+Math.round(F)),className:"".concat(N().quickAmountBtn," ").concat(N().quickAmountBtnExact),children:["+",m,Math.round(F)," (exact)"]})]})]},e.categoryId)),j.filter(e=>e.isNew).map(e=>(0,s.jsxs)("div",{className:N().categoryRow,style:{backgroundColor:"var(--success-light)"},children:[(0,s.jsxs)("div",{className:N().categoryRowHeader,children:[(0,s.jsx)("div",{className:N().categoryRowInfo,children:(0,s.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.color&&(0,s.jsx)("div",{style:{width:"12px",height:"12px",borderRadius:"50%",backgroundColor:e.color}}),(0,s.jsx)("span",{className:N().categoryRowName,children:e.name}),(0,s.jsx)("span",{style:{fontSize:"0.7rem",padding:"2px 6px",borderRadius:"4px",backgroundColor:"var(--success-light)",color:"var(--modal-success)"},children:"New"})]})}),(0,s.jsx)("button",{type:"button",onClick:()=>{var a;return a=e.categoryId,void f(e=>e.filter(e=>e.categoryId!==a))},style:{padding:"4px",color:"var(--modal-text-muted)"},title:"Remove",children:(0,s.jsx)(h.A,{className:"h-4 w-4"})})]}),(0,s.jsx)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginTop:"8px"},children:(0,s.jsxs)("span",{style:{color:"var(--modal-success)",fontWeight:500},children:["+",m,et(e.addAmount)]})})]},e.categoryId)),_?(0,s.jsxs)("div",{className:N().categoryRow,style:{backgroundColor:"var(--modal-bg-secondary)"},children:[(0,s.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"12px"},children:[(0,s.jsx)("span",{style:{fontSize:"0.875rem",fontWeight:500,color:"var(--modal-secondary)"},children:"Create New Category"}),(0,s.jsx)("button",{type:"button",onClick:()=>{A(!1),I(""),D(""),y(null)},style:{color:"var(--modal-text-muted)"},children:(0,s.jsx)(h.A,{className:"h-5 w-5"})})]}),(0,s.jsxs)("div",{style:{display:"grid",gridTemplateColumns:"1fr 120px",gap:"12px"},children:[(0,s.jsx)("input",{type:"text",value:S,onChange:e=>I(e.target.value),placeholder:"Category name",className:N().input,style:{padding:"8px 12px",fontSize:"0.875rem"},autoFocus:!0}),(0,s.jsxs)("div",{style:{position:"relative"},children:[(0,s.jsx)("span",{style:{position:"absolute",left:"10px",top:"50%",transform:"translateY(-50%)",color:"var(--modal-text-muted)"},children:m}),(0,s.jsx)("input",{type:"number",min:"0",max:F,value:R,onChange:e=>D(e.target.value),placeholder:"0",className:N().input,style:{padding:"8px 12px 8px 24px",fontSize:"0.875rem",textAlign:"right"}})]})]}),(0,s.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginTop:"12px"},children:[(0,s.jsxs)("span",{style:{fontSize:"0.75rem",color:"var(--modal-text-muted)"},children:["Max: ",m,et(F)]}),(0,s.jsx)("button",{type:"button",onClick:()=>
1{if(!S.trim())return void y("Please enter a category name");let e=parseFloat(R)||0;if(e<=0)return void y("Please enter an amount greater than 0");if(e>F+.01)return void y("Amount cannot exceed ".concat(m).concat(et(F)," remaining"));if(j.some(e=>e.name.toLowerCase()===S.trim().toLowerCase()))return void y("A category with this name already exists");let a=j.filter(e=>e.color).map(e=>e.color),t=es.find(e=>!a.includes(e))||es[0],s={categoryId:"new_".concat(Date.now()),name:S.trim(),currentAllocated:0,addAmount:e,isNew:!0,color:t};f(e=>[...e,s]),I(""),D(""),A(!1),y(null)},className:N().primaryButton,style:{padding:"6px 12px",fontSize:"0.875rem"},children:"Add Category"})]})]}):(0,s.jsxs)("button",{type:"button",onClick:()=>A(!0),disabled:F<1,className:N().addCategoryButton,style:{opacity:F<1?.5:1,cursor:F<1?"not-allowed":"pointer"},children:[(0,s.jsx)(T.A,{className:"h-5 w-5"}),(0,s.jsx)("span",{children:"Add New Category"})]})]})]})]}),(0,s.jsx)("div",{className:N().footer,children:z?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("button",{onClick:()=>{C("intro"),f(e=>e.filter(e=>!e.isNew).map(e=>({...e,addAmount:0}))),A(!1),y(null)},disabled:u,className:N().backButton,children:[(0,s.jsx)(B.A,{className:"h-4 w-4"}),"Back"]}),(0,s.jsx)("button",{onClick:E,disabled:u||!P,className:N().warningButton,children:u?(0,s.jsxs)("span",{className:"flex items-center gap-2",children:[(0,s.jsxs)("svg",{className:N().spinner,width:"14",height:"14",viewBox:"0 0 24 24",children:[(0,s.jsx)("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4",fill:"none"}),(0,s.jsx)("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]}),"Pausing..."]}):"Pause Plan"})]}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("button",{onClick:W,disabled:u,className:N().secondaryButton,children:c?"Close":"Not Now"}),!c&&(0,s.jsx)("button",{onClick:()=>{C("allocate")},disabled:u,className:N().primaryButton,children:"Got It"})]})})]})})}var er=t(73293);let en=e=>Math.round(e).toLocaleString();function eo(e){let{isOpen:a,onClose:t,planId:r,neededAmount:n,minimumRequired:o,planTotal:c,flexibleCategories:i,totalUnspent:d,canResumeImmediately:m,onResume:u}=e,{symbol:x}=(0,b.H)(),[g,y]=(0,l.useState)(!1),[j,f]=(0,l.useState)(null),[w,C]=(0,l.useState)([]);(0,l.useEffect)(()=>{a&&(C(i.filter(e=>e.unspent>0).map(e=>({categoryId:e.id,name:e.name,currentAllocated:e.currentAllocated,unspent:e.unspent,reduceAmount:0}))),f(null))},[a,i]);let _=(0,l.useMemo)(()=>w.reduce((e,a)=>e+a.reduceAmount,0),[w]),A=_>0,k=(e,a)=>{C(t=>t.map(t=>{if(t.categoryId!==e)return t;let s=Math.max(0,Math.min(a,t.unspent));return{...t,reduceAmount:s}}))},S=async()=>{if(_<=0)return void f("Select funds from at least one category");y(!0),f(null);try{let e=w.filter(e=>e.reduceAmount>0).map(e=>({category_id:e.categoryId,amount:e.reduceAmount}));await u({targetAmount:Math.round(_+o),customReductions:e}),t()}catch(a){let{message:e}=(0,v.P)(a);f(e)}finally{y(!1)}},I=()=>{g||t()};return a?(0,s.jsx)("div",{className:N().overlay,onClick:e=>{e.target===e.currentTarget&&I()},children:(0,s.jsxs)("div",{className:"".concat(N().modal," ").concat(N().modalLarge),role:"dialog","aria-modal":"true",children:[(0,s.jsxs)("div",{className:N().header,children:[(0,s.jsxs)("div",{className:N().headerLeft,children:[(0,s.jsx)(er.A,{className:"h-5 w-5",style:{color:"var(--modal-success)"}}),(0,s.jsx)("h2",{className:N().headerTitle,children:"Resume Debt Elimination Plan"})]}),(0,s.jsx)("button",{onClick:I,disabled:g,className:N().closeButton,children:(0,s.jsx)(h.A,{className:"h-5 w-5"})})]}),(0,s.jsxs)("div",{className:N().content,style:{paddingBottom:0},children:[j&&(0,s.jsxs)("div",{className:N().errorBox,children:[(0,s.jsx)(p.A,{className:"h-5 w-5 ".concat(N().errorIcon)}),(0,s.jsx)("p",{className:N().errorText,children:j})]}),(0,s.jsxs)("div",{className:N().infoBox,children:[(0,s.jsx)(ee.A,{className:"h-5 w-5 flex-shrink-0",style:{color:"var(--modal-primary)"}}),(0,s.jsxs)("div",{style:{flex:1},children:[(0,s.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[(0,s.jsxs)("span",{style:{color:"var(--modal-primary)",fontWeight:500},children:["Resuming with: ",x,en(_),"/month"]}),(0,s.jsxs)("span",{className:N().budgetContext,children:["(was ",x,en(c),"/month)"]})]}),(0,s.jsx)("p",{className:N().infoText,children:0===_?"You don't have to match the original amount - free up whatever you're comfortable with.":_<c-o?"Plan will recalculate with your new amount":"Restoring full debt attack plan"})]})]})]}),(0,s.jsx)("div",{className:N().contentRebalancing,style:{paddingTop:"0.75rem"},children:w.length>0?(0,s.jsx)("div",{className:N().categoryList,children:w.map(e=>(0,s.jsxs)("div",{className:N().categoryRow,children:[(0,s.jsx)("div",{className:N().categoryRowHeader,children:(0,s.jsxs)("div",{className:N().categoryRowInfo,children:[(0,s.jsx)("span",{className:N().categoryRowName,children:e.name}),(0,s.jsxs)("span",{className:N().categoryRowMeta,children:[x,en(e.currentAllocated)," allocated \xb7 ",x,en(e.unspent)," unspent"]})]})}),(0,s.jsxs)("div",{className:N().categoryRowControls,children:[(0,s.jsx)("input",{type:"range",min:"0",max:e.unspent,value:e.reduceAmount,onChange:a=>k(e.categoryId,parseFloat(a.target.value)),className:N().categorySlider}),(0,s.jsxs)("div",{className:N().categoryInputWrapper,children:[(0,s.jsxs)("span",{className:N().categoryInputPrefix,children:["-",x]}),(0,s.jsx)("input",{type:"number",min:"0",max:e.unspent,value:e.reduceAmount||"",onChange:a=>k(e.categoryId,parseFloat(a.target.value)||0),className:N().categoryInput})]})]}),(0,s.jsx)("div",{className:N().quickAmounts,children:[25,50,100].map(a=>(0,s.jsxs)("button",{type:"button",onClick:()=>{var t;return t=e.categoryId,void C(e=>e.map(e=>{if(e.categoryId!==t)return e;let s=Math.min(e.reduceAmount+a,e.unspent);return{...e,reduceAmount:s}}
1))},disabled:e.reduceAmount>=e.unspent,className:"".concat(N().quickAmountBtn," ").concat(N().quickAmountBtnNormal),style:e.reduceAmount>=e.unspent?{opacity:.5,cursor:"not-allowed"}:{},children:["+",x,a]},a))})]},e.categoryId))}):(0,s.jsx)("div",{className:N().warningBox,children:(0,s.jsx)("p",{className:N().warningText,children:"No categories have unspent funds available. The resume will be scheduled for next month when your budget resets."})})}),(0,s.jsxs)("div",{className:N().footer,children:[(0,s.jsx)("button",{onClick:I,disabled:g,className:N().secondaryButton,children:"Cancel"}),(0,s.jsx)("button",{onClick:S,disabled:g||!A,className:N().primaryButton,children:g?(0,s.jsxs)("span",{className:"flex items-center gap-2",children:[(0,s.jsxs)("svg",{className:N().spinner,width:"14",height:"14",viewBox:"0 0 24 24",children:[(0,s.jsx)("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4",fill:"none"}),(0,s.jsx)("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]}),"Resuming..."]}):"Resume Plan"})]})]})}):null}var ec=t(5763),ei=t(54532),ed=t(61284),em=t(37286),eu=t(48037),ex=t(86336);let eh=e=>Math.round(e).toLocaleString(),ep={avalanche:{label:"Avalanche",description:"Pay off highest interest rate first",icon:ec.A,benefit:"Usually the least interest paid overall"},snowball:{label:"Snowball",description:"Pay off smallest balance first",icon:ei.A,benefit:"Quick wins to build momentum and motivation"}};function eg(e){let{isOpen:a,onClose:t,budgetId:r,debts:n,flexibleCategories:o,totalUnspent:c,totalMinimums:i,onCreate:d}=e,{symbol:m}=(0,b.H)(),[u,x]=(0,l.useState)(1),[g,y]=(0,l.useState)(!1),[j,f]=(0,l.useState)(null),[N,w]=(0,l.useState)("avalanche"),[C,_]=(0,l.useState)([]),A=(0,l.useMemo)(()=>n.reduce((e,a)=>e+a.balance,0),[n]),k=(0,l.useMemo)(()=>n.reduce((e,a)=>e+a.minimumPayment,0),[n]),S=(0,l.useMemo)(()=>n.length>0?Math.max(...n.map(e=>e.apr)):0,[n]),I=(0,l.useMemo)(()=>C.reduce((e,a)=>e+a.reduceAmount,0),[C]),R=k+I;(0,l.useEffect)(()=>{a&&(x(1),w("avalanche"),f(null),_(o.filter(e=>e.unspent>0).map(e=>({categoryId:e.id,name:e.name,currentAllocated:e.currentAllocated,unspent:e.unspent,reduceAmount:0}))))},[a,o]);let B=(e,a)=>{_(t=>t.map(t=>{if(t.categoryId!==e)return t;let s=Math.max(0,Math.min(a,t.unspent));return{...t,reduceAmount:s}}))},T=async()=>{if(I<=0)return void f("Free up funds from at least one category");y(!0),f(null);try{let e=C.filter(e=>e.reduceAmount>0).map(e=>({categoryId:e.categoryId,newAllocated:Math.floor(e.currentAllocated-e.reduceAmount)}));await d({strategy:N,budgetChanges:e}),t()}catch(a){let{message:e}=(0,v.P)(a);f(e)}finally{y(!1)}},M=()=>{g||t()},F={backgroundColor:"rgba(0, 0, 0, 0.7)",backdropFilter:"blur(8px)"},P={backgroundColor:"var(--modal-bg)",border:"1px solid var(--border-subtle)",borderRadius:"20px",boxShadow:"0 25px 50px -12px rgba(0, 0, 0, 0.25)"},L={color:"var(--foreground)"},E={color:"var(--muted-foreground)"},W={color:"var(--muted-foreground)"},z={color:"var(--primary)"},H={color:"var(--muted-foreground)"},V={color:"var(--primary)"},U={color:"var(--foreground)"},q={color:"var(--text-secondary)"},O={color:"var(--muted-foreground)"},Y={color:"var(--primary)"},G={color:"var(--primary)"},J={color:"var(--primary)"},Q={backgroundColor:"var(--modal-bg-subtle)",border:"1px solid var(--border-subtle)",borderRadius:"12px"},K={color:"var(--foreground)"},Z={color:"var(--muted-foreground)"},X={backgroundColor:"var(--modal-bg-elevated)",accentColor:"var(--primary)"},$={backgroundColor:"var(--modal-bg-elevated)",border:"1px solid var(--modal-bg-elevated)",borderRadius:"6px",color:"var(--foreground)"},ea={backgroundColor:"var(--callout-purple)",border:"1px solid var(--callout-purple-border)",borderRadius:"6px",color:"var(--primary)"},et={backgroundColor:"var(--modal-bg-subtle)",borderRadius:"12px"},es={color:"var(--muted-foreground)"},el={color:"var(--text-muted)"},er={backgroundColor:"var(--callout-purple)",color:"var(--primary)"},en={backgroundColor:"var(--modal-bg-elevated)",border:"1px solid var(--modal-bg-elevated)",borderRadius:"12px",color:"var(--text-secondary)"},eo={background:"var(--brand-gradient)",border:"none",borderRadius:"12px",color:"var(--primary-foreground)",fontWeight:500},ec={color:"var(--text-muted)"};return a?0===n.length?(0,s.jsx)("div",{className:"fixed inset-0 flex items-center justify-center z-50 p-4",style:F,onClick:e=>{e.target===e.currentTarget&&M()},children:(0,s.jsxs)("div",{className:"max-w-md w-full p-6",style:P,children:[(0,s.jsxs)("div",{className:"flex items-center justify-between mb-4",children:[(0,s.jsx)("h2",{className:"text-xl font-semibold",style:L,children:"Create Debt Plan"}),(0,s.jsx)("button",{onClick:M,style:W,className:"hover:opacity-80",children:(0,s.jsx)(h.A,{className:"h-6 w-6"})})]}),(0,s.jsxs)("div",{className:"text-center py-6",children:[(0,s.jsx)(p.A,{className:"h-12 w-12 mx-auto mb-3",style:G}),(0,s.jsx)("p",{className:"mb-2",style:q,children:"No debt accounts found"}),(0,s.jsx)("p",{className:"text-sm",style:E,children:"Add your debts in the Debt Accounts section first, then create a plan to pay them off faster."})]}),(0,s.jsx)("button",{onClick:M,className:"w-full mt-4 px-4 py-3 font-medium transition-all hover:opacity-80",style:en,children:"Got it"})]})}):(0,s.jsx)("div",{className:"fixed inset-0 flex items-center justify-center z-50 p-4 overflow-y-auto",style:F,onClick:e=>{e.target===e.currentTarget&&M()},children:(0,s.jsxs)("div",{className:"max-w-2xl w-full my-8 flex flex-col max-h-[90vh]",style:P,children:[(0,s.jsxs)("div",{className:"px-6 py-4 flex items-center justify-between flex-shrink-0",style:{borderBottom:"1px solid var(--border-subtle)"},children:[(0,s.jsxs)("div",{className:"flex items-center gap-3",children:[(0,s.jsx)("div",{className:"p-2 rounded-lg",style:{backgroundColor:"var(--callout-purple)",color:"var(--primary)"},children:(0,s.jsx)(ed.A,{className:"h-6 w-6"})}),(0,s.jsxs)("div",{children:[(0,s.jsx)("h2",{className:"text-xl font-semibold",style:L,children:"Create Debt Elimination Plan"}),(0,s.jsxs)("p",{className:"text-sm",style:E,children:["Step ",u," of 3"]})]})]}),(0,s.jsx)("button",{onClick:M,disabled:g,className:"transition-colors disabled:opacity-50 hover:opacity-80",style:W,children:(0,s.jsx)(h.A,{className:"h-6 w-6"})})]}),(0,s.jsx)("div",{className:"px-6 py-2 flex-shrink-0",style:{borderBottom:"1px solid var(--border-subtle)"},children:(0,s.jsx)("div",{className:"flex gap-2",children:[1,2,3].map(e=>(0,s.jsx)("div",{className:"flex-1 h-1.5 transition-colors",style:{background:e<=u?"var(--brand-gradient)":"var(--modal-bg-elevated)",borderRadius:"9999px"}},e))})}),j&&(0,s.jsx)("div",{className:"px-6 pt-4 flex-shrink-0",children:(0,s.jsxs)("div",{className:"p-3 flex items-start gap-2",style:{backgroundColor:"var(--modal-bg-subtle)",border:"1px solid var(--modal-bg-elevated)",borderRadius:"12px"},children:[(0,s.jsx)(p.A,{className:"h-5 w-5 flex-shrink-0 mt-0.5",style:z}),(0,s.jsx)("p",{className:"text-sm",style:z,children:j})]})}),(0,s.jsxs)("div",{className:"flex-1 overflow-y-auto px-6 py-4",children:[1===u&&(0,s.jsxs)("div",{className:"space-y-4",children:[(0,s.jsxs)("div",{className:"p-4",style:{backgroundColor:"var(--modal-bg-subtle)",border:"1px solid var(--border-subtle)",borderRadius:"16px"},children:[(0,s.jsx)("h3",{className:"text-sm font-medium mb-3",style:H,children:"Your Debt Overview"}),(0,s.jsxs)("div",{className:"grid grid-cols-3 gap-4",children:[(0,s.jsxs)("div",{children:[(0,s.jsxs)("p",{className:"text-2xl font-bold",style:V,children:[m,eh(A)]}),(0,s.jsx)("p",{className:"text-xs",style:H,children:"Total Debt"})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:"text-2xl font-bold",style:U,children:n.length}),(0,s.jsx)("p",{className:"text-xs",style:H,children:"Accounts"})]}),(0,s.jsxs)("div",{children:[(0,s.jsxs)("p",{className:"text-2xl font-bold",style:V,children:[S.toFixed(2),"%"]}
1),(0,s.jsx)("p",{className:"text-xs",style:H,children:"Highest APR"})]})]})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("h3",{className:"text-sm font-medium mb-3",style:q,children:"Choose Your Strategy"}),(0,s.jsx)("div",{className:"space-y-3",children:Object.keys(ep).map(e=>{let a,t,l=ep[e],r=l.icon,n=N===e;return(0,s.jsx)("button",{type:"button",onClick:()=>w(e),className:"w-full text-left p-4 transition-all",style:{backgroundColor:(a=n)?"var(--callout-purple)":"var(--modal-bg-subtle)",border:"1px solid ".concat(a?"var(--callout-purple-border)":"var(--border-subtle)"),borderRadius:"16px"},children:(0,s.jsxs)("div",{className:"flex items-start gap-3",children:[(0,s.jsx)("div",{className:"p-2 rounded-lg",style:{backgroundColor:(t=n)?"var(--callout-purple-border)":"var(--modal-bg-elevated)",color:t?"var(--primary)":"var(--muted-foreground)"},children:(0,s.jsx)(r,{className:"h-5 w-5"})}),(0,s.jsxs)("div",{className:"flex-1",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)("span",{className:"font-medium",style:{color:n?"var(--foreground)":"var(--text-secondary)"},children:l.label}),n&&(0,s.jsx)(D.A,{className:"h-5 w-5",style:Y})]}),(0,s.jsx)("p",{className:"text-sm mt-0.5",style:O,children:l.description}),(0,s.jsx)("p",{className:"text-xs mt-1",style:{color:n?"var(--primary)":"var(--text-muted)"},children:l.benefit})]})]})},e)})})]}),(0,s.jsx)("div",{className:"p-3",style:{backgroundColor:"var(--callout-purple)",border:"1px solid var(--callout-purple-border)",borderRadius:"12px"},children:(0,s.jsxs)("div",{className:"flex items-start gap-2",children:[(0,s.jsx)(em.A,{className:"h-5 w-5 flex-shrink-0",style:G}),(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:"text-sm font-medium",style:{color:"var(--primary)"},children:"Choosing a method"}),(0,s.jsx)("p",{className:"text-xs mt-1",style:{color:"var(--muted-foreground)"},children:"Both methods pay every minimum first, then put any extra money toward one debt at a time. Neither method is right for everyone. Pick the one that fits how you work."})]})]})})]}),2===u&&(0,s.jsxs)("div",{className:"space-y-4",children:[(0,s.jsx)("div",{className:"p-4",style:{backgroundColor:"var(--callout-purple)",border:"1px solid var(--callout-purple-border)",borderRadius:"12px"},children:(0,s.jsxs)("div",{className:"flex items-start gap-3",children:[(0,s.jsx)(ee.A,{className:"h-5 w-5 flex-shrink-0 mt-0.5",style:{color:"var(--primary)"}}),(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:"font-medium",style:{color:"var(--primary)"},children:"Free Up Funds for Debt Attack"}),(0,s.jsxs)("p",{className:"text-sm mt-1",style:{color:"var(--text-secondary)"},children:["Your minimum payments total ",(0,s.jsxs)("span",{className:"font-bold",children:[m,eh(k),"/month"]}),". Free up additional funds from your budget to pay down debt faster."]})]})]})}),(0,s.jsx)("div",{className:"sticky top-0 py-3 -mx-6 px-6 z-10",style:{backgroundColor:"var(--modal-bg)",borderBottom:"1px solid var(--border-subtle)"},children:(0,s.jsxs)("div",{className:"flex items-center justify-between",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("span",{className:"text-sm",style:{color:"var(--muted-foreground)"},children:"Extra payment:"}),(0,s.jsxs)("span",{className:"text-xl font-bold ml-2",style:J,children:["+",m,eh(I),"/month"]})]}),(0,s.jsxs)("div",{className:"text-right",children:[(0,s.jsx)("span",{className:"text-sm",style:{color:"var(--muted-foreground)"},children:"Total plan:"}),(0,s.jsxs)("span",{className:"text-lg font-bold ml-2",style:{color:"var(--foreground)"},children:[m,eh(R),"/month"]})]})]})}),C.length>0?(0,s.jsx)("div",{className:"space-y-3",children:C.map(e=>(0,s.jsxs)("div",{className:"p-3",style:Q,children:[(0,s.jsx)("div",{className:"flex items-center justify-between mb-2",children:(0,s.jsxs)("div",{children:[(0,s.jsx)("span",{className:"font-medium",style:K,children:e.name}),(0,s.jsxs)("p",{className:"text-xs",style:Z,children:[m,eh(e.currentAllocated)," allocated \xb7 ",m,eh(e.unspent)," unspent"]})]})}),(0,s.jsxs)("div",{className:"flex items-center gap-3",children:[(0,s.jsx)("input",{type:"range",min:"0",max:e.unspent,value:e.reduceAmount,onChange:a=>B(e.categoryId,parseFloat(a.target.value)),className:"flex-1 h-2 rounded-lg appearance-none cursor-pointer",style:X}),(0,s.jsxs)("div",{className:"flex items-center gap-1 w-24",children:[(0,s.jsx)("span",{style:ec,children:m}),(0,s.jsx)("input",{type:"number",min:"0",max:e.unspent,value:e.reduceAmount||"",onChange:a=>B(e.categoryId,parseFloat(a.target.value)||0),className:"w-16 px-2 py-1 text-sm text-right outline-none",style:$})]})]}),(0,s.jsx)("div",{className:"flex gap-1 mt-2 flex-wrap",children:[25,50,100].map(a=>(0,s.jsxs)("button",{type:"button",onClick:()=>{var t;return t=e.categoryId,void _(e=>e.map(e=>{if(e.categoryId!==t)return e;let s=Math.min(e.reduceAmount+a,e.unspent);return{...e,reduceAmount:s}}
1))},disabled:e.reduceAmount>=e.unspent,className:"px-2 py-0.5 text-xs transition-opacity disabled:opacity-50 disabled:cursor-not-allowed hover:opacity-80",style:ea,children:["+",m,a]},a))})]},e.categoryId))}):(0,s.jsxs)("div",{className:"p-4 text-center",style:{backgroundColor:"var(--modal-bg-subtle)",border:"1px solid var(--border-subtle)",borderRadius:"12px"},children:[(0,s.jsx)("p",{style:{color:"var(--muted-foreground)"},children:"No categories have unspent funds available."}),(0,s.jsx)("p",{className:"text-sm mt-1",style:E,children:"You can still create a plan with minimum payments only, or adjust your budget first."})]})]}),3===u&&(0,s.jsxs)("div",{className:"space-y-4",children:[(0,s.jsxs)("div",{className:"p-4",style:{background:"var(--callout-purple)",border:"1px solid var(--callout-purple-border)",borderRadius:"16px"},children:[(0,s.jsxs)("h3",{className:"font-medium mb-3 flex items-center gap-2",style:{color:"var(--primary)"},children:[(0,s.jsx)(D.A,{className:"h-5 w-5"}),"Your Debt Elimination Plan"]}),(0,s.jsxs)("div",{className:"grid grid-cols-2 gap-4 mb-4",children:[(0,s.jsxs)("div",{className:"p-3",style:et,children:[(0,s.jsx)("p",{className:"text-xs",style:es,children:"Strategy"}),(0,s.jsx)("p",{className:"text-lg font-bold",style:U,children:ep[N].label})]}),(0,s.jsxs)("div",{className:"p-3",style:et,children:[(0,s.jsx)("p",{className:"text-xs",style:es,children:"Total Monthly"}),(0,s.jsxs)("p",{className:"text-lg font-bold",style:J,children:[m,eh(R)]})]})]}),(0,s.jsxs)("div",{className:"space-y-2 text-sm",children:[(0,s.jsxs)("div",{className:"flex justify-between",children:[(0,s.jsx)("span",{style:E,children:"Minimum Payments"}),(0,s.jsxs)("span",{style:U,children:[m,eh(k)]})]}),(0,s.jsxs)("div",{className:"flex justify-between",children:[(0,s.jsx)("span",{style:J,children:"+ Extra Payment"}),(0,s.jsxs)("span",{style:J,children:[m,eh(I)]})]}),(0,s.jsxs)("div",{className:"pt-2 flex justify-between font-medium",style:{borderTop:"1px solid var(--border-subtle)"},children:[(0,s.jsx)("span",{style:U,children:"Total Debt Attack"}),(0,s.jsxs)("span",{style:U,children:[m,eh(R),"/mo"]})]})]})]}),(0,s.jsxs)("div",{className:"p-4",style:{backgroundColor:"var(--modal-bg-subtle)",border:"1px solid var(--border-subtle)",borderRadius:"16px"},children:[(0,s.jsxs)("h3",{className:"text-sm font-medium mb-3",style:q,children:["Payment Order (",ep[N].label,")"]}),(0,s.jsx)("div",{className:"space-y-2",children:[...n].sort((e,a)=>"avalanche"===N?a.apr-e.apr:"snowball"===N?e.balance-a.balance:a.apr-e.apr).map((e,a)=>{let t,l;return(0,s.jsxs)("div",{className:"flex items-center justify-between p-2",style:{backgroundColor:(t=0===a)?"var(--callout-purple)":"var(--modal-bg-subtle)",border:t?"1px solid var(--callout-purple-border)":"none",borderRadius:"12px"},children:[(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)("span",{className:"w-6 h-6 rounded-full flex items-center justify-center text-xs font-bold",style:{backgroundColor:(l=0===a)?"var(--primary)":"var(--modal-bg-elevated)",color:l?"var(--primary-foreground)":"var(--muted-foreground)"},children:a+1}),(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:"font-medium",style:{color:0===a?"var(--foreground)":"var(--text-secondary)"},children:e.name}),(0,s.jsxs)("p",{className:"text-xs",style:el,children:[e.apr.toFixed(1),"% APR \xb7 ",m,eh(e.balance)]})]})]}),0===a&&(0,s.jsx)("span",{className:"text-xs px-2 py-1 rounded-full",style:er,children:"Priority"})]},e.id)})})]}),(0,s.jsxs)("div",{className:"p-3",style:{backgroundColor:"var(--callout-purple)",border:"1px solid var(--callout-purple-border)",borderRadius:"12px"},children:[(0,s.jsx)("p",{className:"text-sm font-medium mb-1",style:{color:"var(--primary)"},children:"What happens next:"}),(0,s.jsxs)("ul",{className:"text-xs space-y-1 list-disc list-inside",style:{color:"var(--muted-foreground)"},children:[(0,s.jsxs)("li",{children:["Your budget categories will be reduced by ",m,eh(I)]}),(0,s.jsxs)("li",{children:["Extra funds go to your priority debt (",n.length>0?n[0].name:"first debt",")"]}),(0,s.jsx)("li",{children:"When one debt is paid off, funds automatically cascade to the next"})]})]})]})]}),(0,s.jsxs)("div",{className:"px-6 py-4 flex gap-3 flex-shrink-0",style:{borderTop:"1px solid var(--border-subtle)"},children:[u>1&&(0,s.jsxs)("button",{onClick:()=>{f(null),2===u&&x(1),3===u&&x(2)},disabled:g,className:"flex items-center gap-1 px-4 py-3 font-medium transition-all disabled:opacity-50 hover:opacity-80",style:{backgroundColor:"var(--modal-bg-elevated)",border:"1px solid var(--modal-bg-elevated)",borderRadius:"12px",color:"var(--text-secondary)"},children:[(0,s.jsx)(eu.A,{className:"h-4 w-4"}),"Back"]}),(0,s.jsx)("button",{onClick:M,disabled:g,className:"px-4 py-3 font-medium transition-all disabled:opacity-50 hover:opacity-80 ".concat(1===u?"flex-1":""),style:en,children:"Cancel"}),u<3?(0,s.jsxs)("button",{onClick:()=>
1{if(f(null),1===u)x(2);else if(2===u){if(I<=0)return void f("Free up funds from at least one category to accelerate debt payoff");x(3)}},disabled:g,className:"flex-1 px-4 py-3 font-medium flex items-center justify-center gap-2 transition-all hover:brightness-110",style:eo,children:["Continue",(0,s.jsx)(ex.A,{className:"h-4 w-4"})]}):(0,s.jsx)("button",{onClick:T,disabled:g||I<=0,className:"flex-1 px-4 py-3 font-medium transition-all disabled:opacity-50 disabled:cursor-not-allowed hover:brightness-110",style:eo,children:g?(0,s.jsxs)("span",{className:"flex items-center justify-center gap-2",children:[(0,s.jsxs)("svg",{className:"animate-spin h-4 w-4",viewBox:"0 0 24 24",children:[(0,s.jsx)("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4",fill:"none"}),(0,s.jsx)("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]}),"Creating Plan..."]}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(ed.A,{className:"h-5 w-5 inline mr-1"}),"Create Plan"]})})]})]})}):null}let ey=e=>Math.round(e).toLocaleString(),ev=["#3B82F6","#10B981","#F59E0B","#EF4444","#8B5CF6","#EC4899","#06B6D4","#84CC16","#F97316","#6366F1"];function eb(e){let{isOpen:a,onClose:t,freedFunds:r,message:n,eligibleCategories:o,budgetId:c,onRebalance:i}=e,{symbol:d}=(0,b.H)(),[m,u]=(0,l.useState)(!1),[x,g]=(0,l.useState)(null),[y,j]=(0,l.useState)([]),[f,w]=(0,l.useState)(!1),[C,_]=(0,l.useState)(""),[A,k]=(0,l.useState)("");(0,l.useEffect)(()=>{a&&(j(o.filter(e=>!e.isDebt).map(e=>({categoryId:e.id,name:e.name,currentAllocated:e.currentAllocated,addAmount:0,isNew:!1}))),g(null),w(!1),_(""),k(""))},[a,o]);let S=(0,l.useMemo)(()=>y.reduce((e,a)=>e+a.addAmount,0),[y]),I=r-S,R=I<=.99,B=(e,a)=>{j(t=>t.map(t=>t.categoryId!==e?t:{...t,addAmount:Math.max(0,a)}))},D=async()=>{if(!R&&r>0)return void g("You still need to allocate ".concat(d).concat(ey(I)));u(!0),g(null);try{let e=y.filter(e=>e.addAmount>0).map(e=>({categoryId:e.categoryId,newAllocated:Math.round(e.currentAllocated+e.addAmount),isNew:e.isNew,name:e.isNew?e.name:void 0,color:e.isNew?e.color:void 0}));await i({rebalanceChanges:e}),t()}catch(a){let{message:e}=(0,v.P)(a);g(e)}finally{u(!1)}},M=()=>{m||t()};return a?(0,s.jsx)("div",{className:N().overlay,onClick:e=>{e.target===e.currentTarget&&M()},children:(0,s.jsxs)("div",{className:"".concat(N().modal," ").concat(N().modalLarge),role:"dialog","aria-modal":"true",children:[(0,s.jsxs)("div",{className:N().header,children:[(0,s.jsxs)("div",{className:N().headerLeft,children:[(0,s.jsx)(ee.A,{className:"h-5 w-5 ".concat(N().headerIconSuccess)}),(0,s.jsx)("h2",{className:N().headerTitle,children:"Allocate Freed Funds"})]}),(0,s.jsx)("button",{onClick:M,disabled:m,className:N().closeButton,children:(0,s.jsx)(h.A,{className:"h-5 w-5"})})]}),(0,s.jsxs)("div",{className:N().contentRebalancing,children:[x&&(0,s.jsxs)("div",{className:N().errorBox,children:[(0,s.jsx)(p.A,{className:"h-5 w-5 ".concat(N().errorIcon)}),(0,s.jsx)("p",{className:N().errorText,children:x})]}),(0,s.jsxs)("div",{className:N().infoBox,children:[(0,s.jsx)(ee.A,{className:"h-5 w-5 flex-shrink-0",style:{color:"var(--modal-success)"}}),(0,s.jsxs)("div",{children:[(0,s.jsxs)("span",{style:{color:"var(--modal-success)",fontWeight:500},children:[d,ey(r)," freed"]}),(0,s.jsx)("p",{className:N().infoText,children:n})]})]}),(0,s.jsxs)("div",{className:N().infoBox,style:{marginTop:"0.75rem"},children:[(0,s.jsx)(G.A,{className:"h-5 w-5 flex-shrink-0",style:{color:"var(--modal-accent)"}}),(0,s.jsx)("p",{className:N().infoText,children:"Reducing the minimum payment freed up funds in your budget. Distribute these funds across your categories to keep your budget balanced."})]}),(0,s.jsxs)("div",{className:N().infoBox,style:{marginTop:"0.75rem"},children:[(0,s.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",width:"100%"},children:[(0,s.jsx)("span",{style:{color:"var(--modal-primary)",fontWeight:500},children:"Allocation progress"}),(0,s.jsxs)("span",{style:{color:R?"var(--modal-success)":"var(--modal-text-muted)",fontSize:"0.875rem",fontWeight:500},children:[d,ey(S)," / ",d,ey(r)]})]}),(0,s.jsx)("div",{className:N().progressTrack,style:{marginTop:"0.5rem"},children:(0,s.jsx)("div",{className:"".concat(N().progressFill," ").concat(R?N().progressFillC
1omplete:N().progressFillIncrease),style:{width:"".concat(r>0?Math.min(S/r*100,100):0,"%")}})})]}),(0,s.jsxs)("div",{className:N().categoryList,style:{marginTop:"0.75rem"},children:[y.filter(e=>!e.isNew).map(e=>(0,s.jsxs)("div",{className:N().categoryRow,children:[(0,s.jsx)("div",{className:N().categoryRowHeader,children:(0,s.jsxs)("div",{className:N().categoryRowInfo,children:[(0,s.jsx)("span",{className:N().categoryRowName,children:e.name}),(0,s.jsxs)("span",{className:N().categoryRowMeta,children:["Current: ",d,ey(e.currentAllocated)]})]})}),(0,s.jsxs)("div",{className:N().categoryRowControls,children:[(0,s.jsx)("input",{type:"range",min:"0",max:r,value:e.addAmount,onChange:a=>B(e.categoryId,parseFloat(a.target.value)),className:N().categorySlider}),(0,s.jsxs)("div",{className:N().categoryInputWrapper,children:[(0,s.jsxs)("span",{className:N().categoryInputPrefix,children:["+",d]}),(0,s.jsx)("input",{type:"number",min:"0",value:e.addAmount||"",onChange:a=>B(e.categoryId,parseFloat(a.target.value)||0),className:N().categoryInput})]})]}),(0,s.jsxs)("div",{className:N().quickAmounts,children:[[25,50,100].map(a=>(0,s.jsxs)("button",{type:"button",onClick:()=>B(e.categoryId,e.addAmount+a),className:"".concat(N().quickAmountBtn," ").concat(N().quickAmountBtnNormal),children:["+",d,a]},a)),I>0&&Math.round(I)>0&&(0,s.jsxs)("button",{type:"button",onClick:()=>B(e.categoryId,e.addAmount+Math.round(I)),className:"".concat(N().quickAmountBtn," ").concat(N().quickAmountBtnExact),children:["+",d,Math.round(I)," (exact)"]})]})]},e.categoryId)),y.filter(e=>e.isNew).map(e=>(0,s.jsxs)("div",{className:N().categoryRow,style:{backgroundColor:"var(--success-light)"},children:[(0,s.jsxs)("div",{className:N().categoryRowHeader,children:[(0,s.jsx)("div",{className:N().categoryRowInfo,children:(0,s.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.color&&(0,s.jsx)("div",{style:{width:"12px",height:"12px",borderRadius:"50%",backgroundColor:e.color}}),(0,s.jsx)("span",{className:N().categoryRowName,children:e.name}),(0,s.jsx)("span",{style:{fontSize:"0.7rem",padding:"2px 6px",borderRadius:"4px",backgroundColor:"var(--success-light)",color:"var(--modal-success)"},children:"New"})]})}),(0,s.jsx)("button",{type:"button",onClick:()=>{var a;return a=e.categoryId,void j(e=>e.filter(e=>e.categoryId!==a))},style:{padding:"4px",color:"var(--modal-text-muted)"},title:"Remove",children:(0,s.jsx)(h.A,{className:"h-4 w-4"})})]}),(0,s.jsx)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginTop:"8px"},children:(0,s.jsxs)("span",{style:{color:"var(--modal-success)",fontWeight:500},children:["+",d,ey(e.addAmount)]})})]},e.categoryId)),f?(0,s.jsxs)("div",{className:N().categoryRow,style:{backgroundColor:"var(--modal-bg-secondary)"},children:[(0,s.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"12px"},children:[(0,s.jsx)("span",{style:{fontSize:"0.875rem",fontWeight:500,color:"var(--modal-secondary)"},children:"Create New Category"}),(0,s.jsx)("button",{type:"button",onClick:()=>{w(!1),_(""),k(""),g(null)},style:{color:"var(--modal-text-muted)"},children:(0,s.jsx)(h.A,{className:"h-5 w-5"})})]}),(0,s.jsxs)("div",{style:{display:"grid",gridTemplateColumns:"1fr 120px",gap:"12px"},children:[(0,s.jsx)("input",{type:"text",value:C,onChange:e=>_(e.target.value),placeholder:"Category name",className:N().input,style:{padding:"8px 12px",fontSize:"0.875rem"},autoFocus:!0}),(0,s.jsxs)("div",{style:{position:"relative"},children:[(0,s.jsx)("span",{style:{position:"absolute",left:"10px",top:"50%",transform:"translateY(-50%)",color:"var(--modal-text-muted)"},children:d}),(0,s.jsx)("input",{type:"number",min:"0",max:I,value:A,onChange:e=>k(e.target.value),placeholder:"0",className:N().input,style:{padding:"8px 12px 8px 24px",fontSize:"0.875rem",textAlign:"right"}})]})]}),(0,s.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginTop:"12px"},children:[(0,s.jsxs)("span",{style:{fontSize:"0.75rem",color:"var(--modal-text-muted)"},children:["Max: ",d,ey(I)]}),(0,s.jsx)("button",{type:"button",onClick:()=>
1{if(!C.trim())return void g("Please enter a category name");let e=parseFloat(A)||0;if(e<=0)return void g("Please enter an amount greater than 0");if(e>I+.01)return void g("Amount cannot exceed ".concat(d).concat(ey(I)," remaining"));if(y.some(e=>e.name.toLowerCase()===C.trim().toLowerCase()))return void g("A category with this name already exists");let a=y.filter(e=>e.color).map(e=>e.color),t=ev.find(e=>!a.includes(e))||ev[0],s={categoryId:"new_".concat(Date.now()),name:C.trim(),currentAllocated:0,addAmount:e,isNew:!0,color:t};j(e=>[...e,s]),_(""),k(""),w(!1),g(null)},className:N().primaryButton,style:{padding:"6px 12px",fontSize:"0.875rem"},children:"Add Category"})]})]}):(0,s.jsxs)("button",{type:"button",onClick:()=>w(!0),disabled:I<1,className:N().addCategoryButton,style:{opacity:I<1?.5:1,cursor:I<1?"not-allowed":"pointer"},children:[(0,s.jsx)(T.A,{className:"h-5 w-5"}),(0,s.jsx)("span",{children:"Add New Category"})]})]})]}),(0,s.jsxs)("div",{className:N().footer,children:[(0,s.jsx)("button",{onClick:M,disabled:m,className:N().secondaryButton,children:"Cancel"}),(0,s.jsx)("button",{onClick:D,disabled:m||!R,className:N().primaryButton,children:m?(0,s.jsxs)("span",{className:"flex items-center gap-2",children:[(0,s.jsxs)("svg",{className:N().spinner,width:"14",height:"14",viewBox:"0 0 24 24",children:[(0,s.jsx)("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4",fill:"none"}),(0,s.jsx)("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]}),"Saving..."]}):"Apply Allocations"})]})]})}):null}var ej=t(91214);let ef={get:async()=>(await u.uE.get("/streaks")).data};var eN=t(95691);function ew(e){let{sources:a,monthly:t,netMonthly:l,onAddIncome:r,onEditIncome:n,onDeleteIncome:o}=e,{currency:c}=(0,b.H)(),d=e=>new Intl.NumberFormat("en-US",{style:"currency",currency:c,minimumFractionDigits:0,maximumFractionDigits:0}).format(e),m=a.length>1;return(0,s.jsxs)("div",{className:i().detailSection,children:[(0,s.jsxs)("div",{className:i().detailHeader,children:[(0,s.jsxs)("div",{className:i().detailStat,children:[(0,s.jsx)("span",{className:i().detailStatLabel,children:"Gross Income"}),(0,s.jsx)("span",{className:i().detailStatValue,children:d(t)})]}),(0,s.jsxs)("div",{className:i().detailStat,children:[(0,s.jsx)("span",{className:i().detailStatLabel,children:"Net Income"}),(0,s.jsx)("span",{className:i().detailStatValue,children:d(l)})]}),(0,s.jsxs)("div",{className:i().detailStat,children:[(0,s.jsx)("span",{className:i().detailStatLabel,children:"Active Sources"}),(0,s.jsx)("span",{className:i().detailStatValue,children:a.filter(e=>e.isActive).length})]})]}),(0,s.jsx)("div",{className:i().detailList,children:a.map(e=>(0,s.jsxs)("div",{className:i().detailRow,children:[(0,s.jsxs)("div",{className:i().detailRowLeft,children:[(0,s.jsx)("span",{className:i().detailRowName,children:e.name}),(0,s.jsx)("span",{className:i().detailRowMeta,children:e.frequency||"monthly"})]}),(0,s.jsxs)("div",{className:i().detailRowRight,children:[(0,s.jsx)("span",{className:i().detailRowAmount,children:d(e.amount)}),(0,s.jsxs)("div",{className:i().detailRowActions,children:[(0,s.jsx)("button",{className:i().detailRowActionBtn,onClick:()=>n(e),title:"Edit",children:(0,s.jsxs)("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,s.jsx)("path",{d:"M11 4H4a2 2 0 00-2 2v14a2 2 0 002 2h14a2 2 0 002-2v-7"}),(0,s.jsx)("path",{d:"M18.5 2.5a2.121 2.121 0 013 3L12 15l-4 1 1-4 9.5-9.5z"})]})}),(0,s.jsx)("button",{className:"".concat(i().detailRowActionBtn," ").concat(i().deleteBtn," ").concat(m?"":i().disabled),onClick:()=>m&&o(e),disabled:!m,title:m?"Delete":"Cannot delete your only income source",children:(0,s.jsx)("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:(0,s.jsx)("path",{d:"M3 6h18M19 6v14a2 2 0 01-2 2H7a2 2 0 01-2-2V6m3 0V4a2 2 0 012-2h4a2 2 0 012 2v2"})})})]})]})]},e.id))}),(0,s.jsxs)("button",{className:i().detailAddBtn,onClick:r,children:[(0,s.jsx)("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:(0,s.jsx)("path",{d:"M12 5v14M5 12h14"})}),"Add Income Source"]})]})}function eC(e){let{categories:a,totalAllocated:t,totalSpent:l,budgetIncome:r,onAddCategory:n,onEditCategory:o,onDeleteCategory:c}=e,{currency:d}=(0,b.H)(),m=e=>new Intl.NumberFormat("en-US",{style:"currency",currency:d,minimumFractionDigits:0,maximumFractionDigits:0}).format(e),u=r-t,x=1>Math.abs(u)?0:u;return(0,s.jsxs)("div",{className:i().detailSection,children:[(0,s.jsxs)("div",{className:i().detailHeader,children:[(0,s.jsxs)("div",{className:i().detailStat,children:[(0,s.jsx)("span",{className:i().detailStatLabel,children:"Total Allocated"}),(0,s.jsx)("span",{className:i().detailStatValue,children:m(t)})]}),(0,s.jsxs)("div",{className:i().detailStat,children:[(0,s.jsx)("span",{className:i().detailStatLabel,children:"Total Spent"}),(0,s.jsx)("span",{className:i().detailStatValue,children:m(l)})]}),(0,s.jsxs)("div",{className:i().detailStat,children:[(0,s.jsx)("span",{className:i().detailStatLabel,children:0===x?"Allocated":x>0?"Unallocated":"Over Budget"}),(0,s.jsx)("span",{className:"".concat(i().detailStatValue," ").concat(0===x?i().success:x<0?i().negative:""),children:0===x?"100%":m(Math.abs(x))})]})]}),(0,s.jsx)("div",{className:i().detailList,children:a.map(e=>{let a=e.allocated,t=e.spent,l=a>0?t/a*100:0;return(0,s.jsxs)("div",{className:i().detailRow,children:[(0,s.jsxs)("div",{className:i().detailRowLeft,children:[(0,s.jsxs)("div",{className:i().detailRowNameWithColor,children:[e.color&&(0,s.jsx)("div",{className:i().categoryDot,style:{backgroundColor:e.color}}),(0,s.jsx)("span",{className:i().detailRowName,children:e.name}),e.isDebt&&(0,s.jsx)("span",{className:i().debtBadge,children:"Debt"})]}),(0,s.jsx)("div",{className:i().miniProgress,children:(0,s.jsx)("div",{className:"".concat(i().miniProgressFill," ").concat(l>100?i().over:""),style:{width:"".concat(Math.min(l,100),"%"),backgroundColor:e.color||void 0}})})]}),(0,s.jsxs)("div",{className:i().detailRowRight,children:[(0,s.jsxs)("span",{className:i().detailRowAmount,children:[m(t)," / ",m(a)]}),(0,s.jsxs)("div",{className:i().detailRowActions,children:[(0,s.jsx)("button",{className:i().detailRowActionBtn,onClick:()=>o(e),title:"Edit",children:(0,s.jsxs)("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,s.jsx)("path",{d:"M11 4H4a2 2 0 00-2 2v14a2 2 0 002 2h14a2 2 0 002-2v-7"}),(0,s.jsx)("path",{d:"M18.5 2.5a2.121 2.121 0 013 3L12 15l-4 1 1-4 9.5-9.5z"})]})}),(0,s.jsx)("button",{className:"".concat(i().detailRowActionBtn," ").concat(i().deleteBtn," ").concat(e.isDebt?i().disabled:""),onClick:()=>!e.isDebt&&c(e),disabled:e.isDebt,title:e.isDebt?"Cannot delete debt categories here - manage via Debt page":"Delete",children:(0,s.jsx)("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:(0,s.jsx)("path",{d:"M3 6h18M19 6v14a2 2 0 01-2 2H7a2 2 0 01-2-2V6m3 0V4a2 2 0 012-2h4a2 2 0 012 2v2"})})})]})]})]},e.id)})}),(0,s.jsxs)("button",{className:i().detailAddBtn,onClick:n,children:[(0,s.jsx)("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:(0,s.jsx)("path",{d:"M12 5v14M5 12h14"})}),"Add Category"]})]})}function e_(e){let{debts:a,totalDebt:t,totalMinimums:l,onAddDebt:r,onEditDebt:n,onDeleteDebt:o}=e,{currency:c}=(0,b.H)(),d=e=>new Intl.NumberFormat("en-US",{style:"currency",currency:c,minimumFractionDigits:0,maximumFractionDigits:0}).format(e),m=a.length>0?Math.max(...a.map(e=>e.apr)):0;return(0,s.jsxs)("div",{className:i().detailSection,children:[(0,s.jsxs)("div",{className:i().detailHeader,children:[(0,s.jsxs)("div",{className:i().detailStat,children:[(0,s.jsx)("span",{className:i().detailStatLabel,children:"Total Debt"}),(0,s.jsx)("span",{className:i().detailStatValue,children:d(t)})]}),(0,s.jsxs)("div",{className:i().detailStat,children:[(0,s.jsx)("span",{className:i().detailStatLabel,children:"Monthly Minimums"}),(0,s.jsx)("span",{className:i().detailStatValue,children:d(l)})]}),(0,s.jsxs)("div",{className:i().detailStat,children:[(0,s.jsx)("span",{className:i().detailStatLabel,children:"Highe
1st APR"}),(0,s.jsxs)("span",{className:i().detailStatValue,children:[m,"%"]})]})]}),(0,s.jsx)("div",{className:i().detailList,children:a.map(e=>{var a;return(0,s.jsxs)("div",{className:i().detailRow,children:[(0,s.jsxs)("div",{className:i().detailRowLeft,children:[(0,s.jsx)("span",{className:i().detailRowName,children:e.accountName}),(0,s.jsxs)("span",{className:i().detailRowMeta,children:[null==(a=e.accountType)?void 0:a.replace("_"," ")," ⢠",e.apr,"% APR"]})]}),(0,s.jsxs)("div",{className:i().detailRowRight,children:[(0,s.jsx)("span",{className:i().detailRowAmount,children:d(e.balance)}),(0,s.jsxs)("span",{className:i().detailRowMeta,children:["min: ",d(e.minimumPayment)]})]}),(0,s.jsxs)("div",{className:i().detailRowActions,children:[(0,s.jsx)("button",{className:i().detailRowActionBtn,onClick:()=>n(e),title:"Edit",children:(0,s.jsxs)("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,s.jsx)("path",{d:"M11 4H4a2 2 0 00-2 2v14a2 2 0 002 2h14a2 2 0 002-2v-7"}),(0,s.jsx)("path",{d:"M18.5 2.5a2.121 2.121 0 013 3L12 15l-4 1 1-4 9.5-9.5z"})]})}),(0,s.jsx)("button",{onClick:()=>o(e),className:"".concat(i().detailRowActionBtn," ").concat(i().deleteBtn),title:"Delete debt",children:(0,s.jsx)("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:(0,s.jsx)("path",{d:"M3 6h18M19 6v14a2 2 0 01-2 2H7a2 2 0 01-2-2V6m3 0V4a2 2 0 012-2h4a2 2 0 012 2v2"})})})]})]},e.id)})}),(0,s.jsxs)("button",{className:i().detailAddBtn,onClick:r,children:[(0,s.jsx)("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:(0,s.jsx)("path",{d:"M12 5v14M5 12h14"})}),"Add Debt Account"]})]})}function eA(e){var a;let{plan:t,debts:l,onPausePlan:r,onResumePlan:n,onCreatePlan:o}=e,{currency:c}=(0,b.H)(),d=e=>new Intl.NumberFormat("en-US",{style:"currency",currency:c,minimumFractionDigits:0,maximumFractionDigits:0}).format(e),m=(null==t?void 0:t.status)==="paused",u=(null==t?void 0:t.status)==="pausing_next_month",x=(null==t?void 0:t.status)==="resuming_next_month",h=(null==t?void 0:t.status)==="active",p=null==t||null==(a=t.priority_debt)?void 0:a.id;if(!t)return(0,s.jsx)("div",{className:i().detailSection,children:(0,s.jsxs)("div",{className:i().emptyState,children:[(0,s.jsx)("div",{className:i().emptyIcon,children:(0,s.jsxs)("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1",children:[(0,s.jsx)("circle",{cx:"12",cy:"12",r:"10"}),(0,s.jsx)("path",{d:"M12 6v6l4 2"})]})}),(0,s.jsx)("h3",{children:"No Active Plan"}),(0,s.jsx)("p",{children:"Create a debt elimination plan to calculate your Freedom Date â the day you owe nothing."}),(0,s.jsx)("button",{className:i().createPlanBtn,disabled:0===l.length,onClick:o,children:0===l.length?"Add debts first":"Create Freedom Plan"})]})});let g=[...l].sort((e,a)=>e.id===p?-1:a.id===p?1:(a.balance||0)-(e.balance||0));return(0,s.jsxs)("div",{className:i().detailSection,children:[(m||u||x)&&(0,s.jsxs)("div",{className:"".concat(i().statusBanner," ").concat(m?i().statusPaused:i().statusDeferred),children:[(0,s.jsx)("span",{className:i().statusIcon,children:m?"â¸ï¸":"\uD83D\uDCC5"}),(0,s.jsxs)("div",{className:i().statusInfo,children:[(0,s.jsxs)("span",{className:i().statusTitle,children:[m&&"Plan Paused",u&&"Pausing Next Month",x&&"Resuming Next Month"]}),(0,s.jsxs)("span",{className:i().statusText,children:[m&&"Debt payments at minimums only",u&&"Will pause on the 1st",x&&"Will resume on the 1st"]})]}),m&&(0,s.jsxs)("button",{className:"".concat(i().planActionBtn," ").concat(i().planActionBtnPrimary),onClick:n,children:[(0,s.jsx)("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",style:{width:16,height:16},children:(0,s.jsx)("polygon",{points:"5 3 19 12 5 21 5 3"})}),"Resume"]})]}),(0,s.jsxs)("div",{className:i().detailHeader,children:[(0,s.jsxs)("div",{className:i().detailStat,children:[(0,s.jsx)("span",{className:i().detailStatLabel,children:"Strategy"}),(0,s.jsx)("span",{className:i().detailStatValue,style:{textTransform:"capitalize"},children:t.strategy})]}),(0,s.jsxs)("div",{className:i().detailStat,children:[(0,s.jsx)("span",{className:i().detailStatLabel,children:"Monthly Payment"}),(0,s.jsx)("span",{className:i().detailStatValue,children:d(t.total_monthly_payment||t.total_monthly_allocation||0)})]}),(0,s.jsxs)("div",{className:i().detailStat,children:[(0,s.jsx)("span",{className:i().detailStatLabel,children:"Freedom Date"}),(0,s.jsx)("span",{className:i().detailStatValue,children:t.projected_payoff_date?(()=>{let[e,a]=t.projected_payoff_date.split("T")[0].split("-").map(Number);return new Date(e,a-1,1).toLocaleDateString("en-US",{month:"short",year:"numeric"})})():"Calculating..."})]}),h&&(0,s.jsxs)("button",{className:"".concat(i().planActionBtn," ").concat(i().planActionBtnWarning),onClick:r,children:[(0,s.jsxs)("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",style:{width:16,height:16},children:[(0,s.jsx)("rect",{x:"6",y:"4",width:"4",height:"16"}),(0,s.jsx)("rect",{x:"14",y:"4",width:"4",height:"16"})]}),"Pause"]})]}),(0,s.jsx)("div",{className:i().detailList,children:g.map(e=>{var a;let t=e.id===p;return(0,s.jsxs)("div",{className:"".concat(i().detailRow," ").concat(t?i().priorityRow:""),children:[(0,s.jsxs)("div",{className:i().detailRowLeft,children:[(0,s.jsxs)("div",{className:i().detailRowNameWithBadge,children:[(0,s.jsx)("span",{className:i().detailRowName,children:e.accountName}),t&&(0,s.jsx)("span",{className:i().focusBadge,children:"Focus"})]}),(0,s.jsxs)("span",{className:i().detailRowMeta,children:[null==(a=e.accountType)?void 0:a.replace("_"," ")," ⢠",e.apr,"% APR"]})]}),(0,s.jsxs)("div",{className:i().detailRowRight,children:[(0,s.jsx)("span",{className:i().detailRowAmount,children:d(e.balance||0)}),(0,s.jsxs)("span",{className:i().detailRowMeta,children:["min: ",d(e.minimumPayment||0)]})]})]},e.id)})}),(u||x)&&(0,s.jsx)("div",{className:i().planActions,children:(0,s.jsx)("button",{className:i().planActionBtn,disabled:!0,children:u?"Pause Scheduled":"Resume Scheduled"})})]})}let ek=[{id:"income",title:"Manage Income",subtitle:"Add, edit, delete sources",icon:(0,s.jsx)("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:(0,s.jsx)("path",{d:"M12 2v20M17 5H9.5a3.5 3.5 0 000 7h5a3.5 3.5 0 010 7H6"})}),gradient:"linear-gradient(135deg, #10b981 0%, #059669 100%)"},{id:"budget",title:"Manage Budget",subtitle:"Add, edit, delete categories",icon:(0,s.jsxs)("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:[(0,s.jsx)("path",{d:"M11 3.055A9.001 9.001 0 1020.945 13H11V3.055z"}),(0,s.jsx)("path",{d:"M20.488 9H15V3.512A9.025 9.025 0 0120.488 9z"})]}),gradient:"linear-gradient(135deg, #6366f1 0%, #4f46e5 100%)"},{id:"debts",title:"Manage Debts",subtitle:"Add, edit, delete accounts",icon:(0,s.jsxs)("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:[(0,s.jsx)("rect",{x:"2",y:"5",width:"20",height:"14",rx:"2"}),(0,s.jsx)("path",{d:"M2 10h20"})]}),gradient:"linear-gradient(135deg, #f59e0b 0%, #d97706 100%)"},{id:"freedom",title:"Freedom Plan",subtitle:"Debt elimination strategy",icon:(0,s.jsxs)("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:[(0,s.jsx)("circle",{cx:"12",cy:"12",r:"10"}),(0,s.jsx)("path",{d:"M12 6v6l4 2"})]}),gradient:"linear-gradient(135deg, #ec4899 0%, #db2777 100%)"}];function eS(){var e,a;let t=(0,r.useRouter)(),c=(0,r.useSearchParams)(),{resolvedTheme:h,setTheme:p}=(0,n.D)(),{symbol:g,format:y}=(0,b.H)(),[v,j]=(0,l.useState)(!1),[f,N]=(0,l.useState)(!0),[w,C]=(0,l.useState)(null),[A,k]=(0,l.useState)(null),[S,I]=(0,l.useState)(null),[B,D]=(0,l.useState)(!1),[T,M]=(0,l.useState)(!1),[F,P]=(0,l.useState)(!1),L=v&&"light"===h,[E,W]=(0,l.useState)(null),[z,V]=(0,l.useState)([]),[U,q]=(0,l.useState)([]),[O,G]=(0,l.useState)([]),[J,Q]=(0,l.useState)(null),[Z,X]=(0,l.useState)(!1),[ee,ea]=(0,l.useState)(0),[et,es]=(0,l.useState)(0),[er,en]=(0,l.useState)(null),[ec,ei]=(0,l.useState)(!1),[ed,em]=(0,l.useState)(null),[eu,ex]=(0,l.useState)(!1),[eh,ep]=(0,l.useState)(null),[ey,ev]=(0,l.useState)(!1),[eS,eI]=(0,l.useState)(null),[eR,eB]=(0,l.useState)(!1),[eD,eT]=(0,l.useState)(null),[eM,eF]=(0,l.useState)(!1),[eP,eL]=(0,l.useState)(null),[eE,eW]=(0,l.useState)(!1),[ez,eH]=(0,l.useState)(null),[eV,eU]=(0,l.useState)([]),[eq,eO]=(0,l.useState)(!1),[eY,eG]=(0,l.useState)(!1),[eJ,eQ]=(0,l.useState)(!1),[eK,eZ]=(0,l.useState)(null),[eX,e$]=(0,l.useState)(null),[e0,e1]=(0,l.useState)(!1),[e2,e5]=(0,l.useState)(null),[e4,e3]=(0,l.useState)(!1),[e6,e8]=(0,l.useState)(0);(0,l.useEffect)(()=>{j(!0),e7()},[]),(0,l.useEffect)(()=>
1{if(!v||f||F)return;let e=null==c?void 0:c.get("view");if(e&&ek.some(a=>a.id===e)){k(e),M(!0),P(!0);let a=new URL(window.location.href);a.searchParams.delete("view"),window.history.replaceState({},"",a.pathname)}else P(!0)},[v,f,c,F]),(0,l.useEffect)(()=>{v&&Z&&"true"===(null==c?void 0:c.get("reallocation"))&&(async()=>{try{if(!(null==E?void 0:E.id))return;z.filter(e=>"debt"===e.type&&"paid_off"===e.status);let e=z.reduce((e,a)=>e+Number(a.allocated||0),0),a=ee-e;a>0&&(e8(a),e3(!0));let t=new URL(window.location.href);t.searchParams.delete("reallocation"),window.history.replaceState({},"",t.pathname)}catch(e){}})()},[v,Z,c,null==E?void 0:E.id,z,ee]);let e7=async()=>{N(!0),X(!1),C(null);try{var e,a,s;let l=await x.Y.getAllBudgets();if(0===l.length)return void t.push("/onboarding");let r=new Date,n=l.find(e=>{if(e.is_closed)return!1;let a=new Date(e.start_date||""),t=e.end_date?new Date(e.end_date):new Date;return r>=a&&r<=t})||l.find(e=>!e.is_closed)||l[0];W(n),N(!1);let[o,c,i,d,m,h]=await Promise.all([u.uE.get("/budgets/".concat(n.id,"/categories")),u.uE.get("/debts/accounts"),u.uE.get("/income/sources"),u.uE.get("/debt-payoff/active-plan").catch(()=>({data:{has_active_plan:!1}
1})),u.uE.get("/budgets/".concat(n.id,"/effective-income")).catch(()=>({data:{effectiveIncome:0,grossIncome:0}})),ef.get().catch(()=>null)]);V(o.data||[]),q(Array.isArray(c.data)?c.data:[]),G(Array.isArray(i.data)?i.data:(null==(e=i.data)?void 0:e.sources)||[]),d.data.has_active_plan&&Q(d.data.plan),ea(Number(null==(a=m.data)?void 0:a.effectiveIncome)||0),es(Number(null==(s=m.data)?void 0:s.grossIncome)||0),h&&en(h),X(!0)}catch(e){C("Failed to load your data"),N(!1),X(!0)}},e9=z.reduce((e,a)=>e+Number(a.allocated||0),0),ae=z.reduce((e,a)=>e+Number(a.spent||0),0),aa=U.reduce((e,a)=>e+Number(a.balance||0),0),at=U.reduce((e,a)=>e+Number(a.minimum_payment||0),0),as=O.map(e=>({id:e.id,name:e.name||"",type:e.type||"fixed",amount:Number(e.amount||0),frequency:e.frequency||"monthly",description:e.description||"",isActive:!1!==e.is_active,taxRate:null!=e.tax_rate?Number(e.tax_rate):void 0,retirementContributionPct:null!=e.retirement_contribution_pct?Number(e.retirement_contribution_pct):void 0,otherPretaxDeductions:null!=e.other_pretax_deductions?Number(e.other_pretax_deductions):void 0,hoursPerWeek:null!=e.hours_per_week?Number(e.hours_per_week):void 0,workDaysPerWeek:null!=e.work_days_per_week?Number(e.work_days_per_week):void 0,monthlyEquivalent:Number(e.amount||0)*(({weekly:52/12,biweekly:26/12,"semi-monthly":2,monthly:1,annual:1/12})[e.frequency||"monthly"]||1)})),al=z.map(e=>({id:e.id,name:e.name||"",allocated:Number(e.allocated||0),spent:Number(e.spent||0),isDebt:"debt"===e.type||!!e.linked_debt_id,minimumPayment:e.minimum_payment?Number(e.minimum_payment):void 0,color:e.color,icon:e.icon,linkedDebtId:e.linked_debt_id})),ar=U.map(e=>{let a=al.find(a=>a.linkedDebtId===e.id);return{id:e.id,accountName:e.account_name||"",accountType:e.account_type||"OTHER",balance:Number(e.balance||0),apr:Number(e.apr||0),minimumPayment:Number(e.minimum_payment||0),dueDate:e.due_date,creditor:e.creditor,creditLimit:e.credit_limit?Number(e.credit_limit):void 0,isInPlan:!!J,linkedCategoryId:null==a?void 0:a.id}}),an=(0,l.useCallback)(()=>{em(null),ei(!0)},[]),ao=(0,l.useCallback)(e=>{em(e),ei(!0)},[]),ac=(0,l.useCallback)(e=>{ep(e),ex(!0)},[]),ai=(0,l.useCallback)(async e=>{var a,t,s,l;try{let s=e.frequency;"semi-monthly"===e.frequency&&(s="biweekly"),"yearly"===e.frequency&&(s="monthly");let l=(null==(a=e.allocations)?void 0:a.filter(e=>e.isNew&&e.name).map(e=>({name:e.name,allocated:e.newAllocated,color:e.color||"#3B82F6"})))||[],r=[...(null==(t=e.allocations)?void 0:t.filter(e=>!e.isNew).map(e=>({categoryId:e.categoryId,newAllocated:e.newAllocated})))||[],...e.rebalanceChanges||[]];ed?await u.uE.put("/income/sources/".concat(ed.id),{name:e.name,type:e.type,amount:e.amount,frequency:s,description:e.description,is_active:e.isActive,tax_rate:e.taxRate,retirement_contribution_pct:e.retirementContributionPct,other_pretax_deductions:e.otherPretax
1Deductions,hours_per_week:e.hoursPerWeek,work_days_per_week:e.workDaysPerWeek,rebalanceChanges:r,newCategories:l,debtPlanExtra:e.debtPlanExtra}):await u.uE.post("/income/sources",{name:e.name,type:e.type,amount:e.amount,frequency:s,description:e.description,is_active:e.isActive,tax_rate:e.taxRate,retirement_contribution_pct:e.retirementContributionPct,other_pretax_deductions:e.otherPretaxDeductions,hours_per_week:e.hoursPerWeek,work_days_per_week:e.workDaysPerWeek,newCategories:l,existingCategoryUpdates:r,debtPlanExtra:e.debtPlanExtra}),await e7(),ei(!1),em(null)}catch(e){throw Error((null==(l=e.response)||null==(s=l.data)?void 0:s.error)||e.message||"Failed to save income source")}},[ed,e7]),ad=(0,l.useCallback)(async e=>{try{await u.uE.delete("/income/sources/".concat(e.sourceId),{data:{rebalanceChanges:e.rebalanceChanges||[]}}),await e7(),ex(!1),ep(null)}catch(e){var a,t;throw Error((null==(t=e.response)||null==(a=t.data)?void 0:a.error)||e.message||"Failed to delete income source")}},[e7]),am=(0,l.useCallback)(()=>{eI(null),ev(!0)},[]),au=(0,l.useCallback)(e=>{eI(e),ev(!0)},[]),ax=(0,l.useCallback)(e=>{eT(e),eB(!0)},[]),ah=(0,l.useCallback)(async e=>{if(!E)throw Error("No budget loaded");try{if(eS){let a={name:e.name,allocated:e.allocated,rebalanceChanges:e.rebalanceChanges||[]};e.color&&/^#[0-9A-Fa-f]{6}$/.test(e.color)&&(a.color=e.color),e.icon&&(a.icon=e.icon),await u.uE.put("/budgets/".concat(E.id,"/categories/").concat(eS.id),a)}else{let a={name:e.name,allocated:e.allocated,type:"expense",rebalanceChanges:e.rebalanceChanges||[]};e.color&&/^#[0-9A-Fa-f]{6}$/.test(e.color)&&(a.color=e.color),e.icon&&(a.icon=e.icon),await u.uE.post("/budgets/".concat(E.id,"/categories"),a)}await e7(),ev(!1),eI(null)}catch(e){var a,t;throw Error((null==(t=e.response)||null==(a=t.data)?void 0:a.message)||e.message||"Failed to save category")}},[E,eS,e7]),ap=(0,l.useCallback)(async e=>{if(!E)throw Error("No budget loaded");try{await u.uE.delete("/budgets/".concat(E.id,"/categories/").concat(e.categoryId),{data:{rebalanceChanges:e.rebalanceChanges||[],forceWithPartialReallocation:e.forceWithPartialReallocation}}),await e7(),eB(!1),eT(null)}catch(e){var a,t;throw Error((null==(t=e.response)||null==(a=t.data)?void 0:a.message)||e.message||"Failed to delete category")}},[E,e7]),ag=(0,l.useCallback)(()=>{eH(null),eF(!0)},[]),ay=(0,l.useCallback)(async e=>{if(!E)return void eU([]);let a=al.find(a=>a.linkedDebtId===e.id);if(!a)return void eU([]);try{let e=new Date,t=new Date(e.getFullYear(),e.getMonth(),1).toISOString().split("T")[0],s=new Date(e.getFullYear(),e.getMonth()+1,0).toISOString().split("T")[0],l=await u.uE.get("/transactions",{params:{categoryId:a.id,startDate:t,endDate:s,limit:50}}),r=Array.isArray(l.data)?l.data:[];eU(r.map(e=>({id:e.id,amount:Number(e.amount)||0,description:e.description||e.notes||"",date:e.date||e.transaction_date||new Date().toISOString()})))}catch(e){eU([])}},[E,al]),av=(0,l.useCallback)(async e=>{eH(e),eW(!0),await ay(e)},[ay]),ab=(0,l.useCallback)(async e=>{await u.uE.delete("/transactions/".concat(e)),eH(null),eU([]),eW(!1),e7()},[e7]),aj=(0,l.useCallback)(async e=>{var a,t,s,l,r,n,c,i,d;if(!E)throw Error("No budget loaded");try{if(e.isEditing&&e.debtId){let s=await u.uE.put("/debts/accounts/".concat(e.debtId),{account_name:e.accountName,account_type:e.accountType,balance:e.balance,apr:e.apr,minimum_payment:e.minimumPayment,due_date:e.dueDate,creditor:e.creditor,credit_limit:e.creditLimit,rebalanceChanges:e.rebalanceChanges||[]});if((null==(a=s.data)?void 0:a.requiresRebalance)&&(null==(t=s.data)?void 0:t.freedFunds)>0){e5({amount:s.data.freedFunds,message:s.data.rebalanceMessage||"$".concat(Math.round(s.data.freedFunds)," freed from reduced minimum payment"),debtId:e.debtId}),await e7(),eF(!1),e1(!0);return}}else{let a=await u.uE.post("/debts/accounts",{account_name:e.accountName,account_type:e.accountType,balance:e.balance,original_balance:e.balance,apr:e.apr,minimum_payment:e.minimumPayment,due_date:e.dueDate,creditor:e.creditor,credit_limit:e.creditLimit,rebalanceChanges:e.rebalanceChanges||[]});(null==(l=a.data)||null==(s=l.planUpdateData)?void 0:s.priorityChangeWarning)&&o.oR.success(a.data.planUpdateData.priorityChangeWarning,{duration:8e3})}await e7(),eF(!1)}catch(e){if((null==(r=e.response)?void 0:r.status)===409&&(null==(c=e.response)||null==(n=c.data)?void 0:n.blocked))return void o.oR.error(e.response.data.message||"Operation blocked due to existing spending.",{duration:5e3});throw Error((null==(d=e.response)||null==(i=d.data)?void 0:i.message)||e.message||"Failed to save debt")}},[E,e7]),af=(0,l.useCallback)(async e=>{var a,t,s;if(!E)throw Error("No budget loaded");try{let t=(null==(a=e.rolloverDistribution)?void 0:a.map(e=>{var a;return{categoryId:e.categoryId,newAllocated:Math.round((((null==(a=al.find(a=>a.id===e.categoryId))?void 0:a.allocated)||0)+e.addAmount)*100)/100}}))||[],s=[...e.rebalanceChanges||[],...t];await u.uE.delete("/debts/accounts/".concat(e.debtId),{data:{rebalanceChanges:s}}),await e7(),eW(!1),eH(null)}catch(e){throw Error((null==(s=e.response)||null==(t=s.data)?void 0:t.message)||e.message||"Failed to delete debt")}},[E,e7,al]),aN=(0,l.useCallback)(async()=>
1{if(J)try{let e=await u.uE.post("/debt-payoff/pause-options");eZ(e.data),eG(!0)}catch(t){var e,a;o.oR.error((null==(a=t.response)||null==(e=a.data)?void 0:e.error)||"Failed to fetch pause options")}},[J]),aw=(0,l.useCallback)(async e=>{try{await u.uE.post("/debt-payoff/pause-interactive",{custom_allocations:e.customAllocations}),await e7(),eG(!1),eZ(null)}catch(e){var a,t;throw Error((null==(t=e.response)||null==(a=t.data)?void 0:a.error)||"Failed to pause plan")}},[e7]),aC=(0,l.useCallback)(async()=>{if(J)try{let e=await u.uE.post("/debt-payoff/resume-options");e$(e.data),eQ(!0)}catch(t){var e,a;o.oR.error((null==(a=t.response)||null==(e=a.data)?void 0:e.error)||"Failed to fetch resume options")}},[J]),a_=(0,l.useCallback)(async e=>{try{await u.uE.post("/debt-payoff/resume-interactive",{target_amount:e.targetAmount,custom_reductions:e.customReductions}),await e7(),eQ(!1),e$(null)}catch(e){var a,t;throw Error((null==(t=e.response)||null==(a=t.data)?void 0:a.error)||"Failed to resume plan")}},[e7]),aA=(0,l.useCallback)(async e=>{if(!E)throw Error("No budget loaded");try{let a=e.budgetChanges.map(e=>{let a=z.find(a=>a.id===e.categoryId),t=Number((null==a?void 0:a.allocated)||0);return{categoryId:e.categoryId,categoryName:(null==a?void 0:a.name)||"",oldAmount:t,newAmount:e.newAllocated,changeAmount:e.newAllocated-t}});await u.uE.post("/debt-payoff/create-plan",{budgetId:E.id,budgetChanges:a,strategy:e.strategy}),o.oR.success("Freedom Plan created!"),await e7(),eO(!1)}catch(e){var a,t,s,l;throw Error((null==(t=e.response)||null==(a=t.data)?void 0:a.error)||(null==(l=e.response)||null==(s=l.data)?void 0:s.message)||"Failed to create plan")}},[E,z,e7]),ak=(0,l.useCallback)(async e=>{if(!E)throw Error("No budget loaded");if(!e2)throw Error("No freed funds data");try{let a=e.rebalanceChanges.filter(e=>e.isNew&&e.name),t=e.rebalanceChanges.filter(e=>!e.isNew);for(let e of a)await u.uE.post("/budgets/".concat(E.id,"/categories"),{name:e.name,allocated:0,color:e.color||"#3B82F6",type:"expense"});let s=z;a.length>0&&(s=await x.Y.getBudgetCategories(E.id));let l=[],r=s.find(e=>e.linked_debt_id===e2.debtId);for(let e of(r&&l.push({categoryId:r.id,newAllocated:Math.round(Number(r.allocated)-e2.amount)}),t))l.push({categoryId:e.categoryId,newAllocated:e.newAllocated});for(let e of a){let a=s.find(a=>a.name===e.name);a&&l.push({categoryId:a.id,newAllocated:e.newAllocated})}l.length>0&&await x.Y.rebalanceCategories(E.id,l),await e7(),e1(!1),e5(null),o.oR.success("Freed funds allocated successfully")}catch(e){var a,t;throw Error((null==(t=e.response)||null==(a=t.data)?void 0:a.message)||e.message||"Failed to reallocate funds")}},[E,z,e2,e7]),aS=e=>{B||(D(!0),I(e),setTimeout(()=>{k(e),M(!0)},400),setTimeout(()=>{I(null),D(!1)},800))},aI=[i().page,L?i().lightMode:""].filter(Boolean).join(" ");return(0,s.jsxs)("div",{className:aI,children:[(0,s.jsxs)("div",{className:i().bgEffects,children:[(0,s.jsx)("div",{className:i().gridLines}),(0,s.jsx)("div",{className:i().glowOrb})]}),(0,s.jsxs)("main",{className:i().main,children:[(0,s.jsx)(m.J,{delay:.05,children:(0,s.jsx)(m.T,{children:(0,s.jsx)("header",{className:i().header,children:(0,s.jsxs)("div",{className:i().headerContent,children:[(0,s.jsxs)("div",{className:i().headerLeft,children:[A&&(0,s.jsx)("button",{className:i().backBtn,onClick:()=>{B||(D(!0),M(!1),setTimeout(()=>{k(null)},300),setTimeout(()=>{D(!1)},600))},children:(0,s.jsx)("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:(0,s.jsx)("path",{d:"M19 12H5M12 19l-7-7 7-7"})})}),(0,s.jsxs)("div",{children:[(0,s.jsx)("h1",{className:i().title,children:A?null==(e=ek.find(e=>e.id===A))?void 0:e.title:"The Vault"}),(0,s.jsx)("p",{className:i().subtitle,children:new Date().toLocaleDateString("en-US",{weekday:"long",month:"long",day:"numeric"})})]})]}),er&&(er.currentStreak>0||er.gracePeriodActive)&&(0,s.jsx)("div",{className:i().headerCenter,children:(0,s.jsx)(eN.X,{currentStreak:er.currentStreak,gracePeriodActive:er.gracePeriodActive})}),(0,s.jsx)("div",{className:i().headerRight,children:(0,s.jsx)("button",{className:i().actionBtn,onClick:e7,children:(0,s.jsx)("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:(0,s.jsx)("path",{d:"M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"})})})})]})})})}),(0,s.jsxs)("div",{className:i().content,children:[w&&!f&&(0,s.jsx)(d.W5,{message:w,onRetry:e7}),!A&&!w&&(0,s.jsxs)(m.J,{delay:.1,stagger:.12,children:[(0,s.jsx)(m.T,{children:(0,s.jsxs)("div",{className:i().introBanner,children:[(0,s.jsx)("div",{className:i().introBannerIcon,children:(0,s.jsxs)("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:[(0,s.jsx)("path",{d:"M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.065 2.572c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.572 1.065c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.065-2.572c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065z"}),(0,s.jsx)("circle",{cx:"12",cy:"12",r:"3"})]})}),(0,s.jsxs)("div",{className:i().introBannerText,children:[(0,s.jsx)("span",{className:i().introBannerTitle,children:"Your financial control panel"}
1),(0,s.jsx)("span",{className:i().introBannerDesc,children:"Add, edit, or remove income sources, budget categories, and debt accounts here."})]})]})}),(0,s.jsx)(m.T,{children:(0,s.jsx)(d.lo,{isExiting:!!S,children:ek.map((e,a)=>{let t=(e=>{if(!Z)return{primary:"â",secondary:"Loading"};switch(e){case"income":return{primary:y(et),secondary:"".concat(O.length," sources")};case"budget":return{primary:y(e9),secondary:"".concat(z.length," categories")};case"debts":return{primary:y(aa),secondary:"".concat(U.length," accounts")};case"freedom":if((null==J?void 0:J.status)==="paused")return{primary:"Paused",secondary:"Tap to resume"};return{primary:(null==J?void 0:J.projected_payoff_date)?(()=>{let[e,a]=J.projected_payoff_date.split("T")[0].split("-").map(Number);return new Date(e,a-1,1).toLocaleDateString("en-US",{month:"short",year:"numeric"})})():"Not Set",secondary:J?J.strategy:"Create a plan"};default:return{primary:"--",secondary:"--"}}})(e.id);return(0,s.jsx)(d.bh,{id:e.id,title:e.title,subtitle:e.subtitle,icon:e.icon,gradient:e.gradient,primaryStat:t.primary,secondaryStat:t.secondary,isSelected:S===e.id,isFading:!!S&&S!==e.id,isAnimating:B,isDataLoading:!Z,onClick:aS,animationDelay:"".concat(.18*a,"s")},e.id)})})})]}),A&&(0,s.jsxs)("div",{className:"".concat(i().detailView," ").concat(T?i().detailViewVisible:""),children:["income"===A&&(0,s.jsx)(ew,{sources:as,monthly:et,netMonthly:ee,onAddIncome:an,onEditIncome:ao,onDeleteIncome:ac}),"budget"===A&&(0,s.jsx)(eC,{categories:al,totalAllocated:e9,totalSpent:ae,budgetIncome:ee,onAddCategory:am,onEditCategory:au,onDeleteCategory:ax}),"debts"===A&&(0,s.jsx)(e_,{debts:ar,totalDebt:aa,totalMinimums:at,onAddDebt:ag,onEditDebt:e=>eL(e),onDeleteDebt:av}),"freedom"===A&&(0,s.jsx)(eA,{plan:J,debts:ar,onPausePlan:aN,onResumePlan:aC,onCreatePlan:()=>eO(!0)})]})]})]}),(0,s.jsx)(H,{isOpen:ec,onClose:()=>{ei(!1),em(null)},editingSource:ed,existingSources:as,existingCategories:al,totalAllocated:e9,totalSpentThisMonth:ae,currentTotalMonthlyIncome:ee,budgetId:null==E?void 0:E.id,activePlan:J?{strategy:J.strategy,status:J.status}:null,onSave:ai}),(0,s.jsx)(Y,{isOpen:eu,onClose:()=>{ex(!1),ep(null)},deletingSource:eh,existingCategories:al,totalAllocated:e9,totalSpentThisMonth:ae,currentTotalMonthlyIncome:ee,totalIncomeSources:O.length,onDelete:ad}),(0,s.jsx)(_,{isOpen:ey,onClose:()=>{ev(!1),eI(null)},editingCategory:eS,existingCategories:al,budgetIncome:ee,totalAllocated:eS?e9-eS.allocated:e9,onSave:ah}),(0,s.jsx)(R,{isOpen:eR,onClose:()=>{eB(!1),eT(null)},category:eD,existingCategories:al,onDelete:ap}),(0,s.jsx)(K,{isOpen:eM||!!eP,onClose:()=>{eF(!1),eL(null)},editingDebt:eP,existingCategories:al,budgetIncome:ee,totalAllocated:e9,budgetId:(null==E?void 0:E.id)||"",onSave:aj}),(0,s.jsx)($,{isOpen:eE,onClose:()=>{eW(!1),eH(null),eU([])},debt:ez,existingCategories:al,spentThisMonth:ez&&(null==(a=al.find(e=>e.linkedDebtId===ez.id))?void 0:a.spent)||0,blockingTransactions:eV,isInPlan:!!J,planStatus:null==J?void 0:J.status,planStrategy:null==J?void 0:J.strategy,allDebts:ar,onDelete:af,onDeleteTransaction:ab}),eK&&(0,s.jsx)(el,{isOpen:eY,onClose:()=>{eG(!1),eZ(null)},planId:(null==J?void 0:J.id)||"",freedFunds:eK.freed_funds||0,eligibleCategories:(eK.eligible_categories||[]).map(e=>({id:e.id,name:e.name,currentAllocated:e.current_allocated,currentSpent:e.current_spent,type:e.type||"expense"})),blocked:eK.blocked||!1,blockingInfo:eK.blocking_info,onPause:aw}),eX&&(0,s.jsx)(eo,{isOpen:eJ,onClose:()=>{eQ(!1),e$(null)},planId:(null==J?void 0:J.id)||"",neededAmount:eX.needed_amount||0,minimumRequired:eX.minimum_required||eX.current_debt_total||0,planTotal:eX.plan_total||0,flexibleCategories:(eX.flexible_categories||[]).map(e=>({id:e.id,name:e.name,currentAllocated:e.current_allocated,currentSpent:e.current_spent,unspent:e.unspent,type:e.type||"expense"})),totalUnspent:eX.total_unspent||0,canResumeImmediately:!1!==eX.can_resume_immediately,onResume:a_}),(0,s.jsx)(eg,{isOpen:eq,onClose:()=>eO(!1),budgetId:(null==E?void 0:E.id)||"",debts:U.map(e=>({id:e.id,name:e.account_name||"",balance:Number(e.balance||0),apr:Number(e.apr||0),minimumPayment:Number(e.minimum_payment||0)})),flexibleCategories:z.filter(e=>"debt"!==e.type&&!e.linked_debt_id).map(e=>({id:e.id,name:e.name||"",currentAllocated:Number(e.allocated||0),currentSpent:Number(e.spent||0),unspent:Math.max(0,Number(e.allocated||0)-Number(e.spent||0)),type:e.type||"expense"})),totalUnspent:z.filter(e=>"debt"!==e.type&&!e.linked_debt_id).reduce((e,a)=>e+Math.max(0,Number(a.allocated||0)-Number(a.spent||0)),0),totalMinimums:U.reduce((e,a)=>e+Number(a.minimum_payment||0),0),onCreate:aA}),e2&&(0,s.jsx)(eb,{isOpen:e0,onClose:()=>{e1(!1),e5(null)},freedFunds:e2.amount,message:e2.message,eligibleCategories:al.map(e=>({id:e.id,name:e.name,currentAllocated:e.allocated,currentSpent:e.spent,isDebt:e.isDebt})),budgetId:(null==E?void 0:E.id)||"",onRebalance:ak}),(0,s.jsx)(ej.do,{isOpen:e4,onClose:()=>e3(!1),freedAmount:e6,existingCategories:al.filter(e=>!e.isDebt).map(e=>({id:e.id,name:e.name,allocated:e.allocated,spent:e.spent,type:e.isDebt?"debt":"expense",color:e.color})),budgetId:(null==E?void 0:E.id)||"",onSave:async e=>{try{for(let a of e)await u.uE.put("/budgets/".concat(null==E?void 0:E.id,"/categories/").concat(a.categoryId),{allocated:a.newAllocated});o.oR.success("Budget rebalanced successfully!"),await e7()}catch(e){throw o.oR.error("Failed to apply reallocation"),e}}})]})}function eI(){return(0,s.jsx)(l.Suspense,{fallback:null,children:(0,s.jsx)(eS,{})})}}
1,77800:(e,a,t)=>{"use strict";t.d(a,{E:()=>o});var s=t(54568),l=t(46975),r=t.n(l);let n={sm:"4px",md:"8px",lg:"14px",full:"9999px"};function o(e){let{className:a,width:t,height:l,rounded:o,style:c}=e;return(0,s.jsx)("div",{className:"".concat(r().skeleton).concat(a?" ".concat(a):""),style:{width:t,height:l,...o?{borderRadius:n[o]}:{},...c}})}},78036:(e,a,t)=>{"use strict";t.d(a,{H:()=>n});var s=t(72203),l=t(38676),r=t(7620);function n(){let{user:e}=(0,s.A)(),a=(null==e?void 0:e.currency)||"USD",t=(0,r.useCallback)(e=>(0,l.vv)(e,a),[a]),n=(0,r.useCallback)(e=>(0,l.vv)(e,a,{compact:!0}),[a]),o=(0,r.useCallback)(e=>(0,l.vv)(e,a,{showSign:!0}),[a]),c=(0,r.useCallback)(e=>(0,l.vv)(e,a,{wholeNumber:!0}),[a]),i=(0,r.useMemo)(()=>(0,l.Qn)(a),[a]);return{currency:a,symbol:i,format:t,formatCompact:n,formatSigned:o,formatWhole:c}}},86383:(e,a,t)=>{"use strict";t.d(a,{W5:()=>x,bh:()=>c,lo:()=>i});var s=t(54568);t(7620);var l=t(69029),r=t.n(l);let n=()=>(0,s.jsxs)("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:[(0,s.jsx)("rect",{x:"3",y:"11",width:"18",height:"11",rx:"2"}),(0,s.jsx)("path",{d:"M7 11V7a5 5 0 0110 0v4"})]}),o=()=>(0,s.jsxs)("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:[(0,s.jsx)("rect",{x:"3",y:"11",width:"18",height:"11",rx:"2"}),(0,s.jsx)("path",{d:"M7 11V7a5 5 0 019.9-1"})]});function c(e){let{id:a,title:t,subtitle:l,icon:c,gradient:i,primaryStat:d,secondaryStat:m,isSelected:u=!1,isFading:x=!1,isAnimating:h=!1,isDataLoading:p=!1,onClick:g,animationDelay:y="0s",className:v=""}=e,b=[r().vaultCard,u?r().vaultCardSelected:"",x?r().vaultCardFading:"",v].filter(Boolean).join(" ");return(0,s.jsx)("button",{className:b,onClick:()=>{!h&&g&&g(a)},disabled:h,style:{"--card-gradient":i,"--delay":y},children:(0,s.jsxs)("div",{className:r().vaultCardInner,children:[(0,s.jsx)("div",{className:r().vaultGlow}),u&&(0,s.jsx)("div",{className:r().unlockPulse}),(0,s.jsx)("div",{className:r().vaultIcon,children:c}),(0,s.jsxs)("div",{className:r().vaultContent,children:[(0,s.jsx)("span",{className:r().vaultTitle,children:t}),(0,s.jsx)("span",{className:r().vaultSubtitle,children:l})]}),(0,s.jsxs)("div",{className:"".concat(r().vaultStats," ").concat(p?r().vaultStatsLoading:""),children:[(0,s.jsx)("span",{className:r().vaultPrimary,children:d}),(0,s.jsx)("span",{className:r().vaultSecondary,children:m})]}),(0,s.jsx)("div",{className:r().vaultArrow,children:(0,s.jsx)("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:(0,s.jsx)("path",{d:"M9 18l6-6-6-6"})})}),(0,s.jsx)("div",{className:"".concat(r().vaultLock," ").concat(u?r().vaultLockUnlocking:""),children:u?(0,s.jsx)(o,{}):(0,s.jsx)(n,{})})]})})}function i(e){let{children:a,isExiting:t=!1,className:l=""}=e,n=[r().vaultGrid,t?r().vaultGridExiting:"",l].filter(Boolean).join(" ");return(0,s.jsx)("div",{className:n,children:a})}t(77800);var d=t(64682),m=t(88362),u=t.n(m);function x(e){let{message:a="Something went wrong",onRetry:t,compact:l=!1,className:r}=e;return l?(0,s.jsxs)("div",{className:"".concat(u().compact).concat(r?" ".concat(r):""),children:[(0,s.jsx)("span",{className:u().compactMessage,children:a}),t&&(0,s.jsx)("button",{className:u().compactRetry,onClick:t,children:"Try Again"})]}):(0,s.jsxs)("div",{className:"".concat(u().wrapper).concat(r?" ".concat(r):""),children:[(0,s.jsx)("div",{className:u().iconWrap,children:(0,s.jsx)(d.A,{className:u().icon})}),(0,s.jsx)("p",{className:u().message,children:a}),t&&(0,s.jsx)("button",{className:u().retryBtn,onClick:t,children:"Try Again"})]})}},88362:e=>{e.exports={wrapper:"error-state_wrapper__39q7K",errorFadeIn:"error-state_errorFadeIn___Dx4h",iconWrap:"error-state_iconWrap__Vommc",icon:"error-state_icon__rFjBf",message:"error-state_message__OM45_",retryBtn:"error-state_retryBtn__ZJAqz",compact:"error-state_compact__Eb5io",compactMessage:"error-state_compactMessage__aHOwS",compactRetry:"error-state_compactRetry__55RMf"}},95691:(e,a,t)=>{"use strict";t.d(a,{X:()=>r});var s=t(54568);function l(e){let{size:a=14}=e;return(0,s.jsx)("svg",{width:a,height:a,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:{color:"var(--success)"},children:(0,s.jsx)("path",{d:"M13 2L4.094 12.688c-.34.418-.51.627-.506.801a.5.5 0 00.19.378C3.9 13.97 4.167 13.97 4.7 14H12l-1 8 8.907-10.688c.34-.418.51-.627.506-.801a.5.5 0 00-.19-.378C20.1 10.03 19.833 10.
103 19.3 10H12l1-8Z",fill:"currentColor"})})}function r(e){let{currentStreak:a,gracePeriodActive:t}=e;if(0===a&&!t)return null;let r=a>=100?3:a>=30?2:1;return(0,s.jsxs)("div",{className:"flex flex-col items-end gap-1",children:[(0,s.jsxs)("span",{className:"inline-flex items-center gap-1.5 rounded-full px-3 py-1 text-sm font-medium border",style:{backgroundColor:"var(--bg-card)",borderColor:"var(--border)",color:"var(--text)"},children:[(0,s.jsx)("span",{className:"inline-flex items-center",children:Array.from({length:r},(e,a)=>(0,s.jsx)(l,{size:14},a))}),(0,s.jsxs)("span",{children:[a," day streak"]})]}),t&&(0,s.jsx)("span",{className:"text-xs text-amber-400 font-medium",children:"Don't break your streak - log a transaction today!"})]})}t(7620)}},e=>{e.O(0,[4635,7592,9081,4288,1090,3558,5730,9878,2668,8526,2203,7099,587,6531,7358],()=>e(e.s=48003)),_N_E=e.O()}]);
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.