@100mslive/roomkit-react 0.1.4-alpha.1 → 0.1.5

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 (152) hide show
  1. package/dist/{HLSView-F2K5VSTS.js → HLSView-P57IRMAR.js} +7 -11
  2. package/dist/{HLSView-F2K5VSTS.js.map → HLSView-P57IRMAR.js.map} +1 -1
  3. package/dist/PinnedTrackView-4FYJEBTB.js +102 -0
  4. package/dist/PinnedTrackView-4FYJEBTB.js.map +7 -0
  5. package/dist/Popover/index.d.ts +1 -0
  6. package/dist/Prebuilt/App.d.ts +25 -0
  7. package/dist/Prebuilt/index.d.ts +1 -0
  8. package/dist/Prebuilt/provider/roomLayoutProvider/index.d.ts +1 -1
  9. package/dist/Sheet/Sheet.d.ts +3093 -0
  10. package/dist/Sheet/index.d.ts +1 -0
  11. package/dist/Theme/ThemeProvider.d.ts +4 -286
  12. package/dist/Theme/stitches.config.d.ts +1 -1
  13. package/dist/{VirtualBackground-S3XEPZ2T.js → VirtualBackground-GGCQJ5JM.js} +31 -7
  14. package/dist/VirtualBackground-GGCQJ5JM.js.map +7 -0
  15. package/dist/chunk-IVTWKQI3.js +827 -0
  16. package/dist/chunk-IVTWKQI3.js.map +7 -0
  17. package/dist/{chunk-42SWPN2C.js → chunk-OSM4QEQG.js} +3020 -2189
  18. package/dist/chunk-OSM4QEQG.js.map +7 -0
  19. package/dist/chunk-P5X32KOD.js +67 -0
  20. package/dist/chunk-P5X32KOD.js.map +7 -0
  21. package/dist/chunk-RVCZPPTL.js +1100 -0
  22. package/dist/chunk-RVCZPPTL.js.map +7 -0
  23. package/dist/{chunk-ESUJK7AT.js → conference-P6I6ESVF.js} +3136 -653
  24. package/dist/conference-P6I6ESVF.js.map +7 -0
  25. package/dist/index.cjs.js +15733 -15498
  26. package/dist/index.cjs.js.map +4 -4
  27. package/dist/index.js +4 -8
  28. package/dist/meta.cjs.json +3355 -3017
  29. package/dist/meta.esbuild.json +3534 -3329
  30. package/dist/utils/animations.d.ts +16 -0
  31. package/package.json +8 -10
  32. package/src/Button/Button.tsx +4 -4
  33. package/src/Dropdown/Dropdown.tsx +2 -2
  34. package/src/IconButton/IconButton.tsx +4 -2
  35. package/src/Pagination/StyledPagination.tsx +1 -0
  36. package/src/Popover/index.tsx +2 -1
  37. package/src/Prebuilt/{App.jsx → App.tsx} +95 -48
  38. package/src/Prebuilt/Prebuilt.stories.tsx +22 -8
  39. package/src/Prebuilt/common/constants.js +1 -2
  40. package/src/Prebuilt/common/hooks.js +8 -0
  41. package/src/Prebuilt/common/utils.js +15 -0
  42. package/src/Prebuilt/components/AppData/AppData.jsx +1 -2
  43. package/src/Prebuilt/components/AppData/useUISettings.js +0 -5
  44. package/src/Prebuilt/components/AudioVideoToggle.jsx +69 -26
  45. package/src/Prebuilt/components/AuthToken.jsx +3 -2
  46. package/src/Prebuilt/components/Chat/ChatSelector.jsx +1 -1
  47. package/src/Prebuilt/components/Connection/TileConnection.jsx +0 -1
  48. package/src/Prebuilt/components/EmojiReaction.jsx +23 -73
  49. package/src/Prebuilt/components/EndSessionContent.jsx +57 -0
  50. package/src/Prebuilt/components/EqualProminence.jsx +180 -0
  51. package/src/Prebuilt/components/ErrorBoundary.jsx +4 -10
  52. package/src/Prebuilt/components/Footer/EmojiCard.jsx +34 -0
  53. package/src/Prebuilt/components/Footer/Footer.jsx +73 -0
  54. package/src/Prebuilt/components/{Header → Footer}/ParticipantList.jsx +5 -5
  55. package/src/Prebuilt/components/Header/ConferencingHeader.jsx +27 -7
  56. package/src/Prebuilt/components/Header/HeaderComponents.jsx +16 -14
  57. package/src/Prebuilt/components/Header/StreamActions.jsx +101 -36
  58. package/src/Prebuilt/components/Header/StreamingHeader.jsx +1 -1
  59. package/src/Prebuilt/components/Header/common.jsx +164 -0
  60. package/src/Prebuilt/components/IconButtonWithOptions/IconButtonWithOptions.jsx +1 -2
  61. package/src/Prebuilt/components/LeaveCard.jsx +19 -0
  62. package/src/Prebuilt/components/LeaveRoom.jsx +35 -143
  63. package/src/Prebuilt/components/LeaveSessionContent.jsx +45 -0
  64. package/src/Prebuilt/components/MoreSettings/ActionTile.jsx +55 -0
  65. package/src/Prebuilt/components/MoreSettings/ChangeNameContent.jsx +96 -0
  66. package/src/Prebuilt/components/MoreSettings/ChangeNameModal.jsx +31 -54
  67. package/src/Prebuilt/components/MoreSettings/EmbedUrl.jsx +48 -73
  68. package/src/Prebuilt/components/MoreSettings/MoreSettings.jsx +5 -221
  69. package/src/Prebuilt/components/MoreSettings/MuteAllContent.jsx +61 -0
  70. package/src/Prebuilt/components/MoreSettings/MuteAllModal.jsx +32 -49
  71. package/src/Prebuilt/components/MoreSettings/SplitComponents/DesktopLeaveRoom.jsx +129 -0
  72. package/src/Prebuilt/components/MoreSettings/SplitComponents/DesktopOptions.jsx +219 -0
  73. package/src/Prebuilt/components/MoreSettings/SplitComponents/MwebLeaveRoom.jsx +100 -0
  74. package/src/Prebuilt/components/MoreSettings/SplitComponents/MwebOptions.jsx +259 -0
  75. package/src/Prebuilt/components/Notifications/Notifications.jsx +0 -2
  76. package/src/Prebuilt/components/Notifications/ReconnectNotifications.jsx +0 -4
  77. package/src/Prebuilt/components/PIP/PIPComponent.jsx +30 -26
  78. package/src/Prebuilt/components/PIP/PIPManager.js +13 -0
  79. package/src/Prebuilt/components/PIP/index.jsx +2 -7
  80. package/src/Prebuilt/components/Pagination.jsx +4 -4
  81. package/src/Prebuilt/components/Preview/PreviewContainer.jsx +5 -13
  82. package/src/Prebuilt/components/Preview/PreviewForm.jsx +9 -5
  83. package/src/Prebuilt/components/Preview/PreviewJoin.jsx +20 -27
  84. package/src/Prebuilt/components/RaiseHand.jsx +27 -0
  85. package/src/Prebuilt/components/ScreenShare.jsx +1 -1
  86. package/src/Prebuilt/components/ScreenshareDisplay.jsx +2 -2
  87. package/src/Prebuilt/components/ScreenshareTile.jsx +2 -2
  88. package/src/Prebuilt/components/Settings/DeviceSettings.jsx +2 -1
  89. package/src/Prebuilt/components/Settings/LayoutSettings.jsx +1 -24
  90. package/src/Prebuilt/components/Settings/SettingsModal.jsx +152 -17
  91. package/src/Prebuilt/components/ShareMenuIcon.jsx +1 -0
  92. package/src/Prebuilt/components/TileMenu/TileMenu.jsx +133 -0
  93. package/src/Prebuilt/components/TileMenu/TileMenuContent.jsx +313 -0
  94. package/src/Prebuilt/components/VideoList.jsx +5 -33
  95. package/src/Prebuilt/components/VideoTile.jsx +30 -8
  96. package/src/Prebuilt/components/conference.jsx +14 -1
  97. package/src/Prebuilt/components/init/Init.jsx +0 -27
  98. package/src/Prebuilt/components/init/initUtils.js +0 -23
  99. package/src/Prebuilt/components/pdfAnnotator/pdfFileOptions.jsx +2 -1
  100. package/src/Prebuilt/components/pdfAnnotator/pdfInfo.jsx +1 -1
  101. package/src/Prebuilt/components/pdfAnnotator/shareScreenOptions.jsx +19 -8
  102. package/src/Prebuilt/components/pdfAnnotator/uploadedFile.jsx +1 -0
  103. package/src/Prebuilt/images/pdf-share.png +0 -0
  104. package/src/Prebuilt/images/screen-share.png +0 -0
  105. package/src/Prebuilt/index.ts +1 -0
  106. package/src/Prebuilt/layouts/EmbedView.jsx +0 -1
  107. package/src/Prebuilt/layouts/InsetView.jsx +65 -24
  108. package/src/Prebuilt/layouts/PDFView.jsx +0 -1
  109. package/src/Prebuilt/layouts/SidePane.jsx +8 -7
  110. package/src/Prebuilt/layouts/mainView.jsx +22 -31
  111. package/src/Prebuilt/layouts/screenShareView.jsx +0 -2
  112. package/src/Prebuilt/plugins/VirtualBackground/VirtualBackground.jsx +25 -1
  113. package/src/Prebuilt/primitives/DialogContent.jsx +1 -1
  114. package/src/Prebuilt/provider/roomLayoutProvider/index.tsx +1 -1
  115. package/src/Sheet/Sheet.mdx +19 -0
  116. package/src/Sheet/Sheet.stories.tsx +103 -0
  117. package/src/Sheet/Sheet.tsx +118 -0
  118. package/src/Sheet/index.ts +1 -0
  119. package/src/Theme/ThemeProvider.tsx +10 -13
  120. package/src/Theme/base.config.ts +1 -1
  121. package/src/Theme/stitches.config.ts +1 -1
  122. package/src/TileMenu/StyledMenuTile.tsx +2 -2
  123. package/src/TileMenu/TileMenu.tsx +2 -0
  124. package/src/VideoTile/StyledVideoTile.tsx +5 -0
  125. package/src/utils/animations.ts +18 -0
  126. package/dist/ActiveSpeakerView-V6O4K3BV.js +0 -39
  127. package/dist/ActiveSpeakerView-V6O4K3BV.js.map +0 -7
  128. package/dist/PinnedTrackView-7YQG4QKC.js +0 -70
  129. package/dist/PinnedTrackView-7YQG4QKC.js.map +0 -7
  130. package/dist/VirtualBackground-S3XEPZ2T.js.map +0 -7
  131. package/dist/chunk-42SWPN2C.js.map +0 -7
  132. package/dist/chunk-4NEZLVVH.js +0 -811
  133. package/dist/chunk-4NEZLVVH.js.map +0 -7
  134. package/dist/chunk-4ZBEFSRC.js +0 -58
  135. package/dist/chunk-4ZBEFSRC.js.map +0 -7
  136. package/dist/chunk-ESUJK7AT.js.map +0 -7
  137. package/dist/chunk-R6PDR5WZ.js +0 -243
  138. package/dist/chunk-R6PDR5WZ.js.map +0 -7
  139. package/dist/conference-7QKOMJPP.js +0 -3697
  140. package/dist/conference-7QKOMJPP.js.map +0 -7
  141. package/dist/transcription-RJA4V6PC.js +0 -356
  142. package/dist/transcription-RJA4V6PC.js.map +0 -7
  143. package/src/Prebuilt/common/useSortedPeers.js +0 -28
  144. package/src/Prebuilt/components/BottomActionSheet/BottomActionSheet.jsx +0 -96
  145. package/src/Prebuilt/components/BottomActionSheet/BottomActionSheet.stories.tsx +0 -46
  146. package/src/Prebuilt/components/Footer/ConferencingFooter.jsx +0 -101
  147. package/src/Prebuilt/components/Footer/StreamingFooter.jsx +0 -71
  148. package/src/Prebuilt/components/Footer.jsx +0 -8
  149. package/src/Prebuilt/components/MoreSettings/ChangeSelfRole.jsx +0 -67
  150. package/src/Prebuilt/components/TileMenu.jsx +0 -268
  151. package/src/Prebuilt/index.d.ts +0 -20
  152. package/src/Prebuilt/index.js +0 -2
