@therealtinhtute/baroiplayer 1.1.0 → 1.2.0

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.
Files changed (78) hide show
  1. package/dist/core-plugins-By-4-kGs.cjs +2 -0
  2. package/dist/core-plugins-By-4-kGs.cjs.map +1 -0
  3. package/dist/{core-plugins-CROGvQUy.js → core-plugins-DSBWcTuX.js} +444 -309
  4. package/dist/core-plugins-DSBWcTuX.js.map +1 -0
  5. package/dist/core.js +2 -2
  6. package/dist/core.mjs +19 -19
  7. package/dist/{enhanced-components-DUw2KrmQ.js → enhanced-components-B_l3cist.js} +2 -2
  8. package/dist/{enhanced-components-DUw2KrmQ.js.map → enhanced-components-B_l3cist.js.map} +1 -1
  9. package/dist/{enhanced-components-DXBCHU0v.cjs → enhanced-components-BspFs9OO.cjs} +2 -2
  10. package/dist/{enhanced-components-DXBCHU0v.cjs.map → enhanced-components-BspFs9OO.cjs.map} +1 -1
  11. package/dist/hooks-BXwI8QG6.cjs +4 -0
  12. package/dist/hooks-BXwI8QG6.cjs.map +1 -0
  13. package/dist/hooks-Bpi-jDiO.js +1816 -0
  14. package/dist/hooks-Bpi-jDiO.js.map +1 -0
  15. package/dist/index.js +2 -2
  16. package/dist/index.js.map +1 -1
  17. package/dist/index.mjs +18 -20
  18. package/dist/index.mjs.map +1 -1
  19. package/dist/{minimal-components-DlRK7Qu_.js → minimal-components-C4z900Ro.js} +297 -298
  20. package/dist/minimal-components-C4z900Ro.js.map +1 -0
  21. package/dist/minimal-components-v4qBp6jv.cjs +2 -0
  22. package/dist/minimal-components-v4qBp6jv.cjs.map +1 -0
  23. package/package.json +1 -1
  24. package/src/components/accessibility/keyboard-help-overlay.tsx +2 -0
  25. package/src/components/enhanced/debug-panel.tsx +1 -1
  26. package/src/components/enhanced/enhanced-media-player.tsx +68 -25
  27. package/src/components/legacy.tsx +6 -6
  28. package/src/components/media-player-video.tsx +5 -12
  29. package/src/components/media-player.tsx +2 -2
  30. package/src/components/ui/enhanced-seek-bar.tsx +2 -2
  31. package/src/components/ui/media-resource-preloader.tsx +21 -23
  32. package/src/components/unified/base-media-player.tsx +22 -10
  33. package/src/components/variants/minimal/AccessibleMinimalPlayer.tsx +58 -38
  34. package/src/components/variants/minimal/EnhancedMinimalMediaPlayer.tsx +6 -6
  35. package/src/core/optimization/bundle-optimizer.tsx +26 -27
  36. package/src/core/plugins/__tests__/registry.test.ts +1 -1
  37. package/src/core/plugins/enhanced-plugin-system.ts +26 -8
  38. package/src/core/plugins/registry.ts +319 -92
  39. package/src/core/plugins/types.ts +21 -3
  40. package/src/core/providers/enhanced-hls-provider.ts +11 -40
  41. package/src/core/providers/lazy-provider.tsx +5 -42
  42. package/src/features/media-session/media-session-manager.ts +4 -26
  43. package/src/features/picture-in-picture/pip-manager.ts +2 -2
  44. package/src/features/playlist/playlist-manager.ts +26 -18
  45. package/src/features/subtitles/subtitle-manager.ts +1 -1
  46. package/src/features/subtitles/subtitle-parser.ts +19 -16
  47. package/src/features/thumbnails/thumbnail-generator.ts +12 -5
  48. package/src/hooks/__tests__/currentTime-fix.test.ts +149 -0
  49. package/src/hooks/accessibility/use-accessibility-preferences.ts +1 -1
  50. package/src/hooks/accessibility/use-focus-management.ts +2 -2
  51. package/src/hooks/accessibility/use-keyboard-shortcuts.ts +2 -2
  52. package/src/hooks/accessibility/use-screen-reader.ts +1 -1
  53. package/src/hooks/core/index.ts +1 -1
  54. package/src/hooks/use-buffer-health.ts +1 -1
  55. package/src/hooks/use-enhanced-media-player.ts +107 -9
  56. package/src/hooks/use-focus-trap.tsx +2 -2
  57. package/src/hooks/use-intelligent-preloading.ts +23 -3
  58. package/src/hooks/use-keyboard-shortcuts.ts +2 -2
  59. package/src/hooks/use-media-player.ts +74 -43
  60. package/src/hooks/use-memory-optimization.ts +15 -15
  61. package/src/hooks/use-smart-preload.ts +1 -2
  62. package/src/hooks/useKeyboardShortcuts.ts +34 -2
  63. package/src/hooks/useVideoPlayer.ts +50 -4
  64. package/src/index-legacy.ts +3 -5
  65. package/src/test/accessibility-utils.ts +7 -7
  66. package/src/test/media-mocks.ts +41 -28
  67. package/src/test/setup.ts +22 -4
  68. package/src/types/index.ts +13 -0
  69. package/dist/core-plugins-CROGvQUy.js.map +0 -1
  70. package/dist/core-plugins-DtsHBOtF.cjs +0 -2
  71. package/dist/core-plugins-DtsHBOtF.cjs.map +0 -1
  72. package/dist/hooks-BW-JjVgP.cjs +0 -4
  73. package/dist/hooks-BW-JjVgP.cjs.map +0 -1
  74. package/dist/hooks-CyX6De5M.js +0 -1693
  75. package/dist/hooks-CyX6De5M.js.map +0 -1
  76. package/dist/minimal-components-Bdcpxav5.cjs +0 -2
  77. package/dist/minimal-components-Bdcpxav5.cjs.map +0 -1
  78. package/dist/minimal-components-DlRK7Qu_.js.map +0 -1
