@snapcall/stream-ui 1.26.1 → 1.27.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,18 +1,18 @@
1
1
  import {jsxs as $3Sbms$jsxs, Fragment as $3Sbms$Fragment, jsx as $3Sbms$jsx} from "react/jsx-runtime";
2
2
  import {createRoot as $3Sbms$createRoot} from "react-dom/client";
3
3
  import $3Sbms$bowser, {parse as $3Sbms$parse, getParser as $3Sbms$getParser} from "bowser";
4
+ import {QueryClient as $3Sbms$QueryClient, QueryClientProvider as $3Sbms$QueryClientProvider, useMutation as $3Sbms$useMutation, useQuery as $3Sbms$useQuery, useQueryClient as $3Sbms$useQueryClient} from "@tanstack/react-query";
4
5
  import $3Sbms$reacthottoast, {toast as $3Sbms$toast, Toaster as $3Sbms$Toaster1, ToastBar as $3Sbms$ToastBar} from "react-hot-toast";
5
6
  import $3Sbms$styledcomponents, {keyframes as $3Sbms$keyframes, ThemeProvider as $3Sbms$ThemeProvider, ThemeContext as $3Sbms$ThemeContext, css as $3Sbms$css, createGlobalStyle as $3Sbms$createGlobalStyle} from "styled-components";
6
7
  import {useState as $3Sbms$useState, useRef as $3Sbms$useRef, useCallback as $3Sbms$useCallback, useEffect as $3Sbms$useEffect, useContext as $3Sbms$useContext, useMemo as $3Sbms$useMemo, createContext as $3Sbms$createContext, useReducer as $3Sbms$useReducer, useLayoutEffect as $3Sbms$useLayoutEffect, cloneElement as $3Sbms$cloneElement, forwardRef as $3Sbms$forwardRef} from "react";
7
8
  import {Toaster as $3Sbms$Toaster, UserPlus1Icon as $3Sbms$UserPlus1Icon, PhoneCall1Icon as $3Sbms$PhoneCall1Icon, VideoRecorderIcon as $3Sbms$VideoRecorderIcon, Recording2Icon as $3Sbms$Recording2Icon, Monitor2Icon as $3Sbms$Monitor2Icon, Camera2Icon as $3Sbms$Camera2Icon, Select as $3Sbms$Select, SelectTrigger as $3Sbms$SelectTrigger, SelectValue as $3Sbms$SelectValue, SelectContent as $3Sbms$SelectContent, SelectGroup as $3Sbms$SelectGroup, SelectItem as $3Sbms$SelectItem, useToast as $3Sbms$useToast, Copy5Icon as $3Sbms$Copy5Icon, CheckIcon as $3Sbms$CheckIcon, XCircleIcon as $3Sbms$XCircleIcon, Send3Icon as $3Sbms$Send3Icon, AlertTriangleIcon as $3Sbms$AlertTriangleIcon, Dialog as $3Sbms$Dialog, DialogContent as $3Sbms$DialogContent, DialogHeader as $3Sbms$DialogHeader, DialogTitle as $3Sbms$DialogTitle, Tabs as $3Sbms$Tabs, TabsList as $3Sbms$TabsList, TabsTrigger as $3Sbms$TabsTrigger, TabsContent as $3Sbms$TabsContent, Input as $3Sbms$Input, Button as $3Sbms$Button, CopyIcon as $3Sbms$CopyIcon, Form as $3Sbms$Form, FormField as $3Sbms$FormField, FormItem as $3Sbms$FormItem, FormLabel as $3Sbms$FormLabel, FormControl as $3Sbms$FormControl, CreatableSelect as $3Sbms$CreatableSelect, FormMessage as $3Sbms$FormMessage, Textarea as $3Sbms$Textarea, ToastAction as $3Sbms$ToastAction, InfoCircleIcon as $3Sbms$InfoCircleIcon, FlipBackwardIcon as $3Sbms$FlipBackwardIcon, ArrowUpRightIcon as $3Sbms$ArrowUpRightIcon, RawToast as $3Sbms$RawToast, ToastContent as $3Sbms$ToastContent, QrCode1Icon as $3Sbms$QrCode1Icon, Settings1Icon as $3Sbms$Settings1Icon, Upload1Icon as $3Sbms$Upload1Icon, VolumeMaxIcon as $3Sbms$VolumeMaxIcon, Settings3Icon as $3Sbms$Settings3Icon, XCloseIcon as $3Sbms$XCloseIcon, ArrowLeftIcon as $3Sbms$ArrowLeftIcon, HelpCircleIcon as $3Sbms$HelpCircleIcon, Sheet as $3Sbms$Sheet, DialogTrigger as $3Sbms$DialogTrigger, SheetTrigger as $3Sbms$SheetTrigger, SheetHeader as $3Sbms$SheetHeader, SheetClose as $3Sbms$SheetClose, SheetContent as $3Sbms$SheetContent, SheetTitle as $3Sbms$SheetTitle, DialogDescription as $3Sbms$DialogDescription, SheetDescription as $3Sbms$SheetDescription, SpinnerIcon as $3Sbms$SpinnerIcon, CheckCircleIcon as $3Sbms$CheckCircleIcon, PlusCircleIcon as $3Sbms$PlusCircleIcon, Camera1Icon as $3Sbms$Camera1Icon, PlayIcon as $3Sbms$PlayIcon, Trash3Icon as $3Sbms$Trash3Icon, DialogFooter as $3Sbms$DialogFooter, AlertDialog as $3Sbms$AlertDialog, AlertDialogContent as $3Sbms$AlertDialogContent, AlertDialogHeader as $3Sbms$AlertDialogHeader, AlertDialogTitle as $3Sbms$AlertDialogTitle, AlertDialogDescription as $3Sbms$AlertDialogDescription, AlertDialogFooter as $3Sbms$AlertDialogFooter, AlertDialogCancel as $3Sbms$AlertDialogCancel, AlertDialogAction as $3Sbms$AlertDialogAction, TrashIcon as $3Sbms$TrashIcon, Hourglass3Icon as $3Sbms$Hourglass3Icon, MicrophoneOffIcon as $3Sbms$MicrophoneOffIcon, RefreshCw3Icon as $3Sbms$RefreshCw3Icon, QrCodeIcon as $3Sbms$QrCodeIcon, Avatar as $3Sbms$Avatar, SlashCircle1Icon as $3Sbms$SlashCircle1Icon, CalendarIcon as $3Sbms$CalendarIcon, Microphone1Icon as $3Sbms$Microphone1Icon, VideoRecorderOffIcon as $3Sbms$VideoRecorderOffIcon, MicrophoneOff1Icon as $3Sbms$MicrophoneOff1Icon, AlertCircleIcon as $3Sbms$AlertCircleIcon, Lock1Icon as $3Sbms$Lock1Icon, Lock3Icon as $3Sbms$Lock3Icon, VoicemailIcon as $3Sbms$VoicemailIcon} from "@snapcall/design-system";
8
9
  import "inobounce";
9
- import {QueryClient as $3Sbms$QueryClient, QueryClientProvider as $3Sbms$QueryClientProvider, useMutation as $3Sbms$useMutation, useQuery as $3Sbms$useQuery, useQueryClient as $3Sbms$useQueryClient} from "react-query";
10
10
  import {useTranslation as $3Sbms$useTranslation, initReactI18next as $3Sbms$initReactI18next, Trans as $3Sbms$Trans} from "react-i18next";
11
11
  import $3Sbms$i18next from "i18next";
12
12
  import {useOverlayTriggerState as $3Sbms$useOverlayTriggerState} from "react-stately";
13
13
  import {v4 as $3Sbms$v4} from "uuid";
14
14
  import {WebSocketTransport as $3Sbms$WebSocketTransport, Peer as $3Sbms$Peer} from "protoo-client";
15
- import {addBreadcrumb as $3Sbms$addBreadcrumb, setTag as $3Sbms$setTag} from "@sentry/browser";
15
+ import {captureMessage as $3Sbms$captureMessage, captureException as $3Sbms$captureException, addBreadcrumb as $3Sbms$addBreadcrumb, setTag as $3Sbms$setTag} from "@sentry/browser";
16
16
  import {Producer as $3Sbms$Producer} from "mediasoup-client/lib/Producer";
17
17
  import {Device as $3Sbms$Device} from "mediasoup-client";
18
18
  import {SelfieSegmentation as $3Sbms$SelfieSegmentation} from "@mediapipe/selfie_segmentation";
