1import{r as e,j as t}from"./vendor-react-C9yDzYQD.js";import{b as a,u as r,r as s,o as n,g as o,a as i,V as l,c as u,d as c,i as d}from"./VideoPosterOnly-CNeQsWm2.js";import{a as m}from"./runtime-utils-GN4cODRt.js";import{b as f}from"./useUserSettings-COPNty3J.js";import{a as p}from"./startup-platform-OWIpYyjW.js";import{u as v}from"./useDocumentVisibility-D-qOhV7W.js";import{g as y}from"./feedMotion-BhgUIjw7.js";import{l as g,b,s as h,f as w,h as j}from"./image-utils-AdRSPECl.js";import{V as S}from"./video-DibMJbQh.js";import{L as E}from"./loader-circle-CWK_zhHB.js";const x=()=>p()&&"idle"!==y().phase,N=e=>(window.addEventListener("echo:feed-motion",e),()=>window.removeEventListener("echo:feed-motion",e)),k=()=>!1,R=e=>{j(e)};function T({src:y,fallbackSrc:j,posterSrc:T,posterFallbackSrc:C,alt:V="Video preview",className:B,mediaClassName:L,mediaStyle:F,playMode:M="never",priority:P=!1,dominantColor:D,preferVideoFrame:$=!1,showVideoBadge:_=!0,showOverlay:z=!0,onReady:O,onDimensions:U}){const{settings:W}=f(),A=p(),H=e.useSyncExternalStore(N,x,k),I=W.disable_video_autoplay?"never":M,G=e.useRef(null),K=e.useRef(null),X=e.useRef(null),q=e.useRef(!1),J=e.useCallback(e=>{const t=K.current;t&&t!==e&&R(t),K.current=e},[]),Q=e.useRef(!1),Y=y||j||"",[Z,ee]=e.useState(null),te=(null==Z?void 0:Z.key)===Y?Z.src:a(Y),ae=e.useRef(0);e.useEffect(()=>{ae.current=0},[Y]);const[re,se]=e.useState(!1),[ne,oe]=e.useState(!1),[ie,le]=e.useState(0),[ue,ce]=e.useState(!1),[de,me]=e.useState(!1),[fe,pe]=e.useState(!1),[ve,ye]=e.useState("always"===I),[ge,be]=e.useState("always"===I),[he,we]=e.useState(!1),[je,Se]=e.useState(!1),[Ee,xe]=e.useState("always"===I?1:0),[Ne,ke]=e.useState(0),Re=v(),[Te,Ce]=e.useState(null),Ve=e.useMemo(()=>g(b(T,"medium"),T,b(C,"medium"),C),[C,T]),{source:Be,retryKey:Le,exhausted:Fe,handleError:Me,markReady:Pe,retry:De}=r(y,j),$e=Ve.join("\0");e.useEffect(()=>{se(!1),oe(0===Ve.length),le(0),Q.current=!1},[Ve.length,$e]),e.useEffect(()=>{ce(!1),me(!1),pe(!1),Q.current=!1},[Be,Le]),e.useEffect(()=>{ye("always"===I),be("always"===I),xe("always"===I?1:0),ke(0),q.current="always"===I},[I]),e.useEffect(()=>{const e=s({enabled:!1,visible:!1,visibilityRatio:0,distanceToViewportCenter:Number.MAX_SAFE_INTEGER,kind:"autoplay"},we);return X.current=e,()=>{X.current=null,e.release()}},[]),e.useEffect(()=>{var e;null==(e=X.current)||e.update({enabled:Boolean(Be&&Re&&ge&&!Fe&&"never"!==I),visible:ve,visibilityRatio:Ee,distanceToViewportCenter:Ne,interacting:je,preferred:P,kind:"autoplay"})},[Be,Ne,Re,I,je,ve,P,ge,Fe,Ee]),e.useEffect(()=>{if("never"!==I&&G.current)return n(G.current,(e,t)=>{const a=e&&!q.current;q.current=e,ye(e),xe(t.visibilityRatio),ke(t.distanceToViewportCenter),e?(be(!0),a&&Fe&&De()):(K.current&&w(K.current),pe(!1),A&&be(!1))})},[I,A,De,Fe]),e.useEffect(()=>{K.current&&"never"!==I&&ge&&he?!Re||H||"always"!==I&&!ve?(w(K.current),pe(!1)):h(K.current).then(e=>{e||pe(!1)}):pe(!1)},[Be,Le,Te,Re,ve,I,he,ge,H]),e.useEffect(()=>{Re||pe(!1),A&&!Re&&ce(!1)},[Re,A]),e.useEffect(()=>{he||(ce(!1),me(!1),pe(!1))},[he]),e.useEffect(()=>{if(!Fe)return;const e=()=>De();return window.addEventListener("online",e),()=>window.removeEventListener("online",e)},[De,Fe]),e.useEffect(()=>()=>{const e=K.current;e&&R(e)},[]),e.useEffect(()=>{(ue||Ve.length>0&&re||0===Ve.length&&(Fe||"never"===I))&&!Q.current&&(Q.current=!0,null==O||O())},[O,I,Ve.length,re,Fe,ue]);const _e=e.useMemo(()=>({background:`linear-gradient(145deg, ${D||"#171717"} 0%, rgba(10,10,10,0.96) 100%)`}),[D]),ze=($||ne?te:void 0)||Ve[ie]||te||null,Oe=d(Be),Ue=e.useMemo(()=>o(Be),[Be]),We=Boolean(te)||Boolean(ze)&&!ne,Ae=(Re||!A)&&he&&(!H||ue)&&Boolean(Be)&&"never"!==I&&ge&&("always"===I||ve)&&!Fe,He=Ae&&!ue&&!We,Ie=Ae&&ue&&de,Ge=!We&&!Ie&&!He,Ke=!A||"never"!==I||Boolean(O),Xe=Re&&!H&&Ae&&("always"===I||ve);return i(K,Be,Ae&&Oe,Xe,Le),"never"===I?t.jsx(l,{posterSrc:T,posterFallbackSrc:C,videoSrc:y,videoFallbackSrc:j,alt:V,className:B,mediaClassName:L,mediaStyle:F,loading:P?"eager":"lazy",showBadge:_,preferVideoFrame:$,onReady:O,onDimensions:U}):t.jsxs("div",{ref:G,className:m("relative overflow-hidden bg-black",B),style:Ge?_e:void 0,"data-vi
1deo-playback-granted":he?"true":"false",onPointerDown:()=>Se(!0),onPointerUp:()=>Se(!1),onPointerCancel:()=>Se(!1),onFocusCapture:()=>Se(!0),onBlurCapture:()=>Se(!1),"data-video-preview-state":Fe?"error":Ie?H?"paused":fe?"playing":"buffering":We?"poster":He?"loading":"fallback",children:[We&&t.jsx("img",{src:ze||void 0,alt:V,className:m("absolute inset-0 h-full w-full object-cover",Ie?"opacity-0":"opacity-100",L),style:F,onLoad:e=>{Ke&&se(!0),null==U||U(e.currentTarget.naturalWidth,e.currentTarget.naturalHeight,"poster")},onError:()=>{se(!1),ie+1<Ve.length?le(e=>e+1):oe(!0)},loading:P?"eager":"lazy",decoding:"async"}),Ae&&t.jsx("video",{ref:J,crossOrigin:Te===Be?void 0:"anonymous",src:Ue,poster:ze||void 0,"aria-label":V,className:m("absolute inset-0 h-full w-full object-cover",Ie?"opacity-100":"opacity-0",L),style:F,muted:!0,loop:!0,playsInline:!0,preload:P?"auto":"always"===I?"metadata":"none",onLoadedMetadata:e=>null==U?void 0:U(e.currentTarget.videoWidth,e.currentTarget.videoHeight),onLoadedData:()=>{var e;ce(!0),Pe(),Xe&&(null==(e=K.current)||e.play().catch(()=>pe(!1)))},onCanPlay:e=>{Pe(),Xe&&e.currentTarget.play().catch(()=>pe(!1))},onTimeUpdate:e=>(e=>{if(!$&&!ne&&Ve.length>0)return;if(te||ae.current>=8||e.seeking||e.currentTime<.5)return;ae.current+=1;const t=u(e);t&&(c(Y,t),ee({key:Y,src:t}))})(e.currentTarget),onPlaying:()=>{pe(!0),me(!0)},onPause:()=>pe(!1),onWaiting:()=>pe(!1),onEnded:()=>pe(!1),onError:()=>{ce(!1),pe(!1),Be&&Te!==Be?Ce(Be):Me()}},`${Be||""}:${Le}:${Te===Be}`),He&&t.jsxs("div",{className:"pointer-events-none absolute inset-0",children:[t.jsx("div",{className:"absolute inset-0 bg-gradient-to-br from-white/10 via-trans
1parent to-black/30"}),t.jsx("div",{className:"absolute inset-0 animate-shimmer bg-gradient-to-r from-transparent via-white/10 to-transparent motion-reduce:animate-none",style:{backgroundSize:"200% 100%"}})]}),Ge&&t.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:t.jsx("div",{className:"flex flex-col items-center gap-3 text-white/88",children:t.jsx("div",{className:"flex h-12 w-12 items-center justify-center rounded-full border border-white/20 bg-black/25",children:Fe||!he||H?t.jsx(S,{className:"h-5 w-5"}):t.jsx(E,{className:"h-5 w-5 animate-spin"})})})}),z&&t.jsx("div",{className:"pointer-events-none absolute inset-0 bg-gradient-to-t from-black/28 via-transparent to-white/6"}),_&&t.jsx("div",{className:"absolute right-3 top-3 rounded-full bg-black/30 p-2 text-white/90",children:t.jsx(S,{className:"h-3.5 w-3.5"})})]})}export{T as VideoPreviewPlayable};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.