sceyt-chat-react-uikit 1.6.9-beta.5 → 1.6.9-beta.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.modern.js CHANGED
@@ -23,8 +23,8 @@ import { useBasicTypeaheadTriggerMatch, LexicalTypeaheadMenuPlugin, MenuOption }
23
23
  import { $createOffsetView } from '@lexical/offset';
24
24
  import { HistoryPlugin } from '@lexical/react/LexicalHistoryPlugin';
25
25
 
26
- /** A function that accepts a potential "extra argument" value to be injected later,
27
- * and returns an instance of the thunk middleware that uses that value
26
+ /** A function that accepts a potential "extra argument" value to be injected later,
27
+ * and returns an instance of the thunk middleware that uses that value
28
28
  */
29
29
  function createThunkMiddleware(extraArgument) {
30
30
  // Standard Redux middleware definition pattern:
@@ -55,523 +55,523 @@ var thunk = createThunkMiddleware(); // Attach the factory function so users can
55
55
 
56
56
  thunk.withExtraArgument = createThunkMiddleware;
57
57
 
58
- var __extends = (undefined && undefined.__extends) || (function () {
59
- var extendStatics = function (d, b) {
60
- extendStatics = Object.setPrototypeOf ||
61
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
62
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
63
- return extendStatics(d, b);
64
- };
65
- return function (d, b) {
66
- if (typeof b !== "function" && b !== null)
67
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
68
- extendStatics(d, b);
69
- function __() { this.constructor = d; }
70
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
71
- };
72
- })();
73
- var __spreadArray = (undefined && undefined.__spreadArray) || function (to, from) {
74
- for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
75
- to[j] = from[i];
76
- return to;
77
- };
78
- var __defProp = Object.defineProperty;
79
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
80
- var __hasOwnProp = Object.prototype.hasOwnProperty;
81
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
82
- var __defNormalProp = function (obj, key, value) { return key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value: value }) : obj[key] = value; };
83
- var __spreadValues = function (a, b) {
84
- for (var prop in b || (b = {}))
85
- if (__hasOwnProp.call(b, prop))
86
- __defNormalProp(a, prop, b[prop]);
87
- if (__getOwnPropSymbols)
88
- for (var _i = 0, _c = __getOwnPropSymbols(b); _i < _c.length; _i++) {
89
- var prop = _c[_i];
90
- if (__propIsEnum.call(b, prop))
91
- __defNormalProp(a, prop, b[prop]);
92
- }
93
- return a;
94
- };
95
- var composeWithDevTools = typeof window !== "undefined" && window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ ? window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ : function () {
96
- if (arguments.length === 0)
97
- return void 0;
98
- if (typeof arguments[0] === "object")
99
- return compose;
100
- return compose.apply(null, arguments);
101
- };
102
- // src/isPlainObject.ts
103
- function isPlainObject(value) {
104
- if (typeof value !== "object" || value === null)
105
- return false;
106
- var proto = Object.getPrototypeOf(value);
107
- if (proto === null)
108
- return true;
109
- var baseProto = proto;
110
- while (Object.getPrototypeOf(baseProto) !== null) {
111
- baseProto = Object.getPrototypeOf(baseProto);
112
- }
113
- return proto === baseProto;
114
- }
115
- // src/tsHelpers.ts
116
- var hasMatchFunction = function (v) {
117
- return v && typeof v.match === "function";
118
- };
119
- function isActionCreator(action) {
120
- return typeof action === "function" && "type" in action && hasMatchFunction(action);
121
- }
122
- // src/actionCreatorInvariantMiddleware.ts
123
- function getMessage(type) {
124
- var splitType = type ? ("" + type).split("/") : [];
125
- var actionName = splitType[splitType.length - 1] || "actionCreator";
126
- return "Detected an action creator with type \"" + (type || "unknown") + "\" being dispatched. \nMake sure you're calling the action creator before dispatching, i.e. `dispatch(" + actionName + "())` instead of `dispatch(" + actionName + ")`. This is necessary even if the action has no payload.";
127
- }
128
- function createActionCreatorInvariantMiddleware(options) {
129
- if (options === void 0) { options = {}; }
130
- if (process.env.NODE_ENV === "production") {
131
- return function () { return function (next) { return function (action) { return next(action); }; }; };
132
- }
133
- var _c = options.isActionCreator, isActionCreator2 = _c === void 0 ? isActionCreator : _c;
134
- return function () { return function (next) { return function (action) {
135
- if (isActionCreator2(action)) {
136
- console.warn(getMessage(action.type));
137
- }
138
- return next(action);
139
- }; }; };
140
- }
141
- function getTimeMeasureUtils(maxDelay, fnName) {
142
- var elapsed = 0;
143
- return {
144
- measureTime: function (fn) {
145
- var started = Date.now();
146
- try {
147
- return fn();
148
- }
149
- finally {
150
- var finished = Date.now();
151
- elapsed += finished - started;
152
- }
153
- },
154
- warnIfExceeded: function () {
155
- if (elapsed > maxDelay) {
156
- console.warn(fnName + " took " + elapsed + "ms, which is more than the warning threshold of " + maxDelay + "ms. \nIf your state or actions are very large, you may want to disable the middleware as it might cause too much of a slowdown in development mode. See https://redux-toolkit.js.org/api/getDefaultMiddleware for instructions.\nIt is disabled in production builds, so you don't need to worry about that.");
157
- }
158
- }
159
- };
160
- }
161
- var MiddlewareArray = /** @class */ (function (_super) {
162
- __extends(MiddlewareArray, _super);
163
- function MiddlewareArray() {
164
- var args = [];
165
- for (var _i = 0; _i < arguments.length; _i++) {
166
- args[_i] = arguments[_i];
167
- }
168
- var _this = _super.apply(this, args) || this;
169
- Object.setPrototypeOf(_this, MiddlewareArray.prototype);
170
- return _this;
171
- }
172
- Object.defineProperty(MiddlewareArray, Symbol.species, {
173
- get: function () {
174
- return MiddlewareArray;
175
- },
176
- enumerable: false,
177
- configurable: true
178
- });
179
- MiddlewareArray.prototype.concat = function () {
180
- var arr = [];
181
- for (var _i = 0; _i < arguments.length; _i++) {
182
- arr[_i] = arguments[_i];
183
- }
184
- return _super.prototype.concat.apply(this, arr);
185
- };
186
- MiddlewareArray.prototype.prepend = function () {
187
- var arr = [];
188
- for (var _i = 0; _i < arguments.length; _i++) {
189
- arr[_i] = arguments[_i];
190
- }
191
- if (arr.length === 1 && Array.isArray(arr[0])) {
192
- return new (MiddlewareArray.bind.apply(MiddlewareArray, __spreadArray([void 0], arr[0].concat(this))))();
193
- }
194
- return new (MiddlewareArray.bind.apply(MiddlewareArray, __spreadArray([void 0], arr.concat(this))))();
195
- };
196
- return MiddlewareArray;
197
- }(Array));
198
- var EnhancerArray = /** @class */ (function (_super) {
199
- __extends(EnhancerArray, _super);
200
- function EnhancerArray() {
201
- var args = [];
202
- for (var _i = 0; _i < arguments.length; _i++) {
203
- args[_i] = arguments[_i];
204
- }
205
- var _this = _super.apply(this, args) || this;
206
- Object.setPrototypeOf(_this, EnhancerArray.prototype);
207
- return _this;
208
- }
209
- Object.defineProperty(EnhancerArray, Symbol.species, {
210
- get: function () {
211
- return EnhancerArray;
212
- },
213
- enumerable: false,
214
- configurable: true
215
- });
216
- EnhancerArray.prototype.concat = function () {
217
- var arr = [];
218
- for (var _i = 0; _i < arguments.length; _i++) {
219
- arr[_i] = arguments[_i];
220
- }
221
- return _super.prototype.concat.apply(this, arr);
222
- };
223
- EnhancerArray.prototype.prepend = function () {
224
- var arr = [];
225
- for (var _i = 0; _i < arguments.length; _i++) {
226
- arr[_i] = arguments[_i];
227
- }
228
- if (arr.length === 1 && Array.isArray(arr[0])) {
229
- return new (EnhancerArray.bind.apply(EnhancerArray, __spreadArray([void 0], arr[0].concat(this))))();
230
- }
231
- return new (EnhancerArray.bind.apply(EnhancerArray, __spreadArray([void 0], arr.concat(this))))();
232
- };
233
- return EnhancerArray;
234
- }(Array));
235
- // src/immutableStateInvariantMiddleware.ts
236
- var isProduction = process.env.NODE_ENV === "production";
237
- var prefix = "Invariant failed";
238
- function invariant(condition, message) {
239
- if (condition) {
240
- return;
241
- }
242
- if (isProduction) {
243
- throw new Error(prefix);
244
- }
245
- throw new Error(prefix + ": " + (message || ""));
246
- }
247
- function stringify(obj, serializer, indent, decycler) {
248
- return JSON.stringify(obj, getSerialize(serializer, decycler), indent);
249
- }
250
- function getSerialize(serializer, decycler) {
251
- var stack = [], keys = [];
252
- if (!decycler)
253
- decycler = function (_, value) {
254
- if (stack[0] === value)
255
- return "[Circular ~]";
256
- return "[Circular ~." + keys.slice(0, stack.indexOf(value)).join(".") + "]";
257
- };
258
- return function (key, value) {
259
- if (stack.length > 0) {
260
- var thisPos = stack.indexOf(this);
261
- ~thisPos ? stack.splice(thisPos + 1) : stack.push(this);
262
- ~thisPos ? keys.splice(thisPos, Infinity, key) : keys.push(key);
263
- if (~stack.indexOf(value))
264
- value = decycler.call(this, key, value);
265
- }
266
- else
267
- stack.push(value);
268
- return serializer == null ? value : serializer.call(this, key, value);
269
- };
270
- }
271
- function isImmutableDefault(value) {
272
- return typeof value !== "object" || value == null || Object.isFrozen(value);
273
- }
274
- function trackForMutations(isImmutable, ignorePaths, obj) {
275
- var trackedProperties = trackProperties(isImmutable, ignorePaths, obj);
276
- return {
277
- detectMutations: function () {
278
- return detectMutations(isImmutable, ignorePaths, trackedProperties, obj);
279
- }
280
- };
281
- }
282
- function trackProperties(isImmutable, ignorePaths, obj, path, checkedObjects) {
283
- if (ignorePaths === void 0) { ignorePaths = []; }
284
- if (path === void 0) { path = ""; }
285
- if (checkedObjects === void 0) { checkedObjects = new Set(); }
286
- var tracked = { value: obj };
287
- if (!isImmutable(obj) && !checkedObjects.has(obj)) {
288
- checkedObjects.add(obj);
289
- tracked.children = {};
290
- for (var key in obj) {
291
- var childPath = path ? path + "." + key : key;
292
- if (ignorePaths.length && ignorePaths.indexOf(childPath) !== -1) {
293
- continue;
294
- }
295
- tracked.children[key] = trackProperties(isImmutable, ignorePaths, obj[key], childPath);
296
- }
297
- }
298
- return tracked;
299
- }
300
- function detectMutations(isImmutable, ignoredPaths, trackedProperty, obj, sameParentRef, path) {
301
- if (ignoredPaths === void 0) { ignoredPaths = []; }
302
- if (sameParentRef === void 0) { sameParentRef = false; }
303
- if (path === void 0) { path = ""; }
304
- var prevObj = trackedProperty ? trackedProperty.value : void 0;
305
- var sameRef = prevObj === obj;
306
- if (sameParentRef && !sameRef && !Number.isNaN(obj)) {
307
- return { wasMutated: true, path: path };
308
- }
309
- if (isImmutable(prevObj) || isImmutable(obj)) {
310
- return { wasMutated: false };
311
- }
312
- var keysToDetect = {};
313
- for (var key in trackedProperty.children) {
314
- keysToDetect[key] = true;
315
- }
316
- for (var key in obj) {
317
- keysToDetect[key] = true;
318
- }
319
- var hasIgnoredPaths = ignoredPaths.length > 0;
320
- var _loop_1 = function (key) {
321
- var nestedPath = path ? path + "." + key : key;
322
- if (hasIgnoredPaths) {
323
- var hasMatches = ignoredPaths.some(function (ignored) {
324
- if (ignored instanceof RegExp) {
325
- return ignored.test(nestedPath);
326
- }
327
- return nestedPath === ignored;
328
- });
329
- if (hasMatches) {
330
- return "continue";
331
- }
332
- }
333
- var result = detectMutations(isImmutable, ignoredPaths, trackedProperty.children[key], obj[key], sameRef, nestedPath);
334
- if (result.wasMutated) {
335
- return { value: result };
336
- }
337
- };
338
- for (var key in keysToDetect) {
339
- var state_1 = _loop_1(key);
340
- if (typeof state_1 === "object")
341
- return state_1.value;
342
- }
343
- return { wasMutated: false };
344
- }
345
- function createImmutableStateInvariantMiddleware(options) {
346
- if (options === void 0) { options = {}; }
347
- if (process.env.NODE_ENV === "production") {
348
- return function () { return function (next) { return function (action) { return next(action); }; }; };
349
- }
350
- var _c = options.isImmutable, isImmutable = _c === void 0 ? isImmutableDefault : _c, ignoredPaths = options.ignoredPaths, _d = options.warnAfter, warnAfter = _d === void 0 ? 32 : _d, ignore = options.ignore;
351
- ignoredPaths = ignoredPaths || ignore;
352
- var track = trackForMutations.bind(null, isImmutable, ignoredPaths);
353
- return function (_c) {
354
- var getState = _c.getState;
355
- var state = getState();
356
- var tracker = track(state);
357
- var result;
358
- return function (next) { return function (action) {
359
- var measureUtils = getTimeMeasureUtils(warnAfter, "ImmutableStateInvariantMiddleware");
360
- measureUtils.measureTime(function () {
361
- state = getState();
362
- result = tracker.detectMutations();
363
- tracker = track(state);
364
- invariant(!result.wasMutated, "A state mutation was detected between dispatches, in the path '" + (result.path || "") + "'. This may cause incorrect behavior. (https://redux.js.org/style-guide/style-guide#do-not-mutate-state)");
365
- });
366
- var dispatchedAction = next(action);
367
- measureUtils.measureTime(function () {
368
- state = getState();
369
- result = tracker.detectMutations();
370
- tracker = track(state);
371
- result.wasMutated && invariant(!result.wasMutated, "A state mutation was detected inside a dispatch, in the path: " + (result.path || "") + ". Take a look at the reducer(s) handling the action " + stringify(action) + ". (https://redux.js.org/style-guide/style-guide#do-not-mutate-state)");
372
- });
373
- measureUtils.warnIfExceeded();
374
- return dispatchedAction;
375
- }; };
376
- };
377
- }
378
- // src/serializableStateInvariantMiddleware.ts
379
- function isPlain(val) {
380
- var type = typeof val;
381
- return val == null || type === "string" || type === "boolean" || type === "number" || Array.isArray(val) || isPlainObject(val);
382
- }
383
- function findNonSerializableValue(value, path, isSerializable, getEntries, ignoredPaths, cache) {
384
- if (path === void 0) { path = ""; }
385
- if (isSerializable === void 0) { isSerializable = isPlain; }
386
- if (ignoredPaths === void 0) { ignoredPaths = []; }
387
- var foundNestedSerializable;
388
- if (!isSerializable(value)) {
389
- return {
390
- keyPath: path || "<root>",
391
- value: value
392
- };
393
- }
394
- if (typeof value !== "object" || value === null) {
395
- return false;
396
- }
397
- if (cache == null ? void 0 : cache.has(value))
398
- return false;
399
- var entries = getEntries != null ? getEntries(value) : Object.entries(value);
400
- var hasIgnoredPaths = ignoredPaths.length > 0;
401
- var _loop_2 = function (key, nestedValue) {
402
- var nestedPath = path ? path + "." + key : key;
403
- if (hasIgnoredPaths) {
404
- var hasMatches = ignoredPaths.some(function (ignored) {
405
- if (ignored instanceof RegExp) {
406
- return ignored.test(nestedPath);
407
- }
408
- return nestedPath === ignored;
409
- });
410
- if (hasMatches) {
411
- return "continue";
412
- }
413
- }
414
- if (!isSerializable(nestedValue)) {
415
- return { value: {
416
- keyPath: nestedPath,
417
- value: nestedValue
418
- } };
419
- }
420
- if (typeof nestedValue === "object") {
421
- foundNestedSerializable = findNonSerializableValue(nestedValue, nestedPath, isSerializable, getEntries, ignoredPaths, cache);
422
- if (foundNestedSerializable) {
423
- return { value: foundNestedSerializable };
424
- }
425
- }
426
- };
427
- for (var _i = 0, entries_1 = entries; _i < entries_1.length; _i++) {
428
- var _c = entries_1[_i], key = _c[0], nestedValue = _c[1];
429
- var state_2 = _loop_2(key, nestedValue);
430
- if (typeof state_2 === "object")
431
- return state_2.value;
432
- }
433
- if (cache && isNestedFrozen(value))
434
- cache.add(value);
435
- return false;
436
- }
437
- function isNestedFrozen(value) {
438
- if (!Object.isFrozen(value))
439
- return false;
440
- for (var _i = 0, _c = Object.values(value); _i < _c.length; _i++) {
441
- var nestedValue = _c[_i];
442
- if (typeof nestedValue !== "object" || nestedValue === null)
443
- continue;
444
- if (!isNestedFrozen(nestedValue))
445
- return false;
446
- }
447
- return true;
448
- }
449
- function createSerializableStateInvariantMiddleware(options) {
450
- if (options === void 0) { options = {}; }
451
- if (process.env.NODE_ENV === "production") {
452
- return function () { return function (next) { return function (action) { return next(action); }; }; };
453
- }
454
- var _c = options.isSerializable, isSerializable = _c === void 0 ? isPlain : _c, getEntries = options.getEntries, _d = options.ignoredActions, ignoredActions = _d === void 0 ? [] : _d, _e = options.ignoredActionPaths, ignoredActionPaths = _e === void 0 ? ["meta.arg", "meta.baseQueryMeta"] : _e, _f = options.ignoredPaths, ignoredPaths = _f === void 0 ? [] : _f, _g = options.warnAfter, warnAfter = _g === void 0 ? 32 : _g, _h = options.ignoreState, ignoreState = _h === void 0 ? false : _h, _j = options.ignoreActions, ignoreActions = _j === void 0 ? false : _j, _k = options.disableCache, disableCache = _k === void 0 ? false : _k;
455
- var cache = !disableCache && WeakSet ? new WeakSet() : void 0;
456
- return function (storeAPI) { return function (next) { return function (action) {
457
- var result = next(action);
458
- var measureUtils = getTimeMeasureUtils(warnAfter, "SerializableStateInvariantMiddleware");
459
- if (!ignoreActions && !(ignoredActions.length && ignoredActions.indexOf(action.type) !== -1)) {
460
- measureUtils.measureTime(function () {
461
- var foundActionNonSerializableValue = findNonSerializableValue(action, "", isSerializable, getEntries, ignoredActionPaths, cache);
462
- if (foundActionNonSerializableValue) {
463
- var keyPath = foundActionNonSerializableValue.keyPath, value = foundActionNonSerializableValue.value;
464
- console.error("A non-serializable value was detected in an action, in the path: `" + keyPath + "`. Value:", value, "\nTake a look at the logic that dispatched this action: ", action, "\n(See https://redux.js.org/faq/actions#why-should-type-be-a-string-or-at-least-serializable-why-should-my-action-types-be-constants)", "\n(To allow non-serializable values see: https://redux-toolkit.js.org/usage/usage-guide#working-with-non-serializable-data)");
465
- }
466
- });
467
- }
468
- if (!ignoreState) {
469
- measureUtils.measureTime(function () {
470
- var state = storeAPI.getState();
471
- var foundStateNonSerializableValue = findNonSerializableValue(state, "", isSerializable, getEntries, ignoredPaths, cache);
472
- if (foundStateNonSerializableValue) {
473
- var keyPath = foundStateNonSerializableValue.keyPath, value = foundStateNonSerializableValue.value;
474
- console.error("A non-serializable value was detected in the state, in the path: `" + keyPath + "`. Value:", value, "\nTake a look at the reducer(s) handling this action type: " + action.type + ".\n(See https://redux.js.org/faq/organizing-state#can-i-put-functions-promises-or-other-non-serializable-items-in-my-store-state)");
475
- }
476
- });
477
- measureUtils.warnIfExceeded();
478
- }
479
- return result;
480
- }; }; };
481
- }
482
- // src/getDefaultMiddleware.ts
483
- function isBoolean(x) {
484
- return typeof x === "boolean";
485
- }
486
- function curryGetDefaultMiddleware() {
487
- return function curriedGetDefaultMiddleware(options) {
488
- return getDefaultMiddleware(options);
489
- };
490
- }
491
- function getDefaultMiddleware(options) {
492
- if (options === void 0) { options = {}; }
493
- var _c = options.thunk, thunk$1 = _c === void 0 ? true : _c, _d = options.immutableCheck, immutableCheck = _d === void 0 ? true : _d, _e = options.serializableCheck, serializableCheck = _e === void 0 ? true : _e, _f = options.actionCreatorCheck, actionCreatorCheck = _f === void 0 ? true : _f;
494
- var middlewareArray = new MiddlewareArray();
495
- if (thunk$1) {
496
- if (isBoolean(thunk$1)) {
497
- middlewareArray.push(thunk);
498
- }
499
- else {
500
- middlewareArray.push(thunk.withExtraArgument(thunk$1.extraArgument));
501
- }
502
- }
503
- if (process.env.NODE_ENV !== "production") {
504
- if (immutableCheck) {
505
- var immutableOptions = {};
506
- if (!isBoolean(immutableCheck)) {
507
- immutableOptions = immutableCheck;
508
- }
509
- middlewareArray.unshift(createImmutableStateInvariantMiddleware(immutableOptions));
510
- }
511
- if (serializableCheck) {
512
- var serializableOptions = {};
513
- if (!isBoolean(serializableCheck)) {
514
- serializableOptions = serializableCheck;
515
- }
516
- middlewareArray.push(createSerializableStateInvariantMiddleware(serializableOptions));
517
- }
518
- if (actionCreatorCheck) {
519
- var actionCreatorOptions = {};
520
- if (!isBoolean(actionCreatorCheck)) {
521
- actionCreatorOptions = actionCreatorCheck;
522
- }
523
- middlewareArray.unshift(createActionCreatorInvariantMiddleware(actionCreatorOptions));
524
- }
525
- }
526
- return middlewareArray;
527
- }
528
- // src/configureStore.ts
529
- var IS_PRODUCTION = process.env.NODE_ENV === "production";
530
- function configureStore(options) {
531
- var curriedGetDefaultMiddleware = curryGetDefaultMiddleware();
532
- var _c = options || {}, _d = _c.reducer, reducer = _d === void 0 ? void 0 : _d, _e = _c.middleware, middleware = _e === void 0 ? curriedGetDefaultMiddleware() : _e, _f = _c.devTools, devTools = _f === void 0 ? true : _f, _g = _c.preloadedState, preloadedState = _g === void 0 ? void 0 : _g, _h = _c.enhancers, enhancers = _h === void 0 ? void 0 : _h;
533
- var rootReducer;
534
- if (typeof reducer === "function") {
535
- rootReducer = reducer;
536
- }
537
- else if (isPlainObject(reducer)) {
538
- rootReducer = combineReducers(reducer);
539
- }
540
- else {
541
- throw new Error('"reducer" is a required argument, and must be a function or an object of functions that can be passed to combineReducers');
542
- }
543
- var finalMiddleware = middleware;
544
- if (typeof finalMiddleware === "function") {
545
- finalMiddleware = finalMiddleware(curriedGetDefaultMiddleware);
546
- if (!IS_PRODUCTION && !Array.isArray(finalMiddleware)) {
547
- throw new Error("when using a middleware builder function, an array of middleware must be returned");
548
- }
549
- }
550
- if (!IS_PRODUCTION && finalMiddleware.some(function (item) { return typeof item !== "function"; })) {
551
- throw new Error("each middleware provided to configureStore must be a function");
552
- }
553
- var middlewareEnhancer = applyMiddleware.apply(void 0, finalMiddleware);
554
- var finalCompose = compose;
555
- if (devTools) {
556
- finalCompose = composeWithDevTools(__spreadValues({
557
- trace: !IS_PRODUCTION
558
- }, typeof devTools === "object" && devTools));
559
- }
560
- var defaultEnhancers = new EnhancerArray(middlewareEnhancer);
561
- var storeEnhancers = defaultEnhancers;
562
- if (Array.isArray(enhancers)) {
563
- storeEnhancers = __spreadArray([middlewareEnhancer], enhancers);
564
- }
565
- else if (typeof enhancers === "function") {
566
- storeEnhancers = enhancers(defaultEnhancers);
567
- }
568
- var composedEnhancer = finalCompose.apply(void 0, storeEnhancers);
569
- return createStore(rootReducer, preloadedState, composedEnhancer);
570
- }
571
- var promise;
572
- var queueMicrotaskShim = typeof queueMicrotask === "function" ? queueMicrotask.bind(typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : globalThis) : function (cb) { return (promise || (promise = Promise.resolve())).then(cb).catch(function (err) { return setTimeout(function () {
573
- throw err;
574
- }, 0); }); };
58
+ var __extends = (undefined && undefined.__extends) || (function () {
59
+ var extendStatics = function (d, b) {
60
+ extendStatics = Object.setPrototypeOf ||
61
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
62
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
63
+ return extendStatics(d, b);
64
+ };
65
+ return function (d, b) {
66
+ if (typeof b !== "function" && b !== null)
67
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
68
+ extendStatics(d, b);
69
+ function __() { this.constructor = d; }
70
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
71
+ };
72
+ })();
73
+ var __spreadArray = (undefined && undefined.__spreadArray) || function (to, from) {
74
+ for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
75
+ to[j] = from[i];
76
+ return to;
77
+ };
78
+ var __defProp = Object.defineProperty;
79
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
80
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
81
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
82
+ var __defNormalProp = function (obj, key, value) { return key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value: value }) : obj[key] = value; };
83
+ var __spreadValues = function (a, b) {
84
+ for (var prop in b || (b = {}))
85
+ if (__hasOwnProp.call(b, prop))
86
+ __defNormalProp(a, prop, b[prop]);
87
+ if (__getOwnPropSymbols)
88
+ for (var _i = 0, _c = __getOwnPropSymbols(b); _i < _c.length; _i++) {
89
+ var prop = _c[_i];
90
+ if (__propIsEnum.call(b, prop))
91
+ __defNormalProp(a, prop, b[prop]);
92
+ }
93
+ return a;
94
+ };
95
+ var composeWithDevTools = typeof window !== "undefined" && window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ ? window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ : function () {
96
+ if (arguments.length === 0)
97
+ return void 0;
98
+ if (typeof arguments[0] === "object")
99
+ return compose;
100
+ return compose.apply(null, arguments);
101
+ };
102
+ // src/isPlainObject.ts
103
+ function isPlainObject(value) {
104
+ if (typeof value !== "object" || value === null)
105
+ return false;
106
+ var proto = Object.getPrototypeOf(value);
107
+ if (proto === null)
108
+ return true;
109
+ var baseProto = proto;
110
+ while (Object.getPrototypeOf(baseProto) !== null) {
111
+ baseProto = Object.getPrototypeOf(baseProto);
112
+ }
113
+ return proto === baseProto;
114
+ }
115
+ // src/tsHelpers.ts
116
+ var hasMatchFunction = function (v) {
117
+ return v && typeof v.match === "function";
118
+ };
119
+ function isActionCreator(action) {
120
+ return typeof action === "function" && "type" in action && hasMatchFunction(action);
121
+ }
122
+ // src/actionCreatorInvariantMiddleware.ts
123
+ function getMessage(type) {
124
+ var splitType = type ? ("" + type).split("/") : [];
125
+ var actionName = splitType[splitType.length - 1] || "actionCreator";
126
+ return "Detected an action creator with type \"" + (type || "unknown") + "\" being dispatched. \nMake sure you're calling the action creator before dispatching, i.e. `dispatch(" + actionName + "())` instead of `dispatch(" + actionName + ")`. This is necessary even if the action has no payload.";
127
+ }
128
+ function createActionCreatorInvariantMiddleware(options) {
129
+ if (options === void 0) { options = {}; }
130
+ if (process.env.NODE_ENV === "production") {
131
+ return function () { return function (next) { return function (action) { return next(action); }; }; };
132
+ }
133
+ var _c = options.isActionCreator, isActionCreator2 = _c === void 0 ? isActionCreator : _c;
134
+ return function () { return function (next) { return function (action) {
135
+ if (isActionCreator2(action)) {
136
+ console.warn(getMessage(action.type));
137
+ }
138
+ return next(action);
139
+ }; }; };
140
+ }
141
+ function getTimeMeasureUtils(maxDelay, fnName) {
142
+ var elapsed = 0;
143
+ return {
144
+ measureTime: function (fn) {
145
+ var started = Date.now();
146
+ try {
147
+ return fn();
148
+ }
149
+ finally {
150
+ var finished = Date.now();
151
+ elapsed += finished - started;
152
+ }
153
+ },
154
+ warnIfExceeded: function () {
155
+ if (elapsed > maxDelay) {
156
+ console.warn(fnName + " took " + elapsed + "ms, which is more than the warning threshold of " + maxDelay + "ms. \nIf your state or actions are very large, you may want to disable the middleware as it might cause too much of a slowdown in development mode. See https://redux-toolkit.js.org/api/getDefaultMiddleware for instructions.\nIt is disabled in production builds, so you don't need to worry about that.");
157
+ }
158
+ }
159
+ };
160
+ }
161
+ var MiddlewareArray = /** @class */ (function (_super) {
162
+ __extends(MiddlewareArray, _super);
163
+ function MiddlewareArray() {
164
+ var args = [];
165
+ for (var _i = 0; _i < arguments.length; _i++) {
166
+ args[_i] = arguments[_i];
167
+ }
168
+ var _this = _super.apply(this, args) || this;
169
+ Object.setPrototypeOf(_this, MiddlewareArray.prototype);
170
+ return _this;
171
+ }
172
+ Object.defineProperty(MiddlewareArray, Symbol.species, {
173
+ get: function () {
174
+ return MiddlewareArray;
175
+ },
176
+ enumerable: false,
177
+ configurable: true
178
+ });
179
+ MiddlewareArray.prototype.concat = function () {
180
+ var arr = [];
181
+ for (var _i = 0; _i < arguments.length; _i++) {
182
+ arr[_i] = arguments[_i];
183
+ }
184
+ return _super.prototype.concat.apply(this, arr);
185
+ };
186
+ MiddlewareArray.prototype.prepend = function () {
187
+ var arr = [];
188
+ for (var _i = 0; _i < arguments.length; _i++) {
189
+ arr[_i] = arguments[_i];
190
+ }
191
+ if (arr.length === 1 && Array.isArray(arr[0])) {
192
+ return new (MiddlewareArray.bind.apply(MiddlewareArray, __spreadArray([void 0], arr[0].concat(this))))();
193
+ }
194
+ return new (MiddlewareArray.bind.apply(MiddlewareArray, __spreadArray([void 0], arr.concat(this))))();
195
+ };
196
+ return MiddlewareArray;
197
+ }(Array));
198
+ var EnhancerArray = /** @class */ (function (_super) {
199
+ __extends(EnhancerArray, _super);
200
+ function EnhancerArray() {
201
+ var args = [];
202
+ for (var _i = 0; _i < arguments.length; _i++) {
203
+ args[_i] = arguments[_i];
204
+ }
205
+ var _this = _super.apply(this, args) || this;
206
+ Object.setPrototypeOf(_this, EnhancerArray.prototype);
207
+ return _this;
208
+ }
209
+ Object.defineProperty(EnhancerArray, Symbol.species, {
210
+ get: function () {
211
+ return EnhancerArray;
212
+ },
213
+ enumerable: false,
214
+ configurable: true
215
+ });
216
+ EnhancerArray.prototype.concat = function () {
217
+ var arr = [];
218
+ for (var _i = 0; _i < arguments.length; _i++) {
219
+ arr[_i] = arguments[_i];
220
+ }
221
+ return _super.prototype.concat.apply(this, arr);
222
+ };
223
+ EnhancerArray.prototype.prepend = function () {
224
+ var arr = [];
225
+ for (var _i = 0; _i < arguments.length; _i++) {
226
+ arr[_i] = arguments[_i];
227
+ }
228
+ if (arr.length === 1 && Array.isArray(arr[0])) {
229
+ return new (EnhancerArray.bind.apply(EnhancerArray, __spreadArray([void 0], arr[0].concat(this))))();
230
+ }
231
+ return new (EnhancerArray.bind.apply(EnhancerArray, __spreadArray([void 0], arr.concat(this))))();
232
+ };
233
+ return EnhancerArray;
234
+ }(Array));
235
+ // src/immutableStateInvariantMiddleware.ts
236
+ var isProduction = process.env.NODE_ENV === "production";
237
+ var prefix = "Invariant failed";
238
+ function invariant(condition, message) {
239
+ if (condition) {
240
+ return;
241
+ }
242
+ if (isProduction) {
243
+ throw new Error(prefix);
244
+ }
245
+ throw new Error(prefix + ": " + (message || ""));
246
+ }
247
+ function stringify(obj, serializer, indent, decycler) {
248
+ return JSON.stringify(obj, getSerialize(serializer, decycler), indent);
249
+ }
250
+ function getSerialize(serializer, decycler) {
251
+ var stack = [], keys = [];
252
+ if (!decycler)
253
+ decycler = function (_, value) {
254
+ if (stack[0] === value)
255
+ return "[Circular ~]";
256
+ return "[Circular ~." + keys.slice(0, stack.indexOf(value)).join(".") + "]";
257
+ };
258
+ return function (key, value) {
259
+ if (stack.length > 0) {
260
+ var thisPos = stack.indexOf(this);
261
+ ~thisPos ? stack.splice(thisPos + 1) : stack.push(this);
262
+ ~thisPos ? keys.splice(thisPos, Infinity, key) : keys.push(key);
263
+ if (~stack.indexOf(value))
264
+ value = decycler.call(this, key, value);
265
+ }
266
+ else
267
+ stack.push(value);
268
+ return serializer == null ? value : serializer.call(this, key, value);
269
+ };
270
+ }
271
+ function isImmutableDefault(value) {
272
+ return typeof value !== "object" || value == null || Object.isFrozen(value);
273
+ }
274
+ function trackForMutations(isImmutable, ignorePaths, obj) {
275
+ var trackedProperties = trackProperties(isImmutable, ignorePaths, obj);
276
+ return {
277
+ detectMutations: function () {
278
+ return detectMutations(isImmutable, ignorePaths, trackedProperties, obj);
279
+ }
280
+ };
281
+ }
282
+ function trackProperties(isImmutable, ignorePaths, obj, path, checkedObjects) {
283
+ if (ignorePaths === void 0) { ignorePaths = []; }
284
+ if (path === void 0) { path = ""; }
285
+ if (checkedObjects === void 0) { checkedObjects = new Set(); }
286
+ var tracked = { value: obj };
287
+ if (!isImmutable(obj) && !checkedObjects.has(obj)) {
288
+ checkedObjects.add(obj);
289
+ tracked.children = {};
290
+ for (var key in obj) {
291
+ var childPath = path ? path + "." + key : key;
292
+ if (ignorePaths.length && ignorePaths.indexOf(childPath) !== -1) {
293
+ continue;
294
+ }
295
+ tracked.children[key] = trackProperties(isImmutable, ignorePaths, obj[key], childPath);
296
+ }
297
+ }
298
+ return tracked;
299
+ }
300
+ function detectMutations(isImmutable, ignoredPaths, trackedProperty, obj, sameParentRef, path) {
301
+ if (ignoredPaths === void 0) { ignoredPaths = []; }
302
+ if (sameParentRef === void 0) { sameParentRef = false; }
303
+ if (path === void 0) { path = ""; }
304
+ var prevObj = trackedProperty ? trackedProperty.value : void 0;
305
+ var sameRef = prevObj === obj;
306
+ if (sameParentRef && !sameRef && !Number.isNaN(obj)) {
307
+ return { wasMutated: true, path: path };
308
+ }
309
+ if (isImmutable(prevObj) || isImmutable(obj)) {
310
+ return { wasMutated: false };
311
+ }
312
+ var keysToDetect = {};
313
+ for (var key in trackedProperty.children) {
314
+ keysToDetect[key] = true;
315
+ }
316
+ for (var key in obj) {
317
+ keysToDetect[key] = true;
318
+ }
319
+ var hasIgnoredPaths = ignoredPaths.length > 0;
320
+ var _loop_1 = function (key) {
321
+ var nestedPath = path ? path + "." + key : key;
322
+ if (hasIgnoredPaths) {
323
+ var hasMatches = ignoredPaths.some(function (ignored) {
324
+ if (ignored instanceof RegExp) {
325
+ return ignored.test(nestedPath);
326
+ }
327
+ return nestedPath === ignored;
328
+ });
329
+ if (hasMatches) {
330
+ return "continue";
331
+ }
332
+ }
333
+ var result = detectMutations(isImmutable, ignoredPaths, trackedProperty.children[key], obj[key], sameRef, nestedPath);
334
+ if (result.wasMutated) {
335
+ return { value: result };
336
+ }
337
+ };
338
+ for (var key in keysToDetect) {
339
+ var state_1 = _loop_1(key);
340
+ if (typeof state_1 === "object")
341
+ return state_1.value;
342
+ }
343
+ return { wasMutated: false };
344
+ }
345
+ function createImmutableStateInvariantMiddleware(options) {
346
+ if (options === void 0) { options = {}; }
347
+ if (process.env.NODE_ENV === "production") {
348
+ return function () { return function (next) { return function (action) { return next(action); }; }; };
349
+ }
350
+ var _c = options.isImmutable, isImmutable = _c === void 0 ? isImmutableDefault : _c, ignoredPaths = options.ignoredPaths, _d = options.warnAfter, warnAfter = _d === void 0 ? 32 : _d, ignore = options.ignore;
351
+ ignoredPaths = ignoredPaths || ignore;
352
+ var track = trackForMutations.bind(null, isImmutable, ignoredPaths);
353
+ return function (_c) {
354
+ var getState = _c.getState;
355
+ var state = getState();
356
+ var tracker = track(state);
357
+ var result;
358
+ return function (next) { return function (action) {
359
+ var measureUtils = getTimeMeasureUtils(warnAfter, "ImmutableStateInvariantMiddleware");
360
+ measureUtils.measureTime(function () {
361
+ state = getState();
362
+ result = tracker.detectMutations();
363
+ tracker = track(state);
364
+ invariant(!result.wasMutated, "A state mutation was detected between dispatches, in the path '" + (result.path || "") + "'. This may cause incorrect behavior. (https://redux.js.org/style-guide/style-guide#do-not-mutate-state)");
365
+ });
366
+ var dispatchedAction = next(action);
367
+ measureUtils.measureTime(function () {
368
+ state = getState();
369
+ result = tracker.detectMutations();
370
+ tracker = track(state);
371
+ result.wasMutated && invariant(!result.wasMutated, "A state mutation was detected inside a dispatch, in the path: " + (result.path || "") + ". Take a look at the reducer(s) handling the action " + stringify(action) + ". (https://redux.js.org/style-guide/style-guide#do-not-mutate-state)");
372
+ });
373
+ measureUtils.warnIfExceeded();
374
+ return dispatchedAction;
375
+ }; };
376
+ };
377
+ }
378
+ // src/serializableStateInvariantMiddleware.ts
379
+ function isPlain(val) {
380
+ var type = typeof val;
381
+ return val == null || type === "string" || type === "boolean" || type === "number" || Array.isArray(val) || isPlainObject(val);
382
+ }
383
+ function findNonSerializableValue(value, path, isSerializable, getEntries, ignoredPaths, cache) {
384
+ if (path === void 0) { path = ""; }
385
+ if (isSerializable === void 0) { isSerializable = isPlain; }
386
+ if (ignoredPaths === void 0) { ignoredPaths = []; }
387
+ var foundNestedSerializable;
388
+ if (!isSerializable(value)) {
389
+ return {
390
+ keyPath: path || "<root>",
391
+ value: value
392
+ };
393
+ }
394
+ if (typeof value !== "object" || value === null) {
395
+ return false;
396
+ }
397
+ if (cache == null ? void 0 : cache.has(value))
398
+ return false;
399
+ var entries = getEntries != null ? getEntries(value) : Object.entries(value);
400
+ var hasIgnoredPaths = ignoredPaths.length > 0;
401
+ var _loop_2 = function (key, nestedValue) {
402
+ var nestedPath = path ? path + "." + key : key;
403
+ if (hasIgnoredPaths) {
404
+ var hasMatches = ignoredPaths.some(function (ignored) {
405
+ if (ignored instanceof RegExp) {
406
+ return ignored.test(nestedPath);
407
+ }
408
+ return nestedPath === ignored;
409
+ });
410
+ if (hasMatches) {
411
+ return "continue";
412
+ }
413
+ }
414
+ if (!isSerializable(nestedValue)) {
415
+ return { value: {
416
+ keyPath: nestedPath,
417
+ value: nestedValue
418
+ } };
419
+ }
420
+ if (typeof nestedValue === "object") {
421
+ foundNestedSerializable = findNonSerializableValue(nestedValue, nestedPath, isSerializable, getEntries, ignoredPaths, cache);
422
+ if (foundNestedSerializable) {
423
+ return { value: foundNestedSerializable };
424
+ }
425
+ }
426
+ };
427
+ for (var _i = 0, entries_1 = entries; _i < entries_1.length; _i++) {
428
+ var _c = entries_1[_i], key = _c[0], nestedValue = _c[1];
429
+ var state_2 = _loop_2(key, nestedValue);
430
+ if (typeof state_2 === "object")
431
+ return state_2.value;
432
+ }
433
+ if (cache && isNestedFrozen(value))
434
+ cache.add(value);
435
+ return false;
436
+ }
437
+ function isNestedFrozen(value) {
438
+ if (!Object.isFrozen(value))
439
+ return false;
440
+ for (var _i = 0, _c = Object.values(value); _i < _c.length; _i++) {
441
+ var nestedValue = _c[_i];
442
+ if (typeof nestedValue !== "object" || nestedValue === null)
443
+ continue;
444
+ if (!isNestedFrozen(nestedValue))
445
+ return false;
446
+ }
447
+ return true;
448
+ }
449
+ function createSerializableStateInvariantMiddleware(options) {
450
+ if (options === void 0) { options = {}; }
451
+ if (process.env.NODE_ENV === "production") {
452
+ return function () { return function (next) { return function (action) { return next(action); }; }; };
453
+ }
454
+ var _c = options.isSerializable, isSerializable = _c === void 0 ? isPlain : _c, getEntries = options.getEntries, _d = options.ignoredActions, ignoredActions = _d === void 0 ? [] : _d, _e = options.ignoredActionPaths, ignoredActionPaths = _e === void 0 ? ["meta.arg", "meta.baseQueryMeta"] : _e, _f = options.ignoredPaths, ignoredPaths = _f === void 0 ? [] : _f, _g = options.warnAfter, warnAfter = _g === void 0 ? 32 : _g, _h = options.ignoreState, ignoreState = _h === void 0 ? false : _h, _j = options.ignoreActions, ignoreActions = _j === void 0 ? false : _j, _k = options.disableCache, disableCache = _k === void 0 ? false : _k;
455
+ var cache = !disableCache && WeakSet ? new WeakSet() : void 0;
456
+ return function (storeAPI) { return function (next) { return function (action) {
457
+ var result = next(action);
458
+ var measureUtils = getTimeMeasureUtils(warnAfter, "SerializableStateInvariantMiddleware");
459
+ if (!ignoreActions && !(ignoredActions.length && ignoredActions.indexOf(action.type) !== -1)) {
460
+ measureUtils.measureTime(function () {
461
+ var foundActionNonSerializableValue = findNonSerializableValue(action, "", isSerializable, getEntries, ignoredActionPaths, cache);
462
+ if (foundActionNonSerializableValue) {
463
+ var keyPath = foundActionNonSerializableValue.keyPath, value = foundActionNonSerializableValue.value;
464
+ console.error("A non-serializable value was detected in an action, in the path: `" + keyPath + "`. Value:", value, "\nTake a look at the logic that dispatched this action: ", action, "\n(See https://redux.js.org/faq/actions#why-should-type-be-a-string-or-at-least-serializable-why-should-my-action-types-be-constants)", "\n(To allow non-serializable values see: https://redux-toolkit.js.org/usage/usage-guide#working-with-non-serializable-data)");
465
+ }
466
+ });
467
+ }
468
+ if (!ignoreState) {
469
+ measureUtils.measureTime(function () {
470
+ var state = storeAPI.getState();
471
+ var foundStateNonSerializableValue = findNonSerializableValue(state, "", isSerializable, getEntries, ignoredPaths, cache);
472
+ if (foundStateNonSerializableValue) {
473
+ var keyPath = foundStateNonSerializableValue.keyPath, value = foundStateNonSerializableValue.value;
474
+ console.error("A non-serializable value was detected in the state, in the path: `" + keyPath + "`. Value:", value, "\nTake a look at the reducer(s) handling this action type: " + action.type + ".\n(See https://redux.js.org/faq/organizing-state#can-i-put-functions-promises-or-other-non-serializable-items-in-my-store-state)");
475
+ }
476
+ });
477
+ measureUtils.warnIfExceeded();
478
+ }
479
+ return result;
480
+ }; }; };
481
+ }
482
+ // src/getDefaultMiddleware.ts
483
+ function isBoolean(x) {
484
+ return typeof x === "boolean";
485
+ }
486
+ function curryGetDefaultMiddleware() {
487
+ return function curriedGetDefaultMiddleware(options) {
488
+ return getDefaultMiddleware(options);
489
+ };
490
+ }
491
+ function getDefaultMiddleware(options) {
492
+ if (options === void 0) { options = {}; }
493
+ var _c = options.thunk, thunk$1 = _c === void 0 ? true : _c, _d = options.immutableCheck, immutableCheck = _d === void 0 ? true : _d, _e = options.serializableCheck, serializableCheck = _e === void 0 ? true : _e, _f = options.actionCreatorCheck, actionCreatorCheck = _f === void 0 ? true : _f;
494
+ var middlewareArray = new MiddlewareArray();
495
+ if (thunk$1) {
496
+ if (isBoolean(thunk$1)) {
497
+ middlewareArray.push(thunk);
498
+ }
499
+ else {
500
+ middlewareArray.push(thunk.withExtraArgument(thunk$1.extraArgument));
501
+ }
502
+ }
503
+ if (process.env.NODE_ENV !== "production") {
504
+ if (immutableCheck) {
505
+ var immutableOptions = {};
506
+ if (!isBoolean(immutableCheck)) {
507
+ immutableOptions = immutableCheck;
508
+ }
509
+ middlewareArray.unshift(createImmutableStateInvariantMiddleware(immutableOptions));
510
+ }
511
+ if (serializableCheck) {
512
+ var serializableOptions = {};
513
+ if (!isBoolean(serializableCheck)) {
514
+ serializableOptions = serializableCheck;
515
+ }
516
+ middlewareArray.push(createSerializableStateInvariantMiddleware(serializableOptions));
517
+ }
518
+ if (actionCreatorCheck) {
519
+ var actionCreatorOptions = {};
520
+ if (!isBoolean(actionCreatorCheck)) {
521
+ actionCreatorOptions = actionCreatorCheck;
522
+ }
523
+ middlewareArray.unshift(createActionCreatorInvariantMiddleware(actionCreatorOptions));
524
+ }
525
+ }
526
+ return middlewareArray;
527
+ }
528
+ // src/configureStore.ts
529
+ var IS_PRODUCTION = process.env.NODE_ENV === "production";
530
+ function configureStore(options) {
531
+ var curriedGetDefaultMiddleware = curryGetDefaultMiddleware();
532
+ var _c = options || {}, _d = _c.reducer, reducer = _d === void 0 ? void 0 : _d, _e = _c.middleware, middleware = _e === void 0 ? curriedGetDefaultMiddleware() : _e, _f = _c.devTools, devTools = _f === void 0 ? true : _f, _g = _c.preloadedState, preloadedState = _g === void 0 ? void 0 : _g, _h = _c.enhancers, enhancers = _h === void 0 ? void 0 : _h;
533
+ var rootReducer;
534
+ if (typeof reducer === "function") {
535
+ rootReducer = reducer;
536
+ }
537
+ else if (isPlainObject(reducer)) {
538
+ rootReducer = combineReducers(reducer);
539
+ }
540
+ else {
541
+ throw new Error('"reducer" is a required argument, and must be a function or an object of functions that can be passed to combineReducers');
542
+ }
543
+ var finalMiddleware = middleware;
544
+ if (typeof finalMiddleware === "function") {
545
+ finalMiddleware = finalMiddleware(curriedGetDefaultMiddleware);
546
+ if (!IS_PRODUCTION && !Array.isArray(finalMiddleware)) {
547
+ throw new Error("when using a middleware builder function, an array of middleware must be returned");
548
+ }
549
+ }
550
+ if (!IS_PRODUCTION && finalMiddleware.some(function (item) { return typeof item !== "function"; })) {
551
+ throw new Error("each middleware provided to configureStore must be a function");
552
+ }
553
+ var middlewareEnhancer = applyMiddleware.apply(void 0, finalMiddleware);
554
+ var finalCompose = compose;
555
+ if (devTools) {
556
+ finalCompose = composeWithDevTools(__spreadValues({
557
+ trace: !IS_PRODUCTION
558
+ }, typeof devTools === "object" && devTools));
559
+ }
560
+ var defaultEnhancers = new EnhancerArray(middlewareEnhancer);
561
+ var storeEnhancers = defaultEnhancers;
562
+ if (Array.isArray(enhancers)) {
563
+ storeEnhancers = __spreadArray([middlewareEnhancer], enhancers);
564
+ }
565
+ else if (typeof enhancers === "function") {
566
+ storeEnhancers = enhancers(defaultEnhancers);
567
+ }
568
+ var composedEnhancer = finalCompose.apply(void 0, storeEnhancers);
569
+ return createStore(rootReducer, preloadedState, composedEnhancer);
570
+ }
571
+ var promise;
572
+ var queueMicrotaskShim = typeof queueMicrotask === "function" ? queueMicrotask.bind(typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : globalThis) : function (cb) { return (promise || (promise = Promise.resolve())).then(cb).catch(function (err) { return setTimeout(function () {
573
+ throw err;
574
+ }, 0); }); };
575
575
  //# sourceMappingURL=redux-toolkit.esm.js.map
