1import{d as R,m as _,o as j,y as z}from"./date-DaA_GYiE.js";import{ay as T,aN as G}from"./graphql-BW49-ESX.js";import{s as N}from"./startOfDay-B8BzCanN.js";import{a as V}from"./addBusinessDays-DwRurj7C.js";import{i as J}from"./isFuture-C5y-XyAx.js";import{s as K}from"./setDate-ddiw6ZcE.js";import{i as A}from"./isBefore-DW9nW1Zb.js";import{a as Q}from"./addMonths-DJTMKyDh.js";const de=()=>Array.from(Array(28).keys()).map(e=>{const t=e+1;if(t>3&&t<21)return{value:t,label:`${t}th`};switch(t%10){case 1:return{value:t,label:`${t}st`};case 2:return{value:t,label:`${t}nd`};case 3:return{value:t,label:`${t}rd`};default:return{value:t,label:`${t}th`}}}),U=({validFrom:e})=>!!e&&j(e),X=({validTo:e})=>e&&_(e),Z=e=>new Date(e)<new Date(z(2)),ee=({validFrom:e})=>!!e&&Z(e),h=e=>e.reason==="SSD_PAYMENT",te=e=>e.isVariablePaymentAmount,S=e=>e.isPaymentHoliday,ae=e=>(e?.totalDebtAmount||0)>0,De=e=>{const t=[],s=[],n=[],o=[],y=[];let l=!1,m=!1,u=!1,d=!1;e?.forEach(p=>{const a=p?.node;a&&(X(a)?t.push(a):U(a)?(ee(a)&&o.push(a),!h(a)&&!S(a)&&n.push(a),S(a)&&y.push(a)):(te(a)&&(l=!0),h(a)&&(m=!0),S(a)?(y.push(a),d=!0):s.push(a)),ae(a)&&(u=!0))});const D=n?.[0]?.scheduleType==T.DirectDebit&&s?.[0]?.scheduleType!==T.DirectDebit;return{pastSchedules:t,activeSchedules:s,futureSchedules:n,nearFutureSchedules:o,hasActiveVariableSchedule:l,hasActiveSSDSchedule:m,hasPaymentAdequacySchedule:u,hasActivePaymentHoliday:d,holidaySchedules:y,brandNewDirectDebit:D}},ne=(e,t)=>{const s=e&&e?.amount!==t?.paymentAmount&&t?.paymentAmount===100&&t?.paymentDay===1,n=s?e?.amount:t?.paymentAmount,o=s?new Date(e?.date??"").getDate():t?.paymentDay;return{paymentAmount:n??0,paymentDay:o??1,isOnPaymentPlan:s}},he=({activeSchedules:e,futureSchedules:t,holidaySchedules:s,nearFutureSchedules:n,hasActivePaymentHoliday:o,pastSchedules:y,upcomingPaymentForecast:l})=>{const m=e?.[0]||{},u=y?.[0]||{},d=t?.[1]||{},D=t?.[0]||{},p=s?.[0]||{},{paymentDay:a,paymentAmount:F,validFrom:B}=d,{paymentDay:c,paymentAmount:f,validFrom:O}=D,{paymentDay:$,validTo:g,validFrom:E}=m,q=[...e,...n].find(i=>i.reason===G.GeneralAccountPayment),{paymentDay:r,paymentAmount:b,isOnPaymentPlan:P}=ne(l,q),x=!o||P?b:u?.paymentAmount,M=!o||P?r:u?.paymentDay,W=r!==c&&c!==void 0?c:M,Y=!!e.find(i=>h(i)),k=!!n.find(i=>h(i)),C=Y||k,H=!!c&&!!f,I=!!a&&!!F,L=(o||H)&&!C,v=r?se({currentPaymentDay:r,validFrom:new Date}):void 0;return{currentSchedule:m,pastSchedule:u,latestFutureSchedule:D,holiday:p,nonPastGeneralAccountPaymentDay:r,nonPastGeneralAccountPaymentAmount:b,latestFuturePaymentDay:c,latestFuturePaymentAmount:f,latestDDValidFrom:O,nextFuturePaymentDay:a,nextFuturePaymentAmount:F,nextDDValidFrom:B,hasTwoFuturePayments:I,currentPaymentDay:$,currentValidFrom:E,currentValidTo:g,displayAmount:x===0?f:x,displayDay:W,showNotification:L,isOnPaymentPlan:P,isNextPaymentIn10BusinessDays:v,nextPaymentDate:r?w(v?N(V(new Date,11)):new Date,r):void 0}},w=(e,t)=>{if(!e||!t)return;const s=J(new Date(e))?new Date(e):new Date(Date.now());let n=K(s,t);return A(n,s)&&(n=Q(n,1)),n},pe=({currentPaymentDay:e,validFrom:t})=>{const s=new Date(Date.now()),n=R(s,{days:10}),o=w(t,e);return o?A(o,n):!1},se=({currentPaymentDay:e,validFrom:t})=>{const n=N(V(new Date,11)),o=w(t,e);return o?A(o,n):!1};export{he as a,w as b,de as d,De as g,pe as h};
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.