@@ -1 +0,0 @@
1
- {"version":3,"file":"core-plugins-DtsHBOtF.cjs","sources":["../src/core/plugins/types.ts","../src/core/plugins/registry.ts","../src/core/plugins/base-plugin.ts","../src/core/plugins/examples/analytics-plugin.ts","../src/core/plugins/utils.ts","../src/core/plugins/index.ts"],"sourcesContent":["// TODO: Import proper types when integrated\nexport interface MediaState {\n\tisPlaying: boolean\n\tcurrentTime: number\n\tduration: number\n\tvolume: number\n\tisMuted: boolean\n}\n\nexport interface MediaPlayerControls {\n\tplay(): void\n\tpause(): void\n\tseek(time: number): void\n\tsetVolume(volume: number): void\n}\n\n// Plugin lifecycle phases\nexport type PluginPhase = \"initialize\" | \"activate\" | \"deactivate\" | \"destroy\"\n\n// Plugin categories for organization\nexport type PluginCategory =\n\t| \"controls\"\n\t| \"analytics\"\n\t| \"streaming\"\n\t| \"subtitle\"\n\t| \"quality\"\n\t| \"ui\"\n\t| \"accessibility\"\n\t| \"performance\"\n\n// Plugin priority for execution order\nexport type PluginPriority = \"high\" | \"medium\" | \"low\"\n\n// Plugin configuration interface\nexport interface PluginConfig {\n\t[key: string]: any\n}\n\n// Plugin context provided to each plugin\nexport interface PluginContext {\n\t// Core media player state and controls\n\tstate: MediaState\n\tcontrols: MediaPlayerControls\n\n\t// Plugin management\n\tplugins: PluginRegistry\n\n\t// Event system\n\temit: (event: string, data?: any) => void\n\ton: (event: string, handler: (data: any) => void) => () => void\n\n\t// Utilities\n\telement: HTMLElement | null\n\tlogger: PluginLogger\n}\n\n// Plugin metadata\nexport interface PluginMetadata {\n\tname: string\n\tversion: string\n\tdescription: string\n\tauthor?: string\n\tcategory: PluginCategory\n\tpriority: PluginPriority\n\tdependencies?: string[]\n\tconflicts?: string[]\n}\n\n// Plugin interface that all plugins must implement\nexport interface Plugin {\n\tmetadata: PluginMetadata\n\n\t// Plugin lifecycle methods\n\tinitialize(context: PluginContext, config?: PluginConfig): Promise<void> | void\n\tactivate(context: PluginContext): Promise<void> | void\n\tdeactivate(context: PluginContext): Promise<void> | void\n\tdestroy(context: PluginContext): Promise<void> | void\n\n\t// Configuration handling\n\tconfigure?(config: PluginConfig): Promise<void> | void\n\n\t// Health check for plugin status\n\thealthCheck?(): Promise<boolean> | boolean\n}\n\n// Plugin factory function type\nexport type PluginFactory<T extends Plugin = Plugin> = (config?: PluginConfig) => T\n\n// Plugin registry interface\nexport interface PluginRegistry {\n\tregister(factory: PluginFactory, config?: PluginConfig): Promise<void>\n\tunregister(name: string): Promise<void>\n\tget(name: string): Plugin | undefined\n\tgetAll(): Plugin[]\n\tisEnabled(name: string): boolean\n\tenable(name: string): Promise<void>\n\tdisable(name: string): Promise<void>\n\tconfigure(name: string, config: PluginConfig): Promise<void>\n}\n\n// Plugin logger interface\nexport interface PluginLogger {\n\tinfo(message: string, data?: any): void\n\twarn(message: string, data?: any): void\n\terror(message: string, data?: any): void\n\tdebug(message: string, data?: any): void\n}\n\n// Plugin event types\nexport interface PluginEvents {\n\t\"plugin:registered\": { name: string; plugin: Plugin }\n\t\"plugin:enabled\": { name: string; plugin: Plugin }\n\t\"plugin:disabled\": { name: string; plugin: Plugin }\n\t\"plugin:error\": { name: string; error: Error }\n\t\"plugin:configured\": { name: string; config: PluginConfig }\n}\n\n// Plugin error types\nexport class PluginError extends Error {\n\tconstructor(\n\t\tpublic pluginName: string,\n\t\tpublic phase: PluginPhase,\n\t\tmessage: string,\n\t\tpublic originalError?: Error\n\t) {\n\t\tsuper(`Plugin '${pluginName}' failed during ${phase}: ${message}`)\n\t\tthis.name = \"PluginError\"\n\t}\n}\n\n// Plugin dependency error\nexport class PluginDependencyError extends PluginError {\n\tconstructor(\n\t\tpluginName: string,\n\t\tpublic missingDependencies: string[]\n\t) {\n\t\tsuper(pluginName, \"initialize\", `Missing dependencies: ${missingDependencies.join(\", \")}`)\n\t\tthis.name = \"PluginDependencyError\"\n\t}\n}\n\n// Plugin conflict error\nexport class PluginConflictError extends PluginError {\n\tconstructor(\n\t\tpluginName: string,\n\t\tpublic conflictingPlugins: string[]\n\t) {\n\t\tsuper(pluginName, \"activate\", `Conflicts with active plugins: ${conflictingPlugins.join(\", \")}`)\n\t\tthis.name = \"PluginConflictError\"\n\t}\n}\n","import { EventBus } from \"../events/event-system\"\nimport type {\n\tPluginRegistry as IPluginRegistry,\n\tPlugin,\n\tPluginConfig,\n\tPluginContext,\n\tPluginEvents,\n\tPluginFactory,\n\tPluginLogger,\n\tPluginPriority\n} from \"./types\"\nimport { PluginConflictError, PluginDependencyError, PluginError } from \"./types\"\n\n// Plugin registry implementation\nexport class PluginRegistry implements IPluginRegistry {\n\tprivate plugins = new Map<string, Plugin>()\n\tprivate pluginConfigs = new Map<string, PluginConfig>()\n\tprivate enabledPlugins = new Set<string>()\n\tprivate eventBus = new EventBus()\n\tprivate logger: PluginLogger\n\n\tconstructor(logger: PluginLogger) {\n\t\tthis.logger = logger\n\t}\n\n\t// Register a plugin factory\n\tasync register(factory: PluginFactory, config: PluginConfig = {}): Promise<void> {\n\t\ttry {\n\t\t\tconst plugin = factory(config)\n\t\t\tconst { name, dependencies = [], conflicts = [] } = plugin.metadata\n\n\t\t\t// Check if plugin already exists\n\t\t\tif (this.plugins.has(name)) {\n\t\t\t\tthrow new PluginError(name, \"initialize\", \"Plugin already registered\")\n\t\t\t}\n\n\t\t\t// Validate dependencies\n\t\t\tconst missingDependencies = dependencies.filter((dep) => !this.plugins.has(dep))\n\t\t\tif (missingDependencies.length > 0) {\n\t\t\t\tthrow new PluginDependencyError(name, missingDependencies)\n\t\t\t}\n\n\t\t\t// Check for conflicts with enabled plugins\n\t\t\tconst activeConflicts = conflicts.filter((conflict) => this.enabledPlugins.has(conflict))\n\t\t\tif (activeConflicts.length > 0) {\n\t\t\t\tthrow new PluginConflictError(name, activeConflicts)\n\t\t\t}\n\n\t\t\t// Store plugin and configuration\n\t\t\tthis.plugins.set(name, plugin)\n\t\t\tthis.pluginConfigs.set(name, config)\n\n\t\t\tthis.logger.info(`Plugin '${name}' registered successfully`)\n\t\t\t;(this.eventBus as any).emit(\"plugin:registered\", { name, plugin })\n\t\t} catch (error) {\n\t\t\tconst pluginName = factory({}).metadata.name\n\t\t\tthis.logger.error(`Failed to register plugin '${pluginName}'`, error)\n\t\t\t;(this.eventBus as any).emit(\"plugin:error\", { name: pluginName, error: error as Error })\n\t\t\tthrow error\n\t\t}\n\t}\n\n\t// Unregister a plugin\n\tasync unregister(name: string): Promise<void> {\n\t\tconst plugin = this.plugins.get(name)\n\t\tif (!plugin) {\n\t\t\tthrow new PluginError(name, \"destroy\", \"Plugin not found\")\n\t\t}\n\n\t\ttry {\n\t\t\t// Disable plugin if enabled\n\t\t\tif (this.enabledPlugins.has(name)) {\n\t\t\t\tawait this.disable(name)\n\t\t\t}\n\n\t\t\t// Remove from registry\n\t\t\tthis.plugins.delete(name)\n\t\t\tthis.pluginConfigs.delete(name)\n\n\t\t\tthis.logger.info(`Plugin '${name}' unregistered successfully`)\n\t\t} catch (error) {\n\t\t\tthis.logger.error(`Failed to unregister plugin '${name}'`, error)\n\t\t\tthrow error\n\t\t}\n\t}\n\n\t// Get a plugin by name\n\tget(name: string): Plugin | undefined {\n\t\treturn this.plugins.get(name)\n\t}\n\n\t// Get all plugins sorted by priority\n\tgetAll(): Plugin[] {\n\t\treturn Array.from(this.plugins.values()).sort(this.sortByPriority)\n\t}\n\n\t// Check if plugin is enabled\n\tisEnabled(name: string): boolean {\n\t\treturn this.enabledPlugins.has(name)\n\t}\n\n\t// Enable a plugin\n\tasync enable(name: string): Promise<void> {\n\t\tconst plugin = this.plugins.get(name)\n\t\tif (!plugin) {\n\t\t\tthrow new PluginError(name, \"activate\", \"Plugin not found\")\n\t\t}\n\n\t\tif (this.enabledPlugins.has(name)) {\n\t\t\tthis.logger.warn(`Plugin '${name}' is already enabled`)\n\t\t\treturn\n\t\t}\n\n\t\ttry {\n\t\t\tconst context = this.createPluginContext(name)\n\t\t\tconst config = this.pluginConfigs.get(name)\n\n\t\t\t// Initialize plugin\n\t\t\tawait plugin.initialize(context, config)\n\n\t\t\t// Activate plugin\n\t\t\tawait plugin.activate(context)\n\n\t\t\tthis.enabledPlugins.add(name)\n\t\t\tthis.logger.info(`Plugin '${name}' enabled successfully`)\n\t\t\t;(this.eventBus as any).emit(\"plugin:enabled\", { name, plugin })\n\t\t} catch (error) {\n\t\t\tthis.logger.error(`Failed to enable plugin '${name}'`, error)\n\t\t\t;(this.eventBus as any).emit(\"plugin:error\", { name, error: error as Error })\n\t\t\tthrow error\n\t\t}\n\t}\n\n\t// Disable a plugin\n\tasync disable(name: string): Promise<void> {\n\t\tconst plugin = this.plugins.get(name)\n\t\tif (!plugin) {\n\t\t\tthrow new PluginError(name, \"deactivate\", \"Plugin not found\")\n\t\t}\n\n\t\tif (!this.enabledPlugins.has(name)) {\n\t\t\tthis.logger.warn(`Plugin '${name}' is already disabled`)\n\t\t\treturn\n\t\t}\n\n\t\ttry {\n\t\t\tconst context = this.createPluginContext(name)\n\n\t\t\t// Deactivate plugin\n\t\t\tawait plugin.deactivate(context)\n\n\t\t\t// Destroy plugin resources\n\t\t\tawait plugin.destroy(context)\n\n\t\t\tthis.enabledPlugins.delete(name)\n\t\t\tthis.logger.info(`Plugin '${name}' disabled successfully`)\n\t\t\t;(this.eventBus as any).emit(\"plugin:disabled\", { name, plugin })\n\t\t} catch (error) {\n\t\t\tthis.logger.error(`Failed to disable plugin '${name}'`, error)\n\t\t\t;(this.eventBus as any).emit(\"plugin:error\", { name, error: error as Error })\n\t\t\tthrow error\n\t\t}\n\t}\n\n\t// Configure a plugin\n\tasync configure(name: string, config: PluginConfig): Promise<void> {\n\t\tconst plugin = this.plugins.get(name)\n\t\tif (!plugin) {\n\t\t\tthrow new PluginError(name, \"initialize\", \"Plugin not found\")\n\t\t}\n\n\t\ttry {\n\t\t\t// Update stored configuration\n\t\t\tthis.pluginConfigs.set(name, { ...this.pluginConfigs.get(name), ...config })\n\n\t\t\t// If plugin has configure method, call it\n\t\t\tif (plugin.configure) {\n\t\t\t\tawait plugin.configure(config)\n\t\t\t}\n\n\t\t\tthis.logger.info(`Plugin '${name}' configured successfully`)\n\t\t\t;(this.eventBus as any).emit(\"plugin:configured\", { name, config })\n\t\t} catch (error) {\n\t\t\tthis.logger.error(`Failed to configure plugin '${name}'`, error)\n\t\t\t;(this.eventBus as any).emit(\"plugin:error\", { name, error: error as Error })\n\t\t\tthrow error\n\t\t}\n\t}\n\n\t// Enable multiple plugins with dependency resolution\n\tasync enablePlugins(names: string[]): Promise<void> {\n\t\tconst resolved = this.resolveDependencies(names)\n\n\t\tfor (const name of resolved) {\n\t\t\tif (!this.enabledPlugins.has(name)) {\n\t\t\t\tawait this.enable(name)\n\t\t\t}\n\t\t}\n\t}\n\n\t// Disable multiple plugins\n\tasync disablePlugins(names: string[]): Promise<void> {\n\t\t// Disable in reverse order to handle dependencies\n\t\tconst reversed = [...names].reverse()\n\n\t\tfor (const name of reversed) {\n\t\t\tif (this.enabledPlugins.has(name)) {\n\t\t\t\tawait this.disable(name)\n\t\t\t}\n\t\t}\n\t}\n\n\t// Get enabled plugins\n\tgetEnabledPlugins(): Plugin[] {\n\t\treturn Array.from(this.enabledPlugins)\n\t\t\t.map((name) => this.plugins.get(name)!)\n\t\t\t.filter(Boolean)\n\t\t\t.sort(this.sortByPriority)\n\t}\n\n\t// Health check for all enabled plugins\n\tasync healthCheck(): Promise<{ name: string; healthy: boolean; error?: Error }[]> {\n\t\tconst results = []\n\n\t\tfor (const name of this.enabledPlugins) {\n\t\t\tconst plugin = this.plugins.get(name)!\n\t\t\ttry {\n\t\t\t\tconst healthy = plugin.healthCheck ? await plugin.healthCheck() : true\n\t\t\t\tresults.push({ name, healthy })\n\t\t\t} catch (error) {\n\t\t\t\tresults.push({ name, healthy: false, error: error as Error })\n\t\t\t}\n\t\t}\n\n\t\treturn results\n\t}\n\n\t// Event handling\n\ton<K extends keyof PluginEvents>(\n\t\tevent: K,\n\t\tlistener: (data: PluginEvents[K]) => void\n\t): () => void {\n\t\t;(this.eventBus as any).on(event, listener)\n\t\treturn () => (this.eventBus as any).off(event, listener)\n\t}\n\n\t// Create plugin context (will be implemented when we have the full context)\n\tprivate createPluginContext(pluginName: string): PluginContext {\n\t\t// This will be implemented when we integrate with the media player\n\t\t// For now, return a minimal context\n\t\treturn {\n\t\t\tstate: {} as any,\n\t\t\tcontrols: {} as any,\n\t\t\tplugins: this,\n\t\t\temit: (event: string, data?: any) => (this.eventBus as any).emit(event, data),\n\t\t\ton: (event: string, handler: (data: any) => void) => {\n\t\t\t\t;(this.eventBus as any).on(event, handler)\n\t\t\t\treturn () => (this.eventBus as any).off(event, handler)\n\t\t\t},\n\t\t\telement: null,\n\t\t\tlogger: this.createPluginLogger(pluginName)\n\t\t}\n\t}\n\n\t// Create plugin-specific logger\n\tprivate createPluginLogger(pluginName: string): PluginLogger {\n\t\treturn {\n\t\t\tinfo: (message: string, data?: any) => this.logger.info(`[${pluginName}] ${message}`, data),\n\t\t\twarn: (message: string, data?: any) => this.logger.warn(`[${pluginName}] ${message}`, data),\n\t\t\terror: (message: string, data?: any) => this.logger.error(`[${pluginName}] ${message}`, data),\n\t\t\tdebug: (message: string, data?: any) => this.logger.debug(`[${pluginName}] ${message}`, data)\n\t\t}\n\t}\n\n\t// Resolve plugin dependencies\n\tprivate resolveDependencies(names: string[]): string[] {\n\t\tconst resolved: string[] = []\n\t\tconst visiting = new Set<string>()\n\n\t\tconst visit = (name: string) => {\n\t\t\tif (resolved.includes(name)) return\n\t\t\tif (visiting.has(name)) {\n\t\t\t\tthrow new PluginError(name, \"initialize\", \"Circular dependency detected\")\n\t\t\t}\n\n\t\t\tvisiting.add(name)\n\n\t\t\tconst plugin = this.plugins.get(name)\n\t\t\tif (!plugin) {\n\t\t\t\tthrow new PluginError(name, \"initialize\", \"Plugin not found\")\n\t\t\t}\n\n\t\t\t// Visit dependencies first\n\t\t\tfor (const dep of plugin.metadata.dependencies || []) {\n\t\t\t\tvisit(dep)\n\t\t\t}\n\n\t\t\tvisiting.delete(name)\n\t\t\tresolved.push(name)\n\t\t}\n\n\t\tfor (const name of names) {\n\t\t\tvisit(name)\n\t\t}\n\n\t\treturn resolved\n\t}\n\n\t// Sort plugins by priority\n\tprivate sortByPriority(a: Plugin, b: Plugin): number {\n\t\tconst priorityOrder: Record<PluginPriority, number> = {\n\t\t\thigh: 3,\n\t\t\tmedium: 2,\n\t\t\tlow: 1\n\t\t}\n\n\t\treturn priorityOrder[b.metadata.priority] - priorityOrder[a.metadata.priority]\n\t}\n}\n","import type {\n\tPlugin,\n\tPluginCategory,\n\tPluginConfig,\n\tPluginContext,\n\tPluginMetadata,\n\tPluginPriority\n} from \"./types\"\n\n// Abstract base plugin class\nexport abstract class BasePlugin implements Plugin {\n\tpublic readonly metadata: PluginMetadata\n\n\tprotected context?: PluginContext\n\tprotected config: PluginConfig = {}\n\tprotected initialized = false\n\tprotected active = false\n\n\tconstructor(metadata: Omit<PluginMetadata, \"version\"> & { version?: string }) {\n\t\tthis.metadata = {\n\t\t\tversion: \"1.0.0\",\n\t\t\t...metadata\n\t\t}\n\t}\n\n\t// Plugin lifecycle methods - can be overridden by subclasses\n\tasync initialize(context: PluginContext, config: PluginConfig = {}): Promise<void> {\n\t\tif (this.initialized) {\n\t\t\tcontext.logger.warn(\"Plugin already initialized\")\n\t\t\treturn\n\t\t}\n\n\t\tthis.context = context\n\t\tthis.config = { ...this.config, ...config }\n\n\t\ttry {\n\t\t\tawait this.onInitialize()\n\t\t\tthis.initialized = true\n\t\t\tcontext.logger.info(`Plugin initialized`)\n\t\t} catch (error) {\n\t\t\tcontext.logger.error(\"Failed to initialize plugin\", error)\n\t\t\tthrow error\n\t\t}\n\t}\n\n\tasync activate(context: PluginContext): Promise<void> {\n\t\tif (!this.initialized) {\n\t\t\tthrow new Error(\"Plugin must be initialized before activation\")\n\t\t}\n\n\t\tif (this.active) {\n\t\t\tcontext.logger.warn(\"Plugin already active\")\n\t\t\treturn\n\t\t}\n\n\t\ttry {\n\t\t\tawait this.onActivate()\n\t\t\tthis.active = true\n\t\t\tcontext.logger.info(`Plugin activated`)\n\t\t} catch (error) {\n\t\t\tcontext.logger.error(\"Failed to activate plugin\", error)\n\t\t\tthrow error\n\t\t}\n\t}\n\n\tasync deactivate(context: PluginContext): Promise<void> {\n\t\tif (!this.active) {\n\t\t\tcontext.logger.warn(\"Plugin already inactive\")\n\t\t\treturn\n\t\t}\n\n\t\ttry {\n\t\t\tawait this.onDeactivate()\n\t\t\tthis.active = false\n\t\t\tcontext.logger.info(`Plugin deactivated`)\n\t\t} catch (error) {\n\t\t\tcontext.logger.error(\"Failed to deactivate plugin\", error)\n\t\t\tthrow error\n\t\t}\n\t}\n\n\tasync destroy(context: PluginContext): Promise<void> {\n\t\tif (this.active) {\n\t\t\tawait this.deactivate(context)\n\t\t}\n\n\t\ttry {\n\t\t\tawait this.onDestroy()\n\t\t\tthis.initialized = false\n\t\t\tcontext.logger.info(`Plugin destroyed`)\n\t\t} catch (error) {\n\t\t\tcontext.logger.error(\"Failed to destroy plugin\", error)\n\t\t\tthrow error\n\t\t}\n\t}\n\n\tasync configure(config: PluginConfig): Promise<void> {\n\t\tconst oldConfig = { ...this.config }\n\t\tthis.config = { ...this.config, ...config }\n\n\t\ttry {\n\t\t\tawait this.onConfigure(config, oldConfig)\n\t\t\tthis.context?.logger.info(\"Plugin configured\")\n\t\t} catch (error) {\n\t\t\t// Rollback configuration on error\n\t\t\tthis.config = oldConfig\n\t\t\tthis.context?.logger.error(\"Failed to configure plugin\", error)\n\t\t\tthrow error\n\t\t}\n\t}\n\n\thealthCheck(): boolean {\n\t\treturn this.initialized && this.onHealthCheck()\n\t}\n\n\t// Template methods for subclasses to override\n\tprotected abstract onInitialize(): Promise<void> | void\n\tprotected abstract onActivate(): Promise<void> | void\n\tprotected abstract onDeactivate(): Promise<void> | void\n\n\tprotected onDestroy(): Promise<void> | void {\n\t\t// Default implementation - subclasses can override\n\t}\n\n\tprotected onConfigure(newConfig: PluginConfig, oldConfig: PluginConfig): Promise<void> | void {\n\t\t// Default implementation - subclasses can override\n\t}\n\n\tprotected onHealthCheck(): boolean {\n\t\t// Default implementation - subclasses can override\n\t\treturn true\n\t}\n\n\t// Utility methods for plugins\n\tprotected get state() {\n\t\treturn this.context?.state\n\t}\n\n\tprotected get controls() {\n\t\treturn this.context?.controls\n\t}\n\n\tprotected get element() {\n\t\treturn this.context?.element\n\t}\n\n\tprotected get logger() {\n\t\treturn this.context?.logger\n\t}\n\n\tprotected emit(event: string, data?: any): void {\n\t\tthis.context?.emit(event, data)\n\t}\n\n\tprotected on(event: string, handler: (data: any) => void): () => void {\n\t\treturn this.context?.on(event, handler) || (() => {})\n\t}\n\n\t// Helper methods for common plugin patterns\n\tprotected addEventListeners(\n\t\telement: HTMLElement,\n\t\tevents: Record<string, (e: Event) => void>\n\t): () => void {\n\t\tObject.entries(events).forEach(([event, handler]) => {\n\t\t\telement.addEventListener(event, handler)\n\t\t})\n\n\t\t// Return cleanup function\n\t\treturn () => {\n\t\t\tObject.entries(events).forEach(([event, handler]) => {\n\t\t\t\telement.removeEventListener(event, handler)\n\t\t\t})\n\t\t}\n\t}\n\n\tprotected createConfig<T extends PluginConfig>(defaults: T): T {\n\t\treturn { ...defaults, ...this.config } as T\n\t}\n\n\t// Plugin status\n\tget isInitialized(): boolean {\n\t\treturn this.initialized\n\t}\n\n\tget isActive(): boolean {\n\t\treturn this.active\n\t}\n}\n\n// Simple plugin factory helper\nexport function createPlugin<T extends BasePlugin>(PluginClass: new (config?: PluginConfig) => T) {\n\treturn (config?: PluginConfig) => new PluginClass(config)\n}\n\n// Plugin decorator for metadata - TODO: Fix implementation\n// export function plugin(metadata: Omit<PluginMetadata, 'version'> & { version?: string }) {\n// return function<T extends { new (...args: any[]): BasePlugin }>(constructor: T) {\n// return class extends constructor {\n// constructor(...args: any[]) {\n// super(metadata, ...args)\n// }\n// }\n// }\n// }\n\n// Common plugin configurations\nexport interface UIPluginConfig extends PluginConfig {\n\tposition?: \"top\" | \"bottom\" | \"left\" | \"right\" | \"center\"\n\tzIndex?: number\n\tclassName?: string\n\tstyle?: Record<string, string>\n}\n\nexport interface AnalyticsPluginConfig extends PluginConfig {\n\ttrackingId?: string\n\tevents?: string[]\n\tsamplingRate?: number\n\tdebug?: boolean\n}\n\nexport interface PerformancePluginConfig extends PluginConfig {\n\tenableMetrics?: boolean\n\treportInterval?: number\n\tthresholds?: Record<string, number>\n}\n","import { type AnalyticsPluginConfig, BasePlugin } from \"../base-plugin\"\n\ninterface AnalyticsEvent {\n\tevent: string\n\ttimestamp: number\n\tdata?: any\n}\n\ninterface AnalyticsConfig extends AnalyticsPluginConfig {\n\ttrackingId: string\n\tevents: string[]\n\tsamplingRate: number\n\tdebug: boolean\n\tendpoint?: string\n}\n\nexport class AnalyticsPlugin extends BasePlugin {\n\tprivate events: AnalyticsEvent[] = []\n\tprivate analyticsConfig!: AnalyticsConfig\n\tprivate cleanupFunctions: Array<() => void> = []\n\tprivate reportTimer?: NodeJS.Timeout\n\n\tconstructor(config?: AnalyticsPluginConfig) {\n\t\tsuper({\n\t\t\tname: \"analytics\",\n\t\t\tdescription: \"Media player analytics and tracking\",\n\t\t\tcategory: \"analytics\",\n\t\t\tpriority: \"low\",\n\t\t\tauthor: \"BaroiPlayer Team\"\n\t\t})\n\t}\n\n\tprotected onInitialize(): void {\n\t\tthis.analyticsConfig = this.createConfig<AnalyticsConfig>({\n\t\t\ttrackingId: \"\",\n\t\t\tevents: [\"play\", \"pause\", \"seek\", \"ended\", \"error\"],\n\t\t\tsamplingRate: 1.0,\n\t\t\tdebug: false,\n\t\t\tendpoint: \"/api/analytics\"\n\t\t})\n\n\t\tif (!this.analyticsConfig.trackingId) {\n\t\t\tthrow new Error(\"Analytics plugin requires a tracking ID\")\n\t\t}\n\n\t\tthis.logger?.info(\"Analytics plugin initialized\", {\n\t\t\ttrackingId: this.analyticsConfig.trackingId,\n\t\t\tevents: this.analyticsConfig.events\n\t\t})\n\t}\n\n\tprotected onActivate(): void {\n\t\t// Set up event listeners for media events\n\t\tconst mediaEventCleanup = this.setupMediaEventListeners()\n\t\tthis.cleanupFunctions.push(mediaEventCleanup)\n\n\t\t// Set up periodic reporting\n\t\tif (this.analyticsConfig.endpoint) {\n\t\t\tthis.reportTimer = setInterval(() => {\n\t\t\t\tthis.reportEvents()\n\t\t\t}, 30000) // Report every 30 seconds\n\n\t\t\tthis.cleanupFunctions.push(() => {\n\t\t\t\tif (this.reportTimer) {\n\t\t\t\t\tclearInterval(this.reportTimer)\n\t\t\t\t}\n\t\t\t})\n\t\t}\n\n\t\tthis.trackEvent(\"plugin_activated\", { plugin: \"analytics\" })\n\t\tthis.logger?.info(\"Analytics tracking started\")\n\t}\n\n\tprotected onDeactivate(): void {\n\t\t// Clean up all event listeners and timers\n\t\tthis.cleanupFunctions.forEach((cleanup) => cleanup())\n\t\tthis.cleanupFunctions = []\n\n\t\t// Report any remaining events\n\t\tif (this.events.length > 0) {\n\t\t\tthis.reportEvents()\n\t\t}\n\n\t\tthis.trackEvent(\"plugin_deactivated\", { plugin: \"analytics\" })\n\t\tthis.logger?.info(\"Analytics tracking stopped\")\n\t}\n\n\tprotected onConfigure(newConfig: AnalyticsConfig): void {\n\t\t// Update tracking configuration\n\t\tthis.analyticsConfig = { ...this.analyticsConfig, ...newConfig }\n\t\tif (newConfig.events) {\n\t\t\t// Re-setup event listeners if events changed\n\t\t\tthis.cleanupFunctions.forEach((cleanup) => cleanup())\n\t\t\tthis.cleanupFunctions = []\n\n\t\t\tconst mediaEventCleanup = this.setupMediaEventListeners()\n\t\t\tthis.cleanupFunctions.push(mediaEventCleanup)\n\t\t}\n\t}\n\n\tprivate setupMediaEventListeners(): () => void {\n\t\tconst cleanupFunctions: Array<() => void> = []\n\n\t\t// Listen for media state changes\n\t\tif (this.analyticsConfig.events.includes(\"play\")) {\n\t\t\tconst unsubscribe = this.on(\"media:play\", (data) => {\n\t\t\t\tthis.trackEvent(\"play\", data)\n\t\t\t})\n\t\t\tcleanupFunctions.push(unsubscribe)\n\t\t}\n\n\t\tif (this.analyticsConfig.events.includes(\"pause\")) {\n\t\t\tconst unsubscribe = this.on(\"media:pause\", (data) => {\n\t\t\t\tthis.trackEvent(\"pause\", data)\n\t\t\t})\n\t\t\tcleanupFunctions.push(unsubscribe)\n\t\t}\n\n\t\tif (this.analyticsConfig.events.includes(\"seek\")) {\n\t\t\tconst unsubscribe = this.on(\"media:seek\", (data) => {\n\t\t\t\tthis.trackEvent(\"seek\", data)\n\t\t\t})\n\t\t\tcleanupFunctions.push(unsubscribe)\n\t\t}\n\n\t\tif (this.analyticsConfig.events.includes(\"ended\")) {\n\t\t\tconst unsubscribe = this.on(\"media:ended\", (data) => {\n\t\t\t\tthis.trackEvent(\"ended\", data)\n\t\t\t})\n\t\t\tcleanupFunctions.push(unsubscribe)\n\t\t}\n\n\t\tif (this.analyticsConfig.events.includes(\"error\")) {\n\t\t\tconst unsubscribe = this.on(\"media:error\", (data) => {\n\t\t\t\tthis.trackEvent(\"error\", data)\n\t\t\t})\n\t\t\tcleanupFunctions.push(unsubscribe)\n\t\t}\n\n\t\t// Return cleanup function\n\t\treturn () => {\n\t\t\tcleanupFunctions.forEach((cleanup) => cleanup())\n\t\t}\n\t}\n\n\tprivate trackEvent(event: string, data?: any): void {\n\t\t// Apply sampling rate\n\t\tif (Math.random() > this.analyticsConfig.samplingRate) {\n\t\t\treturn\n\t\t}\n\n\t\tconst analyticsEvent: AnalyticsEvent = {\n\t\t\tevent,\n\t\t\ttimestamp: Date.now(),\n\t\t\tdata: {\n\t\t\t\t...data,\n\t\t\t\ttrackingId: this.analyticsConfig.trackingId,\n\t\t\t\tsessionId: this.generateSessionId(),\n\t\t\t\tmediaState: {\n\t\t\t\t\tcurrentTime: this.state?.currentTime,\n\t\t\t\t\tduration: this.state?.duration,\n\t\t\t\t\tvolume: this.state?.volume,\n\t\t\t\t\tisPlaying: this.state?.isPlaying\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tthis.events.push(analyticsEvent)\n\n\t\tif (this.analyticsConfig.debug) {\n\t\t\tthis.logger?.info(\"Analytics event tracked\", analyticsEvent)\n\t\t}\n\n\t\t// Emit event for other plugins or applications to use\n\t\tthis.emit(\"analytics:event\", analyticsEvent)\n\t}\n\n\tprivate async reportEvents(): Promise<void> {\n\t\tif (this.events.length === 0 || !this.analyticsConfig.endpoint) {\n\t\t\treturn\n\t\t}\n\n\t\tconst eventsToReport = [...this.events]\n\t\tthis.events = []\n\n\t\ttry {\n\t\t\tconst response = await fetch(this.analyticsConfig.endpoint, {\n\t\t\t\tmethod: \"POST\",\n\t\t\t\theaders: {\n\t\t\t\t\t\"Content-Type\": \"application/json\"\n\t\t\t\t},\n\t\t\t\tbody: JSON.stringify({\n\t\t\t\t\ttrackingId: this.analyticsConfig.trackingId,\n\t\t\t\t\tevents: eventsToReport\n\t\t\t\t})\n\t\t\t})\n\n\t\t\tif (!response.ok) {\n\t\t\t\tthrow new Error(`Analytics report failed: ${response.status}`)\n\t\t\t}\n\n\t\t\tif (this.analyticsConfig.debug) {\n\t\t\t\tthis.logger?.info(`Reported ${eventsToReport.length} analytics events`)\n\t\t\t}\n\t\t} catch (error) {\n\t\t\t// Put events back in queue on failure\n\t\t\tthis.events.unshift(...eventsToReport)\n\t\t\tthis.logger?.error(\"Failed to report analytics events\", error)\n\t\t}\n\t}\n\n\tprivate generateSessionId(): string {\n\t\t// Simple session ID generation - could be more sophisticated\n\t\treturn `session_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`\n\t}\n\n\t// Public API for manual event tracking\n\tpublic track(event: string, data?: any): void {\n\t\tthis.trackEvent(event, data)\n\t}\n\n\t// Get pending events count\n\tpublic getPendingEventsCount(): number {\n\t\treturn this.events.length\n\t}\n\n\t// Flush all pending events\n\tpublic async flush(): Promise<void> {\n\t\tawait this.reportEvents()\n\t}\n\n\tprotected onHealthCheck(): boolean {\n\t\t// Check if we're not accumulating too many events\n\t\treturn this.events.length < 1000\n\t}\n}\n\n// Plugin factory\nexport const createAnalyticsPlugin = (config?: AnalyticsPluginConfig) => {\n\treturn new AnalyticsPlugin(config)\n}\n","import type { Plugin, PluginConfig, PluginLogger } from \"./types\"\n\n// Simple console logger implementation\nexport class ConsolePluginLogger implements PluginLogger {\n\tprivate prefix: string\n\n\tconstructor(prefix = \"[Plugin]\") {\n\t\tthis.prefix = prefix\n\t}\n\n\tinfo(message: string, data?: any): void {\n\t\tif (data) {\n\t\t\tconsole.info(`${this.prefix} ${message}`, data)\n\t\t} else {\n\t\t\tconsole.info(`${this.prefix} ${message}`)\n\t\t}\n\t}\n\n\twarn(message: string, data?: any): void {\n\t\tif (data) {\n\t\t\tconsole.warn(`${this.prefix} ${message}`, data)\n\t\t} else {\n\t\t\tconsole.warn(`${this.prefix} ${message}`)\n\t\t}\n\t}\n\n\terror(message: string, data?: any): void {\n\t\tif (data) {\n\t\t\tconsole.error(`${this.prefix} ${message}`, data)\n\t\t} else {\n\t\t\tconsole.error(`${this.prefix} ${message}`)\n\t\t}\n\t}\n\n\tdebug(message: string, data?: any): void {\n\t\tif (process.env.NODE_ENV === \"development\") {\n\t\t\tif (data) {\n\t\t\t\tconsole.debug(`${this.prefix} ${message}`, data)\n\t\t\t} else {\n\t\t\t\tconsole.debug(`${this.prefix} ${message}`)\n\t\t\t}\n\t\t}\n\t}\n}\n\n// Plugin validation utilities\nexport class PluginValidator {\n\tstatic validateMetadata(plugin: Plugin): boolean {\n\t\tconst { metadata } = plugin\n\n\t\tif (!metadata.name || typeof metadata.name !== \"string\") {\n\t\t\tthrow new Error(\"Plugin metadata must include a valid name\")\n\t\t}\n\n\t\tif (!metadata.version || typeof metadata.version !== \"string\") {\n\t\t\tthrow new Error(\"Plugin metadata must include a valid version\")\n\t\t}\n\n\t\tif (!metadata.description || typeof metadata.description !== \"string\") {\n\t\t\tthrow new Error(\"Plugin metadata must include a valid description\")\n\t\t}\n\n\t\tif (!metadata.category) {\n\t\t\tthrow new Error(\"Plugin metadata must include a valid category\")\n\t\t}\n\n\t\tif (!metadata.priority) {\n\t\t\tthrow new Error(\"Plugin metadata must include a valid priority\")\n\t\t}\n\n\t\treturn true\n\t}\n\n\tstatic validateConfig(config: PluginConfig, schema?: Record<string, any>): boolean {\n\t\tif (!schema) return true\n\n\t\t// Simple schema validation - could be enhanced with a proper schema validator\n\t\tfor (const [key, rules] of Object.entries(schema)) {\n\t\t\tconst value = config[key]\n\n\t\t\tif (rules.required && (value === undefined || value === null)) {\n\t\t\t\tthrow new Error(`Configuration property '${key}' is required`)\n\t\t\t}\n\n\t\t\tif (value !== undefined && rules.type && typeof value !== rules.type) {\n\t\t\t\tthrow new Error(`Configuration property '${key}' must be of type '${rules.type}'`)\n\t\t\t}\n\n\t\t\tif (rules.enum && !rules.enum.includes(value)) {\n\t\t\t\tthrow new Error(`Configuration property '${key}' must be one of: ${rules.enum.join(\", \")}`)\n\t\t\t}\n\n\t\t\tif (rules.min !== undefined && typeof value === \"number\" && value < rules.min) {\n\t\t\t\tthrow new Error(`Configuration property '${key}' must be at least ${rules.min}`)\n\t\t\t}\n\n\t\t\tif (rules.max !== undefined && typeof value === \"number\" && value > rules.max) {\n\t\t\t\tthrow new Error(`Configuration property '${key}' must be at most ${rules.max}`)\n\t\t\t}\n\t\t}\n\n\t\treturn true\n\t}\n}\n\n// Plugin performance monitoring\nexport class PluginPerformanceMonitor {\n\tprivate metrics = new Map<\n\t\tstring,\n\t\t{\n\t\t\tcalls: number\n\t\t\ttotalTime: number\n\t\t\taverageTime: number\n\t\t\tlastCall: number\n\t\t}\n\t>()\n\n\tmeasure<T>(pluginName: string, operation: string, fn: () => T | Promise<T>): T | Promise<T> {\n\t\tconst key = `${pluginName}.${operation}`\n\t\tconst startTime = performance.now()\n\n\t\tconst updateMetrics = () => {\n\t\t\tconst endTime = performance.now()\n\t\t\tconst duration = endTime - startTime\n\n\t\t\tconst existing = this.metrics.get(key) || {\n\t\t\t\tcalls: 0,\n\t\t\t\ttotalTime: 0,\n\t\t\t\taverageTime: 0,\n\t\t\t\tlastCall: 0\n\t\t\t}\n\n\t\t\texisting.calls++\n\t\t\texisting.totalTime += duration\n\t\t\texisting.averageTime = existing.totalTime / existing.calls\n\t\t\texisting.lastCall = endTime\n\n\t\t\tthis.metrics.set(key, existing)\n\t\t}\n\n\t\tconst result = fn()\n\n\t\tif (result instanceof Promise) {\n\t\t\treturn result.then(\n\t\t\t\t(value) => {\n\t\t\t\t\tupdateMetrics()\n\t\t\t\t\treturn value\n\t\t\t\t},\n\t\t\t\t(error) => {\n\t\t\t\t\tupdateMetrics()\n\t\t\t\t\tthrow error\n\t\t\t\t}\n\t\t\t)\n\t\t} else {\n\t\t\tupdateMetrics()\n\t\t\treturn result\n\t\t}\n\t}\n\n\tgetMetrics(pluginName?: string) {\n\t\tif (pluginName) {\n\t\t\tconst pluginMetrics: Record<string, any> = {}\n\t\t\tfor (const [key, value] of this.metrics.entries()) {\n\t\t\t\tif (key.startsWith(`${pluginName}.`)) {\n\t\t\t\t\tconst operation = key.substring(pluginName.length + 1)\n\t\t\t\t\tpluginMetrics[operation] = value\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn pluginMetrics\n\t\t}\n\n\t\treturn Object.fromEntries(this.metrics.entries())\n\t}\n\n\treset(pluginName?: string): void {\n\t\tif (pluginName) {\n\t\t\tfor (const key of this.metrics.keys()) {\n\t\t\t\tif (key.startsWith(`${pluginName}.`)) {\n\t\t\t\t\tthis.metrics.delete(key)\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tthis.metrics.clear()\n\t\t}\n\t}\n}\n\n// Plugin development helpers\nexport const PluginDevelopmentHelpers = {\n\t// Create a mock plugin context for testing\n\tcreateMockContext(): any {\n\t\treturn {\n\t\t\tstate: {\n\t\t\t\tisPlaying: false,\n\t\t\t\tcurrentTime: 0,\n\t\t\t\tduration: 0,\n\t\t\t\tvolume: 1,\n\t\t\t\tisMuted: false,\n\t\t\t\tisLoading: false,\n\t\t\t\terror: null\n\t\t\t},\n\t\t\tcontrols: {\n\t\t\t\tplay: () => Promise.resolve(),\n\t\t\t\tpause: () => Promise.resolve(),\n\t\t\t\tseek: (time: number) => Promise.resolve(),\n\t\t\t\tsetVolume: (volume: number) => Promise.resolve(),\n\t\t\t\tmute: () => Promise.resolve(),\n\t\t\t\tunmute: () => Promise.resolve(),\n\t\t\t\ttoggleMute: () => Promise.resolve()\n\t\t\t},\n\t\t\tplugins: {\n\t\t\t\tget: () => undefined,\n\t\t\t\tgetAll: () => [],\n\t\t\t\tisEnabled: () => false\n\t\t\t},\n\t\t\temit: () => {},\n\t\t\ton: () => () => {},\n\t\t\telement: null,\n\t\t\tlogger: new ConsolePluginLogger(\"[MockPlugin]\")\n\t\t}\n\t},\n\n\t// Create a test plugin for development\n\tcreateTestPlugin(name: string, hooks: Partial<Plugin> = {}): Plugin {\n\t\treturn {\n\t\t\tmetadata: {\n\t\t\t\tname,\n\t\t\t\tversion: \"1.0.0\",\n\t\t\t\tdescription: `Test plugin: ${name}`,\n\t\t\t\tcategory: \"ui\",\n\t\t\t\tpriority: \"medium\"\n\t\t\t},\n\t\t\tinitialize: async () => {},\n\t\t\tactivate: async () => {},\n\t\t\tdeactivate: async () => {},\n\t\t\tdestroy: async () => {},\n\t\t\thealthCheck: () => true,\n\t\t\t...hooks\n\t\t}\n\t},\n\n\t// Plugin timing utilities\n\ttime: {\n\t\tasync: async <T>(label: string, fn: () => Promise<T>): Promise<T> => {\n\t\t\tconsole.time(label)\n\t\t\ttry {\n\t\t\t\tconst result = await fn()\n\t\t\t\tconsole.timeEnd(label)\n\t\t\t\treturn result\n\t\t\t} catch (error) {\n\t\t\t\tconsole.timeEnd(label)\n\t\t\t\tthrow error\n\t\t\t}\n\t\t},\n\n\t\tsync: <T>(label: string, fn: () => T): T => {\n\t\t\tconsole.time(label)\n\t\t\ttry {\n\t\t\t\tconst result = fn()\n\t\t\t\tconsole.timeEnd(label)\n\t\t\t\treturn result\n\t\t\t} catch (error) {\n\t\t\t\tconsole.timeEnd(label)\n\t\t\t\tthrow error\n\t\t\t}\n\t\t}\n\t}\n}\n\n// Plugin storage utilities for persistent data\nexport class PluginStorage {\n\tprivate prefix: string\n\n\tconstructor(pluginName: string) {\n\t\tthis.prefix = `baroi-plugin-${pluginName}`\n\t}\n\n\tget<T>(key: string, defaultValue?: T): T | undefined {\n\t\ttry {\n\t\t\tconst item = localStorage.getItem(`${this.prefix}-${key}`)\n\t\t\treturn item ? (JSON.parse(item) as T) : defaultValue\n\t\t} catch {\n\t\t\treturn defaultValue\n\t\t}\n\t}\n\n\tset<T>(key: string, value: T): void {\n\t\ttry {\n\t\t\tlocalStorage.setItem(`${this.prefix}-${key}`, JSON.stringify(value))\n\t\t} catch (error) {\n\t\t\tconsole.warn(`Failed to store plugin data for key: ${key}`, error)\n\t\t}\n\t}\n\n\tremove(key: string): void {\n\t\ttry {\n\t\t\tlocalStorage.removeItem(`${this.prefix}-${key}`)\n\t\t} catch (error) {\n\t\t\tconsole.warn(`Failed to remove plugin data for key: ${key}`, error)\n\t\t}\n\t}\n\n\tclear(): void {\n\t\ttry {\n\t\t\tconst keys = Object.keys(localStorage).filter((key) => key.startsWith(`${this.prefix}-`))\n\t\t\tkeys.forEach((key) => localStorage.removeItem(key))\n\t\t} catch (error) {\n\t\t\tconsole.warn(\"Failed to clear plugin data\", error)\n\t\t}\n\t}\n}\n\n// Export default logger instance\nexport const defaultPluginLogger = new ConsolePluginLogger()\n\n// Export default performance monitor instance\nexport const defaultPerformanceMonitor = new PluginPerformanceMonitor()\n","// Plugin system core exports\nexport type {\n\tPlugin,\n\tPluginFactory,\n\tPluginConfig,\n\tPluginRegistry as IPluginRegistry,\n\tPluginContext,\n\tPluginLogger,\n\tPluginMetadata,\n\tPluginCategory,\n\tPluginPriority,\n\tPluginPhase,\n\tPluginEvents\n} from \"./types\"\n\nexport {\n\tPluginError,\n\tPluginDependencyError,\n\tPluginConflictError\n} from \"./types\"\n\nexport { PluginRegistry } from \"./registry\"\n\nexport {\n\tBasePlugin,\n\tcreatePlugin,\n\ttype UIPluginConfig,\n\ttype AnalyticsPluginConfig,\n\ttype PerformancePluginConfig\n} from \"./base-plugin\"\n\n// Example plugins\nexport { AnalyticsPlugin, createAnalyticsPlugin } from \"./examples/analytics-plugin\"\n\n// Plugin utilities\nexport * from \"./utils\"\n\n// Version\nexport const PLUGIN_SYSTEM_VERSION = \"1.0.0\"\n"],"names":["PluginError","pluginName","phase","message","originalError","PluginDependencyError","missingDependencies","PluginConflictError","conflictingPlugins","PluginRegistry","logger","__publicField","EventBus","factory","config","plugin","name","dependencies","conflicts","dep","activeConflicts","conflict","error","context","names","resolved","reversed","results","healthy","event","listener","data","handler","visiting","visit","a","b","priorityOrder","BasePlugin","metadata","oldConfig","newConfig","element","events","defaults","createPlugin","PluginClass","AnalyticsPlugin","mediaEventCleanup","cleanup","cleanupFunctions","unsubscribe","analyticsEvent","eventsToReport","response","createAnalyticsPlugin","ConsolePluginLogger","prefix","PluginValidator","schema","key","rules","value","PluginPerformanceMonitor","operation","fn","startTime","updateMetrics","endTime","duration","existing","result","pluginMetrics","PluginDevelopmentHelpers","time","volume","hooks","label","PluginStorage","defaultValue","item","defaultPluginLogger","defaultPerformanceMonitor","PLUGIN_SYSTEM_VER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GAAG,KAAK,MAAM,GAAG,CAAC,EACnF,QAASA,GAAQ,aAAa,WAAWA,CAAG,CAAC,CACnD,OAAStC,EAAO,CACf,QAAQ,KAAK,8BAA+BA,CAAK,CAClD,CACD,CACD,CAGO,MAAM2D,EAAsB,IAAIzB,EAG1B0B,EAA4B,IAAInB,ECtRhCoB,EAAwB"}
@@ -1,4 +0,0 @@
1
- "use strict";const a=require("react"),D=require("./context-eNS62_ac.cjs"),ie=require("./utils-CFOue_9K.cjs");function pe(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const s=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,s.get?s:{enumerable:!0,get:()=>e[n]})}}return t.default=e,Object.freeze(t)}const K=pe(a);function B(e,t){return((n,s=!1)=>{const m={type:e,detail:n,optimistic:s,timestamp:Date.now()};return s?t.dispatchOptimistic(m):(t.dispatch(m),Promise.resolve())})}function oe(e){const[t,n]=a.useState(e.getActionState());return a.useEffect(()=>e.subscribe(()=>{const m=e.getActionState();n(l=>JSON.stringify(l)!==JSON.stringify(m)?m:l)}),[e]),t}function ce(e){const t=a.useMemo(()=>({play:B(D.MediaActionTypes.PLAY,e),pause:B(D.MediaActionTypes.PAUSE,e),seek:B(D.MediaActionTypes.SEEK,e),setVolume:B(D.MediaActionTypes.SET_VOLUME,e),mute:B(D.MediaActionTypes.MUTE,e),unmute:B(D.MediaActionTypes.UNMUTE,e),toggleMute:B(D.MediaActionTypes.TOGGLE_MUTE,e),setDuration:B(D.MediaActionTypes.SET_DURATION,e),setCurrentTime:B(D.MediaActionTypes.SET_CURRENT_TIME,e),setBuffered:B(D.MediaActionTypes.SET_BUFFERED,e),setLoading:B(D.MediaActionTypes.SET_LOADING,e),setError:B(D.MediaActionTypes.SET_ERROR,e),enterFullscreen:B(D.MediaActionTypes.ENTER_FULLSCREEN,e),exitFullscreen:B(D.MediaActionTypes.EXIT_FULLSCREEN,e),enterPiP:B(D.MediaActionTypes.ENTER_PIP,e),exitPiP:B(D.MediaActionTypes.EXIT_PIP,e),setPlaybackRate:B(D.MediaActionTypes.SET_PLAYBACK_RATE,e),setSubtitleTrack:B(D.MediaActionTypes.SET_SUBTITLE_TRACK,e),setRendition:B(D.MediaActionTypes.SET_RENDITION,e),toggleSubtitles:B(D.MediaActionTypes.TOGGLE_SUBTITLES,e),previewTime:B(D.MediaActionTypes.PREVIEW_TIME,e),clearPreview:B(D.MediaActionTypes.CLEAR_PREVIEW,e)}),[e]),n=oe(e),s=a.useMemo(()=>({togglePlayPause:async l=>{l?await t.pause(!0):await t.play(!0)},seekWithPreview:async l=>{await t.previewTime(l,!0),await t.seek(l,!0)},adjustVolume:async(l,i)=>{const d=Math.max(0,Math.min(1,i+l));await t.setVolume(d,!0)},toggleFullscreenOptimistic:async l=>{l?await t.exitFullscreen(!0):await t.enterFullscreen(!0)}}),[t]),m=a.useCallback(async()=>{const{lastAction:l}=n;l&&n.error&&await e.dispatchOptimistic({...l,retryCount:(l.retryCount||0)+1})},[e,n]);return{...t,...s,actionState:n,retryLastAction:m,isLoading:n.pending,hasError:!!n.error,errorMessage:n.error,retryCount:n.retryCount}}function ge(e,t){if(!t.optimistic)return e;switch(t.type){case"PLAY":return{...e,isPlaying:!0,error:null};case"PAUSE":return{...e,isPlaying:!1};case"SEEK":return{...e,currentTime:t.detail};case"SET_VOLUME":return{...e,volume:Math.max(0,Math.min(1,t.detail))};case"MUTE":return{...e,isMuted:!0};case"UNMUTE":return{...e,isMuted:!1};case"TOGGLE_MUTE":return{...e,isMuted:!e.isMuted};case"ENTER_FULLSCREEN":return{...e,isFullscreen:!0};case"EXIT_FULLSCREEN":return{...e,isFullscreen:!1};case"SET_PLAYBACK_RATE":return{...e,playbackRate:t.detail};case"TOGGLE_SUBTITLES":return{...e,subtitlesShowing:!e.subtitlesShowing};case"PREVIEW_TIME":return{...e,previewTime:t.detail};case"CLEAR_PREVIEW":return{...e,previewTime:null,previewImage:null,previewCoords:null};default:return e}}function ve(e){const t=a.useSyncExternalStore(e.subscribe,e.getState,e.getState),[n,s]=a.useOptimistic(t,ge),m=a.useCallback(async d=>{d.optimistic&&s(d),await e.dispatchOptimistic(d)},[e,s]),l=a.useMemo(()=>({togglePlayPause:async()=>{const d={type:n.isPlaying?"PAUSE":"PLAY",optimistic:!0,timestamp:Date.now()};await m(d)},setVolumeOptimistic:async d=>{const S={type:"SET_VOLUME",detail:Math.max(0,Math.min(1,d)),optimistic:!0,timestamp:Date.now()};await m(S)},seekOptimistic:async d=>{const S={type:"SEEK",detail:d,optimistic:!0,timestamp:Date.now()};await m(S)},toggleMuteOptimistic:async()=>{const d={type:"TOGGLE_MUTE",optimistic:!0,timestamp:Date.now()};await m(d)},toggleFullscreenOptimistic:async()=>{const d={type:n.isFullscreen?"EXIT_FULLSCREEN":"ENTER_FULLSCREEN",optimistic:!0,timestamp:Date.now()};await m(d)},setPlaybackRateOptimistic:async d=>{const S={type:"SET_PLAYBACK_RATE",detail:d,optimistic:!0,timestamp:Date.now()};await m(S)},toggleSubtitlesOptimistic:async()=>{const d={type:"TOGGLE_SUBTITLES",optimistic:!0,timestamp:Date.now()};await m(d)}}),[n,m]),i=a.useMemo(()=>({isPlaying:n.isPlaying,currentTime:n.currentTime,volume:n.volume,isMuted:n.isMuted,isFullscreen:n.isFullscreen,playbackRate:n.playbackRate,subtitlesShowing:n.subtitlesShowing,previewTime:n.previewTime,progress:n.duration>0?n.currentTime/n.duration:0,formattedTime:ne(n.currentTime),formattedDuration:ne(n.duration),canPlay:!n.isLoading&&!n.error,hasError:!!n.error,isBuffering:n.isLoading}),[n]);return{state:n,actualState:t,...i,...l,dispatchOptimistic:m}}function ne(e){if(!e||!isFinite(e))return"0:00";const t=Math.floor(e/60),n=Math.floor(e%60),s=Math.floor(t/60);return s>0?`${s}:${String(t%60).padStart(2,"0")}:${String(n).padStart(2,"0")}`:`${t}:${String(n).padStart(2,"0")}`}function ye(e){const t=a.useRef(null),n=a.useRef(null),[s,m]=a.useTransition(),[l,i]=a.useTransition();a.useRef(0);const d=a.useRef(0),S=a.useRef(0);a.useRef();const R=a.useRef(0),F=D.useMediaStore(),w="getOptimisticState"in F,r=D.useMediaSelector(y=>y.isPlaying),E=D.useMediaSelector(y=>y.currentTime),v=D.useMediaSelector(y=>y.duration),c=D.useMediaSelector(y=>y.volume),h=D.useMediaSelector(y=>y.isMuted),L=D.useMediaSelector(y=>y.isLoading),f=D.useMediaSelector(y=>y.isBuffering),o=D.useMediaSelector(y=>y.error),g=D.useMediaSelector(y=>y.buffered),p=D.useMediaSelector(y=>y.isFullscreen),b=F,M=ve(b),T=ce(b),[H,C]=a.useState({frameRate:0,averageRenderTime:0,droppedFrames:0,bufferHealth:0}),[O,P]=a.useOptimistic(c,(y,I)=>Math.max(0,Math.min(1,I)));a.useOptimistic(E,(y,I)=>Math.max(0,Math.min(v||0,I))),a.useEffect(()=>{const y=t.current;if(!y)return;const I={volume:e.volume,muted:e.muted,autoplay:e.autoPlay,loop:e.loop,preload:e.preload,crossOrigin:e.crossOrigin};Object.entries(I).forEach(([$,j])=>{j!==void 0&&(y[$]=j)}),y.setAttribute("preload",e.preloadStrategy==="eager"?"auto":"metadata"),e.bufferingStrategy==="aggressive"&&y.setAttribute("buffered","auto"),y instanceof HTMLVideoElement&&(y.style.willChange="transform",y.style.transform="translateZ(0)")},[e.volume,e.muted,e.autoPlay,e.loop,e.preload,e.crossOrigin,e.preloadStrategy,e.bufferingStrategy]);const k=a.useCallback(()=>{const y=t.current;if(!y)return;const I=performance.now();if(e.enableTimeUpdateThrottling!==!1){if(I-R.current<(e.timeUpdateThrottleMs||100))return;R.current=I}m(()=>{w&&T&&T.setCurrentTime(y.currentTime)})},[e.enableTimeUpdateThrottling,e.timeUpdateThrottleMs,w,T]),A=a.useCallback(()=>{m(()=>{w&&T&&T.play(!0)}),e.onPlay?.()},[w,T,e.onPlay]),V=a.useCallback(()=>{m(()=>{w&&T&&T.pause(!0)}),e.onPause?.()},[w,T,e.onPause]),U=a.useCallback(()=>{const y=t.current;y&&m(()=>{w&&T&&(T.setVolume(y.volume,!0),y.muted?T.mute(!0):T.unmute(!0))})},[w,T]),x=a.useCallback(()=>{i(()=>{})},[]),W=a.useCallback(()=>{},[]),u=a.useCallback(()=>{const y=t.current;y&&m(()=>{w&&T&&T.setBuffered(y.buffered)})},[w,T]),_=a.useCallback(()=>{const y=performance.now();if(y-S.current>0&&(d.current++,d.current>=60)){const $=Math.round(d.current*1e3/(y-S.current));C(j=>({...j,frameRate:$,droppedFrames:Math.max(0,60-$)})),d.current=0,S.current=y}},[]);a.useEffect(()=>{const y=t.current;if(!y)return;const I=[{event:"timeupdate",handler:k,passive:!0},{event:"play",handler:A},{event:"pause",handler:V},{event:"volumechange",handler:U},{event:"seeking",handler:x},{event:"seeked",handler:W},{event:"progress",handler:u,passive:!0},{event:"loadedmetadata",handler:()=>_()},{event:"loadeddata",handler:()=>_()}];I.forEach(({event:X,handler:Z,passive:ee})=>{const te=ee?{passive:!0}:{};y.addEventListener(X,Z,te)});let $;const j=()=>{_(),$=requestAnimationFrame(j)};return e.enablePerformanceMonitoring&&j(),()=>{I.forEach(({event:X,handler:Z})=>{y.removeEventListener(X,Z)}),$&&cancelAnimationFrame($)}},[k,A,V,U,x,W,u,_,e.enablePerformanceMonitoring]);const q=a.useMemo(()=>{const y=async()=>{const N=t.current;if(N)if(w&&T)await T.play(!0);else try{await N.play()}catch(z){console.error("Failed to play media:",z)}},I=()=>{const N=t.current;N&&(w&&T?T.pause(!0):N.pause())};return{play:y,pause:I,toggle:()=>{r?I():y()},seek:N=>{const z=t.current;if(!z)return;const Y=Math.max(0,Math.min(N,v||0));w&&T?i(()=>{T.seek(Y,!0)}):z.currentTime=Y},setVolume:N=>{const z=t.current;if(!z)return;const Y=Math.max(0,Math.min(1,N));w&&T?(P(Y),m(()=>{T.setVolume(Y,!0)})):z.volume=Y},toggleMute:()=>{const N=t.current;N&&(w&&T?T.toggleMute(!0):N.muted=!N.muted)},enterFullscreen:async()=>{const N=n.current;if(!(!N||!document.fullscreenEnabled))try{await N.requestFullscreen(),w&&T&&T.enterFullscreen(!0)}catch(z){console.error("Failed to enter fullscreen:",z)}},exitFullscreen:async()=>{if(document.fullscreenElement)try{await document.exitFullscreen(),w&&T&&T.exitFullscreen(!0)}catch(N){console.error("Failed to exit fullscreen:",N)}}}},[r,v,w,T,m,i,P]),Q=a.useMemo(()=>({isPlaying:M?.isPlaying??r,currentTime:M?.currentTime??E,duration:M?.duration??v,volume:M?.volume??O,isMuted:M?.isMuted??h,isLoading:M?.isBuffering??L,isBuffering:M?.isBuffering??f,error:M?.error??o,buffered:M?.buffered??g,isFullscreen:M?.isFullscreen??p,progress:v>0?E/v:0,isTransitioning:s||l,canPlay:!L&&!f&&!o}),[M,r,E,v,O,h,L,f,o,g,p,s,l]);return{mediaRef:t,containerRef:n,state:Q,actualState:M?.actualState,controls:q,performanceMetrics:H,isTransitioning:s||l,actions:M?.actions,actionState:M?.actionState,optimisticState:M,isEnhanced:w}}function ue({enabled:e=!0,state:t,controls:n,seekStep:s=10,volumeStep:m=.1}){const l=i=>{if(!e)return;const d=i.target;if(!(d.tagName==="INPUT"||d.tagName==="TEXTAREA"||d.contentEditable==="true"))switch(i.code){case"Space":case"KeyK":i.preventDefault(),n.toggle();break;case"KeyM":i.preventDefault(),n.toggleMute();break;case"KeyF":i.preventDefault(),n.toggleFullscreen();break;case"ArrowLeft":i.preventDefault(),n.seek(Math.max(0,t.currentTime-s));break;case"ArrowRight":i.preventDefault(),n.seek(Math.min(t.duration,t.currentTime+s));break;case"ArrowUp":i.preventDefault(),n.setVolume(Math.min(1,t.volume+m));break;case"ArrowDown":i.preventDefault(),n.setVolume(Math.max(0,t.volume-m));break;case"Digit0":case"Digit1":case"Digit2":case"Digit3":case"Digit4":case"Digit5":case"Digit6":case"Digit7":case"Digit8":case"Digit9":i.preventDefault();const R=parseInt(i.code.replace("Digit",""),10)/10;n.seek(t.duration*R);break;case"Home":i.preventDefault(),n.seek(0);break;case"End":i.preventDefault(),n.seek(t.duration);break}};return a.useEffect(()=>{if(e)return document.addEventListener("keydown",l),()=>{document.removeEventListener("keydown",l)}},[e,l]),{handleKeyDown:l}}const Ee=Object.freeze(Object.defineProperty({__proto__:null,useKeyboardControls:ue},Symbol.toStringTag,{value:"Module"}));function Te(e={}){const{maxMemoryUsage:t=100,cleanupInterval:n=3e4,enableGC:s=!0,monitorMemory:m=!0}=e;a.useRef();const l=a.useRef(new Set),i=a.useRef(new Map),d=a.useRef(new Set),S=a.useRef(new Set),R=a.useCallback(()=>{if(typeof window>"u"||!("memory"in performance))return{used:0,total:0,limit:0};const f=performance.memory;return{used:f.usedJSHeapSize,total:f.totalJSHeapSize,limit:f.jsHeapSizeLimit}},[]),[F,w]=a.useState({used:0,total:0,limit:0,usage:0,isHighUsage:!1}),r=a.useCallback(()=>{d.current.forEach(f=>{clearTimeout(f)}),d.current.clear(),S.current.forEach(f=>{cancelAnimationFrame(f)}),S.current.clear(),l.current.forEach(f=>{f.disconnect()}),l.current.clear(),i.current.forEach((f,o)=>{f.forEach(({event:g,handler:p})=>{o.removeEventListener(g,p)})}),i.current.clear(),typeof window<"u"&&"gc"in window&&window.gc()},[]),E=a.useCallback((f,o)=>{const g=setInterval(f,o);return d.current.add(g),()=>{clearInterval(g),d.current.delete(g)}},[]);a.useEffect(()=>{if(!m)return;const f=()=>{const o=R(),g=o.used/1024/1024,p=g>t;w({...o,usage:g,isHighUsage:p}),p&&s&&r()};return f(),E(f,n)},[m,R,t,s,n,r]);const v=a.useCallback((f,o,g,p)=>(f.addEventListener(o,g,p),i.current.has(f)||i.current.set(f,[]),i.current.get(f).push({event:o,handler:g}),()=>{f.removeEventListener(o,g);const b=i.current.get(f);if(b){const M=b.findIndex(T=>T.event===o&&T.handler===g);M>-1&&b.splice(M,1),b.length===0&&i.current.delete(f)}}),[]),c=a.useCallback((f,o)=>{const g=c(f,o);return d.current.add(g),()=>{clearTimeout(g),d.current.delete(g)}},[]),h=a.useCallback(f=>{const o=h(f);return S.current.add(o),()=>{cancelAnimationFrame(o),S.current.delete(o)}},[]),L=a.useCallback(f=>(l.current.add(f),()=>{f.disconnect(),l.current.delete(f)}),[]);return a.useEffect(()=>()=>{r()},[r]),{memoryStats:F,getMemoryUsage:R,performCleanup:r,addEventListener:v,setInterval,setTimeout:c,requestAnimationFrame:h,addObserver:L,formatBytes:f=>{if(f===0)return"0 Bytes";const o=1024,g=["Bytes","KB","MB","GB"],p=Math.floor(Math.log(f)/Math.log(o));return parseFloat((f/Math.pow(o,p)).toFixed(2))+" "+g[p]}}}function le(){const[e,t]=a.useState({isPlaying:!1,currentTime:0,duration:0,volume:1,isMuted:!1,isLoading:!1,isFullscreen:!1,error:null,buffered:null}),n=r=>{t(E=>({...E,...r}))};return{state:e,updateState:n,setPlaying:r=>{n({isPlaying:r})},setCurrentTime:r=>{n({currentTime:r})},setDuration:r=>{n({duration:r})},setVolume:r=>{n({volume:Math.max(0,Math.min(1,r))})},setMuted:r=>{n({isMuted:r})},setLoading:r=>{n({isLoading:r})},setFullscreen:r=>{n({isFullscreen:r})},setError:r=>{n({error:r})},setBuffered:r=>{n({buffered:r})}}}function de(e){const t=a.useRef(null),n=a.useRef(null),{state:s,setPlaying:m,setCurrentTime:l,setDuration:i,setVolume:d,setMuted:S,setLoading:R,setFullscreen:F,setError:w,setBuffered:r}=le();a.useEffect(()=>{const u=t.current;u&&(e.volume!==void 0&&(u.volume=e.volume,d(e.volume)),e.muted!==void 0&&(u.muted=e.muted,S(e.muted)),e.autoPlay!==void 0&&(u.autoplay=e.autoPlay),e.loop!==void 0&&(u.loop=e.loop),e.preload!==void 0&&(u.preload=e.preload),e.crossOrigin!==void 0&&(u.crossOrigin=e.crossOrigin))},[e,d,S]);const E=()=>{m(!0),e.onPlay?.()},v=()=>{m(!1),e.onPause?.()},c=()=>{const u=t.current;u&&(l(u.currentTime),e.onTimeUpdate?.(u.currentTime))},h=()=>{const u=t.current;u&&(i(u.duration),e.onDurationChange?.(u.duration))},L=()=>{const u=t.current;u&&(d(u.volume),S(u.muted),e.onVolumeChange?.(u.volume))},f=()=>{R(!0),w(null),e.onLoadStart?.()},o=()=>{R(!1),e.onLoadedData?.()},g=()=>{const u=t.current;if(!u)return;const _=u.error?.message||"An error occurred while loading the media";w(_),R(!1),e.onError?.(_)},p=()=>{m(!1),e.onEnded?.()},b=()=>{const u=t.current;u&&r(u.buffered)};a.useEffect(()=>{const u=t.current;if(u)return u.addEventListener("play",E),u.addEventListener("pause",v),u.addEventListener("timeupdate",c),u.addEventListener("durationchange",h),u.addEventListener("volumechange",L),u.addEventListener("loadstart",f),u.addEventListener("loadeddata",o),u.addEventListener("error",g),u.addEventListener("ended",p),u.addEventListener("progress",b),()=>{u.removeEventListener("play",E),u.removeEventListener("pause",v),u.removeEventListener("timeupdate",c),u.removeEventListener("durationchange",h),u.removeEventListener("volumechange",L),u.removeEventListener("loadstart",f),u.removeEventListener("loadeddata",o),u.removeEventListener("error",g),u.removeEventListener("ended",p),u.removeEventListener("progress",b)}},[E,v,c,h,L,f,o,g,p,b]);const M=async()=>{const u=t.current;if(u)try{await u.play()}catch(_){console.error("Failed to play media:",_),w("Failed to play media")}},T=()=>{const u=t.current;u&&u.pause()},H=()=>{s.isPlaying?T():M()},C=u=>{const _=t.current;_&&(_.currentTime=Math.max(0,Math.min(u,_.duration||0)))},O=u=>{const _=t.current;if(!_)return;const q=Math.max(0,Math.min(1,u));_.volume=q},P=()=>{const u=t.current;u&&(u.muted=!0)},k=()=>{const u=t.current;u&&(u.muted=!1)},A=()=>{const u=t.current;u&&(u.muted=!u.muted)},V=async()=>{const u=n.current;if(!(!u||!document.fullscreenEnabled))try{await u.requestFullscreen(),F(!0)}catch(_){console.error("Failed to enter fullscreen:",_)}},U=async()=>{if(document.fullscreenElement)try{await document.exitFullscreen(),F(!1)}catch(u){console.error("Failed to exit fullscreen:",u)}},x=()=>{document.fullscreenElement?U():V()};return a.useEffect(()=>{const u=()=>{F(!!document.fullscreenElement)};return document.addEventListener("fullscreenchange",u),()=>{document.removeEventListener("fullscreenchange",u)}},[F]),{state:s,controls:{play:M,pause:T,toggle:H,seek:C,setVolume:O,mute:P,unmute:k,toggleMute:A,enterFullscreen:V,exitFullscreen:U,toggleFullscreen:x},mediaRef:t,containerRef:n}}const G={mobile:768,desktop:1280};function re(){if(typeof window>"u")return"unknown";const e=window.navigator.userAgent.toLowerCase();return/iphone|ipad|ipod/.test(e)?"ios":/android/.test(e)?"android":/windows|mac|linux/.test(e)?"desktop":"unknown"}function se(){return typeof window>"u"?!1:"ontouchstart"in window||navigator.maxTouchPoints>0||navigator.msMaxTouchPoints>0}function ae(){return typeof window>"u"?!1:"vibrate"in navigator||"vibration"in navigator||"ondevicemotion"in window}function J(){const[e,t]=K.useState(()=>{if(typeof window>"u")return{isMobile:!1,isTablet:!1,isDesktop:!0,isTouchDevice:!1,platform:"unknown",supportsHaptics:!1,screenSize:{width:1920,height:1080},orientation:"landscape"};const n=window.innerWidth,s=window.innerHeight;return{isMobile:n<G.mobile,isTablet:n>=G.mobile&&n<G.desktop,isDesktop:n>=G.desktop,isTouchDevice:se(),platform:re(),supportsHaptics:ae(),screenSize:{width:n,height:s},orientation:n>s?"landscape":"portrait"}});return K.useEffect(()=>{const n=()=>{const i=window.innerWidth,d=window.innerHeight;t({isMobile:i<G.mobile,isTablet:i>=G.mobile&&i<G.desktop,isDesktop:i>=G.desktop,isTouchDevice:se(),platform:re(),supportsHaptics:ae(),screenSize:{width:i,height:d},orientation:i>d?"landscape":"portrait"})};window.addEventListener("resize",n),window.addEventListener("orientationchange",n);const s=window.matchMedia(`(max-width: ${G.mobile-1}px)`),m=window.matchMedia(`(min-width: ${G.mobile}px) and (max-width: ${G.desktop-1}px)`),l=window.matchMedia(`(min-width: ${G.desktop}px)`);return s.addEventListener("change",n),m.addEventListener("change",n),l.addEventListener("change",n),()=>{window.removeEventListener("resize",n),window.removeEventListener("orientationchange",n),s.removeEventListener("change",n),m.removeEventListener("change",n),l.removeEventListener("change",n)}},[]),e}function we(){const{platform:e,isMobile:t}=J();K.useEffect(()=>{if(t){if(e==="ios"){const n=s=>{s.touches.length>1&&s.preventDefault()};return document.addEventListener("touchstart",n,{passive:!1}),document.body.style.webkitOverflowScrolling="touch",()=>{document.removeEventListener("touchstart",n)}}e==="android"&&(document.body.style.touchAction="manipulation"),document.documentElement.style.setProperty("--webkit-transform","translateZ(0)"),document.documentElement.style.setProperty("--transform","translateZ(0)")}},[e,t])}function be(){const{supportsHaptics:e}=J();return{triggerHaptic:K.useCallback((n="light")=>{if(!e)return;const m={light:[10],medium:[20],heavy:[30],success:[10,10,10],warning:[20,20],error:[50,20,50]}[n];"vibrate"in navigator&&navigator.vibrate(m)},[e]),supportsHaptics:e}}const Se={enabledGestures:["tap","double-tap","long-press","swipe-left","swipe-right","swipe-up","swipe-down","pinch-in","pinch-out"],tapThreshold:200,doubleTapThreshold:300,longPressThreshold:500,swipeThreshold:50,swipeVelocityThreshold:.5,pinchThreshold:.1,rotationThreshold:15,enableHapticFeedback:!0};function me(e,t,n={}){const s={...Se,...n},{isTouchDevice:m}=J(),{triggerHaptic:l}=be(),i=K.useRef({isTracking:!1,touches:[],startTouches:[]}),d=v=>({id:v.identifier,x:v.clientX,y:v.clientY,timestamp:Date.now()}),S=(v,c)=>Math.sqrt(Math.pow(c.x-v.x,2)+Math.pow(c.y-v.y,2)),R=(v,c)=>{const h=Math.max(c.timestamp-v.timestamp,1);return{x:(c.x-v.x)/h,y:(c.y-v.y)/h}},F=(v,c,h,L={})=>({type:v,startPoint:{x:c.x,y:c.y},currentPoint:{x:h.x,y:h.y},duration:h.timestamp-c.timestamp,target:e.current,preventDefault:()=>{},...L}),w=K.useCallback(v=>{if(!s.enabledGestures.length)return;const c=Array.from(v.touches).map(d),h=i.current;h.isTracking=!0,h.touches=c,h.startTouches=[...c],h.longPressTimer&&clearTimeout(h.longPressTimer),c.length===1&&s.enabledGestures.includes("long-press")&&(h.longPressTimer=setTimeout(()=>{if(h.touches.length===1&&c[0]){const L=F("long-press",c[0],c[0]);t(L),s.enableHapticFeedback&&l("heavy")}},s.longPressThreshold)),c.length===2&&c[0]&&c[1]&&(h.initialDistance=S(c[0],c[1]),h.initialScale=1,h.lastScale=1)},[s,t,l]),r=K.useCallback(v=>{const c=i.current;if(!c.isTracking)return;const h=Array.from(v.touches).map(d);if(c.touches=h,h.length===2&&c.initialDistance&&h[0]&&h[1]){const L=S(h[0],h[1]),f=L/c.initialDistance;if(Math.abs(f-(c.lastScale||1))>s.pinchThreshold){const g=f>(c.lastScale||1)?"pinch-out":"pinch-in";if(s.enabledGestures.includes(g)){const p={x:(h[0].x+h[1].x)/2,y:(h[0].y+h[1].y)/2,timestamp:Date.now()},b={x:((c.startTouches[0]?.x??0)+(c.startTouches[1]?.x??0))/2,y:((c.startTouches[0]?.y??0)+(c.startTouches[1]?.y??0))/2,timestamp:c.startTouches[0]?.timestamp??Date.now()},M=F(g,b,p,{scale:f,distance:L});t(M),c.lastScale=f}}}if(c.longPressTimer&&h.length===1&&c.startTouches[0]&&h[0]){const L=c.startTouches[0],f=h[0];S(L,f)>s.swipeThreshold&&(clearTimeout(c.longPressTimer),c.longPressTimer=void 0)}},[s,t]),E=K.useCallback(v=>{const c=i.current;if(!c.isTracking)return;const h=Array.from(v.changedTouches).map(d),L=Date.now();if(c.longPressTimer&&(clearTimeout(c.longPressTimer),c.longPressTimer=void 0),c.startTouches.length===1&&h.length===1&&c.startTouches[0]&&h[0]){const f=c.startTouches[0],o=h[0],g=S(f,o),p=o.timestamp-f.timestamp;if(g>s.swipeThreshold){const b=R(f,o),M=Math.abs(b.x),T=Math.abs(b.y);if(M>s.swipeVelocityThreshold||T>s.swipeVelocityThreshold){let H;if(M>T?H=b.x>0?"swipe-right":"swipe-left":H=b.y>0?"swipe-down":"swipe-up",s.enabledGestures.includes(H)){const C=F(H,f,o,{velocity:b,distance:g});t(C),s.enableHapticFeedback&&l("light")}}}else if(p<s.tapThreshold&&g<s.swipeThreshold)if(c.lastTap&&L-c.lastTap.timestamp<s.doubleTapThreshold&&S({...c.lastTap.point},o)<s.swipeThreshold){if(s.enabledGestures.includes("double-tap")){const b=F("double-tap",f,o);t(b),s.enableHapticFeedback&&l("medium")}c.lastTap=void 0}else{if(s.enabledGestures.includes("tap")){const b=F("tap",f,o);t(b),s.enableHapticFeedback&&l("light")}c.lastTap={timestamp:L,point:{x:o.x,y:o.y}}}}v.touches.length===0&&(c.isTracking=!1,c.touches=[],c.startTouches=[],c.initialDistance=void 0,c.initialScale=void 0,c.lastScale=void 0)},[s,t,l]);return K.useEffect(()=>{const v=e.current;if(!(!v||!m))return v.addEventListener("touchstart",w,{passive:!1}),v.addEventListener("touchmove",r,{passive:!1}),v.addEventListener("touchend",E,{passive:!1}),v.addEventListener("touchcancel",E,{passive:!1}),()=>{v.removeEventListener("touchstart",w),v.removeEventListener("touchmove",r),v.removeEventListener("touchend",E),v.removeEventListener("touchcancel",E)}},[w,r,E,m]),{isGestureEnabled:m&&s.enabledGestures.length>0}}function Me(e,t){const n=K.useCallback(m=>{const{type:l,distance:i,scale:d}=m;switch(l){case"double-tap":t.onPlayPause?.();break;case"swipe-left":const S=Math.min((i||0)/10,30);t.onSeek?.("backward",S);break;case"swipe-right":const R=Math.min((i||0)/10,30);t.onSeek?.("forward",R);break;case"swipe-up":if(m.startPoint.x>(e.current?.clientWidth||0)/2){const F=Math.min((i||0)/100,.2);t.onVolumeChange?.("up",F)}break;case"swipe-down":if(m.startPoint.x>(e.current?.clientWidth||0)/2){const F=Math.min((i||0)/100,.2);t.onVolumeChange?.("down",F)}break;case"pinch-out":t.onZoom?.(d||1);break;case"pinch-in":t.onZoom?.(d||1);break;case"long-press":t.onToggleFullscreen?.();break}},[t,e]);return me(e,n,{enabledGestures:["tap","double-tap","long-press","swipe-left","swipe-right","swipe-up","swipe-down","pinch-in","pinch-out"],enableHapticFeedback:!0,swipeThreshold:30,swipeVelocityThreshold:.3})}function fe({subtitleSrc:e,subtitleTracks:t=[],defaultFontSize:n="medium",onLoadError:s}={}){const[m,l]=a.useState(!1),[i,d]=a.useState([]),[S,R]=a.useState(""),[F,w]=a.useState(null),[r,E]=a.useState(n),[v,c]=a.useState(null),[h,L]=a.useState(!1),f={small:"text-sm",medium:"text-base",large:"text-lg"},o=!!(e||t&&t.length>0),g=P=>{const k=P.split(":"),A=k[2]?parseFloat(k[2]):0,V=k[1]?parseInt(k[1],10)*60:0;return(k[0]?parseInt(k[0],10)*3600:0)+V+A},p=P=>{const[k,A]=P.split(","),V=(k||"").split(":"),U=A?parseInt(A,10)/1e3:0,x=V[2]?parseInt(V[2],10):0,W=V[1]?parseInt(V[1],10)*60:0;return(V[0]?parseInt(V[0],10)*3600:0)+W+x+U},b=async P=>{L(!0),c(null);try{const k=await fetch(P);if(!k.ok)throw new Error(`Failed to load subtitles: ${k.status} ${k.statusText}`);const A=await k.text(),V=[],U=A.split(`
2
- `);let x=0;const W=A.includes("WEBVTT")||P.endsWith(".vtt"),u=P.endsWith(".srt")||/^\d+$/.test(U[0]?.trim()||"");if(W)for(;x<U.length;){if(U[x]?.includes("-->")){const[_,q]=(U[x]||"").split("-->").map($=>$.trim()),Q=g(_||""),y=g(q||"");x++;let I="";for(;x<U.length&&U[x]?.trim()!=="";)I+=(I?" ":"")+U[x]?.trim(),x++;I&&V.push({start:Q,end:y,text:I})}x++}else if(u)for(;x<U.length;){if(/^\d+$/.test(U[x]?.trim()||"")&&(x++,U[x]?.includes("-->"))){const[_,q]=(U[x]||"").split("-->").map($=>$.trim()),Q=p(_||""),y=p(q||"");x++;let I="";for(;x<U.length&&U[x]?.trim()!=="";)I+=(I?" ":"")+U[x]?.trim(),x++;I&&V.push({start:Q,end:y,text:I})}x++}else throw new Error("Unsupported subtitle format. Only VTT and SRT are supported.");if(V.length===0)throw new Error("No subtitle cues found in file");d(V),L(!1)}catch(k){const A=k instanceof Error?k:new Error("Failed to load subtitles");console.error("Failed to load subtitles:",A),c(A),L(!1),d([]),s?.(A)}},M=P=>!m||i.length===0?"":i.find(A=>P>=A.start&&P<=A.end)?.text||"",T=()=>{l(P=>{const k=!P;if(k&&!v){if(i.length===0&&!h){const A=e||t[0]?.src;A&&(b(A),t[0]&&w(t[0].id))}}else k||R("");return k})},H=P=>{if(!P){l(!1),w(null),R("");return}const k=t.find(A=>A.id===P);k?.src&&(w(P),b(k.src),l(!0))},C=P=>{E(P)},O={fontSize:f[r],className:`${f[r]} font-medium`};return a.useEffect(()=>{m||R("")},[m]),a.useEffect(()=>{},[]),{subtitlesEnabled:m,currentSubtitle:S,subtitleCues:i,currentTrackId:F,fontSize:r,loadError:v,isLoading:h,hasSubtitles:o,toggleSubtitles:T,selectSubtitleTrack:H,changeSubtitleFontSize:C,setCurrentSubtitle:R,getCurrentSubtitle:M,getSubtitleStyles:O,availableTracks:t}}const ke=Object.freeze(Object.defineProperty({__proto__:null,useEnhancedSubtitles:fe},Symbol.toStringTag,{value:"Module"}));function Le({videoControls:e,toggleSubtitles:t,takeScreenshot:n,duration:s}){const m=l=>{const i=document.querySelector("video");if(i)switch(l.key.toLowerCase()){case" ":case"k":l.preventDefault(),e.togglePlay();break;case"j":l.preventDefault(),e.seekBackward();break;case"l":l.preventDefault(),e.seekForward();break;case"arrowleft":l.preventDefault(),i.currentTime=Math.max(0,i.currentTime-5);break;case"arrowright":l.preventDefault(),i.currentTime=Math.min(s,i.currentTime+5);break;case"arrowup":l.preventDefault(),i.volume=Math.min(1,i.volume+.1);break;case"arrowdown":l.preventDefault(),i.volume=Math.max(0,i.volume-.1);break;case"m":l.preventDefault(),e.toggleMute();break;case"f":l.preventDefault(),e.toggleFullscreen();break;case"c":l.preventDefault(),t();break;case"s":l.preventDefault(),n(l.ctrlKey||l.metaKey);break}};a.useEffect(()=>(document.addEventListener("keydown",m),()=>document.removeEventListener("keydown",m)),[m])}function Pe(e,t){const[n,s]=a.useState(!0),[m,l]=a.useState(!1),i=a.useRef(null),d=()=>{s(!0),i.current&&clearTimeout(i.current),e&&!t&&(i.current=setTimeout(()=>{s(!1)},3e3))},S=()=>{d()},R=()=>{s(!0)},F=()=>{e&&s(!1)};return a.useEffect(()=>(d(),()=>{i.current&&clearTimeout(i.current)}),[d]),{controlsVisible:n,showVolumeSlider:m,setShowVolumeSlider:l,handleMouseMove:S,handleMouseEnter:R,handleMouseLeave:F}}function Ce(e){return{takeScreenshot:(n=!1)=>{if(!e.current)return;const s=e.current,m=document.createElement("canvas");m.width=s.videoWidth,m.height=s.videoHeight;const l=m.getContext("2d");if(l)try{l.drawImage(s,0,0),m.toBlob(i=>{if(!i){console.error("Failed to create blob from canvas");return}if(n)if(navigator.clipboard&&window.ClipboardItem){const d=new ClipboardItem({"image/png":i});navigator.clipboard.write([d]).catch(S=>{console.error("Failed to copy to clipboard:",S)})}else console.warn("Clipboard API not supported");else{const d=URL.createObjectURL(i),S=document.createElement("a");S.href=d,S.download=`screenshot-${Date.now()}.png`,S.click(),URL.revokeObjectURL(d)}},"image/png")}catch(i){i instanceof Error&&i.message.includes("tainted")?(console.error("Canvas is tainted - video source may not have proper CORS headers. Try setting crossOrigin='anonymous' on the video element."),alert("Screenshot failed: The video source doesn't allow screenshots due to CORS policy. Please ensure the video server includes proper CORS headers or set crossOrigin='anonymous' on the video player.")):(console.error("Screenshot failed:",i),alert("Screenshot failed: "+(i instanceof Error?i.message:"Unknown error")))}}}}function Fe(e){const t=a.useRef(null),[n,s]=a.useState({isPlaying:!1,currentTime:0,duration:0,volume:1,isMuted:!1,isFullscreen:!1,isLoading:!0,isSeeking:!1,isBuffering:!1,bufferedRanges:[]});return a.useEffect(()=>{const r=t.current;if(!r)return;const E=()=>{s(C=>({...C,currentTime:r.currentTime}))},v=()=>{s(C=>({...C,duration:r.duration}))},c=()=>{s(C=>({...C,isPlaying:!0,isBuffering:!1}))},h=()=>{s(C=>({...C,isPlaying:!1}))},L=()=>{s(C=>({...C,volume:r.volume,isMuted:r.muted}))},f=()=>{s(C=>({...C,isLoading:!0}))},o=()=>{s(C=>({...C,isLoading:!1}))},g=()=>{s(C=>({...C,isSeeking:!0}))},p=()=>{s(C=>({...C,isSeeking:!1}))},b=()=>{s(C=>({...C,isBuffering:!0}))},M=()=>{s(C=>({...C,isBuffering:!1,isLoading:!1}))},T=()=>{s(C=>({...C,isLoading:!1,isBuffering:!1}))},H=()=>{if(!r.buffered||r.buffered.length===0||r.duration===0){s(O=>({...O,bufferedRanges:[]}));return}const C=[];for(let O=0;O<r.buffered.length;O++){const P=r.buffered.start(O),k=r.buffered.end(O);C.push({start:P,end:k,percentage:(k-P)/r.duration*100})}s(O=>({...O,bufferedRanges:C}))};return r.addEventListener("timeupdate",E),r.addEventListener("loadedmetadata",v),r.addEventListener("play",c),r.addEventListener("pause",h),r.addEventListener("volumechange",L),r.addEventListener("loadstart",f),r.addEventListener("loadeddata",o),r.addEventListener("seeking",g),r.addEventListener("seeked",p),r.addEventListener("waiting",b),r.addEventListener("playing",M),r.addEventListener("canplay",T),r.addEventListener("progress",H),()=>{r.removeEventListener("timeupdate",E),r.removeEventListener("loadedmetadata",v),r.removeEventListener("play",c),r.removeEventListener("pause",h),r.removeEventListener("volumechange",L),r.removeEventListener("loadstart",f),r.removeEventListener("loadeddata",o),r.removeEventListener("seeking",g),r.removeEventListener("seeked",p),r.removeEventListener("waiting",b),r.removeEventListener("playing",M),r.removeEventListener("canplay",T),r.removeEventListener("progress",H)}},[]),{videoRef:t,state:n,controls:{togglePlay:()=>{const r=t.current;r&&(n.isPlaying?r.pause():r.play())},seekForward:(r=10)=>{const E=t.current;E&&(E.currentTime=Math.min(n.duration,E.currentTime+r))},seekBackward:(r=10)=>{const E=t.current;E&&(E.currentTime=Math.max(0,E.currentTime-r))},toggleMute:()=>{const r=t.current;r&&(r.muted=!n.isMuted)},setVolume:r=>{const E=t.current;E&&(E.volume=r,r>0&&n.isMuted&&(E.muted=!1))},toggleFullscreen:()=>{const r=e.current;r&&(n.isFullscreen?document.exitFullscreen&&document.exitFullscreen():r.requestFullscreen&&r.requestFullscreen(),s(E=>({...E,isFullscreen:!E.isFullscreen})))},seekTo:r=>{const E=t.current;!E||n.duration===0||(E.currentTime=Math.max(0,Math.min(n.duration,r)))}}}}const De=(e,t={})=>{const{trackUserBehavior:n=!0,adaptToNetwork:s=!0,strategy:m="balanced",maxPreloadItems:l=3,preloadRadius:i=2}=t,d=a.useRef({mouseMovements:0,scrollEvents:0,keyPresses:0,focusEvents:0,timeOnPage:0,engagementScore:0,lastInteraction:Date.now()}),S=a.useRef(null),R=a.useRef(new Set),F=a.useRef([]),w=a.useCallback(()=>{const o=d.current,g=Math.min(o.timeOnPage/6e4,1),p=Math.min((o.mouseMovements+o.scrollEvents+o.keyPresses)/100,1);return(g*.4+p*.6)*100},[]),r=a.useCallback((o,g=1)=>{const p=d.current;p[o]=typeof p[o]=="number"?p[o]+g:Date.now(),p.engagementScore=w(),p.lastInteraction=Date.now()},[w]),E=a.useCallback(()=>{if(!S.current||!s)return{type:"unknown",downlink:10,effectiveType:"4g",saveData:!1};const o=S.current;return{type:o.type,downlink:o.downlink||10,effectiveType:o.effectiveType||"4g",saveData:o.saveData||!1,rtt:o.rtt||100}},[s]),v=a.useCallback((o,g,p=0)=>{if(R.current.has(o.src))return{shouldPreload:!1,priority:"low",reason:"Already preloaded"};const b=Math.abs(g-p);if(b>i)return{shouldPreload:!1,priority:"low",reason:"Outside preload radius"};const M=d.current,T=E(),H=M.engagementScore,C=Date.now()-M.lastInteraction;if(T.saveData)return{shouldPreload:!1,priority:"low",reason:"Data saver mode"};let O=!1,P="medium",k="";switch(m){case"conservative":O=H>70&&T.effectiveType!=="2g"&&b===1,P=O?"medium":"low",k=O?"High engagement and optimal network":"Conservative strategy";break;case"aggressive":O=H>30&&T.effectiveType!=="slow-2g",P=H>70?"high":H>50?"medium":"low",k=O?"Aggressive preloading":"Low engagement";break;case"balanced":default:const A=T.effectiveType==="4g"?1:T.effectiveType==="3g"?.7:.3,V=H*A;O=V>40&&b<=2,P=V>70?"high":V>55?"medium":"low",k=O?`Balanced: score ${V.toFixed(1)}`:"Low adjusted score";break}return O&&((o.type==="hls"||o.type==="m3u8")&&(P=P==="low"?"medium":"high"),C<5e3&&(P="high",k+=" + Recent interaction"),(o.type==="mp4"||o.type==="webm")&&(P=P==="low"?"medium":P)),{shouldPreload:O,priority:P,reason:k}},[m,i,E,w]),c=a.useCallback(async(o,g)=>{try{const p=document.createElement("link");switch(p.rel="preload",p.href=o.src,o.type){case"hls":case"m3u8":p.as="fetch";break;case"mp4":case"webm":p.as="video";break;case"mp3":case"wav":case"ogg":p.as="audio";break;default:p.as="fetch"}p.crossOrigin="anonymous",document.head.appendChild(p),R.current.add(o.src),console.debug(`Preloaded: ${o.src} (${g})`),setTimeout(()=>{document.head.contains(p)&&document.head.removeChild(p)},3e4)}catch(p){console.warn("Failed to preload source:",o.src,p)}},[]),h=a.useCallback(()=>{if(F.current.length===0)return;const g=[...F.current].sort((p,b)=>b.priority-p.priority).slice(0,l);F.current=[],g.forEach(({source:p,priority:b})=>{c(p,b)})},[l,c]),L=a.useCallback((o=0)=>{F.current=[],e.forEach((g,p)=>{const b=v(g,p,o);if(b.shouldPreload){const M=b.priority==="high"?3:b.priority==="medium"?2:1;F.current.push({source:g,priority:M})}}),h()},[e,v,h]);return a.useEffect(()=>{if(!n)return;const o=()=>r("mouseMovements"),g=()=>r("scrollEvents"),p=()=>r("keyPresses"),b=()=>r("focusEvents");document.addEventListener("mousemove",o,{passive:!0}),document.addEventListener("scroll",g,{passive:!0}),document.addEventListener("keydown",p,{passive:!0}),document.addEventListener("focusin",b,{passive:!0});const M=setInterval(()=>{r("timeOnPage",1)},1e3);return()=>{document.removeEventListener("mousemove",o),document.removeEventListener("scroll",g),document.removeEventListener("keydown",p),document.removeEventListener("focusin",b),clearInterval(M)}},[n,r]),a.useEffect(()=>{if(!s||!("connection"in navigator))return;const o=navigator.connection;S.current=o;const g=()=>{L()};return o.addEventListener("change",g),()=>{o.removeEventListener("change",g)}},[s,L]),a.useEffect(()=>{L()},[L]),a.useMemo(()=>({preloadAtIndex:o=>{L(o)},getUserBehavior:()=>({...d.current}),getNetworkConditions:E,clearCache:()=>{R.current.clear()},getStats:()=>({preloadedItems:R.current.size,engagementScore:d.current.engagementScore,queueLength:F.current.length,maxPreloadItems:l})}),[L,E,l])};function he(e){const[t,n]=a.useState(!1),[s,m]=a.useState([]),[l,i]=a.useState(""),d=w=>{const r=w.split(":"),E=r[2]?parseFloat(r[2]):0,v=r[1]?parseInt(r[1],10)*60:0;return(r[0]?parseInt(r[0],10)*3600:0)+v+E},S=async w=>{try{const E=await(await fetch(w)).text(),v=[],c=E.split(`
3
- `);let h=0;for(;h<c.length;){if(c[h]?.includes("-->")){const[L,f]=(c[h]||"").split("-->").map(b=>b.trim()),o=d(L||""),g=d(f||"");h++;let p="";for(;h<c.length&&c[h]?.trim()!=="";)p+=(p?" ":"")+c[h]?.trim(),h++;p&&v.push({start:o,end:g,text:p})}h++}m(v)}catch(r){console.error("Failed to load subtitles:",r)}},R=w=>!t||s.length===0?"":s.find(E=>w>=E.start&&w<=E.end)?.text||"",F=()=>{n(w=>{const r=!w;return r&&e&&s.length===0?S(e):r||i(""),r})};return a.useEffect(()=>{t||i("")},[t]),{subtitlesEnabled:t,currentSubtitle:l,toggleSubtitles:F,getCurrentSubtitle:R,setCurrentSubtitle:i}}function Re(e){return ie.showDeprecationWarning("useVideoPlayer","useMediaPlayer (the primary media player hook)"),de(e)}function xe(e){return ie.showDeprecationWarning("useEnhancedSubtitles","useSubtitles (the current subtitle hook)"),he(e)}exports.useDeviceInfo=J;exports.useEnhancedMediaPlayer=ye;exports.useEnhancedSubtitles=fe;exports.useEnhancedSubtitles$1=xe;exports.useEnhancedSubtitles$2=ke;exports.useIntelligentPreloading=De;exports.useKeyboardControls=ue;exports.useKeyboardControls$1=Ee;exports.useKeyboardShortcuts=Le;exports.useMediaActionState=oe;exports.useMediaActions=ce;exports.useMediaControls=Pe;exports.useMediaGestures=Me;exports.useMediaPlayer=de;exports.useMediaState=le;exports.useMemoryOptimization=Te;exports.useMobileOptimizations=we;exports.useScreenshot=Ce;exports.useSubtitles=he;exports.useTouchGestures=me;exports.useVideoPlayer=Fe;exports.useVideoPlayer$1=Re;
4
- //# sourceMappingURL=hooks-BW-JjVgP.cjs.map