Module 35587

1,945 characters · in no known chunk
Dependencies
Lazily required by (0)none
Lazily requires (0)none
Source Raw
function(e,t,n){"use strict";n.d(t,{Eu:()=>E,IO:()=>f,T1:()=>_,Wi:()=>p,y7:()=>h});var i=n(64700),r=n(17928),s=n(228366),a=n(287809),o=n(428262),l=n(264779),u=n(962644),d=n(374200),c=n(202541);function _(){let{includeClaimedPromotions:e=!1}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=(0,r.yK)([d.A],()=>d.A.outboundPromotions),n=(0,r.bG)([d.A],()=>d.A.consumedInboundPromotionId),s=(0,r.bG)([d.A],()=>d.A.claimedOutboundPromotionCodes);return i.useMemo(()=>{let i=e?new Set(s.map(e=>{let{promotion:t}=e;return t.id})):null;return t.filter(e=>!(e.id===n||!(0,l.OP)(e)||(0,l.dG)(e))&&(i?.has(e.id),!0))},[t,n,s,e])}function h(){let e=(0,r.bG)([d.A],()=>d.A.lastFetchedActivePromotions),t=(0,r.bG)([a.default],()=>a.default.getCurrentUser()),n=o.Ay.isPremiumExactly(t,c.PremiumTypes.TIER_2),h=!o.Ay.isPremium(t)||n,f=(0,r.bG)([d.A],()=>d.A.claimedOutboundPromotionCodes),E=(0,r.bG)([d.A],()=>d.A.claimedOutboundPromotionCodesLoaded);i.useEffect(()=>{null!=e&&s.h.wait(()=>u.Ay.markOutboundPromotionsSeen())},[e]),i.useEffect(()=>{s.h.wait(()=>{h&&null==e&&u.Ay.fetchActivePromotions()})},[e,h]),i.useEffect(()=>{s.h.wait(()=>{u.Ay.fetchClaimedOutboundPromotionCodes()})},[]);let p=i.useMemo(()=>(0,l.eN)(f),[f]),m=_({includeClaimedPromotions:!0}),g=i.useMemo(()=>{let e=new Set(m.map(e=>{let{id:t}=e;return t}));return f.filter(t=>{let{promotion:n}=t;return!e.has(n.id)&&!1===(0,l.HB)({promotionType:n.promotionType})&&!(0,l.dG)(n)&&(0,l.OP)(n)})},[m,f]);return{promotionsLoaded:E&&(!h||null!=e),activeOutboundPromotions:m,claimedEndedOutboundPromotions:g,claimedOutboundPromotionCodeMap:p}}function f(){let e=(0,r.bG)([d.A],()=>d.A.lastSeenOutboundPromotionStartDate),t=_();return i.useMemo(()=>null==e?t:t.filter(t=>{let{startDate:n}=t;return new Date(n)>new Date(e)}),[t,e]).filter(e=>(0,l.OP)(e))}function E(){return{promotion:(0,r.bG)([d.A],()=>d.A.bogoPromotion)}}function p(e){return(0,r.bG)([d.A],()=>d.A.hasPromotion(e))}}