Build 584177stable
Module 821925
2,223 characters · in ae8fb12054309a89.jsDependencies
Source Raw
function(t,e,l){l.d(e,{A:()=>s}),l(321073);var r=l(17928),o=l(228366);let n={},c={};class u extends r.Ay.Store{static displayName="StorefrontProductStore";getFetchState(t){return null!=t?n[t]?.state:void 0}getFetchStateForSku(t){return null!=t?c[t]?.state:void 0}getFetchedAt(t){return null!=t?n[t]?.fetchedAt:void 0}getFetchedAtForSku(t){return null!=t?c[t]?.fetchedAt:void 0}getFetchError(t){return null!=t?n[t]?.fetchError:void 0}getFetchErrorForSku(t){return null!=t?c[t]?.fetchError:void 0}getProduct(t){let e=null!=t?n[t]:null;return null==e||e?.state==="error"||null==e.product?null:e.product}getProductsForSku(t){return null!=t?c[t]?.products:void 0}}let s=new u(o.h,{STOREFRONT_PRODUCTS_WITH_SKUS_FETCH:function(t){let{productIds:e}=t;e.forEach(t=>{n[t]={state:"loading",product:n[t]?.product}})},STOREFRONT_PRODUCTS_WITH_SKUS_FETCH_SUCCESS:function(t){let{productIds:e,products:l}=t,r=Date.now(),o=new Set;l.forEach(t=>{o.add(t.id),n[t.id]={state:"success",product:t,fetchedAt:r}}),e.forEach(t=>{o.has(t)||delete n[t]})},STOREFRONT_PRODUCTS_WITH_SKUS_FETCH_FAILURE:function(t){let{productIds:e,apiError:l}=t,r=Date.now();e.forEach(t=>{n[t]={state:"error",fetchedAt:r,fetchError:l}})},STOREFRONT_PRODUCTS_BY_SKU_IDS_FETCH:function(t){let{skuIds:e}=t;e.forEach(t=>{c[t]={state:"loading",products:c[t]?.products}})},STOREFRONT_PRODUCTS_BY_SKU_IDS_FETCH_SUCCESS:function(t){let{skuIds:e,products:l}=t,r=Date.now(),o=l.reduce((t,e)=>(e.skuIds.forEach(l=>{null==t[l]?t[l]=[e]:t[l].push(e)}),t),{});e.forEach(t=>{null==o[t]?delete c[t]:c[t]={state:"success",products:o[t],fetchedAt:r}}),l.forEach(t=>{n[t.id]={state:"success",product:t,fetchedAt:r}})},STOREFRONT_PRODUCTS_BY_SKU_IDS_FETCH_FAILURE:function(t){let{skuIds:e,apiError:l}=t,r=Date.now();e.forEach(t=>{c[t]={state:"error",fetchedAt:r,fetchError:l}})},STOREFRONT_COLLECTIONS_WITH_PRODUCTS_FETCH_SUCCESS:function(t){let{collections:e}=t,l=Date.now();e.forEach(t=>{t.products.forEach(t=>{n[t.id]={state:"success",product:t,fetchedAt:l}})})},STOREFRONT_COLLECTIONS_FOR_APPLICATION_FETCH_SUCCESS:function(t){let{collections:e}=t,l=Date.now();e.forEach(t=>{t.products.forEach(t=>{n[t.id]={state:"success",product:t,fetchedAt:l}})})},LOGOUT:function(t){n={},c={}}})}