Module 177366

2,072 characters · in d9f1f00ad4e2c99c.js
Dependencies
Required by (2)
Lazily required by (0)none
Lazily requires (0)none
Source Raw
function(t,e,i){i.d(e,{XU:()=>E,Yr:()=>S,k0:()=>C});var l=i(64700),n=i(873263),r=i(17928),a=i(775602),u=i(793574),s=i(688810),o=i(590180),d=i(870216),c=i(298072),h=i(238184),p=i(572595),m=i(159439),f=i(57020),g=i(652215);let A="#itemSkuId=",v=RegExp(`^${A}(\\d+)$`),x=[g.BVt.COLLECTIBLES_SHOP],S=t=>{let e=(0,n.zy)();l.useEffect(()=>{if(null!=t&&x.includes(e.pathname))return()=>{window.location.hash.startsWith(A)&&window.location.replace("#")}},[t,e.pathname])},E=t=>{let e=(0,m.U)(),i=l.useRef(null),a=(0,n.zy)(),A=a.pathname===g.BVt.COLLECTIBLES_SHOP?u.A.HOME_PAGE_SHOP_TAB:u.A.COLLECTIBLES_SHOP,{analyticsLocations:x}=(0,s.Ay)(A),S=(0,h.A)();l.useEffect(()=>{let t=v.exec(a.hash);null!=t?i.current=t[1]:i.current=null},[S,a.hash]);let E=(0,r.bG)([d.A],()=>d.A.initialProductSkuId);l.useEffect(()=>{if(e)return;let l=null;if(null!=E?l=E:null!=i.current&&(l=i.current),null!=l){let e=setTimeout(()=>{(t=>{let{productSkuId:e,analyticsLocations:i,analyticsSource:l,tab:n,sessionId:r}=t,a=o.A.getProduct(e),u=o.A.getCategoryForProduct(e);if(null!=a&&null!=u){let t=a,s=(0,f.A)({product:a}),d=document.getElementById(`shop-item-${t.skuId}`);if(d!==document.activeElement&&d?.focus(),null!=a.variantGroupStoreListingId){let i=o.A.getProductByStoreListingId(a.variantGroupStoreListingId);if(null!=i){t=i;let l=i.variants?.findIndex(t=>t.skuId===e);null!=l&&l>-1&&(0,c.n)(i,l)}}(0,p.t)({product:t,category:u,analyticsSource:l,analyticsLocations:i,tab:n,shouldCheckoutWithOrbs:s,sessionId:r})}})({productSkuId:l,analyticsLocations:x,analyticsSource:A,tab:S,sessionId:t})},250);return()=>clearTimeout(e)}},[x,A,e,E,S,t])},C=t=>{let e=l.useRef({}),i=(0,r.bG)([a.A],()=>a.A.useReducedMotion),n=(0,r.bG)([o.A],()=>o.A.isFetchingCategories),[u,s]=l.useState(null),d=l.useCallback((t,i)=>{e.current[t]=i},[]),c=l.useCallback(l=>{n?s(l):setTimeout(()=>{let n=e.current[l];null!=n&&t?.scrollIntoViewNode({node:n,padding:48,animate:!i,shouldScrollToStart:!0})},100)},[t,i,n,s]);return l.useEffect(()=>{n||null==u||(c(u),s(null))},[n,c,u,s]),{setCategoryRef:d,handleScrollToCategory:c}}}