576
576
 
577
577
  function _arrayLikeToArray(r, a) {
@@ -8313,15 +8313,25 @@ var getPendingMessagesMap = function getPendingMessagesMap() {
8313
8313
  return pendingMessagesMap;
8314
8314
  };
8315
8315
  var draftMessagesMap = {};
8316
+ var audioRecordingMap = {};
8316
8317
  var getDraftMessageFromMap = function getDraftMessageFromMap(channelId) {
8317
8318
  return draftMessagesMap[channelId];
8318
8319
  };
8320
+ var getAudioRecordingFromMap = function getAudioRecordingFromMap(channelId) {
8321
+ return audioRecordingMap[channelId];
8322
+ };
8319
8323
  var checkDraftMessagesIsEmpty = function checkDraftMessagesIsEmpty() {
8320
8324
  return Object.keys(draftMessagesMap).length === 0;
8321
8325
  };
8326
+ var setAudioRecordingToMap = function setAudioRecordingToMap(channelId, audioRecording) {
8327
+ audioRecordingMap[channelId] = audioRecording;
8328
+ };
8322
8329
  var removeDraftMessageFromMap = function removeDraftMessageFromMap(channelId) {
8323
8330
  delete draftMessagesMap[channelId];
8324
8331
  };
8332
+ var removeAudioRecordingFromMap = function removeAudioRecordingFromMap(channelId) {
8333
+ delete audioRecordingMap[channelId];
8334
+ };
8325
8335
  var setDraftMessageToMap = function setDraftMessageToMap(channelId, draftMessage) {
8326
8336
  draftMessagesMap[channelId] = draftMessage;
8327
8337
  };
@@ -16280,7 +16290,7 @@ function sendMessage(action) {
16280
16290
  }, _marked$3, null, [[2, 80]]);
