sceyt-chat-react-uikit 1.8.3-beta.7 → 1.8.3-beta.9
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/components/AudioPlayer/AudioVisualization.d.ts +1 -0
- package/index.js +779 -2481
- package/index.modern.js +1063 -2765
- package/package.json +1 -2
package/index.js
CHANGED
|
@@ -13,6 +13,7 @@ var styled = require('styled-components');
|
|
|
13
13
|
var styled__default = _interopDefault(styled);
|
|
14
14
|
var LinkifyIt = _interopDefault(require('linkify-it'));
|
|
15
15
|
var Pica = _interopDefault(require('pica'));
|
|
16
|
+
var reactDom = require('react-dom');
|
|
16
17
|
var Cropper = _interopDefault(require('react-easy-crop'));
|
|
17
18
|
var reactCircularProgressbar = require('react-circular-progressbar');
|
|
18
19
|
var ffmpeg = require('@ffmpeg/ffmpeg');
|
|
@@ -25,7 +26,6 @@ var LexicalRichTextPlugin = require('@lexical/react/LexicalRichTextPlugin');
|
|
|
25
26
|
var LexicalErrorBoundary = _interopDefault(require('@lexical/react/LexicalErrorBoundary'));
|
|
26
27
|
var LexicalOnChangePlugin = require('@lexical/react/LexicalOnChangePlugin');
|
|
27
28
|
var LexicalTypeaheadMenuPlugin = require('@lexical/react/LexicalTypeaheadMenuPlugin');
|
|
28
|
-
var reactDom = require('react-dom');
|
|
29
29
|
var offset = require('@lexical/offset');
|
|
30
30
|
var MicRecorder = _interopDefault(require('mic-recorder-to-mp3'));
|
|
31
31
|
var LexicalHistoryPlugin = require('@lexical/react/LexicalHistoryPlugin');
|
|
@@ -9069,6 +9069,101 @@ var _extractTextFromReactElement = function extractTextFromReactElement(element)
|
|
|
9069
9069
|
}
|
|
9070
9070
|
return '';
|
|
9071
9071
|
};
|
|
9072
|
+
var escapeHTML = function escapeHTML(str) {
|
|
9073
|
+
return str.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"');
|
|
9074
|
+
};
|
|
9075
|
+
var setsEqual = function setsEqual(a, b) {
|
|
9076
|
+
if (a.size !== b.size) return false;
|
|
9077
|
+
var equal = true;
|
|
9078
|
+
a.forEach(function (item) {
|
|
9079
|
+
if (!b.has(item)) equal = false;
|
|
9080
|
+
});
|
|
9081
|
+
return equal;
|
|
9082
|
+
};
|
|
9083
|
+
var wrapWithFormatTags = function wrapWithFormatTags(text, formats) {
|
|
9084
|
+
var result = text;
|
|
9085
|
+
if (formats.has('monospace')) result = "<code>" + result + "</code>";
|
|
9086
|
+
if (formats.has('strikethrough')) result = "<s>" + result + "</s>";
|
|
9087
|
+
if (formats.has('underline')) result = "<u>" + result + "</u>";
|
|
9088
|
+
if (formats.has('italic')) result = "<i>" + result + "</i>";
|
|
9089
|
+
if (formats.has('bold')) result = "<b>" + result + "</b>";
|
|
9090
|
+
return result;
|
|
9091
|
+
};
|
|
9092
|
+
var bodyAttributesToHTML = function bodyAttributesToHTML(body, bodyAttributes, mentionedUsers, contactsMap, getFromContacts) {
|
|
9093
|
+
if (!body) return '';
|
|
9094
|
+
if (!bodyAttributes || bodyAttributes.length === 0) {
|
|
9095
|
+
return escapeHTML(body);
|
|
9096
|
+
}
|
|
9097
|
+
var charFormats = Array.from({
|
|
9098
|
+
length: body.length
|
|
9099
|
+
}, function () {
|
|
9100
|
+
return new Set();
|
|
9101
|
+
});
|
|
9102
|
+
var mentionRanges = new Map();
|
|
9103
|
+
var _loop = function _loop() {
|
|
9104
|
+
var attr = _step2.value;
|
|
9105
|
+
var start = attr.offset;
|
|
9106
|
+
var end = Math.min(attr.offset + attr.length, body.length);
|
|
9107
|
+
if (attr.type === 'mention') {
|
|
9108
|
+
var mentionUser = mentionedUsers === null || mentionedUsers === void 0 ? void 0 : mentionedUsers.find(function (u) {
|
|
9109
|
+
return u.id === attr.metadata;
|
|
9110
|
+
});
|
|
9111
|
+
var displayName;
|
|
9112
|
+
if (mentionUser) {
|
|
9113
|
+
var contact = contactsMap === null || contactsMap === void 0 ? void 0 : contactsMap[mentionUser.id];
|
|
9114
|
+
displayName = "@" + makeUsername(contact, mentionUser, getFromContacts).trim();
|
|
9115
|
+
} else {
|
|
9116
|
+
displayName = body.slice(start, end);
|
|
9117
|
+
}
|
|
9118
|
+
mentionRanges.set(start, {
|
|
9119
|
+
userId: attr.metadata,
|
|
9120
|
+
displayName: displayName,
|
|
9121
|
+
length: attr.length
|
|
9122
|
+
});
|
|
9123
|
+
} else {
|
|
9124
|
+
var types = attr.type.split(' ');
|
|
9125
|
+
var _loop2 = function _loop2(_i) {
|
|
9126
|
+
types.forEach(function (t) {
|
|
9127
|
+
return charFormats[_i].add(t);
|
|
9128
|
+
});
|
|
9129
|
+
};
|
|
9130
|
+
for (var _i = start; _i < end; _i++) {
|
|
9131
|
+
_loop2(_i);
|
|
9132
|
+
}
|
|
9133
|
+
}
|
|
9134
|
+
};
|
|
9135
|
+
for (var _iterator2 = _createForOfIteratorHelperLoose(bodyAttributes), _step2; !(_step2 = _iterator2()).done;) {
|
|
9136
|
+
_loop();
|
|
9137
|
+
}
|
|
9138
|
+
var html = '';
|
|
9139
|
+
var i = 0;
|
|
9140
|
+
while (i < body.length) {
|
|
9141
|
+
var mention = mentionRanges.get(i);
|
|
9142
|
+
if (mention) {
|
|
9143
|
+
var formats = new Set(charFormats[i]);
|
|
9144
|
+
var wrapped = "<span data-mention=\"" + escapeHTML(mention.userId) + "\">" + escapeHTML(mention.displayName) + "</span>";
|
|
9145
|
+
if (formats.size > 0) {
|
|
9146
|
+
wrapped = wrapWithFormatTags(wrapped, formats);
|
|
9147
|
+
}
|
|
9148
|
+
html += wrapped;
|
|
9149
|
+
i += mention.length;
|
|
9150
|
+
continue;
|
|
9151
|
+
}
|
|
9152
|
+
var currentFormats = charFormats[i];
|
|
9153
|
+
var segmentEnd = i + 1;
|
|
9154
|
+
while (segmentEnd < body.length && !mentionRanges.has(segmentEnd) && setsEqual(charFormats[segmentEnd], currentFormats)) {
|
|
9155
|
+
segmentEnd++;
|
|
9156
|
+
}
|
|
9157
|
+
var segmentText = body.slice(i, segmentEnd);
|
|
9158
|
+
if (currentFormats.size === 0) {
|
|
9159
|
+
html += escapeHTML(segmentText);
|
|
9160
|
+
} else {
|
|
9161
|
+
html += wrapWithFormatTags(escapeHTML(segmentText), currentFormats);
|
|
9162
|
+
}
|
|
9163
|
+
i = segmentEnd;
|
|
9164
|
+
}
|
|
9165
|
+
return html;
|
|
9166
|
+
};
|
|
9072
9167
|
var checkIsTypeKeyPressed = function checkIsTypeKeyPressed(code) {
|
|
9073
9168
|
return !(code === 'Enter' || code === 'NumpadEnter' || code === 'Backspace' || code === 'Delete' || code === 'ArrowLeft' || code === 'ArrowRight' || code === 'ArrowUp' || code === 'ArrowDown' || code === 'PageUp' || code === 'PageDown' || code === 'Home' || code === 'End' || code === 'Insert' || code === 'Escape' || code === 'Tab' || code === 'F1' || code === 'F2' || code === 'F3' || code === 'F4' || code === 'F5' || code === 'F6' || code === 'F7' || code === 'F8' || code === 'F9' || code === 'F10' || code === 'F11' || code === 'F12' || code === 'CapsLock' || code === 'Shift' || code === 'ShiftLeft' || code === 'ShiftRight' || code === 'Control' || code === 'ControlLeft' || code === 'ControlRight' || code === 'Alt' || code === 'AltLeft' || code === 'AltRight' || code === 'MetaLeft' || code === 'MetaRight' || code === 'Space' || code === 'Enter' || code === 'NumpadEnter' || code === 'Backspace' || code === 'Delete' || code === 'ArrowLeft' || code === 'ArrowRight' || code === 'ArrowUp' || code === 'ArrowDown' || code === 'PageUp' || code === 'PageDown' || code === 'Home' || code === 'End' || code === 'Insert' || code === 'Escape' || code === 'Tab' || code === 'F1' || code === 'F2' || code === 'F3' || code === 'F4' || code === 'F5' || code === 'F6' || code === 'F7' || code === 'F8' || code === 'F9' || code === 'F10' || code === 'F11' || code === 'F12' || code === 'Shift');
|
|
9074
9169
|
};
|
|
@@ -11733,7 +11828,6 @@ var initialState$1 = {
|
|
|
11733
11828
|
attachmentForPopupLoadingState: null,
|
|
11734
11829
|
messageToEdit: null,
|
|
11735
11830
|
activeChannelNewMessage: null,
|
|
11736
|
-
pendingMessages: {},
|
|
11737
11831
|
activeChannelMessageUpdated: null,
|
|
11738
11832
|
scrollToNewMessage: {
|
|
11739
11833
|
scrollToBottom: false,
|
|
@@ -20339,7 +20433,7 @@ var getVideoFirstFrame = function getVideoFirstFrame(videoSrc, maxWidth, maxHeig
|
|
|
20339
20433
|
var video = document.createElement('video');
|
|
20340
20434
|
video.preload = 'metadata';
|
|
20341
20435
|
video.muted = true;
|
|
20342
|
-
video.
|
|
20436
|
+
video.setAttribute('playsinline', 'true');
|
|
20343
20437
|
if (videoSrc instanceof Blob) {
|
|
20344
20438
|
video.src = URL.createObjectURL(videoSrc);
|
|
20345
20439
|
} else {
|
|
@@ -20393,7 +20487,24 @@ var getVideoFirstFrame = function getVideoFirstFrame(videoSrc, maxWidth, maxHeig
|
|
|
20393
20487
|
videoUrlCreated = true;
|
|
20394
20488
|
video.currentTime = 0.01;
|
|
20395
20489
|
video.onseeked = function () {
|
|
20396
|
-
|
|
20490
|
+
video.onseeked = null;
|
|
20491
|
+
var capture = function capture() {
|
|
20492
|
+
return requestAnimationFrame(extractFrame);
|
|
20493
|
+
};
|
|
20494
|
+
video.play().then(function () {
|
|
20495
|
+
var done = false;
|
|
20496
|
+
var _finish = function finish() {
|
|
20497
|
+
if (done) return;
|
|
20498
|
+
done = true;
|
|
20499
|
+
video.removeEventListener('timeupdate', _finish);
|
|
20500
|
+
video.removeEventListener('ended', _finish);
|
|
20501
|
+
video.pause();
|
|
20502
|
+
capture();
|
|
20503
|
+
};
|
|
20504
|
+
video.addEventListener('timeupdate', _finish);
|
|
20505
|
+
video.addEventListener('ended', _finish);
|
|
20506
|
+
setTimeout(_finish, 500);
|
|
20507
|
+
})["catch"](capture);
|
|
20397
20508
|
};
|
|
20398
20509
|
video.onerror = function (error) {
|
|
20399
20510
|
log.error('Error seeking video for frame extraction', error);
|
|
@@ -20415,52 +20526,72 @@ var getVideoFirstFrame = function getVideoFirstFrame(videoSrc, maxWidth, maxHeig
|
|
|
20415
20526
|
return Promise.reject(e);
|
|
20416
20527
|
}
|
|
20417
20528
|
};
|
|
20418
|
-
var getFrame = function getFrame(videoSrc,
|
|
20529
|
+
var getFrame = function getFrame(videoSrc, _time) {
|
|
20419
20530
|
try {
|
|
20420
|
-
var video = document.createElement('video');
|
|
20421
|
-
video.src = videoSrc;
|
|
20422
|
-
video.crossOrigin = 'anonymous';
|
|
20423
|
-
video.preload = 'auto';
|
|
20424
|
-
video.muted = true;
|
|
20425
20531
|
return Promise.resolve(new Promise(function (resolve, reject) {
|
|
20426
|
-
if (videoSrc) {
|
|
20427
|
-
video.onloadedmetadata = function () {
|
|
20428
|
-
video.currentTime = time || 0;
|
|
20429
|
-
video.onseeked = function () {
|
|
20430
|
-
var _video$duration;
|
|
20431
|
-
var _calculateSize = calculateSize(video.videoWidth, video.videoHeight, 100, 100),
|
|
20432
|
-
newWidth = _calculateSize[0],
|
|
20433
|
-
newHeight = _calculateSize[1];
|
|
20434
|
-
var canvas = document.createElement('canvas');
|
|
20435
|
-
canvas.width = newWidth;
|
|
20436
|
-
canvas.height = newHeight;
|
|
20437
|
-
var ctx = canvas.getContext('2d');
|
|
20438
|
-
if (!ctx) {
|
|
20439
|
-
reject(new Error('Failed to get canvas context'));
|
|
20440
|
-
return;
|
|
20441
|
-
}
|
|
20442
|
-
ctx.drawImage(video, 0, 0, newWidth, newHeight);
|
|
20443
|
-
var pixels = ctx.getImageData(0, 0, canvas.width, canvas.height);
|
|
20444
|
-
var binaryThumbHash = rgbaToThumbHash(pixels.width, pixels.height, pixels.data);
|
|
20445
|
-
var thumb = binaryToBase64(binaryThumbHash);
|
|
20446
|
-
var duration = Number((_video$duration = video.duration) === null || _video$duration === void 0 ? void 0 : _video$duration.toFixed(0));
|
|
20447
|
-
resolve({
|
|
20448
|
-
thumb: thumb,
|
|
20449
|
-
width: video.videoWidth,
|
|
20450
|
-
height: video.videoHeight,
|
|
20451
|
-
duration: duration
|
|
20452
|
-
});
|
|
20453
|
-
};
|
|
20454
|
-
video.onerror = function () {
|
|
20455
|
-
reject(new Error('Failed to seek video'));
|
|
20456
|
-
};
|
|
20457
|
-
};
|
|
20458
|
-
video.onerror = function () {
|
|
20459
|
-
reject(new Error('Failed to load video'));
|
|
20460
|
-
};
|
|
20461
|
-
} else {
|
|
20532
|
+
if (!videoSrc) {
|
|
20462
20533
|
reject(new Error('src not found'));
|
|
20534
|
+
return;
|
|
20463
20535
|
}
|
|
20536
|
+
var video = document.createElement('video');
|
|
20537
|
+
video.preload = 'metadata';
|
|
20538
|
+
video.muted = true;
|
|
20539
|
+
video.setAttribute('playsinline', 'true');
|
|
20540
|
+
video.src = videoSrc;
|
|
20541
|
+
video.onloadedmetadata = function () {
|
|
20542
|
+
try {
|
|
20543
|
+
var _video$duration;
|
|
20544
|
+
var origWidth = video.videoWidth;
|
|
20545
|
+
var origHeight = video.videoHeight;
|
|
20546
|
+
var duration = Number((_video$duration = video.duration) === null || _video$duration === void 0 ? void 0 : _video$duration.toFixed(0));
|
|
20547
|
+
var _calculateSize = calculateSize(origWidth, origHeight, 100, 100),
|
|
20548
|
+
newWidth = _calculateSize[0],
|
|
20549
|
+
newHeight = _calculateSize[1];
|
|
20550
|
+
return Promise.resolve(_catch(function () {
|
|
20551
|
+
return Promise.resolve(getVideoFirstFrame(videoSrc, newWidth, newHeight)).then(function (frameResult) {
|
|
20552
|
+
if (!frameResult) {
|
|
20553
|
+
reject(new Error('Failed to extract video frame'));
|
|
20554
|
+
return;
|
|
20555
|
+
}
|
|
20556
|
+
var img = document.createElement('img');
|
|
20557
|
+
img.onload = function () {
|
|
20558
|
+
var canvas = document.createElement('canvas');
|
|
20559
|
+
canvas.width = newWidth;
|
|
20560
|
+
canvas.height = newHeight;
|
|
20561
|
+
var ctx = canvas.getContext('2d');
|
|
20562
|
+
if (!ctx) {
|
|
20563
|
+
URL.revokeObjectURL(frameResult.frameBlobUrl);
|
|
20564
|
+
reject(new Error('Failed to get canvas context'));
|
|
20565
|
+
return;
|
|
20566
|
+
}
|
|
20567
|
+
ctx.drawImage(img, 0, 0, newWidth, newHeight);
|
|
20568
|
+
var pixels = ctx.getImageData(0, 0, canvas.width, canvas.height);
|
|
20569
|
+
var binaryThumbHash = rgbaToThumbHash(pixels.width, pixels.height, pixels.data);
|
|
20570
|
+
var thumb = binaryToBase64(binaryThumbHash);
|
|
20571
|
+
URL.revokeObjectURL(frameResult.frameBlobUrl);
|
|
20572
|
+
resolve({
|
|
20573
|
+
thumb: thumb,
|
|
20574
|
+
width: origWidth,
|
|
20575
|
+
height: origHeight,
|
|
20576
|
+
duration: duration
|
|
20577
|
+
});
|
|
20578
|
+
};
|
|
20579
|
+
img.onerror = function () {
|
|
20580
|
+
URL.revokeObjectURL(frameResult.frameBlobUrl);
|
|
20581
|
+
reject(new Error('Failed to load frame image'));
|
|
20582
|
+
};
|
|
20583
|
+
img.src = frameResult.frameBlobUrl;
|
|
20584
|
+
});
|
|
20585
|
+
}, function (err) {
|
|
20586
|
+
reject(err);
|
|
20587
|
+
}));
|
|
20588
|
+
} catch (e) {
|
|
20589
|
+
return Promise.reject(e);
|
|
20590
|
+
}
|
|
20591
|
+
};
|
|
20592
|
+
video.onerror = function () {
|
|
20593
|
+
reject(new Error('Failed to load video'));
|
|
20594
|
+
};
|
|
20464
20595
|
}));
|
|
20465
20596
|
} catch (e) {
|
|
20466
20597
|
return Promise.reject(e);
|
|
@@ -20472,8 +20603,8 @@ var compressAndCacheImage = function compressAndCacheImage(url, cacheKey, maxWid
|
|
|
20472
20603
|
return Promise.resolve(fetch(url)).then(function (response) {
|
|
20473
20604
|
return Promise.resolve(response.blob()).then(function (blob) {
|
|
20474
20605
|
var _exit = false;
|
|
20475
|
-
function _temp2(
|
|
20476
|
-
if (_exit) return
|
|
20606
|
+
function _temp2(_result2) {
|
|
20607
|
+
if (_exit) return _result2;
|
|
20477
20608
|
setAttachmentToCache(cacheKey, response);
|
|
20478
20609
|
return '';
|
|
20479
20610
|
}
|
|
@@ -25778,9 +25909,9 @@ var PopupContainer = function PopupContainer(_ref) {
|
|
|
25778
25909
|
}
|
|
25779
25910
|
};
|
|
25780
25911
|
}, []);
|
|
25781
|
-
return /*#__PURE__*/React__default.createElement(Container, {
|
|
25912
|
+
return /*#__PURE__*/reactDom.createPortal(/*#__PURE__*/React__default.createElement(Container, {
|
|
25782
25913
|
backgroundColor: bgColor || overlayBackground
|
|
25783
|
-
}, children);
|
|
25914
|
+
}, children), document.body);
|
|
25784
25915
|
};
|
|
25785
25916
|
var Container = styled__default.div(_templateObject$2 || (_templateObject$2 = _taggedTemplateLiteralLoose(["\n direction: initial;\n position: fixed;\n top: 0;\n left: 0;\n //top: ", ";\n //left: ", ";\n z-index: 200;\n //width: ", ";\n //height: ", ";\n width: 100%;\n height: 100%;\n overflow: auto;\n display: flex;\n justify-content: center;\n align-items: center;\n background: ", ";\n"])), function (props) {
|
|
25786
25917
|
return props.top ? props.top + "px" : '0px';
|
|
@@ -25958,6 +26089,9 @@ var pollVotesHasMoreSelector = function pollVotesHasMoreSelector(store) {
|
|
|
25958
26089
|
var pollVotesLoadingStateSelector = function pollVotesLoadingStateSelector(store) {
|
|
25959
26090
|
return store.MessageReducer.pollVotesLoadingState;
|
|
25960
26091
|
};
|
|
26092
|
+
var pendingMessagesMapSelector = function pendingMessagesMapSelector(store) {
|
|
26093
|
+
return store.MessageReducer.pendingMessagesMap;
|
|
26094
|
+
};
|
|
25961
26095
|
var unreadScrollToSelector = function unreadScrollToSelector(store) {
|
|
25962
26096
|
return store.MessageReducer.unreadScrollTo;
|
|
25963
26097
|
};
|
|
@@ -27162,7 +27296,7 @@ var ChannelMessageText = function ChannelMessageText(_ref2) {
|
|
|
27162
27296
|
poll: (lastMessage === null || lastMessage === void 0 ? void 0 : lastMessage.pollDetails) && (lastMessage === null || lastMessage === void 0 ? void 0 : lastMessage.type) === exports.MESSAGE_TYPE.POLL
|
|
27163
27297
|
}, channel.lastReactedMessage && (/*#__PURE__*/React__default.createElement(React__default.Fragment, null, "Reacted", /*#__PURE__*/React__default.createElement(ReactionItem, null, channel.newReactions && channel.newReactions[0] && channel.newReactions[0].key), "to", ' "')), LastMessageAttachments({
|
|
27164
27298
|
lastMessage: lastMessage
|
|
27165
|
-
}), !!
|
|
27299
|
+
}), !!lastMessage && !isViewOnce && MessageTextFormat({
|
|
27166
27300
|
text: lastMessage.body,
|
|
27167
27301
|
message: lastMessage,
|
|
27168
27302
|
contactsMap: contactsMap,
|
|
@@ -27233,7 +27367,17 @@ var Channel = function Channel(_ref3) {
|
|
|
27233
27367
|
var _useState2 = React.useState(),
|
|
27234
27368
|
draftMessage = _useState2[0],
|
|
27235
27369
|
setDraftMessage = _useState2[1];
|
|
27236
|
-
var
|
|
27370
|
+
var pendingMessagesMap = useSelector(pendingMessagesMapSelector);
|
|
27371
|
+
var channelPendingLastMessage = React.useMemo(function () {
|
|
27372
|
+
var messages = pendingMessagesMap[channel.id];
|
|
27373
|
+
if (messages && messages !== null && messages !== void 0 && messages.length) {
|
|
27374
|
+
return messages[(messages === null || messages === void 0 ? void 0 : messages.length) - 1];
|
|
27375
|
+
}
|
|
27376
|
+
return null;
|
|
27377
|
+
}, [pendingMessagesMap]);
|
|
27378
|
+
var lastMessage = React.useMemo(function () {
|
|
27379
|
+
return channelPendingLastMessage || channel.lastReactedMessage || channel.lastMessage;
|
|
27380
|
+
}, [channelPendingLastMessage, channel.lastReactedMessage, channel.lastMessage]);
|
|
27237
27381
|
var lastMessageMetas = lastMessage && lastMessage.type === exports.MESSAGE_TYPE.SYSTEM && lastMessage.metadata && (isJSON(lastMessage.metadata) ? JSON.parse(lastMessage.metadata) : lastMessage.metadata);
|
|
27238
27382
|
var _useState3 = React.useState(0),
|
|
27239
27383
|
statusWidth = _useState3[0],
|
|
@@ -33736,1879 +33880,6 @@ function SvgPause(props) {
|
|
|
33736
33880
|
})));
|
|
33737
33881
|
}
|
|
33738
33882
|
|
|
33739
|
-
/** A simple event emitter that can be used to listen to and emit events. */
|
|
33740
|
-
class EventEmitter {
|
|
33741
|
-
constructor() {
|
|
33742
|
-
this.listeners = {};
|
|
33743
|
-
}
|
|
33744
|
-
/** Subscribe to an event. Returns an unsubscribe function. */
|
|
33745
|
-
on(event, listener, options) {
|
|
33746
|
-
if (!this.listeners[event]) {
|
|
33747
|
-
this.listeners[event] = new Set();
|
|
33748
|
-
}
|
|
33749
|
-
this.listeners[event].add(listener);
|
|
33750
|
-
if (options === null || options === void 0 ? void 0 : options.once) {
|
|
33751
|
-
const unsubscribeOnce = () => {
|
|
33752
|
-
this.un(event, unsubscribeOnce);
|
|
33753
|
-
this.un(event, listener);
|
|
33754
|
-
};
|
|
33755
|
-
this.on(event, unsubscribeOnce);
|
|
33756
|
-
return unsubscribeOnce;
|
|
33757
|
-
}
|
|
33758
|
-
return () => this.un(event, listener);
|
|
33759
|
-
}
|
|
33760
|
-
/** Unsubscribe from an event */
|
|
33761
|
-
un(event, listener) {
|
|
33762
|
-
var _a;
|
|
33763
|
-
(_a = this.listeners[event]) === null || _a === void 0 ? void 0 : _a.delete(listener);
|
|
33764
|
-
}
|
|
33765
|
-
/** Subscribe to an event only once */
|
|
33766
|
-
once(event, listener) {
|
|
33767
|
-
return this.on(event, listener, { once: true });
|
|
33768
|
-
}
|
|
33769
|
-
/** Clear all events */
|
|
33770
|
-
unAll() {
|
|
33771
|
-
this.listeners = {};
|
|
33772
|
-
}
|
|
33773
|
-
/** Emit an event */
|
|
33774
|
-
emit(eventName, ...args) {
|
|
33775
|
-
if (this.listeners[eventName]) {
|
|
33776
|
-
this.listeners[eventName].forEach((listener) => listener(...args));
|
|
33777
|
-
}
|
|
33778
|
-
}
|
|
33779
|
-
}
|
|
33780
|
-
|
|
33781
|
-
/** Base class for wavesurfer plugins */
|
|
33782
|
-
class BasePlugin extends EventEmitter {
|
|
33783
|
-
/** Create a plugin instance */
|
|
33784
|
-
constructor(options) {
|
|
33785
|
-
super();
|
|
33786
|
-
this.subscriptions = [];
|
|
33787
|
-
this.isDestroyed = false;
|
|
33788
|
-
this.options = options;
|
|
33789
|
-
}
|
|
33790
|
-
/** Called after this.wavesurfer is available */
|
|
33791
|
-
onInit() {
|
|
33792
|
-
return;
|
|
33793
|
-
}
|
|
33794
|
-
/** Do not call directly, only called by WavesSurfer internally */
|
|
33795
|
-
_init(wavesurfer) {
|
|
33796
|
-
// Reset state if plugin was previously destroyed
|
|
33797
|
-
if (this.isDestroyed) {
|
|
33798
|
-
this.subscriptions = [];
|
|
33799
|
-
this.isDestroyed = false;
|
|
33800
|
-
}
|
|
33801
|
-
this.wavesurfer = wavesurfer;
|
|
33802
|
-
this.onInit();
|
|
33803
|
-
}
|
|
33804
|
-
/** Destroy the plugin and unsubscribe from all events */
|
|
33805
|
-
destroy() {
|
|
33806
|
-
this.emit('destroy');
|
|
33807
|
-
this.subscriptions.forEach((unsubscribe) => unsubscribe());
|
|
33808
|
-
this.subscriptions = [];
|
|
33809
|
-
this.isDestroyed = true;
|
|
33810
|
-
this.wavesurfer = undefined;
|
|
33811
|
-
}
|
|
33812
|
-
}
|
|
33813
|
-
|
|
33814
|
-
var __awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
33815
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
33816
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
33817
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
33818
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
33819
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
33820
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
33821
|
-
});
|
|
33822
|
-
};
|
|
33823
|
-
/** Decode an array buffer into an audio buffer */
|
|
33824
|
-
function decode(audioData, sampleRate) {
|
|
33825
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
33826
|
-
const audioCtx = new AudioContext({ sampleRate });
|
|
33827
|
-
const decode = audioCtx.decodeAudioData(audioData);
|
|
33828
|
-
return decode.finally(() => audioCtx.close());
|
|
33829
|
-
});
|
|
33830
|
-
}
|
|
33831
|
-
/** Normalize peaks to -1..1 */
|
|
33832
|
-
function normalize(channelData) {
|
|
33833
|
-
const firstChannel = channelData[0];
|
|
33834
|
-
if (firstChannel.some((n) => n > 1 || n < -1)) {
|
|
33835
|
-
const length = firstChannel.length;
|
|
33836
|
-
let max = 0;
|
|
33837
|
-
for (let i = 0; i < length; i++) {
|
|
33838
|
-
const absN = Math.abs(firstChannel[i]);
|
|
33839
|
-
if (absN > max)
|
|
33840
|
-
max = absN;
|
|
33841
|
-
}
|
|
33842
|
-
for (const channel of channelData) {
|
|
33843
|
-
for (let i = 0; i < length; i++) {
|
|
33844
|
-
channel[i] /= max;
|
|
33845
|
-
}
|
|
33846
|
-
}
|
|
33847
|
-
}
|
|
33848
|
-
return channelData;
|
|
33849
|
-
}
|
|
33850
|
-
/** Create an audio buffer from pre-decoded audio data */
|
|
33851
|
-
function createBuffer(channelData, duration) {
|
|
33852
|
-
// If a single array of numbers is passed, make it an array of arrays
|
|
33853
|
-
if (typeof channelData[0] === 'number')
|
|
33854
|
-
channelData = [channelData];
|
|
33855
|
-
// Normalize to -1..1
|
|
33856
|
-
normalize(channelData);
|
|
33857
|
-
return {
|
|
33858
|
-
duration,
|
|
33859
|
-
length: channelData[0].length,
|
|
33860
|
-
sampleRate: channelData[0].length / duration,
|
|
33861
|
-
numberOfChannels: channelData.length,
|
|
33862
|
-
getChannelData: (i) => channelData === null || channelData === void 0 ? void 0 : channelData[i],
|
|
33863
|
-
copyFromChannel: AudioBuffer.prototype.copyFromChannel,
|
|
33864
|
-
copyToChannel: AudioBuffer.prototype.copyToChannel,
|
|
33865
|
-
};
|
|
33866
|
-
}
|
|
33867
|
-
const Decoder = {
|
|
33868
|
-
decode,
|
|
33869
|
-
createBuffer,
|
|
33870
|
-
};
|
|
33871
|
-
|
|
33872
|
-
function renderNode(tagName, content) {
|
|
33873
|
-
const element = content.xmlns
|
|
33874
|
-
? document.createElementNS(content.xmlns, tagName)
|
|
33875
|
-
: document.createElement(tagName);
|
|
33876
|
-
for (const [key, value] of Object.entries(content)) {
|
|
33877
|
-
if (key === 'children' && value) {
|
|
33878
|
-
for (const [childTag, childValue] of Object.entries(value)) {
|
|
33879
|
-
if (childValue instanceof Node) {
|
|
33880
|
-
element.appendChild(childValue);
|
|
33881
|
-
}
|
|
33882
|
-
else if (typeof childValue === 'string') {
|
|
33883
|
-
element.appendChild(document.createTextNode(childValue));
|
|
33884
|
-
}
|
|
33885
|
-
else {
|
|
33886
|
-
element.appendChild(renderNode(childTag, childValue));
|
|
33887
|
-
}
|
|
33888
|
-
}
|
|
33889
|
-
}
|
|
33890
|
-
else if (key === 'style') {
|
|
33891
|
-
Object.assign(element.style, value);
|
|
33892
|
-
}
|
|
33893
|
-
else if (key === 'textContent') {
|
|
33894
|
-
element.textContent = value;
|
|
33895
|
-
}
|
|
33896
|
-
else {
|
|
33897
|
-
element.setAttribute(key, value.toString());
|
|
33898
|
-
}
|
|
33899
|
-
}
|
|
33900
|
-
return element;
|
|
33901
|
-
}
|
|
33902
|
-
function createElement(tagName, content, container) {
|
|
33903
|
-
const el = renderNode(tagName, content || {});
|
|
33904
|
-
container === null || container === void 0 ? void 0 : container.appendChild(el);
|
|
33905
|
-
return el;
|
|
33906
|
-
}
|
|
33907
|
-
|
|
33908
|
-
var dom = {
|
|
33909
|
-
__proto__: null,
|
|
33910
|
-
createElement: createElement,
|
|
33911
|
-
'default': createElement
|
|
33912
|
-
};
|
|
33913
|
-
|
|
33914
|
-
var __awaiter$1 = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
33915
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
33916
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
33917
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
33918
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
33919
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
33920
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
33921
|
-
});
|
|
33922
|
-
};
|
|
33923
|
-
function watchProgress(response, progressCallback) {
|
|
33924
|
-
return __awaiter$1(this, void 0, void 0, function* () {
|
|
33925
|
-
if (!response.body || !response.headers)
|
|
33926
|
-
return;
|
|
33927
|
-
const reader = response.body.getReader();
|
|
33928
|
-
const contentLength = Number(response.headers.get('Content-Length')) || 0;
|
|
33929
|
-
let receivedLength = 0;
|
|
33930
|
-
// Process the data
|
|
33931
|
-
const processChunk = (value) => __awaiter$1(this, void 0, void 0, function* () {
|
|
33932
|
-
// Add to the received length
|
|
33933
|
-
receivedLength += (value === null || value === void 0 ? void 0 : value.length) || 0;
|
|
33934
|
-
const percentage = Math.round((receivedLength / contentLength) * 100);
|
|
33935
|
-
progressCallback(percentage);
|
|
33936
|
-
});
|
|
33937
|
-
const read = () => __awaiter$1(this, void 0, void 0, function* () {
|
|
33938
|
-
let data;
|
|
33939
|
-
try {
|
|
33940
|
-
data = yield reader.read();
|
|
33941
|
-
}
|
|
33942
|
-
catch (_a) {
|
|
33943
|
-
// Ignore errors because we can only handle the main response
|
|
33944
|
-
return;
|
|
33945
|
-
}
|
|
33946
|
-
// Continue reading data until done
|
|
33947
|
-
if (!data.done) {
|
|
33948
|
-
processChunk(data.value);
|
|
33949
|
-
yield read();
|
|
33950
|
-
}
|
|
33951
|
-
});
|
|
33952
|
-
read();
|
|
33953
|
-
});
|
|
33954
|
-
}
|
|
33955
|
-
function fetchBlob(url, progressCallback, requestInit) {
|
|
33956
|
-
return __awaiter$1(this, void 0, void 0, function* () {
|
|
33957
|
-
// Fetch the resource
|
|
33958
|
-
const response = yield fetch(url, requestInit);
|
|
33959
|
-
if (response.status >= 400) {
|
|
33960
|
-
throw new Error(`Failed to fetch ${url}: ${response.status} (${response.statusText})`);
|
|
33961
|
-
}
|
|
33962
|
-
// Read the data to track progress
|
|
33963
|
-
watchProgress(response.clone(), progressCallback);
|
|
33964
|
-
return response.blob();
|
|
33965
|
-
});
|
|
33966
|
-
}
|
|
33967
|
-
const Fetcher = {
|
|
33968
|
-
fetchBlob,
|
|
33969
|
-
};
|
|
33970
|
-
|
|
33971
|
-
var __awaiter$2 = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
33972
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
33973
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
33974
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
33975
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
33976
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
33977
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
33978
|
-
});
|
|
33979
|
-
};
|
|
33980
|
-
class Player extends EventEmitter {
|
|
33981
|
-
constructor(options) {
|
|
33982
|
-
super();
|
|
33983
|
-
this.isExternalMedia = false;
|
|
33984
|
-
if (options.media) {
|
|
33985
|
-
this.media = options.media;
|
|
33986
|
-
this.isExternalMedia = true;
|
|
33987
|
-
}
|
|
33988
|
-
else {
|
|
33989
|
-
this.media = document.createElement('audio');
|
|
33990
|
-
}
|
|
33991
|
-
// Controls
|
|
33992
|
-
if (options.mediaControls) {
|
|
33993
|
-
this.media.controls = true;
|
|
33994
|
-
}
|
|
33995
|
-
// Autoplay
|
|
33996
|
-
if (options.autoplay) {
|
|
33997
|
-
this.media.autoplay = true;
|
|
33998
|
-
}
|
|
33999
|
-
// Speed
|
|
34000
|
-
if (options.playbackRate != null) {
|
|
34001
|
-
this.onMediaEvent('canplay', () => {
|
|
34002
|
-
if (options.playbackRate != null) {
|
|
34003
|
-
this.media.playbackRate = options.playbackRate;
|
|
34004
|
-
}
|
|
34005
|
-
}, { once: true });
|
|
34006
|
-
}
|
|
34007
|
-
}
|
|
34008
|
-
onMediaEvent(event, callback, options) {
|
|
34009
|
-
this.media.addEventListener(event, callback, options);
|
|
34010
|
-
return () => this.media.removeEventListener(event, callback, options);
|
|
34011
|
-
}
|
|
34012
|
-
getSrc() {
|
|
34013
|
-
return this.media.currentSrc || this.media.src || '';
|
|
34014
|
-
}
|
|
34015
|
-
revokeSrc() {
|
|
34016
|
-
const src = this.getSrc();
|
|
34017
|
-
if (src.startsWith('blob:')) {
|
|
34018
|
-
URL.revokeObjectURL(src);
|
|
34019
|
-
}
|
|
34020
|
-
}
|
|
34021
|
-
canPlayType(type) {
|
|
34022
|
-
return this.media.canPlayType(type) !== '';
|
|
34023
|
-
}
|
|
34024
|
-
setSrc(url, blob) {
|
|
34025
|
-
const prevSrc = this.getSrc();
|
|
34026
|
-
if (url && prevSrc === url)
|
|
34027
|
-
return; // no need to change the source
|
|
34028
|
-
this.revokeSrc();
|
|
34029
|
-
const newSrc = blob instanceof Blob && (this.canPlayType(blob.type) || !url) ? URL.createObjectURL(blob) : url;
|
|
34030
|
-
// Reset the media element, otherwise it keeps the previous source
|
|
34031
|
-
if (prevSrc) {
|
|
34032
|
-
this.media.removeAttribute('src');
|
|
34033
|
-
}
|
|
34034
|
-
if (newSrc || url) {
|
|
34035
|
-
try {
|
|
34036
|
-
this.media.src = newSrc;
|
|
34037
|
-
}
|
|
34038
|
-
catch (_a) {
|
|
34039
|
-
this.media.src = url;
|
|
34040
|
-
}
|
|
34041
|
-
}
|
|
34042
|
-
}
|
|
34043
|
-
destroy() {
|
|
34044
|
-
if (this.isExternalMedia)
|
|
34045
|
-
return;
|
|
34046
|
-
this.media.pause();
|
|
34047
|
-
this.media.remove();
|
|
34048
|
-
this.revokeSrc();
|
|
34049
|
-
this.media.removeAttribute('src');
|
|
34050
|
-
// Load resets the media element to its initial state
|
|
34051
|
-
this.media.load();
|
|
34052
|
-
}
|
|
34053
|
-
setMediaElement(element) {
|
|
34054
|
-
this.media = element;
|
|
34055
|
-
}
|
|
34056
|
-
/** Start playing the audio */
|
|
34057
|
-
play() {
|
|
34058
|
-
return __awaiter$2(this, void 0, void 0, function* () {
|
|
34059
|
-
try {
|
|
34060
|
-
return yield this.media.play();
|
|
34061
|
-
}
|
|
34062
|
-
catch (err) {
|
|
34063
|
-
if (err instanceof DOMException && err.name === 'AbortError') {
|
|
34064
|
-
return;
|
|
34065
|
-
}
|
|
34066
|
-
throw err;
|
|
34067
|
-
}
|
|
34068
|
-
});
|
|
34069
|
-
}
|
|
34070
|
-
/** Pause the audio */
|
|
34071
|
-
pause() {
|
|
34072
|
-
this.media.pause();
|
|
34073
|
-
}
|
|
34074
|
-
/** Check if the audio is playing */
|
|
34075
|
-
isPlaying() {
|
|
34076
|
-
return !this.media.paused && !this.media.ended;
|
|
34077
|
-
}
|
|
34078
|
-
/** Jump to a specific time in the audio (in seconds) */
|
|
34079
|
-
setTime(time) {
|
|
34080
|
-
this.media.currentTime = Math.max(0, Math.min(time, this.getDuration()));
|
|
34081
|
-
}
|
|
34082
|
-
/** Get the duration of the audio in seconds */
|
|
34083
|
-
getDuration() {
|
|
34084
|
-
return this.media.duration;
|
|
34085
|
-
}
|
|
34086
|
-
/** Get the current audio position in seconds */
|
|
34087
|
-
getCurrentTime() {
|
|
34088
|
-
return this.media.currentTime;
|
|
34089
|
-
}
|
|
34090
|
-
/** Get the audio volume */
|
|
34091
|
-
getVolume() {
|
|
34092
|
-
return this.media.volume;
|
|
34093
|
-
}
|
|
34094
|
-
/** Set the audio volume */
|
|
34095
|
-
setVolume(volume) {
|
|
34096
|
-
this.media.volume = volume;
|
|
34097
|
-
}
|
|
34098
|
-
/** Get the audio muted state */
|
|
34099
|
-
getMuted() {
|
|
34100
|
-
return this.media.muted;
|
|
34101
|
-
}
|
|
34102
|
-
/** Mute or unmute the audio */
|
|
34103
|
-
setMuted(muted) {
|
|
34104
|
-
this.media.muted = muted;
|
|
34105
|
-
}
|
|
34106
|
-
/** Get the playback speed */
|
|
34107
|
-
getPlaybackRate() {
|
|
34108
|
-
return this.media.playbackRate;
|
|
34109
|
-
}
|
|
34110
|
-
/** Check if the audio is seeking */
|
|
34111
|
-
isSeeking() {
|
|
34112
|
-
return this.media.seeking;
|
|
34113
|
-
}
|
|
34114
|
-
/** Set the playback speed, pass an optional false to NOT preserve the pitch */
|
|
34115
|
-
setPlaybackRate(rate, preservePitch) {
|
|
34116
|
-
// preservePitch is true by default in most browsers
|
|
34117
|
-
if (preservePitch != null) {
|
|
34118
|
-
this.media.preservesPitch = preservePitch;
|
|
34119
|
-
}
|
|
34120
|
-
this.media.playbackRate = rate;
|
|
34121
|
-
}
|
|
34122
|
-
/** Get the HTML media element */
|
|
34123
|
-
getMediaElement() {
|
|
34124
|
-
return this.media;
|
|
34125
|
-
}
|
|
34126
|
-
/** Set a sink id to change the audio output device */
|
|
34127
|
-
setSinkId(sinkId) {
|
|
34128
|
-
// See https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/setSinkId
|
|
34129
|
-
const media = this.media;
|
|
34130
|
-
return media.setSinkId(sinkId);
|
|
34131
|
-
}
|
|
34132
|
-
}
|
|
34133
|
-
|
|
34134
|
-
function makeDraggable(element, onDrag, onStart, onEnd, threshold = 3, mouseButton = 0, touchDelay = 100) {
|
|
34135
|
-
if (!element)
|
|
34136
|
-
return () => void 0;
|
|
34137
|
-
const isTouchDevice = matchMedia('(pointer: coarse)').matches;
|
|
34138
|
-
let unsubscribeDocument = () => void 0;
|
|
34139
|
-
const onPointerDown = (event) => {
|
|
34140
|
-
if (event.button !== mouseButton)
|
|
34141
|
-
return;
|
|
34142
|
-
event.preventDefault();
|
|
34143
|
-
event.stopPropagation();
|
|
34144
|
-
let startX = event.clientX;
|
|
34145
|
-
let startY = event.clientY;
|
|
34146
|
-
let isDragging = false;
|
|
34147
|
-
const touchStartTime = Date.now();
|
|
34148
|
-
const onPointerMove = (event) => {
|
|
34149
|
-
event.preventDefault();
|
|
34150
|
-
event.stopPropagation();
|
|
34151
|
-
if (isTouchDevice && Date.now() - touchStartTime < touchDelay)
|
|
34152
|
-
return;
|
|
34153
|
-
const x = event.clientX;
|
|
34154
|
-
const y = event.clientY;
|
|
34155
|
-
const dx = x - startX;
|
|
34156
|
-
const dy = y - startY;
|
|
34157
|
-
if (isDragging || Math.abs(dx) > threshold || Math.abs(dy) > threshold) {
|
|
34158
|
-
const rect = element.getBoundingClientRect();
|
|
34159
|
-
const { left, top } = rect;
|
|
34160
|
-
if (!isDragging) {
|
|
34161
|
-
onStart === null || onStart === void 0 ? void 0 : onStart(startX - left, startY - top);
|
|
34162
|
-
isDragging = true;
|
|
34163
|
-
}
|
|
34164
|
-
onDrag(dx, dy, x - left, y - top);
|
|
34165
|
-
startX = x;
|
|
34166
|
-
startY = y;
|
|
34167
|
-
}
|
|
34168
|
-
};
|
|
34169
|
-
const onPointerUp = (event) => {
|
|
34170
|
-
if (isDragging) {
|
|
34171
|
-
const x = event.clientX;
|
|
34172
|
-
const y = event.clientY;
|
|
34173
|
-
const rect = element.getBoundingClientRect();
|
|
34174
|
-
const { left, top } = rect;
|
|
34175
|
-
onEnd === null || onEnd === void 0 ? void 0 : onEnd(x - left, y - top);
|
|
34176
|
-
}
|
|
34177
|
-
unsubscribeDocument();
|
|
34178
|
-
};
|
|
34179
|
-
const onPointerLeave = (e) => {
|
|
34180
|
-
// Listen to events only on the document and not on inner elements
|
|
34181
|
-
if (!e.relatedTarget || e.relatedTarget === document.documentElement) {
|
|
34182
|
-
onPointerUp(e);
|
|
34183
|
-
}
|
|
34184
|
-
};
|
|
34185
|
-
const onClick = (event) => {
|
|
34186
|
-
if (isDragging) {
|
|
34187
|
-
event.stopPropagation();
|
|
34188
|
-
event.preventDefault();
|
|
34189
|
-
}
|
|
34190
|
-
};
|
|
34191
|
-
const onTouchMove = (event) => {
|
|
34192
|
-
if (isDragging) {
|
|
34193
|
-
event.preventDefault();
|
|
34194
|
-
}
|
|
34195
|
-
};
|
|
34196
|
-
document.addEventListener('pointermove', onPointerMove);
|
|
34197
|
-
document.addEventListener('pointerup', onPointerUp);
|
|
34198
|
-
document.addEventListener('pointerout', onPointerLeave);
|
|
34199
|
-
document.addEventListener('pointercancel', onPointerLeave);
|
|
34200
|
-
document.addEventListener('touchmove', onTouchMove, { passive: false });
|
|
34201
|
-
document.addEventListener('click', onClick, { capture: true });
|
|
34202
|
-
unsubscribeDocument = () => {
|
|
34203
|
-
document.removeEventListener('pointermove', onPointerMove);
|
|
34204
|
-
document.removeEventListener('pointerup', onPointerUp);
|
|
34205
|
-
document.removeEventListener('pointerout', onPointerLeave);
|
|
34206
|
-
document.removeEventListener('pointercancel', onPointerLeave);
|
|
34207
|
-
document.removeEventListener('touchmove', onTouchMove);
|
|
34208
|
-
setTimeout(() => {
|
|
34209
|
-
document.removeEventListener('click', onClick, { capture: true });
|
|
34210
|
-
}, 10);
|
|
34211
|
-
};
|
|
34212
|
-
};
|
|
34213
|
-
element.addEventListener('pointerdown', onPointerDown);
|
|
34214
|
-
return () => {
|
|
34215
|
-
unsubscribeDocument();
|
|
34216
|
-
element.removeEventListener('pointerdown', onPointerDown);
|
|
34217
|
-
};
|
|
34218
|
-
}
|
|
34219
|
-
|
|
34220
|
-
var __awaiter$3 = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
34221
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
34222
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
34223
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
34224
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
34225
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
34226
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
34227
|
-
});
|
|
34228
|
-
};
|
|
34229
|
-
var __rest = (undefined && undefined.__rest) || function (s, e) {
|
|
34230
|
-
var t = {};
|
|
34231
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
34232
|
-
t[p] = s[p];
|
|
34233
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
34234
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
34235
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
34236
|
-
t[p[i]] = s[p[i]];
|
|
34237
|
-
}
|
|
34238
|
-
return t;
|
|
34239
|
-
};
|
|
34240
|
-
class Renderer extends EventEmitter {
|
|
34241
|
-
constructor(options, audioElement) {
|
|
34242
|
-
super();
|
|
34243
|
-
this.timeouts = [];
|
|
34244
|
-
this.isScrollable = false;
|
|
34245
|
-
this.audioData = null;
|
|
34246
|
-
this.resizeObserver = null;
|
|
34247
|
-
this.lastContainerWidth = 0;
|
|
34248
|
-
this.isDragging = false;
|
|
34249
|
-
this.subscriptions = [];
|
|
34250
|
-
this.unsubscribeOnScroll = [];
|
|
34251
|
-
this.subscriptions = [];
|
|
34252
|
-
this.options = options;
|
|
34253
|
-
const parent = this.parentFromOptionsContainer(options.container);
|
|
34254
|
-
this.parent = parent;
|
|
34255
|
-
const [div, shadow] = this.initHtml();
|
|
34256
|
-
parent.appendChild(div);
|
|
34257
|
-
this.container = div;
|
|
34258
|
-
this.scrollContainer = shadow.querySelector('.scroll');
|
|
34259
|
-
this.wrapper = shadow.querySelector('.wrapper');
|
|
34260
|
-
this.canvasWrapper = shadow.querySelector('.canvases');
|
|
34261
|
-
this.progressWrapper = shadow.querySelector('.progress');
|
|
34262
|
-
this.cursor = shadow.querySelector('.cursor');
|
|
34263
|
-
if (audioElement) {
|
|
34264
|
-
shadow.appendChild(audioElement);
|
|
34265
|
-
}
|
|
34266
|
-
this.initEvents();
|
|
34267
|
-
}
|
|
34268
|
-
parentFromOptionsContainer(container) {
|
|
34269
|
-
let parent;
|
|
34270
|
-
if (typeof container === 'string') {
|
|
34271
|
-
parent = document.querySelector(container);
|
|
34272
|
-
}
|
|
34273
|
-
else if (container instanceof HTMLElement) {
|
|
34274
|
-
parent = container;
|
|
34275
|
-
}
|
|
34276
|
-
if (!parent) {
|
|
34277
|
-
throw new Error('Container not found');
|
|
34278
|
-
}
|
|
34279
|
-
return parent;
|
|
34280
|
-
}
|
|
34281
|
-
initEvents() {
|
|
34282
|
-
const getClickPosition = (e) => {
|
|
34283
|
-
const rect = this.wrapper.getBoundingClientRect();
|
|
34284
|
-
const x = e.clientX - rect.left;
|
|
34285
|
-
const y = e.clientY - rect.top;
|
|
34286
|
-
const relativeX = x / rect.width;
|
|
34287
|
-
const relativeY = y / rect.height;
|
|
34288
|
-
return [relativeX, relativeY];
|
|
34289
|
-
};
|
|
34290
|
-
// Add a click listener
|
|
34291
|
-
this.wrapper.addEventListener('click', (e) => {
|
|
34292
|
-
const [x, y] = getClickPosition(e);
|
|
34293
|
-
this.emit('click', x, y);
|
|
34294
|
-
});
|
|
34295
|
-
// Add a double click listener
|
|
34296
|
-
this.wrapper.addEventListener('dblclick', (e) => {
|
|
34297
|
-
const [x, y] = getClickPosition(e);
|
|
34298
|
-
this.emit('dblclick', x, y);
|
|
34299
|
-
});
|
|
34300
|
-
// Drag
|
|
34301
|
-
if (this.options.dragToSeek === true || typeof this.options.dragToSeek === 'object') {
|
|
34302
|
-
this.initDrag();
|
|
34303
|
-
}
|
|
34304
|
-
// Add a scroll listener
|
|
34305
|
-
this.scrollContainer.addEventListener('scroll', () => {
|
|
34306
|
-
const { scrollLeft, scrollWidth, clientWidth } = this.scrollContainer;
|
|
34307
|
-
const startX = scrollLeft / scrollWidth;
|
|
34308
|
-
const endX = (scrollLeft + clientWidth) / scrollWidth;
|
|
34309
|
-
this.emit('scroll', startX, endX, scrollLeft, scrollLeft + clientWidth);
|
|
34310
|
-
});
|
|
34311
|
-
// Re-render the waveform on container resize
|
|
34312
|
-
if (typeof ResizeObserver === 'function') {
|
|
34313
|
-
const delay = this.createDelay(100);
|
|
34314
|
-
this.resizeObserver = new ResizeObserver(() => {
|
|
34315
|
-
delay()
|
|
34316
|
-
.then(() => this.onContainerResize())
|
|
34317
|
-
.catch(() => undefined);
|
|
34318
|
-
});
|
|
34319
|
-
this.resizeObserver.observe(this.scrollContainer);
|
|
34320
|
-
}
|
|
34321
|
-
}
|
|
34322
|
-
onContainerResize() {
|
|
34323
|
-
const width = this.parent.clientWidth;
|
|
34324
|
-
if (width === this.lastContainerWidth && this.options.height !== 'auto')
|
|
34325
|
-
return;
|
|
34326
|
-
this.lastContainerWidth = width;
|
|
34327
|
-
this.reRender();
|
|
34328
|
-
}
|
|
34329
|
-
initDrag() {
|
|
34330
|
-
this.subscriptions.push(makeDraggable(this.wrapper,
|
|
34331
|
-
// On drag
|
|
34332
|
-
(_, __, x) => {
|
|
34333
|
-
this.emit('drag', Math.max(0, Math.min(1, x / this.wrapper.getBoundingClientRect().width)));
|
|
34334
|
-
},
|
|
34335
|
-
// On start drag
|
|
34336
|
-
(x) => {
|
|
34337
|
-
this.isDragging = true;
|
|
34338
|
-
this.emit('dragstart', Math.max(0, Math.min(1, x / this.wrapper.getBoundingClientRect().width)));
|
|
34339
|
-
},
|
|
34340
|
-
// On end drag
|
|
34341
|
-
(x) => {
|
|
34342
|
-
this.isDragging = false;
|
|
34343
|
-
this.emit('dragend', Math.max(0, Math.min(1, x / this.wrapper.getBoundingClientRect().width)));
|
|
34344
|
-
}));
|
|
34345
|
-
}
|
|
34346
|
-
getHeight(optionsHeight, optionsSplitChannel) {
|
|
34347
|
-
var _a;
|
|
34348
|
-
const defaultHeight = 128;
|
|
34349
|
-
const numberOfChannels = ((_a = this.audioData) === null || _a === void 0 ? void 0 : _a.numberOfChannels) || 1;
|
|
34350
|
-
if (optionsHeight == null)
|
|
34351
|
-
return defaultHeight;
|
|
34352
|
-
if (!isNaN(Number(optionsHeight)))
|
|
34353
|
-
return Number(optionsHeight);
|
|
34354
|
-
if (optionsHeight === 'auto') {
|
|
34355
|
-
const height = this.parent.clientHeight || defaultHeight;
|
|
34356
|
-
if (optionsSplitChannel === null || optionsSplitChannel === void 0 ? void 0 : optionsSplitChannel.every((channel) => !channel.overlay))
|
|
34357
|
-
return height / numberOfChannels;
|
|
34358
|
-
return height;
|
|
34359
|
-
}
|
|
34360
|
-
return defaultHeight;
|
|
34361
|
-
}
|
|
34362
|
-
initHtml() {
|
|
34363
|
-
const div = document.createElement('div');
|
|
34364
|
-
const shadow = div.attachShadow({ mode: 'open' });
|
|
34365
|
-
const cspNonce = this.options.cspNonce && typeof this.options.cspNonce === 'string' ? this.options.cspNonce.replace(/"/g, '') : '';
|
|
34366
|
-
shadow.innerHTML = `
|
|
34367
|
-
<style${cspNonce ? ` nonce="${cspNonce}"` : ''}>
|
|
34368
|
-
:host {
|
|
34369
|
-
user-select: none;
|
|
34370
|
-
min-width: 1px;
|
|
34371
|
-
}
|
|
34372
|
-
:host audio {
|
|
34373
|
-
display: block;
|
|
34374
|
-
width: 100%;
|
|
34375
|
-
}
|
|
34376
|
-
:host .scroll {
|
|
34377
|
-
overflow-x: auto;
|
|
34378
|
-
overflow-y: hidden;
|
|
34379
|
-
width: 100%;
|
|
34380
|
-
position: relative;
|
|
34381
|
-
}
|
|
34382
|
-
:host .noScrollbar {
|
|
34383
|
-
scrollbar-color: transparent;
|
|
34384
|
-
scrollbar-width: none;
|
|
34385
|
-
}
|
|
34386
|
-
:host .noScrollbar::-webkit-scrollbar {
|
|
34387
|
-
display: none;
|
|
34388
|
-
-webkit-appearance: none;
|
|
34389
|
-
}
|
|
34390
|
-
:host .wrapper {
|
|
34391
|
-
position: relative;
|
|
34392
|
-
overflow: visible;
|
|
34393
|
-
z-index: 2;
|
|
34394
|
-
}
|
|
34395
|
-
:host .canvases {
|
|
34396
|
-
min-height: ${this.getHeight(this.options.height, this.options.splitChannels)}px;
|
|
34397
|
-
}
|
|
34398
|
-
:host .canvases > div {
|
|
34399
|
-
position: relative;
|
|
34400
|
-
}
|
|
34401
|
-
:host canvas {
|
|
34402
|
-
display: block;
|
|
34403
|
-
position: absolute;
|
|
34404
|
-
top: 0;
|
|
34405
|
-
image-rendering: pixelated;
|
|
34406
|
-
}
|
|
34407
|
-
:host .progress {
|
|
34408
|
-
pointer-events: none;
|
|
34409
|
-
position: absolute;
|
|
34410
|
-
z-index: 2;
|
|
34411
|
-
top: 0;
|
|
34412
|
-
left: 0;
|
|
34413
|
-
width: 0;
|
|
34414
|
-
height: 100%;
|
|
34415
|
-
overflow: hidden;
|
|
34416
|
-
}
|
|
34417
|
-
:host .progress > div {
|
|
34418
|
-
position: relative;
|
|
34419
|
-
}
|
|
34420
|
-
:host .cursor {
|
|
34421
|
-
pointer-events: none;
|
|
34422
|
-
position: absolute;
|
|
34423
|
-
z-index: 5;
|
|
34424
|
-
top: 0;
|
|
34425
|
-
left: 0;
|
|
34426
|
-
height: 100%;
|
|
34427
|
-
border-radius: 2px;
|
|
34428
|
-
}
|
|
34429
|
-
</style>
|
|
34430
|
-
|
|
34431
|
-
<div class="scroll" part="scroll">
|
|
34432
|
-
<div class="wrapper" part="wrapper">
|
|
34433
|
-
<div class="canvases" part="canvases"></div>
|
|
34434
|
-
<div class="progress" part="progress"></div>
|
|
34435
|
-
<div class="cursor" part="cursor"></div>
|
|
34436
|
-
</div>
|
|
34437
|
-
</div>
|
|
34438
|
-
`;
|
|
34439
|
-
return [div, shadow];
|
|
34440
|
-
}
|
|
34441
|
-
/** Wavesurfer itself calls this method. Do not call it manually. */
|
|
34442
|
-
setOptions(options) {
|
|
34443
|
-
if (this.options.container !== options.container) {
|
|
34444
|
-
const newParent = this.parentFromOptionsContainer(options.container);
|
|
34445
|
-
newParent.appendChild(this.container);
|
|
34446
|
-
this.parent = newParent;
|
|
34447
|
-
}
|
|
34448
|
-
if (options.dragToSeek === true || typeof this.options.dragToSeek === 'object') {
|
|
34449
|
-
this.initDrag();
|
|
34450
|
-
}
|
|
34451
|
-
this.options = options;
|
|
34452
|
-
// Re-render the waveform
|
|
34453
|
-
this.reRender();
|
|
34454
|
-
}
|
|
34455
|
-
getWrapper() {
|
|
34456
|
-
return this.wrapper;
|
|
34457
|
-
}
|
|
34458
|
-
getWidth() {
|
|
34459
|
-
return this.scrollContainer.clientWidth;
|
|
34460
|
-
}
|
|
34461
|
-
getScroll() {
|
|
34462
|
-
return this.scrollContainer.scrollLeft;
|
|
34463
|
-
}
|
|
34464
|
-
setScroll(pixels) {
|
|
34465
|
-
this.scrollContainer.scrollLeft = pixels;
|
|
34466
|
-
}
|
|
34467
|
-
setScrollPercentage(percent) {
|
|
34468
|
-
const { scrollWidth } = this.scrollContainer;
|
|
34469
|
-
const scrollStart = scrollWidth * percent;
|
|
34470
|
-
this.setScroll(scrollStart);
|
|
34471
|
-
}
|
|
34472
|
-
destroy() {
|
|
34473
|
-
var _a, _b;
|
|
34474
|
-
this.subscriptions.forEach((unsubscribe) => unsubscribe());
|
|
34475
|
-
this.container.remove();
|
|
34476
|
-
(_a = this.resizeObserver) === null || _a === void 0 ? void 0 : _a.disconnect();
|
|
34477
|
-
(_b = this.unsubscribeOnScroll) === null || _b === void 0 ? void 0 : _b.forEach((unsubscribe) => unsubscribe());
|
|
34478
|
-
this.unsubscribeOnScroll = [];
|
|
34479
|
-
}
|
|
34480
|
-
createDelay(delayMs = 10) {
|
|
34481
|
-
let timeout;
|
|
34482
|
-
let reject;
|
|
34483
|
-
const onClear = () => {
|
|
34484
|
-
if (timeout)
|
|
34485
|
-
clearTimeout(timeout);
|
|
34486
|
-
if (reject)
|
|
34487
|
-
reject();
|
|
34488
|
-
};
|
|
34489
|
-
this.timeouts.push(onClear);
|
|
34490
|
-
return () => {
|
|
34491
|
-
return new Promise((resolveFn, rejectFn) => {
|
|
34492
|
-
onClear();
|
|
34493
|
-
reject = rejectFn;
|
|
34494
|
-
timeout = setTimeout(() => {
|
|
34495
|
-
timeout = undefined;
|
|
34496
|
-
reject = undefined;
|
|
34497
|
-
resolveFn();
|
|
34498
|
-
}, delayMs);
|
|
34499
|
-
});
|
|
34500
|
-
};
|
|
34501
|
-
}
|
|
34502
|
-
// Convert array of color values to linear gradient
|
|
34503
|
-
convertColorValues(color) {
|
|
34504
|
-
if (!Array.isArray(color))
|
|
34505
|
-
return color || '';
|
|
34506
|
-
if (color.length < 2)
|
|
34507
|
-
return color[0] || '';
|
|
34508
|
-
const canvasElement = document.createElement('canvas');
|
|
34509
|
-
const ctx = canvasElement.getContext('2d');
|
|
34510
|
-
const gradientHeight = canvasElement.height * (window.devicePixelRatio || 1);
|
|
34511
|
-
const gradient = ctx.createLinearGradient(0, 0, 0, gradientHeight);
|
|
34512
|
-
const colorStopPercentage = 1 / (color.length - 1);
|
|
34513
|
-
color.forEach((color, index) => {
|
|
34514
|
-
const offset = index * colorStopPercentage;
|
|
34515
|
-
gradient.addColorStop(offset, color);
|
|
34516
|
-
});
|
|
34517
|
-
return gradient;
|
|
34518
|
-
}
|
|
34519
|
-
getPixelRatio() {
|
|
34520
|
-
return Math.max(1, window.devicePixelRatio || 1);
|
|
34521
|
-
}
|
|
34522
|
-
renderBarWaveform(channelData, options, ctx, vScale) {
|
|
34523
|
-
const topChannel = channelData[0];
|
|
34524
|
-
const bottomChannel = channelData[1] || channelData[0];
|
|
34525
|
-
const length = topChannel.length;
|
|
34526
|
-
const { width, height } = ctx.canvas;
|
|
34527
|
-
const halfHeight = height / 2;
|
|
34528
|
-
const pixelRatio = this.getPixelRatio();
|
|
34529
|
-
const barWidth = options.barWidth ? options.barWidth * pixelRatio : 1;
|
|
34530
|
-
const barGap = options.barGap ? options.barGap * pixelRatio : options.barWidth ? barWidth / 2 : 0;
|
|
34531
|
-
const barRadius = options.barRadius || 0;
|
|
34532
|
-
const barIndexScale = width / (barWidth + barGap) / length;
|
|
34533
|
-
const rectFn = barRadius && 'roundRect' in ctx ? 'roundRect' : 'rect';
|
|
34534
|
-
ctx.beginPath();
|
|
34535
|
-
let prevX = 0;
|
|
34536
|
-
let maxTop = 0;
|
|
34537
|
-
let maxBottom = 0;
|
|
34538
|
-
for (let i = 0; i <= length; i++) {
|
|
34539
|
-
const x = Math.round(i * barIndexScale);
|
|
34540
|
-
if (x > prevX) {
|
|
34541
|
-
const topBarHeight = Math.round(maxTop * halfHeight * vScale);
|
|
34542
|
-
const bottomBarHeight = Math.round(maxBottom * halfHeight * vScale);
|
|
34543
|
-
const barHeight = topBarHeight + bottomBarHeight || 1;
|
|
34544
|
-
// Vertical alignment
|
|
34545
|
-
let y = halfHeight - topBarHeight;
|
|
34546
|
-
if (options.barAlign === 'top') {
|
|
34547
|
-
y = 0;
|
|
34548
|
-
}
|
|
34549
|
-
else if (options.barAlign === 'bottom') {
|
|
34550
|
-
y = height - barHeight;
|
|
34551
|
-
}
|
|
34552
|
-
ctx[rectFn](prevX * (barWidth + barGap), y, barWidth, barHeight, barRadius);
|
|
34553
|
-
prevX = x;
|
|
34554
|
-
maxTop = 0;
|
|
34555
|
-
maxBottom = 0;
|
|
34556
|
-
}
|
|
34557
|
-
const magnitudeTop = Math.abs(topChannel[i] || 0);
|
|
34558
|
-
const magnitudeBottom = Math.abs(bottomChannel[i] || 0);
|
|
34559
|
-
if (magnitudeTop > maxTop)
|
|
34560
|
-
maxTop = magnitudeTop;
|
|
34561
|
-
if (magnitudeBottom > maxBottom)
|
|
34562
|
-
maxBottom = magnitudeBottom;
|
|
34563
|
-
}
|
|
34564
|
-
ctx.fill();
|
|
34565
|
-
ctx.closePath();
|
|
34566
|
-
}
|
|
34567
|
-
renderLineWaveform(channelData, _options, ctx, vScale) {
|
|
34568
|
-
const drawChannel = (index) => {
|
|
34569
|
-
const channel = channelData[index] || channelData[0];
|
|
34570
|
-
const length = channel.length;
|
|
34571
|
-
const { height } = ctx.canvas;
|
|
34572
|
-
const halfHeight = height / 2;
|
|
34573
|
-
const hScale = ctx.canvas.width / length;
|
|
34574
|
-
ctx.moveTo(0, halfHeight);
|
|
34575
|
-
let prevX = 0;
|
|
34576
|
-
let max = 0;
|
|
34577
|
-
for (let i = 0; i <= length; i++) {
|
|
34578
|
-
const x = Math.round(i * hScale);
|
|
34579
|
-
if (x > prevX) {
|
|
34580
|
-
const h = Math.round(max * halfHeight * vScale) || 1;
|
|
34581
|
-
const y = halfHeight + h * (index === 0 ? -1 : 1);
|
|
34582
|
-
ctx.lineTo(prevX, y);
|
|
34583
|
-
prevX = x;
|
|
34584
|
-
max = 0;
|
|
34585
|
-
}
|
|
34586
|
-
const value = Math.abs(channel[i] || 0);
|
|
34587
|
-
if (value > max)
|
|
34588
|
-
max = value;
|
|
34589
|
-
}
|
|
34590
|
-
ctx.lineTo(prevX, halfHeight);
|
|
34591
|
-
};
|
|
34592
|
-
ctx.beginPath();
|
|
34593
|
-
drawChannel(0);
|
|
34594
|
-
drawChannel(1);
|
|
34595
|
-
ctx.fill();
|
|
34596
|
-
ctx.closePath();
|
|
34597
|
-
}
|
|
34598
|
-
renderWaveform(channelData, options, ctx) {
|
|
34599
|
-
ctx.fillStyle = this.convertColorValues(options.waveColor);
|
|
34600
|
-
// Custom rendering function
|
|
34601
|
-
if (options.renderFunction) {
|
|
34602
|
-
options.renderFunction(channelData, ctx);
|
|
34603
|
-
return;
|
|
34604
|
-
}
|
|
34605
|
-
// Vertical scaling
|
|
34606
|
-
let vScale = options.barHeight || 1;
|
|
34607
|
-
if (options.normalize) {
|
|
34608
|
-
const max = Array.from(channelData[0]).reduce((max, value) => Math.max(max, Math.abs(value)), 0);
|
|
34609
|
-
vScale = max ? 1 / max : 1;
|
|
34610
|
-
}
|
|
34611
|
-
// Render waveform as bars
|
|
34612
|
-
if (options.barWidth || options.barGap || options.barAlign) {
|
|
34613
|
-
this.renderBarWaveform(channelData, options, ctx, vScale);
|
|
34614
|
-
return;
|
|
34615
|
-
}
|
|
34616
|
-
// Render waveform as a polyline
|
|
34617
|
-
this.renderLineWaveform(channelData, options, ctx, vScale);
|
|
34618
|
-
}
|
|
34619
|
-
renderSingleCanvas(data, options, width, height, offset, canvasContainer, progressContainer) {
|
|
34620
|
-
const pixelRatio = this.getPixelRatio();
|
|
34621
|
-
const canvas = document.createElement('canvas');
|
|
34622
|
-
canvas.width = Math.round(width * pixelRatio);
|
|
34623
|
-
canvas.height = Math.round(height * pixelRatio);
|
|
34624
|
-
canvas.style.width = `${width}px`;
|
|
34625
|
-
canvas.style.height = `${height}px`;
|
|
34626
|
-
canvas.style.left = `${Math.round(offset)}px`;
|
|
34627
|
-
canvasContainer.appendChild(canvas);
|
|
34628
|
-
const ctx = canvas.getContext('2d');
|
|
34629
|
-
this.renderWaveform(data, options, ctx);
|
|
34630
|
-
// Draw a progress canvas
|
|
34631
|
-
if (canvas.width > 0 && canvas.height > 0) {
|
|
34632
|
-
const progressCanvas = canvas.cloneNode();
|
|
34633
|
-
const progressCtx = progressCanvas.getContext('2d');
|
|
34634
|
-
progressCtx.drawImage(canvas, 0, 0);
|
|
34635
|
-
// Set the composition method to draw only where the waveform is drawn
|
|
34636
|
-
progressCtx.globalCompositeOperation = 'source-in';
|
|
34637
|
-
progressCtx.fillStyle = this.convertColorValues(options.progressColor);
|
|
34638
|
-
// This rectangle acts as a mask thanks to the composition method
|
|
34639
|
-
progressCtx.fillRect(0, 0, canvas.width, canvas.height);
|
|
34640
|
-
progressContainer.appendChild(progressCanvas);
|
|
34641
|
-
}
|
|
34642
|
-
}
|
|
34643
|
-
renderMultiCanvas(channelData, options, width, height, canvasContainer, progressContainer) {
|
|
34644
|
-
const pixelRatio = this.getPixelRatio();
|
|
34645
|
-
const { clientWidth } = this.scrollContainer;
|
|
34646
|
-
const totalWidth = width / pixelRatio;
|
|
34647
|
-
let singleCanvasWidth = Math.min(Renderer.MAX_CANVAS_WIDTH, clientWidth, totalWidth);
|
|
34648
|
-
let drawnIndexes = {};
|
|
34649
|
-
// Adjust width to avoid gaps between canvases when using bars
|
|
34650
|
-
if (options.barWidth || options.barGap) {
|
|
34651
|
-
const barWidth = options.barWidth || 0.5;
|
|
34652
|
-
const barGap = options.barGap || barWidth / 2;
|
|
34653
|
-
const totalBarWidth = barWidth + barGap;
|
|
34654
|
-
if (singleCanvasWidth % totalBarWidth !== 0) {
|
|
34655
|
-
singleCanvasWidth = Math.floor(singleCanvasWidth / totalBarWidth) * totalBarWidth;
|
|
34656
|
-
}
|
|
34657
|
-
}
|
|
34658
|
-
// Nothing to render
|
|
34659
|
-
if (singleCanvasWidth === 0)
|
|
34660
|
-
return;
|
|
34661
|
-
// Draw a single canvas
|
|
34662
|
-
const draw = (index) => {
|
|
34663
|
-
if (index < 0 || index >= numCanvases)
|
|
34664
|
-
return;
|
|
34665
|
-
if (drawnIndexes[index])
|
|
34666
|
-
return;
|
|
34667
|
-
drawnIndexes[index] = true;
|
|
34668
|
-
const offset = index * singleCanvasWidth;
|
|
34669
|
-
let clampedWidth = Math.min(totalWidth - offset, singleCanvasWidth);
|
|
34670
|
-
// Clamp the width to the bar grid to avoid empty canvases at the end
|
|
34671
|
-
if (options.barWidth || options.barGap) {
|
|
34672
|
-
const barWidth = options.barWidth || 0.5;
|
|
34673
|
-
const barGap = options.barGap || barWidth / 2;
|
|
34674
|
-
const totalBarWidth = barWidth + barGap;
|
|
34675
|
-
clampedWidth = Math.floor(clampedWidth / totalBarWidth) * totalBarWidth;
|
|
34676
|
-
}
|
|
34677
|
-
if (clampedWidth <= 0)
|
|
34678
|
-
return;
|
|
34679
|
-
const data = channelData.map((channel) => {
|
|
34680
|
-
const start = Math.floor((offset / totalWidth) * channel.length);
|
|
34681
|
-
const end = Math.floor(((offset + clampedWidth) / totalWidth) * channel.length);
|
|
34682
|
-
return channel.slice(start, end);
|
|
34683
|
-
});
|
|
34684
|
-
this.renderSingleCanvas(data, options, clampedWidth, height, offset, canvasContainer, progressContainer);
|
|
34685
|
-
};
|
|
34686
|
-
// Clear canvases to avoid too many DOM nodes
|
|
34687
|
-
const clearCanvases = () => {
|
|
34688
|
-
if (Object.keys(drawnIndexes).length > Renderer.MAX_NODES) {
|
|
34689
|
-
canvasContainer.innerHTML = '';
|
|
34690
|
-
progressContainer.innerHTML = '';
|
|
34691
|
-
drawnIndexes = {};
|
|
34692
|
-
}
|
|
34693
|
-
};
|
|
34694
|
-
// Calculate how many canvases to render
|
|
34695
|
-
const numCanvases = Math.ceil(totalWidth / singleCanvasWidth);
|
|
34696
|
-
// Render all canvases if the waveform doesn't scroll
|
|
34697
|
-
if (!this.isScrollable) {
|
|
34698
|
-
for (let i = 0; i < numCanvases; i++) {
|
|
34699
|
-
draw(i);
|
|
34700
|
-
}
|
|
34701
|
-
return;
|
|
34702
|
-
}
|
|
34703
|
-
// Lazy rendering
|
|
34704
|
-
const viewPosition = this.scrollContainer.scrollLeft / totalWidth;
|
|
34705
|
-
const startCanvas = Math.floor(viewPosition * numCanvases);
|
|
34706
|
-
// Draw the canvases in the viewport first
|
|
34707
|
-
draw(startCanvas - 1);
|
|
34708
|
-
draw(startCanvas);
|
|
34709
|
-
draw(startCanvas + 1);
|
|
34710
|
-
// Subscribe to the scroll event to draw additional canvases
|
|
34711
|
-
if (numCanvases > 1) {
|
|
34712
|
-
const unsubscribe = this.on('scroll', () => {
|
|
34713
|
-
const { scrollLeft } = this.scrollContainer;
|
|
34714
|
-
const canvasIndex = Math.floor((scrollLeft / totalWidth) * numCanvases);
|
|
34715
|
-
clearCanvases();
|
|
34716
|
-
draw(canvasIndex - 1);
|
|
34717
|
-
draw(canvasIndex);
|
|
34718
|
-
draw(canvasIndex + 1);
|
|
34719
|
-
});
|
|
34720
|
-
this.unsubscribeOnScroll.push(unsubscribe);
|
|
34721
|
-
}
|
|
34722
|
-
}
|
|
34723
|
-
renderChannel(channelData, _a, width, channelIndex) {
|
|
34724
|
-
var { overlay } = _a, options = __rest(_a, ["overlay"]);
|
|
34725
|
-
// A container for canvases
|
|
34726
|
-
const canvasContainer = document.createElement('div');
|
|
34727
|
-
const height = this.getHeight(options.height, options.splitChannels);
|
|
34728
|
-
canvasContainer.style.height = `${height}px`;
|
|
34729
|
-
if (overlay && channelIndex > 0) {
|
|
34730
|
-
canvasContainer.style.marginTop = `-${height}px`;
|
|
34731
|
-
}
|
|
34732
|
-
this.canvasWrapper.style.minHeight = `${height}px`;
|
|
34733
|
-
this.canvasWrapper.appendChild(canvasContainer);
|
|
34734
|
-
// A container for progress canvases
|
|
34735
|
-
const progressContainer = canvasContainer.cloneNode();
|
|
34736
|
-
this.progressWrapper.appendChild(progressContainer);
|
|
34737
|
-
// Render the waveform
|
|
34738
|
-
this.renderMultiCanvas(channelData, options, width, height, canvasContainer, progressContainer);
|
|
34739
|
-
}
|
|
34740
|
-
render(audioData) {
|
|
34741
|
-
return __awaiter$3(this, void 0, void 0, function* () {
|
|
34742
|
-
var _a;
|
|
34743
|
-
// Clear previous timeouts
|
|
34744
|
-
this.timeouts.forEach((clear) => clear());
|
|
34745
|
-
this.timeouts = [];
|
|
34746
|
-
// Clear the canvases
|
|
34747
|
-
this.canvasWrapper.innerHTML = '';
|
|
34748
|
-
this.progressWrapper.innerHTML = '';
|
|
34749
|
-
// Width
|
|
34750
|
-
if (this.options.width != null) {
|
|
34751
|
-
this.scrollContainer.style.width =
|
|
34752
|
-
typeof this.options.width === 'number' ? `${this.options.width}px` : this.options.width;
|
|
34753
|
-
}
|
|
34754
|
-
// Determine the width of the waveform
|
|
34755
|
-
const pixelRatio = this.getPixelRatio();
|
|
34756
|
-
const parentWidth = this.scrollContainer.clientWidth;
|
|
34757
|
-
const scrollWidth = Math.ceil(audioData.duration * (this.options.minPxPerSec || 0));
|
|
34758
|
-
// Whether the container should scroll
|
|
34759
|
-
this.isScrollable = scrollWidth > parentWidth;
|
|
34760
|
-
const useParentWidth = this.options.fillParent && !this.isScrollable;
|
|
34761
|
-
// Width of the waveform in pixels
|
|
34762
|
-
const width = (useParentWidth ? parentWidth : scrollWidth) * pixelRatio;
|
|
34763
|
-
// Set the width of the wrapper
|
|
34764
|
-
this.wrapper.style.width = useParentWidth ? '100%' : `${scrollWidth}px`;
|
|
34765
|
-
// Set additional styles
|
|
34766
|
-
this.scrollContainer.style.overflowX = this.isScrollable ? 'auto' : 'hidden';
|
|
34767
|
-
this.scrollContainer.classList.toggle('noScrollbar', !!this.options.hideScrollbar);
|
|
34768
|
-
this.cursor.style.backgroundColor = `${this.options.cursorColor || this.options.progressColor}`;
|
|
34769
|
-
this.cursor.style.width = `${this.options.cursorWidth}px`;
|
|
34770
|
-
this.audioData = audioData;
|
|
34771
|
-
this.emit('render');
|
|
34772
|
-
// Render the waveform
|
|
34773
|
-
if (this.options.splitChannels) {
|
|
34774
|
-
// Render a waveform for each channel
|
|
34775
|
-
for (let i = 0; i < audioData.numberOfChannels; i++) {
|
|
34776
|
-
const options = Object.assign(Object.assign({}, this.options), (_a = this.options.splitChannels) === null || _a === void 0 ? void 0 : _a[i]);
|
|
34777
|
-
this.renderChannel([audioData.getChannelData(i)], options, width, i);
|
|
34778
|
-
}
|
|
34779
|
-
}
|
|
34780
|
-
else {
|
|
34781
|
-
// Render a single waveform for the first two channels (left and right)
|
|
34782
|
-
const channels = [audioData.getChannelData(0)];
|
|
34783
|
-
if (audioData.numberOfChannels > 1)
|
|
34784
|
-
channels.push(audioData.getChannelData(1));
|
|
34785
|
-
this.renderChannel(channels, this.options, width, 0);
|
|
34786
|
-
}
|
|
34787
|
-
// Must be emitted asynchronously for backward compatibility
|
|
34788
|
-
Promise.resolve().then(() => this.emit('rendered'));
|
|
34789
|
-
});
|
|
34790
|
-
}
|
|
34791
|
-
reRender() {
|
|
34792
|
-
this.unsubscribeOnScroll.forEach((unsubscribe) => unsubscribe());
|
|
34793
|
-
this.unsubscribeOnScroll = [];
|
|
34794
|
-
// Return if the waveform has not been rendered yet
|
|
34795
|
-
if (!this.audioData)
|
|
34796
|
-
return;
|
|
34797
|
-
// Remember the current cursor position
|
|
34798
|
-
const { scrollWidth } = this.scrollContainer;
|
|
34799
|
-
const { right: before } = this.progressWrapper.getBoundingClientRect();
|
|
34800
|
-
// Re-render the waveform
|
|
34801
|
-
this.render(this.audioData);
|
|
34802
|
-
// Adjust the scroll position so that the cursor stays in the same place
|
|
34803
|
-
if (this.isScrollable && scrollWidth !== this.scrollContainer.scrollWidth) {
|
|
34804
|
-
const { right: after } = this.progressWrapper.getBoundingClientRect();
|
|
34805
|
-
let delta = after - before;
|
|
34806
|
-
// to limit compounding floating-point drift
|
|
34807
|
-
// we need to round to the half px furthest from 0
|
|
34808
|
-
delta *= 2;
|
|
34809
|
-
delta = delta < 0 ? Math.floor(delta) : Math.ceil(delta);
|
|
34810
|
-
delta /= 2;
|
|
34811
|
-
this.scrollContainer.scrollLeft += delta;
|
|
34812
|
-
}
|
|
34813
|
-
}
|
|
34814
|
-
zoom(minPxPerSec) {
|
|
34815
|
-
this.options.minPxPerSec = minPxPerSec;
|
|
34816
|
-
this.reRender();
|
|
34817
|
-
}
|
|
34818
|
-
scrollIntoView(progress, isPlaying = false) {
|
|
34819
|
-
const { scrollLeft, scrollWidth, clientWidth } = this.scrollContainer;
|
|
34820
|
-
const progressWidth = progress * scrollWidth;
|
|
34821
|
-
const startEdge = scrollLeft;
|
|
34822
|
-
const endEdge = scrollLeft + clientWidth;
|
|
34823
|
-
const middle = clientWidth / 2;
|
|
34824
|
-
if (this.isDragging) {
|
|
34825
|
-
// Scroll when dragging close to the edge of the viewport
|
|
34826
|
-
const minGap = 30;
|
|
34827
|
-
if (progressWidth + minGap > endEdge) {
|
|
34828
|
-
this.scrollContainer.scrollLeft += minGap;
|
|
34829
|
-
}
|
|
34830
|
-
else if (progressWidth - minGap < startEdge) {
|
|
34831
|
-
this.scrollContainer.scrollLeft -= minGap;
|
|
34832
|
-
}
|
|
34833
|
-
}
|
|
34834
|
-
else {
|
|
34835
|
-
if (progressWidth < startEdge || progressWidth > endEdge) {
|
|
34836
|
-
this.scrollContainer.scrollLeft = progressWidth - (this.options.autoCenter ? middle : 0);
|
|
34837
|
-
}
|
|
34838
|
-
// Keep the cursor centered when playing
|
|
34839
|
-
const center = progressWidth - scrollLeft - middle;
|
|
34840
|
-
if (isPlaying && this.options.autoCenter && center > 0) {
|
|
34841
|
-
this.scrollContainer.scrollLeft += Math.min(center, 10);
|
|
34842
|
-
}
|
|
34843
|
-
}
|
|
34844
|
-
// Emit the scroll event
|
|
34845
|
-
{
|
|
34846
|
-
const newScroll = this.scrollContainer.scrollLeft;
|
|
34847
|
-
const startX = newScroll / scrollWidth;
|
|
34848
|
-
const endX = (newScroll + clientWidth) / scrollWidth;
|
|
34849
|
-
this.emit('scroll', startX, endX, newScroll, newScroll + clientWidth);
|
|
34850
|
-
}
|
|
34851
|
-
}
|
|
34852
|
-
renderProgress(progress, isPlaying) {
|
|
34853
|
-
if (isNaN(progress))
|
|
34854
|
-
return;
|
|
34855
|
-
const percents = progress * 100;
|
|
34856
|
-
this.canvasWrapper.style.clipPath = `polygon(${percents}% 0%, 100% 0%, 100% 100%, ${percents}% 100%)`;
|
|
34857
|
-
this.progressWrapper.style.width = `${percents}%`;
|
|
34858
|
-
this.cursor.style.left = `${percents}%`;
|
|
34859
|
-
this.cursor.style.transform = this.options.cursorWidth
|
|
34860
|
-
? `translateX(-${progress * this.options.cursorWidth}px)`
|
|
34861
|
-
: '';
|
|
34862
|
-
if (this.isScrollable && this.options.autoScroll) {
|
|
34863
|
-
this.scrollIntoView(progress, isPlaying);
|
|
34864
|
-
}
|
|
34865
|
-
}
|
|
34866
|
-
exportImage(format, quality, type) {
|
|
34867
|
-
return __awaiter$3(this, void 0, void 0, function* () {
|
|
34868
|
-
const canvases = this.canvasWrapper.querySelectorAll('canvas');
|
|
34869
|
-
if (!canvases.length) {
|
|
34870
|
-
throw new Error('No waveform data');
|
|
34871
|
-
}
|
|
34872
|
-
// Data URLs
|
|
34873
|
-
if (type === 'dataURL') {
|
|
34874
|
-
const images = Array.from(canvases).map((canvas) => canvas.toDataURL(format, quality));
|
|
34875
|
-
return Promise.resolve(images);
|
|
34876
|
-
}
|
|
34877
|
-
// Blobs
|
|
34878
|
-
return Promise.all(Array.from(canvases).map((canvas) => {
|
|
34879
|
-
return new Promise((resolve, reject) => {
|
|
34880
|
-
canvas.toBlob((blob) => {
|
|
34881
|
-
if (blob) {
|
|
34882
|
-
resolve(blob);
|
|
34883
|
-
}
|
|
34884
|
-
else {
|
|
34885
|
-
reject(new Error('Could not export image'));
|
|
34886
|
-
}
|
|
34887
|
-
}, format, quality);
|
|
34888
|
-
});
|
|
34889
|
-
}));
|
|
34890
|
-
});
|
|
34891
|
-
}
|
|
34892
|
-
}
|
|
34893
|
-
Renderer.MAX_CANVAS_WIDTH = 8000;
|
|
34894
|
-
Renderer.MAX_NODES = 10;
|
|
34895
|
-
|
|
34896
|
-
class Timer extends EventEmitter {
|
|
34897
|
-
constructor() {
|
|
34898
|
-
super(...arguments);
|
|
34899
|
-
this.unsubscribe = () => undefined;
|
|
34900
|
-
}
|
|
34901
|
-
start() {
|
|
34902
|
-
this.unsubscribe = this.on('tick', () => {
|
|
34903
|
-
requestAnimationFrame(() => {
|
|
34904
|
-
this.emit('tick');
|
|
34905
|
-
});
|
|
34906
|
-
});
|
|
34907
|
-
this.emit('tick');
|
|
34908
|
-
}
|
|
34909
|
-
stop() {
|
|
34910
|
-
this.unsubscribe();
|
|
34911
|
-
}
|
|
34912
|
-
destroy() {
|
|
34913
|
-
this.unsubscribe();
|
|
34914
|
-
}
|
|
34915
|
-
}
|
|
34916
|
-
|
|
34917
|
-
var __awaiter$4 = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
34918
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
34919
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
34920
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
34921
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
34922
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
34923
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
34924
|
-
});
|
|
34925
|
-
};
|
|
34926
|
-
/**
|
|
34927
|
-
* A Web Audio buffer player emulating the behavior of an HTML5 Audio element.
|
|
34928
|
-
*/
|
|
34929
|
-
class WebAudioPlayer extends EventEmitter {
|
|
34930
|
-
constructor(audioContext = new AudioContext()) {
|
|
34931
|
-
super();
|
|
34932
|
-
this.bufferNode = null;
|
|
34933
|
-
this.playStartTime = 0;
|
|
34934
|
-
this.playedDuration = 0;
|
|
34935
|
-
this._muted = false;
|
|
34936
|
-
this._playbackRate = 1;
|
|
34937
|
-
this._duration = undefined;
|
|
34938
|
-
this.buffer = null;
|
|
34939
|
-
this.currentSrc = '';
|
|
34940
|
-
this.paused = true;
|
|
34941
|
-
this.crossOrigin = null;
|
|
34942
|
-
this.seeking = false;
|
|
34943
|
-
this.autoplay = false;
|
|
34944
|
-
/** Subscribe to an event. Returns an unsubscribe function. */
|
|
34945
|
-
this.addEventListener = this.on;
|
|
34946
|
-
/** Unsubscribe from an event */
|
|
34947
|
-
this.removeEventListener = this.un;
|
|
34948
|
-
this.audioContext = audioContext;
|
|
34949
|
-
this.gainNode = this.audioContext.createGain();
|
|
34950
|
-
this.gainNode.connect(this.audioContext.destination);
|
|
34951
|
-
}
|
|
34952
|
-
load() {
|
|
34953
|
-
return __awaiter$4(this, void 0, void 0, function* () {
|
|
34954
|
-
return;
|
|
34955
|
-
});
|
|
34956
|
-
}
|
|
34957
|
-
get src() {
|
|
34958
|
-
return this.currentSrc;
|
|
34959
|
-
}
|
|
34960
|
-
set src(value) {
|
|
34961
|
-
this.currentSrc = value;
|
|
34962
|
-
this._duration = undefined;
|
|
34963
|
-
if (!value) {
|
|
34964
|
-
this.buffer = null;
|
|
34965
|
-
this.emit('emptied');
|
|
34966
|
-
return;
|
|
34967
|
-
}
|
|
34968
|
-
fetch(value)
|
|
34969
|
-
.then((response) => {
|
|
34970
|
-
if (response.status >= 400) {
|
|
34971
|
-
throw new Error(`Failed to fetch ${value}: ${response.status} (${response.statusText})`);
|
|
34972
|
-
}
|
|
34973
|
-
return response.arrayBuffer();
|
|
34974
|
-
})
|
|
34975
|
-
.then((arrayBuffer) => {
|
|
34976
|
-
if (this.currentSrc !== value)
|
|
34977
|
-
return null;
|
|
34978
|
-
return this.audioContext.decodeAudioData(arrayBuffer);
|
|
34979
|
-
})
|
|
34980
|
-
.then((audioBuffer) => {
|
|
34981
|
-
if (this.currentSrc !== value)
|
|
34982
|
-
return;
|
|
34983
|
-
this.buffer = audioBuffer;
|
|
34984
|
-
this.emit('loadedmetadata');
|
|
34985
|
-
this.emit('canplay');
|
|
34986
|
-
if (this.autoplay)
|
|
34987
|
-
this.play();
|
|
34988
|
-
});
|
|
34989
|
-
}
|
|
34990
|
-
_play() {
|
|
34991
|
-
var _a;
|
|
34992
|
-
if (!this.paused)
|
|
34993
|
-
return;
|
|
34994
|
-
this.paused = false;
|
|
34995
|
-
(_a = this.bufferNode) === null || _a === void 0 ? void 0 : _a.disconnect();
|
|
34996
|
-
this.bufferNode = this.audioContext.createBufferSource();
|
|
34997
|
-
if (this.buffer) {
|
|
34998
|
-
this.bufferNode.buffer = this.buffer;
|
|
34999
|
-
}
|
|
35000
|
-
this.bufferNode.playbackRate.value = this._playbackRate;
|
|
35001
|
-
this.bufferNode.connect(this.gainNode);
|
|
35002
|
-
let currentPos = this.playedDuration * this._playbackRate;
|
|
35003
|
-
if (currentPos >= this.duration || currentPos < 0) {
|
|
35004
|
-
currentPos = 0;
|
|
35005
|
-
this.playedDuration = 0;
|
|
35006
|
-
}
|
|
35007
|
-
this.bufferNode.start(this.audioContext.currentTime, currentPos);
|
|
35008
|
-
this.playStartTime = this.audioContext.currentTime;
|
|
35009
|
-
this.bufferNode.onended = () => {
|
|
35010
|
-
if (this.currentTime >= this.duration) {
|
|
35011
|
-
this.pause();
|
|
35012
|
-
this.emit('ended');
|
|
35013
|
-
}
|
|
35014
|
-
};
|
|
35015
|
-
}
|
|
35016
|
-
_pause() {
|
|
35017
|
-
var _a;
|
|
35018
|
-
this.paused = true;
|
|
35019
|
-
(_a = this.bufferNode) === null || _a === void 0 ? void 0 : _a.stop();
|
|
35020
|
-
this.playedDuration += this.audioContext.currentTime - this.playStartTime;
|
|
35021
|
-
}
|
|
35022
|
-
play() {
|
|
35023
|
-
return __awaiter$4(this, void 0, void 0, function* () {
|
|
35024
|
-
if (!this.paused)
|
|
35025
|
-
return;
|
|
35026
|
-
this._play();
|
|
35027
|
-
this.emit('play');
|
|
35028
|
-
});
|
|
35029
|
-
}
|
|
35030
|
-
pause() {
|
|
35031
|
-
if (this.paused)
|
|
35032
|
-
return;
|
|
35033
|
-
this._pause();
|
|
35034
|
-
this.emit('pause');
|
|
35035
|
-
}
|
|
35036
|
-
stopAt(timeSeconds) {
|
|
35037
|
-
const delay = timeSeconds - this.currentTime;
|
|
35038
|
-
const currentBufferNode = this.bufferNode;
|
|
35039
|
-
currentBufferNode === null || currentBufferNode === void 0 ? void 0 : currentBufferNode.stop(this.audioContext.currentTime + delay);
|
|
35040
|
-
currentBufferNode === null || currentBufferNode === void 0 ? void 0 : currentBufferNode.addEventListener('ended', () => {
|
|
35041
|
-
if (currentBufferNode === this.bufferNode) {
|
|
35042
|
-
this.bufferNode = null;
|
|
35043
|
-
this.pause();
|
|
35044
|
-
}
|
|
35045
|
-
}, { once: true });
|
|
35046
|
-
}
|
|
35047
|
-
setSinkId(deviceId) {
|
|
35048
|
-
return __awaiter$4(this, void 0, void 0, function* () {
|
|
35049
|
-
const ac = this.audioContext;
|
|
35050
|
-
return ac.setSinkId(deviceId);
|
|
35051
|
-
});
|
|
35052
|
-
}
|
|
35053
|
-
get playbackRate() {
|
|
35054
|
-
return this._playbackRate;
|
|
35055
|
-
}
|
|
35056
|
-
set playbackRate(value) {
|
|
35057
|
-
this._playbackRate = value;
|
|
35058
|
-
if (this.bufferNode) {
|
|
35059
|
-
this.bufferNode.playbackRate.value = value;
|
|
35060
|
-
}
|
|
35061
|
-
}
|
|
35062
|
-
get currentTime() {
|
|
35063
|
-
const time = this.paused
|
|
35064
|
-
? this.playedDuration
|
|
35065
|
-
: this.playedDuration + (this.audioContext.currentTime - this.playStartTime);
|
|
35066
|
-
return time * this._playbackRate;
|
|
35067
|
-
}
|
|
35068
|
-
set currentTime(value) {
|
|
35069
|
-
const wasPlaying = !this.paused;
|
|
35070
|
-
if (wasPlaying)
|
|
35071
|
-
this._pause();
|
|
35072
|
-
this.playedDuration = value / this._playbackRate;
|
|
35073
|
-
if (wasPlaying)
|
|
35074
|
-
this._play();
|
|
35075
|
-
this.emit('seeking');
|
|
35076
|
-
this.emit('timeupdate');
|
|
35077
|
-
}
|
|
35078
|
-
get duration() {
|
|
35079
|
-
var _a, _b;
|
|
35080
|
-
return (_a = this._duration) !== null && _a !== void 0 ? _a : (((_b = this.buffer) === null || _b === void 0 ? void 0 : _b.duration) || 0);
|
|
35081
|
-
}
|
|
35082
|
-
set duration(value) {
|
|
35083
|
-
this._duration = value;
|
|
35084
|
-
}
|
|
35085
|
-
get volume() {
|
|
35086
|
-
return this.gainNode.gain.value;
|
|
35087
|
-
}
|
|
35088
|
-
set volume(value) {
|
|
35089
|
-
this.gainNode.gain.value = value;
|
|
35090
|
-
this.emit('volumechange');
|
|
35091
|
-
}
|
|
35092
|
-
get muted() {
|
|
35093
|
-
return this._muted;
|
|
35094
|
-
}
|
|
35095
|
-
set muted(value) {
|
|
35096
|
-
if (this._muted === value)
|
|
35097
|
-
return;
|
|
35098
|
-
this._muted = value;
|
|
35099
|
-
if (this._muted) {
|
|
35100
|
-
this.gainNode.disconnect();
|
|
35101
|
-
}
|
|
35102
|
-
else {
|
|
35103
|
-
this.gainNode.connect(this.audioContext.destination);
|
|
35104
|
-
}
|
|
35105
|
-
}
|
|
35106
|
-
canPlayType(mimeType) {
|
|
35107
|
-
return /^(audio|video)\//.test(mimeType);
|
|
35108
|
-
}
|
|
35109
|
-
/** Get the GainNode used to play the audio. Can be used to attach filters. */
|
|
35110
|
-
getGainNode() {
|
|
35111
|
-
return this.gainNode;
|
|
35112
|
-
}
|
|
35113
|
-
/** Get decoded audio */
|
|
35114
|
-
getChannelData() {
|
|
35115
|
-
const channels = [];
|
|
35116
|
-
if (!this.buffer)
|
|
35117
|
-
return channels;
|
|
35118
|
-
const numChannels = this.buffer.numberOfChannels;
|
|
35119
|
-
for (let i = 0; i < numChannels; i++) {
|
|
35120
|
-
channels.push(this.buffer.getChannelData(i));
|
|
35121
|
-
}
|
|
35122
|
-
return channels;
|
|
35123
|
-
}
|
|
35124
|
-
/**
|
|
35125
|
-
* Imitate `HTMLElement.removeAttribute` for compatibility with `Player`.
|
|
35126
|
-
*/
|
|
35127
|
-
removeAttribute(attrName) {
|
|
35128
|
-
switch (attrName) {
|
|
35129
|
-
case 'src':
|
|
35130
|
-
this.src = '';
|
|
35131
|
-
break;
|
|
35132
|
-
case 'playbackRate':
|
|
35133
|
-
this.playbackRate = 0;
|
|
35134
|
-
break;
|
|
35135
|
-
case 'currentTime':
|
|
35136
|
-
this.currentTime = 0;
|
|
35137
|
-
break;
|
|
35138
|
-
case 'duration':
|
|
35139
|
-
this.duration = 0;
|
|
35140
|
-
break;
|
|
35141
|
-
case 'volume':
|
|
35142
|
-
this.volume = 0;
|
|
35143
|
-
break;
|
|
35144
|
-
case 'muted':
|
|
35145
|
-
this.muted = false;
|
|
35146
|
-
break;
|
|
35147
|
-
}
|
|
35148
|
-
}
|
|
35149
|
-
}
|
|
35150
|
-
|
|
35151
|
-
var __awaiter$5 = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
35152
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
35153
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
35154
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
35155
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
35156
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
35157
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
35158
|
-
});
|
|
35159
|
-
};
|
|
35160
|
-
const defaultOptions = {
|
|
35161
|
-
waveColor: '#999',
|
|
35162
|
-
progressColor: '#555',
|
|
35163
|
-
cursorWidth: 1,
|
|
35164
|
-
minPxPerSec: 0,
|
|
35165
|
-
fillParent: true,
|
|
35166
|
-
interact: true,
|
|
35167
|
-
dragToSeek: false,
|
|
35168
|
-
autoScroll: true,
|
|
35169
|
-
autoCenter: true,
|
|
35170
|
-
sampleRate: 8000,
|
|
35171
|
-
};
|
|
35172
|
-
class WaveSurfer extends Player {
|
|
35173
|
-
/** Create a new WaveSurfer instance */
|
|
35174
|
-
static create(options) {
|
|
35175
|
-
return new WaveSurfer(options);
|
|
35176
|
-
}
|
|
35177
|
-
/** Create a new WaveSurfer instance */
|
|
35178
|
-
constructor(options) {
|
|
35179
|
-
const media = options.media ||
|
|
35180
|
-
(options.backend === 'WebAudio' ? new WebAudioPlayer() : undefined);
|
|
35181
|
-
super({
|
|
35182
|
-
media,
|
|
35183
|
-
mediaControls: options.mediaControls,
|
|
35184
|
-
autoplay: options.autoplay,
|
|
35185
|
-
playbackRate: options.audioRate,
|
|
35186
|
-
});
|
|
35187
|
-
this.plugins = [];
|
|
35188
|
-
this.decodedData = null;
|
|
35189
|
-
this.stopAtPosition = null;
|
|
35190
|
-
this.subscriptions = [];
|
|
35191
|
-
this.mediaSubscriptions = [];
|
|
35192
|
-
this.abortController = null;
|
|
35193
|
-
this.options = Object.assign({}, defaultOptions, options);
|
|
35194
|
-
this.timer = new Timer();
|
|
35195
|
-
const audioElement = media ? undefined : this.getMediaElement();
|
|
35196
|
-
this.renderer = new Renderer(this.options, audioElement);
|
|
35197
|
-
this.initPlayerEvents();
|
|
35198
|
-
this.initRendererEvents();
|
|
35199
|
-
this.initTimerEvents();
|
|
35200
|
-
this.initPlugins();
|
|
35201
|
-
// Read the initial URL before load has been called
|
|
35202
|
-
const initialUrl = this.options.url || this.getSrc() || '';
|
|
35203
|
-
// Init and load async to allow external events to be registered
|
|
35204
|
-
Promise.resolve().then(() => {
|
|
35205
|
-
this.emit('init');
|
|
35206
|
-
// Load audio if URL or an external media with an src is passed,
|
|
35207
|
-
// of render w/o audio if pre-decoded peaks and duration are provided
|
|
35208
|
-
const { peaks, duration } = this.options;
|
|
35209
|
-
if (initialUrl || (peaks && duration)) {
|
|
35210
|
-
// Swallow async errors because they cannot be caught from a constructor call.
|
|
35211
|
-
// Subscribe to the wavesurfer's error event to handle them.
|
|
35212
|
-
this.load(initialUrl, peaks, duration).catch(() => null);
|
|
35213
|
-
}
|
|
35214
|
-
});
|
|
35215
|
-
}
|
|
35216
|
-
updateProgress(currentTime = this.getCurrentTime()) {
|
|
35217
|
-
this.renderer.renderProgress(currentTime / this.getDuration(), this.isPlaying());
|
|
35218
|
-
return currentTime;
|
|
35219
|
-
}
|
|
35220
|
-
initTimerEvents() {
|
|
35221
|
-
// The timer fires every 16ms for a smooth progress animation
|
|
35222
|
-
this.subscriptions.push(this.timer.on('tick', () => {
|
|
35223
|
-
if (!this.isSeeking()) {
|
|
35224
|
-
const currentTime = this.updateProgress();
|
|
35225
|
-
this.emit('timeupdate', currentTime);
|
|
35226
|
-
this.emit('audioprocess', currentTime);
|
|
35227
|
-
// Pause audio when it reaches the stopAtPosition
|
|
35228
|
-
if (this.stopAtPosition != null && this.isPlaying() && currentTime >= this.stopAtPosition) {
|
|
35229
|
-
this.pause();
|
|
35230
|
-
}
|
|
35231
|
-
}
|
|
35232
|
-
}));
|
|
35233
|
-
}
|
|
35234
|
-
initPlayerEvents() {
|
|
35235
|
-
if (this.isPlaying()) {
|
|
35236
|
-
this.emit('play');
|
|
35237
|
-
this.timer.start();
|
|
35238
|
-
}
|
|
35239
|
-
this.mediaSubscriptions.push(this.onMediaEvent('timeupdate', () => {
|
|
35240
|
-
const currentTime = this.updateProgress();
|
|
35241
|
-
this.emit('timeupdate', currentTime);
|
|
35242
|
-
}), this.onMediaEvent('play', () => {
|
|
35243
|
-
this.emit('play');
|
|
35244
|
-
this.timer.start();
|
|
35245
|
-
}), this.onMediaEvent('pause', () => {
|
|
35246
|
-
this.emit('pause');
|
|
35247
|
-
this.timer.stop();
|
|
35248
|
-
this.stopAtPosition = null;
|
|
35249
|
-
}), this.onMediaEvent('emptied', () => {
|
|
35250
|
-
this.timer.stop();
|
|
35251
|
-
this.stopAtPosition = null;
|
|
35252
|
-
}), this.onMediaEvent('ended', () => {
|
|
35253
|
-
this.emit('timeupdate', this.getDuration());
|
|
35254
|
-
this.emit('finish');
|
|
35255
|
-
this.stopAtPosition = null;
|
|
35256
|
-
}), this.onMediaEvent('seeking', () => {
|
|
35257
|
-
this.emit('seeking', this.getCurrentTime());
|
|
35258
|
-
}), this.onMediaEvent('error', () => {
|
|
35259
|
-
var _a;
|
|
35260
|
-
this.emit('error', ((_a = this.getMediaElement().error) !== null && _a !== void 0 ? _a : new Error('Media error')));
|
|
35261
|
-
this.stopAtPosition = null;
|
|
35262
|
-
}));
|
|
35263
|
-
}
|
|
35264
|
-
initRendererEvents() {
|
|
35265
|
-
this.subscriptions.push(
|
|
35266
|
-
// Seek on click
|
|
35267
|
-
this.renderer.on('click', (relativeX, relativeY) => {
|
|
35268
|
-
if (this.options.interact) {
|
|
35269
|
-
this.seekTo(relativeX);
|
|
35270
|
-
this.emit('interaction', relativeX * this.getDuration());
|
|
35271
|
-
this.emit('click', relativeX, relativeY);
|
|
35272
|
-
}
|
|
35273
|
-
}),
|
|
35274
|
-
// Double click
|
|
35275
|
-
this.renderer.on('dblclick', (relativeX, relativeY) => {
|
|
35276
|
-
this.emit('dblclick', relativeX, relativeY);
|
|
35277
|
-
}),
|
|
35278
|
-
// Scroll
|
|
35279
|
-
this.renderer.on('scroll', (startX, endX, scrollLeft, scrollRight) => {
|
|
35280
|
-
const duration = this.getDuration();
|
|
35281
|
-
this.emit('scroll', startX * duration, endX * duration, scrollLeft, scrollRight);
|
|
35282
|
-
}),
|
|
35283
|
-
// Redraw
|
|
35284
|
-
this.renderer.on('render', () => {
|
|
35285
|
-
this.emit('redraw');
|
|
35286
|
-
}),
|
|
35287
|
-
// RedrawComplete
|
|
35288
|
-
this.renderer.on('rendered', () => {
|
|
35289
|
-
this.emit('redrawcomplete');
|
|
35290
|
-
}),
|
|
35291
|
-
// DragStart
|
|
35292
|
-
this.renderer.on('dragstart', (relativeX) => {
|
|
35293
|
-
this.emit('dragstart', relativeX);
|
|
35294
|
-
}),
|
|
35295
|
-
// DragEnd
|
|
35296
|
-
this.renderer.on('dragend', (relativeX) => {
|
|
35297
|
-
this.emit('dragend', relativeX);
|
|
35298
|
-
}));
|
|
35299
|
-
// Drag
|
|
35300
|
-
{
|
|
35301
|
-
let debounce;
|
|
35302
|
-
this.subscriptions.push(this.renderer.on('drag', (relativeX) => {
|
|
35303
|
-
if (!this.options.interact)
|
|
35304
|
-
return;
|
|
35305
|
-
// Update the visual position
|
|
35306
|
-
this.renderer.renderProgress(relativeX);
|
|
35307
|
-
// Set the audio position with a debounce
|
|
35308
|
-
clearTimeout(debounce);
|
|
35309
|
-
let debounceTime;
|
|
35310
|
-
if (this.isPlaying()) {
|
|
35311
|
-
debounceTime = 0;
|
|
35312
|
-
}
|
|
35313
|
-
else if (this.options.dragToSeek === true) {
|
|
35314
|
-
debounceTime = 200;
|
|
35315
|
-
}
|
|
35316
|
-
else if (typeof this.options.dragToSeek === 'object' && this.options.dragToSeek !== undefined) {
|
|
35317
|
-
debounceTime = this.options.dragToSeek['debounceTime'];
|
|
35318
|
-
}
|
|
35319
|
-
debounce = setTimeout(() => {
|
|
35320
|
-
this.seekTo(relativeX);
|
|
35321
|
-
}, debounceTime);
|
|
35322
|
-
this.emit('interaction', relativeX * this.getDuration());
|
|
35323
|
-
this.emit('drag', relativeX);
|
|
35324
|
-
}));
|
|
35325
|
-
}
|
|
35326
|
-
}
|
|
35327
|
-
initPlugins() {
|
|
35328
|
-
var _a;
|
|
35329
|
-
if (!((_a = this.options.plugins) === null || _a === void 0 ? void 0 : _a.length))
|
|
35330
|
-
return;
|
|
35331
|
-
this.options.plugins.forEach((plugin) => {
|
|
35332
|
-
this.registerPlugin(plugin);
|
|
35333
|
-
});
|
|
35334
|
-
}
|
|
35335
|
-
unsubscribePlayerEvents() {
|
|
35336
|
-
this.mediaSubscriptions.forEach((unsubscribe) => unsubscribe());
|
|
35337
|
-
this.mediaSubscriptions = [];
|
|
35338
|
-
}
|
|
35339
|
-
/** Set new wavesurfer options and re-render it */
|
|
35340
|
-
setOptions(options) {
|
|
35341
|
-
this.options = Object.assign({}, this.options, options);
|
|
35342
|
-
if (options.duration && !options.peaks) {
|
|
35343
|
-
this.decodedData = Decoder.createBuffer(this.exportPeaks(), options.duration);
|
|
35344
|
-
}
|
|
35345
|
-
if (options.peaks && options.duration) {
|
|
35346
|
-
// Create new decoded data buffer from peaks and duration
|
|
35347
|
-
this.decodedData = Decoder.createBuffer(options.peaks, options.duration);
|
|
35348
|
-
}
|
|
35349
|
-
this.renderer.setOptions(this.options);
|
|
35350
|
-
if (options.audioRate) {
|
|
35351
|
-
this.setPlaybackRate(options.audioRate);
|
|
35352
|
-
}
|
|
35353
|
-
if (options.mediaControls != null) {
|
|
35354
|
-
this.getMediaElement().controls = options.mediaControls;
|
|
35355
|
-
}
|
|
35356
|
-
}
|
|
35357
|
-
/** Register a wavesurfer.js plugin */
|
|
35358
|
-
registerPlugin(plugin) {
|
|
35359
|
-
// Check if the plugin is already registered
|
|
35360
|
-
if (this.plugins.includes(plugin)) {
|
|
35361
|
-
return plugin;
|
|
35362
|
-
}
|
|
35363
|
-
plugin._init(this);
|
|
35364
|
-
this.plugins.push(plugin);
|
|
35365
|
-
// Unregister plugin on destroy
|
|
35366
|
-
const unsubscribe = plugin.once('destroy', () => {
|
|
35367
|
-
this.plugins = this.plugins.filter((p) => p !== plugin);
|
|
35368
|
-
this.subscriptions = this.subscriptions.filter((fn) => fn !== unsubscribe);
|
|
35369
|
-
});
|
|
35370
|
-
this.subscriptions.push(unsubscribe);
|
|
35371
|
-
return plugin;
|
|
35372
|
-
}
|
|
35373
|
-
/** Unregister a wavesurfer.js plugin */
|
|
35374
|
-
unregisterPlugin(plugin) {
|
|
35375
|
-
this.plugins = this.plugins.filter((p) => p !== plugin);
|
|
35376
|
-
plugin.destroy();
|
|
35377
|
-
}
|
|
35378
|
-
/** For plugins only: get the waveform wrapper div */
|
|
35379
|
-
getWrapper() {
|
|
35380
|
-
return this.renderer.getWrapper();
|
|
35381
|
-
}
|
|
35382
|
-
/** For plugins only: get the scroll container client width */
|
|
35383
|
-
getWidth() {
|
|
35384
|
-
return this.renderer.getWidth();
|
|
35385
|
-
}
|
|
35386
|
-
/** Get the current scroll position in pixels */
|
|
35387
|
-
getScroll() {
|
|
35388
|
-
return this.renderer.getScroll();
|
|
35389
|
-
}
|
|
35390
|
-
/** Set the current scroll position in pixels */
|
|
35391
|
-
setScroll(pixels) {
|
|
35392
|
-
return this.renderer.setScroll(pixels);
|
|
35393
|
-
}
|
|
35394
|
-
/** Move the start of the viewing window to a specific time in the audio (in seconds) */
|
|
35395
|
-
setScrollTime(time) {
|
|
35396
|
-
const percentage = time / this.getDuration();
|
|
35397
|
-
this.renderer.setScrollPercentage(percentage);
|
|
35398
|
-
}
|
|
35399
|
-
/** Get all registered plugins */
|
|
35400
|
-
getActivePlugins() {
|
|
35401
|
-
return this.plugins;
|
|
35402
|
-
}
|
|
35403
|
-
loadAudio(url, blob, channelData, duration) {
|
|
35404
|
-
return __awaiter$5(this, void 0, void 0, function* () {
|
|
35405
|
-
var _a;
|
|
35406
|
-
this.emit('load', url);
|
|
35407
|
-
if (!this.options.media && this.isPlaying())
|
|
35408
|
-
this.pause();
|
|
35409
|
-
this.decodedData = null;
|
|
35410
|
-
this.stopAtPosition = null;
|
|
35411
|
-
// Fetch the entire audio as a blob if pre-decoded data is not provided
|
|
35412
|
-
if (!blob && !channelData) {
|
|
35413
|
-
const fetchParams = this.options.fetchParams || {};
|
|
35414
|
-
if (window.AbortController && !fetchParams.signal) {
|
|
35415
|
-
this.abortController = new AbortController();
|
|
35416
|
-
fetchParams.signal = (_a = this.abortController) === null || _a === void 0 ? void 0 : _a.signal;
|
|
35417
|
-
}
|
|
35418
|
-
const onProgress = (percentage) => this.emit('loading', percentage);
|
|
35419
|
-
blob = yield Fetcher.fetchBlob(url, onProgress, fetchParams);
|
|
35420
|
-
const overridenMimeType = this.options.blobMimeType;
|
|
35421
|
-
if (overridenMimeType) {
|
|
35422
|
-
blob = new Blob([blob], { type: overridenMimeType });
|
|
35423
|
-
}
|
|
35424
|
-
}
|
|
35425
|
-
// Set the mediaelement source
|
|
35426
|
-
this.setSrc(url, blob);
|
|
35427
|
-
// Wait for the audio duration
|
|
35428
|
-
const audioDuration = yield new Promise((resolve) => {
|
|
35429
|
-
const staticDuration = duration || this.getDuration();
|
|
35430
|
-
if (staticDuration) {
|
|
35431
|
-
resolve(staticDuration);
|
|
35432
|
-
}
|
|
35433
|
-
else {
|
|
35434
|
-
this.mediaSubscriptions.push(this.onMediaEvent('loadedmetadata', () => resolve(this.getDuration()), { once: true }));
|
|
35435
|
-
}
|
|
35436
|
-
});
|
|
35437
|
-
// Set the duration if the player is a WebAudioPlayer without a URL
|
|
35438
|
-
if (!url && !blob) {
|
|
35439
|
-
const media = this.getMediaElement();
|
|
35440
|
-
if (media instanceof WebAudioPlayer) {
|
|
35441
|
-
media.duration = audioDuration;
|
|
35442
|
-
}
|
|
35443
|
-
}
|
|
35444
|
-
// Decode the audio data or use user-provided peaks
|
|
35445
|
-
if (channelData) {
|
|
35446
|
-
this.decodedData = Decoder.createBuffer(channelData, audioDuration || 0);
|
|
35447
|
-
}
|
|
35448
|
-
else if (blob) {
|
|
35449
|
-
const arrayBuffer = yield blob.arrayBuffer();
|
|
35450
|
-
this.decodedData = yield Decoder.decode(arrayBuffer, this.options.sampleRate);
|
|
35451
|
-
}
|
|
35452
|
-
if (this.decodedData) {
|
|
35453
|
-
this.emit('decode', this.getDuration());
|
|
35454
|
-
this.renderer.render(this.decodedData);
|
|
35455
|
-
}
|
|
35456
|
-
this.emit('ready', this.getDuration());
|
|
35457
|
-
});
|
|
35458
|
-
}
|
|
35459
|
-
/** Load an audio file by URL, with optional pre-decoded audio data */
|
|
35460
|
-
load(url, channelData, duration) {
|
|
35461
|
-
return __awaiter$5(this, void 0, void 0, function* () {
|
|
35462
|
-
try {
|
|
35463
|
-
return yield this.loadAudio(url, undefined, channelData, duration);
|
|
35464
|
-
}
|
|
35465
|
-
catch (err) {
|
|
35466
|
-
this.emit('error', err);
|
|
35467
|
-
throw err;
|
|
35468
|
-
}
|
|
35469
|
-
});
|
|
35470
|
-
}
|
|
35471
|
-
/** Load an audio blob */
|
|
35472
|
-
loadBlob(blob, channelData, duration) {
|
|
35473
|
-
return __awaiter$5(this, void 0, void 0, function* () {
|
|
35474
|
-
try {
|
|
35475
|
-
return yield this.loadAudio('', blob, channelData, duration);
|
|
35476
|
-
}
|
|
35477
|
-
catch (err) {
|
|
35478
|
-
this.emit('error', err);
|
|
35479
|
-
throw err;
|
|
35480
|
-
}
|
|
35481
|
-
});
|
|
35482
|
-
}
|
|
35483
|
-
/** Zoom the waveform by a given pixels-per-second factor */
|
|
35484
|
-
zoom(minPxPerSec) {
|
|
35485
|
-
if (!this.decodedData) {
|
|
35486
|
-
throw new Error('No audio loaded');
|
|
35487
|
-
}
|
|
35488
|
-
this.renderer.zoom(minPxPerSec);
|
|
35489
|
-
this.emit('zoom', minPxPerSec);
|
|
35490
|
-
}
|
|
35491
|
-
/** Get the decoded audio data */
|
|
35492
|
-
getDecodedData() {
|
|
35493
|
-
return this.decodedData;
|
|
35494
|
-
}
|
|
35495
|
-
/** Get decoded peaks */
|
|
35496
|
-
exportPeaks({ channels = 2, maxLength = 8000, precision = 10000 } = {}) {
|
|
35497
|
-
if (!this.decodedData) {
|
|
35498
|
-
throw new Error('The audio has not been decoded yet');
|
|
35499
|
-
}
|
|
35500
|
-
const maxChannels = Math.min(channels, this.decodedData.numberOfChannels);
|
|
35501
|
-
const peaks = [];
|
|
35502
|
-
for (let i = 0; i < maxChannels; i++) {
|
|
35503
|
-
const channel = this.decodedData.getChannelData(i);
|
|
35504
|
-
const data = [];
|
|
35505
|
-
const sampleSize = channel.length / maxLength;
|
|
35506
|
-
for (let i = 0; i < maxLength; i++) {
|
|
35507
|
-
const sample = channel.slice(Math.floor(i * sampleSize), Math.ceil((i + 1) * sampleSize));
|
|
35508
|
-
let max = 0;
|
|
35509
|
-
for (let x = 0; x < sample.length; x++) {
|
|
35510
|
-
const n = sample[x];
|
|
35511
|
-
if (Math.abs(n) > Math.abs(max))
|
|
35512
|
-
max = n;
|
|
35513
|
-
}
|
|
35514
|
-
data.push(Math.round(max * precision) / precision);
|
|
35515
|
-
}
|
|
35516
|
-
peaks.push(data);
|
|
35517
|
-
}
|
|
35518
|
-
return peaks;
|
|
35519
|
-
}
|
|
35520
|
-
/** Get the duration of the audio in seconds */
|
|
35521
|
-
getDuration() {
|
|
35522
|
-
let duration = super.getDuration() || 0;
|
|
35523
|
-
// Fall back to the decoded data duration if the media duration is incorrect
|
|
35524
|
-
if ((duration === 0 || duration === Infinity) && this.decodedData) {
|
|
35525
|
-
duration = this.decodedData.duration;
|
|
35526
|
-
}
|
|
35527
|
-
return duration;
|
|
35528
|
-
}
|
|
35529
|
-
/** Toggle if the waveform should react to clicks */
|
|
35530
|
-
toggleInteraction(isInteractive) {
|
|
35531
|
-
this.options.interact = isInteractive;
|
|
35532
|
-
}
|
|
35533
|
-
/** Jump to a specific time in the audio (in seconds) */
|
|
35534
|
-
setTime(time) {
|
|
35535
|
-
this.stopAtPosition = null;
|
|
35536
|
-
super.setTime(time);
|
|
35537
|
-
this.updateProgress(time);
|
|
35538
|
-
this.emit('timeupdate', time);
|
|
35539
|
-
}
|
|
35540
|
-
/** Seek to a percentage of audio as [0..1] (0 = beginning, 1 = end) */
|
|
35541
|
-
seekTo(progress) {
|
|
35542
|
-
const time = this.getDuration() * progress;
|
|
35543
|
-
this.setTime(time);
|
|
35544
|
-
}
|
|
35545
|
-
/** Start playing the audio */
|
|
35546
|
-
play(start, end) {
|
|
35547
|
-
const _super = Object.create(null, {
|
|
35548
|
-
play: { get: () => super.play }
|
|
35549
|
-
});
|
|
35550
|
-
return __awaiter$5(this, void 0, void 0, function* () {
|
|
35551
|
-
if (start != null) {
|
|
35552
|
-
this.setTime(start);
|
|
35553
|
-
}
|
|
35554
|
-
const playResult = yield _super.play.call(this);
|
|
35555
|
-
if (end != null) {
|
|
35556
|
-
if (this.media instanceof WebAudioPlayer) {
|
|
35557
|
-
this.media.stopAt(end);
|
|
35558
|
-
}
|
|
35559
|
-
else {
|
|
35560
|
-
this.stopAtPosition = end;
|
|
35561
|
-
}
|
|
35562
|
-
}
|
|
35563
|
-
return playResult;
|
|
35564
|
-
});
|
|
35565
|
-
}
|
|
35566
|
-
/** Play or pause the audio */
|
|
35567
|
-
playPause() {
|
|
35568
|
-
return __awaiter$5(this, void 0, void 0, function* () {
|
|
35569
|
-
return this.isPlaying() ? this.pause() : this.play();
|
|
35570
|
-
});
|
|
35571
|
-
}
|
|
35572
|
-
/** Stop the audio and go to the beginning */
|
|
35573
|
-
stop() {
|
|
35574
|
-
this.pause();
|
|
35575
|
-
this.setTime(0);
|
|
35576
|
-
}
|
|
35577
|
-
/** Skip N or -N seconds from the current position */
|
|
35578
|
-
skip(seconds) {
|
|
35579
|
-
this.setTime(this.getCurrentTime() + seconds);
|
|
35580
|
-
}
|
|
35581
|
-
/** Empty the waveform */
|
|
35582
|
-
empty() {
|
|
35583
|
-
this.load('', [[0]], 0.001);
|
|
35584
|
-
}
|
|
35585
|
-
/** Set HTML media element */
|
|
35586
|
-
setMediaElement(element) {
|
|
35587
|
-
this.unsubscribePlayerEvents();
|
|
35588
|
-
super.setMediaElement(element);
|
|
35589
|
-
this.initPlayerEvents();
|
|
35590
|
-
}
|
|
35591
|
-
exportImage() {
|
|
35592
|
-
return __awaiter$5(this, arguments, void 0, function* (format = 'image/png', quality = 1, type = 'dataURL') {
|
|
35593
|
-
return this.renderer.exportImage(format, quality, type);
|
|
35594
|
-
});
|
|
35595
|
-
}
|
|
35596
|
-
/** Unmount wavesurfer */
|
|
35597
|
-
destroy() {
|
|
35598
|
-
var _a;
|
|
35599
|
-
this.emit('destroy');
|
|
35600
|
-
(_a = this.abortController) === null || _a === void 0 ? void 0 : _a.abort();
|
|
35601
|
-
this.plugins.forEach((plugin) => plugin.destroy());
|
|
35602
|
-
this.subscriptions.forEach((unsubscribe) => unsubscribe());
|
|
35603
|
-
this.unsubscribePlayerEvents();
|
|
35604
|
-
this.timer.destroy();
|
|
35605
|
-
this.renderer.destroy();
|
|
35606
|
-
super.destroy();
|
|
35607
|
-
}
|
|
35608
|
-
}
|
|
35609
|
-
WaveSurfer.BasePlugin = BasePlugin;
|
|
35610
|
-
WaveSurfer.dom = dom;
|
|
35611
|
-
|
|
35612
33883
|
var _templateObject$u, _templateObject2$q;
|
|
35613
33884
|
var AudioVisualization = function AudioVisualization(_ref) {
|
|
35614
33885
|
var tmb = _ref.tmb,
|
|
@@ -35621,7 +33892,9 @@ var AudioVisualization = function AudioVisualization(_ref) {
|
|
|
35621
33892
|
_ref$barWidth = _ref.barWidth,
|
|
35622
33893
|
barWidth = _ref$barWidth === void 0 ? 1 : _ref$barWidth,
|
|
35623
33894
|
_ref$barRadius = _ref.barRadius,
|
|
35624
|
-
barRadius = _ref$barRadius === void 0 ? 1.5 : _ref$barRadius
|
|
33895
|
+
barRadius = _ref$barRadius === void 0 ? 1.5 : _ref$barRadius,
|
|
33896
|
+
_ref$containerWidth = _ref.containerWidth,
|
|
33897
|
+
containerWidth = _ref$containerWidth === void 0 ? 148 : _ref$containerWidth;
|
|
35625
33898
|
var normalizedBars = React.useMemo(function () {
|
|
35626
33899
|
if (!tmb || tmb.length === 0) return [];
|
|
35627
33900
|
var maxVal = Math.max.apply(Math, tmb);
|
|
@@ -35630,7 +33903,6 @@ var AudioVisualization = function AudioVisualization(_ref) {
|
|
|
35630
33903
|
return Math.max(2, normalized);
|
|
35631
33904
|
});
|
|
35632
33905
|
}, [tmb, height]);
|
|
35633
|
-
var containerWidth = 148;
|
|
35634
33906
|
var calculatedGap = React.useMemo(function () {
|
|
35635
33907
|
if (normalizedBars.length <= 1) return 0;
|
|
35636
33908
|
var totalBarWidth = normalizedBars.length * barWidth;
|
|
@@ -35692,7 +33964,7 @@ var AudioVisualization = function AudioVisualization(_ref) {
|
|
|
35692
33964
|
})));
|
|
35693
33965
|
})));
|
|
35694
33966
|
};
|
|
35695
|
-
var
|
|
33967
|
+
var AudioVisualizationComponent = /*#__PURE__*/React.memo(AudioVisualization);
|
|
35696
33968
|
var Container$d = styled__default.div(_templateObject$u || (_templateObject$u = _taggedTemplateLiteralLoose(["\n display: flex;\n align-items: center;\n width: 100%;\n justify-content: flex-start;\n margin-right: 4px;\n position: relative;\n"])));
|
|
35697
33969
|
var SVG = styled__default.svg(_templateObject2$q || (_templateObject2$q = _taggedTemplateLiteralLoose(["\n display: block;\n"])));
|
|
35698
33970
|
|
|
@@ -35758,7 +34030,22 @@ var initFFmpeg = function initFFmpeg() {
|
|
|
35758
34030
|
return Promise.reject(e);
|
|
35759
34031
|
}
|
|
35760
34032
|
};
|
|
35761
|
-
var
|
|
34033
|
+
var getExtensionForType = function getExtensionForType(mimeType) {
|
|
34034
|
+
var typeMap = {
|
|
34035
|
+
'audio/mpeg': 'mp3',
|
|
34036
|
+
'audio/mp3': 'mp3',
|
|
34037
|
+
'audio/webm': 'webm',
|
|
34038
|
+
'audio/ogg': 'ogg',
|
|
34039
|
+
'audio/opus': 'opus',
|
|
34040
|
+
'audio/wav': 'wav',
|
|
34041
|
+
'audio/x-wav': 'wav',
|
|
34042
|
+
'audio/mp4': 'm4a',
|
|
34043
|
+
'audio/aac': 'aac'
|
|
34044
|
+
};
|
|
34045
|
+
var baseType = mimeType.split(';')[0].trim().toLowerCase();
|
|
34046
|
+
return typeMap[baseType] || 'bin';
|
|
34047
|
+
};
|
|
34048
|
+
var convertToAac = function convertToAac(file, messageId) {
|
|
35762
34049
|
try {
|
|
35763
34050
|
return Promise.resolve(_catch(function () {
|
|
35764
34051
|
var maxSize = 50 * 1024 * 1024;
|
|
@@ -35772,9 +34059,9 @@ var convertMp3ToAac = function convertMp3ToAac(file, messageId) {
|
|
|
35772
34059
|
function _temp8() {
|
|
35773
34060
|
function _temp6() {
|
|
35774
34061
|
return Promise.resolve(util.fetchFile(file)).then(function (inputData) {
|
|
35775
|
-
return Promise.resolve(ffmpeg.writeFile(
|
|
35776
|
-
return Promise.resolve(ffmpeg.exec(['-i',
|
|
35777
|
-
return Promise.resolve(ffmpeg.readFile(
|
|
34062
|
+
return Promise.resolve(ffmpeg.writeFile(inputName, inputData)).then(function () {
|
|
34063
|
+
return Promise.resolve(ffmpeg.exec(['-i', inputName, '-c:a', 'aac', '-b:a', '128k', '-movflags', '+faststart', outputName])).then(function () {
|
|
34064
|
+
return Promise.resolve(ffmpeg.readFile(outputName)).then(function (data) {
|
|
35778
34065
|
function _temp4() {
|
|
35779
34066
|
function _temp2() {
|
|
35780
34067
|
var dataArray;
|
|
@@ -35794,19 +34081,19 @@ var convertMp3ToAac = function convertMp3ToAac(file, messageId) {
|
|
|
35794
34081
|
var blob = new Blob([arrayBuffer], {
|
|
35795
34082
|
type: 'audio/mp4'
|
|
35796
34083
|
});
|
|
35797
|
-
var convertedFile = new File([blob], messageId + "
|
|
34084
|
+
var convertedFile = new File([blob], messageId + "_converted.m4a", {
|
|
35798
34085
|
type: 'audio/mp4',
|
|
35799
34086
|
lastModified: file.lastModified
|
|
35800
34087
|
});
|
|
35801
34088
|
return convertedFile;
|
|
35802
34089
|
}
|
|
35803
34090
|
var _temp = _catch(function () {
|
|
35804
|
-
return Promise.resolve(ffmpeg.deleteFile(
|
|
34091
|
+
return Promise.resolve(ffmpeg.deleteFile(outputName)).then(function () {});
|
|
35805
34092
|
}, function () {});
|
|
35806
34093
|
return _temp && _temp.then ? _temp.then(_temp2) : _temp2(_temp);
|
|
35807
34094
|
}
|
|
35808
34095
|
var _temp3 = _catch(function () {
|
|
35809
|
-
return Promise.resolve(ffmpeg.deleteFile(
|
|
34096
|
+
return Promise.resolve(ffmpeg.deleteFile(inputName)).then(function () {});
|
|
35810
34097
|
}, function () {});
|
|
35811
34098
|
return _temp3 && _temp3.then ? _temp3.then(_temp4) : _temp4(_temp3);
|
|
35812
34099
|
});
|
|
@@ -35815,51 +34102,50 @@ var convertMp3ToAac = function convertMp3ToAac(file, messageId) {
|
|
|
35815
34102
|
});
|
|
35816
34103
|
}
|
|
35817
34104
|
var _temp5 = _catch(function () {
|
|
35818
|
-
return Promise.resolve(ffmpeg.deleteFile(
|
|
34105
|
+
return Promise.resolve(ffmpeg.deleteFile(outputName)).then(function () {});
|
|
35819
34106
|
}, function () {});
|
|
35820
34107
|
return _temp5 && _temp5.then ? _temp5.then(_temp6) : _temp6(_temp5);
|
|
35821
34108
|
}
|
|
34109
|
+
var inputExt = getExtensionForType(file.type);
|
|
34110
|
+
var inputName = messageId + "_input." + inputExt;
|
|
34111
|
+
var outputName = messageId + "_output.m4a";
|
|
35822
34112
|
var _temp7 = _catch(function () {
|
|
35823
|
-
return Promise.resolve(ffmpeg.deleteFile(
|
|
34113
|
+
return Promise.resolve(ffmpeg.deleteFile(inputName)).then(function () {});
|
|
35824
34114
|
}, function () {});
|
|
35825
34115
|
return _temp7 && _temp7.then ? _temp7.then(_temp8) : _temp8(_temp7);
|
|
35826
34116
|
});
|
|
35827
34117
|
}, function (error) {
|
|
35828
|
-
log.error('Failed to convert
|
|
34118
|
+
log.error('Failed to convert audio to AAC:', error);
|
|
35829
34119
|
throw error;
|
|
35830
34120
|
}));
|
|
35831
34121
|
} catch (e) {
|
|
35832
34122
|
return Promise.reject(e);
|
|
35833
34123
|
}
|
|
35834
34124
|
};
|
|
34125
|
+
var SAFARI_SUPPORTED_TYPES = new Set(['audio/mp4', 'audio/aac', 'audio/x-m4a', 'audio/wav', 'audio/x-wav', 'audio/aiff']);
|
|
35835
34126
|
var convertAudioForSafari = function convertAudioForSafari(file, messageId) {
|
|
35836
34127
|
try {
|
|
35837
|
-
|
|
35838
|
-
|
|
35839
|
-
|
|
35840
|
-
|
|
35841
|
-
|
|
35842
|
-
|
|
35843
|
-
|
|
35844
|
-
|
|
35845
|
-
|
|
35846
|
-
|
|
35847
|
-
|
|
35848
|
-
|
|
35849
|
-
|
|
35850
|
-
}
|
|
35851
|
-
}();
|
|
35852
|
-
return Promise.resolve(_temp9 && _temp9.then ? _temp9.then(function (_result2) {
|
|
35853
|
-
return _exit ? _result2 : file;
|
|
35854
|
-
}) : _exit ? _temp9 : file);
|
|
34128
|
+
if (!isSafari()) {
|
|
34129
|
+
return Promise.resolve(file);
|
|
34130
|
+
}
|
|
34131
|
+
var baseType = file.type.split(';')[0].trim().toLowerCase();
|
|
34132
|
+
if (SAFARI_SUPPORTED_TYPES.has(baseType)) {
|
|
34133
|
+
return Promise.resolve(file);
|
|
34134
|
+
}
|
|
34135
|
+
return Promise.resolve(_catch(function () {
|
|
34136
|
+
return Promise.resolve(convertToAac(file, messageId));
|
|
34137
|
+
}, function (error) {
|
|
34138
|
+
log.warn('Audio conversion failed, using original file:', error);
|
|
34139
|
+
return file;
|
|
34140
|
+
}));
|
|
35855
34141
|
} catch (e) {
|
|
35856
34142
|
return Promise.reject(e);
|
|
35857
34143
|
}
|
|
35858
34144
|
};
|
|
35859
34145
|
|
|
35860
|
-
var _templateObject$v, _templateObject2$r, _templateObject3$l, _templateObject4$h, _templateObject5$e, _templateObject6$b, _templateObject7$a
|
|
34146
|
+
var _templateObject$v, _templateObject2$r, _templateObject3$l, _templateObject4$h, _templateObject5$e, _templateObject6$b, _templateObject7$a;
|
|
35861
34147
|
var AudioPlayer = function AudioPlayer(_ref) {
|
|
35862
|
-
var _file$
|
|
34148
|
+
var _file$metadata6, _file$metadata7;
|
|
35863
34149
|
var url = _ref.url,
|
|
35864
34150
|
file = _ref.file,
|
|
35865
34151
|
messagePlayed = _ref.messagePlayed,
|
|
@@ -35870,14 +34156,6 @@ var AudioPlayer = function AudioPlayer(_ref) {
|
|
|
35870
34156
|
bgColor = _ref.bgColor,
|
|
35871
34157
|
borderRadius = _ref.borderRadius,
|
|
35872
34158
|
onClose = _ref.onClose;
|
|
35873
|
-
var recordingInitialState = {
|
|
35874
|
-
recordingSeconds: 0,
|
|
35875
|
-
recordingMilliseconds: 0,
|
|
35876
|
-
initRecording: false,
|
|
35877
|
-
mediaStream: null,
|
|
35878
|
-
mediaRecorder: null,
|
|
35879
|
-
audio: undefined
|
|
35880
|
-
};
|
|
35881
34159
|
var _useColor = useColors(),
|
|
35882
34160
|
accentColor = _useColor[THEME_COLORS.ACCENT],
|
|
35883
34161
|
textSecondary = _useColor[THEME_COLORS.TEXT_SECONDARY],
|
|
@@ -35886,249 +34164,164 @@ var AudioPlayer = function AudioPlayer(_ref) {
|
|
|
35886
34164
|
outgoingMessageBackground = _useColor[THEME_COLORS.OUTGOING_MESSAGE_BACKGROUND];
|
|
35887
34165
|
var dispatch = useDispatch();
|
|
35888
34166
|
var playingAudioId = useSelector(playingAudioIdSelector);
|
|
35889
|
-
var _useState = React.useState(
|
|
35890
|
-
|
|
35891
|
-
|
|
35892
|
-
var _useState2 = React.useState(
|
|
35893
|
-
|
|
35894
|
-
|
|
35895
|
-
var _useState3 = React.useState(
|
|
35896
|
-
|
|
35897
|
-
|
|
35898
|
-
var _useState4 = React.useState(
|
|
35899
|
-
|
|
35900
|
-
|
|
34167
|
+
var _useState = React.useState(false),
|
|
34168
|
+
playAudio = _useState[0],
|
|
34169
|
+
setPlayAudio = _useState[1];
|
|
34170
|
+
var _useState2 = React.useState(''),
|
|
34171
|
+
currentTime = _useState2[0],
|
|
34172
|
+
setCurrentTime = _useState2[1];
|
|
34173
|
+
var _useState3 = React.useState(0),
|
|
34174
|
+
currentTimeSeconds = _useState3[0],
|
|
34175
|
+
setCurrentTimeSeconds = _useState3[1];
|
|
34176
|
+
var _useState4 = React.useState(0),
|
|
34177
|
+
duration = _useState4[0],
|
|
34178
|
+
setDuration = _useState4[1];
|
|
35901
34179
|
var _useState5 = React.useState(0),
|
|
35902
|
-
|
|
35903
|
-
|
|
35904
|
-
var _useState6 = React.useState(
|
|
35905
|
-
|
|
35906
|
-
|
|
35907
|
-
var
|
|
35908
|
-
realDuration = _useState7[0],
|
|
35909
|
-
setRealDuration = _useState7[1];
|
|
35910
|
-
var _useState8 = React.useState(1),
|
|
35911
|
-
audioRate = _useState8[0],
|
|
35912
|
-
setAudioRate = _useState8[1];
|
|
35913
|
-
var wavesurfer = React.useRef(null);
|
|
35914
|
-
var wavesurferContainer = React.useRef(null);
|
|
34180
|
+
realDuration = _useState5[0],
|
|
34181
|
+
setRealDuration = _useState5[1];
|
|
34182
|
+
var _useState6 = React.useState(1),
|
|
34183
|
+
audioRate = _useState6[0],
|
|
34184
|
+
setAudioRate = _useState6[1];
|
|
34185
|
+
var audioRef = React.useRef(null);
|
|
35915
34186
|
var intervalRef = React.useRef(null);
|
|
35916
34187
|
var convertedUrlRef = React.useRef(null);
|
|
34188
|
+
var visualizationRef = React.useRef(null);
|
|
35917
34189
|
var handleSetAudioRate = function handleSetAudioRate() {
|
|
35918
|
-
if (
|
|
34190
|
+
if (audioRef.current) {
|
|
35919
34191
|
if (audioRate === 1) {
|
|
35920
34192
|
setAudioRate(1.5);
|
|
35921
|
-
|
|
34193
|
+
audioRef.current.playbackRate = 1.5;
|
|
35922
34194
|
} else if (audioRate === 1.5) {
|
|
35923
34195
|
setAudioRate(2);
|
|
35924
|
-
|
|
35925
|
-
wavesurfer.current.setPlaybackRate(2);
|
|
34196
|
+
audioRef.current.playbackRate = 2;
|
|
35926
34197
|
} else {
|
|
35927
34198
|
setAudioRate(1);
|
|
35928
|
-
|
|
35929
|
-
wavesurfer.current.setPlaybackRate(1);
|
|
34199
|
+
audioRef.current.playbackRate = 1;
|
|
35930
34200
|
}
|
|
35931
34201
|
}
|
|
35932
34202
|
};
|
|
34203
|
+
var startTimeTracking = function startTimeTracking() {
|
|
34204
|
+
clearInterval(intervalRef.current);
|
|
34205
|
+
intervalRef.current = setInterval(function () {
|
|
34206
|
+
if (audioRef.current) {
|
|
34207
|
+
var time = audioRef.current.currentTime;
|
|
34208
|
+
if (time >= 0) {
|
|
34209
|
+
setCurrentTime(formatAudioVideoTime(time));
|
|
34210
|
+
setCurrentTimeSeconds(time);
|
|
34211
|
+
}
|
|
34212
|
+
}
|
|
34213
|
+
}, 10);
|
|
34214
|
+
};
|
|
35933
34215
|
var handlePlayPause = function handlePlayPause() {
|
|
35934
34216
|
if (setViewOnceVoiceModalOpen) {
|
|
35935
34217
|
setViewOnceVoiceModalOpen(true);
|
|
35936
34218
|
return;
|
|
35937
34219
|
}
|
|
35938
|
-
if (
|
|
35939
|
-
if (
|
|
34220
|
+
if (audioRef.current) {
|
|
34221
|
+
if (audioRef.current.paused) {
|
|
35940
34222
|
setPlayAudio(true);
|
|
35941
34223
|
dispatch(setPlayingAudioIdAC("player_" + file.id));
|
|
35942
|
-
|
|
35943
|
-
|
|
35944
|
-
|
|
35945
|
-
|
|
35946
|
-
|
|
35947
|
-
}
|
|
35948
|
-
}, 10);
|
|
34224
|
+
startTimeTracking();
|
|
34225
|
+
audioRef.current.play()["catch"](function (e) {
|
|
34226
|
+
log.error('Audio play failed:', e);
|
|
34227
|
+
setPlayAudio(false);
|
|
34228
|
+
});
|
|
35949
34229
|
} else {
|
|
34230
|
+
audioRef.current.pause();
|
|
35950
34231
|
if (playingAudioId === file.id) {
|
|
35951
34232
|
dispatch(setPlayingAudioIdAC(null));
|
|
35952
34233
|
}
|
|
35953
34234
|
}
|
|
35954
|
-
wavesurfer.current.playPause();
|
|
35955
34235
|
if (!messagePlayed && incoming) {
|
|
35956
34236
|
dispatch(markVoiceMessageAsPlayedAC(channelId, [file.messageId]));
|
|
35957
34237
|
}
|
|
35958
34238
|
}
|
|
35959
34239
|
};
|
|
35960
|
-
|
|
35961
|
-
if (
|
|
35962
|
-
|
|
35963
|
-
|
|
35964
|
-
|
|
35965
|
-
|
|
35966
|
-
|
|
34240
|
+
var handleSeek = function handleSeek(e) {
|
|
34241
|
+
if (!audioRef.current || !visualizationRef.current) return;
|
|
34242
|
+
var rect = visualizationRef.current.getBoundingClientRect();
|
|
34243
|
+
var clickX = e.clientX - rect.left;
|
|
34244
|
+
var ratio = Math.max(0, Math.min(1, clickX / rect.width));
|
|
34245
|
+
var audioDuration = audioRef.current.duration;
|
|
34246
|
+
if (audioDuration && isFinite(audioDuration)) {
|
|
34247
|
+
audioRef.current.currentTime = ratio * audioDuration;
|
|
34248
|
+
setCurrentTime(formatAudioVideoTime(audioRef.current.currentTime));
|
|
34249
|
+
setCurrentTimeSeconds(audioRef.current.currentTime);
|
|
35967
34250
|
}
|
|
35968
|
-
}
|
|
35969
|
-
React.useEffect(function () {
|
|
35970
|
-
var MAX_RECORDER_TIME = 15;
|
|
35971
|
-
var recordingInterval = null;
|
|
35972
|
-
if (recording.initRecording) {
|
|
35973
|
-
recordingInterval = setInterval(function () {
|
|
35974
|
-
setRecording(function (prevState) {
|
|
35975
|
-
if (prevState.recordingSeconds === MAX_RECORDER_TIME && prevState.recordingMilliseconds === 0) {
|
|
35976
|
-
clearInterval(recordingInterval);
|
|
35977
|
-
return prevState;
|
|
35978
|
-
}
|
|
35979
|
-
if (prevState.recordingMilliseconds >= 0 && prevState.recordingMilliseconds < 99) {
|
|
35980
|
-
return _extends({}, prevState, {
|
|
35981
|
-
recordingMilliseconds: prevState.recordingMilliseconds + 1
|
|
35982
|
-
});
|
|
35983
|
-
}
|
|
35984
|
-
if (prevState.recordingMilliseconds === 99) {
|
|
35985
|
-
return _extends({}, prevState, {
|
|
35986
|
-
recordingSeconds: prevState.recordingSeconds + 1,
|
|
35987
|
-
recordingMilliseconds: 0
|
|
35988
|
-
});
|
|
35989
|
-
}
|
|
35990
|
-
return prevState;
|
|
35991
|
-
});
|
|
35992
|
-
}, 10);
|
|
35993
|
-
} else clearInterval(recordingInterval);
|
|
35994
|
-
return function () {
|
|
35995
|
-
return clearInterval(recordingInterval);
|
|
35996
|
-
};
|
|
35997
|
-
}, [recording.initRecording]);
|
|
34251
|
+
};
|
|
35998
34252
|
React.useEffect(function () {
|
|
35999
|
-
if (url) {
|
|
34253
|
+
if (url && url !== '_') {
|
|
34254
|
+
var _file$metadata;
|
|
36000
34255
|
if (convertedUrlRef.current) {
|
|
36001
34256
|
URL.revokeObjectURL(convertedUrlRef.current);
|
|
36002
34257
|
convertedUrlRef.current = null;
|
|
36003
34258
|
}
|
|
36004
|
-
|
|
36005
|
-
|
|
36006
|
-
|
|
36007
|
-
|
|
36008
|
-
|
|
36009
|
-
|
|
36010
|
-
|
|
36011
|
-
|
|
36012
|
-
|
|
36013
|
-
|
|
36014
|
-
|
|
36015
|
-
|
|
36016
|
-
|
|
36017
|
-
|
|
36018
|
-
|
|
36019
|
-
barWidth: 1,
|
|
36020
|
-
barHeight: 1,
|
|
36021
|
-
hideScrollbar: true,
|
|
36022
|
-
barRadius: 1.5,
|
|
36023
|
-
cursorWidth: 0,
|
|
36024
|
-
barGap: 2,
|
|
36025
|
-
height: 20
|
|
36026
|
-
});
|
|
36027
|
-
var peaks;
|
|
36028
|
-
if (file.metadata) {
|
|
36029
|
-
if (file.metadata.dur) {
|
|
36030
|
-
setDuration(file.metadata.dur);
|
|
36031
|
-
setCurrentTime(formatAudioVideoTime(file.metadata.dur));
|
|
36032
|
-
}
|
|
36033
|
-
if (file.metadata.tmb) {
|
|
36034
|
-
var maxVal = Array.isArray(file.metadata.tmb) && file.metadata.tmb.length > 0 ? file.metadata.tmb.reduce(function (acc, n) {
|
|
36035
|
-
return n > acc ? n : acc;
|
|
36036
|
-
}, -Infinity) : 0;
|
|
36037
|
-
var dec = maxVal / 100;
|
|
36038
|
-
peaks = file.metadata.tmb.map(function (peak) {
|
|
36039
|
-
return peak / dec / 100;
|
|
36040
|
-
});
|
|
36041
|
-
}
|
|
36042
|
-
}
|
|
36043
|
-
wavesurfer.current.load(audioUrl, peaks);
|
|
36044
|
-
wavesurfer.current.on('ready', function () {
|
|
36045
|
-
var _file$metadata, _file$metadata2;
|
|
36046
|
-
var audioDuration = wavesurfer.current.getDuration();
|
|
36047
|
-
setRealDuration(audioDuration);
|
|
36048
|
-
setDuration((file === null || file === void 0 ? void 0 : (_file$metadata = file.metadata) === null || _file$metadata === void 0 ? void 0 : _file$metadata.dur) || audioDuration);
|
|
36049
|
-
setCurrentTime(formatAudioVideoTime((file === null || file === void 0 ? void 0 : (_file$metadata2 = file.metadata) === null || _file$metadata2 === void 0 ? void 0 : _file$metadata2.dur) || audioDuration));
|
|
36050
|
-
wavesurfer.current.drawBuffer = function (d) {
|
|
36051
|
-
log.info('filters --- ', d);
|
|
36052
|
-
};
|
|
36053
|
-
});
|
|
36054
|
-
wavesurfer.current.on('finish', function () {
|
|
36055
|
-
var _file$metadata3, _file$metadata4;
|
|
36056
|
-
setPlayAudio(false);
|
|
36057
|
-
wavesurfer.current.seekTo(0);
|
|
36058
|
-
var audioDuration = wavesurfer.current.getDuration();
|
|
36059
|
-
setRealDuration(audioDuration);
|
|
36060
|
-
setDuration((file === null || file === void 0 ? void 0 : (_file$metadata3 = file.metadata) === null || _file$metadata3 === void 0 ? void 0 : _file$metadata3.dur) || audioDuration);
|
|
36061
|
-
setCurrentTime(formatAudioVideoTime((file === null || file === void 0 ? void 0 : (_file$metadata4 = file.metadata) === null || _file$metadata4 === void 0 ? void 0 : _file$metadata4.dur) || audioDuration));
|
|
36062
|
-
setCurrentTimeSeconds(0);
|
|
36063
|
-
if (playingAudioId === file.id) {
|
|
36064
|
-
dispatch(setPlayingAudioIdAC(null));
|
|
36065
|
-
}
|
|
36066
|
-
clearInterval(intervalRef.current);
|
|
36067
|
-
if (onClose) {
|
|
36068
|
-
onClose();
|
|
36069
|
-
}
|
|
36070
|
-
});
|
|
36071
|
-
wavesurfer.current.on('pause', function () {
|
|
36072
|
-
setPlayAudio(false);
|
|
36073
|
-
if (playingAudioId === file.id) {
|
|
36074
|
-
dispatch(setPlayingAudioIdAC(null));
|
|
36075
|
-
}
|
|
36076
|
-
clearInterval(intervalRef.current);
|
|
36077
|
-
});
|
|
36078
|
-
wavesurfer.current.on('interaction', function () {
|
|
36079
|
-
var currentTime = wavesurfer.current.getCurrentTime();
|
|
36080
|
-
setCurrentTime(formatAudioVideoTime(currentTime));
|
|
36081
|
-
setCurrentTimeSeconds(currentTime);
|
|
36082
|
-
});
|
|
36083
|
-
if (url !== '_') {
|
|
36084
|
-
setIsRendered(true);
|
|
36085
|
-
}
|
|
36086
|
-
}
|
|
36087
|
-
var audioUrl = url;
|
|
36088
|
-
var needsConversion = isSafari() && url && url !== '_' && (url.endsWith('.mp3') || ((_file$name = file.name) === null || _file$name === void 0 ? void 0 : _file$name.endsWith('.mp3')) || file.type === 'audio/mpeg');
|
|
36089
|
-
var _temp = function () {
|
|
36090
|
-
if (needsConversion) {
|
|
36091
|
-
return _catch(function () {
|
|
36092
|
-
if (convertedUrlRef.current) {
|
|
36093
|
-
URL.revokeObjectURL(convertedUrlRef.current);
|
|
36094
|
-
convertedUrlRef.current = null;
|
|
36095
|
-
}
|
|
36096
|
-
var cacheKey = file.id || url;
|
|
36097
|
-
return Promise.resolve(fetch(url, {
|
|
36098
|
-
cache: 'no-store'
|
|
36099
|
-
})).then(function (response) {
|
|
36100
|
-
if (!response.ok) {
|
|
36101
|
-
throw new Error("Failed to fetch audio: " + response.statusText);
|
|
36102
|
-
}
|
|
36103
|
-
return Promise.resolve(response.blob()).then(function (blob) {
|
|
36104
|
-
var uniqueFileName = (file.id || Date.now()) + "_" + (file.name || 'audio.mp3');
|
|
36105
|
-
var audioFile = new File([blob], uniqueFileName, {
|
|
36106
|
-
type: blob.type || 'audio/mpeg',
|
|
36107
|
-
lastModified: Date.now()
|
|
36108
|
-
});
|
|
36109
|
-
return Promise.resolve(convertAudioForSafari(audioFile, file === null || file === void 0 ? void 0 : file.messageId)).then(function (convertedFile) {
|
|
36110
|
-
var convertedBlobUrl = URL.createObjectURL(convertedFile);
|
|
36111
|
-
audioUrl = convertedBlobUrl;
|
|
36112
|
-
convertedUrlRef.current = convertedBlobUrl;
|
|
36113
|
-
log.info("Converted audio for Safari: " + cacheKey + " -> " + convertedBlobUrl);
|
|
36114
|
-
});
|
|
36115
|
-
});
|
|
36116
|
-
});
|
|
36117
|
-
}, function (conversionError) {
|
|
36118
|
-
log.warn('Failed to convert audio for Safari, using original:', conversionError);
|
|
36119
|
-
audioUrl = url;
|
|
36120
|
-
});
|
|
36121
|
-
}
|
|
36122
|
-
}();
|
|
36123
|
-
return _temp && _temp.then ? _temp.then(_temp2) : _temp2(_temp);
|
|
36124
|
-
}, function (e) {
|
|
36125
|
-
log.error('Failed to init wavesurfer', e);
|
|
36126
|
-
}));
|
|
36127
|
-
} catch (e) {
|
|
36128
|
-
return Promise.reject(e);
|
|
34259
|
+
var audio = new Audio();
|
|
34260
|
+
audioRef.current = audio;
|
|
34261
|
+
audio.playbackRate = audioRate;
|
|
34262
|
+
audio.preload = 'metadata';
|
|
34263
|
+
if ((_file$metadata = file.metadata) !== null && _file$metadata !== void 0 && _file$metadata.dur) {
|
|
34264
|
+
setDuration(file.metadata.dur);
|
|
34265
|
+
setCurrentTime(formatAudioVideoTime(file.metadata.dur));
|
|
34266
|
+
}
|
|
34267
|
+
audio.addEventListener('loadedmetadata', function () {
|
|
34268
|
+
var audioDuration = audio.duration;
|
|
34269
|
+
if (audioDuration && isFinite(audioDuration)) {
|
|
34270
|
+
var _file$metadata2, _file$metadata3;
|
|
34271
|
+
setRealDuration(audioDuration);
|
|
34272
|
+
setDuration((file === null || file === void 0 ? void 0 : (_file$metadata2 = file.metadata) === null || _file$metadata2 === void 0 ? void 0 : _file$metadata2.dur) || audioDuration);
|
|
34273
|
+
setCurrentTime(formatAudioVideoTime((file === null || file === void 0 ? void 0 : (_file$metadata3 = file.metadata) === null || _file$metadata3 === void 0 ? void 0 : _file$metadata3.dur) || audioDuration));
|
|
36129
34274
|
}
|
|
36130
|
-
};
|
|
36131
|
-
|
|
34275
|
+
});
|
|
34276
|
+
audio.addEventListener('ended', function () {
|
|
34277
|
+
setPlayAudio(false);
|
|
34278
|
+
audio.currentTime = 0;
|
|
34279
|
+
var audioDuration = audio.duration;
|
|
34280
|
+
if (audioDuration && isFinite(audioDuration)) {
|
|
34281
|
+
var _file$metadata4, _file$metadata5;
|
|
34282
|
+
setRealDuration(audioDuration);
|
|
34283
|
+
setDuration((file === null || file === void 0 ? void 0 : (_file$metadata4 = file.metadata) === null || _file$metadata4 === void 0 ? void 0 : _file$metadata4.dur) || audioDuration);
|
|
34284
|
+
setCurrentTime(formatAudioVideoTime((file === null || file === void 0 ? void 0 : (_file$metadata5 = file.metadata) === null || _file$metadata5 === void 0 ? void 0 : _file$metadata5.dur) || audioDuration));
|
|
34285
|
+
}
|
|
34286
|
+
setCurrentTimeSeconds(0);
|
|
34287
|
+
if (playingAudioId === file.id) {
|
|
34288
|
+
dispatch(setPlayingAudioIdAC(null));
|
|
34289
|
+
}
|
|
34290
|
+
clearInterval(intervalRef.current);
|
|
34291
|
+
if (onClose) {
|
|
34292
|
+
onClose();
|
|
34293
|
+
}
|
|
34294
|
+
});
|
|
34295
|
+
audio.addEventListener('pause', function () {
|
|
34296
|
+
setPlayAudio(false);
|
|
34297
|
+
if (playingAudioId === file.id) {
|
|
34298
|
+
dispatch(setPlayingAudioIdAC(null));
|
|
34299
|
+
}
|
|
34300
|
+
clearInterval(intervalRef.current);
|
|
34301
|
+
});
|
|
34302
|
+
audio.addEventListener('error', function () {
|
|
34303
|
+
var _audio$error, _audio$error2;
|
|
34304
|
+
log.error('Audio element error:', (_audio$error = audio.error) === null || _audio$error === void 0 ? void 0 : _audio$error.message, 'code:', (_audio$error2 = audio.error) === null || _audio$error2 === void 0 ? void 0 : _audio$error2.code);
|
|
34305
|
+
if (isSafari() && !convertedUrlRef.current) {
|
|
34306
|
+
log.info('Attempting Safari audio conversion fallback...');
|
|
34307
|
+
fetch(url).then(function (response) {
|
|
34308
|
+
return response.blob();
|
|
34309
|
+
}).then(function (blob) {
|
|
34310
|
+
var audioFile = new File([blob], file.name || 'audio', {
|
|
34311
|
+
type: blob.type || 'audio/mpeg',
|
|
34312
|
+
lastModified: Date.now()
|
|
34313
|
+
});
|
|
34314
|
+
return convertAudioForSafari(audioFile, file === null || file === void 0 ? void 0 : file.messageId);
|
|
34315
|
+
}).then(function (convertedFile) {
|
|
34316
|
+
var blobUrl = URL.createObjectURL(convertedFile);
|
|
34317
|
+
convertedUrlRef.current = blobUrl;
|
|
34318
|
+
audio.src = blobUrl;
|
|
34319
|
+
})["catch"](function (conversionError) {
|
|
34320
|
+
log.error('Safari audio conversion fallback failed:', conversionError);
|
|
34321
|
+
});
|
|
34322
|
+
}
|
|
34323
|
+
});
|
|
34324
|
+
audio.src = url;
|
|
36132
34325
|
}
|
|
36133
34326
|
return function () {
|
|
36134
34327
|
clearInterval(intervalRef.current);
|
|
@@ -36136,16 +34329,17 @@ var AudioPlayer = function AudioPlayer(_ref) {
|
|
|
36136
34329
|
URL.revokeObjectURL(convertedUrlRef.current);
|
|
36137
34330
|
convertedUrlRef.current = null;
|
|
36138
34331
|
}
|
|
36139
|
-
if (
|
|
36140
|
-
|
|
36141
|
-
|
|
34332
|
+
if (audioRef.current) {
|
|
34333
|
+
audioRef.current.pause();
|
|
34334
|
+
audioRef.current.src = '';
|
|
34335
|
+
audioRef.current = null;
|
|
36142
34336
|
}
|
|
36143
34337
|
};
|
|
36144
34338
|
}, [url, file.id]);
|
|
36145
34339
|
React.useEffect(function () {
|
|
36146
|
-
if (playAudio && playingAudioId && playingAudioId !== "player_" + file.id &&
|
|
34340
|
+
if (playAudio && playingAudioId && playingAudioId !== "player_" + file.id && audioRef.current) {
|
|
36147
34341
|
setPlayAudio(false);
|
|
36148
|
-
|
|
34342
|
+
audioRef.current.pause();
|
|
36149
34343
|
}
|
|
36150
34344
|
}, [playingAudioId]);
|
|
36151
34345
|
return /*#__PURE__*/React__default.createElement(Container$e, {
|
|
@@ -36157,10 +34351,10 @@ var AudioPlayer = function AudioPlayer(_ref) {
|
|
|
36157
34351
|
}, playAudio ? /*#__PURE__*/React__default.createElement(SvgPause, null) : /*#__PURE__*/React__default.createElement(SvgPlay, null), viewOnce && (/*#__PURE__*/React__default.createElement(DisappearingMessagesBadge$1, {
|
|
36158
34352
|
color: incoming ? incomingMessageBackground : outgoingMessageBackground,
|
|
36159
34353
|
"$iconColor": accentColor
|
|
36160
|
-
}))), /*#__PURE__*/React__default.createElement(WaveContainer, null, /*#__PURE__*/React__default.createElement(VisualizationWrapper,
|
|
36161
|
-
ref:
|
|
36162
|
-
|
|
36163
|
-
}
|
|
34354
|
+
}))), /*#__PURE__*/React__default.createElement(WaveContainer, null, /*#__PURE__*/React__default.createElement(VisualizationWrapper, {
|
|
34355
|
+
ref: visualizationRef,
|
|
34356
|
+
onClick: handleSeek
|
|
34357
|
+
}, ((_file$metadata6 = file.metadata) === null || _file$metadata6 === void 0 ? void 0 : _file$metadata6.tmb) && Array.isArray(file.metadata.tmb) && (/*#__PURE__*/React__default.createElement(AudioVisualizationComponent, {
|
|
36164
34358
|
tmb: file.metadata.tmb,
|
|
36165
34359
|
duration: realDuration || duration || file.metadata.dur || 0,
|
|
36166
34360
|
currentTime: currentTimeSeconds,
|
|
@@ -36173,7 +34367,7 @@ var AudioPlayer = function AudioPlayer(_ref) {
|
|
|
36173
34367
|
color: textSecondary,
|
|
36174
34368
|
onClick: handleSetAudioRate,
|
|
36175
34369
|
backgroundColor: backgroundSections
|
|
36176
|
-
}, audioRate, /*#__PURE__*/React__default.createElement("span", null, "X"))), /*#__PURE__*/React__default.createElement(Timer
|
|
34370
|
+
}, audioRate, /*#__PURE__*/React__default.createElement("span", null, "X"))), /*#__PURE__*/React__default.createElement(Timer, {
|
|
36177
34371
|
color: textSecondary
|
|
36178
34372
|
}, currentTime || formatAudioVideoTime(((_file$metadata7 = file.metadata) === null || _file$metadata7 === void 0 ? void 0 : _file$metadata7.dur) || 0)));
|
|
36179
34373
|
};
|
|
@@ -36185,24 +34379,17 @@ var Container$e = styled__default.div(_templateObject$v || (_templateObject$v =
|
|
|
36185
34379
|
var PlayPause = styled__default.div(_templateObject2$r || (_templateObject2$r = _taggedTemplateLiteralLoose(["\n cursor: pointer;\n position: relative;\n & > svg {\n color: ", ";\n display: flex;\n width: 40px;\n height: 40px;\n }\n"])), function (props) {
|
|
36186
34380
|
return props.iconColor;
|
|
36187
34381
|
});
|
|
36188
|
-
var VisualizationWrapper = styled__default.div(_templateObject3$l || (_templateObject3$l = _taggedTemplateLiteralLoose(["\n width: 100%;\n display: flex;\n align-items: center;\n position: relative;\n"])));
|
|
36189
|
-
var
|
|
36190
|
-
return props.hidden ? 'absolute' : 'relative';
|
|
36191
|
-
}, function (props) {
|
|
36192
|
-
return props.hidden ? 0 : 1;
|
|
36193
|
-
}, function (props) {
|
|
36194
|
-
return props.hidden ? 'none' : 'auto';
|
|
36195
|
-
});
|
|
36196
|
-
var AudioRate = styled__default.div(_templateObject5$e || (_templateObject5$e = _taggedTemplateLiteralLoose(["\n display: flex;\n align-items: center;\n justify-content: center;\n background-color: ", ";\n width: 30px;\n min-width: 30px;\n border-radius: 12px;\n font-weight: 600;\n font-size: 12px;\n line-height: 14px;\n color: ", ";\n height: 18px;\n box-sizing: border-box;\n margin-left: auto;\n cursor: pointer;\n\n & > span {\n margin-top: auto;\n line-height: 16px;\n font-size: 9px;\n }\n"])), function (props) {
|
|
34382
|
+
var VisualizationWrapper = styled__default.div(_templateObject3$l || (_templateObject3$l = _taggedTemplateLiteralLoose(["\n width: 100%;\n display: flex;\n align-items: center;\n position: relative;\n cursor: pointer;\n"])));
|
|
34383
|
+
var AudioRate = styled__default.div(_templateObject4$h || (_templateObject4$h = _taggedTemplateLiteralLoose(["\n display: flex;\n align-items: center;\n justify-content: center;\n background-color: ", ";\n width: 30px;\n min-width: 30px;\n border-radius: 12px;\n font-weight: 600;\n font-size: 12px;\n line-height: 14px;\n color: ", ";\n height: 18px;\n box-sizing: border-box;\n margin-left: auto;\n cursor: pointer;\n\n & > span {\n margin-top: auto;\n line-height: 16px;\n font-size: 9px;\n }\n"])), function (props) {
|
|
36197
34384
|
return props.backgroundColor;
|
|
36198
34385
|
}, function (props) {
|
|
36199
34386
|
return props.color;
|
|
36200
34387
|
});
|
|
36201
|
-
var WaveContainer = styled__default.div(
|
|
36202
|
-
var Timer
|
|
34388
|
+
var WaveContainer = styled__default.div(_templateObject5$e || (_templateObject5$e = _taggedTemplateLiteralLoose(["\n width: 100%;\n display: flex;\n margin-left: 8px;\n"])));
|
|
34389
|
+
var Timer = styled__default.div(_templateObject6$b || (_templateObject6$b = _taggedTemplateLiteralLoose(["\n position: absolute;\n left: 59px;\n bottom: 12px;\n display: inline-block;\n font-weight: 400;\n font-size: 11px;\n line-height: 12px;\n color: ", ";\n"])), function (props) {
|
|
36203
34390
|
return props.color;
|
|
36204
34391
|
});
|
|
36205
|
-
var DisappearingMessagesBadge$1 = styled__default(SvgBadge)(
|
|
34392
|
+
var DisappearingMessagesBadge$1 = styled__default(SvgBadge)(_templateObject7$a || (_templateObject7$a = _taggedTemplateLiteralLoose(["\n position: absolute;\n bottom: -3px;\n right: -8px;\n width: 24px !important;\n height: 24px !important;\n transform: scale(0.875);\n display: flex;\n align-items: center;\n justify-content: center;\n z-index: 1;\n color: ", ";\n & > path:nth-child(1) {\n stroke: ", ";\n fill: ", ";\n }\n g {\n path {\n stroke: ", ";\n }\n }\n"])), function (props) {
|
|
36206
34393
|
return props.color;
|
|
36207
34394
|
}, function (props) {
|
|
36208
34395
|
return props.color;
|
|
@@ -36670,7 +34857,7 @@ var UploadInProgress = styled__default.img(_templateObject7$c || (_templateObjec
|
|
|
36670
34857
|
return props.isDetailsView && "\n width: 100%;\n height: 100%;\n min-width: inherit;\n ";
|
|
36671
34858
|
});
|
|
36672
34859
|
|
|
36673
|
-
var _templateObject$z, _templateObject2$v, _templateObject3$p, _templateObject4$l, _templateObject5$h, _templateObject6$e, _templateObject7$d, _templateObject8$
|
|
34860
|
+
var _templateObject$z, _templateObject2$v, _templateObject3$p, _templateObject4$l, _templateObject5$h, _templateObject6$e, _templateObject7$d, _templateObject8$a, _templateObject9$9, _templateObject0$8, _templateObject1$6, _templateObject10$3, _templateObject11$3;
|
|
36674
34861
|
var Attachment = function Attachment(_ref) {
|
|
36675
34862
|
var attachment = _ref.attachment,
|
|
36676
34863
|
_ref$isPreview = _ref.isPreview,
|
|
@@ -37530,7 +35717,7 @@ var AttachmentFile$1 = styled__default.div(_templateObject7$d || (_templateObjec
|
|
|
37530
35717
|
}, function (props) {
|
|
37531
35718
|
return !props.isRepliedMessage && !props.isPreview && !props.isUploading && "\n &:hover " + DownloadFile$1 + " {\n display: flex;\n }\n\n &:hover " + UploadPercent + " {\n border-radius: 50%\n }\n\n &:hover " + FileThumbnail + " {\n }\n &:hover " + AttachmentIconCont + " {\n display: none;\n }\n ";
|
|
37532
35719
|
}, AttachmentIconCont);
|
|
37533
|
-
var RemoveChosenFile = styled__default(SvgDeleteUpload)(_templateObject8$
|
|
35720
|
+
var RemoveChosenFile = styled__default(SvgDeleteUpload)(_templateObject8$a || (_templateObject8$a = _taggedTemplateLiteralLoose(["\n position: absolute;\n width: 20px;\n height: 20px !important;\n top: -11px;\n right: -11px;\n padding: 2px;\n cursor: pointer;\n color: ", ";\n z-index: 5;\n circle {\n stroke: ", ";\n }\n path {\n stroke: ", ";\n }\n"])), function (props) {
|
|
37534
35721
|
return props.color;
|
|
37535
35722
|
}, function (props) {
|
|
37536
35723
|
return props.$backgroundColor;
|
|
@@ -38185,7 +36372,7 @@ var EMOJIS = [{
|
|
|
38185
36372
|
}]
|
|
38186
36373
|
}];
|
|
38187
36374
|
|
|
38188
|
-
var _templateObject$C, _templateObject2$x, _templateObject3$r, _templateObject4$n, _templateObject5$i, _templateObject6$f, _templateObject7$e, _templateObject8$
|
|
36375
|
+
var _templateObject$C, _templateObject2$x, _templateObject3$r, _templateObject4$n, _templateObject5$i, _templateObject6$f, _templateObject7$e, _templateObject8$b;
|
|
38189
36376
|
var EmojiIcon = function EmojiIcon(_ref) {
|
|
38190
36377
|
var collectionName = _ref.collectionName;
|
|
38191
36378
|
switch (collectionName) {
|
|
@@ -38397,7 +36584,7 @@ var EmojiFooter = styled__default.div(_templateObject7$e || (_templateObject7$e
|
|
|
38397
36584
|
}, function (props) {
|
|
38398
36585
|
return props.emojisCategoryIconsPosition === 'top' && "1px solid " + props.borderColor;
|
|
38399
36586
|
});
|
|
38400
|
-
var Emoji = styled__default.li(_templateObject8$
|
|
36587
|
+
var Emoji = styled__default.li(_templateObject8$b || (_templateObject8$b = _taggedTemplateLiteralLoose(["\n cursor: pointer;\n width: 32px;\n height: 32px;\n margin: 0 2px;\n display: inline-block;\n box-sizing: border-box;\n border-radius: 50%;\n padding-top: 2px;\n text-align: center;\n background: transparent;\n font-family:\n apple color emoji,\n segoe ui emoji,\n noto color emoji,\n android emoji,\n emojisymbols,\n emojione mozilla,\n twemoji mozilla,\n segoe ui symbol;\n & > * {\n font-size: 22px;\n }\n &:hover {\n background: ", ";\n }\n"])), function (props) {
|
|
38401
36588
|
return props.hoverBackgroundColor;
|
|
38402
36589
|
});
|
|
38403
36590
|
|
|
@@ -38571,7 +36758,7 @@ var OpenMoreEmojis = styled__default.span(_templateObject3$s || (_templateObject
|
|
|
38571
36758
|
return props.iconHoverColor;
|
|
38572
36759
|
});
|
|
38573
36760
|
|
|
38574
|
-
var _templateObject$E, _templateObject2$z, _templateObject3$t, _templateObject4$o, _templateObject5$j, _templateObject6$g, _templateObject7$f, _templateObject8$
|
|
36761
|
+
var _templateObject$E, _templateObject2$z, _templateObject3$t, _templateObject4$o, _templateObject5$j, _templateObject6$g, _templateObject7$f, _templateObject8$c, _templateObject9$a, _templateObject0$9, _templateObject1$7, _templateObject10$4;
|
|
38575
36762
|
var POLL_VOTES_LIMIT = 20;
|
|
38576
36763
|
var AllVotesPopup = function AllVotesPopup(_ref) {
|
|
38577
36764
|
var _pollVotesHasMore$key, _poll$voteDetails, _poll$voteDetails$vot, _poll$voteDetails3;
|
|
@@ -38712,7 +36899,7 @@ var LoadingText = styled__default.div(_templateObject6$g || (_templateObject6$g
|
|
|
38712
36899
|
return p.color;
|
|
38713
36900
|
});
|
|
38714
36901
|
var TitleWrapper = styled__default.div(_templateObject7$f || (_templateObject7$f = _taggedTemplateLiteralLoose(["\n max-width: calc(100% - 54px);\n margin: 0 auto;\n"])));
|
|
38715
|
-
var BackButton = styled__default.button(_templateObject8$
|
|
36902
|
+
var BackButton = styled__default.button(_templateObject8$c || (_templateObject8$c = _taggedTemplateLiteralLoose(["\n position: absolute;\n left: 13px;\n top: 13px;\n padding: 9px;\n cursor: pointer;\n box-sizing: content-box;\n background: transparent;\n border: none;\n display: flex;\n align-items: center;\n justify-content: center;\n color: ", ";\n flex-shrink: 0;\n\n & > svg {\n width: 24px;\n height: 24px;\n }\n\n &:hover {\n opacity: 0.7;\n }\n"])), function (p) {
|
|
38716
36903
|
return p.color;
|
|
38717
36904
|
});
|
|
38718
36905
|
var VotesContainer = styled__default.div(_templateObject9$a || (_templateObject9$a = _taggedTemplateLiteralLoose(["\n padding: 0 2px 8px 16px;\n border-radius: 10px;\n background-color: ", ";\n margin-top: 16px;\n"])), function (p) {
|
|
@@ -38728,7 +36915,7 @@ var Loader = styled__default.div(_templateObject10$4 || (_templateObject10$4 = _
|
|
|
38728
36915
|
return p.color;
|
|
38729
36916
|
});
|
|
38730
36917
|
|
|
38731
|
-
var _templateObject$F, _templateObject2$A, _templateObject3$u, _templateObject4$p, _templateObject5$k, _templateObject6$h, _templateObject7$g, _templateObject8$
|
|
36918
|
+
var _templateObject$F, _templateObject2$A, _templateObject3$u, _templateObject4$p, _templateObject5$k, _templateObject6$h, _templateObject7$g, _templateObject8$d, _templateObject9$b, _templateObject0$a, _templateObject1$8, _templateObject10$5;
|
|
38732
36919
|
var VotesResultsPopup = function VotesResultsPopup(_ref) {
|
|
38733
36920
|
var _poll$voteDetails3, _poll$voteDetails4, _poll$options$find;
|
|
38734
36921
|
var onClose = _ref.onClose,
|
|
@@ -38891,7 +37078,7 @@ var OptionBlock = styled__default.div(_templateObject2$A || (_templateObject2$A
|
|
|
38891
37078
|
return p.border;
|
|
38892
37079
|
});
|
|
38893
37080
|
var OptionHeader = styled__default.div(_templateObject3$u || (_templateObject3$u = _taggedTemplateLiteralLoose(["\n display: flex;\n align-items: center;\n justify-content: space-between;\n margin-bottom: 8px;\n"])));
|
|
38894
|
-
var OptionTitle = styled__default.div(_templateObject4$p || (_templateObject4$p = _taggedTemplateLiteralLoose(["\n color: ", ";\n max-width: calc(100% - 60px);\n font-family: Inter;\n font-weight: 500;\n font-size: 15px;\n line-height: 20px;\n letter-spacing: -0.4px;\n"])), function (p) {
|
|
37081
|
+
var OptionTitle = styled__default.div(_templateObject4$p || (_templateObject4$p = _taggedTemplateLiteralLoose(["\n color: ", ";\n max-width: calc(100% - 60px);\n font-family: Inter;\n font-weight: 500;\n font-size: 15px;\n line-height: 20px;\n letter-spacing: -0.4px;\n overflow-wrap: break-word;\n"])), function (p) {
|
|
38895
37082
|
return p.color;
|
|
38896
37083
|
});
|
|
38897
37084
|
var OptionCount = styled__default.div(_templateObject5$k || (_templateObject5$k = _taggedTemplateLiteralLoose(["\n color: ", ";\n font-size: 13px;\n margin-bottom: auto;\n font-weight: 400;\n font-size: 15px;\n line-height: 20px;\n letter-spacing: -0.4px;\n"])), function (p) {
|
|
@@ -38899,7 +37086,7 @@ var OptionCount = styled__default.div(_templateObject5$k || (_templateObject5$k
|
|
|
38899
37086
|
});
|
|
38900
37087
|
var Voters = styled__default.div(_templateObject6$h || (_templateObject6$h = _taggedTemplateLiteralLoose(["\n display: flex;\n flex-direction: column;\n margin-bottom: 5px;\n"])));
|
|
38901
37088
|
var VoterRow$1 = styled__default.div(_templateObject7$g || (_templateObject7$g = _taggedTemplateLiteralLoose(["\n display: flex;\n align-items: center;\n gap: 12px;\n padding: 6px 0;\n"])));
|
|
38902
|
-
var VoterInfo$1 = styled__default.div(_templateObject8$
|
|
37089
|
+
var VoterInfo$1 = styled__default.div(_templateObject8$d || (_templateObject8$d = _taggedTemplateLiteralLoose(["\n display: flex;\n align-items: center;\n gap: 10px;\n width: 100%;\n justify-content: space-between;\n"])));
|
|
38903
37090
|
var VoterName$1 = styled__default.div(_templateObject9$b || (_templateObject9$b = _taggedTemplateLiteralLoose(["\n color: ", ";\n font-weight: 500;\n font-size: 15px;\n line-height: 20px;\n letter-spacing: -0.2px;\n max-width: calc(100% - 120px);\n"])), function (p) {
|
|
38904
37091
|
return p.color;
|
|
38905
37092
|
});
|
|
@@ -38935,7 +37122,7 @@ function SvgFilledCheckbox(props) {
|
|
|
38935
37122
|
})));
|
|
38936
37123
|
}
|
|
38937
37124
|
|
|
38938
|
-
var _templateObject$G, _templateObject2$B, _templateObject3$v, _templateObject4$q, _templateObject5$l, _templateObject6$i, _templateObject7$h, _templateObject8$
|
|
37125
|
+
var _templateObject$G, _templateObject2$B, _templateObject3$v, _templateObject4$q, _templateObject5$l, _templateObject6$i, _templateObject7$h, _templateObject8$e, _templateObject9$c, _templateObject0$b, _templateObject1$9, _templateObject10$6, _templateObject11$4, _templateObject12$3;
|
|
38939
37126
|
var PollMessage = function PollMessage(_ref) {
|
|
38940
37127
|
var _poll$voteDetails3, _poll$voteDetails4, _poll$voteDetails5, _poll$voteDetails6, _poll$voteDetails7;
|
|
38941
37128
|
var message = _ref.message,
|
|
@@ -39106,7 +37293,7 @@ var Indicator = styled__default.div(_templateObject7$h || (_templateObject7$h =
|
|
|
39106
37293
|
}, function (p) {
|
|
39107
37294
|
return p.disabled ? 'not-allowed' : 'pointer';
|
|
39108
37295
|
});
|
|
39109
|
-
var EmptyCircle = styled__default.span(_templateObject8$
|
|
37296
|
+
var EmptyCircle = styled__default.span(_templateObject8$e || (_templateObject8$e = _taggedTemplateLiteralLoose(["\n display: inline-block;\n width: 18.5px;\n height: 18.5px;\n border-radius: 50%;\n border: 1px solid ", ";\n box-sizing: border-box;\n"])), function (p) {
|
|
39110
37297
|
return p.border;
|
|
39111
37298
|
});
|
|
39112
37299
|
var StyledCheck = styled__default(SvgFilledCheckbox)(_templateObject9$c || (_templateObject9$c = _taggedTemplateLiteralLoose(["\n color: ", ";\n width: 18.5px;\n height: 18.5px;\n"])), function (p) {
|
|
@@ -39130,7 +37317,7 @@ var UsersContainer = styled__default.div(_templateObject12$3 || (_templateObject
|
|
|
39130
37317
|
return p.cursor;
|
|
39131
37318
|
});
|
|
39132
37319
|
|
|
39133
|
-
var _templateObject$H, _templateObject2$C, _templateObject3$w, _templateObject4$r, _templateObject5$m, _templateObject6$j, _templateObject7$i, _templateObject8$
|
|
37320
|
+
var _templateObject$H, _templateObject2$C, _templateObject3$w, _templateObject4$r, _templateObject5$m, _templateObject6$j, _templateObject7$i, _templateObject8$f, _templateObject9$d, _templateObject0$c, _templateObject1$a;
|
|
39134
37321
|
var validateUrl = function validateUrl(url) {
|
|
39135
37322
|
try {
|
|
39136
37323
|
var urlObj = new URL(url);
|
|
@@ -39461,12 +37648,12 @@ var Img = styled__default.img(_templateObject7$i || (_templateObject7$i = _tagge
|
|
|
39461
37648
|
var shouldAnimate = _ref22.shouldAnimate;
|
|
39462
37649
|
return shouldAnimate && "\n animation: fadeIn 0.4s ease-out forwards;\n ";
|
|
39463
37650
|
});
|
|
39464
|
-
var OGRow = styled__default.div(_templateObject8$
|
|
37651
|
+
var OGRow = styled__default.div(_templateObject8$f || (_templateObject8$f = _taggedTemplateLiteralLoose(["\n display: flex;\n align-items: flex-start;\n justify-content: space-between;\n padding: 0;\n"])));
|
|
39465
37652
|
var OGTextWrapper = styled__default.div(_templateObject9$d || (_templateObject9$d = _taggedTemplateLiteralLoose(["\n flex: 1 1 auto;\n"])));
|
|
39466
37653
|
var FaviconContainer = styled__default.div(_templateObject0$c || (_templateObject0$c = _taggedTemplateLiteralLoose(["\n width: 52px;\n height: 52px;\n border-radius: 8px;\n overflow: hidden;\n margin: 8px;\n flex: 0 0 52px;\n"])));
|
|
39467
37654
|
var FaviconImg = styled__default.img(_templateObject1$a || (_templateObject1$a = _taggedTemplateLiteralLoose(["\n width: 100%;\n height: 100%;\n object-fit: cover;\n display: block;\n"])));
|
|
39468
37655
|
|
|
39469
|
-
var _templateObject$I, _templateObject2$D, _templateObject3$x, _templateObject4$s, _templateObject5$n, _templateObject6$k, _templateObject7$j, _templateObject8$
|
|
37656
|
+
var _templateObject$I, _templateObject2$D, _templateObject3$x, _templateObject4$s, _templateObject5$n, _templateObject6$k, _templateObject7$j, _templateObject8$g, _templateObject9$e, _templateObject0$d;
|
|
39470
37657
|
var MessageBody = function MessageBody(_ref) {
|
|
39471
37658
|
var _message$attachments2, _message$attachments3, _message$pollDetails, _message$pollDetails2, _message$attachments4;
|
|
39472
37659
|
var message = _ref.message,
|
|
@@ -40227,7 +38414,7 @@ var EmojiContainer = styled__default.div(_templateObject7$j || (_templateObject7
|
|
|
40227
38414
|
}, function (props) {
|
|
40228
38415
|
return props.position === 'top' && 'calc(100% + 4px)';
|
|
40229
38416
|
});
|
|
40230
|
-
var FrequentlyEmojisContainer = styled__default.div(_templateObject8$
|
|
38417
|
+
var FrequentlyEmojisContainer = styled__default.div(_templateObject8$g || (_templateObject8$g = _taggedTemplateLiteralLoose(["\n position: absolute;\n left: ", ";\n right: ", ";\n top: -50px;\n z-index: 99;\n"])), function (props) {
|
|
40231
38418
|
return props.rtlDirection ? '' : '0';
|
|
40232
38419
|
}, function (props) {
|
|
40233
38420
|
return props.rtlDirection && '0';
|
|
@@ -40239,7 +38426,7 @@ var ReadMoreLink = styled__default.span(_templateObject0$d || (_templateObject0$
|
|
|
40239
38426
|
return props.accentColor;
|
|
40240
38427
|
});
|
|
40241
38428
|
|
|
40242
|
-
var _templateObject$J, _templateObject2$E, _templateObject3$y, _templateObject4$t, _templateObject5$o, _templateObject6$l, _templateObject7$k, _templateObject8$
|
|
38429
|
+
var _templateObject$J, _templateObject2$E, _templateObject3$y, _templateObject4$t, _templateObject5$o, _templateObject6$l, _templateObject7$k, _templateObject8$h, _templateObject9$f, _templateObject0$e;
|
|
40243
38430
|
var reactionsPrevLength = 0;
|
|
40244
38431
|
function ReactionsPopup(_ref) {
|
|
40245
38432
|
var messageId = _ref.messageId,
|
|
@@ -40482,7 +38669,7 @@ var ReactionsList = styled__default.ul(_templateObject4$t || (_templateObject4$t
|
|
|
40482
38669
|
var ReactionScoresCont = styled__default.div(_templateObject5$o || (_templateObject5$o = _taggedTemplateLiteralLoose(["\n max-width: 100%;\n overflow: auto;\n overflow-y: hidden;\n\n &::-webkit-scrollbar {\n display: none;\n }\n &::-webkit-scrollbar-thumb {\n display: none;\n }\n &::-webkit-scrollbar-track {\n display: none;\n }\n"])));
|
|
40483
38670
|
var ReactionScoresList = styled__default.div(_templateObject6$l || (_templateObject6$l = _taggedTemplateLiteralLoose(["\n display: flex;\n padding: 2px 8px 0;\n"])));
|
|
40484
38671
|
var TabKey = styled__default.span(_templateObject7$k || (_templateObject7$k = _taggedTemplateLiteralLoose([""])));
|
|
40485
|
-
var ReactionScoreItem = styled__default.div(_templateObject8$
|
|
38672
|
+
var ReactionScoreItem = styled__default.div(_templateObject8$h || (_templateObject8$h = _taggedTemplateLiteralLoose(["\n position: relative;\n display: flex;\n white-space: nowrap;\n padding: ", ";\n font-weight: 500;\n font-size: 13px;\n color: ", ";\n margin-bottom: -1px;\n cursor: pointer;\n & > span {\n position: relative;\n padding: ", ";\n border-radius: 16px;\n height: 30px;\n box-sizing: border-box;\n font-family: Inter, sans-serif;\n font-style: normal;\n font-weight: 600;\n font-size: 14px;\n line-height: ", ";\n background-color: ", ";\n color: ", ";\n ", "\n\n & ", " {\n font-family:\n apple color emoji,\n segoe ui emoji,\n noto color emoji,\n android emoji,\n emojisymbols,\n emojione mozilla,\n twemoji mozilla,\n segoe ui symbol;\n margin-right: 4px;\n font-size: 15px;\n }\n }\n"])), function (props) {
|
|
40486
38673
|
return props.bubbleStyle ? '12px 4px' : '12px';
|
|
40487
38674
|
}, function (props) {
|
|
40488
38675
|
return props.active ? props.activeColor : props.color;
|
|
@@ -40659,7 +38846,7 @@ function SvgCircleDashed(props) {
|
|
|
40659
38846
|
})));
|
|
40660
38847
|
}
|
|
40661
38848
|
|
|
40662
|
-
var _templateObject$L, _templateObject2$G, _templateObject3$A, _templateObject4$v, _templateObject5$q, _templateObject6$m, _templateObject7$l, _templateObject8$
|
|
38849
|
+
var _templateObject$L, _templateObject2$G, _templateObject3$A, _templateObject4$v, _templateObject5$q, _templateObject6$m, _templateObject7$l, _templateObject8$i, _templateObject9$g, _templateObject0$f, _templateObject1$b, _templateObject10$7, _templateObject11$5, _templateObject12$4, _templateObject13$3;
|
|
40663
38850
|
var defaultFormatDate = function defaultFormatDate(date) {
|
|
40664
38851
|
var m = moment(date);
|
|
40665
38852
|
if (m.isSame(moment(), 'day')) {
|
|
@@ -41218,7 +39405,7 @@ var RowTitle = styled__default.div(_templateObject6$m || (_templateObject6$m = _
|
|
|
41218
39405
|
var RowDate = styled__default.div(_templateObject7$l || (_templateObject7$l = _taggedTemplateLiteralLoose(["\n color: ", ";\n min-width: max-content;\n font-weight: 400;\n font-size: 13px;\n line-height: 16px;\n"])), function (p) {
|
|
41219
39406
|
return p.color;
|
|
41220
39407
|
});
|
|
41221
|
-
var Empty = styled__default.div(_templateObject8$
|
|
39408
|
+
var Empty = styled__default.div(_templateObject8$i || (_templateObject8$i = _taggedTemplateLiteralLoose(["\n color: ", ";\n text-align: center;\n padding: 16px 0;\n font-size: 14px;\n height: calc(100% - 32px);\n display: flex;\n align-items: center;\n justify-content: center;\n overflow: hidden;\n"])), function (p) {
|
|
41222
39409
|
return p.color;
|
|
41223
39410
|
});
|
|
41224
39411
|
var DropdownRoot = styled__default.div(_templateObject9$g || (_templateObject9$g = _taggedTemplateLiteralLoose(["\n position: absolute;\n top: ", ";\n bottom: ", ";\n ", "\n transform: ", ";\n z-index: 15;\n background: ", ";\n box-shadow: 0px 0px 24px 0px #11153929;\n border-radius: 16px;\n direction: initial;\n visibility: ", ";\n"])), function (p) {
|
|
@@ -41379,6 +39566,97 @@ var EmptySelection = styled__default.span(_templateObject2$H || (_templateObject
|
|
|
41379
39566
|
return props.disabled && '0.5';
|
|
41380
39567
|
});
|
|
41381
39568
|
|
|
39569
|
+
var copyRichTextToClipboard = function copyRichTextToClipboard(html, plainText) {
|
|
39570
|
+
try {
|
|
39571
|
+
var _temp4 = function _temp4(_result4) {
|
|
39572
|
+
if (_exit2) return _result4;
|
|
39573
|
+
try {
|
|
39574
|
+
if (typeof document !== 'undefined') {
|
|
39575
|
+
var container = document.createElement('div');
|
|
39576
|
+
container.innerHTML = html;
|
|
39577
|
+
container.style.position = 'fixed';
|
|
39578
|
+
container.style.left = '-9999px';
|
|
39579
|
+
container.style.opacity = '0';
|
|
39580
|
+
document.body.appendChild(container);
|
|
39581
|
+
var range = document.createRange();
|
|
39582
|
+
range.selectNodeContents(container);
|
|
39583
|
+
var selection = window.getSelection();
|
|
39584
|
+
if (selection) {
|
|
39585
|
+
selection.removeAllRanges();
|
|
39586
|
+
selection.addRange(range);
|
|
39587
|
+
var successful = document.execCommand('copy');
|
|
39588
|
+
selection.removeAllRanges();
|
|
39589
|
+
document.body.removeChild(container);
|
|
39590
|
+
return successful;
|
|
39591
|
+
}
|
|
39592
|
+
document.body.removeChild(container);
|
|
39593
|
+
}
|
|
39594
|
+
} catch (e) {}
|
|
39595
|
+
return copyToClipboard(plainText);
|
|
39596
|
+
};
|
|
39597
|
+
var _exit2 = false;
|
|
39598
|
+
var _temp3 = _catch(function () {
|
|
39599
|
+
var clipboard = navigator.clipboard;
|
|
39600
|
+
return function () {
|
|
39601
|
+
if (typeof navigator !== 'undefined' && clipboard && clipboard.write) {
|
|
39602
|
+
var htmlBlob = new Blob([html], {
|
|
39603
|
+
type: 'text/html'
|
|
39604
|
+
});
|
|
39605
|
+
var textBlob = new Blob([plainText], {
|
|
39606
|
+
type: 'text/plain'
|
|
39607
|
+
});
|
|
39608
|
+
var ClipboardItemCtor = window.ClipboardItem;
|
|
39609
|
+
var clipboardItem = new ClipboardItemCtor({
|
|
39610
|
+
'text/html': htmlBlob,
|
|
39611
|
+
'text/plain': textBlob
|
|
39612
|
+
});
|
|
39613
|
+
return Promise.resolve(clipboard.write([clipboardItem])).then(function () {
|
|
39614
|
+
_exit2 = true;
|
|
39615
|
+
return true;
|
|
39616
|
+
});
|
|
39617
|
+
}
|
|
39618
|
+
}();
|
|
39619
|
+
}, function () {});
|
|
39620
|
+
return Promise.resolve(_temp3 && _temp3.then ? _temp3.then(_temp4) : _temp4(_temp3));
|
|
39621
|
+
} catch (e) {
|
|
39622
|
+
return Promise.reject(e);
|
|
39623
|
+
}
|
|
39624
|
+
};
|
|
39625
|
+
var copyToClipboard = function copyToClipboard(text) {
|
|
39626
|
+
try {
|
|
39627
|
+
var _temp2 = function _temp2(_result2) {
|
|
39628
|
+
if (_exit) return _result2;
|
|
39629
|
+
try {
|
|
39630
|
+
if (typeof document !== 'undefined') {
|
|
39631
|
+
var textarea = document.createElement('textarea');
|
|
39632
|
+
textarea.value = text;
|
|
39633
|
+
textarea.style.position = 'fixed';
|
|
39634
|
+
textarea.style.left = '-9999px';
|
|
39635
|
+
document.body.appendChild(textarea);
|
|
39636
|
+
textarea.focus();
|
|
39637
|
+
textarea.select();
|
|
39638
|
+
var successful = document.execCommand('copy');
|
|
39639
|
+
document.body.removeChild(textarea);
|
|
39640
|
+
return successful;
|
|
39641
|
+
}
|
|
39642
|
+
} catch (e) {}
|
|
39643
|
+
return false;
|
|
39644
|
+
};
|
|
39645
|
+
var _exit = false;
|
|
39646
|
+
var _temp = _catch(function () {
|
|
39647
|
+
if (typeof navigator !== 'undefined' && navigator.clipboard && navigator.clipboard.writeText) {
|
|
39648
|
+
return Promise.resolve(navigator.clipboard.writeText(text)).then(function () {
|
|
39649
|
+
_exit = true;
|
|
39650
|
+
return true;
|
|
39651
|
+
});
|
|
39652
|
+
}
|
|
39653
|
+
}, function () {});
|
|
39654
|
+
return Promise.resolve(_temp && _temp.then ? _temp.then(_temp2) : _temp2(_temp));
|
|
39655
|
+
} catch (e) {
|
|
39656
|
+
return Promise.reject(e);
|
|
39657
|
+
}
|
|
39658
|
+
};
|
|
39659
|
+
|
|
41382
39660
|
var useMessageState = function useMessageState() {
|
|
41383
39661
|
var _useState = React.useState(false),
|
|
41384
39662
|
deletePopupOpen = _useState[0],
|
|
@@ -41769,8 +40047,13 @@ var Message$1 = function Message(_ref) {
|
|
|
41769
40047
|
accentColor: '',
|
|
41770
40048
|
textSecondary: ''
|
|
41771
40049
|
});
|
|
41772
|
-
var
|
|
41773
|
-
|
|
40050
|
+
var plainText = typeof textToCopyHTML === 'string' ? textToCopyHTML : _extractTextFromReactElement(textToCopyHTML);
|
|
40051
|
+
if (message.bodyAttributes && message.bodyAttributes.length > 0) {
|
|
40052
|
+
var html = bodyAttributesToHTML(message.body, message.bodyAttributes, message.mentionedUsers, contactsMap, getFromContacts);
|
|
40053
|
+
copyRichTextToClipboard(html, plainText);
|
|
40054
|
+
} else {
|
|
40055
|
+
navigator.clipboard.writeText(plainText);
|
|
40056
|
+
}
|
|
41774
40057
|
setMessageActionsShow(false);
|
|
41775
40058
|
}, [message, contactsMap]);
|
|
41776
40059
|
var handleToggleReactionsPopup = React.useCallback(function () {
|
|
@@ -42315,7 +40598,7 @@ var MessageItem = styled__default.div(_templateObject7$m || (_templateObject7$m
|
|
|
42315
40598
|
return props.hoverBackground || '';
|
|
42316
40599
|
}, HiddenMessageTime$1, MessageStatus$1);
|
|
42317
40600
|
|
|
42318
|
-
var _templateObject$O, _templateObject2$J, _templateObject3$C, _templateObject4$x, _templateObject5$s, _templateObject6$o, _templateObject7$n, _templateObject8$
|
|
40601
|
+
var _templateObject$O, _templateObject2$J, _templateObject3$C, _templateObject4$x, _templateObject5$s, _templateObject6$o, _templateObject7$n, _templateObject8$j, _templateObject9$h, _templateObject0$g, _templateObject1$c;
|
|
42319
40602
|
var CreateMessageDateDivider = function CreateMessageDateDivider(_ref) {
|
|
42320
40603
|
var lastIndex = _ref.lastIndex,
|
|
42321
40604
|
currentMessageDate = _ref.currentMessageDate,
|
|
@@ -43454,7 +41737,7 @@ var DropAttachmentArea = styled__default.div(_templateObject7$n || (_templateObj
|
|
|
43454
41737
|
}, IconWrapper$1, function (props) {
|
|
43455
41738
|
return props.iconBackgroundColor;
|
|
43456
41739
|
});
|
|
43457
|
-
var MessageWrapper = styled__default.div(_templateObject8$
|
|
41740
|
+
var MessageWrapper = styled__default.div(_templateObject8$j || (_templateObject8$j = _taggedTemplateLiteralLoose(["\n &.highlight {\n & .message_item {\n padding-top: 4px;\n padding-bottom: 4px;\n background-color: ", ";\n }\n }\n"])), function (props) {
|
|
43458
41741
|
return props.highlightBg || '#d5d5d5';
|
|
43459
41742
|
});
|
|
43460
41743
|
var NoMessagesContainer = styled__default.div(_templateObject9$h || (_templateObject9$h = _taggedTemplateLiteralLoose(["\n display: flex;\n align-items: center;\n justify-content: center;\n flex-direction: column;\n height: 100%;\n width: 100%;\n font-weight: 400;\n font-size: 15px;\n line-height: 18px;\n letter-spacing: -0.2px;\n color: ", ";\n"])), function (props) {
|
|
@@ -44932,6 +43215,63 @@ function EditMessagePlugin(_ref) {
|
|
|
44932
43215
|
return null;
|
|
44933
43216
|
}
|
|
44934
43217
|
|
|
43218
|
+
function parseHTMLToFormattedSegments(html) {
|
|
43219
|
+
var parser = new DOMParser();
|
|
43220
|
+
var doc = parser.parseFromString(html, 'text/html');
|
|
43221
|
+
var segments = [];
|
|
43222
|
+
function walkNode(node, inheritedFormat) {
|
|
43223
|
+
if (node.nodeType === Node.TEXT_NODE) {
|
|
43224
|
+
var text = node.textContent || '';
|
|
43225
|
+
if (text) {
|
|
43226
|
+
segments.push({
|
|
43227
|
+
text: text,
|
|
43228
|
+
format: inheritedFormat
|
|
43229
|
+
});
|
|
43230
|
+
}
|
|
43231
|
+
return;
|
|
43232
|
+
}
|
|
43233
|
+
if (node.nodeType !== Node.ELEMENT_NODE) return;
|
|
43234
|
+
var el = node;
|
|
43235
|
+
var format = inheritedFormat;
|
|
43236
|
+
var tag = el.tagName.toLowerCase();
|
|
43237
|
+
if (tag === 'b' || tag === 'strong') format |= 1;
|
|
43238
|
+
if (tag === 'i' || tag === 'em') format |= 2;
|
|
43239
|
+
if (tag === 's' || tag === 'del' || tag === 'strike') format |= 4;
|
|
43240
|
+
if (tag === 'u') format |= 8;
|
|
43241
|
+
if (tag === 'code') format |= 16;
|
|
43242
|
+
var style = el.style;
|
|
43243
|
+
if (style) {
|
|
43244
|
+
var fontWeight = style.fontWeight;
|
|
43245
|
+
if (fontWeight === 'bold' || fontWeight === 'bolder' || fontWeight && parseInt(fontWeight, 10) >= 600) {
|
|
43246
|
+
format |= 1;
|
|
43247
|
+
}
|
|
43248
|
+
if (style.fontStyle === 'italic') format |= 2;
|
|
43249
|
+
var textDecoration = style.textDecoration || style.textDecorationLine || '';
|
|
43250
|
+
if (textDecoration.indexOf('line-through') !== -1) format |= 4;
|
|
43251
|
+
if (textDecoration.indexOf('underline') !== -1) format |= 8;
|
|
43252
|
+
if (style.letterSpacing === '4px' || tag === 'code') format |= 16;
|
|
43253
|
+
}
|
|
43254
|
+
var mentionId = el.getAttribute('data-mention');
|
|
43255
|
+
if (mentionId) {
|
|
43256
|
+
var _text = el.textContent || '';
|
|
43257
|
+
segments.push({
|
|
43258
|
+
text: _text,
|
|
43259
|
+
format: format,
|
|
43260
|
+
mentionUserId: mentionId
|
|
43261
|
+
});
|
|
43262
|
+
return;
|
|
43263
|
+
}
|
|
43264
|
+
var childNodes = el.childNodes;
|
|
43265
|
+
for (var i = 0; i < childNodes.length; i++) {
|
|
43266
|
+
walkNode(childNodes[i], format);
|
|
43267
|
+
}
|
|
43268
|
+
}
|
|
43269
|
+
var bodyChildNodes = doc.body.childNodes;
|
|
43270
|
+
for (var i = 0; i < bodyChildNodes.length; i++) {
|
|
43271
|
+
walkNode(bodyChildNodes[i], 0);
|
|
43272
|
+
}
|
|
43273
|
+
return segments;
|
|
43274
|
+
}
|
|
44935
43275
|
function useFormatMessage(editor, editorState, setMessageBodyAttributes, setMessageText, setMentionedMember, messageToEdit, activeChannelMembers, contactsMap, getFromContacts) {
|
|
44936
43276
|
if (activeChannelMembers === void 0) {
|
|
44937
43277
|
activeChannelMembers = [];
|
|
@@ -45036,7 +43376,54 @@ function useFormatMessage(editor, editorState, setMessageBodyAttributes, setMess
|
|
|
45036
43376
|
if (!('clipboardData' in e) || !e.clipboardData) {
|
|
45037
43377
|
return false;
|
|
45038
43378
|
}
|
|
43379
|
+
var pastedHTML = e.clipboardData.getData('text/html');
|
|
45039
43380
|
var pastedText = e.clipboardData.getData('text/plain');
|
|
43381
|
+
if (pastedHTML) {
|
|
43382
|
+
var segments = parseHTMLToFormattedSegments(pastedHTML);
|
|
43383
|
+
var hasFormatting = segments.some(function (s) {
|
|
43384
|
+
return s.format > 0 || s.mentionUserId;
|
|
43385
|
+
});
|
|
43386
|
+
if (hasFormatting && segments.length > 0) {
|
|
43387
|
+
editor.update(function () {
|
|
43388
|
+
var selection = lexical.$getSelection();
|
|
43389
|
+
if (!lexical.$isRangeSelection(selection)) return;
|
|
43390
|
+
var nodes = [];
|
|
43391
|
+
segments.forEach(function (segment) {
|
|
43392
|
+
if (segment.mentionUserId) {
|
|
43393
|
+
var member = activeChannelMembers.find(function (m) {
|
|
43394
|
+
return m.id === segment.mentionUserId;
|
|
43395
|
+
});
|
|
43396
|
+
if (member) {
|
|
43397
|
+
setMentionedMember(member);
|
|
43398
|
+
var mentionNode = $createMentionNode(_extends({}, member, {
|
|
43399
|
+
name: segment.text
|
|
43400
|
+
}));
|
|
43401
|
+
if (segment.format > 0) {
|
|
43402
|
+
mentionNode.setFormat(segment.format);
|
|
43403
|
+
}
|
|
43404
|
+
nodes.push(mentionNode);
|
|
43405
|
+
} else {
|
|
43406
|
+
var textNode = lexical.$createTextNode(segment.text);
|
|
43407
|
+
if (segment.format > 0) {
|
|
43408
|
+
textNode.setFormat(segment.format);
|
|
43409
|
+
}
|
|
43410
|
+
nodes.push(textNode);
|
|
43411
|
+
}
|
|
43412
|
+
} else {
|
|
43413
|
+
var _textNode = lexical.$createTextNode(segment.text);
|
|
43414
|
+
if (segment.format > 0) {
|
|
43415
|
+
_textNode.setFormat(segment.format);
|
|
43416
|
+
}
|
|
43417
|
+
nodes.push(_textNode);
|
|
43418
|
+
}
|
|
43419
|
+
});
|
|
43420
|
+
if (nodes.length > 0) {
|
|
43421
|
+
selection.insertNodes(nodes);
|
|
43422
|
+
}
|
|
43423
|
+
});
|
|
43424
|
+
return true;
|
|
43425
|
+
}
|
|
43426
|
+
}
|
|
45040
43427
|
if (pastedText) {
|
|
45041
43428
|
editor.update(function () {
|
|
45042
43429
|
var selection = lexical.$getSelection();
|
|
@@ -45175,7 +43562,7 @@ function FormatMessagePlugin(_ref3) {
|
|
|
45175
43562
|
return null;
|
|
45176
43563
|
}
|
|
45177
43564
|
|
|
45178
|
-
var _templateObject$R, _templateObject2$M, _templateObject3$E, _templateObject4$z, _templateObject5$u, _templateObject6$q, _templateObject7$o, _templateObject8$
|
|
43565
|
+
var _templateObject$R, _templateObject2$M, _templateObject3$E, _templateObject4$z, _templateObject5$u, _templateObject6$q, _templateObject7$o, _templateObject8$k;
|
|
45179
43566
|
var EmojiIcon$1 = function EmojiIcon(_ref) {
|
|
45180
43567
|
var collectionName = _ref.collectionName;
|
|
45181
43568
|
switch (collectionName) {
|
|
@@ -45407,7 +43794,7 @@ var EmojiFooter$1 = styled__default.div(_templateObject7$o || (_templateObject7$
|
|
|
45407
43794
|
}, function (props) {
|
|
45408
43795
|
return props.emojisCategoryIconsPosition === 'top' && "1px solid " + props.borderColor;
|
|
45409
43796
|
});
|
|
45410
|
-
var Emoji$1 = styled__default.li(_templateObject8$
|
|
43797
|
+
var Emoji$1 = styled__default.li(_templateObject8$k || (_templateObject8$k = _taggedTemplateLiteralLoose(["\n cursor: pointer;\n width: 32px;\n height: 32px;\n margin: 0 2px;\n display: inline-block;\n box-sizing: border-box;\n border-radius: 50%;\n padding-top: 2px;\n text-align: center;\n background: transparent;\n font-family:\n apple color emoji,\n segoe ui emoji,\n noto color emoji,\n android emoji,\n emojisymbols,\n emojione mozilla,\n twemoji mozilla,\n segoe ui symbol;\n & > * {\n font-size: 22px;\n }\n &:hover {\n background: ", ";\n }\n"])), function (props) {
|
|
45411
43798
|
return props.hoverBackgroundColor;
|
|
45412
43799
|
});
|
|
45413
43800
|
|
|
@@ -45697,8 +44084,7 @@ var fieldsObject = {
|
|
|
45697
44084
|
channelId: '',
|
|
45698
44085
|
currentRecordedFile: null,
|
|
45699
44086
|
recording: null,
|
|
45700
|
-
recorder: null
|
|
45701
|
-
wavesurferContainer: null
|
|
44087
|
+
recorder: null
|
|
45702
44088
|
};
|
|
45703
44089
|
var shouldDraw = false;
|
|
45704
44090
|
var DEFAULT_MAX_RECORDING_DURATION = 600;
|
|
@@ -45738,18 +44124,20 @@ var AudioRecord = function AudioRecord(_ref) {
|
|
|
45738
44124
|
var _useState5 = React.useState(0),
|
|
45739
44125
|
currentTime = _useState5[0],
|
|
45740
44126
|
setCurrentTime = _useState5[1];
|
|
45741
|
-
var _useState6 = React.useState(
|
|
45742
|
-
|
|
45743
|
-
|
|
45744
|
-
var _useState7 = React.useState(
|
|
45745
|
-
|
|
45746
|
-
|
|
45747
|
-
var _useState8 = React.useState(
|
|
45748
|
-
|
|
45749
|
-
|
|
45750
|
-
var
|
|
44127
|
+
var _useState6 = React.useState(0),
|
|
44128
|
+
currentTimeSeconds = _useState6[0],
|
|
44129
|
+
setCurrentTimeSeconds = _useState6[1];
|
|
44130
|
+
var _useState7 = React.useState(null),
|
|
44131
|
+
sendingInterval = _useState7[0],
|
|
44132
|
+
setSendingInterval = _useState7[1];
|
|
44133
|
+
var _useState8 = React.useState(''),
|
|
44134
|
+
currentChannelId = _useState8[0],
|
|
44135
|
+
setCurrentChannelId = _useState8[1];
|
|
44136
|
+
var _useState9 = React.useState(false),
|
|
44137
|
+
playAudio = _useState9[0],
|
|
44138
|
+
setPlayAudio = _useState9[1];
|
|
45751
44139
|
var recordButtonRef = React.useRef(null);
|
|
45752
|
-
var
|
|
44140
|
+
var audioElements = React.useRef({});
|
|
45753
44141
|
var intervalRef = React.useRef({});
|
|
45754
44142
|
var currentRecordedFile = React.useMemo(function () {
|
|
45755
44143
|
var current = getAudioRecordingFromMap(currentChannelId) || recordedFile;
|
|
@@ -45780,6 +44168,59 @@ var AudioRecord = function AudioRecord(_ref) {
|
|
|
45780
44168
|
setSendingInterval(null);
|
|
45781
44169
|
}
|
|
45782
44170
|
};
|
|
44171
|
+
var cleanupAudioElement = function cleanupAudioElement(id) {
|
|
44172
|
+
if (intervalRef.current[id]) {
|
|
44173
|
+
clearInterval(intervalRef.current[id]);
|
|
44174
|
+
intervalRef.current[id] = null;
|
|
44175
|
+
}
|
|
44176
|
+
if (audioElements.current[id]) {
|
|
44177
|
+
audioElements.current[id].pause();
|
|
44178
|
+
audioElements.current[id].src = '';
|
|
44179
|
+
delete audioElements.current[id];
|
|
44180
|
+
}
|
|
44181
|
+
};
|
|
44182
|
+
var initAudioPlayback = function initAudioPlayback(draft, cId, audioRecording) {
|
|
44183
|
+
if (draft) return;
|
|
44184
|
+
var id = cId || currentChannelId;
|
|
44185
|
+
var fileData = audioRecording || currentRecordedFile;
|
|
44186
|
+
if (!(fileData !== null && fileData !== void 0 && fileData.objectUrl)) return;
|
|
44187
|
+
if (audioElements.current[id]) {
|
|
44188
|
+
setRecordingIsReadyToPlay(true);
|
|
44189
|
+
var audioDuration = audioElements.current[id].duration;
|
|
44190
|
+
if (audioDuration && isFinite(audioDuration)) {
|
|
44191
|
+
setCurrentTime(audioDuration);
|
|
44192
|
+
}
|
|
44193
|
+
return;
|
|
44194
|
+
}
|
|
44195
|
+
var audio = new Audio();
|
|
44196
|
+
audioElements.current[id] = audio;
|
|
44197
|
+
audio.addEventListener('loadedmetadata', function () {
|
|
44198
|
+
setRecordingIsReadyToPlay(true);
|
|
44199
|
+
var audioDuration = audio.duration;
|
|
44200
|
+
if (audioDuration && isFinite(audioDuration)) {
|
|
44201
|
+
setCurrentTime(audioDuration);
|
|
44202
|
+
}
|
|
44203
|
+
});
|
|
44204
|
+
audio.addEventListener('ended', function () {
|
|
44205
|
+
setPlayAudio(false);
|
|
44206
|
+
audio.currentTime = 0;
|
|
44207
|
+
var audioDuration = audio.duration;
|
|
44208
|
+
if (audioDuration && isFinite(audioDuration)) {
|
|
44209
|
+
setCurrentTime(audioDuration);
|
|
44210
|
+
}
|
|
44211
|
+
setCurrentTimeSeconds(0);
|
|
44212
|
+
clearInterval(intervalRef.current[id]);
|
|
44213
|
+
});
|
|
44214
|
+
audio.addEventListener('pause', function () {
|
|
44215
|
+
setPlayAudio(false);
|
|
44216
|
+
clearInterval(intervalRef.current[id]);
|
|
44217
|
+
});
|
|
44218
|
+
audio.addEventListener('error', function () {
|
|
44219
|
+
var _audio$error;
|
|
44220
|
+
log.error('Audio playback error:', (_audio$error = audio.error) === null || _audio$error === void 0 ? void 0 : _audio$error.message);
|
|
44221
|
+
});
|
|
44222
|
+
audio.src = fileData.objectUrl;
|
|
44223
|
+
};
|
|
45783
44224
|
var startRecording = function startRecording(cId) {
|
|
45784
44225
|
try {
|
|
45785
44226
|
var id = cId || currentChannelId;
|
|
@@ -45795,13 +44236,10 @@ var AudioRecord = function AudioRecord(_ref) {
|
|
|
45795
44236
|
if (recording) {
|
|
45796
44237
|
stopRecording(true, id, false, recorder);
|
|
45797
44238
|
} else if (currentRecordedFile) {
|
|
45798
|
-
var _wavesurfer$current;
|
|
45799
44239
|
removeAudioRecordingFromMap(id);
|
|
45800
44240
|
setRecordedFile(null);
|
|
45801
44241
|
setPlayAudio(false);
|
|
45802
|
-
|
|
45803
|
-
wavesurfer.current[id].destroy();
|
|
45804
|
-
}
|
|
44242
|
+
cleanupAudioElement(id);
|
|
45805
44243
|
setStartRecording(false);
|
|
45806
44244
|
setShowRecording(false);
|
|
45807
44245
|
dispatch(setChannelDraftMessageIsRemovedAC(id));
|
|
@@ -45905,13 +44343,10 @@ var AudioRecord = function AudioRecord(_ref) {
|
|
|
45905
44343
|
var cancelRecording = React.useCallback(function () {
|
|
45906
44344
|
handleStopRecording();
|
|
45907
44345
|
if (currentRecordedFile) {
|
|
45908
|
-
var _wavesurfer$current2;
|
|
45909
44346
|
dispatch(setChannelDraftMessageIsRemovedAC(currentChannelId));
|
|
45910
44347
|
setRecordedFile(null);
|
|
45911
44348
|
setPlayAudio(false);
|
|
45912
|
-
|
|
45913
|
-
wavesurfer.current[currentChannelId].destroy();
|
|
45914
|
-
}
|
|
44349
|
+
cleanupAudioElement(currentChannelId);
|
|
45915
44350
|
} else {
|
|
45916
44351
|
shouldDraw = false;
|
|
45917
44352
|
recorder === null || recorder === void 0 ? void 0 : recorder.stop();
|
|
@@ -45920,130 +44355,16 @@ var AudioRecord = function AudioRecord(_ref) {
|
|
|
45920
44355
|
setRecordingIsReadyToPlay(false);
|
|
45921
44356
|
setStartRecording(false);
|
|
45922
44357
|
setCurrentTime(0);
|
|
44358
|
+
setCurrentTimeSeconds(0);
|
|
45923
44359
|
setShowRecording(false);
|
|
45924
|
-
}, [currentRecordedFile, currentChannelId,
|
|
45925
|
-
var
|
|
45926
|
-
try {
|
|
45927
|
-
var _exit = false;
|
|
45928
|
-
return Promise.resolve(_catch(function () {
|
|
45929
|
-
var _wavesurfer$current3;
|
|
45930
|
-
function _temp3(_result3) {
|
|
45931
|
-
var _wavesurfer$current$i, _wavesurfer$current$i2;
|
|
45932
|
-
if (_exit) return _result3;
|
|
45933
|
-
setCurrentTime(((_wavesurfer$current$i = wavesurfer.current[id]) === null || _wavesurfer$current$i === void 0 ? void 0 : (_wavesurfer$current$i2 = _wavesurfer$current$i.decodedData) === null || _wavesurfer$current$i2 === void 0 ? void 0 : _wavesurfer$current$i2.duration) || 0);
|
|
45934
|
-
wavesurfer.current[id].on('ready', function () {
|
|
45935
|
-
setRecordingIsReadyToPlay(true);
|
|
45936
|
-
var audioDuration = wavesurfer.current[id].getDuration();
|
|
45937
|
-
setCurrentTime(audioDuration);
|
|
45938
|
-
});
|
|
45939
|
-
wavesurfer.current[id].on('finish', function () {
|
|
45940
|
-
setPlayAudio(false);
|
|
45941
|
-
wavesurfer.current[id].seekTo(0);
|
|
45942
|
-
var audioDuration = wavesurfer.current[id].getDuration();
|
|
45943
|
-
setCurrentTime(audioDuration);
|
|
45944
|
-
clearInterval(intervalRef.current[id]);
|
|
45945
|
-
});
|
|
45946
|
-
wavesurfer.current[id].on('pause', function () {
|
|
45947
|
-
setPlayAudio(false);
|
|
45948
|
-
clearInterval(intervalRef.current[id]);
|
|
45949
|
-
});
|
|
45950
|
-
wavesurfer.current[id].on('interaction', function () {
|
|
45951
|
-
var currentTime = wavesurfer.current[id].getCurrentTime();
|
|
45952
|
-
setCurrentTime(currentTime);
|
|
45953
|
-
});
|
|
45954
|
-
}
|
|
45955
|
-
if (draft) {
|
|
45956
|
-
return;
|
|
45957
|
-
}
|
|
45958
|
-
var id = cId || currentChannelId;
|
|
45959
|
-
if ((_wavesurfer$current3 = wavesurfer.current) !== null && _wavesurfer$current3 !== void 0 && _wavesurfer$current3[id]) {
|
|
45960
|
-
setRecordingIsReadyToPlay(true);
|
|
45961
|
-
var audioDuration = wavesurfer.current[id].getDuration();
|
|
45962
|
-
setCurrentTime(audioDuration);
|
|
45963
|
-
}
|
|
45964
|
-
var _temp2 = function (_wavesurfer$current4) {
|
|
45965
|
-
if (!((_wavesurfer$current4 = wavesurfer.current) !== null && _wavesurfer$current4 !== void 0 && _wavesurfer$current4[id])) {
|
|
45966
|
-
var _ref2;
|
|
45967
|
-
var containerElement = wavesurferContainer.current || container;
|
|
45968
|
-
if (!containerElement) {
|
|
45969
|
-
setTimeout(function () {
|
|
45970
|
-
return _initWaveSurfer(draft, cId, audioRecording, container);
|
|
45971
|
-
}, 100);
|
|
45972
|
-
_exit = true;
|
|
45973
|
-
return;
|
|
45974
|
-
}
|
|
45975
|
-
var rect = containerElement.getBoundingClientRect();
|
|
45976
|
-
if (rect.width === 0 || rect.height === 0) {
|
|
45977
|
-
setTimeout(function () {
|
|
45978
|
-
return _initWaveSurfer(draft, cId, audioRecording, container);
|
|
45979
|
-
}, 100);
|
|
45980
|
-
_exit = true;
|
|
45981
|
-
return;
|
|
45982
|
-
}
|
|
45983
|
-
var ws = WaveSurfer.create({
|
|
45984
|
-
container: containerElement,
|
|
45985
|
-
waveColor: textSecondary,
|
|
45986
|
-
progressColor: accentColor,
|
|
45987
|
-
barWidth: 1,
|
|
45988
|
-
barHeight: 2,
|
|
45989
|
-
audioRate: 1,
|
|
45990
|
-
hideScrollbar: true,
|
|
45991
|
-
barRadius: 1.5,
|
|
45992
|
-
cursorWidth: 0,
|
|
45993
|
-
barGap: 2.5,
|
|
45994
|
-
height: 28
|
|
45995
|
-
});
|
|
45996
|
-
var peaks = [];
|
|
45997
|
-
if ((_ref2 = audioRecording || currentRecordedFile) !== null && _ref2 !== void 0 && _ref2.thumb) {
|
|
45998
|
-
var _ref3;
|
|
45999
|
-
var thumbData = (_ref3 = audioRecording || currentRecordedFile) === null || _ref3 === void 0 ? void 0 : _ref3.thumb;
|
|
46000
|
-
if (Array.isArray(thumbData) && thumbData.length > 0) {
|
|
46001
|
-
var maxVal = thumbData.reduce(function (acc, n) {
|
|
46002
|
-
return n > acc ? n : acc;
|
|
46003
|
-
}, -Infinity);
|
|
46004
|
-
if (maxVal > 0 && isFinite(maxVal)) {
|
|
46005
|
-
var dec = maxVal / 100;
|
|
46006
|
-
peaks = thumbData.map(function (peak) {
|
|
46007
|
-
var normalizedPeak = peak / dec / 100;
|
|
46008
|
-
return isFinite(normalizedPeak) ? normalizedPeak : 0;
|
|
46009
|
-
}).filter(function (peak) {
|
|
46010
|
-
return isFinite(peak);
|
|
46011
|
-
});
|
|
46012
|
-
if (peaks.length === 0) {
|
|
46013
|
-
peaks = [];
|
|
46014
|
-
}
|
|
46015
|
-
}
|
|
46016
|
-
}
|
|
46017
|
-
}
|
|
46018
|
-
wavesurfer.current[id] = ws;
|
|
46019
|
-
return _catch(function () {
|
|
46020
|
-
var validPeaks = peaks.length > 0 ? peaks : undefined;
|
|
46021
|
-
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 () {});
|
|
46022
|
-
}, function () {
|
|
46023
|
-
return _catch(function () {
|
|
46024
|
-
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 () {});
|
|
46025
|
-
}, function (fallbackError) {
|
|
46026
|
-
console.error('Failed to load audio completely:', fallbackError);
|
|
46027
|
-
throw fallbackError;
|
|
46028
|
-
});
|
|
46029
|
-
});
|
|
46030
|
-
}
|
|
46031
|
-
}();
|
|
46032
|
-
return _temp2 && _temp2.then ? _temp2.then(_temp3) : _temp3(_temp2);
|
|
46033
|
-
}, function (e) {
|
|
46034
|
-
log.error('Failed to init wavesurfer', e);
|
|
46035
|
-
}));
|
|
46036
|
-
} catch (e) {
|
|
46037
|
-
return Promise.reject(e);
|
|
46038
|
-
}
|
|
46039
|
-
};
|
|
46040
|
-
var stopRecording = React.useCallback(function (send, cId, draft, recorder, container) {
|
|
44360
|
+
}, [currentRecordedFile, currentChannelId, setShowRecording, setRecordedFile]);
|
|
44361
|
+
var stopRecording = React.useCallback(function (send, cId, draft, recorder) {
|
|
46041
44362
|
handleStopRecording();
|
|
46042
44363
|
shouldDraw = false;
|
|
46043
44364
|
var id = cId || channelId;
|
|
46044
|
-
recorder === null || recorder === void 0 ? void 0 : recorder.stop().getMp3().then(function (
|
|
46045
|
-
var buffer =
|
|
46046
|
-
blob =
|
|
44365
|
+
recorder === null || recorder === void 0 ? void 0 : recorder.stop().getMp3().then(function (_ref2) {
|
|
44366
|
+
var buffer = _ref2[0],
|
|
44367
|
+
blob = _ref2[1];
|
|
46047
44368
|
var file = new File(buffer, 'record.mp3', {
|
|
46048
44369
|
type: blob.type,
|
|
46049
44370
|
lastModified: Date.now()
|
|
@@ -46099,7 +44420,7 @@ var AudioRecord = function AudioRecord(_ref) {
|
|
|
46099
44420
|
};
|
|
46100
44421
|
setAudioRecordingToMap(id, audioRecording);
|
|
46101
44422
|
if (draft) {
|
|
46102
|
-
|
|
44423
|
+
initAudioPlayback(draft, id, audioRecording);
|
|
46103
44424
|
}
|
|
46104
44425
|
}
|
|
46105
44426
|
}, function (e) {
|
|
@@ -46113,18 +44434,25 @@ var AudioRecord = function AudioRecord(_ref) {
|
|
|
46113
44434
|
});
|
|
46114
44435
|
}, [sendRecordedFile, setShowRecording, setAudioRecordingToMap, setRecordedFile, handleStopRecording, channelId]);
|
|
46115
44436
|
var handlePlayPause = function handlePlayPause(cId) {
|
|
46116
|
-
var
|
|
46117
|
-
|
|
46118
|
-
|
|
46119
|
-
|
|
46120
|
-
|
|
46121
|
-
|
|
46122
|
-
|
|
46123
|
-
|
|
46124
|
-
|
|
46125
|
-
|
|
46126
|
-
|
|
46127
|
-
|
|
44437
|
+
var id = cId || currentChannelId;
|
|
44438
|
+
var audio = audioElements.current[id];
|
|
44439
|
+
if (!audio) return;
|
|
44440
|
+
if (audio.paused) {
|
|
44441
|
+
setPlayAudio(true);
|
|
44442
|
+
intervalRef.current[id] = setInterval(function () {
|
|
44443
|
+
var _audioElements$curren;
|
|
44444
|
+
var time = (_audioElements$curren = audioElements.current[id]) === null || _audioElements$curren === void 0 ? void 0 : _audioElements$curren.currentTime;
|
|
44445
|
+
if (time !== undefined && time >= 0) {
|
|
44446
|
+
setCurrentTime(time);
|
|
44447
|
+
setCurrentTimeSeconds(time);
|
|
44448
|
+
}
|
|
44449
|
+
}, 10);
|
|
44450
|
+
audio.play()["catch"](function (e) {
|
|
44451
|
+
log.error('Audio play failed:', e);
|
|
44452
|
+
setPlayAudio(false);
|
|
44453
|
+
});
|
|
44454
|
+
} else {
|
|
44455
|
+
audio.pause();
|
|
46128
44456
|
}
|
|
46129
44457
|
};
|
|
46130
44458
|
React.useEffect(function () {
|
|
@@ -46173,32 +44501,21 @@ var AudioRecord = function AudioRecord(_ref) {
|
|
|
46173
44501
|
React.useEffect(function () {
|
|
46174
44502
|
fieldsObject.recording = recording;
|
|
46175
44503
|
}, [recording]);
|
|
46176
|
-
React.useEffect(function () {
|
|
46177
|
-
fieldsObject.wavesurferContainer = wavesurferContainer.current;
|
|
46178
|
-
}, [wavesurferContainer.current]);
|
|
46179
44504
|
React.useEffect(function () {
|
|
46180
44505
|
return function () {
|
|
46181
44506
|
var _fieldsObject$current;
|
|
46182
44507
|
if (fieldsObject.channelId && (!fieldsObject.currentRecordedFile || !((_fieldsObject$current = fieldsObject.currentRecordedFile) !== null && _fieldsObject$current !== void 0 && _fieldsObject$current.file)) && fieldsObject.recorder && fieldsObject.recording) {
|
|
46183
|
-
stopRecording(false, fieldsObject.channelId, true, fieldsObject.recorder
|
|
44508
|
+
stopRecording(false, fieldsObject.channelId, true, fieldsObject.recorder);
|
|
46184
44509
|
handleStopRecording();
|
|
46185
44510
|
}
|
|
46186
44511
|
};
|
|
46187
44512
|
}, []);
|
|
46188
44513
|
React.useEffect(function () {
|
|
46189
44514
|
if (currentRecordedFile) {
|
|
46190
|
-
|
|
44515
|
+
initAudioPlayback();
|
|
46191
44516
|
} else {
|
|
46192
|
-
var _wavesurfer$current6;
|
|
46193
44517
|
setRecordingIsReadyToPlay(false);
|
|
46194
|
-
|
|
46195
|
-
clearInterval(intervalRef.current[currentChannelId]);
|
|
46196
|
-
intervalRef.current[currentChannelId] = null;
|
|
46197
|
-
}
|
|
46198
|
-
if ((_wavesurfer$current6 = wavesurfer.current) !== null && _wavesurfer$current6 !== void 0 && _wavesurfer$current6[currentChannelId]) {
|
|
46199
|
-
wavesurfer.current[currentChannelId].destroy();
|
|
46200
|
-
wavesurfer.current[currentChannelId] = null;
|
|
46201
|
-
}
|
|
44518
|
+
cleanupAudioElement(currentChannelId);
|
|
46202
44519
|
}
|
|
46203
44520
|
return function () {
|
|
46204
44521
|
for (var key in intervalRef.current) {
|
|
@@ -46207,10 +44524,11 @@ var AudioRecord = function AudioRecord(_ref) {
|
|
|
46207
44524
|
intervalRef.current[key] = null;
|
|
46208
44525
|
}
|
|
46209
44526
|
}
|
|
46210
|
-
for (var _key in
|
|
46211
|
-
if (
|
|
46212
|
-
|
|
46213
|
-
|
|
44527
|
+
for (var _key in audioElements.current) {
|
|
44528
|
+
if (audioElements.current[_key]) {
|
|
44529
|
+
audioElements.current[_key].pause();
|
|
44530
|
+
audioElements.current[_key].src = '';
|
|
44531
|
+
delete audioElements.current[_key];
|
|
46214
44532
|
}
|
|
46215
44533
|
}
|
|
46216
44534
|
};
|
|
@@ -46236,16 +44554,18 @@ var AudioRecord = function AudioRecord(_ref) {
|
|
|
46236
44554
|
React.useEffect(function () {
|
|
46237
44555
|
if (!showRecording) {
|
|
46238
44556
|
setCurrentTime(0);
|
|
44557
|
+
setCurrentTimeSeconds(0);
|
|
46239
44558
|
}
|
|
46240
44559
|
return function () {
|
|
46241
44560
|
handleStopRecording();
|
|
46242
44561
|
setCurrentTime(0);
|
|
44562
|
+
setCurrentTimeSeconds(0);
|
|
46243
44563
|
};
|
|
46244
44564
|
}, [showRecording]);
|
|
46245
44565
|
React.useEffect(function () {
|
|
46246
44566
|
if (channelId && (showRecording || currentRecordedFile)) {
|
|
46247
44567
|
if (!currentRecordedFile) {
|
|
46248
|
-
stopRecording(false, currentChannelId, true, recorder
|
|
44568
|
+
stopRecording(false, currentChannelId, true, recorder);
|
|
46249
44569
|
}
|
|
46250
44570
|
if (playAudio) {
|
|
46251
44571
|
handlePlayPause(channelId);
|
|
@@ -46254,10 +44574,11 @@ var AudioRecord = function AudioRecord(_ref) {
|
|
|
46254
44574
|
clearInterval(intervalRef.current[key]);
|
|
46255
44575
|
intervalRef.current[key] = null;
|
|
46256
44576
|
}
|
|
46257
|
-
for (var _key2 in
|
|
46258
|
-
var
|
|
46259
|
-
(
|
|
46260
|
-
|
|
44577
|
+
for (var _key2 in audioElements.current) {
|
|
44578
|
+
var _audioElements$curren2;
|
|
44579
|
+
(_audioElements$curren2 = audioElements.current[_key2]) === null || _audioElements$curren2 === void 0 ? void 0 : _audioElements$curren2.pause();
|
|
44580
|
+
audioElements.current[_key2].src = '';
|
|
44581
|
+
delete audioElements.current[_key2];
|
|
46261
44582
|
}
|
|
46262
44583
|
setShowRecording(false);
|
|
46263
44584
|
setStartRecording(false);
|
|
@@ -46267,9 +44588,11 @@ var AudioRecord = function AudioRecord(_ref) {
|
|
|
46267
44588
|
setRecordingIsReadyToPlay(!!audioRecording);
|
|
46268
44589
|
}
|
|
46269
44590
|
setCurrentTime(0);
|
|
44591
|
+
setCurrentTimeSeconds(0);
|
|
46270
44592
|
handleStopRecording();
|
|
46271
44593
|
setCurrentChannelId(channelId);
|
|
46272
44594
|
}, [channelId]);
|
|
44595
|
+
var recordedFileDuration = (currentRecordedFile === null || currentRecordedFile === void 0 ? void 0 : currentRecordedFile.dur) || 0;
|
|
46273
44596
|
return /*#__PURE__*/React__default.createElement(Container$l, {
|
|
46274
44597
|
recording: showRecording || currentRecordedFile
|
|
46275
44598
|
}, (showRecording || currentRecordedFile) && (/*#__PURE__*/React__default.createElement(PlayPause$1, {
|
|
@@ -46300,17 +44623,24 @@ var AudioRecord = function AudioRecord(_ref) {
|
|
|
46300
44623
|
hide: currentRecordedFile,
|
|
46301
44624
|
id: "waveform-" + channelId,
|
|
46302
44625
|
recording: recording
|
|
46303
|
-
}), recording && /*#__PURE__*/React__default.createElement(Timer$
|
|
44626
|
+
}), recording && /*#__PURE__*/React__default.createElement(Timer$1, {
|
|
46304
44627
|
color: textSecondary
|
|
46305
44628
|
}, formatAudioVideoTime(currentTime)), (recordingIsReadyToPlay || currentRecordedFile) && (/*#__PURE__*/React__default.createElement(PlayPause$1, {
|
|
46306
44629
|
iconColor: accentColor,
|
|
46307
44630
|
onClick: function onClick() {
|
|
46308
44631
|
return handlePlayPause(channelId);
|
|
46309
44632
|
}
|
|
46310
|
-
}, playAudio ? /*#__PURE__*/React__default.createElement(SvgPauseRecord, null) : /*#__PURE__*/React__default.createElement(SvgPlayRecord, null))), /*#__PURE__*/React__default.createElement(
|
|
46311
|
-
|
|
46312
|
-
|
|
46313
|
-
|
|
44633
|
+
}, playAudio ? /*#__PURE__*/React__default.createElement(SvgPauseRecord, null) : /*#__PURE__*/React__default.createElement(SvgPlayRecord, null))), (currentRecordedFile === null || currentRecordedFile === void 0 ? void 0 : currentRecordedFile.thumb) && Array.isArray(currentRecordedFile.thumb) && (/*#__PURE__*/React__default.createElement(RecordedVisualizationWrapper, null, /*#__PURE__*/React__default.createElement(AudioVisualizationComponent, {
|
|
44634
|
+
tmb: currentRecordedFile.thumb,
|
|
44635
|
+
duration: recordedFileDuration,
|
|
44636
|
+
currentTime: currentTimeSeconds,
|
|
44637
|
+
waveColor: textSecondary,
|
|
44638
|
+
progressColor: accentColor,
|
|
44639
|
+
height: 28,
|
|
44640
|
+
barWidth: 1,
|
|
44641
|
+
barRadius: 1.5,
|
|
44642
|
+
containerWidth: 190
|
|
44643
|
+
}))), (recordingIsReadyToPlay || currentRecordedFile) && (/*#__PURE__*/React__default.createElement(Timer$1, {
|
|
46314
44644
|
color: textSecondary
|
|
46315
44645
|
}, formatAudioVideoTime(currentTime)))), /*#__PURE__*/React__default.createElement(RecordIconWrapper, {
|
|
46316
44646
|
ref: recordButtonRef,
|
|
@@ -46338,32 +44668,21 @@ var AudioWrapper = styled__default.div(_templateObject2$N || (_templateObject2$N
|
|
|
46338
44668
|
var RecordIconWrapper = styled__default.span(_templateObject3$F || (_templateObject3$F = _taggedTemplateLiteralLoose(["\n display: flex;\n cursor: pointer;\n > svg {\n color: ", ";\n }\n"])), function (props) {
|
|
46339
44669
|
return props.iconColor;
|
|
46340
44670
|
});
|
|
46341
|
-
var
|
|
46342
|
-
var show = _ref5.show;
|
|
46343
|
-
return show ? '1' : '0';
|
|
46344
|
-
}, function (_ref6) {
|
|
46345
|
-
var show = _ref6.show;
|
|
46346
|
-
return !show && '-1';
|
|
46347
|
-
}, function (_ref7) {
|
|
46348
|
-
var show = _ref7.show;
|
|
46349
|
-
return show ? 'visible' : 'hidden';
|
|
46350
|
-
}, function (props) {
|
|
46351
|
-
return props.color;
|
|
46352
|
-
});
|
|
44671
|
+
var RecordedVisualizationWrapper = styled__default.div(_templateObject4$A || (_templateObject4$A = _taggedTemplateLiteralLoose(["\n position: absolute;\n left: 40px;\n width: 300px;\n height: 28px;\n max-width: calc(100% - 100px);\n display: flex;\n align-items: center;\n"])));
|
|
46353
44672
|
var PlayPause$1 = styled__default.div(_templateObject5$v || (_templateObject5$v = _taggedTemplateLiteralLoose(["\n padding: 10px 0 10px 10px;\n display: flex;\n align-items: center;\n justify-content: center;\n gap: 8px;\n > svg {\n cursor: pointer;\n color: ", ";\n }\n"])), function (props) {
|
|
46354
44673
|
return props.iconColor;
|
|
46355
44674
|
});
|
|
46356
|
-
var Canvas = styled__default.canvas(_templateObject6$r || (_templateObject6$r = _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 (
|
|
46357
|
-
var recording =
|
|
44675
|
+
var Canvas = styled__default.canvas(_templateObject6$r || (_templateObject6$r = _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 (_ref3) {
|
|
44676
|
+
var recording = _ref3.recording;
|
|
46358
44677
|
return recording ? '300px' : '0';
|
|
46359
|
-
}, function (
|
|
46360
|
-
var hide =
|
|
44678
|
+
}, function (_ref4) {
|
|
44679
|
+
var hide = _ref4.hide;
|
|
46361
44680
|
return hide ? '0' : '1';
|
|
46362
|
-
}, function (
|
|
46363
|
-
var hide =
|
|
44681
|
+
}, function (_ref5) {
|
|
44682
|
+
var hide = _ref5.hide;
|
|
46364
44683
|
return hide && '-1';
|
|
46365
44684
|
});
|
|
46366
|
-
var Timer$
|
|
44685
|
+
var Timer$1 = styled__default.div(_templateObject7$p || (_templateObject7$p = _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) {
|
|
46367
44686
|
return props.color;
|
|
46368
44687
|
});
|
|
46369
44688
|
|
|
@@ -46418,7 +44737,7 @@ function SvgDotsVertica(props) {
|
|
|
46418
44737
|
})));
|
|
46419
44738
|
}
|
|
46420
44739
|
|
|
46421
|
-
var _templateObject$U, _templateObject2$P, _templateObject3$H, _templateObject4$B, _templateObject5$w, _templateObject6$s, _templateObject7$q, _templateObject8$
|
|
44740
|
+
var _templateObject$U, _templateObject2$P, _templateObject3$H, _templateObject4$B, _templateObject5$w, _templateObject6$s, _templateObject7$q, _templateObject8$l, _templateObject9$i;
|
|
46422
44741
|
var CreatePollPopup = function CreatePollPopup(_ref) {
|
|
46423
44742
|
var togglePopup = _ref.togglePopup,
|
|
46424
44743
|
onCreate = _ref.onCreate;
|
|
@@ -46431,7 +44750,8 @@ var CreatePollPopup = function CreatePollPopup(_ref) {
|
|
|
46431
44750
|
iconInactive = _useColor[THEME_COLORS.ICON_INACTIVE],
|
|
46432
44751
|
borderColor = _useColor[THEME_COLORS.BORDER],
|
|
46433
44752
|
accentColor = _useColor[THEME_COLORS.ACCENT],
|
|
46434
|
-
textOnPrimary = _useColor[THEME_COLORS.TEXT_ON_PRIMARY]
|
|
44753
|
+
textOnPrimary = _useColor[THEME_COLORS.TEXT_ON_PRIMARY],
|
|
44754
|
+
surface2 = _useColor[THEME_COLORS.SURFACE_2];
|
|
46435
44755
|
var _useState = React.useState(''),
|
|
46436
44756
|
question = _useState[0],
|
|
46437
44757
|
setQuestion = _useState[1];
|
|
@@ -46457,8 +44777,11 @@ var CreatePollPopup = function CreatePollPopup(_ref) {
|
|
|
46457
44777
|
dragOverId = _useState6[0],
|
|
46458
44778
|
setDragOverId = _useState6[1];
|
|
46459
44779
|
var _useState7 = React.useState(false),
|
|
46460
|
-
|
|
46461
|
-
|
|
44780
|
+
isScrolling = _useState7[0],
|
|
44781
|
+
setIsScrolling = _useState7[1];
|
|
44782
|
+
var _useState8 = React.useState(false),
|
|
44783
|
+
showDiscardConfirm = _useState8[0],
|
|
44784
|
+
setShowDiscardConfirm = _useState8[1];
|
|
46462
44785
|
var optionsListRef = React.useRef(null);
|
|
46463
44786
|
var optionInputRefs = React.useRef({});
|
|
46464
44787
|
var questionTextAreaRef = React.useRef(null);
|
|
@@ -46671,7 +44994,15 @@ var CreatePollPopup = function CreatePollPopup(_ref) {
|
|
|
46671
44994
|
color: textSecondary
|
|
46672
44995
|
}, "Options"), /*#__PURE__*/React__default.createElement(OptionsList$1, {
|
|
46673
44996
|
ref: optionsListRef,
|
|
46674
|
-
onDragOver: handleAutoScroll
|
|
44997
|
+
onDragOver: handleAutoScroll,
|
|
44998
|
+
className: isScrolling ? 'show-scrollbar' : '',
|
|
44999
|
+
onMouseEnter: function onMouseEnter() {
|
|
45000
|
+
return setIsScrolling(true);
|
|
45001
|
+
},
|
|
45002
|
+
onMouseLeave: function onMouseLeave() {
|
|
45003
|
+
return setIsScrolling(false);
|
|
45004
|
+
},
|
|
45005
|
+
thumbColor: surface2
|
|
46675
45006
|
}, options.map(function (opt) {
|
|
46676
45007
|
return /*#__PURE__*/React__default.createElement(OptionRow, {
|
|
46677
45008
|
key: opt.id,
|
|
@@ -46811,7 +45142,9 @@ var CustomTextArea = styled__default.textarea(_templateObject2$P || (_templateOb
|
|
|
46811
45142
|
var TextCounter = styled__default.span(_templateObject3$H || (_templateObject3$H = _taggedTemplateLiteralLoose(["\n color: ", ";\n font-weight: 500;\n font-size: 13px;\n line-height: 20px;\n margin-left: auto;\n"])), function (props) {
|
|
46812
45143
|
return props.color;
|
|
46813
45144
|
});
|
|
46814
|
-
var OptionsList$1 = styled__default.div(_templateObject4$B || (_templateObject4$B = _taggedTemplateLiteralLoose(["\n max-height: 200px;\n overflow-y: auto;\n margin-top: 8px;\n padding-right: 6px;\n"])))
|
|
45145
|
+
var OptionsList$1 = styled__default.div(_templateObject4$B || (_templateObject4$B = _taggedTemplateLiteralLoose(["\n max-height: 200px;\n overflow-y: auto;\n margin-top: 8px;\n padding-right: 6px;\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) {
|
|
45146
|
+
return props.thumbColor;
|
|
45147
|
+
});
|
|
46815
45148
|
var OptionRow = styled__default.div(_templateObject5$w || (_templateObject5$w = _taggedTemplateLiteralLoose(["\n display: flex;\n align-items: center;\n gap: 8px;\n margin-top: 8px;\n cursor: grab;\n border: ", ";\n border-radius: 6px;\n padding: 4px;\n opacity: ", ";\n"])), function (props) {
|
|
46816
45149
|
return props.isDragOver ? '1px dashed #A0A1B0' : '1px solid transparent';
|
|
46817
45150
|
}, function (props) {
|
|
@@ -46833,12 +45166,12 @@ var AddOptionButton = styled__default.button(_templateObject7$q || (_templateObj
|
|
|
46833
45166
|
}, function (props) {
|
|
46834
45167
|
return props.disabled ? 0.5 : 1;
|
|
46835
45168
|
});
|
|
46836
|
-
var Settings = styled__default.div(_templateObject8$
|
|
45169
|
+
var Settings = styled__default.div(_templateObject8$l || (_templateObject8$l = _taggedTemplateLiteralLoose(["\n display: flex;\n flex-direction: column;\n gap: 12px;\n margin-top: 8px;\n"])));
|
|
46837
45170
|
var SettingItem = styled__default.div(_templateObject9$i || (_templateObject9$i = _taggedTemplateLiteralLoose(["\n display: flex;\n align-items: center;\n gap: 10px;\n color: ", ";\n"])), function (props) {
|
|
46838
45171
|
return props.color;
|
|
46839
45172
|
});
|
|
46840
45173
|
|
|
46841
|
-
var _templateObject$V, _templateObject2$Q, _templateObject3$I, _templateObject4$C, _templateObject5$x, _templateObject6$t, _templateObject7$r, _templateObject8$
|
|
45174
|
+
var _templateObject$V, _templateObject2$Q, _templateObject3$I, _templateObject4$C, _templateObject5$x, _templateObject6$t, _templateObject7$r, _templateObject8$m, _templateObject9$j, _templateObject0$h, _templateObject1$d, _templateObject10$8, _templateObject11$6, _templateObject12$5, _templateObject13$4, _templateObject14$3, _templateObject15$2, _templateObject16$2, _templateObject17$2, _templateObject18$2, _templateObject19$2, _templateObject20$2, _templateObject21$2, _templateObject22$1, _templateObject23$1, _templateObject24$1, _templateObject25$1, _templateObject26$1, _templateObject27$1, _templateObject28$1, _templateObject29$1, _templateObject30$1, _templateObject31$1, _templateObject32$1, _templateObject33$1, _templateObject34$1, _templateObject35$1, _templateObject36$1, _templateObject37$1, _templateObject38$1, _templateObject39$1, _templateObject40$1, _templateObject41$1, _templateObject42$1, _templateObject43, _templateObject44, _templateObject45, _templateObject46;
|
|
46842
45175
|
function AutoFocusPlugin(_ref) {
|
|
46843
45176
|
var messageForReply = _ref.messageForReply;
|
|
46844
45177
|
var _useLexicalComposerCo = LexicalComposerContext.useLexicalComposerContext(),
|
|
@@ -48886,7 +47219,7 @@ var WarningIconWrapper = styled__default.div(_templateObject6$t || (_templateObj
|
|
|
48886
47219
|
var WarningText = styled__default.span(_templateObject7$r || (_templateObject7$r = _taggedTemplateLiteralLoose(["\n color: ", ";\n font-weight: 400;\n font-size: 14px;\n line-height: 18px;\n"])), function (props) {
|
|
48887
47220
|
return props.color;
|
|
48888
47221
|
});
|
|
48889
|
-
var CloseEditMode = styled__default.span(_templateObject8$
|
|
47222
|
+
var CloseEditMode = styled__default.span(_templateObject8$m || (_templateObject8$m = _taggedTemplateLiteralLoose(["\n position: absolute;\n top: 8px;\n right: 12px;\n width: 20px;\n height: 20px;\n text-align: center;\n line-height: 22px;\n cursor: pointer;\n\n & > svg {\n color: ", ";\n }\n"])), function (props) {
|
|
48890
47223
|
return props.color;
|
|
48891
47224
|
});
|
|
48892
47225
|
var UserName$1 = styled__default.span(_templateObject9$j || (_templateObject9$j = _taggedTemplateLiteralLoose(["\n font-weight: 500;\n margin-left: 4px;\n"])));
|
|
@@ -49034,41 +47367,6 @@ var LinkPreviewDescription = styled__default.div(_templateObject45 || (_template
|
|
|
49034
47367
|
});
|
|
49035
47368
|
var LinkPreviewCloseButton = styled__default.button(_templateObject46 || (_templateObject46 = _taggedTemplateLiteralLoose(["\n display: flex;\n align-items: center;\n justify-content: center;\n width: 14px;\n height: 25px;\n border: none;\n background: transparent;\n cursor: pointer;\n padding: 0;\n flex-shrink: 0;\n\n svg {\n width: 12px;\n height: 12px;\n }\n"])));
|
|
49036
47369
|
|
|
49037
|
-
var copyToClipboard = function copyToClipboard(text) {
|
|
49038
|
-
try {
|
|
49039
|
-
var _temp2 = function _temp2(_result2) {
|
|
49040
|
-
if (_exit) return _result2;
|
|
49041
|
-
try {
|
|
49042
|
-
if (typeof document !== 'undefined') {
|
|
49043
|
-
var textarea = document.createElement('textarea');
|
|
49044
|
-
textarea.value = text;
|
|
49045
|
-
textarea.style.position = 'fixed';
|
|
49046
|
-
textarea.style.left = '-9999px';
|
|
49047
|
-
document.body.appendChild(textarea);
|
|
49048
|
-
textarea.focus();
|
|
49049
|
-
textarea.select();
|
|
49050
|
-
var successful = document.execCommand('copy');
|
|
49051
|
-
document.body.removeChild(textarea);
|
|
49052
|
-
return successful;
|
|
49053
|
-
}
|
|
49054
|
-
} catch (e) {}
|
|
49055
|
-
return false;
|
|
49056
|
-
};
|
|
49057
|
-
var _exit = false;
|
|
49058
|
-
var _temp = _catch(function () {
|
|
49059
|
-
if (typeof navigator !== 'undefined' && navigator.clipboard && navigator.clipboard.writeText) {
|
|
49060
|
-
return Promise.resolve(navigator.clipboard.writeText(text)).then(function () {
|
|
49061
|
-
_exit = true;
|
|
49062
|
-
return true;
|
|
49063
|
-
});
|
|
49064
|
-
}
|
|
49065
|
-
}, function () {});
|
|
49066
|
-
return Promise.resolve(_temp && _temp.then ? _temp.then(_temp2) : _temp2(_temp));
|
|
49067
|
-
} catch (e) {
|
|
49068
|
-
return Promise.reject(e);
|
|
49069
|
-
}
|
|
49070
|
-
};
|
|
49071
|
-
|
|
49072
47370
|
var _path$1s;
|
|
49073
47371
|
function _extends$1w() {
|
|
49074
47372
|
return _extends$1w = Object.assign ? Object.assign.bind() : function (n) {
|
|
@@ -49386,7 +47684,7 @@ var StyledPopupName = styled__default(PopupName)(_templateObject$W || (_template
|
|
|
49386
47684
|
var StyledPopupDescription = styled__default(PopupDescription)(_templateObject2$R || (_templateObject2$R = _taggedTemplateLiteralLoose(["\n font-weight: 400;\n font-style: normal;\n font-size: 15px;\n line-height: 150%;\n letter-spacing: 0%;\n margin-top: 0;\n margin-bottom: 0;\n width: 437px;\n height: 68px;\n opacity: 1;\n display: block;\n overflow-wrap: break-word;\n word-wrap: break-word;\n"])));
|
|
49387
47685
|
var CloseButton$1 = styled__default(Button)(_templateObject3$J || (_templateObject3$J = _taggedTemplateLiteralLoose(["\n width: 73px;\n height: 36px;\n min-width: 73px;\n max-width: 73px;\n padding: 0;\n display: flex;\n align-items: center;\n justify-content: center;\n"])));
|
|
49388
47686
|
|
|
49389
|
-
var _templateObject$X, _templateObject2$S, _templateObject3$K, _templateObject4$D, _templateObject5$y, _templateObject6$u, _templateObject7$s, _templateObject8$
|
|
47687
|
+
var _templateObject$X, _templateObject2$S, _templateObject3$K, _templateObject4$D, _templateObject5$y, _templateObject6$u, _templateObject7$s, _templateObject8$n;
|
|
49390
47688
|
var TIMER_OPTIONS = [{
|
|
49391
47689
|
key: 'off',
|
|
49392
47690
|
label: 'Off'
|
|
@@ -49637,9 +47935,9 @@ var CustomDropdownOptionLi = styled__default(DropdownOptionLi)(_templateObject6$
|
|
|
49637
47935
|
var CustomDropdownOptionsUl = styled__default(DropdownOptionsUl)(_templateObject7$s || (_templateObject7$s = _taggedTemplateLiteralLoose(["\n border-color: ", ";\n height: 268px;\n max-height: 268px;\n border-radius: 0;\n\n ", " {\n padding-left: 24px;\n padding-right: 24px;\n }\n"])), function (props) {
|
|
49638
47936
|
return props.accentColor;
|
|
49639
47937
|
}, CustomDropdownOptionLi);
|
|
49640
|
-
var SetButton = styled__default(Button)(_templateObject8$
|
|
47938
|
+
var SetButton = styled__default(Button)(_templateObject8$n || (_templateObject8$n = _taggedTemplateLiteralLoose(["\n width: 57px;\n height: 36px;\n min-width: 57px;\n max-width: 57px;\n padding: 0;\n display: flex;\n align-items: center;\n justify-content: center;\n"])));
|
|
49641
47939
|
|
|
49642
|
-
var _templateObject$Y, _templateObject2$T, _templateObject3$L, _templateObject4$E, _templateObject5$z, _templateObject6$v, _templateObject7$t, _templateObject8$
|
|
47940
|
+
var _templateObject$Y, _templateObject2$T, _templateObject3$L, _templateObject4$E, _templateObject5$z, _templateObject6$v, _templateObject7$t, _templateObject8$o;
|
|
49643
47941
|
var formatMemberCount = function formatMemberCount(count, channelType) {
|
|
49644
47942
|
if (channelType === DEFAULT_CHANNEL_TYPE.BROADCAST || channelType === DEFAULT_CHANNEL_TYPE.PUBLIC) {
|
|
49645
47943
|
return count + " " + (count > 1 ? 'subscribers' : 'subscriber');
|
|
@@ -49813,9 +48111,9 @@ var LoadingText$1 = styled__default.div(_templateObject6$v || (_templateObject6$
|
|
|
49813
48111
|
var EmptyText = styled__default.div(_templateObject7$t || (_templateObject7$t = _taggedTemplateLiteralLoose(["\n text-align: center;\n padding: 40px 20px;\n font-size: 14px;\n color: ", ";\n"])), function (props) {
|
|
49814
48112
|
return props.color;
|
|
49815
48113
|
});
|
|
49816
|
-
var ChevronRightIconWrapper = styled__default.span(_templateObject8$
|
|
48114
|
+
var ChevronRightIconWrapper = styled__default.span(_templateObject8$o || (_templateObject8$o = _taggedTemplateLiteralLoose(["\n display: flex;\n align-items: center;\n\n & > svg {\n width: 16px;\n height: 16px;\n transform: rotate(-90deg);\n }\n"])));
|
|
49817
48115
|
|
|
49818
|
-
var _templateObject$Z, _templateObject2$U, _templateObject3$M, _templateObject4$F, _templateObject5$A, _templateObject6$w, _templateObject7$u, _templateObject8$
|
|
48116
|
+
var _templateObject$Z, _templateObject2$U, _templateObject3$M, _templateObject4$F, _templateObject5$A, _templateObject6$w, _templateObject7$u, _templateObject8$p, _templateObject9$k, _templateObject0$i, _templateObject1$e, _templateObject10$9, _templateObject11$7, _templateObject12$6, _templateObject13$5, _templateObject14$4, _templateObject15$3, _templateObject16$3, _templateObject17$3, _templateObject18$3, _templateObject19$3, _templateObject20$3;
|
|
49819
48117
|
var Actions = function Actions(_ref) {
|
|
49820
48118
|
var _getDisappearingSetti;
|
|
49821
48119
|
var setActionsHeight = _ref.setActionsHeight,
|
|
@@ -50346,7 +48644,7 @@ var ActionsMenu = styled__default.ul(_templateObject4$F || (_templateObject4$F =
|
|
|
50346
48644
|
var DefaultMutedIcon = styled__default(SvgUnmuteNotifications)(_templateObject5$A || (_templateObject5$A = _taggedTemplateLiteralLoose([""])));
|
|
50347
48645
|
var DefaultMuteIcon = styled__default(SvgNotifications)(_templateObject6$w || (_templateObject6$w = _taggedTemplateLiteralLoose([""])));
|
|
50348
48646
|
var DefaultStarIcon = styled__default(SvgStar)(_templateObject7$u || (_templateObject7$u = _taggedTemplateLiteralLoose([""])));
|
|
50349
|
-
var DefaultUnpinIcon = styled__default(SvgUnpin)(_templateObject8$
|
|
48647
|
+
var DefaultUnpinIcon = styled__default(SvgUnpin)(_templateObject8$p || (_templateObject8$p = _taggedTemplateLiteralLoose([""])));
|
|
50350
48648
|
var DefaultPinIcon = styled__default(SvgPin)(_templateObject9$k || (_templateObject9$k = _taggedTemplateLiteralLoose([""])));
|
|
50351
48649
|
var DefaultMarkAsRead = styled__default(SvgMarkAsRead)(_templateObject0$i || (_templateObject0$i = _taggedTemplateLiteralLoose([""])));
|
|
50352
48650
|
var DefaultMarkAsUnRead = styled__default(SvgMarkAsUnRead)(_templateObject1$e || (_templateObject1$e = _taggedTemplateLiteralLoose([""])));
|
|
@@ -50520,7 +48818,7 @@ function SvgDownloadFile(props) {
|
|
|
50520
48818
|
})));
|
|
50521
48819
|
}
|
|
50522
48820
|
|
|
50523
|
-
var _templateObject$10, _templateObject2$W, _templateObject3$N, _templateObject4$G, _templateObject5$B, _templateObject6$x, _templateObject7$v, _templateObject8$
|
|
48821
|
+
var _templateObject$10, _templateObject2$W, _templateObject3$N, _templateObject4$G, _templateObject5$B, _templateObject6$x, _templateObject7$v, _templateObject8$q;
|
|
50524
48822
|
var Files = function Files(_ref) {
|
|
50525
48823
|
var channelId = _ref.channelId,
|
|
50526
48824
|
filePreviewIcon = _ref.filePreviewIcon,
|
|
@@ -50667,7 +48965,7 @@ var FileThumb = styled__default.img(_templateObject6$x || (_templateObject6$x =
|
|
|
50667
48965
|
var FileItem = styled__default.div(_templateObject7$v || (_templateObject7$v = _taggedTemplateLiteralLoose(["\n position: relative;\n padding: 11px 16px;\n display: flex;\n align-items: center;\n font-size: 15px;\n transition: all 0.2s;\n div {\n margin-left: 7px;\n width: calc(100% - 48px);\n }\n &:hover {\n background-color: ", ";\n ", " {\n visibility: visible;\n }\n & ", " {\n display: none;\n }\n & ", " {\n display: inline-flex;\n }\n }\n /*&.isHover {\n\n }*/\n"])), function (props) {
|
|
50668
48966
|
return props.hoverBackgroundColor;
|
|
50669
48967
|
}, DownloadWrapper, FileIconCont, FileHoverIconCont);
|
|
50670
|
-
var FileSizeAndDate = styled__default.span(_templateObject8$
|
|
48968
|
+
var FileSizeAndDate = styled__default.span(_templateObject8$q || (_templateObject8$q = _taggedTemplateLiteralLoose(["\n display: block;\n font-style: normal;\n font-weight: normal;\n font-size: ", ";\n line-height: ", ";\n color: ", ";\n margin-top: 2px;\n"])), function (props) {
|
|
50671
48969
|
return props.fontSize || '13px';
|
|
50672
48970
|
}, function (props) {
|
|
50673
48971
|
return props.lineHeight || '16px';
|
|
@@ -50811,7 +49109,7 @@ function SvgVoicePreviewPause(props) {
|
|
|
50811
49109
|
})));
|
|
50812
49110
|
}
|
|
50813
49111
|
|
|
50814
|
-
var _templateObject$13, _templateObject2$Y, _templateObject3$P, _templateObject4$I, _templateObject5$D, _templateObject6$y, _templateObject7$w, _templateObject8$
|
|
49112
|
+
var _templateObject$13, _templateObject2$Y, _templateObject3$P, _templateObject4$I, _templateObject5$D, _templateObject6$y, _templateObject7$w, _templateObject8$r;
|
|
50815
49113
|
var VoiceItem = function VoiceItem(_ref) {
|
|
50816
49114
|
var file = _ref.file,
|
|
50817
49115
|
voicePreviewPlayIcon = _ref.voicePreviewPlayIcon,
|
|
@@ -50924,7 +49222,7 @@ var VoiceItem = function VoiceItem(_ref) {
|
|
|
50924
49222
|
color: voicePreviewDateAndTimeColor || textSecondary
|
|
50925
49223
|
}, formatChannelDetailsDate(file.createdAt)), /*#__PURE__*/React__default.createElement(AudioSendTime, {
|
|
50926
49224
|
color: textSecondary
|
|
50927
|
-
}, currentTime || (file.metadata.dur ? formatAudioVideoTime(file.metadata.dur) : ''))), /*#__PURE__*/React__default.createElement(Audio, {
|
|
49225
|
+
}, currentTime || (file.metadata.dur ? formatAudioVideoTime(file.metadata.dur) : ''))), /*#__PURE__*/React__default.createElement(Audio$1, {
|
|
50928
49226
|
controls: true,
|
|
50929
49227
|
ref: audioRef,
|
|
50930
49228
|
src: fileUrl,
|
|
@@ -50960,7 +49258,7 @@ var AudioDate = styled__default.span(_templateObject6$y || (_templateObject6$y =
|
|
|
50960
49258
|
var AudioSendTime = styled__default.span(_templateObject7$w || (_templateObject7$w = _taggedTemplateLiteralLoose(["\n position: absolute;\n right: 0;\n top: 11px;\n color: ", ";\n font-size: 12px;\n line-height: 16px;\n"])), function (props) {
|
|
50961
49259
|
return props.color;
|
|
50962
49260
|
});
|
|
50963
|
-
var Audio = styled__default.audio(_templateObject8$
|
|
49261
|
+
var Audio$1 = styled__default.audio(_templateObject8$r || (_templateObject8$r = _taggedTemplateLiteralLoose(["\n display: none;\n"])));
|
|
50964
49262
|
|
|
50965
49263
|
var _templateObject$14;
|
|
50966
49264
|
var Voices = function Voices(_ref) {
|
|
@@ -51201,7 +49499,7 @@ function ResetLinkConfirmModal(_ref) {
|
|
|
51201
49499
|
});
|
|
51202
49500
|
}
|
|
51203
49501
|
|
|
51204
|
-
var _templateObject$16, _templateObject2$_, _templateObject3$R, _templateObject4$J, _templateObject5$E, _templateObject6$z, _templateObject7$x, _templateObject8$
|
|
49502
|
+
var _templateObject$16, _templateObject2$_, _templateObject3$R, _templateObject4$J, _templateObject5$E, _templateObject6$z, _templateObject7$x, _templateObject8$s, _templateObject9$l, _templateObject0$j, _templateObject1$f, _templateObject10$a, _templateObject11$8, _templateObject12$7, _templateObject13$6;
|
|
51205
49503
|
function InviteLinkModal(_ref) {
|
|
51206
49504
|
var _getInviteLinkOptions, _tabs$link, _tabs$qr, _tabs$link2, _tabs$qr2;
|
|
51207
49505
|
var onClose = _ref.onClose,
|
|
@@ -51710,7 +50008,7 @@ var LinkField = styled__default.div(_templateObject6$z || (_templateObject6$z =
|
|
|
51710
50008
|
var LinkInput = styled__default.input(_templateObject7$x || (_templateObject7$x = _taggedTemplateLiteralLoose(["\n flex: 1;\n border: none;\n outline: none;\n height: 40px;\n background: transparent;\n color: ", ";\n font-size: 14px;\n"])), function (p) {
|
|
51711
50009
|
return p.color;
|
|
51712
50010
|
});
|
|
51713
|
-
var CopyButton = styled__default.button(_templateObject8$
|
|
50011
|
+
var CopyButton = styled__default.button(_templateObject8$s || (_templateObject8$s = _taggedTemplateLiteralLoose(["\n display: inline-flex;\n align-items: center;\n justify-content: center;\n width: 40px;\n height: 40px;\n border: none;\n background: transparent;\n cursor: pointer;\n"])));
|
|
51714
50012
|
var CopyButtonWrapper = styled__default.div(_templateObject9$l || (_templateObject9$l = _taggedTemplateLiteralLoose(["\n position: relative;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n"])));
|
|
51715
50013
|
var SectionTitle = styled__default.h4(_templateObject0$j || (_templateObject0$j = _taggedTemplateLiteralLoose(["\n margin: 16px 0 8px;\n font-weight: 500;\n font-size: 15px;\n line-height: 16px;\n color: ", ";\n"])), function (p) {
|
|
51716
50014
|
return p.color;
|
|
@@ -51731,7 +50029,7 @@ var QrHint = styled__default.p(_templateObject13$6 || (_templateObject13$6 = _ta
|
|
|
51731
50029
|
return p.color;
|
|
51732
50030
|
});
|
|
51733
50031
|
|
|
51734
|
-
var _templateObject$17, _templateObject2$$, _templateObject3$S, _templateObject4$K, _templateObject5$F, _templateObject6$A, _templateObject7$y, _templateObject8$
|
|
50032
|
+
var _templateObject$17, _templateObject2$$, _templateObject3$S, _templateObject4$K, _templateObject5$F, _templateObject6$A, _templateObject7$y, _templateObject8$t, _templateObject9$m;
|
|
51735
50033
|
var Members = function Members(_ref) {
|
|
51736
50034
|
var _members$find;
|
|
51737
50035
|
var channel = _ref.channel,
|
|
@@ -52050,7 +50348,7 @@ var EditMemberIcon = styled__default.span(_templateObject6$A || (_templateObject
|
|
|
52050
50348
|
return props.color;
|
|
52051
50349
|
});
|
|
52052
50350
|
var MembersList = styled__default.ul(_templateObject7$y || (_templateObject7$y = _taggedTemplateLiteralLoose(["\n margin: 0;\n padding: 0;\n list-style: none;\n transition: all 0.2s;\n"])));
|
|
52053
|
-
var MemberItem$1 = styled__default.li(_templateObject8$
|
|
50351
|
+
var MemberItem$1 = styled__default.li(_templateObject8$t || (_templateObject8$t = _taggedTemplateLiteralLoose(["\n display: flex;\n align-items: center;\n font-size: ", ";\n font-weight: 500;\n padding: 6px 16px;\n transition: all 0.2s;\n color: ", ";\n cursor: pointer;\n\n & > svg {\n rect {\n fill: transparent;\n }\n }\n\n &:first-child {\n cursor: pointer;\n\n > svg {\n color: ", ";\n margin-right: 12px;\n & > rect {\n fill: ", " !important;\n }\n }\n }\n\n &:hover {\n background-color: ", ";\n }\n\n &:hover ", " {\n opacity: 1;\n visibility: visible;\n }\n\n & .dropdown-wrapper {\n margin-left: auto;\n }\n\n & ", " {\n width: 12px;\n height: 12px;\n right: -1px;\n bottom: -1px;\n }\n"])), function (props) {
|
|
52054
50352
|
return props.fontSize || '15px';
|
|
52055
50353
|
}, function (props) {
|
|
52056
50354
|
return props.color;
|
|
@@ -52497,7 +50795,7 @@ var EditChannel = function EditChannel(_ref) {
|
|
|
52497
50795
|
})));
|
|
52498
50796
|
};
|
|
52499
50797
|
|
|
52500
|
-
var _templateObject$1a, _templateObject2$12, _templateObject3$U, _templateObject4$M, _templateObject5$G, _templateObject6$B, _templateObject7$z, _templateObject8$
|
|
50798
|
+
var _templateObject$1a, _templateObject2$12, _templateObject3$U, _templateObject4$M, _templateObject5$G, _templateObject6$B, _templateObject7$z, _templateObject8$u, _templateObject9$n, _templateObject0$k, _templateObject1$g, _templateObject10$b, _templateObject11$9;
|
|
52501
50799
|
var Details = function Details(_ref) {
|
|
52502
50800
|
var _activeChannel$member;
|
|
52503
50801
|
var detailsTitleText = _ref.detailsTitleText,
|
|
@@ -52978,7 +51276,7 @@ var ChannelInfo$5 = styled__default.div(_templateObject7$z || (_templateObject7$
|
|
|
52978
51276
|
}, function (props) {
|
|
52979
51277
|
return props.direction && props.direction === 'column' && 'center';
|
|
52980
51278
|
});
|
|
52981
|
-
var DetailsHeader = styled__default.div(_templateObject8$
|
|
51279
|
+
var DetailsHeader = styled__default.div(_templateObject8$u || (_templateObject8$u = _taggedTemplateLiteralLoose(["\n border-bottom: 6px solid ", ";\n align-items: center;\n box-sizing: border-box;\n padding: 20px 16px;\n"])), function (props) {
|
|
52982
51280
|
return props.borderColor;
|
|
52983
51281
|
});
|
|
52984
51282
|
var ChannelAvatarAndName = styled__default.div(_templateObject9$n || (_templateObject9$n = _taggedTemplateLiteralLoose(["\n position: relative;\n display: flex;\n align-items: center;\n box-sizing: border-box;\n flex-direction: ", ";\n"])), function (props) {
|