@@ -30,6 +30,7 @@ function $parcel$interopDefault(a) {
30
30
 
31
31
 
32
32
 
33
+
33
34
  // https://github.com/voodoocreation/ts-deepmerge/blob/master/src/index.ts
34
35
  const $365e765f9890497b$var$isObject = (obj)=>{
35
36
  if (typeof obj === "object" && obj !== null) {
@@ -1070,18 +1071,45 @@ class $107ba89b5d0109ab$export$22ddc20344c01547 {
1070
1071
 
1071
1072
 
1072
1073
 
1074
+ const $8c9dca4cd56e4637$export$8a48322ecc4782be = async (url, streamToken, file)=>{
1075
+ const searchParams = new URLSearchParams({
1076
+ filename: file
1077
+ });
1078
+ const result = await fetch(`${url}/public/streams/${streamToken}/temporary-assets?${searchParams}`, {
1079
+ method: "get",
1080
+ headers: {
1081
+ "Content-Type": "application/json"
1082
+ }
1083
+ }).then((response)=>response.json());
1084
+ return result;
1085
+ };
1086
+ const $8c9dca4cd56e4637$export$df987b50509121ea = async (url, streamToken, file)=>{
1087
+ const searchParams = new URLSearchParams({
1088
+ filename: file
1089
+ });
1090
+ const result = await fetch(`${url}/public/streams/${streamToken}/temporary-assets?${searchParams}`, {
1091
+ method: "delete",
1092
+ headers: {
1093
+ "Content-Type": "application/json"
1094
+ }
1095
+ }).then((response)=>response.json());
1096
+ return result;
1097
+ };
1098
+
1099
+
1073
1100
 
1074
1101
  var $2114f1d49575b676$require$Buffer = $3Sbms$Buffer;
1075
- const $2114f1d49575b676$export$bfc52a1c1f84ba66 = async (apiUrl, { token: token, base64Image: base64Image, session_id: session_id, user_id: user_id, peer_id: peer_id, stepToken: stepToken })=>{
1076
- const filename = `${(0, $3Sbms$v4)()}.jpeg`;
1102
+ const $2114f1d49575b676$export$bfc52a1c1f84ba66 = async (apiUrl, { token: token, base64Image: base64Image })=>{
1103
+ const file = `${(0, $3Sbms$v4)()}.jpeg`;
1077
1104
  const uploadBody = $2114f1d49575b676$require$Buffer.from(String(base64Image).replace(/^data:image\/\w+;base64,/, ""), "base64");
1078
- const { url: url, headers: headers } = await fetch(`${apiUrl}/streams/${token}/snapshot`, {
1105
+ const { url: url, headers: headers, filename: filename } = await fetch(`${apiUrl}/public/streams/${token}/events/upload`, {
1079
1106
  method: "POST",
1080
1107
  headers: {
1081
1108
  "Content-Type": "application/json"
1082
1109
  },
1083
1110
  body: JSON.stringify({
1084
- filename: filename,
1111
+ type: "image",
1112
+ filename: file,
1085
1113
  contentLength: uploadBody.length
1086
1114
  })
1087
1115
  }).then((res)=>res.json());
@@ -1094,22 +1122,10 @@ const $2114f1d49575b676$export$bfc52a1c1f84ba66 = async (apiUrl, { token: token,
1094
1122
  },
1095
1123
  body: uploadBody
1096
1124
  });
1097
- const event = await fetch(`${apiUrl}/public/streams/${token}/snapshot-event`, {
1098
- method: "POST",
1099
- headers: {
1100
- "Content-Type": "application/json"
1101
- },
1102
- body: JSON.stringify({
1103
- stepToken: stepToken,
1104
- filename: filename,
1105
- peer_id: peer_id,
1106
- session_id: session_id,
1107
- user_id: user_id
1108
- })
1109
- }).then((res)=>res.json());
1125
+ const { url: assetUrl } = await (0, $8c9dca4cd56e4637$export$8a48322ecc4782be)(apiUrl, token, filename);
1110
1126
  return {
1111
- url: event.url,
1112
- assetId: event.id
1127
+ filename: filename,
1128
+ url: assetUrl
1113
1129
  };
1114
1130
  };
1115
1131
 
@@ -1135,7 +1151,9 @@ const $120418cdeb6706cf$export$de363e709c412c8a = (fn, wait = 300)=>{
1135
1151
  };
1136
1152
 
1137
1153
 
1138
- const $8042747316a8a88d$export$deda6dde1c58aa97 = async (apiUrl, { file: file, token: token, stepToken: stepToken, sessionId: sessionId, userId: userId, peerId: peerId })=>{
1154
+
1155
+
1156
+ const $07e4bc01ab825269$export$6ad2c48011488f7 = async (apiUrl, { file: file, token: token })=>{
1139
1157
  if (!file) throw new Error(`Missing file on "${file}"`);
1140
1158
  const upload = await fetch(`${apiUrl}/public/streams/${token}/events/upload`, {
1141
1159
  method: "POST",
@@ -1157,23 +1175,27 @@ const $8042747316a8a88d$export$deda6dde1c58aa97 = async (apiUrl, { file: file, t
1157
1175
  },
1158
1176
  body: file
1159
1177
  });
1178
+ const { url: assetUrl } = await (0, $8c9dca4cd56e4637$export$8a48322ecc4782be)(apiUrl, token, filename);
1160
1179
  if (!uploadResponse.ok) throw new Error("Upload failed");
1161
- const type = file.type.split("/")[0];
1162
- const eventRequest = await fetch(`${apiUrl}/public/streams/${token}/events`, {
1180
+ return {
1181
+ filename: filename,
1182
+ url: assetUrl
1183
+ };
1184
+ };
1185
+
1186
+
1187
+ const $7a4afee3d30fe755$export$c30017717ce2168e = async (apiUrl, token, asset)=>{
1188
+ const event = await fetch(`${apiUrl}/public/streams/${token}/events/batch`, {
1163
1189
  method: "POST",
1164
1190
  headers: {
1165
1191
  "Content-Type": "application/json"
1166
1192
  },
1167
1193
  body: JSON.stringify({
1168
- filename: filename,
1169
- type: type,
1170
- stepToken: stepToken,
1171
- session_id: sessionId,
1172
- user_id: userId,
1173
- peer_id: peerId
1194
+ medias: asset
1174
1195
  })
1175
1196
  });
1176
- return eventRequest.json();
1197
+ if (event.ok) return event.json();
1198
+ throw new Error(` request failed ${event.status} `);
1177
1199
  };
1178
1200
 
1179
1201
 
@@ -1181,6 +1203,7 @@ const $c31e3fb4360572af$var$log = new (0, $0f65a9eaf4a1e910$export$2e2bcd8739ae0
1181
1203
  const $c31e3fb4360572af$export$103bedf43ba882db = {
1182
1204
  WEBRTC_FAILED: "WRTC1",
1183
1205
  WEBRTC_RECOVER_ERROR: "WRTC2",
1206
+ WEBRTC_BAD_STATE_ERROR: "WRTC3",
1184
1207
  CREATE_TRANSPORT_FAILED: "TRANS1",
1185
1208
  CONSUME_ERROR: "CONS1",
1186
1209
  SOCKET_LOST: "SOCK1",
@@ -1431,12 +1454,12 @@ class $c31e3fb4360572af$export$2e2bcd8739ae039 extends $c31e3fb4360572af$var$Str
1431
1454
  this.company = company;
1432
1455
  this.permissions = permissions;
1433
1456
  this.defaultPublicPage = defaultPublicPage;
1434
- if (recordings?.headless === true || recordings?.video === true) permissions.push("record_video_on_demand");
1435
1457
  this.plan = name;
1436
1458
  const searchParams = new URLSearchParams({
1437
1459
  peerId: this.peerId,
1438
1460
  clientId: this.clientId,
1439
- roomId: room
1461
+ roomId: room,
1462
+ events: "0"
1440
1463
  });
1441
1464
  if (options.authKey) searchParams.append("authKey", options.authKey);
1442
1465
  const recorderPath = this.joinOptions.recorder ? "/recorder" : "";
@@ -2321,7 +2344,7 @@ class $c31e3fb4360572af$export$2e2bcd8739ae039 extends $c31e3fb4360572af$var$Str
2321
2344
  };
2322
2345
  if (capabilities.focusMode) // https://github.com/w3c/mediacapture-image/blob/main/implementation-status.md
2323
2346
  try {
2324
- track.applyConstraints({
2347
+ await track.applyConstraints({
2325
2348
  advanced: [
2326
2349
  {
2327
2350
  focusMode: "continuous"
@@ -2518,26 +2541,28 @@ class $c31e3fb4360572af$export$2e2bcd8739ae039 extends $c31e3fb4360572af$var$Str
2518
2541
  async saveCapture(base64Image) {
2519
2542
  return (0, $2114f1d49575b676$export$bfc52a1c1f84ba66)(this.config.apiUrl, {
2520
2543
  token: this.roomId,
2521
- base64Image: base64Image,
2522
- peer_id: this.peerId,
2523
- user_id: this.agentIdentity?.id,
2524
- stepToken: this.stepToken
2544
+ base64Image: base64Image
2525
2545
  });
2526
2546
  }
2527
- async uploadEvent(file) {
2528
- return (0, $8042747316a8a88d$export$deda6dde1c58aa97)(this.config.apiUrl, {
2547
+ async uploadAsset(file) {
2548
+ return (0, $07e4bc01ab825269$export$6ad2c48011488f7)(this.config.apiUrl, {
2529
2549
  token: this.roomId,
2530
- file: file,
2531
- peerId: this.peerId,
2532
- userId: this.agentIdentity?.id,
2533
- stepToken: this.stepToken
2550
+ file: file
2534
2551
  });
2535
2552
  }
2536
- async deleteCapture(assetId) {
2537
- const res = await this.protoo?.request("deleteCapture", {
2538
- assetId: assetId
2553
+ createEvents(assets) {
2554
+ const baseEvent = {
2555
+ peer_id: this.peerId,
2556
+ user_id: this.agentIdentity?.id,
2557
+ stepToken: this.stepToken
2558
+ };
2559
+ const events = assets.map((asset)=>{
2560
+ return {
2561
+ ...asset,
2562
+ ...baseEvent
2563
+ };
2539
2564
  });
2540
- return res;
2565
+ return (0, $7a4afee3d30fe755$export$c30017717ce2168e)(this.config.apiUrl, this.roomId, events);
2541
2566
  }
2542
2567
  async captureVideo(videoElement) {
2543
2568
  if (this.permissions.find((permission)=>permission === "instant_picture")) {
@@ -2843,7 +2868,25 @@ class $c31e3fb4360572af$export$2e2bcd8739ae039 extends $c31e3fb4360572af$var$Str
2843
2868
  return this.permissions;
2844
2869
  }
2845
2870
  async startRecord() {
2846
- await this.protoo?.request("startRecord");
2871
+ if (this.micProducer?.rtpSender?.transport?.iceTransport.state !== "connected") try {
2872
+ this.onCriticalError($c31e3fb4360572af$export$103bedf43ba882db.WEBRTC_BAD_STATE_ERROR);
2873
+ const stats = await this.micProducer?.getStats();
2874
+ const dump = {};
2875
+ stats?.forEach((value, key)=>{
2876
+ dump[key] = value;
2877
+ });
2878
+ $3Sbms$captureMessage("Start record in bad state", {
2879
+ contexts: {
2880
+ data: {
2881
+ producerState: this.micProducer?.rtpSender?.transport?.iceTransport?.state,
2882
+ dump: JSON.stringify(dump)
2883
+ }
2884
+ }
2885
+ });
2886
+ } catch (err) {
2887
+ $3Sbms$captureException(err);
2888
+ }
2889
+ await this.protoo?.request("startRecord", this.micProducer?.rtpSender?.transport?.iceTransport.state);
2847
2890
  }
2848
2891
  async stopRecord() {
2849
2892
  await this.protoo?.request("stopRecord");
@@ -2860,6 +2903,12 @@ class $c31e3fb4360572af$export$2e2bcd8739ae039 extends $c31e3fb4360572af$var$Str
2860
2903
  if (!this.protoo) throw new Error("not connected");
2861
2904
  return this.protoo?.request("waitingRequests");
2862
2905
  }
2906
+ readAsset(file) {
2907
+ return (0, $8c9dca4cd56e4637$export$8a48322ecc4782be)(this.config.apiUrl, this.roomId, file);
2908
+ }
2909
+ deleteAsset(file) {
2910
+ return (0, $8c9dca4cd56e4637$export$df987b50509121ea)(this.config.apiUrl, this.roomId, file);
2911
+ }
2863
2912
  }
2864
2913
 
2865
2914
 
@@ -10390,7 +10439,7 @@ const $df41bfe6da05853a$var$EndView = ({ state: state })=>{
10390
10439
  }
10391
10440
  });
10392
10441
  const showFeedback = (state === "ended" || state === "terminated") && !options.apiKey;
10393
- const feedbackSent = sendSessionFeedback.isLoading || sendSessionFeedback.isSuccess || sendSessionFeedback.isError;
10442
+ const feedbackSent = sendSessionFeedback.isPending || sendSessionFeedback.isSuccess || sendSessionFeedback.isError;
10394
10443
  const statesData = {
10395
10444
  ended: {
10396
10445
  title: t("endView.callLeft"),
@@ -11370,21 +11419,21 @@ const $20431dc869bb21e0$export$b3fd96a52c80b3af = ()=>{
11370
11419
  try {
11371
11420
  let url;
11372
11421
  let thumbnailUrl;
11373
- let id;
11422
+ let filename;
11374
11423
  if (type === "image") {
11375
11424
  const dataUrl = await $20431dc869bb21e0$var$fileToDataUrl(file);
11376
11425
  const data = await (0, $c9e496369b59be7a$export$2f377c2162fd02b2).saveCapture(dataUrl);
11377
11426
  url = data.url;
11378
- id = data.assetId;
11427
+ filename = data.filename;
11379
11428
  } else {
11380
- const data = await (0, $c9e496369b59be7a$export$2f377c2162fd02b2).uploadEvent(file);
11429
+ const data = await (0, $c9e496369b59be7a$export$2f377c2162fd02b2).uploadAsset(file);
11381
11430
  url = data.url;
11382
- id = data.id;
11431
+ filename = data.filename;
11383
11432
  if (type === "video") thumbnailUrl = await $20431dc869bb21e0$var$generateVideoThumbnail(file);
11384
- if (!url || !id) throw new Error("upload failed");
11433
+ if (!url || !filename) throw new Error("upload failed");
11385
11434
  }
11386
11435
  addAsset({
11387
- id: id,
11436
+ filename: filename,
11388
11437
  mode: mode,
11389
11438
  url: url,
11390
11439
  thumbnailUrl: thumbnailUrl || url,
@@ -11670,9 +11719,11 @@ const $ea6c91cf7e6319d8$export$20144d37f30919ab = ()=>{
11670
11719
  else if (device.kind === "audiooutput") throw new Error("Audio output not supported");
11671
11720
  throw new Error("Unsupported device info");
11672
11721
  },
11673
- onSettled: ()=>queryClient.invalidateQueries([
11674
- "devicesState"
11675
- ])
11722
+ onSettled: ()=>queryClient.invalidateQueries({
11723
+ queryKey: [
11724
+ "devicesState"
11725
+ ]
11726
+ })
11676
11727
  });
11677
11728
  };
11678
11729
 
@@ -11829,7 +11880,7 @@ const $2ff9d0247afca2f1$export$75b44b566abc4e9c = ()=>{
11829
11880
  className: "bg-gray-50",
11830
11881
  id: "microphone",
11831
11882
  children: /*#__PURE__*/ (0, $3Sbms$jsx)((0, $3Sbms$SelectValue), {
11832
- children: updateDevice.isLoading ? /*#__PURE__*/ (0, $3Sbms$jsx)((0, $3Sbms$Fragment), {
11883
+ children: updateDevice.isPending ? /*#__PURE__*/ (0, $3Sbms$jsx)((0, $3Sbms$Fragment), {
11833
11884
  children: updateDevice.variables?.label
11834
11885
  }) : undefined
11835
11886
  })
@@ -11889,7 +11940,7 @@ const $c00f86b929ef980e$export$40214e6b2a12030d = ()=>{
11889
11940
  id: "camera",
11890
11941
  children: /*#__PURE__*/ (0, $3Sbms$jsx)((0, $3Sbms$SelectValue), {
11891
11942
  placeholder: "/",
11892
- children: updateDevice.isLoading ? /*#__PURE__*/ (0, $3Sbms$jsx)((0, $3Sbms$Fragment), {
11943
+ children: updateDevice.isPending ? /*#__PURE__*/ (0, $3Sbms$jsx)((0, $3Sbms$Fragment), {
11893
11944
  children: updateDevice.variables?.label
11894
11945
  }) : undefined
11895
11946
  })
@@ -12366,7 +12417,6 @@ const $5b15985a93e05fe7$export$e9b744e15e8fe06f = ()=>{
12366
12417
 
12367
12418
 
12368
12419
 
12369
-
12370
12420
  const $701bafa18dab70d0$export$f56b3b5841ad32ae = ({ state: state, mode: mode, url: url })=>{
12371
12421
  const { t: t } = (0, $3Sbms$useTranslation)();
12372
12422
  return /*#__PURE__*/ (0, $3Sbms$jsx)((0, $3Sbms$Dialog), {
@@ -12599,7 +12649,7 @@ const $2e0820b96c3c65d5$export$d70ec5859ea7c9bc = ({ asset: asset, canRemove: ca
12599
12649
  }),
12600
12650
  /*#__PURE__*/ (0, $3Sbms$jsx)((0, $cec166f8085cb2c0$export$520a0918a6dd04fd), {
12601
12651
  state: assetDeleteModalState,
12602
- onDelete: ()=>removeAsset(asset.id)
12652
+ onDelete: ()=>removeAsset(asset.filename)
12603
12653
  }),
12604
12654
  /*#__PURE__*/ (0, $3Sbms$jsxs)("div", {
12605
12655
  className: "flex items-center gap-2.5 p-2 border border-gray-200 rounded-lg",
@@ -12640,7 +12690,7 @@ const $2e0820b96c3c65d5$export$d70ec5859ea7c9bc = ({ asset: asset, canRemove: ca
12640
12690
  })
12641
12691
  })
12642
12692
  ]
12643
- }, asset.id),
12693
+ }, asset.filename),
12644
12694
  asset.mode !== "photo" && /*#__PURE__*/ (0, $3Sbms$jsx)((0, $64dee502cbd6331e$export$1ea93f9eface5983), {
12645
12695
  duration: asset.duration,
12646
12696
  averageAudioLevel: asset.averageAudioLevel
@@ -12651,17 +12701,120 @@ const $2e0820b96c3c65d5$export$d70ec5859ea7c9bc = ({ asset: asset, canRemove: ca
12651
12701
 
12652
12702
 
12653
12703
 
12704
+
12705
+
12706
+ const $a5dd8f67439dd9eb$var$getStoredAssets = async ()=>{
12707
+ try {
12708
+ const storedAssets = JSON.parse(localStorage.getItem("snapcall_assets") || "[]");
12709
+ const assets = await Promise.all(storedAssets.map(async (storedAsset)=>{
12710
+ try {
12711
+ let { url: url, thumbnailUrl: thumbnailUrl } = await (0, $c9e496369b59be7a$export$2f377c2162fd02b2).readAsset(storedAsset.filename);
12712
+ if (url) {
12713
+ if (storedAsset.mode === "photo") thumbnailUrl = url;
12714
+ return {
12715
+ ...storedAsset,
12716
+ url: url,
12717
+ thumbnailUrl: thumbnailUrl
12718
+ };
12719
+ }
12720
+ } catch (error) {
12721
+ $a5dd8f67439dd9eb$export$df987b50509121ea(storedAsset.filename);
12722
+ }
12723
+ }));
12724
+ return assets.filter((asset)=>Boolean(asset?.filename));
12725
+ } catch (err) {}
12726
+ return [];
12727
+ };
12728
+ const $a5dd8f67439dd9eb$export$cfdbe7fcc2578443 = (asset)=>{
12729
+ try {
12730
+ const storedAsset = JSON.parse(localStorage.getItem("snapcall_assets") || "[]");
12731
+ storedAsset.push({
12732
+ ...asset,
12733
+ url: undefined,
12734
+ thumbnailUrl: null
12735
+ });
12736
+ localStorage.setItem("snapcall_assets", JSON.stringify(storedAsset));
12737
+ } catch (err) {}
12738
+ };
12739
+ const $a5dd8f67439dd9eb$export$df987b50509121ea = (filename)=>{
12740
+ try {
12741
+ const storedAsset = JSON.parse(localStorage.getItem("snapcall_assets") || "[]");
12742
+ localStorage.setItem("snapcall_assets", JSON.stringify(storedAsset.filter((asset)=>{
12743
+ return asset.filename !== filename;
12744
+ })));
12745
+ } catch (err) {}
12746
+ };
12747
+ const $a5dd8f67439dd9eb$export$931d641a2a152cf = ()=>{
12748
+ const storedAssets = (0, $3Sbms$useQuery)({
12749
+ queryKey: [
12750
+ "stored-assets"
12751
+ ],
12752
+ queryFn: ()=>$a5dd8f67439dd9eb$var$getStoredAssets(),
12753
+ retry: false,
12754
+ refetchOnMount: false,
12755
+ refetchOnReconnect: false,
12756
+ refetchOnWindowFocus: false,
12757
+ staleTime: Infinity
12758
+ });
12759
+ return storedAssets;
12760
+ };
12761
+
12762
+
12763
+
12764
+
12765
+ const $3ecacdd28d707ec1$var$eventTypes = {
12766
+ screen: "screenshare",
12767
+ photo: "image",
12768
+ video: "video",
12769
+ audio: "audio"
12770
+ };
12654
12771
  const $3ecacdd28d707ec1$export$c01bb29adf88f117 = ({ state: state })=>{
12655
12772
  const { t: t } = (0, $3Sbms$useTranslation)();
12656
12773
  const { assets: assets, incomingAsset: incomingAsset } = (0, $75812785bb101fee$export$2174f25d572f9f31)();
12657
- const [sent, setSent] = (0, $3Sbms$useState)(false);
12774
+ const sendMutation = (0, $3Sbms$useMutation)({
12775
+ mutationFn: async ()=>{
12776
+ try {
12777
+ const events = assets.map((asset)=>{
12778
+ return {
12779
+ filename: asset.filename,
12780
+ type: $3ecacdd28d707ec1$var$eventTypes[asset.mode]
12781
+ };
12782
+ });
12783
+ const results = await (0, $c9e496369b59be7a$export$2f377c2162fd02b2).createEvents(events);
12784
+ let errors = results.filter((result)=>{
12785
+ if (result?.success) {
12786
+ (0, $a5dd8f67439dd9eb$export$df987b50509121ea)(result.filename);
12787
+ return false;
12788
+ }
12789
+ return true;
12790
+ });
12791
+ if (errors.length > 0) {
12792
+ reportError({
12793
+ code: "CRE_EV_1",
12794
+ error: "failed to create assets"
12795
+ });
12796
+ throw new Error("some media not saved");
12797
+ }
12798
+ (0, $c9e496369b59be7a$export$2f377c2162fd02b2).release();
12799
+ return results;
12800
+ } catch (error) {
12801
+ reportError({
12802
+ code: "CRE_EV_1",
12803
+ error: "failed to create assets"
12804
+ });
12805
+ console.log(error);
12806
+ throw error;
12807
+ }
12808
+ }
12809
+ });
12810
+ const reportError = (0, $946223bbb2c552ef$export$5a5695b638d078e7)();
12658
12811
  const isMedium = window.matchMedia("(min-width: 768px)").matches;
12659
12812
  return /*#__PURE__*/ (0, $3Sbms$jsx)((0, $79bae5c9904f9029$export$56d72fe406945300), {
12660
12813
  type: isMedium ? "dialog" : "sheet",
12661
- showClose: !sent,
12814
+ showClose: !sendMutation.isSuccess,
12662
12815
  children: /*#__PURE__*/ (0, $3Sbms$jsx)((0, $79bae5c9904f9029$export$e943710ec76a9465), {
12663
- open: sent ? true : state.isOpen,
12664
- onOpenChange: sent ? ()=>{} : state.setOpen,
12816
+ open: sendMutation.isSuccess ? true : state.isOpen,
12817
+ onOpenChange: sendMutation.isSuccess ? ()=>{} : state.setOpen,
12665
12818
  children: /*#__PURE__*/ (0, $3Sbms$jsxs)((0, $79bae5c9904f9029$export$4cf67c05c32f37ce), {
12666
12819
  className: "w-full max-h-[90vh] overflow-auto",
12667
12820
  children: [
@@ -12669,7 +12822,7 @@ const $3ecacdd28d707ec1$export$c01bb29adf88f117 = ({ state: state })=>{
12669
12822
  children: [
12670
12823
  /*#__PURE__*/ (0, $3Sbms$jsx)((0, $79bae5c9904f9029$export$5e9fc1357420b7eb), {
12671
12824
  className: "text-left flex items-center gap-2",
12672
- children: sent ? /*#__PURE__*/ (0, $3Sbms$jsxs)((0, $3Sbms$Fragment), {
12825
+ children: sendMutation.isSuccess ? /*#__PURE__*/ (0, $3Sbms$jsxs)((0, $3Sbms$Fragment), {
12673
12826
  children: [
12674
12827
  /*#__PURE__*/ (0, $3Sbms$jsx)((0, $3Sbms$CheckCircleIcon), {
12675
12828
  size: 18,
@@ -12684,7 +12837,7 @@ const $3ecacdd28d707ec1$export$c01bb29adf88f117 = ({ state: state })=>{
12684
12837
  count: assets.length
12685
12838
  })
12686
12839
  }),
12687
- sent && /*#__PURE__*/ (0, $3Sbms$jsx)((0, $79bae5c9904f9029$export$51c201eb88940e0f), {
12840
+ sendMutation.isSuccess && /*#__PURE__*/ (0, $3Sbms$jsx)((0, $79bae5c9904f9029$export$51c201eb88940e0f), {
12688
12841
  children: t("recorder.clipSubmissionDescription")
12689
12842
  })
12690
12843
  ]
@@ -12694,8 +12847,8 @@ const $3ecacdd28d707ec1$export$c01bb29adf88f117 = ({ state: state })=>{
12694
12847
  children: [
12695
12848
  assets.map((asset)=>/*#__PURE__*/ (0, $3Sbms$jsx)((0, $2e0820b96c3c65d5$export$d70ec5859ea7c9bc), {
12696
12849
  asset: asset,
12697
- canRemove: !sent
12698
- }, asset.id)),
12850
+ canRemove: !sendMutation.isSuccess
12851
+ }, asset.filename)),
12699
12852
  incomingAsset && /*#__PURE__*/ (0, $3Sbms$jsx)("div", {
12700
12853
  className: "flex items-center justify-center p-2 border border-gray-200 rounded-lg",
12701
12854
  children: /*#__PURE__*/ (0, $3Sbms$jsx)((0, $3Sbms$SpinnerIcon), {
@@ -12703,10 +12856,10 @@ const $3ecacdd28d707ec1$export$c01bb29adf88f117 = ({ state: state })=>{
12703
12856
  className: "text-blue-700 animate-spin"
12704
12857
  })
12705
12858
  }),
12706
- !sent && /*#__PURE__*/ (0, $3Sbms$jsxs)((0, $3Sbms$Button), {
12859
+ /*#__PURE__*/ (0, $3Sbms$jsxs)((0, $3Sbms$Button), {
12707
12860
  className: "mt-1",
12708
12861
  variant: "secondary",
12709
- onClick: state.close,
12862
+ onClick: sendMutation.isSuccess ? ()=>window.location.reload() : state.close,
12710
12863
  children: [
12711
12864
  /*#__PURE__*/ (0, $3Sbms$jsx)((0, $3Sbms$PlusCircleIcon), {
12712
12865
  size: 18
@@ -12717,14 +12870,16 @@ const $3ecacdd28d707ec1$export$c01bb29adf88f117 = ({ state: state })=>{
12717
12870
  })
12718
12871
  ]
12719
12872
  }),
12720
- !sent && /*#__PURE__*/ (0, $3Sbms$jsxs)((0, $3Sbms$Button), {
12873
+ !sendMutation.isSuccess && /*#__PURE__*/ (0, $3Sbms$jsxs)((0, $3Sbms$Button), {
12721
12874
  className: "w-full",
12722
12875
  onClick: ()=>{
12723
- setSent(true);
12724
- (0, $c9e496369b59be7a$export$2f377c2162fd02b2).release();
12876
+ sendMutation.mutate();
12725
12877
  },
12726
12878
  children: [
12727
- /*#__PURE__*/ (0, $3Sbms$jsx)((0, $3Sbms$Send3Icon), {
12879
+ sendMutation.isPending ? /*#__PURE__*/ (0, $3Sbms$jsx)((0, $3Sbms$SpinnerIcon), {
12880
+ size: 24,
12881
+ className: "text-blue-700 animate-spin"
12882
+ }) : /*#__PURE__*/ (0, $3Sbms$jsx)((0, $3Sbms$Send3Icon), {
12728
12883
  size: 18,
12729
12884
  className: "text-white"
12730
12885
  }),
@@ -12907,9 +13062,9 @@ const $24e31aa1532c4049$export$f9da3144ae2525a3 = ()=>{
12907
13062
  openAssetsModal();
12908
13063
  try {
12909
13064
  const image = await (0, $c9e496369b59be7a$export$2f377c2162fd02b2).captureVideo(videoElementRef.current);
12910
- const { url: url, assetId: assetId } = await (0, $c9e496369b59be7a$export$2f377c2162fd02b2).saveCapture(image);
13065
+ const { url: url, filename: filename } = await (0, $c9e496369b59be7a$export$2f377c2162fd02b2).saveCapture(image);
12911
13066
  addAsset({
12912
- id: assetId,
13067
+ filename: filename,
12913
13068
  mode: "photo",
12914
13069
  url: url,
12915
13070
  thumbnailUrl: url,
@@ -13242,12 +13397,12 @@ const $1783de801b9dd149$export$b916fa2db97921a4 = ({ state: state, flow: flow, c
13242
13397
  children: /*#__PURE__*/ (0, $3Sbms$jsxs)((0, $3Sbms$AlertDialogContent), {
13243
13398
  className: "w-[334px] md:w-[334px] rounded-xl max-h-screen overflow-y-auto",
13244
13399
  children: [
13245
- flow.steps?.[0]?.image_url ? /*#__PURE__*/ (0, $3Sbms$jsxs)("div", {
13400
+ flow.steps?.[0]?.config?.image_url ? /*#__PURE__*/ (0, $3Sbms$jsxs)("div", {
13246
13401
  className: "relative rounded-xl",
13247
13402
  children: [
13248
13403
  /*#__PURE__*/ (0, $3Sbms$jsx)("img", {
13249
13404
  className: "w-full h-[200px] object-cover rounded-[inherit]",
13250
- src: flow.steps?.[0]?.image_url,
13405
+ src: flow.steps?.[0]?.config?.image_url,
13251
13406
  alt: ""
13252
13407
  }),
13253
13408
  /*#__PURE__*/ (0, $3Sbms$jsx)("div", {
@@ -13296,7 +13451,7 @@ const $1783de801b9dd149$export$b916fa2db97921a4 = ({ state: state, flow: flow, c
13296
13451
  }),
13297
13452
  /*#__PURE__*/ (0, $3Sbms$jsx)("p", {
13298
13453
  className: "text-sm text-gray-700 whitespace-pre-line",
13299
- children: flow.steps?.[0]?.translation?.description || flow.steps?.[0]?.description
13454
+ children: flow.steps?.[0]?.translation?.description || flow.steps?.[0]?.config?.description
13300
13455
  }),
13301
13456
  /*#__PURE__*/ (0, $3Sbms$jsx)((0, $3Sbms$AlertDialogFooter), {
13302
13457
  children: /*#__PURE__*/ (0, $3Sbms$jsx)((0, $3Sbms$Button), {
@@ -13424,6 +13579,7 @@ const $a272d78208225664$export$54c6bcb39df9c9b9 = ({ state: state, flow: flow })
13424
13579
 
13425
13580
 
13426
13581
 
13582
+
13427
13583
  const $d6943d128e6c8399$var$browser = (0, $3Sbms$bowser).parse(window.navigator.userAgent);
13428
13584
  const $d6943d128e6c8399$export$336a011955157f9a = ()=>{
13429
13585
  const { clientInitResult: clientInitResult, recorderOptions: recorderOptions } = (0, $3Sbms$useContext)((0, $5f30d8bf4f04621e$export$2e2bcd8739ae039));
@@ -13434,10 +13590,10 @@ const $d6943d128e6c8399$export$336a011955157f9a = ()=>{
13434
13590
  const videoRef = (0, $3Sbms$useRef)(null);
13435
13591
  const assetsModalState = (0, $3Sbms$useOverlayTriggerState)({});
13436
13592
  const flowV0ModalState = (0, $3Sbms$useOverlayTriggerState)({
13437
- defaultOpen: Boolean(clientInitResult.flowV0)
13593
+ defaultOpen: Boolean(clientInitResult.flowV0 && !clientInitResult.flow)
13438
13594
  });
13439
13595
  const flowModalState = (0, $3Sbms$useOverlayTriggerState)({
13440
- defaultOpen: clientInitResult.flow && !clientInitResult.flowV0
13596
+ defaultOpen: Boolean(clientInitResult.flow)
13441
13597
  });
13442
13598
  const switchToMobileModalState = (0, $3Sbms$useOverlayTriggerState)({
13443
13599
  defaultOpen: $d6943d128e6c8399$var$browser.platform.type === "desktop" && !clientInitResult.flow && !clientInitResult.flowV0
@@ -13447,16 +13603,31 @@ const $d6943d128e6c8399$export$336a011955157f9a = ()=>{
13447
13603
  const devicesState = (0, $c9e496369b59be7a$export$2f377c2162fd02b2).getDevicesState();
13448
13604
  const hasVideo = devicesState.camera.enabled || devicesState.screenshare.enabled;
13449
13605
  const addAsset = (0, $3Sbms$useCallback)((asset)=>{
13606
+ (0, $a5dd8f67439dd9eb$export$cfdbe7fcc2578443)(asset);
13450
13607
  setAssets((currentAssets)=>[
13451
13608
  ...currentAssets,
13452
13609
  asset
13453
13610
  ]);
13454
13611
  setIncomingAsset(null);
13455
13612
  }, []);
13456
- const removeAsset = async (assetId)=>{
13613
+ const storedAssets = (0, $a5dd8f67439dd9eb$export$931d641a2a152cf)();
13614
+ (0, $3Sbms$useEffect)(()=>{
13615
+ storedAssets.data?.forEach((storedAsset)=>{
13616
+ try {
13617
+ setAssets((currentAssets)=>[
13618
+ ...currentAssets,
13619
+ storedAsset
13620
+ ]);
13621
+ } catch (error) {}
13622
+ });
13623
+ }, [
13624
+ storedAssets.data
13625
+ ]);
13626
+ const removeAsset = async (filename)=>{
13457
13627
  try {
13458
- await (0, $c9e496369b59be7a$export$2f377c2162fd02b2).deleteCapture(assetId);
13459
- setAssets((currentAssets)=>currentAssets.filter((asset)=>asset.id !== assetId));
13628
+ (0, $a5dd8f67439dd9eb$export$df987b50509121ea)(filename);
13629
+ await (0, $c9e496369b59be7a$export$2f377c2162fd02b2).deleteAsset(filename);
13630
+ setAssets((currentAssets)=>currentAssets.filter((asset)=>asset.filename !== filename));
13460
13631
  } catch (error) {
13461
13632
  reportError({
13462
13633
  code: "DEL_CAP_1",
@@ -13465,17 +13636,26 @@ const $d6943d128e6c8399$export$336a011955157f9a = ()=>{
13465
13636
  }
13466
13637
  };
13467
13638
  (0, $3Sbms$useEffect)(()=>{
13468
- const onRecordStopped = (event)=>{
13469
- const { url: url, assetId: assetId } = event.detail;
13639
+ const onRecordStopped = async (event)=>{
13470
13640
  setIsRecording(false);
13471
- if (incomingAsset) {
13641
+ const { filename: filename, durationMs: durationMs, sizeInBytes: sizeInBytes, success: success } = event.detail;
13642
+ const { url: url } = await (0, $c9e496369b59be7a$export$2f377c2162fd02b2).readAsset(filename);
13643
+ const durationSec = durationMs ? Math.round(durationMs / 1000) : undefined;
13644
+ console.log("onRecordStopped", `size: ${sizeInBytes} bytes`, `duration: ${durationSec} sec`);
13645
+ if (!success || sizeInBytes === 0) {
13646
+ setIncomingAsset(null);
13647
+ reportError({
13648
+ code: "REC_4",
13649
+ error: "error in the recording chain"
13650
+ });
13651
+ } else if (incomingAsset) {
13472
13652
  const averageAudioLevel = (0, $c9e496369b59be7a$export$2f377c2162fd02b2).audioLevel?.stopAverageAnalysis();
13473
13653
  addAsset({
13474
- id: assetId,
13654
+ filename: filename,
13475
13655
  mode: incomingAsset.mode,
13476
13656
  url: url,
13477
13657
  thumbnailUrl: incomingAsset.thumbnailUrl,
13478
- duration: Math.round((Date.now() - incomingAsset.createdAt) / 1000),
13658
+ duration: durationSec,
13479
13659
  averageAudioLevel: averageAudioLevel || 0,
13480
13660
  createdAt: incomingAsset.createdAt
13481
13661
  });
@@ -13487,6 +13667,7 @@ const $d6943d128e6c8399$export$336a011955157f9a = ()=>{
13487
13667
  };
13488
13668
  }, [
13489
13669
  addAsset,
13670
+ reportError,
13490
13671
  incomingAsset
13491
13672
  ]);
13492
13673
  (0, $3Sbms$useEffect)(()=>{
@@ -13601,7 +13782,6 @@ const $91d20ee7d2ade85c$export$669f6ea7d267feaf = ()=>{
13601
13782
 
13602
13783
 
13603
13784
 
13604
-
13605
13785
  const $095542f48ed9fed0$export$8d6498a96ae0e73f = ({ className: className, type: type, state: state, onClick: onClick })=>{
13606
13786
  const { t: t } = (0, $3Sbms$useTranslation)();
13607
13787
  const iconEl = type === "camera" ? state === "on" ? /*#__PURE__*/ (0, $3Sbms$jsx)((0, $3Sbms$VideoRecorderIcon), {}) : /*#__PURE__*/ (0, $3Sbms$jsx)((0, $3Sbms$VideoRecorderOffIcon), {}) : state === "on" ? /*#__PURE__*/ (0, $3Sbms$jsx)((0, $3Sbms$Microphone1Icon), {}) : /*#__PURE__*/ (0, $3Sbms$jsx)((0, $3Sbms$MicrophoneOff1Icon), {});
@@ -13868,9 +14048,11 @@ const $8f7af36c0532a6c4$var$GreetingView = ()=>{
13868
14048
  name: ""
13869
14049
  }
13870
14050
  });
13871
- const publicPage = (0, $3Sbms$useQuery)([
13872
- (0, $c9e496369b59be7a$export$2f377c2162fd02b2).defaultPublicPage?.token
13873
- ], ()=>(0, $c9e496369b59be7a$export$2f377c2162fd02b2).getPublicPage((0, $c9e496369b59be7a$export$2f377c2162fd02b2).defaultPublicPage?.token || ""), {
14051
+ const publicPage = (0, $3Sbms$useQuery)({
14052
+ queryKey: [
14053
+ "public-page"
14054
+ ],
14055
+ queryFn: ()=>(0, $c9e496369b59be7a$export$2f377c2162fd02b2).getPublicPage((0, $c9e496369b59be7a$export$2f377c2162fd02b2).defaultPublicPage?.token || ""),
13874
14056
  enabled: Boolean((0, $c9e496369b59be7a$export$2f377c2162fd02b2).defaultPublicPage?.token),
13875
14057
  staleTime: Infinity
13876
14058
  });
@@ -14333,19 +14515,23 @@ const $c6a143d1088045e0$export$ed71079a84f20635 = ()=>{
14333
14515
  });
14334
14516
  const acceptWaitingRequest = (0, $3Sbms$useMutation)({
14335
14517
  mutationFn: (id)=>(0, $c9e496369b59be7a$export$2f377c2162fd02b2).acceptAccessRequest(id),
14336
- onSettled: ()=>queryClient.invalidateQueries([
14337
- "waitingRequests"
14338
- ])
14518
+ onSettled: ()=>queryClient.invalidateQueries({
14519
+ queryKey: [
14520
+ "waitingRequests"
14521
+ ]
14522
+ })
14339
14523
  });
14340
14524
  const denyWaitingRequest = (0, $3Sbms$useMutation)({
14341
14525
  mutationFn: (id)=>(0, $c9e496369b59be7a$export$2f377c2162fd02b2).denyAccessRequest(id),
14342
- onSettled: ()=>queryClient.invalidateQueries([
14343
- "waitingRequests"
14344
- ])
14526
+ onSettled: ()=>queryClient.invalidateQueries({
14527
+ queryKey: [
14528
+ "waitingRequests"
14529
+ ]
14530
+ })
14345
14531
  });
14346
14532
  const hasWaitingRequests = (waitingRequests.data?.length || 0) > 0;
14347
14533
  const firstWaitingRequest = waitingRequests.data?.[0];
14348
- const isProcessingWaitingRequest = acceptWaitingRequest.isLoading || denyWaitingRequest.isLoading;
14534
+ const isProcessingWaitingRequest = acceptWaitingRequest.isPending || denyWaitingRequest.isPending;
14349
14535
  (0, $3Sbms$useEffect)(()=>{
14350
14536
  const onAccessRequest = (event)=>{
14351
14537
  queryClient.setQueryData([
@@ -14432,9 +14618,22 @@ const $c6a143d1088045e0$export$ed71079a84f20635 = ()=>{
14432
14618
  };
14433
14619
 
14434
14620
 
14621
+
14622
+ const $5916a04ef33296ce$export$6bd92120cafe6ad8 = (options = {})=>{
14623
+ return (0, $3Sbms$useQuery)({
14624
+ queryKey: [
14625
+ "dashboard-session"
14626
+ ],
14627
+ queryFn: ()=>fetch(`${"https://app.snapcall.io"}/api/user`, {
14628
+ credentials: "include"
14629
+ }).then((response)=>response.json()),
14630
+ ...options
14631
+ });
14632
+ };
14633
+
14634
+
14435
14635
  const $26ed036cbc17809a$var$currentTheme = (0, $52580db2e49cdd90$export$3bfd0d5209a8006a)();
14436
14636
  const $26ed036cbc17809a$var$currentLanguage = (0, $a3e657fb86ae23f3$export$604ba5624273df44)();
14437
- const $26ed036cbc17809a$var$queryClient = new (0, $3Sbms$QueryClient)();
14438
14637
  let $26ed036cbc17809a$var$timestampCriticalError = -1;
14439
14638
  const $26ed036cbc17809a$var$endViewStates = [
14440
14639
  "ended",
@@ -14442,8 +14641,9 @@ const $26ed036cbc17809a$var$endViewStates = [
14442
14641
  "expired",
14443
14642
  "full"
14444
14643
  ];
14445
- const $26ed036cbc17809a$var$StreamUI = ({ options: options })=>{
14644
+ const $26ed036cbc17809a$var$StreamUI = ({ options: baseOptions })=>{
14446
14645
  const { t: t } = (0, $3Sbms$useTranslation)();
14646
+ const [options, setOptions] = (0, $3Sbms$useState)(baseOptions);
14447
14647
  const [selfPeerId, setSelfPeerId] = (0, $3Sbms$useState)(undefined);
14448
14648
  const streamUIContainerRef = (0, $3Sbms$useRef)(null);
14449
14649
  const videosContainerRef = (0, $3Sbms$useRef)(null);
@@ -14475,6 +14675,14 @@ const $26ed036cbc17809a$var$StreamUI = ({ options: options })=>{
14475
14675
  const [recorderOptions, setRecorderOptions] = (0, $3Sbms$useState)(options.recorder);
14476
14676
  const [clientInitResult, setClientInitResult] = (0, $3Sbms$useState)({});
14477
14677
  const isFirstRender = (0, $648652ea36cc4fd9$export$5964c316e853650f)();
14678
+ const dashboardSession = (0, $5916a04ef33296ce$export$6bd92120cafe6ad8)({
14679
+ enabled: !options.disableSessionFetching,
14680
+ staleTime: Infinity,
14681
+ retry: false,
14682
+ refetchOnMount: false,
14683
+ refetchOnReconnect: false,
14684
+ refetchOnWindowFocus: false
14685
+ });
14478
14686
  const orientation = (containerWidth || window.screen.width) > (containerHeight || window.screen.height) ? "landscape" : "portrait";
14479
14687
  const styledTheme = theme === "dark" ? (0, $52580db2e49cdd90$export$3e936a8db52a10a0) : (0, $52580db2e49cdd90$export$f30cb9bc4f736419);
14480
14688
  const onWebcamUpdate = (event)=>{
@@ -14705,102 +14913,131 @@ const $26ed036cbc17809a$var$StreamUI = ({ options: options })=>{
14705
14913
  recorderOptions,
14706
14914
  t
14707
14915
  ]);
14916
+ const initClient = (uiOptions)=>{
14917
+ if (uiOptions.token) (0, $c9e496369b59be7a$export$2f377c2162fd02b2).init(uiOptions.token, {
14918
+ languageCode: uiOptions.language,
14919
+ flowToken: uiOptions.flowToken,
14920
+ recorder: uiOptions.recorder?.enabled,
14921
+ apiKey: uiOptions.apiKey,
14922
+ email: uiOptions.email,
14923
+ profile: uiOptions.profile,
14924
+ authKey: uiOptions.authKey
14925
+ }).catch((err)=>console.error(err));
14926
+ else setStreamState("expired");
14927
+ };
14708
14928
  (0, $3Sbms$useEffect)(()=>{
14709
- if (isFirstRender) {
14710
- if (options.token) (0, $c9e496369b59be7a$export$2f377c2162fd02b2).init(options.token, {
14711
- languageCode: options.language,
14712
- flowToken: options.flowToken,
14713
- recorder: options.recorder?.enabled,
14714
- apiKey: options.apiKey,
14715
- email: options.email,
14716
- profile: options.profile,
14717
- authKey: options.authKey
14718
- }).catch((err)=>console.error(err));
14719
- else setStreamState("expired");
14720
- }
14929
+ if (isFirstRender && options.disableSessionFetching) initClient(options);
14721
14930
  }, [
14722
14931
  options,
14723
14932
  isFirstRender
14724
14933
  ]);
14725
- return /*#__PURE__*/ (0, $3Sbms$jsx)((0, $3Sbms$QueryClientProvider), {
14726
- client: $26ed036cbc17809a$var$queryClient,
14727
- children: /*#__PURE__*/ (0, $3Sbms$jsx)((0, $5f30d8bf4f04621e$export$2e2bcd8739ae039).Provider, {
14728
- value: {
14729
- videoRecording: videoRecording,
14730
- setVideoRecording: setVideoRecording,
14731
- headless: Boolean(options.headless),
14732
- plan: plan,
14733
- permissions: permissions,
14734
- selfPeerId: selfPeerId,
14735
- streamUIContainerRef: streamUIContainerRef,
14736
- videosContainerRef: videosContainerRef,
14737
- remoteTilesContainerRef: remoteTilesContainerRef,
14738
- streamState: streamState,
14739
- setStreamState: setStreamState,
14740
- isQuickConnectPopupVisible: isQuickConnectPopupVisible,
14741
- setIsQuickConnectPopupVisible: setIsQuickConnectPopupVisible,
14742
- isSettingsMenuVisible: isSettingsMenuVisible,
14743
- setIsSettingsMenuVisible: setIsSettingsMenuVisible,
14744
- isYoutubePopupVisible: isYoutubePopupVisible,
14745
- setIsYoutubePopupVisible: setIsYoutubePopupVisible,
14746
- isLinksharePopupVisible: isLinksharePopupVisible,
14747
- setIsLinksharePopupVisible: setIsLinksharePopupVisible,
14748
- isVirtualBackgroundPopupVisible: isVirtualBackgroundPopupVisible,
14749
- setIsVirtualBackgroundPopupVisible: setIsVirtualBackgroundPopupVisible,
14750
- isBlockedFeaturePopupOpen: isBlockedFeaturePopupOpen,
14751
- setBlockedFeaturePopupOpen: setBlockedFeaturePopupOpen,
14752
- isRecordingStartPopupOpen: isRecordingStartPopupOpen,
14753
- setRecordingStartPopupOpen: setRecordingStartPopupOpen,
14754
- theme: theme,
14755
- setTheme: setTheme,
14756
- language: language,
14757
- setLanguage: setLanguage,
14758
- options: options,
14759
- profile: profile,
14760
- muted: muted,
14761
- streaming: streaming,
14762
- screensharing: screensharing,
14763
- isAgent: isAgent,
14764
- userInteractionTriggered: userInteractionTriggered,
14765
- orientation: orientation,
14766
- clientInitResult: clientInitResult,
14767
- recorderOptions: recorderOptions
14768
- },
14769
- children: /*#__PURE__*/ (0, $3Sbms$jsxs)((0, $3Sbms$ThemeProvider), {
14770
- theme: styledTheme,
14771
- children: [
14772
- /*#__PURE__*/ (0, $3Sbms$jsx)((0, $4fb4815baa04b470$export$20f257fc407da7a3), {}),
14773
- /*#__PURE__*/ (0, $3Sbms$jsx)((0, $d6008ea114507578$export$2e2bcd8739ae039), {}),
14774
- /*#__PURE__*/ (0, $3Sbms$jsxs)((0, $4fb4815baa04b470$export$914ddf2021ea8ee6), {
14775
- ref: streamUIContainerRef,
14776
- children: [
14777
- /*#__PURE__*/ (0, $3Sbms$jsx)((0, $3a42b2ef7646d035$export$2e2bcd8739ae039), {}),
14778
- /*#__PURE__*/ (0, $3Sbms$jsx)((0, $3Sbms$Toaster), {
14779
- duration: 3000,
14780
- className: "gap-2"
14781
- }),
14782
- /*#__PURE__*/ (0, $3Sbms$jsx)((0, $805d92fa41e6e1b0$export$2e2bcd8739ae039), {}),
14783
- isBlockedDevicesPopupOpen && /*#__PURE__*/ (0, $3Sbms$jsx)((0, $6aca0f707e80bf63$export$2e2bcd8739ae039), {
14784
- close: ()=>{
14785
- setUserInteractionTriggered(true);
14786
- setBlockedDevicesPopupOpen(false);
14787
- }
14788
- }),
14789
- streamState === "loading" ? /*#__PURE__*/ (0, $3Sbms$jsx)((0, $91d20ee7d2ade85c$export$669f6ea7d267feaf), {}) : streamState === "greeting" ? /*#__PURE__*/ (0, $3Sbms$jsx)((0, $8f7af36c0532a6c4$export$2e2bcd8739ae039), {}) : streamState === "recorder" ? /*#__PURE__*/ (0, $3Sbms$jsx)((0, $d6943d128e6c8399$export$336a011955157f9a), {}) : streamState === "streaming" ? /*#__PURE__*/ (0, $3Sbms$jsxs)((0, $cce9fd41d8a55a18$export$74636703cfe1eecf), {
14790
- children: [
14791
- /*#__PURE__*/ (0, $3Sbms$jsx)((0, $c6a143d1088045e0$export$ed71079a84f20635), {}),
14792
- /*#__PURE__*/ (0, $3Sbms$jsx)((0, $f235befa4cdc42d6$export$2e2bcd8739ae039), {}),
14793
- /*#__PURE__*/ (0, $3Sbms$jsx)((0, $cdab47bb8796991e$export$2e2bcd8739ae039), {}),
14794
- /*#__PURE__*/ (0, $3Sbms$jsx)((0, $69a9c49ece80e773$export$2e2bcd8739ae039), {}),
14795
- /*#__PURE__*/ (0, $3Sbms$jsx)((0, $01986a58bfba8001$export$2e2bcd8739ae039), {})
14796
- ]
14797
- }) : $26ed036cbc17809a$var$endViewStates.includes(streamState) ? /*#__PURE__*/ (0, $3Sbms$jsx)((0, $df41bfe6da05853a$export$2e2bcd8739ae039), {
14798
- state: streamState
14799
- }) : /*#__PURE__*/ (0, $3Sbms$jsx)((0, $91d20ee7d2ade85c$export$669f6ea7d267feaf), {})
14800
- ]
14801
- })
14802
- ]
14803
- })
14934
+ (0, $3Sbms$useEffect)(()=>{
14935
+ if (dashboardSession.isSuccess || dashboardSession.isError) {
14936
+ const newOptions = {
14937
+ ...options,
14938
+ apiKey: dashboardSession.data?.apiKey || options.apiKey,
14939
+ controls: {
14940
+ ...options.controls,
14941
+ camera: {
14942
+ ...options.controls?.camera,
14943
+ enabled: dashboardSession.data?.settings?.stream?.cameraEnabled ?? options.controls?.camera?.enabled
14944
+ },
14945
+ microphone: {
14946
+ ...options.controls?.microphone,
14947
+ enabled: dashboardSession.data?.settings?.stream?.microphoneEnabled ?? options.controls?.microphone?.enabled
14948
+ }
14949
+ },
14950
+ profile: {
14951
+ name: dashboardSession.data?.name || options.profile?.name,
14952
+ image: dashboardSession.data?.settings?.avatar_url || options.profile?.image
14953
+ }
14954
+ };
14955
+ setOptions(newOptions);
14956
+ if (dashboardSession.data?.settings?.language) setLanguage(dashboardSession.data.settings.language);
14957
+ initClient(newOptions);
14958
+ }
14959
+ // eslint-disable-next-line react-hooks/exhaustive-deps
14960
+ }, [
14961
+ dashboardSession.data,
14962
+ dashboardSession.isSuccess,
14963
+ dashboardSession.isError
14964
+ ]);
14965
+ return /*#__PURE__*/ (0, $3Sbms$jsx)((0, $5f30d8bf4f04621e$export$2e2bcd8739ae039).Provider, {
14966
+ value: {
14967
+ videoRecording: videoRecording,
14968
+ setVideoRecording: setVideoRecording,
14969
+ headless: Boolean(options.headless),
14970
+ plan: plan,
14971
+ permissions: permissions,
14972
+ selfPeerId: selfPeerId,
14973
+ streamUIContainerRef: streamUIContainerRef,
14974
+ videosContainerRef: videosContainerRef,
14975
+ remoteTilesContainerRef: remoteTilesContainerRef,
14976
+ streamState: streamState,
14977
+ setStreamState: setStreamState,
14978
+ isQuickConnectPopupVisible: isQuickConnectPopupVisible,
14979
+ setIsQuickConnectPopupVisible: setIsQuickConnectPopupVisible,
14980
+ isSettingsMenuVisible: isSettingsMenuVisible,
14981
+ setIsSettingsMenuVisible: setIsSettingsMenuVisible,
14982
+ isYoutubePopupVisible: isYoutubePopupVisible,
14983
+ setIsYoutubePopupVisible: setIsYoutubePopupVisible,
14984
+ isLinksharePopupVisible: isLinksharePopupVisible,
14985
+ setIsLinksharePopupVisible: setIsLinksharePopupVisible,
14986
+ isVirtualBackgroundPopupVisible: isVirtualBackgroundPopupVisible,
14987
+ setIsVirtualBackgroundPopupVisible: setIsVirtualBackgroundPopupVisible,
14988
+ isBlockedFeaturePopupOpen: isBlockedFeaturePopupOpen,
14989
+ setBlockedFeaturePopupOpen: setBlockedFeaturePopupOpen,
14990
+ isRecordingStartPopupOpen: isRecordingStartPopupOpen,
14991
+ setRecordingStartPopupOpen: setRecordingStartPopupOpen,
14992
+ theme: theme,
14993
+ setTheme: setTheme,
14994
+ language: language,
14995
+ setLanguage: setLanguage,
14996
+ options: options,
14997
+ profile: profile,
14998
+ muted: muted,
14999
+ streaming: streaming,
15000
+ screensharing: screensharing,
15001
+ isAgent: isAgent,
15002
+ userInteractionTriggered: userInteractionTriggered,
15003
+ orientation: orientation,
15004
+ clientInitResult: clientInitResult,
15005
+ recorderOptions: recorderOptions
15006
+ },
15007
+ children: /*#__PURE__*/ (0, $3Sbms$jsxs)((0, $3Sbms$ThemeProvider), {
15008
+ theme: styledTheme,
15009
+ children: [
15010
+ /*#__PURE__*/ (0, $3Sbms$jsx)((0, $4fb4815baa04b470$export$20f257fc407da7a3), {}),
15011
+ /*#__PURE__*/ (0, $3Sbms$jsx)((0, $d6008ea114507578$export$2e2bcd8739ae039), {}),
15012
+ /*#__PURE__*/ (0, $3Sbms$jsxs)((0, $4fb4815baa04b470$export$914ddf2021ea8ee6), {
15013
+ ref: streamUIContainerRef,
15014
+ children: [
15015
+ /*#__PURE__*/ (0, $3Sbms$jsx)((0, $3a42b2ef7646d035$export$2e2bcd8739ae039), {}),
15016
+ /*#__PURE__*/ (0, $3Sbms$jsx)((0, $3Sbms$Toaster), {
15017
+ duration: 3000,
15018
+ className: "gap-2"
15019
+ }),
15020
+ /*#__PURE__*/ (0, $3Sbms$jsx)((0, $805d92fa41e6e1b0$export$2e2bcd8739ae039), {}),
15021
+ isBlockedDevicesPopupOpen && /*#__PURE__*/ (0, $3Sbms$jsx)((0, $6aca0f707e80bf63$export$2e2bcd8739ae039), {
15022
+ close: ()=>{
15023
+ setUserInteractionTriggered(true);
15024
+ setBlockedDevicesPopupOpen(false);
15025
+ }
15026
+ }),
15027
+ streamState === "loading" ? /*#__PURE__*/ (0, $3Sbms$jsx)((0, $91d20ee7d2ade85c$export$669f6ea7d267feaf), {}) : streamState === "greeting" ? /*#__PURE__*/ (0, $3Sbms$jsx)((0, $8f7af36c0532a6c4$export$2e2bcd8739ae039), {}) : streamState === "recorder" ? /*#__PURE__*/ (0, $3Sbms$jsx)((0, $d6943d128e6c8399$export$336a011955157f9a), {}) : streamState === "streaming" ? /*#__PURE__*/ (0, $3Sbms$jsxs)((0, $cce9fd41d8a55a18$export$74636703cfe1eecf), {
15028
+ children: [
15029
+ /*#__PURE__*/ (0, $3Sbms$jsx)((0, $c6a143d1088045e0$export$ed71079a84f20635), {}),
15030
+ /*#__PURE__*/ (0, $3Sbms$jsx)((0, $f235befa4cdc42d6$export$2e2bcd8739ae039), {}),
15031
+ /*#__PURE__*/ (0, $3Sbms$jsx)((0, $cdab47bb8796991e$export$2e2bcd8739ae039), {}),
15032
+ /*#__PURE__*/ (0, $3Sbms$jsx)((0, $69a9c49ece80e773$export$2e2bcd8739ae039), {}),
15033
+ /*#__PURE__*/ (0, $3Sbms$jsx)((0, $01986a58bfba8001$export$2e2bcd8739ae039), {})
15034
+ ]
15035
+ }) : $26ed036cbc17809a$var$endViewStates.includes(streamState) ? /*#__PURE__*/ (0, $3Sbms$jsx)((0, $df41bfe6da05853a$export$2e2bcd8739ae039), {
15036
+ state: streamState
15037
+ }) : /*#__PURE__*/ (0, $3Sbms$jsx)((0, $91d20ee7d2ade85c$export$669f6ea7d267feaf), {})
15038
+ ]
15039
+ })
15040
+ ]
14804
15041
  })
14805
15042
  });
14806
15043
  };
@@ -14822,6 +15059,7 @@ $e02c50a47b475960$exports = "*, :before, :after {\n box-sizing: border-box;\n
14822
15059
 
14823
15060
 
14824
15061
  const $24075a5d702d64b3$var$browser = (0, $3Sbms$bowser).parse(window.navigator.userAgent);
15062
+ const $24075a5d702d64b3$var$queryClient = new (0, $3Sbms$QueryClient)();
14825
15063
  const $24075a5d702d64b3$var$defaultOptions = {
14826
15064
  headless: false,
14827
15065
  recorder: {
@@ -14918,8 +15156,11 @@ const $24075a5d702d64b3$export$3f94917203ab7078 = {
14918
15156
  rel: "stylesheet",
14919
15157
  href: "https://rsms.me/inter/inter.css"
14920
15158
  }),
14921
- /*#__PURE__*/ (0, $3Sbms$jsx)((0, $26ed036cbc17809a$export$2e2bcd8739ae039), {
14922
- options: mergedOptions
15159
+ /*#__PURE__*/ (0, $3Sbms$jsx)((0, $3Sbms$QueryClientProvider), {
15160
+ client: $24075a5d702d64b3$var$queryClient,
15161
+ children: /*#__PURE__*/ (0, $3Sbms$jsx)((0, $26ed036cbc17809a$export$2e2bcd8739ae039), {
15162
+ options: mergedOptions
15163
+ })
14923
15164
  })
14924
15165
  ]
14925
15166
  }));