@xhub-reel/embed 0.2.0 → 0.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,9 +1,9 @@
1
- 'use strict';var ln=require('hls.js'),zustand=require('zustand'),middleware=require('zustand/middleware'),designTokens=require('@xhub-reel/design-tokens'),react=require('react'),react$1=require('motion/react'),jsxRuntime=require('react/jsx-runtime'),react$2=require('@use-gesture/react'),client=require('react-dom/client');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var ln__default=/*#__PURE__*/_interopDefault(ln);var Ct={maxBufferLength:30,maxMaxBufferLength:60,maxBufferSize:3e7,maxBufferHole:.5,abrEwmaDefaultEstimate:5e5,abrBandWidthUpFactor:.7,abrBandWidthFactor:.9,startLevel:-1,autoStartLoad:true,startPosition:-1,fragLoadingMaxRetry:3,manifestLoadingMaxRetry:3,levelLoadingMaxRetry:3,fragLoadingTimeOut:2e4,manifestLoadingTimeOut:1e4,levelLoadingTimeOut:1e4,lowLatencyMode:false,liveSyncDuration:3};var Je={ACTIVATION_THRESHOLD:.5,DEACTIVATION_THRESHOLD:.3},Re={MAX_VIDEOS_IN_DOM:5,MAX_DECODED_FRAMES:3,MAX_TOTAL_MEMORY:150*1024*1024},Ne={HEIGHT_DEFAULT:2,HEIGHT_ACTIVE:4};var kt={PLAYER_PREFERENCES:"xhub-reel-player"};var Kt={isMuted:true,volume:1,playbackSpeed:1,quality:"auto"},_e=zustand.create()(middleware.persist(e=>({...Kt,toggleMute:()=>e(t=>({isMuted:!t.isMuted})),setMuted:t=>e({isMuted:t}),setVolume:t=>e({volume:Math.max(0,Math.min(1,t)),isMuted:t===0}),setPlaybackSpeed:t=>e({playbackSpeed:t}),setQuality:t=>e({quality:t}),resetPreferences:()=>e(Kt)}),{name:kt.PLAYER_PREFERENCES}));var jt={videos:[],currentIndex:0,isLoading:false,hasMore:true,error:null},Lt=zustand.create(e=>({...jt,setVideos:t=>e({videos:t,currentIndex:0}),appendVideos:t=>e(n=>({videos:[...n.videos,...t]})),setCurrentIndex:t=>e({currentIndex:t}),goToNext:()=>e(t=>({currentIndex:Math.min(t.currentIndex+1,t.videos.length-1)})),goToPrevious:()=>e(t=>({currentIndex:Math.max(t.currentIndex-1,0)})),removeVideo:t=>e(n=>{let r=n.videos.filter(s=>s.id!==t),o=Math.min(n.currentIndex,r.length-1);return {videos:r,currentIndex:Math.max(0,o)}}),setLoading:t=>e({isLoading:t}),setHasMore:t=>e({hasMore:t}),setError:t=>e({error:t}),reset:()=>e(jt)}));function Y(...e){return Object.assign({},...e.filter(Boolean))}var Ue={flex:(e={})=>({display:"flex",flexDirection:e.direction,alignItems:e.align,justifyContent:e.justify,gap:typeof e.gap=="number"?e.gap:designTokens.spacing[e.gap||0],flexWrap:e.wrap}),flexCenter:{display:"flex",alignItems:"center",justifyContent:"center"},flexBetween:{display:"flex",alignItems:"center",justifyContent:"space-between"},flexColumn:{display:"flex",flexDirection:"column"},grid:(e={})=>({display:"grid",gridTemplateColumns:typeof e.columns=="number"?`repeat(${e.columns}, 1fr)`:e.columns,gridTemplateRows:typeof e.rows=="number"?`repeat(${e.rows}, 1fr)`:e.rows,gap:typeof e.gap=="number"?e.gap:designTokens.spacing[e.gap||0]}),absolute:(e={})=>({position:"absolute",...e.inset!==void 0&&{inset:e.inset},...e.top!==void 0&&{top:e.top},...e.right!==void 0&&{right:e.right},...e.bottom!==void 0&&{bottom:e.bottom},...e.left!==void 0&&{left:e.left}}),fixed:(e={})=>({position:"fixed",...e.inset!==void 0&&{inset:e.inset},...e.top!==void 0&&{top:e.top},...e.right!==void 0&&{right:e.right},...e.bottom!==void 0&&{bottom:e.bottom},...e.left!==void 0&&{left:e.left}}),fullScreen:{position:"fixed",inset:0,width:"100%",height:"100%"},fullSize:{width:"100%",height:"100%"},centerAbsolute:{position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)"}};({heading:{fontSize:designTokens.fontSizes.xl,fontWeight:designTokens.fontWeights.bold,color:designTokens.colors.text},body:{fontSize:designTokens.fontSizes.md,fontWeight:designTokens.fontWeights.normal,color:designTokens.colors.text},caption:{fontSize:designTokens.fontSizes.xs,fontWeight:designTokens.fontWeights.normal,color:designTokens.colors.textSecondary},videoText:{color:designTokens.colors.text,textShadow:designTokens.shadows.text}});var Ie={bg:e=>({backgroundColor:e in designTokens.colors?designTokens.colors[e]:e}),rounded:(e="md")=>({borderRadius:designTokens.radii[e]}),border:(e={})=>({borderWidth:e.width||1,borderStyle:e.style||"solid",borderColor:e.color?e.color in designTokens.colors?designTokens.colors[e.color]:e.color:designTokens.colors.border}),shadow:(e="md")=>({boxShadow:designTokens.shadows[e]}),opacity:e=>({opacity:e}),glass:(e=20)=>({backgroundColor:designTokens.colors.overlay,backdropFilter:`blur(${e}px)`,WebkitBackdropFilter:`blur(${e}px)`}),glassLight:(e=10)=>({backgroundColor:designTokens.colors.overlayLight,backdropFilter:`blur(${e}px)`,WebkitBackdropFilter:`blur(${e}px)`})},en={clickable:{cursor:"pointer",userSelect:"none"}},tn={transition:(e="all",t="normal",n="xhubReel")=>({transitionProperty:Array.isArray(e)?e.join(", "):e,transitionDuration:designTokens.durations[t],transitionTimingFunction:designTokens.easings[n]}),noTransition:{transition:"none"}},Qe={scrollY:{overflowY:"auto",overflowX:"hidden",WebkitOverflowScrolling:"touch"},hideScrollbar:{scrollbarWidth:"none",msOverflowStyle:"none"},snapY:{scrollSnapType:"y mandatory",overscrollBehaviorY:"contain"},snapStart:{scrollSnapAlign:"start",scrollSnapStop:"always"}};var nn={square:e=>({width:e,height:e}),width:e=>({width:e}),height:e=>({height:e}),minHeight:e=>({minHeight:e}),maxWidth:e=>({maxWidth:e})};({feedContainer:Y(Ue.fixed({inset:0}),Qe.scrollY,Qe.snapY,Qe.hideScrollbar,Ie.bg("background"),{touchAction:"pan-y"}),feedItem:Y(Ue.fullSize,Qe.snapStart,Ie.bg("background"),{position:"relative"}),actionButton:Y(Ue.flexCenter,nn.square(48),Ie.rounded("full"),en.clickable,tn.transition(["transform","background-color"])),bottomSheet:Y(Ue.fixed({left:0,right:0,bottom:0}),Ie.glass(),Ie.rounded("xl"),{borderBottomLeftRadius:0,borderBottomRightRadius:0})});var rn=class{callbacks={};currentInfo;constructor(){this.currentInfo=this.detectNetwork(),this.setupListeners();}detectNetwork(){let e=navigator.connection;return {online:navigator.onLine,effectiveType:e?.effectiveType??"unknown",downlink:e?.downlink??null,rtt:e?.rtt??null,saveData:e?.saveData??false,type:e?.type??"unknown"}}setupListeners(){window.addEventListener("online",this.handleOnline),window.addEventListener("offline",this.handleOffline);let e=navigator.connection;e&&e.addEventListener("change",this.handleConnectionChange);}handleOnline=()=>{this.currentInfo={...this.currentInfo,online:true},this.callbacks.onOnline?.(),this.callbacks.onNetworkChange?.(this.currentInfo);};handleOffline=()=>{this.currentInfo={...this.currentInfo,online:false},this.callbacks.onOffline?.(),this.callbacks.onNetworkChange?.(this.currentInfo);};handleConnectionChange=()=>{this.currentInfo=this.detectNetwork(),this.callbacks.onNetworkChange?.(this.currentInfo);};subscribe(e){return this.callbacks={...this.callbacks,...e},()=>{this.callbacks={};}}getInfo(){return this.currentInfo}isSlowNetwork(){let{effectiveType:e}=this.currentInfo;return e==="slow-2g"||e==="2g"}getRecommendedConfig(){let{effectiveType:e,saveData:t}=this.currentInfo;return t||e==="slow-2g"||e==="2g"?{maxBufferLength:10,maxMaxBufferLength:20,startLevel:0}:e==="3g"?{maxBufferLength:20,maxMaxBufferLength:40,startLevel:1}:{}}estimateDownloadTime(e){let{downlink:t}=this.currentInfo;if(!t||t===0)return 1/0;let n=t*1e6/8;return e/n}destroy(){window.removeEventListener("online",this.handleOnline),window.removeEventListener("offline",this.handleOffline);let e=navigator.connection;e&&e.removeEventListener("change",this.handleConnectionChange);}};var on=class{callbacks={};currentInfo={batteryLevel:null,isCharging:false,isLowPowerMode:false};battery=null;constructor(){this.initBattery();}async initBattery(){try{let e=navigator;e.getBattery&&(this.battery=await e.getBattery(),this.updateInfo(),this.setupListeners());}catch{}}updateInfo(){this.battery&&(this.currentInfo={batteryLevel:this.battery.level,isCharging:this.battery.charging,isLowPowerMode:this.battery.level<.2},this.callbacks.onPowerChange?.(this.currentInfo),this.currentInfo.batteryLevel!==null&&this.currentInfo.batteryLevel<.15&&this.callbacks.onLowBattery?.());}setupListeners(){this.battery&&(this.battery.addEventListener("levelchange",()=>this.updateInfo()),this.battery.addEventListener("chargingchange",()=>this.updateInfo()));}subscribe(e){return this.callbacks={...this.callbacks,...e},()=>{this.callbacks={};}}getInfo(){return this.currentInfo}isPowerSaving(){return this.currentInfo.isLowPowerMode&&!this.currentInfo.isCharging}getRecommendedConfig(){return this.isPowerSaving()?{maxBufferLength:15,capLevelToPlayerSize:true}:{}}destroy(){this.callbacks={};}};var sn=class{queue=[];preloaded=new Set;loading=new Set;callbacks={};options;paused=false;velocityThreshold=2e3;constructor(e={}){this.options={maxConcurrent:e.maxConcurrent??2,maxQueue:e.maxQueue??5};}enqueue(e){let t=e.id??e.url;if(!(this.preloaded.has(e.url)||this.queue.some(n=>n.url===e.url))){if(this.queue.length>=this.options.maxQueue){let n=this.queue.shift();n&&this.callbacks.onPreloadCancel?.(n);}this.queue.push({...e,id:t,status:"pending"}),this.queue.sort((n,r)=>r.priority-n.priority),this.processQueue();}}enqueueMany(e){e.forEach(t=>this.enqueue(t));}cancel(e){let t=this.queue.find(n=>n.url===e);t&&(this.queue=this.queue.filter(n=>n.url!==e),this.loading.delete(t.id),this.callbacks.onPreloadCancel?.(t));}cancelAll(){this.queue.forEach(e=>{this.callbacks.onPreloadCancel?.(e);}),this.queue=[],this.loading.clear();}add(e,t,n=0){this.enqueue({id:e,url:t,priority:n});}remove(e){this.queue=this.queue.filter(t=>t.id!==e),this.loading.delete(e);}clear(){this.cancelAll(),this.preloaded.clear();}setPaused(e){this.paused=e,e||this.processQueue();}handleScrollVelocity(e){Math.abs(e)>this.velocityThreshold?this.setPaused(true):this.setPaused(false);}isPreloaded(e){return this.preloaded.has(e)}getStatus(e){let t=this.queue.find(n=>n.url===e);return t?t.status:this.preloaded.has(e)?"loaded":null}getAllStatuses(){return this.queue.map(e=>e.status)}getPreloadedUrls(){return Array.from(this.preloaded)}subscribe(e){return this.callbacks={...this.callbacks,...e},()=>{this.callbacks={};}}processQueue(){if(!this.paused)for(;this.loading.size<this.options.maxConcurrent&&this.queue.some(e=>e.status==="pending");){let e=this.queue.find(t=>t.status==="pending");e&&this.preloadItem(e);}}async preloadItem(e){e.status="loading",this.loading.add(e.id),this.callbacks.onPreloadStart?.(e);try{let t=document.createElement("link");t.rel="preload",t.as="fetch",t.href=e.url,t.crossOrigin="anonymous",document.head.appendChild(t),await new Promise((n,r)=>{t.onload=()=>n(),t.onerror=()=>r(new Error("Preload failed"));}),e.status="loaded",this.preloaded.add(e.url),this.callbacks.onPreloadComplete?.(e);}catch(t){e.status="error",this.callbacks.onPreloadError?.(e,t);}finally{this.loading.delete(e.id),this.processQueue();}}destroy(){this.clear(),this.callbacks={};}};var an=class{metrics=this.createEmptyMetrics();callbacks={};bufferingStartTime=null;playStartTime=null;isPlaying=false;createEmptyMetrics(){return {videoId:null,sessionStartTime:null,playbackStartTime:null,totalPlayTime:0,totalBufferingTime:0,bufferingCount:0,qualitySwitches:[],errors:[],seeks:[],avgBitrate:0,startupTime:null}}startSession(e,t){this.metrics={...this.createEmptyMetrics(),videoId:e,sessionStartTime:Date.now()},this.notifyUpdate();}endSession(){this.isPlaying&&this.playStartTime&&(this.metrics.totalPlayTime+=Date.now()-this.playStartTime),this.isPlaying=false,this.playStartTime=null;let e={...this.metrics};return this.callbacks.onSessionEnd?.(e),e}trackFirstFrame(){this.metrics.sessionStartTime&&!this.metrics.playbackStartTime&&(this.metrics.playbackStartTime=Date.now(),this.metrics.startupTime=this.metrics.playbackStartTime-this.metrics.sessionStartTime,this.isPlaying=true,this.playStartTime=Date.now(),this.notifyUpdate());}trackBuffering(e){let t=Date.now();e&&!this.bufferingStartTime?(this.bufferingStartTime=t,this.metrics.bufferingCount++):!e&&this.bufferingStartTime&&(this.metrics.totalBufferingTime+=t-this.bufferingStartTime,this.bufferingStartTime=null),this.notifyUpdate();}trackQualitySwitch(e,t,n){this.metrics.qualitySwitches.push({timestamp:Date.now(),fromLevel:e,toLevel:t,automatic:n}),this.notifyUpdate();}trackError(e,t,n){let r=typeof e=="string"?e:e.message;this.metrics.errors.push({timestamp:Date.now(),message:r,recoverable:t}),this.notifyUpdate();}trackBitrate(e){this.metrics.avgBitrate=e,this.notifyUpdate();}trackReplay(){this.playStartTime=Date.now(),this.isPlaying=true,this.notifyUpdate();}trackSeek(e,t,n){this.metrics.seeks.push({timestamp:Date.now(),from:e,to:t,latency:n}),this.notifyUpdate();}subscribe(e){return this.callbacks={...this.callbacks,...e},()=>{this.callbacks={};}}getMetrics(){return {...this.metrics}}notifyUpdate(){this.callbacks.onMetricsUpdate?.(this.getMetrics());}destroy(){this.endSession(),this.callbacks={};}};var Rt=class hn{hls=null;video=null;options;retryCount=0;maxRetries=3;constructor(t={}){this.options=t;}static isSupported(){return ln__default.default.isSupported()}attach(t,n){if(this.destroy(),this.video=t,this.retryCount=0,!hn.isSupported()){this.options.callbacks?.onError?.(new Error("HLS.js is not supported in this browser"),false);return}this.options.callbacks?.onStateChange?.("loading"),this.hls=new ln__default.default({...Ct,...this.options.config}),this.setupHLSListeners(),this.setupVideoListeners(),this.hls.attachMedia(t),this.hls.loadSource(n);}loadSource(t){if(!this.hls||!this.video)throw new Error("HLS engine not attached to video element");this.retryCount=0,this.options.callbacks?.onStateChange?.("loading"),this.hls.loadSource(t);}destroy(){this.video&&(this.removeVideoListeners(),this.video=null),this.hls&&(this.hls.destroy(),this.hls=null);}getQualityLevels(){return this.hls?this.hls.levels.map(t=>({label:`${t.height}p`,height:t.height,bitrate:t.bitrate})):[]}setQuality(t){this.hls&&(this.hls.currentLevel=t);}getCurrentQuality(){return this.hls?.currentLevel??-1}getBandwidth(){return this.hls?.bandwidthEstimate??0}isAutoQuality(){return this.hls?.autoLevelEnabled??true}startLoad(t){this.hls?.startLoad(t);}stopLoad(){this.hls?.stopLoad();}setupHLSListeners(){this.hls&&(this.hls.on(ln.Events.MANIFEST_PARSED,(t,n)=>{let r=this.getQualityLevels();this.options.callbacks?.onQualityLevelsLoaded?.(r),this.options.callbacks?.onStateChange?.("ready"),this.video?.autoplay&&this.video.play().catch(()=>{});}),this.hls.on(ln.Events.LEVEL_SWITCHED,(t,n)=>{this.options.callbacks?.onQualityChange?.(n.level,this.isAutoQuality());}),this.hls.on(ln.Events.FRAG_LOADED,()=>{this.options.callbacks?.onBandwidthUpdate?.(this.getBandwidth());}),this.hls.on(ln.Events.ERROR,(t,n)=>{this.handleError(n);}));}setupVideoListeners(){this.video&&(this.video.addEventListener("playing",this.handlePlaying),this.video.addEventListener("pause",this.handlePause),this.video.addEventListener("waiting",this.handleWaiting),this.video.addEventListener("ended",this.handleEnded),this.video.addEventListener("canplay",this.handleCanPlay),this.video.addEventListener("error",this.handleVideoError));}removeVideoListeners(){this.video&&(this.video.removeEventListener("playing",this.handlePlaying),this.video.removeEventListener("pause",this.handlePause),this.video.removeEventListener("waiting",this.handleWaiting),this.video.removeEventListener("ended",this.handleEnded),this.video.removeEventListener("canplay",this.handleCanPlay),this.video.removeEventListener("error",this.handleVideoError));}handlePlaying=()=>{this.options.callbacks?.onStateChange?.("playing");};handlePause=()=>{this.options.callbacks?.onStateChange?.("paused");};handleWaiting=()=>{this.options.callbacks?.onStateChange?.("buffering");};handleEnded=()=>{this.options.callbacks?.onStateChange?.("ended");};handleCanPlay=()=>{this.video?.paused&&this.options.callbacks?.onStateChange?.("ready");};handleVideoError=()=>{let t=this.video?.error;this.options.callbacks?.onError?.(new Error(t?.message??"Video playback error"),false),this.options.callbacks?.onStateChange?.("error");};handleError(t){if(t.fatal){let n=false;switch(t.type){case ln.ErrorTypes.NETWORK_ERROR:this.retryCount<this.maxRetries&&(this.retryCount++,console.warn(`[HLSEngine] Network error, retry ${this.retryCount}/${this.maxRetries}`),this.hls?.startLoad(),n=true);break;case ln.ErrorTypes.MEDIA_ERROR:console.warn("[HLSEngine] Media error, attempting recovery"),this.hls?.recoverMediaError(),n=true;break}n?this.options.callbacks?.onError?.(new Error(`HLS error (recovering): ${t.details}`),true):(this.options.callbacks?.onError?.(new Error(`HLS fatal error: ${t.details}`),false),this.options.callbacks?.onStateChange?.("error"),this.destroy());}else console.warn("[HLSEngine] Non-fatal error:",t.details);}};async function pn(e,t={}){try{return await e.play(),{success:!0}}catch(n){let r=n;if(r.name==="NotAllowedError"){e.muted=true;try{return await e.play(),{success:!0,mutedAutoplay:!0}}catch{return t.onNeedsUserGesture?.(),{success:false,reason:"user_gesture_required"}}}return {success:false,reason:"unknown",error:r}}}var cn=[.5,1,1.5,2],rt=class It{video=null;options;lastQuality=null;bandwidthSamples=[];constructor(t={}){this.options=t;}static isSupported(){return typeof document>"u"?false:document.createElement("video").canPlayType("application/vnd.apple.mpegurl")!==""}static isIOS(){return typeof navigator>"u"?false:/iPad|iPhone|iPod/.test(navigator.userAgent)||navigator.platform==="MacIntel"&&navigator.maxTouchPoints>1}attach(t,n){this.destroy(),this.video=t,this.options.callbacks?.onStateChange?.("loading"),this.setupVideoListeners(),t.src=n,t.load();}loadSource(t){if(!this.video)throw new Error("Native HLS not attached to video element");this.options.callbacks?.onStateChange?.("loading"),this.video.src=t,this.video.load();}async play(){return this.video?pn(this.video,{onNeedsUserGesture:this.options.callbacks?.onNeedsUserGesture}):{success:false,reason:"unknown"}}destroy(){this.video&&(this.removeVideoListeners(),this.video.removeAttribute("src"),this.video.load(),this.video=null),this.bandwidthSamples=[],this.lastQuality=null;}getQualityLevels(){let t=this.estimateCurrentQuality(),n=[{label:"Auto",height:0,bitrate:0}];return t&&n.push(t),n}setQuality(t){console.warn("[NativeHLS] Quality selection not supported, using auto");}getCurrentQuality(){return -1}estimateCurrentQuality(){if(!this.video||this.video.videoHeight===0)return null;let t=this.video.videoHeight,n=this.estimateBitrate();return {label:`${t}p`,height:t,bitrate:n}}estimateBitrate(){if(this.bandwidthSamples.length>0){let n=this.bandwidthSamples.reduce((r,o)=>r+o,0);return Math.round(n/this.bandwidthSamples.length)}if(!this.video)return 0;let t=this.video.videoHeight;return t>=1080?5e6:t>=720?25e5:t>=480?1e6:t>=360?5e5:25e4}getBandwidth(){return this.estimateBitrate()}isAutoQuality(){return true}startLoad(){this.video?.load();}stopLoad(){this.video&&(this.video.preload="none");}async enterFullscreen(){let t=this.video;if(t){if(t.requestFullscreen){await t.requestFullscreen();return}t.webkitEnterFullscreen&&await t.webkitEnterFullscreen();}}async exitFullscreen(){let t=this.video;if(t){if(document.exitFullscreen){await document.exitFullscreen();return}t.webkitExitFullscreen&&await t.webkitExitFullscreen();}}isFullscreen(){let t=this.video;return t?document.fullscreenElement?document.fullscreenElement===t:t.webkitDisplayingFullscreen??false:false}isFullscreenSupported(){let t=this.video;return t?!!(t.requestFullscreen||t.webkitSupportsFullscreen):false}isPlaybackRateSupported(t){return It.isIOS()?cn.includes(t):t>=.5&&t<=2}getSupportedPlaybackRates(){return It.isIOS()?[...cn]:[.5,.75,1,1.25,1.5,2]}setupVideoListeners(){this.video&&(this.video.addEventListener("loadedmetadata",this.handleLoadedMetadata),this.video.addEventListener("playing",this.handlePlaying),this.video.addEventListener("pause",this.handlePause),this.video.addEventListener("waiting",this.handleWaiting),this.video.addEventListener("ended",this.handleEnded),this.video.addEventListener("canplay",this.handleCanPlay),this.video.addEventListener("error",this.handleError),this.video.addEventListener("resize",this.handleResize),this.video.addEventListener("progress",this.handleProgress));}removeVideoListeners(){this.video&&(this.video.removeEventListener("loadedmetadata",this.handleLoadedMetadata),this.video.removeEventListener("playing",this.handlePlaying),this.video.removeEventListener("pause",this.handlePause),this.video.removeEventListener("waiting",this.handleWaiting),this.video.removeEventListener("ended",this.handleEnded),this.video.removeEventListener("canplay",this.handleCanPlay),this.video.removeEventListener("error",this.handleError),this.video.removeEventListener("resize",this.handleResize),this.video.removeEventListener("progress",this.handleProgress));}handleLoadedMetadata=()=>{let t=this.getQualityLevels();this.options.callbacks?.onQualityLevelsLoaded?.(t),this.options.callbacks?.onStateChange?.("ready"),this.checkQualityChange();};handlePlaying=()=>{this.options.callbacks?.onStateChange?.("playing");};handlePause=()=>{this.options.callbacks?.onStateChange?.("paused");};handleWaiting=()=>{this.options.callbacks?.onStateChange?.("buffering");};handleEnded=()=>{this.options.callbacks?.onStateChange?.("ended");};handleCanPlay=()=>{this.video?.paused&&this.options.callbacks?.onStateChange?.("ready");};handleError=()=>{let t=this.video?.error,n=t?.message??"Video playback error",r=t?.code!==MediaError.MEDIA_ERR_SRC_NOT_SUPPORTED;this.options.callbacks?.onError?.(new Error(n),r),this.options.callbacks?.onStateChange?.("error");};handleResize=()=>{this.checkQualityChange();};handleProgress=()=>{this.updateBandwidthEstimate();};checkQualityChange(){let t=this.estimateCurrentQuality();t&&(!this.lastQuality||this.lastQuality.height!==t.height)&&(this.lastQuality=t,this.options.callbacks?.onQualityChange?.(t));}updateBandwidthEstimate(){if(this.video&&typeof performance<"u"&&performance.getEntriesByType){let n=performance.getEntriesByType("resource").filter(r=>r.initiatorType==="video"||r.name.includes(".ts")||r.name.includes(".m3u8"));if(n.length>0){let o=n.slice(-5).filter(s=>s.transferSize>0&&s.duration>0).map(s=>s.transferSize*8/(s.duration/1e3));if(o.length>0){let s=o.reduce((d,u)=>d+u,0)/o.length;this.bandwidthSamples.push(s),this.bandwidthSamples.length>10&&this.bandwidthSamples.shift(),this.options.callbacks?.onBandwidthUpdate?.(s);}}}}},fn=class{engine=null;video=null;options;isNative=false;animationFrameId=null;isTracking=false;networkDetector=null;powerManager=null;preloadManager=null;analytics=null;cleanupFunctions=[];wasPlayingBeforeOffline=false;wasPlayingBeforeLowBattery=false;constructor(e={}){this.options={enableNetworkAdaptation:true,enablePowerAdaptation:true,enableAnalytics:false,...e},this.isNative=this.shouldUseNative(),this.initializeServices();}static isSupported(){return Rt.isSupported()||rt.isSupported()}attach(e,t,n){this.video=e,this.destroyEngine(),this.setupVideoListeners(),this.analytics&&n&&this.analytics.startSession(n,e);let r=this.getAdaptedConfig();this.isNative?this.engine=new rt({callbacks:{onStateChange:this.options.callbacks?.onStateChange,onError:this.options.callbacks?.onError,onQualityLevelsLoaded:this.options.callbacks?.onQualityLevelsLoaded,onBandwidthUpdate:this.options.callbacks?.onBandwidthUpdate,onNeedsUserGesture:this.options.callbacks?.onNeedsUserGesture,onQualityChange:o=>{this.options.callbacks?.onQualityChange?.(-1,o);}}}):this.engine=new Rt({config:r,callbacks:{onStateChange:this.options.callbacks?.onStateChange,onError:this.options.callbacks?.onError,onQualityLevelsLoaded:this.options.callbacks?.onQualityLevelsLoaded,onBandwidthUpdate:this.options.callbacks?.onBandwidthUpdate,onQualityChange:(o,s)=>{let d=this.engine?.getQualityLevels()??[],u=o>=0&&o<d.length?d[o]:void 0;this.options.callbacks?.onQualityChange?.(s?-1:o,u);}}}),this.engine.attach(e,t);}loadSource(e,t){if(!this.engine||!this.video)throw new Error("Player not attached to video element");this.analytics&&(this.analytics.endSession(),t&&this.analytics.startSession(t,this.video)),this.engine.loadSource(e);}destroy(){this.destroyEngine(),this.destroyServices();}async play(){return this.video?this.isNative&&this.engine instanceof rt?this.engine.play():pn(this.video,{onNeedsUserGesture:this.options.callbacks?.onNeedsUserGesture}):{success:false,reason:"unknown"}}pause(){this.video?.pause();}async togglePlay(){return this.video?.paused?this.play():(this.pause(),{success:true})}seek(e){if(this.video){let t=this.video.currentTime;this.video.currentTime=Math.max(0,Math.min(e,this.video.duration||0)),this.analytics?.trackSeek(t,e,0);}}seekForward(e=10){this.video&&this.seek(this.video.currentTime+e);}seekBackward(e=10){this.video&&this.seek(this.video.currentTime-e);}getCurrentTime(){return this.video?.currentTime??0}getDuration(){return this.video?.duration??0}setVolume(e){this.video&&(this.video.volume=Math.max(0,Math.min(1,e)));}getVolume(){return this.video?.volume??1}setMuted(e){this.video&&(this.video.muted=e);}isMuted(){return this.video?.muted??true}toggleMute(){this.setMuted(!this.isMuted());}setPlaybackRate(e){this.video&&(this.video.playbackRate=e);}getPlaybackRate(){return this.video?.playbackRate??1}getQualityLevels(){return this.engine?.getQualityLevels()??[]}setQuality(e){let t=this.getCurrentQuality();this.engine?.setQuality(e),t!==e&&this.analytics?.trackQualitySwitch(t,e,e===-1);}getCurrentQuality(){return this.engine?.getCurrentQuality()??-1}isUsingNative(){return this.isNative}getVideoElement(){return this.video}getBuffered(){if(!this.video)return 0;let e=this.video.buffered,t=this.video.currentTime;for(let n=0;n<e.length;n++)if(t>=e.start(n)&&t<=e.end(n))return e.end(n)-t;return 0}getNetworkInfo(){return this.networkDetector?.getInfo()??null}getPowerInfo(){return this.powerManager?.getInfo()??null}getPreloadManager(){return this.preloadManager}getAnalytics(){return this.analytics?.getMetrics()??null}isSlowNetwork(){return this.networkDetector?.isSlowNetwork()??false}isPowerSaving(){return this.powerManager?.isPowerSaving()??false}shouldUseNative(){return this.options.preferNative!==false&&rt.isSupported()?true:!Rt.isSupported()}initializeServices(){if(this.options.enableNetworkAdaptation){this.networkDetector=new rn;let e=this.networkDetector.subscribe({onNetworkChange:this.handleNetworkChange,onOffline:()=>this.options.callbacks?.onError?.(new Error("Network offline"),true)});this.cleanupFunctions.push(e);}if(this.options.enablePowerAdaptation){this.powerManager=new on;let e=this.powerManager.subscribe({onPowerChange:this.handlePowerChange});this.cleanupFunctions.push(e),this.cleanupFunctions.push(()=>this.powerManager?.destroy());}if(this.options.preloadConfig&&(this.preloadManager=new sn(this.options.preloadConfig),this.cleanupFunctions.push(()=>this.preloadManager?.destroy())),this.options.enableAnalytics){this.analytics=new an;let e=this.analytics.subscribe({onMetricsUpdate:t=>this.options.callbacks?.onAnalyticsUpdate?.(t)});this.cleanupFunctions.push(e),this.cleanupFunctions.push(()=>this.analytics?.destroy());}}destroyServices(){this.cleanupFunctions.forEach(e=>e()),this.cleanupFunctions=[],this.networkDetector=null,this.powerManager=null,this.preloadManager=null,this.analytics=null;}destroyEngine(){this.stopProgressTracking(),this.removeVideoListeners(),this.engine&&(this.engine.destroy(),this.engine=null);}getAdaptedConfig(){let e={};return this.networkDetector&&(e={...e,...this.networkDetector.getRecommendedConfig()}),this.powerManager&&(e={...e,...this.powerManager.getRecommendedConfig()}),e}isNetworkBelowThreshold(e,t){let n=["slow-2g","2g","3g","4g","5g","unknown"],r=n.indexOf(e),o=n.indexOf(t);return e==="unknown"?false:r>=0&&r<=o}handleNetworkChange=e=>{this.options.callbacks?.onNetworkChange?.(e);let t=this.options.lowQualityThreshold??"2g",n=this.isNetworkBelowThreshold(e.effectiveType,t);this.options.autoQualityOnNetworkChange&&this.engine&&(n?this.setQuality(0):(e.effectiveType==="4g"||e.effectiveType==="5g")&&this.setQuality(-1)),this.options.autoPauseOnOffline&&!e.online&&(this.wasPlayingBeforeOffline=this.video?!this.video.paused:false,this.pause()),this.options.autoResumeOnOnline&&e.online&&this.wasPlayingBeforeOffline&&(this.play(),this.wasPlayingBeforeOffline=false),this.preloadManager&&this.preloadManager.setPaused(e.effectiveType==="2g"||!e.online);};handlePowerChange=e=>{this.options.callbacks?.onPowerChange?.(e);let t=this.options.lowBatteryThreshold??.15,n=e.batteryLevel!==null&&e.batteryLevel<t;this.options.autoPauseOnLowBattery&&n&&!e.isCharging&&(this.wasPlayingBeforeLowBattery=this.video?!this.video.paused:false,this.pause()),this.wasPlayingBeforeLowBattery&&(e.isCharging||e.batteryLevel!==null&&e.batteryLevel>=t+.05)&&(this.play(),this.wasPlayingBeforeLowBattery=false),this.preloadManager&&e.isLowPowerMode&&this.preloadManager.setPaused(true);};setupVideoListeners(){this.video&&(this.video.addEventListener("timeupdate",this.handleTimeUpdate),this.video.addEventListener("progress",this.handleProgress),this.video.addEventListener("volumechange",this.handleVolumeChange),this.video.addEventListener("ratechange",this.handleRateChange),this.video.addEventListener("play",this.handlePlay),this.video.addEventListener("pause",this.handlePause),this.video.addEventListener("ended",this.handleEnded),this.video.addEventListener("waiting",this.handleWaiting),this.video.addEventListener("playing",this.handlePlaying));}removeVideoListeners(){this.video&&(this.video.removeEventListener("timeupdate",this.handleTimeUpdate),this.video.removeEventListener("progress",this.handleProgress),this.video.removeEventListener("volumechange",this.handleVolumeChange),this.video.removeEventListener("ratechange",this.handleRateChange),this.video.removeEventListener("play",this.handlePlay),this.video.removeEventListener("pause",this.handlePause),this.video.removeEventListener("ended",this.handleEnded),this.video.removeEventListener("waiting",this.handleWaiting),this.video.removeEventListener("playing",this.handlePlaying));}handleTimeUpdate=()=>{this.video&&this.options.callbacks?.onTimeUpdate?.(this.video.currentTime,this.video.duration||0);};handleProgress=()=>{this.options.callbacks?.onProgress?.(this.getBuffered());};handleVolumeChange=()=>{this.video&&this.options.callbacks?.onVolumeChange?.(this.video.volume,this.video.muted);};handleRateChange=()=>{this.video&&this.options.callbacks?.onRateChange?.(this.video.playbackRate);};handlePlay=()=>{this.options.enableSmoothTimeUpdates&&this.startProgressTracking();};handlePause=()=>{this.stopProgressTracking();};handleEnded=()=>{this.stopProgressTracking(),this.analytics&&this.analytics.endSession();};handleWaiting=()=>{this.analytics?.trackBuffering(true);};handlePlaying=()=>{this.analytics?.trackBuffering(false),this.analytics?.trackFirstFrame();};startProgressTracking(){if(this.isTracking||!this.video)return;this.isTracking=true;let e=()=>{if(!this.video||this.video.paused||this.video.ended){this.isTracking=false,this.animationFrameId=null;return}this.options.callbacks?.onTimeUpdate?.(this.video.currentTime,this.video.duration||0),this.animationFrameId=requestAnimationFrame(e);};this.animationFrameId=requestAnimationFrame(e);}stopProgressTracking(){this.animationFrameId!==null&&(cancelAnimationFrame(this.animationFrameId),this.animationFrameId=null),this.isTracking=false;}},Er=[{from:"idle",to:"loading"},{from:"loading",to:"ready"},{from:"loading",to:"error"},{from:"ready",to:"playing"},{from:"ready",to:"loading"},{from:"ready",to:"error"},{from:"playing",to:"paused"},{from:"playing",to:"buffering"},{from:"playing",to:"ended"},{from:"playing",to:"error"},{from:"playing",to:"loading"},{from:"paused",to:"playing"},{from:"paused",to:"buffering"},{from:"paused",to:"loading"},{from:"paused",to:"error"},{from:"buffering",to:"playing"},{from:"buffering",to:"paused"},{from:"buffering",to:"stalled"},{from:"buffering",to:"error"},{from:"stalled",to:"playing"},{from:"stalled",to:"buffering"},{from:"stalled",to:"error"},{from:"stalled",to:"loading"},{from:"ended",to:"playing"},{from:"ended",to:"loading"},{from:"ended",to:"idle"},{from:"error",to:"loading"},{from:"error",to:"idle"},{from:"*",to:"idle"}],Cr=class{_state="idle";listeners=new Set;stalledTimeout=null;stalledThreshold=3e3;get state(){return this._state}transition(e){if(!this.canTransition(e))return console.warn(`[PlayerStateMachine] Invalid transition: ${this._state} -> ${e}`),false;let n=this._state;return this._state=e,e==="buffering"?this.startStalledTimer():this.clearStalledTimer(),this.listeners.forEach(r=>r(e,n)),true}canTransition(e){let t=Er.find(n=>(n.from===this._state||n.from==="*")&&n.to===e);return !(!t||t.guard&&!t.guard())}subscribe(e){return this.listeners.add(e),()=>this.listeners.delete(e)}reset(){this.clearStalledTimer(),this._state="idle";}isPlaying(){return this._state==="playing"}canPlay(){return ["ready","paused","ended"].includes(this._state)}isLoading(){return ["loading","buffering"].includes(this._state)}hasError(){return this._state==="error"}startStalledTimer(){this.clearStalledTimer(),this.stalledTimeout=setTimeout(()=>{this._state==="buffering"&&this.transition("stalled");},this.stalledThreshold);}clearStalledTimer(){this.stalledTimeout&&(clearTimeout(this.stalledTimeout),this.stalledTimeout=null);}};function kr(){return new Cr}function mn(){let e=react.useMemo(()=>kr(),[]),[t,n]=react.useState(e.state);react.useEffect(()=>e.subscribe(d=>{n(d);}),[e]);let r=react.useCallback(s=>e.transition(s),[e]),o=react.useCallback(()=>{e.reset(),n("idle");},[e]);return {state:t,isPlaying:t==="playing",isPaused:t==="paused",isLoading:t==="loading",isBuffering:t==="buffering",isStalled:t==="stalled",isEnded:t==="ended",hasError:t==="error",canPlay:e.canPlay(),transition:r,reset:o}}function gn(e){let{volume:t,isMuted:n,setVolume:r,toggleMute:o,setMuted:s}=_e();react.useEffect(()=>{let i=e.current;i&&(i.volume=t,i.muted=n);},[e,t,n]),react.useEffect(()=>{let i=e.current;if(!i)return;let a=()=>{i.volume!==t&&r(i.volume),i.muted!==n&&s(i.muted);};return i.addEventListener("volumechange",a),()=>i.removeEventListener("volumechange",a)},[e,t,n,r,s]);let d=react.useCallback(i=>{let a=Math.max(0,Math.min(1,i));r(a),e.current&&(e.current.volume=a),a>0&&n&&(s(false),e.current&&(e.current.muted=false));},[e,n,r,s]),u=react.useCallback(()=>{o(),e.current&&(e.current.muted=!n);},[e,n,o]),l=react.useCallback(()=>{n||(s(true),e.current&&(e.current.muted=true));},[e,n,s]),m=react.useCallback(()=>{n&&(s(false),e.current&&(e.current.muted=false));},[e,n,s]);return {volume:t,isMuted:n,setVolume:d,toggleMute:u,mute:l,unmute:m}}function yn(e,t={}){let{enableSmoothTracking:n=false}=t,[r,o]=react.useState(0),[s,d]=react.useState(0),[u,l]=react.useState(0),[m,i]=react.useState([]),a=react.useRef(null),p=react.useRef(false),c=s>0?r/s*100:0,g=react.useCallback(h=>{let y=[],P=h.buffered;for(let C=0;C<P.length;C++)y.push({start:P.start(C),end:P.end(C)});i(y);let O=0;for(let C of y)if(h.currentTime>=C.start&&h.currentTime<=C.end){O=C.end-h.currentTime;break}l(O);},[]),f=react.useCallback(()=>{a.current!==null&&(cancelAnimationFrame(a.current),a.current=null),p.current=false;},[]),S=react.useCallback(()=>{let h=e.current;if(!h||p.current)return;p.current=true;let y=()=>{if(!h||h.paused||h.ended){p.current=false,a.current=null;return}o(h.currentTime),a.current=requestAnimationFrame(y);};a.current=requestAnimationFrame(y);},[e]);react.useEffect(()=>{let h=e.current;if(!h)return;let y=()=>{o(h.currentTime);},P=()=>{d(h.duration||0);},O=()=>{d(h.duration||0);},C=()=>{g(h);},B=()=>{n&&S();},z=()=>{f();},H=()=>{f();},A=()=>{o(h.currentTime);},v=()=>{o(h.currentTime),g(h);};return h.addEventListener("timeupdate",y),h.addEventListener("loadedmetadata",P),h.addEventListener("durationchange",O),h.addEventListener("progress",C),h.addEventListener("play",B),h.addEventListener("pause",z),h.addEventListener("ended",H),h.addEventListener("seeking",A),h.addEventListener("seeked",v),h.readyState>=1&&(d(h.duration||0),o(h.currentTime)),h.readyState>=3&&g(h),!h.paused&&n&&S(),()=>{h.removeEventListener("timeupdate",y),h.removeEventListener("loadedmetadata",P),h.removeEventListener("durationchange",O),h.removeEventListener("progress",C),h.removeEventListener("play",B),h.removeEventListener("pause",z),h.removeEventListener("ended",H),h.removeEventListener("seeking",A),h.removeEventListener("seeked",v),f();}},[e,n,g,S,f]);let b=react.useCallback(h=>{let y=e.current;if(!y||!isFinite(y.duration))return;let P=Math.max(0,Math.min(h,y.duration));y.currentTime=P,o(P);},[e]),V=react.useCallback(h=>{let y=e.current;if(!y||!isFinite(y.duration))return;let O=Math.max(0,Math.min(100,h))/100*y.duration;y.currentTime=O,o(O);},[e]),L=s>0&&isFinite(s);return {currentTime:r,duration:s,buffered:u,progress:c,bufferedRanges:m,seek:b,seekToProgress:V,isSeekable:L,startSmoothTracking:S,stopSmoothTracking:f}}function vn(e){let{quality:t,setQuality:n}=_e(),[r,o]=react.useState(-1),[s,d]=react.useState([]);react.useEffect(()=>{if(!e)return;let i=e.getQualityLevels();d(i),o(e.getCurrentQuality());},[e]),react.useEffect(()=>{if(!(!e||s.length===0))if(t==="auto")e.setQuality(-1),o(-1);else {let i=parseInt(t.replace("p","")),a=s.findIndex(p=>p.height===i);a!==-1&&(e.setQuality(a),o(a));}},[e,t,s]);let u=r===-1,l=react.useCallback(i=>{if(e)if(typeof i=="number")if(e.setQuality(i),o(i),i===-1)n("auto");else {let a=s[i];a&&n(`${a.height}p`);}else n(i);},[e,s,n]),m=react.useCallback(()=>{l("auto");},[l]);return {quality:t,currentLevel:r,availableLevels:s,isAuto:u,setQuality:l,setAuto:m}}function Mt(e){return e<1e3?e.toString():e<1e4?`${(e/1e3).toFixed(1)}K`:e<1e6?`${Math.floor(e/1e3)}K`:`${(e/1e6).toFixed(1)}M`}var Mr={position:"absolute",right:designTokens.spacing[4],bottom:160,display:"flex",flexDirection:"column",alignItems:"center",gap:designTokens.components.actionBar.gap,zIndex:10},Vr={display:"flex",flexDirection:"column",alignItems:"center",gap:designTokens.components.actionBar.iconCountGap,background:"none",border:"none",padding:0,cursor:"pointer"},Ar={width:designTokens.components.actionBar.iconSize,height:designTokens.components.actionBar.iconSize,display:"flex",alignItems:"center",justifyContent:"center"},Fr={fontSize:designTokens.fontSizes.xs,fontWeight:designTokens.fontWeights.normal,color:designTokens.colors.text,textShadow:designTokens.shadows.text,lineHeight:designTokens.components.actionBar.counterLineHeight,textAlign:"center"},Or={display:"flex",flexDirection:"column",alignItems:"center",position:"relative",width:designTokens.components.profileAction.avatarSize,height:55},bn={width:designTokens.components.profileAction.avatarSize,height:designTokens.components.profileAction.avatarSize,borderRadius:"50%",objectFit:"cover",cursor:"pointer",background:designTokens.colors.surface},Hr={position:"absolute",bottom:0,left:"50%",transform:"translateX(-50%)",width:designTokens.components.profileAction.followButtonSize,height:designTokens.components.profileAction.followButtonSize,borderRadius:"50%",backgroundColor:designTokens.colors.like,border:"none",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center"},Dr=({filled:e,color:t="white"})=>e?jsxRuntime.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:designTokens.components.actionBar.iconSize,height:designTokens.components.actionBar.iconSize,viewBox:"0 0 28 28",fill:"none",children:jsxRuntime.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M1.74988 11.0538C1.74988 6.75595 4.69822 2.91699 9.20877 2.91699C11.4347 2.91699 12.9986 3.9593 13.9999 4.96978C15.0011 3.95929 16.565 2.91699 18.791 2.91699C23.3015 2.91699 26.2499 6.75595 26.2499 11.0538C26.2499 15.3962 23.6265 18.9036 20.8781 21.3587C18.1288 23.8145 15.1442 25.3171 14.1843 25.6371L13.9999 25.6985L13.8154 25.6371C12.8555 25.3171 9.87093 23.8145 7.12168 21.3587C4.37329 18.9036 1.74988 15.3962 1.74988 11.0538ZM17.7449 6.41699C17.2617 6.41699 16.8699 6.80874 16.8699 7.29199C16.8699 7.77524 17.2617 8.16699 17.7449 8.16699C19.6221 8.16699 20.9952 9.75855 20.9952 11.8241C20.9952 12.3073 21.387 12.6991 21.8702 12.6991C22.3535 12.6991 22.7452 12.3073 22.7452 11.8241C22.7452 9.02543 20.8066 6.41699 17.7449 6.41699Z",fill:t})}):jsxRuntime.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:designTokens.components.actionBar.iconSize,height:designTokens.components.actionBar.iconSize,viewBox:"0 0 24 24",fill:"none",children:[jsxRuntime.jsx("path",{d:"M15.21 5.5C14.7957 5.5 14.46 5.83579 14.46 6.25C14.46 6.66421 14.7957 7 15.21 7C16.819 7 17.996 8.3642 17.996 10.1346C17.996 10.5488 18.3317 10.8846 18.746 10.8846C19.1602 10.8846 19.496 10.5488 19.496 10.1346C19.496 7.7358 17.8342 5.5 15.21 5.5Z",fill:t}),jsxRuntime.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M7.89327 2.25C3.85788 2.25 1.24994 5.6858 1.24994 9.47438C1.24994 13.301 3.5604 16.37 5.9378 18.4936C8.31629 20.6183 10.9036 21.9251 11.7628 22.2115L11.9999 22.2906L12.2371 22.2115C13.0963 21.9251 15.6836 20.6183 18.0621 18.4936C20.4395 16.37 22.7499 13.301 22.7499 9.47438C22.7499 5.6858 20.142 2.25 16.1066 2.25C14.2397 2.25 12.8941 3.06969 11.9999 3.91063C11.1058 3.06969 9.76018 2.25 7.89327 2.25ZM2.74994 9.47438C2.74994 6.3142 4.8731 3.75 7.89327 3.75C9.60588 3.75 10.7397 4.66987 11.4269 5.48383L11.9999 6.16259L12.573 5.48383C13.2602 4.66987 14.394 3.75 16.1066 3.75C19.1268 3.75 21.2499 6.3142 21.2499 9.47438C21.2499 12.6733 19.3104 15.3672 17.0628 17.375C15.0361 19.1854 12.8741 20.3336 11.9999 20.6978C11.1257 20.3336 8.96379 19.1854 6.93708 17.375C4.68948 15.3672 2.74994 12.6733 2.74994 9.47438Z",fill:t})]}),Br=()=>jsxRuntime.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:designTokens.components.actionBar.iconSize,height:designTokens.components.actionBar.iconSize,viewBox:"0 0 28 28",fill:"none",children:jsxRuntime.jsx("path",{d:"M14 1.45801C7.07347 1.45801 1.45837 7.0731 1.45837 13.9997C1.45837 16.3815 2.1232 18.6107 3.27778 20.5088L2.36541 23.0178C1.77294 24.6471 3.35258 26.2268 4.98188 25.6343L7.49089 24.7219C9.389 25.8765 11.6182 26.5413 14 26.5413C20.9266 26.5413 26.5417 20.9262 26.5417 13.9997C26.5417 7.0731 20.9266 1.45801 14 1.45801Z",fill:"white"})}),Nr=({filled:e})=>jsxRuntime.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:designTokens.components.actionBar.iconSize,height:designTokens.components.actionBar.iconSize,viewBox:"0 0 28 28",fill:"none",children:jsxRuntime.jsx("path",{d:"M16.6904 1.45801H11.2789C10.2487 1.458 9.4224 1.45799 8.75434 1.51253C8.06795 1.56857 7.47186 1.68652 6.92253 1.96632C6.90122 1.97718 6.88036 1.98891 6.86 2.00147C5.64436 2.75199 4.94533 3.52276 4.62739 4.64643C4.48015 5.1668 4.42512 5.72644 4.40084 6.3243C4.38332 6.75558 4.3811 7.24294 4.37866 7.77623C4.37775 7.97537 4.37678 8.18091 4.375 8.39232V24.8275C4.375 25.7739 5.14242 26.5413 6.08883 26.5413C6.51994 26.5413 6.93517 26.3792 7.25226 26.0859L13.3276 20.4783C13.3386 20.4682 13.3493 20.4578 13.3597 20.4471C13.5821 20.2197 13.743 20.0895 13.8601 20.0183C13.9156 19.9846 13.9524 19.9697 13.9731 19.9631C13.9833 19.9599 13.9898 19.9585 13.9933 19.958L13.9975 19.9575L13.9992 19.9574C13.9992 19.9574 14.0065 19.9571 14.0257 19.9632C14.0466 19.9698 14.0837 19.9849 14.1394 20.0187C14.2569 20.0901 14.4182 20.2206 14.641 20.4479C14.6512 20.4583 14.6616 20.4684 14.6724 20.4783L20.7477 26.0859C21.0648 26.3792 21.4801 26.5413 21.9112 26.5413C22.8576 26.5413 23.625 25.7739 23.625 24.8275V8.3619C23.625 7.33168 23.625 6.5054 23.5705 5.83735C23.5144 5.15096 23.3965 4.55487 23.1167 4.00554C23.1058 3.98416 23.094 3.96325 23.0814 3.94284C22.3309 2.72781 21.5599 2.0287 20.4364 1.71046C19.9159 1.56305 19.3562 1.50785 18.7583 1.48352C18.3245 1.46588 17.8344 1.46376 17.2978 1.46144C17.1014 1.46059 16.8988 1.45968 16.6904 1.45801Z",fill:e?designTokens.colors.warning:"white"})}),_r=()=>jsxRuntime.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:28,height:28,viewBox:"0 0 28 28",fill:"none",children:[jsxRuntime.jsx("path",{d:"M20.6583 8.99195C21.1139 8.53634 21.1139 7.79765 20.6583 7.34203L14.8249 1.5087C14.6061 1.28991 14.3094 1.16699 14 1.16699C13.6905 1.16699 13.3938 1.28991 13.175 1.5087L7.34167 7.34204C6.88606 7.79765 6.88606 8.53634 7.34167 8.99195C7.79728 9.44756 8.53597 9.44756 8.99158 8.99195L12.8333 5.15024L12.8333 17.5003C12.8333 18.1447 13.3556 18.667 14 18.667C14.6443 18.667 15.1666 18.1447 15.1666 17.5003L15.1666 5.15024L19.0083 8.99195C19.4639 9.44756 20.2026 9.44756 20.6583 8.99195Z",fill:"white"}),jsxRuntime.jsx("path",{d:"M24.4562 22.2708C24.4991 21.7457 24.5 21.0663 24.5 20.067V16.3337C24.5 15.6893 25.0223 15.167 25.6666 15.167C26.311 15.167 26.8333 15.6893 26.8333 16.3337L26.8333 20.1152C26.8333 21.0543 26.8333 21.8294 26.7817 22.4608C26.7282 23.1166 26.6132 23.7194 26.3247 24.2856C25.8772 25.1637 25.1633 25.8776 24.2852 26.325C23.719 26.6135 23.1162 26.7285 22.4604 26.7821C21.829 26.8337 21.054 26.8337 20.1149 26.8337H7.88508C6.94599 26.8337 6.17087 26.8337 5.5395 26.7821C4.88372 26.7285 4.28089 26.6135 3.71467 26.325C2.83658 25.8776 2.12267 25.1637 1.67526 24.2856C1.38676 23.7194 1.27176 23.1166 1.21819 22.4608C1.1666 21.8294 1.16661 21.0543 1.16663 20.1152V16.3337C1.16663 15.6893 1.68896 15.167 2.33329 15.167C2.97762 15.167 3.49996 15.6893 3.49996 16.3337L3.49996 20.067C3.49996 21.0663 3.50087 21.7457 3.54377 22.2708C3.58556 22.7823 3.66131 23.0438 3.75428 23.2263C3.97798 23.6653 4.33494 24.0223 4.77398 24.246C4.95645 24.339 5.21802 24.4147 5.7295 24.4565C6.25461 24.4994 6.93395 24.5003 7.93329 24.5003H20.0666C21.066 24.5003 21.7453 24.4994 22.2704 24.4565C22.7819 24.4147 23.0435 24.339 23.2259 24.246C23.665 24.0223 24.0219 23.6653 24.2456 23.2263C24.3386 23.0438 24.4144 22.7823 24.4562 22.2708Z",fill:"white"})]}),Ur=()=>jsxRuntime.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:12,height:12,viewBox:"0 0 12 12",fill:"white",children:jsxRuntime.jsx("path",{d:"M6 1V11M1 6H11",stroke:"white",strokeWidth:2,strokeLinecap:"round"})}),Qr=()=>jsxRuntime.jsx("svg",{width:12,height:12,viewBox:"0 0 12 12",fill:"none",children:jsxRuntime.jsx("path",{d:"M2 6L5 9L10 3",stroke:"white",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"})});function zr({avatarUrl:e,isFollowed:t=false,onClick:n,onFollow:r}){return jsxRuntime.jsxs("div",{style:Or,children:[jsxRuntime.jsx(react$1.motion.button,{style:{background:"none",border:"none",padding:0,cursor:"pointer"},onClick:n,whileTap:{scale:.95},"aria-label":"View profile",children:e?jsxRuntime.jsx("img",{src:e,alt:"Profile",style:bn}):jsxRuntime.jsx("div",{style:bn})}),!t&&r&&jsxRuntime.jsx(react$1.motion.button,{style:Hr,onClick:o=>{o.stopPropagation(),r();},whileTap:{scale:.9},animate:t?{scale:[1,1.2,1]}:{scale:1},transition:{type:"spring",...designTokens.springs.bouncy},"aria-label":t?"Following":"Follow",children:t?jsxRuntime.jsx(Qr,{}):jsxRuntime.jsx(Ur,{})})]})}function it({icon:e,count:t,isActive:n=false,onClick:r,label:o}){return jsxRuntime.jsxs(react$1.motion.button,{style:Vr,onClick:r,"aria-label":o,whileTap:{scale:.9},transition:{type:"spring",...designTokens.springs.bouncy},children:[jsxRuntime.jsx(react$1.motion.div,{style:Ar,animate:n?{scale:[1,1.2,1]}:{scale:1},transition:n?{duration:.3,ease:[.32,.72,0,1]}:{type:"spring",...designTokens.springs.default},children:e}),t!==void 0&&jsxRuntime.jsx("span",{style:Fr,children:Mt(t)})]})}function st({likeCount:e,commentCount:t,shareCount:n,saveCount:r,isLiked:o=false,isSaved:s=false,onLike:d,onComment:u,onShare:l,onSave:m,avatarUrl:i,onProfileClick:a,onFollow:p,isFollowed:c=false,style:g,className:f=""}){return jsxRuntime.jsxs("div",{style:designTokens.mergeStyles(Mr,g),className:f,children:[i&&jsxRuntime.jsx(zr,{avatarUrl:i,isFollowed:c,onClick:a,onFollow:p}),jsxRuntime.jsx(it,{icon:jsxRuntime.jsx(Dr,{filled:o,color:o?designTokens.colors.like:"white"}),count:e,isActive:o,onClick:d,label:o?"Unlike":"Like"}),jsxRuntime.jsx(it,{icon:jsxRuntime.jsx(Br,{}),count:t,onClick:u,label:"Comments"}),jsxRuntime.jsx(it,{icon:jsxRuntime.jsx(Nr,{filled:s}),count:r,isActive:s,onClick:m,label:s?"Unsave":"Save"}),jsxRuntime.jsx(it,{icon:jsxRuntime.jsx(_r,{}),count:n,onClick:l,label:"Share"})]})}var Xr={display:"inline-flex",alignItems:"center",justifyContent:"center",border:"none",cursor:"pointer",borderRadius:designTokens.radii.full,transitionProperty:"background-color, transform, opacity",transitionDuration:designTokens.durations.fast,transitionTimingFunction:designTokens.easings.xhubReel,userSelect:"none"},Kr={sm:{width:32,height:32},md:{width:designTokens.components.tapArea,height:designTokens.components.tapArea},lg:{width:56,height:56}},jr={default:{backgroundColor:designTokens.colors.surface,color:designTokens.colors.text},ghost:{backgroundColor:"transparent",color:designTokens.colors.text},glass:{backgroundColor:"rgba(0, 0, 0, 0.2)",backdropFilter:"blur(4px)",WebkitBackdropFilter:"blur(4px)",color:designTokens.colors.text}},Zr={opacity:.5,cursor:"not-allowed",pointerEvents:"none"},At=react.forwardRef(({icon:e,size:t="md",variant:n="ghost",disabled:r,style:o,className:s="",...d},u)=>jsxRuntime.jsx("button",{ref:u,type:"button",disabled:r,style:designTokens.mergeStyles(Xr,Kr[t],jr[n],r&&Zr,o),className:s,...d,children:e}));At.displayName="IconButton";var si={position:"absolute",inset:0,display:"flex",alignItems:"center",justifyContent:"center",zIndex:designTokens.zIndices.overlay},ai={display:"flex",alignItems:"center",justifyContent:"center",backgroundColor:"rgba(0, 0, 0, 0.5)",borderRadius:"50%",backdropFilter:"blur(8px)",WebkitBackdropFilter:"blur(8px)",cursor:"pointer"},li=({size:e})=>jsxRuntime.jsx("svg",{width:e*.4,height:e*.4,viewBox:"0 0 24 24",fill:designTokens.colors.text,children:jsxRuntime.jsx("polygon",{points:"5 3 19 12 5 21 5 3"})}),di=({size:e})=>jsxRuntime.jsxs("svg",{width:e*.35,height:e*.35,viewBox:"0 0 24 24",fill:designTokens.colors.text,children:[jsxRuntime.jsx("rect",{x:"6",y:"4",width:"4",height:"16"}),jsxRuntime.jsx("rect",{x:"14",y:"4",width:"4",height:"16"})]});function lt({isPlaying:e,show:t,onToggle:n,size:r=72,autoHideDelay:o=1e3,showOnStateChange:s=true,style:d,className:u=""}){let[l,m]=react.useState(false),[i,a]=react.useState(false),p=t!==void 0,c=p?t:l;react.useEffect(()=>{if(!(p||!s||!i)&&(m(true),o>0)){let b=setTimeout(()=>{m(false);},o);return ()=>clearTimeout(b)}},[e,p,s,o,i]);let g=react.useCallback(()=>{n&&(a(true),m(true),n());},[n]),f=!!n,S=f?"auto":"none";return jsxRuntime.jsx(react$1.AnimatePresence,{children:c&&jsxRuntime.jsx(react$1.motion.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.15},style:designTokens.mergeStyles(si,{pointerEvents:S},d),className:u,onClick:g,children:jsxRuntime.jsx(react$1.motion.div,{initial:{scale:.8,opacity:0},animate:{scale:1,opacity:1},exit:{scale:.8,opacity:0},transition:{type:"spring",...designTokens.springs.default},whileTap:f?{scale:.9}:void 0,style:{...ai,width:r,height:r,cursor:f?"pointer":"default"},children:e?jsxRuntime.jsx(di,{size:r}):jsxRuntime.jsx(li,{size:r})})})})}var gi={position:"fixed",inset:0,backgroundColor:"rgba(0, 0, 0, 0.6)",zIndex:designTokens.zIndices.modal},yi={position:"fixed",left:0,right:0,bottom:0,backgroundColor:designTokens.colors.overlay,backdropFilter:"blur(20px)",WebkitBackdropFilter:"blur(20px)",borderTopLeftRadius:designTokens.radii.xl,borderTopRightRadius:designTokens.radii.xl,zIndex:designTokens.zIndices.modal+1,display:"flex",flexDirection:"column",maxHeight:"90vh"},vi={width:designTokens.components.bottomSheet.handleWidth,height:designTokens.components.bottomSheet.handleHeight,backgroundColor:"rgba(255, 255, 255, 0.3)",borderRadius:2,margin:"12px auto 0",flexShrink:0},bi={display:"flex",alignItems:"center",justifyContent:"space-between",padding:`${designTokens.spacing[4]}px ${designTokens.spacing[4]}px ${designTokens.spacing[3]}px`,flexShrink:0},Si={fontSize:18,fontWeight:600,color:designTokens.colors.text},wi={width:32,height:32,display:"flex",alignItems:"center",justifyContent:"center",background:"none",border:"none",cursor:"pointer",color:designTokens.colors.textSecondary,borderRadius:"50%"},Pi={flex:1,overflow:"auto",WebkitOverflowScrolling:"touch"},Ei=()=>jsxRuntime.jsxs("svg",{width:20,height:20,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,children:[jsxRuntime.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),jsxRuntime.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]});function xn({isOpen:e,onClose:t,title:n,children:r,height:o="60vh",maxHeight:s="90vh",showClose:d=true,showHandle:u=true,style:l,className:m=""}){let i=react.useCallback(a=>{a.key==="Escape"&&t();},[t]);return react.useEffect(()=>(e&&(document.addEventListener("keydown",i),document.body.style.overflow="hidden"),()=>{document.removeEventListener("keydown",i),document.body.style.overflow="";}),[e,i]),jsxRuntime.jsx(react$1.AnimatePresence,{children:e&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(react$1.motion.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},style:gi,onClick:t}),jsxRuntime.jsxs(react$1.motion.div,{initial:{y:"100%"},animate:{y:0},exit:{y:"100%"},transition:{type:"spring",...designTokens.springs.default},drag:"y",dragConstraints:{top:0,bottom:0},dragElastic:{top:0,bottom:.5},onDragEnd:(a,p)=>{(p.offset.y>100||p.velocity.y>500)&&t();},style:designTokens.mergeStyles(yi,{height:o,maxHeight:s,touchAction:"none"},l),className:m,children:[u&&jsxRuntime.jsx("div",{style:vi}),(n||d)&&jsxRuntime.jsxs("div",{style:bi,children:[jsxRuntime.jsx("span",{style:Si,children:n}),d&&jsxRuntime.jsx("button",{style:wi,onClick:t,"aria-label":"Close",children:jsxRuntime.jsx(Ei,{})})]}),jsxRuntime.jsx("div",{style:Pi,children:r})]})]})})}function In({size:e=24,color:t=designTokens.colors.text,thickness:n=2,style:r,className:o=""}){return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("style",{children:`
1
+ 'use strict';var dn=require('hls.js'),zustand=require('zustand'),middleware=require('zustand/middleware'),designTokens=require('@xhub-reel/design-tokens'),react=require('react'),react$1=require('motion/react'),jsxRuntime=require('react/jsx-runtime'),react$2=require('@use-gesture/react'),client=require('react-dom/client');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var dn__default=/*#__PURE__*/_interopDefault(dn);var kt={maxBufferLength:30,maxMaxBufferLength:60,maxBufferSize:3e7,maxBufferHole:.5,abrEwmaDefaultEstimate:5e5,abrBandWidthUpFactor:.7,abrBandWidthFactor:.9,startLevel:-1,autoStartLoad:true,startPosition:-1,fragLoadingMaxRetry:3,manifestLoadingMaxRetry:3,levelLoadingMaxRetry:3,fragLoadingTimeOut:2e4,manifestLoadingTimeOut:1e4,levelLoadingTimeOut:1e4,lowLatencyMode:false,liveSyncDuration:3};var et={ACTIVATION_THRESHOLD:.5,DEACTIVATION_THRESHOLD:.3},Re={MAX_VIDEOS_IN_DOM:5,MAX_DECODED_FRAMES:3,MAX_TOTAL_MEMORY:150*1024*1024},Ne={HEIGHT_DEFAULT:2,HEIGHT_ACTIVE:4};var Lt={PLAYER_PREFERENCES:"xhub-reel-player"};var jt={isMuted:true,volume:1,playbackSpeed:1,quality:"auto"},_e=zustand.create()(middleware.persist(e=>({...jt,toggleMute:()=>e(t=>({isMuted:!t.isMuted})),setMuted:t=>e({isMuted:t}),setVolume:t=>e({volume:Math.max(0,Math.min(1,t)),isMuted:t===0}),setPlaybackSpeed:t=>e({playbackSpeed:t}),setQuality:t=>e({quality:t}),resetPreferences:()=>e(jt)}),{name:Lt.PLAYER_PREFERENCES}));var Zt={videos:[],currentIndex:0,isLoading:false,hasMore:true,error:null},Tt=zustand.create(e=>({...Zt,setVideos:t=>e({videos:t,currentIndex:0}),appendVideos:t=>e(n=>({videos:[...n.videos,...t]})),setCurrentIndex:t=>e({currentIndex:t}),goToNext:()=>e(t=>({currentIndex:Math.min(t.currentIndex+1,t.videos.length-1)})),goToPrevious:()=>e(t=>({currentIndex:Math.max(t.currentIndex-1,0)})),removeVideo:t=>e(n=>{let r=n.videos.filter(s=>s.id!==t),o=Math.min(n.currentIndex,r.length-1);return {videos:r,currentIndex:Math.max(0,o)}}),setLoading:t=>e({isLoading:t}),setHasMore:t=>e({hasMore:t}),setError:t=>e({error:t}),reset:()=>e(Zt)}));function Y(...e){return Object.assign({},...e.filter(Boolean))}var Ue={flex:(e={})=>({display:"flex",flexDirection:e.direction,alignItems:e.align,justifyContent:e.justify,gap:typeof e.gap=="number"?e.gap:designTokens.spacing[e.gap||0],flexWrap:e.wrap}),flexCenter:{display:"flex",alignItems:"center",justifyContent:"center"},flexBetween:{display:"flex",alignItems:"center",justifyContent:"space-between"},flexColumn:{display:"flex",flexDirection:"column"},grid:(e={})=>({display:"grid",gridTemplateColumns:typeof e.columns=="number"?`repeat(${e.columns}, 1fr)`:e.columns,gridTemplateRows:typeof e.rows=="number"?`repeat(${e.rows}, 1fr)`:e.rows,gap:typeof e.gap=="number"?e.gap:designTokens.spacing[e.gap||0]}),absolute:(e={})=>({position:"absolute",...e.inset!==void 0&&{inset:e.inset},...e.top!==void 0&&{top:e.top},...e.right!==void 0&&{right:e.right},...e.bottom!==void 0&&{bottom:e.bottom},...e.left!==void 0&&{left:e.left}}),fixed:(e={})=>({position:"fixed",...e.inset!==void 0&&{inset:e.inset},...e.top!==void 0&&{top:e.top},...e.right!==void 0&&{right:e.right},...e.bottom!==void 0&&{bottom:e.bottom},...e.left!==void 0&&{left:e.left}}),fullScreen:{position:"fixed",inset:0,width:"100%",height:"100%"},fullSize:{width:"100%",height:"100%"},centerAbsolute:{position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)"}};({heading:{fontSize:designTokens.fontSizes.xl,fontWeight:designTokens.fontWeights.bold,color:designTokens.colors.text},body:{fontSize:designTokens.fontSizes.md,fontWeight:designTokens.fontWeights.normal,color:designTokens.colors.text},caption:{fontSize:designTokens.fontSizes.xs,fontWeight:designTokens.fontWeights.normal,color:designTokens.colors.textSecondary},videoText:{color:designTokens.colors.text,textShadow:designTokens.shadows.text}});var Ie={bg:e=>({backgroundColor:e in designTokens.colors?designTokens.colors[e]:e}),rounded:(e="md")=>({borderRadius:designTokens.radii[e]}),border:(e={})=>({borderWidth:e.width||1,borderStyle:e.style||"solid",borderColor:e.color?e.color in designTokens.colors?designTokens.colors[e.color]:e.color:designTokens.colors.border}),shadow:(e="md")=>({boxShadow:designTokens.shadows[e]}),opacity:e=>({opacity:e}),glass:(e=20)=>({backgroundColor:designTokens.colors.overlay,backdropFilter:`blur(${e}px)`,WebkitBackdropFilter:`blur(${e}px)`}),glassLight:(e=10)=>({backgroundColor:designTokens.colors.overlayLight,backdropFilter:`blur(${e}px)`,WebkitBackdropFilter:`blur(${e}px)`})},tn={clickable:{cursor:"pointer",userSelect:"none"}},nn={transition:(e="all",t="normal",n="xhubReel")=>({transitionProperty:Array.isArray(e)?e.join(", "):e,transitionDuration:designTokens.durations[t],transitionTimingFunction:designTokens.easings[n]}),noTransition:{transition:"none"}},Qe={scrollY:{overflowY:"auto",overflowX:"hidden",WebkitOverflowScrolling:"touch"},hideScrollbar:{scrollbarWidth:"none",msOverflowStyle:"none"},snapY:{scrollSnapType:"y mandatory",overscrollBehaviorY:"contain"},snapStart:{scrollSnapAlign:"start",scrollSnapStop:"always"}};var rn={square:e=>({width:e,height:e}),width:e=>({width:e}),height:e=>({height:e}),minHeight:e=>({minHeight:e}),maxWidth:e=>({maxWidth:e})};({feedContainer:Y(Ue.fixed({inset:0}),Qe.scrollY,Qe.snapY,Qe.hideScrollbar,Ie.bg("background"),{touchAction:"pan-y"}),feedItem:Y(Ue.fullSize,Qe.snapStart,Ie.bg("background"),{position:"relative"}),actionButton:Y(Ue.flexCenter,rn.square(48),Ie.rounded("full"),tn.clickable,nn.transition(["transform","background-color"])),bottomSheet:Y(Ue.fixed({left:0,right:0,bottom:0}),Ie.glass(),Ie.rounded("xl"),{borderBottomLeftRadius:0,borderBottomRightRadius:0})});var on=class{callbacks={};currentInfo;constructor(){this.currentInfo=this.detectNetwork(),this.setupListeners();}detectNetwork(){let e=navigator.connection;return {online:navigator.onLine,effectiveType:e?.effectiveType??"unknown",downlink:e?.downlink??null,rtt:e?.rtt??null,saveData:e?.saveData??false,type:e?.type??"unknown"}}setupListeners(){window.addEventListener("online",this.handleOnline),window.addEventListener("offline",this.handleOffline);let e=navigator.connection;e&&e.addEventListener("change",this.handleConnectionChange);}handleOnline=()=>{this.currentInfo={...this.currentInfo,online:true},this.callbacks.onOnline?.(),this.callbacks.onNetworkChange?.(this.currentInfo);};handleOffline=()=>{this.currentInfo={...this.currentInfo,online:false},this.callbacks.onOffline?.(),this.callbacks.onNetworkChange?.(this.currentInfo);};handleConnectionChange=()=>{this.currentInfo=this.detectNetwork(),this.callbacks.onNetworkChange?.(this.currentInfo);};subscribe(e){return this.callbacks={...this.callbacks,...e},()=>{this.callbacks={};}}getInfo(){return this.currentInfo}isSlowNetwork(){let{effectiveType:e}=this.currentInfo;return e==="slow-2g"||e==="2g"}getRecommendedConfig(){let{effectiveType:e,saveData:t}=this.currentInfo;return t||e==="slow-2g"||e==="2g"?{maxBufferLength:10,maxMaxBufferLength:20,startLevel:0}:e==="3g"?{maxBufferLength:20,maxMaxBufferLength:40,startLevel:1}:{}}estimateDownloadTime(e){let{downlink:t}=this.currentInfo;if(!t||t===0)return 1/0;let n=t*1e6/8;return e/n}destroy(){window.removeEventListener("online",this.handleOnline),window.removeEventListener("offline",this.handleOffline);let e=navigator.connection;e&&e.removeEventListener("change",this.handleConnectionChange);}};var sn=class{callbacks={};currentInfo={batteryLevel:null,isCharging:false,isLowPowerMode:false};battery=null;constructor(){this.initBattery();}async initBattery(){try{let e=navigator;e.getBattery&&(this.battery=await e.getBattery(),this.updateInfo(),this.setupListeners());}catch{}}updateInfo(){this.battery&&(this.currentInfo={batteryLevel:this.battery.level,isCharging:this.battery.charging,isLowPowerMode:this.battery.level<.2},this.callbacks.onPowerChange?.(this.currentInfo),this.currentInfo.batteryLevel!==null&&this.currentInfo.batteryLevel<.15&&this.callbacks.onLowBattery?.());}setupListeners(){this.battery&&(this.battery.addEventListener("levelchange",()=>this.updateInfo()),this.battery.addEventListener("chargingchange",()=>this.updateInfo()));}subscribe(e){return this.callbacks={...this.callbacks,...e},()=>{this.callbacks={};}}getInfo(){return this.currentInfo}isPowerSaving(){return this.currentInfo.isLowPowerMode&&!this.currentInfo.isCharging}getRecommendedConfig(){return this.isPowerSaving()?{maxBufferLength:15,capLevelToPlayerSize:true}:{}}destroy(){this.callbacks={};}};var an=class{queue=[];preloaded=new Set;loading=new Set;callbacks={};options;paused=false;velocityThreshold=2e3;constructor(e={}){this.options={maxConcurrent:e.maxConcurrent??2,maxQueue:e.maxQueue??5};}enqueue(e){let t=e.id??e.url;if(!(this.preloaded.has(e.url)||this.queue.some(n=>n.url===e.url))){if(this.queue.length>=this.options.maxQueue){let n=this.queue.shift();n&&this.callbacks.onPreloadCancel?.(n);}this.queue.push({...e,id:t,status:"pending"}),this.queue.sort((n,r)=>r.priority-n.priority),this.processQueue();}}enqueueMany(e){e.forEach(t=>this.enqueue(t));}cancel(e){let t=this.queue.find(n=>n.url===e);t&&(this.queue=this.queue.filter(n=>n.url!==e),this.loading.delete(t.id),this.callbacks.onPreloadCancel?.(t));}cancelAll(){this.queue.forEach(e=>{this.callbacks.onPreloadCancel?.(e);}),this.queue=[],this.loading.clear();}add(e,t,n=0){this.enqueue({id:e,url:t,priority:n});}remove(e){this.queue=this.queue.filter(t=>t.id!==e),this.loading.delete(e);}clear(){this.cancelAll(),this.preloaded.clear();}setPaused(e){this.paused=e,e||this.processQueue();}handleScrollVelocity(e){Math.abs(e)>this.velocityThreshold?this.setPaused(true):this.setPaused(false);}isPreloaded(e){return this.preloaded.has(e)}getStatus(e){let t=this.queue.find(n=>n.url===e);return t?t.status:this.preloaded.has(e)?"loaded":null}getAllStatuses(){return this.queue.map(e=>e.status)}getPreloadedUrls(){return Array.from(this.preloaded)}subscribe(e){return this.callbacks={...this.callbacks,...e},()=>{this.callbacks={};}}processQueue(){if(!this.paused)for(;this.loading.size<this.options.maxConcurrent&&this.queue.some(e=>e.status==="pending");){let e=this.queue.find(t=>t.status==="pending");e&&this.preloadItem(e);}}async preloadItem(e){e.status="loading",this.loading.add(e.id),this.callbacks.onPreloadStart?.(e);try{let t=document.createElement("link");t.rel="preload",t.as="fetch",t.href=e.url,t.crossOrigin="anonymous",document.head.appendChild(t),await new Promise((n,r)=>{t.onload=()=>n(),t.onerror=()=>r(new Error("Preload failed"));}),e.status="loaded",this.preloaded.add(e.url),this.callbacks.onPreloadComplete?.(e);}catch(t){e.status="error",this.callbacks.onPreloadError?.(e,t);}finally{this.loading.delete(e.id),this.processQueue();}}destroy(){this.clear(),this.callbacks={};}};var ln=class{metrics=this.createEmptyMetrics();callbacks={};bufferingStartTime=null;playStartTime=null;isPlaying=false;createEmptyMetrics(){return {videoId:null,sessionStartTime:null,playbackStartTime:null,totalPlayTime:0,totalBufferingTime:0,bufferingCount:0,qualitySwitches:[],errors:[],seeks:[],avgBitrate:0,startupTime:null}}startSession(e,t){this.metrics={...this.createEmptyMetrics(),videoId:e,sessionStartTime:Date.now()},this.notifyUpdate();}endSession(){this.isPlaying&&this.playStartTime&&(this.metrics.totalPlayTime+=Date.now()-this.playStartTime),this.isPlaying=false,this.playStartTime=null;let e={...this.metrics};return this.callbacks.onSessionEnd?.(e),e}trackFirstFrame(){this.metrics.sessionStartTime&&!this.metrics.playbackStartTime&&(this.metrics.playbackStartTime=Date.now(),this.metrics.startupTime=this.metrics.playbackStartTime-this.metrics.sessionStartTime,this.isPlaying=true,this.playStartTime=Date.now(),this.notifyUpdate());}trackBuffering(e){let t=Date.now();e&&!this.bufferingStartTime?(this.bufferingStartTime=t,this.metrics.bufferingCount++):!e&&this.bufferingStartTime&&(this.metrics.totalBufferingTime+=t-this.bufferingStartTime,this.bufferingStartTime=null),this.notifyUpdate();}trackQualitySwitch(e,t,n){this.metrics.qualitySwitches.push({timestamp:Date.now(),fromLevel:e,toLevel:t,automatic:n}),this.notifyUpdate();}trackError(e,t,n){let r=typeof e=="string"?e:e.message;this.metrics.errors.push({timestamp:Date.now(),message:r,recoverable:t}),this.notifyUpdate();}trackBitrate(e){this.metrics.avgBitrate=e,this.notifyUpdate();}trackReplay(){this.playStartTime=Date.now(),this.isPlaying=true,this.notifyUpdate();}trackSeek(e,t,n){this.metrics.seeks.push({timestamp:Date.now(),from:e,to:t,latency:n}),this.notifyUpdate();}subscribe(e){return this.callbacks={...this.callbacks,...e},()=>{this.callbacks={};}}getMetrics(){return {...this.metrics}}notifyUpdate(){this.callbacks.onMetricsUpdate?.(this.getMetrics());}destroy(){this.endSession(),this.callbacks={};}};var It=class pn{hls=null;video=null;options;retryCount=0;maxRetries=3;constructor(t={}){this.options=t;}static isSupported(){return dn__default.default.isSupported()}attach(t,n){if(this.destroy(),this.video=t,this.retryCount=0,!pn.isSupported()){this.options.callbacks?.onError?.(new Error("HLS.js is not supported in this browser"),false);return}this.options.callbacks?.onStateChange?.("loading"),this.hls=new dn__default.default({...kt,...this.options.config}),this.setupHLSListeners(),this.setupVideoListeners(),this.hls.attachMedia(t),this.hls.loadSource(n);}loadSource(t){if(!this.hls||!this.video)throw new Error("HLS engine not attached to video element");this.retryCount=0,this.options.callbacks?.onStateChange?.("loading"),this.hls.loadSource(t);}destroy(){this.video&&(this.removeVideoListeners(),this.video=null),this.hls&&(this.hls.destroy(),this.hls=null);}getQualityLevels(){return this.hls?this.hls.levels.map(t=>({label:`${t.height}p`,height:t.height,bitrate:t.bitrate})):[]}setQuality(t){this.hls&&(this.hls.currentLevel=t);}getCurrentQuality(){return this.hls?.currentLevel??-1}getBandwidth(){return this.hls?.bandwidthEstimate??0}isAutoQuality(){return this.hls?.autoLevelEnabled??true}startLoad(t){this.hls?.startLoad(t);}stopLoad(){this.hls?.stopLoad();}setupHLSListeners(){this.hls&&(this.hls.on(dn.Events.MANIFEST_PARSED,(t,n)=>{let r=this.getQualityLevels();this.options.callbacks?.onQualityLevelsLoaded?.(r),this.options.callbacks?.onStateChange?.("ready"),this.video?.autoplay&&this.video.play().catch(()=>{});}),this.hls.on(dn.Events.LEVEL_SWITCHED,(t,n)=>{this.options.callbacks?.onQualityChange?.(n.level,this.isAutoQuality());}),this.hls.on(dn.Events.FRAG_LOADED,()=>{this.options.callbacks?.onBandwidthUpdate?.(this.getBandwidth());}),this.hls.on(dn.Events.ERROR,(t,n)=>{this.handleError(n);}));}setupVideoListeners(){this.video&&(this.video.addEventListener("playing",this.handlePlaying),this.video.addEventListener("pause",this.handlePause),this.video.addEventListener("waiting",this.handleWaiting),this.video.addEventListener("ended",this.handleEnded),this.video.addEventListener("canplay",this.handleCanPlay),this.video.addEventListener("error",this.handleVideoError));}removeVideoListeners(){this.video&&(this.video.removeEventListener("playing",this.handlePlaying),this.video.removeEventListener("pause",this.handlePause),this.video.removeEventListener("waiting",this.handleWaiting),this.video.removeEventListener("ended",this.handleEnded),this.video.removeEventListener("canplay",this.handleCanPlay),this.video.removeEventListener("error",this.handleVideoError));}handlePlaying=()=>{this.options.callbacks?.onStateChange?.("playing");};handlePause=()=>{this.options.callbacks?.onStateChange?.("paused");};handleWaiting=()=>{this.options.callbacks?.onStateChange?.("buffering");};handleEnded=()=>{this.options.callbacks?.onStateChange?.("ended");};handleCanPlay=()=>{this.video?.paused&&this.options.callbacks?.onStateChange?.("ready");};handleVideoError=()=>{let t=this.video?.error;this.options.callbacks?.onError?.(new Error(t?.message??"Video playback error"),false),this.options.callbacks?.onStateChange?.("error");};handleError(t){if(t.fatal){let n=false;switch(t.type){case dn.ErrorTypes.NETWORK_ERROR:this.retryCount<this.maxRetries&&(this.retryCount++,console.warn(`[HLSEngine] Network error, retry ${this.retryCount}/${this.maxRetries}`),this.hls?.startLoad(),n=true);break;case dn.ErrorTypes.MEDIA_ERROR:console.warn("[HLSEngine] Media error, attempting recovery"),this.hls?.recoverMediaError(),n=true;break}n?this.options.callbacks?.onError?.(new Error(`HLS error (recovering): ${t.details}`),true):(this.options.callbacks?.onError?.(new Error(`HLS fatal error: ${t.details}`),false),this.options.callbacks?.onStateChange?.("error"),this.destroy());}else console.warn("[HLSEngine] Non-fatal error:",t.details);}};async function fn(e,t={}){try{return await e.play(),{success:!0}}catch(n){let r=n;if(r.name==="NotAllowedError"){e.muted=true;try{return await e.play(),{success:!0,mutedAutoplay:!0}}catch{return t.onNeedsUserGesture?.(),{success:false,reason:"user_gesture_required"}}}return {success:false,reason:"unknown",error:r}}}var hn=[.5,1,1.5,2],it=class Mt{video=null;options;lastQuality=null;bandwidthSamples=[];constructor(t={}){this.options=t;}static isSupported(){return typeof document>"u"?false:document.createElement("video").canPlayType("application/vnd.apple.mpegurl")!==""}static isIOS(){return typeof navigator>"u"?false:/iPad|iPhone|iPod/.test(navigator.userAgent)||navigator.platform==="MacIntel"&&navigator.maxTouchPoints>1}attach(t,n){this.destroy(),this.video=t,this.options.callbacks?.onStateChange?.("loading"),this.setupVideoListeners(),t.src=n,t.load();}loadSource(t){if(!this.video)throw new Error("Native HLS not attached to video element");this.options.callbacks?.onStateChange?.("loading"),this.video.src=t,this.video.load();}async play(){return this.video?fn(this.video,{onNeedsUserGesture:this.options.callbacks?.onNeedsUserGesture}):{success:false,reason:"unknown"}}destroy(){this.video&&(this.removeVideoListeners(),this.video.removeAttribute("src"),this.video.load(),this.video=null),this.bandwidthSamples=[],this.lastQuality=null;}getQualityLevels(){let t=this.estimateCurrentQuality(),n=[{label:"Auto",height:0,bitrate:0}];return t&&n.push(t),n}setQuality(t){console.warn("[NativeHLS] Quality selection not supported, using auto");}getCurrentQuality(){return -1}estimateCurrentQuality(){if(!this.video||this.video.videoHeight===0)return null;let t=this.video.videoHeight,n=this.estimateBitrate();return {label:`${t}p`,height:t,bitrate:n}}estimateBitrate(){if(this.bandwidthSamples.length>0){let n=this.bandwidthSamples.reduce((r,o)=>r+o,0);return Math.round(n/this.bandwidthSamples.length)}if(!this.video)return 0;let t=this.video.videoHeight;return t>=1080?5e6:t>=720?25e5:t>=480?1e6:t>=360?5e5:25e4}getBandwidth(){return this.estimateBitrate()}isAutoQuality(){return true}startLoad(){this.video?.load();}stopLoad(){this.video&&(this.video.preload="none");}async enterFullscreen(){let t=this.video;if(t){if(t.requestFullscreen){await t.requestFullscreen();return}t.webkitEnterFullscreen&&await t.webkitEnterFullscreen();}}async exitFullscreen(){let t=this.video;if(t){if(document.exitFullscreen){await document.exitFullscreen();return}t.webkitExitFullscreen&&await t.webkitExitFullscreen();}}isFullscreen(){let t=this.video;return t?document.fullscreenElement?document.fullscreenElement===t:t.webkitDisplayingFullscreen??false:false}isFullscreenSupported(){let t=this.video;return t?!!(t.requestFullscreen||t.webkitSupportsFullscreen):false}isPlaybackRateSupported(t){return Mt.isIOS()?hn.includes(t):t>=.5&&t<=2}getSupportedPlaybackRates(){return Mt.isIOS()?[...hn]:[.5,.75,1,1.25,1.5,2]}setupVideoListeners(){this.video&&(this.video.addEventListener("loadedmetadata",this.handleLoadedMetadata),this.video.addEventListener("playing",this.handlePlaying),this.video.addEventListener("pause",this.handlePause),this.video.addEventListener("waiting",this.handleWaiting),this.video.addEventListener("ended",this.handleEnded),this.video.addEventListener("canplay",this.handleCanPlay),this.video.addEventListener("error",this.handleError),this.video.addEventListener("resize",this.handleResize),this.video.addEventListener("progress",this.handleProgress));}removeVideoListeners(){this.video&&(this.video.removeEventListener("loadedmetadata",this.handleLoadedMetadata),this.video.removeEventListener("playing",this.handlePlaying),this.video.removeEventListener("pause",this.handlePause),this.video.removeEventListener("waiting",this.handleWaiting),this.video.removeEventListener("ended",this.handleEnded),this.video.removeEventListener("canplay",this.handleCanPlay),this.video.removeEventListener("error",this.handleError),this.video.removeEventListener("resize",this.handleResize),this.video.removeEventListener("progress",this.handleProgress));}handleLoadedMetadata=()=>{let t=this.getQualityLevels();this.options.callbacks?.onQualityLevelsLoaded?.(t),this.options.callbacks?.onStateChange?.("ready"),this.checkQualityChange();};handlePlaying=()=>{this.options.callbacks?.onStateChange?.("playing");};handlePause=()=>{this.options.callbacks?.onStateChange?.("paused");};handleWaiting=()=>{this.options.callbacks?.onStateChange?.("buffering");};handleEnded=()=>{this.options.callbacks?.onStateChange?.("ended");};handleCanPlay=()=>{this.video?.paused&&this.options.callbacks?.onStateChange?.("ready");};handleError=()=>{let t=this.video?.error,n=t?.message??"Video playback error",r=t?.code!==MediaError.MEDIA_ERR_SRC_NOT_SUPPORTED;this.options.callbacks?.onError?.(new Error(n),r),this.options.callbacks?.onStateChange?.("error");};handleResize=()=>{this.checkQualityChange();};handleProgress=()=>{this.updateBandwidthEstimate();};checkQualityChange(){let t=this.estimateCurrentQuality();t&&(!this.lastQuality||this.lastQuality.height!==t.height)&&(this.lastQuality=t,this.options.callbacks?.onQualityChange?.(t));}updateBandwidthEstimate(){if(this.video&&typeof performance<"u"&&performance.getEntriesByType){let n=performance.getEntriesByType("resource").filter(r=>r.initiatorType==="video"||r.name.includes(".ts")||r.name.includes(".m3u8"));if(n.length>0){let o=n.slice(-5).filter(s=>s.transferSize>0&&s.duration>0).map(s=>s.transferSize*8/(s.duration/1e3));if(o.length>0){let s=o.reduce((a,d)=>a+d,0)/o.length;this.bandwidthSamples.push(s),this.bandwidthSamples.length>10&&this.bandwidthSamples.shift(),this.options.callbacks?.onBandwidthUpdate?.(s);}}}}},mn=class{engine=null;video=null;options;isNative=false;animationFrameId=null;isTracking=false;networkDetector=null;powerManager=null;preloadManager=null;analytics=null;cleanupFunctions=[];wasPlayingBeforeOffline=false;wasPlayingBeforeLowBattery=false;constructor(e={}){this.options={enableNetworkAdaptation:true,enablePowerAdaptation:true,enableAnalytics:false,...e},this.isNative=this.shouldUseNative(),this.initializeServices();}static isSupported(){return It.isSupported()||it.isSupported()}attach(e,t,n){this.video=e,this.destroyEngine(),this.setupVideoListeners(),this.analytics&&n&&this.analytics.startSession(n,e);let r=this.getAdaptedConfig();this.isNative?this.engine=new it({callbacks:{onStateChange:this.options.callbacks?.onStateChange,onError:this.options.callbacks?.onError,onQualityLevelsLoaded:this.options.callbacks?.onQualityLevelsLoaded,onBandwidthUpdate:this.options.callbacks?.onBandwidthUpdate,onNeedsUserGesture:this.options.callbacks?.onNeedsUserGesture,onQualityChange:o=>{this.options.callbacks?.onQualityChange?.(-1,o);}}}):this.engine=new It({config:r,callbacks:{onStateChange:this.options.callbacks?.onStateChange,onError:this.options.callbacks?.onError,onQualityLevelsLoaded:this.options.callbacks?.onQualityLevelsLoaded,onBandwidthUpdate:this.options.callbacks?.onBandwidthUpdate,onQualityChange:(o,s)=>{let a=this.engine?.getQualityLevels()??[],d=o>=0&&o<a.length?a[o]:void 0;this.options.callbacks?.onQualityChange?.(s?-1:o,d);}}}),this.engine.attach(e,t);}loadSource(e,t){if(!this.engine||!this.video)throw new Error("Player not attached to video element");this.analytics&&(this.analytics.endSession(),t&&this.analytics.startSession(t,this.video)),this.engine.loadSource(e);}destroy(){this.destroyEngine(),this.destroyServices();}async play(){return this.video?this.isNative&&this.engine instanceof it?this.engine.play():fn(this.video,{onNeedsUserGesture:this.options.callbacks?.onNeedsUserGesture}):{success:false,reason:"unknown"}}pause(){this.video?.pause();}async togglePlay(){return this.video?.paused?this.play():(this.pause(),{success:true})}seek(e){if(this.video){let t=this.video.currentTime;this.video.currentTime=Math.max(0,Math.min(e,this.video.duration||0)),this.analytics?.trackSeek(t,e,0);}}seekForward(e=10){this.video&&this.seek(this.video.currentTime+e);}seekBackward(e=10){this.video&&this.seek(this.video.currentTime-e);}getCurrentTime(){return this.video?.currentTime??0}getDuration(){return this.video?.duration??0}setVolume(e){this.video&&(this.video.volume=Math.max(0,Math.min(1,e)));}getVolume(){return this.video?.volume??1}setMuted(e){this.video&&(this.video.muted=e);}isMuted(){return this.video?.muted??true}toggleMute(){this.setMuted(!this.isMuted());}setPlaybackRate(e){this.video&&(this.video.playbackRate=e);}getPlaybackRate(){return this.video?.playbackRate??1}getQualityLevels(){return this.engine?.getQualityLevels()??[]}setQuality(e){let t=this.getCurrentQuality();this.engine?.setQuality(e),t!==e&&this.analytics?.trackQualitySwitch(t,e,e===-1);}getCurrentQuality(){return this.engine?.getCurrentQuality()??-1}isUsingNative(){return this.isNative}getVideoElement(){return this.video}getBuffered(){if(!this.video)return 0;let e=this.video.buffered,t=this.video.currentTime;for(let n=0;n<e.length;n++)if(t>=e.start(n)&&t<=e.end(n))return e.end(n)-t;return 0}getNetworkInfo(){return this.networkDetector?.getInfo()??null}getPowerInfo(){return this.powerManager?.getInfo()??null}getPreloadManager(){return this.preloadManager}getAnalytics(){return this.analytics?.getMetrics()??null}isSlowNetwork(){return this.networkDetector?.isSlowNetwork()??false}isPowerSaving(){return this.powerManager?.isPowerSaving()??false}shouldUseNative(){return this.options.preferNative!==false&&it.isSupported()?true:!It.isSupported()}initializeServices(){if(this.options.enableNetworkAdaptation){this.networkDetector=new on;let e=this.networkDetector.subscribe({onNetworkChange:this.handleNetworkChange,onOffline:()=>this.options.callbacks?.onError?.(new Error("Network offline"),true)});this.cleanupFunctions.push(e);}if(this.options.enablePowerAdaptation){this.powerManager=new sn;let e=this.powerManager.subscribe({onPowerChange:this.handlePowerChange});this.cleanupFunctions.push(e),this.cleanupFunctions.push(()=>this.powerManager?.destroy());}if(this.options.preloadConfig&&(this.preloadManager=new an(this.options.preloadConfig),this.cleanupFunctions.push(()=>this.preloadManager?.destroy())),this.options.enableAnalytics){this.analytics=new ln;let e=this.analytics.subscribe({onMetricsUpdate:t=>this.options.callbacks?.onAnalyticsUpdate?.(t)});this.cleanupFunctions.push(e),this.cleanupFunctions.push(()=>this.analytics?.destroy());}}destroyServices(){this.cleanupFunctions.forEach(e=>e()),this.cleanupFunctions=[],this.networkDetector=null,this.powerManager=null,this.preloadManager=null,this.analytics=null;}destroyEngine(){this.stopProgressTracking(),this.removeVideoListeners(),this.engine&&(this.engine.destroy(),this.engine=null);}getAdaptedConfig(){let e={};return this.networkDetector&&(e={...e,...this.networkDetector.getRecommendedConfig()}),this.powerManager&&(e={...e,...this.powerManager.getRecommendedConfig()}),e}isNetworkBelowThreshold(e,t){let n=["slow-2g","2g","3g","4g","5g","unknown"],r=n.indexOf(e),o=n.indexOf(t);return e==="unknown"?false:r>=0&&r<=o}handleNetworkChange=e=>{this.options.callbacks?.onNetworkChange?.(e);let t=this.options.lowQualityThreshold??"2g",n=this.isNetworkBelowThreshold(e.effectiveType,t);this.options.autoQualityOnNetworkChange&&this.engine&&(n?this.setQuality(0):(e.effectiveType==="4g"||e.effectiveType==="5g")&&this.setQuality(-1)),this.options.autoPauseOnOffline&&!e.online&&(this.wasPlayingBeforeOffline=this.video?!this.video.paused:false,this.pause()),this.options.autoResumeOnOnline&&e.online&&this.wasPlayingBeforeOffline&&(this.play(),this.wasPlayingBeforeOffline=false),this.preloadManager&&this.preloadManager.setPaused(e.effectiveType==="2g"||!e.online);};handlePowerChange=e=>{this.options.callbacks?.onPowerChange?.(e);let t=this.options.lowBatteryThreshold??.15,n=e.batteryLevel!==null&&e.batteryLevel<t;this.options.autoPauseOnLowBattery&&n&&!e.isCharging&&(this.wasPlayingBeforeLowBattery=this.video?!this.video.paused:false,this.pause()),this.wasPlayingBeforeLowBattery&&(e.isCharging||e.batteryLevel!==null&&e.batteryLevel>=t+.05)&&(this.play(),this.wasPlayingBeforeLowBattery=false),this.preloadManager&&e.isLowPowerMode&&this.preloadManager.setPaused(true);};setupVideoListeners(){this.video&&(this.video.addEventListener("timeupdate",this.handleTimeUpdate),this.video.addEventListener("progress",this.handleProgress),this.video.addEventListener("volumechange",this.handleVolumeChange),this.video.addEventListener("ratechange",this.handleRateChange),this.video.addEventListener("play",this.handlePlay),this.video.addEventListener("pause",this.handlePause),this.video.addEventListener("ended",this.handleEnded),this.video.addEventListener("waiting",this.handleWaiting),this.video.addEventListener("playing",this.handlePlaying));}removeVideoListeners(){this.video&&(this.video.removeEventListener("timeupdate",this.handleTimeUpdate),this.video.removeEventListener("progress",this.handleProgress),this.video.removeEventListener("volumechange",this.handleVolumeChange),this.video.removeEventListener("ratechange",this.handleRateChange),this.video.removeEventListener("play",this.handlePlay),this.video.removeEventListener("pause",this.handlePause),this.video.removeEventListener("ended",this.handleEnded),this.video.removeEventListener("waiting",this.handleWaiting),this.video.removeEventListener("playing",this.handlePlaying));}handleTimeUpdate=()=>{this.video&&this.options.callbacks?.onTimeUpdate?.(this.video.currentTime,this.video.duration||0);};handleProgress=()=>{this.options.callbacks?.onProgress?.(this.getBuffered());};handleVolumeChange=()=>{this.video&&this.options.callbacks?.onVolumeChange?.(this.video.volume,this.video.muted);};handleRateChange=()=>{this.video&&this.options.callbacks?.onRateChange?.(this.video.playbackRate);};handlePlay=()=>{this.options.enableSmoothTimeUpdates&&this.startProgressTracking();};handlePause=()=>{this.stopProgressTracking();};handleEnded=()=>{this.stopProgressTracking(),this.analytics&&this.analytics.endSession();};handleWaiting=()=>{this.analytics?.trackBuffering(true);};handlePlaying=()=>{this.analytics?.trackBuffering(false),this.analytics?.trackFirstFrame();};startProgressTracking(){if(this.isTracking||!this.video)return;this.isTracking=true;let e=()=>{if(!this.video||this.video.paused||this.video.ended){this.isTracking=false,this.animationFrameId=null;return}this.options.callbacks?.onTimeUpdate?.(this.video.currentTime,this.video.duration||0),this.animationFrameId=requestAnimationFrame(e);};this.animationFrameId=requestAnimationFrame(e);}stopProgressTracking(){this.animationFrameId!==null&&(cancelAnimationFrame(this.animationFrameId),this.animationFrameId=null),this.isTracking=false;}},Cr=[{from:"idle",to:"loading"},{from:"loading",to:"ready"},{from:"loading",to:"error"},{from:"ready",to:"playing"},{from:"ready",to:"loading"},{from:"ready",to:"error"},{from:"playing",to:"paused"},{from:"playing",to:"buffering"},{from:"playing",to:"ended"},{from:"playing",to:"error"},{from:"playing",to:"loading"},{from:"paused",to:"playing"},{from:"paused",to:"buffering"},{from:"paused",to:"loading"},{from:"paused",to:"error"},{from:"buffering",to:"playing"},{from:"buffering",to:"paused"},{from:"buffering",to:"stalled"},{from:"buffering",to:"error"},{from:"stalled",to:"playing"},{from:"stalled",to:"buffering"},{from:"stalled",to:"error"},{from:"stalled",to:"loading"},{from:"ended",to:"playing"},{from:"ended",to:"loading"},{from:"ended",to:"idle"},{from:"error",to:"loading"},{from:"error",to:"idle"},{from:"*",to:"idle"}],kr=class{_state="idle";listeners=new Set;stalledTimeout=null;stalledThreshold=3e3;get state(){return this._state}transition(e){if(!this.canTransition(e))return console.warn(`[PlayerStateMachine] Invalid transition: ${this._state} -> ${e}`),false;let n=this._state;return this._state=e,e==="buffering"?this.startStalledTimer():this.clearStalledTimer(),this.listeners.forEach(r=>r(e,n)),true}canTransition(e){let t=Cr.find(n=>(n.from===this._state||n.from==="*")&&n.to===e);return !(!t||t.guard&&!t.guard())}subscribe(e){return this.listeners.add(e),()=>this.listeners.delete(e)}reset(){this.clearStalledTimer(),this._state="idle";}isPlaying(){return this._state==="playing"}canPlay(){return ["ready","paused","ended"].includes(this._state)}isLoading(){return ["loading","buffering"].includes(this._state)}hasError(){return this._state==="error"}startStalledTimer(){this.clearStalledTimer(),this.stalledTimeout=setTimeout(()=>{this._state==="buffering"&&this.transition("stalled");},this.stalledThreshold);}clearStalledTimer(){this.stalledTimeout&&(clearTimeout(this.stalledTimeout),this.stalledTimeout=null);}};function Lr(){return new kr}function gn(){let e=react.useMemo(()=>Lr(),[]),[t,n]=react.useState(e.state);react.useEffect(()=>e.subscribe(a=>{n(a);}),[e]);let r=react.useCallback(s=>e.transition(s),[e]),o=react.useCallback(()=>{e.reset(),n("idle");},[e]);return {state:t,isPlaying:t==="playing",isPaused:t==="paused",isLoading:t==="loading",isBuffering:t==="buffering",isStalled:t==="stalled",isEnded:t==="ended",hasError:t==="error",canPlay:e.canPlay(),transition:r,reset:o}}function yn(e){let{volume:t,isMuted:n,setVolume:r,toggleMute:o,setMuted:s}=_e();react.useEffect(()=>{let i=e.current;i&&(i.volume=t,i.muted=n);},[e,t,n]),react.useEffect(()=>{let i=e.current;if(!i)return;let l=()=>{i.volume!==t&&r(i.volume),i.muted!==n&&s(i.muted);};return i.addEventListener("volumechange",l),()=>i.removeEventListener("volumechange",l)},[e,t,n,r,s]);let a=react.useCallback(i=>{let l=Math.max(0,Math.min(1,i));r(l),e.current&&(e.current.volume=l),l>0&&n&&(s(false),e.current&&(e.current.muted=false));},[e,n,r,s]),d=react.useCallback(()=>{o(),e.current&&(e.current.muted=!n);},[e,n,o]),u=react.useCallback(()=>{n||(s(true),e.current&&(e.current.muted=true));},[e,n,s]),h=react.useCallback(()=>{n&&(s(false),e.current&&(e.current.muted=false));},[e,n,s]);return {volume:t,isMuted:n,setVolume:a,toggleMute:d,mute:u,unmute:h}}function vn(e,t={}){let{enableSmoothTracking:n=false}=t,[r,o]=react.useState(0),[s,a]=react.useState(0),[d,u]=react.useState(0),[h,i]=react.useState([]),l=react.useRef(null),p=react.useRef(false),f=s>0?r/s*100:0,y=react.useCallback(c=>{let v=[],P=c.buffered;for(let R=0;R<P.length;R++)v.push({start:P.start(R),end:P.end(R)});i(v);let x=0;for(let R of v)if(c.currentTime>=R.start&&c.currentTime<=R.end){x=R.end-c.currentTime;break}u(x);},[]),m=react.useCallback(()=>{l.current!==null&&(cancelAnimationFrame(l.current),l.current=null),p.current=false;},[]),b=react.useCallback(()=>{let c=e.current;if(!c||p.current)return;p.current=true;let v=()=>{if(!c||c.paused||c.ended){p.current=false,l.current=null;return}o(c.currentTime),l.current=requestAnimationFrame(v);};l.current=requestAnimationFrame(v);},[e]);react.useEffect(()=>{let c=e.current;if(!c)return;let v=()=>{o(c.currentTime);},P=()=>{a(c.duration||0);},x=()=>{a(c.duration||0);},R=()=>{y(c);},A=()=>{n&&b();},D=()=>{m();},z=()=>{m();},_=()=>{o(c.currentTime);},g=()=>{o(c.currentTime),y(c);};return c.addEventListener("timeupdate",v),c.addEventListener("loadedmetadata",P),c.addEventListener("durationchange",x),c.addEventListener("progress",R),c.addEventListener("play",A),c.addEventListener("pause",D),c.addEventListener("ended",z),c.addEventListener("seeking",_),c.addEventListener("seeked",g),c.readyState>=1&&(a(c.duration||0),o(c.currentTime)),c.readyState>=3&&y(c),!c.paused&&n&&b(),()=>{c.removeEventListener("timeupdate",v),c.removeEventListener("loadedmetadata",P),c.removeEventListener("durationchange",x),c.removeEventListener("progress",R),c.removeEventListener("play",A),c.removeEventListener("pause",D),c.removeEventListener("ended",z),c.removeEventListener("seeking",_),c.removeEventListener("seeked",g),m();}},[e,n,y,b,m]);let S=react.useCallback(c=>{let v=e.current;if(!v||!isFinite(v.duration))return;let P=Math.max(0,Math.min(c,v.duration));v.currentTime=P,o(P);},[e]),V=react.useCallback(c=>{let v=e.current;if(!v||!isFinite(v.duration))return;let x=Math.max(0,Math.min(100,c))/100*v.duration;v.currentTime=x,o(x);},[e]),H=s>0&&isFinite(s);return {currentTime:r,duration:s,buffered:d,progress:f,bufferedRanges:h,seek:S,seekToProgress:V,isSeekable:H,startSmoothTracking:b,stopSmoothTracking:m}}function bn(e){let{quality:t,setQuality:n}=_e(),[r,o]=react.useState(-1),[s,a]=react.useState([]);react.useEffect(()=>{if(!e)return;let i=e.getQualityLevels();a(i),o(e.getCurrentQuality());},[e]),react.useEffect(()=>{if(!(!e||s.length===0))if(t==="auto")e.setQuality(-1),o(-1);else {let i=parseInt(t.replace("p","")),l=s.findIndex(p=>p.height===i);l!==-1&&(e.setQuality(l),o(l));}},[e,t,s]);let d=r===-1,u=react.useCallback(i=>{if(e)if(typeof i=="number")if(e.setQuality(i),o(i),i===-1)n("auto");else {let l=s[i];l&&n(`${l.height}p`);}else n(i);},[e,s,n]),h=react.useCallback(()=>{u("auto");},[u]);return {quality:t,currentLevel:r,availableLevels:s,isAuto:d,setQuality:u,setAuto:h}}function Vt(e){return e<1e3?e.toString():e<1e4?`${(e/1e3).toFixed(1)}K`:e<1e6?`${Math.floor(e/1e3)}K`:`${(e/1e6).toFixed(1)}M`}var Vr={position:"absolute",right:designTokens.spacing[4],bottom:160,display:"flex",flexDirection:"column",alignItems:"center",gap:designTokens.components.actionBar.gap,zIndex:10},Ar={display:"flex",flexDirection:"column",alignItems:"center",gap:designTokens.components.actionBar.iconCountGap,background:"none",border:"none",padding:0,cursor:"pointer"},Fr={width:designTokens.components.actionBar.iconSize,height:designTokens.components.actionBar.iconSize,display:"flex",alignItems:"center",justifyContent:"center"},Or={fontSize:designTokens.fontSizes.xs,fontWeight:designTokens.fontWeights.normal,color:designTokens.colors.text,textShadow:designTokens.shadows.text,lineHeight:designTokens.components.actionBar.counterLineHeight,textAlign:"center"},Hr={display:"flex",flexDirection:"column",alignItems:"center",position:"relative",width:designTokens.components.profileAction.avatarSize,height:55},Sn={width:designTokens.components.profileAction.avatarSize,height:designTokens.components.profileAction.avatarSize,borderRadius:"50%",objectFit:"cover",cursor:"pointer",background:designTokens.colors.surface},Dr={position:"absolute",bottom:0,left:"50%",transform:"translateX(-50%)",width:designTokens.components.profileAction.followButtonSize,height:designTokens.components.profileAction.followButtonSize,borderRadius:"50%",backgroundColor:designTokens.colors.like,border:"none",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center"},Br=({filled:e,color:t="white"})=>e?jsxRuntime.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:designTokens.components.actionBar.iconSize,height:designTokens.components.actionBar.iconSize,viewBox:"0 0 28 28",fill:"none",children:jsxRuntime.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M1.74988 11.0538C1.74988 6.75595 4.69822 2.91699 9.20877 2.91699C11.4347 2.91699 12.9986 3.9593 13.9999 4.96978C15.0011 3.95929 16.565 2.91699 18.791 2.91699C23.3015 2.91699 26.2499 6.75595 26.2499 11.0538C26.2499 15.3962 23.6265 18.9036 20.8781 21.3587C18.1288 23.8145 15.1442 25.3171 14.1843 25.6371L13.9999 25.6985L13.8154 25.6371C12.8555 25.3171 9.87093 23.8145 7.12168 21.3587C4.37329 18.9036 1.74988 15.3962 1.74988 11.0538ZM17.7449 6.41699C17.2617 6.41699 16.8699 6.80874 16.8699 7.29199C16.8699 7.77524 17.2617 8.16699 17.7449 8.16699C19.6221 8.16699 20.9952 9.75855 20.9952 11.8241C20.9952 12.3073 21.387 12.6991 21.8702 12.6991C22.3535 12.6991 22.7452 12.3073 22.7452 11.8241C22.7452 9.02543 20.8066 6.41699 17.7449 6.41699Z",fill:t})}):jsxRuntime.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:designTokens.components.actionBar.iconSize,height:designTokens.components.actionBar.iconSize,viewBox:"0 0 24 24",fill:"none",children:[jsxRuntime.jsx("path",{d:"M15.21 5.5C14.7957 5.5 14.46 5.83579 14.46 6.25C14.46 6.66421 14.7957 7 15.21 7C16.819 7 17.996 8.3642 17.996 10.1346C17.996 10.5488 18.3317 10.8846 18.746 10.8846C19.1602 10.8846 19.496 10.5488 19.496 10.1346C19.496 7.7358 17.8342 5.5 15.21 5.5Z",fill:t}),jsxRuntime.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M7.89327 2.25C3.85788 2.25 1.24994 5.6858 1.24994 9.47438C1.24994 13.301 3.5604 16.37 5.9378 18.4936C8.31629 20.6183 10.9036 21.9251 11.7628 22.2115L11.9999 22.2906L12.2371 22.2115C13.0963 21.9251 15.6836 20.6183 18.0621 18.4936C20.4395 16.37 22.7499 13.301 22.7499 9.47438C22.7499 5.6858 20.142 2.25 16.1066 2.25C14.2397 2.25 12.8941 3.06969 11.9999 3.91063C11.1058 3.06969 9.76018 2.25 7.89327 2.25ZM2.74994 9.47438C2.74994 6.3142 4.8731 3.75 7.89327 3.75C9.60588 3.75 10.7397 4.66987 11.4269 5.48383L11.9999 6.16259L12.573 5.48383C13.2602 4.66987 14.394 3.75 16.1066 3.75C19.1268 3.75 21.2499 6.3142 21.2499 9.47438C21.2499 12.6733 19.3104 15.3672 17.0628 17.375C15.0361 19.1854 12.8741 20.3336 11.9999 20.6978C11.1257 20.3336 8.96379 19.1854 6.93708 17.375C4.68948 15.3672 2.74994 12.6733 2.74994 9.47438Z",fill:t})]}),Nr=()=>jsxRuntime.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:designTokens.components.actionBar.iconSize,height:designTokens.components.actionBar.iconSize,viewBox:"0 0 28 28",fill:"none",children:jsxRuntime.jsx("path",{d:"M14 1.45801C7.07347 1.45801 1.45837 7.0731 1.45837 13.9997C1.45837 16.3815 2.1232 18.6107 3.27778 20.5088L2.36541 23.0178C1.77294 24.6471 3.35258 26.2268 4.98188 25.6343L7.49089 24.7219C9.389 25.8765 11.6182 26.5413 14 26.5413C20.9266 26.5413 26.5417 20.9262 26.5417 13.9997C26.5417 7.0731 20.9266 1.45801 14 1.45801Z",fill:"white"})}),_r=({filled:e})=>jsxRuntime.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:designTokens.components.actionBar.iconSize,height:designTokens.components.actionBar.iconSize,viewBox:"0 0 28 28",fill:"none",children:jsxRuntime.jsx("path",{d:"M16.6904 1.45801H11.2789C10.2487 1.458 9.4224 1.45799 8.75434 1.51253C8.06795 1.56857 7.47186 1.68652 6.92253 1.96632C6.90122 1.97718 6.88036 1.98891 6.86 2.00147C5.64436 2.75199 4.94533 3.52276 4.62739 4.64643C4.48015 5.1668 4.42512 5.72644 4.40084 6.3243C4.38332 6.75558 4.3811 7.24294 4.37866 7.77623C4.37775 7.97537 4.37678 8.18091 4.375 8.39232V24.8275C4.375 25.7739 5.14242 26.5413 6.08883 26.5413C6.51994 26.5413 6.93517 26.3792 7.25226 26.0859L13.3276 20.4783C13.3386 20.4682 13.3493 20.4578 13.3597 20.4471C13.5821 20.2197 13.743 20.0895 13.8601 20.0183C13.9156 19.9846 13.9524 19.9697 13.9731 19.9631C13.9833 19.9599 13.9898 19.9585 13.9933 19.958L13.9975 19.9575L13.9992 19.9574C13.9992 19.9574 14.0065 19.9571 14.0257 19.9632C14.0466 19.9698 14.0837 19.9849 14.1394 20.0187C14.2569 20.0901 14.4182 20.2206 14.641 20.4479C14.6512 20.4583 14.6616 20.4684 14.6724 20.4783L20.7477 26.0859C21.0648 26.3792 21.4801 26.5413 21.9112 26.5413C22.8576 26.5413 23.625 25.7739 23.625 24.8275V8.3619C23.625 7.33168 23.625 6.5054 23.5705 5.83735C23.5144 5.15096 23.3965 4.55487 23.1167 4.00554C23.1058 3.98416 23.094 3.96325 23.0814 3.94284C22.3309 2.72781 21.5599 2.0287 20.4364 1.71046C19.9159 1.56305 19.3562 1.50785 18.7583 1.48352C18.3245 1.46588 17.8344 1.46376 17.2978 1.46144C17.1014 1.46059 16.8988 1.45968 16.6904 1.45801Z",fill:e?designTokens.colors.warning:"white"})}),Ur=()=>jsxRuntime.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:28,height:28,viewBox:"0 0 28 28",fill:"none",children:[jsxRuntime.jsx("path",{d:"M20.6583 8.99195C21.1139 8.53634 21.1139 7.79765 20.6583 7.34203L14.8249 1.5087C14.6061 1.28991 14.3094 1.16699 14 1.16699C13.6905 1.16699 13.3938 1.28991 13.175 1.5087L7.34167 7.34204C6.88606 7.79765 6.88606 8.53634 7.34167 8.99195C7.79728 9.44756 8.53597 9.44756 8.99158 8.99195L12.8333 5.15024L12.8333 17.5003C12.8333 18.1447 13.3556 18.667 14 18.667C14.6443 18.667 15.1666 18.1447 15.1666 17.5003L15.1666 5.15024L19.0083 8.99195C19.4639 9.44756 20.2026 9.44756 20.6583 8.99195Z",fill:"white"}),jsxRuntime.jsx("path",{d:"M24.4562 22.2708C24.4991 21.7457 24.5 21.0663 24.5 20.067V16.3337C24.5 15.6893 25.0223 15.167 25.6666 15.167C26.311 15.167 26.8333 15.6893 26.8333 16.3337L26.8333 20.1152C26.8333 21.0543 26.8333 21.8294 26.7817 22.4608C26.7282 23.1166 26.6132 23.7194 26.3247 24.2856C25.8772 25.1637 25.1633 25.8776 24.2852 26.325C23.719 26.6135 23.1162 26.7285 22.4604 26.7821C21.829 26.8337 21.054 26.8337 20.1149 26.8337H7.88508C6.94599 26.8337 6.17087 26.8337 5.5395 26.7821C4.88372 26.7285 4.28089 26.6135 3.71467 26.325C2.83658 25.8776 2.12267 25.1637 1.67526 24.2856C1.38676 23.7194 1.27176 23.1166 1.21819 22.4608C1.1666 21.8294 1.16661 21.0543 1.16663 20.1152V16.3337C1.16663 15.6893 1.68896 15.167 2.33329 15.167C2.97762 15.167 3.49996 15.6893 3.49996 16.3337L3.49996 20.067C3.49996 21.0663 3.50087 21.7457 3.54377 22.2708C3.58556 22.7823 3.66131 23.0438 3.75428 23.2263C3.97798 23.6653 4.33494 24.0223 4.77398 24.246C4.95645 24.339 5.21802 24.4147 5.7295 24.4565C6.25461 24.4994 6.93395 24.5003 7.93329 24.5003H20.0666C21.066 24.5003 21.7453 24.4994 22.2704 24.4565C22.7819 24.4147 23.0435 24.339 23.2259 24.246C23.665 24.0223 24.0219 23.6653 24.2456 23.2263C24.3386 23.0438 24.4144 22.7823 24.4562 22.2708Z",fill:"white"})]}),Qr=()=>jsxRuntime.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:12,height:12,viewBox:"0 0 12 12",fill:"white",children:jsxRuntime.jsx("path",{d:"M6 1V11M1 6H11",stroke:"white",strokeWidth:2,strokeLinecap:"round"})}),zr=()=>jsxRuntime.jsx("svg",{width:12,height:12,viewBox:"0 0 12 12",fill:"none",children:jsxRuntime.jsx("path",{d:"M2 6L5 9L10 3",stroke:"white",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"})});function Wr({avatarUrl:e,isFollowed:t=false,onClick:n,onFollow:r}){return jsxRuntime.jsxs("div",{style:Hr,children:[jsxRuntime.jsx(react$1.motion.button,{style:{background:"none",border:"none",padding:0,cursor:"pointer"},onClick:n,whileTap:{scale:.95},"aria-label":"View profile",children:e?jsxRuntime.jsx("img",{src:e,alt:"Profile",style:Sn}):jsxRuntime.jsx("div",{style:Sn})}),!t&&r&&jsxRuntime.jsx(react$1.motion.button,{style:Dr,onClick:o=>{o.stopPropagation(),r();},whileTap:{scale:.9},animate:t?{scale:[1,1.2,1]}:{scale:1},transition:{type:"spring",...designTokens.springs.bouncy},"aria-label":t?"Following":"Follow",children:t?jsxRuntime.jsx(zr,{}):jsxRuntime.jsx(Qr,{})})]})}function ot({icon:e,count:t,isActive:n=false,onClick:r,label:o}){return jsxRuntime.jsxs(react$1.motion.button,{style:Ar,onClick:r,"aria-label":o,whileTap:{scale:.9},transition:{type:"spring",...designTokens.springs.bouncy},children:[jsxRuntime.jsx(react$1.motion.div,{style:Fr,animate:n?{scale:[1,1.2,1]}:{scale:1},transition:n?{duration:.3,ease:[.32,.72,0,1]}:{type:"spring",...designTokens.springs.default},children:e}),t!==void 0&&jsxRuntime.jsx("span",{style:Or,children:Vt(t)})]})}function at({likeCount:e,commentCount:t,shareCount:n,saveCount:r,isLiked:o=false,isSaved:s=false,onLike:a,onComment:d,onShare:u,onSave:h,avatarUrl:i,onProfileClick:l,onFollow:p,isFollowed:f=false,style:y,className:m=""}){return jsxRuntime.jsxs("div",{style:designTokens.mergeStyles(Vr,y),className:m,children:[i&&jsxRuntime.jsx(Wr,{avatarUrl:i,isFollowed:f,onClick:l,onFollow:p}),jsxRuntime.jsx(ot,{icon:jsxRuntime.jsx(Br,{filled:o,color:o?designTokens.colors.like:"white"}),count:e,isActive:o,onClick:a,label:o?"Unlike":"Like"}),jsxRuntime.jsx(ot,{icon:jsxRuntime.jsx(Nr,{}),count:t,onClick:d,label:"Comments"}),jsxRuntime.jsx(ot,{icon:jsxRuntime.jsx(_r,{filled:s}),count:r,isActive:s,onClick:h,label:s?"Unsave":"Save"}),jsxRuntime.jsx(ot,{icon:jsxRuntime.jsx(Ur,{}),count:n,onClick:u,label:"Share"})]})}var Kr={display:"inline-flex",alignItems:"center",justifyContent:"center",border:"none",cursor:"pointer",borderRadius:designTokens.radii.full,transitionProperty:"background-color, transform, opacity",transitionDuration:designTokens.durations.fast,transitionTimingFunction:designTokens.easings.xhubReel,userSelect:"none"},jr={sm:{width:32,height:32},md:{width:designTokens.components.tapArea,height:designTokens.components.tapArea},lg:{width:56,height:56}},Zr={default:{backgroundColor:designTokens.colors.surface,color:designTokens.colors.text},ghost:{backgroundColor:"transparent",color:designTokens.colors.text},glass:{backgroundColor:"rgba(0, 0, 0, 0.2)",backdropFilter:"blur(4px)",WebkitBackdropFilter:"blur(4px)",color:designTokens.colors.text}},Jr={opacity:.5,cursor:"not-allowed",pointerEvents:"none"},Ft=react.forwardRef(({icon:e,size:t="md",variant:n="ghost",disabled:r,style:o,className:s="",...a},d)=>jsxRuntime.jsx("button",{ref:d,type:"button",disabled:r,style:designTokens.mergeStyles(Kr,jr[t],Zr[n],r&&Jr,o),className:s,...a,children:e}));Ft.displayName="IconButton";var ai={position:"absolute",inset:0,display:"flex",alignItems:"center",justifyContent:"center",zIndex:designTokens.zIndices.overlay},li={display:"flex",alignItems:"center",justifyContent:"center",backgroundColor:"rgba(0, 0, 0, 0.5)",borderRadius:"50%",backdropFilter:"blur(8px)",WebkitBackdropFilter:"blur(8px)",cursor:"pointer"},di=({size:e})=>jsxRuntime.jsx("svg",{width:e*.4,height:e*.4,viewBox:"0 0 24 24",fill:designTokens.colors.text,children:jsxRuntime.jsx("polygon",{points:"5 3 19 12 5 21 5 3"})}),ui=({size:e})=>jsxRuntime.jsxs("svg",{width:e*.35,height:e*.35,viewBox:"0 0 24 24",fill:designTokens.colors.text,children:[jsxRuntime.jsx("rect",{x:"6",y:"4",width:"4",height:"16"}),jsxRuntime.jsx("rect",{x:"14",y:"4",width:"4",height:"16"})]});function dt({isPlaying:e,show:t,onToggle:n,size:r=72,autoHideDelay:o=1e3,showOnStateChange:s=true,style:a,className:d=""}){let[u,h]=react.useState(false),[i,l]=react.useState(false),p=t!==void 0,f=p?t:u;react.useEffect(()=>{if(!(p||!s||!i)&&(h(true),o>0)){let S=setTimeout(()=>{h(false);},o);return ()=>clearTimeout(S)}},[e,p,s,o,i]);let y=react.useCallback(()=>{n&&(l(true),h(true),n());},[n]),m=!!n,b=m?"auto":"none";return jsxRuntime.jsx(react$1.AnimatePresence,{children:f&&jsxRuntime.jsx(react$1.motion.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.15},style:designTokens.mergeStyles(ai,{pointerEvents:b},a),className:d,onClick:y,children:jsxRuntime.jsx(react$1.motion.div,{initial:{scale:.8,opacity:0},animate:{scale:1,opacity:1},exit:{scale:.8,opacity:0},transition:{type:"spring",...designTokens.springs.default},whileTap:m?{scale:.9}:void 0,style:{...li,width:r,height:r,cursor:m?"pointer":"default"},children:e?jsxRuntime.jsx(ui,{size:r}):jsxRuntime.jsx(di,{size:r})})})})}var yi={position:"fixed",inset:0,backgroundColor:"rgba(0, 0, 0, 0.6)",zIndex:designTokens.zIndices.modal},vi={position:"fixed",left:0,right:0,bottom:0,backgroundColor:designTokens.colors.overlay,backdropFilter:"blur(20px)",WebkitBackdropFilter:"blur(20px)",borderTopLeftRadius:designTokens.radii.xl,borderTopRightRadius:designTokens.radii.xl,zIndex:designTokens.zIndices.modal+1,display:"flex",flexDirection:"column",maxHeight:"90vh"},bi={width:designTokens.components.bottomSheet.handleWidth,height:designTokens.components.bottomSheet.handleHeight,backgroundColor:"rgba(255, 255, 255, 0.3)",borderRadius:2,margin:"12px auto 0",flexShrink:0},Si={display:"flex",alignItems:"center",justifyContent:"space-between",padding:`${designTokens.spacing[4]}px ${designTokens.spacing[4]}px ${designTokens.spacing[3]}px`,flexShrink:0},wi={fontSize:18,fontWeight:600,color:designTokens.colors.text},Pi={width:32,height:32,display:"flex",alignItems:"center",justifyContent:"center",background:"none",border:"none",cursor:"pointer",color:designTokens.colors.textSecondary,borderRadius:"50%"},Ei={flex:1,overflow:"auto",WebkitOverflowScrolling:"touch"},Ci=()=>jsxRuntime.jsxs("svg",{width:20,height:20,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,children:[jsxRuntime.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),jsxRuntime.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]});function Rn({isOpen:e,onClose:t,title:n,children:r,height:o="60vh",maxHeight:s="90vh",showClose:a=true,showHandle:d=true,style:u,className:h=""}){let i=react.useCallback(l=>{l.key==="Escape"&&t();},[t]);return react.useEffect(()=>(e&&(document.addEventListener("keydown",i),document.body.style.overflow="hidden"),()=>{document.removeEventListener("keydown",i),document.body.style.overflow="";}),[e,i]),jsxRuntime.jsx(react$1.AnimatePresence,{children:e&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(react$1.motion.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},style:yi,onClick:t}),jsxRuntime.jsxs(react$1.motion.div,{initial:{y:"100%"},animate:{y:0},exit:{y:"100%"},transition:{type:"spring",...designTokens.springs.default},drag:"y",dragConstraints:{top:0,bottom:0},dragElastic:{top:0,bottom:.5},onDragEnd:(l,p)=>{(p.offset.y>100||p.velocity.y>500)&&t();},style:designTokens.mergeStyles(vi,{height:o,maxHeight:s,touchAction:"none"},u),className:h,children:[d&&jsxRuntime.jsx("div",{style:bi}),(n||a)&&jsxRuntime.jsxs("div",{style:Si,children:[jsxRuntime.jsx("span",{style:wi,children:n}),a&&jsxRuntime.jsx("button",{style:Pi,onClick:t,"aria-label":"Close",children:jsxRuntime.jsx(Ci,{})})]}),jsxRuntime.jsx("div",{style:Ei,children:r})]})]})})}function Mn({size:e=24,color:t=designTokens.colors.text,thickness:n=2,style:r,className:o=""}){return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("style",{children:`
2
2
  @keyframes xhub-reel-spin {
3
3
  to { transform: rotate(360deg); }
4
4
  }
5
- `}),jsxRuntime.jsx("div",{role:"status","aria-label":"Loading",style:designTokens.mergeStyles({width:e,height:e,borderWidth:n,borderStyle:"solid",borderColor:`${t}30`,borderTopColor:t,borderRadius:"50%",animation:"xhub-reel-spin 1s linear infinite"},r),className:o})]})}var Oi={position:"fixed",left:designTokens.spacing[4],right:designTokens.spacing[4],zIndex:designTokens.zIndices.toast,display:"flex",justifyContent:"center",pointerEvents:"none"},Hi={display:"flex",alignItems:"center",gap:designTokens.spacing[3],padding:`${designTokens.spacing[3]}px ${designTokens.spacing[4]}px`,backgroundColor:designTokens.colors.surface,borderRadius:designTokens.radii.lg,boxShadow:"0 4px 12px rgba(0, 0, 0, 0.5)",pointerEvents:"auto",maxWidth:400},Di={default:{},success:{borderLeft:`3px solid ${designTokens.colors.success}`},error:{borderLeft:`3px solid ${designTokens.colors.error}`},warning:{borderLeft:`3px solid ${designTokens.colors.warning}`}},Bi={flex:1,fontSize:designTokens.fontSizes.sm,color:designTokens.colors.text,lineHeight:1.4},Ni={padding:`${designTokens.spacing[1]}px ${designTokens.spacing[3]}px`,backgroundColor:"transparent",border:"none",color:designTokens.colors.accent,fontSize:designTokens.fontSizes.sm,fontWeight:600,cursor:"pointer",borderRadius:designTokens.radii.sm};function An({message:e,isVisible:t,onClose:n,duration:r=3e3,variant:o="default",action:s,position:d="bottom",style:u,className:l=""}){react.useEffect(()=>{if(t&&r>0){let i=setTimeout(n,r);return ()=>clearTimeout(i)}},[t,r,n]);let m=d==="top"?{top:designTokens.spacing[4]}:{bottom:designTokens.spacing[4]+80};return jsxRuntime.jsx(react$1.AnimatePresence,{children:t&&jsxRuntime.jsx("div",{style:{...Oi,...m},children:jsxRuntime.jsxs(react$1.motion.div,{initial:{opacity:0,y:d==="top"?-20:20,scale:.95},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:d==="top"?-20:20,scale:.95},transition:{type:"spring",...designTokens.springs.default},style:designTokens.mergeStyles(Hi,Di[o],u),className:l,children:[jsxRuntime.jsx("span",{style:Bi,children:e}),s&&jsxRuntime.jsx("button",{style:Ni,onClick:()=>{s.onClick(),n();},children:s.label})]})})})}var Wi={position:"absolute",pointerEvents:"none",zIndex:designTokens.zIndices.overlay},Gi={filter:"drop-shadow(0 4px 8px rgba(255, 45, 85, 0.5))"};function ct(){let[e,t]=react.useState(false),[n,r]=react.useState({x:0,y:0}),o=react.useCallback((d,u)=>{let l=d??(typeof window<"u"?window.innerWidth/2:200),m=u??(typeof window<"u"?window.innerHeight/2:400);r({x:l,y:m}),t(true),setTimeout(()=>{t(false);},800);},[]),s=react.useCallback(()=>{t(false);},[]);return {isShowing:e,position:n,showHeart:o,hideHeart:s}}var $i=({size:e,color:t})=>jsxRuntime.jsx("svg",{style:Gi,xmlns:"http://www.w3.org/2000/svg",width:e,height:e,viewBox:"0 0 28 28",fill:t,children:jsxRuntime.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M1.74988 11.0538C1.74988 6.75595 4.69822 2.91699 9.20877 2.91699C11.4347 2.91699 12.9986 3.9593 13.9999 4.96978C15.0011 3.95929 16.565 2.91699 18.791 2.91699C23.3015 2.91699 26.2499 6.75595 26.2499 11.0538C26.2499 15.3962 23.6265 18.9036 20.8781 21.3587C18.1288 23.8145 15.1442 25.3171 14.1843 25.6371L13.9999 25.6985L13.8154 25.6371C12.8555 25.3171 9.87093 23.8145 7.12168 21.3587C4.37329 18.9036 1.74988 15.3962 1.74988 11.0538ZM17.7449 6.41699C17.2617 6.41699 16.8699 6.80874 16.8699 7.29199C16.8699 7.77524 17.2617 8.16699 17.7449 8.16699C19.6221 8.16699 20.9952 9.75855 20.9952 11.8241C20.9952 12.3073 21.387 12.6991 21.8702 12.6991C22.3535 12.6991 22.7452 12.3073 22.7452 11.8241C22.7452 9.02543 20.8066 6.41699 17.7449 6.41699Z",fill:t})});function ht({show:e,position:t={x:0,y:0},size:n=100,color:r=designTokens.colors.like,showParticles:o=true,particleCount:s=8,onComplete:d,style:u,className:l=""}){return jsxRuntime.jsx(react$1.AnimatePresence,{onExitComplete:d,children:e&&jsxRuntime.jsxs(react$1.motion.div,{initial:{opacity:0,scale:0},animate:{opacity:[0,1,1,0],scale:[0,1.3,1,.8],y:[0,-20,-20,-40]},exit:{scale:0,opacity:0},transition:{duration:.8,times:[0,.2,.6,1],ease:"easeOut"},style:{...Wi,left:t.x-n/2,top:t.y-n/2,width:n,height:n,...u},className:l,children:[jsxRuntime.jsx($i,{size:n,color:r}),o&&[...Array(s)].map((m,i)=>jsxRuntime.jsx(react$1.motion.div,{style:{position:"absolute",width:12,height:12,borderRadius:"50%",backgroundColor:r,left:n/2-6,top:n/2-6},initial:{opacity:1,scale:1},animate:{opacity:0,scale:.5,x:Math.cos(i*Math.PI*2/s)*60,y:Math.sin(i*Math.PI*2/s)*60},transition:{duration:.5,delay:.1,ease:"easeOut"}},i))]})})}function Dn(e){let[t,n]=react.useState(false),r=typeof document<"u"&&!!(document.fullscreenEnabled||document.webkitFullscreenElement!==void 0||document.mozFullScreenElement!==void 0||document.msFullscreenElement!==void 0),o=()=>{let i=document;return i.fullscreenElement||i.webkitFullscreenElement||i.mozFullScreenElement||i.msFullscreenElement||null},s=async i=>{let a=i;a.requestFullscreen?await a.requestFullscreen():a.webkitRequestFullscreen?await a.webkitRequestFullscreen():a.mozRequestFullScreen?await a.mozRequestFullScreen():a.msRequestFullscreen&&await a.msRequestFullscreen();},d=async()=>{let i=document;i.exitFullscreen?await i.exitFullscreen():i.webkitExitFullscreen?await i.webkitExitFullscreen():i.mozCancelFullScreen?await i.mozCancelFullScreen():i.msExitFullscreen&&await i.msExitFullscreen();};react.useEffect(()=>{let i=()=>{let a=o();n(a===e.current);};return document.addEventListener("fullscreenchange",i),document.addEventListener("webkitfullscreenchange",i),document.addEventListener("mozfullscreenchange",i),document.addEventListener("MSFullscreenChange",i),()=>{document.removeEventListener("fullscreenchange",i),document.removeEventListener("webkitfullscreenchange",i),document.removeEventListener("mozfullscreenchange",i),document.removeEventListener("MSFullscreenChange",i);}},[e]);let u=react.useCallback(async()=>{let i=e.current;if(!(!i||!r))try{await s(i),n(!0);let a=screen.orientation;if(a?.lock)try{await a.lock("landscape");}catch{}}catch(a){console.error("[useFullscreen] Failed to enter fullscreen:",a);}},[e,r]),l=react.useCallback(async()=>{if(r)try{await d(),n(!1);let i=screen.orientation;i?.unlock&&i.unlock();}catch(i){console.error("[useFullscreen] Failed to exit fullscreen:",i);}},[r]),m=react.useCallback(async()=>{t?await l():await u();},[t,u,l]);return {isFullscreen:t,isSupported:r,toggleFullscreen:m,enterFullscreen:u,exitFullscreen:l}}var Zi={feed:{autoQualitySwitch:true,pauseOnOffline:false,resumeOnOnline:false,lowQualityOn:"2g"},watch:{autoQualitySwitch:true,pauseOnOffline:false,resumeOnOnline:false,lowQualityOn:"2g"},auto:{autoQualitySwitch:true,pauseOnOffline:true,resumeOnOnline:true,lowQualityOn:"2g"},manual:{autoQualitySwitch:false,pauseOnOffline:false,resumeOnOnline:false}},Ji={aggressive:{autoPauseOnLowBattery:true,pauseThreshold:.2},moderate:{autoPauseOnLowBattery:true,pauseThreshold:.15},conservative:{autoPauseOnLowBattery:true,pauseThreshold:.1},manual:{autoPauseOnLowBattery:false}};function $e(e,t,n={}){let r=react.useRef(null),o=react.useRef(null),s=t??o,[d,u]=react.useState(false),l=mn(),m=gn(e),i=yn(e),a=vn(r.current),p=Dn(s),c=react.useRef(n);c.current=n;let{networkBehavior:g,powerBehavior:f}=n,S=react.useMemo(()=>{if(g)return typeof g=="string"?Zi[g]:g},[g]),b=react.useMemo(()=>{if(f)return typeof f=="string"?Ji[f]:f},[f]),V=react.useMemo(()=>({onStateChange:v=>{l.transition(v),c.current.onStateChange?.(v),v==="ready"&&!d&&(u(true),c.current.onReady?.());},onError:(v,N)=>{c.current.onError?.(v,N);},onTimeUpdate:(v,N)=>{c.current.onTimeUpdate?.(v,N);},onQualityLevelsLoaded:v=>{c.current.onQualityLevelsLoaded?.(v);},onNetworkChange:v=>{S?.onNetworkChange?.(v),c.current.onNetworkChange?.(v);},onPowerChange:v=>{b?.onPowerChange?.(v),c.current.onPowerChange?.(v);},onAnalyticsUpdate:v=>{c.current.onAnalyticsUpdate?.(v);}}),[l,d,S,b]);react.useEffect(()=>{let v=e.current;if(!v)return;let N=()=>c.current.onPlay?.(),X=()=>c.current.onPause?.(),$=()=>c.current.onEnded?.();return v.addEventListener("play",N),v.addEventListener("pause",X),v.addEventListener("ended",$),()=>{v.removeEventListener("play",N),v.removeEventListener("pause",X),v.removeEventListener("ended",$);}},[e]);let L=react.useCallback((v,N)=>{let X=e.current;if(!X){console.error("[usePlayer] No video element");return}u(false),r.current&&r.current.destroy(),r.current=new fn({preferNative:c.current.preferNative,enableSmoothTimeUpdates:c.current.enableSmoothTimeUpdates,enableNetworkAdaptation:c.current.enableNetworkAdaptation,enablePowerAdaptation:c.current.enablePowerAdaptation,enableAnalytics:c.current.enableAnalytics,preloadConfig:c.current.preloadConfig,callbacks:V,autoQualityOnNetworkChange:S?.autoQualitySwitch,autoPauseOnOffline:S?.pauseOnOffline,autoResumeOnOnline:S?.resumeOnOnline,lowQualityThreshold:S?.lowQualityOn,autoPauseOnLowBattery:b?.autoPauseOnLowBattery,lowBatteryThreshold:b?.pauseThreshold}),r.current.attach(X,v,N);},[e,V,S,b]),h=react.useCallback(()=>{r.current&&(r.current.destroy(),r.current=null),l.reset(),u(false);},[l]),y=react.useCallback(async()=>{await r.current?.play();},[]),P=react.useCallback(()=>{r.current?.pause();},[]),O=react.useCallback(async()=>{await r.current?.togglePlay();},[]),C=react.useCallback(v=>{r.current?.seek(v);},[]),B=react.useCallback((v=10)=>{r.current?.seekForward(v);},[]),z=react.useCallback((v=10)=>{r.current?.seekBackward(v);},[]),H=react.useCallback(v=>{r.current?.setPlaybackRate(v);},[]),A=react.useCallback(()=>{let v=e.current;v&&(v.currentTime=0,v.play().catch(()=>{}));},[e]);return {playerCore:r.current,videoRef:e,containerRef:s,state:l,isReady:d,play:y,pause:P,togglePlay:O,seek:C,seekForward:B,seekBackward:z,setPlaybackSpeed:H,restart:A,volume:m,progress:i,quality:a,fullscreen:p,attach:L,destroy:h}}var no={position:"relative",width:"100%",height:"100%",backgroundColor:designTokens.colors.background},ro={width:"100%",height:"100%",objectFit:"contain"},_t=react.forwardRef(({video:e,autoPlay:t=true,muted:n=true,loop:r=true,poster:o,children:s,style:d,className:u="",onPlay:l,onPause:m,onEnded:i,onError:a,onStateChange:p,onTimeUpdate:c,onQualityLevelsLoaded:g,onReady:f},S)=>{let b=react.useRef(null),V=react.useRef(null),L=typeof e=="string"?e:e.url,h=o??(typeof e=="object"?e.thumbnail:void 0),y=$e(b,V,{onStateChange:p,onError:P=>a?.(P),onTimeUpdate:c,onQualityLevelsLoaded:g,onPlay:l,onPause:m,onEnded:i,onReady:f});return react.useEffect(()=>(L&&y.attach(L),()=>{y.destroy();}),[L]),react.useEffect(()=>{let P=b.current;P&&(P.muted=n,P.loop=r);},[n,r]),react.useEffect(()=>{let P=b.current;!P||!y.isReady||!t||P.play().catch(O=>{O.name==="NotAllowedError"&&(P.muted=true,P.play().catch(()=>{}));});},[t,y.isReady]),react.useImperativeHandle(S,()=>({play:y.play,pause:y.pause,togglePlay:y.togglePlay,seek:y.seek,seekForward:y.seekForward,seekBackward:y.seekBackward,restart:y.restart,setVolume:y.volume.setVolume,toggleMute:y.volume.toggleMute,setPlaybackSpeed:y.setPlaybackSpeed,setQuality:y.quality.setQuality,getQualityLevels:()=>y.quality.availableLevels,getVideoElement:()=>b.current,getCurrentTime:()=>y.progress.currentTime,getDuration:()=>y.progress.duration,isPaused:()=>b.current?.paused??true}),[y]),jsxRuntime.jsxs("div",{ref:V,style:Y(no,d),className:u,children:[jsxRuntime.jsx("video",{ref:b,poster:h,playsInline:true,preload:"auto",style:ro}),s]})});_t.displayName="VideoPlayer";var uo=30,co=1e3/uo,Z={container:{position:"absolute",bottom:0,left:0,right:0,zIndex:designTokens.zIndices.sticky,touchAction:"none",userSelect:"none",WebkitUserSelect:"none",transition:"all 0.125s ease-in-out"},collapsed:{height:Ne.HEIGHT_DEFAULT,paddingInline:designTokens.spacing[3],cursor:"pointer"},expanded:{padding:`${designTokens.spacing[2]}px ${designTokens.spacing[3]}px`,paddingBottom:`calc(${designTokens.spacing[1]}px + env(safe-area-inset-bottom, 0px))`,background:"linear-gradient(to top, rgba(0,0,0,0.8) 0%, transparent 100%)"},timeContainer:{display:"flex",justifyContent:"center",alignItems:"center",marginBottom:designTokens.spacing[2]},timeText:{fontSize:designTokens.fontSizes.sm,fontWeight:designTokens.fontWeights.semibold,color:designTokens.colors.text,textShadow:designTokens.shadows.text,fontVariantNumeric:"tabular-nums",backgroundColor:"rgba(0, 0, 0, 0.6)",padding:`${designTokens.spacing[1]}px ${designTokens.spacing[3]}px`,borderRadius:designTokens.radii.md},track:{position:"relative",width:"100%",backgroundColor:"rgba(255, 255, 255, 0.2)",borderRadius:designTokens.radii.full,overflow:"hidden"},trackCollapsed:{height:Ne.HEIGHT_DEFAULT},trackExpanded:{height:Ne.HEIGHT_ACTIVE},buffer:{position:"absolute",top:0,left:0,height:"100%",backgroundColor:"rgba(255, 255, 255, 0.3)",borderRadius:designTokens.radii.full},progress:{position:"absolute",top:0,left:0,height:"100%",backgroundColor:designTokens.colors.text,borderRadius:designTokens.radii.full},scrubber:{position:"absolute",top:"50%",width:16,height:16,marginLeft:-8,marginTop:-8,backgroundColor:designTokens.colors.text,borderRadius:designTokens.radii.full,boxShadow:"0 2px 4px rgba(0,0,0,0.3)",transform:"scale(0)",transition:"transform 150ms ease"},scrubberVisible:{transform:"scale(1)"},touchArea:{position:"absolute",top:-12,left:0,right:0,bottom:-12,cursor:"pointer"}};function ye(e){if(!isFinite(e)||isNaN(e))return "0:00";let t=Math.floor(e/60),n=Math.floor(e%60);return `${t}:${n.toString().padStart(2,"0")}`}function ho(e){if(e.buffered.length===0)return 0;for(let t=0;t<e.buffered.length;t++)if(e.buffered.start(t)<=e.currentTime&&e.buffered.end(t)>=e.currentTime)return e.buffered.end(t);return e.buffered.end(e.buffered.length-1)}var pt=react.forwardRef(({videoRef:e,expanded:t=false,onSeekStart:n,onSeek:r,onSeekEnd:o,onExpandedChange:s,style:d,className:u=""},l)=>{let m=react.useRef(null),i=react.useRef(null),a=react.useRef(null),p=react.useRef(null),c=react.useRef(null),g=react.useRef(0),[f,S]=react.useState({currentTime:0,duration:0}),b=react.useRef(null),V=react.useRef(0),L=react.useRef(0),h=react.useRef(false),y=react.useRef(t);react.useEffect(()=>{y.current=t;},[t]);let P=react.useCallback(x=>{let w=e.current;if(!w||h.current)return;let k=w.duration||0,R=w.currentTime||0,D=ho(w),E=k>0?R/k*100:0,_=k>0?D/k*100:0;i.current&&(i.current.style.width=`${E}%`),a.current&&(a.current.style.width=`${_}%`),p.current&&y.current&&(p.current.style.left=`${E}%`),g.current=k,c.current&&(c.current.textContent=`${ye(R)} / ${ye(k)}`);let se=x??performance.now();se-L.current>=500&&(L.current=se,S(ge=>Math.abs(ge.currentTime-R)>=.5||ge.duration!==k?{currentTime:Math.floor(R),duration:Math.floor(k)}:ge));},[e]),O=react.useCallback(x=>{x-V.current>=co&&(V.current=x,P()),b.current=requestAnimationFrame(O);},[P]);react.useEffect(()=>(b.current=requestAnimationFrame(O),()=>{b.current&&cancelAnimationFrame(b.current);}),[O]);let C=react.useCallback(x=>{let w=m.current,k=e.current;if(!w||!k)return 0;let R=w.getBoundingClientRect(),D=x-R.left;return Math.max(0,Math.min(1,D/R.width))*(k.duration||0)},[e]),B=react.useCallback(x=>{h.current=true,n?.();let w=C(x);r?.(w);let k=e.current;if(k&&i.current){let R=k.duration||g.current||1,D=w/R*100;i.current.style.width=`${D}%`,p.current&&(p.current.style.left=`${D}%`),c.current&&(c.current.textContent=`${ye(w)} / ${ye(R)}`);}},[C,r,n,e]),z=react.useCallback(x=>{if(!h.current)return;let w=C(x);r?.(w);let k=e.current;if(k&&i.current){let R=k.duration||g.current||1,D=w/R*100;i.current.style.width=`${D}%`,p.current&&(p.current.style.left=`${D}%`),c.current&&(c.current.textContent=`${ye(w)} / ${ye(R)}`);}},[C,r,e]),H=react.useCallback(x=>{if(!h.current)return;h.current=false;let w=C(x);o?.(w);let k=e.current;k&&(k.currentTime=w);},[C,o,e]),A=react.useCallback(x=>{let w=x.touches[0];w&&B(w.clientX);},[B]),v=react.useCallback(x=>{let w=x.touches[0];w&&z(w.clientX);},[z]),N=react.useCallback(x=>{let w=x.changedTouches[0];w&&H(w.clientX);},[H]),X=react.useCallback(x=>{B(x.clientX);let w=R=>z(R.clientX),k=R=>{H(R.clientX),document.removeEventListener("mousemove",w),document.removeEventListener("mouseup",k);};document.addEventListener("mousemove",w),document.addEventListener("mouseup",k);},[B,z,H]),$=react.useCallback(()=>{t||s?.(true);},[t,s]),q=react.useCallback(x=>{let w=e.current;if(!w)return;let k=w.duration||0,R=w.currentTime||0,D=R;switch(x.key){case "ArrowLeft":D=Math.max(0,R-5);break;case "ArrowRight":D=Math.min(k,R+5);break;case "ArrowUp":D=Math.min(k,R+10);break;case "ArrowDown":D=Math.max(0,R-10);break;case "Home":D=0;break;case "End":D=k;break;default:return}x.preventDefault(),w.currentTime=D,r?.(D),P();},[e,r,P]);react.useImperativeHandle(l,()=>({update:P,setExpanded:x=>{s?.(x);}}));let K={...Z.container,...t?Z.expanded:Z.collapsed,...d},oe={...Z.track,...t?Z.trackExpanded:Z.trackCollapsed},J={...Z.scrubber,...t?Z.scrubberVisible:{}};return jsxRuntime.jsxs("div",{ref:m,style:K,className:u,onClick:t?void 0:$,onTouchStart:A,onTouchMove:v,onTouchEnd:N,onTouchCancel:N,onMouseDown:X,onKeyDown:q,role:"slider","aria-label":"Video progress","aria-valuemin":0,"aria-valuemax":f.duration,"aria-valuenow":f.currentTime,"aria-valuetext":`${ye(f.currentTime)} of ${ye(f.duration)}`,tabIndex:0,children:[t&&jsxRuntime.jsx("div",{style:Z.timeContainer,children:jsxRuntime.jsx("span",{ref:c,style:Z.timeText,children:"0:00 / 0:00"})}),jsxRuntime.jsxs("div",{style:oe,"aria-hidden":"true",children:[jsxRuntime.jsx("div",{style:Z.touchArea}),jsxRuntime.jsx("div",{ref:a,style:Z.buffer}),jsxRuntime.jsx("div",{ref:i,style:Z.progress}),t&&jsxRuntime.jsx("div",{ref:p,style:J})]})]})});pt.displayName="Timeline";var po={DOUBLE_TAP_DELAY:200},fo={THRESHOLD:500},qe={VERTICAL_THRESHOLD:.3,HORIZONTAL_THRESHOLD:.4,MIN_VELOCITY:.5},ft={THRESHOLD:10};var ve={TAP_DELAY:po.DOUBLE_TAP_DELAY,LONG_PRESS_THRESHOLD:fo.THRESHOLD,SWIPE_VERTICAL_THRESHOLD:qe.VERTICAL_THRESHOLD,SWIPE_HORIZONTAL_THRESHOLD:qe.HORIZONTAL_THRESHOLD,DRAG_THRESHOLD:ft.THRESHOLD};function Un(){return typeof navigator<"u"&&"vibrate"in navigator}function mt(){Un()&&navigator.vibrate(10);}function Qn(){Un()&&navigator.vibrate(20);}function zn(e,t){let n=e.currentTarget||e.target;if(!n||typeof n.getBoundingClientRect!="function")return "center";let r=n.getBoundingClientRect(),o=e.clientX-r.left,s=r.width;if(s===0)return "center";let d=s*.33,u=s*.67;return o<d?"left":o>u?"right":"center"}function gt(e){let t=react.useRef(0),n=react.useRef("center"),r=react.useRef(null),o=react.useRef(null),s=react.useRef(false),d=react.useRef(false),u=react.useRef({x:0,y:0}),l=react.useCallback(i=>{if(d.current){d.current=false;return}let a=zn(i),p=Date.now(),c=p-t.current,g={x:i.clientX,y:i.clientY};c<ve.TAP_DELAY&&n.current===a?(r.current&&(clearTimeout(r.current),r.current=null),mt(),e.onDoubleTap?.(a,g)):r.current=setTimeout(()=>{e.onSingleTap?.(a),r.current=null;},ve.TAP_DELAY),t.current=p,n.current=a;},[e]);return react$2.useGesture({onPointerDown:({event:i})=>{let a=i;u.current={x:a.clientX,y:a.clientY},d.current=false;let p=setTimeout(()=>{s.current=true,e.onHoldStart?.();},150);o.current=setTimeout(()=>{d.current=true,Qn();let g=a.target.getBoundingClientRect();e.onLongPress?.({x:a.clientX-g.left,y:a.clientY-g.top});},ve.LONG_PRESS_THRESHOLD),i.target.dataset.holdTimeout=String(p);},onPointerUp:({event:i})=>{let a=i.target.dataset.holdTimeout;a&&clearTimeout(Number(a)),o.current&&(clearTimeout(o.current),o.current=null),s.current&&(s.current=false,e.onHoldEnd?.());},onPointerMove:({event:i})=>{let a=i,p=Math.abs(a.clientX-u.current.x),c=Math.abs(a.clientY-u.current.y);(p>10||c>10)&&o.current&&(clearTimeout(o.current),o.current=null);},onClick:({event:i})=>{l(i);},onDrag:({movement:[i,a],direction:[p,c],velocity:[g,f],last:S,event:b})=>{if(b.preventDefault(),!S)return;let V=window.innerWidth,L=window.innerHeight;if(Math.abs(a)>L*ve.SWIPE_VERTICAL_THRESHOLD){c>0?e.onSwipeDown?.():e.onSwipeUp?.();return}if(Math.abs(i)>V*ve.SWIPE_HORIZONTAL_THRESHOLD){p>0?e.onSwipeRight?.():e.onSwipeLeft?.();return}Math.abs(i)>ve.DRAG_THRESHOLD&&Math.abs(g)>Math.abs(f)&&e.onSeekDrag?.(i);}},{drag:{threshold:ve.DRAG_THRESHOLD,filterTaps:true},eventOptions:{passive:false}})}var So=800,wo=.05,Po=.95;function Ut({onSwipeUp:e,onSwipeDown:t,onSwipeProgress:n,onSwipeCancel:r,threshold:o=qe.VERTICAL_THRESHOLD,velocityThreshold:s=qe.MIN_VELOCITY,hapticEnabled:d=true,disabled:u=false,enableProgressState:l=false}={}){let m=Math.max(wo,Math.min(Po,o)),[i,a]=react.useState({progress:0,direction:null,isSwiping:false}),p=react.useRef({onSwipeUp:e,onSwipeDown:t,onSwipeProgress:n,onSwipeCancel:r}),c=react.useRef(typeof window<"u"?window.innerHeight:So);return p.current={onSwipeUp:e,onSwipeDown:t,onSwipeProgress:n,onSwipeCancel:r},react.useEffect(()=>{let f=()=>{c.current=window.innerHeight;},S=()=>{setTimeout(()=>{c.current=window.innerHeight;},100);};return window.addEventListener("resize",f,{passive:true}),window.addEventListener("orientationchange",S,{passive:true}),()=>{window.removeEventListener("resize",f),window.removeEventListener("orientationchange",S);}},[]),{bind:react$2.useDrag(({movement:[,f],velocity:[,S],active:b,cancel:V})=>{if(u){V?.();return}let h=c.current*m,y=Math.min(1,Math.abs(f)/h),P=f<0?"up":"down";if(b)p.current.onSwipeProgress?.(y,P,f),l&&a({progress:y,direction:P,isSwiping:true});else {let O=Math.abs(f)>=h,C=Math.abs(S)>=s;O||C?(d&&mt(),P==="up"?p.current.onSwipeUp?.():p.current.onSwipeDown?.()):p.current.onSwipeCancel?.(),a({progress:0,direction:null,isSwiping:false});}},{axis:"y",threshold:ft.THRESHOLD,filterTaps:true,pointer:{touch:true},eventOptions:{passive:true}}),...i}}var Oe={container:{position:"relative",width:"100%",height:"100%",backgroundColor:designTokens.colors.background},video:{position:"absolute",inset:0,width:"100%",height:"100%",objectFit:"cover"},placeholder:{position:"absolute",inset:0,backgroundSize:"cover",backgroundPosition:"center"},tapArea:{zIndex:designTokens.zIndices.base},pauseOverlay:{zIndex:designTokens.zIndices.overlay},pauseIconWrapper:{borderRadius:designTokens.radii.full,transition:`opacity ${designTokens.durations.normal}ms ${designTokens.easings.xhubReel}, transform ${designTokens.durations.normal}ms ${designTokens.easings.xhubReel}`}};var Qt=react.createContext(null);function pe(){let e=react.useContext(Qt);if(!e)throw new Error("VideoFeedItem compound components must be used within a VideoFeedItem");return e}function Gn({elementRef:e,activateThreshold:t=Je.ACTIVATION_THRESHOLD,deactivateThreshold:n=Je.DEACTIVATION_THRESHOLD,rootMargin:r="0px",onVisibilityChange:o}){let[s,d]=react.useState(false),[u,l]=react.useState(false),[m,i]=react.useState(0),a=react.useRef(null);return react.useEffect(()=>{let p=e.current;if(!p)return;a.current&&a.current.disconnect();let c=[0,.1,.2,.3,.4,.5,.6,.7,.8,.9,1];return a.current=new IntersectionObserver(g=>{g.forEach(f=>{let S=f.intersectionRatio;i(S),d(S>0),S>=t?l(true):S<n&&l(false),o?.(S>0,S);});},{threshold:c,rootMargin:r}),a.current.observe(p),()=>{a.current?.disconnect();}},[e,t,n,r,o]),{isVisible:s,isActive:u,visibilityRatio:m}}function qn({containerRef:e,videoRef:t,isCurrentVideo:n=false,onActivate:r,onDeactivate:o,autoActivate:s=true,trackVisibility:d=false,onVisibilityChange:u}){let l=react.useRef(false),{isVisible:m,isActive:i,visibilityRatio:a}=Gn({elementRef:e??{current:null},onVisibilityChange:d?u:void 0}),p=d?i:n;react.useEffect(()=>{s&&(p&&!l.current?(l.current=true,r?.()):!p&&l.current&&(l.current=false,o?.()));},[p,r,o,s]);let c=react.useCallback(()=>{let f=t.current;f&&f.play().catch(()=>{f.muted=true,f.play().catch(()=>{});}),r?.();},[t,r]),g=react.useCallback(()=>{let f=t.current;f&&(f.pause(),f.currentTime=0),o?.();},[t,o]);return {isActive:p,isVisible:d?m:n,visibilityRatio:d?a:n?1:0,activate:c,deactivate:g}}var Wt=class{entries=new Map;listeners=new Set;memoryWarningThreshold;constructor(){this.memoryWarningThreshold=Re.MAX_TOTAL_MEMORY/(1024*1024),this.setupMemoryPressureListener();}register(t,n=10){this.entries.set(t,{videoId:t,inDom:false,hasDecodedFrames:false,estimatedSizeMB:n,lastAccessed:Date.now()}),this.notifyListeners();}unregister(t){this.entries.delete(t),this.notifyListeners();}setInDom(t,n){let r=this.entries.get(t);r&&(r.inDom=n,r.lastAccessed=Date.now(),this.notifyListeners());}setHasDecodedFrames(t,n){let r=this.entries.get(t);r&&(r.hasDecodedFrames=n,r.lastAccessed=Date.now(),this.notifyListeners());}getState(){let t=0,n=0,r=0;return this.entries.forEach(o=>{o.inDom&&t++,o.hasDecodedFrames&&n++,r+=o.estimatedSizeMB;}),{videosInDom:t,decodedVideos:n,estimatedMemoryMB:r,isLowMemory:r>this.memoryWarningThreshold}}getVideosToDispose(){let t=this.getState(),n=[],r=Re?.MAX_VIDEOS_IN_DOM,o=Re?.MAX_DECODED_FRAMES,s=Array.from(this.entries.values()).sort((d,u)=>d.lastAccessed-u.lastAccessed);if(t.videosInDom>r){let d=t.videosInDom-r,u=0;for(let l of s){if(u>=d)break;l.inDom&&(n.push(l.videoId),u++);}}if(t.decodedVideos>o){let d=t.decodedVideos-o,u=0;for(let l of s){if(u>=d)break;l.hasDecodedFrames&&!n.includes(l.videoId)&&(n.push(l.videoId),u++);}}return n}subscribe(t){return this.listeners.add(t),()=>this.listeners.delete(t)}forceCleanup(){let t=this.getVideosToDispose();return t.forEach(n=>this.unregister(n)),t}notifyListeners(){let t=this.getState();this.listeners.forEach(n=>n(t));}setupMemoryPressureListener(){typeof window>"u"||"memory"in performance&&setInterval(()=>{this.getState().isLowMemory&&(console.warn("[MemoryManager] Low memory warning, forcing cleanup"),this.forceCleanup());},5e3);}},be=new Wt;function jn({videoId:e,estimatedSizeMB:t=10,onShouldDispose:n}){let[r,o]=react.useState(()=>be.getState()),[s,d]=react.useState(false);react.useEffect(()=>(be.register(e,t),()=>{be.unregister(e);}),[e,t]),react.useEffect(()=>be.subscribe(i=>{o(i);let p=be.getVideosToDispose().includes(e);p&&!s?(d(true),n?.()):!p&&s&&d(false);}),[e,s,n]);let u=react.useCallback(m=>{be.setInDom(e,m);},[e]),l=react.useCallback(m=>{be.setHasDecodedFrames(e,m);},[e]);return {memoryState:r,setInDom:u,setHasDecodedFrames:l,shouldDispose:s}}function Jn({video:e,isActive:t,priority:n,onLike:r,onComment:o,onShare:s,onAuthorClick:d}){let u=react.useRef(null),l=react.useRef(null),m=react.useRef(false),[i,a]=react.useState(false),[p,c]=react.useState(false),[g,f]=react.useState(false),{isShowing:S,position:b,showHeart:V}=ct(),L=react.useMemo(()=>({maxConcurrent:2,maxBufferSize:10*1024*1024,priorityLevels:10}),[]),h=react.useCallback(E=>{},[]),y=react.useCallback(E=>{},[]),P=react.useCallback(E=>{E.startupTime&&E.startupTime>1e3&&console.warn("[VideoFeedItem] Slow startup:",E.startupTime,"ms",e.id);},[e.id]),{state:O}=$e(l,u,{preferNative:true,enableSmoothTimeUpdates:true,networkBehavior:"feed",powerBehavior:"moderate",preloadConfig:L,enableAnalytics:true,onPlay:()=>{a(false),c(false);},onPause:()=>{l.current?.seeking||(a(true),c(true));},onNetworkChange:h,onPowerChange:y,onAnalyticsUpdate:P}),C=react.useCallback(async()=>{let E=l.current;if(E){E.muted=true;try{await E.play();}catch(_){console.warn("[VideoFeedItem] Play failed:",_.message);}}},[]),B=react.useCallback(()=>{let E=l.current;E&&E.pause();},[]),z=react.useCallback(E=>{let _=l.current;_&&(_.currentTime=E);},[]),[H,A]=react.useState(false);react.useEffect(()=>{let E=l.current;if(!E)return;let _=()=>A(true),se=()=>A(false),ge=()=>A(false);return E.addEventListener("play",_),E.addEventListener("pause",se),E.addEventListener("ended",ge),A(!E.paused),()=>{E.removeEventListener("play",_),E.removeEventListener("pause",se),E.removeEventListener("ended",ge);}},[e.id]);let v=H||O.state==="playing",{setInDom:N,setHasDecodedFrames:X,shouldDispose:$}=jn({videoId:e.id,onShouldDispose:()=>{B(),l.current&&(l.current.src="",l.current.load());}}),q=!$&&n!=="none",K=react.useRef(false);qn({videoRef:l,isCurrentVideo:t,onActivate:()=>{console.log("[VideoFeedItem] onActivate called, videoRef:",l.current?.src),X(true),l.current?C():(console.log("[VideoFeedItem] Video element not ready, marking pending play"),K.current=true);},onDeactivate:()=>{console.log("[VideoFeedItem] onDeactivate called"),K.current=false,X(false),B(),z(0);},autoActivate:true}),react.useEffect(()=>{l.current&&K.current&&t&&(console.log("[VideoFeedItem] Video element now available, executing pending play"),K.current=false,C());}),react.useEffect(()=>(N(true),()=>N(false)),[N]),react.useEffect(()=>{let E=l.current;if(!E)return;f(false);let _=()=>{console.log("[VideoFeedItem] Video loadeddata:",e.id,{isActive:t,priority:n}),n==="high"&&!t?requestAnimationFrame(()=>{E.readyState>=2&&(E.currentTime=.01,f(true),console.log("[VideoFeedItem] First frame decoded (preloaded):",e.id));}):t&&f(true);},se=()=>{n==="high"&&!g&&f(true);};return E.addEventListener("loadeddata",_),E.addEventListener("canplay",se),E.readyState>=2&&_(),()=>{E.removeEventListener("loadeddata",_),E.removeEventListener("canplay",se);}},[e.id,t,n,g]),react.useEffect(()=>{console.log("[VideoFeedItem] State:",{videoId:e.id,isActive:t,priority:n,shouldRenderVideo:q,hasVideoElement:!!l.current,videoSrc:l.current?.src});},[e.id,t,n,q]);let oe=react.useMemo(()=>{switch(n){case "high":return "auto";case "medium":return "metadata";case "low":case "metadata":return "none";default:return "none"}},[n]),J=react.useCallback(()=>{m.current=v,c(true),a(false),B();},[v,B]),x=react.useCallback(E=>{z(E),m.current?(C(),c(false)):a(true);},[z,C]),w=react.useCallback(()=>{v?B():C();},[v,C,B]),k=react.useCallback((E,_)=>{V(_.x,_.y),r?.();},[V,r]),R=react.useCallback(()=>{},[]),D=gt({onSingleTap:w,onDoubleTap:k,onLongPress:R});return {video:e,isActive:t,shouldRenderVideo:q,preload:oe,isPreloaded:g,containerRef:u,videoRef:l,isPlaying:v,showPauseOverlay:i,timelineExpanded:p,play:C,pause:B,seek:z,setShowPauseOverlay:a,setTimelineExpanded:c,gestureBindings:D,showHeart:S,heartPosition:b,triggerHeart:V,onLike:r,onComment:o,onShare:s,onAuthorClick:d,handleSeekStart:J,handleSeekEnd:x}}var bt=react.forwardRef(({placeholder:e,...t},n)=>{let{video:r,videoRef:o,shouldRenderVideo:s,preload:d,isPreloaded:u}=pe();if(!s)return e??jsxRuntime.jsx("div",{...t,style:{...Oe.placeholder,backgroundImage:`url(${r.thumbnail})`,...t.style}});let l=!u;return jsxRuntime.jsx("video",{ref:m=>{typeof n=="function"?n(m):n&&(n.current=m),o.current=m;},src:r.url,poster:l?r.thumbnail:void 0,preload:d,loop:true,playsInline:true,muted:true,style:Oe.video})});bt.displayName="VideoFeedItemPlayer";var St=react.forwardRef(({onLike:e,onComment:t,onShare:n,...r},o)=>{let{video:s,onLike:d,onComment:u,onShare:l}=pe();return jsxRuntime.jsx("div",{ref:o,...r,children:jsxRuntime.jsx(st,{avatarUrl:s.author.avatar,likeCount:s.stats.likes,commentCount:s.stats.comments,shareCount:s.stats.shares,isLiked:s.isLiked,onLike:e??d,onComment:t??u,onShare:n??l})})});St.displayName="VideoFeedItemActions";var wt=react.forwardRef(({expanded:e,...t},n)=>{let{videoRef:r,shouldRenderVideo:o,timelineExpanded:s,setTimelineExpanded:d,handleSeekStart:u,handleSeekEnd:l}=pe();return o?jsxRuntime.jsx("div",{ref:n,...t,children:jsxRuntime.jsx(pt,{videoRef:r,expanded:e??s,onSeekStart:u,onSeekEnd:l,onExpandedChange:d})}):null});wt.displayName="VideoFeedItemTimeline";var He={container:{position:"absolute",bottom:0,left:0,right:64,padding:designTokens.spacing[4],paddingBottom:"env(safe-area-inset-bottom, 16px)",zIndex:designTokens.zIndices.base},containerWithTimeline:{paddingBottom:"calc(env(safe-area-inset-bottom, 16px) + 48px)"},authorButton:{gap:designTokens.spacing[2],marginBottom:designTokens.spacing[3]},avatar:{borderRadius:designTokens.radii.full,border:`2px solid ${designTokens.colors.text}`},username:{color:designTokens.colors.text,fontWeight:designTokens.fontWeights.semibold,fontSize:designTokens.fontSizes.sm,textShadow:designTokens.shadows.text},caption:{color:designTokens.colors.text,fontSize:designTokens.fontSizes.sm,lineHeight:1.4,textShadow:designTokens.shadows.text,display:"-webkit-box",WebkitLineClamp:2,WebkitBoxOrient:"vertical",overflow:"hidden",paddingBottom:designTokens.spacing[1]},author:{color:designTokens.colors.text,fontSize:designTokens.fontSizes.sm,fontWeight:designTokens.fontWeights.semibold,textShadow:designTokens.shadows.text,display:"-webkit-box",WebkitLineClamp:1,WebkitBoxOrient:"vertical",overflow:"hidden",paddingBottom:designTokens.spacing[1]},hashtags:{display:"flex",flexWrap:"wrap",gap:designTokens.spacing[1],marginTop:designTokens.spacing[2],paddingBottom:designTokens.spacing[1]},hashtag:{color:designTokens.colors.accent,fontSize:designTokens.fontSizes.sm,fontWeight:designTokens.fontWeights.medium,textShadow:designTokens.shadows.text}};function ir({video:e,timelineExpanded:t=false,style:n,className:r=""}){let o=Y(He.container,t&&He.containerWithTimeline,n);return jsxRuntime.jsxs("div",{style:o,className:r,children:[e.author&&jsxRuntime.jsx("p",{style:He.author,children:e.author.displayName}),e.caption&&jsxRuntime.jsx("p",{style:He.caption,children:e.caption}),e.hashtags&&e.hashtags.length>0&&jsxRuntime.jsx("div",{style:He.hashtags,children:e.hashtags.slice(0,3).map((s,d)=>jsxRuntime.jsxs("span",{style:He.hashtag,children:["#",s]},d))})]})}var Pt=react.forwardRef(({showPlayPause:e=true,showDoubleTapHeart:t=true,showVideoInfo:n=true,...r},o)=>{let{video:s,isPlaying:d,showPauseOverlay:u,timelineExpanded:l,showHeart:m,heartPosition:i,onAuthorClick:a}=pe();return jsxRuntime.jsxs("div",{ref:o,...r,children:[e&&jsxRuntime.jsx(lt,{isPlaying:d,show:u,size:64,autoHideDelay:800,showOnStateChange:false}),t&&jsxRuntime.jsx(ht,{show:m,position:i,size:100,showParticles:true,particleCount:8}),n&&jsxRuntime.jsx(ir,{video:s,onAuthorClick:a,timelineExpanded:l})]})});Pt.displayName="VideoFeedItemOverlay";var Be=react.forwardRef(({video:e,isActive:t=false,priority:n="none",showTimeline:r=true,onLike:o,onComment:s,onShare:d,onAuthorClick:u,style:l,className:m="",children:i},a)=>{let p=Jn({video:e,isActive:t,priority:n,onLike:o,onComment:s,onShare:d,onAuthorClick:u}),c=i??jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(bt,{}),jsxRuntime.jsx(Pt,{}),jsxRuntime.jsx(St,{}),r&&jsxRuntime.jsx(wt,{})]});return jsxRuntime.jsx(Qt.Provider,{value:p,children:jsxRuntime.jsx("div",{ref:g=>{typeof a=="function"?a(g):a&&(a.current=g),p.containerRef.current=g;},style:Y(Oe.container,l),className:m,...p.gestureBindings(),children:c})})});Be.displayName="VideoFeedItem";function or(e,t){let n=e-t;return n===0||n===-1||n===1?"high":n===2?"medium":n===3?"low":Math.abs(n)<=5?"metadata":"none"}var Do="cubic-bezier(0.32, 0.72, 0, 1)",Bo=300,No=800,_o=50;function ar({trackRef:e,transitionDuration:t=Bo,easing:n=Do,onTransitionEnd:r}){let o=react.useRef(typeof window<"u"?window.innerHeight:No),s=react.useRef(0),d=react.useRef(null),u=react.useRef(false),l=react.useRef(true);react.useEffect(()=>{let c=()=>{o.current=window.innerHeight;},g=()=>{setTimeout(()=>{o.current=window.innerHeight;},100);};return window.addEventListener("resize",c,{passive:true}),window.addEventListener("orientationchange",g,{passive:true}),()=>{window.removeEventListener("resize",c),window.removeEventListener("orientationchange",g);}},[]);let m=react.useCallback(c=>{s.current=c,d.current!==null&&cancelAnimationFrame(d.current),d.current=requestAnimationFrame(()=>{let g=e.current;g&&(g.style.transition="none",g.style.transform=`translateY(${c}px)`),d.current=null;});},[e]),i=react.useCallback(c=>new Promise(g=>{let f=e.current;if(!f||!l.current){g();return}if(u.current){g();return}u.current=true,s.current=c;let S=null,b=null,V=L=>{L.propertyName==="transform"&&(S?.(),l.current&&(u.current=false,r?.()),g());};S=()=>{f.removeEventListener("transitionend",V),b&&(clearTimeout(b),b=null);},f.addEventListener("transitionend",V),b=setTimeout(()=>{S?.(),l.current&&u.current&&(u.current=false,r?.()),g();},t+_o),f.offsetHeight,f.style.transition=`transform ${t}ms ${n}`,f.style.transform=`translateY(${c}px)`;}),[e,t,n,r]),a=react.useCallback(()=>i(0),[i]),p=react.useCallback(()=>s.current,[]);return react.useEffect(()=>(l.current=true,()=>{l.current=false,d.current!==null&&(cancelAnimationFrame(d.current),d.current=null);}),[]),{setTranslateY:m,animateTo:i,snapBack:a,getCurrentY:p,viewportHeight:o.current,isAnimating:u.current}}var zo=300,Wo=50,Go=.3,$o="cubic-bezier(0.32, 0.72, 0, 1)",Se={container:{position:"fixed",inset:0,overflow:"hidden",backgroundColor:designTokens.colors.background,touchAction:"none",userSelect:"none",WebkitUserSelect:"none"},track:{position:"relative",width:"100%",height:"100%",willChange:"transform"},slide:{position:"absolute",left:0,width:"100%",height:"100%",backfaceVisibility:"hidden",WebkitBackfaceVisibility:"hidden"},loadingIndicator:{position:"absolute",bottom:80,left:0,right:0,display:"flex",justifyContent:"center",zIndex:designTokens.zIndices.base,pointerEvents:"none"},spinner:{width:24,height:24,borderWidth:2,borderStyle:"solid",borderColor:"rgba(255, 255, 255, 0.3)",borderTopColor:designTokens.colors.text,borderRadius:designTokens.radii.full,animation:"xhub-reel-spin 1s linear infinite"}},Ke=react.forwardRef(({videos:e,initialIndex:t=0,onLoadMore:n,onVideoChange:r,onLike:o,onComment:s,onShare:d,onAuthorClick:u,isLoading:l=false,hasMore:m=false,loadMoreThreshold:i=3,transitionDuration:a=zo,swipeThreshold:p=Wo,velocityThreshold:c=Go,gesturesDisabled:g=false,hapticEnabled:f=true,style:S,className:b=""},V)=>{let[L,h]=react.useState(()=>Math.min(Math.max(0,t),Math.max(0,e.length-1))),[y,P]=react.useState(false),[O,C]=react.useState(false),B=react.useRef(null),z=react.useRef(null),H=react.useRef(e),A=react.useRef(L),v=react.useRef(l),N=react.useRef(m),X=react.useRef(y),{setCurrentIndex:$}=Lt(),{setTranslateY:q,animateTo:K,snapBack:oe,viewportHeight:J}=ar({trackRef:z,transitionDuration:a,easing:$o});react.useEffect(()=>{H.current=e;},[e]),react.useEffect(()=>{A.current=L;},[L]),react.useEffect(()=>{v.current=l;},[l]),react.useEffect(()=>{N.current=m;},[m]),react.useEffect(()=>{X.current=y;},[y]),react.useEffect(()=>{if(e.length===0){h(0);return}if(L>=e.length){let I=e.length-1,U=e[I];h(I),$(I),U&&r?.(U,I);}},[e.length,L,$,r,e]);let x=react.useCallback(I=>or(I,L),[L]),w=react.useCallback(I=>{let U=H.current;N.current&&!v.current&&U.length-I<=i&&n?.();},[i,n]),k=react.useCallback(async(I,U=true)=>{if(X.current)return;let F=H.current,M=Math.max(0,Math.min(I,F.length-1)),ae=A.current;if(M===ae){q(0);return}let xe=M>ae?-1:1;if(U){P(true),C(true),await K(xe*J),h(M),$(M),q(0);let we=F[M];we&&r?.(we,M),w(M),C(false),P(false);}else {h(M),$(M),q(0);let we=F[M];we&&(r?.(we,M),w(M));}},[J,K,q,$,r,w]),R=react.useCallback((I=true)=>{let U=H.current,F=A.current;F<U.length-1&&k(F+1,I);},[k]),D=react.useCallback((I=true)=>{let U=A.current;U>0&&k(U-1,I);},[k]),E=react.useCallback((I,U,F)=>{let M=H.current,ae=A.current,xe=ae>0,we=ae<M.length-1,Xt=F;(U==="down"&&!xe||U==="up"&&!we)&&(Xt*=.3),q(Xt);},[q]),_=react.useCallback(async()=>{let I=H.current;if(!(A.current<I.length-1)){await oe();return}P(true),C(true),await K(-J);let M=A.current+1,ae=H.current;if(M<ae.length){h(M),$(M);let xe=ae[M];xe&&r?.(xe,M),w(M);}q(0),C(false),P(false);},[J,K,oe,q,$,r,w]),se=react.useCallback(async()=>{if(!(A.current>0)){await oe();return}P(true),C(true),await K(J);let F=A.current-1;if(F>=0){h(F),$(F);let M=H.current[F];M&&r?.(M,F);}q(0),C(false),P(false);},[J,K,oe,q,$,r]),ge=react.useCallback(async()=>{await oe();},[oe]),{bind:ur}=Ut({onSwipeUp:_,onSwipeDown:se,onSwipeProgress:E,onSwipeCancel:ge,threshold:p/J,velocityThreshold:c,hapticEnabled:f,disabled:g||y,enableProgressState:false});react.useImperativeHandle(V,()=>({slideTo:k,slideNext:R,slidePrev:D,get activeIndex(){return A.current},get totalSlides(){return H.current.length},get isBeginning(){return A.current===0},get isEnd(){return A.current===H.current.length-1}})),react.useEffect(()=>{let I=e[L];I&&r?.(I,L);},[]);let Ze=[];if(L>0&&Ze.push({index:L-1,position:-1}),Ze.push({index:L,position:0}),L<e.length-1&&Ze.push({index:L+1,position:1}),e.length===0)return jsxRuntime.jsx("div",{ref:B,style:Y(Se.container,S),className:b,"data-xhub-reel-feed":true,children:l&&jsxRuntime.jsx("div",{style:{...Se.loadingIndicator,top:"50%",bottom:"auto"},children:jsxRuntime.jsx("div",{style:Se.spinner})})});let cr={...Se.track};return jsxRuntime.jsxs("div",{ref:B,...ur(),style:Y(Se.container,S),className:b,"data-xhub-reel-feed":true,children:[jsxRuntime.jsx("style",{children:`
5
+ `}),jsxRuntime.jsx("div",{role:"status","aria-label":"Loading",style:designTokens.mergeStyles({width:e,height:e,borderWidth:n,borderStyle:"solid",borderColor:`${t}30`,borderTopColor:t,borderRadius:"50%",animation:"xhub-reel-spin 1s linear infinite"},r),className:o})]})}var Hi={position:"fixed",left:designTokens.spacing[4],right:designTokens.spacing[4],zIndex:designTokens.zIndices.toast,display:"flex",justifyContent:"center",pointerEvents:"none"},Di={display:"flex",alignItems:"center",gap:designTokens.spacing[3],padding:`${designTokens.spacing[3]}px ${designTokens.spacing[4]}px`,backgroundColor:designTokens.colors.surface,borderRadius:designTokens.radii.lg,boxShadow:"0 4px 12px rgba(0, 0, 0, 0.5)",pointerEvents:"auto",maxWidth:400},Bi={default:{},success:{borderLeft:`3px solid ${designTokens.colors.success}`},error:{borderLeft:`3px solid ${designTokens.colors.error}`},warning:{borderLeft:`3px solid ${designTokens.colors.warning}`}},Ni={flex:1,fontSize:designTokens.fontSizes.sm,color:designTokens.colors.text,lineHeight:1.4},_i={padding:`${designTokens.spacing[1]}px ${designTokens.spacing[3]}px`,backgroundColor:"transparent",border:"none",color:designTokens.colors.accent,fontSize:designTokens.fontSizes.sm,fontWeight:600,cursor:"pointer",borderRadius:designTokens.radii.sm};function Fn({message:e,isVisible:t,onClose:n,duration:r=3e3,variant:o="default",action:s,position:a="bottom",style:d,className:u=""}){react.useEffect(()=>{if(t&&r>0){let i=setTimeout(n,r);return ()=>clearTimeout(i)}},[t,r,n]);let h=a==="top"?{top:designTokens.spacing[4]}:{bottom:designTokens.spacing[4]+80};return jsxRuntime.jsx(react$1.AnimatePresence,{children:t&&jsxRuntime.jsx("div",{style:{...Hi,...h},children:jsxRuntime.jsxs(react$1.motion.div,{initial:{opacity:0,y:a==="top"?-20:20,scale:.95},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:a==="top"?-20:20,scale:.95},transition:{type:"spring",...designTokens.springs.default},style:designTokens.mergeStyles(Di,Bi[o],d),className:u,children:[jsxRuntime.jsx("span",{style:Ni,children:e}),s&&jsxRuntime.jsx("button",{style:_i,onClick:()=>{s.onClick(),n();},children:s.label})]})})})}var Gi={position:"absolute",pointerEvents:"none",zIndex:designTokens.zIndices.overlay},$i={filter:"drop-shadow(0 4px 8px rgba(255, 45, 85, 0.5))"};function ht(){let[e,t]=react.useState(false),[n,r]=react.useState({x:0,y:0}),o=react.useCallback((a,d)=>{let u=a??(typeof window<"u"?window.innerWidth/2:200),h=d??(typeof window<"u"?window.innerHeight/2:400);r({x:u,y:h}),t(true),setTimeout(()=>{t(false);},800);},[]),s=react.useCallback(()=>{t(false);},[]);return {isShowing:e,position:n,showHeart:o,hideHeart:s}}var qi=({size:e,color:t})=>jsxRuntime.jsx("svg",{style:$i,xmlns:"http://www.w3.org/2000/svg",width:e,height:e,viewBox:"0 0 28 28",fill:t,children:jsxRuntime.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M1.74988 11.0538C1.74988 6.75595 4.69822 2.91699 9.20877 2.91699C11.4347 2.91699 12.9986 3.9593 13.9999 4.96978C15.0011 3.95929 16.565 2.91699 18.791 2.91699C23.3015 2.91699 26.2499 6.75595 26.2499 11.0538C26.2499 15.3962 23.6265 18.9036 20.8781 21.3587C18.1288 23.8145 15.1442 25.3171 14.1843 25.6371L13.9999 25.6985L13.8154 25.6371C12.8555 25.3171 9.87093 23.8145 7.12168 21.3587C4.37329 18.9036 1.74988 15.3962 1.74988 11.0538ZM17.7449 6.41699C17.2617 6.41699 16.8699 6.80874 16.8699 7.29199C16.8699 7.77524 17.2617 8.16699 17.7449 8.16699C19.6221 8.16699 20.9952 9.75855 20.9952 11.8241C20.9952 12.3073 21.387 12.6991 21.8702 12.6991C22.3535 12.6991 22.7452 12.3073 22.7452 11.8241C22.7452 9.02543 20.8066 6.41699 17.7449 6.41699Z",fill:t})});function pt({show:e,position:t={x:0,y:0},size:n=100,color:r=designTokens.colors.like,showParticles:o=true,particleCount:s=8,onComplete:a,style:d,className:u=""}){return jsxRuntime.jsx(react$1.AnimatePresence,{onExitComplete:a,children:e&&jsxRuntime.jsxs(react$1.motion.div,{initial:{opacity:0,scale:0},animate:{opacity:[0,1,1,0],scale:[0,1.3,1,.8],y:[0,-20,-20,-40]},exit:{scale:0,opacity:0},transition:{duration:.8,times:[0,.2,.6,1],ease:"easeOut"},style:{...Gi,left:t.x-n/2,top:t.y-n/2,width:n,height:n,...d},className:u,children:[jsxRuntime.jsx(qi,{size:n,color:r}),o&&[...Array(s)].map((h,i)=>jsxRuntime.jsx(react$1.motion.div,{style:{position:"absolute",width:12,height:12,borderRadius:"50%",backgroundColor:r,left:n/2-6,top:n/2-6},initial:{opacity:1,scale:1},animate:{opacity:0,scale:.5,x:Math.cos(i*Math.PI*2/s)*60,y:Math.sin(i*Math.PI*2/s)*60},transition:{duration:.5,delay:.1,ease:"easeOut"}},i))]})})}function Bn(e){let[t,n]=react.useState(false),r=typeof document<"u"&&!!(document.fullscreenEnabled||document.webkitFullscreenElement!==void 0||document.mozFullScreenElement!==void 0||document.msFullscreenElement!==void 0),o=()=>{let i=document;return i.fullscreenElement||i.webkitFullscreenElement||i.mozFullScreenElement||i.msFullscreenElement||null},s=async i=>{let l=i;l.requestFullscreen?await l.requestFullscreen():l.webkitRequestFullscreen?await l.webkitRequestFullscreen():l.mozRequestFullScreen?await l.mozRequestFullScreen():l.msRequestFullscreen&&await l.msRequestFullscreen();},a=async()=>{let i=document;i.exitFullscreen?await i.exitFullscreen():i.webkitExitFullscreen?await i.webkitExitFullscreen():i.mozCancelFullScreen?await i.mozCancelFullScreen():i.msExitFullscreen&&await i.msExitFullscreen();};react.useEffect(()=>{let i=()=>{let l=o();n(l===e.current);};return document.addEventListener("fullscreenchange",i),document.addEventListener("webkitfullscreenchange",i),document.addEventListener("mozfullscreenchange",i),document.addEventListener("MSFullscreenChange",i),()=>{document.removeEventListener("fullscreenchange",i),document.removeEventListener("webkitfullscreenchange",i),document.removeEventListener("mozfullscreenchange",i),document.removeEventListener("MSFullscreenChange",i);}},[e]);let d=react.useCallback(async()=>{let i=e.current;if(!(!i||!r))try{await s(i),n(!0);let l=screen.orientation;if(l?.lock)try{await l.lock("landscape");}catch{}}catch(l){console.error("[useFullscreen] Failed to enter fullscreen:",l);}},[e,r]),u=react.useCallback(async()=>{if(r)try{await a(),n(!1);let i=screen.orientation;i?.unlock&&i.unlock();}catch(i){console.error("[useFullscreen] Failed to exit fullscreen:",i);}},[r]),h=react.useCallback(async()=>{t?await u():await d();},[t,d,u]);return {isFullscreen:t,isSupported:r,toggleFullscreen:h,enterFullscreen:d,exitFullscreen:u}}var Ji={feed:{autoQualitySwitch:true,pauseOnOffline:false,resumeOnOnline:false,lowQualityOn:"2g"},watch:{autoQualitySwitch:true,pauseOnOffline:false,resumeOnOnline:false,lowQualityOn:"2g"},auto:{autoQualitySwitch:true,pauseOnOffline:true,resumeOnOnline:true,lowQualityOn:"2g"},manual:{autoQualitySwitch:false,pauseOnOffline:false,resumeOnOnline:false}},eo={aggressive:{autoPauseOnLowBattery:true,pauseThreshold:.2},moderate:{autoPauseOnLowBattery:true,pauseThreshold:.15},conservative:{autoPauseOnLowBattery:true,pauseThreshold:.1},manual:{autoPauseOnLowBattery:false}};function $e(e,t,n={}){let r=react.useRef(null),o=react.useRef(null),s=t??o,[a,d]=react.useState(false),u=gn(),h=yn(e),i=vn(e),l=bn(r.current),p=Bn(s),f=react.useRef(n);f.current=n;let{networkBehavior:y,powerBehavior:m}=n,b=react.useMemo(()=>{if(y)return typeof y=="string"?Ji[y]:y},[y]),S=react.useMemo(()=>{if(m)return typeof m=="string"?eo[m]:m},[m]),V=react.useMemo(()=>({onStateChange:g=>{u.transition(g),f.current.onStateChange?.(g),g==="ready"&&!a&&(d(true),f.current.onReady?.());},onError:(g,B)=>{f.current.onError?.(g,B);},onTimeUpdate:(g,B)=>{f.current.onTimeUpdate?.(g,B);},onQualityLevelsLoaded:g=>{f.current.onQualityLevelsLoaded?.(g);},onNetworkChange:g=>{b?.onNetworkChange?.(g),f.current.onNetworkChange?.(g);},onPowerChange:g=>{S?.onPowerChange?.(g),f.current.onPowerChange?.(g);},onAnalyticsUpdate:g=>{f.current.onAnalyticsUpdate?.(g);}}),[u,a,b,S]);react.useEffect(()=>{let g=e.current;if(!g)return;let B=()=>f.current.onPlay?.(),q=()=>f.current.onPause?.(),oe=()=>f.current.onEnded?.();return g.addEventListener("play",B),g.addEventListener("pause",q),g.addEventListener("ended",oe),()=>{g.removeEventListener("play",B),g.removeEventListener("pause",q),g.removeEventListener("ended",oe);}},[e]);let H=react.useCallback((g,B)=>{let q=e.current;if(!q){console.error("[usePlayer] No video element");return}d(false),r.current&&r.current.destroy(),r.current=new mn({preferNative:f.current.preferNative,enableSmoothTimeUpdates:f.current.enableSmoothTimeUpdates,enableNetworkAdaptation:f.current.enableNetworkAdaptation,enablePowerAdaptation:f.current.enablePowerAdaptation,enableAnalytics:f.current.enableAnalytics,preloadConfig:f.current.preloadConfig,callbacks:V,autoQualityOnNetworkChange:b?.autoQualitySwitch,autoPauseOnOffline:b?.pauseOnOffline,autoResumeOnOnline:b?.resumeOnOnline,lowQualityThreshold:b?.lowQualityOn,autoPauseOnLowBattery:S?.autoPauseOnLowBattery,lowBatteryThreshold:S?.pauseThreshold}),r.current.attach(q,g,B);},[e,V,b,S]),c=react.useCallback(()=>{r.current&&(r.current.destroy(),r.current=null),u.reset(),d(false);},[u]),v=react.useCallback(async()=>{await r.current?.play();},[]),P=react.useCallback(()=>{r.current?.pause();},[]),x=react.useCallback(async()=>{await r.current?.togglePlay();},[]),R=react.useCallback(g=>{r.current?.seek(g);},[]),A=react.useCallback((g=10)=>{r.current?.seekForward(g);},[]),D=react.useCallback((g=10)=>{r.current?.seekBackward(g);},[]),z=react.useCallback(g=>{r.current?.setPlaybackRate(g);},[]),_=react.useCallback(()=>{let g=e.current;g&&(g.currentTime=0,g.play().catch(()=>{}));},[e]);return {playerCore:r.current,videoRef:e,containerRef:s,state:u,isReady:a,play:v,pause:P,togglePlay:x,seek:R,seekForward:A,seekBackward:D,setPlaybackSpeed:z,restart:_,volume:h,progress:i,quality:l,fullscreen:p,attach:H,destroy:c}}var ro={position:"relative",width:"100%",height:"100%",backgroundColor:designTokens.colors.background},io={width:"100%",height:"100%",objectFit:"contain"},Ut=react.forwardRef(({video:e,autoPlay:t=true,muted:n=true,loop:r=true,poster:o,children:s,style:a,className:d="",onPlay:u,onPause:h,onEnded:i,onError:l,onStateChange:p,onTimeUpdate:f,onQualityLevelsLoaded:y,onReady:m},b)=>{let S=react.useRef(null),V=react.useRef(null),H=typeof e=="string"?e:e.url,c=o??(typeof e=="object"?e.thumbnail:void 0),v=$e(S,V,{onStateChange:p,onError:P=>l?.(P),onTimeUpdate:f,onQualityLevelsLoaded:y,onPlay:u,onPause:h,onEnded:i,onReady:m});return react.useEffect(()=>(H&&v.attach(H),()=>{v.destroy();}),[H]),react.useEffect(()=>{let P=S.current;P&&(P.muted=n,P.loop=r);},[n,r]),react.useEffect(()=>{let P=S.current;!P||!v.isReady||!t||P.play().catch(x=>{x.name==="NotAllowedError"&&(P.muted=true,P.play().catch(()=>{}));});},[t,v.isReady]),react.useImperativeHandle(b,()=>({play:v.play,pause:v.pause,togglePlay:v.togglePlay,seek:v.seek,seekForward:v.seekForward,seekBackward:v.seekBackward,restart:v.restart,setVolume:v.volume.setVolume,toggleMute:v.volume.toggleMute,setPlaybackSpeed:v.setPlaybackSpeed,setQuality:v.quality.setQuality,getQualityLevels:()=>v.quality.availableLevels,getVideoElement:()=>S.current,getCurrentTime:()=>v.progress.currentTime,getDuration:()=>v.progress.duration,isPaused:()=>S.current?.paused??true}),[v]),jsxRuntime.jsxs("div",{ref:V,style:Y(ro,a),className:d,children:[jsxRuntime.jsx("video",{ref:S,poster:c,playsInline:true,preload:"auto",style:io}),s]})});Ut.displayName="VideoPlayer";var co=30,ho=1e3/co,J={container:{position:"absolute",bottom:0,left:0,right:0,zIndex:designTokens.zIndices.sticky,touchAction:"none",userSelect:"none",WebkitUserSelect:"none",transition:"all 0.125s ease-in-out"},collapsed:{height:Ne.HEIGHT_DEFAULT,paddingInline:designTokens.spacing[3],cursor:"pointer"},expanded:{padding:`${designTokens.spacing[2]}px ${designTokens.spacing[3]}px`,paddingBottom:`calc(${designTokens.spacing[1]}px + env(safe-area-inset-bottom, 0px))`,background:"linear-gradient(to top, rgba(0,0,0,0.8) 0%, transparent 100%)"},timeContainer:{display:"flex",justifyContent:"center",alignItems:"center",marginBottom:designTokens.spacing[2]},timeText:{fontSize:designTokens.fontSizes.sm,fontWeight:designTokens.fontWeights.semibold,color:designTokens.colors.text,textShadow:designTokens.shadows.text,fontVariantNumeric:"tabular-nums",backgroundColor:"rgba(0, 0, 0, 0.6)",padding:`${designTokens.spacing[1]}px ${designTokens.spacing[3]}px`,borderRadius:designTokens.radii.md},track:{position:"relative",width:"100%",backgroundColor:"rgba(255, 255, 255, 0.2)",borderRadius:designTokens.radii.full,overflow:"hidden"},trackCollapsed:{height:Ne.HEIGHT_DEFAULT},trackExpanded:{height:Ne.HEIGHT_ACTIVE},buffer:{position:"absolute",top:0,left:0,height:"100%",backgroundColor:"rgba(255, 255, 255, 0.3)",borderRadius:designTokens.radii.full},progress:{position:"absolute",top:0,left:0,height:"100%",backgroundColor:designTokens.colors.text,borderRadius:designTokens.radii.full},scrubber:{position:"absolute",top:"50%",width:16,height:16,marginLeft:-8,marginTop:-8,backgroundColor:designTokens.colors.text,borderRadius:designTokens.radii.full,boxShadow:"0 2px 4px rgba(0,0,0,0.3)",transform:"scale(0)",transition:"transform 150ms ease"},scrubberVisible:{transform:"scale(1)"},touchArea:{position:"absolute",top:-12,left:0,right:0,bottom:-12,cursor:"pointer"}};function ge(e){if(!isFinite(e)||isNaN(e))return "0:00";let t=Math.floor(e/60),n=Math.floor(e%60);return `${t}:${n.toString().padStart(2,"0")}`}function po(e){if(e.buffered.length===0)return 0;for(let t=0;t<e.buffered.length;t++)if(e.buffered.start(t)<=e.currentTime&&e.buffered.end(t)>=e.currentTime)return e.buffered.end(t);return e.buffered.end(e.buffered.length-1)}var ft=react.forwardRef(({videoRef:e,expanded:t=false,onSeekStart:n,onSeek:r,onSeekEnd:o,onExpandedChange:s,style:a,className:d=""},u)=>{let h=react.useRef(null),i=react.useRef(null),l=react.useRef(null),p=react.useRef(null),f=react.useRef(null),y=react.useRef(0),[m,b]=react.useState({currentTime:0,duration:0}),S=react.useRef(null),V=react.useRef(0),H=react.useRef(0),c=react.useRef(false),v=react.useRef(t);react.useEffect(()=>{v.current=t;},[t]);let P=react.useCallback(C=>{let E=e.current;if(!E||c.current)return;let k=E.duration||0,L=E.currentTime||0,O=po(E),Se=k>0?L/k*100:0,w=k>0?O/k*100:0;i.current&&(i.current.style.width=`${Se}%`),l.current&&(l.current.style.width=`${w}%`),p.current&&v.current&&(p.current.style.left=`${Se}%`),y.current=k,f.current&&(f.current.textContent=`${ge(L)} / ${ge(k)}`);let N=C??performance.now();N-H.current>=500&&(H.current=N,b(j=>Math.abs(j.currentTime-L)>=.5||j.duration!==k?{currentTime:Math.floor(L),duration:Math.floor(k)}:j));},[e]),x=react.useCallback(C=>{C-V.current>=ho&&(V.current=C,P()),S.current=requestAnimationFrame(x);},[P]);react.useEffect(()=>(S.current=requestAnimationFrame(x),()=>{S.current&&cancelAnimationFrame(S.current);}),[x]);let R=react.useCallback(C=>{let E=h.current,k=e.current;if(!E||!k)return 0;let L=E.getBoundingClientRect(),O=C-L.left;return Math.max(0,Math.min(1,O/L.width))*(k.duration||0)},[e]),A=react.useCallback(C=>{c.current=true,n?.();let E=R(C);r?.(E);let k=e.current;if(k&&i.current){let L=k.duration||y.current||1,O=E/L*100;i.current.style.width=`${O}%`,p.current&&(p.current.style.left=`${O}%`),f.current&&(f.current.textContent=`${ge(E)} / ${ge(L)}`);}},[R,r,n,e]),D=react.useCallback(C=>{if(!c.current)return;let E=R(C);r?.(E);let k=e.current;if(k&&i.current){let L=k.duration||y.current||1,O=E/L*100;i.current.style.width=`${O}%`,p.current&&(p.current.style.left=`${O}%`),f.current&&(f.current.textContent=`${ge(E)} / ${ge(L)}`);}},[R,r,e]),z=react.useCallback(C=>{if(!c.current)return;c.current=false;let E=R(C);o?.(E);let k=e.current;k&&(k.currentTime=E);},[R,o,e]),_=react.useCallback(C=>{let E=C.touches[0];E&&A(E.clientX);},[A]),g=react.useCallback(C=>{let E=C.touches[0];E&&D(E.clientX);},[D]),B=react.useCallback(C=>{let E=C.changedTouches[0];E&&z(E.clientX);},[z]),q=react.useCallback(C=>{A(C.clientX);let E=L=>D(L.clientX),k=L=>{z(L.clientX),document.removeEventListener("mousemove",E),document.removeEventListener("mouseup",k);};document.addEventListener("mousemove",E),document.addEventListener("mouseup",k);},[A,D,z]),oe=react.useCallback(()=>{t||s?.(true);},[t,s]),X=react.useCallback(C=>{let E=e.current;if(!E)return;let k=E.duration||0,L=E.currentTime||0,O=L;switch(C.key){case "ArrowLeft":O=Math.max(0,L-5);break;case "ArrowRight":O=Math.min(k,L+5);break;case "ArrowUp":O=Math.min(k,L+10);break;case "ArrowDown":O=Math.max(0,L-10);break;case "Home":O=0;break;case "End":O=k;break;default:return}C.preventDefault(),E.currentTime=O,r?.(O),P();},[e,r,P]);react.useImperativeHandle(u,()=>({update:P,setExpanded:C=>{s?.(C);}}));let $={...J.container,...t?J.expanded:J.collapsed,...a},K={...J.track,...t?J.trackExpanded:J.trackCollapsed},se={...J.scrubber,...t?J.scrubberVisible:{}};return jsxRuntime.jsxs("div",{ref:h,style:$,className:d,onClick:t?void 0:oe,onTouchStart:_,onTouchMove:g,onTouchEnd:B,onTouchCancel:B,onMouseDown:q,onKeyDown:X,role:"slider","aria-label":"Video progress","aria-valuemin":0,"aria-valuemax":m.duration,"aria-valuenow":m.currentTime,"aria-valuetext":`${ge(m.currentTime)} of ${ge(m.duration)}`,tabIndex:0,children:[t&&jsxRuntime.jsx("div",{style:J.timeContainer,children:jsxRuntime.jsx("span",{ref:f,style:J.timeText,children:"0:00 / 0:00"})}),jsxRuntime.jsxs("div",{style:K,"aria-hidden":"true",children:[jsxRuntime.jsx("div",{style:J.touchArea}),jsxRuntime.jsx("div",{ref:l,style:J.buffer}),jsxRuntime.jsx("div",{ref:i,style:J.progress}),t&&jsxRuntime.jsx("div",{ref:p,style:se})]})]})});ft.displayName="Timeline";var fo={DOUBLE_TAP_DELAY:200},mo={THRESHOLD:500},qe={VERTICAL_THRESHOLD:.3,HORIZONTAL_THRESHOLD:.4,MIN_VELOCITY:.5},mt={THRESHOLD:10};var ye={TAP_DELAY:fo.DOUBLE_TAP_DELAY,LONG_PRESS_THRESHOLD:mo.THRESHOLD,SWIPE_VERTICAL_THRESHOLD:qe.VERTICAL_THRESHOLD,SWIPE_HORIZONTAL_THRESHOLD:qe.HORIZONTAL_THRESHOLD,DRAG_THRESHOLD:mt.THRESHOLD};function Qn(){return typeof navigator<"u"&&"vibrate"in navigator}function gt(){Qn()&&navigator.vibrate(10);}function zn(){Qn()&&navigator.vibrate(20);}function Wn(e,t){let n=e.currentTarget||e.target;if(!n||typeof n.getBoundingClientRect!="function")return "center";let r=n.getBoundingClientRect(),o=e.clientX-r.left,s=r.width;if(s===0)return "center";let a=s*.33,d=s*.67;return o<a?"left":o>d?"right":"center"}function yt(e){let t=react.useRef(0),n=react.useRef("center"),r=react.useRef(null),o=react.useRef(null),s=react.useRef(false),a=react.useRef(false),d=react.useRef({x:0,y:0}),u=react.useCallback(i=>{if(a.current){a.current=false;return}let l=Wn(i),p=Date.now(),f=p-t.current,y={x:i.clientX,y:i.clientY};f<ye.TAP_DELAY&&n.current===l?(r.current&&(clearTimeout(r.current),r.current=null),gt(),e.onDoubleTap?.(l,y)):r.current=setTimeout(()=>{e.onSingleTap?.(l),r.current=null;},ye.TAP_DELAY),t.current=p,n.current=l;},[e]);return react$2.useGesture({onPointerDown:({event:i})=>{let l=i;d.current={x:l.clientX,y:l.clientY},a.current=false;let p=setTimeout(()=>{s.current=true,e.onHoldStart?.();},150);o.current=setTimeout(()=>{a.current=true,zn();let y=l.target.getBoundingClientRect();e.onLongPress?.({x:l.clientX-y.left,y:l.clientY-y.top});},ye.LONG_PRESS_THRESHOLD),i.target.dataset.holdTimeout=String(p);},onPointerUp:({event:i})=>{let l=i.target.dataset.holdTimeout;l&&clearTimeout(Number(l)),o.current&&(clearTimeout(o.current),o.current=null),s.current&&(s.current=false,e.onHoldEnd?.());},onPointerMove:({event:i})=>{let l=i,p=Math.abs(l.clientX-d.current.x),f=Math.abs(l.clientY-d.current.y);(p>10||f>10)&&o.current&&(clearTimeout(o.current),o.current=null);},onClick:({event:i})=>{u(i);},onDrag:({movement:[i,l],direction:[p,f],velocity:[y,m],last:b,event:S})=>{if(S.preventDefault(),!b)return;let V=window.innerWidth,H=window.innerHeight;if(Math.abs(l)>H*ye.SWIPE_VERTICAL_THRESHOLD){f>0?e.onSwipeDown?.():e.onSwipeUp?.();return}if(Math.abs(i)>V*ye.SWIPE_HORIZONTAL_THRESHOLD){p>0?e.onSwipeRight?.():e.onSwipeLeft?.();return}Math.abs(i)>ye.DRAG_THRESHOLD&&Math.abs(y)>Math.abs(m)&&e.onSeekDrag?.(i);}},{drag:{threshold:ye.DRAG_THRESHOLD,filterTaps:true},eventOptions:{passive:false}})}var wo=800,Po=.05,Eo=.95;function Qt({onSwipeUp:e,onSwipeDown:t,onSwipeProgress:n,onSwipeCancel:r,threshold:o=qe.VERTICAL_THRESHOLD,velocityThreshold:s=qe.MIN_VELOCITY,hapticEnabled:a=true,disabled:d=false,enableProgressState:u=false}={}){let h=Math.max(Po,Math.min(Eo,o)),[i,l]=react.useState({progress:0,direction:null,isSwiping:false}),p=react.useRef({onSwipeUp:e,onSwipeDown:t,onSwipeProgress:n,onSwipeCancel:r}),f=react.useRef(typeof window<"u"?window.innerHeight:wo);return p.current={onSwipeUp:e,onSwipeDown:t,onSwipeProgress:n,onSwipeCancel:r},react.useEffect(()=>{let m=()=>{f.current=window.innerHeight;},b=()=>{setTimeout(()=>{f.current=window.innerHeight;},100);};return window.addEventListener("resize",m,{passive:true}),window.addEventListener("orientationchange",b,{passive:true}),()=>{window.removeEventListener("resize",m),window.removeEventListener("orientationchange",b);}},[]),{bind:react$2.useDrag(({movement:[,m],velocity:[,b],active:S,cancel:V})=>{if(d){V?.();return}let c=f.current*h,v=Math.min(1,Math.abs(m)/c),P=m<0?"up":"down";if(S)p.current.onSwipeProgress?.(v,P,m),u&&l({progress:v,direction:P,isSwiping:true});else {let x=Math.abs(m)>=c,R=Math.abs(b)>=s;x||R?(a&&gt(),P==="up"?p.current.onSwipeUp?.():p.current.onSwipeDown?.()):p.current.onSwipeCancel?.(),l({progress:0,direction:null,isSwiping:false});}},{axis:"y",threshold:mt.THRESHOLD,filterTaps:true,pointer:{touch:true},eventOptions:{passive:true}}),...i}}var Oe={container:{position:"relative",width:"100%",height:"100%",backgroundColor:designTokens.colors.background},video:{position:"absolute",inset:0,width:"100%",height:"100%",objectFit:"contain"},placeholder:{position:"absolute",inset:0,backgroundSize:"cover",backgroundPosition:"center"},tapArea:{zIndex:designTokens.zIndices.base},pauseOverlay:{zIndex:designTokens.zIndices.overlay},pauseIconWrapper:{borderRadius:designTokens.radii.full,transition:`opacity ${designTokens.durations.normal}ms ${designTokens.easings.xhubReel}, transform ${designTokens.durations.normal}ms ${designTokens.easings.xhubReel}`}};var zt=react.createContext(null);function pe(){let e=react.useContext(zt);if(!e)throw new Error("VideoFeedItem compound components must be used within a VideoFeedItem");return e}function $n({elementRef:e,activateThreshold:t=et.ACTIVATION_THRESHOLD,deactivateThreshold:n=et.DEACTIVATION_THRESHOLD,rootMargin:r="0px",onVisibilityChange:o}){let[s,a]=react.useState(false),[d,u]=react.useState(false),[h,i]=react.useState(0),l=react.useRef(null);return react.useEffect(()=>{let p=e.current;if(!p)return;l.current&&l.current.disconnect();let f=[0,.1,.2,.3,.4,.5,.6,.7,.8,.9,1];return l.current=new IntersectionObserver(y=>{y.forEach(m=>{let b=m.intersectionRatio;i(b),a(b>0),b>=t?u(true):b<n&&u(false),o?.(b>0,b);});},{threshold:f,rootMargin:r}),l.current.observe(p),()=>{l.current?.disconnect();}},[e,t,n,r,o]),{isVisible:s,isActive:d,visibilityRatio:h}}function Yn({containerRef:e,videoRef:t,isCurrentVideo:n=false,onActivate:r,onDeactivate:o,autoActivate:s=true,trackVisibility:a=false,onVisibilityChange:d}){let u=react.useRef(false),{isVisible:h,isActive:i,visibilityRatio:l}=$n({elementRef:e??{current:null},onVisibilityChange:a?d:void 0}),p=a?i:n;react.useEffect(()=>{s&&(p&&!u.current?(u.current=true,r?.()):!p&&u.current&&(u.current=false,o?.()));},[p,r,o,s]);let f=react.useCallback(()=>{let m=t.current;m&&m.play().catch(()=>{m.muted=true,m.play().catch(()=>{});}),r?.();},[t,r]),y=react.useCallback(()=>{let m=t.current;m&&(m.pause(),m.currentTime=0),o?.();},[t,o]);return {isActive:p,isVisible:a?h:n,visibilityRatio:a?l:n?1:0,activate:f,deactivate:y}}var Gt=class{entries=new Map;listeners=new Set;memoryWarningThreshold;constructor(){this.memoryWarningThreshold=Re.MAX_TOTAL_MEMORY/(1024*1024),this.setupMemoryPressureListener();}register(t,n=10){this.entries.set(t,{videoId:t,inDom:false,hasDecodedFrames:false,estimatedSizeMB:n,lastAccessed:Date.now()}),this.notifyListeners();}unregister(t){this.entries.delete(t),this.notifyListeners();}setInDom(t,n){let r=this.entries.get(t);r&&(r.inDom=n,r.lastAccessed=Date.now(),this.notifyListeners());}setHasDecodedFrames(t,n){let r=this.entries.get(t);r&&(r.hasDecodedFrames=n,r.lastAccessed=Date.now(),this.notifyListeners());}getState(){let t=0,n=0,r=0;return this.entries.forEach(o=>{o.inDom&&t++,o.hasDecodedFrames&&n++,r+=o.estimatedSizeMB;}),{videosInDom:t,decodedVideos:n,estimatedMemoryMB:r,isLowMemory:r>this.memoryWarningThreshold}}getVideosToDispose(){let t=this.getState(),n=[],r=Re?.MAX_VIDEOS_IN_DOM,o=Re?.MAX_DECODED_FRAMES,s=Array.from(this.entries.values()).sort((a,d)=>a.lastAccessed-d.lastAccessed);if(t.videosInDom>r){let a=t.videosInDom-r,d=0;for(let u of s){if(d>=a)break;u.inDom&&(n.push(u.videoId),d++);}}if(t.decodedVideos>o){let a=t.decodedVideos-o,d=0;for(let u of s){if(d>=a)break;u.hasDecodedFrames&&!n.includes(u.videoId)&&(n.push(u.videoId),d++);}}return n}subscribe(t){return this.listeners.add(t),()=>this.listeners.delete(t)}forceCleanup(){let t=this.getVideosToDispose();return t.forEach(n=>this.unregister(n)),t}notifyListeners(){let t=this.getState();this.listeners.forEach(n=>n(t));}setupMemoryPressureListener(){typeof window>"u"||"memory"in performance&&setInterval(()=>{this.getState().isLowMemory&&(console.warn("[MemoryManager] Low memory warning, forcing cleanup"),this.forceCleanup());},5e3);}},ve=new Gt;function Zn({videoId:e,estimatedSizeMB:t=10,onShouldDispose:n}){let[r,o]=react.useState(()=>ve.getState()),[s,a]=react.useState(false);react.useEffect(()=>(ve.register(e,t),()=>{ve.unregister(e);}),[e,t]),react.useEffect(()=>ve.subscribe(i=>{o(i);let p=ve.getVideosToDispose().includes(e);p&&!s?(a(true),n?.()):!p&&s&&a(false);}),[e,s,n]);let d=react.useCallback(h=>{ve.setInDom(e,h);},[e]),u=react.useCallback(h=>{ve.setHasDecodedFrames(e,h);},[e]);return {memoryState:r,setInDom:d,setHasDecodedFrames:u,shouldDispose:s}}function er({video:e,isActive:t,priority:n,initialMuted:r=true,onLike:o,onComment:s,onShare:a,onAuthorClick:d}){let u=react.useRef(null),h=react.useRef(null),i=react.useRef(false),[l,p]=react.useState(false),[f,y]=react.useState(false),[m,b]=react.useState(false),{isShowing:S,position:V,showHeart:H}=ht(),c=react.useMemo(()=>({maxConcurrent:2,maxBufferSize:10*1024*1024,priorityLevels:10}),[]),v=react.useCallback(w=>{},[]),P=react.useCallback(w=>{},[]),x=react.useCallback(w=>{w.startupTime&&w.startupTime>1e3&&console.warn("[VideoFeedItem] Slow startup:",w.startupTime,"ms",e.id);},[e.id]),{state:R}=$e(h,u,{preferNative:true,enableSmoothTimeUpdates:true,networkBehavior:"feed",powerBehavior:"moderate",preloadConfig:c,enableAnalytics:true,onPlay:()=>{p(false),y(false);},onPause:()=>{h.current?.seeking||(p(true),y(true));},onNetworkChange:v,onPowerChange:P,onAnalyticsUpdate:x}),A=react.useCallback(async()=>{let w=h.current;if(w){w.muted=r;try{await w.play();}catch(N){if(N.name==="NotAllowedError"&&!r){console.warn("[VideoFeedItem] Autoplay blocked, falling back to muted"),w.muted=true;try{await w.play();}catch(j){console.warn("[VideoFeedItem] Play failed even muted:",j.message);}}else console.warn("[VideoFeedItem] Play failed:",N.message);}}},[r]),D=react.useCallback(()=>{let w=h.current;w&&w.pause();},[]),z=react.useCallback(w=>{let N=h.current;N&&(N.currentTime=w);},[]),[_,g]=react.useState(false);react.useEffect(()=>{let w=h.current;if(!w)return;let N=()=>g(true),j=()=>g(false),Ze=()=>g(false);return w.addEventListener("play",N),w.addEventListener("pause",j),w.addEventListener("ended",Ze),g(!w.paused),()=>{w.removeEventListener("play",N),w.removeEventListener("pause",j),w.removeEventListener("ended",Ze);}},[e.id]);let B=_||R.state==="playing",{setInDom:q,setHasDecodedFrames:oe,shouldDispose:X}=Zn({videoId:e.id,onShouldDispose:()=>{D(),h.current&&(h.current.src="",h.current.load());}}),$=!X&&n!=="none",K=react.useRef(false);Yn({videoRef:h,isCurrentVideo:t,onActivate:()=>{console.log("[VideoFeedItem] onActivate called, videoRef:",h.current?.src),oe(true),h.current?A():(console.log("[VideoFeedItem] Video element not ready, marking pending play"),K.current=true);},onDeactivate:()=>{console.log("[VideoFeedItem] onDeactivate called"),K.current=false,oe(false),D(),z(0);},autoActivate:true}),react.useEffect(()=>{h.current&&K.current&&t&&(console.log("[VideoFeedItem] Video element now available, executing pending play"),K.current=false,A());}),react.useEffect(()=>(q(true),()=>q(false)),[q]),react.useEffect(()=>{let w=h.current;if(!w)return;b(false);let N=()=>{console.log("[VideoFeedItem] Video loadeddata:",e.id,{isActive:t,priority:n}),n==="high"&&!t?requestAnimationFrame(()=>{w.readyState>=2&&(w.currentTime=.01,b(true),console.log("[VideoFeedItem] First frame decoded (preloaded):",e.id));}):t&&b(true);},j=()=>{n==="high"&&!m&&b(true);};return w.addEventListener("loadeddata",N),w.addEventListener("canplay",j),w.readyState>=2&&N(),()=>{w.removeEventListener("loadeddata",N),w.removeEventListener("canplay",j);}},[e.id,t,n,m]),react.useEffect(()=>{console.log("[VideoFeedItem] State:",{videoId:e.id,isActive:t,priority:n,shouldRenderVideo:$,hasVideoElement:!!h.current,videoSrc:h.current?.src});},[e.id,t,n,$]);let se=react.useMemo(()=>{switch(n){case "high":return "auto";case "medium":return "metadata";case "low":case "metadata":return "none";default:return "none"}},[n]),C=react.useCallback(()=>{i.current=B,y(true),p(false),D();},[B,D]),E=react.useCallback(w=>{z(w),i.current?(A(),y(false)):p(true);},[z,A]),k=react.useCallback(()=>{B?D():A();},[B,A,D]),L=react.useCallback((w,N)=>{H(N.x,N.y),o?.();},[H,o]),O=react.useCallback(()=>{},[]),Se=yt({onSingleTap:k,onDoubleTap:L,onLongPress:O});return {video:e,isActive:t,shouldRenderVideo:$,preload:se,isPreloaded:m,initialMuted:r,containerRef:u,videoRef:h,isPlaying:B,showPauseOverlay:l,timelineExpanded:f,play:A,pause:D,seek:z,setShowPauseOverlay:p,setTimelineExpanded:y,gestureBindings:Se,showHeart:S,heartPosition:V,triggerHeart:H,onLike:o,onComment:s,onShare:a,onAuthorClick:d,handleSeekStart:C,handleSeekEnd:E}}var St=react.forwardRef(({placeholder:e,...t},n)=>{let{video:r,videoRef:o,shouldRenderVideo:s,preload:a,isPreloaded:d,initialMuted:u}=pe();if(!s)return e??jsxRuntime.jsx("div",{...t,style:{...Oe.placeholder,backgroundImage:`url(${r.thumbnail})`,...t.style}});let h=!d;return jsxRuntime.jsx("video",{ref:i=>{typeof n=="function"?n(i):n&&(n.current=i),o.current=i;},src:r.url,poster:h?r.thumbnail:void 0,preload:a,loop:true,playsInline:true,muted:u,style:Oe.video})});St.displayName="VideoFeedItemPlayer";var wt=react.forwardRef(({onLike:e,onComment:t,onShare:n,...r},o)=>{let{video:s,onLike:a,onComment:d,onShare:u}=pe();return jsxRuntime.jsx("div",{ref:o,...r,children:jsxRuntime.jsx(at,{avatarUrl:s.author.avatar,likeCount:s.stats.likes,commentCount:s.stats.comments,shareCount:s.stats.shares,isLiked:s.isLiked,onLike:e??a,onComment:t??d,onShare:n??u})})});wt.displayName="VideoFeedItemActions";var Pt=react.forwardRef(({expanded:e,...t},n)=>{let{videoRef:r,shouldRenderVideo:o,timelineExpanded:s,setTimelineExpanded:a,handleSeekStart:d,handleSeekEnd:u}=pe();return o?jsxRuntime.jsx("div",{ref:n,...t,children:jsxRuntime.jsx(ft,{videoRef:r,expanded:e??s,onSeekStart:d,onSeekEnd:u,onExpandedChange:a})}):null});Pt.displayName="VideoFeedItemTimeline";var He={container:{position:"absolute",bottom:0,left:0,right:64,padding:designTokens.spacing[4],paddingBottom:"env(safe-area-inset-bottom, 16px)",zIndex:designTokens.zIndices.base},containerWithTimeline:{paddingBottom:"calc(env(safe-area-inset-bottom, 16px) + 48px)"},authorButton:{gap:designTokens.spacing[2],marginBottom:designTokens.spacing[3]},avatar:{borderRadius:designTokens.radii.full,border:`2px solid ${designTokens.colors.text}`},username:{color:designTokens.colors.text,fontWeight:designTokens.fontWeights.semibold,fontSize:designTokens.fontSizes.sm,textShadow:designTokens.shadows.text},caption:{color:designTokens.colors.text,fontSize:designTokens.fontSizes.sm,lineHeight:1.4,textShadow:designTokens.shadows.text,display:"-webkit-box",WebkitLineClamp:2,WebkitBoxOrient:"vertical",overflow:"hidden",paddingBottom:designTokens.spacing[1]},author:{color:designTokens.colors.text,fontSize:designTokens.fontSizes.sm,fontWeight:designTokens.fontWeights.semibold,textShadow:designTokens.shadows.text,display:"-webkit-box",WebkitLineClamp:1,WebkitBoxOrient:"vertical",overflow:"hidden",paddingBottom:designTokens.spacing[1]},hashtags:{display:"flex",flexWrap:"wrap",gap:designTokens.spacing[1],marginTop:designTokens.spacing[2],paddingBottom:designTokens.spacing[1]},hashtag:{color:designTokens.colors.accent,fontSize:designTokens.fontSizes.sm,fontWeight:designTokens.fontWeights.medium,textShadow:designTokens.shadows.text}};function or({video:e,timelineExpanded:t=false,style:n,className:r=""}){let o=Y(He.container,t&&He.containerWithTimeline,n);return jsxRuntime.jsxs("div",{style:o,className:r,children:[e.author&&jsxRuntime.jsx("p",{style:He.author,children:e.author.displayName}),e.caption&&jsxRuntime.jsx("p",{style:He.caption,children:e.caption}),e.hashtags&&e.hashtags.length>0&&jsxRuntime.jsx("div",{style:He.hashtags,children:e.hashtags.slice(0,3).map((s,a)=>jsxRuntime.jsxs("span",{style:He.hashtag,children:["#",s]},a))})]})}var Et=react.forwardRef(({showPlayPause:e=true,showDoubleTapHeart:t=true,showVideoInfo:n=true,...r},o)=>{let{video:s,isPlaying:a,showPauseOverlay:d,timelineExpanded:u,showHeart:h,heartPosition:i,onAuthorClick:l}=pe();return jsxRuntime.jsxs("div",{ref:o,...r,children:[e&&jsxRuntime.jsx(dt,{isPlaying:a,show:d,size:64,autoHideDelay:800,showOnStateChange:false}),t&&jsxRuntime.jsx(pt,{show:h,position:i,size:100,showParticles:true,particleCount:8}),n&&jsxRuntime.jsx(or,{video:s,onAuthorClick:l,timelineExpanded:u})]})});Et.displayName="VideoFeedItemOverlay";var Be=react.forwardRef(({video:e,isActive:t=false,priority:n="none",initialMuted:r=true,showTimeline:o=true,onLike:s,onComment:a,onShare:d,onAuthorClick:u,style:h,className:i="",children:l},p)=>{let f=er({video:e,isActive:t,priority:n,initialMuted:r,onLike:s,onComment:a,onShare:d,onAuthorClick:u}),y=l??jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(St,{}),jsxRuntime.jsx(Et,{}),jsxRuntime.jsx(wt,{}),o&&jsxRuntime.jsx(Pt,{})]});return jsxRuntime.jsx(zt.Provider,{value:f,children:jsxRuntime.jsx("div",{ref:m=>{typeof p=="function"?p(m):p&&(p.current=m),f.containerRef.current=m;},style:Y(Oe.container,h),className:i,...f.gestureBindings(),children:y})})});Be.displayName="VideoFeedItem";function sr(e,t){let n=e-t;return n===0||n===-1||n===1?"high":n===2?"medium":n===3?"low":Math.abs(n)<=5?"metadata":"none"}var Bo="cubic-bezier(0.32, 0.72, 0, 1)",No=300,_o=800,Uo=50;function lr({trackRef:e,transitionDuration:t=No,easing:n=Bo,onTransitionEnd:r}){let o=react.useRef(typeof window<"u"?window.innerHeight:_o),s=react.useRef(0),a=react.useRef(null),d=react.useRef(false),u=react.useRef(true);react.useEffect(()=>{let f=()=>{o.current=window.innerHeight;},y=()=>{setTimeout(()=>{o.current=window.innerHeight;},100);};return window.addEventListener("resize",f,{passive:true}),window.addEventListener("orientationchange",y,{passive:true}),()=>{window.removeEventListener("resize",f),window.removeEventListener("orientationchange",y);}},[]);let h=react.useCallback(f=>{s.current=f,a.current!==null&&cancelAnimationFrame(a.current),a.current=requestAnimationFrame(()=>{let y=e.current;y&&(y.style.transition="none",y.style.transform=`translateY(${f}px)`),a.current=null;});},[e]),i=react.useCallback(f=>new Promise(y=>{let m=e.current;if(!m||!u.current){y();return}if(d.current){y();return}d.current=true,s.current=f;let b=null,S=null,V=H=>{H.propertyName==="transform"&&(b?.(),u.current&&(d.current=false,r?.()),y());};b=()=>{m.removeEventListener("transitionend",V),S&&(clearTimeout(S),S=null);},m.addEventListener("transitionend",V),S=setTimeout(()=>{b?.(),u.current&&d.current&&(d.current=false,r?.()),y();},t+Uo),m.offsetHeight,m.style.transition=`transform ${t}ms ${n}`,m.style.transform=`translateY(${f}px)`;}),[e,t,n,r]),l=react.useCallback(()=>i(0),[i]),p=react.useCallback(()=>s.current,[]);return react.useEffect(()=>(u.current=true,()=>{u.current=false,a.current!==null&&(cancelAnimationFrame(a.current),a.current=null);}),[]),{setTranslateY:h,animateTo:i,snapBack:l,getCurrentY:p,viewportHeight:o.current,isAnimating:d.current}}var Wo=300,Go=50,$o=.3,qo="cubic-bezier(0.32, 0.72, 0, 1)",be={container:{position:"fixed",inset:0,overflow:"hidden",backgroundColor:designTokens.colors.background,touchAction:"none",userSelect:"none",WebkitUserSelect:"none"},track:{position:"relative",width:"100%",height:"100%",willChange:"transform"},slide:{position:"absolute",left:0,width:"100%",height:"100%",backfaceVisibility:"hidden",WebkitBackfaceVisibility:"hidden"},loadingIndicator:{position:"absolute",bottom:80,left:0,right:0,display:"flex",justifyContent:"center",zIndex:designTokens.zIndices.base,pointerEvents:"none"},spinner:{width:24,height:24,borderWidth:2,borderStyle:"solid",borderColor:"rgba(255, 255, 255, 0.3)",borderTopColor:designTokens.colors.text,borderRadius:designTokens.radii.full,animation:"xhub-reel-spin 1s linear infinite"}},Ke=react.forwardRef(({videos:e,initialIndex:t=0,onLoadMore:n,onVideoChange:r,onLike:o,onComment:s,onShare:a,onAuthorClick:d,isLoading:u=false,hasMore:h=false,loadMoreThreshold:i=3,transitionDuration:l=Wo,swipeThreshold:p=Go,velocityThreshold:f=$o,gesturesDisabled:y=false,hapticEnabled:m=true,initialMuted:b=true,style:S,className:V=""},H)=>{let[c,v]=react.useState(()=>Math.min(Math.max(0,t),Math.max(0,e.length-1))),[P,x]=react.useState(false),[R,A]=react.useState(false),D=react.useRef(null),z=react.useRef(null),_=react.useRef(e),g=react.useRef(c),B=react.useRef(u),q=react.useRef(h),oe=react.useRef(P),{setCurrentIndex:X}=Tt(),{setTranslateY:$,animateTo:K,snapBack:se,viewportHeight:C}=lr({trackRef:z,transitionDuration:l,easing:qo});react.useEffect(()=>{_.current=e;},[e]),react.useEffect(()=>{g.current=c;},[c]),react.useEffect(()=>{B.current=u;},[u]),react.useEffect(()=>{q.current=h;},[h]),react.useEffect(()=>{oe.current=P;},[P]),react.useEffect(()=>{if(e.length===0){v(0);return}if(c>=e.length){let I=e.length-1,U=e[I];v(I),X(I),U&&r?.(U,I);}},[e.length,c,X,r,e]);let E=react.useCallback(I=>sr(I,c),[c]),k=react.useCallback(I=>{let U=_.current;q.current&&!B.current&&U.length-I<=i&&n?.();},[i,n]),L=react.useCallback(async(I,U=true)=>{if(oe.current)return;let F=_.current,M=Math.max(0,Math.min(I,F.length-1)),ae=g.current;if(M===ae){$(0);return}let xe=M>ae?-1:1;if(U){x(true),A(true),await K(xe*C),v(M),X(M),$(0);let we=F[M];we&&r?.(we,M),k(M),A(false),x(false);}else {v(M),X(M),$(0);let we=F[M];we&&(r?.(we,M),k(M));}},[C,K,$,X,r,k]),O=react.useCallback((I=true)=>{let U=_.current,F=g.current;F<U.length-1&&L(F+1,I);},[L]),Se=react.useCallback((I=true)=>{let U=g.current;U>0&&L(U-1,I);},[L]),w=react.useCallback((I,U,F)=>{let M=_.current,ae=g.current,xe=ae>0,we=ae<M.length-1,Kt=F;(U==="down"&&!xe||U==="up"&&!we)&&(Kt*=.3),$(Kt);},[$]),N=react.useCallback(async()=>{let I=_.current;if(!(g.current<I.length-1)){await se();return}x(true),A(true),await K(-C);let M=g.current+1,ae=_.current;if(M<ae.length){v(M),X(M);let xe=ae[M];xe&&r?.(xe,M),k(M);}$(0),A(false),x(false);},[C,K,se,$,X,r,k]),j=react.useCallback(async()=>{if(!(g.current>0)){await se();return}x(true),A(true),await K(C);let F=g.current-1;if(F>=0){v(F),X(F);let M=_.current[F];M&&r?.(M,F);}$(0),A(false),x(false);},[C,K,se,$,X,r]),Ze=react.useCallback(async()=>{await se();},[se]),{bind:cr}=Qt({onSwipeUp:N,onSwipeDown:j,onSwipeProgress:w,onSwipeCancel:Ze,threshold:p/C,velocityThreshold:f,hapticEnabled:m,disabled:y||P,enableProgressState:false});react.useImperativeHandle(H,()=>({slideTo:L,slideNext:O,slidePrev:Se,get activeIndex(){return g.current},get totalSlides(){return _.current.length},get isBeginning(){return g.current===0},get isEnd(){return g.current===_.current.length-1}})),react.useEffect(()=>{let I=e[c];I&&r?.(I,c);},[]);let Je=[];if(c>0&&Je.push({index:c-1,position:-1}),Je.push({index:c,position:0}),c<e.length-1&&Je.push({index:c+1,position:1}),e.length===0)return jsxRuntime.jsx("div",{ref:D,style:Y(be.container,S),className:V,"data-xhub-reel-feed":true,children:u&&jsxRuntime.jsx("div",{style:{...be.loadingIndicator,top:"50%",bottom:"auto"},children:jsxRuntime.jsx("div",{style:be.spinner})})});let hr={...be.track};return jsxRuntime.jsxs("div",{ref:D,...cr(),style:Y(be.container,S),className:V,"data-xhub-reel-feed":true,children:[jsxRuntime.jsx("style",{children:`
6
6
  @keyframes xhub-reel-spin {
7
7
  to { transform: rotate(360deg); }
8
8
  }
9
- `}),jsxRuntime.jsx("div",{ref:z,style:cr,children:Ze.map(({index:I,position:U})=>{let F=e[I];if(!F)return null;let M=x(I),ae=I===L&&!O;return jsxRuntime.jsx("div",{"data-index":I,style:{...Se.slide,top:U*J},children:jsxRuntime.jsx(Be,{video:F,isActive:ae,priority:M,onLike:()=>o?.(F),onComment:()=>s?.(F),onShare:()=>d?.(F),onAuthorClick:()=>u?.(F)})},F.id)})}),l&&jsxRuntime.jsx("div",{style:Se.loadingIndicator,children:jsxRuntime.jsx("div",{style:Se.spinner})})]})});Ke.displayName="VideoFeed";function Yt({videos:e,initialIndex:t=0,onLoadMore:n,hasMore:r=true,isLoading:o=false,onLike:s,onComment:d,onShare:u,onAuthorClick:l,onVideoChange:m,className:i=""}){let a=react.useRef(null),p=react.useCallback((b,V)=>{m?.(b,V);},[m]),c=react.useCallback(b=>{s?.(b);},[s]),g=react.useCallback(b=>{d?.(b);},[d]),f=react.useCallback(b=>{u?.(b);},[u]),S=react.useCallback(b=>{l?.(b);},[l]);return jsxRuntime.jsx("div",{className:`h-screen w-full overflow-hidden bg-black ${i}`,children:jsxRuntime.jsx(Ke,{ref:a,videos:e,initialIndex:t,onLoadMore:n,hasMore:r,isLoading:o,onVideoChange:p,onLike:c,onComment:g,onShare:f,onAuthorClick:S})})}function dr(e){let{container:t,...n}=e,r=typeof t=="string"?document.querySelector(t):t;if(!r||!(r instanceof HTMLElement))throw new Error("[XHubReelEmbed] Invalid container element");let o=client.createRoot(r),s=n,d=u=>{s=u,o.render(react.createElement(Yt,u));};return d(n),{updateVideos:u=>{d({...s,videos:u});},destroy:()=>{o.unmount();}}}typeof window<"u"&&(window.XHubReel=dr);exports.ActionBar=st;exports.BottomSheet=xn;exports.IconButton=At;exports.PlayPauseOverlay=lt;exports.Spinner=In;exports.Toast=An;exports.VideoFeed=Ke;exports.VideoFeedItem=Be;exports.VideoPlayer=_t;exports.XHubReelEmbed=Yt;exports.createXHubReelEmbed=dr;exports.useVideoGestures=gt;
9
+ `}),jsxRuntime.jsx("div",{ref:z,style:hr,children:Je.map(({index:I,position:U})=>{let F=e[I];if(!F)return null;let M=E(I),ae=I===c&&!R;return jsxRuntime.jsx("div",{"data-index":I,style:{...be.slide,top:U*C},children:jsxRuntime.jsx(Be,{video:F,isActive:ae,priority:M,initialMuted:b,onLike:()=>o?.(F),onComment:()=>s?.(F),onShare:()=>a?.(F),onAuthorClick:()=>d?.(F)})},F.id)})}),u&&jsxRuntime.jsx("div",{style:be.loadingIndicator,children:jsxRuntime.jsx("div",{style:be.spinner})})]})});Ke.displayName="VideoFeed";function Xt({videos:e,initialIndex:t=0,onLoadMore:n,hasMore:r=true,isLoading:o=false,onLike:s,onComment:a,onShare:d,onAuthorClick:u,onVideoChange:h,className:i=""}){let l=react.useRef(null),p=react.useCallback((S,V)=>{h?.(S,V);},[h]),f=react.useCallback(S=>{s?.(S);},[s]),y=react.useCallback(S=>{a?.(S);},[a]),m=react.useCallback(S=>{d?.(S);},[d]),b=react.useCallback(S=>{u?.(S);},[u]);return jsxRuntime.jsx("div",{className:`h-screen w-full overflow-hidden bg-black ${i}`,children:jsxRuntime.jsx(Ke,{ref:l,videos:e,initialIndex:t,onLoadMore:n,hasMore:r,isLoading:o,onVideoChange:p,onLike:f,onComment:y,onShare:m,onAuthorClick:b})})}function ur(e){let{container:t,...n}=e,r=typeof t=="string"?document.querySelector(t):t;if(!r||!(r instanceof HTMLElement))throw new Error("[XHubReelEmbed] Invalid container element");let o=client.createRoot(r),s=n,a=d=>{s=d,o.render(react.createElement(Xt,d));};return a(n),{updateVideos:d=>{a({...s,videos:d});},destroy:()=>{o.unmount();}}}typeof window<"u"&&(window.XHubReel=ur);exports.ActionBar=at;exports.BottomSheet=Rn;exports.IconButton=Ft;exports.PlayPauseOverlay=dt;exports.Spinner=Mn;exports.Toast=Fn;exports.VideoFeed=Ke;exports.VideoFeedItem=Be;exports.VideoPlayer=Ut;exports.XHubReelEmbed=Xt;exports.createXHubReelEmbed=ur;exports.useVideoGestures=yt;
package/dist/index.mjs CHANGED
@@ -1,9 +1,9 @@
1
- import ln,{Events,ErrorTypes}from'hls.js';import {create}from'zustand';import {persist}from'zustand/middleware';import {shadows,colors,fontWeights,fontSizes,radii,spacing,easings,durations,components,mergeStyles,zIndices,springs}from'@xhub-reel/design-tokens';import {forwardRef,useRef,useEffect,useImperativeHandle,useState,useCallback,createContext,useMemo,useContext,createElement}from'react';import {AnimatePresence,motion}from'motion/react';import {jsx,jsxs,Fragment}from'react/jsx-runtime';import {useDrag,useGesture}from'@use-gesture/react';import {createRoot}from'react-dom/client';var Ct={maxBufferLength:30,maxMaxBufferLength:60,maxBufferSize:3e7,maxBufferHole:.5,abrEwmaDefaultEstimate:5e5,abrBandWidthUpFactor:.7,abrBandWidthFactor:.9,startLevel:-1,autoStartLoad:true,startPosition:-1,fragLoadingMaxRetry:3,manifestLoadingMaxRetry:3,levelLoadingMaxRetry:3,fragLoadingTimeOut:2e4,manifestLoadingTimeOut:1e4,levelLoadingTimeOut:1e4,lowLatencyMode:false,liveSyncDuration:3};var Je={ACTIVATION_THRESHOLD:.5,DEACTIVATION_THRESHOLD:.3},Re={MAX_VIDEOS_IN_DOM:5,MAX_DECODED_FRAMES:3,MAX_TOTAL_MEMORY:150*1024*1024},Ne={HEIGHT_DEFAULT:2,HEIGHT_ACTIVE:4};var kt={PLAYER_PREFERENCES:"xhub-reel-player"};var Kt={isMuted:true,volume:1,playbackSpeed:1,quality:"auto"},_e=create()(persist(e=>({...Kt,toggleMute:()=>e(t=>({isMuted:!t.isMuted})),setMuted:t=>e({isMuted:t}),setVolume:t=>e({volume:Math.max(0,Math.min(1,t)),isMuted:t===0}),setPlaybackSpeed:t=>e({playbackSpeed:t}),setQuality:t=>e({quality:t}),resetPreferences:()=>e(Kt)}),{name:kt.PLAYER_PREFERENCES}));var jt={videos:[],currentIndex:0,isLoading:false,hasMore:true,error:null},Lt=create(e=>({...jt,setVideos:t=>e({videos:t,currentIndex:0}),appendVideos:t=>e(n=>({videos:[...n.videos,...t]})),setCurrentIndex:t=>e({currentIndex:t}),goToNext:()=>e(t=>({currentIndex:Math.min(t.currentIndex+1,t.videos.length-1)})),goToPrevious:()=>e(t=>({currentIndex:Math.max(t.currentIndex-1,0)})),removeVideo:t=>e(n=>{let r=n.videos.filter(s=>s.id!==t),o=Math.min(n.currentIndex,r.length-1);return {videos:r,currentIndex:Math.max(0,o)}}),setLoading:t=>e({isLoading:t}),setHasMore:t=>e({hasMore:t}),setError:t=>e({error:t}),reset:()=>e(jt)}));function Y(...e){return Object.assign({},...e.filter(Boolean))}var Ue={flex:(e={})=>({display:"flex",flexDirection:e.direction,alignItems:e.align,justifyContent:e.justify,gap:typeof e.gap=="number"?e.gap:spacing[e.gap||0],flexWrap:e.wrap}),flexCenter:{display:"flex",alignItems:"center",justifyContent:"center"},flexBetween:{display:"flex",alignItems:"center",justifyContent:"space-between"},flexColumn:{display:"flex",flexDirection:"column"},grid:(e={})=>({display:"grid",gridTemplateColumns:typeof e.columns=="number"?`repeat(${e.columns}, 1fr)`:e.columns,gridTemplateRows:typeof e.rows=="number"?`repeat(${e.rows}, 1fr)`:e.rows,gap:typeof e.gap=="number"?e.gap:spacing[e.gap||0]}),absolute:(e={})=>({position:"absolute",...e.inset!==void 0&&{inset:e.inset},...e.top!==void 0&&{top:e.top},...e.right!==void 0&&{right:e.right},...e.bottom!==void 0&&{bottom:e.bottom},...e.left!==void 0&&{left:e.left}}),fixed:(e={})=>({position:"fixed",...e.inset!==void 0&&{inset:e.inset},...e.top!==void 0&&{top:e.top},...e.right!==void 0&&{right:e.right},...e.bottom!==void 0&&{bottom:e.bottom},...e.left!==void 0&&{left:e.left}}),fullScreen:{position:"fixed",inset:0,width:"100%",height:"100%"},fullSize:{width:"100%",height:"100%"},centerAbsolute:{position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)"}};({heading:{fontSize:fontSizes.xl,fontWeight:fontWeights.bold,color:colors.text},body:{fontSize:fontSizes.md,fontWeight:fontWeights.normal,color:colors.text},caption:{fontSize:fontSizes.xs,fontWeight:fontWeights.normal,color:colors.textSecondary},videoText:{color:colors.text,textShadow:shadows.text}});var Ie={bg:e=>({backgroundColor:e in colors?colors[e]:e}),rounded:(e="md")=>({borderRadius:radii[e]}),border:(e={})=>({borderWidth:e.width||1,borderStyle:e.style||"solid",borderColor:e.color?e.color in colors?colors[e.color]:e.color:colors.border}),shadow:(e="md")=>({boxShadow:shadows[e]}),opacity:e=>({opacity:e}),glass:(e=20)=>({backgroundColor:colors.overlay,backdropFilter:`blur(${e}px)`,WebkitBackdropFilter:`blur(${e}px)`}),glassLight:(e=10)=>({backgroundColor:colors.overlayLight,backdropFilter:`blur(${e}px)`,WebkitBackdropFilter:`blur(${e}px)`})},en={clickable:{cursor:"pointer",userSelect:"none"}},tn={transition:(e="all",t="normal",n="xhubReel")=>({transitionProperty:Array.isArray(e)?e.join(", "):e,transitionDuration:durations[t],transitionTimingFunction:easings[n]}),noTransition:{transition:"none"}},Qe={scrollY:{overflowY:"auto",overflowX:"hidden",WebkitOverflowScrolling:"touch"},hideScrollbar:{scrollbarWidth:"none",msOverflowStyle:"none"},snapY:{scrollSnapType:"y mandatory",overscrollBehaviorY:"contain"},snapStart:{scrollSnapAlign:"start",scrollSnapStop:"always"}};var nn={square:e=>({width:e,height:e}),width:e=>({width:e}),height:e=>({height:e}),minHeight:e=>({minHeight:e}),maxWidth:e=>({maxWidth:e})};({feedContainer:Y(Ue.fixed({inset:0}),Qe.scrollY,Qe.snapY,Qe.hideScrollbar,Ie.bg("background"),{touchAction:"pan-y"}),feedItem:Y(Ue.fullSize,Qe.snapStart,Ie.bg("background"),{position:"relative"}),actionButton:Y(Ue.flexCenter,nn.square(48),Ie.rounded("full"),en.clickable,tn.transition(["transform","background-color"])),bottomSheet:Y(Ue.fixed({left:0,right:0,bottom:0}),Ie.glass(),Ie.rounded("xl"),{borderBottomLeftRadius:0,borderBottomRightRadius:0})});var rn=class{callbacks={};currentInfo;constructor(){this.currentInfo=this.detectNetwork(),this.setupListeners();}detectNetwork(){let e=navigator.connection;return {online:navigator.onLine,effectiveType:e?.effectiveType??"unknown",downlink:e?.downlink??null,rtt:e?.rtt??null,saveData:e?.saveData??false,type:e?.type??"unknown"}}setupListeners(){window.addEventListener("online",this.handleOnline),window.addEventListener("offline",this.handleOffline);let e=navigator.connection;e&&e.addEventListener("change",this.handleConnectionChange);}handleOnline=()=>{this.currentInfo={...this.currentInfo,online:true},this.callbacks.onOnline?.(),this.callbacks.onNetworkChange?.(this.currentInfo);};handleOffline=()=>{this.currentInfo={...this.currentInfo,online:false},this.callbacks.onOffline?.(),this.callbacks.onNetworkChange?.(this.currentInfo);};handleConnectionChange=()=>{this.currentInfo=this.detectNetwork(),this.callbacks.onNetworkChange?.(this.currentInfo);};subscribe(e){return this.callbacks={...this.callbacks,...e},()=>{this.callbacks={};}}getInfo(){return this.currentInfo}isSlowNetwork(){let{effectiveType:e}=this.currentInfo;return e==="slow-2g"||e==="2g"}getRecommendedConfig(){let{effectiveType:e,saveData:t}=this.currentInfo;return t||e==="slow-2g"||e==="2g"?{maxBufferLength:10,maxMaxBufferLength:20,startLevel:0}:e==="3g"?{maxBufferLength:20,maxMaxBufferLength:40,startLevel:1}:{}}estimateDownloadTime(e){let{downlink:t}=this.currentInfo;if(!t||t===0)return 1/0;let n=t*1e6/8;return e/n}destroy(){window.removeEventListener("online",this.handleOnline),window.removeEventListener("offline",this.handleOffline);let e=navigator.connection;e&&e.removeEventListener("change",this.handleConnectionChange);}};var on=class{callbacks={};currentInfo={batteryLevel:null,isCharging:false,isLowPowerMode:false};battery=null;constructor(){this.initBattery();}async initBattery(){try{let e=navigator;e.getBattery&&(this.battery=await e.getBattery(),this.updateInfo(),this.setupListeners());}catch{}}updateInfo(){this.battery&&(this.currentInfo={batteryLevel:this.battery.level,isCharging:this.battery.charging,isLowPowerMode:this.battery.level<.2},this.callbacks.onPowerChange?.(this.currentInfo),this.currentInfo.batteryLevel!==null&&this.currentInfo.batteryLevel<.15&&this.callbacks.onLowBattery?.());}setupListeners(){this.battery&&(this.battery.addEventListener("levelchange",()=>this.updateInfo()),this.battery.addEventListener("chargingchange",()=>this.updateInfo()));}subscribe(e){return this.callbacks={...this.callbacks,...e},()=>{this.callbacks={};}}getInfo(){return this.currentInfo}isPowerSaving(){return this.currentInfo.isLowPowerMode&&!this.currentInfo.isCharging}getRecommendedConfig(){return this.isPowerSaving()?{maxBufferLength:15,capLevelToPlayerSize:true}:{}}destroy(){this.callbacks={};}};var sn=class{queue=[];preloaded=new Set;loading=new Set;callbacks={};options;paused=false;velocityThreshold=2e3;constructor(e={}){this.options={maxConcurrent:e.maxConcurrent??2,maxQueue:e.maxQueue??5};}enqueue(e){let t=e.id??e.url;if(!(this.preloaded.has(e.url)||this.queue.some(n=>n.url===e.url))){if(this.queue.length>=this.options.maxQueue){let n=this.queue.shift();n&&this.callbacks.onPreloadCancel?.(n);}this.queue.push({...e,id:t,status:"pending"}),this.queue.sort((n,r)=>r.priority-n.priority),this.processQueue();}}enqueueMany(e){e.forEach(t=>this.enqueue(t));}cancel(e){let t=this.queue.find(n=>n.url===e);t&&(this.queue=this.queue.filter(n=>n.url!==e),this.loading.delete(t.id),this.callbacks.onPreloadCancel?.(t));}cancelAll(){this.queue.forEach(e=>{this.callbacks.onPreloadCancel?.(e);}),this.queue=[],this.loading.clear();}add(e,t,n=0){this.enqueue({id:e,url:t,priority:n});}remove(e){this.queue=this.queue.filter(t=>t.id!==e),this.loading.delete(e);}clear(){this.cancelAll(),this.preloaded.clear();}setPaused(e){this.paused=e,e||this.processQueue();}handleScrollVelocity(e){Math.abs(e)>this.velocityThreshold?this.setPaused(true):this.setPaused(false);}isPreloaded(e){return this.preloaded.has(e)}getStatus(e){let t=this.queue.find(n=>n.url===e);return t?t.status:this.preloaded.has(e)?"loaded":null}getAllStatuses(){return this.queue.map(e=>e.status)}getPreloadedUrls(){return Array.from(this.preloaded)}subscribe(e){return this.callbacks={...this.callbacks,...e},()=>{this.callbacks={};}}processQueue(){if(!this.paused)for(;this.loading.size<this.options.maxConcurrent&&this.queue.some(e=>e.status==="pending");){let e=this.queue.find(t=>t.status==="pending");e&&this.preloadItem(e);}}async preloadItem(e){e.status="loading",this.loading.add(e.id),this.callbacks.onPreloadStart?.(e);try{let t=document.createElement("link");t.rel="preload",t.as="fetch",t.href=e.url,t.crossOrigin="anonymous",document.head.appendChild(t),await new Promise((n,r)=>{t.onload=()=>n(),t.onerror=()=>r(new Error("Preload failed"));}),e.status="loaded",this.preloaded.add(e.url),this.callbacks.onPreloadComplete?.(e);}catch(t){e.status="error",this.callbacks.onPreloadError?.(e,t);}finally{this.loading.delete(e.id),this.processQueue();}}destroy(){this.clear(),this.callbacks={};}};var an=class{metrics=this.createEmptyMetrics();callbacks={};bufferingStartTime=null;playStartTime=null;isPlaying=false;createEmptyMetrics(){return {videoId:null,sessionStartTime:null,playbackStartTime:null,totalPlayTime:0,totalBufferingTime:0,bufferingCount:0,qualitySwitches:[],errors:[],seeks:[],avgBitrate:0,startupTime:null}}startSession(e,t){this.metrics={...this.createEmptyMetrics(),videoId:e,sessionStartTime:Date.now()},this.notifyUpdate();}endSession(){this.isPlaying&&this.playStartTime&&(this.metrics.totalPlayTime+=Date.now()-this.playStartTime),this.isPlaying=false,this.playStartTime=null;let e={...this.metrics};return this.callbacks.onSessionEnd?.(e),e}trackFirstFrame(){this.metrics.sessionStartTime&&!this.metrics.playbackStartTime&&(this.metrics.playbackStartTime=Date.now(),this.metrics.startupTime=this.metrics.playbackStartTime-this.metrics.sessionStartTime,this.isPlaying=true,this.playStartTime=Date.now(),this.notifyUpdate());}trackBuffering(e){let t=Date.now();e&&!this.bufferingStartTime?(this.bufferingStartTime=t,this.metrics.bufferingCount++):!e&&this.bufferingStartTime&&(this.metrics.totalBufferingTime+=t-this.bufferingStartTime,this.bufferingStartTime=null),this.notifyUpdate();}trackQualitySwitch(e,t,n){this.metrics.qualitySwitches.push({timestamp:Date.now(),fromLevel:e,toLevel:t,automatic:n}),this.notifyUpdate();}trackError(e,t,n){let r=typeof e=="string"?e:e.message;this.metrics.errors.push({timestamp:Date.now(),message:r,recoverable:t}),this.notifyUpdate();}trackBitrate(e){this.metrics.avgBitrate=e,this.notifyUpdate();}trackReplay(){this.playStartTime=Date.now(),this.isPlaying=true,this.notifyUpdate();}trackSeek(e,t,n){this.metrics.seeks.push({timestamp:Date.now(),from:e,to:t,latency:n}),this.notifyUpdate();}subscribe(e){return this.callbacks={...this.callbacks,...e},()=>{this.callbacks={};}}getMetrics(){return {...this.metrics}}notifyUpdate(){this.callbacks.onMetricsUpdate?.(this.getMetrics());}destroy(){this.endSession(),this.callbacks={};}};var Rt=class hn{hls=null;video=null;options;retryCount=0;maxRetries=3;constructor(t={}){this.options=t;}static isSupported(){return ln.isSupported()}attach(t,n){if(this.destroy(),this.video=t,this.retryCount=0,!hn.isSupported()){this.options.callbacks?.onError?.(new Error("HLS.js is not supported in this browser"),false);return}this.options.callbacks?.onStateChange?.("loading"),this.hls=new ln({...Ct,...this.options.config}),this.setupHLSListeners(),this.setupVideoListeners(),this.hls.attachMedia(t),this.hls.loadSource(n);}loadSource(t){if(!this.hls||!this.video)throw new Error("HLS engine not attached to video element");this.retryCount=0,this.options.callbacks?.onStateChange?.("loading"),this.hls.loadSource(t);}destroy(){this.video&&(this.removeVideoListeners(),this.video=null),this.hls&&(this.hls.destroy(),this.hls=null);}getQualityLevels(){return this.hls?this.hls.levels.map(t=>({label:`${t.height}p`,height:t.height,bitrate:t.bitrate})):[]}setQuality(t){this.hls&&(this.hls.currentLevel=t);}getCurrentQuality(){return this.hls?.currentLevel??-1}getBandwidth(){return this.hls?.bandwidthEstimate??0}isAutoQuality(){return this.hls?.autoLevelEnabled??true}startLoad(t){this.hls?.startLoad(t);}stopLoad(){this.hls?.stopLoad();}setupHLSListeners(){this.hls&&(this.hls.on(Events.MANIFEST_PARSED,(t,n)=>{let r=this.getQualityLevels();this.options.callbacks?.onQualityLevelsLoaded?.(r),this.options.callbacks?.onStateChange?.("ready"),this.video?.autoplay&&this.video.play().catch(()=>{});}),this.hls.on(Events.LEVEL_SWITCHED,(t,n)=>{this.options.callbacks?.onQualityChange?.(n.level,this.isAutoQuality());}),this.hls.on(Events.FRAG_LOADED,()=>{this.options.callbacks?.onBandwidthUpdate?.(this.getBandwidth());}),this.hls.on(Events.ERROR,(t,n)=>{this.handleError(n);}));}setupVideoListeners(){this.video&&(this.video.addEventListener("playing",this.handlePlaying),this.video.addEventListener("pause",this.handlePause),this.video.addEventListener("waiting",this.handleWaiting),this.video.addEventListener("ended",this.handleEnded),this.video.addEventListener("canplay",this.handleCanPlay),this.video.addEventListener("error",this.handleVideoError));}removeVideoListeners(){this.video&&(this.video.removeEventListener("playing",this.handlePlaying),this.video.removeEventListener("pause",this.handlePause),this.video.removeEventListener("waiting",this.handleWaiting),this.video.removeEventListener("ended",this.handleEnded),this.video.removeEventListener("canplay",this.handleCanPlay),this.video.removeEventListener("error",this.handleVideoError));}handlePlaying=()=>{this.options.callbacks?.onStateChange?.("playing");};handlePause=()=>{this.options.callbacks?.onStateChange?.("paused");};handleWaiting=()=>{this.options.callbacks?.onStateChange?.("buffering");};handleEnded=()=>{this.options.callbacks?.onStateChange?.("ended");};handleCanPlay=()=>{this.video?.paused&&this.options.callbacks?.onStateChange?.("ready");};handleVideoError=()=>{let t=this.video?.error;this.options.callbacks?.onError?.(new Error(t?.message??"Video playback error"),false),this.options.callbacks?.onStateChange?.("error");};handleError(t){if(t.fatal){let n=false;switch(t.type){case ErrorTypes.NETWORK_ERROR:this.retryCount<this.maxRetries&&(this.retryCount++,console.warn(`[HLSEngine] Network error, retry ${this.retryCount}/${this.maxRetries}`),this.hls?.startLoad(),n=true);break;case ErrorTypes.MEDIA_ERROR:console.warn("[HLSEngine] Media error, attempting recovery"),this.hls?.recoverMediaError(),n=true;break}n?this.options.callbacks?.onError?.(new Error(`HLS error (recovering): ${t.details}`),true):(this.options.callbacks?.onError?.(new Error(`HLS fatal error: ${t.details}`),false),this.options.callbacks?.onStateChange?.("error"),this.destroy());}else console.warn("[HLSEngine] Non-fatal error:",t.details);}};async function pn(e,t={}){try{return await e.play(),{success:!0}}catch(n){let r=n;if(r.name==="NotAllowedError"){e.muted=true;try{return await e.play(),{success:!0,mutedAutoplay:!0}}catch{return t.onNeedsUserGesture?.(),{success:false,reason:"user_gesture_required"}}}return {success:false,reason:"unknown",error:r}}}var cn=[.5,1,1.5,2],rt=class It{video=null;options;lastQuality=null;bandwidthSamples=[];constructor(t={}){this.options=t;}static isSupported(){return typeof document>"u"?false:document.createElement("video").canPlayType("application/vnd.apple.mpegurl")!==""}static isIOS(){return typeof navigator>"u"?false:/iPad|iPhone|iPod/.test(navigator.userAgent)||navigator.platform==="MacIntel"&&navigator.maxTouchPoints>1}attach(t,n){this.destroy(),this.video=t,this.options.callbacks?.onStateChange?.("loading"),this.setupVideoListeners(),t.src=n,t.load();}loadSource(t){if(!this.video)throw new Error("Native HLS not attached to video element");this.options.callbacks?.onStateChange?.("loading"),this.video.src=t,this.video.load();}async play(){return this.video?pn(this.video,{onNeedsUserGesture:this.options.callbacks?.onNeedsUserGesture}):{success:false,reason:"unknown"}}destroy(){this.video&&(this.removeVideoListeners(),this.video.removeAttribute("src"),this.video.load(),this.video=null),this.bandwidthSamples=[],this.lastQuality=null;}getQualityLevels(){let t=this.estimateCurrentQuality(),n=[{label:"Auto",height:0,bitrate:0}];return t&&n.push(t),n}setQuality(t){console.warn("[NativeHLS] Quality selection not supported, using auto");}getCurrentQuality(){return -1}estimateCurrentQuality(){if(!this.video||this.video.videoHeight===0)return null;let t=this.video.videoHeight,n=this.estimateBitrate();return {label:`${t}p`,height:t,bitrate:n}}estimateBitrate(){if(this.bandwidthSamples.length>0){let n=this.bandwidthSamples.reduce((r,o)=>r+o,0);return Math.round(n/this.bandwidthSamples.length)}if(!this.video)return 0;let t=this.video.videoHeight;return t>=1080?5e6:t>=720?25e5:t>=480?1e6:t>=360?5e5:25e4}getBandwidth(){return this.estimateBitrate()}isAutoQuality(){return true}startLoad(){this.video?.load();}stopLoad(){this.video&&(this.video.preload="none");}async enterFullscreen(){let t=this.video;if(t){if(t.requestFullscreen){await t.requestFullscreen();return}t.webkitEnterFullscreen&&await t.webkitEnterFullscreen();}}async exitFullscreen(){let t=this.video;if(t){if(document.exitFullscreen){await document.exitFullscreen();return}t.webkitExitFullscreen&&await t.webkitExitFullscreen();}}isFullscreen(){let t=this.video;return t?document.fullscreenElement?document.fullscreenElement===t:t.webkitDisplayingFullscreen??false:false}isFullscreenSupported(){let t=this.video;return t?!!(t.requestFullscreen||t.webkitSupportsFullscreen):false}isPlaybackRateSupported(t){return It.isIOS()?cn.includes(t):t>=.5&&t<=2}getSupportedPlaybackRates(){return It.isIOS()?[...cn]:[.5,.75,1,1.25,1.5,2]}setupVideoListeners(){this.video&&(this.video.addEventListener("loadedmetadata",this.handleLoadedMetadata),this.video.addEventListener("playing",this.handlePlaying),this.video.addEventListener("pause",this.handlePause),this.video.addEventListener("waiting",this.handleWaiting),this.video.addEventListener("ended",this.handleEnded),this.video.addEventListener("canplay",this.handleCanPlay),this.video.addEventListener("error",this.handleError),this.video.addEventListener("resize",this.handleResize),this.video.addEventListener("progress",this.handleProgress));}removeVideoListeners(){this.video&&(this.video.removeEventListener("loadedmetadata",this.handleLoadedMetadata),this.video.removeEventListener("playing",this.handlePlaying),this.video.removeEventListener("pause",this.handlePause),this.video.removeEventListener("waiting",this.handleWaiting),this.video.removeEventListener("ended",this.handleEnded),this.video.removeEventListener("canplay",this.handleCanPlay),this.video.removeEventListener("error",this.handleError),this.video.removeEventListener("resize",this.handleResize),this.video.removeEventListener("progress",this.handleProgress));}handleLoadedMetadata=()=>{let t=this.getQualityLevels();this.options.callbacks?.onQualityLevelsLoaded?.(t),this.options.callbacks?.onStateChange?.("ready"),this.checkQualityChange();};handlePlaying=()=>{this.options.callbacks?.onStateChange?.("playing");};handlePause=()=>{this.options.callbacks?.onStateChange?.("paused");};handleWaiting=()=>{this.options.callbacks?.onStateChange?.("buffering");};handleEnded=()=>{this.options.callbacks?.onStateChange?.("ended");};handleCanPlay=()=>{this.video?.paused&&this.options.callbacks?.onStateChange?.("ready");};handleError=()=>{let t=this.video?.error,n=t?.message??"Video playback error",r=t?.code!==MediaError.MEDIA_ERR_SRC_NOT_SUPPORTED;this.options.callbacks?.onError?.(new Error(n),r),this.options.callbacks?.onStateChange?.("error");};handleResize=()=>{this.checkQualityChange();};handleProgress=()=>{this.updateBandwidthEstimate();};checkQualityChange(){let t=this.estimateCurrentQuality();t&&(!this.lastQuality||this.lastQuality.height!==t.height)&&(this.lastQuality=t,this.options.callbacks?.onQualityChange?.(t));}updateBandwidthEstimate(){if(this.video&&typeof performance<"u"&&performance.getEntriesByType){let n=performance.getEntriesByType("resource").filter(r=>r.initiatorType==="video"||r.name.includes(".ts")||r.name.includes(".m3u8"));if(n.length>0){let o=n.slice(-5).filter(s=>s.transferSize>0&&s.duration>0).map(s=>s.transferSize*8/(s.duration/1e3));if(o.length>0){let s=o.reduce((d,u)=>d+u,0)/o.length;this.bandwidthSamples.push(s),this.bandwidthSamples.length>10&&this.bandwidthSamples.shift(),this.options.callbacks?.onBandwidthUpdate?.(s);}}}}},fn=class{engine=null;video=null;options;isNative=false;animationFrameId=null;isTracking=false;networkDetector=null;powerManager=null;preloadManager=null;analytics=null;cleanupFunctions=[];wasPlayingBeforeOffline=false;wasPlayingBeforeLowBattery=false;constructor(e={}){this.options={enableNetworkAdaptation:true,enablePowerAdaptation:true,enableAnalytics:false,...e},this.isNative=this.shouldUseNative(),this.initializeServices();}static isSupported(){return Rt.isSupported()||rt.isSupported()}attach(e,t,n){this.video=e,this.destroyEngine(),this.setupVideoListeners(),this.analytics&&n&&this.analytics.startSession(n,e);let r=this.getAdaptedConfig();this.isNative?this.engine=new rt({callbacks:{onStateChange:this.options.callbacks?.onStateChange,onError:this.options.callbacks?.onError,onQualityLevelsLoaded:this.options.callbacks?.onQualityLevelsLoaded,onBandwidthUpdate:this.options.callbacks?.onBandwidthUpdate,onNeedsUserGesture:this.options.callbacks?.onNeedsUserGesture,onQualityChange:o=>{this.options.callbacks?.onQualityChange?.(-1,o);}}}):this.engine=new Rt({config:r,callbacks:{onStateChange:this.options.callbacks?.onStateChange,onError:this.options.callbacks?.onError,onQualityLevelsLoaded:this.options.callbacks?.onQualityLevelsLoaded,onBandwidthUpdate:this.options.callbacks?.onBandwidthUpdate,onQualityChange:(o,s)=>{let d=this.engine?.getQualityLevels()??[],u=o>=0&&o<d.length?d[o]:void 0;this.options.callbacks?.onQualityChange?.(s?-1:o,u);}}}),this.engine.attach(e,t);}loadSource(e,t){if(!this.engine||!this.video)throw new Error("Player not attached to video element");this.analytics&&(this.analytics.endSession(),t&&this.analytics.startSession(t,this.video)),this.engine.loadSource(e);}destroy(){this.destroyEngine(),this.destroyServices();}async play(){return this.video?this.isNative&&this.engine instanceof rt?this.engine.play():pn(this.video,{onNeedsUserGesture:this.options.callbacks?.onNeedsUserGesture}):{success:false,reason:"unknown"}}pause(){this.video?.pause();}async togglePlay(){return this.video?.paused?this.play():(this.pause(),{success:true})}seek(e){if(this.video){let t=this.video.currentTime;this.video.currentTime=Math.max(0,Math.min(e,this.video.duration||0)),this.analytics?.trackSeek(t,e,0);}}seekForward(e=10){this.video&&this.seek(this.video.currentTime+e);}seekBackward(e=10){this.video&&this.seek(this.video.currentTime-e);}getCurrentTime(){return this.video?.currentTime??0}getDuration(){return this.video?.duration??0}setVolume(e){this.video&&(this.video.volume=Math.max(0,Math.min(1,e)));}getVolume(){return this.video?.volume??1}setMuted(e){this.video&&(this.video.muted=e);}isMuted(){return this.video?.muted??true}toggleMute(){this.setMuted(!this.isMuted());}setPlaybackRate(e){this.video&&(this.video.playbackRate=e);}getPlaybackRate(){return this.video?.playbackRate??1}getQualityLevels(){return this.engine?.getQualityLevels()??[]}setQuality(e){let t=this.getCurrentQuality();this.engine?.setQuality(e),t!==e&&this.analytics?.trackQualitySwitch(t,e,e===-1);}getCurrentQuality(){return this.engine?.getCurrentQuality()??-1}isUsingNative(){return this.isNative}getVideoElement(){return this.video}getBuffered(){if(!this.video)return 0;let e=this.video.buffered,t=this.video.currentTime;for(let n=0;n<e.length;n++)if(t>=e.start(n)&&t<=e.end(n))return e.end(n)-t;return 0}getNetworkInfo(){return this.networkDetector?.getInfo()??null}getPowerInfo(){return this.powerManager?.getInfo()??null}getPreloadManager(){return this.preloadManager}getAnalytics(){return this.analytics?.getMetrics()??null}isSlowNetwork(){return this.networkDetector?.isSlowNetwork()??false}isPowerSaving(){return this.powerManager?.isPowerSaving()??false}shouldUseNative(){return this.options.preferNative!==false&&rt.isSupported()?true:!Rt.isSupported()}initializeServices(){if(this.options.enableNetworkAdaptation){this.networkDetector=new rn;let e=this.networkDetector.subscribe({onNetworkChange:this.handleNetworkChange,onOffline:()=>this.options.callbacks?.onError?.(new Error("Network offline"),true)});this.cleanupFunctions.push(e);}if(this.options.enablePowerAdaptation){this.powerManager=new on;let e=this.powerManager.subscribe({onPowerChange:this.handlePowerChange});this.cleanupFunctions.push(e),this.cleanupFunctions.push(()=>this.powerManager?.destroy());}if(this.options.preloadConfig&&(this.preloadManager=new sn(this.options.preloadConfig),this.cleanupFunctions.push(()=>this.preloadManager?.destroy())),this.options.enableAnalytics){this.analytics=new an;let e=this.analytics.subscribe({onMetricsUpdate:t=>this.options.callbacks?.onAnalyticsUpdate?.(t)});this.cleanupFunctions.push(e),this.cleanupFunctions.push(()=>this.analytics?.destroy());}}destroyServices(){this.cleanupFunctions.forEach(e=>e()),this.cleanupFunctions=[],this.networkDetector=null,this.powerManager=null,this.preloadManager=null,this.analytics=null;}destroyEngine(){this.stopProgressTracking(),this.removeVideoListeners(),this.engine&&(this.engine.destroy(),this.engine=null);}getAdaptedConfig(){let e={};return this.networkDetector&&(e={...e,...this.networkDetector.getRecommendedConfig()}),this.powerManager&&(e={...e,...this.powerManager.getRecommendedConfig()}),e}isNetworkBelowThreshold(e,t){let n=["slow-2g","2g","3g","4g","5g","unknown"],r=n.indexOf(e),o=n.indexOf(t);return e==="unknown"?false:r>=0&&r<=o}handleNetworkChange=e=>{this.options.callbacks?.onNetworkChange?.(e);let t=this.options.lowQualityThreshold??"2g",n=this.isNetworkBelowThreshold(e.effectiveType,t);this.options.autoQualityOnNetworkChange&&this.engine&&(n?this.setQuality(0):(e.effectiveType==="4g"||e.effectiveType==="5g")&&this.setQuality(-1)),this.options.autoPauseOnOffline&&!e.online&&(this.wasPlayingBeforeOffline=this.video?!this.video.paused:false,this.pause()),this.options.autoResumeOnOnline&&e.online&&this.wasPlayingBeforeOffline&&(this.play(),this.wasPlayingBeforeOffline=false),this.preloadManager&&this.preloadManager.setPaused(e.effectiveType==="2g"||!e.online);};handlePowerChange=e=>{this.options.callbacks?.onPowerChange?.(e);let t=this.options.lowBatteryThreshold??.15,n=e.batteryLevel!==null&&e.batteryLevel<t;this.options.autoPauseOnLowBattery&&n&&!e.isCharging&&(this.wasPlayingBeforeLowBattery=this.video?!this.video.paused:false,this.pause()),this.wasPlayingBeforeLowBattery&&(e.isCharging||e.batteryLevel!==null&&e.batteryLevel>=t+.05)&&(this.play(),this.wasPlayingBeforeLowBattery=false),this.preloadManager&&e.isLowPowerMode&&this.preloadManager.setPaused(true);};setupVideoListeners(){this.video&&(this.video.addEventListener("timeupdate",this.handleTimeUpdate),this.video.addEventListener("progress",this.handleProgress),this.video.addEventListener("volumechange",this.handleVolumeChange),this.video.addEventListener("ratechange",this.handleRateChange),this.video.addEventListener("play",this.handlePlay),this.video.addEventListener("pause",this.handlePause),this.video.addEventListener("ended",this.handleEnded),this.video.addEventListener("waiting",this.handleWaiting),this.video.addEventListener("playing",this.handlePlaying));}removeVideoListeners(){this.video&&(this.video.removeEventListener("timeupdate",this.handleTimeUpdate),this.video.removeEventListener("progress",this.handleProgress),this.video.removeEventListener("volumechange",this.handleVolumeChange),this.video.removeEventListener("ratechange",this.handleRateChange),this.video.removeEventListener("play",this.handlePlay),this.video.removeEventListener("pause",this.handlePause),this.video.removeEventListener("ended",this.handleEnded),this.video.removeEventListener("waiting",this.handleWaiting),this.video.removeEventListener("playing",this.handlePlaying));}handleTimeUpdate=()=>{this.video&&this.options.callbacks?.onTimeUpdate?.(this.video.currentTime,this.video.duration||0);};handleProgress=()=>{this.options.callbacks?.onProgress?.(this.getBuffered());};handleVolumeChange=()=>{this.video&&this.options.callbacks?.onVolumeChange?.(this.video.volume,this.video.muted);};handleRateChange=()=>{this.video&&this.options.callbacks?.onRateChange?.(this.video.playbackRate);};handlePlay=()=>{this.options.enableSmoothTimeUpdates&&this.startProgressTracking();};handlePause=()=>{this.stopProgressTracking();};handleEnded=()=>{this.stopProgressTracking(),this.analytics&&this.analytics.endSession();};handleWaiting=()=>{this.analytics?.trackBuffering(true);};handlePlaying=()=>{this.analytics?.trackBuffering(false),this.analytics?.trackFirstFrame();};startProgressTracking(){if(this.isTracking||!this.video)return;this.isTracking=true;let e=()=>{if(!this.video||this.video.paused||this.video.ended){this.isTracking=false,this.animationFrameId=null;return}this.options.callbacks?.onTimeUpdate?.(this.video.currentTime,this.video.duration||0),this.animationFrameId=requestAnimationFrame(e);};this.animationFrameId=requestAnimationFrame(e);}stopProgressTracking(){this.animationFrameId!==null&&(cancelAnimationFrame(this.animationFrameId),this.animationFrameId=null),this.isTracking=false;}},Er=[{from:"idle",to:"loading"},{from:"loading",to:"ready"},{from:"loading",to:"error"},{from:"ready",to:"playing"},{from:"ready",to:"loading"},{from:"ready",to:"error"},{from:"playing",to:"paused"},{from:"playing",to:"buffering"},{from:"playing",to:"ended"},{from:"playing",to:"error"},{from:"playing",to:"loading"},{from:"paused",to:"playing"},{from:"paused",to:"buffering"},{from:"paused",to:"loading"},{from:"paused",to:"error"},{from:"buffering",to:"playing"},{from:"buffering",to:"paused"},{from:"buffering",to:"stalled"},{from:"buffering",to:"error"},{from:"stalled",to:"playing"},{from:"stalled",to:"buffering"},{from:"stalled",to:"error"},{from:"stalled",to:"loading"},{from:"ended",to:"playing"},{from:"ended",to:"loading"},{from:"ended",to:"idle"},{from:"error",to:"loading"},{from:"error",to:"idle"},{from:"*",to:"idle"}],Cr=class{_state="idle";listeners=new Set;stalledTimeout=null;stalledThreshold=3e3;get state(){return this._state}transition(e){if(!this.canTransition(e))return console.warn(`[PlayerStateMachine] Invalid transition: ${this._state} -> ${e}`),false;let n=this._state;return this._state=e,e==="buffering"?this.startStalledTimer():this.clearStalledTimer(),this.listeners.forEach(r=>r(e,n)),true}canTransition(e){let t=Er.find(n=>(n.from===this._state||n.from==="*")&&n.to===e);return !(!t||t.guard&&!t.guard())}subscribe(e){return this.listeners.add(e),()=>this.listeners.delete(e)}reset(){this.clearStalledTimer(),this._state="idle";}isPlaying(){return this._state==="playing"}canPlay(){return ["ready","paused","ended"].includes(this._state)}isLoading(){return ["loading","buffering"].includes(this._state)}hasError(){return this._state==="error"}startStalledTimer(){this.clearStalledTimer(),this.stalledTimeout=setTimeout(()=>{this._state==="buffering"&&this.transition("stalled");},this.stalledThreshold);}clearStalledTimer(){this.stalledTimeout&&(clearTimeout(this.stalledTimeout),this.stalledTimeout=null);}};function kr(){return new Cr}function mn(){let e=useMemo(()=>kr(),[]),[t,n]=useState(e.state);useEffect(()=>e.subscribe(d=>{n(d);}),[e]);let r=useCallback(s=>e.transition(s),[e]),o=useCallback(()=>{e.reset(),n("idle");},[e]);return {state:t,isPlaying:t==="playing",isPaused:t==="paused",isLoading:t==="loading",isBuffering:t==="buffering",isStalled:t==="stalled",isEnded:t==="ended",hasError:t==="error",canPlay:e.canPlay(),transition:r,reset:o}}function gn(e){let{volume:t,isMuted:n,setVolume:r,toggleMute:o,setMuted:s}=_e();useEffect(()=>{let i=e.current;i&&(i.volume=t,i.muted=n);},[e,t,n]),useEffect(()=>{let i=e.current;if(!i)return;let a=()=>{i.volume!==t&&r(i.volume),i.muted!==n&&s(i.muted);};return i.addEventListener("volumechange",a),()=>i.removeEventListener("volumechange",a)},[e,t,n,r,s]);let d=useCallback(i=>{let a=Math.max(0,Math.min(1,i));r(a),e.current&&(e.current.volume=a),a>0&&n&&(s(false),e.current&&(e.current.muted=false));},[e,n,r,s]),u=useCallback(()=>{o(),e.current&&(e.current.muted=!n);},[e,n,o]),l=useCallback(()=>{n||(s(true),e.current&&(e.current.muted=true));},[e,n,s]),m=useCallback(()=>{n&&(s(false),e.current&&(e.current.muted=false));},[e,n,s]);return {volume:t,isMuted:n,setVolume:d,toggleMute:u,mute:l,unmute:m}}function yn(e,t={}){let{enableSmoothTracking:n=false}=t,[r,o]=useState(0),[s,d]=useState(0),[u,l]=useState(0),[m,i]=useState([]),a=useRef(null),p=useRef(false),c=s>0?r/s*100:0,g=useCallback(h=>{let y=[],P=h.buffered;for(let C=0;C<P.length;C++)y.push({start:P.start(C),end:P.end(C)});i(y);let O=0;for(let C of y)if(h.currentTime>=C.start&&h.currentTime<=C.end){O=C.end-h.currentTime;break}l(O);},[]),f=useCallback(()=>{a.current!==null&&(cancelAnimationFrame(a.current),a.current=null),p.current=false;},[]),S=useCallback(()=>{let h=e.current;if(!h||p.current)return;p.current=true;let y=()=>{if(!h||h.paused||h.ended){p.current=false,a.current=null;return}o(h.currentTime),a.current=requestAnimationFrame(y);};a.current=requestAnimationFrame(y);},[e]);useEffect(()=>{let h=e.current;if(!h)return;let y=()=>{o(h.currentTime);},P=()=>{d(h.duration||0);},O=()=>{d(h.duration||0);},C=()=>{g(h);},B=()=>{n&&S();},z=()=>{f();},H=()=>{f();},A=()=>{o(h.currentTime);},v=()=>{o(h.currentTime),g(h);};return h.addEventListener("timeupdate",y),h.addEventListener("loadedmetadata",P),h.addEventListener("durationchange",O),h.addEventListener("progress",C),h.addEventListener("play",B),h.addEventListener("pause",z),h.addEventListener("ended",H),h.addEventListener("seeking",A),h.addEventListener("seeked",v),h.readyState>=1&&(d(h.duration||0),o(h.currentTime)),h.readyState>=3&&g(h),!h.paused&&n&&S(),()=>{h.removeEventListener("timeupdate",y),h.removeEventListener("loadedmetadata",P),h.removeEventListener("durationchange",O),h.removeEventListener("progress",C),h.removeEventListener("play",B),h.removeEventListener("pause",z),h.removeEventListener("ended",H),h.removeEventListener("seeking",A),h.removeEventListener("seeked",v),f();}},[e,n,g,S,f]);let b=useCallback(h=>{let y=e.current;if(!y||!isFinite(y.duration))return;let P=Math.max(0,Math.min(h,y.duration));y.currentTime=P,o(P);},[e]),V=useCallback(h=>{let y=e.current;if(!y||!isFinite(y.duration))return;let O=Math.max(0,Math.min(100,h))/100*y.duration;y.currentTime=O,o(O);},[e]),L=s>0&&isFinite(s);return {currentTime:r,duration:s,buffered:u,progress:c,bufferedRanges:m,seek:b,seekToProgress:V,isSeekable:L,startSmoothTracking:S,stopSmoothTracking:f}}function vn(e){let{quality:t,setQuality:n}=_e(),[r,o]=useState(-1),[s,d]=useState([]);useEffect(()=>{if(!e)return;let i=e.getQualityLevels();d(i),o(e.getCurrentQuality());},[e]),useEffect(()=>{if(!(!e||s.length===0))if(t==="auto")e.setQuality(-1),o(-1);else {let i=parseInt(t.replace("p","")),a=s.findIndex(p=>p.height===i);a!==-1&&(e.setQuality(a),o(a));}},[e,t,s]);let u=r===-1,l=useCallback(i=>{if(e)if(typeof i=="number")if(e.setQuality(i),o(i),i===-1)n("auto");else {let a=s[i];a&&n(`${a.height}p`);}else n(i);},[e,s,n]),m=useCallback(()=>{l("auto");},[l]);return {quality:t,currentLevel:r,availableLevels:s,isAuto:u,setQuality:l,setAuto:m}}function Mt(e){return e<1e3?e.toString():e<1e4?`${(e/1e3).toFixed(1)}K`:e<1e6?`${Math.floor(e/1e3)}K`:`${(e/1e6).toFixed(1)}M`}var Mr={position:"absolute",right:spacing[4],bottom:160,display:"flex",flexDirection:"column",alignItems:"center",gap:components.actionBar.gap,zIndex:10},Vr={display:"flex",flexDirection:"column",alignItems:"center",gap:components.actionBar.iconCountGap,background:"none",border:"none",padding:0,cursor:"pointer"},Ar={width:components.actionBar.iconSize,height:components.actionBar.iconSize,display:"flex",alignItems:"center",justifyContent:"center"},Fr={fontSize:fontSizes.xs,fontWeight:fontWeights.normal,color:colors.text,textShadow:shadows.text,lineHeight:components.actionBar.counterLineHeight,textAlign:"center"},Or={display:"flex",flexDirection:"column",alignItems:"center",position:"relative",width:components.profileAction.avatarSize,height:55},bn={width:components.profileAction.avatarSize,height:components.profileAction.avatarSize,borderRadius:"50%",objectFit:"cover",cursor:"pointer",background:colors.surface},Hr={position:"absolute",bottom:0,left:"50%",transform:"translateX(-50%)",width:components.profileAction.followButtonSize,height:components.profileAction.followButtonSize,borderRadius:"50%",backgroundColor:colors.like,border:"none",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center"},Dr=({filled:e,color:t="white"})=>e?jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:components.actionBar.iconSize,height:components.actionBar.iconSize,viewBox:"0 0 28 28",fill:"none",children:jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M1.74988 11.0538C1.74988 6.75595 4.69822 2.91699 9.20877 2.91699C11.4347 2.91699 12.9986 3.9593 13.9999 4.96978C15.0011 3.95929 16.565 2.91699 18.791 2.91699C23.3015 2.91699 26.2499 6.75595 26.2499 11.0538C26.2499 15.3962 23.6265 18.9036 20.8781 21.3587C18.1288 23.8145 15.1442 25.3171 14.1843 25.6371L13.9999 25.6985L13.8154 25.6371C12.8555 25.3171 9.87093 23.8145 7.12168 21.3587C4.37329 18.9036 1.74988 15.3962 1.74988 11.0538ZM17.7449 6.41699C17.2617 6.41699 16.8699 6.80874 16.8699 7.29199C16.8699 7.77524 17.2617 8.16699 17.7449 8.16699C19.6221 8.16699 20.9952 9.75855 20.9952 11.8241C20.9952 12.3073 21.387 12.6991 21.8702 12.6991C22.3535 12.6991 22.7452 12.3073 22.7452 11.8241C22.7452 9.02543 20.8066 6.41699 17.7449 6.41699Z",fill:t})}):jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:components.actionBar.iconSize,height:components.actionBar.iconSize,viewBox:"0 0 24 24",fill:"none",children:[jsx("path",{d:"M15.21 5.5C14.7957 5.5 14.46 5.83579 14.46 6.25C14.46 6.66421 14.7957 7 15.21 7C16.819 7 17.996 8.3642 17.996 10.1346C17.996 10.5488 18.3317 10.8846 18.746 10.8846C19.1602 10.8846 19.496 10.5488 19.496 10.1346C19.496 7.7358 17.8342 5.5 15.21 5.5Z",fill:t}),jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M7.89327 2.25C3.85788 2.25 1.24994 5.6858 1.24994 9.47438C1.24994 13.301 3.5604 16.37 5.9378 18.4936C8.31629 20.6183 10.9036 21.9251 11.7628 22.2115L11.9999 22.2906L12.2371 22.2115C13.0963 21.9251 15.6836 20.6183 18.0621 18.4936C20.4395 16.37 22.7499 13.301 22.7499 9.47438C22.7499 5.6858 20.142 2.25 16.1066 2.25C14.2397 2.25 12.8941 3.06969 11.9999 3.91063C11.1058 3.06969 9.76018 2.25 7.89327 2.25ZM2.74994 9.47438C2.74994 6.3142 4.8731 3.75 7.89327 3.75C9.60588 3.75 10.7397 4.66987 11.4269 5.48383L11.9999 6.16259L12.573 5.48383C13.2602 4.66987 14.394 3.75 16.1066 3.75C19.1268 3.75 21.2499 6.3142 21.2499 9.47438C21.2499 12.6733 19.3104 15.3672 17.0628 17.375C15.0361 19.1854 12.8741 20.3336 11.9999 20.6978C11.1257 20.3336 8.96379 19.1854 6.93708 17.375C4.68948 15.3672 2.74994 12.6733 2.74994 9.47438Z",fill:t})]}),Br=()=>jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:components.actionBar.iconSize,height:components.actionBar.iconSize,viewBox:"0 0 28 28",fill:"none",children:jsx("path",{d:"M14 1.45801C7.07347 1.45801 1.45837 7.0731 1.45837 13.9997C1.45837 16.3815 2.1232 18.6107 3.27778 20.5088L2.36541 23.0178C1.77294 24.6471 3.35258 26.2268 4.98188 25.6343L7.49089 24.7219C9.389 25.8765 11.6182 26.5413 14 26.5413C20.9266 26.5413 26.5417 20.9262 26.5417 13.9997C26.5417 7.0731 20.9266 1.45801 14 1.45801Z",fill:"white"})}),Nr=({filled:e})=>jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:components.actionBar.iconSize,height:components.actionBar.iconSize,viewBox:"0 0 28 28",fill:"none",children:jsx("path",{d:"M16.6904 1.45801H11.2789C10.2487 1.458 9.4224 1.45799 8.75434 1.51253C8.06795 1.56857 7.47186 1.68652 6.92253 1.96632C6.90122 1.97718 6.88036 1.98891 6.86 2.00147C5.64436 2.75199 4.94533 3.52276 4.62739 4.64643C4.48015 5.1668 4.42512 5.72644 4.40084 6.3243C4.38332 6.75558 4.3811 7.24294 4.37866 7.77623C4.37775 7.97537 4.37678 8.18091 4.375 8.39232V24.8275C4.375 25.7739 5.14242 26.5413 6.08883 26.5413C6.51994 26.5413 6.93517 26.3792 7.25226 26.0859L13.3276 20.4783C13.3386 20.4682 13.3493 20.4578 13.3597 20.4471C13.5821 20.2197 13.743 20.0895 13.8601 20.0183C13.9156 19.9846 13.9524 19.9697 13.9731 19.9631C13.9833 19.9599 13.9898 19.9585 13.9933 19.958L13.9975 19.9575L13.9992 19.9574C13.9992 19.9574 14.0065 19.9571 14.0257 19.9632C14.0466 19.9698 14.0837 19.9849 14.1394 20.0187C14.2569 20.0901 14.4182 20.2206 14.641 20.4479C14.6512 20.4583 14.6616 20.4684 14.6724 20.4783L20.7477 26.0859C21.0648 26.3792 21.4801 26.5413 21.9112 26.5413C22.8576 26.5413 23.625 25.7739 23.625 24.8275V8.3619C23.625 7.33168 23.625 6.5054 23.5705 5.83735C23.5144 5.15096 23.3965 4.55487 23.1167 4.00554C23.1058 3.98416 23.094 3.96325 23.0814 3.94284C22.3309 2.72781 21.5599 2.0287 20.4364 1.71046C19.9159 1.56305 19.3562 1.50785 18.7583 1.48352C18.3245 1.46588 17.8344 1.46376 17.2978 1.46144C17.1014 1.46059 16.8988 1.45968 16.6904 1.45801Z",fill:e?colors.warning:"white"})}),_r=()=>jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:28,height:28,viewBox:"0 0 28 28",fill:"none",children:[jsx("path",{d:"M20.6583 8.99195C21.1139 8.53634 21.1139 7.79765 20.6583 7.34203L14.8249 1.5087C14.6061 1.28991 14.3094 1.16699 14 1.16699C13.6905 1.16699 13.3938 1.28991 13.175 1.5087L7.34167 7.34204C6.88606 7.79765 6.88606 8.53634 7.34167 8.99195C7.79728 9.44756 8.53597 9.44756 8.99158 8.99195L12.8333 5.15024L12.8333 17.5003C12.8333 18.1447 13.3556 18.667 14 18.667C14.6443 18.667 15.1666 18.1447 15.1666 17.5003L15.1666 5.15024L19.0083 8.99195C19.4639 9.44756 20.2026 9.44756 20.6583 8.99195Z",fill:"white"}),jsx("path",{d:"M24.4562 22.2708C24.4991 21.7457 24.5 21.0663 24.5 20.067V16.3337C24.5 15.6893 25.0223 15.167 25.6666 15.167C26.311 15.167 26.8333 15.6893 26.8333 16.3337L26.8333 20.1152C26.8333 21.0543 26.8333 21.8294 26.7817 22.4608C26.7282 23.1166 26.6132 23.7194 26.3247 24.2856C25.8772 25.1637 25.1633 25.8776 24.2852 26.325C23.719 26.6135 23.1162 26.7285 22.4604 26.7821C21.829 26.8337 21.054 26.8337 20.1149 26.8337H7.88508C6.94599 26.8337 6.17087 26.8337 5.5395 26.7821C4.88372 26.7285 4.28089 26.6135 3.71467 26.325C2.83658 25.8776 2.12267 25.1637 1.67526 24.2856C1.38676 23.7194 1.27176 23.1166 1.21819 22.4608C1.1666 21.8294 1.16661 21.0543 1.16663 20.1152V16.3337C1.16663 15.6893 1.68896 15.167 2.33329 15.167C2.97762 15.167 3.49996 15.6893 3.49996 16.3337L3.49996 20.067C3.49996 21.0663 3.50087 21.7457 3.54377 22.2708C3.58556 22.7823 3.66131 23.0438 3.75428 23.2263C3.97798 23.6653 4.33494 24.0223 4.77398 24.246C4.95645 24.339 5.21802 24.4147 5.7295 24.4565C6.25461 24.4994 6.93395 24.5003 7.93329 24.5003H20.0666C21.066 24.5003 21.7453 24.4994 22.2704 24.4565C22.7819 24.4147 23.0435 24.339 23.2259 24.246C23.665 24.0223 24.0219 23.6653 24.2456 23.2263C24.3386 23.0438 24.4144 22.7823 24.4562 22.2708Z",fill:"white"})]}),Ur=()=>jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:12,height:12,viewBox:"0 0 12 12",fill:"white",children:jsx("path",{d:"M6 1V11M1 6H11",stroke:"white",strokeWidth:2,strokeLinecap:"round"})}),Qr=()=>jsx("svg",{width:12,height:12,viewBox:"0 0 12 12",fill:"none",children:jsx("path",{d:"M2 6L5 9L10 3",stroke:"white",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"})});function zr({avatarUrl:e,isFollowed:t=false,onClick:n,onFollow:r}){return jsxs("div",{style:Or,children:[jsx(motion.button,{style:{background:"none",border:"none",padding:0,cursor:"pointer"},onClick:n,whileTap:{scale:.95},"aria-label":"View profile",children:e?jsx("img",{src:e,alt:"Profile",style:bn}):jsx("div",{style:bn})}),!t&&r&&jsx(motion.button,{style:Hr,onClick:o=>{o.stopPropagation(),r();},whileTap:{scale:.9},animate:t?{scale:[1,1.2,1]}:{scale:1},transition:{type:"spring",...springs.bouncy},"aria-label":t?"Following":"Follow",children:t?jsx(Qr,{}):jsx(Ur,{})})]})}function it({icon:e,count:t,isActive:n=false,onClick:r,label:o}){return jsxs(motion.button,{style:Vr,onClick:r,"aria-label":o,whileTap:{scale:.9},transition:{type:"spring",...springs.bouncy},children:[jsx(motion.div,{style:Ar,animate:n?{scale:[1,1.2,1]}:{scale:1},transition:n?{duration:.3,ease:[.32,.72,0,1]}:{type:"spring",...springs.default},children:e}),t!==void 0&&jsx("span",{style:Fr,children:Mt(t)})]})}function st({likeCount:e,commentCount:t,shareCount:n,saveCount:r,isLiked:o=false,isSaved:s=false,onLike:d,onComment:u,onShare:l,onSave:m,avatarUrl:i,onProfileClick:a,onFollow:p,isFollowed:c=false,style:g,className:f=""}){return jsxs("div",{style:mergeStyles(Mr,g),className:f,children:[i&&jsx(zr,{avatarUrl:i,isFollowed:c,onClick:a,onFollow:p}),jsx(it,{icon:jsx(Dr,{filled:o,color:o?colors.like:"white"}),count:e,isActive:o,onClick:d,label:o?"Unlike":"Like"}),jsx(it,{icon:jsx(Br,{}),count:t,onClick:u,label:"Comments"}),jsx(it,{icon:jsx(Nr,{filled:s}),count:r,isActive:s,onClick:m,label:s?"Unsave":"Save"}),jsx(it,{icon:jsx(_r,{}),count:n,onClick:l,label:"Share"})]})}var Xr={display:"inline-flex",alignItems:"center",justifyContent:"center",border:"none",cursor:"pointer",borderRadius:radii.full,transitionProperty:"background-color, transform, opacity",transitionDuration:durations.fast,transitionTimingFunction:easings.xhubReel,userSelect:"none"},Kr={sm:{width:32,height:32},md:{width:components.tapArea,height:components.tapArea},lg:{width:56,height:56}},jr={default:{backgroundColor:colors.surface,color:colors.text},ghost:{backgroundColor:"transparent",color:colors.text},glass:{backgroundColor:"rgba(0, 0, 0, 0.2)",backdropFilter:"blur(4px)",WebkitBackdropFilter:"blur(4px)",color:colors.text}},Zr={opacity:.5,cursor:"not-allowed",pointerEvents:"none"},At=forwardRef(({icon:e,size:t="md",variant:n="ghost",disabled:r,style:o,className:s="",...d},u)=>jsx("button",{ref:u,type:"button",disabled:r,style:mergeStyles(Xr,Kr[t],jr[n],r&&Zr,o),className:s,...d,children:e}));At.displayName="IconButton";var si={position:"absolute",inset:0,display:"flex",alignItems:"center",justifyContent:"center",zIndex:zIndices.overlay},ai={display:"flex",alignItems:"center",justifyContent:"center",backgroundColor:"rgba(0, 0, 0, 0.5)",borderRadius:"50%",backdropFilter:"blur(8px)",WebkitBackdropFilter:"blur(8px)",cursor:"pointer"},li=({size:e})=>jsx("svg",{width:e*.4,height:e*.4,viewBox:"0 0 24 24",fill:colors.text,children:jsx("polygon",{points:"5 3 19 12 5 21 5 3"})}),di=({size:e})=>jsxs("svg",{width:e*.35,height:e*.35,viewBox:"0 0 24 24",fill:colors.text,children:[jsx("rect",{x:"6",y:"4",width:"4",height:"16"}),jsx("rect",{x:"14",y:"4",width:"4",height:"16"})]});function lt({isPlaying:e,show:t,onToggle:n,size:r=72,autoHideDelay:o=1e3,showOnStateChange:s=true,style:d,className:u=""}){let[l,m]=useState(false),[i,a]=useState(false),p=t!==void 0,c=p?t:l;useEffect(()=>{if(!(p||!s||!i)&&(m(true),o>0)){let b=setTimeout(()=>{m(false);},o);return ()=>clearTimeout(b)}},[e,p,s,o,i]);let g=useCallback(()=>{n&&(a(true),m(true),n());},[n]),f=!!n,S=f?"auto":"none";return jsx(AnimatePresence,{children:c&&jsx(motion.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.15},style:mergeStyles(si,{pointerEvents:S},d),className:u,onClick:g,children:jsx(motion.div,{initial:{scale:.8,opacity:0},animate:{scale:1,opacity:1},exit:{scale:.8,opacity:0},transition:{type:"spring",...springs.default},whileTap:f?{scale:.9}:void 0,style:{...ai,width:r,height:r,cursor:f?"pointer":"default"},children:e?jsx(di,{size:r}):jsx(li,{size:r})})})})}var gi={position:"fixed",inset:0,backgroundColor:"rgba(0, 0, 0, 0.6)",zIndex:zIndices.modal},yi={position:"fixed",left:0,right:0,bottom:0,backgroundColor:colors.overlay,backdropFilter:"blur(20px)",WebkitBackdropFilter:"blur(20px)",borderTopLeftRadius:radii.xl,borderTopRightRadius:radii.xl,zIndex:zIndices.modal+1,display:"flex",flexDirection:"column",maxHeight:"90vh"},vi={width:components.bottomSheet.handleWidth,height:components.bottomSheet.handleHeight,backgroundColor:"rgba(255, 255, 255, 0.3)",borderRadius:2,margin:"12px auto 0",flexShrink:0},bi={display:"flex",alignItems:"center",justifyContent:"space-between",padding:`${spacing[4]}px ${spacing[4]}px ${spacing[3]}px`,flexShrink:0},Si={fontSize:18,fontWeight:600,color:colors.text},wi={width:32,height:32,display:"flex",alignItems:"center",justifyContent:"center",background:"none",border:"none",cursor:"pointer",color:colors.textSecondary,borderRadius:"50%"},Pi={flex:1,overflow:"auto",WebkitOverflowScrolling:"touch"},Ei=()=>jsxs("svg",{width:20,height:20,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,children:[jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]});function xn({isOpen:e,onClose:t,title:n,children:r,height:o="60vh",maxHeight:s="90vh",showClose:d=true,showHandle:u=true,style:l,className:m=""}){let i=useCallback(a=>{a.key==="Escape"&&t();},[t]);return useEffect(()=>(e&&(document.addEventListener("keydown",i),document.body.style.overflow="hidden"),()=>{document.removeEventListener("keydown",i),document.body.style.overflow="";}),[e,i]),jsx(AnimatePresence,{children:e&&jsxs(Fragment,{children:[jsx(motion.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},style:gi,onClick:t}),jsxs(motion.div,{initial:{y:"100%"},animate:{y:0},exit:{y:"100%"},transition:{type:"spring",...springs.default},drag:"y",dragConstraints:{top:0,bottom:0},dragElastic:{top:0,bottom:.5},onDragEnd:(a,p)=>{(p.offset.y>100||p.velocity.y>500)&&t();},style:mergeStyles(yi,{height:o,maxHeight:s,touchAction:"none"},l),className:m,children:[u&&jsx("div",{style:vi}),(n||d)&&jsxs("div",{style:bi,children:[jsx("span",{style:Si,children:n}),d&&jsx("button",{style:wi,onClick:t,"aria-label":"Close",children:jsx(Ei,{})})]}),jsx("div",{style:Pi,children:r})]})]})})}function In({size:e=24,color:t=colors.text,thickness:n=2,style:r,className:o=""}){return jsxs(Fragment,{children:[jsx("style",{children:`
1
+ import dn,{Events,ErrorTypes}from'hls.js';import {create}from'zustand';import {persist}from'zustand/middleware';import {shadows,colors,fontWeights,fontSizes,radii,spacing,easings,durations,components,mergeStyles,zIndices,springs}from'@xhub-reel/design-tokens';import {forwardRef,useRef,useEffect,useImperativeHandle,useState,useCallback,createContext,useMemo,useContext,createElement}from'react';import {AnimatePresence,motion}from'motion/react';import {jsx,jsxs,Fragment}from'react/jsx-runtime';import {useDrag,useGesture}from'@use-gesture/react';import {createRoot}from'react-dom/client';var kt={maxBufferLength:30,maxMaxBufferLength:60,maxBufferSize:3e7,maxBufferHole:.5,abrEwmaDefaultEstimate:5e5,abrBandWidthUpFactor:.7,abrBandWidthFactor:.9,startLevel:-1,autoStartLoad:true,startPosition:-1,fragLoadingMaxRetry:3,manifestLoadingMaxRetry:3,levelLoadingMaxRetry:3,fragLoadingTimeOut:2e4,manifestLoadingTimeOut:1e4,levelLoadingTimeOut:1e4,lowLatencyMode:false,liveSyncDuration:3};var et={ACTIVATION_THRESHOLD:.5,DEACTIVATION_THRESHOLD:.3},Re={MAX_VIDEOS_IN_DOM:5,MAX_DECODED_FRAMES:3,MAX_TOTAL_MEMORY:150*1024*1024},Ne={HEIGHT_DEFAULT:2,HEIGHT_ACTIVE:4};var Lt={PLAYER_PREFERENCES:"xhub-reel-player"};var jt={isMuted:true,volume:1,playbackSpeed:1,quality:"auto"},_e=create()(persist(e=>({...jt,toggleMute:()=>e(t=>({isMuted:!t.isMuted})),setMuted:t=>e({isMuted:t}),setVolume:t=>e({volume:Math.max(0,Math.min(1,t)),isMuted:t===0}),setPlaybackSpeed:t=>e({playbackSpeed:t}),setQuality:t=>e({quality:t}),resetPreferences:()=>e(jt)}),{name:Lt.PLAYER_PREFERENCES}));var Zt={videos:[],currentIndex:0,isLoading:false,hasMore:true,error:null},Tt=create(e=>({...Zt,setVideos:t=>e({videos:t,currentIndex:0}),appendVideos:t=>e(n=>({videos:[...n.videos,...t]})),setCurrentIndex:t=>e({currentIndex:t}),goToNext:()=>e(t=>({currentIndex:Math.min(t.currentIndex+1,t.videos.length-1)})),goToPrevious:()=>e(t=>({currentIndex:Math.max(t.currentIndex-1,0)})),removeVideo:t=>e(n=>{let r=n.videos.filter(s=>s.id!==t),o=Math.min(n.currentIndex,r.length-1);return {videos:r,currentIndex:Math.max(0,o)}}),setLoading:t=>e({isLoading:t}),setHasMore:t=>e({hasMore:t}),setError:t=>e({error:t}),reset:()=>e(Zt)}));function Y(...e){return Object.assign({},...e.filter(Boolean))}var Ue={flex:(e={})=>({display:"flex",flexDirection:e.direction,alignItems:e.align,justifyContent:e.justify,gap:typeof e.gap=="number"?e.gap:spacing[e.gap||0],flexWrap:e.wrap}),flexCenter:{display:"flex",alignItems:"center",justifyContent:"center"},flexBetween:{display:"flex",alignItems:"center",justifyContent:"space-between"},flexColumn:{display:"flex",flexDirection:"column"},grid:(e={})=>({display:"grid",gridTemplateColumns:typeof e.columns=="number"?`repeat(${e.columns}, 1fr)`:e.columns,gridTemplateRows:typeof e.rows=="number"?`repeat(${e.rows}, 1fr)`:e.rows,gap:typeof e.gap=="number"?e.gap:spacing[e.gap||0]}),absolute:(e={})=>({position:"absolute",...e.inset!==void 0&&{inset:e.inset},...e.top!==void 0&&{top:e.top},...e.right!==void 0&&{right:e.right},...e.bottom!==void 0&&{bottom:e.bottom},...e.left!==void 0&&{left:e.left}}),fixed:(e={})=>({position:"fixed",...e.inset!==void 0&&{inset:e.inset},...e.top!==void 0&&{top:e.top},...e.right!==void 0&&{right:e.right},...e.bottom!==void 0&&{bottom:e.bottom},...e.left!==void 0&&{left:e.left}}),fullScreen:{position:"fixed",inset:0,width:"100%",height:"100%"},fullSize:{width:"100%",height:"100%"},centerAbsolute:{position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)"}};({heading:{fontSize:fontSizes.xl,fontWeight:fontWeights.bold,color:colors.text},body:{fontSize:fontSizes.md,fontWeight:fontWeights.normal,color:colors.text},caption:{fontSize:fontSizes.xs,fontWeight:fontWeights.normal,color:colors.textSecondary},videoText:{color:colors.text,textShadow:shadows.text}});var Ie={bg:e=>({backgroundColor:e in colors?colors[e]:e}),rounded:(e="md")=>({borderRadius:radii[e]}),border:(e={})=>({borderWidth:e.width||1,borderStyle:e.style||"solid",borderColor:e.color?e.color in colors?colors[e.color]:e.color:colors.border}),shadow:(e="md")=>({boxShadow:shadows[e]}),opacity:e=>({opacity:e}),glass:(e=20)=>({backgroundColor:colors.overlay,backdropFilter:`blur(${e}px)`,WebkitBackdropFilter:`blur(${e}px)`}),glassLight:(e=10)=>({backgroundColor:colors.overlayLight,backdropFilter:`blur(${e}px)`,WebkitBackdropFilter:`blur(${e}px)`})},tn={clickable:{cursor:"pointer",userSelect:"none"}},nn={transition:(e="all",t="normal",n="xhubReel")=>({transitionProperty:Array.isArray(e)?e.join(", "):e,transitionDuration:durations[t],transitionTimingFunction:easings[n]}),noTransition:{transition:"none"}},Qe={scrollY:{overflowY:"auto",overflowX:"hidden",WebkitOverflowScrolling:"touch"},hideScrollbar:{scrollbarWidth:"none",msOverflowStyle:"none"},snapY:{scrollSnapType:"y mandatory",overscrollBehaviorY:"contain"},snapStart:{scrollSnapAlign:"start",scrollSnapStop:"always"}};var rn={square:e=>({width:e,height:e}),width:e=>({width:e}),height:e=>({height:e}),minHeight:e=>({minHeight:e}),maxWidth:e=>({maxWidth:e})};({feedContainer:Y(Ue.fixed({inset:0}),Qe.scrollY,Qe.snapY,Qe.hideScrollbar,Ie.bg("background"),{touchAction:"pan-y"}),feedItem:Y(Ue.fullSize,Qe.snapStart,Ie.bg("background"),{position:"relative"}),actionButton:Y(Ue.flexCenter,rn.square(48),Ie.rounded("full"),tn.clickable,nn.transition(["transform","background-color"])),bottomSheet:Y(Ue.fixed({left:0,right:0,bottom:0}),Ie.glass(),Ie.rounded("xl"),{borderBottomLeftRadius:0,borderBottomRightRadius:0})});var on=class{callbacks={};currentInfo;constructor(){this.currentInfo=this.detectNetwork(),this.setupListeners();}detectNetwork(){let e=navigator.connection;return {online:navigator.onLine,effectiveType:e?.effectiveType??"unknown",downlink:e?.downlink??null,rtt:e?.rtt??null,saveData:e?.saveData??false,type:e?.type??"unknown"}}setupListeners(){window.addEventListener("online",this.handleOnline),window.addEventListener("offline",this.handleOffline);let e=navigator.connection;e&&e.addEventListener("change",this.handleConnectionChange);}handleOnline=()=>{this.currentInfo={...this.currentInfo,online:true},this.callbacks.onOnline?.(),this.callbacks.onNetworkChange?.(this.currentInfo);};handleOffline=()=>{this.currentInfo={...this.currentInfo,online:false},this.callbacks.onOffline?.(),this.callbacks.onNetworkChange?.(this.currentInfo);};handleConnectionChange=()=>{this.currentInfo=this.detectNetwork(),this.callbacks.onNetworkChange?.(this.currentInfo);};subscribe(e){return this.callbacks={...this.callbacks,...e},()=>{this.callbacks={};}}getInfo(){return this.currentInfo}isSlowNetwork(){let{effectiveType:e}=this.currentInfo;return e==="slow-2g"||e==="2g"}getRecommendedConfig(){let{effectiveType:e,saveData:t}=this.currentInfo;return t||e==="slow-2g"||e==="2g"?{maxBufferLength:10,maxMaxBufferLength:20,startLevel:0}:e==="3g"?{maxBufferLength:20,maxMaxBufferLength:40,startLevel:1}:{}}estimateDownloadTime(e){let{downlink:t}=this.currentInfo;if(!t||t===0)return 1/0;let n=t*1e6/8;return e/n}destroy(){window.removeEventListener("online",this.handleOnline),window.removeEventListener("offline",this.handleOffline);let e=navigator.connection;e&&e.removeEventListener("change",this.handleConnectionChange);}};var sn=class{callbacks={};currentInfo={batteryLevel:null,isCharging:false,isLowPowerMode:false};battery=null;constructor(){this.initBattery();}async initBattery(){try{let e=navigator;e.getBattery&&(this.battery=await e.getBattery(),this.updateInfo(),this.setupListeners());}catch{}}updateInfo(){this.battery&&(this.currentInfo={batteryLevel:this.battery.level,isCharging:this.battery.charging,isLowPowerMode:this.battery.level<.2},this.callbacks.onPowerChange?.(this.currentInfo),this.currentInfo.batteryLevel!==null&&this.currentInfo.batteryLevel<.15&&this.callbacks.onLowBattery?.());}setupListeners(){this.battery&&(this.battery.addEventListener("levelchange",()=>this.updateInfo()),this.battery.addEventListener("chargingchange",()=>this.updateInfo()));}subscribe(e){return this.callbacks={...this.callbacks,...e},()=>{this.callbacks={};}}getInfo(){return this.currentInfo}isPowerSaving(){return this.currentInfo.isLowPowerMode&&!this.currentInfo.isCharging}getRecommendedConfig(){return this.isPowerSaving()?{maxBufferLength:15,capLevelToPlayerSize:true}:{}}destroy(){this.callbacks={};}};var an=class{queue=[];preloaded=new Set;loading=new Set;callbacks={};options;paused=false;velocityThreshold=2e3;constructor(e={}){this.options={maxConcurrent:e.maxConcurrent??2,maxQueue:e.maxQueue??5};}enqueue(e){let t=e.id??e.url;if(!(this.preloaded.has(e.url)||this.queue.some(n=>n.url===e.url))){if(this.queue.length>=this.options.maxQueue){let n=this.queue.shift();n&&this.callbacks.onPreloadCancel?.(n);}this.queue.push({...e,id:t,status:"pending"}),this.queue.sort((n,r)=>r.priority-n.priority),this.processQueue();}}enqueueMany(e){e.forEach(t=>this.enqueue(t));}cancel(e){let t=this.queue.find(n=>n.url===e);t&&(this.queue=this.queue.filter(n=>n.url!==e),this.loading.delete(t.id),this.callbacks.onPreloadCancel?.(t));}cancelAll(){this.queue.forEach(e=>{this.callbacks.onPreloadCancel?.(e);}),this.queue=[],this.loading.clear();}add(e,t,n=0){this.enqueue({id:e,url:t,priority:n});}remove(e){this.queue=this.queue.filter(t=>t.id!==e),this.loading.delete(e);}clear(){this.cancelAll(),this.preloaded.clear();}setPaused(e){this.paused=e,e||this.processQueue();}handleScrollVelocity(e){Math.abs(e)>this.velocityThreshold?this.setPaused(true):this.setPaused(false);}isPreloaded(e){return this.preloaded.has(e)}getStatus(e){let t=this.queue.find(n=>n.url===e);return t?t.status:this.preloaded.has(e)?"loaded":null}getAllStatuses(){return this.queue.map(e=>e.status)}getPreloadedUrls(){return Array.from(this.preloaded)}subscribe(e){return this.callbacks={...this.callbacks,...e},()=>{this.callbacks={};}}processQueue(){if(!this.paused)for(;this.loading.size<this.options.maxConcurrent&&this.queue.some(e=>e.status==="pending");){let e=this.queue.find(t=>t.status==="pending");e&&this.preloadItem(e);}}async preloadItem(e){e.status="loading",this.loading.add(e.id),this.callbacks.onPreloadStart?.(e);try{let t=document.createElement("link");t.rel="preload",t.as="fetch",t.href=e.url,t.crossOrigin="anonymous",document.head.appendChild(t),await new Promise((n,r)=>{t.onload=()=>n(),t.onerror=()=>r(new Error("Preload failed"));}),e.status="loaded",this.preloaded.add(e.url),this.callbacks.onPreloadComplete?.(e);}catch(t){e.status="error",this.callbacks.onPreloadError?.(e,t);}finally{this.loading.delete(e.id),this.processQueue();}}destroy(){this.clear(),this.callbacks={};}};var ln=class{metrics=this.createEmptyMetrics();callbacks={};bufferingStartTime=null;playStartTime=null;isPlaying=false;createEmptyMetrics(){return {videoId:null,sessionStartTime:null,playbackStartTime:null,totalPlayTime:0,totalBufferingTime:0,bufferingCount:0,qualitySwitches:[],errors:[],seeks:[],avgBitrate:0,startupTime:null}}startSession(e,t){this.metrics={...this.createEmptyMetrics(),videoId:e,sessionStartTime:Date.now()},this.notifyUpdate();}endSession(){this.isPlaying&&this.playStartTime&&(this.metrics.totalPlayTime+=Date.now()-this.playStartTime),this.isPlaying=false,this.playStartTime=null;let e={...this.metrics};return this.callbacks.onSessionEnd?.(e),e}trackFirstFrame(){this.metrics.sessionStartTime&&!this.metrics.playbackStartTime&&(this.metrics.playbackStartTime=Date.now(),this.metrics.startupTime=this.metrics.playbackStartTime-this.metrics.sessionStartTime,this.isPlaying=true,this.playStartTime=Date.now(),this.notifyUpdate());}trackBuffering(e){let t=Date.now();e&&!this.bufferingStartTime?(this.bufferingStartTime=t,this.metrics.bufferingCount++):!e&&this.bufferingStartTime&&(this.metrics.totalBufferingTime+=t-this.bufferingStartTime,this.bufferingStartTime=null),this.notifyUpdate();}trackQualitySwitch(e,t,n){this.metrics.qualitySwitches.push({timestamp:Date.now(),fromLevel:e,toLevel:t,automatic:n}),this.notifyUpdate();}trackError(e,t,n){let r=typeof e=="string"?e:e.message;this.metrics.errors.push({timestamp:Date.now(),message:r,recoverable:t}),this.notifyUpdate();}trackBitrate(e){this.metrics.avgBitrate=e,this.notifyUpdate();}trackReplay(){this.playStartTime=Date.now(),this.isPlaying=true,this.notifyUpdate();}trackSeek(e,t,n){this.metrics.seeks.push({timestamp:Date.now(),from:e,to:t,latency:n}),this.notifyUpdate();}subscribe(e){return this.callbacks={...this.callbacks,...e},()=>{this.callbacks={};}}getMetrics(){return {...this.metrics}}notifyUpdate(){this.callbacks.onMetricsUpdate?.(this.getMetrics());}destroy(){this.endSession(),this.callbacks={};}};var It=class pn{hls=null;video=null;options;retryCount=0;maxRetries=3;constructor(t={}){this.options=t;}static isSupported(){return dn.isSupported()}attach(t,n){if(this.destroy(),this.video=t,this.retryCount=0,!pn.isSupported()){this.options.callbacks?.onError?.(new Error("HLS.js is not supported in this browser"),false);return}this.options.callbacks?.onStateChange?.("loading"),this.hls=new dn({...kt,...this.options.config}),this.setupHLSListeners(),this.setupVideoListeners(),this.hls.attachMedia(t),this.hls.loadSource(n);}loadSource(t){if(!this.hls||!this.video)throw new Error("HLS engine not attached to video element");this.retryCount=0,this.options.callbacks?.onStateChange?.("loading"),this.hls.loadSource(t);}destroy(){this.video&&(this.removeVideoListeners(),this.video=null),this.hls&&(this.hls.destroy(),this.hls=null);}getQualityLevels(){return this.hls?this.hls.levels.map(t=>({label:`${t.height}p`,height:t.height,bitrate:t.bitrate})):[]}setQuality(t){this.hls&&(this.hls.currentLevel=t);}getCurrentQuality(){return this.hls?.currentLevel??-1}getBandwidth(){return this.hls?.bandwidthEstimate??0}isAutoQuality(){return this.hls?.autoLevelEnabled??true}startLoad(t){this.hls?.startLoad(t);}stopLoad(){this.hls?.stopLoad();}setupHLSListeners(){this.hls&&(this.hls.on(Events.MANIFEST_PARSED,(t,n)=>{let r=this.getQualityLevels();this.options.callbacks?.onQualityLevelsLoaded?.(r),this.options.callbacks?.onStateChange?.("ready"),this.video?.autoplay&&this.video.play().catch(()=>{});}),this.hls.on(Events.LEVEL_SWITCHED,(t,n)=>{this.options.callbacks?.onQualityChange?.(n.level,this.isAutoQuality());}),this.hls.on(Events.FRAG_LOADED,()=>{this.options.callbacks?.onBandwidthUpdate?.(this.getBandwidth());}),this.hls.on(Events.ERROR,(t,n)=>{this.handleError(n);}));}setupVideoListeners(){this.video&&(this.video.addEventListener("playing",this.handlePlaying),this.video.addEventListener("pause",this.handlePause),this.video.addEventListener("waiting",this.handleWaiting),this.video.addEventListener("ended",this.handleEnded),this.video.addEventListener("canplay",this.handleCanPlay),this.video.addEventListener("error",this.handleVideoError));}removeVideoListeners(){this.video&&(this.video.removeEventListener("playing",this.handlePlaying),this.video.removeEventListener("pause",this.handlePause),this.video.removeEventListener("waiting",this.handleWaiting),this.video.removeEventListener("ended",this.handleEnded),this.video.removeEventListener("canplay",this.handleCanPlay),this.video.removeEventListener("error",this.handleVideoError));}handlePlaying=()=>{this.options.callbacks?.onStateChange?.("playing");};handlePause=()=>{this.options.callbacks?.onStateChange?.("paused");};handleWaiting=()=>{this.options.callbacks?.onStateChange?.("buffering");};handleEnded=()=>{this.options.callbacks?.onStateChange?.("ended");};handleCanPlay=()=>{this.video?.paused&&this.options.callbacks?.onStateChange?.("ready");};handleVideoError=()=>{let t=this.video?.error;this.options.callbacks?.onError?.(new Error(t?.message??"Video playback error"),false),this.options.callbacks?.onStateChange?.("error");};handleError(t){if(t.fatal){let n=false;switch(t.type){case ErrorTypes.NETWORK_ERROR:this.retryCount<this.maxRetries&&(this.retryCount++,console.warn(`[HLSEngine] Network error, retry ${this.retryCount}/${this.maxRetries}`),this.hls?.startLoad(),n=true);break;case ErrorTypes.MEDIA_ERROR:console.warn("[HLSEngine] Media error, attempting recovery"),this.hls?.recoverMediaError(),n=true;break}n?this.options.callbacks?.onError?.(new Error(`HLS error (recovering): ${t.details}`),true):(this.options.callbacks?.onError?.(new Error(`HLS fatal error: ${t.details}`),false),this.options.callbacks?.onStateChange?.("error"),this.destroy());}else console.warn("[HLSEngine] Non-fatal error:",t.details);}};async function fn(e,t={}){try{return await e.play(),{success:!0}}catch(n){let r=n;if(r.name==="NotAllowedError"){e.muted=true;try{return await e.play(),{success:!0,mutedAutoplay:!0}}catch{return t.onNeedsUserGesture?.(),{success:false,reason:"user_gesture_required"}}}return {success:false,reason:"unknown",error:r}}}var hn=[.5,1,1.5,2],it=class Mt{video=null;options;lastQuality=null;bandwidthSamples=[];constructor(t={}){this.options=t;}static isSupported(){return typeof document>"u"?false:document.createElement("video").canPlayType("application/vnd.apple.mpegurl")!==""}static isIOS(){return typeof navigator>"u"?false:/iPad|iPhone|iPod/.test(navigator.userAgent)||navigator.platform==="MacIntel"&&navigator.maxTouchPoints>1}attach(t,n){this.destroy(),this.video=t,this.options.callbacks?.onStateChange?.("loading"),this.setupVideoListeners(),t.src=n,t.load();}loadSource(t){if(!this.video)throw new Error("Native HLS not attached to video element");this.options.callbacks?.onStateChange?.("loading"),this.video.src=t,this.video.load();}async play(){return this.video?fn(this.video,{onNeedsUserGesture:this.options.callbacks?.onNeedsUserGesture}):{success:false,reason:"unknown"}}destroy(){this.video&&(this.removeVideoListeners(),this.video.removeAttribute("src"),this.video.load(),this.video=null),this.bandwidthSamples=[],this.lastQuality=null;}getQualityLevels(){let t=this.estimateCurrentQuality(),n=[{label:"Auto",height:0,bitrate:0}];return t&&n.push(t),n}setQuality(t){console.warn("[NativeHLS] Quality selection not supported, using auto");}getCurrentQuality(){return -1}estimateCurrentQuality(){if(!this.video||this.video.videoHeight===0)return null;let t=this.video.videoHeight,n=this.estimateBitrate();return {label:`${t}p`,height:t,bitrate:n}}estimateBitrate(){if(this.bandwidthSamples.length>0){let n=this.bandwidthSamples.reduce((r,o)=>r+o,0);return Math.round(n/this.bandwidthSamples.length)}if(!this.video)return 0;let t=this.video.videoHeight;return t>=1080?5e6:t>=720?25e5:t>=480?1e6:t>=360?5e5:25e4}getBandwidth(){return this.estimateBitrate()}isAutoQuality(){return true}startLoad(){this.video?.load();}stopLoad(){this.video&&(this.video.preload="none");}async enterFullscreen(){let t=this.video;if(t){if(t.requestFullscreen){await t.requestFullscreen();return}t.webkitEnterFullscreen&&await t.webkitEnterFullscreen();}}async exitFullscreen(){let t=this.video;if(t){if(document.exitFullscreen){await document.exitFullscreen();return}t.webkitExitFullscreen&&await t.webkitExitFullscreen();}}isFullscreen(){let t=this.video;return t?document.fullscreenElement?document.fullscreenElement===t:t.webkitDisplayingFullscreen??false:false}isFullscreenSupported(){let t=this.video;return t?!!(t.requestFullscreen||t.webkitSupportsFullscreen):false}isPlaybackRateSupported(t){return Mt.isIOS()?hn.includes(t):t>=.5&&t<=2}getSupportedPlaybackRates(){return Mt.isIOS()?[...hn]:[.5,.75,1,1.25,1.5,2]}setupVideoListeners(){this.video&&(this.video.addEventListener("loadedmetadata",this.handleLoadedMetadata),this.video.addEventListener("playing",this.handlePlaying),this.video.addEventListener("pause",this.handlePause),this.video.addEventListener("waiting",this.handleWaiting),this.video.addEventListener("ended",this.handleEnded),this.video.addEventListener("canplay",this.handleCanPlay),this.video.addEventListener("error",this.handleError),this.video.addEventListener("resize",this.handleResize),this.video.addEventListener("progress",this.handleProgress));}removeVideoListeners(){this.video&&(this.video.removeEventListener("loadedmetadata",this.handleLoadedMetadata),this.video.removeEventListener("playing",this.handlePlaying),this.video.removeEventListener("pause",this.handlePause),this.video.removeEventListener("waiting",this.handleWaiting),this.video.removeEventListener("ended",this.handleEnded),this.video.removeEventListener("canplay",this.handleCanPlay),this.video.removeEventListener("error",this.handleError),this.video.removeEventListener("resize",this.handleResize),this.video.removeEventListener("progress",this.handleProgress));}handleLoadedMetadata=()=>{let t=this.getQualityLevels();this.options.callbacks?.onQualityLevelsLoaded?.(t),this.options.callbacks?.onStateChange?.("ready"),this.checkQualityChange();};handlePlaying=()=>{this.options.callbacks?.onStateChange?.("playing");};handlePause=()=>{this.options.callbacks?.onStateChange?.("paused");};handleWaiting=()=>{this.options.callbacks?.onStateChange?.("buffering");};handleEnded=()=>{this.options.callbacks?.onStateChange?.("ended");};handleCanPlay=()=>{this.video?.paused&&this.options.callbacks?.onStateChange?.("ready");};handleError=()=>{let t=this.video?.error,n=t?.message??"Video playback error",r=t?.code!==MediaError.MEDIA_ERR_SRC_NOT_SUPPORTED;this.options.callbacks?.onError?.(new Error(n),r),this.options.callbacks?.onStateChange?.("error");};handleResize=()=>{this.checkQualityChange();};handleProgress=()=>{this.updateBandwidthEstimate();};checkQualityChange(){let t=this.estimateCurrentQuality();t&&(!this.lastQuality||this.lastQuality.height!==t.height)&&(this.lastQuality=t,this.options.callbacks?.onQualityChange?.(t));}updateBandwidthEstimate(){if(this.video&&typeof performance<"u"&&performance.getEntriesByType){let n=performance.getEntriesByType("resource").filter(r=>r.initiatorType==="video"||r.name.includes(".ts")||r.name.includes(".m3u8"));if(n.length>0){let o=n.slice(-5).filter(s=>s.transferSize>0&&s.duration>0).map(s=>s.transferSize*8/(s.duration/1e3));if(o.length>0){let s=o.reduce((a,d)=>a+d,0)/o.length;this.bandwidthSamples.push(s),this.bandwidthSamples.length>10&&this.bandwidthSamples.shift(),this.options.callbacks?.onBandwidthUpdate?.(s);}}}}},mn=class{engine=null;video=null;options;isNative=false;animationFrameId=null;isTracking=false;networkDetector=null;powerManager=null;preloadManager=null;analytics=null;cleanupFunctions=[];wasPlayingBeforeOffline=false;wasPlayingBeforeLowBattery=false;constructor(e={}){this.options={enableNetworkAdaptation:true,enablePowerAdaptation:true,enableAnalytics:false,...e},this.isNative=this.shouldUseNative(),this.initializeServices();}static isSupported(){return It.isSupported()||it.isSupported()}attach(e,t,n){this.video=e,this.destroyEngine(),this.setupVideoListeners(),this.analytics&&n&&this.analytics.startSession(n,e);let r=this.getAdaptedConfig();this.isNative?this.engine=new it({callbacks:{onStateChange:this.options.callbacks?.onStateChange,onError:this.options.callbacks?.onError,onQualityLevelsLoaded:this.options.callbacks?.onQualityLevelsLoaded,onBandwidthUpdate:this.options.callbacks?.onBandwidthUpdate,onNeedsUserGesture:this.options.callbacks?.onNeedsUserGesture,onQualityChange:o=>{this.options.callbacks?.onQualityChange?.(-1,o);}}}):this.engine=new It({config:r,callbacks:{onStateChange:this.options.callbacks?.onStateChange,onError:this.options.callbacks?.onError,onQualityLevelsLoaded:this.options.callbacks?.onQualityLevelsLoaded,onBandwidthUpdate:this.options.callbacks?.onBandwidthUpdate,onQualityChange:(o,s)=>{let a=this.engine?.getQualityLevels()??[],d=o>=0&&o<a.length?a[o]:void 0;this.options.callbacks?.onQualityChange?.(s?-1:o,d);}}}),this.engine.attach(e,t);}loadSource(e,t){if(!this.engine||!this.video)throw new Error("Player not attached to video element");this.analytics&&(this.analytics.endSession(),t&&this.analytics.startSession(t,this.video)),this.engine.loadSource(e);}destroy(){this.destroyEngine(),this.destroyServices();}async play(){return this.video?this.isNative&&this.engine instanceof it?this.engine.play():fn(this.video,{onNeedsUserGesture:this.options.callbacks?.onNeedsUserGesture}):{success:false,reason:"unknown"}}pause(){this.video?.pause();}async togglePlay(){return this.video?.paused?this.play():(this.pause(),{success:true})}seek(e){if(this.video){let t=this.video.currentTime;this.video.currentTime=Math.max(0,Math.min(e,this.video.duration||0)),this.analytics?.trackSeek(t,e,0);}}seekForward(e=10){this.video&&this.seek(this.video.currentTime+e);}seekBackward(e=10){this.video&&this.seek(this.video.currentTime-e);}getCurrentTime(){return this.video?.currentTime??0}getDuration(){return this.video?.duration??0}setVolume(e){this.video&&(this.video.volume=Math.max(0,Math.min(1,e)));}getVolume(){return this.video?.volume??1}setMuted(e){this.video&&(this.video.muted=e);}isMuted(){return this.video?.muted??true}toggleMute(){this.setMuted(!this.isMuted());}setPlaybackRate(e){this.video&&(this.video.playbackRate=e);}getPlaybackRate(){return this.video?.playbackRate??1}getQualityLevels(){return this.engine?.getQualityLevels()??[]}setQuality(e){let t=this.getCurrentQuality();this.engine?.setQuality(e),t!==e&&this.analytics?.trackQualitySwitch(t,e,e===-1);}getCurrentQuality(){return this.engine?.getCurrentQuality()??-1}isUsingNative(){return this.isNative}getVideoElement(){return this.video}getBuffered(){if(!this.video)return 0;let e=this.video.buffered,t=this.video.currentTime;for(let n=0;n<e.length;n++)if(t>=e.start(n)&&t<=e.end(n))return e.end(n)-t;return 0}getNetworkInfo(){return this.networkDetector?.getInfo()??null}getPowerInfo(){return this.powerManager?.getInfo()??null}getPreloadManager(){return this.preloadManager}getAnalytics(){return this.analytics?.getMetrics()??null}isSlowNetwork(){return this.networkDetector?.isSlowNetwork()??false}isPowerSaving(){return this.powerManager?.isPowerSaving()??false}shouldUseNative(){return this.options.preferNative!==false&&it.isSupported()?true:!It.isSupported()}initializeServices(){if(this.options.enableNetworkAdaptation){this.networkDetector=new on;let e=this.networkDetector.subscribe({onNetworkChange:this.handleNetworkChange,onOffline:()=>this.options.callbacks?.onError?.(new Error("Network offline"),true)});this.cleanupFunctions.push(e);}if(this.options.enablePowerAdaptation){this.powerManager=new sn;let e=this.powerManager.subscribe({onPowerChange:this.handlePowerChange});this.cleanupFunctions.push(e),this.cleanupFunctions.push(()=>this.powerManager?.destroy());}if(this.options.preloadConfig&&(this.preloadManager=new an(this.options.preloadConfig),this.cleanupFunctions.push(()=>this.preloadManager?.destroy())),this.options.enableAnalytics){this.analytics=new ln;let e=this.analytics.subscribe({onMetricsUpdate:t=>this.options.callbacks?.onAnalyticsUpdate?.(t)});this.cleanupFunctions.push(e),this.cleanupFunctions.push(()=>this.analytics?.destroy());}}destroyServices(){this.cleanupFunctions.forEach(e=>e()),this.cleanupFunctions=[],this.networkDetector=null,this.powerManager=null,this.preloadManager=null,this.analytics=null;}destroyEngine(){this.stopProgressTracking(),this.removeVideoListeners(),this.engine&&(this.engine.destroy(),this.engine=null);}getAdaptedConfig(){let e={};return this.networkDetector&&(e={...e,...this.networkDetector.getRecommendedConfig()}),this.powerManager&&(e={...e,...this.powerManager.getRecommendedConfig()}),e}isNetworkBelowThreshold(e,t){let n=["slow-2g","2g","3g","4g","5g","unknown"],r=n.indexOf(e),o=n.indexOf(t);return e==="unknown"?false:r>=0&&r<=o}handleNetworkChange=e=>{this.options.callbacks?.onNetworkChange?.(e);let t=this.options.lowQualityThreshold??"2g",n=this.isNetworkBelowThreshold(e.effectiveType,t);this.options.autoQualityOnNetworkChange&&this.engine&&(n?this.setQuality(0):(e.effectiveType==="4g"||e.effectiveType==="5g")&&this.setQuality(-1)),this.options.autoPauseOnOffline&&!e.online&&(this.wasPlayingBeforeOffline=this.video?!this.video.paused:false,this.pause()),this.options.autoResumeOnOnline&&e.online&&this.wasPlayingBeforeOffline&&(this.play(),this.wasPlayingBeforeOffline=false),this.preloadManager&&this.preloadManager.setPaused(e.effectiveType==="2g"||!e.online);};handlePowerChange=e=>{this.options.callbacks?.onPowerChange?.(e);let t=this.options.lowBatteryThreshold??.15,n=e.batteryLevel!==null&&e.batteryLevel<t;this.options.autoPauseOnLowBattery&&n&&!e.isCharging&&(this.wasPlayingBeforeLowBattery=this.video?!this.video.paused:false,this.pause()),this.wasPlayingBeforeLowBattery&&(e.isCharging||e.batteryLevel!==null&&e.batteryLevel>=t+.05)&&(this.play(),this.wasPlayingBeforeLowBattery=false),this.preloadManager&&e.isLowPowerMode&&this.preloadManager.setPaused(true);};setupVideoListeners(){this.video&&(this.video.addEventListener("timeupdate",this.handleTimeUpdate),this.video.addEventListener("progress",this.handleProgress),this.video.addEventListener("volumechange",this.handleVolumeChange),this.video.addEventListener("ratechange",this.handleRateChange),this.video.addEventListener("play",this.handlePlay),this.video.addEventListener("pause",this.handlePause),this.video.addEventListener("ended",this.handleEnded),this.video.addEventListener("waiting",this.handleWaiting),this.video.addEventListener("playing",this.handlePlaying));}removeVideoListeners(){this.video&&(this.video.removeEventListener("timeupdate",this.handleTimeUpdate),this.video.removeEventListener("progress",this.handleProgress),this.video.removeEventListener("volumechange",this.handleVolumeChange),this.video.removeEventListener("ratechange",this.handleRateChange),this.video.removeEventListener("play",this.handlePlay),this.video.removeEventListener("pause",this.handlePause),this.video.removeEventListener("ended",this.handleEnded),this.video.removeEventListener("waiting",this.handleWaiting),this.video.removeEventListener("playing",this.handlePlaying));}handleTimeUpdate=()=>{this.video&&this.options.callbacks?.onTimeUpdate?.(this.video.currentTime,this.video.duration||0);};handleProgress=()=>{this.options.callbacks?.onProgress?.(this.getBuffered());};handleVolumeChange=()=>{this.video&&this.options.callbacks?.onVolumeChange?.(this.video.volume,this.video.muted);};handleRateChange=()=>{this.video&&this.options.callbacks?.onRateChange?.(this.video.playbackRate);};handlePlay=()=>{this.options.enableSmoothTimeUpdates&&this.startProgressTracking();};handlePause=()=>{this.stopProgressTracking();};handleEnded=()=>{this.stopProgressTracking(),this.analytics&&this.analytics.endSession();};handleWaiting=()=>{this.analytics?.trackBuffering(true);};handlePlaying=()=>{this.analytics?.trackBuffering(false),this.analytics?.trackFirstFrame();};startProgressTracking(){if(this.isTracking||!this.video)return;this.isTracking=true;let e=()=>{if(!this.video||this.video.paused||this.video.ended){this.isTracking=false,this.animationFrameId=null;return}this.options.callbacks?.onTimeUpdate?.(this.video.currentTime,this.video.duration||0),this.animationFrameId=requestAnimationFrame(e);};this.animationFrameId=requestAnimationFrame(e);}stopProgressTracking(){this.animationFrameId!==null&&(cancelAnimationFrame(this.animationFrameId),this.animationFrameId=null),this.isTracking=false;}},Cr=[{from:"idle",to:"loading"},{from:"loading",to:"ready"},{from:"loading",to:"error"},{from:"ready",to:"playing"},{from:"ready",to:"loading"},{from:"ready",to:"error"},{from:"playing",to:"paused"},{from:"playing",to:"buffering"},{from:"playing",to:"ended"},{from:"playing",to:"error"},{from:"playing",to:"loading"},{from:"paused",to:"playing"},{from:"paused",to:"buffering"},{from:"paused",to:"loading"},{from:"paused",to:"error"},{from:"buffering",to:"playing"},{from:"buffering",to:"paused"},{from:"buffering",to:"stalled"},{from:"buffering",to:"error"},{from:"stalled",to:"playing"},{from:"stalled",to:"buffering"},{from:"stalled",to:"error"},{from:"stalled",to:"loading"},{from:"ended",to:"playing"},{from:"ended",to:"loading"},{from:"ended",to:"idle"},{from:"error",to:"loading"},{from:"error",to:"idle"},{from:"*",to:"idle"}],kr=class{_state="idle";listeners=new Set;stalledTimeout=null;stalledThreshold=3e3;get state(){return this._state}transition(e){if(!this.canTransition(e))return console.warn(`[PlayerStateMachine] Invalid transition: ${this._state} -> ${e}`),false;let n=this._state;return this._state=e,e==="buffering"?this.startStalledTimer():this.clearStalledTimer(),this.listeners.forEach(r=>r(e,n)),true}canTransition(e){let t=Cr.find(n=>(n.from===this._state||n.from==="*")&&n.to===e);return !(!t||t.guard&&!t.guard())}subscribe(e){return this.listeners.add(e),()=>this.listeners.delete(e)}reset(){this.clearStalledTimer(),this._state="idle";}isPlaying(){return this._state==="playing"}canPlay(){return ["ready","paused","ended"].includes(this._state)}isLoading(){return ["loading","buffering"].includes(this._state)}hasError(){return this._state==="error"}startStalledTimer(){this.clearStalledTimer(),this.stalledTimeout=setTimeout(()=>{this._state==="buffering"&&this.transition("stalled");},this.stalledThreshold);}clearStalledTimer(){this.stalledTimeout&&(clearTimeout(this.stalledTimeout),this.stalledTimeout=null);}};function Lr(){return new kr}function gn(){let e=useMemo(()=>Lr(),[]),[t,n]=useState(e.state);useEffect(()=>e.subscribe(a=>{n(a);}),[e]);let r=useCallback(s=>e.transition(s),[e]),o=useCallback(()=>{e.reset(),n("idle");},[e]);return {state:t,isPlaying:t==="playing",isPaused:t==="paused",isLoading:t==="loading",isBuffering:t==="buffering",isStalled:t==="stalled",isEnded:t==="ended",hasError:t==="error",canPlay:e.canPlay(),transition:r,reset:o}}function yn(e){let{volume:t,isMuted:n,setVolume:r,toggleMute:o,setMuted:s}=_e();useEffect(()=>{let i=e.current;i&&(i.volume=t,i.muted=n);},[e,t,n]),useEffect(()=>{let i=e.current;if(!i)return;let l=()=>{i.volume!==t&&r(i.volume),i.muted!==n&&s(i.muted);};return i.addEventListener("volumechange",l),()=>i.removeEventListener("volumechange",l)},[e,t,n,r,s]);let a=useCallback(i=>{let l=Math.max(0,Math.min(1,i));r(l),e.current&&(e.current.volume=l),l>0&&n&&(s(false),e.current&&(e.current.muted=false));},[e,n,r,s]),d=useCallback(()=>{o(),e.current&&(e.current.muted=!n);},[e,n,o]),u=useCallback(()=>{n||(s(true),e.current&&(e.current.muted=true));},[e,n,s]),h=useCallback(()=>{n&&(s(false),e.current&&(e.current.muted=false));},[e,n,s]);return {volume:t,isMuted:n,setVolume:a,toggleMute:d,mute:u,unmute:h}}function vn(e,t={}){let{enableSmoothTracking:n=false}=t,[r,o]=useState(0),[s,a]=useState(0),[d,u]=useState(0),[h,i]=useState([]),l=useRef(null),p=useRef(false),f=s>0?r/s*100:0,y=useCallback(c=>{let v=[],P=c.buffered;for(let R=0;R<P.length;R++)v.push({start:P.start(R),end:P.end(R)});i(v);let x=0;for(let R of v)if(c.currentTime>=R.start&&c.currentTime<=R.end){x=R.end-c.currentTime;break}u(x);},[]),m=useCallback(()=>{l.current!==null&&(cancelAnimationFrame(l.current),l.current=null),p.current=false;},[]),b=useCallback(()=>{let c=e.current;if(!c||p.current)return;p.current=true;let v=()=>{if(!c||c.paused||c.ended){p.current=false,l.current=null;return}o(c.currentTime),l.current=requestAnimationFrame(v);};l.current=requestAnimationFrame(v);},[e]);useEffect(()=>{let c=e.current;if(!c)return;let v=()=>{o(c.currentTime);},P=()=>{a(c.duration||0);},x=()=>{a(c.duration||0);},R=()=>{y(c);},A=()=>{n&&b();},D=()=>{m();},z=()=>{m();},_=()=>{o(c.currentTime);},g=()=>{o(c.currentTime),y(c);};return c.addEventListener("timeupdate",v),c.addEventListener("loadedmetadata",P),c.addEventListener("durationchange",x),c.addEventListener("progress",R),c.addEventListener("play",A),c.addEventListener("pause",D),c.addEventListener("ended",z),c.addEventListener("seeking",_),c.addEventListener("seeked",g),c.readyState>=1&&(a(c.duration||0),o(c.currentTime)),c.readyState>=3&&y(c),!c.paused&&n&&b(),()=>{c.removeEventListener("timeupdate",v),c.removeEventListener("loadedmetadata",P),c.removeEventListener("durationchange",x),c.removeEventListener("progress",R),c.removeEventListener("play",A),c.removeEventListener("pause",D),c.removeEventListener("ended",z),c.removeEventListener("seeking",_),c.removeEventListener("seeked",g),m();}},[e,n,y,b,m]);let S=useCallback(c=>{let v=e.current;if(!v||!isFinite(v.duration))return;let P=Math.max(0,Math.min(c,v.duration));v.currentTime=P,o(P);},[e]),V=useCallback(c=>{let v=e.current;if(!v||!isFinite(v.duration))return;let x=Math.max(0,Math.min(100,c))/100*v.duration;v.currentTime=x,o(x);},[e]),H=s>0&&isFinite(s);return {currentTime:r,duration:s,buffered:d,progress:f,bufferedRanges:h,seek:S,seekToProgress:V,isSeekable:H,startSmoothTracking:b,stopSmoothTracking:m}}function bn(e){let{quality:t,setQuality:n}=_e(),[r,o]=useState(-1),[s,a]=useState([]);useEffect(()=>{if(!e)return;let i=e.getQualityLevels();a(i),o(e.getCurrentQuality());},[e]),useEffect(()=>{if(!(!e||s.length===0))if(t==="auto")e.setQuality(-1),o(-1);else {let i=parseInt(t.replace("p","")),l=s.findIndex(p=>p.height===i);l!==-1&&(e.setQuality(l),o(l));}},[e,t,s]);let d=r===-1,u=useCallback(i=>{if(e)if(typeof i=="number")if(e.setQuality(i),o(i),i===-1)n("auto");else {let l=s[i];l&&n(`${l.height}p`);}else n(i);},[e,s,n]),h=useCallback(()=>{u("auto");},[u]);return {quality:t,currentLevel:r,availableLevels:s,isAuto:d,setQuality:u,setAuto:h}}function Vt(e){return e<1e3?e.toString():e<1e4?`${(e/1e3).toFixed(1)}K`:e<1e6?`${Math.floor(e/1e3)}K`:`${(e/1e6).toFixed(1)}M`}var Vr={position:"absolute",right:spacing[4],bottom:160,display:"flex",flexDirection:"column",alignItems:"center",gap:components.actionBar.gap,zIndex:10},Ar={display:"flex",flexDirection:"column",alignItems:"center",gap:components.actionBar.iconCountGap,background:"none",border:"none",padding:0,cursor:"pointer"},Fr={width:components.actionBar.iconSize,height:components.actionBar.iconSize,display:"flex",alignItems:"center",justifyContent:"center"},Or={fontSize:fontSizes.xs,fontWeight:fontWeights.normal,color:colors.text,textShadow:shadows.text,lineHeight:components.actionBar.counterLineHeight,textAlign:"center"},Hr={display:"flex",flexDirection:"column",alignItems:"center",position:"relative",width:components.profileAction.avatarSize,height:55},Sn={width:components.profileAction.avatarSize,height:components.profileAction.avatarSize,borderRadius:"50%",objectFit:"cover",cursor:"pointer",background:colors.surface},Dr={position:"absolute",bottom:0,left:"50%",transform:"translateX(-50%)",width:components.profileAction.followButtonSize,height:components.profileAction.followButtonSize,borderRadius:"50%",backgroundColor:colors.like,border:"none",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center"},Br=({filled:e,color:t="white"})=>e?jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:components.actionBar.iconSize,height:components.actionBar.iconSize,viewBox:"0 0 28 28",fill:"none",children:jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M1.74988 11.0538C1.74988 6.75595 4.69822 2.91699 9.20877 2.91699C11.4347 2.91699 12.9986 3.9593 13.9999 4.96978C15.0011 3.95929 16.565 2.91699 18.791 2.91699C23.3015 2.91699 26.2499 6.75595 26.2499 11.0538C26.2499 15.3962 23.6265 18.9036 20.8781 21.3587C18.1288 23.8145 15.1442 25.3171 14.1843 25.6371L13.9999 25.6985L13.8154 25.6371C12.8555 25.3171 9.87093 23.8145 7.12168 21.3587C4.37329 18.9036 1.74988 15.3962 1.74988 11.0538ZM17.7449 6.41699C17.2617 6.41699 16.8699 6.80874 16.8699 7.29199C16.8699 7.77524 17.2617 8.16699 17.7449 8.16699C19.6221 8.16699 20.9952 9.75855 20.9952 11.8241C20.9952 12.3073 21.387 12.6991 21.8702 12.6991C22.3535 12.6991 22.7452 12.3073 22.7452 11.8241C22.7452 9.02543 20.8066 6.41699 17.7449 6.41699Z",fill:t})}):jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:components.actionBar.iconSize,height:components.actionBar.iconSize,viewBox:"0 0 24 24",fill:"none",children:[jsx("path",{d:"M15.21 5.5C14.7957 5.5 14.46 5.83579 14.46 6.25C14.46 6.66421 14.7957 7 15.21 7C16.819 7 17.996 8.3642 17.996 10.1346C17.996 10.5488 18.3317 10.8846 18.746 10.8846C19.1602 10.8846 19.496 10.5488 19.496 10.1346C19.496 7.7358 17.8342 5.5 15.21 5.5Z",fill:t}),jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M7.89327 2.25C3.85788 2.25 1.24994 5.6858 1.24994 9.47438C1.24994 13.301 3.5604 16.37 5.9378 18.4936C8.31629 20.6183 10.9036 21.9251 11.7628 22.2115L11.9999 22.2906L12.2371 22.2115C13.0963 21.9251 15.6836 20.6183 18.0621 18.4936C20.4395 16.37 22.7499 13.301 22.7499 9.47438C22.7499 5.6858 20.142 2.25 16.1066 2.25C14.2397 2.25 12.8941 3.06969 11.9999 3.91063C11.1058 3.06969 9.76018 2.25 7.89327 2.25ZM2.74994 9.47438C2.74994 6.3142 4.8731 3.75 7.89327 3.75C9.60588 3.75 10.7397 4.66987 11.4269 5.48383L11.9999 6.16259L12.573 5.48383C13.2602 4.66987 14.394 3.75 16.1066 3.75C19.1268 3.75 21.2499 6.3142 21.2499 9.47438C21.2499 12.6733 19.3104 15.3672 17.0628 17.375C15.0361 19.1854 12.8741 20.3336 11.9999 20.6978C11.1257 20.3336 8.96379 19.1854 6.93708 17.375C4.68948 15.3672 2.74994 12.6733 2.74994 9.47438Z",fill:t})]}),Nr=()=>jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:components.actionBar.iconSize,height:components.actionBar.iconSize,viewBox:"0 0 28 28",fill:"none",children:jsx("path",{d:"M14 1.45801C7.07347 1.45801 1.45837 7.0731 1.45837 13.9997C1.45837 16.3815 2.1232 18.6107 3.27778 20.5088L2.36541 23.0178C1.77294 24.6471 3.35258 26.2268 4.98188 25.6343L7.49089 24.7219C9.389 25.8765 11.6182 26.5413 14 26.5413C20.9266 26.5413 26.5417 20.9262 26.5417 13.9997C26.5417 7.0731 20.9266 1.45801 14 1.45801Z",fill:"white"})}),_r=({filled:e})=>jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:components.actionBar.iconSize,height:components.actionBar.iconSize,viewBox:"0 0 28 28",fill:"none",children:jsx("path",{d:"M16.6904 1.45801H11.2789C10.2487 1.458 9.4224 1.45799 8.75434 1.51253C8.06795 1.56857 7.47186 1.68652 6.92253 1.96632C6.90122 1.97718 6.88036 1.98891 6.86 2.00147C5.64436 2.75199 4.94533 3.52276 4.62739 4.64643C4.48015 5.1668 4.42512 5.72644 4.40084 6.3243C4.38332 6.75558 4.3811 7.24294 4.37866 7.77623C4.37775 7.97537 4.37678 8.18091 4.375 8.39232V24.8275C4.375 25.7739 5.14242 26.5413 6.08883 26.5413C6.51994 26.5413 6.93517 26.3792 7.25226 26.0859L13.3276 20.4783C13.3386 20.4682 13.3493 20.4578 13.3597 20.4471C13.5821 20.2197 13.743 20.0895 13.8601 20.0183C13.9156 19.9846 13.9524 19.9697 13.9731 19.9631C13.9833 19.9599 13.9898 19.9585 13.9933 19.958L13.9975 19.9575L13.9992 19.9574C13.9992 19.9574 14.0065 19.9571 14.0257 19.9632C14.0466 19.9698 14.0837 19.9849 14.1394 20.0187C14.2569 20.0901 14.4182 20.2206 14.641 20.4479C14.6512 20.4583 14.6616 20.4684 14.6724 20.4783L20.7477 26.0859C21.0648 26.3792 21.4801 26.5413 21.9112 26.5413C22.8576 26.5413 23.625 25.7739 23.625 24.8275V8.3619C23.625 7.33168 23.625 6.5054 23.5705 5.83735C23.5144 5.15096 23.3965 4.55487 23.1167 4.00554C23.1058 3.98416 23.094 3.96325 23.0814 3.94284C22.3309 2.72781 21.5599 2.0287 20.4364 1.71046C19.9159 1.56305 19.3562 1.50785 18.7583 1.48352C18.3245 1.46588 17.8344 1.46376 17.2978 1.46144C17.1014 1.46059 16.8988 1.45968 16.6904 1.45801Z",fill:e?colors.warning:"white"})}),Ur=()=>jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:28,height:28,viewBox:"0 0 28 28",fill:"none",children:[jsx("path",{d:"M20.6583 8.99195C21.1139 8.53634 21.1139 7.79765 20.6583 7.34203L14.8249 1.5087C14.6061 1.28991 14.3094 1.16699 14 1.16699C13.6905 1.16699 13.3938 1.28991 13.175 1.5087L7.34167 7.34204C6.88606 7.79765 6.88606 8.53634 7.34167 8.99195C7.79728 9.44756 8.53597 9.44756 8.99158 8.99195L12.8333 5.15024L12.8333 17.5003C12.8333 18.1447 13.3556 18.667 14 18.667C14.6443 18.667 15.1666 18.1447 15.1666 17.5003L15.1666 5.15024L19.0083 8.99195C19.4639 9.44756 20.2026 9.44756 20.6583 8.99195Z",fill:"white"}),jsx("path",{d:"M24.4562 22.2708C24.4991 21.7457 24.5 21.0663 24.5 20.067V16.3337C24.5 15.6893 25.0223 15.167 25.6666 15.167C26.311 15.167 26.8333 15.6893 26.8333 16.3337L26.8333 20.1152C26.8333 21.0543 26.8333 21.8294 26.7817 22.4608C26.7282 23.1166 26.6132 23.7194 26.3247 24.2856C25.8772 25.1637 25.1633 25.8776 24.2852 26.325C23.719 26.6135 23.1162 26.7285 22.4604 26.7821C21.829 26.8337 21.054 26.8337 20.1149 26.8337H7.88508C6.94599 26.8337 6.17087 26.8337 5.5395 26.7821C4.88372 26.7285 4.28089 26.6135 3.71467 26.325C2.83658 25.8776 2.12267 25.1637 1.67526 24.2856C1.38676 23.7194 1.27176 23.1166 1.21819 22.4608C1.1666 21.8294 1.16661 21.0543 1.16663 20.1152V16.3337C1.16663 15.6893 1.68896 15.167 2.33329 15.167C2.97762 15.167 3.49996 15.6893 3.49996 16.3337L3.49996 20.067C3.49996 21.0663 3.50087 21.7457 3.54377 22.2708C3.58556 22.7823 3.66131 23.0438 3.75428 23.2263C3.97798 23.6653 4.33494 24.0223 4.77398 24.246C4.95645 24.339 5.21802 24.4147 5.7295 24.4565C6.25461 24.4994 6.93395 24.5003 7.93329 24.5003H20.0666C21.066 24.5003 21.7453 24.4994 22.2704 24.4565C22.7819 24.4147 23.0435 24.339 23.2259 24.246C23.665 24.0223 24.0219 23.6653 24.2456 23.2263C24.3386 23.0438 24.4144 22.7823 24.4562 22.2708Z",fill:"white"})]}),Qr=()=>jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:12,height:12,viewBox:"0 0 12 12",fill:"white",children:jsx("path",{d:"M6 1V11M1 6H11",stroke:"white",strokeWidth:2,strokeLinecap:"round"})}),zr=()=>jsx("svg",{width:12,height:12,viewBox:"0 0 12 12",fill:"none",children:jsx("path",{d:"M2 6L5 9L10 3",stroke:"white",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"})});function Wr({avatarUrl:e,isFollowed:t=false,onClick:n,onFollow:r}){return jsxs("div",{style:Hr,children:[jsx(motion.button,{style:{background:"none",border:"none",padding:0,cursor:"pointer"},onClick:n,whileTap:{scale:.95},"aria-label":"View profile",children:e?jsx("img",{src:e,alt:"Profile",style:Sn}):jsx("div",{style:Sn})}),!t&&r&&jsx(motion.button,{style:Dr,onClick:o=>{o.stopPropagation(),r();},whileTap:{scale:.9},animate:t?{scale:[1,1.2,1]}:{scale:1},transition:{type:"spring",...springs.bouncy},"aria-label":t?"Following":"Follow",children:t?jsx(zr,{}):jsx(Qr,{})})]})}function ot({icon:e,count:t,isActive:n=false,onClick:r,label:o}){return jsxs(motion.button,{style:Ar,onClick:r,"aria-label":o,whileTap:{scale:.9},transition:{type:"spring",...springs.bouncy},children:[jsx(motion.div,{style:Fr,animate:n?{scale:[1,1.2,1]}:{scale:1},transition:n?{duration:.3,ease:[.32,.72,0,1]}:{type:"spring",...springs.default},children:e}),t!==void 0&&jsx("span",{style:Or,children:Vt(t)})]})}function at({likeCount:e,commentCount:t,shareCount:n,saveCount:r,isLiked:o=false,isSaved:s=false,onLike:a,onComment:d,onShare:u,onSave:h,avatarUrl:i,onProfileClick:l,onFollow:p,isFollowed:f=false,style:y,className:m=""}){return jsxs("div",{style:mergeStyles(Vr,y),className:m,children:[i&&jsx(Wr,{avatarUrl:i,isFollowed:f,onClick:l,onFollow:p}),jsx(ot,{icon:jsx(Br,{filled:o,color:o?colors.like:"white"}),count:e,isActive:o,onClick:a,label:o?"Unlike":"Like"}),jsx(ot,{icon:jsx(Nr,{}),count:t,onClick:d,label:"Comments"}),jsx(ot,{icon:jsx(_r,{filled:s}),count:r,isActive:s,onClick:h,label:s?"Unsave":"Save"}),jsx(ot,{icon:jsx(Ur,{}),count:n,onClick:u,label:"Share"})]})}var Kr={display:"inline-flex",alignItems:"center",justifyContent:"center",border:"none",cursor:"pointer",borderRadius:radii.full,transitionProperty:"background-color, transform, opacity",transitionDuration:durations.fast,transitionTimingFunction:easings.xhubReel,userSelect:"none"},jr={sm:{width:32,height:32},md:{width:components.tapArea,height:components.tapArea},lg:{width:56,height:56}},Zr={default:{backgroundColor:colors.surface,color:colors.text},ghost:{backgroundColor:"transparent",color:colors.text},glass:{backgroundColor:"rgba(0, 0, 0, 0.2)",backdropFilter:"blur(4px)",WebkitBackdropFilter:"blur(4px)",color:colors.text}},Jr={opacity:.5,cursor:"not-allowed",pointerEvents:"none"},Ft=forwardRef(({icon:e,size:t="md",variant:n="ghost",disabled:r,style:o,className:s="",...a},d)=>jsx("button",{ref:d,type:"button",disabled:r,style:mergeStyles(Kr,jr[t],Zr[n],r&&Jr,o),className:s,...a,children:e}));Ft.displayName="IconButton";var ai={position:"absolute",inset:0,display:"flex",alignItems:"center",justifyContent:"center",zIndex:zIndices.overlay},li={display:"flex",alignItems:"center",justifyContent:"center",backgroundColor:"rgba(0, 0, 0, 0.5)",borderRadius:"50%",backdropFilter:"blur(8px)",WebkitBackdropFilter:"blur(8px)",cursor:"pointer"},di=({size:e})=>jsx("svg",{width:e*.4,height:e*.4,viewBox:"0 0 24 24",fill:colors.text,children:jsx("polygon",{points:"5 3 19 12 5 21 5 3"})}),ui=({size:e})=>jsxs("svg",{width:e*.35,height:e*.35,viewBox:"0 0 24 24",fill:colors.text,children:[jsx("rect",{x:"6",y:"4",width:"4",height:"16"}),jsx("rect",{x:"14",y:"4",width:"4",height:"16"})]});function dt({isPlaying:e,show:t,onToggle:n,size:r=72,autoHideDelay:o=1e3,showOnStateChange:s=true,style:a,className:d=""}){let[u,h]=useState(false),[i,l]=useState(false),p=t!==void 0,f=p?t:u;useEffect(()=>{if(!(p||!s||!i)&&(h(true),o>0)){let S=setTimeout(()=>{h(false);},o);return ()=>clearTimeout(S)}},[e,p,s,o,i]);let y=useCallback(()=>{n&&(l(true),h(true),n());},[n]),m=!!n,b=m?"auto":"none";return jsx(AnimatePresence,{children:f&&jsx(motion.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.15},style:mergeStyles(ai,{pointerEvents:b},a),className:d,onClick:y,children:jsx(motion.div,{initial:{scale:.8,opacity:0},animate:{scale:1,opacity:1},exit:{scale:.8,opacity:0},transition:{type:"spring",...springs.default},whileTap:m?{scale:.9}:void 0,style:{...li,width:r,height:r,cursor:m?"pointer":"default"},children:e?jsx(ui,{size:r}):jsx(di,{size:r})})})})}var yi={position:"fixed",inset:0,backgroundColor:"rgba(0, 0, 0, 0.6)",zIndex:zIndices.modal},vi={position:"fixed",left:0,right:0,bottom:0,backgroundColor:colors.overlay,backdropFilter:"blur(20px)",WebkitBackdropFilter:"blur(20px)",borderTopLeftRadius:radii.xl,borderTopRightRadius:radii.xl,zIndex:zIndices.modal+1,display:"flex",flexDirection:"column",maxHeight:"90vh"},bi={width:components.bottomSheet.handleWidth,height:components.bottomSheet.handleHeight,backgroundColor:"rgba(255, 255, 255, 0.3)",borderRadius:2,margin:"12px auto 0",flexShrink:0},Si={display:"flex",alignItems:"center",justifyContent:"space-between",padding:`${spacing[4]}px ${spacing[4]}px ${spacing[3]}px`,flexShrink:0},wi={fontSize:18,fontWeight:600,color:colors.text},Pi={width:32,height:32,display:"flex",alignItems:"center",justifyContent:"center",background:"none",border:"none",cursor:"pointer",color:colors.textSecondary,borderRadius:"50%"},Ei={flex:1,overflow:"auto",WebkitOverflowScrolling:"touch"},Ci=()=>jsxs("svg",{width:20,height:20,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,children:[jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]});function Rn({isOpen:e,onClose:t,title:n,children:r,height:o="60vh",maxHeight:s="90vh",showClose:a=true,showHandle:d=true,style:u,className:h=""}){let i=useCallback(l=>{l.key==="Escape"&&t();},[t]);return useEffect(()=>(e&&(document.addEventListener("keydown",i),document.body.style.overflow="hidden"),()=>{document.removeEventListener("keydown",i),document.body.style.overflow="";}),[e,i]),jsx(AnimatePresence,{children:e&&jsxs(Fragment,{children:[jsx(motion.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},style:yi,onClick:t}),jsxs(motion.div,{initial:{y:"100%"},animate:{y:0},exit:{y:"100%"},transition:{type:"spring",...springs.default},drag:"y",dragConstraints:{top:0,bottom:0},dragElastic:{top:0,bottom:.5},onDragEnd:(l,p)=>{(p.offset.y>100||p.velocity.y>500)&&t();},style:mergeStyles(vi,{height:o,maxHeight:s,touchAction:"none"},u),className:h,children:[d&&jsx("div",{style:bi}),(n||a)&&jsxs("div",{style:Si,children:[jsx("span",{style:wi,children:n}),a&&jsx("button",{style:Pi,onClick:t,"aria-label":"Close",children:jsx(Ci,{})})]}),jsx("div",{style:Ei,children:r})]})]})})}function Mn({size:e=24,color:t=colors.text,thickness:n=2,style:r,className:o=""}){return jsxs(Fragment,{children:[jsx("style",{children:`
2
2
  @keyframes xhub-reel-spin {
3
3
  to { transform: rotate(360deg); }
4
4
  }
5
- `}),jsx("div",{role:"status","aria-label":"Loading",style:mergeStyles({width:e,height:e,borderWidth:n,borderStyle:"solid",borderColor:`${t}30`,borderTopColor:t,borderRadius:"50%",animation:"xhub-reel-spin 1s linear infinite"},r),className:o})]})}var Oi={position:"fixed",left:spacing[4],right:spacing[4],zIndex:zIndices.toast,display:"flex",justifyContent:"center",pointerEvents:"none"},Hi={display:"flex",alignItems:"center",gap:spacing[3],padding:`${spacing[3]}px ${spacing[4]}px`,backgroundColor:colors.surface,borderRadius:radii.lg,boxShadow:"0 4px 12px rgba(0, 0, 0, 0.5)",pointerEvents:"auto",maxWidth:400},Di={default:{},success:{borderLeft:`3px solid ${colors.success}`},error:{borderLeft:`3px solid ${colors.error}`},warning:{borderLeft:`3px solid ${colors.warning}`}},Bi={flex:1,fontSize:fontSizes.sm,color:colors.text,lineHeight:1.4},Ni={padding:`${spacing[1]}px ${spacing[3]}px`,backgroundColor:"transparent",border:"none",color:colors.accent,fontSize:fontSizes.sm,fontWeight:600,cursor:"pointer",borderRadius:radii.sm};function An({message:e,isVisible:t,onClose:n,duration:r=3e3,variant:o="default",action:s,position:d="bottom",style:u,className:l=""}){useEffect(()=>{if(t&&r>0){let i=setTimeout(n,r);return ()=>clearTimeout(i)}},[t,r,n]);let m=d==="top"?{top:spacing[4]}:{bottom:spacing[4]+80};return jsx(AnimatePresence,{children:t&&jsx("div",{style:{...Oi,...m},children:jsxs(motion.div,{initial:{opacity:0,y:d==="top"?-20:20,scale:.95},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:d==="top"?-20:20,scale:.95},transition:{type:"spring",...springs.default},style:mergeStyles(Hi,Di[o],u),className:l,children:[jsx("span",{style:Bi,children:e}),s&&jsx("button",{style:Ni,onClick:()=>{s.onClick(),n();},children:s.label})]})})})}var Wi={position:"absolute",pointerEvents:"none",zIndex:zIndices.overlay},Gi={filter:"drop-shadow(0 4px 8px rgba(255, 45, 85, 0.5))"};function ct(){let[e,t]=useState(false),[n,r]=useState({x:0,y:0}),o=useCallback((d,u)=>{let l=d??(typeof window<"u"?window.innerWidth/2:200),m=u??(typeof window<"u"?window.innerHeight/2:400);r({x:l,y:m}),t(true),setTimeout(()=>{t(false);},800);},[]),s=useCallback(()=>{t(false);},[]);return {isShowing:e,position:n,showHeart:o,hideHeart:s}}var $i=({size:e,color:t})=>jsx("svg",{style:Gi,xmlns:"http://www.w3.org/2000/svg",width:e,height:e,viewBox:"0 0 28 28",fill:t,children:jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M1.74988 11.0538C1.74988 6.75595 4.69822 2.91699 9.20877 2.91699C11.4347 2.91699 12.9986 3.9593 13.9999 4.96978C15.0011 3.95929 16.565 2.91699 18.791 2.91699C23.3015 2.91699 26.2499 6.75595 26.2499 11.0538C26.2499 15.3962 23.6265 18.9036 20.8781 21.3587C18.1288 23.8145 15.1442 25.3171 14.1843 25.6371L13.9999 25.6985L13.8154 25.6371C12.8555 25.3171 9.87093 23.8145 7.12168 21.3587C4.37329 18.9036 1.74988 15.3962 1.74988 11.0538ZM17.7449 6.41699C17.2617 6.41699 16.8699 6.80874 16.8699 7.29199C16.8699 7.77524 17.2617 8.16699 17.7449 8.16699C19.6221 8.16699 20.9952 9.75855 20.9952 11.8241C20.9952 12.3073 21.387 12.6991 21.8702 12.6991C22.3535 12.6991 22.7452 12.3073 22.7452 11.8241C22.7452 9.02543 20.8066 6.41699 17.7449 6.41699Z",fill:t})});function ht({show:e,position:t={x:0,y:0},size:n=100,color:r=colors.like,showParticles:o=true,particleCount:s=8,onComplete:d,style:u,className:l=""}){return jsx(AnimatePresence,{onExitComplete:d,children:e&&jsxs(motion.div,{initial:{opacity:0,scale:0},animate:{opacity:[0,1,1,0],scale:[0,1.3,1,.8],y:[0,-20,-20,-40]},exit:{scale:0,opacity:0},transition:{duration:.8,times:[0,.2,.6,1],ease:"easeOut"},style:{...Wi,left:t.x-n/2,top:t.y-n/2,width:n,height:n,...u},className:l,children:[jsx($i,{size:n,color:r}),o&&[...Array(s)].map((m,i)=>jsx(motion.div,{style:{position:"absolute",width:12,height:12,borderRadius:"50%",backgroundColor:r,left:n/2-6,top:n/2-6},initial:{opacity:1,scale:1},animate:{opacity:0,scale:.5,x:Math.cos(i*Math.PI*2/s)*60,y:Math.sin(i*Math.PI*2/s)*60},transition:{duration:.5,delay:.1,ease:"easeOut"}},i))]})})}function Dn(e){let[t,n]=useState(false),r=typeof document<"u"&&!!(document.fullscreenEnabled||document.webkitFullscreenElement!==void 0||document.mozFullScreenElement!==void 0||document.msFullscreenElement!==void 0),o=()=>{let i=document;return i.fullscreenElement||i.webkitFullscreenElement||i.mozFullScreenElement||i.msFullscreenElement||null},s=async i=>{let a=i;a.requestFullscreen?await a.requestFullscreen():a.webkitRequestFullscreen?await a.webkitRequestFullscreen():a.mozRequestFullScreen?await a.mozRequestFullScreen():a.msRequestFullscreen&&await a.msRequestFullscreen();},d=async()=>{let i=document;i.exitFullscreen?await i.exitFullscreen():i.webkitExitFullscreen?await i.webkitExitFullscreen():i.mozCancelFullScreen?await i.mozCancelFullScreen():i.msExitFullscreen&&await i.msExitFullscreen();};useEffect(()=>{let i=()=>{let a=o();n(a===e.current);};return document.addEventListener("fullscreenchange",i),document.addEventListener("webkitfullscreenchange",i),document.addEventListener("mozfullscreenchange",i),document.addEventListener("MSFullscreenChange",i),()=>{document.removeEventListener("fullscreenchange",i),document.removeEventListener("webkitfullscreenchange",i),document.removeEventListener("mozfullscreenchange",i),document.removeEventListener("MSFullscreenChange",i);}},[e]);let u=useCallback(async()=>{let i=e.current;if(!(!i||!r))try{await s(i),n(!0);let a=screen.orientation;if(a?.lock)try{await a.lock("landscape");}catch{}}catch(a){console.error("[useFullscreen] Failed to enter fullscreen:",a);}},[e,r]),l=useCallback(async()=>{if(r)try{await d(),n(!1);let i=screen.orientation;i?.unlock&&i.unlock();}catch(i){console.error("[useFullscreen] Failed to exit fullscreen:",i);}},[r]),m=useCallback(async()=>{t?await l():await u();},[t,u,l]);return {isFullscreen:t,isSupported:r,toggleFullscreen:m,enterFullscreen:u,exitFullscreen:l}}var Zi={feed:{autoQualitySwitch:true,pauseOnOffline:false,resumeOnOnline:false,lowQualityOn:"2g"},watch:{autoQualitySwitch:true,pauseOnOffline:false,resumeOnOnline:false,lowQualityOn:"2g"},auto:{autoQualitySwitch:true,pauseOnOffline:true,resumeOnOnline:true,lowQualityOn:"2g"},manual:{autoQualitySwitch:false,pauseOnOffline:false,resumeOnOnline:false}},Ji={aggressive:{autoPauseOnLowBattery:true,pauseThreshold:.2},moderate:{autoPauseOnLowBattery:true,pauseThreshold:.15},conservative:{autoPauseOnLowBattery:true,pauseThreshold:.1},manual:{autoPauseOnLowBattery:false}};function $e(e,t,n={}){let r=useRef(null),o=useRef(null),s=t??o,[d,u]=useState(false),l=mn(),m=gn(e),i=yn(e),a=vn(r.current),p=Dn(s),c=useRef(n);c.current=n;let{networkBehavior:g,powerBehavior:f}=n,S=useMemo(()=>{if(g)return typeof g=="string"?Zi[g]:g},[g]),b=useMemo(()=>{if(f)return typeof f=="string"?Ji[f]:f},[f]),V=useMemo(()=>({onStateChange:v=>{l.transition(v),c.current.onStateChange?.(v),v==="ready"&&!d&&(u(true),c.current.onReady?.());},onError:(v,N)=>{c.current.onError?.(v,N);},onTimeUpdate:(v,N)=>{c.current.onTimeUpdate?.(v,N);},onQualityLevelsLoaded:v=>{c.current.onQualityLevelsLoaded?.(v);},onNetworkChange:v=>{S?.onNetworkChange?.(v),c.current.onNetworkChange?.(v);},onPowerChange:v=>{b?.onPowerChange?.(v),c.current.onPowerChange?.(v);},onAnalyticsUpdate:v=>{c.current.onAnalyticsUpdate?.(v);}}),[l,d,S,b]);useEffect(()=>{let v=e.current;if(!v)return;let N=()=>c.current.onPlay?.(),X=()=>c.current.onPause?.(),$=()=>c.current.onEnded?.();return v.addEventListener("play",N),v.addEventListener("pause",X),v.addEventListener("ended",$),()=>{v.removeEventListener("play",N),v.removeEventListener("pause",X),v.removeEventListener("ended",$);}},[e]);let L=useCallback((v,N)=>{let X=e.current;if(!X){console.error("[usePlayer] No video element");return}u(false),r.current&&r.current.destroy(),r.current=new fn({preferNative:c.current.preferNative,enableSmoothTimeUpdates:c.current.enableSmoothTimeUpdates,enableNetworkAdaptation:c.current.enableNetworkAdaptation,enablePowerAdaptation:c.current.enablePowerAdaptation,enableAnalytics:c.current.enableAnalytics,preloadConfig:c.current.preloadConfig,callbacks:V,autoQualityOnNetworkChange:S?.autoQualitySwitch,autoPauseOnOffline:S?.pauseOnOffline,autoResumeOnOnline:S?.resumeOnOnline,lowQualityThreshold:S?.lowQualityOn,autoPauseOnLowBattery:b?.autoPauseOnLowBattery,lowBatteryThreshold:b?.pauseThreshold}),r.current.attach(X,v,N);},[e,V,S,b]),h=useCallback(()=>{r.current&&(r.current.destroy(),r.current=null),l.reset(),u(false);},[l]),y=useCallback(async()=>{await r.current?.play();},[]),P=useCallback(()=>{r.current?.pause();},[]),O=useCallback(async()=>{await r.current?.togglePlay();},[]),C=useCallback(v=>{r.current?.seek(v);},[]),B=useCallback((v=10)=>{r.current?.seekForward(v);},[]),z=useCallback((v=10)=>{r.current?.seekBackward(v);},[]),H=useCallback(v=>{r.current?.setPlaybackRate(v);},[]),A=useCallback(()=>{let v=e.current;v&&(v.currentTime=0,v.play().catch(()=>{}));},[e]);return {playerCore:r.current,videoRef:e,containerRef:s,state:l,isReady:d,play:y,pause:P,togglePlay:O,seek:C,seekForward:B,seekBackward:z,setPlaybackSpeed:H,restart:A,volume:m,progress:i,quality:a,fullscreen:p,attach:L,destroy:h}}var no={position:"relative",width:"100%",height:"100%",backgroundColor:colors.background},ro={width:"100%",height:"100%",objectFit:"contain"},_t=forwardRef(({video:e,autoPlay:t=true,muted:n=true,loop:r=true,poster:o,children:s,style:d,className:u="",onPlay:l,onPause:m,onEnded:i,onError:a,onStateChange:p,onTimeUpdate:c,onQualityLevelsLoaded:g,onReady:f},S)=>{let b=useRef(null),V=useRef(null),L=typeof e=="string"?e:e.url,h=o??(typeof e=="object"?e.thumbnail:void 0),y=$e(b,V,{onStateChange:p,onError:P=>a?.(P),onTimeUpdate:c,onQualityLevelsLoaded:g,onPlay:l,onPause:m,onEnded:i,onReady:f});return useEffect(()=>(L&&y.attach(L),()=>{y.destroy();}),[L]),useEffect(()=>{let P=b.current;P&&(P.muted=n,P.loop=r);},[n,r]),useEffect(()=>{let P=b.current;!P||!y.isReady||!t||P.play().catch(O=>{O.name==="NotAllowedError"&&(P.muted=true,P.play().catch(()=>{}));});},[t,y.isReady]),useImperativeHandle(S,()=>({play:y.play,pause:y.pause,togglePlay:y.togglePlay,seek:y.seek,seekForward:y.seekForward,seekBackward:y.seekBackward,restart:y.restart,setVolume:y.volume.setVolume,toggleMute:y.volume.toggleMute,setPlaybackSpeed:y.setPlaybackSpeed,setQuality:y.quality.setQuality,getQualityLevels:()=>y.quality.availableLevels,getVideoElement:()=>b.current,getCurrentTime:()=>y.progress.currentTime,getDuration:()=>y.progress.duration,isPaused:()=>b.current?.paused??true}),[y]),jsxs("div",{ref:V,style:Y(no,d),className:u,children:[jsx("video",{ref:b,poster:h,playsInline:true,preload:"auto",style:ro}),s]})});_t.displayName="VideoPlayer";var uo=30,co=1e3/uo,Z={container:{position:"absolute",bottom:0,left:0,right:0,zIndex:zIndices.sticky,touchAction:"none",userSelect:"none",WebkitUserSelect:"none",transition:"all 0.125s ease-in-out"},collapsed:{height:Ne.HEIGHT_DEFAULT,paddingInline:spacing[3],cursor:"pointer"},expanded:{padding:`${spacing[2]}px ${spacing[3]}px`,paddingBottom:`calc(${spacing[1]}px + env(safe-area-inset-bottom, 0px))`,background:"linear-gradient(to top, rgba(0,0,0,0.8) 0%, transparent 100%)"},timeContainer:{display:"flex",justifyContent:"center",alignItems:"center",marginBottom:spacing[2]},timeText:{fontSize:fontSizes.sm,fontWeight:fontWeights.semibold,color:colors.text,textShadow:shadows.text,fontVariantNumeric:"tabular-nums",backgroundColor:"rgba(0, 0, 0, 0.6)",padding:`${spacing[1]}px ${spacing[3]}px`,borderRadius:radii.md},track:{position:"relative",width:"100%",backgroundColor:"rgba(255, 255, 255, 0.2)",borderRadius:radii.full,overflow:"hidden"},trackCollapsed:{height:Ne.HEIGHT_DEFAULT},trackExpanded:{height:Ne.HEIGHT_ACTIVE},buffer:{position:"absolute",top:0,left:0,height:"100%",backgroundColor:"rgba(255, 255, 255, 0.3)",borderRadius:radii.full},progress:{position:"absolute",top:0,left:0,height:"100%",backgroundColor:colors.text,borderRadius:radii.full},scrubber:{position:"absolute",top:"50%",width:16,height:16,marginLeft:-8,marginTop:-8,backgroundColor:colors.text,borderRadius:radii.full,boxShadow:"0 2px 4px rgba(0,0,0,0.3)",transform:"scale(0)",transition:"transform 150ms ease"},scrubberVisible:{transform:"scale(1)"},touchArea:{position:"absolute",top:-12,left:0,right:0,bottom:-12,cursor:"pointer"}};function ye(e){if(!isFinite(e)||isNaN(e))return "0:00";let t=Math.floor(e/60),n=Math.floor(e%60);return `${t}:${n.toString().padStart(2,"0")}`}function ho(e){if(e.buffered.length===0)return 0;for(let t=0;t<e.buffered.length;t++)if(e.buffered.start(t)<=e.currentTime&&e.buffered.end(t)>=e.currentTime)return e.buffered.end(t);return e.buffered.end(e.buffered.length-1)}var pt=forwardRef(({videoRef:e,expanded:t=false,onSeekStart:n,onSeek:r,onSeekEnd:o,onExpandedChange:s,style:d,className:u=""},l)=>{let m=useRef(null),i=useRef(null),a=useRef(null),p=useRef(null),c=useRef(null),g=useRef(0),[f,S]=useState({currentTime:0,duration:0}),b=useRef(null),V=useRef(0),L=useRef(0),h=useRef(false),y=useRef(t);useEffect(()=>{y.current=t;},[t]);let P=useCallback(x=>{let w=e.current;if(!w||h.current)return;let k=w.duration||0,R=w.currentTime||0,D=ho(w),E=k>0?R/k*100:0,_=k>0?D/k*100:0;i.current&&(i.current.style.width=`${E}%`),a.current&&(a.current.style.width=`${_}%`),p.current&&y.current&&(p.current.style.left=`${E}%`),g.current=k,c.current&&(c.current.textContent=`${ye(R)} / ${ye(k)}`);let se=x??performance.now();se-L.current>=500&&(L.current=se,S(ge=>Math.abs(ge.currentTime-R)>=.5||ge.duration!==k?{currentTime:Math.floor(R),duration:Math.floor(k)}:ge));},[e]),O=useCallback(x=>{x-V.current>=co&&(V.current=x,P()),b.current=requestAnimationFrame(O);},[P]);useEffect(()=>(b.current=requestAnimationFrame(O),()=>{b.current&&cancelAnimationFrame(b.current);}),[O]);let C=useCallback(x=>{let w=m.current,k=e.current;if(!w||!k)return 0;let R=w.getBoundingClientRect(),D=x-R.left;return Math.max(0,Math.min(1,D/R.width))*(k.duration||0)},[e]),B=useCallback(x=>{h.current=true,n?.();let w=C(x);r?.(w);let k=e.current;if(k&&i.current){let R=k.duration||g.current||1,D=w/R*100;i.current.style.width=`${D}%`,p.current&&(p.current.style.left=`${D}%`),c.current&&(c.current.textContent=`${ye(w)} / ${ye(R)}`);}},[C,r,n,e]),z=useCallback(x=>{if(!h.current)return;let w=C(x);r?.(w);let k=e.current;if(k&&i.current){let R=k.duration||g.current||1,D=w/R*100;i.current.style.width=`${D}%`,p.current&&(p.current.style.left=`${D}%`),c.current&&(c.current.textContent=`${ye(w)} / ${ye(R)}`);}},[C,r,e]),H=useCallback(x=>{if(!h.current)return;h.current=false;let w=C(x);o?.(w);let k=e.current;k&&(k.currentTime=w);},[C,o,e]),A=useCallback(x=>{let w=x.touches[0];w&&B(w.clientX);},[B]),v=useCallback(x=>{let w=x.touches[0];w&&z(w.clientX);},[z]),N=useCallback(x=>{let w=x.changedTouches[0];w&&H(w.clientX);},[H]),X=useCallback(x=>{B(x.clientX);let w=R=>z(R.clientX),k=R=>{H(R.clientX),document.removeEventListener("mousemove",w),document.removeEventListener("mouseup",k);};document.addEventListener("mousemove",w),document.addEventListener("mouseup",k);},[B,z,H]),$=useCallback(()=>{t||s?.(true);},[t,s]),q=useCallback(x=>{let w=e.current;if(!w)return;let k=w.duration||0,R=w.currentTime||0,D=R;switch(x.key){case "ArrowLeft":D=Math.max(0,R-5);break;case "ArrowRight":D=Math.min(k,R+5);break;case "ArrowUp":D=Math.min(k,R+10);break;case "ArrowDown":D=Math.max(0,R-10);break;case "Home":D=0;break;case "End":D=k;break;default:return}x.preventDefault(),w.currentTime=D,r?.(D),P();},[e,r,P]);useImperativeHandle(l,()=>({update:P,setExpanded:x=>{s?.(x);}}));let K={...Z.container,...t?Z.expanded:Z.collapsed,...d},oe={...Z.track,...t?Z.trackExpanded:Z.trackCollapsed},J={...Z.scrubber,...t?Z.scrubberVisible:{}};return jsxs("div",{ref:m,style:K,className:u,onClick:t?void 0:$,onTouchStart:A,onTouchMove:v,onTouchEnd:N,onTouchCancel:N,onMouseDown:X,onKeyDown:q,role:"slider","aria-label":"Video progress","aria-valuemin":0,"aria-valuemax":f.duration,"aria-valuenow":f.currentTime,"aria-valuetext":`${ye(f.currentTime)} of ${ye(f.duration)}`,tabIndex:0,children:[t&&jsx("div",{style:Z.timeContainer,children:jsx("span",{ref:c,style:Z.timeText,children:"0:00 / 0:00"})}),jsxs("div",{style:oe,"aria-hidden":"true",children:[jsx("div",{style:Z.touchArea}),jsx("div",{ref:a,style:Z.buffer}),jsx("div",{ref:i,style:Z.progress}),t&&jsx("div",{ref:p,style:J})]})]})});pt.displayName="Timeline";var po={DOUBLE_TAP_DELAY:200},fo={THRESHOLD:500},qe={VERTICAL_THRESHOLD:.3,HORIZONTAL_THRESHOLD:.4,MIN_VELOCITY:.5},ft={THRESHOLD:10};var ve={TAP_DELAY:po.DOUBLE_TAP_DELAY,LONG_PRESS_THRESHOLD:fo.THRESHOLD,SWIPE_VERTICAL_THRESHOLD:qe.VERTICAL_THRESHOLD,SWIPE_HORIZONTAL_THRESHOLD:qe.HORIZONTAL_THRESHOLD,DRAG_THRESHOLD:ft.THRESHOLD};function Un(){return typeof navigator<"u"&&"vibrate"in navigator}function mt(){Un()&&navigator.vibrate(10);}function Qn(){Un()&&navigator.vibrate(20);}function zn(e,t){let n=e.currentTarget||e.target;if(!n||typeof n.getBoundingClientRect!="function")return "center";let r=n.getBoundingClientRect(),o=e.clientX-r.left,s=r.width;if(s===0)return "center";let d=s*.33,u=s*.67;return o<d?"left":o>u?"right":"center"}function gt(e){let t=useRef(0),n=useRef("center"),r=useRef(null),o=useRef(null),s=useRef(false),d=useRef(false),u=useRef({x:0,y:0}),l=useCallback(i=>{if(d.current){d.current=false;return}let a=zn(i),p=Date.now(),c=p-t.current,g={x:i.clientX,y:i.clientY};c<ve.TAP_DELAY&&n.current===a?(r.current&&(clearTimeout(r.current),r.current=null),mt(),e.onDoubleTap?.(a,g)):r.current=setTimeout(()=>{e.onSingleTap?.(a),r.current=null;},ve.TAP_DELAY),t.current=p,n.current=a;},[e]);return useGesture({onPointerDown:({event:i})=>{let a=i;u.current={x:a.clientX,y:a.clientY},d.current=false;let p=setTimeout(()=>{s.current=true,e.onHoldStart?.();},150);o.current=setTimeout(()=>{d.current=true,Qn();let g=a.target.getBoundingClientRect();e.onLongPress?.({x:a.clientX-g.left,y:a.clientY-g.top});},ve.LONG_PRESS_THRESHOLD),i.target.dataset.holdTimeout=String(p);},onPointerUp:({event:i})=>{let a=i.target.dataset.holdTimeout;a&&clearTimeout(Number(a)),o.current&&(clearTimeout(o.current),o.current=null),s.current&&(s.current=false,e.onHoldEnd?.());},onPointerMove:({event:i})=>{let a=i,p=Math.abs(a.clientX-u.current.x),c=Math.abs(a.clientY-u.current.y);(p>10||c>10)&&o.current&&(clearTimeout(o.current),o.current=null);},onClick:({event:i})=>{l(i);},onDrag:({movement:[i,a],direction:[p,c],velocity:[g,f],last:S,event:b})=>{if(b.preventDefault(),!S)return;let V=window.innerWidth,L=window.innerHeight;if(Math.abs(a)>L*ve.SWIPE_VERTICAL_THRESHOLD){c>0?e.onSwipeDown?.():e.onSwipeUp?.();return}if(Math.abs(i)>V*ve.SWIPE_HORIZONTAL_THRESHOLD){p>0?e.onSwipeRight?.():e.onSwipeLeft?.();return}Math.abs(i)>ve.DRAG_THRESHOLD&&Math.abs(g)>Math.abs(f)&&e.onSeekDrag?.(i);}},{drag:{threshold:ve.DRAG_THRESHOLD,filterTaps:true},eventOptions:{passive:false}})}var So=800,wo=.05,Po=.95;function Ut({onSwipeUp:e,onSwipeDown:t,onSwipeProgress:n,onSwipeCancel:r,threshold:o=qe.VERTICAL_THRESHOLD,velocityThreshold:s=qe.MIN_VELOCITY,hapticEnabled:d=true,disabled:u=false,enableProgressState:l=false}={}){let m=Math.max(wo,Math.min(Po,o)),[i,a]=useState({progress:0,direction:null,isSwiping:false}),p=useRef({onSwipeUp:e,onSwipeDown:t,onSwipeProgress:n,onSwipeCancel:r}),c=useRef(typeof window<"u"?window.innerHeight:So);return p.current={onSwipeUp:e,onSwipeDown:t,onSwipeProgress:n,onSwipeCancel:r},useEffect(()=>{let f=()=>{c.current=window.innerHeight;},S=()=>{setTimeout(()=>{c.current=window.innerHeight;},100);};return window.addEventListener("resize",f,{passive:true}),window.addEventListener("orientationchange",S,{passive:true}),()=>{window.removeEventListener("resize",f),window.removeEventListener("orientationchange",S);}},[]),{bind:useDrag(({movement:[,f],velocity:[,S],active:b,cancel:V})=>{if(u){V?.();return}let h=c.current*m,y=Math.min(1,Math.abs(f)/h),P=f<0?"up":"down";if(b)p.current.onSwipeProgress?.(y,P,f),l&&a({progress:y,direction:P,isSwiping:true});else {let O=Math.abs(f)>=h,C=Math.abs(S)>=s;O||C?(d&&mt(),P==="up"?p.current.onSwipeUp?.():p.current.onSwipeDown?.()):p.current.onSwipeCancel?.(),a({progress:0,direction:null,isSwiping:false});}},{axis:"y",threshold:ft.THRESHOLD,filterTaps:true,pointer:{touch:true},eventOptions:{passive:true}}),...i}}var Oe={container:{position:"relative",width:"100%",height:"100%",backgroundColor:colors.background},video:{position:"absolute",inset:0,width:"100%",height:"100%",objectFit:"cover"},placeholder:{position:"absolute",inset:0,backgroundSize:"cover",backgroundPosition:"center"},tapArea:{zIndex:zIndices.base},pauseOverlay:{zIndex:zIndices.overlay},pauseIconWrapper:{borderRadius:radii.full,transition:`opacity ${durations.normal}ms ${easings.xhubReel}, transform ${durations.normal}ms ${easings.xhubReel}`}};var Qt=createContext(null);function pe(){let e=useContext(Qt);if(!e)throw new Error("VideoFeedItem compound components must be used within a VideoFeedItem");return e}function Gn({elementRef:e,activateThreshold:t=Je.ACTIVATION_THRESHOLD,deactivateThreshold:n=Je.DEACTIVATION_THRESHOLD,rootMargin:r="0px",onVisibilityChange:o}){let[s,d]=useState(false),[u,l]=useState(false),[m,i]=useState(0),a=useRef(null);return useEffect(()=>{let p=e.current;if(!p)return;a.current&&a.current.disconnect();let c=[0,.1,.2,.3,.4,.5,.6,.7,.8,.9,1];return a.current=new IntersectionObserver(g=>{g.forEach(f=>{let S=f.intersectionRatio;i(S),d(S>0),S>=t?l(true):S<n&&l(false),o?.(S>0,S);});},{threshold:c,rootMargin:r}),a.current.observe(p),()=>{a.current?.disconnect();}},[e,t,n,r,o]),{isVisible:s,isActive:u,visibilityRatio:m}}function qn({containerRef:e,videoRef:t,isCurrentVideo:n=false,onActivate:r,onDeactivate:o,autoActivate:s=true,trackVisibility:d=false,onVisibilityChange:u}){let l=useRef(false),{isVisible:m,isActive:i,visibilityRatio:a}=Gn({elementRef:e??{current:null},onVisibilityChange:d?u:void 0}),p=d?i:n;useEffect(()=>{s&&(p&&!l.current?(l.current=true,r?.()):!p&&l.current&&(l.current=false,o?.()));},[p,r,o,s]);let c=useCallback(()=>{let f=t.current;f&&f.play().catch(()=>{f.muted=true,f.play().catch(()=>{});}),r?.();},[t,r]),g=useCallback(()=>{let f=t.current;f&&(f.pause(),f.currentTime=0),o?.();},[t,o]);return {isActive:p,isVisible:d?m:n,visibilityRatio:d?a:n?1:0,activate:c,deactivate:g}}var Wt=class{entries=new Map;listeners=new Set;memoryWarningThreshold;constructor(){this.memoryWarningThreshold=Re.MAX_TOTAL_MEMORY/(1024*1024),this.setupMemoryPressureListener();}register(t,n=10){this.entries.set(t,{videoId:t,inDom:false,hasDecodedFrames:false,estimatedSizeMB:n,lastAccessed:Date.now()}),this.notifyListeners();}unregister(t){this.entries.delete(t),this.notifyListeners();}setInDom(t,n){let r=this.entries.get(t);r&&(r.inDom=n,r.lastAccessed=Date.now(),this.notifyListeners());}setHasDecodedFrames(t,n){let r=this.entries.get(t);r&&(r.hasDecodedFrames=n,r.lastAccessed=Date.now(),this.notifyListeners());}getState(){let t=0,n=0,r=0;return this.entries.forEach(o=>{o.inDom&&t++,o.hasDecodedFrames&&n++,r+=o.estimatedSizeMB;}),{videosInDom:t,decodedVideos:n,estimatedMemoryMB:r,isLowMemory:r>this.memoryWarningThreshold}}getVideosToDispose(){let t=this.getState(),n=[],r=Re?.MAX_VIDEOS_IN_DOM,o=Re?.MAX_DECODED_FRAMES,s=Array.from(this.entries.values()).sort((d,u)=>d.lastAccessed-u.lastAccessed);if(t.videosInDom>r){let d=t.videosInDom-r,u=0;for(let l of s){if(u>=d)break;l.inDom&&(n.push(l.videoId),u++);}}if(t.decodedVideos>o){let d=t.decodedVideos-o,u=0;for(let l of s){if(u>=d)break;l.hasDecodedFrames&&!n.includes(l.videoId)&&(n.push(l.videoId),u++);}}return n}subscribe(t){return this.listeners.add(t),()=>this.listeners.delete(t)}forceCleanup(){let t=this.getVideosToDispose();return t.forEach(n=>this.unregister(n)),t}notifyListeners(){let t=this.getState();this.listeners.forEach(n=>n(t));}setupMemoryPressureListener(){typeof window>"u"||"memory"in performance&&setInterval(()=>{this.getState().isLowMemory&&(console.warn("[MemoryManager] Low memory warning, forcing cleanup"),this.forceCleanup());},5e3);}},be=new Wt;function jn({videoId:e,estimatedSizeMB:t=10,onShouldDispose:n}){let[r,o]=useState(()=>be.getState()),[s,d]=useState(false);useEffect(()=>(be.register(e,t),()=>{be.unregister(e);}),[e,t]),useEffect(()=>be.subscribe(i=>{o(i);let p=be.getVideosToDispose().includes(e);p&&!s?(d(true),n?.()):!p&&s&&d(false);}),[e,s,n]);let u=useCallback(m=>{be.setInDom(e,m);},[e]),l=useCallback(m=>{be.setHasDecodedFrames(e,m);},[e]);return {memoryState:r,setInDom:u,setHasDecodedFrames:l,shouldDispose:s}}function Jn({video:e,isActive:t,priority:n,onLike:r,onComment:o,onShare:s,onAuthorClick:d}){let u=useRef(null),l=useRef(null),m=useRef(false),[i,a]=useState(false),[p,c]=useState(false),[g,f]=useState(false),{isShowing:S,position:b,showHeart:V}=ct(),L=useMemo(()=>({maxConcurrent:2,maxBufferSize:10*1024*1024,priorityLevels:10}),[]),h=useCallback(E=>{},[]),y=useCallback(E=>{},[]),P=useCallback(E=>{E.startupTime&&E.startupTime>1e3&&console.warn("[VideoFeedItem] Slow startup:",E.startupTime,"ms",e.id);},[e.id]),{state:O}=$e(l,u,{preferNative:true,enableSmoothTimeUpdates:true,networkBehavior:"feed",powerBehavior:"moderate",preloadConfig:L,enableAnalytics:true,onPlay:()=>{a(false),c(false);},onPause:()=>{l.current?.seeking||(a(true),c(true));},onNetworkChange:h,onPowerChange:y,onAnalyticsUpdate:P}),C=useCallback(async()=>{let E=l.current;if(E){E.muted=true;try{await E.play();}catch(_){console.warn("[VideoFeedItem] Play failed:",_.message);}}},[]),B=useCallback(()=>{let E=l.current;E&&E.pause();},[]),z=useCallback(E=>{let _=l.current;_&&(_.currentTime=E);},[]),[H,A]=useState(false);useEffect(()=>{let E=l.current;if(!E)return;let _=()=>A(true),se=()=>A(false),ge=()=>A(false);return E.addEventListener("play",_),E.addEventListener("pause",se),E.addEventListener("ended",ge),A(!E.paused),()=>{E.removeEventListener("play",_),E.removeEventListener("pause",se),E.removeEventListener("ended",ge);}},[e.id]);let v=H||O.state==="playing",{setInDom:N,setHasDecodedFrames:X,shouldDispose:$}=jn({videoId:e.id,onShouldDispose:()=>{B(),l.current&&(l.current.src="",l.current.load());}}),q=!$&&n!=="none",K=useRef(false);qn({videoRef:l,isCurrentVideo:t,onActivate:()=>{console.log("[VideoFeedItem] onActivate called, videoRef:",l.current?.src),X(true),l.current?C():(console.log("[VideoFeedItem] Video element not ready, marking pending play"),K.current=true);},onDeactivate:()=>{console.log("[VideoFeedItem] onDeactivate called"),K.current=false,X(false),B(),z(0);},autoActivate:true}),useEffect(()=>{l.current&&K.current&&t&&(console.log("[VideoFeedItem] Video element now available, executing pending play"),K.current=false,C());}),useEffect(()=>(N(true),()=>N(false)),[N]),useEffect(()=>{let E=l.current;if(!E)return;f(false);let _=()=>{console.log("[VideoFeedItem] Video loadeddata:",e.id,{isActive:t,priority:n}),n==="high"&&!t?requestAnimationFrame(()=>{E.readyState>=2&&(E.currentTime=.01,f(true),console.log("[VideoFeedItem] First frame decoded (preloaded):",e.id));}):t&&f(true);},se=()=>{n==="high"&&!g&&f(true);};return E.addEventListener("loadeddata",_),E.addEventListener("canplay",se),E.readyState>=2&&_(),()=>{E.removeEventListener("loadeddata",_),E.removeEventListener("canplay",se);}},[e.id,t,n,g]),useEffect(()=>{console.log("[VideoFeedItem] State:",{videoId:e.id,isActive:t,priority:n,shouldRenderVideo:q,hasVideoElement:!!l.current,videoSrc:l.current?.src});},[e.id,t,n,q]);let oe=useMemo(()=>{switch(n){case "high":return "auto";case "medium":return "metadata";case "low":case "metadata":return "none";default:return "none"}},[n]),J=useCallback(()=>{m.current=v,c(true),a(false),B();},[v,B]),x=useCallback(E=>{z(E),m.current?(C(),c(false)):a(true);},[z,C]),w=useCallback(()=>{v?B():C();},[v,C,B]),k=useCallback((E,_)=>{V(_.x,_.y),r?.();},[V,r]),R=useCallback(()=>{},[]),D=gt({onSingleTap:w,onDoubleTap:k,onLongPress:R});return {video:e,isActive:t,shouldRenderVideo:q,preload:oe,isPreloaded:g,containerRef:u,videoRef:l,isPlaying:v,showPauseOverlay:i,timelineExpanded:p,play:C,pause:B,seek:z,setShowPauseOverlay:a,setTimelineExpanded:c,gestureBindings:D,showHeart:S,heartPosition:b,triggerHeart:V,onLike:r,onComment:o,onShare:s,onAuthorClick:d,handleSeekStart:J,handleSeekEnd:x}}var bt=forwardRef(({placeholder:e,...t},n)=>{let{video:r,videoRef:o,shouldRenderVideo:s,preload:d,isPreloaded:u}=pe();if(!s)return e??jsx("div",{...t,style:{...Oe.placeholder,backgroundImage:`url(${r.thumbnail})`,...t.style}});let l=!u;return jsx("video",{ref:m=>{typeof n=="function"?n(m):n&&(n.current=m),o.current=m;},src:r.url,poster:l?r.thumbnail:void 0,preload:d,loop:true,playsInline:true,muted:true,style:Oe.video})});bt.displayName="VideoFeedItemPlayer";var St=forwardRef(({onLike:e,onComment:t,onShare:n,...r},o)=>{let{video:s,onLike:d,onComment:u,onShare:l}=pe();return jsx("div",{ref:o,...r,children:jsx(st,{avatarUrl:s.author.avatar,likeCount:s.stats.likes,commentCount:s.stats.comments,shareCount:s.stats.shares,isLiked:s.isLiked,onLike:e??d,onComment:t??u,onShare:n??l})})});St.displayName="VideoFeedItemActions";var wt=forwardRef(({expanded:e,...t},n)=>{let{videoRef:r,shouldRenderVideo:o,timelineExpanded:s,setTimelineExpanded:d,handleSeekStart:u,handleSeekEnd:l}=pe();return o?jsx("div",{ref:n,...t,children:jsx(pt,{videoRef:r,expanded:e??s,onSeekStart:u,onSeekEnd:l,onExpandedChange:d})}):null});wt.displayName="VideoFeedItemTimeline";var He={container:{position:"absolute",bottom:0,left:0,right:64,padding:spacing[4],paddingBottom:"env(safe-area-inset-bottom, 16px)",zIndex:zIndices.base},containerWithTimeline:{paddingBottom:"calc(env(safe-area-inset-bottom, 16px) + 48px)"},authorButton:{gap:spacing[2],marginBottom:spacing[3]},avatar:{borderRadius:radii.full,border:`2px solid ${colors.text}`},username:{color:colors.text,fontWeight:fontWeights.semibold,fontSize:fontSizes.sm,textShadow:shadows.text},caption:{color:colors.text,fontSize:fontSizes.sm,lineHeight:1.4,textShadow:shadows.text,display:"-webkit-box",WebkitLineClamp:2,WebkitBoxOrient:"vertical",overflow:"hidden",paddingBottom:spacing[1]},author:{color:colors.text,fontSize:fontSizes.sm,fontWeight:fontWeights.semibold,textShadow:shadows.text,display:"-webkit-box",WebkitLineClamp:1,WebkitBoxOrient:"vertical",overflow:"hidden",paddingBottom:spacing[1]},hashtags:{display:"flex",flexWrap:"wrap",gap:spacing[1],marginTop:spacing[2],paddingBottom:spacing[1]},hashtag:{color:colors.accent,fontSize:fontSizes.sm,fontWeight:fontWeights.medium,textShadow:shadows.text}};function ir({video:e,timelineExpanded:t=false,style:n,className:r=""}){let o=Y(He.container,t&&He.containerWithTimeline,n);return jsxs("div",{style:o,className:r,children:[e.author&&jsx("p",{style:He.author,children:e.author.displayName}),e.caption&&jsx("p",{style:He.caption,children:e.caption}),e.hashtags&&e.hashtags.length>0&&jsx("div",{style:He.hashtags,children:e.hashtags.slice(0,3).map((s,d)=>jsxs("span",{style:He.hashtag,children:["#",s]},d))})]})}var Pt=forwardRef(({showPlayPause:e=true,showDoubleTapHeart:t=true,showVideoInfo:n=true,...r},o)=>{let{video:s,isPlaying:d,showPauseOverlay:u,timelineExpanded:l,showHeart:m,heartPosition:i,onAuthorClick:a}=pe();return jsxs("div",{ref:o,...r,children:[e&&jsx(lt,{isPlaying:d,show:u,size:64,autoHideDelay:800,showOnStateChange:false}),t&&jsx(ht,{show:m,position:i,size:100,showParticles:true,particleCount:8}),n&&jsx(ir,{video:s,onAuthorClick:a,timelineExpanded:l})]})});Pt.displayName="VideoFeedItemOverlay";var Be=forwardRef(({video:e,isActive:t=false,priority:n="none",showTimeline:r=true,onLike:o,onComment:s,onShare:d,onAuthorClick:u,style:l,className:m="",children:i},a)=>{let p=Jn({video:e,isActive:t,priority:n,onLike:o,onComment:s,onShare:d,onAuthorClick:u}),c=i??jsxs(Fragment,{children:[jsx(bt,{}),jsx(Pt,{}),jsx(St,{}),r&&jsx(wt,{})]});return jsx(Qt.Provider,{value:p,children:jsx("div",{ref:g=>{typeof a=="function"?a(g):a&&(a.current=g),p.containerRef.current=g;},style:Y(Oe.container,l),className:m,...p.gestureBindings(),children:c})})});Be.displayName="VideoFeedItem";function or(e,t){let n=e-t;return n===0||n===-1||n===1?"high":n===2?"medium":n===3?"low":Math.abs(n)<=5?"metadata":"none"}var Do="cubic-bezier(0.32, 0.72, 0, 1)",Bo=300,No=800,_o=50;function ar({trackRef:e,transitionDuration:t=Bo,easing:n=Do,onTransitionEnd:r}){let o=useRef(typeof window<"u"?window.innerHeight:No),s=useRef(0),d=useRef(null),u=useRef(false),l=useRef(true);useEffect(()=>{let c=()=>{o.current=window.innerHeight;},g=()=>{setTimeout(()=>{o.current=window.innerHeight;},100);};return window.addEventListener("resize",c,{passive:true}),window.addEventListener("orientationchange",g,{passive:true}),()=>{window.removeEventListener("resize",c),window.removeEventListener("orientationchange",g);}},[]);let m=useCallback(c=>{s.current=c,d.current!==null&&cancelAnimationFrame(d.current),d.current=requestAnimationFrame(()=>{let g=e.current;g&&(g.style.transition="none",g.style.transform=`translateY(${c}px)`),d.current=null;});},[e]),i=useCallback(c=>new Promise(g=>{let f=e.current;if(!f||!l.current){g();return}if(u.current){g();return}u.current=true,s.current=c;let S=null,b=null,V=L=>{L.propertyName==="transform"&&(S?.(),l.current&&(u.current=false,r?.()),g());};S=()=>{f.removeEventListener("transitionend",V),b&&(clearTimeout(b),b=null);},f.addEventListener("transitionend",V),b=setTimeout(()=>{S?.(),l.current&&u.current&&(u.current=false,r?.()),g();},t+_o),f.offsetHeight,f.style.transition=`transform ${t}ms ${n}`,f.style.transform=`translateY(${c}px)`;}),[e,t,n,r]),a=useCallback(()=>i(0),[i]),p=useCallback(()=>s.current,[]);return useEffect(()=>(l.current=true,()=>{l.current=false,d.current!==null&&(cancelAnimationFrame(d.current),d.current=null);}),[]),{setTranslateY:m,animateTo:i,snapBack:a,getCurrentY:p,viewportHeight:o.current,isAnimating:u.current}}var zo=300,Wo=50,Go=.3,$o="cubic-bezier(0.32, 0.72, 0, 1)",Se={container:{position:"fixed",inset:0,overflow:"hidden",backgroundColor:colors.background,touchAction:"none",userSelect:"none",WebkitUserSelect:"none"},track:{position:"relative",width:"100%",height:"100%",willChange:"transform"},slide:{position:"absolute",left:0,width:"100%",height:"100%",backfaceVisibility:"hidden",WebkitBackfaceVisibility:"hidden"},loadingIndicator:{position:"absolute",bottom:80,left:0,right:0,display:"flex",justifyContent:"center",zIndex:zIndices.base,pointerEvents:"none"},spinner:{width:24,height:24,borderWidth:2,borderStyle:"solid",borderColor:"rgba(255, 255, 255, 0.3)",borderTopColor:colors.text,borderRadius:radii.full,animation:"xhub-reel-spin 1s linear infinite"}},Ke=forwardRef(({videos:e,initialIndex:t=0,onLoadMore:n,onVideoChange:r,onLike:o,onComment:s,onShare:d,onAuthorClick:u,isLoading:l=false,hasMore:m=false,loadMoreThreshold:i=3,transitionDuration:a=zo,swipeThreshold:p=Wo,velocityThreshold:c=Go,gesturesDisabled:g=false,hapticEnabled:f=true,style:S,className:b=""},V)=>{let[L,h]=useState(()=>Math.min(Math.max(0,t),Math.max(0,e.length-1))),[y,P]=useState(false),[O,C]=useState(false),B=useRef(null),z=useRef(null),H=useRef(e),A=useRef(L),v=useRef(l),N=useRef(m),X=useRef(y),{setCurrentIndex:$}=Lt(),{setTranslateY:q,animateTo:K,snapBack:oe,viewportHeight:J}=ar({trackRef:z,transitionDuration:a,easing:$o});useEffect(()=>{H.current=e;},[e]),useEffect(()=>{A.current=L;},[L]),useEffect(()=>{v.current=l;},[l]),useEffect(()=>{N.current=m;},[m]),useEffect(()=>{X.current=y;},[y]),useEffect(()=>{if(e.length===0){h(0);return}if(L>=e.length){let I=e.length-1,U=e[I];h(I),$(I),U&&r?.(U,I);}},[e.length,L,$,r,e]);let x=useCallback(I=>or(I,L),[L]),w=useCallback(I=>{let U=H.current;N.current&&!v.current&&U.length-I<=i&&n?.();},[i,n]),k=useCallback(async(I,U=true)=>{if(X.current)return;let F=H.current,M=Math.max(0,Math.min(I,F.length-1)),ae=A.current;if(M===ae){q(0);return}let xe=M>ae?-1:1;if(U){P(true),C(true),await K(xe*J),h(M),$(M),q(0);let we=F[M];we&&r?.(we,M),w(M),C(false),P(false);}else {h(M),$(M),q(0);let we=F[M];we&&(r?.(we,M),w(M));}},[J,K,q,$,r,w]),R=useCallback((I=true)=>{let U=H.current,F=A.current;F<U.length-1&&k(F+1,I);},[k]),D=useCallback((I=true)=>{let U=A.current;U>0&&k(U-1,I);},[k]),E=useCallback((I,U,F)=>{let M=H.current,ae=A.current,xe=ae>0,we=ae<M.length-1,Xt=F;(U==="down"&&!xe||U==="up"&&!we)&&(Xt*=.3),q(Xt);},[q]),_=useCallback(async()=>{let I=H.current;if(!(A.current<I.length-1)){await oe();return}P(true),C(true),await K(-J);let M=A.current+1,ae=H.current;if(M<ae.length){h(M),$(M);let xe=ae[M];xe&&r?.(xe,M),w(M);}q(0),C(false),P(false);},[J,K,oe,q,$,r,w]),se=useCallback(async()=>{if(!(A.current>0)){await oe();return}P(true),C(true),await K(J);let F=A.current-1;if(F>=0){h(F),$(F);let M=H.current[F];M&&r?.(M,F);}q(0),C(false),P(false);},[J,K,oe,q,$,r]),ge=useCallback(async()=>{await oe();},[oe]),{bind:ur}=Ut({onSwipeUp:_,onSwipeDown:se,onSwipeProgress:E,onSwipeCancel:ge,threshold:p/J,velocityThreshold:c,hapticEnabled:f,disabled:g||y,enableProgressState:false});useImperativeHandle(V,()=>({slideTo:k,slideNext:R,slidePrev:D,get activeIndex(){return A.current},get totalSlides(){return H.current.length},get isBeginning(){return A.current===0},get isEnd(){return A.current===H.current.length-1}})),useEffect(()=>{let I=e[L];I&&r?.(I,L);},[]);let Ze=[];if(L>0&&Ze.push({index:L-1,position:-1}),Ze.push({index:L,position:0}),L<e.length-1&&Ze.push({index:L+1,position:1}),e.length===0)return jsx("div",{ref:B,style:Y(Se.container,S),className:b,"data-xhub-reel-feed":true,children:l&&jsx("div",{style:{...Se.loadingIndicator,top:"50%",bottom:"auto"},children:jsx("div",{style:Se.spinner})})});let cr={...Se.track};return jsxs("div",{ref:B,...ur(),style:Y(Se.container,S),className:b,"data-xhub-reel-feed":true,children:[jsx("style",{children:`
5
+ `}),jsx("div",{role:"status","aria-label":"Loading",style:mergeStyles({width:e,height:e,borderWidth:n,borderStyle:"solid",borderColor:`${t}30`,borderTopColor:t,borderRadius:"50%",animation:"xhub-reel-spin 1s linear infinite"},r),className:o})]})}var Hi={position:"fixed",left:spacing[4],right:spacing[4],zIndex:zIndices.toast,display:"flex",justifyContent:"center",pointerEvents:"none"},Di={display:"flex",alignItems:"center",gap:spacing[3],padding:`${spacing[3]}px ${spacing[4]}px`,backgroundColor:colors.surface,borderRadius:radii.lg,boxShadow:"0 4px 12px rgba(0, 0, 0, 0.5)",pointerEvents:"auto",maxWidth:400},Bi={default:{},success:{borderLeft:`3px solid ${colors.success}`},error:{borderLeft:`3px solid ${colors.error}`},warning:{borderLeft:`3px solid ${colors.warning}`}},Ni={flex:1,fontSize:fontSizes.sm,color:colors.text,lineHeight:1.4},_i={padding:`${spacing[1]}px ${spacing[3]}px`,backgroundColor:"transparent",border:"none",color:colors.accent,fontSize:fontSizes.sm,fontWeight:600,cursor:"pointer",borderRadius:radii.sm};function Fn({message:e,isVisible:t,onClose:n,duration:r=3e3,variant:o="default",action:s,position:a="bottom",style:d,className:u=""}){useEffect(()=>{if(t&&r>0){let i=setTimeout(n,r);return ()=>clearTimeout(i)}},[t,r,n]);let h=a==="top"?{top:spacing[4]}:{bottom:spacing[4]+80};return jsx(AnimatePresence,{children:t&&jsx("div",{style:{...Hi,...h},children:jsxs(motion.div,{initial:{opacity:0,y:a==="top"?-20:20,scale:.95},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:a==="top"?-20:20,scale:.95},transition:{type:"spring",...springs.default},style:mergeStyles(Di,Bi[o],d),className:u,children:[jsx("span",{style:Ni,children:e}),s&&jsx("button",{style:_i,onClick:()=>{s.onClick(),n();},children:s.label})]})})})}var Gi={position:"absolute",pointerEvents:"none",zIndex:zIndices.overlay},$i={filter:"drop-shadow(0 4px 8px rgba(255, 45, 85, 0.5))"};function ht(){let[e,t]=useState(false),[n,r]=useState({x:0,y:0}),o=useCallback((a,d)=>{let u=a??(typeof window<"u"?window.innerWidth/2:200),h=d??(typeof window<"u"?window.innerHeight/2:400);r({x:u,y:h}),t(true),setTimeout(()=>{t(false);},800);},[]),s=useCallback(()=>{t(false);},[]);return {isShowing:e,position:n,showHeart:o,hideHeart:s}}var qi=({size:e,color:t})=>jsx("svg",{style:$i,xmlns:"http://www.w3.org/2000/svg",width:e,height:e,viewBox:"0 0 28 28",fill:t,children:jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M1.74988 11.0538C1.74988 6.75595 4.69822 2.91699 9.20877 2.91699C11.4347 2.91699 12.9986 3.9593 13.9999 4.96978C15.0011 3.95929 16.565 2.91699 18.791 2.91699C23.3015 2.91699 26.2499 6.75595 26.2499 11.0538C26.2499 15.3962 23.6265 18.9036 20.8781 21.3587C18.1288 23.8145 15.1442 25.3171 14.1843 25.6371L13.9999 25.6985L13.8154 25.6371C12.8555 25.3171 9.87093 23.8145 7.12168 21.3587C4.37329 18.9036 1.74988 15.3962 1.74988 11.0538ZM17.7449 6.41699C17.2617 6.41699 16.8699 6.80874 16.8699 7.29199C16.8699 7.77524 17.2617 8.16699 17.7449 8.16699C19.6221 8.16699 20.9952 9.75855 20.9952 11.8241C20.9952 12.3073 21.387 12.6991 21.8702 12.6991C22.3535 12.6991 22.7452 12.3073 22.7452 11.8241C22.7452 9.02543 20.8066 6.41699 17.7449 6.41699Z",fill:t})});function pt({show:e,position:t={x:0,y:0},size:n=100,color:r=colors.like,showParticles:o=true,particleCount:s=8,onComplete:a,style:d,className:u=""}){return jsx(AnimatePresence,{onExitComplete:a,children:e&&jsxs(motion.div,{initial:{opacity:0,scale:0},animate:{opacity:[0,1,1,0],scale:[0,1.3,1,.8],y:[0,-20,-20,-40]},exit:{scale:0,opacity:0},transition:{duration:.8,times:[0,.2,.6,1],ease:"easeOut"},style:{...Gi,left:t.x-n/2,top:t.y-n/2,width:n,height:n,...d},className:u,children:[jsx(qi,{size:n,color:r}),o&&[...Array(s)].map((h,i)=>jsx(motion.div,{style:{position:"absolute",width:12,height:12,borderRadius:"50%",backgroundColor:r,left:n/2-6,top:n/2-6},initial:{opacity:1,scale:1},animate:{opacity:0,scale:.5,x:Math.cos(i*Math.PI*2/s)*60,y:Math.sin(i*Math.PI*2/s)*60},transition:{duration:.5,delay:.1,ease:"easeOut"}},i))]})})}function Bn(e){let[t,n]=useState(false),r=typeof document<"u"&&!!(document.fullscreenEnabled||document.webkitFullscreenElement!==void 0||document.mozFullScreenElement!==void 0||document.msFullscreenElement!==void 0),o=()=>{let i=document;return i.fullscreenElement||i.webkitFullscreenElement||i.mozFullScreenElement||i.msFullscreenElement||null},s=async i=>{let l=i;l.requestFullscreen?await l.requestFullscreen():l.webkitRequestFullscreen?await l.webkitRequestFullscreen():l.mozRequestFullScreen?await l.mozRequestFullScreen():l.msRequestFullscreen&&await l.msRequestFullscreen();},a=async()=>{let i=document;i.exitFullscreen?await i.exitFullscreen():i.webkitExitFullscreen?await i.webkitExitFullscreen():i.mozCancelFullScreen?await i.mozCancelFullScreen():i.msExitFullscreen&&await i.msExitFullscreen();};useEffect(()=>{let i=()=>{let l=o();n(l===e.current);};return document.addEventListener("fullscreenchange",i),document.addEventListener("webkitfullscreenchange",i),document.addEventListener("mozfullscreenchange",i),document.addEventListener("MSFullscreenChange",i),()=>{document.removeEventListener("fullscreenchange",i),document.removeEventListener("webkitfullscreenchange",i),document.removeEventListener("mozfullscreenchange",i),document.removeEventListener("MSFullscreenChange",i);}},[e]);let d=useCallback(async()=>{let i=e.current;if(!(!i||!r))try{await s(i),n(!0);let l=screen.orientation;if(l?.lock)try{await l.lock("landscape");}catch{}}catch(l){console.error("[useFullscreen] Failed to enter fullscreen:",l);}},[e,r]),u=useCallback(async()=>{if(r)try{await a(),n(!1);let i=screen.orientation;i?.unlock&&i.unlock();}catch(i){console.error("[useFullscreen] Failed to exit fullscreen:",i);}},[r]),h=useCallback(async()=>{t?await u():await d();},[t,d,u]);return {isFullscreen:t,isSupported:r,toggleFullscreen:h,enterFullscreen:d,exitFullscreen:u}}var Ji={feed:{autoQualitySwitch:true,pauseOnOffline:false,resumeOnOnline:false,lowQualityOn:"2g"},watch:{autoQualitySwitch:true,pauseOnOffline:false,resumeOnOnline:false,lowQualityOn:"2g"},auto:{autoQualitySwitch:true,pauseOnOffline:true,resumeOnOnline:true,lowQualityOn:"2g"},manual:{autoQualitySwitch:false,pauseOnOffline:false,resumeOnOnline:false}},eo={aggressive:{autoPauseOnLowBattery:true,pauseThreshold:.2},moderate:{autoPauseOnLowBattery:true,pauseThreshold:.15},conservative:{autoPauseOnLowBattery:true,pauseThreshold:.1},manual:{autoPauseOnLowBattery:false}};function $e(e,t,n={}){let r=useRef(null),o=useRef(null),s=t??o,[a,d]=useState(false),u=gn(),h=yn(e),i=vn(e),l=bn(r.current),p=Bn(s),f=useRef(n);f.current=n;let{networkBehavior:y,powerBehavior:m}=n,b=useMemo(()=>{if(y)return typeof y=="string"?Ji[y]:y},[y]),S=useMemo(()=>{if(m)return typeof m=="string"?eo[m]:m},[m]),V=useMemo(()=>({onStateChange:g=>{u.transition(g),f.current.onStateChange?.(g),g==="ready"&&!a&&(d(true),f.current.onReady?.());},onError:(g,B)=>{f.current.onError?.(g,B);},onTimeUpdate:(g,B)=>{f.current.onTimeUpdate?.(g,B);},onQualityLevelsLoaded:g=>{f.current.onQualityLevelsLoaded?.(g);},onNetworkChange:g=>{b?.onNetworkChange?.(g),f.current.onNetworkChange?.(g);},onPowerChange:g=>{S?.onPowerChange?.(g),f.current.onPowerChange?.(g);},onAnalyticsUpdate:g=>{f.current.onAnalyticsUpdate?.(g);}}),[u,a,b,S]);useEffect(()=>{let g=e.current;if(!g)return;let B=()=>f.current.onPlay?.(),q=()=>f.current.onPause?.(),oe=()=>f.current.onEnded?.();return g.addEventListener("play",B),g.addEventListener("pause",q),g.addEventListener("ended",oe),()=>{g.removeEventListener("play",B),g.removeEventListener("pause",q),g.removeEventListener("ended",oe);}},[e]);let H=useCallback((g,B)=>{let q=e.current;if(!q){console.error("[usePlayer] No video element");return}d(false),r.current&&r.current.destroy(),r.current=new mn({preferNative:f.current.preferNative,enableSmoothTimeUpdates:f.current.enableSmoothTimeUpdates,enableNetworkAdaptation:f.current.enableNetworkAdaptation,enablePowerAdaptation:f.current.enablePowerAdaptation,enableAnalytics:f.current.enableAnalytics,preloadConfig:f.current.preloadConfig,callbacks:V,autoQualityOnNetworkChange:b?.autoQualitySwitch,autoPauseOnOffline:b?.pauseOnOffline,autoResumeOnOnline:b?.resumeOnOnline,lowQualityThreshold:b?.lowQualityOn,autoPauseOnLowBattery:S?.autoPauseOnLowBattery,lowBatteryThreshold:S?.pauseThreshold}),r.current.attach(q,g,B);},[e,V,b,S]),c=useCallback(()=>{r.current&&(r.current.destroy(),r.current=null),u.reset(),d(false);},[u]),v=useCallback(async()=>{await r.current?.play();},[]),P=useCallback(()=>{r.current?.pause();},[]),x=useCallback(async()=>{await r.current?.togglePlay();},[]),R=useCallback(g=>{r.current?.seek(g);},[]),A=useCallback((g=10)=>{r.current?.seekForward(g);},[]),D=useCallback((g=10)=>{r.current?.seekBackward(g);},[]),z=useCallback(g=>{r.current?.setPlaybackRate(g);},[]),_=useCallback(()=>{let g=e.current;g&&(g.currentTime=0,g.play().catch(()=>{}));},[e]);return {playerCore:r.current,videoRef:e,containerRef:s,state:u,isReady:a,play:v,pause:P,togglePlay:x,seek:R,seekForward:A,seekBackward:D,setPlaybackSpeed:z,restart:_,volume:h,progress:i,quality:l,fullscreen:p,attach:H,destroy:c}}var ro={position:"relative",width:"100%",height:"100%",backgroundColor:colors.background},io={width:"100%",height:"100%",objectFit:"contain"},Ut=forwardRef(({video:e,autoPlay:t=true,muted:n=true,loop:r=true,poster:o,children:s,style:a,className:d="",onPlay:u,onPause:h,onEnded:i,onError:l,onStateChange:p,onTimeUpdate:f,onQualityLevelsLoaded:y,onReady:m},b)=>{let S=useRef(null),V=useRef(null),H=typeof e=="string"?e:e.url,c=o??(typeof e=="object"?e.thumbnail:void 0),v=$e(S,V,{onStateChange:p,onError:P=>l?.(P),onTimeUpdate:f,onQualityLevelsLoaded:y,onPlay:u,onPause:h,onEnded:i,onReady:m});return useEffect(()=>(H&&v.attach(H),()=>{v.destroy();}),[H]),useEffect(()=>{let P=S.current;P&&(P.muted=n,P.loop=r);},[n,r]),useEffect(()=>{let P=S.current;!P||!v.isReady||!t||P.play().catch(x=>{x.name==="NotAllowedError"&&(P.muted=true,P.play().catch(()=>{}));});},[t,v.isReady]),useImperativeHandle(b,()=>({play:v.play,pause:v.pause,togglePlay:v.togglePlay,seek:v.seek,seekForward:v.seekForward,seekBackward:v.seekBackward,restart:v.restart,setVolume:v.volume.setVolume,toggleMute:v.volume.toggleMute,setPlaybackSpeed:v.setPlaybackSpeed,setQuality:v.quality.setQuality,getQualityLevels:()=>v.quality.availableLevels,getVideoElement:()=>S.current,getCurrentTime:()=>v.progress.currentTime,getDuration:()=>v.progress.duration,isPaused:()=>S.current?.paused??true}),[v]),jsxs("div",{ref:V,style:Y(ro,a),className:d,children:[jsx("video",{ref:S,poster:c,playsInline:true,preload:"auto",style:io}),s]})});Ut.displayName="VideoPlayer";var co=30,ho=1e3/co,J={container:{position:"absolute",bottom:0,left:0,right:0,zIndex:zIndices.sticky,touchAction:"none",userSelect:"none",WebkitUserSelect:"none",transition:"all 0.125s ease-in-out"},collapsed:{height:Ne.HEIGHT_DEFAULT,paddingInline:spacing[3],cursor:"pointer"},expanded:{padding:`${spacing[2]}px ${spacing[3]}px`,paddingBottom:`calc(${spacing[1]}px + env(safe-area-inset-bottom, 0px))`,background:"linear-gradient(to top, rgba(0,0,0,0.8) 0%, transparent 100%)"},timeContainer:{display:"flex",justifyContent:"center",alignItems:"center",marginBottom:spacing[2]},timeText:{fontSize:fontSizes.sm,fontWeight:fontWeights.semibold,color:colors.text,textShadow:shadows.text,fontVariantNumeric:"tabular-nums",backgroundColor:"rgba(0, 0, 0, 0.6)",padding:`${spacing[1]}px ${spacing[3]}px`,borderRadius:radii.md},track:{position:"relative",width:"100%",backgroundColor:"rgba(255, 255, 255, 0.2)",borderRadius:radii.full,overflow:"hidden"},trackCollapsed:{height:Ne.HEIGHT_DEFAULT},trackExpanded:{height:Ne.HEIGHT_ACTIVE},buffer:{position:"absolute",top:0,left:0,height:"100%",backgroundColor:"rgba(255, 255, 255, 0.3)",borderRadius:radii.full},progress:{position:"absolute",top:0,left:0,height:"100%",backgroundColor:colors.text,borderRadius:radii.full},scrubber:{position:"absolute",top:"50%",width:16,height:16,marginLeft:-8,marginTop:-8,backgroundColor:colors.text,borderRadius:radii.full,boxShadow:"0 2px 4px rgba(0,0,0,0.3)",transform:"scale(0)",transition:"transform 150ms ease"},scrubberVisible:{transform:"scale(1)"},touchArea:{position:"absolute",top:-12,left:0,right:0,bottom:-12,cursor:"pointer"}};function ge(e){if(!isFinite(e)||isNaN(e))return "0:00";let t=Math.floor(e/60),n=Math.floor(e%60);return `${t}:${n.toString().padStart(2,"0")}`}function po(e){if(e.buffered.length===0)return 0;for(let t=0;t<e.buffered.length;t++)if(e.buffered.start(t)<=e.currentTime&&e.buffered.end(t)>=e.currentTime)return e.buffered.end(t);return e.buffered.end(e.buffered.length-1)}var ft=forwardRef(({videoRef:e,expanded:t=false,onSeekStart:n,onSeek:r,onSeekEnd:o,onExpandedChange:s,style:a,className:d=""},u)=>{let h=useRef(null),i=useRef(null),l=useRef(null),p=useRef(null),f=useRef(null),y=useRef(0),[m,b]=useState({currentTime:0,duration:0}),S=useRef(null),V=useRef(0),H=useRef(0),c=useRef(false),v=useRef(t);useEffect(()=>{v.current=t;},[t]);let P=useCallback(C=>{let E=e.current;if(!E||c.current)return;let k=E.duration||0,L=E.currentTime||0,O=po(E),Se=k>0?L/k*100:0,w=k>0?O/k*100:0;i.current&&(i.current.style.width=`${Se}%`),l.current&&(l.current.style.width=`${w}%`),p.current&&v.current&&(p.current.style.left=`${Se}%`),y.current=k,f.current&&(f.current.textContent=`${ge(L)} / ${ge(k)}`);let N=C??performance.now();N-H.current>=500&&(H.current=N,b(j=>Math.abs(j.currentTime-L)>=.5||j.duration!==k?{currentTime:Math.floor(L),duration:Math.floor(k)}:j));},[e]),x=useCallback(C=>{C-V.current>=ho&&(V.current=C,P()),S.current=requestAnimationFrame(x);},[P]);useEffect(()=>(S.current=requestAnimationFrame(x),()=>{S.current&&cancelAnimationFrame(S.current);}),[x]);let R=useCallback(C=>{let E=h.current,k=e.current;if(!E||!k)return 0;let L=E.getBoundingClientRect(),O=C-L.left;return Math.max(0,Math.min(1,O/L.width))*(k.duration||0)},[e]),A=useCallback(C=>{c.current=true,n?.();let E=R(C);r?.(E);let k=e.current;if(k&&i.current){let L=k.duration||y.current||1,O=E/L*100;i.current.style.width=`${O}%`,p.current&&(p.current.style.left=`${O}%`),f.current&&(f.current.textContent=`${ge(E)} / ${ge(L)}`);}},[R,r,n,e]),D=useCallback(C=>{if(!c.current)return;let E=R(C);r?.(E);let k=e.current;if(k&&i.current){let L=k.duration||y.current||1,O=E/L*100;i.current.style.width=`${O}%`,p.current&&(p.current.style.left=`${O}%`),f.current&&(f.current.textContent=`${ge(E)} / ${ge(L)}`);}},[R,r,e]),z=useCallback(C=>{if(!c.current)return;c.current=false;let E=R(C);o?.(E);let k=e.current;k&&(k.currentTime=E);},[R,o,e]),_=useCallback(C=>{let E=C.touches[0];E&&A(E.clientX);},[A]),g=useCallback(C=>{let E=C.touches[0];E&&D(E.clientX);},[D]),B=useCallback(C=>{let E=C.changedTouches[0];E&&z(E.clientX);},[z]),q=useCallback(C=>{A(C.clientX);let E=L=>D(L.clientX),k=L=>{z(L.clientX),document.removeEventListener("mousemove",E),document.removeEventListener("mouseup",k);};document.addEventListener("mousemove",E),document.addEventListener("mouseup",k);},[A,D,z]),oe=useCallback(()=>{t||s?.(true);},[t,s]),X=useCallback(C=>{let E=e.current;if(!E)return;let k=E.duration||0,L=E.currentTime||0,O=L;switch(C.key){case "ArrowLeft":O=Math.max(0,L-5);break;case "ArrowRight":O=Math.min(k,L+5);break;case "ArrowUp":O=Math.min(k,L+10);break;case "ArrowDown":O=Math.max(0,L-10);break;case "Home":O=0;break;case "End":O=k;break;default:return}C.preventDefault(),E.currentTime=O,r?.(O),P();},[e,r,P]);useImperativeHandle(u,()=>({update:P,setExpanded:C=>{s?.(C);}}));let $={...J.container,...t?J.expanded:J.collapsed,...a},K={...J.track,...t?J.trackExpanded:J.trackCollapsed},se={...J.scrubber,...t?J.scrubberVisible:{}};return jsxs("div",{ref:h,style:$,className:d,onClick:t?void 0:oe,onTouchStart:_,onTouchMove:g,onTouchEnd:B,onTouchCancel:B,onMouseDown:q,onKeyDown:X,role:"slider","aria-label":"Video progress","aria-valuemin":0,"aria-valuemax":m.duration,"aria-valuenow":m.currentTime,"aria-valuetext":`${ge(m.currentTime)} of ${ge(m.duration)}`,tabIndex:0,children:[t&&jsx("div",{style:J.timeContainer,children:jsx("span",{ref:f,style:J.timeText,children:"0:00 / 0:00"})}),jsxs("div",{style:K,"aria-hidden":"true",children:[jsx("div",{style:J.touchArea}),jsx("div",{ref:l,style:J.buffer}),jsx("div",{ref:i,style:J.progress}),t&&jsx("div",{ref:p,style:se})]})]})});ft.displayName="Timeline";var fo={DOUBLE_TAP_DELAY:200},mo={THRESHOLD:500},qe={VERTICAL_THRESHOLD:.3,HORIZONTAL_THRESHOLD:.4,MIN_VELOCITY:.5},mt={THRESHOLD:10};var ye={TAP_DELAY:fo.DOUBLE_TAP_DELAY,LONG_PRESS_THRESHOLD:mo.THRESHOLD,SWIPE_VERTICAL_THRESHOLD:qe.VERTICAL_THRESHOLD,SWIPE_HORIZONTAL_THRESHOLD:qe.HORIZONTAL_THRESHOLD,DRAG_THRESHOLD:mt.THRESHOLD};function Qn(){return typeof navigator<"u"&&"vibrate"in navigator}function gt(){Qn()&&navigator.vibrate(10);}function zn(){Qn()&&navigator.vibrate(20);}function Wn(e,t){let n=e.currentTarget||e.target;if(!n||typeof n.getBoundingClientRect!="function")return "center";let r=n.getBoundingClientRect(),o=e.clientX-r.left,s=r.width;if(s===0)return "center";let a=s*.33,d=s*.67;return o<a?"left":o>d?"right":"center"}function yt(e){let t=useRef(0),n=useRef("center"),r=useRef(null),o=useRef(null),s=useRef(false),a=useRef(false),d=useRef({x:0,y:0}),u=useCallback(i=>{if(a.current){a.current=false;return}let l=Wn(i),p=Date.now(),f=p-t.current,y={x:i.clientX,y:i.clientY};f<ye.TAP_DELAY&&n.current===l?(r.current&&(clearTimeout(r.current),r.current=null),gt(),e.onDoubleTap?.(l,y)):r.current=setTimeout(()=>{e.onSingleTap?.(l),r.current=null;},ye.TAP_DELAY),t.current=p,n.current=l;},[e]);return useGesture({onPointerDown:({event:i})=>{let l=i;d.current={x:l.clientX,y:l.clientY},a.current=false;let p=setTimeout(()=>{s.current=true,e.onHoldStart?.();},150);o.current=setTimeout(()=>{a.current=true,zn();let y=l.target.getBoundingClientRect();e.onLongPress?.({x:l.clientX-y.left,y:l.clientY-y.top});},ye.LONG_PRESS_THRESHOLD),i.target.dataset.holdTimeout=String(p);},onPointerUp:({event:i})=>{let l=i.target.dataset.holdTimeout;l&&clearTimeout(Number(l)),o.current&&(clearTimeout(o.current),o.current=null),s.current&&(s.current=false,e.onHoldEnd?.());},onPointerMove:({event:i})=>{let l=i,p=Math.abs(l.clientX-d.current.x),f=Math.abs(l.clientY-d.current.y);(p>10||f>10)&&o.current&&(clearTimeout(o.current),o.current=null);},onClick:({event:i})=>{u(i);},onDrag:({movement:[i,l],direction:[p,f],velocity:[y,m],last:b,event:S})=>{if(S.preventDefault(),!b)return;let V=window.innerWidth,H=window.innerHeight;if(Math.abs(l)>H*ye.SWIPE_VERTICAL_THRESHOLD){f>0?e.onSwipeDown?.():e.onSwipeUp?.();return}if(Math.abs(i)>V*ye.SWIPE_HORIZONTAL_THRESHOLD){p>0?e.onSwipeRight?.():e.onSwipeLeft?.();return}Math.abs(i)>ye.DRAG_THRESHOLD&&Math.abs(y)>Math.abs(m)&&e.onSeekDrag?.(i);}},{drag:{threshold:ye.DRAG_THRESHOLD,filterTaps:true},eventOptions:{passive:false}})}var wo=800,Po=.05,Eo=.95;function Qt({onSwipeUp:e,onSwipeDown:t,onSwipeProgress:n,onSwipeCancel:r,threshold:o=qe.VERTICAL_THRESHOLD,velocityThreshold:s=qe.MIN_VELOCITY,hapticEnabled:a=true,disabled:d=false,enableProgressState:u=false}={}){let h=Math.max(Po,Math.min(Eo,o)),[i,l]=useState({progress:0,direction:null,isSwiping:false}),p=useRef({onSwipeUp:e,onSwipeDown:t,onSwipeProgress:n,onSwipeCancel:r}),f=useRef(typeof window<"u"?window.innerHeight:wo);return p.current={onSwipeUp:e,onSwipeDown:t,onSwipeProgress:n,onSwipeCancel:r},useEffect(()=>{let m=()=>{f.current=window.innerHeight;},b=()=>{setTimeout(()=>{f.current=window.innerHeight;},100);};return window.addEventListener("resize",m,{passive:true}),window.addEventListener("orientationchange",b,{passive:true}),()=>{window.removeEventListener("resize",m),window.removeEventListener("orientationchange",b);}},[]),{bind:useDrag(({movement:[,m],velocity:[,b],active:S,cancel:V})=>{if(d){V?.();return}let c=f.current*h,v=Math.min(1,Math.abs(m)/c),P=m<0?"up":"down";if(S)p.current.onSwipeProgress?.(v,P,m),u&&l({progress:v,direction:P,isSwiping:true});else {let x=Math.abs(m)>=c,R=Math.abs(b)>=s;x||R?(a&&gt(),P==="up"?p.current.onSwipeUp?.():p.current.onSwipeDown?.()):p.current.onSwipeCancel?.(),l({progress:0,direction:null,isSwiping:false});}},{axis:"y",threshold:mt.THRESHOLD,filterTaps:true,pointer:{touch:true},eventOptions:{passive:true}}),...i}}var Oe={container:{position:"relative",width:"100%",height:"100%",backgroundColor:colors.background},video:{position:"absolute",inset:0,width:"100%",height:"100%",objectFit:"contain"},placeholder:{position:"absolute",inset:0,backgroundSize:"cover",backgroundPosition:"center"},tapArea:{zIndex:zIndices.base},pauseOverlay:{zIndex:zIndices.overlay},pauseIconWrapper:{borderRadius:radii.full,transition:`opacity ${durations.normal}ms ${easings.xhubReel}, transform ${durations.normal}ms ${easings.xhubReel}`}};var zt=createContext(null);function pe(){let e=useContext(zt);if(!e)throw new Error("VideoFeedItem compound components must be used within a VideoFeedItem");return e}function $n({elementRef:e,activateThreshold:t=et.ACTIVATION_THRESHOLD,deactivateThreshold:n=et.DEACTIVATION_THRESHOLD,rootMargin:r="0px",onVisibilityChange:o}){let[s,a]=useState(false),[d,u]=useState(false),[h,i]=useState(0),l=useRef(null);return useEffect(()=>{let p=e.current;if(!p)return;l.current&&l.current.disconnect();let f=[0,.1,.2,.3,.4,.5,.6,.7,.8,.9,1];return l.current=new IntersectionObserver(y=>{y.forEach(m=>{let b=m.intersectionRatio;i(b),a(b>0),b>=t?u(true):b<n&&u(false),o?.(b>0,b);});},{threshold:f,rootMargin:r}),l.current.observe(p),()=>{l.current?.disconnect();}},[e,t,n,r,o]),{isVisible:s,isActive:d,visibilityRatio:h}}function Yn({containerRef:e,videoRef:t,isCurrentVideo:n=false,onActivate:r,onDeactivate:o,autoActivate:s=true,trackVisibility:a=false,onVisibilityChange:d}){let u=useRef(false),{isVisible:h,isActive:i,visibilityRatio:l}=$n({elementRef:e??{current:null},onVisibilityChange:a?d:void 0}),p=a?i:n;useEffect(()=>{s&&(p&&!u.current?(u.current=true,r?.()):!p&&u.current&&(u.current=false,o?.()));},[p,r,o,s]);let f=useCallback(()=>{let m=t.current;m&&m.play().catch(()=>{m.muted=true,m.play().catch(()=>{});}),r?.();},[t,r]),y=useCallback(()=>{let m=t.current;m&&(m.pause(),m.currentTime=0),o?.();},[t,o]);return {isActive:p,isVisible:a?h:n,visibilityRatio:a?l:n?1:0,activate:f,deactivate:y}}var Gt=class{entries=new Map;listeners=new Set;memoryWarningThreshold;constructor(){this.memoryWarningThreshold=Re.MAX_TOTAL_MEMORY/(1024*1024),this.setupMemoryPressureListener();}register(t,n=10){this.entries.set(t,{videoId:t,inDom:false,hasDecodedFrames:false,estimatedSizeMB:n,lastAccessed:Date.now()}),this.notifyListeners();}unregister(t){this.entries.delete(t),this.notifyListeners();}setInDom(t,n){let r=this.entries.get(t);r&&(r.inDom=n,r.lastAccessed=Date.now(),this.notifyListeners());}setHasDecodedFrames(t,n){let r=this.entries.get(t);r&&(r.hasDecodedFrames=n,r.lastAccessed=Date.now(),this.notifyListeners());}getState(){let t=0,n=0,r=0;return this.entries.forEach(o=>{o.inDom&&t++,o.hasDecodedFrames&&n++,r+=o.estimatedSizeMB;}),{videosInDom:t,decodedVideos:n,estimatedMemoryMB:r,isLowMemory:r>this.memoryWarningThreshold}}getVideosToDispose(){let t=this.getState(),n=[],r=Re?.MAX_VIDEOS_IN_DOM,o=Re?.MAX_DECODED_FRAMES,s=Array.from(this.entries.values()).sort((a,d)=>a.lastAccessed-d.lastAccessed);if(t.videosInDom>r){let a=t.videosInDom-r,d=0;for(let u of s){if(d>=a)break;u.inDom&&(n.push(u.videoId),d++);}}if(t.decodedVideos>o){let a=t.decodedVideos-o,d=0;for(let u of s){if(d>=a)break;u.hasDecodedFrames&&!n.includes(u.videoId)&&(n.push(u.videoId),d++);}}return n}subscribe(t){return this.listeners.add(t),()=>this.listeners.delete(t)}forceCleanup(){let t=this.getVideosToDispose();return t.forEach(n=>this.unregister(n)),t}notifyListeners(){let t=this.getState();this.listeners.forEach(n=>n(t));}setupMemoryPressureListener(){typeof window>"u"||"memory"in performance&&setInterval(()=>{this.getState().isLowMemory&&(console.warn("[MemoryManager] Low memory warning, forcing cleanup"),this.forceCleanup());},5e3);}},ve=new Gt;function Zn({videoId:e,estimatedSizeMB:t=10,onShouldDispose:n}){let[r,o]=useState(()=>ve.getState()),[s,a]=useState(false);useEffect(()=>(ve.register(e,t),()=>{ve.unregister(e);}),[e,t]),useEffect(()=>ve.subscribe(i=>{o(i);let p=ve.getVideosToDispose().includes(e);p&&!s?(a(true),n?.()):!p&&s&&a(false);}),[e,s,n]);let d=useCallback(h=>{ve.setInDom(e,h);},[e]),u=useCallback(h=>{ve.setHasDecodedFrames(e,h);},[e]);return {memoryState:r,setInDom:d,setHasDecodedFrames:u,shouldDispose:s}}function er({video:e,isActive:t,priority:n,initialMuted:r=true,onLike:o,onComment:s,onShare:a,onAuthorClick:d}){let u=useRef(null),h=useRef(null),i=useRef(false),[l,p]=useState(false),[f,y]=useState(false),[m,b]=useState(false),{isShowing:S,position:V,showHeart:H}=ht(),c=useMemo(()=>({maxConcurrent:2,maxBufferSize:10*1024*1024,priorityLevels:10}),[]),v=useCallback(w=>{},[]),P=useCallback(w=>{},[]),x=useCallback(w=>{w.startupTime&&w.startupTime>1e3&&console.warn("[VideoFeedItem] Slow startup:",w.startupTime,"ms",e.id);},[e.id]),{state:R}=$e(h,u,{preferNative:true,enableSmoothTimeUpdates:true,networkBehavior:"feed",powerBehavior:"moderate",preloadConfig:c,enableAnalytics:true,onPlay:()=>{p(false),y(false);},onPause:()=>{h.current?.seeking||(p(true),y(true));},onNetworkChange:v,onPowerChange:P,onAnalyticsUpdate:x}),A=useCallback(async()=>{let w=h.current;if(w){w.muted=r;try{await w.play();}catch(N){if(N.name==="NotAllowedError"&&!r){console.warn("[VideoFeedItem] Autoplay blocked, falling back to muted"),w.muted=true;try{await w.play();}catch(j){console.warn("[VideoFeedItem] Play failed even muted:",j.message);}}else console.warn("[VideoFeedItem] Play failed:",N.message);}}},[r]),D=useCallback(()=>{let w=h.current;w&&w.pause();},[]),z=useCallback(w=>{let N=h.current;N&&(N.currentTime=w);},[]),[_,g]=useState(false);useEffect(()=>{let w=h.current;if(!w)return;let N=()=>g(true),j=()=>g(false),Ze=()=>g(false);return w.addEventListener("play",N),w.addEventListener("pause",j),w.addEventListener("ended",Ze),g(!w.paused),()=>{w.removeEventListener("play",N),w.removeEventListener("pause",j),w.removeEventListener("ended",Ze);}},[e.id]);let B=_||R.state==="playing",{setInDom:q,setHasDecodedFrames:oe,shouldDispose:X}=Zn({videoId:e.id,onShouldDispose:()=>{D(),h.current&&(h.current.src="",h.current.load());}}),$=!X&&n!=="none",K=useRef(false);Yn({videoRef:h,isCurrentVideo:t,onActivate:()=>{console.log("[VideoFeedItem] onActivate called, videoRef:",h.current?.src),oe(true),h.current?A():(console.log("[VideoFeedItem] Video element not ready, marking pending play"),K.current=true);},onDeactivate:()=>{console.log("[VideoFeedItem] onDeactivate called"),K.current=false,oe(false),D(),z(0);},autoActivate:true}),useEffect(()=>{h.current&&K.current&&t&&(console.log("[VideoFeedItem] Video element now available, executing pending play"),K.current=false,A());}),useEffect(()=>(q(true),()=>q(false)),[q]),useEffect(()=>{let w=h.current;if(!w)return;b(false);let N=()=>{console.log("[VideoFeedItem] Video loadeddata:",e.id,{isActive:t,priority:n}),n==="high"&&!t?requestAnimationFrame(()=>{w.readyState>=2&&(w.currentTime=.01,b(true),console.log("[VideoFeedItem] First frame decoded (preloaded):",e.id));}):t&&b(true);},j=()=>{n==="high"&&!m&&b(true);};return w.addEventListener("loadeddata",N),w.addEventListener("canplay",j),w.readyState>=2&&N(),()=>{w.removeEventListener("loadeddata",N),w.removeEventListener("canplay",j);}},[e.id,t,n,m]),useEffect(()=>{console.log("[VideoFeedItem] State:",{videoId:e.id,isActive:t,priority:n,shouldRenderVideo:$,hasVideoElement:!!h.current,videoSrc:h.current?.src});},[e.id,t,n,$]);let se=useMemo(()=>{switch(n){case "high":return "auto";case "medium":return "metadata";case "low":case "metadata":return "none";default:return "none"}},[n]),C=useCallback(()=>{i.current=B,y(true),p(false),D();},[B,D]),E=useCallback(w=>{z(w),i.current?(A(),y(false)):p(true);},[z,A]),k=useCallback(()=>{B?D():A();},[B,A,D]),L=useCallback((w,N)=>{H(N.x,N.y),o?.();},[H,o]),O=useCallback(()=>{},[]),Se=yt({onSingleTap:k,onDoubleTap:L,onLongPress:O});return {video:e,isActive:t,shouldRenderVideo:$,preload:se,isPreloaded:m,initialMuted:r,containerRef:u,videoRef:h,isPlaying:B,showPauseOverlay:l,timelineExpanded:f,play:A,pause:D,seek:z,setShowPauseOverlay:p,setTimelineExpanded:y,gestureBindings:Se,showHeart:S,heartPosition:V,triggerHeart:H,onLike:o,onComment:s,onShare:a,onAuthorClick:d,handleSeekStart:C,handleSeekEnd:E}}var St=forwardRef(({placeholder:e,...t},n)=>{let{video:r,videoRef:o,shouldRenderVideo:s,preload:a,isPreloaded:d,initialMuted:u}=pe();if(!s)return e??jsx("div",{...t,style:{...Oe.placeholder,backgroundImage:`url(${r.thumbnail})`,...t.style}});let h=!d;return jsx("video",{ref:i=>{typeof n=="function"?n(i):n&&(n.current=i),o.current=i;},src:r.url,poster:h?r.thumbnail:void 0,preload:a,loop:true,playsInline:true,muted:u,style:Oe.video})});St.displayName="VideoFeedItemPlayer";var wt=forwardRef(({onLike:e,onComment:t,onShare:n,...r},o)=>{let{video:s,onLike:a,onComment:d,onShare:u}=pe();return jsx("div",{ref:o,...r,children:jsx(at,{avatarUrl:s.author.avatar,likeCount:s.stats.likes,commentCount:s.stats.comments,shareCount:s.stats.shares,isLiked:s.isLiked,onLike:e??a,onComment:t??d,onShare:n??u})})});wt.displayName="VideoFeedItemActions";var Pt=forwardRef(({expanded:e,...t},n)=>{let{videoRef:r,shouldRenderVideo:o,timelineExpanded:s,setTimelineExpanded:a,handleSeekStart:d,handleSeekEnd:u}=pe();return o?jsx("div",{ref:n,...t,children:jsx(ft,{videoRef:r,expanded:e??s,onSeekStart:d,onSeekEnd:u,onExpandedChange:a})}):null});Pt.displayName="VideoFeedItemTimeline";var He={container:{position:"absolute",bottom:0,left:0,right:64,padding:spacing[4],paddingBottom:"env(safe-area-inset-bottom, 16px)",zIndex:zIndices.base},containerWithTimeline:{paddingBottom:"calc(env(safe-area-inset-bottom, 16px) + 48px)"},authorButton:{gap:spacing[2],marginBottom:spacing[3]},avatar:{borderRadius:radii.full,border:`2px solid ${colors.text}`},username:{color:colors.text,fontWeight:fontWeights.semibold,fontSize:fontSizes.sm,textShadow:shadows.text},caption:{color:colors.text,fontSize:fontSizes.sm,lineHeight:1.4,textShadow:shadows.text,display:"-webkit-box",WebkitLineClamp:2,WebkitBoxOrient:"vertical",overflow:"hidden",paddingBottom:spacing[1]},author:{color:colors.text,fontSize:fontSizes.sm,fontWeight:fontWeights.semibold,textShadow:shadows.text,display:"-webkit-box",WebkitLineClamp:1,WebkitBoxOrient:"vertical",overflow:"hidden",paddingBottom:spacing[1]},hashtags:{display:"flex",flexWrap:"wrap",gap:spacing[1],marginTop:spacing[2],paddingBottom:spacing[1]},hashtag:{color:colors.accent,fontSize:fontSizes.sm,fontWeight:fontWeights.medium,textShadow:shadows.text}};function or({video:e,timelineExpanded:t=false,style:n,className:r=""}){let o=Y(He.container,t&&He.containerWithTimeline,n);return jsxs("div",{style:o,className:r,children:[e.author&&jsx("p",{style:He.author,children:e.author.displayName}),e.caption&&jsx("p",{style:He.caption,children:e.caption}),e.hashtags&&e.hashtags.length>0&&jsx("div",{style:He.hashtags,children:e.hashtags.slice(0,3).map((s,a)=>jsxs("span",{style:He.hashtag,children:["#",s]},a))})]})}var Et=forwardRef(({showPlayPause:e=true,showDoubleTapHeart:t=true,showVideoInfo:n=true,...r},o)=>{let{video:s,isPlaying:a,showPauseOverlay:d,timelineExpanded:u,showHeart:h,heartPosition:i,onAuthorClick:l}=pe();return jsxs("div",{ref:o,...r,children:[e&&jsx(dt,{isPlaying:a,show:d,size:64,autoHideDelay:800,showOnStateChange:false}),t&&jsx(pt,{show:h,position:i,size:100,showParticles:true,particleCount:8}),n&&jsx(or,{video:s,onAuthorClick:l,timelineExpanded:u})]})});Et.displayName="VideoFeedItemOverlay";var Be=forwardRef(({video:e,isActive:t=false,priority:n="none",initialMuted:r=true,showTimeline:o=true,onLike:s,onComment:a,onShare:d,onAuthorClick:u,style:h,className:i="",children:l},p)=>{let f=er({video:e,isActive:t,priority:n,initialMuted:r,onLike:s,onComment:a,onShare:d,onAuthorClick:u}),y=l??jsxs(Fragment,{children:[jsx(St,{}),jsx(Et,{}),jsx(wt,{}),o&&jsx(Pt,{})]});return jsx(zt.Provider,{value:f,children:jsx("div",{ref:m=>{typeof p=="function"?p(m):p&&(p.current=m),f.containerRef.current=m;},style:Y(Oe.container,h),className:i,...f.gestureBindings(),children:y})})});Be.displayName="VideoFeedItem";function sr(e,t){let n=e-t;return n===0||n===-1||n===1?"high":n===2?"medium":n===3?"low":Math.abs(n)<=5?"metadata":"none"}var Bo="cubic-bezier(0.32, 0.72, 0, 1)",No=300,_o=800,Uo=50;function lr({trackRef:e,transitionDuration:t=No,easing:n=Bo,onTransitionEnd:r}){let o=useRef(typeof window<"u"?window.innerHeight:_o),s=useRef(0),a=useRef(null),d=useRef(false),u=useRef(true);useEffect(()=>{let f=()=>{o.current=window.innerHeight;},y=()=>{setTimeout(()=>{o.current=window.innerHeight;},100);};return window.addEventListener("resize",f,{passive:true}),window.addEventListener("orientationchange",y,{passive:true}),()=>{window.removeEventListener("resize",f),window.removeEventListener("orientationchange",y);}},[]);let h=useCallback(f=>{s.current=f,a.current!==null&&cancelAnimationFrame(a.current),a.current=requestAnimationFrame(()=>{let y=e.current;y&&(y.style.transition="none",y.style.transform=`translateY(${f}px)`),a.current=null;});},[e]),i=useCallback(f=>new Promise(y=>{let m=e.current;if(!m||!u.current){y();return}if(d.current){y();return}d.current=true,s.current=f;let b=null,S=null,V=H=>{H.propertyName==="transform"&&(b?.(),u.current&&(d.current=false,r?.()),y());};b=()=>{m.removeEventListener("transitionend",V),S&&(clearTimeout(S),S=null);},m.addEventListener("transitionend",V),S=setTimeout(()=>{b?.(),u.current&&d.current&&(d.current=false,r?.()),y();},t+Uo),m.offsetHeight,m.style.transition=`transform ${t}ms ${n}`,m.style.transform=`translateY(${f}px)`;}),[e,t,n,r]),l=useCallback(()=>i(0),[i]),p=useCallback(()=>s.current,[]);return useEffect(()=>(u.current=true,()=>{u.current=false,a.current!==null&&(cancelAnimationFrame(a.current),a.current=null);}),[]),{setTranslateY:h,animateTo:i,snapBack:l,getCurrentY:p,viewportHeight:o.current,isAnimating:d.current}}var Wo=300,Go=50,$o=.3,qo="cubic-bezier(0.32, 0.72, 0, 1)",be={container:{position:"fixed",inset:0,overflow:"hidden",backgroundColor:colors.background,touchAction:"none",userSelect:"none",WebkitUserSelect:"none"},track:{position:"relative",width:"100%",height:"100%",willChange:"transform"},slide:{position:"absolute",left:0,width:"100%",height:"100%",backfaceVisibility:"hidden",WebkitBackfaceVisibility:"hidden"},loadingIndicator:{position:"absolute",bottom:80,left:0,right:0,display:"flex",justifyContent:"center",zIndex:zIndices.base,pointerEvents:"none"},spinner:{width:24,height:24,borderWidth:2,borderStyle:"solid",borderColor:"rgba(255, 255, 255, 0.3)",borderTopColor:colors.text,borderRadius:radii.full,animation:"xhub-reel-spin 1s linear infinite"}},Ke=forwardRef(({videos:e,initialIndex:t=0,onLoadMore:n,onVideoChange:r,onLike:o,onComment:s,onShare:a,onAuthorClick:d,isLoading:u=false,hasMore:h=false,loadMoreThreshold:i=3,transitionDuration:l=Wo,swipeThreshold:p=Go,velocityThreshold:f=$o,gesturesDisabled:y=false,hapticEnabled:m=true,initialMuted:b=true,style:S,className:V=""},H)=>{let[c,v]=useState(()=>Math.min(Math.max(0,t),Math.max(0,e.length-1))),[P,x]=useState(false),[R,A]=useState(false),D=useRef(null),z=useRef(null),_=useRef(e),g=useRef(c),B=useRef(u),q=useRef(h),oe=useRef(P),{setCurrentIndex:X}=Tt(),{setTranslateY:$,animateTo:K,snapBack:se,viewportHeight:C}=lr({trackRef:z,transitionDuration:l,easing:qo});useEffect(()=>{_.current=e;},[e]),useEffect(()=>{g.current=c;},[c]),useEffect(()=>{B.current=u;},[u]),useEffect(()=>{q.current=h;},[h]),useEffect(()=>{oe.current=P;},[P]),useEffect(()=>{if(e.length===0){v(0);return}if(c>=e.length){let I=e.length-1,U=e[I];v(I),X(I),U&&r?.(U,I);}},[e.length,c,X,r,e]);let E=useCallback(I=>sr(I,c),[c]),k=useCallback(I=>{let U=_.current;q.current&&!B.current&&U.length-I<=i&&n?.();},[i,n]),L=useCallback(async(I,U=true)=>{if(oe.current)return;let F=_.current,M=Math.max(0,Math.min(I,F.length-1)),ae=g.current;if(M===ae){$(0);return}let xe=M>ae?-1:1;if(U){x(true),A(true),await K(xe*C),v(M),X(M),$(0);let we=F[M];we&&r?.(we,M),k(M),A(false),x(false);}else {v(M),X(M),$(0);let we=F[M];we&&(r?.(we,M),k(M));}},[C,K,$,X,r,k]),O=useCallback((I=true)=>{let U=_.current,F=g.current;F<U.length-1&&L(F+1,I);},[L]),Se=useCallback((I=true)=>{let U=g.current;U>0&&L(U-1,I);},[L]),w=useCallback((I,U,F)=>{let M=_.current,ae=g.current,xe=ae>0,we=ae<M.length-1,Kt=F;(U==="down"&&!xe||U==="up"&&!we)&&(Kt*=.3),$(Kt);},[$]),N=useCallback(async()=>{let I=_.current;if(!(g.current<I.length-1)){await se();return}x(true),A(true),await K(-C);let M=g.current+1,ae=_.current;if(M<ae.length){v(M),X(M);let xe=ae[M];xe&&r?.(xe,M),k(M);}$(0),A(false),x(false);},[C,K,se,$,X,r,k]),j=useCallback(async()=>{if(!(g.current>0)){await se();return}x(true),A(true),await K(C);let F=g.current-1;if(F>=0){v(F),X(F);let M=_.current[F];M&&r?.(M,F);}$(0),A(false),x(false);},[C,K,se,$,X,r]),Ze=useCallback(async()=>{await se();},[se]),{bind:cr}=Qt({onSwipeUp:N,onSwipeDown:j,onSwipeProgress:w,onSwipeCancel:Ze,threshold:p/C,velocityThreshold:f,hapticEnabled:m,disabled:y||P,enableProgressState:false});useImperativeHandle(H,()=>({slideTo:L,slideNext:O,slidePrev:Se,get activeIndex(){return g.current},get totalSlides(){return _.current.length},get isBeginning(){return g.current===0},get isEnd(){return g.current===_.current.length-1}})),useEffect(()=>{let I=e[c];I&&r?.(I,c);},[]);let Je=[];if(c>0&&Je.push({index:c-1,position:-1}),Je.push({index:c,position:0}),c<e.length-1&&Je.push({index:c+1,position:1}),e.length===0)return jsx("div",{ref:D,style:Y(be.container,S),className:V,"data-xhub-reel-feed":true,children:u&&jsx("div",{style:{...be.loadingIndicator,top:"50%",bottom:"auto"},children:jsx("div",{style:be.spinner})})});let hr={...be.track};return jsxs("div",{ref:D,...cr(),style:Y(be.container,S),className:V,"data-xhub-reel-feed":true,children:[jsx("style",{children:`
6
6
  @keyframes xhub-reel-spin {
7
7
  to { transform: rotate(360deg); }
8
8
  }
9
- `}),jsx("div",{ref:z,style:cr,children:Ze.map(({index:I,position:U})=>{let F=e[I];if(!F)return null;let M=x(I),ae=I===L&&!O;return jsx("div",{"data-index":I,style:{...Se.slide,top:U*J},children:jsx(Be,{video:F,isActive:ae,priority:M,onLike:()=>o?.(F),onComment:()=>s?.(F),onShare:()=>d?.(F),onAuthorClick:()=>u?.(F)})},F.id)})}),l&&jsx("div",{style:Se.loadingIndicator,children:jsx("div",{style:Se.spinner})})]})});Ke.displayName="VideoFeed";function Yt({videos:e,initialIndex:t=0,onLoadMore:n,hasMore:r=true,isLoading:o=false,onLike:s,onComment:d,onShare:u,onAuthorClick:l,onVideoChange:m,className:i=""}){let a=useRef(null),p=useCallback((b,V)=>{m?.(b,V);},[m]),c=useCallback(b=>{s?.(b);},[s]),g=useCallback(b=>{d?.(b);},[d]),f=useCallback(b=>{u?.(b);},[u]),S=useCallback(b=>{l?.(b);},[l]);return jsx("div",{className:`h-screen w-full overflow-hidden bg-black ${i}`,children:jsx(Ke,{ref:a,videos:e,initialIndex:t,onLoadMore:n,hasMore:r,isLoading:o,onVideoChange:p,onLike:c,onComment:g,onShare:f,onAuthorClick:S})})}function dr(e){let{container:t,...n}=e,r=typeof t=="string"?document.querySelector(t):t;if(!r||!(r instanceof HTMLElement))throw new Error("[XHubReelEmbed] Invalid container element");let o=createRoot(r),s=n,d=u=>{s=u,o.render(createElement(Yt,u));};return d(n),{updateVideos:u=>{d({...s,videos:u});},destroy:()=>{o.unmount();}}}typeof window<"u"&&(window.XHubReel=dr);export{st as ActionBar,xn as BottomSheet,At as IconButton,lt as PlayPauseOverlay,In as Spinner,An as Toast,Ke as VideoFeed,Be as VideoFeedItem,_t as VideoPlayer,Yt as XHubReelEmbed,dr as createXHubReelEmbed,gt as useVideoGestures};
9
+ `}),jsx("div",{ref:z,style:hr,children:Je.map(({index:I,position:U})=>{let F=e[I];if(!F)return null;let M=E(I),ae=I===c&&!R;return jsx("div",{"data-index":I,style:{...be.slide,top:U*C},children:jsx(Be,{video:F,isActive:ae,priority:M,initialMuted:b,onLike:()=>o?.(F),onComment:()=>s?.(F),onShare:()=>a?.(F),onAuthorClick:()=>d?.(F)})},F.id)})}),u&&jsx("div",{style:be.loadingIndicator,children:jsx("div",{style:be.spinner})})]})});Ke.displayName="VideoFeed";function Xt({videos:e,initialIndex:t=0,onLoadMore:n,hasMore:r=true,isLoading:o=false,onLike:s,onComment:a,onShare:d,onAuthorClick:u,onVideoChange:h,className:i=""}){let l=useRef(null),p=useCallback((S,V)=>{h?.(S,V);},[h]),f=useCallback(S=>{s?.(S);},[s]),y=useCallback(S=>{a?.(S);},[a]),m=useCallback(S=>{d?.(S);},[d]),b=useCallback(S=>{u?.(S);},[u]);return jsx("div",{className:`h-screen w-full overflow-hidden bg-black ${i}`,children:jsx(Ke,{ref:l,videos:e,initialIndex:t,onLoadMore:n,hasMore:r,isLoading:o,onVideoChange:p,onLike:f,onComment:y,onShare:m,onAuthorClick:b})})}function ur(e){let{container:t,...n}=e,r=typeof t=="string"?document.querySelector(t):t;if(!r||!(r instanceof HTMLElement))throw new Error("[XHubReelEmbed] Invalid container element");let o=createRoot(r),s=n,a=d=>{s=d,o.render(createElement(Xt,d));};return a(n),{updateVideos:d=>{a({...s,videos:d});},destroy:()=>{o.unmount();}}}typeof window<"u"&&(window.XHubReel=ur);export{at as ActionBar,Rn as BottomSheet,Ft as IconButton,dt as PlayPauseOverlay,Mn as Spinner,Fn as Toast,Ke as VideoFeed,Be as VideoFeedItem,Ut as VideoPlayer,Xt as XHubReelEmbed,ur as createXHubReelEmbed,yt as useVideoGestures};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xhub-reel/embed",
3
- "version": "0.2.0",
3
+ "version": "0.2.2",
4
4
  "description": "Embeddable widget for XHubReel",
5
5
  "license": "MIT",
6
6
  "author": "XHubReel Team",
@@ -37,11 +37,11 @@
37
37
  "dependencies": {
38
38
  "@xhub-reel/core": "0.2.0",
39
39
  "@xhub-reel/design-tokens": "0.0.2",
40
- "@xhub-reel/feed": "0.2.0",
41
40
  "@xhub-reel/gestures": "0.2.0",
42
- "@xhub-reel/player-engine": "0.0.2",
43
- "@xhub-reel/player": "0.2.0",
44
41
  "@xhub-reel/player-core": "0.0.3",
42
+ "@xhub-reel/player": "0.2.0",
43
+ "@xhub-reel/player-engine": "0.0.2",
44
+ "@xhub-reel/feed": "0.2.2",
45
45
  "@xhub-reel/types": "0.0.2",
46
46
  "@xhub-reel/ui": "0.2.0"
47
47
  },