Build 555975stable
Module 530868
4,464 characters · in 1ab2d0b4471f679c.jsDependencies
Source Raw
function(t,e,r){r.d(e,{x:()=>y,j:()=>g});var i=r(64700),l=r(636537),s=r(228366),n=r(615405),u=r(927813),o=r(561573);r(321073);var a=r(17928);let d={};class c extends a.Ay.Store{static displayName="StorefrontPromotionStore";getFetchState(t){return d[t]?.state}getFetchedAt(t){let e=d[t];if(e?.state==="success"||e?.state==="error")return e.fetchedAt}getPromotionsForApplication(t){let e=d[t];return e?.state==="success"||e?.state==="loading"?e.promotions??null:null}}new c(s.h,{LOGOUT:function(){d={}},STOREFRONT_PROMOTIONS_FETCH_START:function(t){let{applicationIds:e}=t;for(let t of e){let e=d[t];d[t]={state:"loading",promotions:e?.state==="success"?[...e.promotions]:void 0}}},STOREFRONT_PROMOTIONS_FETCH_SUCCESS:function(t){let{applicationIds:e,promotions:r}=t,i=Date.now(),l={...d};for(let t of e)l[t]={state:"success",promotions:[],fetchedAt:i};for(let t of r){let e=t.applicationId;l[e]?.state==="success"&&l[e].promotions.push(t)}d=l},STOREFRONT_PROMOTIONS_FETCH_FAIL:function(t){let{applicationIds:e}=t,r=Date.now();for(let t of e)d[t]={state:"error",fetchedAt:r}}});var p=r(723090);let S=(0,r(945810).mj)({name:"2026-04-storefront-pricing",kind:"user",defaultConfig:{enabled:!1,thresholdMs:5*u.A.Millis.MINUTE},variations:{0:{enabled:!1,thresholdMs:5*u.A.Millis.MINUTE},1:{enabled:!0,thresholdMs:+u.A.Millis.MINUTE},2:{enabled:!0,thresholdMs:2*u.A.Millis.MINUTE},3:{enabled:!0,thresholdMs:5*u.A.Millis.MINUTE},4:{enabled:!0,thresholdMs:10*u.A.Millis.MINUTE}}});var I=r(315069);class h extends I.A{id;applicationId;displayName;rewardType;rewardConfig;skuIds;appliesToAllSkus;startsAt;endsAt;static createFromServer(t){var e;return new h({id:t.id,applicationId:t.application_id,displayName:t.display_name??null,rewardType:t.reward_type,rewardConfig:null!=t.reward_config?null==(e=t.reward_config)?null:{discount:null!=e.discount?{id:e.discount.id,type:e.discount.type,amount:e.discount.amount}:null}:null,skuIds:function(t){if(null==t)return null;let e={};for(let[r,i]of Object.entries(t))e[r]={priceTiers:i.price_tiers};return e}(t.sku_ids),appliesToAllSkus:t.applies_to_all_skus,startsAt:null!=t.starts_at?new Date(t.starts_at):null,endsAt:null!=t.ends_at?new Date(t.ends_at):null})}constructor(t){super(),this.id=t.id,this.applicationId=t.applicationId,this.displayName=t.displayName,this.rewardType=t.rewardType,this.rewardConfig=t.rewardConfig,this.skuIds=t.skuIds,this.appliesToAllSkus=t.appliesToAllSkus,this.startsAt=t.startsAt,this.endsAt=t.endsAt}}var _=r(652215);u.A.Millis.HOUR;let f=10*u.A.Millis.MINUTE;function A(t,e){return t?.type==="error"?f:function(t){let{location:e}=t;return S.getConfig({location:e}).thresholdMs}({location:e})}async function E(t){let{applicationId:e,location:r}=t;await T({type:"application",applicationId:e},r)}async function m(t){let{skuIds:e,location:r}=t;await T({type:"skus",skuIds:e},r)}async function T(t,e){let{shouldFetch:r,filteredSkuIds:i,applicationId:u}=function(t,e){if(!function(t){let{location:e}=t;return S.getConfig({location:e}).enabled}({location:e}))return{shouldFetch:!1,filteredSkuIds:[],applicationId:null};if("application"===t.type){let r=o.A.getFetchStateForApplicationId(t.applicationId),i=A(r,e);return null!=r&&("loading"===r.type||r.fetchedAt>Date.now()-i)?{shouldFetch:!1,filteredSkuIds:[],applicationId:t.applicationId}:{shouldFetch:!0,filteredSkuIds:[],applicationId:t.applicationId}}{let r=t.skuIds.filter(t=>{let r=o.A.getFetchStateForSkuId(t);if(null==r)return!0;let i=A(r,e);return"loading"!==r.type&&r.fetchedAt<Date.now()-i}).sort((t,e)=>{let r=o.A.getFetchStateForSkuId(t),i=o.A.getFetchStateForSkuId(e);return null==r&&null!=i?-1:+(null!=r&&null==i)});return 0===r.length?{shouldFetch:!1,filteredSkuIds:[],applicationId:null}:{shouldFetch:!0,filteredSkuIds:r.slice(0,50),applicationId:null}}}(t,e);if(!r)return;let a=null!=u?{type:"application",applicationId:u}:{type:"skus",skuIds:i};try{s.h.dispatch({type:"SKUS_PRICING_FETCH_START",priceId:a});let t=(await l.Bo.get({url:_.Rsh.STOREFRONT_PRICES,query:{...null!=u?{application_id:u}:{sku_ids:i},country_code:n.A.ipCountryCode??void 0},rejectWithError:!0})).body;s.h.dispatch({type:"SKUS_PRICING_FETCH_SUCCESS",priceId:a,data:(0,p.Oj)(t)})}catch{s.h.dispatch({type:"SKUS_PRICING_FETCH_FAIL",priceId:a})}}function y(t){let{applicationId:e,location:r}=t;i.useEffect(()=>{null!=e&&E({applicationId:e,location:r})},[e,r])}function g(t){let{skuIds:e,location:r}=t;i.useEffect(()=>{0!==e.length&&m({skuIds:e,location:r})},[e,r])}}