@@ -1,3697 +0,0 @@
1
- import {
2
- FirstPersonDisplay,
3
- GridCenterView,
4
- GridSidePaneView,
5
- ScreenshareTile_default,
6
- VideoList_default,
7
- VideoTile_default,
8
- useAppConfig
9
- } from "./chunk-ESUJK7AT.js";
10
- import {
11
- AudioVideoToggle,
12
- Button,
13
- Checkbox,
14
- Dialog,
15
- DialogCol,
16
- DialogContent,
17
- DialogDropdownTrigger,
18
- DialogInput,
19
- DialogInputFile,
20
- DialogRow,
21
- DialogSelect,
22
- Dropdown,
23
- EmojiReaction,
24
- FeatureFlags,
25
- Footer,
26
- FullPageProgress_default,
27
- Header,
28
- HorizontalDivider,
29
- Input,
30
- Label,
31
- LeaveRoom,
32
- MetaActions_default,
33
- RadioGroup,
34
- RequestDialog,
35
- ResolutionInput,
36
- RoleChangeModal,
37
- SettingsModal_default,
38
- SidePane_default,
39
- Slider,
40
- StreamActions,
41
- Switch,
42
- ThemeTypes,
43
- ToastManager,
44
- UserPreferencesKeys,
45
- Video,
46
- VideoTileStats,
47
- arrayIntersection,
48
- getResolution,
49
- isScreenshareSupported,
50
- isStreamingKit,
51
- useAuthToken,
52
- useDropdownList,
53
- useDropdownSelection,
54
- useFilteredRoles,
55
- useHLSViewerRole,
56
- useHMSPrebuiltContext,
57
- useIsHeadless,
58
- useIsSidepaneTypeOpen,
59
- useNavigation,
60
- usePDFAnnotator,
61
- usePinnedTrack,
62
- useRoomLayout,
63
- useSetAppDataByKey,
64
- useSetUiSettings,
65
- useSidepaneToggle,
66
- useSkipPreview,
67
- useTheme,
68
- useUISettings,
69
- useUrlToEmbed,
70
- useUserPreferences,
71
- useWaitingViewerRole,
72
- useWhiteboardMetadata
73
- } from "./chunk-42SWPN2C.js";
74
- import {
75
- Loading,
76
- useIsFeatureEnabled,
77
- useRolePreference
78
- } from "./chunk-4ZBEFSRC.js";
79
- import {
80
- Box,
81
- Flex,
82
- Text
83
- } from "./chunk-R6PDR5WZ.js";
84
- import {
85
- APP_DATA,
86
- DEFAULT_HLS_VIEWER_ROLE,
87
- EMOJI_REACTION_TYPE,
88
- FEATURE_LIST,
89
- IconButton,
90
- IconButton_default,
91
- RTMP_RECORD_DEFAULT_RESOLUTION,
92
- SESSION_STORE_KEY,
93
- SIDE_PANE_OPTIONS,
94
- Tooltip,
95
- UI_MODE_ACTIVE_SPEAKER,
96
- UI_SETTINGS,
97
- __async,
98
- __publicField,
99
- __spreadProps,
100
- __spreadValues,
101
- config,
102
- define_process_env_default,
103
- init_define_process_env,
104
- isAndroid,
105
- isChrome,
106
- isIOS,
107
- isIPadOS,
108
- isMacOS,
109
- isSafari,
110
- styled
111
- } from "./chunk-4NEZLVVH.js";
112
-
113
- // src/Prebuilt/components/conference.jsx
114
- init_define_process_env();
115
- import React38, { useEffect as useEffect9, useRef as useRef7, useState as useState17 } from "react";
116
- import { useParams } from "react-router-dom";
117
- import { usePrevious } from "react-use";
118
- import {
119
- HMSRoomState,
120
- selectAppData as selectAppData3,
121
- selectIsConnectedToRoom as selectIsConnectedToRoom2,
122
- selectRoomState,
123
- useHMSActions as useHMSActions16,
124
- useHMSStore as useHMSStore21
125
- } from "@100mslive/react-sdk";
126
-
127
- // src/Prebuilt/components/Notifications/HLSFailureModal.jsx
128
- init_define_process_env();
129
- import React, { useCallback, useState } from "react";
130
- import { selectHLSState, useHMSActions, useHMSStore } from "@100mslive/react-sdk";
131
- function HLSFailureModal() {
132
- const { hlsError } = useHMSStore(selectHLSState).error || false;
133
- const [openModal, setOpenModal] = useState(!!hlsError);
134
- const hmsActions = useHMSActions();
135
- const [isHLSStarted, setHLSStarted] = useSetAppDataByKey(APP_DATA.hlsStarted);
136
- const startHLS = useCallback(() => __async(this, null, function* () {
137
- try {
138
- if (isHLSStarted) {
139
- return;
140
- }
141
- setHLSStarted(true);
142
- yield hmsActions.startHLSStreaming({});
143
- } catch (error) {
144
- if (error.message.includes("invalid input")) {
145
- yield startHLS();
146
- return;
147
- }
148
- setHLSStarted(false);
149
- }
150
- }), [hmsActions, isHLSStarted, setHLSStarted]);
151
- return hlsError ? /* @__PURE__ */ React.createElement(
152
- Dialog.Root,
153
- {
154
- open: openModal,
155
- onOpenChange: (value) => {
156
- if (!value) {
157
- setOpenModal(false);
158
- }
159
- }
160
- },
161
- /* @__PURE__ */ React.createElement(Dialog.Portal, null, /* @__PURE__ */ React.createElement(Dialog.Overlay, null), /* @__PURE__ */ React.createElement(Dialog.Content, { css: { w: "min(360px, 90%)" } }, /* @__PURE__ */ React.createElement(
162
- Dialog.Title,
163
- {
164
- css: {
165
- display: "flex",
166
- alignItems: "center",
167
- justifyContent: "space-between",
168
- borderBottom: "1px solid $border_default",
169
- mt: "$4"
170
- }
171
- },
172
- /* @__PURE__ */ React.createElement(Text, { variant: "h6", css: { fontWeight: "$semiBold" } }, "Failed to Go Live")
173
- ), /* @__PURE__ */ React.createElement(Text, { variant: "sm", css: { mb: "$10", color: "$on_surface_medium" } }, "Something went wrong and your live broadcast failed. Please try again."), /* @__PURE__ */ React.createElement(Flex, { align: "center", justify: "between", css: { w: "100%", gap: "$8" } }, /* @__PURE__ */ React.createElement(Button, { outlined: true, variant: "standard", css: { w: "100%" }, onClick: () => setOpenModal(false) }, "Dismiss"), /* @__PURE__ */ React.createElement(Button, { css: { w: "100%" } }, "Go Live"))))
174
- ) : null;
175
- }
176
-
177
- // src/Prebuilt/layouts/mainView.jsx
178
- init_define_process_env();
179
- import React12, { Suspense, useCallback as useCallback5, useEffect as useEffect5 } from "react";
180
- import { JoinForm_JoinBtnType } from "@100mslive/types-prebuilt/elements/join_form";
181
- import {
182
- selectIsConnectedToRoom,
183
- selectLocalPeerRoleName as selectLocalPeerRoleName3,
184
- selectPeerScreenSharing as selectPeerScreenSharing3,
185
- selectPeerSharingAudio,
186
- selectPeerSharingVideoPlaylist as selectPeerSharingVideoPlaylist3,
187
- selectPermissions,
188
- selectTemplateAppData,
189
- useHMSActions as useHMSActions6,
190
- useHMSStore as useHMSStore10,
191
- useRecordingStreaming
192
- } from "@100mslive/react-sdk";
193
-
194
- // src/Prebuilt/layouts/EmbedView.jsx
195
- init_define_process_env();
196
- import React6, { useCallback as useCallback3, useEffect, useMemo as useMemo2, useRef as useRef2, useState as useState2 } from "react";
197
- import { useMedia as useMedia2 } from "react-use";
198
- import {
199
- selectLocalPeerID as selectLocalPeerID2,
200
- selectLocalPeerRoleName as selectLocalPeerRoleName2,
201
- selectPeers as selectPeers2,
202
- selectPeerScreenSharing as selectPeerScreenSharing2,
203
- throwErrorHandler,
204
- useHMSStore as useHMSStore6,
205
- useScreenShare
206
- } from "@100mslive/react-sdk";
207
-
208
- // src/Prebuilt/layouts/screenShareView.jsx
209
- init_define_process_env();
210
- import React5, { Fragment, useCallback as useCallback2, useMemo } from "react";
211
- import { useMedia } from "react-use";
212
- import {
213
- selectLocalPeerID,
214
- selectLocalPeerRoleName,
215
- selectPeers,
216
- selectPeerScreenSharing,
217
- selectPeerSharingVideoPlaylist as selectPeerSharingVideoPlaylist2,
218
- selectScreenShareByPeerID,
219
- useHMSStore as useHMSStore5
220
- } from "@100mslive/react-sdk";
221
-
222
- // src/Prebuilt/components/Playlist/VideoPlayer.jsx
223
- init_define_process_env();
224
- import React3, { useRef } from "react";
225
- import { useFullscreen, useToggle } from "react-use";
226
- import screenfull from "screenfull";
227
- import {
228
- selectVideoPlaylist as selectVideoPlaylist3,
229
- selectVideoPlaylistAudioTrackByPeerID as selectVideoPlaylistAudioTrackByPeerID2,
230
- selectVideoPlaylistVideoTrackByPeerID,
231
- useHMSActions as useHMSActions4,
232
- useHMSStore as useHMSStore4
233
- } from "@100mslive/react-sdk";
234
- import { CrossIcon, ExpandIcon, ShrinkIcon } from "@100mslive/react-icons";
235
-
236
- // src/Prebuilt/components/Playlist/PlaylistControls.jsx
237
- init_define_process_env();
238
- import React2 from "react";
239
- import {
240
- HMSPlaylistType as HMSPlaylistType2,
241
- selectAudioPlaylist as selectAudioPlaylist2,
242
- selectAudioTrackVolume,
243
- selectPeerSharingVideoPlaylist,
244
- selectVideoPlaylist as selectVideoPlaylist2,
245
- selectVideoPlaylistAudioTrackByPeerID,
246
- useHMSActions as useHMSActions3,
247
- useHMSStore as useHMSStore3
248
- } from "@100mslive/react-sdk";
249
- import { NextIcon, PauseIcon, PlayIcon, PlaylistIcon, PrevIcon, SpeakerIcon } from "@100mslive/react-icons";
250
-
251
- // src/Prebuilt/components/hooks/usePlaylist.js
252
- init_define_process_env();
253
- import {
254
- HMSPlaylistType,
255
- selectAudioPlaylist,
256
- selectVideoPlaylist,
257
- useHMSActions as useHMSActions2,
258
- useHMSStore as useHMSStore2
259
- } from "@100mslive/react-sdk";
260
- var usePlaylist = (type) => {
261
- const isAudioPlaylist = type === HMSPlaylistType.audio;
262
- const selector = isAudioPlaylist ? selectAudioPlaylist : selectVideoPlaylist;
263
- const active = useHMSStore2(selector.selectedItem);
264
- const selection = useHMSStore2(selector.selection);
265
- const playlist = useHMSStore2(selector.list);
266
- const hmsActions = useHMSActions2();
267
- const playlistAction = isAudioPlaylist ? hmsActions.audioPlaylist : hmsActions.videoPlaylist;
268
- return {
269
- active,
270
- hasNext: selection.hasNext,
271
- hasPrevious: selection.hasPrevious,
272
- actions: playlistAction,
273
- list: playlist
274
- };
275
- };
276
-
277
- // src/Prebuilt/components/Playlist/PlaylistControls.jsx
278
- var Progress = ({ type, duration }) => {
279
- const selectPlaylist = type === HMSPlaylistType2.audio ? selectAudioPlaylist2 : selectVideoPlaylist2;
280
- const progress = useHMSStore3(selectPlaylist.progress);
281
- const hmsActions = useHMSActions3();
282
- const playlistAction = type === HMSPlaylistType2.audio ? hmsActions.audioPlaylist : hmsActions.videoPlaylist;
283
- if (!duration) {
284
- return null;
285
- }
286
- return /* @__PURE__ */ React2.createElement(
287
- Slider,
288
- {
289
- step: 1,
290
- value: [progress],
291
- onValueChange: (e) => {
292
- playlistAction.seekTo(e[0] * 0.01 * duration);
293
- }
294
- }
295
- );
296
- };
297
- var Controls = ({ type, css = {} }) => {
298
- const { active, hasNext, hasPrevious, actions } = usePlaylist(type);
299
- if (!active) {
300
- return null;
301
- }
302
- return /* @__PURE__ */ React2.createElement(Flex, { justify: "center", css }, /* @__PURE__ */ React2.createElement(
303
- IconButton,
304
- {
305
- disabled: !hasPrevious,
306
- onClick: () => {
307
- actions.playPrevious();
308
- },
309
- "data-testid": "playlist_prev_btn"
310
- },
311
- /* @__PURE__ */ React2.createElement(PrevIcon, null)
312
- ), /* @__PURE__ */ React2.createElement(
313
- IconButton,
314
- {
315
- onClick: () => {
316
- active.playing ? actions.pause() : actions.play(active.id);
317
- },
318
- "data-testid": "playlist_play_pause_btn"
319
- },
320
- active.playing ? /* @__PURE__ */ React2.createElement(PauseIcon, { width: 32, height: 32 }) : /* @__PURE__ */ React2.createElement(PlayIcon, { width: 32, height: 32 })
321
- ), /* @__PURE__ */ React2.createElement(
322
- IconButton,
323
- {
324
- disabled: !hasNext,
325
- onClick: () => {
326
- actions.playNext();
327
- },
328
- "data-testid": "playlist_next_btn"
329
- },
330
- /* @__PURE__ */ React2.createElement(NextIcon, null)
331
- ));
332
- };
333
- var VolumeControl = () => {
334
- const hmsActions = useHMSActions3();
335
- const volume = useHMSStore3(selectVideoPlaylist2.volume);
336
- const active = useHMSStore3(selectVideoPlaylist2.selectedItem);
337
- const peerSharingPlaylist = useHMSStore3(selectPeerSharingVideoPlaylist);
338
- const audioTrack = useHMSStore3(selectVideoPlaylistAudioTrackByPeerID(peerSharingPlaylist == null ? void 0 : peerSharingPlaylist.id));
339
- const audioTrackVolume = useHMSStore3(selectAudioTrackVolume(audioTrack == null ? void 0 : audioTrack.id));
340
- const sliderVolume = active ? volume : audioTrackVolume;
341
- return /* @__PURE__ */ React2.createElement(Flex, { align: "center", css: { color: "$on_primary_high" } }, /* @__PURE__ */ React2.createElement(SpeakerIcon, null), /* @__PURE__ */ React2.createElement(
342
- Slider,
343
- {
344
- css: { mx: "$4", w: "$20" },
345
- min: 0,
346
- max: 100,
347
- step: 1,
348
- value: [Math.floor(sliderVolume != null ? sliderVolume : 100)],
349
- onValueChange: (e) => {
350
- const value = e[0];
351
- if (active) {
352
- hmsActions.videoPlaylist.setVolume(value);
353
- } else if (audioTrack) {
354
- hmsActions.setVolume(value, audioTrack.id);
355
- }
356
- },
357
- thumbStyles: { w: "$6", h: "$6" }
358
- }
359
- ));
360
- };
361
- var VideoPlaylistControls = ({ children }) => {
362
- const { active } = usePlaylist(HMSPlaylistType2.video);
363
- return /* @__PURE__ */ React2.createElement(
364
- Box,
365
- {
366
- css: {
367
- p: "$8",
368
- mt: "-$24",
369
- w: "100%",
370
- zIndex: 1,
371
- "@lg": {
372
- mt: 0,
373
- p: "$6"
374
- }
375
- }
376
- },
377
- active && /* @__PURE__ */ React2.createElement(Progress, { type: HMSPlaylistType2.video, duration: active.duration }),
378
- /* @__PURE__ */ React2.createElement(Flex, { align: "center", justify: "between" }, /* @__PURE__ */ React2.createElement(VolumeControl, null), active && /* @__PURE__ */ React2.createElement(Controls, { css: { flex: "1 1 0" } }), children)
379
- );
380
- };
381
-
382
- // src/Prebuilt/components/Playlist/VideoPlayer.jsx
383
- var VideoPlayer = React3.memo(({ peerId }) => {
384
- const videoTrack = useHMSStore4(selectVideoPlaylistVideoTrackByPeerID(peerId));
385
- const audioTrack = useHMSStore4(selectVideoPlaylistAudioTrackByPeerID2(peerId));
386
- const active = useHMSStore4(selectVideoPlaylist3.selectedItem);
387
- const isAudioOnly = useUISettings(UI_SETTINGS.isAudioOnly);
388
- const hmsActions = useHMSActions4();
389
- const ref = useRef(null);
390
- const [show, toggle] = useToggle(false);
391
- const isFullscreen = useFullscreen(ref, show, {
392
- onClose: () => toggle(false)
393
- });
394
- const showStatsOnTiles = useUISettings(UI_SETTINGS.showStatsOnTiles);
395
- return /* @__PURE__ */ React3.createElement(Flex, { direction: "column", justify: "center", css: { w: "100%", h: "100%" }, ref }, active && /* @__PURE__ */ React3.createElement(
396
- Flex,
397
- {
398
- justify: "between",
399
- align: "center",
400
- css: {
401
- bg: "$surface_default",
402
- p: "$2 $2 $2 $6",
403
- borderTopLeftRadius: "$1",
404
- borderTopRightRadius: "$1"
405
- }
406
- },
407
- /* @__PURE__ */ React3.createElement(Text, { css: { color: "$on_primary_high" } }, active.name),
408
- /* @__PURE__ */ React3.createElement(
409
- IconButton,
410
- {
411
- css: {
412
- color: "$on_primary_high"
413
- },
414
- onClick: () => {
415
- hmsActions.videoPlaylist.stop();
416
- },
417
- "data-testid": "videoplaylist_cross_btn"
418
- },
419
- /* @__PURE__ */ React3.createElement(CrossIcon, null)
420
- )
421
- ), showStatsOnTiles ? /* @__PURE__ */ React3.createElement(Box, { css: { "& > div": { top: "$14", left: "$8" } } }, /* @__PURE__ */ React3.createElement(
422
- VideoTileStats,
423
- {
424
- audioTrackID: audioTrack == null ? void 0 : audioTrack.id,
425
- videoTrackID: videoTrack == null ? void 0 : videoTrack.id,
426
- peerID: peerId,
427
- isLocal: active
428
- }
429
- )) : null, /* @__PURE__ */ React3.createElement(
430
- Video,
431
- {
432
- trackId: videoTrack == null ? void 0 : videoTrack.id,
433
- attach: !isAudioOnly,
434
- css: {
435
- objectFit: "contain",
436
- h: "auto",
437
- r: "$1",
438
- borderTopLeftRadius: 0,
439
- borderTopRightRadius: 0
440
- }
441
- }
442
- ), /* @__PURE__ */ React3.createElement(VideoPlaylistControls, null, screenfull.enabled && /* @__PURE__ */ React3.createElement(
443
- IconButton,
444
- {
445
- onClick: () => toggle(),
446
- css: {
447
- color: "$on_primary_high",
448
- height: "max-content",
449
- alignSelf: "center",
450
- cursor: "pointer"
451
- }
452
- },
453
- isFullscreen ? /* @__PURE__ */ React3.createElement(ShrinkIcon, null) : /* @__PURE__ */ React3.createElement(ExpandIcon, null)
454
- )));
455
- });
456
-
457
- // src/Prebuilt/components/ScreenshareDisplay.jsx
458
- init_define_process_env();
459
- import React4 from "react";
460
- import { useHMSActions as useHMSActions5 } from "@100mslive/react-sdk";
461
- import { CrossIcon as CrossIcon2, ShareScreenIcon } from "@100mslive/react-icons";
462
- var ScreenshareDisplay = () => {
463
- const hmsActions = useHMSActions5();
464
- return /* @__PURE__ */ React4.createElement(
465
- Flex,
466
- {
467
- direction: "column",
468
- align: "center",
469
- justify: "center",
470
- css: {
471
- position: "relative",
472
- overflow: "hidden",
473
- w: "37.5rem",
474
- maxWidth: "80%",
475
- h: "100%",
476
- r: "$3",
477
- m: "0 auto",
478
- color: "$on_surface_high",
479
- bg: "$surface_default",
480
- textAlign: "center"
481
- }
482
- },
483
- /* @__PURE__ */ React4.createElement(ShareScreenIcon, { width: 48, height: 48 }),
484
- /* @__PURE__ */ React4.createElement(Text, { variant: "h5", css: { m: "$8 0" } }, "You are sharing your screen"),
485
- /* @__PURE__ */ React4.createElement(
486
- Button,
487
- {
488
- variant: "danger",
489
- onClick: () => __async(void 0, null, function* () {
490
- yield hmsActions.setScreenShareEnabled(false);
491
- }),
492
- "data-testid": "stop_screen_share_btn"
493
- },
494
- /* @__PURE__ */ React4.createElement(CrossIcon2, { width: 18, height: 18 }),
495
- "\xA0 Stop screen share"
496
- )
497
- );
498
- };
499
-
500
- // src/Prebuilt/layouts/screenShareView.jsx
501
- var ScreenShareView = () => {
502
- var _a;
503
- const mediaQueryLg = config.media.xl;
504
- const showSidebarInBottom = useMedia(mediaQueryLg);
505
- const peers = useHMSStore5(selectPeers);
506
- const localPeerID = useHMSStore5(selectLocalPeerID);
507
- const localPeerRole = useHMSStore5(selectLocalPeerRoleName);
508
- const peerPresenting = useHMSStore5(selectPeerScreenSharing);
509
- const peerSharingPlaylist = useHMSStore5(selectPeerSharingVideoPlaylist2);
510
- const isPresenterFromMyRole = ((_a = peerPresenting == null ? void 0 : peerPresenting.roleName) == null ? void 0 : _a.toLowerCase()) === (localPeerRole == null ? void 0 : localPeerRole.toLowerCase());
511
- const amIPresenting = localPeerID === (peerPresenting == null ? void 0 : peerPresenting.id);
512
- const showPresenterInSmallTile = showSidebarInBottom || amIPresenting || isPresenterFromMyRole;
513
- const smallTilePeers = useMemo(() => {
514
- const smallTilePeers2 = peers.filter((peer) => peer.id !== (peerPresenting == null ? void 0 : peerPresenting.id));
515
- if (showPresenterInSmallTile && peerPresenting) {
516
- smallTilePeers2.unshift(peerPresenting);
517
- }
518
- return smallTilePeers2;
519
- }, [peers, peerPresenting, showPresenterInSmallTile]);
520
- return /* @__PURE__ */ React5.createElement(
521
- Flex,
522
- {
523
- css: {
524
- size: "100%"
525
- },
526
- direction: showSidebarInBottom ? "column" : "row"
527
- },
528
- /* @__PURE__ */ React5.createElement(
529
- ScreenShareComponent,
530
- {
531
- amIPresenting,
532
- peerPresenting,
533
- peerSharingPlaylist
534
- }
535
- ),
536
- /* @__PURE__ */ React5.createElement(
537
- Flex,
538
- {
539
- direction: { "@initial": "column", "@lg": "row" },
540
- css: {
541
- overflow: "hidden",
542
- p: "$4 $8",
543
- flex: "0 0 20%",
544
- "@xl": {
545
- flex: "1 1 0"
546
- }
547
- }
548
- },
549
- /* @__PURE__ */ React5.createElement(
550
- SidePane,
551
- {
552
- showSidebarInBottom,
553
- peerScreenSharing: peerPresenting,
554
- isPresenterInSmallTiles: showPresenterInSmallTile,
555
- smallTilePeers,
556
- totalPeers: peers.length
557
- }
558
- )
559
- )
560
- );
561
- };
562
- var SidePane = ({
563
- isPresenterInSmallTiles,
564
- peerScreenSharing,
565
- // the peer who is screensharing
566
- smallTilePeers,
567
- showSidebarInBottom
568
- }) => {
569
- const shouldShowScreenFn = useCallback2(
570
- (peer) => peerScreenSharing && peer.id !== peerScreenSharing.id,
571
- [peerScreenSharing]
572
- );
573
- return /* @__PURE__ */ React5.createElement(Fragment, null, !isPresenterInSmallTiles && /* @__PURE__ */ React5.createElement(LargeTilePeerView, { peerScreenSharing }), /* @__PURE__ */ React5.createElement(
574
- SmallTilePeersView,
575
- {
576
- showSidebarInBottom,
577
- smallTilePeers,
578
- shouldShowScreenFn
579
- }
580
- ));
581
- };
582
- var ScreenShareComponent = ({ amIPresenting, peerPresenting, peerSharingPlaylist }) => {
583
- const screenshareTrack = useHMSStore5(selectScreenShareByPeerID(peerPresenting == null ? void 0 : peerPresenting.id));
584
- if (peerSharingPlaylist) {
585
- return /* @__PURE__ */ React5.createElement(
586
- Box,
587
- {
588
- css: {
589
- mx: "$8",
590
- flex: "3 1 0",
591
- "@xl": {
592
- flex: "2 1 0",
593
- display: "flex",
594
- alignItems: "center"
595
- }
596
- }
597
- },
598
- /* @__PURE__ */ React5.createElement(VideoPlayer, { peerId: peerSharingPlaylist.id })
599
- );
600
- }
601
- return /* @__PURE__ */ React5.createElement(
602
- Box,
603
- {
604
- css: {
605
- flex: "3 1 0",
606
- mx: "$8",
607
- "@xl": { ml: "$4", maxHeight: "80%", minHeight: 0 }
608
- }
609
- },
610
- peerPresenting && (amIPresenting && !["browser", "window", "application"].includes(screenshareTrack == null ? void 0 : screenshareTrack.displaySurface) ? /* @__PURE__ */ React5.createElement(Box, { css: { objectFit: "contain", h: "100%" } }, /* @__PURE__ */ React5.createElement(ScreenshareDisplay, null)) : /* @__PURE__ */ React5.createElement(ScreenshareTile_default, { peerId: peerPresenting == null ? void 0 : peerPresenting.id }))
611
- );
612
- };
613
- var SmallTilePeersView = ({ smallTilePeers, shouldShowScreenFn, showSidebarInBottom }) => {
614
- return /* @__PURE__ */ React5.createElement(
615
- Flex,
616
- {
617
- css: {
618
- flex: "2 1 0"
619
- }
620
- },
621
- smallTilePeers && smallTilePeers.length > 0 && /* @__PURE__ */ React5.createElement(
622
- VideoList_default,
623
- {
624
- peers: smallTilePeers,
625
- maxColCount: showSidebarInBottom ? void 0 : 1,
626
- maxRowCount: showSidebarInBottom ? 1 : void 0,
627
- includeScreenShareForPeer: shouldShowScreenFn
628
- }
629
- )
630
- );
631
- };
632
- var LargeTilePeerView = ({ peerScreenSharing, showStatsOnTiles }) => {
633
- return peerScreenSharing ? /* @__PURE__ */ React5.createElement(
634
- Box,
635
- {
636
- css: {
637
- flex: "1 1 0",
638
- minHeight: "25%",
639
- py: "$4",
640
- "@lg": {
641
- mr: "$4",
642
- minHeight: "unset",
643
- py: 0
644
- },
645
- "@sm": {
646
- height: "100%",
647
- maxHeight: "75%",
648
- alignSelf: "center"
649
- }
650
- }
651
- },
652
- /* @__PURE__ */ React5.createElement(VideoTile_default, { showStatsOnTiles, width: "100%", height: "100%", peerId: peerScreenSharing.id })
653
- ) : null;
654
- };
655
- var screenShareView_default = ScreenShareView;
656
-
657
- // src/Prebuilt/layouts/EmbedView.jsx
658
- var EmbedView = () => {
659
- return /* @__PURE__ */ React6.createElement(EmbebScreenShareView, null, /* @__PURE__ */ React6.createElement(EmbedComponent, null));
660
- };
661
- var EmbebScreenShareView = ({ children }) => {
662
- var _a;
663
- const peers = useHMSStore6(selectPeers2);
664
- const mediaQueryLg = config.media.xl;
665
- const showSidebarInBottom = useMedia2(mediaQueryLg);
666
- const localPeerID = useHMSStore6(selectLocalPeerID2);
667
- const localPeerRole = useHMSStore6(selectLocalPeerRoleName2);
668
- const peerPresenting = useHMSStore6(selectPeerScreenSharing2);
669
- const isPresenterFromMyRole = ((_a = peerPresenting == null ? void 0 : peerPresenting.roleName) == null ? void 0 : _a.toLowerCase()) === (localPeerRole == null ? void 0 : localPeerRole.toLowerCase());
670
- const amIPresenting = localPeerID === (peerPresenting == null ? void 0 : peerPresenting.id);
671
- const showPresenterInSmallTile = showSidebarInBottom || amIPresenting || isPresenterFromMyRole;
672
- const smallTilePeers = useMemo2(() => {
673
- const smallTilePeers2 = peers.filter((peer) => peer.id !== (peerPresenting == null ? void 0 : peerPresenting.id));
674
- if (showPresenterInSmallTile && peerPresenting) {
675
- smallTilePeers2.unshift(peerPresenting);
676
- }
677
- return smallTilePeers2;
678
- }, [peers, peerPresenting, showPresenterInSmallTile]);
679
- return /* @__PURE__ */ React6.createElement(Flex, { css: { size: "100%" }, direction: showSidebarInBottom ? "column" : "row" }, children, /* @__PURE__ */ React6.createElement(
680
- Flex,
681
- {
682
- direction: { "@initial": "column", "@lg": "row" },
683
- css: {
684
- overflow: "hidden",
685
- p: "$4 $8",
686
- flex: "0 0 20%",
687
- "@xl": {
688
- flex: "1 1 0"
689
- }
690
- }
691
- },
692
- /* @__PURE__ */ React6.createElement(
693
- SidePane,
694
- {
695
- showSidebarInBottom,
696
- peerScreenSharing: peerPresenting,
697
- isPresenterInSmallTiles: showPresenterInSmallTile,
698
- smallTilePeers,
699
- totalPeers: peers.length
700
- }
701
- )
702
- ));
703
- };
704
- var EmbedComponent = () => {
705
- const { amIScreenSharing, toggleScreenShare } = useScreenShare(throwErrorHandler);
706
- const [embedConfig, setEmbedConfig] = useSetAppDataByKey(APP_DATA.embedConfig);
707
- const [wasScreenShared, setWasScreenShared] = useState2(false);
708
- const screenShareAttemptInProgress = useRef2(false);
709
- const src = embedConfig.url;
710
- const iframeRef = useRef2();
711
- const resetEmbedConfig = useCallback3(() => {
712
- if (src) {
713
- setEmbedConfig({ url: "" });
714
- }
715
- }, [src, setEmbedConfig]);
716
- useEffect(() => {
717
- if (embedConfig.shareScreen && !amIScreenSharing && !wasScreenShared && !screenShareAttemptInProgress.current) {
718
- screenShareAttemptInProgress.current = true;
719
- toggleScreenShare({
720
- forceCurrentTab: true,
721
- cropElement: iframeRef.current
722
- }).then(() => {
723
- setWasScreenShared(true);
724
- }).catch(resetEmbedConfig).finally(() => {
725
- screenShareAttemptInProgress.current = false;
726
- });
727
- }
728
- }, []);
729
- useEffect(() => {
730
- if (wasScreenShared && !amIScreenSharing) {
731
- resetEmbedConfig();
732
- }
733
- return () => {
734
- if (wasScreenShared && amIScreenSharing) {
735
- resetEmbedConfig();
736
- toggleScreenShare();
737
- }
738
- };
739
- }, [wasScreenShared, amIScreenSharing, resetEmbedConfig, toggleScreenShare]);
740
- return /* @__PURE__ */ React6.createElement(
741
- Box,
742
- {
743
- ref: iframeRef,
744
- css: {
745
- mx: "$8",
746
- flex: "3 1 0",
747
- "@lg": {
748
- flex: "2 1 0",
749
- display: "flex",
750
- alignItems: "center"
751
- }
752
- }
753
- },
754
- /* @__PURE__ */ React6.createElement(
755
- "iframe",
756
- {
757
- src,
758
- title: src,
759
- style: { width: "100%", height: "100%", border: 0 },
760
- allow: "accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture fullscreen",
761
- referrerPolicy: "no-referrer"
762
- }
763
- )
764
- );
765
- };
766
-
767
- // src/Prebuilt/layouts/InsetView.jsx
768
- init_define_process_env();
769
- import React7, { Fragment as Fragment2, useEffect as useEffect2, useRef as useRef3 } from "react";
770
- import Draggable from "react-draggable";
771
- import { useMedia as useMedia3 } from "react-use";
772
- import { selectAppData, selectLocalPeer, selectRemotePeers, selectRolesMap, useHMSStore as useHMSStore7 } from "@100mslive/react-sdk";
773
- var getAspectRatio = ({ roleMap, roleName, isMobile }) => {
774
- const role = roleMap[roleName];
775
- const { width, height } = role.publishParams.video;
776
- return isMobile ? height / width : width / height;
777
- };
778
- function InsetView() {
779
- var _a;
780
- const remotePeers = useHMSStore7(selectRemotePeers);
781
- const localPeer = useHMSStore7(selectLocalPeer);
782
- const isMobile = useMedia3(config.media.md);
783
- const isLandscape = useMedia3(config.media.ls);
784
- const roleMap = useHMSStore7(selectRolesMap);
785
- const rolePreference = useRolePreference();
786
- let centerPeers = [];
787
- let sidepanePeers = [];
788
- if (rolePreference) {
789
- const center = ((_a = rolePreference[localPeer.roleName]) == null ? void 0 : _a.split(",")) || [];
790
- for (const peer of remotePeers) {
791
- if (center.includes(peer.roleName)) {
792
- centerPeers.push(peer);
793
- } else {
794
- sidepanePeers.push(peer);
795
- }
796
- }
797
- if (centerPeers.length === 0 && sidepanePeers.length > 0) {
798
- centerPeers = sidepanePeers;
799
- sidepanePeers = [];
800
- }
801
- } else {
802
- centerPeers = remotePeers;
803
- }
804
- const hideInset = sidepanePeers.length > 0 && (isMobile || isLandscape);
805
- return /* @__PURE__ */ React7.createElement(Fragment2, null, /* @__PURE__ */ React7.createElement(
806
- Box,
807
- {
808
- css: {
809
- display: "grid",
810
- gridTemplateColumns: sidepanePeers.length > 0 ? "3fr 1fr" : "100%",
811
- gridTemplateRows: "1fr",
812
- gap: "$8",
813
- px: "$10",
814
- size: "100%",
815
- "@md": {
816
- gridTemplateColumns: "1fr",
817
- gridTemplateRows: sidepanePeers.length > 0 ? `3fr 1fr` : "100%"
818
- }
819
- }
820
- },
821
- /* @__PURE__ */ React7.createElement(
822
- Flex,
823
- {
824
- align: "center",
825
- justify: "center",
826
- css: {
827
- size: "100%",
828
- gap: "$8",
829
- flexWrap: "wrap",
830
- placeContent: "center",
831
- minHeight: 0,
832
- minWidth: 0,
833
- "@lg": { flexFlow: "column" },
834
- "@ls": { flexFlow: "row" }
835
- }
836
- },
837
- centerPeers.length > 0 ? centerPeers.map((peer) => /* @__PURE__ */ React7.createElement(
838
- VideoTile_default,
839
- {
840
- key: peer.videoTrack || peer.id,
841
- peerId: peer.id,
842
- trackId: peer.videoTrack,
843
- rootCSS: {
844
- aspectRatio: getAspectRatio({
845
- roleMap,
846
- roleName: peer.roleName,
847
- isMobile
848
- }),
849
- padding: 0,
850
- height: "100%",
851
- maxWidth: "100%",
852
- minWidth: 0,
853
- minHeight: 0,
854
- flex: remotePeers.length === 1 ? void 0 : "1 1 0",
855
- display: "flex",
856
- alignItems: "center",
857
- "@lg": {
858
- display: "block",
859
- padding: "0 !important",
860
- width: "100%"
861
- }
862
- },
863
- objectFit: "contain"
864
- }
865
- )) : /* @__PURE__ */ React7.createElement(FirstPersonDisplay, null)
866
- ),
867
- sidepanePeers.length > 0 && /* @__PURE__ */ React7.createElement(
868
- Flex,
869
- {
870
- align: "center",
871
- justify: "center",
872
- css: {
873
- size: "100%",
874
- gap: "$4",
875
- flexFlow: "row wrap",
876
- placeContent: "center"
877
- }
878
- },
879
- (hideInset ? [...sidepanePeers, localPeer] : sidepanePeers).map((peer, _, arr) => /* @__PURE__ */ React7.createElement(
880
- VideoTile_default,
881
- {
882
- key: peer.videoTrack || peer.id,
883
- peerId: peer.id,
884
- trackId: peer.videoTrack,
885
- rootCSS: {
886
- aspectRatio: getAspectRatio({
887
- roleMap,
888
- roleName: peer.roleName,
889
- isMobile: false
890
- }),
891
- flexBasis: "100%",
892
- "@ls": {
893
- aspectRatio: 1,
894
- flexBasis: "calc(50% - $4)"
895
- },
896
- "@md": {
897
- aspectRatio: 1,
898
- flexBasis: arr.length < 4 ? "calc(50% - $4)" : "calc(33% - $4)"
899
- },
900
- "@sm": {
901
- flexBasis: arr.length <= 4 ? "calc(50% - $4)" : "calc(33% - $4)"
902
- },
903
- padding: 0
904
- },
905
- objectFit: "contain"
906
- }
907
- ))
908
- )
909
- ), !hideInset && /* @__PURE__ */ React7.createElement(InsetTile, { roleMap, isMobile, isLandscape }));
910
- }
911
- var InsetTile = ({ isMobile, roleMap, isLandscape }) => {
912
- const localPeer = useHMSStore7(selectLocalPeer);
913
- const sidepane = useHMSStore7(selectAppData(APP_DATA.sidePane));
914
- const aspectRatio = getAspectRatio({
915
- roleMap,
916
- roleName: localPeer.roleName,
917
- isMobile
918
- });
919
- let height = 180;
920
- let width = height * aspectRatio;
921
- if (isLandscape && width > 240) {
922
- width = 240;
923
- height = width / aspectRatio;
924
- }
925
- const nodeRef = useRef3(null);
926
- useEffect2(() => {
927
- if (!nodeRef.current || !window.ResizeObserver) {
928
- return;
929
- }
930
- const node = nodeRef.current;
931
- const resizeObserver = new ResizeObserver((entries) => {
932
- entries.forEach((entry) => {
933
- if (entry.target === node.parentElement) {
934
- node.style.transform = `translate(0,0)`;
935
- }
936
- });
937
- });
938
- resizeObserver.observe(node.parentElement);
939
- return () => {
940
- (node == null ? void 0 : node.parentElement) && (resizeObserver == null ? void 0 : resizeObserver.unobserve(node.parentElement));
941
- resizeObserver == null ? void 0 : resizeObserver.disconnect();
942
- };
943
- }, []);
944
- return /* @__PURE__ */ React7.createElement(Draggable, { bounds: "parent", nodeRef }, /* @__PURE__ */ React7.createElement(
945
- Box,
946
- {
947
- ref: nodeRef,
948
- css: {
949
- position: "absolute",
950
- bottom: 0,
951
- right: sidepane ? "$100" : "$10",
952
- mr: sidepane ? "$14" : 0,
953
- boxShadow: "0 0 8px 0 rgba(0,0,0,0.3)",
954
- zIndex: 10,
955
- aspectRatio,
956
- h: height
957
- }
958
- },
959
- /* @__PURE__ */ React7.createElement(
960
- VideoTile_default,
961
- {
962
- peerId: localPeer.id,
963
- trackid: localPeer.videoTrack,
964
- rootCSS: {
965
- size: "100%",
966
- padding: 0
967
- },
968
- width,
969
- height
970
- }
971
- )
972
- ));
973
- };
974
-
975
- // src/Prebuilt/layouts/mainGridView.jsx
976
- init_define_process_env();
977
- import React9, { useEffect as useEffect3, useState as useState3 } from "react";
978
- import {
979
- selectLocalPeerID as selectLocalPeerID3,
980
- selectLocalPeerRole,
981
- selectPeers as selectPeers3,
982
- selectPeersByRoles,
983
- selectRolesMap as selectRolesMap2,
984
- useHMSStore as useHMSStore9
985
- } from "@100mslive/react-sdk";
986
-
987
- // src/Prebuilt/layouts/NonPublisherView.jsx
988
- init_define_process_env();
989
- import React8 from "react";
990
- import { ShieldAlertIcon } from "@100mslive/react-icons";
991
- var NonPublisherView = React8.memo(({ message }) => {
992
- return /* @__PURE__ */ React8.createElement(
993
- Box,
994
- {
995
- css: {
996
- overflow: "hidden",
997
- w: "96%",
998
- maxWidth: "96%",
999
- h: "100%",
1000
- m: "auto",
1001
- background: "$surface_default",
1002
- borderRadius: "$3"
1003
- },
1004
- "data-testid": "non_publisher_view"
1005
- },
1006
- /* @__PURE__ */ React8.createElement(
1007
- Flex,
1008
- {
1009
- align: "center",
1010
- direction: "column",
1011
- css: {
1012
- w: "$96",
1013
- textAlign: "center",
1014
- margin: "auto",
1015
- h: "100%",
1016
- justifyContent: "center",
1017
- gap: "$8"
1018
- }
1019
- },
1020
- /* @__PURE__ */ React8.createElement(ShieldAlertIcon, { color: "#C3D0E5", width: "80px", height: "80px" }),
1021
- /* @__PURE__ */ React8.createElement(
1022
- Flex,
1023
- {
1024
- direction: "column",
1025
- css: {
1026
- w: "$80",
1027
- p: "$1",
1028
- gap: "$4"
1029
- }
1030
- },
1031
- /* @__PURE__ */ React8.createElement(Text, { color: "white", variant: "h6", css: { "@md": { fontSize: "$md" } } }, message),
1032
- /* @__PURE__ */ React8.createElement(Text, { color: "$on_surface_medium", css: { mt: "$4", "@md": { fontSize: "$sm" } } }, "Please go to dashboard and reconfigure role settings or contact the role admin.")
1033
- )
1034
- )
1035
- );
1036
- });
1037
-
1038
- // src/Prebuilt/components/AppData/useAppLayout.js
1039
- init_define_process_env();
1040
- import { selectAppDataByPath, useHMSStore as useHMSStore8 } from "@100mslive/react-sdk";
1041
- var useAppLayout = (path) => {
1042
- return useHMSStore8(selectAppDataByPath(APP_DATA.appLayout, path));
1043
- };
1044
-
1045
- // src/Prebuilt/layouts/mainGridView.jsx
1046
- var MainGridView = () => {
1047
- var _a;
1048
- const centerRoles = useAppLayout("center") || [];
1049
- const sidepaneRoles = useAppLayout("sidepane") || [];
1050
- const maxTileCount = useUISettings(UI_SETTINGS.maxTileCount);
1051
- const peers = useHMSStore9(selectPeers3);
1052
- const roles = useHMSStore9(selectRolesMap2);
1053
- const localPeerId = useHMSStore9(selectLocalPeerID3);
1054
- const centerPeers = peers.filter((peer) => centerRoles.includes(peer.roleName));
1055
- const sidebarPeers = peers.filter((peer) => sidepaneRoles.includes(peer.roleName));
1056
- const localRole = useHMSStore9(selectLocalPeerRole);
1057
- const peersByRoles = useHMSStore9(selectPeersByRoles(localRole.subscribeParams.subscribeToRoles || []));
1058
- const [placeholder, setPlaceholder] = useState3("");
1059
- useEffect3(() => {
1060
- var _a2;
1061
- const hasPublishingPeers = peers.some((peer) => {
1062
- var _a3;
1063
- if (peer.roleName && roles[peer.roleName]) {
1064
- return !!((_a3 = roles[peer.roleName].publishParams) == null ? void 0 : _a3.allowed.length);
1065
- }
1066
- return true;
1067
- });
1068
- const hasSubscribedRolePublishing = peersByRoles.some((peer) => {
1069
- var _a3;
1070
- if (peer.roleName && roles[peer.roleName]) {
1071
- return !!((_a3 = roles[peer.roleName].publishParams) == null ? void 0 : _a3.allowed.length);
1072
- }
1073
- return true;
1074
- });
1075
- if (!hasPublishingPeers) {
1076
- setPlaceholder("None of the roles can publish video, audio or screen");
1077
- } else if (!((_a2 = localRole.subscribeParams.subscribeToRoles) == null ? void 0 : _a2.length)) {
1078
- setPlaceholder("This role isn't subscribed to any role");
1079
- } else if (!hasSubscribedRolePublishing) {
1080
- setPlaceholder("This role subscribed to roles is not publishing");
1081
- } else {
1082
- setPlaceholder("");
1083
- }
1084
- }, [(_a = localRole.subscribeParams.subscribeToRoles) == null ? void 0 : _a.length, peers, peersByRoles, roles]);
1085
- let showSidePane = centerPeers.length > 0 && sidebarPeers.length > 0;
1086
- if (centerPeers.length === 0) {
1087
- const itsOnlyMeInTheRoom = peers.length === 1 && peers[0].id === localPeerId;
1088
- const nooneIsPublishing = sidebarPeers.length === 0;
1089
- showSidePane = itsOnlyMeInTheRoom || nooneIsPublishing;
1090
- }
1091
- return /* @__PURE__ */ React9.createElement(
1092
- Flex,
1093
- {
1094
- css: {
1095
- size: "100%"
1096
- },
1097
- direction: {
1098
- "@initial": "row",
1099
- "@md": "column"
1100
- }
1101
- },
1102
- placeholder ? /* @__PURE__ */ React9.createElement(NonPublisherView, { message: placeholder }) : /* @__PURE__ */ React9.createElement(React9.Fragment, null, /* @__PURE__ */ React9.createElement(
1103
- GridCenterView,
1104
- {
1105
- peers: showSidePane ? centerPeers : peers,
1106
- maxTileCount,
1107
- allowRemoteMute: false,
1108
- hideSidePane: !showSidePane,
1109
- totalPeers: peers.length
1110
- }
1111
- ), showSidePane && /* @__PURE__ */ React9.createElement(GridSidePaneView, { peers: sidebarPeers, totalPeers: peers.length }))
1112
- );
1113
- };
1114
-
1115
- // src/Prebuilt/layouts/PDFView.jsx
1116
- init_define_process_env();
1117
- import React10, { useCallback as useCallback4, useEffect as useEffect4, useRef as useRef4, useState as useState4 } from "react";
1118
- import { throwErrorHandler as throwErrorHandler2, useScreenShare as useScreenShare2 } from "@100mslive/react-sdk";
1119
- var PDFView = () => {
1120
- return /* @__PURE__ */ React10.createElement(EmbebScreenShareView, null, /* @__PURE__ */ React10.createElement(PDFEmbedComponent, null));
1121
- };
1122
- var PDFEmbedComponent = () => {
1123
- const ref = useRef4();
1124
- const themeType = useTheme().themeType;
1125
- const [isPDFLoaded, setIsPDFLoaded] = useState4(false);
1126
- let pdfJSURL = define_process_env_default.REACT_APP_PDFJS_IFRAME_URL;
1127
- const { amIScreenSharing, toggleScreenShare } = useScreenShare2(throwErrorHandler2);
1128
- const [pdfConfig, setPDFConfig] = useSetAppDataByKey(APP_DATA.pdfConfig);
1129
- if (pdfConfig.url && !pdfConfig.file) {
1130
- pdfJSURL = pdfJSURL + "?file=" + encodeURIComponent(pdfConfig.url);
1131
- }
1132
- const [wasScreenShared, setWasScreenShared] = useState4(false);
1133
- const screenShareAttemptInProgress = useRef4(false);
1134
- const iframeRef = useRef4();
1135
- const resetEmbedConfig = useCallback4(() => {
1136
- setPDFConfig({ state: false });
1137
- }, [setPDFConfig]);
1138
- useEffect4(() => {
1139
- if (isPDFLoaded && ref.current) {
1140
- ref.current.contentWindow.postMessage(
1141
- {
1142
- theme: themeType === ThemeTypes.dark ? 2 : 1
1143
- },
1144
- "*"
1145
- );
1146
- }
1147
- }, [isPDFLoaded, themeType]);
1148
- useEffect4(() => {
1149
- if (!amIScreenSharing && !wasScreenShared && !screenShareAttemptInProgress.current) {
1150
- screenShareAttemptInProgress.current = true;
1151
- toggleScreenShare({
1152
- forceCurrentTab: isChrome,
1153
- cropElement: iframeRef.current,
1154
- preferCurrentTab: isChrome
1155
- }).then(() => {
1156
- setWasScreenShared(true);
1157
- }).catch(resetEmbedConfig).finally(() => {
1158
- screenShareAttemptInProgress.current = false;
1159
- });
1160
- }
1161
- }, []);
1162
- useEffect4(() => {
1163
- if (wasScreenShared && !amIScreenSharing) {
1164
- resetEmbedConfig();
1165
- }
1166
- return () => {
1167
- if (wasScreenShared && amIScreenSharing) {
1168
- resetEmbedConfig();
1169
- toggleScreenShare();
1170
- }
1171
- };
1172
- }, [wasScreenShared, amIScreenSharing, resetEmbedConfig, toggleScreenShare]);
1173
- return /* @__PURE__ */ React10.createElement(
1174
- Box,
1175
- {
1176
- ref: iframeRef,
1177
- css: {
1178
- mx: "$8",
1179
- flex: "3 1 0",
1180
- "@lg": {
1181
- flex: "2 1 0",
1182
- display: "flex",
1183
- alignItems: "center"
1184
- }
1185
- }
1186
- },
1187
- /* @__PURE__ */ React10.createElement(
1188
- "iframe",
1189
- {
1190
- src: pdfJSURL,
1191
- title: "PDF Annotator",
1192
- ref,
1193
- style: {
1194
- width: "100%",
1195
- height: "100%",
1196
- border: 0,
1197
- borderRadius: "0.75rem"
1198
- },
1199
- allow: "accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture fullscreen",
1200
- referrerPolicy: "no-referrer",
1201
- onLoad: () => {
1202
- if (ref.current && pdfConfig.file) {
1203
- requestAnimationFrame(() => {
1204
- ref.current.contentWindow.postMessage(
1205
- {
1206
- file: pdfConfig.file,
1207
- theme: themeType === ThemeTypes.dark ? 2 : 1
1208
- },
1209
- "*"
1210
- );
1211
- setIsPDFLoaded(true);
1212
- }, 1e3);
1213
- }
1214
- }
1215
- }
1216
- )
1217
- );
1218
- };
1219
-
1220
- // src/Prebuilt/layouts/WaitingView.jsx
1221
- init_define_process_env();
1222
- import React11 from "react";
1223
- import { ColoredTimeIcon } from "@100mslive/react-icons";
1224
- var WaitingView = React11.memo(() => {
1225
- return /* @__PURE__ */ React11.createElement(
1226
- Box,
1227
- {
1228
- css: {
1229
- overflow: "hidden",
1230
- w: "96%",
1231
- maxWidth: "96%",
1232
- h: "100%",
1233
- m: "auto",
1234
- background: "$surface_default",
1235
- borderRadius: "$3"
1236
- },
1237
- "data-testid": "waiting_view"
1238
- },
1239
- /* @__PURE__ */ React11.createElement(
1240
- Flex,
1241
- {
1242
- align: "center",
1243
- direction: "column",
1244
- css: {
1245
- w: "$96",
1246
- textAlign: "center",
1247
- margin: "auto",
1248
- h: "100%",
1249
- justifyContent: "center",
1250
- gap: "$8"
1251
- }
1252
- },
1253
- /* @__PURE__ */ React11.createElement(ColoredTimeIcon, { width: "80px", height: "80px" }),
1254
- /* @__PURE__ */ React11.createElement(
1255
- Flex,
1256
- {
1257
- direction: "column",
1258
- css: {
1259
- w: "$80",
1260
- p: "$1",
1261
- gap: "$4"
1262
- }
1263
- },
1264
- /* @__PURE__ */ React11.createElement(Text, { color: "white", variant: "h6", css: { "@md": { fontSize: "$md" } } }, "Please wait"),
1265
- /* @__PURE__ */ React11.createElement(Text, { color: "$on_surface_medium", css: { mt: "$4", "@md": { fontSize: "$sm" } } }, "Sit back and relax till others let you join.")
1266
- )
1267
- )
1268
- );
1269
- });
1270
-
1271
- // src/Prebuilt/plugins/whiteboard/index.js
1272
- init_define_process_env();
1273
-
1274
- // src/Prebuilt/layouts/mainView.jsx
1275
- var HLSView = React12.lazy(() => import("./HLSView-F2K5VSTS.js"));
1276
- var ActiveSpeakerView = React12.lazy(() => import("./ActiveSpeakerView-V6O4K3BV.js"));
1277
- var PinnedTrackView = React12.lazy(() => import("./PinnedTrackView-7YQG4QKC.js"));
1278
- var ConferenceMainView = () => {
1279
- var _a, _b, _c;
1280
- const localPeerRole = useHMSStore10(selectLocalPeerRoleName3);
1281
- const pinnedTrack = usePinnedTrack();
1282
- const peerSharing = useHMSStore10(selectPeerScreenSharing3);
1283
- const peerSharingAudio = useHMSStore10(selectPeerSharingAudio);
1284
- const peerSharingPlaylist = useHMSStore10(selectPeerSharingVideoPlaylist3);
1285
- const { whiteboardOwner: whiteboardShared } = useWhiteboardMetadata();
1286
- const isConnected = useHMSStore10(selectIsConnectedToRoom);
1287
- const uiMode = useHMSStore10(selectTemplateAppData).uiMode;
1288
- const hmsActions = useHMSActions6();
1289
- const isHeadless = useIsHeadless();
1290
- const headlessUIMode = useAppConfig("headlessConfig", "uiMode");
1291
- const { uiViewMode, isAudioOnly } = useUISettings();
1292
- const hlsViewerRole = useHLSViewerRole();
1293
- const waitingViewerRole = useWaitingViewerRole();
1294
- const urlToIframe = useUrlToEmbed();
1295
- const pdfAnnotatorActive = usePDFAnnotator();
1296
- const { isHLSRunning } = useRecordingStreaming();
1297
- const [isHLSStarted, setHLSStarted] = useSetAppDataByKey(APP_DATA.hlsStarted);
1298
- const permissions = useHMSStore10(selectPermissions);
1299
- const roomLayout = useRoomLayout();
1300
- const { join_form: joinForm = {} } = ((_c = (_b = (_a = roomLayout == null ? void 0 : roomLayout.screens) == null ? void 0 : _a.preview) == null ? void 0 : _b.default) == null ? void 0 : _c.elements) || {};
1301
- const startHLS = useCallback5(() => __async(void 0, null, function* () {
1302
- try {
1303
- if (isHLSStarted) {
1304
- return;
1305
- }
1306
- setHLSStarted(true);
1307
- yield hmsActions.startHLSStreaming({});
1308
- } catch (error) {
1309
- if (error.message.includes("invalid input")) {
1310
- yield startHLS();
1311
- return;
1312
- }
1313
- setHLSStarted(false);
1314
- }
1315
- }), [hmsActions, isHLSStarted, setHLSStarted]);
1316
- useEffect5(() => {
1317
- if (!isConnected) {
1318
- return;
1319
- }
1320
- const audioPlaylist = JSON.parse(define_process_env_default.REACT_APP_AUDIO_PLAYLIST || "[]");
1321
- const videoPlaylist = JSON.parse(define_process_env_default.REACT_APP_VIDEO_PLAYLIST || "[]");
1322
- if (videoPlaylist.length > 0) {
1323
- hmsActions.videoPlaylist.setList(videoPlaylist);
1324
- }
1325
- if (audioPlaylist.length > 0) {
1326
- hmsActions.audioPlaylist.setList(audioPlaylist);
1327
- }
1328
- if ((permissions == null ? void 0 : permissions.hlsStreaming) && !isHLSRunning && joinForm.join_btn_type === JoinForm_JoinBtnType.JOIN_BTN_TYPE_JOIN_AND_GO_LIVE) {
1329
- startHLS();
1330
- }
1331
- hmsActions.sessionStore.observe([SESSION_STORE_KEY.PINNED_MESSAGE, SESSION_STORE_KEY.SPOTLIGHT]);
1332
- }, [isConnected, hmsActions, permissions, joinForm]);
1333
- if (!localPeerRole) {
1334
- return null;
1335
- }
1336
- let ViewComponent;
1337
- if (localPeerRole === hlsViewerRole) {
1338
- ViewComponent = HLSView;
1339
- } else if (localPeerRole === waitingViewerRole) {
1340
- ViewComponent = WaitingView;
1341
- } else if (pdfAnnotatorActive) {
1342
- ViewComponent = PDFView;
1343
- } else if (urlToIframe) {
1344
- ViewComponent = EmbedView;
1345
- } else if (whiteboardShared) {
1346
- } else if (uiMode === "inset") {
1347
- ViewComponent = InsetView;
1348
- } else if ((peerSharing && peerSharing.id !== (peerSharingAudio == null ? void 0 : peerSharingAudio.id) || peerSharingPlaylist) && !isAudioOnly) {
1349
- ViewComponent = screenShareView_default;
1350
- } else if (pinnedTrack) {
1351
- ViewComponent = PinnedTrackView;
1352
- } else if (uiViewMode === UI_MODE_ACTIVE_SPEAKER || isHeadless && headlessUIMode === UI_MODE_ACTIVE_SPEAKER) {
1353
- ViewComponent = ActiveSpeakerView;
1354
- } else {
1355
- ViewComponent = MainGridView;
1356
- }
1357
- return /* @__PURE__ */ React12.createElement(Suspense, { fallback: /* @__PURE__ */ React12.createElement(FullPageProgress_default, null) }, /* @__PURE__ */ React12.createElement(
1358
- Flex,
1359
- {
1360
- css: {
1361
- size: "100%",
1362
- position: "relative"
1363
- }
1364
- },
1365
- /* @__PURE__ */ React12.createElement(ViewComponent, null),
1366
- /* @__PURE__ */ React12.createElement(SidePane_default, null)
1367
- ));
1368
- };
1369
-
1370
- // src/Prebuilt/components/Footer.jsx
1371
- init_define_process_env();
1372
- import React36 from "react";
1373
-
1374
- // src/Prebuilt/components/Footer/ConferencingFooter.jsx
1375
- init_define_process_env();
1376
- import React34, { Fragment as Fragment6, Suspense as Suspense2, useState as useState16 } from "react";
1377
- import { useMedia as useMedia6 } from "react-use";
1378
- import { selectIsAllowedToPublish as selectIsAllowedToPublish3, useHMSStore as useHMSStore19, useScreenShare as useScreenShare5 } from "@100mslive/react-sdk";
1379
- import { MusicIcon } from "@100mslive/react-icons";
1380
-
1381
- // src/Prebuilt/components/MoreSettings/MoreSettings.jsx
1382
- init_define_process_env();
1383
- import React21, { Fragment as Fragment3, useState as useState12 } from "react";
1384
- import { useMedia as useMedia5 } from "react-use";
1385
- import Hls from "hls.js";
1386
- import {
1387
- selectAppData as selectAppData2,
1388
- selectIsAllowedToPublish,
1389
- selectLocalPeerID as selectLocalPeerID6,
1390
- selectLocalPeerRoleName as selectLocalPeerRoleName5,
1391
- selectPermissions as selectPermissions4,
1392
- useHMSActions as useHMSActions12,
1393
- useHMSStore as useHMSStore15,
1394
- useRecordingStreaming as useRecordingStreaming3
1395
- } from "@100mslive/react-sdk";
1396
- import {
1397
- ChangeRoleIcon as ChangeRoleIcon2,
1398
- CheckIcon as CheckIcon3,
1399
- InfoIcon,
1400
- MicOffIcon as MicOffIcon2,
1401
- PencilIcon,
1402
- RecordIcon,
1403
- SettingsIcon,
1404
- VerticalMenuIcon
1405
- } from "@100mslive/react-icons";
1406
-
1407
- // src/Prebuilt/components/Settings/StartRecording.jsx
1408
- init_define_process_env();
1409
- import React13, { useState as useState5 } from "react";
1410
- import { selectPermissions as selectPermissions2, useHMSActions as useHMSActions7, useHMSStore as useHMSStore11, useRecordingStreaming as useRecordingStreaming2 } from "@100mslive/react-sdk";
1411
- import { AlertTriangleIcon } from "@100mslive/react-icons";
1412
- var StartRecording = ({ open, onOpenChange }) => {
1413
- const permissions = useHMSStore11(selectPermissions2);
1414
- const [resolution, setResolution] = useState5(RTMP_RECORD_DEFAULT_RESOLUTION);
1415
- const [recordingStarted, setRecordingState] = useSetAppDataByKey(APP_DATA.recordingStarted);
1416
- const { isBrowserRecordingOn, isStreamingOn, isHLSRunning } = useRecordingStreaming2();
1417
- const hmsActions = useHMSActions7();
1418
- if (!(permissions == null ? void 0 : permissions.browserRecording) || isHLSRunning) {
1419
- return null;
1420
- }
1421
- if (isBrowserRecordingOn) {
1422
- return /* @__PURE__ */ React13.createElement(Dialog.Root, { open, onOpenChange }, /* @__PURE__ */ React13.createElement(Dialog.Portal, null, /* @__PURE__ */ React13.createElement(
1423
- Dialog.Content,
1424
- {
1425
- css: {
1426
- width: "min(400px,80%)",
1427
- p: "$10",
1428
- bg: "#201617"
1429
- }
1430
- },
1431
- /* @__PURE__ */ React13.createElement(Dialog.Title, null, /* @__PURE__ */ React13.createElement(Flex, { gap: 2, css: { c: "$alert_error_default" } }, /* @__PURE__ */ React13.createElement(AlertTriangleIcon, null), /* @__PURE__ */ React13.createElement(Text, { css: { c: "inherit" }, variant: "h6" }, "End Recording"))),
1432
- /* @__PURE__ */ React13.createElement(Text, { variant: "sm", css: { c: "$on_surface_medium", my: "$8" } }, "Are you sure you want to end recording? You can\u2019t undo this action."),
1433
- /* @__PURE__ */ React13.createElement(Flex, { justify: "end", css: { mt: "$12" } }, /* @__PURE__ */ React13.createElement(Dialog.Close, { asChild: true }, /* @__PURE__ */ React13.createElement(Button, { outlined: true, css: { borderColor: "$secondary_bright", mr: "$4" } }, "Don't end")), /* @__PURE__ */ React13.createElement(
1434
- Button,
1435
- {
1436
- "data-testid": "stop_recording_confirm_mobile",
1437
- variant: "danger",
1438
- icon: true,
1439
- onClick: () => __async(void 0, null, function* () {
1440
- try {
1441
- yield hmsActions.stopRTMPAndRecording();
1442
- } catch (error) {
1443
- ToastManager.addToast({
1444
- title: error.message,
1445
- variant: "error"
1446
- });
1447
- }
1448
- onOpenChange(false);
1449
- })
1450
- },
1451
- "End recording"
1452
- ))
1453
- )));
1454
- }
1455
- return /* @__PURE__ */ React13.createElement(Dialog.Root, { open, onOpenChange }, /* @__PURE__ */ React13.createElement(Dialog.Content, { css: { width: "min(400px,80%)", p: "$10" } }, /* @__PURE__ */ React13.createElement(Dialog.Title, null, /* @__PURE__ */ React13.createElement(Text, { variant: "h6" }, "Start Recording")), /* @__PURE__ */ React13.createElement(
1456
- ResolutionInput,
1457
- {
1458
- testId: "recording_resolution_mobile",
1459
- css: { flexDirection: "column", alignItems: "start" },
1460
- onResolutionChange: setResolution
1461
- }
1462
- ), /* @__PURE__ */ React13.createElement(
1463
- Button,
1464
- {
1465
- "data-testid": "start_recording_confirm_mobile",
1466
- variant: "primary",
1467
- icon: true,
1468
- css: { ml: "auto" },
1469
- type: "submit",
1470
- disabled: recordingStarted || isStreamingOn,
1471
- onClick: () => __async(void 0, null, function* () {
1472
- try {
1473
- setRecordingState(true);
1474
- yield hmsActions.startRTMPOrRecording({
1475
- resolution: getResolution(resolution),
1476
- record: true
1477
- });
1478
- } catch (error) {
1479
- if (error.message.includes("stream already running")) {
1480
- ToastManager.addToast({
1481
- title: "Recording already running",
1482
- variant: "error"
1483
- });
1484
- } else {
1485
- ToastManager.addToast({
1486
- title: error.message,
1487
- variant: "error"
1488
- });
1489
- }
1490
- setRecordingState(false);
1491
- }
1492
- onOpenChange(false);
1493
- })
1494
- },
1495
- "Start"
1496
- )));
1497
- };
1498
- var StartRecording_default = StartRecording;
1499
-
1500
- // src/Prebuilt/components/StatsForNerds.jsx
1501
- init_define_process_env();
1502
- import React14, { useEffect as useEffect6, useMemo as useMemo3, useRef as useRef5, useState as useState6 } from "react";
1503
- import {
1504
- selectHMSStats,
1505
- selectLocalPeerID as selectLocalPeerID4,
1506
- selectPeersMap,
1507
- selectTracksMap,
1508
- useHMSStatsStore,
1509
- useHMSStore as useHMSStore12
1510
- } from "@100mslive/react-sdk";
1511
- var StatsForNerds = ({ onOpenChange }) => {
1512
- var _a;
1513
- const tracksWithLabels = useTracksWithLabel();
1514
- const statsOptions = useMemo3(
1515
- () => [{ id: "local-peer", label: "Local Peer Stats" }, ...tracksWithLabels],
1516
- [tracksWithLabels]
1517
- );
1518
- const [selectedStat, setSelectedStat] = useState6(statsOptions[0]);
1519
- const [showStatsOnTiles, setShowStatsOnTiles] = useSetUiSettings(UI_SETTINGS.showStatsOnTiles);
1520
- const [open, setOpen] = useState6(false);
1521
- const ref = useRef5();
1522
- const selectionBg = useDropdownSelection();
1523
- useEffect6(() => {
1524
- if (selectedStat.id !== "local-peer" && !tracksWithLabels.find((track) => track.id === selectedStat.id)) {
1525
- setSelectedStat("local-peer");
1526
- }
1527
- }, [tracksWithLabels, selectedStat]);
1528
- return /* @__PURE__ */ React14.createElement(Dialog.Root, { defaultOpen: true, onOpenChange }, /* @__PURE__ */ React14.createElement(Dialog.Portal, null, /* @__PURE__ */ React14.createElement(Dialog.Overlay, null), /* @__PURE__ */ React14.createElement(
1529
- Dialog.Content,
1530
- {
1531
- css: {
1532
- width: "min(500px, 95%)",
1533
- maxHeight: "100%",
1534
- overflowY: "auto"
1535
- }
1536
- },
1537
- /* @__PURE__ */ React14.createElement(Dialog.Title, { css: { p: "$4 0" } }, /* @__PURE__ */ React14.createElement(Flex, { justify: "between" }, /* @__PURE__ */ React14.createElement(Flex, { align: "center", css: { mb: "$1" } }, /* @__PURE__ */ React14.createElement(Text, { variant: "h6", inline: true }, "Stats For Nerds")), /* @__PURE__ */ React14.createElement(Dialog.DefaultClose, { "data-testid": "stats_dialog_close_icon" }))),
1538
- /* @__PURE__ */ React14.createElement(HorizontalDivider, { css: { mt: "0.8rem" } }),
1539
- /* @__PURE__ */ React14.createElement(Flex, { justify: "start", gap: 4, css: { m: "$10 0" } }, /* @__PURE__ */ React14.createElement(Switch, { checked: showStatsOnTiles, onCheckedChange: setShowStatsOnTiles }), /* @__PURE__ */ React14.createElement(Text, { variant: "body2", css: { fontWeight: "$semiBold" } }, "Show Stats on Tiles")),
1540
- /* @__PURE__ */ React14.createElement(
1541
- Flex,
1542
- {
1543
- direction: "column",
1544
- css: {
1545
- mb: "$12",
1546
- position: "relative",
1547
- minWidth: 0
1548
- }
1549
- },
1550
- /* @__PURE__ */ React14.createElement(Label, { variant: "body2" }, "Stats For"),
1551
- /* @__PURE__ */ React14.createElement(Dropdown.Root, { "data-testid": "dialog_select_Stats For", open, onOpenChange: setOpen }, /* @__PURE__ */ React14.createElement(
1552
- DialogDropdownTrigger,
1553
- {
1554
- title: selectedStat.label || "Select Stats",
1555
- css: { mt: "$4" },
1556
- titleCSS: { mx: 0 },
1557
- open,
1558
- ref
1559
- }
1560
- ), /* @__PURE__ */ React14.createElement(Dropdown.Portal, null, /* @__PURE__ */ React14.createElement(Dropdown.Content, { align: "start", sideOffset: 8, css: { w: (_a = ref.current) == null ? void 0 : _a.clientWidth, zIndex: 1e3 } }, statsOptions.map((option) => {
1561
- const isSelected = option.id === selectedStat.id && option.layer === selectedStat.layer;
1562
- return /* @__PURE__ */ React14.createElement(
1563
- Dropdown.Item,
1564
- {
1565
- key: `${option.id}-${option.layer || ""}`,
1566
- onClick: () => {
1567
- setSelectedStat(option);
1568
- },
1569
- css: {
1570
- px: "$9",
1571
- bg: isSelected ? selectionBg : void 0,
1572
- c: isSelected ? "$on_primary_high" : "$on_primary_high"
1573
- }
1574
- },
1575
- option.label
1576
- );
1577
- }))))
1578
- ),
1579
- selectedStat.id === "local-peer" ? /* @__PURE__ */ React14.createElement(LocalPeerStats, null) : /* @__PURE__ */ React14.createElement(TrackStats, { trackID: selectedStat.id, layer: selectedStat.layer, local: selectedStat.local })
1580
- )));
1581
- };
1582
- var useTracksWithLabel = () => {
1583
- const tracksMap = useHMSStore12(selectTracksMap);
1584
- const peersMap = useHMSStore12(selectPeersMap);
1585
- const localPeerID = useHMSStore12(selectLocalPeerID4);
1586
- const tracksWithLabels = useMemo3(
1587
- () => Object.values(tracksMap).reduce((res, track) => {
1588
- var _a, _b;
1589
- const peerName = (_a = peersMap[track.peerId]) == null ? void 0 : _a.name;
1590
- const isLocalTrack = track.peerId === localPeerID;
1591
- if (isLocalTrack && ((_b = track.layerDefinitions) == null ? void 0 : _b.length)) {
1592
- res = res.concat(
1593
- track.layerDefinitions.map(({ layer }) => {
1594
- return {
1595
- id: track.id,
1596
- layer,
1597
- local: true,
1598
- label: `${peerName} ${track.source} ${track.type} - ${layer}`
1599
- };
1600
- })
1601
- );
1602
- return res;
1603
- }
1604
- res.push({
1605
- id: track.id,
1606
- local: isLocalTrack,
1607
- label: `${peerName} ${track.source} ${track.type}`
1608
- });
1609
- return res;
1610
- }, []),
1611
- [tracksMap, peersMap, localPeerID]
1612
- );
1613
- return tracksWithLabels;
1614
- };
1615
- var LocalPeerStats = () => {
1616
- var _a, _b, _c, _d, _e, _f, _g, _h, _i;
1617
- const stats = useHMSStatsStore(selectHMSStats.localPeerStats);
1618
- if (!stats) {
1619
- return null;
1620
- }
1621
- return /* @__PURE__ */ React14.createElement(Flex, { css: { flexWrap: "wrap", gap: "$10" } }, /* @__PURE__ */ React14.createElement(StatsRow, { label: "Packets Lost", value: (_a = stats.subscribe) == null ? void 0 : _a.packetsLost }), /* @__PURE__ */ React14.createElement(StatsRow, { label: "Jitter", value: (_b = stats.subscribe) == null ? void 0 : _b.jitter }), /* @__PURE__ */ React14.createElement(StatsRow, { label: "Publish Bitrate", value: formatBytes((_c = stats.publish) == null ? void 0 : _c.bitrate, "b/s") }), /* @__PURE__ */ React14.createElement(StatsRow, { label: "Subscribe Bitrate", value: formatBytes((_d = stats.subscribe) == null ? void 0 : _d.bitrate, "b/s") }), /* @__PURE__ */ React14.createElement(
1622
- StatsRow,
1623
- {
1624
- label: "Available Outgoing Bitrate",
1625
- value: formatBytes((_e = stats.publish) == null ? void 0 : _e.availableOutgoingBitrate, "b/s")
1626
- }
1627
- ), /* @__PURE__ */ React14.createElement(StatsRow, { label: "Total Bytes Sent", value: formatBytes((_f = stats.publish) == null ? void 0 : _f.bytesSent) }), /* @__PURE__ */ React14.createElement(StatsRow, { label: "Total Bytes Received", value: formatBytes((_g = stats.subscribe) == null ? void 0 : _g.bytesReceived) }), /* @__PURE__ */ React14.createElement(
1628
- StatsRow,
1629
- {
1630
- label: "Round Trip Time",
1631
- value: `${(((((_h = stats.publish) == null ? void 0 : _h.currentRoundTripTime) || 0) + (((_i = stats.subscribe) == null ? void 0 : _i.currentRoundTripTime) || 0)) / 2).toFixed(3) * 1e3} ms`
1632
- }
1633
- ));
1634
- };
1635
- var TrackStats = ({ trackID, layer, local }) => {
1636
- var _a;
1637
- const selector = layer ? selectHMSStats.localVideoTrackStatsByLayer(layer)(trackID) : local ? selectHMSStats.localAudioTrackStatsByID(trackID) : selectHMSStats.trackStatsByID(trackID);
1638
- const stats = useHMSStatsStore(selector);
1639
- if (!stats) {
1640
- return null;
1641
- }
1642
- const inbound = stats.type.includes("inbound");
1643
- return /* @__PURE__ */ React14.createElement(Flex, { css: { flexWrap: "wrap", gap: "$10" } }, /* @__PURE__ */ React14.createElement(StatsRow, { label: "Type", value: stats.type + " " + stats.kind }), /* @__PURE__ */ React14.createElement(StatsRow, { label: "Bitrate", value: formatBytes(stats.bitrate, "b/s") }), /* @__PURE__ */ React14.createElement(StatsRow, { label: "Packets Lost", value: stats.packetsLost }), /* @__PURE__ */ React14.createElement(StatsRow, { label: "Jitter", value: (_a = stats.jitter) == null ? void 0 : _a.toFixed(3) }), /* @__PURE__ */ React14.createElement(
1644
- StatsRow,
1645
- {
1646
- label: inbound ? "Bytes Received" : "Bytes Sent",
1647
- value: formatBytes(inbound ? stats.bytesReceived : stats.bytesSent)
1648
- }
1649
- ), stats.kind === "video" && /* @__PURE__ */ React14.createElement(React14.Fragment, null, /* @__PURE__ */ React14.createElement(StatsRow, { label: "Framerate", value: stats.framesPerSecond }), !inbound && /* @__PURE__ */ React14.createElement(StatsRow, { label: "Quality Limitation Reason", value: stats.qualityLimitationReason })), /* @__PURE__ */ React14.createElement(StatsRow, { label: "Round Trip Time", value: stats.roundTripTime ? `${stats.roundTripTime * 1e3} ms` : "-" }));
1650
- };
1651
- var StatsRow = React14.memo(({ label, value }) => /* @__PURE__ */ React14.createElement(Box, { css: { bg: "$surface_bright", w: "calc(50% - $6)", p: "$8", r: "$3" } }, /* @__PURE__ */ React14.createElement(
1652
- Text,
1653
- {
1654
- variant: "overline",
1655
- css: {
1656
- fontWeight: "$semiBold",
1657
- color: "$on_surface_medium",
1658
- textTransform: "uppercase"
1659
- }
1660
- },
1661
- label
1662
- ), /* @__PURE__ */ React14.createElement(Text, { variant: "sub1", css: { fontWeight: "$semiBold", color: "$on_surface_high" } }, value || "-")));
1663
- var formatBytes = (bytes, unit = "B", decimals = 2) => {
1664
- if (bytes === void 0)
1665
- return "-";
1666
- if (bytes === 0)
1667
- return "0 " + unit;
1668
- const k = 1024;
1669
- const dm = decimals < 0 ? 0 : decimals;
1670
- const sizes = ["", "K", "M", "G", "T", "P", "E", "Z", "Y"].map((size) => size + unit);
1671
- const i = Math.floor(Math.log(bytes) / Math.log(k));
1672
- return parseFloat((bytes / Math.pow(k, i)).toFixed(dm)) + " " + sizes[i];
1673
- };
1674
-
1675
- // src/Prebuilt/components/MoreSettings/BulkRoleChangeModal.jsx
1676
- init_define_process_env();
1677
- import React15, { useCallback as useCallback6, useRef as useRef6, useState as useState7 } from "react";
1678
- import { useHMSActions as useHMSActions8 } from "@100mslive/react-sdk";
1679
- import { AlertTriangleIcon as AlertTriangleIcon2, ChangeRoleIcon, CheckIcon } from "@100mslive/react-icons";
1680
- var BulkRoleChangeModal = ({ onOpenChange }) => {
1681
- var _a, _b;
1682
- const roles = useFilteredRoles();
1683
- const hmsActions = useHMSActions8();
1684
- const ref = useRef6(null);
1685
- const roleRef = useRef6(null);
1686
- const [selectedBulkRole, setBulkRole] = useState7([]);
1687
- const [selectedRole, setRole] = useState7("");
1688
- const [bulkRoleDialog, setBulkRoleDialog] = useState7(false);
1689
- const [roleDialog, setRoleDialog] = useState7(false);
1690
- const [errorMessage, setErrorMessage] = useState7("");
1691
- const [isSubmiting, setIsSubmiting] = useState7(false);
1692
- const changeBulkRole = useCallback6(() => __async(void 0, null, function* () {
1693
- if (selectedBulkRole.length > 0 && selectedRole) {
1694
- try {
1695
- setIsSubmiting(true);
1696
- yield hmsActions.changeRoleOfPeersWithRoles(selectedBulkRole, selectedRole);
1697
- setIsSubmiting(false);
1698
- setErrorMessage("");
1699
- onOpenChange(false);
1700
- } catch (err) {
1701
- setErrorMessage((err == null ? void 0 : err.message) ? err == null ? void 0 : err.message : "Unknown error");
1702
- setIsSubmiting(false);
1703
- }
1704
- }
1705
- }), [selectedBulkRole, selectedRole, hmsActions, onOpenChange]);
1706
- return /* @__PURE__ */ React15.createElement(Dialog.Root, { defaultOpen: true, onOpenChange }, /* @__PURE__ */ React15.createElement(DialogContent, { title: "Bulk Role Change", Icon: ChangeRoleIcon }, /* @__PURE__ */ React15.createElement(DialogRow, null, /* @__PURE__ */ React15.createElement(Text, null, "For Roles: "), /* @__PURE__ */ React15.createElement(
1707
- Dropdown.Root,
1708
- {
1709
- open: bulkRoleDialog,
1710
- onOpenChange: (value) => {
1711
- if (value) {
1712
- setBulkRoleDialog(value);
1713
- }
1714
- },
1715
- modal: false
1716
- },
1717
- /* @__PURE__ */ React15.createElement(
1718
- DialogDropdownTrigger,
1719
- {
1720
- ref,
1721
- title: selectedBulkRole.length === 0 ? "Select Multiple Roles" : selectedBulkRole.toString(),
1722
- css: {
1723
- w: "70%",
1724
- p: "$8"
1725
- },
1726
- open: bulkRoleDialog
1727
- }
1728
- ),
1729
- /* @__PURE__ */ React15.createElement(
1730
- Dropdown.Content,
1731
- {
1732
- css: { w: (_a = ref.current) == null ? void 0 : _a.clientWidth, zIndex: 1e3 },
1733
- onInteractOutside: () => {
1734
- if (bulkRoleDialog) {
1735
- setBulkRoleDialog(false);
1736
- }
1737
- }
1738
- },
1739
- roles && roles.map((role) => {
1740
- return /* @__PURE__ */ React15.createElement(
1741
- Dropdown.CheckboxItem,
1742
- {
1743
- key: role,
1744
- checked: selectedBulkRole.includes(role),
1745
- onCheckedChange: (value) => {
1746
- setBulkRole((selection) => {
1747
- return value ? [...selection, role] : selection.filter((selectedRole2) => selectedRole2 !== role);
1748
- });
1749
- setErrorMessage("");
1750
- }
1751
- },
1752
- /* @__PURE__ */ React15.createElement(Checkbox.Root, { css: { margin: "$2" }, checked: selectedBulkRole.includes(role) }, /* @__PURE__ */ React15.createElement(Checkbox.Indicator, null, /* @__PURE__ */ React15.createElement(CheckIcon, { width: 16, height: 16 }))),
1753
- role
1754
- );
1755
- })
1756
- )
1757
- )), /* @__PURE__ */ React15.createElement(DialogRow, null, /* @__PURE__ */ React15.createElement(Text, null, "To Role: "), /* @__PURE__ */ React15.createElement(Dropdown.Root, { open: roleDialog, onOpenChange: (value) => setRoleDialog(value) }, /* @__PURE__ */ React15.createElement(
1758
- DialogDropdownTrigger,
1759
- {
1760
- ref: roleRef,
1761
- title: selectedRole || "Select Role",
1762
- css: {
1763
- w: "70%",
1764
- p: "$8"
1765
- },
1766
- open: roleDialog
1767
- }
1768
- ), /* @__PURE__ */ React15.createElement(Dropdown.Content, { css: { w: (_b = roleRef.current) == null ? void 0 : _b.clientWidth, zIndex: 1e3 } }, roles && roles.map((role) => {
1769
- return /* @__PURE__ */ React15.createElement(
1770
- Dropdown.Item,
1771
- {
1772
- key: role,
1773
- onSelect: () => {
1774
- setRole(role);
1775
- setErrorMessage("");
1776
- }
1777
- },
1778
- role
1779
- );
1780
- })))), /* @__PURE__ */ React15.createElement(DialogRow, null, errorMessage && /* @__PURE__ */ React15.createElement(Flex, { gap: 2, css: { c: "$alert_error_default", w: "70%", ml: "auto" } }, /* @__PURE__ */ React15.createElement(AlertTriangleIcon2, null), /* @__PURE__ */ React15.createElement(Text, { css: { c: "inherit" } }, errorMessage))), /* @__PURE__ */ React15.createElement(DialogRow, { justify: "end" }, /* @__PURE__ */ React15.createElement(Button, { variant: "primary", onClick: changeBulkRole, disabled: !(selectedRole && selectedBulkRole.length > 0) }, isSubmiting && /* @__PURE__ */ React15.createElement(Loading, { css: { color: "$on_primary_medium" } }), "Apply"))));
1781
- };
1782
-
1783
- // src/Prebuilt/components/MoreSettings/ChangeNameModal.jsx
1784
- init_define_process_env();
1785
- import React16, { useState as useState8 } from "react";
1786
- import { selectLocalPeerName, useHMSActions as useHMSActions9, useHMSStore as useHMSStore13 } from "@100mslive/react-sdk";
1787
- var ChangeNameModal = ({ onOpenChange }) => {
1788
- const [previewPreference, setPreviewPreference] = useUserPreferences(UserPreferencesKeys.PREVIEW);
1789
- const hmsActions = useHMSActions9();
1790
- const localPeerName = useHMSStore13(selectLocalPeerName);
1791
- const [currentName, setCurrentName] = useState8(localPeerName);
1792
- const changeName = () => __async(void 0, null, function* () {
1793
- const name = currentName.trim();
1794
- if (!name || name === localPeerName) {
1795
- return;
1796
- }
1797
- try {
1798
- yield hmsActions.changeName(name);
1799
- setPreviewPreference(__spreadProps(__spreadValues({}, previewPreference || {}), {
1800
- name
1801
- }));
1802
- } catch (error) {
1803
- console.error("failed to update name", error);
1804
- ToastManager.addToast({ title: error.message });
1805
- } finally {
1806
- onOpenChange(false);
1807
- }
1808
- });
1809
- return /* @__PURE__ */ React16.createElement(Dialog.Root, { defaultOpen: true, onOpenChange }, /* @__PURE__ */ React16.createElement(Dialog.Portal, null, /* @__PURE__ */ React16.createElement(Dialog.Overlay, null), /* @__PURE__ */ React16.createElement(Dialog.Content, { css: { width: "min(400px,80%)", p: "$10" } }, /* @__PURE__ */ React16.createElement(Dialog.Title, { css: { p: "0 $4" } }, /* @__PURE__ */ React16.createElement(Text, { variant: "h6" }, " Change Name")), /* @__PURE__ */ React16.createElement(
1810
- "form",
1811
- {
1812
- onSubmit: (e) => __async(void 0, null, function* () {
1813
- e.preventDefault();
1814
- yield changeName();
1815
- })
1816
- },
1817
- /* @__PURE__ */ React16.createElement(Flex, { justify: "center", align: "center", css: { my: "$8", w: "100%" } }, /* @__PURE__ */ React16.createElement(
1818
- Input,
1819
- {
1820
- css: { width: "100%" },
1821
- value: currentName,
1822
- onChange: (e) => {
1823
- setCurrentName(e.target.value);
1824
- },
1825
- autoComplete: "name",
1826
- required: true,
1827
- "data-testid": "change_name_field"
1828
- }
1829
- )),
1830
- /* @__PURE__ */ React16.createElement(
1831
- Flex,
1832
- {
1833
- justify: "between",
1834
- align: "center",
1835
- css: {
1836
- width: "100%",
1837
- gap: "$md",
1838
- mt: "$10"
1839
- }
1840
- },
1841
- /* @__PURE__ */ React16.createElement(Box, { css: { w: "50%" } }, /* @__PURE__ */ React16.createElement(Dialog.Close, { css: { w: "100%" } }, /* @__PURE__ */ React16.createElement(Button, { variant: "standard", css: { w: "100%" }, outlined: true, type: "submit", disabled: !localPeerName }, "Cancel"))),
1842
- /* @__PURE__ */ React16.createElement(Box, { css: { w: "50%" } }, /* @__PURE__ */ React16.createElement(
1843
- Button,
1844
- {
1845
- variant: "primary",
1846
- css: { width: "100%" },
1847
- type: "submit",
1848
- disabled: !currentName.trim() || currentName.trim() === localPeerName,
1849
- "data-testid": "popup_change_btn"
1850
- },
1851
- "Change"
1852
- ))
1853
- )
1854
- ))));
1855
- };
1856
-
1857
- // src/Prebuilt/components/MoreSettings/ChangeSelfRole.jsx
1858
- init_define_process_env();
1859
- import React17, { useMemo as useMemo4 } from "react";
1860
- import { useMedia as useMedia4 } from "react-use";
1861
- import {
1862
- selectLocalPeerID as selectLocalPeerID5,
1863
- selectLocalPeerRoleName as selectLocalPeerRoleName4,
1864
- selectPermissions as selectPermissions3,
1865
- useHMSActions as useHMSActions10,
1866
- useHMSStore as useHMSStore14
1867
- } from "@100mslive/react-sdk";
1868
- import { ArrowRightIcon, CheckIcon as CheckIcon2, PersonIcon } from "@100mslive/react-icons";
1869
- var ChangeSelfRole = ({ onClick }) => {
1870
- const roles = useFilteredRoles();
1871
- const permissions = useHMSStore14(selectPermissions3);
1872
- const localPeerId = useHMSStore14(selectLocalPeerID5);
1873
- const localPeerRole = useHMSStore14(selectLocalPeerRoleName4);
1874
- const hmsActions = useHMSActions10();
1875
- const hideTriggerItem = useMedia4(config.media.sm);
1876
- const selfRoleChangeTo = useAppLayout("selfRoleChangeTo");
1877
- const availableSelfChangeRoles = useMemo4(() => arrayIntersection(selfRoleChangeTo, roles), [roles, selfRoleChangeTo]);
1878
- if (!permissions.changeRole) {
1879
- return null;
1880
- }
1881
- return hideTriggerItem ? /* @__PURE__ */ React17.createElement(Dropdown.Item, { onClick }, /* @__PURE__ */ React17.createElement(PersonIcon, null), /* @__PURE__ */ React17.createElement(Text, { variant: "sm", css: { mx: "$4" } }, "Change My Role")) : /* @__PURE__ */ React17.createElement(Dropdown.SubMenu, null, /* @__PURE__ */ React17.createElement(Dropdown.TriggerItem, { "data-testid": "change_my_role_btn" }, /* @__PURE__ */ React17.createElement(PersonIcon, null), /* @__PURE__ */ React17.createElement(Text, { variant: "sm", css: { flex: "1 1 0", mx: "$4" } }, "Change My Role"), /* @__PURE__ */ React17.createElement(ArrowRightIcon, null)), /* @__PURE__ */ React17.createElement(Dropdown.SubMenuContent, { sideOffset: 8, alignOffset: -5, css: { py: "$0", "@md": { w: "$64" } } }, availableSelfChangeRoles.map((role) => /* @__PURE__ */ React17.createElement(
1882
- Dropdown.Item,
1883
- {
1884
- key: role,
1885
- css: { justifyContent: "space-between" },
1886
- onClick: () => __async(void 0, null, function* () {
1887
- try {
1888
- yield hmsActions.changeRole(localPeerId, role, true);
1889
- } catch (error) {
1890
- ToastManager.addToast({ title: error.message });
1891
- }
1892
- }),
1893
- "data-testid": "change_to_role_" + role
1894
- },
1895
- /* @__PURE__ */ React17.createElement(Text, { variant: "sm" }, role),
1896
- localPeerRole === role && /* @__PURE__ */ React17.createElement(CheckIcon2, { width: 16, height: 16 })
1897
- ))));
1898
- };
1899
-
1900
- // src/Prebuilt/components/MoreSettings/EmbedUrl.jsx
1901
- init_define_process_env();
1902
- import React18, { useState as useState9 } from "react";
1903
- import { ViewIcon } from "@100mslive/react-icons";
1904
- var EmbedUrl = ({ setShowOpenUrl }) => {
1905
- if (!window.CropTarget) {
1906
- return null;
1907
- }
1908
- return /* @__PURE__ */ React18.createElement(
1909
- Dropdown.Item,
1910
- {
1911
- onClick: () => {
1912
- setShowOpenUrl(true);
1913
- },
1914
- "data-testid": "embed_url_btn"
1915
- },
1916
- /* @__PURE__ */ React18.createElement(ViewIcon, null),
1917
- /* @__PURE__ */ React18.createElement(Text, { variant: "sm", css: { ml: "$4" } }, "Embed URL")
1918
- );
1919
- };
1920
- function EmbedUrlModal({ onOpenChange }) {
1921
- const [embedConfig, setEmbedConfig] = useSetAppDataByKey(APP_DATA.embedConfig);
1922
- const [url, setUrl] = useState9((embedConfig == null ? void 0 : embedConfig.url) || "");
1923
- const isAnythingEmbedded = !!(embedConfig == null ? void 0 : embedConfig.url);
1924
- const isModifying = isAnythingEmbedded && url && url !== embedConfig.url;
1925
- return /* @__PURE__ */ React18.createElement(Dialog.Root, { defaultOpen: true, onOpenChange }, /* @__PURE__ */ React18.createElement(DialogContent, { title: "Embed URL", Icon: ViewIcon }, /* @__PURE__ */ React18.createElement(DialogInput, { title: "URL", value: url, onChange: setUrl, placeholder: "https://www.tldraw.com/", type: "url" }), /* @__PURE__ */ React18.createElement(DialogRow, null, /* @__PURE__ */ React18.createElement(Text, null, "Embed a url and share with everyone in the room. Ensure that you're sharing the current tab when the prompt opens. Note that not all websites support being embedded.")), /* @__PURE__ */ React18.createElement(DialogRow, { justify: "end" }, isAnythingEmbedded ? /* @__PURE__ */ React18.createElement(React18.Fragment, null, /* @__PURE__ */ React18.createElement(
1926
- Button,
1927
- {
1928
- variant: "primary",
1929
- type: "submit",
1930
- disabled: !isModifying,
1931
- onClick: () => {
1932
- setEmbedConfig({ url, shareScreen: embedConfig.shareScreen });
1933
- onOpenChange(false);
1934
- },
1935
- "data-testid": "embed_url_btn",
1936
- css: { mr: "$4" }
1937
- },
1938
- "Update Embed"
1939
- ), /* @__PURE__ */ React18.createElement(
1940
- Button,
1941
- {
1942
- variant: "danger",
1943
- type: "submit",
1944
- onClick: () => {
1945
- setEmbedConfig({ url: "" });
1946
- onOpenChange(false);
1947
- },
1948
- "data-testid": "embed_url_btn"
1949
- },
1950
- "Stop Embed"
1951
- )) : /* @__PURE__ */ React18.createElement(React18.Fragment, null, /* @__PURE__ */ React18.createElement(
1952
- Button,
1953
- {
1954
- variant: "primary",
1955
- type: "submit",
1956
- disabled: !url.trim(),
1957
- onClick: () => {
1958
- setEmbedConfig({ url });
1959
- onOpenChange(false);
1960
- },
1961
- "data-testid": "embed_url_btn",
1962
- css: { mr: "$4" }
1963
- },
1964
- "Just Embed"
1965
- ), /* @__PURE__ */ React18.createElement(
1966
- Button,
1967
- {
1968
- variant: "primary",
1969
- type: "submit",
1970
- disabled: !url.trim(),
1971
- onClick: () => {
1972
- setEmbedConfig({ url, shareScreen: true });
1973
- onOpenChange(false);
1974
- },
1975
- "data-testid": "embed_url_btn"
1976
- },
1977
- "Embed and Share"
1978
- )))));
1979
- }
1980
-
1981
- // src/Prebuilt/components/MoreSettings/FullScreenItem.jsx
1982
- init_define_process_env();
1983
- import React19 from "react";
1984
- import { ExpandIcon as ExpandIcon2 } from "@100mslive/react-icons";
1985
-
1986
- // src/Prebuilt/components/hooks/useFullscreen.js
1987
- init_define_process_env();
1988
- import { useCallback as useCallback7, useEffect as useEffect7, useState as useState10 } from "react";
1989
- import screenfull2 from "screenfull";
1990
- var useFullscreen2 = () => {
1991
- const [isFullScreenEnabled, setIsFullScreenEnabled] = useState10(screenfull2.isFullscreen);
1992
- const toggle = useCallback7(() => __async(void 0, null, function* () {
1993
- if (!screenfull2.isEnabled) {
1994
- ToastManager.addToast({ title: "Fullscreen feature not supported" });
1995
- return;
1996
- }
1997
- try {
1998
- if (isFullScreenEnabled) {
1999
- yield screenfull2.exit();
2000
- } else {
2001
- yield screenfull2.request();
2002
- }
2003
- } catch (err) {
2004
- ToastManager.addToast({ title: err.message });
2005
- }
2006
- }), [isFullScreenEnabled]);
2007
- useEffect7(() => {
2008
- const onChange = () => {
2009
- setIsFullScreenEnabled(screenfull2.isFullscreen);
2010
- };
2011
- if (screenfull2.isEnabled) {
2012
- screenfull2.on("change", onChange);
2013
- }
2014
- return () => {
2015
- if (screenfull2.isEnabled) {
2016
- screenfull2.off("change", onChange);
2017
- }
2018
- };
2019
- }, []);
2020
- return {
2021
- allowed: screenfull2.isEnabled,
2022
- isFullscreen: isFullScreenEnabled,
2023
- toggleFullscreen: toggle
2024
- };
2025
- };
2026
-
2027
- // src/Prebuilt/components/MoreSettings/FullScreenItem.jsx
2028
- var FullScreenItem = () => {
2029
- const { allowed, isFullscreen, toggleFullscreen } = useFullscreen2();
2030
- const isFullscreenEnabled = useIsFeatureEnabled(FEATURE_LIST.FULLSCREEN);
2031
- if (!isFullscreenEnabled || !allowed) {
2032
- return null;
2033
- }
2034
- return /* @__PURE__ */ React19.createElement(
2035
- Dropdown.Item,
2036
- {
2037
- onClick: () => {
2038
- toggleFullscreen();
2039
- },
2040
- "data-testid": "full_screen_btn"
2041
- },
2042
- /* @__PURE__ */ React19.createElement(ExpandIcon2, null),
2043
- /* @__PURE__ */ React19.createElement(Text, { variant: "sm", css: { ml: "$4" } }, isFullscreen ? "Exit " : "Go ", "Fullscreen")
2044
- );
2045
- };
2046
-
2047
- // src/Prebuilt/components/MoreSettings/MuteAllModal.jsx
2048
- init_define_process_env();
2049
- import React20, { useCallback as useCallback8, useState as useState11 } from "react";
2050
- import { useHMSActions as useHMSActions11 } from "@100mslive/react-sdk";
2051
- import { MicOffIcon } from "@100mslive/react-icons";
2052
- var trackSourceOptions = [
2053
- { label: "All Track Sources", value: "" },
2054
- { label: "regular", value: "regular" },
2055
- { label: "screen", value: "screen" },
2056
- { label: "audioplaylist", value: "audioplaylist" },
2057
- { label: "videoplaylist", value: "videoplaylist" }
2058
- ];
2059
- var trackTypeOptions = [
2060
- { label: "All Track Types", value: "" },
2061
- { label: "audio", value: "audio" },
2062
- { label: "video", value: "video" }
2063
- ];
2064
- var MuteAllModal = ({ onOpenChange }) => {
2065
- const roles = useFilteredRoles();
2066
- const hmsActions = useHMSActions11();
2067
- const [enabled, setEnabled] = useState11(false);
2068
- const [trackType, setTrackType] = useState11();
2069
- const [selectedRole, setRole] = useState11();
2070
- const [selectedSource, setSource] = useState11();
2071
- const muteAll = useCallback8(() => __async(void 0, null, function* () {
2072
- yield hmsActions.setRemoteTracksEnabled({
2073
- enabled,
2074
- type: trackType,
2075
- source: selectedSource,
2076
- roles: selectedRole ? [selectedRole] : void 0
2077
- });
2078
- onOpenChange(false);
2079
- }), [selectedRole, enabled, trackType, selectedSource, hmsActions, onOpenChange]);
2080
- return /* @__PURE__ */ React20.createElement(Dialog.Root, { defaultOpen: true, onOpenChange }, /* @__PURE__ */ React20.createElement(DialogContent, { title: "Mute/Unmute Remote Tracks", Icon: MicOffIcon }, /* @__PURE__ */ React20.createElement(
2081
- DialogSelect,
2082
- {
2083
- title: "Role",
2084
- options: [{ label: "All Roles", value: "" }, ...roles.map((role) => ({ label: role, value: role }))],
2085
- selected: selectedRole,
2086
- keyField: "value",
2087
- labelField: "label",
2088
- onChange: setRole
2089
- }
2090
- ), /* @__PURE__ */ React20.createElement(
2091
- DialogSelect,
2092
- {
2093
- title: "Track type",
2094
- options: trackTypeOptions,
2095
- selected: trackType,
2096
- onChange: setTrackType,
2097
- keyField: "value",
2098
- labelField: "label"
2099
- }
2100
- ), /* @__PURE__ */ React20.createElement(
2101
- DialogSelect,
2102
- {
2103
- title: "Track source",
2104
- options: trackSourceOptions,
2105
- selected: selectedSource,
2106
- onChange: setSource,
2107
- keyField: "value",
2108
- labelField: "label"
2109
- }
2110
- ), /* @__PURE__ */ React20.createElement(DialogRow, null, /* @__PURE__ */ React20.createElement(Text, { variant: "md" }, "Track status"), /* @__PURE__ */ React20.createElement(RadioGroup.Root, { value: enabled, onValueChange: setEnabled }, /* @__PURE__ */ React20.createElement(Flex, { align: "center", css: { mr: "$8" } }, /* @__PURE__ */ React20.createElement(RadioGroup.Item, { value: false, id: "trackDisableRadio", css: { mr: "$4" } }, /* @__PURE__ */ React20.createElement(RadioGroup.Indicator, null)), /* @__PURE__ */ React20.createElement(Label, { htmlFor: "trackDisableRadio" }, "Mute")), /* @__PURE__ */ React20.createElement(Flex, { align: "center", css: { cursor: "pointer" } }, /* @__PURE__ */ React20.createElement(RadioGroup.Item, { value: true, id: "trackEnableRadio", css: { mr: "$4" } }, /* @__PURE__ */ React20.createElement(RadioGroup.Indicator, null)), /* @__PURE__ */ React20.createElement(Label, { htmlFor: "trackEnableRadio" }, "Request Unmute")))), /* @__PURE__ */ React20.createElement(DialogRow, { justify: "end" }, /* @__PURE__ */ React20.createElement(Button, { variant: "primary", onClick: muteAll }, "Apply"))));
2111
- };
2112
-
2113
- // src/Prebuilt/components/MoreSettings/MoreSettings.jsx
2114
- var isMobileOS = isAndroid || isIOS;
2115
- var MODALS = {
2116
- CHANGE_NAME: "changeName",
2117
- SELF_ROLE_CHANGE: "selfRoleChange",
2118
- MORE_SETTINGS: "moreSettings",
2119
- START_RECORDING: "startRecording",
2120
- DEVICE_SETTINGS: "deviceSettings",
2121
- STATS_FOR_NERDS: "statsForNerds",
2122
- BULK_ROLE_CHANGE: "bulkRoleChange",
2123
- MUTE_ALL: "muteAll",
2124
- EMBED_URL: "embedUrl"
2125
- };
2126
- var MoreSettings = () => {
2127
- const permissions = useHMSStore15(selectPermissions4);
2128
- const isAllowedToPublish = useHMSStore15(selectIsAllowedToPublish);
2129
- const localPeerId = useHMSStore15(selectLocalPeerID6);
2130
- const localPeerRole = useHMSStore15(selectLocalPeerRoleName5);
2131
- const hmsActions = useHMSActions12();
2132
- const enablHlsStats = useHMSStore15(selectAppData2(APP_DATA.hlsStats));
2133
- const isMobile = useMedia5(config.media.md);
2134
- const { isBrowserRecordingOn } = useRecordingStreaming3();
2135
- const isChangeNameEnabled = useIsFeatureEnabled(FEATURE_LIST.CHANGE_NAME);
2136
- const isEmbedEnabled = useIsFeatureEnabled(FEATURE_LIST.EMBED_URL);
2137
- const isSFNEnabled = useIsFeatureEnabled(FEATURE_LIST.STARTS_FOR_NERDS);
2138
- const [openModals, setOpenModals] = useState12(/* @__PURE__ */ new Set());
2139
- useDropdownList({ open: openModals.size > 0, name: "MoreSettings" });
2140
- const updateState = (modalName, value) => {
2141
- setOpenModals((modals) => {
2142
- const copy = new Set(modals);
2143
- if (value) {
2144
- copy.add(modalName);
2145
- } else {
2146
- copy.delete(modalName);
2147
- }
2148
- return copy;
2149
- });
2150
- };
2151
- return /* @__PURE__ */ React21.createElement(Fragment3, null, /* @__PURE__ */ React21.createElement(
2152
- Dropdown.Root,
2153
- {
2154
- open: openModals.has(MODALS.MORE_SETTINGS),
2155
- onOpenChange: (value) => updateState(MODALS.MORE_SETTINGS, value)
2156
- },
2157
- /* @__PURE__ */ React21.createElement(Dropdown.Trigger, { asChild: true, "data-testid": "more_settings_btn" }, /* @__PURE__ */ React21.createElement(IconButton_default, null, /* @__PURE__ */ React21.createElement(Tooltip, { title: "More options" }, /* @__PURE__ */ React21.createElement(Box, null, /* @__PURE__ */ React21.createElement(VerticalMenuIcon, null))))),
2158
- /* @__PURE__ */ React21.createElement(
2159
- Dropdown.Content,
2160
- {
2161
- sideOffset: 5,
2162
- align: "center",
2163
- css: {
2164
- py: "$0",
2165
- maxHeight: "$96",
2166
- "@md": { w: "$64" },
2167
- "div[role='separator']:first-child": {
2168
- display: "none"
2169
- }
2170
- }
2171
- },
2172
- isMobile && (permissions == null ? void 0 : permissions.browserRecording) ? /* @__PURE__ */ React21.createElement(React21.Fragment, null, /* @__PURE__ */ React21.createElement(Dropdown.Item, { onClick: () => updateState(MODALS.START_RECORDING, true) }, /* @__PURE__ */ React21.createElement(RecordIcon, null), /* @__PURE__ */ React21.createElement(Text, { variant: "sm", css: { ml: "$4" } }, isBrowserRecordingOn ? "Stop" : "Start", " Recording")), /* @__PURE__ */ React21.createElement(Dropdown.ItemSeparator, null)) : null,
2173
- isChangeNameEnabled && /* @__PURE__ */ React21.createElement(Dropdown.Item, { onClick: () => updateState(MODALS.CHANGE_NAME, true), "data-testid": "change_name_btn" }, /* @__PURE__ */ React21.createElement(PencilIcon, null), /* @__PURE__ */ React21.createElement(Text, { variant: "sm", css: { ml: "$4" } }, "Change Name")),
2174
- /* @__PURE__ */ React21.createElement(ChangeSelfRole, { onClick: () => updateState(MODALS.SELF_ROLE_CHANGE, true) }),
2175
- (permissions == null ? void 0 : permissions.changeRole) && /* @__PURE__ */ React21.createElement(
2176
- Dropdown.Item,
2177
- {
2178
- onClick: () => updateState(MODALS.BULK_ROLE_CHANGE, true),
2179
- "data-testid": "bulk_role_change_btn"
2180
- },
2181
- /* @__PURE__ */ React21.createElement(ChangeRoleIcon2, null),
2182
- /* @__PURE__ */ React21.createElement(Text, { variant: "sm", css: { ml: "$4" } }, "Bulk Role Change")
2183
- ),
2184
- /* @__PURE__ */ React21.createElement(FullScreenItem, null),
2185
- isAllowedToPublish.screen && isEmbedEnabled && /* @__PURE__ */ React21.createElement(EmbedUrl, { setShowOpenUrl: () => updateState(MODALS.EMBED_URL, true) }),
2186
- permissions.mute && /* @__PURE__ */ React21.createElement(Dropdown.Item, { onClick: () => updateState(MODALS.MUTE_ALL, true), "data-testid": "mute_all_btn" }, /* @__PURE__ */ React21.createElement(MicOffIcon2, null), /* @__PURE__ */ React21.createElement(Text, { variant: "sm", css: { ml: "$4" } }, "Mute All")),
2187
- /* @__PURE__ */ React21.createElement(Dropdown.ItemSeparator, null),
2188
- /* @__PURE__ */ React21.createElement(Dropdown.Item, { onClick: () => updateState(MODALS.DEVICE_SETTINGS, true), "data-testid": "device_settings_btn" }, /* @__PURE__ */ React21.createElement(SettingsIcon, null), /* @__PURE__ */ React21.createElement(Text, { variant: "sm", css: { ml: "$4" } }, "Settings")),
2189
- FeatureFlags.enableStatsForNerds && isSFNEnabled && (localPeerRole === "hls-viewer" ? Hls.isSupported() ? /* @__PURE__ */ React21.createElement(
2190
- Dropdown.Item,
2191
- {
2192
- onClick: () => hmsActions.setAppData(APP_DATA.hlsStats, !enablHlsStats),
2193
- "data-testid": "hls_stats"
2194
- },
2195
- /* @__PURE__ */ React21.createElement(
2196
- Checkbox.Root,
2197
- {
2198
- css: { margin: "$2" },
2199
- checked: enablHlsStats,
2200
- onCheckedChange: () => hmsActions.setAppData(APP_DATA.hlsStats, !enablHlsStats)
2201
- },
2202
- /* @__PURE__ */ React21.createElement(Checkbox.Indicator, null, /* @__PURE__ */ React21.createElement(CheckIcon3, { width: 16, height: 16 }))
2203
- ),
2204
- /* @__PURE__ */ React21.createElement(Flex, { justify: "between", css: { width: "100%" } }, /* @__PURE__ */ React21.createElement(Text, { variant: "sm", css: { ml: "$4" } }, "Show HLS Stats"), !isMobileOS ? /* @__PURE__ */ React21.createElement(Text, { variant: "sm", css: { ml: "$4" } }, `${isMacOS ? "\u2318" : "ctrl"} + ]`) : null)
2205
- ) : null : /* @__PURE__ */ React21.createElement(
2206
- Dropdown.Item,
2207
- {
2208
- onClick: () => updateState(MODALS.STATS_FOR_NERDS, true),
2209
- "data-testid": "stats_for_nreds_btn"
2210
- },
2211
- /* @__PURE__ */ React21.createElement(InfoIcon, null),
2212
- /* @__PURE__ */ React21.createElement(Text, { variant: "sm", css: { ml: "$4" } }, "Stats for Nerds")
2213
- ))
2214
- )
2215
- ), openModals.has(MODALS.BULK_ROLE_CHANGE) && /* @__PURE__ */ React21.createElement(BulkRoleChangeModal, { onOpenChange: (value) => updateState(MODALS.BULK_ROLE_CHANGE, value) }), openModals.has(MODALS.MUTE_ALL) && /* @__PURE__ */ React21.createElement(MuteAllModal, { onOpenChange: (value) => updateState(MODALS.MUTE_ALL, value) }), openModals.has(MODALS.CHANGE_NAME) && /* @__PURE__ */ React21.createElement(ChangeNameModal, { onOpenChange: (value) => updateState(MODALS.CHANGE_NAME, value) }), openModals.has(MODALS.DEVICE_SETTINGS) && /* @__PURE__ */ React21.createElement(SettingsModal_default, { open: true, onOpenChange: (value) => updateState(MODALS.DEVICE_SETTINGS, value) }), FeatureFlags.enableStatsForNerds && openModals.has(MODALS.STATS_FOR_NERDS) && /* @__PURE__ */ React21.createElement(StatsForNerds, { open: true, onOpenChange: (value) => updateState(MODALS.STATS_FOR_NERDS, value) }), openModals.has(MODALS.SELF_ROLE_CHANGE) && /* @__PURE__ */ React21.createElement(RoleChangeModal, { peerId: localPeerId, onOpenChange: (value) => updateState(MODALS.SELF_ROLE_CHANGE, value) }), openModals.has(MODALS.START_RECORDING) && /* @__PURE__ */ React21.createElement(StartRecording_default, { open: true, onOpenChange: (value) => updateState(MODALS.START_RECORDING, value) }), openModals.has(MODALS.EMBED_URL) && /* @__PURE__ */ React21.createElement(EmbedUrlModal, { onOpenChange: (value) => updateState(MODALS.EMBED_URL, value) }));
2216
- };
2217
-
2218
- // src/Prebuilt/components/PIP/index.jsx
2219
- init_define_process_env();
2220
- import React23 from "react";
2221
-
2222
- // src/Prebuilt/components/PIP/PIPComponent.jsx
2223
- init_define_process_env();
2224
- import React22, { useCallback as useCallback9, useEffect as useEffect8, useState as useState13 } from "react";
2225
- import {
2226
- selectLocalPeerRoleName as selectLocalPeerRoleName6,
2227
- selectPeers as selectPeers4,
2228
- selectRemotePeers as selectRemotePeers2,
2229
- selectTracksMap as selectTracksMap2,
2230
- useHMSActions as useHMSActions13,
2231
- useHMSStore as useHMSStore16,
2232
- useHMSVanillaStore
2233
- } from "@100mslive/react-sdk";
2234
- import { PipIcon } from "@100mslive/react-icons";
2235
-
2236
- // src/Prebuilt/components/PIP/PIPManager.js
2237
- init_define_process_env();
2238
- import * as workerTimers from "worker-timers";
2239
-
2240
- // src/Prebuilt/components/PIP/pipUtils.js
2241
- init_define_process_env();
2242
- var CANVAS_FILL_COLOR;
2243
- var CANVAS_STROKE_COLOR;
2244
- function setPIPCanvasColors() {
2245
- if (!CANVAS_FILL_COLOR) {
2246
- CANVAS_FILL_COLOR = window.getComputedStyle(document.documentElement).getPropertyValue("--hms-ui-colors-surface_bright");
2247
- }
2248
- if (!CANVAS_STROKE_COLOR) {
2249
- CANVAS_STROKE_COLOR = window.getComputedStyle(document.documentElement).getPropertyValue("--hms-ui-colors-border_bright");
2250
- }
2251
- }
2252
- function resetPIPCanvasColors() {
2253
- CANVAS_FILL_COLOR = "";
2254
- CANVAS_STROKE_COLOR = "";
2255
- }
2256
- function drawVideoElementsOnCanvas(videoElements, canvas) {
2257
- let videoTiles = videoElements.filter((videoElement) => videoElement.srcObject !== null);
2258
- const ctx = canvas.getContext("2d");
2259
- setPIPCanvasColors();
2260
- ctx.fillStyle = CANVAS_FILL_COLOR;
2261
- ctx.clearRect(0, 0, canvas.width, canvas.height);
2262
- if (videoTiles.length === 0) {
2263
- ctx.fillRect(0, 0, canvas.width, canvas.height);
2264
- return;
2265
- }
2266
- fillGridTiles(videoTiles.slice(0, 4), ctx, canvas);
2267
- }
2268
- function dummyChangeInCanvas(canvas) {
2269
- const ctx = canvas.getContext("2d");
2270
- setPIPCanvasColors();
2271
- ctx.fillStyle = CANVAS_FILL_COLOR;
2272
- ctx.fillRect(0, 0, canvas.width, canvas.height);
2273
- }
2274
- function fillGridTiles(videoElements, ctx, canvas) {
2275
- const offset = 8;
2276
- canvas.width = 480;
2277
- canvas.height = 320;
2278
- ctx.fillStyle = CANVAS_FILL_COLOR;
2279
- ctx.fillRect(0, 0, canvas.width, canvas.height);
2280
- if (videoElements.length > 0) {
2281
- ctx.strokeStyle = CANVAS_STROKE_COLOR;
2282
- ctx.lineWidth = offset / 2;
2283
- ctx.strokeRect(0, 0, canvas.width, canvas.height);
2284
- }
2285
- if (videoElements.length === 1) {
2286
- const video = videoElements[0];
2287
- const { width, height } = getRenderDimensions(video, canvas.width - offset, canvas.height - offset);
2288
- const xOffset = (canvas.width - width) / 2;
2289
- const yOffset = (canvas.height - height) / 2;
2290
- ctx.drawImage(video, xOffset, yOffset, width, height);
2291
- }
2292
- if (videoElements.length === 2) {
2293
- videoElements.forEach((video, index) => {
2294
- const { width, height } = getRenderDimensions(
2295
- video,
2296
- canvas.width / 2 - offset,
2297
- // This will be the max available width for each tile
2298
- canvas.height - offset
2299
- );
2300
- const xOffset = (canvas.width / 2 - width) / 2 + canvas.width / 2 * index;
2301
- const yOffset = (canvas.height - height) / 2;
2302
- ctx.drawImage(video, xOffset, yOffset, width, height);
2303
- });
2304
- const path = new Path2D();
2305
- path.moveTo(canvas.width / 2, 0);
2306
- path.lineTo(canvas.width / 2, canvas.height);
2307
- ctx.stroke(path);
2308
- }
2309
- if (videoElements.length === 3) {
2310
- videoElements.forEach((video, index) => {
2311
- const { width, height } = getRenderDimensions(video, canvas.width / 2 - offset, canvas.height / 2 - offset);
2312
- const xOffset = index < 2 ? (canvas.width / 2 - width) / 2 + canvas.width / 2 * index : canvas.width / 2 - width / 2;
2313
- const yOffset = (index < 2 ? 0 : canvas.height / 2) + (canvas.height / 2 - height) / 2;
2314
- ctx.drawImage(video, xOffset, yOffset, width, height);
2315
- });
2316
- const path = new Path2D();
2317
- path.moveTo(canvas.width / 2, 0);
2318
- path.lineTo(canvas.width / 2, canvas.height / 2);
2319
- ctx.stroke(path);
2320
- path.moveTo(0, canvas.height / 2);
2321
- path.lineTo(canvas.width, canvas.height / 2);
2322
- ctx.stroke(path);
2323
- }
2324
- if (videoElements.length === 4) {
2325
- videoElements.forEach((video, index) => {
2326
- const { width, height } = getRenderDimensions(video, canvas.width / 2 - offset, canvas.height / 2 - offset);
2327
- const xOffset = (canvas.width / 2 - width) / 2 + canvas.width / 2 * (index % 2);
2328
- const yOffset = (index < 2 ? 0 : canvas.height / 2) + (canvas.height / 2 - height) / 2;
2329
- ctx.drawImage(video, xOffset, yOffset, width, height);
2330
- });
2331
- const path = new Path2D();
2332
- path.moveTo(canvas.width / 2, 0);
2333
- path.lineTo(canvas.width / 2, canvas.height);
2334
- ctx.stroke(path);
2335
- path.moveTo(0, canvas.height / 2);
2336
- path.lineTo(canvas.width, canvas.height / 2);
2337
- ctx.stroke(path);
2338
- }
2339
- }
2340
- function getRenderDimensions(video, width, height) {
2341
- let finalWidth = video.videoWidth / video.videoHeight * height;
2342
- let finalHeight = height;
2343
- if (finalWidth > width) {
2344
- finalWidth = width;
2345
- finalHeight = video.videoHeight / video.videoWidth * width;
2346
- }
2347
- return { width: finalWidth, height: finalHeight };
2348
- }
2349
-
2350
- // src/Prebuilt/components/PIP/PIPManager.js
2351
- var MAX_NUMBER_OF_TILES_IN_PIP = 4;
2352
- var DEFAULT_FPS = 30;
2353
- var DEFAULT_CANVAS_WIDTH = 480;
2354
- var DEFAULT_CANVAS_HEIGHT = 320;
2355
- var LEAVE_EVENT_NAME = "leavepictureinpicture";
2356
- var PIPStates = {
2357
- starting: "starting",
2358
- started: "started",
2359
- stopping: "stopping",
2360
- stopped: "stopped"
2361
- };
2362
- var PipManager = class {
2363
- constructor() {
2364
- __publicField(this, "stop", () => __async(this, null, function* () {
2365
- var _a;
2366
- if (this.state === PIPStates.stopped) {
2367
- return;
2368
- }
2369
- this.state = PIPStates.stopping;
2370
- (_a = this.pipVideo) == null ? void 0 : _a.removeEventListener(LEAVE_EVENT_NAME, this.stop);
2371
- if (this.timeoutRef) {
2372
- workerTimers.clearTimeout(this.timeoutRef);
2373
- }
2374
- if (this.isOn()) {
2375
- this.exitPIP();
2376
- }
2377
- yield this.detachOldAttachNewTracks(this.tracksToShow, []);
2378
- this.onStateChange(false);
2379
- this.reset();
2380
- this.state = PIPStates.stopped;
2381
- }));
2382
- this.reset();
2383
- }
2384
- /**
2385
- * @private
2386
- */
2387
- reset() {
2388
- console.debug("resetting PIP state");
2389
- resetPIPCanvasColors();
2390
- this.canvas = null;
2391
- this.pipVideo = null;
2392
- this.timeoutRef = null;
2393
- this.hmsActions = null;
2394
- this.videoElements = [];
2395
- this.tracksToShow = [];
2396
- this.onStateChange = () => {
2397
- };
2398
- this.state = PIPStates.stopped;
2399
- }
2400
- /**
2401
- * check if PIP is supported in this browser env
2402
- */
2403
- isSupported() {
2404
- return !!document.pictureInPictureEnabled && !isIOS && !(isMacOS && isSafari);
2405
- }
2406
- /**
2407
- * check if pip is currently turned on
2408
- */
2409
- isOn() {
2410
- return !!document.pictureInPictureElement;
2411
- }
2412
- /**
2413
- * request browser to start pip and start the render loop updating the pip
2414
- * video element with peer tracks.
2415
- * @param hmsActions
2416
- * @param onStateChangeFn {function(bool):void} callback called to notify change in pip state
2417
- */
2418
- start(hmsActions, onStateChangeFn) {
2419
- return __async(this, null, function* () {
2420
- if (!this.isSupported()) {
2421
- throw new Error("pip is not supported on this browser");
2422
- }
2423
- console.debug("starting PIP, current state", this.state);
2424
- if (this.state === PIPStates.started) {
2425
- yield this.stop();
2426
- } else if (this.state === PIPStates.starting) {
2427
- return;
2428
- }
2429
- this.state = PIPStates.starting;
2430
- try {
2431
- yield this.init(hmsActions, onStateChangeFn);
2432
- this.pipVideo.addEventListener(LEAVE_EVENT_NAME, this.stop);
2433
- this.renderLoop();
2434
- if (!this.isOn()) {
2435
- yield this.requestPIP();
2436
- }
2437
- console.debug("pip started");
2438
- this.state = PIPStates.started;
2439
- this.onStateChange(true);
2440
- } catch (err) {
2441
- console.error("error in request pip", err);
2442
- this.state = PIPStates.stopped;
2443
- }
2444
- });
2445
- }
2446
- /**
2447
- * @param peers {Array} All Remote Peers present in call.
2448
- * @param tracksMap {Object} map of track id to track
2449
- * */
2450
- updatePeersAndTracks(peers, tracksMap) {
2451
- return __async(this, null, function* () {
2452
- if (!this.canvas) {
2453
- return;
2454
- }
2455
- const newTracksToShowUnordered = this.pickTracksToShow(peers, tracksMap);
2456
- const currentTracksShowing = this.tracksToShow;
2457
- this.tracksToShow = this.orderNewTracksToShow(newTracksToShowUnordered, currentTracksShowing);
2458
- try {
2459
- yield this.detachOldAttachNewTracks(currentTracksShowing, this.tracksToShow, tracksMap);
2460
- } catch (error) {
2461
- console.error("error in detaching/attaching tracks", error);
2462
- }
2463
- });
2464
- }
2465
- // ------- Private function --------------
2466
- /**
2467
- * @private
2468
- */
2469
- init(hmsActions, onStateChangeFn) {
2470
- return __async(this, null, function* () {
2471
- yield this.initMediaElements();
2472
- this.hmsActions = hmsActions;
2473
- this.onStateChange = onStateChangeFn;
2474
- });
2475
- }
2476
- initMediaElements() {
2477
- return __async(this, null, function* () {
2478
- if (!this.canvas) {
2479
- const { canvas, pipVideo } = this.initializeCanvasAndVideoElement();
2480
- this.canvas = canvas;
2481
- this.pipVideo = pipVideo;
2482
- this.videoElements = this.initializeVideoElements();
2483
- const videoPlayPromise = this.pipVideo.play();
2484
- dummyChangeInCanvas(this.canvas);
2485
- yield videoPlayPromise;
2486
- }
2487
- });
2488
- }
2489
- initializeCanvasAndVideoElement() {
2490
- const canvas = document.createElement("canvas");
2491
- canvas.width = DEFAULT_CANVAS_WIDTH;
2492
- canvas.height = DEFAULT_CANVAS_HEIGHT;
2493
- const pipVideo = document.createElement("video");
2494
- pipVideo.width = DEFAULT_CANVAS_WIDTH;
2495
- pipVideo.height = DEFAULT_CANVAS_HEIGHT;
2496
- pipVideo.muted = true;
2497
- pipVideo.srcObject = canvas.captureStream();
2498
- return { canvas, pipVideo };
2499
- }
2500
- initializeVideoElements() {
2501
- let videoElements = [];
2502
- for (let i = 0; i < MAX_NUMBER_OF_TILES_IN_PIP; i++) {
2503
- const videoElement = document.createElement("video");
2504
- videoElement.autoplay = true;
2505
- videoElement.playsinline = true;
2506
- videoElements.push(videoElement);
2507
- }
2508
- return videoElements;
2509
- }
2510
- /**
2511
- * render loop is responsible for rendering the video elements on canvas/pip.
2512
- * in each loop current video elements are stitched and painted on canvas
2513
- */
2514
- renderLoop() {
2515
- const delay = 1e3 / DEFAULT_FPS;
2516
- this.timeoutRef = workerTimers.setTimeout(() => {
2517
- if (this.state === PIPStates.stopping || this.state === PIPStates.stopped) {
2518
- return;
2519
- }
2520
- if (this.state === PIPStates.started) {
2521
- drawVideoElementsOnCanvas(this.videoElements, this.canvas);
2522
- }
2523
- this.renderLoop();
2524
- }, delay);
2525
- }
2526
- requestPIP() {
2527
- return __async(this, null, function* () {
2528
- try {
2529
- if (this.isOn()) {
2530
- this.exitPIP();
2531
- }
2532
- yield this.pipVideo.requestPictureInPicture();
2533
- } catch (error) {
2534
- console.error("error in requestpip", error, "state", this.state);
2535
- throw error;
2536
- }
2537
- });
2538
- }
2539
- exitPIP() {
2540
- document.exitPictureInPicture();
2541
- }
2542
- /**
2543
- * Logic - pick only enabled video tracks
2544
- * @param peers {Array<any>}
2545
- * @param tracksMap {Record<string, any>}
2546
- */
2547
- pickTracksToShow(peers, tracksMap) {
2548
- var _a;
2549
- const tracksToShow = [];
2550
- for (const peer of peers) {
2551
- if (tracksToShow.length === MAX_NUMBER_OF_TILES_IN_PIP) {
2552
- break;
2553
- } else if (peer.videoTrack && ((_a = tracksMap[peer.videoTrack]) == null ? void 0 : _a.enabled)) {
2554
- tracksToShow.push(peer.videoTrack);
2555
- }
2556
- }
2557
- return tracksToShow;
2558
- }
2559
- /**
2560
- * there has to be a smart reordering of new tracks based on currently showing
2561
- * ones to reduce unnecessary displacement. If someone was showing up both
2562
- * earlier and now, it's a better UX to keep their position same instead
2563
- * of letting it change.
2564
- * The returned array is a shuffled version of newTracks with position of
2565
- * tracks present in the old tracks intact.
2566
- * eg. old = [1,5,9,3], new = [3,8,2,9], result = [8,2,9,3]
2567
- * @param oldTracks {Array}
2568
- * @param newTracks {Array}
2569
- * @return {Array}
2570
- */
2571
- orderNewTracksToShow(newTracks, oldTracks) {
2572
- const betterNewTracks = [];
2573
- const leftOvers = [];
2574
- newTracks.forEach((track) => {
2575
- const oldPosition = oldTracks.indexOf(track);
2576
- if (oldPosition !== -1 && oldPosition < newTracks.length) {
2577
- betterNewTracks[oldPosition] = track;
2578
- } else {
2579
- leftOvers.push(track);
2580
- }
2581
- });
2582
- for (let i = 0; i < newTracks.length; i++) {
2583
- if (!betterNewTracks[i]) {
2584
- betterNewTracks[i] = leftOvers.shift();
2585
- }
2586
- }
2587
- return betterNewTracks;
2588
- }
2589
- /**
2590
- * call detach for tracks which no longer need to be shown and attach for
2591
- * new ones which are to be shown now.
2592
- * Note: oldTracks and newTracks are not necessarily of same length
2593
- * @param oldTracks {Array<String>}
2594
- * @param newTracks {Array<String>}
2595
- * @param tracksMap {Record<String, any>}
2596
- */
2597
- // eslint-disable-next-line complexity
2598
- detachOldAttachNewTracks(oldTracks, newTracks, tracksMap = null) {
2599
- return __async(this, null, function* () {
2600
- const numTracks = Math.max(oldTracks.length, newTracks.length);
2601
- for (let i = 0; i < numTracks; i++) {
2602
- if (oldTracks[i] === newTracks[i]) {
2603
- continue;
2604
- } else if (oldTracks[i]) {
2605
- if (!tracksMap || tracksMap[oldTracks[i]]) {
2606
- yield this.hmsActions.detachVideo(oldTracks[i], this.videoElements[i]);
2607
- }
2608
- if (this.videoElements[i]) {
2609
- this.videoElements[i].srcObject = null;
2610
- }
2611
- }
2612
- if (newTracks[i]) {
2613
- yield this.hmsActions.attachVideo(newTracks[i], this.videoElements[i]);
2614
- }
2615
- }
2616
- });
2617
- }
2618
- };
2619
- var PictureInPicture = new PipManager();
2620
-
2621
- // src/Prebuilt/components/PIP/SetupMediaSession.js
2622
- init_define_process_env();
2623
- import { selectIsLocalAudioEnabled, selectIsLocalVideoEnabled } from "@100mslive/react-sdk";
2624
- var SetupMediaSession = class {
2625
- constructor() {
2626
- __publicField(this, "setup", (actions, store) => {
2627
- this.actions = actions;
2628
- this.store = store;
2629
- this.initState();
2630
- this.setUpHandlers();
2631
- });
2632
- __publicField(this, "initState", () => {
2633
- var _a, _b, _c, _d;
2634
- const isMicActive = this.store.getState(selectIsLocalAudioEnabled);
2635
- const isCamActive = this.store.getState(selectIsLocalVideoEnabled);
2636
- (_b = (_a = navigator.mediaSession) == null ? void 0 : _a.setMicrophoneActive) == null ? void 0 : _b.call(_a, isMicActive);
2637
- (_d = (_c = navigator.mediaSession) == null ? void 0 : _c.setCameraActive) == null ? void 0 : _d.call(_c, isCamActive);
2638
- this.store.subscribe((isMicActive2) => {
2639
- var _a2, _b2;
2640
- (_b2 = (_a2 = navigator.mediaSession) == null ? void 0 : _a2.setMicrophoneActive) == null ? void 0 : _b2.call(_a2, isMicActive2);
2641
- }, selectIsLocalAudioEnabled);
2642
- this.store.subscribe((isCamActive2) => {
2643
- var _a2, _b2;
2644
- (_b2 = (_a2 = navigator.mediaSession) == null ? void 0 : _a2.setCameraActive) == null ? void 0 : _b2.call(_a2, isCamActive2);
2645
- }, selectIsLocalVideoEnabled);
2646
- });
2647
- __publicField(this, "toggleMic", () => __async(this, null, function* () {
2648
- console.log("toggle mic clicked in pip");
2649
- const current = this.store.getState(selectIsLocalAudioEnabled);
2650
- yield this.actions.setLocalAudioEnabled(!current);
2651
- }));
2652
- __publicField(this, "toggleCam", () => __async(this, null, function* () {
2653
- console.log("toggle cam clicked in pip");
2654
- const current = this.store.getState(selectIsLocalVideoEnabled);
2655
- yield this.actions.setLocalVideoEnabled(!current);
2656
- }));
2657
- __publicField(this, "leave", () => {
2658
- console.log("leave called from pip");
2659
- this.actions.leave();
2660
- });
2661
- __publicField(this, "setUpHandlers", () => {
2662
- if (navigator.mediaSession) {
2663
- try {
2664
- navigator.mediaSession.setActionHandler("togglemicrophone", this.toggleMic);
2665
- navigator.mediaSession.setActionHandler("togglecamera", this.toggleCam);
2666
- navigator.mediaSession.setActionHandler("hangup", this.leave);
2667
- } catch (err) {
2668
- console.error("error in setting media session handlers", err);
2669
- }
2670
- }
2671
- });
2672
- }
2673
- };
2674
- var MediaSession = new SetupMediaSession();
2675
-
2676
- // src/Prebuilt/components/PIP/PIPComponent.jsx
2677
- var PIPComponent = ({ peers, showLocalPeer }) => {
2678
- const localPeerRole = useHMSStore16(selectLocalPeerRoleName6);
2679
- const [isPipOn, setIsPipOn] = useState13(PictureInPicture.isOn());
2680
- const hmsActions = useHMSActions13();
2681
- const store = useHMSVanillaStore();
2682
- const isFeatureEnabled = useIsFeatureEnabled(FEATURE_LIST.PICTURE_IN_PICTURE);
2683
- const onPipToggle = useCallback9(() => {
2684
- if (!isPipOn) {
2685
- PictureInPicture.start(hmsActions, setIsPipOn).catch((err) => console.error("error in starting pip", err));
2686
- MediaSession.setup(hmsActions, store);
2687
- } else {
2688
- PictureInPicture.stop().catch((err) => console.error("error in stopping pip", err));
2689
- }
2690
- }, [hmsActions, isPipOn, store]);
2691
- useEffect8(() => {
2692
- return () => {
2693
- PictureInPicture.stop().catch((err) => console.error("error in stopping pip on unmount", err));
2694
- };
2695
- }, []);
2696
- if (!PictureInPicture.isSupported() || localPeerRole === DEFAULT_HLS_VIEWER_ROLE || !isFeatureEnabled) {
2697
- return null;
2698
- }
2699
- return /* @__PURE__ */ React22.createElement(React22.Fragment, null, /* @__PURE__ */ React22.createElement(Tooltip, { title: `${isPipOn ? "Deactivate" : "Activate"} picture in picture view` }, /* @__PURE__ */ React22.createElement(IconButton_default, { active: !isPipOn, key: "pip", onClick: () => onPipToggle(), "data-testid": "pip_btn" }, /* @__PURE__ */ React22.createElement(PipIcon, null))), isPipOn && /* @__PURE__ */ React22.createElement(ActivatedPIP, { showLocalPeer, peers }));
2700
- };
2701
- var ActivatedPIP = ({ showLocalPeer, peers }) => {
2702
- const tracksMap = useHMSStore16(selectTracksMap2);
2703
- const storePeers = useHMSStore16(showLocalPeer ? selectPeers4 : selectRemotePeers2);
2704
- useEffect8(() => {
2705
- let pipPeers = storePeers;
2706
- if (peers) {
2707
- pipPeers = storePeers.filter((peer) => peers.includes(peer.id));
2708
- }
2709
- PictureInPicture.updatePeersAndTracks(pipPeers, tracksMap).catch((err) => {
2710
- console.error("error in updating pip", err);
2711
- });
2712
- }, [peers, storePeers, tracksMap]);
2713
- return null;
2714
- };
2715
- var PIPComponent_default = PIPComponent;
2716
-
2717
- // src/Prebuilt/components/PIP/index.jsx
2718
- var PIP = () => {
2719
- const pinnedTrack = usePinnedTrack();
2720
- return /* @__PURE__ */ React23.createElement(PIPComponent_default, { peers: pinnedTrack && pinnedTrack.enabled ? [pinnedTrack.peerId] : void 0, showLocalPeer: true });
2721
- };
2722
-
2723
- // src/Prebuilt/components/ScreenShare.jsx
2724
- init_define_process_env();
2725
- import React31, { Fragment as Fragment5 } from "react";
2726
- import { selectIsAllowedToPublish as selectIsAllowedToPublish2, useHMSStore as useHMSStore17, useScreenShare as useScreenShare4 } from "@100mslive/react-sdk";
2727
- import { ShareScreenIcon as ShareScreenIcon2 } from "@100mslive/react-icons";
2728
-
2729
- // src/Prebuilt/components/pdfAnnotator/shareScreenOptions.jsx
2730
- init_define_process_env();
2731
- import React30, { Fragment as Fragment4, useState as useState15 } from "react";
2732
- import { useScreenShare as useScreenShare3 } from "@100mslive/react-sdk";
2733
- import { PdfShare, ScreenShare, StarIcon, VerticalMenuIcon as VerticalMenuIcon2 } from "@100mslive/react-icons";
2734
-
2735
- // src/Prebuilt/components/ShareMenuIcon.jsx
2736
- init_define_process_env();
2737
- var ScreenShareButton = styled(IconButton_default, {
2738
- h: "$14",
2739
- px: "$8",
2740
- r: "$1",
2741
- borderTopRightRadius: 0,
2742
- borderBottomRightRadius: 0,
2743
- "@md": {
2744
- px: "$4",
2745
- mx: 0
2746
- }
2747
- });
2748
- var ShareMenuIcon = styled(ScreenShareButton, {
2749
- borderTopLeftRadius: 0,
2750
- borderBottomLeftRadius: 0,
2751
- borderTopRightRadius: "$1",
2752
- borderBottomRightRadius: "$1",
2753
- borderLeftWidth: 0,
2754
- w: "$4",
2755
- "@md": {
2756
- px: "$2"
2757
- }
2758
- });
2759
-
2760
- // src/Prebuilt/components/pdfAnnotator/pdfFileOptions.jsx
2761
- init_define_process_env();
2762
- import React29, { useState as useState14 } from "react";
2763
-
2764
- // src/Prebuilt/components/pdfAnnotator/pdfErrorView.jsx
2765
- init_define_process_env();
2766
- import React24 from "react";
2767
- import { InfoIcon as InfoIcon2 } from "@100mslive/react-icons";
2768
- var PdfErrorView = ({ isPDFUrlValid }) => {
2769
- return !isPDFUrlValid && /* @__PURE__ */ React24.createElement(
2770
- DialogRow,
2771
- {
2772
- css: {
2773
- mt: "-$8",
2774
- color: "$alert_error_default",
2775
- justifyContent: "start"
2776
- }
2777
- },
2778
- /* @__PURE__ */ React24.createElement(InfoIcon2, { width: "12px", height: "12px" }),
2779
- /* @__PURE__ */ React24.createElement(
2780
- Text,
2781
- {
2782
- variant: "caption",
2783
- css: {
2784
- pl: "$1",
2785
- color: "$alert_error_default"
2786
- }
2787
- },
2788
- "Please enter a valid PDF URL"
2789
- )
2790
- );
2791
- };
2792
-
2793
- // src/Prebuilt/components/pdfAnnotator/pdfHeader.jsx
2794
- init_define_process_env();
2795
- import React25 from "react";
2796
- var PDFHeader = () => {
2797
- return /* @__PURE__ */ React25.createElement(
2798
- DialogCol,
2799
- {
2800
- align: "start",
2801
- css: {
2802
- mt: 0,
2803
- mb: "$6"
2804
- }
2805
- },
2806
- /* @__PURE__ */ React25.createElement(Dialog.Title, { asChild: true }, /* @__PURE__ */ React25.createElement(Text, { as: "h6", variant: "h6" }, "Share PDF")),
2807
- /* @__PURE__ */ React25.createElement(Dialog.Description, { asChild: true }, /* @__PURE__ */ React25.createElement(
2808
- Text,
2809
- {
2810
- variant: "sm",
2811
- css: {
2812
- c: "$on_surface_medium"
2813
- }
2814
- },
2815
- "Choose PDF you want to annotate and share"
2816
- ))
2817
- );
2818
- };
2819
-
2820
- // src/Prebuilt/components/pdfAnnotator/pdfInfo.jsx
2821
- init_define_process_env();
2822
- import React26 from "react";
2823
- import { InfoIcon as InfoIcon3 } from "@100mslive/react-icons";
2824
- var PDFInfo = () => {
2825
- return /* @__PURE__ */ React26.createElement(
2826
- DialogRow,
2827
- {
2828
- css: {
2829
- px: "$8",
2830
- py: "$3",
2831
- bg: "$surface_bright",
2832
- r: "$1",
2833
- outline: "none",
2834
- border: "1px solid $border_bright",
2835
- minHeight: "$11"
2836
- }
2837
- },
2838
- /* @__PURE__ */ React26.createElement(
2839
- InfoIcon3,
2840
- {
2841
- width: "64px",
2842
- height: "64px",
2843
- style: {
2844
- paddingRight: "16px"
2845
- }
2846
- }
2847
- ),
2848
- /* @__PURE__ */ React26.createElement(Text, { variant: "caption" }, "On the next screen, ensure you select \u201CThis Tab\u201D and click on share. Only the PDF viewer will be seen by other participants")
2849
- );
2850
- };
2851
-
2852
- // src/Prebuilt/components/pdfAnnotator/submitPdf.jsx
2853
- init_define_process_env();
2854
- import React27, { useCallback as useCallback10 } from "react";
2855
- var SubmitPDF = ({
2856
- pdfFile,
2857
- pdfURL,
2858
- isValidateProgress,
2859
- setIsPDFUrlValid,
2860
- setIsValidateProgress,
2861
- onOpenChange
2862
- }) => {
2863
- const [, setPDFConfig] = useSetAppDataByKey(APP_DATA.pdfConfig);
2864
- const isValidPDF = useCallback10(
2865
- (pdfURL2) => {
2866
- const extension = pdfURL2.split(".").pop().toLowerCase();
2867
- setIsValidateProgress(true);
2868
- if (extension === "pdf") {
2869
- setIsPDFUrlValid(true);
2870
- setIsValidateProgress(false);
2871
- setPDFConfig({ state: true, file: pdfFile, url: pdfURL2 });
2872
- onOpenChange(false);
2873
- }
2874
- fetch(pdfURL2, { method: "HEAD" }).then((response) => response.headers.get("content-type")).then((contentType) => {
2875
- if (contentType === "application/pdf") {
2876
- setIsPDFUrlValid(true);
2877
- setIsValidateProgress(false);
2878
- setPDFConfig({ state: true, file: pdfFile, url: pdfURL2 });
2879
- onOpenChange(false);
2880
- } else {
2881
- setIsPDFUrlValid(false);
2882
- setIsValidateProgress(false);
2883
- }
2884
- }).catch(() => {
2885
- setIsPDFUrlValid(false);
2886
- setIsValidateProgress(false);
2887
- });
2888
- },
2889
- [onOpenChange, pdfFile, setIsPDFUrlValid, setIsValidateProgress, setPDFConfig]
2890
- );
2891
- return /* @__PURE__ */ React27.createElement(
2892
- Flex,
2893
- {
2894
- direction: "row",
2895
- css: {
2896
- mb: "0",
2897
- mt: "auto",
2898
- gap: "$8"
2899
- }
2900
- },
2901
- /* @__PURE__ */ React27.createElement(
2902
- Button,
2903
- {
2904
- variant: "standard",
2905
- outlined: true,
2906
- type: "submit",
2907
- onClick: () => {
2908
- onOpenChange(false);
2909
- },
2910
- css: { w: "50%" }
2911
- },
2912
- "Cancel"
2913
- ),
2914
- /* @__PURE__ */ React27.createElement(
2915
- Button,
2916
- {
2917
- variant: "primary",
2918
- type: "submit",
2919
- onClick: () => {
2920
- if (pdfFile) {
2921
- setPDFConfig({ state: true, file: pdfFile, url: pdfURL });
2922
- onOpenChange(false);
2923
- } else if (pdfURL) {
2924
- isValidPDF(pdfURL);
2925
- }
2926
- },
2927
- disabled: !pdfFile && !pdfURL,
2928
- loading: isValidateProgress,
2929
- "data-testid": "share_pdf_btn",
2930
- css: {
2931
- w: "50%"
2932
- }
2933
- },
2934
- "Start Sharing"
2935
- )
2936
- );
2937
- };
2938
-
2939
- // src/Prebuilt/components/pdfAnnotator/uploadedFile.jsx
2940
- init_define_process_env();
2941
- import React28 from "react";
2942
- import { TrashIcon } from "@100mslive/react-icons";
2943
- var UploadedFile = ({
2944
- pdfFile,
2945
- pdfURL,
2946
- isValidateProgress,
2947
- setPDFFile,
2948
- setIsPDFUrlValid,
2949
- setIsValidateProgress,
2950
- onOpenChange
2951
- }) => {
2952
- const [fileName, ext] = pdfFile.name.split(".");
2953
- return /* @__PURE__ */ React28.createElement(Dialog.Root, { defaultOpen: true, onOpenChange }, /* @__PURE__ */ React28.createElement(Dialog.Portal, null, /* @__PURE__ */ React28.createElement(Dialog.Overlay, null), /* @__PURE__ */ React28.createElement(
2954
- Dialog.Content,
2955
- {
2956
- css: {
2957
- w: "min(420px,80%)",
2958
- overflow: "auto",
2959
- p: "$10"
2960
- }
2961
- },
2962
- /* @__PURE__ */ React28.createElement(Flex, { direction: "column" }, /* @__PURE__ */ React28.createElement(PDFHeader, null), /* @__PURE__ */ React28.createElement(
2963
- DialogRow,
2964
- {
2965
- css: {
2966
- fontFamily: "$sans",
2967
- bg: "$surface_bright",
2968
- r: "$1",
2969
- outline: "none",
2970
- border: "1px solid $border_bright",
2971
- p: "$4 $6",
2972
- minHeight: "$11",
2973
- c: "$on_primary_high",
2974
- fs: "$md",
2975
- w: "100%",
2976
- "&:focus": {
2977
- boxShadow: "0 0 0 1px $colors$primary_default",
2978
- border: "1px solid $transparent"
2979
- },
2980
- mb: 0,
2981
- mt: "$6"
2982
- }
2983
- },
2984
- /* @__PURE__ */ React28.createElement(Flex, { direction: "row", css: { flexGrow: "1", maxWidth: "88%" } }, /* @__PURE__ */ React28.createElement(
2985
- Text,
2986
- {
2987
- css: {
2988
- textOverflow: "ellipsis",
2989
- overflow: "hidden",
2990
- whiteSpace: "nowrap"
2991
- }
2992
- },
2993
- fileName
2994
- ), /* @__PURE__ */ React28.createElement(Text, { css: { whiteSpace: "nowrap" } }, ".", ext)),
2995
- /* @__PURE__ */ React28.createElement(
2996
- TrashIcon,
2997
- {
2998
- onClick: () => setPDFFile(null),
2999
- style: {
3000
- cursor: "pointer"
3001
- }
3002
- }
3003
- )
3004
- ), /* @__PURE__ */ React28.createElement(PDFInfo, null), /* @__PURE__ */ React28.createElement(
3005
- SubmitPDF,
3006
- {
3007
- pdfFile,
3008
- pdfURL,
3009
- isValidateProgress,
3010
- setIsPDFUrlValid,
3011
- setIsValidateProgress,
3012
- onOpenChange
3013
- }
3014
- ))
3015
- )));
3016
- };
3017
-
3018
- // src/Prebuilt/components/pdfAnnotator/pdfFileOptions.jsx
3019
- function PDFFileOptions({ onOpenChange }) {
3020
- const [isPDFUrlValid, setIsPDFUrlValid] = useState14(true);
3021
- const [isValidateProgress, setIsValidateProgress] = useState14(false);
3022
- const [pdfFile, setPDFFile] = useState14(null);
3023
- const [pdfURL, setPDFURL] = useState14("");
3024
- return !pdfFile ? /* @__PURE__ */ React29.createElement(Dialog.Root, { defaultOpen: true, onOpenChange }, /* @__PURE__ */ React29.createElement(Dialog.Portal, null, /* @__PURE__ */ React29.createElement(Dialog.Overlay, null), /* @__PURE__ */ React29.createElement(
3025
- Dialog.Content,
3026
- {
3027
- css: {
3028
- w: "min(420px,80%)",
3029
- overflow: "auto",
3030
- p: "$10"
3031
- }
3032
- },
3033
- /* @__PURE__ */ React29.createElement(Flex, { direction: "column" }, /* @__PURE__ */ React29.createElement(PDFHeader, null), /* @__PURE__ */ React29.createElement(
3034
- DialogInputFile,
3035
- {
3036
- onChange: (target) => {
3037
- setPDFFile(target.files[0]);
3038
- },
3039
- placeholder: "Click to upload",
3040
- type: "file",
3041
- accept: ".pdf"
3042
- }
3043
- ), /* @__PURE__ */ React29.createElement(
3044
- DialogRow,
3045
- {
3046
- css: {
3047
- m: "$10 0"
3048
- }
3049
- },
3050
- /* @__PURE__ */ React29.createElement(
3051
- HorizontalDivider,
3052
- {
3053
- css: {
3054
- mr: "$4"
3055
- }
3056
- }
3057
- ),
3058
- /* @__PURE__ */ React29.createElement(
3059
- Text,
3060
- {
3061
- variant: "tiny",
3062
- css: {
3063
- color: "$on_surface_low"
3064
- }
3065
- },
3066
- "OR"
3067
- ),
3068
- /* @__PURE__ */ React29.createElement(
3069
- HorizontalDivider,
3070
- {
3071
- css: {
3072
- ml: "$4"
3073
- }
3074
- }
3075
- )
3076
- ), /* @__PURE__ */ React29.createElement(
3077
- Text,
3078
- {
3079
- variant: "sm",
3080
- css: {
3081
- py: "$2"
3082
- }
3083
- },
3084
- "Import from URL"
3085
- ), /* @__PURE__ */ React29.createElement(
3086
- Input,
3087
- {
3088
- css: { w: "100%", mb: "$10" },
3089
- value: pdfURL,
3090
- onFocus: () => {
3091
- setIsPDFUrlValid(true);
3092
- setIsValidateProgress(false);
3093
- },
3094
- onChange: (e) => {
3095
- setPDFURL(e.target.value);
3096
- },
3097
- placeholder: "Add PDF URL",
3098
- type: "text",
3099
- error: !isPDFUrlValid
3100
- }
3101
- ), !isPDFUrlValid && /* @__PURE__ */ React29.createElement(PdfErrorView, { isPDFUrlValid }), /* @__PURE__ */ React29.createElement(PDFInfo, null), /* @__PURE__ */ React29.createElement(
3102
- SubmitPDF,
3103
- {
3104
- pdfFile,
3105
- pdfURL,
3106
- isValidateProgress,
3107
- setIsPDFUrlValid,
3108
- setIsValidateProgress,
3109
- onOpenChange
3110
- }
3111
- ))
3112
- ))) : /* @__PURE__ */ React29.createElement(
3113
- UploadedFile,
3114
- {
3115
- pdfFile,
3116
- pdfURL,
3117
- isValidateProgress,
3118
- setPDFFile,
3119
- setIsPDFUrlValid,
3120
- setIsValidateProgress,
3121
- onOpenChange
3122
- }
3123
- );
3124
- }
3125
-
3126
- // src/Prebuilt/components/pdfAnnotator/shareScreenOptions.jsx
3127
- var MODALS2 = {
3128
- SHARE: "share",
3129
- SCREEN_SHARE: "screenShare",
3130
- PDF_SHARE: "pdfShare"
3131
- };
3132
- function ShareScreenOptions() {
3133
- const [openModals, setOpenModals] = useState15(/* @__PURE__ */ new Set());
3134
- const { amIScreenSharing } = useScreenShare3();
3135
- const updateState = (modalName, value) => {
3136
- setOpenModals((modals) => {
3137
- const copy = new Set(modals);
3138
- if (value) {
3139
- copy.add(modalName);
3140
- } else {
3141
- copy.delete(modalName);
3142
- }
3143
- return copy;
3144
- });
3145
- };
3146
- const { toggleScreenShare } = useScreenShare3();
3147
- return /* @__PURE__ */ React30.createElement(Fragment4, null, /* @__PURE__ */ React30.createElement(Dropdown.Root, { open: openModals.has(MODALS2.SHARE), onOpenChange: (value) => updateState(MODALS2.SHARE, value) }, /* @__PURE__ */ React30.createElement(Dropdown.Trigger, { asChild: true, "data-testid": "sharing_btn", disabled: amIScreenSharing }, /* @__PURE__ */ React30.createElement(ShareMenuIcon, { disabled: amIScreenSharing }, /* @__PURE__ */ React30.createElement(Tooltip, { title: "Share" }, /* @__PURE__ */ React30.createElement(Box, null, /* @__PURE__ */ React30.createElement(VerticalMenuIcon2, null))))), /* @__PURE__ */ React30.createElement(
3148
- Dropdown.Content,
3149
- {
3150
- sideOffset: 5,
3151
- css: {
3152
- w: "$96",
3153
- maxHeight: "$96",
3154
- p: 0
3155
- }
3156
- },
3157
- /* @__PURE__ */ React30.createElement(
3158
- Dropdown.Item,
3159
- {
3160
- css: {
3161
- flexDirection: "column",
3162
- alignItems: "flex-start",
3163
- px: "$10",
3164
- pt: "$10",
3165
- pb: "$6",
3166
- "&:hover": {
3167
- bg: "$transparent",
3168
- cursor: "default"
3169
- }
3170
- }
3171
- },
3172
- /* @__PURE__ */ React30.createElement(Text, { variant: "h6" }, "Start Sharing"),
3173
- /* @__PURE__ */ React30.createElement(Text, { variant: "sm" }, "Choose what you want to share")
3174
- ),
3175
- /* @__PURE__ */ React30.createElement(
3176
- Dropdown.Item,
3177
- {
3178
- css: {
3179
- flexDirection: "row",
3180
- alignItems: "flex-start",
3181
- gap: "$8",
3182
- px: "$10",
3183
- py: "$6",
3184
- "&:hover": {
3185
- bg: "$transparent",
3186
- cursor: "default"
3187
- }
3188
- }
3189
- },
3190
- /* @__PURE__ */ React30.createElement(
3191
- Flex,
3192
- {
3193
- direction: "column",
3194
- align: "center",
3195
- css: {
3196
- gap: "$6"
3197
- }
3198
- },
3199
- /* @__PURE__ */ React30.createElement(
3200
- IconButton,
3201
- {
3202
- as: "div",
3203
- onClick: () => toggleScreenShare(),
3204
- css: {
3205
- p: "$6",
3206
- display: "flex",
3207
- justifyContent: "center",
3208
- border: "1px solid $border_bright",
3209
- r: "$2",
3210
- bg: "$surface_brighter",
3211
- pb: "0"
3212
- }
3213
- },
3214
- /* @__PURE__ */ React30.createElement(
3215
- ScreenShare,
3216
- {
3217
- width: "100%",
3218
- height: "100%",
3219
- style: {
3220
- borderTopLeftRadius: "$0",
3221
- borderTopRightRadius: "$0"
3222
- }
3223
- }
3224
- )
3225
- ),
3226
- /* @__PURE__ */ React30.createElement(Flex, { direction: "column", align: "center" }, /* @__PURE__ */ React30.createElement(Text, { variant: "body2" }, "Share Screen"), /* @__PURE__ */ React30.createElement(
3227
- Text,
3228
- {
3229
- variant: "caption",
3230
- css: {
3231
- c: "$on_surface_low",
3232
- textAlign: "center"
3233
- }
3234
- },
3235
- "Share your tab, window or your entire screen"
3236
- ))
3237
- ),
3238
- /* @__PURE__ */ React30.createElement(
3239
- Flex,
3240
- {
3241
- direction: "column",
3242
- align: "center",
3243
- css: {
3244
- gap: "$6"
3245
- }
3246
- },
3247
- /* @__PURE__ */ React30.createElement(
3248
- IconButton,
3249
- {
3250
- onClick: () => {
3251
- updateState(MODALS2.PDF_SHARE, true);
3252
- },
3253
- disabled: amIScreenSharing,
3254
- css: {
3255
- p: "$6",
3256
- display: "flex",
3257
- justifyContent: "center",
3258
- border: "$border_bright 1px solid",
3259
- r: "$2",
3260
- bg: "$surface_bright",
3261
- pb: "0"
3262
- }
3263
- },
3264
- /* @__PURE__ */ React30.createElement(
3265
- PdfShare,
3266
- {
3267
- width: "100%",
3268
- height: "100%",
3269
- style: {
3270
- borderTopLeftRadius: "$0",
3271
- borderTopRightRadius: "$0"
3272
- }
3273
- }
3274
- ),
3275
- /* @__PURE__ */ React30.createElement(
3276
- Flex,
3277
- {
3278
- direction: "row",
3279
- align: "center",
3280
- css: {
3281
- position: "absolute",
3282
- top: "29%",
3283
- left: "54%",
3284
- padding: "$2 $4",
3285
- r: "$2",
3286
- bg: "$primary_bright",
3287
- zIndex: "2",
3288
- gap: "$2"
3289
- }
3290
- },
3291
- /* @__PURE__ */ React30.createElement(StarIcon, { height: 14, width: 14 }),
3292
- /* @__PURE__ */ React30.createElement(
3293
- Text,
3294
- {
3295
- variant: "xs",
3296
- css: {
3297
- fontWeight: "$semiBold",
3298
- c: "$on_primary_high",
3299
- pr: "$4"
3300
- }
3301
- },
3302
- "New"
3303
- )
3304
- )
3305
- ),
3306
- /* @__PURE__ */ React30.createElement(Flex, { direction: "column", align: "center" }, /* @__PURE__ */ React30.createElement(Text, { variant: "body2" }, "Share PDF"), /* @__PURE__ */ React30.createElement(
3307
- Text,
3308
- {
3309
- variant: "caption",
3310
- css: {
3311
- c: "$on_surface_low",
3312
- textAlign: "center"
3313
- }
3314
- },
3315
- "Annotate, draw shapes, and more over PDFs"
3316
- ))
3317
- )
3318
- ),
3319
- /* @__PURE__ */ React30.createElement(
3320
- Dropdown.Item,
3321
- {
3322
- css: {
3323
- px: "$10",
3324
- pb: "$10",
3325
- pt: "$6",
3326
- "&:hover": {
3327
- bg: "$transparent",
3328
- cursor: "default"
3329
- }
3330
- }
3331
- },
3332
- /* @__PURE__ */ React30.createElement(
3333
- Button,
3334
- {
3335
- variant: "standard",
3336
- outlined: true,
3337
- type: "submit",
3338
- onClick: () => {
3339
- updateState(MODALS2.SHARE, false);
3340
- },
3341
- "data-testid": "share_btn",
3342
- css: {
3343
- w: "100%"
3344
- }
3345
- },
3346
- "Cancel"
3347
- )
3348
- )
3349
- )), openModals.has(MODALS2.PDF_SHARE) && /* @__PURE__ */ React30.createElement(PDFFileOptions, { onOpenChange: (value) => updateState(MODALS2.PDF_SHARE, value) }));
3350
- }
3351
-
3352
- // src/Prebuilt/components/ScreenShare.jsx
3353
- var ScreenshareToggle = ({ css = {} }) => {
3354
- const isAllowedToPublish = useHMSStore17(selectIsAllowedToPublish2);
3355
- const isAudioOnly = useUISettings(UI_SETTINGS.isAudioOnly);
3356
- const { amIScreenSharing, screenShareVideoTrackId: video, toggleScreenShare } = useScreenShare4();
3357
- const isVideoScreenshare = amIScreenSharing && !!video;
3358
- if (!isAllowedToPublish.screen || !isScreenshareSupported()) {
3359
- return null;
3360
- }
3361
- return /* @__PURE__ */ React31.createElement(Fragment5, null, /* @__PURE__ */ React31.createElement(Flex, { direction: "row" }, /* @__PURE__ */ React31.createElement(
3362
- ScreenShareButton,
3363
- {
3364
- variant: "standard",
3365
- key: "ShareScreen",
3366
- active: !isVideoScreenshare,
3367
- css,
3368
- disabled: isAudioOnly,
3369
- onClick: () => {
3370
- toggleScreenShare();
3371
- }
3372
- },
3373
- /* @__PURE__ */ React31.createElement(Tooltip, { title: `${!isVideoScreenshare ? "Start" : "Stop"} screen sharing` }, /* @__PURE__ */ React31.createElement(Box, null, /* @__PURE__ */ React31.createElement(ShareScreenIcon2, null)))
3374
- ), /* @__PURE__ */ React31.createElement(ShareScreenOptions, null)));
3375
- };
3376
-
3377
- // src/Prebuilt/components/ScreenshareHintModal.jsx
3378
- init_define_process_env();
3379
- import React32 from "react";
3380
- import { useHMSActions as useHMSActions14 } from "@100mslive/react-sdk";
3381
- var ScreenShareHintModal = ({ onClose }) => {
3382
- const hmsActions = useHMSActions14();
3383
- return /* @__PURE__ */ React32.createElement(Dialog.Root, { defaultOpen: true, onOpenChange: (value) => !value && onClose() }, /* @__PURE__ */ React32.createElement(DialogContent, { title: "AudioOnly Screenshare" }, /* @__PURE__ */ React32.createElement(
3384
- "img",
3385
- {
3386
- src: "https://images.app.100ms.live/share-audio.png",
3387
- alt: "AudioOnly Screenshare instructions",
3388
- width: "100%"
3389
- }
3390
- ), /* @__PURE__ */ React32.createElement(DialogRow, { justify: "end" }, /* @__PURE__ */ React32.createElement(
3391
- Button,
3392
- {
3393
- variant: "primary",
3394
- onClick: () => {
3395
- hmsActions.setScreenShareEnabled(true, {
3396
- audioOnly: true,
3397
- displaySurface: "browser"
3398
- }).catch(console.error);
3399
- onClose();
3400
- },
3401
- "data-testid": "audio_screenshare_continue"
3402
- },
3403
- "Continue"
3404
- ))));
3405
- };
3406
-
3407
- // src/Prebuilt/components/Footer/ChatToggle.jsx
3408
- init_define_process_env();
3409
- import React33 from "react";
3410
- import { selectUnreadHMSMessagesCount, useHMSStore as useHMSStore18 } from "@100mslive/react-sdk";
3411
- import { ChatIcon, ChatUnreadIcon } from "@100mslive/react-icons";
3412
- var ChatToggle = () => {
3413
- const countUnreadMessages = useHMSStore18(selectUnreadHMSMessagesCount);
3414
- const isChatOpen = useIsSidepaneTypeOpen(SIDE_PANE_OPTIONS.CHAT);
3415
- const toggleChat = useSidepaneToggle(SIDE_PANE_OPTIONS.CHAT);
3416
- const isFeatureEnabled = useIsFeatureEnabled(FEATURE_LIST.CHAT);
3417
- if (!isFeatureEnabled) {
3418
- return;
3419
- }
3420
- return /* @__PURE__ */ React33.createElement(Tooltip, { key: "chat", title: `${isChatOpen ? "Close" : "Open"} chat` }, /* @__PURE__ */ React33.createElement(IconButton_default, { onClick: toggleChat, active: !isChatOpen, "data-testid": "chat_btn" }, countUnreadMessages === 0 ? /* @__PURE__ */ React33.createElement(ChatIcon, null) : /* @__PURE__ */ React33.createElement(ChatUnreadIcon, { "data-testid": "chat_unread_btn" })));
3421
- };
3422
-
3423
- // src/Prebuilt/components/Footer/ConferencingFooter.jsx
3424
- var TranscriptionButton = React34.lazy(() => import("./transcription-RJA4V6PC.js"));
3425
- var VirtualBackground = React34.lazy(() => import("./VirtualBackground-S3XEPZ2T.js"));
3426
- var ScreenshareAudio = () => {
3427
- const {
3428
- amIScreenSharing,
3429
- screenShareVideoTrackId: video,
3430
- screenShareAudioTrackId: audio,
3431
- toggleScreenShare
3432
- } = useScreenShare5();
3433
- const isAllowedToPublish = useHMSStore19(selectIsAllowedToPublish3);
3434
- const isAudioScreenshare = amIScreenSharing && !video && !!audio;
3435
- const [showModal, setShowModal] = useState16(false);
3436
- const isFeatureEnabled = useIsFeatureEnabled(FEATURE_LIST.AUDIO_ONLY_SCREENSHARE);
3437
- if (!isFeatureEnabled || !isAllowedToPublish.screen || !isScreenshareSupported()) {
3438
- return null;
3439
- }
3440
- return /* @__PURE__ */ React34.createElement(Fragment6, null, /* @__PURE__ */ React34.createElement(Tooltip, { title: `${!isAudioScreenshare ? "Start" : "Stop"} audio sharing`, key: "shareAudio" }, /* @__PURE__ */ React34.createElement(
3441
- IconButton_default,
3442
- {
3443
- active: !isAudioScreenshare,
3444
- onClick: () => {
3445
- if (amIScreenSharing) {
3446
- toggleScreenShare();
3447
- } else {
3448
- setShowModal(true);
3449
- }
3450
- },
3451
- "data-testid": "screenshare_audio"
3452
- },
3453
- /* @__PURE__ */ React34.createElement(MusicIcon, null)
3454
- )), showModal && /* @__PURE__ */ React34.createElement(ScreenShareHintModal, { onClose: () => setShowModal(false) }));
3455
- };
3456
- var ConferencingFooter = () => {
3457
- const isMobile = useMedia6(config.media.md);
3458
- return /* @__PURE__ */ React34.createElement(Footer.Root, null, /* @__PURE__ */ React34.createElement(Footer.Left, null, /* @__PURE__ */ React34.createElement(ScreenshareAudio, null), /* @__PURE__ */ React34.createElement(Suspense2, { fallback: "" }, /* @__PURE__ */ React34.createElement(VirtualBackground, null)), FeatureFlags.enableTranscription ? /* @__PURE__ */ React34.createElement(TranscriptionButton, null) : null, /* @__PURE__ */ React34.createElement(
3459
- Flex,
3460
- {
3461
- align: "center",
3462
- css: {
3463
- display: "none",
3464
- "@md": {
3465
- display: "flex",
3466
- gap: "$8"
3467
- }
3468
- }
3469
- },
3470
- isMobile && /* @__PURE__ */ React34.createElement(EmojiReaction, null),
3471
- /* @__PURE__ */ React34.createElement(MetaActions_default, { isMobile: true })
3472
- )), /* @__PURE__ */ React34.createElement(Footer.Center, null, /* @__PURE__ */ React34.createElement(AudioVideoToggle, null), /* @__PURE__ */ React34.createElement(ScreenshareToggle, null), /* @__PURE__ */ React34.createElement(PIP, null), /* @__PURE__ */ React34.createElement(MoreSettings, null), /* @__PURE__ */ React34.createElement(Flex, { align: "center", css: { display: "none", "@md": { display: "flex" } } }, /* @__PURE__ */ React34.createElement(ChatToggle, null)), /* @__PURE__ */ React34.createElement(LeaveRoom, null)), /* @__PURE__ */ React34.createElement(Footer.Right, null, !isMobile && /* @__PURE__ */ React34.createElement(EmojiReaction, null), /* @__PURE__ */ React34.createElement(MetaActions_default, null), /* @__PURE__ */ React34.createElement(ChatToggle, null)));
3473
- };
3474
-
3475
- // src/Prebuilt/components/Footer/StreamingFooter.jsx
3476
- init_define_process_env();
3477
- import React35 from "react";
3478
- var StreamingFooter = () => {
3479
- return /* @__PURE__ */ React35.createElement(
3480
- Footer.Root,
3481
- {
3482
- css: {
3483
- flexWrap: "nowrap",
3484
- "@md": {
3485
- justifyContent: "center"
3486
- }
3487
- }
3488
- },
3489
- /* @__PURE__ */ React35.createElement(
3490
- Footer.Left,
3491
- {
3492
- css: {
3493
- "@md": {
3494
- w: "unset",
3495
- p: "0"
3496
- }
3497
- }
3498
- },
3499
- /* @__PURE__ */ React35.createElement(AudioVideoToggle, null)
3500
- ),
3501
- /* @__PURE__ */ React35.createElement(
3502
- Footer.Center,
3503
- {
3504
- css: {
3505
- "@md": {
3506
- w: "unset"
3507
- }
3508
- }
3509
- },
3510
- /* @__PURE__ */ React35.createElement(ScreenshareToggle, { css: { "@sm": { display: "none" } } }),
3511
- /* @__PURE__ */ React35.createElement(Box, { css: { "@md": { display: "none" } } }, /* @__PURE__ */ React35.createElement(PIP, null)),
3512
- /* @__PURE__ */ React35.createElement(
3513
- Box,
3514
- {
3515
- css: {
3516
- display: "none",
3517
- "@md": {
3518
- display: "flex",
3519
- alignItems: "center",
3520
- mx: "$4"
3521
- }
3522
- }
3523
- },
3524
- /* @__PURE__ */ React35.createElement(StreamActions, null)
3525
- ),
3526
- /* @__PURE__ */ React35.createElement(MoreSettings, null),
3527
- /* @__PURE__ */ React35.createElement(Box, { css: { "@md": { display: "none" } } }, /* @__PURE__ */ React35.createElement(LeaveRoom, null)),
3528
- /* @__PURE__ */ React35.createElement(Flex, { align: "center", css: { display: "none", "@md": { display: "flex" } } }, /* @__PURE__ */ React35.createElement(ChatToggle, null))
3529
- ),
3530
- /* @__PURE__ */ React35.createElement(Footer.Right, null, /* @__PURE__ */ React35.createElement(EmojiReaction, null), /* @__PURE__ */ React35.createElement(MetaActions_default, null), /* @__PURE__ */ React35.createElement(ChatToggle, null))
3531
- );
3532
- };
3533
-
3534
- // src/Prebuilt/components/Footer.jsx
3535
- var Footer2 = () => {
3536
- return isStreamingKit() ? /* @__PURE__ */ React36.createElement(StreamingFooter, null) : /* @__PURE__ */ React36.createElement(ConferencingFooter, null);
3537
- };
3538
-
3539
- // src/Prebuilt/components/RoleChangeRequestModal.jsx
3540
- init_define_process_env();
3541
- import React37 from "react";
3542
- import { selectRoleChangeRequest, useHMSActions as useHMSActions15, useHMSStore as useHMSStore20 } from "@100mslive/react-sdk";
3543
- var RoleChangeRequestModal = () => {
3544
- var _a, _b;
3545
- const hmsActions = useHMSActions15();
3546
- const isHeadless = useIsHeadless();
3547
- const roleChangeRequest = useHMSStore20(selectRoleChangeRequest);
3548
- if (!(roleChangeRequest == null ? void 0 : roleChangeRequest.role) || isHeadless) {
3549
- return null;
3550
- }
3551
- return /* @__PURE__ */ React37.createElement(
3552
- RequestDialog,
3553
- {
3554
- title: "Role Change Request",
3555
- onOpenChange: (value) => !value && hmsActions.rejectChangeRole(roleChangeRequest),
3556
- body: `${(_a = roleChangeRequest == null ? void 0 : roleChangeRequest.requestedBy) == null ? void 0 : _a.name} has requested you to change your role to ${(_b = roleChangeRequest == null ? void 0 : roleChangeRequest.role) == null ? void 0 : _b.name}.`,
3557
- onAction: () => {
3558
- hmsActions.acceptChangeRole(roleChangeRequest);
3559
- },
3560
- actionText: "Accept"
3561
- }
3562
- );
3563
- };
3564
-
3565
- // src/Prebuilt/components/conference.jsx
3566
- var Conference = () => {
3567
- var _a, _b;
3568
- const navigate = useNavigation();
3569
- const { roomId, role } = useParams();
3570
- const isHeadless = useIsHeadless();
3571
- const roomState = useHMSStore21(selectRoomState);
3572
- const prevState = usePrevious(roomState);
3573
- const isConnectedToRoom = useHMSStore21(selectIsConnectedToRoom2);
3574
- const hmsActions = useHMSActions16();
3575
- const [hideControls, setHideControls] = useState17(false);
3576
- const dropdownList = useHMSStore21(selectAppData3(APP_DATA.dropdownList));
3577
- const skipPreview = useSkipPreview();
3578
- const { showPreview } = useHMSPrebuiltContext();
3579
- const authTokenInAppData = useAuthToken();
3580
- const headerRef = useRef7();
3581
- const footerRef = useRef7();
3582
- const dropdownListRef = useRef7();
3583
- const performAutoHide = hideControls && (isAndroid || isIOS || isIPadOS);
3584
- const [isHLSStarted] = useSetAppDataByKey(APP_DATA.hlsStarted);
3585
- const toggleControls = () => {
3586
- var _a2;
3587
- if (((_a2 = dropdownListRef.current) == null ? void 0 : _a2.length) === 0) {
3588
- setHideControls((value) => !value);
3589
- }
3590
- };
3591
- useEffect9(() => {
3592
- let timeout = null;
3593
- dropdownListRef.current = dropdownList || [];
3594
- if (dropdownListRef.current.length === 0) {
3595
- clearTimeout(timeout);
3596
- timeout = setTimeout(() => {
3597
- if (dropdownListRef.current.length === 0) {
3598
- setHideControls(true);
3599
- }
3600
- }, 5e3);
3601
- }
3602
- return () => {
3603
- clearTimeout(timeout);
3604
- };
3605
- }, [dropdownList, hideControls]);
3606
- useEffect9(() => {
3607
- if (!roomId) {
3608
- navigate(`/`);
3609
- return;
3610
- }
3611
- if (!showPreview) {
3612
- return;
3613
- }
3614
- if (!prevState && !(roomState === HMSRoomState.Connecting || roomState === HMSRoomState.Reconnecting || isConnectedToRoom)) {
3615
- if (role)
3616
- navigate(`/preview/${roomId || ""}/${role}`);
3617
- else
3618
- navigate(`/preview/${roomId || ""}`);
3619
- }
3620
- }, [isConnectedToRoom, prevState, roomState, navigate, role, roomId, showPreview]);
3621
- useEffect9(() => {
3622
- if (authTokenInAppData && !isConnectedToRoom && !showPreview && roomState !== HMSRoomState.Connecting) {
3623
- hmsActions.join({
3624
- userName: "Test",
3625
- authToken: authTokenInAppData,
3626
- initEndpoint: define_process_env_default.REACT_APP_ENV ? `https://${define_process_env_default.REACT_APP_ENV}-init.100ms.live/init` : void 0,
3627
- initialSettings: {
3628
- isAudioMuted: skipPreview,
3629
- isVideoMuted: skipPreview,
3630
- speakerAutoSelectionBlacklist: ["Yeti Stereo Microphone"]
3631
- }
3632
- }).catch(console.error);
3633
- }
3634
- }, [authTokenInAppData, skipPreview, hmsActions, isConnectedToRoom, showPreview, roomState]);
3635
- useEffect9(() => {
3636
- if (isHeadless) {
3637
- hmsActions.ignoreMessageTypes(["chat", EMOJI_REACTION_TYPE]);
3638
- }
3639
- }, [isHeadless, hmsActions]);
3640
- if (!isConnectedToRoom) {
3641
- return /* @__PURE__ */ React38.createElement(FullPageProgress_default, { loadingText: "Joining..." });
3642
- }
3643
- if (isHLSStarted) {
3644
- return /* @__PURE__ */ React38.createElement(FullPageProgress_default, { loadingText: "Starting live stream..." });
3645
- }
3646
- return /* @__PURE__ */ React38.createElement(Flex, { css: { size: "100%", overflow: "hidden" }, direction: "column" }, !isHeadless && /* @__PURE__ */ React38.createElement(
3647
- Box,
3648
- {
3649
- ref: headerRef,
3650
- css: {
3651
- h: "$18",
3652
- transition: "margin 0.3s ease-in-out",
3653
- marginTop: performAutoHide ? `-${(_a = headerRef.current) == null ? void 0 : _a.clientHeight}px` : "none",
3654
- "@md": {
3655
- h: "$17"
3656
- }
3657
- },
3658
- "data-testid": "header"
3659
- },
3660
- /* @__PURE__ */ React38.createElement(Header, null)
3661
- ), /* @__PURE__ */ React38.createElement(
3662
- Box,
3663
- {
3664
- css: {
3665
- w: "100%",
3666
- flex: "1 1 0",
3667
- minHeight: 0,
3668
- paddingBottom: "env(safe-area-inset-bottom)"
3669
- },
3670
- id: "conferencing",
3671
- "data-testid": "conferencing",
3672
- onClick: toggleControls
3673
- },
3674
- /* @__PURE__ */ React38.createElement(ConferenceMainView, null)
3675
- ), !isHeadless && /* @__PURE__ */ React38.createElement(
3676
- Box,
3677
- {
3678
- ref: footerRef,
3679
- css: {
3680
- flexShrink: 0,
3681
- maxHeight: "$24",
3682
- transition: "margin 0.3s ease-in-out",
3683
- marginBottom: performAutoHide ? `-${(_b = footerRef.current) == null ? void 0 : _b.clientHeight}px` : void 0,
3684
- "@md": {
3685
- maxHeight: "unset"
3686
- }
3687
- },
3688
- "data-testid": "footer"
3689
- },
3690
- /* @__PURE__ */ React38.createElement(Footer2, null)
3691
- ), /* @__PURE__ */ React38.createElement(RoleChangeRequestModal, null), /* @__PURE__ */ React38.createElement(HLSFailureModal, null));
3692
- };
3693
- var conference_default = Conference;
3694
- export {
3695
- conference_default as default
3696
- };
3697
- //# sourceMappingURL=conference-7QKOMJPP.js.map