Build 573682stable
Module 480335
6,100 characters · in no known chunkDependencies
Source Raw
function(e,t,n){"use strict";n.d(t,{A:()=>b,p:()=>R});var i=n(627968),r=n(64700),s=n(503698),a=n.n(s),o=n(631903),l=n(17928),u=n(775602),d=n(218394),c=n(203632),_=n(855915),h=n(940622),f=n(881106),E=n(284009),p=n.n(E),m=n(964486);let g=1e3/24,A=function(e){let{minInterval:t=g,allowableMinInterval:n,droppedFramesCallbackThreshold:i,droppedFramesCallback:s,droppedFramesResetTime:a=3e3}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},o=r.useRef(t),l=r.useRef(0),u=r.useRef(void 0),d=r.useRef(void 0),c=r.useRef(!0),_=r.useRef(0),h=r.useRef(void 0),f=r.useCallback(()=>{_.current=0,null!=h.current&&(clearTimeout(h.current),h.current=void 0)},[]),E=r.useCallback(()=>{c.current=!1,cancelAnimationFrame(l.current),clearTimeout(h.current)},[]),A=r.useCallback(t=>{if(!c.current)return;null==u.current&&(u.current=t),null==d.current&&(d.current=t);let r=t-d.current;t-u.current>1.5*Math.min(n??120,o.current)&&(_.current+=1,null!=h.current&&clearTimeout(h.current),h.current=setTimeout(f,a),null!=i&&_.current>i&&(p()(null!=s,"useClock - If you set a dropped frames threshold, you must provide a droppedFramesCallback to do something when that threshold is hit"),s()&&(_.current=0))),u.current=t,r>=o.current-3&&(d.current=t,e(r)),l.current=requestAnimationFrame(A)},[n,f,a,i,s,e]),I=r.useCallback(()=>{c.current=!0,d.current=void 0,cancelAnimationFrame(l.current),l.current=requestAnimationFrame(A)},[A]);return r.useEffect(()=>{o.current=t},[t]),(0,m.Ay)(()=>(l.current=requestAnimationFrame(A),()=>E())),{stop:E,reset:I,ticking:c}};var I=n(942426),T=n(735438);function S(e){if(null==e)return e;let t=(0,T.cloneDeep)(e),n=Math.floor(Math.random()*(t.effects.reduce((e,t)=>{let n=t.randomizedSources?.length??0;return n>0&&(e=0===e?n:Math.min(e,n)),e},0)-1-0+1)+0);return t.effects=t.effects.map(e=>(null!=e.randomizedSources&&e.randomizedSources.length>0&&(e.src=e.randomizedSources[n].src),e)),t}n(323874),n(14289),n(35956);var N=n(676279),C=n(38405),y=n(839827);let v=e=>{let{layerConfig:t,animationType:n,ticking:s,time:a,hasPlayedThrough:l,setHasPlayedThrough:u,maxLoops:d,loopEnd:c,bannerAdjustment:_,imageData:h}=e,E=!0,p=0,[m,g]=r.useState("reset"),A=r.useRef(h?.src??t.src),[I,T]=r.useState(h?.src??t.src),S=r.useRef(null),v=(0,N.gm)()&&null!=t.loopDelay&&t.loopDelay>0&&h?.src!=null;function R(e){(0,N.gm)()&&e!==m&&g(e)}if(r.useEffect(()=>{if(!v||"layer"===m)return;let e=new AbortController;return(async()=>{try{if(null==S.current){let t=await fetch(h.src,{signal:e.signal}),n=await t.blob();if(e.signal.aborted)return;S.current=n}A.current!==h?.src&&URL.revokeObjectURL(A.current),A.current=URL.createObjectURL(S.current),T(()=>A.current)}catch(e){if("AbortError"===e.name)return null;C.A.captureException(e)}})(),()=>{e.abort()}},[m,v,T,h?.src]),r.useEffect(()=>()=>{A.current!==h?.src&&URL.revokeObjectURL(A.current)},[]),s||(E=!1),a<t.start&&(E=!1),!t.loop&&a>t.duration+t.start&&(E=!1),n===o.l.ANIMATION_TYPE_PERSISTENT&&!l&&null!=d&&a>=c&&u(!0),t.loop&&void 0!==t.loopDelay&&t.loopDelay>0){let e=t.duration+t.loopDelay;p=Math.floor((a-t.start)/e),a-t.start-p*e>t.duration&&(n===o.l.ANIMATION_TYPE_INTERMITTENT&&!l&&null!=d&&p>=d&&u(!0),E=!1)}return E?(R("layer"),(0,i.jsx)("img",{src:I,className:y.QZ,style:{top:(t.position?.y??0)-_,left:t.position?.x??0},alt:"","aria-hidden":!0})):(R("reset"),(0,i.jsx)("img",{src:f.Ut,alt:"","aria-hidden":!0}))},R=e=>{let{bannerAdjustment:t=0,maxLoops:n,resetOnHover:s=!1,isHovering:l=!1,useOpacityOnHover:u=!0,autoPlay:d=!0,restartMethod:_,profileEffect:h,delayIntro:f=!0,restartKey:E,layerData:p}=e,m=r.useRef(null),g=r.useMemo(()=>h.effects.sort((e,t)=>(e.zIndex??0)-(t.zIndex??0)),[h]),{accessibilityLabel:I}=h,{firstLoop:T,loopEnd:S}=r.useMemo(()=>{let e=0,t=1/0;return g.forEach(n=>{let i=n.start+n.duration;i>e&&(e=i),n.loop&&n.start<t&&(t=n.start)}),{firstLoop:t,loopEnd:e}},[g]),N=f?500:.1,[C,R]=r.useState(-N),{stop:O,reset:b,ticking:L}=A(r.useCallback(e=>{R(t=>t+e)},[])),D=r.useRef(N);r.useEffect(()=>{D.current=N}),r.useEffect(()=>{R(-D.current)},[h]);let[P,w]=r.useState(!1);return r.useEffect(()=>{null!=E&&(R(-D.current),w(!1),L.current||b())},[E,b,L]),r.useEffect(()=>{!0===d||l||(O(),R(0)),!l&&P&&L.current&&(O(),R(0)),s&&l&&!L.current&&(b(),h.animationType===o.l.ANIMATION_TYPE_PERSISTENT?R(_===c.HL.FromStart?0:T):R(0))},[l,P,T,s,O,b,L,h.animationType,d,_]),(0,i.jsx)("div",{ref:m,className:a()(y.yC,{[y.yo]:l&&u}),"aria-label":I,role:"img",children:(0,i.jsx)("div",{className:y.vW,children:g.map((e,r)=>{if(!L.current&&h.animationType===o.l.ANIMATION_TYPE_PERSISTENT&&null!=h.staticFrameSrc&&0===r&&!0===d){let{staticFrameSrc:n}=h;return(0,i.jsx)("img",{className:y.QZ,style:{top:e.position?.y??0-t,left:e.position?.x??0},src:n,alt:"","aria-hidden":!0},e.src+r)}return(0,i.jsx)(v,{layerConfig:e,animationType:h.animationType,ticking:L.current,time:C,hasPlayedThrough:P,setHasPlayedThrough:w,maxLoops:n,loopEnd:S,bannerAdjustment:t,imageData:p?.[e.src]},e.src+r)})})})};function O(e){let{profileEffect:t,useThumbnail:n,bannerAdjustment:r=0,isHovering:s=!1,useOpacityOnHover:o=!0}=e,{reducedMotionSrc:l,thumbnailPreviewSrc:u,accessibilityLabel:d}=t;return(0,i.jsx)("div",{className:a()(y.yC,{[y.yo]:s&&o}),"aria-label":d,role:"img",children:(0,i.jsx)("div",{className:y.vW,children:(0,i.jsx)("img",{src:n&&!s?u:l,className:y.QZ,style:{top:0-r},alt:"","aria-hidden":!0})})})}let b=function(e){let t=(0,d.j)(),n=(0,l.bG)([u.Ay],()=>u.Ay.useReducedMotion),s=(0,I.A)(e.skuId),a=(0,h.C)(s),c=function(e){let[t,n]=r.useState(e),[i,s]=r.useState(S(e));return(0,T.isEqual)(t,e)||(n(e),s(S(e))),i}(s),f=a??c,{autoPlay:E=!0,isHovering:p}=e,m=!!(!t&&e.shopPreview||!t&&s?.animationType===o.l.ANIMATION_TYPE_PERSISTENT||n||!1===E&&!1===p),{loaded:g,layerData:A}=(0,_.A)({skuId:s?.skuId,layers:m?void 0:s?.effects});return null!=s&&null!=f&&(t||e.shopPreview||s.animationType!==o.l.ANIMATION_TYPE_INTERMITTENT)?m?(0,i.jsx)(O,{useThumbnail:e.useThumbnail,profileEffect:f,bannerAdjustment:e.bannerAdjustment,isHovering:e.isHovering,useOpacityOnHover:e.useOpacityOnHover}):g?(0,i.jsx)(R,{profileEffect:f,layerData:A,...e}):null:null}}