16281
16291
  }
16282
16292
  function sendTextMessage(action) {
16283
- var payload, message, connectionState, channelId, channel, sendMessageTid, SceytChatClient, createChannelData, mentionedUserIds, attachments, attachmentBuilder, att, messageBuilder, messageToSend, pendingMessage, hasNextMessages, messagesToAdd, messageResponse, messageUpdateData, messageToUpdate, channelUpdateParam;
16293
+ var payload, message, connectionState, channelId, channel, sendMessageTid, SceytChatClient, createChannelData, mentionedUserIds, attachments, attachmentBuilder, att, messageBuilder, messageToSend, pendingMessage, messagesToAdd, messageResponse, messageUpdateData, messageToUpdate, channelUpdateParam;
16284
16294
  return _regeneratorRuntime().wrap(function sendTextMessage$(_context4) {
16285
16295
  while (1) switch (_context4.prev = _context4.next) {
16286
16296
  case 0:
@@ -16352,51 +16362,32 @@ function sendTextMessage(action) {
16352
16362
  pendingMessage.metadata = JSON.parse(pendingMessage.metadata);
16353
16363
  }
16354
16364
  _context4.next = 35;
16355
- return select(messagesHasNextSelector);
16365
+ return call(addPendingMessage, message, pendingMessage, channel);
16356
16366
  case 35:
16357
- hasNextMessages = _context4.sent;
16358
- if (getHasNextCached()) {
16359
- _context4.next = 44;
16360
- break;
16361
- }
16362
- if (!hasNextMessages) {
16363
- _context4.next = 42;
16364
- break;
16365
- }
16366
- _context4.next = 40;
16367
- return put(getMessagesAC(channel));
16368
- case 40:
16369
- _context4.next = 44;
16370
- break;
16371
- case 42:
16372
- _context4.next = 44;
16373
- return put(addMessageAC(JSON.parse(JSON.stringify(pendingMessage))));
16374
- case 44:
16375
- addAllMessages([pendingMessage], MESSAGE_LOAD_DIRECTION.NEXT);
16376
16367
  messagesToAdd = getFromAllMessagesByMessageId('', '', true);
16377
- _context4.next = 48;
16368
+ _context4.next = 38;
16378
16369
  return put(setMessagesAC(JSON.parse(JSON.stringify(messagesToAdd))));
16379
- case 48:
16370
+ case 38:
16380
16371
  if (!(connectionState === CONNECTION_STATUS.CONNECTED)) {
16381
- _context4.next = 74;
16372
+ _context4.next = 64;
16382
16373
  break;
16383
16374
  }
16384
16375
  if (!sendMessageHandler) {
16385
- _context4.next = 55;
16376
+ _context4.next = 45;
16386
16377
  break;
16387
16378
  }
16388
- _context4.next = 52;
16379
+ _context4.next = 42;
16389
16380
  return call(sendMessageHandler, messageToSend, channel.id);
16390
- case 52:
16381
+ case 42:
16391
16382
  messageResponse = _context4.sent;
16392
- _context4.next = 58;
16383
+ _context4.next = 48;
16393
16384
  break;
16394
- case 55:
16395
- _context4.next = 57;
16385
+ case 45:
16386
+ _context4.next = 47;
16396
16387
  return call(channel.sendMessage, messageToSend);
16397
- case 57:
16388
+ case 47:
16398
16389
  messageResponse = _context4.sent;
16399
- case 58:
16390
+ case 48:
16400
16391
  messageUpdateData = {
16401
16392
  id: messageResponse.id,
16402
16393
  body: messageResponse.body,
@@ -16412,9 +16403,9 @@ function sendTextMessage(action) {
16412
16403
  repliedInThread: messageResponse.repliedInThread,
16413
16404
  createdAt: messageResponse.createdAt
16414
16405
  };
16415
- _context4.next = 61;
16406
+ _context4.next = 51;
16416
16407
  return put(updateMessageAC(messageToSend.tid, JSON.parse(JSON.stringify(messageUpdateData))));
16417
- case 61:
16408
+ case 51:
16418
16409
  updateMessageOnMap(channel.id, {
16419
16410
  messageId: messageToSend.tid,
16420
16411
  params: messageUpdateData
@@ -16426,32 +16417,32 @@ function sendTextMessage(action) {
16426
16417
  lastMessage: messageToUpdate,
16427
16418
  lastReactedMessage: null
16428
16419
  };
16429
- _context4.next = 68;
16420
+ _context4.next = 58;
16430
16421
  return put(updateChannelDataAC(channel.id, channelUpdateParam, true));
16431
- case 68:
16422
+ case 58:
16432
16423
  updateChannelOnAllChannels(channel.id, channelUpdateParam);
16433
16424
  if (!channel.unread) {
16434
- _context4.next = 72;
16425
+ _context4.next = 62;
16435
16426
  break;
16436
16427
  }
16437
- _context4.next = 72;
16428
+ _context4.next = 62;
16438
16429
  return put(markChannelAsReadAC(channel.id));
16439
- case 72:
16440
- _context4.next = 75;
16430
+ case 62:
16431
+ _context4.next = 65;
16441
16432
  break;
16442
- case 74:
16433
+ case 64:
16443
16434
  throw new Error('Connection required to send message');
16444
- case 75:
16445
- _context4.next = 77;
16435
+ case 65:
16436
+ _context4.next = 67;
16446
16437
  return put(scrollToNewMessageAC(true));
16447
- case 77:
16448
- _context4.next = 79;
16438
+ case 67:
16439
+ _context4.next = 69;
16449
16440
  return put(setMessagesLoadingStateAC(LOADING_STATE.LOADED));
16450
- case 79:
16451
- _context4.next = 90;
16441
+ case 69:
16442
+ _context4.next = 80;
16452
16443
  break;
16453
- case 81:
16454
- _context4.prev = 81;
16444
+ case 71:
16445
+ _context4.prev = 71;
16455
16446
  _context4.t0 = _context4["catch"](8);
16456
16447
  log.error('error on send text message ... ', _context4.t0);
16457
16448
  updateMessageOnMap(channel.id, {
@@ -16463,18 +16454,18 @@ function sendTextMessage(action) {
16463
16454
  updateMessageOnAllMessages(sendMessageTid, {
16464
16455
  state: MESSAGE_STATUS.FAILED
16465
16456
  });
16466
- _context4.next = 88;
16457
+ _context4.next = 78;
16467
16458
  return put(updateMessageAC(sendMessageTid, {
16468
16459
  state: MESSAGE_STATUS.FAILED
16469
16460
  }));
16470
- case 88:
16471
- _context4.next = 90;
16461
+ case 78:
16462
+ _context4.next = 80;
16472
16463
  return put(setMessagesLoadingStateAC(LOADING_STATE.LOADED));
16473
- case 90:
16464
+ case 80:
16474
16465
  case "end":
16475
16466
  return _context4.stop();
16476
16467
  }
16477
- }, _marked2$2, null, [[8, 81]]);
16468
+ }, _marked2$2, null, [[8, 71]]);
16478
16469
  }
16479
16470
  function forwardMessage(action) {
16480
16471
  var payload, message, channelId, connectionState, channel, SceytChatClient, mentionedUserIds, attachments, attachmentBuilder, att, messageBuilder, messageToSend, pendingMessage, activeChannelId, isCachedChannel, hasNextMessages, messageResponse, messageUpdateData, messageToUpdate, channelUpdateParam;
@@ -19621,11 +19612,14 @@ var ChannelMessageText = function ChannelMessageText(_ref2) {
19621
19612
  typingOrRecording = _ref2.typingOrRecording,
19622
19613
  channel = _ref2.channel,
19623
19614
  isDirectChannel = _ref2.isDirectChannel;
19615
+ var audioRecording = useMemo(function () {
19616
+ return getAudioRecordingFromMap(channel.id);
19617
+ }, [channel.id, draftMessageText]);
19624
19618
  return /*#__PURE__*/React__default.createElement(MessageTextContainer, null, isTypingOrRecording && (/*#__PURE__*/React__default.createElement(TypingIndicator, null, !isDirectChannel && /*#__PURE__*/React__default.createElement(Points, {
19625
19619
  color: textPrimary
19626
19620
  }, ":"), typingOrRecording.isTyping ? 'typing' : 'recording', "...")), !isTypingOrRecording && (draftMessageText ? (/*#__PURE__*/React__default.createElement(DraftMessageText, {
19627
19621
  color: textSecondary
19628
- }, draftMessageText)) : lastMessage.state === MESSAGE_STATUS.DELETE ? 'Message was deleted.' : lastMessage.type === 'system' ? (lastMessage.user && (lastMessage.user.id === user.id ? 'You ' : makeUsername(lastMessage.user && contactsMap && contactsMap[lastMessage.user.id], lastMessage.user, getFromContacts))) + " " + (lastMessage.body === 'CC' ? 'created this channel' : lastMessage.body === 'CG' ? 'created this group' : lastMessage.body === 'AM' ? " added " + (lastMessageMetas && lastMessageMetas.m && lastMessageMetas.m.slice(0, 5).map(function (mem) {
19622
+ }, audioRecording && /*#__PURE__*/React__default.createElement(SvgVoiceIcon, null), draftMessageText)) : lastMessage.state === MESSAGE_STATUS.DELETE ? 'Message was deleted.' : lastMessage.type === 'system' ? (lastMessage.user && (lastMessage.user.id === user.id ? 'You ' : makeUsername(lastMessage.user && contactsMap && contactsMap[lastMessage.user.id], lastMessage.user, getFromContacts))) + " " + (lastMessage.body === 'CC' ? 'created this channel' : lastMessage.body === 'CG' ? 'created this group' : lastMessage.body === 'AM' ? " added " + (lastMessageMetas && lastMessageMetas.m && lastMessageMetas.m.slice(0, 5).map(function (mem) {
19629
19623
  return mem === user.id ? ' You' : " " + systemMessageUserName(mem, contactsMap && contactsMap[mem], lastMessage.mentionedUsers);
19630
19624
  })) + " " + (lastMessageMetas && lastMessageMetas.m && lastMessageMetas.m.length > 5 ? "and " + (lastMessageMetas.m.length - 5) + " more" : '') : lastMessage.body === 'RM' ? " removed " + (lastMessageMetas && lastMessageMetas.m && lastMessageMetas.m.slice(0, 5).map(function (mem) {
19631
19625
  return mem === user.id ? ' You' : " " + systemMessageUserName(mem, contactsMap && contactsMap[mem], lastMessage.mentionedUsers);
@@ -19719,8 +19713,13 @@ var Channel = function Channel(_ref3) {
19719
19713
  useEffect(function () {
19720
19714
  if (activeChannel.id !== channel.id) {
19721
19715
  var channelDraftMessage = getDraftMessageFromMap(channel.id);
19722
- if (channelDraftMessage) {
19723
- setDraftMessageText(channelDraftMessage.text);
19716
+ var draftAudioRecording = getAudioRecordingFromMap(channel.id);
19717
+ if (channelDraftMessage || draftAudioRecording) {
19718
+ if (channelDraftMessage) {
19719
+ setDraftMessageText(channelDraftMessage.text);
19720
+ } else if (draftAudioRecording) {
19721
+ setDraftMessageText('Voice');
19722
+ }
19724
19723
  } else if (draftMessageText) {
19725
19724
  setDraftMessageText(undefined);
19726
19725
  }
@@ -19930,7 +19929,7 @@ var Container$2 = styled.div(_templateObject6$1 || (_templateObject6$1 = _tagged
19930
19929
  var DraftMessageTitle = styled.span(_templateObject7$1 || (_templateObject7$1 = _taggedTemplateLiteralLoose(["\n color: ", ";\n"])), function (props) {
19931
19930
  return props.color;
19932
19931
  });
19933
- var DraftMessageText = styled.span(_templateObject8$1 || (_templateObject8$1 = _taggedTemplateLiteralLoose(["\n color: ", ";\n"])), function (props) {
19932
+ var DraftMessageText = styled.span(_templateObject8$1 || (_templateObject8$1 = _taggedTemplateLiteralLoose(["\n color: ", ";\n display: flex;\n align-items: flex-end;\n gap: 4px;\n"])), function (props) {
19934
19933
  return props.color;
19935
19934
  });
19936
19935
  var LastMessageAuthor = styled.div(_templateObject9$1 || (_templateObject9$1 = _taggedTemplateLiteralLoose(["\n max-width: 120px;\n font-weight: 500;\n color: ", ";\n\n ", "\n & > span {\n display: block;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n max-width: 100%;\n }\n"])), function (props) {
@@ -31282,9 +31281,11 @@ var MessageList = function MessageList(_ref2) {
31282
31281
  setIsDragging(false);
31283
31282
  if (e.dataTransfer.files && e.dataTransfer.files.length > 0) {
31284
31283
  var fileList = Object.values(e.dataTransfer.files);
31285
- var attachmentsFiles = [];
31286
31284
  new Promise(function (resolve) {
31287
- fileList.forEach(function (attachment, index) {
31285
+ var attachmentsFiles = [];
31286
+ var readFiles = 0;
31287
+ var errorCount = 0;
31288
+ fileList.forEach(function (attachment) {
31288
31289
  var fileReader = new FileReader();
31289
31290
  fileReader.onload = function (event) {
31290
31291
  var file = event.target.result;
@@ -31293,14 +31294,23 @@ var MessageList = function MessageList(_ref2) {
31293
31294
  data: file,
31294
31295
  type: attachment.type
31295
31296
  });
31296
- if (fileList.length - 1 === index) {
31297
- resolve();
31297
+ readFiles++;
31298
+ if (readFiles + errorCount === fileList.length) {
31299
+ resolve(attachmentsFiles);
31300
+ }
31301
+ };
31302
+ fileReader.onerror = function () {
31303
+ errorCount++;
31304
+ if (readFiles + errorCount === fileList.length) {
31305
+ resolve(attachmentsFiles);
31298
31306
  }
31299
31307
  };
31300
31308
  fileReader.readAsDataURL(attachment);
31301
31309
  });
31302
- }).then(function () {
31303
- dispatch(setDraggedAttachmentsAC(attachmentsFiles, 'file'));
31310
+ }).then(function (result) {
31311
+ dispatch(setDraggedAttachmentsAC(result, 'file'));
31312
+ })["catch"](function (error) {
31313
+ console.error('Error in handleDropFile:', error);
31304
31314
  });
31305
31315
  e.dataTransfer.clearData();
31306
31316
  }
@@ -31311,9 +31321,10 @@ var MessageList = function MessageList(_ref2) {
31311
31321
  setIsDragging(false);
31312
31322
  if (e.dataTransfer.files && e.dataTransfer.files.length > 0) {
31313
31323
  var fileList = Object.values(e.dataTransfer.files);
31314
- var attachmentsFiles = [];
31315
31324
  new Promise(function (resolve) {
31325
+ var attachmentsFiles = [];
31316
31326
  var readFiles = 0;
31327
+ var errorCount = 0;
31317
31328
  fileList.forEach(function (attachment) {
31318
31329
  var fileReader = new FileReader();
31319
31330
  fileReader.onload = function (event) {
@@ -31324,14 +31335,22 @@ var MessageList = function MessageList(_ref2) {
31324
31335
  type: attachment.type
31325
31336
  });
31326
31337
  readFiles++;
31327
- if (fileList.length === readFiles) {
31328
- resolve();
31338
+ if (readFiles + errorCount === fileList.length) {
31339
+ resolve(attachmentsFiles);
31340
+ }
31341
+ };
31342
+ fileReader.onerror = function () {
31343
+ errorCount++;
31344
+ if (readFiles + errorCount === fileList.length) {
31345
+ resolve(attachmentsFiles);
31329
31346
  }
31330
31347
  };
31331
31348
  fileReader.readAsDataURL(attachment);
31332
31349
  });
31333
- }).then(function () {
31334
- dispatch(setDraggedAttachmentsAC(attachmentsFiles, 'media'));
31350
+ }).then(function (result) {
31351
+ dispatch(setDraggedAttachmentsAC(result, 'media'));
31352
+ })["catch"](function (error) {
31353
+ console.error('Error in handleDropMedia:', error);
31335
31354
  });
31336
31355
  e.dataTransfer.clearData();
31337
31356
  }
@@ -31825,7 +31844,7 @@ var MessageList = function MessageList(_ref2) {
31825
31844
  attachmentsPreview: attachmentsPreview
31826
31845
  })))));
31827
31846
  };
31828
- var Container$h = styled.div(_templateObject$C || (_templateObject$C = _taggedTemplateLiteralLoose(["\n display: flex;\n flex-direction: column-reverse;\n flex-grow: 1;\n position: relative;\n overflow: auto;\n scroll-behavior: smooth;\n will-change: left, top;\n background-color: ", ";\n\n &::-webkit-scrollbar {\n width: 8px;\n background: transparent;\n }\n &::-webkit-scrollbar-thumb {\n background: transparent;\n }\n\n &.show-scrollbar::-webkit-scrollbar-thumb {\n background: ", ";\n border-radius: 4px;\n }\n &.show-scrollbar::-webkit-scrollbar-track {\n background: transparent;\n }\n"])), function (props) {
31847
+ var Container$h = styled.div(_templateObject$C || (_templateObject$C = _taggedTemplateLiteralLoose(["\n display: flex;\n flex-direction: column-reverse;\n flex-grow: 1;\n position: relative;\n overflow: auto;\n scroll-behavior: smooth;\n will-change: left, top;\n background-color: ", ";\n overflow-x: hidden;\n\n &::-webkit-scrollbar {\n width: 8px;\n background: transparent;\n }\n &::-webkit-scrollbar-thumb {\n background: transparent;\n }\n\n &.show-scrollbar::-webkit-scrollbar-thumb {\n background: ", ";\n border-radius: 4px;\n }\n &.show-scrollbar::-webkit-scrollbar-track {\n background: transparent;\n }\n"])), function (props) {
31829
31848
  return props.backgroundColor;
31830
31849
  }, function (props) {
31831
31850
  return props.thumbColor;
@@ -33840,9 +33859,77 @@ function SvgRecordButton(props) {
33840
33859
  var _templateObject$G, _templateObject2$B, _templateObject3$u, _templateObject4$q, _templateObject5$m, _templateObject6$i, _templateObject7$g;
33841
33860
  var shouldDraw = false;
33842
33861
  var AudioRecord = function AudioRecord(_ref) {
33843
- var startRecording = function startRecording() {
33862
+ var sendRecordedFile = _ref.sendRecordedFile,
33863
+ setShowRecording = _ref.setShowRecording,
33864
+ showRecording = _ref.showRecording,
33865
+ channelId = _ref.channelId;
33866
+ var _useColor = useColors(),
33867
+ accentColor = _useColor[THEME_COLORS.ACCENT],
33868
+ textSecondary = _useColor[THEME_COLORS.TEXT_SECONDARY],
33869
+ warningColor = _useColor[THEME_COLORS.WARNING],
33870
+ iconPrimary = _useColor[THEME_COLORS.ICON_PRIMARY],
33871
+ surface1 = _useColor[THEME_COLORS.SURFACE_1];
33872
+ var _useState = useState(null),
33873
+ recording = _useState[0],
33874
+ setStartRecording = _useState[1];
33875
+ var _useState2 = useState(null),
33876
+ recorder = _useState2[0],
33877
+ setRecorder = _useState2[1];
33878
+ var _useState3 = useState(null),
33879
+ recordedFile = _useState3[0],
33880
+ setRecordedFile = _useState3[1];
33881
+ var _useState4 = useState(false),
33882
+ recordingIsReadyToPlay = _useState4[0],
33883
+ setRecordingIsReadyToPlay = _useState4[1];
33884
+ var _useState5 = useState(0),
33885
+ currentTime = _useState5[0],
33886
+ setCurrentTime = _useState5[1];
33887
+ var _useState6 = useState(null),
33888
+ sendingInterval = _useState6[0],
33889
+ setSendingInterval = _useState6[1];
33890
+ var _useState7 = useState(''),
33891
+ currentChannelId = _useState7[0],
33892
+ setCurrentChannelId = _useState7[1];
33893
+ var _useState8 = useState(false),
33894
+ playAudio = _useState8[0],
33895
+ setPlayAudio = _useState8[1];
33896
+ var wavesurferContainer = useRef(null);
33897
+ var recordButtonRef = useRef(null);
33898
+ var wavesurfer = useRef({});
33899
+ var intervalRef = useRef({});
33900
+ var currentRecordedFile = useMemo(function () {
33901
+ var current = getAudioRecordingFromMap(currentChannelId) || recordedFile;
33902
+ return current;
33903
+ }, [recordedFile, currentChannelId]);
33904
+ useEffect(function () {
33905
+ if (currentRecordedFile) {
33906
+ setRecordedFile(currentRecordedFile);
33907
+ }
33908
+ }, [currentRecordedFile]);
33909
+ var dispatch = useDispatch();
33910
+ var handleStartRecording = function handleStartRecording() {
33911
+ dispatch(sendRecordingAC(true));
33912
+ if (sendingInterval) {
33913
+ clearInterval(sendingInterval);
33914
+ setSendingInterval(null);
33915
+ return;
33916
+ }
33917
+ var interval = setInterval(function () {
33918
+ dispatch(sendRecordingAC(true));
33919
+ }, 1000);
33920
+ setSendingInterval(interval);
33921
+ };
33922
+ var handleStopRecording = function handleStopRecording() {
33923
+ dispatch(sendRecordingAC(false));
33924
+ if (sendingInterval) {
33925
+ clearInterval(sendingInterval);
33926
+ setSendingInterval(null);
33927
+ }
33928
+ };
33929
+ var startRecording = function startRecording(cId) {
33844
33930
  try {
33845
- var _temp3 = _catch(function () {
33931
+ var id = cId || currentChannelId;
33932
+ var _temp = _catch(function () {
33846
33933
  return Promise.resolve(navigator.permissions.query({
33847
33934
  name: 'microphone'
33848
33935
  })).then(function (permissionStatus) {
@@ -33852,18 +33939,27 @@ var AudioRecord = function AudioRecord(_ref) {
33852
33939
  recordButtonRef.current.style.pointerEvents = 'none';
33853
33940
  }
33854
33941
  if (recording) {
33855
- stopRecording(true);
33856
- } else if (recordedFile) {
33857
- sendRecordedFile(recordedFile);
33942
+ stopRecording(true, id, false, recorder);
33943
+ } else if (currentRecordedFile) {
33944
+ var _wavesurfer$current;
33945
+ removeAudioRecordingFromMap(id);
33858
33946
  setRecordedFile(null);
33859
33947
  setPlayAudio(false);
33860
- if (wavesurfer.current) {
33861
- wavesurfer.current.destroy();
33948
+ if ((_wavesurfer$current = wavesurfer.current) !== null && _wavesurfer$current !== void 0 && _wavesurfer$current[id]) {
33949
+ wavesurfer.current[id].destroy();
33862
33950
  }
33863
33951
  setStartRecording(false);
33864
33952
  setShowRecording(false);
33953
+ dispatch(setChannelDraftMessageIsRemovedAC(id));
33954
+ sendRecordedFile(currentRecordedFile, id);
33865
33955
  } else {
33866
33956
  handleStartRecording();
33957
+ setAudioRecordingToMap(id, {
33958
+ file: null,
33959
+ objectUrl: null,
33960
+ thumb: null,
33961
+ dur: 0
33962
+ });
33867
33963
  recorder.start().then(function () {
33868
33964
  recordButtonRef.current.style.pointerEvents = 'initial';
33869
33965
  setShowRecording(true);
@@ -33871,8 +33967,8 @@ var AudioRecord = function AudioRecord(_ref) {
33871
33967
  shouldDraw = true;
33872
33968
  var stream = recorder.activeStream;
33873
33969
  var obj = {};
33874
- function init() {
33875
- obj.canvas = document.getElementById('waveform');
33970
+ var init = function init() {
33971
+ obj.canvas = document.getElementById("waveform-" + id);
33876
33972
  obj.ctx = obj.canvas.getContext('2d');
33877
33973
  obj.width = 360;
33878
33974
  obj.height = 28;
@@ -33880,10 +33976,10 @@ var AudioRecord = function AudioRecord(_ref) {
33880
33976
  obj.canvas.height = obj.height;
33881
33977
  obj.canvas.style.width = obj.width + 'px';
33882
33978
  obj.canvas.style.height = obj.height + 'px';
33883
- }
33979
+ };
33884
33980
  var timeOffset = 100;
33885
33981
  var now = parseInt(performance.now()) / timeOffset;
33886
- function loop() {
33982
+ var _loop = function loop() {
33887
33983
  if (!shouldDraw) {
33888
33984
  obj.x = 0;
33889
33985
  obj.ctx.clearRect(0, 0, obj.canvas.width, obj.canvas.height);
@@ -33911,10 +34007,10 @@ var AudioRecord = function AudioRecord(_ref) {
33911
34007
  });
33912
34008
  }
33913
34009
  draw();
33914
- requestAnimationFrame(loop);
33915
- }
34010
+ requestAnimationFrame(_loop);
34011
+ };
33916
34012
  obj.bars = [];
33917
- function draw() {
34013
+ var draw = function draw() {
33918
34014
  for (var i = 0; i < obj.bars.length; i++) {
33919
34015
  var bar = obj.bars[i];
33920
34016
  obj.ctx.fillStyle = textSecondary;
@@ -33924,8 +34020,8 @@ var AudioRecord = function AudioRecord(_ref) {
33924
34020
  obj.bars.splice(i, 1);
33925
34021
  }
33926
34022
  }
33927
- }
33928
- function soundAllowed(stream) {
34023
+ };
34024
+ var soundAllowed = function soundAllowed(stream) {
33929
34025
  var AudioContext = window.AudioContext || window.webkitAudioContext;
33930
34026
  var audioContent = new AudioContext();
33931
34027
  var streamSource = audioContent.createMediaStreamSource(stream);
@@ -33934,8 +34030,8 @@ var AudioRecord = function AudioRecord(_ref) {
33934
34030
  obj.analyser.fftSize = 512;
33935
34031
  obj.frequencyArray = new Float32Array(obj.analyser.fftSize);
33936
34032
  init();
33937
- loop();
33938
- }
34033
+ _loop();
34034
+ };
33939
34035
  soundAllowed(stream);
33940
34036
  })["catch"](function (e) {
33941
34037
  handleStopRecording();
@@ -33947,72 +34043,21 @@ var AudioRecord = function AudioRecord(_ref) {
33947
34043
  handleStopRecording();
33948
34044
  log.error(e);
33949
34045
  });
33950
- return Promise.resolve(_temp3 && _temp3.then ? _temp3.then(function () {}) : void 0);
34046
+ return Promise.resolve(_temp && _temp.then ? _temp.then(function () {}) : void 0);
33951
34047
  } catch (e) {
33952
34048
  return Promise.reject(e);
33953
34049
  }
33954
34050
  };
33955
- var sendRecordedFile = _ref.sendRecordedFile,
33956
- setShowRecording = _ref.setShowRecording,
33957
- showRecording = _ref.showRecording;
33958
- var _useColor = useColors(),
33959
- accentColor = _useColor[THEME_COLORS.ACCENT],
33960
- textSecondary = _useColor[THEME_COLORS.TEXT_SECONDARY],
33961
- warningColor = _useColor[THEME_COLORS.WARNING],
33962
- iconPrimary = _useColor[THEME_COLORS.ICON_PRIMARY],
33963
- surface1 = _useColor[THEME_COLORS.SURFACE_1];
33964
- var _useState = useState(null),
33965
- recording = _useState[0],
33966
- setStartRecording = _useState[1];
33967
- var _useState2 = useState(null),
33968
- recorder = _useState2[0],
33969
- setRecorder = _useState2[1];
33970
- var _useState3 = useState(null),
33971
- recordedFile = _useState3[0],
33972
- setRecordedFile = _useState3[1];
33973
- var _useState4 = useState(false),
33974
- recordingIsReadyToPlay = _useState4[0],
33975
- setRecordingIsReadyToPlay = _useState4[1];
33976
- var _useState5 = useState(0),
33977
- currentTime = _useState5[0],
33978
- setCurrentTime = _useState5[1];
33979
- var _useState6 = useState(null),
33980
- sendingInterval = _useState6[0],
33981
- setSendingInterval = _useState6[1];
33982
- var _useState7 = useState(false),
33983
- playAudio = _useState7[0],
33984
- setPlayAudio = _useState7[1];
33985
- var wavesurfer = useRef(null);
33986
- var wavesurferContainer = useRef(null);
33987
- var intervalRef = useRef(null);
33988
- var recordButtonRef = useRef(null);
33989
- var dispatch = useDispatch();
33990
- var handleStartRecording = function handleStartRecording() {
33991
- dispatch(sendRecordingAC(true));
33992
- if (sendingInterval) {
33993
- clearInterval(sendingInterval);
33994
- setSendingInterval(null);
33995
- return;
33996
- }
33997
- var interval = setInterval(function () {
33998
- dispatch(sendRecordingAC(true));
33999
- }, 1000);
34000
- setSendingInterval(interval);
34001
- };
34002
- var handleStopRecording = function handleStopRecording() {
34003
- dispatch(sendRecordingAC(false));
34004
- if (sendingInterval) {
34005
- clearInterval(sendingInterval);
34006
- setSendingInterval(null);
34007
- }
34008
- };
34009
- function cancelRecording() {
34051
+ var cancelRecording = useCallback(function () {
34010
34052
  handleStopRecording();
34011
- if (recordedFile) {
34053
+ if (currentRecordedFile) {
34054
+ var _wavesurfer$current2;
34055
+ removeAudioRecordingFromMap(currentChannelId);
34056
+ dispatch(setChannelDraftMessageIsRemovedAC(currentChannelId));
34012
34057
  setRecordedFile(null);
34013
34058
  setPlayAudio(false);
34014
- if (wavesurfer.current) {
34015
- wavesurfer.current.destroy();
34059
+ if ((_wavesurfer$current2 = wavesurfer.current) !== null && _wavesurfer$current2 !== void 0 && _wavesurfer$current2[currentChannelId]) {
34060
+ wavesurfer.current[currentChannelId].destroy();
34016
34061
  }
34017
34062
  } else {
34018
34063
  shouldDraw = false;
@@ -34022,13 +34067,128 @@ var AudioRecord = function AudioRecord(_ref) {
34022
34067
  setStartRecording(false);
34023
34068
  setCurrentTime(0);
34024
34069
  setShowRecording(false);
34025
- }
34026
- function stopRecording(send) {
34070
+ }, [currentRecordedFile, currentChannelId, wavesurfer, setShowRecording, setRecordedFile]);
34071
+ var _initWaveSurfer = function initWaveSurfer(draft, cId, audioRecording, container) {
34072
+ try {
34073
+ var _exit = false;
34074
+ return Promise.resolve(_catch(function () {
34075
+ var _wavesurfer$current3;
34076
+ function _temp3(_result3) {
34077
+ if (_exit) return _result3;
34078
+ if (draft) {
34079
+ return;
34080
+ }
34081
+ wavesurfer.current[id].on('ready', function () {
34082
+ setRecordingIsReadyToPlay(true);
34083
+ var audioDuration = wavesurfer.current[id].getDuration();
34084
+ setCurrentTime(audioDuration);
34085
+ });
34086
+ wavesurfer.current[id].on('finish', function () {
34087
+ setPlayAudio(false);
34088
+ wavesurfer.current[id].seekTo(0);
34089
+ var audioDuration = wavesurfer.current[id].getDuration();
34090
+ setCurrentTime(audioDuration);
34091
+ clearInterval(intervalRef.current[id]);
34092
+ });
34093
+ wavesurfer.current[id].on('pause', function () {
34094
+ setPlayAudio(false);
34095
+ clearInterval(intervalRef.current[id]);
34096
+ });
34097
+ wavesurfer.current[id].on('interaction', function () {
34098
+ var currentTime = wavesurfer.current[id].getCurrentTime();
34099
+ setCurrentTime(currentTime);
34100
+ });
34101
+ }
34102
+ if (draft) {
34103
+ return;
34104
+ }
34105
+ var id = cId || currentChannelId;
34106
+ if ((_wavesurfer$current3 = wavesurfer.current) !== null && _wavesurfer$current3 !== void 0 && _wavesurfer$current3[id]) {
34107
+ setRecordingIsReadyToPlay(true);
34108
+ var audioDuration = wavesurfer.current[id].getDuration();
34109
+ setCurrentTime(audioDuration);
34110
+ }
34111
+ var _temp2 = function (_wavesurfer$current4) {
34112
+ if (!((_wavesurfer$current4 = wavesurfer.current) !== null && _wavesurfer$current4 !== void 0 && _wavesurfer$current4[id])) {
34113
+ var _ref2;
34114
+ var containerElement = wavesurferContainer.current || container;
34115
+ if (!containerElement) {
34116
+ setTimeout(function () {
34117
+ return _initWaveSurfer(draft, cId, audioRecording, container);
34118
+ }, 100);
34119
+ _exit = true;
34120
+ return;
34121
+ }
34122
+ var rect = containerElement.getBoundingClientRect();
34123
+ if (rect.width === 0 || rect.height === 0) {
34124
+ setTimeout(function () {
34125
+ return _initWaveSurfer(draft, cId, audioRecording, container);
34126
+ }, 100);
34127
+ _exit = true;
34128
+ return;
34129
+ }
34130
+ var ws = WaveSurfer.create({
34131
+ container: containerElement,
34132
+ waveColor: textSecondary,
34133
+ progressColor: accentColor,
34134
+ barWidth: 1,
34135
+ barHeight: 2,
34136
+ audioRate: 1,
34137
+ hideScrollbar: true,
34138
+ barRadius: 1.5,
34139
+ cursorWidth: 0,
34140
+ barGap: 2.5,
34141
+ height: 28
34142
+ });
34143
+ var peaks = [];
34144
+ if ((_ref2 = audioRecording || currentRecordedFile) !== null && _ref2 !== void 0 && _ref2.thumb) {
34145
+ var _ref3;
34146
+ var thumbData = (_ref3 = audioRecording || currentRecordedFile) === null || _ref3 === void 0 ? void 0 : _ref3.thumb;
34147
+ if (Array.isArray(thumbData) && thumbData.length > 0) {
34148
+ var maxVal = Math.max.apply(Math, thumbData);
34149
+ if (maxVal > 0 && isFinite(maxVal)) {
34150
+ var dec = maxVal / 100;
34151
+ peaks = thumbData.map(function (peak) {
34152
+ var normalizedPeak = peak / dec / 100;
34153
+ return isFinite(normalizedPeak) ? normalizedPeak : 0;
34154
+ }).filter(function (peak) {
34155
+ return isFinite(peak);
34156
+ });
34157
+ if (peaks.length === 0) {
34158
+ peaks = [];
34159
+ }
34160
+ }
34161
+ }
34162
+ }
34163
+ wavesurfer.current[id] = ws;
34164
+ return _catch(function () {
34165
+ var validPeaks = peaks.length > 0 ? peaks : undefined;
34166
+ return Promise.resolve(wavesurfer.current[id].loadBlob((audioRecording === null || audioRecording === void 0 ? void 0 : audioRecording.file) || (currentRecordedFile === null || currentRecordedFile === void 0 ? void 0 : currentRecordedFile.file), validPeaks)).then(function () {});
34167
+ }, function () {
34168
+ return _catch(function () {
34169
+ return Promise.resolve(wavesurfer.current[id].loadBlob((audioRecording === null || audioRecording === void 0 ? void 0 : audioRecording.file) || (currentRecordedFile === null || currentRecordedFile === void 0 ? void 0 : currentRecordedFile.file))).then(function () {});
34170
+ }, function (fallbackError) {
34171
+ console.error('Failed to load audio completely:', fallbackError);
34172
+ throw fallbackError;
34173
+ });
34174
+ });
34175
+ }
34176
+ }();
34177
+ return _temp2 && _temp2.then ? _temp2.then(_temp3) : _temp3(_temp2);
34178
+ }, function (e) {
34179
+ log.error('Failed to init wavesurfer', e);
34180
+ }));
34181
+ } catch (e) {
34182
+ return Promise.reject(e);
34183
+ }
34184
+ };
34185
+ var stopRecording = useCallback(function (send, cId, draft, recorder, container) {
34027
34186
  handleStopRecording();
34028
34187
  shouldDraw = false;
34029
- recorder.stop().getMp3().then(function (_ref2) {
34030
- var buffer = _ref2[0],
34031
- blob = _ref2[1];
34188
+ var id = cId || channelId;
34189
+ recorder.stop().getMp3().then(function (_ref4) {
34190
+ var buffer = _ref4[0],
34191
+ blob = _ref4[1];
34032
34192
  setCurrentTime(0);
34033
34193
  var file = new File(buffer, 'record.mp3', {
34034
34194
  type: blob.type,
@@ -34056,15 +34216,29 @@ var AudioRecord = function AudioRecord(_ref) {
34056
34216
  objectUrl: objectUrl,
34057
34217
  thumb: waveform,
34058
34218
  dur: audioBuffer.duration
34059
- });
34219
+ }, id);
34060
34220
  setShowRecording(false);
34221
+ removeAudioRecordingFromMap(id);
34222
+ dispatch(setChannelDraftMessageIsRemovedAC(id));
34061
34223
  } else {
34062
- setRecordedFile({
34224
+ if (!draft) {
34225
+ setRecordedFile({
34226
+ file: file,
34227
+ objectUrl: objectUrl,
34228
+ thumb: waveform,
34229
+ dur: audioBuffer.duration
34230
+ });
34231
+ }
34232
+ var audioRecording = {
34063
34233
  file: file,
34064
34234
  objectUrl: objectUrl,
34065
34235
  thumb: waveform,
34066
34236
  dur: audioBuffer.duration
34067
- });
34237
+ };
34238
+ setAudioRecordingToMap(id, audioRecording);
34239
+ if (draft) {
34240
+ _initWaveSurfer(draft, id, audioRecording, container);
34241
+ }
34068
34242
  }
34069
34243
  }, function (e) {
34070
34244
  log.info('Error decoding audio data: ' + e.err);
@@ -34075,14 +34249,15 @@ var AudioRecord = function AudioRecord(_ref) {
34075
34249
  handleStopRecording();
34076
34250
  log.error(e);
34077
34251
  });
34078
- }
34079
- var handlePlayPause = function handlePlayPause() {
34080
- if (wavesurfer.current) {
34081
- if (!wavesurfer.current.isPlaying()) {
34252
+ }, [sendRecordedFile, setShowRecording, setAudioRecordingToMap, setRecordedFile, handleStopRecording, channelId]);
34253
+ var handlePlayPause = function handlePlayPause(cId) {
34254
+ var _wavesurfer$current5;
34255
+ if ((_wavesurfer$current5 = wavesurfer.current) !== null && _wavesurfer$current5 !== void 0 && _wavesurfer$current5[cId || currentChannelId]) {
34256
+ if (!wavesurfer.current[cId || currentChannelId].isPlaying()) {
34082
34257
  setPlayAudio(true);
34083
34258
  handleStartRecording();
34084
- intervalRef.current = setInterval(function () {
34085
- var currentTime = wavesurfer.current.getCurrentTime();
34259
+ intervalRef.current[cId || currentChannelId] = setInterval(function () {
34260
+ var currentTime = wavesurfer.current[cId || currentChannelId].getCurrentTime();
34086
34261
  if (currentTime >= 0) {
34087
34262
  setCurrentTime(currentTime);
34088
34263
  }
@@ -34090,7 +34265,7 @@ var AudioRecord = function AudioRecord(_ref) {
34090
34265
  } else {
34091
34266
  handleStopRecording();
34092
34267
  }
34093
- wavesurfer.current.playPause();
34268
+ wavesurfer.current[cId || currentChannelId].playPause();
34094
34269
  }
34095
34270
  };
34096
34271
  useEffect(function () {
@@ -34102,7 +34277,7 @@ var AudioRecord = function AudioRecord(_ref) {
34102
34277
  setCurrentTime(function (prevState) {
34103
34278
  if (prevState.recordingSeconds === MAX_RECORDER_TIME) {
34104
34279
  clearInterval(recordingInterval);
34105
- stopRecording();
34280
+ stopRecording(false, currentChannelId, false, recorder);
34106
34281
  return 0;
34107
34282
  }
34108
34283
  return prevState + 1;
@@ -34117,132 +34292,133 @@ var AudioRecord = function AudioRecord(_ref) {
34117
34292
  clearInterval(recordingInterval);
34118
34293
  };
34119
34294
  }, [recording]);
34120
- useDidUpdate(function () {
34121
- if (recordedFile) {
34122
- var initWaveSurfer = function initWaveSurfer() {
34123
- try {
34124
- try {
34125
- if (wavesurfer.current) {
34126
- wavesurfer.current.destroy();
34127
- }
34128
- wavesurfer.current = WaveSurfer.create({
34129
- container: wavesurferContainer.current,
34130
- waveColor: textSecondary,
34131
- progressColor: accentColor,
34132
- barWidth: 1,
34133
- barHeight: 2,
34134
- audioRate: 1,
34135
- hideScrollbar: true,
34136
- barRadius: 1.5,
34137
- cursorWidth: 0,
34138
- barGap: 2.5,
34139
- height: 28
34140
- });
34141
- wavesurfer.current.load(recordedFile.objectUrl);
34142
- wavesurfer.current.on('ready', function () {
34143
- setRecordingIsReadyToPlay(true);
34144
- var audioDuration = wavesurfer.current.getDuration();
34145
- setCurrentTime(audioDuration);
34146
- });
34147
- wavesurfer.current.on('finish', function () {
34148
- setPlayAudio(false);
34149
- wavesurfer.current.seekTo(0);
34150
- var audioDuration = wavesurfer.current.getDuration();
34151
- setCurrentTime(audioDuration);
34152
- clearInterval(intervalRef.current);
34153
- });
34154
- wavesurfer.current.on('pause', function () {
34155
- setPlayAudio(false);
34156
- clearInterval(intervalRef.current);
34157
- });
34158
- wavesurfer.current.on('interaction', function () {
34159
- var currentTime = wavesurfer.current.getCurrentTime();
34160
- setCurrentTime(currentTime);
34161
- });
34162
- } catch (e) {
34163
- log.error('Failed to init wavesurfer', e);
34164
- }
34165
- return Promise.resolve();
34166
- } catch (e) {
34167
- return Promise.reject(e);
34168
- }
34169
- };
34170
- initWaveSurfer();
34295
+ useEffect(function () {
34296
+ if (currentRecordedFile) {
34297
+ _initWaveSurfer();
34171
34298
  } else {
34299
+ var _wavesurfer$current6;
34172
34300
  setRecordingIsReadyToPlay(false);
34173
- clearInterval(intervalRef.current);
34174
- wavesurfer.current = null;
34301
+ if (intervalRef.current[currentChannelId]) {
34302
+ clearInterval(intervalRef.current[currentChannelId]);
34303
+ intervalRef.current[currentChannelId] = null;
34304
+ }
34305
+ if ((_wavesurfer$current6 = wavesurfer.current) !== null && _wavesurfer$current6 !== void 0 && _wavesurfer$current6[currentChannelId]) {
34306
+ wavesurfer.current[currentChannelId].destroy();
34307
+ wavesurfer.current[currentChannelId] = null;
34308
+ }
34175
34309
  }
34176
34310
  return function () {
34177
- clearInterval(intervalRef.current);
34311
+ for (var key in intervalRef.current) {
34312
+ if (intervalRef.current[key]) {
34313
+ clearInterval(intervalRef.current[key]);
34314
+ intervalRef.current[key] = null;
34315
+ }
34316
+ }
34317
+ for (var _key in wavesurfer.current) {
34318
+ if (wavesurfer.current[_key]) {
34319
+ wavesurfer.current[_key].destroy();
34320
+ wavesurfer.current[_key] = null;
34321
+ }
34322
+ }
34178
34323
  };
34179
- }, [recordedFile]);
34324
+ }, [currentRecordedFile, currentChannelId]);
34180
34325
  useEffect(function () {
34181
- (function () {
34182
- try {
34183
- var _temp2 = function () {
34184
- if (!recorder) {
34185
- var _temp = _catch(function () {
34186
- return Promise.resolve(import('mic-recorder-to-mp3')).then(function (MicRecorderModule) {
34187
- var MicRecorder = MicRecorderModule["default"];
34188
- var recorder = new MicRecorder({
34189
- bitRate: 128
34326
+ if (!currentRecordedFile) {
34327
+ (function () {
34328
+ try {
34329
+ var _temp5 = function () {
34330
+ if (!recorder) {
34331
+ var _temp4 = _catch(function () {
34332
+ return Promise.resolve(import('mic-recorder-to-mp3')).then(function (MicRecorderModule) {
34333
+ var MicRecorder = MicRecorderModule["default"];
34334
+ var recorder = new MicRecorder({
34335
+ bitRate: 128
34336
+ });
34337
+ setRecorder(recorder);
34190
34338
  });
34191
- setRecorder(recorder);
34339
+ }, function (e) {
34340
+ log.error('Failed to init mic-recorder-to-mp3', e);
34192
34341
  });
34193
- }, function (e) {
34194
- log.error('Failed to init mic-recorder-to-mp3', e);
34195
- });
34196
- if (_temp && _temp.then) return _temp.then(function () {});
34197
- }
34198
- }();
34199
- return _temp2 && _temp2.then ? _temp2.then(function () {}) : void 0;
34200
- } catch (e) {
34201
- Promise.reject(e);
34202
- }
34203
- })();
34204
- }, []);
34342
+ if (_temp4 && _temp4.then) return _temp4.then(function () {});
34343
+ }
34344
+ }();
34345
+ return _temp5 && _temp5.then ? _temp5.then(function () {}) : void 0;
34346
+ } catch (e) {
34347
+ Promise.reject(e);
34348
+ }
34349
+ })();
34350
+ }
34351
+ }, [currentRecordedFile]);
34205
34352
  useEffect(function () {
34206
34353
  return function () {
34207
34354
  handleStopRecording();
34208
34355
  };
34209
34356
  }, [showRecording]);
34357
+ useEffect(function () {
34358
+ if (channelId && (showRecording || currentRecordedFile)) {
34359
+ if (!currentRecordedFile) {
34360
+ stopRecording(false, currentChannelId, true, recorder, wavesurferContainer.current);
34361
+ }
34362
+ if (playAudio) {
34363
+ handlePlayPause(channelId);
34364
+ }
34365
+ for (var key in intervalRef.current) {
34366
+ clearInterval(intervalRef.current[key]);
34367
+ intervalRef.current[key] = null;
34368
+ }
34369
+ for (var _key2 in wavesurfer.current) {
34370
+ var _wavesurfer$current$_;
34371
+ (_wavesurfer$current$_ = wavesurfer.current[_key2]) === null || _wavesurfer$current$_ === void 0 ? void 0 : _wavesurfer$current$_.destroy();
34372
+ wavesurfer.current[_key2] = null;
34373
+ }
34374
+ setShowRecording(false);
34375
+ setStartRecording(false);
34376
+ setPlayAudio(false);
34377
+ setCurrentTime(0);
34378
+ var audioRecording = getAudioRecordingFromMap(channelId);
34379
+ setRecordedFile(audioRecording || null);
34380
+ setRecordingIsReadyToPlay(!!audioRecording);
34381
+ }
34382
+ setCurrentChannelId(channelId);
34383
+ }, [channelId]);
34210
34384
  return /*#__PURE__*/React__default.createElement(Container$j, {
34211
- recording: showRecording
34212
- }, showRecording && (/*#__PURE__*/React__default.createElement(PlayPause$1, {
34385
+ recording: showRecording || currentRecordedFile
34386
+ }, (showRecording || currentRecordedFile) && (/*#__PURE__*/React__default.createElement(PlayPause$1, {
34213
34387
  iconColor: iconPrimary,
34214
34388
  onClick: function onClick() {
34215
34389
  return cancelRecording();
34216
34390
  }
34217
34391
  }, /*#__PURE__*/React__default.createElement(SvgClose, null))), /*#__PURE__*/React__default.createElement(AudioWrapper, {
34218
34392
  backgroundColor: surface1,
34219
- recording: recording || recordedFile
34393
+ recording: recording || currentRecordedFile
34220
34394
  }, recording && (/*#__PURE__*/React__default.createElement(PlayPause$1, {
34221
34395
  iconColor: warningColor,
34222
34396
  onClick: function onClick() {
34223
- return stopRecording();
34397
+ return stopRecording(false, currentChannelId, false, recorder);
34224
34398
  }
34225
34399
  }, /*#__PURE__*/React__default.createElement(SvgStopRecord, null))), /*#__PURE__*/React__default.createElement(Canvas, {
34226
- hide: recordedFile,
34227
- id: 'waveform',
34400
+ hide: currentRecordedFile,
34401
+ id: "waveform-" + channelId,
34228
34402
  recording: recording
34229
34403
  }), recording && /*#__PURE__*/React__default.createElement(Timer$2, {
34230
34404
  color: textSecondary
34231
- }, formatAudioVideoTime(currentTime)), recordingIsReadyToPlay && (/*#__PURE__*/React__default.createElement(PlayPause$1, {
34405
+ }, formatAudioVideoTime(currentTime)), (recordingIsReadyToPlay || currentRecordedFile) && (/*#__PURE__*/React__default.createElement(PlayPause$1, {
34232
34406
  iconColor: accentColor,
34233
- onClick: handlePlayPause
34407
+ onClick: function onClick() {
34408
+ return handlePlayPause(channelId);
34409
+ }
34234
34410
  }, playAudio ? /*#__PURE__*/React__default.createElement(SvgPauseRecord, null) : /*#__PURE__*/React__default.createElement(SvgPlayRecord, null))), /*#__PURE__*/React__default.createElement(AudioVisualization$1, {
34235
34411
  ref: wavesurferContainer,
34236
- show: recordedFile
34237
- }), recordingIsReadyToPlay && /*#__PURE__*/React__default.createElement(Timer$2, {
34412
+ show: currentRecordedFile
34413
+ }), (recordingIsReadyToPlay || currentRecordedFile) && (/*#__PURE__*/React__default.createElement(Timer$2, {
34238
34414
  color: textSecondary
34239
- }, formatAudioVideoTime(currentTime))), /*#__PURE__*/React__default.createElement(RecordIconWrapper, {
34415
+ }, formatAudioVideoTime(currentTime)))), /*#__PURE__*/React__default.createElement(RecordIconWrapper, {
34240
34416
  ref: recordButtonRef,
34241
34417
  onClick: function onClick() {
34242
- return startRecording();
34418
+ return startRecording(currentChannelId);
34243
34419
  },
34244
34420
  iconColor: accentColor
34245
- }, showRecording ? /*#__PURE__*/React__default.createElement(SvgSend, null) : /*#__PURE__*/React__default.createElement(SvgRecordButton, null)));
34421
+ }, showRecording || currentRecordedFile ? /*#__PURE__*/React__default.createElement(SvgSend, null) : /*#__PURE__*/React__default.createElement(SvgRecordButton, null)));
34246
34422
  };
34247
34423
  var Container$j = styled.div(_templateObject$G || (_templateObject$G = _taggedTemplateLiteralLoose(["\n width: 32px;\n position: relative;\n display: flex;\n align-items: center;\n justify-content: flex-end;\n ", ";\n transition: all 0.3s ease-in-out;\n"])), function (props) {
34248
34424
  return props.recording && "width: 400px";
@@ -34259,14 +34435,14 @@ var AudioWrapper = styled.div(_templateObject2$B || (_templateObject2$B = _tagge
34259
34435
  var RecordIconWrapper = styled.span(_templateObject3$u || (_templateObject3$u = _taggedTemplateLiteralLoose(["\n display: flex;\n cursor: pointer;\n > svg {\n color: ", ";\n }\n"])), function (props) {
34260
34436
  return props.iconColor;
34261
34437
  });
34262
- var AudioVisualization$1 = styled.div(_templateObject4$q || (_templateObject4$q = _taggedTemplateLiteralLoose(["\n position: absolute;\n opacity: ", ";\n z-index: ", ";\n visibility: ", ";\n width: 300px;\n height: 28px;\n max-width: calc(100% - 100px);\n left: 40px;\n background-color: ", ";\n"])), function (_ref3) {
34263
- var show = _ref3.show;
34438
+ var AudioVisualization$1 = styled.div(_templateObject4$q || (_templateObject4$q = _taggedTemplateLiteralLoose(["\n position: absolute;\n opacity: ", ";\n z-index: ", ";\n visibility: ", ";\n width: 300px;\n height: 28px;\n max-width: calc(100% - 100px);\n left: 40px;\n background-color: ", ";\n"])), function (_ref5) {
34439
+ var show = _ref5.show;
34264
34440
  return show ? '1' : '0';
34265
- }, function (_ref4) {
34266
- var show = _ref4.show;
34441
+ }, function (_ref6) {
34442
+ var show = _ref6.show;
34267
34443
  return !show && '-1';
34268
- }, function (_ref5) {
34269
- var show = _ref5.show;
34444
+ }, function (_ref7) {
34445
+ var show = _ref7.show;
34270
34446
  return show ? 'visible' : 'hidden';
34271
34447
  }, function (props) {
34272
34448
  return props.color;
@@ -34274,14 +34450,14 @@ var AudioVisualization$1 = styled.div(_templateObject4$q || (_templateObject4$q
34274
34450
  var PlayPause$1 = styled.div(_templateObject5$m || (_templateObject5$m = _taggedTemplateLiteralLoose(["\n cursor: pointer;\n padding: 10px;\n > svg {\n color: ", ";\n }\n"])), function (props) {
34275
34451
  return props.iconColor;
34276
34452
  });
34277
- var Canvas = styled.canvas(_templateObject6$i || (_templateObject6$i = _taggedTemplateLiteralLoose(["\n height: 28px;\n width: ", ";\n max-width: calc(100% - 110px);\n position: absolute;\n opacity: ", ";\n z-index: ", ";\n left: 42px;\n"])), function (_ref6) {
34278
- var recording = _ref6.recording;
34453
+ var Canvas = styled.canvas(_templateObject6$i || (_templateObject6$i = _taggedTemplateLiteralLoose(["\n height: 28px;\n width: ", ";\n max-width: calc(100% - 110px);\n position: absolute;\n opacity: ", ";\n z-index: ", ";\n left: 42px;\n"])), function (_ref8) {
34454
+ var recording = _ref8.recording;
34279
34455
  return recording ? '300px' : '0';
34280
- }, function (_ref7) {
34281
- var hide = _ref7.hide;
34456
+ }, function (_ref9) {
34457
+ var hide = _ref9.hide;
34282
34458
  return hide ? '0' : '1';
34283
- }, function (_ref8) {
34284
- var hide = _ref8.hide;
34459
+ }, function (_ref0) {
34460
+ var hide = _ref0.hide;
34285
34461
  return hide && '-1';
34286
34462
  });
34287
34463
  var Timer$2 = styled.div(_templateObject7$g || (_templateObject7$g = _taggedTemplateLiteralLoose(["\n width: 40px;\n font-weight: 400;\n font-size: 16px;\n line-height: 12px;\n color: ", ";\n margin-left: auto;\n"])), function (props) {
@@ -34485,92 +34661,89 @@ var SendMessageInput = function SendMessageInput(_ref3) {
34485
34661
  var _useState = useState(false),
34486
34662
  showRecording = _useState[0],
34487
34663
  setShowRecording = _useState[1];
34488
- var _useState2 = useState(null),
34489
- recordedFile = _useState2[0],
34490
- setRecordedFile = _useState2[1];
34491
34664
  var _usePermissions = usePermissions(activeChannel.userRole),
34492
34665
  checkActionPermission = _usePermissions[0];
34493
- var _useState3 = useState(false),
34494
- listenerIsAdded = _useState3[0],
34495
- setListenerIsAdded = _useState3[1];
34666
+ var _useState2 = useState(false),
34667
+ listenerIsAdded = _useState2[0],
34668
+ setListenerIsAdded = _useState2[1];
34669
+ var _useState3 = useState(''),
34670
+ messageText = _useState3[0],
34671
+ setMessageText = _useState3[1];
34496
34672
  var _useState4 = useState(''),
34497
- messageText = _useState4[0],
34498
- setMessageText = _useState4[1];
34499
- var _useState5 = useState(''),
34500
- editMessageText = _useState5[0],
34501
- setEditMessageText = _useState5[1];
34502
- var _useState6 = useState({}),
34503
- readyVideoAttachments = _useState6[0],
34504
- setReadyVideoAttachments = _useState6[1];
34673
+ editMessageText = _useState4[0],
34674
+ setEditMessageText = _useState4[1];
34675
+ var _useState5 = useState({}),
34676
+ readyVideoAttachments = _useState5[0],
34677
+ setReadyVideoAttachments = _useState5[1];
34678
+ var _useState6 = useState(false),
34679
+ showChooseAttachmentType = _useState6[0],
34680
+ setShowChooseAttachmentType = _useState6[1];
34505
34681
  var _useState7 = useState(false),
34506
- showChooseAttachmentType = _useState7[0],
34507
- setShowChooseAttachmentType = _useState7[1];
34682
+ isEmojisOpened = _useState7[0],
34683
+ setIsEmojisOpened = _useState7[1];
34508
34684
  var _useState8 = useState(false),
34509
- isEmojisOpened = _useState8[0],
34510
- setIsEmojisOpened = _useState8[1];
34511
- var _useState9 = useState(false),
34512
- emojisInRightSide = _useState9[0],
34513
- setEmojisInRightSide = _useState9[1];
34685
+ emojisInRightSide = _useState8[0],
34686
+ setEmojisInRightSide = _useState8[1];
34687
+ var _useState9 = useState(0),
34688
+ emojisPopupLeftPosition = _useState9[0],
34689
+ setEmojisPopupLeftPosition = _useState9[1];
34514
34690
  var _useState0 = useState(0),
34515
- emojisPopupLeftPosition = _useState0[0],
34516
- setEmojisPopupLeftPosition = _useState0[1];
34517
- var _useState1 = useState(0),
34518
- emojisPopupBottomPosition = _useState1[0],
34519
- setEmojisPopupBottomPosition = _useState1[1];
34520
- var _useState10 = useState(false),
34521
- addAttachmentsInRightSide = _useState10[0],
34522
- setAddAttachmentsInRightSide = _useState10[1];
34523
- var _useState11 = useState({
34691
+ emojisPopupBottomPosition = _useState0[0],
34692
+ setEmojisPopupBottomPosition = _useState0[1];
34693
+ var _useState1 = useState(false),
34694
+ addAttachmentsInRightSide = _useState1[0],
34695
+ setAddAttachmentsInRightSide = _useState1[1];
34696
+ var _useState10 = useState({
34524
34697
  clear: false
34525
34698
  }),
34526
- shouldClearEditor = _useState11[0],
34527
- setShouldClearEditor = _useState11[1];
34699
+ shouldClearEditor = _useState10[0],
34700
+ setShouldClearEditor = _useState10[1];
34701
+ var _useState11 = useState([]),
34702
+ messageBodyAttributes = _useState11[0],
34703
+ setMessageBodyAttributes = _useState11[1];
34528
34704
  var _useState12 = useState([]),
34529
- messageBodyAttributes = _useState12[0],
34530
- setMessageBodyAttributes = _useState12[1];
34531
- var _useState13 = useState([]),
34532
- mentionedMembers = _useState13[0],
34533
- setMentionedMembers = _useState13[1];
34534
- var _useState14 = useState(''),
34535
- browser = _useState14[0],
34536
- setBrowser = _useState14[1];
34537
- var _useState15 = useState(false),
34538
- mentionsIsOpen = _useState15[0],
34539
- setMentionsIsOpen = _useState15[1];
34540
- var _useState16 = useState(),
34541
- inputContainerHeight = _useState16[0],
34542
- setInputContainerHeight = _useState16[1];
34705
+ mentionedMembers = _useState12[0],
34706
+ setMentionedMembers = _useState12[1];
34707
+ var _useState13 = useState(''),
34708
+ browser = _useState13[0],
34709
+ setBrowser = _useState13[1];
34710
+ var _useState14 = useState(false),
34711
+ mentionsIsOpen = _useState14[0],
34712
+ setMentionsIsOpen = _useState14[1];
34713
+ var _useState15 = useState(),
34714
+ inputContainerHeight = _useState15[0],
34715
+ setInputContainerHeight = _useState15[1];
34543
34716
  var selectedText = useRef(null);
34717
+ var _useState16 = useState(),
34718
+ typingTimout = _useState16[0],
34719
+ setTypingTimout = _useState16[1];
34544
34720
  var _useState17 = useState(),
34545
- typingTimout = _useState17[0],
34546
- setTypingTimout = _useState17[1];
34547
- var _useState18 = useState(),
34548
- inTypingStateTimout = _useState18[0],
34549
- setInTypingStateTimout = _useState18[1];
34721
+ inTypingStateTimout = _useState17[0],
34722
+ setInTypingStateTimout = _useState17[1];
34723
+ var _useState18 = useState(false),
34724
+ inTypingState = _useState18[0],
34725
+ setInTypingState = _useState18[1];
34550
34726
  var _useState19 = useState(false),
34551
- inTypingState = _useState19[0],
34552
- setInTypingState = _useState19[1];
34553
- var _useState20 = useState(false),
34554
- sendMessageIsActive = _useState20[0],
34555
- setSendMessageIsActive = _useState20[1];
34556
- var _useState21 = useState([]),
34557
- attachments = _useState21[0],
34558
- setAttachments = _useState21[1];
34727
+ sendMessageIsActive = _useState19[0],
34728
+ setSendMessageIsActive = _useState19[1];
34729
+ var _useState20 = useState([]),
34730
+ attachments = _useState20[0],
34731
+ setAttachments = _useState20[1];
34732
+ var _useState21 = useState(false),
34733
+ forwardPopupOpen = _useState21[0],
34734
+ setForwardPopupOpen = _useState21[1];
34559
34735
  var _useState22 = useState(false),
34560
- forwardPopupOpen = _useState22[0],
34561
- setForwardPopupOpen = _useState22[1];
34736
+ deletePopupOpen = _useState22[0],
34737
+ setDeletePopupOpen = _useState22[1];
34562
34738
  var _useState23 = useState(false),
34563
- deletePopupOpen = _useState23[0],
34564
- setDeletePopupOpen = _useState23[1];
34565
- var _useState24 = useState(false),
34566
- isIncomingMessage = _useState24[0],
34567
- setIsIncomingMessage = _useState24[1];
34568
- var _useState25 = useState('.jpg,.jpeg,.png,.gif,.mp4,.mov,.avi,.wmv,.flv,.webm,.jfif'),
34569
- mediaExtensions = _useState25[0],
34570
- setMediaExtensions = _useState25[1];
34571
- var _useState26 = useState(''),
34572
- uploadErrorMessage = _useState26[0],
34573
- setUploadErrorMessage = _useState26[1];
34739
+ isIncomingMessage = _useState23[0],
34740
+ setIsIncomingMessage = _useState23[1];
34741
+ var _useState24 = useState('.jpg,.jpeg,.png,.gif,.mp4,.mov,.avi,.wmv,.flv,.webm,.jfif'),
34742
+ mediaExtensions = _useState24[0],
34743
+ setMediaExtensions = _useState24[1];
34744
+ var _useState25 = useState(''),
34745
+ uploadErrorMessage = _useState25[0],
34746
+ setUploadErrorMessage = _useState25[1];
34574
34747
  var typingOrRecordingIndicator = useSelector(typingOrRecordingIndicatorArraySelector(activeChannel.id));
34575
34748
  var contactsMap = useSelector(contactsMapSelector);
34576
34749
  var connectionStatus = useSelector(connectionStatusSelector, shallowEqual);
@@ -34580,15 +34753,15 @@ var SendMessageInput = function SendMessageInput(_ref3) {
34580
34753
  var messageInputRef = useRef(null);
34581
34754
  var emojiBtnRef = useRef(null);
34582
34755
  var addAttachmentsBtnRef = useRef(null);
34583
- var _useState27 = useState(),
34584
- realEditorState = _useState27[0],
34585
- setRealEditorState = _useState27[1];
34586
- var _useState28 = useState(null),
34587
- floatingAnchorElem = _useState28[0],
34588
- setFloatingAnchorElem = _useState28[1];
34589
- var _useState29 = useState(false),
34590
- isSmallWidthViewport = _useState29[0],
34591
- setIsSmallWidthViewport = _useState29[1];
34756
+ var _useState26 = useState(),
34757
+ realEditorState = _useState26[0],
34758
+ setRealEditorState = _useState26[1];
34759
+ var _useState27 = useState(null),
34760
+ floatingAnchorElem = _useState27[0],
34761
+ setFloatingAnchorElem = _useState27[1];
34762
+ var _useState28 = useState(false),
34763
+ isSmallWidthViewport = _useState28[0],
34764
+ setIsSmallWidthViewport = _useState28[1];
34592
34765
  var addAttachmentByMenu = showChooseFileAttachment && showChooseMediaAttachment;
34593
34766
  function onChange(editorState) {
34594
34767
  setRealEditorState(editorState);
@@ -35306,7 +35479,7 @@ var SendMessageInput = function SendMessageInput(_ref3) {
35306
35479
  dispatch(setDraggedAttachmentsAC([], ''));
35307
35480
  }
35308
35481
  }, [draggedAttachments]);
35309
- useEffect(function () {
35482
+ var sendRecordedFile = function sendRecordedFile(recordedFile, id) {
35310
35483
  if (recordedFile) {
35311
35484
  var tid = v4();
35312
35485
  var reader = new FileReader();
@@ -35346,7 +35519,7 @@ var SendMessageInput = function SendMessageInput(_ref3) {
35346
35519
  }],
35347
35520
  type: 'text'
35348
35521
  };
35349
- dispatch(sendMessageAC(messageToSend, activeChannel.id, connectionStatus));
35522
+ dispatch(sendMessageAC(messageToSend, id, connectionStatus));
35350
35523
  });
35351
35524
  } catch (e) {
35352
35525
  return Promise.reject(e);
@@ -35357,7 +35530,7 @@ var SendMessageInput = function SendMessageInput(_ref3) {
35357
35530
  };
35358
35531
  reader.readAsBinaryString(recordedFile.file);
35359
35532
  }
35360
- }, [recordedFile]);
35533
+ };
35361
35534
  useEffect(function () {
35362
35535
  var updateViewPortWidth = function updateViewPortWidth() {
35363
35536
  var isNextSmallWidthViewport = CAN_USE_DOM && window.matchMedia('(max-width: 1025px)').matches;
@@ -35744,7 +35917,7 @@ var SendMessageInput = function SendMessageInput(_ref3) {
35744
35917
  onChange: handleFileUpload,
35745
35918
  multiple: true,
35746
35919
  type: 'file'
35747
- }), showRecording ? (/*#__PURE__*/React__default.createElement(AudioCont, null)) : (/*#__PURE__*/React__default.createElement(MessageInputWrapper, {
35920
+ }), showRecording || getAudioRecordingFromMap(activeChannel.id) ? (/*#__PURE__*/React__default.createElement(AudioCont, null)) : (/*#__PURE__*/React__default.createElement(MessageInputWrapper, {
35748
35921
  className: 'message_input_wrapper',
35749
35922
  borderRadius: messageForReply || messageToEdit ? borderRadiusOnOpenedEditReplyMessage : borderRadius,
35750
35923
  ref: inputWrapperRef,
@@ -35877,9 +36050,10 @@ var SendMessageInput = function SendMessageInput(_ref3) {
35877
36050
  iconColor: accentColor,
35878
36051
  activeColor: accentColor
35879
36052
  }, /*#__PURE__*/React__default.createElement(AudioRecord, {
35880
- sendRecordedFile: setRecordedFile,
36053
+ sendRecordedFile: sendRecordedFile,
35881
36054
  setShowRecording: setShowRecording,
35882
- showRecording: showRecording
36055
+ showRecording: showRecording,
36056
+ channelId: activeChannel.id
35883
36057
  }))))))))));
35884
36058
  };
35885
36059
  var SendMessageWrapper = styled.div(_templateObject$I || (_templateObject$I = _taggedTemplateLiteralLoose(["\n background-color: ", ";\n position: relative;\n z-index: 15;\n"])), function (props) {