@rixl/media-core 1.0.2 → 1.1.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 (173) hide show
  1. package/README.md +74 -84
  2. package/dist/chunks/B-QvSqjj.js +1 -0
  3. package/dist/chunks/B2DDE32u.js +1 -0
  4. package/dist/chunks/BZFoe94X.js +1 -0
  5. package/dist/chunks/DMkwQjgA.js +1 -0
  6. package/dist/index.d.ts +2005 -82
  7. package/dist/index.js +6 -73
  8. package/package.json +13 -6
  9. package/dist/api/analytics.d.ts +0 -16
  10. package/dist/api/analytics.js +0 -227
  11. package/dist/api/feed.js +0 -52
  12. package/dist/api/heatmap.d.ts +0 -6
  13. package/dist/api/heatmap.js +0 -28
  14. package/dist/api/hot-segments.d.ts +0 -7
  15. package/dist/api/hot-segments.js +0 -20
  16. package/dist/api/image.js +0 -11
  17. package/dist/api/rixl-client.d.ts +0 -3
  18. package/dist/api/rixl-client.js +0 -14
  19. package/dist/api/upload.d.ts +0 -76
  20. package/dist/api/upload.js +0 -150
  21. package/dist/api/video.js +0 -11
  22. package/dist/lib/analytics-builders.d.ts +0 -59
  23. package/dist/lib/analytics-builders.js +0 -88
  24. package/dist/lib/analytics-initialize.d.ts +0 -1
  25. package/dist/lib/analytics-initialize.js +0 -59
  26. package/dist/lib/analytics-utils.d.ts +0 -43
  27. package/dist/lib/analytics-utils.js +0 -85
  28. package/dist/lib/analytics-wire.js +0 -153
  29. package/dist/lib/buffer-progress.d.ts +0 -20
  30. package/dist/lib/buffer-progress.js +0 -37
  31. package/dist/lib/caption-styles.d.ts +0 -20
  32. package/dist/lib/caption-styles.js +0 -56
  33. package/dist/lib/caption-utils.d.ts +0 -80
  34. package/dist/lib/caption-utils.js +0 -111
  35. package/dist/lib/chapter-utils.d.ts +0 -102
  36. package/dist/lib/chapter-utils.js +0 -147
  37. package/dist/lib/click-disambiguation.d.ts +0 -44
  38. package/dist/lib/click-disambiguation.js +0 -80
  39. package/dist/lib/click-outside.d.ts +0 -68
  40. package/dist/lib/click-outside.js +0 -64
  41. package/dist/lib/colors.d.ts +0 -6
  42. package/dist/lib/colors.js +0 -16
  43. package/dist/lib/content-analytics.d.ts +0 -27
  44. package/dist/lib/content-analytics.js +0 -38
  45. package/dist/lib/environment-effects.d.ts +0 -89
  46. package/dist/lib/environment-effects.js +0 -139
  47. package/dist/lib/feed-autoscroll.d.ts +0 -10
  48. package/dist/lib/feed-autoscroll.js +0 -13
  49. package/dist/lib/feed-container-height.d.ts +0 -7
  50. package/dist/lib/feed-container-height.js +0 -11
  51. package/dist/lib/feed-description-overflow.d.ts +0 -1
  52. package/dist/lib/feed-description-overflow.js +0 -9
  53. package/dist/lib/feed-dwell.d.ts +0 -2
  54. package/dist/lib/feed-dwell.js +0 -8
  55. package/dist/lib/feed-loop.d.ts +0 -10
  56. package/dist/lib/feed-loop.js +0 -21
  57. package/dist/lib/feed-scroll.d.ts +0 -11
  58. package/dist/lib/feed-scroll.js +0 -19
  59. package/dist/lib/feed-transforms.d.ts +0 -5
  60. package/dist/lib/feed-transforms.js +0 -30
  61. package/dist/lib/filter-undefined.js +0 -11
  62. package/dist/lib/fullscreen-utils.d.ts +0 -1
  63. package/dist/lib/fullscreen-utils.js +0 -7
  64. package/dist/lib/hls-buffer-flush.js +0 -46
  65. package/dist/lib/hls-error-recovery.d.ts +0 -35
  66. package/dist/lib/hls-error-recovery.js +0 -75
  67. package/dist/lib/hls-event-handlers.js +0 -61
  68. package/dist/lib/hls-loader.js +0 -23
  69. package/dist/lib/hls-setup.d.ts +0 -72
  70. package/dist/lib/hls-setup.js +0 -144
  71. package/dist/lib/hls-utils.d.ts +0 -31
  72. package/dist/lib/hls-utils.js +0 -34
  73. package/dist/lib/image-render.d.ts +0 -29
  74. package/dist/lib/image-render.js +0 -63
  75. package/dist/lib/keyboard-config.d.ts +0 -66
  76. package/dist/lib/keyboard-config.js +0 -127
  77. package/dist/lib/keyboard-utils.d.ts +0 -4
  78. package/dist/lib/keyboard-utils.js +0 -11
  79. package/dist/lib/lifecycle-effects.d.ts +0 -67
  80. package/dist/lib/lifecycle-effects.js +0 -78
  81. package/dist/lib/loading-debounce.d.ts +0 -26
  82. package/dist/lib/loading-debounce.js +0 -38
  83. package/dist/lib/numbers.d.ts +0 -6
  84. package/dist/lib/numbers.js +0 -36
  85. package/dist/lib/pip-utils.d.ts +0 -16
  86. package/dist/lib/pip-utils.js +0 -32
  87. package/dist/lib/playback-handlers.d.ts +0 -33
  88. package/dist/lib/playback-handlers.js +0 -51
  89. package/dist/lib/playback-slider.d.ts +0 -23
  90. package/dist/lib/playback-slider.js +0 -24
  91. package/dist/lib/player-labels.d.ts +0 -23
  92. package/dist/lib/player-labels.js +0 -132
  93. package/dist/lib/player-menu-labels.d.ts +0 -80
  94. package/dist/lib/player-menu-labels.js +0 -829
  95. package/dist/lib/player-ui-actions.d.ts +0 -10
  96. package/dist/lib/player-ui-actions.js +0 -58
  97. package/dist/lib/progress-fraction.d.ts +0 -11
  98. package/dist/lib/progress-fraction.js +0 -20
  99. package/dist/lib/progress-persist.d.ts +0 -28
  100. package/dist/lib/progress-persist.js +0 -54
  101. package/dist/lib/segment-analytics.d.ts +0 -20
  102. package/dist/lib/segment-analytics.js +0 -29
  103. package/dist/lib/subtitle-logic.d.ts +0 -31
  104. package/dist/lib/subtitle-logic.js +0 -75
  105. package/dist/lib/subtitle-utils.d.ts +0 -16
  106. package/dist/lib/subtitle-utils.js +0 -37
  107. package/dist/lib/time.d.ts +0 -1
  108. package/dist/lib/time.js +0 -17
  109. package/dist/lib/track-persistence.d.ts +0 -4
  110. package/dist/lib/track-persistence.js +0 -35
  111. package/dist/lib/video-preload-config.d.ts +0 -34
  112. package/dist/lib/video-preload-config.js +0 -41
  113. package/dist/lib/video-spinner.d.ts +0 -25
  114. package/dist/lib/video-spinner.js +0 -35
  115. package/dist/lib/video-stats.d.ts +0 -28
  116. package/dist/lib/video-stats.js +0 -44
  117. package/dist/lib/volume-utils.d.ts +0 -59
  118. package/dist/lib/volume-utils.js +0 -55
  119. package/dist/progressbar.d.ts +0 -10
  120. package/dist/progressbar.js +0 -125
  121. package/dist/store/analytics-context-store.d.ts +0 -4
  122. package/dist/store/analytics-context-store.js +0 -13
  123. package/dist/store/analytics-device-store.d.ts +0 -8
  124. package/dist/store/analytics-device-store.js +0 -44
  125. package/dist/store/analytics-session-store.d.ts +0 -8
  126. package/dist/store/analytics-session-store.js +0 -40
  127. package/dist/store/analytics-store.d.ts +0 -30
  128. package/dist/store/analytics-store.js +0 -88
  129. package/dist/store/controls-store.d.ts +0 -16
  130. package/dist/store/controls-store.js +0 -53
  131. package/dist/store/feed-cache-store.d.ts +0 -24
  132. package/dist/store/feed-cache-store.js +0 -165
  133. package/dist/store/feed-interaction-store.d.ts +0 -17
  134. package/dist/store/feed-interaction-store.js +0 -32
  135. package/dist/store/feed-store.d.ts +0 -16
  136. package/dist/store/feed-store.js +0 -38
  137. package/dist/store/generic-store.js +0 -24
  138. package/dist/store/image-store.d.ts +0 -2
  139. package/dist/store/image-store.js +0 -8
  140. package/dist/store/player-container-element-store.d.ts +0 -10
  141. package/dist/store/player-container-element-store.js +0 -38
  142. package/dist/store/player-global-actions.js +0 -53
  143. package/dist/store/player-media-element-store.d.ts +0 -10
  144. package/dist/store/player-media-element-store.js +0 -38
  145. package/dist/store/player-store-actions.js +0 -197
  146. package/dist/store/player-store.d.ts +0 -94
  147. package/dist/store/player-store.js +0 -127
  148. package/dist/store/player-track-actions.js +0 -44
  149. package/dist/store/postStore.d.ts +0 -20
  150. package/dist/store/postStore.js +0 -112
  151. package/dist/store/settings/constants.d.ts +0 -15
  152. package/dist/store/settings/constants.js +0 -47
  153. package/dist/store/settings/defaults.d.ts +0 -2
  154. package/dist/store/settings/defaults.js +0 -24
  155. package/dist/store/settings/storage.d.ts +0 -3
  156. package/dist/store/settings/storage.js +0 -28
  157. package/dist/store/settings/store.d.ts +0 -32
  158. package/dist/store/settings/store.js +0 -59
  159. package/dist/store/settings/types.d.ts +0 -27
  160. package/dist/store/settings/validation.d.ts +0 -7
  161. package/dist/store/settings/validation.js +0 -55
  162. package/dist/store/settings-menu-store.d.ts +0 -19
  163. package/dist/store/settings-menu-store.js +0 -30
  164. package/dist/store/video-store.d.ts +0 -2
  165. package/dist/store/video-store.js +0 -8
  166. package/dist/types/analytics.d.ts +0 -113
  167. package/dist/types/feed.d.ts +0 -21
  168. package/dist/types/file.d.ts +0 -12
  169. package/dist/types/heatmap.d.ts +0 -5
  170. package/dist/types/hot-segments.d.ts +0 -9
  171. package/dist/types/image.d.ts +0 -9
  172. package/dist/types/uuid.d.ts +0 -1
  173. package/dist/types/video.d.ts +0 -22
package/README.md CHANGED
@@ -1,119 +1,109 @@
1
- # RIXL Media SDK
1
+ # Rixl Media Core
2
2
 
3
- The [RIXL Media SDK](https://rixl.com/en/docs/mediasdk) enables you to build custom media experiences with RIXL's core technology through a highly optimized TypeScript library.
3
+ Headless TypeScript APIs for Rixl images, video, uploads, and media feeds. `@rixl/media-core` provides media fetching and caching, reactive player stores, HLS utilities, captions, and analytics without a UI framework.
4
4
 
5
- The library provides a framework-agnostic foundation for media playback experiences: fetching, caching, player state stores, analytics, and pure helpers for progress, buffering, chapters, captions, and more. It powers the UI components in `@rixl/media-react`, `@rixl/media-vue`, `@rixl/media-svelte`, `@rixl/media-angular`, `@rixl/media-astro`, and `@rixl/media-lit`, and can be used directly from any JavaScript/TypeScript project (vanilla, custom web components, Node.js).
5
+ [Documentation](https://developers.rixl.com/en/sdk/media-core) · [npm](https://www.npmjs.com/package/@rixl/media-core) · [Dashboard](https://dash.rixl.com)
6
6
 
7
- Use of this SDK is subject to our [Terms of Use](https://rixl.com/en/mediasdk-terms/).
7
+ ## When to use Core
8
8
 
9
- ## Installation
9
+ Use Core to build your own media interface, integrate Rixl into an existing player, or upload media. For ready-made components, install your framework's media package instead: it includes Core and exposes these APIs through `/core`.
10
10
 
11
- For headless usage, install the core package. For UI components, install only your framework package (`@rixl/media-react`, `@rixl/media-vue`, `@rixl/media-svelte`, `@rixl/media-angular`, `@rixl/media-astro`, or `@rixl/media-lit`); it installs core automatically and exposes the same APIs through its `/core` subpath.
11
+ - Fetch image and video metadata and paginate feed posts.
12
+ - Upload images, videos, audio tracks, subtitles, and feed posts using presigned URLs.
13
+ - Read and control individual players through shared reactive stores.
14
+ - Reuse progress, buffering, chapters, captions, quality, and analytics utilities.
15
+ - Import pure helpers on the server; initialize browser-dependent interactions in the browser.
12
16
 
13
- ```bash
17
+ ## Install
18
+
19
+ ```sh
14
20
  npm install @rixl/media-core
15
- # or
16
- pnpm add @rixl/media-core
17
- # or
18
- bun add @rixl/media-core
19
21
  ```
20
22
 
21
- ## Media Fetching
23
+ ES modules and TypeScript declarations are included. No React, Vue, Svelte, Angular, or Lit installation is required for headless usage.
22
24
 
23
- | Function | Description |
24
- | --------------------------------------- | ----------------------------------- |
25
- | `getImage(imageId)` | Fetches image data by ID |
26
- | `getVideo(videoId)` | Fetches video data by ID |
27
- | `getFeedPost(feedId, postId)` | Fetches a single post from a feed |
28
- | `getFeedPosts(feedId, offset?, limit?)` | Fetches paginated posts from a feed |
25
+ ## Quick start
29
26
 
30
- ### Usage:
27
+ Connect once before requesting media. Use a Rixl API endpoint and credentials intended for the environment running this code.
31
28
 
32
- ```typescript
33
- // Fetch image data
34
- const imageData = await getImage("image-id");
29
+ ```ts
30
+ import {connect, getImage, getVideo, getFeedPosts} from "@rixl/media-core";
35
31
 
36
- // Fetch video data
37
- const videoData = await getVideo("video-id");
32
+ await connect({
33
+ baseUrl: "https://api.rixl.com",
34
+ apiKey: "YOUR_API_KEY",
35
+ });
38
36
 
39
- // Fetch a single post from a feed
40
- const post = await getFeedPost("feed-id", "post-id");
37
+ const image = await getImage("YOUR_IMAGE_ID");
38
+ const video = await getVideo("YOUR_VIDEO_ID");
39
+ const page = await getFeedPosts("YOUR_FEED_ID", 0, 10);
41
40
 
42
- // Fetch paginated posts from a feed
43
- const posts = await getFeedPosts("feed-id", 0, 10);
41
+ console.log(image.file.url);
42
+ console.log(video.file.url);
43
+ console.log(page.posts, page.total);
44
44
  ```
45
45
 
46
- ### TypeScript Types
46
+ If your application already authenticates the shared `@rixl/sdk` client, reuse that connection. Browser applications should use credentials intended for client access; keep server credentials on the server.
47
+
48
+ ## Media APIs
47
49
 
48
- The library exports the following TypeScript types:
50
+ | API | Returns | Use |
51
+ | --------------------------------------- | ---------------------------- | --------------------------------------------------- |
52
+ | `getImage(imageId)` | `Promise<ImageData>` | Image metadata and file URL |
53
+ | `getVideo(videoId)` | `Promise<VideoData>` | Video metadata, source URL, poster, and chapters |
54
+ | `getFeedPost(feedId, postId)` | `Promise<FeedPost>` | One feed post |
55
+ | `getFeedPosts(feedId, offset?, limit?)` | `Promise<FeedPostsResponse>` | A page of posts; defaults to offset `0`, limit `10` |
49
56
 
50
- | Type | Description |
51
- | ------------------- | ---------------------------------------------- |
52
- | `ImageData` | Image metadata and URLs |
53
- | `VideoData` | Video metadata, URLs, and playback information |
54
- | `FeedPost` | Feed post content and metadata |
55
- | `FeedPostsResponse` | Paginated response for feed posts |
56
- | `FileStatus` | Status of a media file |
57
- | `FileData` | Generic file metadata |
57
+ Image, video, and individual post lookups reuse cached records and pending requests. Feed pagination caches its initial page; later pages are requested from the API.
58
58
 
59
- ## Player State
59
+ ## Upload media
60
60
 
61
- Reactive [nanostores](https://github.com/nanostores/nanostores) for media playback state. All stores are framework-agnostic; consume them in React via `@nanostores/react`, in Vue via `@nanostores/vue`, etc.
61
+ ```ts
62
+ import {uploadImage} from "@rixl/media-core";
62
63
 
63
- | Store | Description |
64
- | ----------------------------- | ----------------------------------------------------------------------- |
65
- | `playerStateStore` | Per-player playback state (mute, volume, rate, tracks, fullscreen, PiP) |
66
- | `controlsStore` | UI controls visibility/state |
67
- | `settingsStore` | User settings (caption styling, language preferences, playback speed) |
68
- | `postStore` | Active post/content metadata |
69
- | `analyticsStore` | Watched-segments tracking for analytics payloads |
70
- | `feedStore` | Feed interaction state (transitions, initialization) |
71
- | `feedCacheStore` | Cached feed pages |
72
- | `playerContainerElementStore` | Reference to the active player container element |
73
- | `playerMediaElementStore` | Reference to the active media element |
64
+ export async function uploadPhoto(file: File) {
65
+ const result = await uploadImage(file, {
66
+ projectId: "YOUR_PROJECT_ID",
67
+ name: file.name,
68
+ });
69
+ return result.imageId;
70
+ }
71
+ ```
74
72
 
75
- ## Progress Bar & Player UI Actions
73
+ Call this after connecting. Upload helpers accept `Blob` or `Uint8Array`, request presigned upload targets, and send the bytes to storage. Upload completion does not mean media processing has finished.
76
74
 
77
- | Function | Description |
78
- | ----------------------------------------------- | --------------------------------------------------- |
79
- | `initProgressBar({video, ...})` | Wires drag/seek interactions to a video element |
80
- | `showPlayerControls()` / `hidePlayerControls()` | Toggle controls visibility |
81
- | `togglePlayerFullscreen()` | Enter/exit fullscreen for the active player |
82
- | `togglePlayerPictureInPicture()` | Enter/exit picture-in-picture for the active player |
75
+ Use `createImageUpload`, `createVideoUpload`, `createAudioTrackUpload`, `createSubtitleUpload`, and `createPostUpload` when you need to handle the file transfer yourself. See the [upload guide](https://developers.rixl.com/en/sdk/media-core/upload) for each signature.
83
76
 
84
- ## Pure Helpers
77
+ ## Player state and actions
85
78
 
86
- Selected utilities (fully tree-shakeable):
79
+ Core stores are shared with the UI packages, so custom controls can use the same player state.
87
80
 
88
- - **Progress / buffer:** `computeProgressFraction`, `computeBufferRanges`, `computeBufferedAhead`
89
- - **Chapters & heatmap:** `calculateChaptersWithEnd`, `calculateHeatmapSlices`, `sliceHeatmapData`, `validateChapters`
90
- - **Subtitles & captions:** `extractSubtitleTracks`, `processCues`, `findNextCue`, `calculateFontSize`, `constrainPercentagePosition`
91
- - **Volume / fullscreen / PiP:** `calculateVolumeToSet`, `shouldBeMuted`, `isEffectivelyMuted`, `isDocumentFullscreen`, `togglePictureInPicture`
92
- - **Persistence:** `getPersistedProgress`, `persistProgress`, `getPersistedAudioTrack`, `getPersistedSubtitleTrack`, `loadSettings`, `saveSettings`
93
- - **HLS / quality:** `sortLevelsByQuality`, `generateLevelName`, `getQualityLabel`, `isHlsStream`
94
- - **Analytics:** `postContentEvent`, `buildVideoAnalyticsPayload`, `buildContentViewEvent`, `calculateWatchDuration`
95
- - **Formatting:** `formatTime`, `formatNumber`, `formatNumberSm`, `clamp`, `hexToRGB`, `hexToRGBAString`
81
+ | Export | Purpose |
82
+ | ------------------------------------------ | ------------------------------------------------------- |
83
+ | `playerStateStore` | Playback, volume, tracks, seeking, and per-player state |
84
+ | `settingsStore` | Shared player preferences and caption settings |
85
+ | `controlsStore` | Player controls visibility |
86
+ | `playerMediaElementStore` | Registered media elements |
87
+ | `playerContainerElementStore` | Registered player containers |
88
+ | `postStore`, `feedStore`, `feedCacheStore` | Feed content, interaction state, and cached pages |
89
+ | `analyticsStore` | Watched segments and analytics state |
96
90
 
97
- ## API Reference
91
+ Player actions use a player ID. For example, `showPlayerControls(playerId)` and `togglePlayerFullscreen(playerId)` target that player's registered elements. React's scoped hooks handle this association for you.
98
92
 
99
- All data is fetched from `https://api.rixl.com`.
93
+ `initProgressBar({video, onProgressChange, onDraggingChange})` connects a browser video element to seeking interactions and returns `handleDragStart` and `destroy`. Call `destroy()` when removing the control.
100
94
 
101
- ### REST Endpoints
95
+ ## Pure utilities
102
96
 
103
- | Endpoint | Description |
104
- | --------------------------------------------------------------- | --------------------------------------------- |
105
- | `GET /images/{imageId}` | Fetch image metadata and URLs |
106
- | `GET /videos/{videoId}` | Fetch video metadata and playback information |
107
- | `GET /feeds/{feedId}/posts?offset=...&limit=...` | Fetch paginated feed posts |
108
- | `GET /feeds/{feedId}/posts/{postId}` | Fetch a specific feed post |
109
- | `GET /feeds/{feedId}/creators/{creatorId}?offset=...&limit=...` | Fetch posts by a specific creator |
97
+ ```ts
98
+ import {computeProgressFraction, formatTime} from "@rixl/media-core";
110
99
 
111
- ## Documentation
100
+ const progress = computeProgressFraction(30, 120);
101
+ const label = formatTime(90);
102
+ console.log(progress, label);
103
+ ```
112
104
 
113
- For complete documentation, tutorials, and examples, visit our **[SDK Documentation](https://docs.rixl.com/en/sdk/getting-started)**.
105
+ Other exports cover buffer ranges, chapter navigation, subtitle cues, HLS quality labels, persisted preferences, and analytics payloads. See the [API guide](https://developers.rixl.com/en/sdk/media-core/core-api) and the declarations shipped with the package.
114
106
 
115
- ## Need Help?
107
+ ## Ready-made components
116
108
 
117
- - [Developer Support](https://support.rixl.com)
118
- - [Developer Forum](https://forum.rixl.com)
119
- - [Premier Developer Support](https://rixl.com/pricing) (priority support)
109
+ Choose [React](https://www.npmjs.com/package/@rixl/media-react), [Vue](https://www.npmjs.com/package/@rixl/media-vue), [Svelte](https://www.npmjs.com/package/@rixl/media-svelte), [Angular](https://www.npmjs.com/package/@rixl/media-angular), [Astro](https://www.npmjs.com/package/@rixl/media-astro), or [Lit / vanilla JavaScript](https://www.npmjs.com/package/@rixl/media-lit).
@@ -0,0 +1 @@
1
+ import{map as e}from"nanostores";import*as t from"valibot";function n(e,t=1){return e>0?e:t}function r({playerMuted:e,playerInteracted:t}){return e||!t}function i(e,t,n=.1){return e===0?Math.max(n,t):e}function a(e){return Math.max(0,Math.min(1,e))}function o(e,t=.01){return e<t}function s(e){return`touches`in e?e.touches[0].clientX:e.clientX}function c(e,t){return a((t-e.left)/e.width)}const l={monospace_serif:`"Courier New", Courier, "Nimbus Mono L", "Cutive Mono", monospace`,proportional_serif:`"Times New Roman", Times, Georgia, Cambria, "PT Serif Caption", serif`,monospace_sans:`"Deja Vu Sans Mono", "Lucida Console", Monaco, Consolas, "PT Mono", monospace`,proportional_sans:`Roboto, Arial, Helvetica, Verdana, "PT Sans Caption", sans-serif`,casual:`"Comic Sans MS", Impact, Handlee, fantasy`,cursive:`"Monotype Corsiva", "URW Chancery L", "Apple Chancery", "Dancing Script", cursive`,small_caps:`Arial, Helvetica, Verdana, "Marcellus SC", sans-serif`},u=[50,100,150,200],d={white:`#ffffff`,yellow:`#ffff00`,green:`#00ff00`,cyan:`#00ffff`,blue:`#0000ff`,magenta:`#ff00ff`,red:`#ff0000`,black:`#000000`},f=[`none`,`drop-shadow`,`raised`,`depressed`,`outline`],p=[1,1.25,1.5,2,3],m=[`off`,`eng`,`auto`],h={volume:1,playbackSpeed:1,customPlayback:1,allowCaptions:!1,captionPosition:{x:20,y:90},captionLang:`off`,captionFontFamily:`proportional_sans`,captionFontSize:100,captionFontColor:`#ffffff`,captionFontOpacity:100,captionBGColor:`#000000`,captionBGOpacity:75,captionWindowColor:`#000000`,captionWindowOpacity:0,captionCharacterEdgeStyle:`none`,globalMutedPreference:!1},g=t.pipe(t.number(),t.minValue(0),t.maxValue(100)),_=t.pipe(t.number(),t.minValue(0),t.maxValue(1)),v=t.pipe(t.number(),t.minValue(.25),t.maxValue(3)),y=Object.values(d),b=Object.keys(l),x=u,S=f,C=m,w=t.picklist(y),T=t.picklist(b),E=t.picklist(x),D=t.picklist(S),O=t.object({x:t.number(),y:t.number()}),k=t.picklist(C),A=t.object({volume:t.fallback(_,h.volume),playbackSpeed:t.fallback(v,h.playbackSpeed),customPlayback:t.fallback(v,h.customPlayback),allowCaptions:t.fallback(t.boolean(),h.allowCaptions),captionPosition:t.fallback(O,h.captionPosition),captionLang:t.fallback(k,h.captionLang),captionFontFamily:t.fallback(T,h.captionFontFamily),captionFontSize:t.fallback(E,h.captionFontSize),captionFontColor:t.fallback(w,h.captionFontColor),captionFontOpacity:t.fallback(g,h.captionFontOpacity),captionBGColor:t.fallback(w,h.captionBGColor),captionBGOpacity:t.fallback(g,h.captionBGOpacity),captionWindowColor:t.fallback(w,h.captionWindowColor),captionWindowOpacity:t.fallback(g,h.captionWindowOpacity),captionCharacterEdgeStyle:t.fallback(D,h.captionCharacterEdgeStyle),selectedLanguageCode:t.optional(t.string()),globalMutedPreference:t.fallback(t.boolean(),h.globalMutedPreference),preferredQuality:t.optional(t.number()),preferredAudioLanguage:t.optional(t.string()),preferredSubtitleLanguage:t.optional(t.string())}),j=e=>e==null?{...h}:t.parse(A,e),M=`videosdk_settings`,N=()=>{if(typeof window>`u`)return h;try{let e=localStorage.getItem(M);if(e){let t=JSON.parse(e);return j(t)}}catch(e){console.error(`Failed to load settings from localStorage:`,e)}return h},P=e=>{if(typeof window<`u`)try{localStorage.setItem(M,JSON.stringify(e))}catch(e){console.error(`Failed to save settings to localStorage:`,e)}},F=(e,t)=>(I.state.setKey(e,t),P(I.state.get()),t),I={state:e(N()),getSettings:()=>I.state.get(),setVolume:e=>F(`volume`,a(e)),setPlaybackSpeed:e=>F(`playbackSpeed`,e),setCustomPlayback:e=>F(`customPlayback`,e),setAllowCaptions:e=>F(`allowCaptions`,e),setCaptionPosition:(e,t)=>F(`captionPosition`,{x:e,y:t}),setSubtitleLang:e=>F(`captionLang`,e),setCaptionFontFamily:e=>F(`captionFontFamily`,e),setCaptionFontSize:e=>F(`captionFontSize`,e),setCaptionFontColor:e=>F(`captionFontColor`,e),setCaptionBGColor:e=>F(`captionBGColor`,e),setCaptionBGOpacity:e=>F(`captionBGOpacity`,e),setCaptionWindowColor:e=>F(`captionWindowColor`,e),setCaptionWindowOpacity:e=>F(`captionWindowOpacity`,e),setCaptionFontOpacity:e=>F(`captionFontOpacity`,e),setCaptionCharacterEdgeStyle:e=>F(`captionCharacterEdgeStyle`,e),resetCaptionSettings:()=>{let e={...I.state.get(),captionPosition:h.captionPosition,captionLang:h.captionLang,captionFontFamily:h.captionFontFamily,captionFontSize:h.captionFontSize,captionFontColor:h.captionFontColor,captionBGColor:h.captionBGColor,captionBGOpacity:h.captionBGOpacity,captionWindowColor:h.captionWindowColor,captionWindowOpacity:h.captionWindowOpacity,captionFontOpacity:h.captionFontOpacity,captionCharacterEdgeStyle:h.captionCharacterEdgeStyle};I.state.set(e),P(e)},setSelectedLanguageCode:e=>F(`selectedLanguageCode`,e),setMuted:e=>F(`globalMutedPreference`,e),setPreferredQuality:e=>F(`preferredQuality`,e),setPreferredAudioLanguage:e=>F(`preferredAudioLanguage`,e),setPreferredSubtitleLanguage:e=>F(`preferredSubtitleLanguage`,e)};export{o as _,h as a,l as c,p as d,n as f,c as g,i as h,j as i,u as l,s as m,N as n,d as o,a as p,P as r,f as s,I as t,m as u,r as v};
@@ -0,0 +1 @@
1
+ function e(e){if(!e||!(e instanceof HTMLElement))return!1;let t=e.tagName;return t===`INPUT`||t===`TEXTAREA`||e.contentEditable===`true`}const t={PLAY_PAUSE:`play_pause`,SEEK_10:`seek_10`,SEEK_5:`seek_5`,FULLSCREEN:`fullscreen`,MINIPLAYER:`miniplayer`,MUTE:`mute`,VOLUME:`volume`},n=[{action:t.PLAY_PAUSE,keys:[`Space`,`KeyK`],labelKey:`shortcuts.play_pause`},{action:t.SEEK_10,keys:[`KeyJ`,`KeyL`],labelKey:`shortcuts.seek_10s`},{action:t.SEEK_5,keys:[`ArrowLeft`,`ArrowRight`],labelKey:`shortcuts.seek_5s`},{action:t.FULLSCREEN,keys:[`KeyF`],labelKey:`shortcuts.fullscreen`},{action:t.MINIPLAYER,keys:[`KeyI`],labelKey:`shortcuts.pip`},{action:t.MUTE,keys:[`KeyM`],labelKey:`shortcuts.mute`},{action:t.VOLUME,keys:[`ArrowUp`,`ArrowDown`],labelKey:`shortcuts.volume`}],r=5,i=10,a=.1;function o(e,n){return n===t.SEEK_10?e===`KeyL`?10:-10:n===t.SEEK_5?e===`ArrowRight`?5:-5:0}function s(e){return e===`ArrowUp`?a:-.1}function c(e,n,r){switch(e){case t.PLAY_PAUSE:r.onPlayPause();break;case t.SEEK_10:case t.SEEK_5:r.onSeek(o(n,e));break;case t.FULLSCREEN:r.onFullscreen();break;case t.MINIPLAYER:r.onMiniplayer();break;case t.MUTE:r.onMute();break;case t.VOLUME:r.onVolume(s(n))}}const l=[`Space`,`KeyK`,`F1`,`F12`,`MediaPlay`,`MediaPause`,`MediaPlayPause`],u=new Map([...n.flatMap(e=>e.keys.map(t=>[t,e.action])),...l.map(e=>[e,t.PLAY_PAUSE])]);function d(e){return u.get(e)??null}function f(e){return/^Digit[0-9]$/.test(e)?Number(e.slice(5))*10:null}export{t as a,o as c,d,e as f,n as i,f as l,i as n,a as o,r,c as s,l as t,s as u};
@@ -0,0 +1 @@
1
+ import{postsV1PostServiceGetPost3 as e,postsV1PostServiceListPosts3 as t}from"@rixl/sdk";import{atom as n}from"nanostores";function r(e){return e===`MEDIA_TYPE_IMAGE`?`image`:e===`MEDIA_TYPE_VIDEO`?`video`:`image`}function i(e){let t=e;return{id:e.id??``,feedId:e.feed_id??``,creatorId:e.creator_id??``,type:r(e.type),description:e.description??``,createdAt:e.created_at??``,image:t.image,video:t.video}}function a(e,t,n){let r=e.total??0;return{posts:(e.posts??[]).map(i),total:typeof r==`number`?r:Number(r),offset:e.offset??t,limit:e.limit??n}}const o=async(e,n=0,r=10)=>{let{data:i,error:o,response:s}=await t({path:{feed_id:e},query:{"pagination.offset":n,"pagination.limit":r}});if(o||!i)throw Error(`HTTP error! status: ${s?.status??500}`);return a(i,n,r)},s=async(t,n)=>{let{data:r,error:a,response:o}=await e({path:{feed_id:t,post_id:n}});if(a)throw Error(`HTTP error! status: ${o?.status??500}`);if(!r?.post)throw Error(`HTTP error! status: 404`);return i(r.post)},c=()=>{let e=/* @__PURE__ */ new Map,t=/* @__PURE__ */ new Map;return{get:async(n,r)=>{let i=e.get(n);if(i)return i;let a=t.get(n);if(a)return a;let o=r(n).then(r=>(e.set(n,r),t.delete(n),r)).catch(e=>{throw t.delete(n),e});return t.set(n,o),o}}},l=c(),u=/* @__PURE__ */ new Map,d=async(e,t)=>{let n=`${e}:${t}`;return l.get(n,()=>s(e,t))},f=async(e,t=0,n=10)=>{if(t>0)return o(e,t,n);let r=`feed:${e}`,i=u.get(r);if(i)return i;let a=await o(e,t,n);return u.set(r,a),a.posts.forEach(t=>{let n=`${e}:${t.id}`;l.get(n,()=>Promise.resolve(t))}),a},p=`rixl_feed_cache`,m=n({cachedPosts:[],isLoadingFromCache:!1});function h(e){return typeof e==`object`&&!!e}function g(e){return typeof e.id==`string`&&typeof e.creatorId==`string`&&typeof e.feedId==`string`&&typeof e.description==`string`&&typeof e.createdAt==`string`}function _(e){if(!h(e)||!g(e))return!1;let t=e.type===`video`,n=e.type===`image`;return!t&&!n?!1:t?e.video!==void 0:e.image!==void 0}function v(e){try{let t=localStorage.getItem(p);if(!t)return[];let n=JSON.parse(t);if(n.version!==6||e&&n.feedId&&n.feedId!==e)return localStorage.removeItem(p),[];let r=n.posts.filter(e=>_(e)?!0:(console.warn(`[FeedCache] Invalid post found in cache:`,e),!1));return r.length!==n.posts.length&&y(r,e),r}catch{return localStorage.removeItem(p),[]}}function y(e,t){try{let n={version:6,feedId:t,posts:e.slice(0,50),timestamp:Date.now()};localStorage.setItem(p,JSON.stringify(n))}catch(e){e instanceof DOMException&&e.name===`QuotaExceededError`&&localStorage.removeItem(p)}}const b={currentFeedId:void 0,loadCache(e){this.currentFeedId=e,m.set({...m.get(),isLoadingFromCache:!0});let t=v(e);return m.set({cachedPosts:t,isLoadingFromCache:!1}),t},saveNewPosts(e,t){if(t!==void 0&&t!==this.currentFeedId)return;let n=m.get(),r=new Set(n.cachedPosts.map(e=>e.id)),i=e.filter(e=>!r.has(e.id));if(i.length===0)return;let a=[...n.cachedPosts,...i];m.set({...n,cachedPosts:a}),y(a,this.currentFeedId)},removePost(e){let t=m.get(),n=t.cachedPosts.filter(t=>t.id!==e);n.length!==t.cachedPosts.length&&(m.set({...t,cachedPosts:n}),y(n,this.currentFeedId))},clearCache(){localStorage.removeItem(p),m.set({cachedPosts:[],isLoadingFromCache:!1})},getCacheStats(){try{let e=localStorage.getItem(p);if(!e)return{size:0,timestamp:null};let t=JSON.parse(e);return{size:t.posts.length,timestamp:t.timestamp}}catch{return{size:0,timestamp:null}}}},x=n({initialized:!1,feedId:``,posts:[],isLoadedInitial:!0,isFetchingVideos:!1,currentIndex:0,total:0});let S=0;function C(e){return e===S}const w={init(e){S+=1;let t=b.loadCache(e);x.set({...x.get(),feedId:e,initialized:!0,posts:t,currentIndex:0,total:0,isLoadedInitial:t.length>0,isFetchingVideos:!1})},async loadInitialPosts(){let e=x.get();if(e.isFetchingVideos)return;let t=S,n=e.feedId;x.set({...e,isFetchingVideos:!0});try{let e=x.get(),r=await f(n);if(!C(t))return;let i=[...e.posts,...r.posts],a=Array.from(new Map(i.map(e=>[e.id,e])).values());b.saveNewPosts(r.posts,n),x.set({...x.get(),posts:a,isLoadedInitial:!0,total:r.total})}catch(e){console.error(`[PostStore] Error loading posts:`,e)}finally{C(t)&&x.set({...x.get(),isFetchingVideos:!1})}},async fetchNewVideos(){let e=x.get();if(e.isFetchingVideos||!e.initialized)return;let t=S,n=e.feedId;x.set({...e,isFetchingVideos:!0});try{let e=x.get(),r=await f(n,e.posts?e.posts.length:0);if(!C(t))return;x.set({...x.get(),posts:[...x.get().posts,...r.posts],total:r.total})}finally{C(t)&&x.set({...x.get(),isFetchingVideos:!1})}},setCurrentIndex(e){let t=x.get();if(e!==t.currentIndex){let n=t.posts[t.currentIndex];n&&b.removePost(n.id),x.set({...t,currentIndex:e})}}},T=5,E=2,D={hasInteracted:n(!1),whenInteracted:n(/* @__PURE__ */ new Date(0)),hasInitialized:n(!1),videosInitialized:n(5),components:n(Array.from({length:5})),originalPositions:n(Array.from({length:5}).map((e,t)=>t)),transforms:n(Array.from({length:5}).map((e,t)=>t)),setTransforms:e=>{let t=D.transforms.get();t.length===e.length&&t.every((t,n)=>t===e[n])||D.transforms.set(e)}},O=()=>(D.hasInitialized.get()&&(D.hasInteracted.set(!0),D.whenInteracted.set(/* @__PURE__ */ new Date)),D.hasInteracted.get()),k=()=>{D.videosInitialized.set(D.videosInitialized.get()+1),D.videosInitialized.get()>=5&&D.hasInitialized.set(!0)},A=2,j=50;function M(e,t){let n=e.length;return t%=n,t<0&&(t=n+t),[...e.slice(t),...e.slice(0,t)]}function N(e,t){let n=Math.floor(e/t),r=e%t,i=[];for(let e=0;e<t;e++)e<t-r?i.push(n):i.push(n+1);return i}function P(e,t){if(e<=2)return t;let n=N(e-2,5),r=M(t,e-2);return n.forEach((e,t)=>{r[t]+=e*5}),r}function F(e,t,n=.3){return t<=0||e<=0?0:Math.ceil(e/t-n)}function I(e,t){return e>=t-1}function L(e,t){return t>0&&e>=t}function R({currentIndex:e,postsLength:t,total:n,isFetching:r,isLoaded:i}){return r||!i||L(t,n)?!1:e>=t-3}function z(e,t,n){return!n||t===0?e:(e%t+t)%t}function B(e){return Math.max(250,e*50)}function V({currentIndex:e,postsLength:t,loop:n,total:r}){return n&&t>0&&L(t,r)&&e>=B(t)}function H(e,t){let n=(e%t+t)%t;return t*2+n}const U=5e3;function W(e,t,n){return!e||!t?!1:n}function G(e,t){return e&&t}function K({isCurrent:e,autoscroll:t,loop:n,currentIndex:r,postsLength:i,total:a}){return!(!e||!t||I(r,i)&&!n&&L(i,a))}function q(e){return Math.max(window.innerHeight-e,1)}function J({measuredHeight:e,scrollContainerHeight:t,safeAreaTabBar:n}){return t>0?t:e>0?e:q(n)}function Y(e){if(!e)return!1;let t=e.scrollHeight-e.clientHeight>1,n=e.scrollWidth-e.clientWidth>1;return t||n}export{d as A,D as C,w as D,x as E,c as M,m as O,E as S,O as T,j as _,K as a,M as b,B as c,V as d,F as f,A as g,R as h,G as i,f as j,b as k,H as l,L as m,q as n,U as o,I as p,J as r,W as s,Y as t,z as u,P as v,k as w,T as x,N as y};
@@ -0,0 +1 @@
1
+ import{h as e,p as t,t as n}from"./B-QvSqjj.js";import{map as r}from"nanostores";function i(e,t,n){return Math.max(t,Math.min(n,e))}function a(e){if(e<1e4)return e.toString();let t=[``,`k`,`M`,`B`],n=Math.log10(e)/3|0,r=e/1e3**n,i=(Math.floor(r*10)/10).toString();return i.includes(`.`)&&(i=i.replace(/\.0$/,``)),i+t[n]}function o(e){let t=[``,`k`,`M`,`B`],n=Math.log10(e)/3|0,r=e/1e3**n,i=(Math.floor(r*10)/10).toString();return i.includes(`.`)&&(i=i.replace(/\.0$/,``)),i+t[n]}const s=(e,t)=>{let n=e.endTime;return t?t.startTime-e.endTime<=.5?t.startTime+.1:i(e.startTime+1,n,t.startTime):Math.max(n,e.startTime+1)},c=(e,t)=>{if(t&&t.length!==0){for(let n=0;n<t.length-1;n++)if(t[n]===e)return t[n+1]}};function l(e){return e.replace(/<[^>]*>/g,``)}const u=e=>l(e instanceof VTTCue?e.text:e.text??``),d=/* @__PURE__ */ new WeakSet,f=(e,t)=>{for(let n=0;n<e.length;n++){let r=e[n];if(!d.has(r)){let e=c(r,t),n=s(r,e);Math.abs(r.endTime-n)>.01&&(r.endTime=n),d.add(r)}}},p=e=>{let t=[];for(let n=0;n<e.length;n++){let r=e[n];if(r.kind===`subtitles`||r.kind===`captions`){if(!r.label&&!r.language&&!r.id)continue;t.push({index:n,label:r.label||`${r.kind} ${n+1}`,language:r.language||`unknown`,kind:r.kind,track:r}),r.mode=`disabled`}}return t},m=`video-player-subtitle-track`,h=`audioTrack`,g=()=>{try{let e=localStorage.getItem(m);return e===null?-1:parseInt(e,10)}catch{return-1}},_=e=>{try{localStorage.setItem(m,e.toString())}catch{return}},v=()=>{try{let e=localStorage.getItem(h);return e?parseInt(e,10):0}catch{return 0}},y=e=>{try{localStorage.setItem(h,e.toString())}catch{return}};function b(e,t){return e.findIndex(e=>e.language===t)}const x={setGlobalMuted(e){this.state.forEach((t,n)=>{e||this.setHasInteracted(n),this.setMuted(n,e)}),n.setMuted(e)},setGlobalVolume(e){this.state.forEach((t,n)=>this.setVolume(n,e)),n.setVolume(e)},setGlobalPlaybackRate(e){this.state.forEach((t,n)=>this.setPlaybackRate(n,e)),n.setPlaybackSpeed(e)},setGlobalPreferredQuality(e){n.setPreferredQuality(e)},setGlobalPreferredAudioLanguage(e){n.setPreferredAudioLanguage(e),e&&this.state.forEach((t,n)=>{let{availableAudioTracks:r}=this.get(n).get(),i=b(r,e);i>=0&&this.setAudioTrack(n,i)})},setGlobalPreferredSubtitleLanguage(e){n.setPreferredSubtitleLanguage(e),e!==void 0&&(e===``?this.state.forEach((e,t)=>this.setSubtitleTrack(t,-1)):this.state.forEach((t,n)=>{let{availableSubtitleTracks:r}=this.get(n).get(),i=b(r,e);i>=0&&this.setSubtitleTrack(n,i)}))},pauseAllPlayers(){this.state.forEach((e,t)=>this.setPaused(t,!0))}},S=/* @__PURE__ */ new Map,C=/* @__PURE__ */ new Map;function w(e){C.get(e)?.forEach(e=>e())}const T={register:(e,t)=>{S.set(e,t),w(e)},unregister:e=>{S.delete(e),w(e)},get:e=>S.get(e)??null,subscribe:(e,t)=>{let n=C.get(e);return n||(n=/* @__PURE__ */ new Set,C.set(e,n)),n.add(t),()=>{let n=C.get(e);n&&(n.delete(t),n.size===0&&C.delete(e))}},clear:()=>{let e=/* @__PURE__ */ new Set([...S.keys(),...C.keys()]);S.clear(),e.forEach(e=>w(e))}},E=[`loadedmetadata`,`durationchange`,`timeupdate`,`progress`,`seeking`,`seeked`,`emptied`],D=/* @__PURE__ */ new Map;function O(e){let t=e?.duration??0;return Number.isFinite(t)&&t>0?t:0}function k(e,t){if(!e||t<=0)return 0;let n=e.currentTime;return Number.isFinite(n)?i(n,0,t):0}function A(e,t){if(!e||t<=0||e.buffered.length===0)return 0;try{let n=e.buffered.end(e.buffered.length-1);return Number.isFinite(n)?i(n/t,0,1):0}catch{return 0}}function j(e,t){if(!e)return()=>{};let n=!0,r=!1,i=()=>{r||(r=!0,queueMicrotask(()=>{r=!1,n&&t()}))};return E.forEach(t=>{e.addEventListener(t,i)}),()=>{n=!1,E.forEach(t=>{e.removeEventListener(t,i)})}}function M(e,t){let n=T.get(e);n&&(n.volume=t.volume,n.muted=t.muted)}const N={getEffectiveMediaMuted:e=>e.muted||e.volume===0||!e.hasInteracted,muteMedia(e){let t=this.get(e).get();this.setHasInteracted(e),t.volume>0&&this.setPreviousVolume(e,t.volume),this.setVolume(e,0),this.setMuted(e,!0),M(e,this.get(e).get())},unmuteMedia(t){let n=this.get(t).get(),r=e(n.volume,n.previousVolume);this.setHasInteracted(t),n.volume===0&&this.setVolume(t,r),this.setMuted(t,!1),M(t,this.get(t).get())},toggleMediaMute(e){let t=this.get(e).get();this.getEffectiveMediaMuted(t)?this.unmuteMedia(e):this.muteMedia(e)},setMediaVolume(e,n){let r=this.get(e).get(),i=t(n);this.setHasInteracted(e),i===0&&r.volume>0&&this.setPreviousVolume(e,r.volume),this.setVolume(e,i),this.setMuted(e,i===0),M(e,this.get(e).get())},async playMedia(e){let t=T.get(e);if(t){this.setHasInteracted(e),this.setEnded(e,!1),this.setPaused(e,!1);try{await t.play()}catch{this.setPaused(e,!0)}}},pauseMedia(e){let t=T.get(e);t&&(t.pause(),this.setPaused(e,!0))},async toggleMediaPlayback(e){this.get(e).get().paused?await this.playMedia(e):this.pauseMedia(e)},pauseOtherMedia(e){this.state.forEach((t,n)=>{if(n===e)return;let r=T.get(n);r&&r.pause(),this.setPaused(n,!0)})},setMediaPlaybackRate(e,t){let n=T.get(e);this.setPlaybackRate(e,t),n&&(n.playbackRate=this.get(e).get().playbackRate)},readProgressSnapshot(e){let t=T.get(e),n=O(t),r=k(t,n),a={currentTime:r,duration:n,progress:n>0?i(r/n,0,1):0,buffered:A(t,n)},o=D.get(e);return o&&o.currentTime===a.currentTime&&o.duration===a.duration&&o.progress===a.progress&&o.buffered===a.buffered?o:(D.set(e,a),a)},subscribeToProgress(e,t){let n=T.get(e),r=j(n,t),i=T.subscribe(e,()=>{let i=T.get(e);i!==n&&(r(),n=i,r=j(n,t),t())});return()=>{i(),r()}},seekProgressTo(e,t){let n=T.get(e);if(!n)return;let r=O(n);n.currentTime=r<=0?0:i(Number.isFinite(t)?t:0,0,r)},seekProgressBy(e,t){let n=T.get(e);if(!n)return;let r=O(n);if(r<=0){n.currentTime=0;return}let a=Number.isFinite(t)?t:0;n.currentTime=i(k(n,r)+a,0,r)}},P=[];function F(e,t){return{index:t,label:e.label,language:e.language,kind:e.kind}}const I={getTrackOptions(e){return e.length>0?e.map(F):P},selectAudioTrack(e,t){let{availableAudioTracks:n}=this.get(e).get();t<0||t>=n.length||this.setAudioTrack(e,t)},selectSubtitleTrack(e,t){if(t!==-1){let{availableSubtitleTracks:n}=this.get(e).get();if(t<0||t>=n.length)return}this.setSubtitleTrack(e,t)},setAudioTrack(e,t){let n=this.get(e),r=n.get();r.hlsInstance&&r.hlsInstance.audioTracks&&t>=0&&t<r.hlsInstance.audioTracks.length&&(r.hlsInstance.audioTrack=t),n.setKey(`audioTrack`,t),y(t)},setAvailableAudioTracks(e,t){this.get(e).setKey(`availableAudioTracks`,t);let n=v();n>=0&&n<t.length?this.setAudioTrack(e,n):t.length>0&&this.setAudioTrack(e,0)}},L=.25,R=()=>{let e=n.getSettings(),t=e.volume;return{paused:!0,loading:!0,ended:!1,mounted:!1,hasInteracted:!1,whenInteracted:/* @__PURE__ */ new Date(0),isFullscreen:!1,isPictureInPicture:!1,muted:e.globalMutedPreference,playbackRate:i(e.playbackSpeed,L,3),volume:t,previousVolume:t,viewport:{width:0,height:0},resolution:-1,subtitleTrack:g(),availableSubtitleTracks:[],currentSubtitleText:``,audioTrack:0,availableAudioTracks:[],hlsInstance:null}},z=()=>r(R());function B(e,t,n){V.get(e).setKey(t,n)}const V={state:/* @__PURE__ */ new Map,get:e=>{let t=V.state.get(e);return t||(t=z(),V.state.set(e,t)),t},deletePlayer:e=>{V.state.delete(e)},...N,...I,...x,setMounted:e=>{B(e,`mounted`,!0)},setHasInteracted:e=>{let t=V.get(e);t.setKey(`hasInteracted`,!0),t.setKey(`whenInteracted`,/* @__PURE__ */ new Date)},setPaused:(e,t)=>{B(e,`paused`,t)},setLoading:(e,t)=>{B(e,`loading`,t)},setEnded:(e,t)=>{B(e,`ended`,t)},setFullscreen:(e,t)=>{B(e,`isFullscreen`,t)},setPictureInPicture:(e,t)=>{B(e,`isPictureInPicture`,t)},setMuted:(e,t)=>{B(e,`muted`,t)},setPlaybackRate:(e,t)=>{B(e,`playbackRate`,i(t,L,3))},setPreviousVolume:(e,n)=>{B(e,`previousVolume`,t(n))},setVolume:(e,n)=>{B(e,`volume`,t(n))},setViewport:(e,t,n)=>{B(e,`viewport`,{width:t,height:n})},setResolution:(e,t)=>{B(e,`resolution`,t)},setSubtitleTrack:(e,t)=>{let n=V.get(e);n.get().availableSubtitleTracks.forEach((e,n)=>{e.track.mode=n===t?`showing`:`disabled`}),n.setKey(`subtitleTrack`,t),_(t)},setAvailableSubtitleTracks:(e,t)=>{V.get(e).setKey(`availableSubtitleTracks`,t);let n=g();n>=0&&n<t.length&&V.setSubtitleTrack(e,n)},setCurrentSubtitleText:(e,t)=>{B(e,`currentSubtitleText`,t)},setHlsInstance:(e,t)=>{B(e,`hlsInstance`,t)}},H=/* @__PURE__ */ new Map,U=/* @__PURE__ */ new Map;function W(e){U.get(e)?.forEach(e=>e())}const G={register:(e,t)=>{H.set(e,t),W(e)},unregister:e=>{H.delete(e),W(e)},get:e=>H.get(e)??null,subscribe:(e,t)=>{let n=U.get(e);return n||(n=/* @__PURE__ */ new Set,U.set(e,n)),n.add(t),()=>{let n=U.get(e);n&&(n.delete(t),n.size===0&&U.delete(e))}},clear:()=>{let e=/* @__PURE__ */ new Set([...H.keys(),...U.keys()]);H.clear(),e.forEach(e=>W(e))}};export{g as a,s as c,u as d,f,o as g,a as h,v as i,p as l,i as m,V as n,y as o,l as p,T as r,_ as s,G as t,c as u};