isometrik-plugin-chat-sdk 1.0.8 → 1.3.13
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/LICENSE +21 -0
- package/dist/cjs/attachment-preview_22.cjs.entry.js +10 -9
- package/dist/cjs/attachment-preview_22.cjs.entry.js.map +1 -1
- package/dist/cjs/audio-bubble_4.cjs.entry.js +1 -1
- package/dist/cjs/chat-assets-e32e80c0.js +73 -0
- package/dist/cjs/chat-assets-e32e80c0.js.map +1 -0
- package/dist/cjs/chat-tile_3.cjs.entry.js +1 -1
- package/dist/cjs/forward-memebers.cjs.entry.js +1 -1
- package/dist/cjs/isometrik-webchat.cjs.js +1 -1
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/login-page_3.cjs.entry.js +23 -13
- package/dist/cjs/login-page_3.cjs.entry.js.map +1 -1
- package/dist/cjs/member-add.cjs.entry.js +1 -1
- package/dist/cjs/new-chat-sidebar.cjs.entry.js +1 -1
- package/dist/collection/components/ChatUIComponent/ChatSidebar/ChatSidebar.js +6 -7
- package/dist/collection/components/ChatUIComponent/ChatSidebar/ChatSidebar.js.map +1 -1
- package/dist/collection/components/ChatUIComponent/WebChatBody/WebChatBody.js +12 -12
- package/dist/collection/components/ChatUIComponent/WebChatBody/WebChatBody.js.map +1 -1
- package/dist/collection/components/my-component/web-chat/WebChat.js +39 -6
- package/dist/collection/components/my-component/web-chat/WebChat.js.map +1 -1
- package/dist/collection/components/my-component/web-chat/shell-render.js +4 -2
- package/dist/collection/components/my-component/web-chat/shell-render.js.map +1 -1
- package/dist/collection/components/theme-provider.js +9 -9
- package/dist/collection/components/theme-provider.js.map +1 -1
- package/dist/collection/constants/chat-assets.js +39 -123
- package/dist/components/ChatSidebar.js +2 -2
- package/dist/components/ChatSidebar.js.map +1 -1
- package/dist/components/WebChat.js +15 -4
- package/dist/components/WebChat.js.map +1 -1
- package/dist/components/WebChatBody.js +9 -8
- package/dist/components/WebChatBody.js.map +1 -1
- package/dist/components/chat-assets.js +34 -82
- package/dist/components/chat-assets.js.map +1 -1
- package/dist/components/theme-provider2.js +9 -9
- package/dist/components/theme-provider2.js.map +1 -1
- package/dist/esm/attachment-preview_22.entry.js +10 -9
- package/dist/esm/attachment-preview_22.entry.js.map +1 -1
- package/dist/esm/audio-bubble_4.entry.js +1 -1
- package/dist/esm/chat-assets-4dfb1106.js +38 -0
- package/dist/esm/chat-assets-4dfb1106.js.map +1 -0
- package/dist/esm/chat-tile_3.entry.js +1 -1
- package/dist/esm/forward-memebers.entry.js +1 -1
- package/dist/esm/isometrik-webchat.js +1 -1
- package/dist/esm/loader.js +1 -1
- package/dist/esm/login-page_3.entry.js +23 -13
- package/dist/esm/login-page_3.entry.js.map +1 -1
- package/dist/esm/member-add.entry.js +1 -1
- package/dist/esm/new-chat-sidebar.entry.js +1 -1
- package/dist/isometrik-webchat/isometrik-webchat.css +1 -1
- package/dist/isometrik-webchat/isometrik-webchat.esm.js +1 -1
- package/dist/isometrik-webchat/isometrik-webchat.esm.js.map +1 -1
- package/dist/isometrik-webchat/{p-188b2631.entry.js → p-0085b397.entry.js} +2 -2
- package/dist/isometrik-webchat/{p-ab5e1e85.entry.js → p-1ad1127f.entry.js} +2 -2
- package/dist/isometrik-webchat/p-6d9f8cec.entry.js +2 -0
- package/dist/isometrik-webchat/p-6d9f8cec.entry.js.map +1 -0
- package/dist/isometrik-webchat/{p-b44f0bd1.entry.js → p-6ec350aa.entry.js} +2 -2
- package/dist/isometrik-webchat/p-6ffeb379.entry.js +2 -0
- package/dist/isometrik-webchat/p-6ffeb379.entry.js.map +1 -0
- package/dist/isometrik-webchat/{p-e589ff24.entry.js → p-71cc96a3.entry.js} +2 -2
- package/dist/isometrik-webchat/{p-ff8f6bd2.entry.js → p-b8cef5e4.entry.js} +2 -2
- package/dist/isometrik-webchat/p-d424871c.js +2 -0
- package/dist/isometrik-webchat/p-d424871c.js.map +1 -0
- package/dist/types/components/ChatUIComponent/ChatSidebar/ChatSidebar.d.ts +2 -1
- package/dist/types/components/ChatUIComponent/WebChatBody/WebChatBody.d.ts +2 -2
- package/dist/types/components/theme-provider.d.ts +3 -2
- package/dist/types/components.d.ts +26 -8
- package/package.json +53 -10
- package/readme.md +428 -0
- package/dist/cjs/chat-assets-ff067e4d.js +0 -121
- package/dist/cjs/chat-assets-ff067e4d.js.map +0 -1
- package/dist/collection/assets/ExcelDocument.js +0 -2
- package/dist/collection/assets/IsometrikLogo.js +0 -38
- package/dist/collection/assets/Moon.svg +0 -1
- package/dist/collection/assets/New-Chat.svg +0 -5
- package/dist/collection/assets/NoChatPlaceholder.js +0 -16
- package/dist/collection/assets/NoContactsPlaceholder.js +0 -9
- package/dist/collection/assets/NoMessagePlaceholder.svg +0 -13
- package/dist/collection/assets/PdfDocument.js +0 -2
- package/dist/collection/assets/ProfilePlaceholder.js +0 -1
- package/dist/collection/assets/SelectChatPlaceholder.js +0 -13
- package/dist/collection/assets/Sun.svg +0 -1
- package/dist/collection/assets/add-user.svg +0 -6
- package/dist/collection/assets/attachment.svg +0 -4
- package/dist/collection/assets/avatar.svg +0 -1
- package/dist/collection/assets/block-user.svg +0 -4
- package/dist/collection/assets/camera-add.svg +0 -4
- package/dist/collection/assets/camera.svg +0 -17
- package/dist/collection/assets/cancel.svg +0 -12
- package/dist/collection/assets/chatBG.png +0 -0
- package/dist/collection/assets/chatdefaultbg.svg +0 -6140
- package/dist/collection/assets/clear-chat.svg +0 -4
- package/dist/collection/assets/close.svg +0 -4
- package/dist/collection/assets/dark-theme.svg +0 -12
- package/dist/collection/assets/delete.svg +0 -8
- package/dist/collection/assets/doc.png +0 -0
- package/dist/collection/assets/documents.svg +0 -15
- package/dist/collection/assets/doublecheck.svg +0 -1
- package/dist/collection/assets/download.svg +0 -4
- package/dist/collection/assets/drop-down.svg +0 -5
- package/dist/collection/assets/edit.svg +0 -4
- package/dist/collection/assets/equalizer.svg +0 -1
- package/dist/collection/assets/excel.svg +0 -2
- package/dist/collection/assets/forward.svg +0 -4
- package/dist/collection/assets/group-cast.svg +0 -1
- package/dist/collection/assets/group.svg +0 -13
- package/dist/collection/assets/imagePlaceholder.png +0 -0
- package/dist/collection/assets/imagePlaceholder.svg +0 -2
- package/dist/collection/assets/info.svg +0 -4
- package/dist/collection/assets/left-arrow.svg +0 -4
- package/dist/collection/assets/link.svg +0 -1
- package/dist/collection/assets/login.svg +0 -3051
- package/dist/collection/assets/logout.svg +0 -5
- package/dist/collection/assets/message-outline.svg +0 -5
- package/dist/collection/assets/message.svg +0 -1
- package/dist/collection/assets/microphone.svg +0 -2
- package/dist/collection/assets/new_group.svg +0 -9
- package/dist/collection/assets/odt-file.png +0 -0
- package/dist/collection/assets/onboarding.webp +0 -0
- package/dist/collection/assets/paper.svg +0 -5
- package/dist/collection/assets/pause.svg +0 -4
- package/dist/collection/assets/pdf.svg +0 -11
- package/dist/collection/assets/photos.svg +0 -4
- package/dist/collection/assets/play.svg +0 -19
- package/dist/collection/assets/profilePlaceholderImage.png +0 -0
- package/dist/collection/assets/reply.svg +0 -4
- package/dist/collection/assets/rtf.png +0 -0
- package/dist/collection/assets/search.svg +0 -4
- package/dist/collection/assets/send.svg +0 -4
- package/dist/collection/assets/singlecheck.svg +0 -1
- package/dist/collection/assets/smile.svg +0 -2
- package/dist/collection/assets/three-dots.svg +0 -5
- package/dist/collection/assets/txt.png +0 -0
- package/dist/collection/assets/videoPlaceholder.svg +0 -4
- package/dist/collection/assets/videoThumbnail.svg +0 -1
- package/dist/collection/components/ChatUIComponent/AudioBubble.js +0 -315
- package/dist/collection/components/ChatUIComponent/BlockChatList.js +0 -177
- package/dist/collection/components/ChatUIComponent/ForwardMessageList.js +0 -152
- package/dist/collection/components/ChatUIComponent/GroupCast.js +0 -461
- package/dist/collection/components/ChatUIComponent/shared/attachment-preview.js +0 -230
- package/dist/collection/components/ChatUIComponent/shared/chat-loading-placeholder.js +0 -70
- package/dist/collection/components/ChatUIComponent/shared/confirm-dialog.js +0 -51
- package/dist/collection/components/ChatUIComponent/shared/contact-info.js +0 -255
- package/dist/collection/components/ChatUIComponent/shared/context-menu.js +0 -112
- package/dist/collection/components/ChatUIComponent/shared/delete-message.js +0 -49
- package/dist/collection/components/ChatUIComponent/shared/document-message.js +0 -161
- package/dist/collection/components/ChatUIComponent/shared/forward-message.js +0 -139
- package/dist/collection/components/ChatUIComponent/shared/group-chat-contacts.js +0 -201
- package/dist/collection/components/ChatUIComponent/shared/group-info.js +0 -170
- package/dist/collection/components/ChatUIComponent/shared/image-message.js +0 -156
- package/dist/collection/components/ChatUIComponent/shared/incoming-text-message-bubble.js +0 -98
- package/dist/collection/components/ChatUIComponent/shared/link-preview.js +0 -125
- package/dist/collection/components/ChatUIComponent/shared/media-gallery.js +0 -152
- package/dist/collection/components/ChatUIComponent/shared/message-body-render.js +0 -19
- package/dist/collection/components/ChatUIComponent/shared/message-bubble.js +0 -189
- package/dist/collection/components/ChatUIComponent/shared/message-date-pill.js +0 -86
- package/dist/collection/components/ChatUIComponent/shared/message-info.js +0 -188
- package/dist/collection/components/ChatUIComponent/shared/message-search.js +0 -125
- package/dist/collection/components/ChatUIComponent/shared/new-chat-sidebar.js +0 -181
- package/dist/collection/components/ChatUIComponent/shared/outgoing-text-message-bubble.js +0 -98
- package/dist/collection/components/ChatUIComponent/shared/profile-avatar.js +0 -136
- package/dist/collection/components/ChatUIComponent/shared/profile-info.js +0 -220
- package/dist/collection/components/ChatUIComponent/shared/reply-block.js +0 -162
- package/dist/collection/components/ChatUIComponent/shared/reply-message-container.js +0 -193
- package/dist/collection/components/ChatUIComponent/shared/share-popup.js +0 -69
- package/dist/collection/components/ChatUIComponent/shared/spinner-loader.js +0 -74
- package/dist/collection/components/ChatUIComponent/shared/toast-notification.js +0 -106
- package/dist/collection/components/ChatUIComponent/shared/video-message.js +0 -165
- package/dist/collection/components/my-component/my-component.e2e.js +0 -25
- package/dist/collection/components/my-component/my-component.spec.js +0 -34
- package/dist/collection/components/my-component/web-chat/web-chat-split.spec.js +0 -40
- package/dist/collection/lib/chat/chat.spec.js +0 -28
- package/dist/collection/lib/custom-ui/custom-ui.spec.js +0 -49
- package/dist/collection/lib/message-body-segments.spec.js +0 -21
- package/dist/collection/lib/message-dedup.spec.js +0 -17
- package/dist/collection/lib/mqtt/mqtt.spec.js +0 -39
- package/dist/collection/utils/utils.spec.js +0 -15
- package/dist/esm/chat-assets-95633770.js +0 -86
- package/dist/esm/chat-assets-95633770.js.map +0 -1
- package/dist/isometrik-webchat/assets/ExcelDocument.js +0 -2
- package/dist/isometrik-webchat/assets/IsometrikLogo.js +0 -38
- package/dist/isometrik-webchat/assets/Moon.svg +0 -1
- package/dist/isometrik-webchat/assets/New-Chat.svg +0 -5
- package/dist/isometrik-webchat/assets/NoChatPlaceholder.js +0 -16
- package/dist/isometrik-webchat/assets/NoContactsPlaceholder.js +0 -9
- package/dist/isometrik-webchat/assets/NoMessagePlaceholder.svg +0 -13
- package/dist/isometrik-webchat/assets/PdfDocument.js +0 -2
- package/dist/isometrik-webchat/assets/ProfilePlaceholder.js +0 -1
- package/dist/isometrik-webchat/assets/SelectChatPlaceholder.js +0 -13
- package/dist/isometrik-webchat/assets/Sun.svg +0 -1
- package/dist/isometrik-webchat/assets/add-user.svg +0 -6
- package/dist/isometrik-webchat/assets/attachment.svg +0 -4
- package/dist/isometrik-webchat/assets/avatar.svg +0 -1
- package/dist/isometrik-webchat/assets/block-user.svg +0 -4
- package/dist/isometrik-webchat/assets/camera-add.svg +0 -4
- package/dist/isometrik-webchat/assets/camera.svg +0 -17
- package/dist/isometrik-webchat/assets/cancel.svg +0 -12
- package/dist/isometrik-webchat/assets/chatBG.png +0 -0
- package/dist/isometrik-webchat/assets/chatdefaultbg.svg +0 -6140
- package/dist/isometrik-webchat/assets/clear-chat.svg +0 -4
- package/dist/isometrik-webchat/assets/close.svg +0 -4
- package/dist/isometrik-webchat/assets/dark-theme.svg +0 -12
- package/dist/isometrik-webchat/assets/delete.svg +0 -8
- package/dist/isometrik-webchat/assets/doc.png +0 -0
- package/dist/isometrik-webchat/assets/documents.svg +0 -15
- package/dist/isometrik-webchat/assets/doublecheck.svg +0 -1
- package/dist/isometrik-webchat/assets/download.svg +0 -4
- package/dist/isometrik-webchat/assets/drop-down.svg +0 -5
- package/dist/isometrik-webchat/assets/edit.svg +0 -4
- package/dist/isometrik-webchat/assets/equalizer.svg +0 -1
- package/dist/isometrik-webchat/assets/excel.svg +0 -2
- package/dist/isometrik-webchat/assets/forward.svg +0 -4
- package/dist/isometrik-webchat/assets/group-cast.svg +0 -1
- package/dist/isometrik-webchat/assets/group.svg +0 -13
- package/dist/isometrik-webchat/assets/imagePlaceholder.png +0 -0
- package/dist/isometrik-webchat/assets/imagePlaceholder.svg +0 -2
- package/dist/isometrik-webchat/assets/info.svg +0 -4
- package/dist/isometrik-webchat/assets/left-arrow.svg +0 -4
- package/dist/isometrik-webchat/assets/link.svg +0 -1
- package/dist/isometrik-webchat/assets/login.svg +0 -3051
- package/dist/isometrik-webchat/assets/logout.svg +0 -5
- package/dist/isometrik-webchat/assets/message-outline.svg +0 -5
- package/dist/isometrik-webchat/assets/message.svg +0 -1
- package/dist/isometrik-webchat/assets/microphone.svg +0 -2
- package/dist/isometrik-webchat/assets/new_group.svg +0 -9
- package/dist/isometrik-webchat/assets/odt-file.png +0 -0
- package/dist/isometrik-webchat/assets/onboarding.webp +0 -0
- package/dist/isometrik-webchat/assets/paper.svg +0 -5
- package/dist/isometrik-webchat/assets/pause.svg +0 -4
- package/dist/isometrik-webchat/assets/pdf.svg +0 -11
- package/dist/isometrik-webchat/assets/photos.svg +0 -4
- package/dist/isometrik-webchat/assets/play.svg +0 -19
- package/dist/isometrik-webchat/assets/profilePlaceholderImage.png +0 -0
- package/dist/isometrik-webchat/assets/reply.svg +0 -4
- package/dist/isometrik-webchat/assets/rtf.png +0 -0
- package/dist/isometrik-webchat/assets/search.svg +0 -4
- package/dist/isometrik-webchat/assets/send.svg +0 -4
- package/dist/isometrik-webchat/assets/singlecheck.svg +0 -1
- package/dist/isometrik-webchat/assets/smile.svg +0 -2
- package/dist/isometrik-webchat/assets/three-dots.svg +0 -5
- package/dist/isometrik-webchat/assets/txt.png +0 -0
- package/dist/isometrik-webchat/assets/videoPlaceholder.svg +0 -4
- package/dist/isometrik-webchat/assets/videoThumbnail.svg +0 -1
- package/dist/isometrik-webchat/p-4bad6da9.entry.js +0 -2
- package/dist/isometrik-webchat/p-4bad6da9.entry.js.map +0 -1
- package/dist/isometrik-webchat/p-8c73a5d5.entry.js +0 -2
- package/dist/isometrik-webchat/p-8c73a5d5.entry.js.map +0 -1
- package/dist/isometrik-webchat/p-d6f0838c.js +0 -2
- package/dist/isometrik-webchat/p-d6f0838c.js.map +0 -1
- /package/dist/isometrik-webchat/{p-188b2631.entry.js.map → p-0085b397.entry.js.map} +0 -0
- /package/dist/isometrik-webchat/{p-ab5e1e85.entry.js.map → p-1ad1127f.entry.js.map} +0 -0
- /package/dist/isometrik-webchat/{p-b44f0bd1.entry.js.map → p-6ec350aa.entry.js.map} +0 -0
- /package/dist/isometrik-webchat/{p-e589ff24.entry.js.map → p-71cc96a3.entry.js.map} +0 -0
- /package/dist/isometrik-webchat/{p-ff8f6bd2.entry.js.map → p-b8cef5e4.entry.js.map} +0 -0
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{r as t,a as i,h as s,g as e}from"./p-17a96a2a.js";import{h as n}from"./p-e5884258.js";import{r as h,e as r}from"./p-d28c5548.js";import{i as o,j as a,k as c,l}from"./p-d6f0838c.js";import"./p-f24cdbbb.js";class u{constructor(){this.listeners={}}on(t,i,s){if(!this.listeners[t]){this.listeners[t]=new Set}if(s===null||s===void 0?void 0:s.once){const s=(...e)=>{this.un(t,s);i(...e)};this.listeners[t].add(s);return()=>this.un(t,s)}this.listeners[t].add(i);return()=>this.un(t,i)}un(t,i){var s;(s=this.listeners[t])===null||s===void 0?void 0:s.delete(i)}once(t,i){return this.on(t,i,{once:true})}unAll(){this.listeners={}}emit(t,...i){if(this.listeners[t]){this.listeners[t].forEach((t=>t(...i)))}}}class d extends u{constructor(t){super();this.subscriptions=[];this.isDestroyed=false;this.options=t}onInit(){return}_init(t){if(this.isDestroyed){this.subscriptions=[];this.isDestroyed=false}this.wavesurfer=t;this.onInit()}destroy(){this.emit("destroy");this.subscriptions.forEach((t=>t()));this.subscriptions=[];this.isDestroyed=true;this.wavesurfer=undefined}}var f=undefined&&undefined.__awaiter||function(t,i,s,e){function n(t){return t instanceof s?t:new s((function(i){i(t)}))}return new(s||(s=Promise))((function(s,h){function r(t){try{a(e.next(t))}catch(t){h(t)}}function o(t){try{a(e["throw"](t))}catch(t){h(t)}}function a(t){t.done?s(t.value):n(t.value).then(r,o)}a((e=e.apply(t,i||[])).next())}))};function v(t,i){return f(this,void 0,void 0,(function*(){const s=new AudioContext({sampleRate:i});try{return yield s.decodeAudioData(t)}finally{if(s.state!=="closed"){yield s.close().catch((()=>undefined))}}}))}function p(t){const i=t[0];if(i.some((t=>t>1||t<-1))){const s=i.length;let e=0;for(let t=0;t<s;t++){const s=Math.abs(i[t]);if(s>e)e=s}for(const i of t){for(let t=0;t<s;t++){i[t]/=e}}}return t}function g(t,i){if(!t||t.length===0){throw new Error("channelData must be a non-empty array")}if(i<=0){throw new Error("duration must be greater than 0")}if(typeof t[0]==="number")t=[t];if(!t[0]||t[0].length===0){throw new Error("channelData must contain non-empty channel arrays")}p(t);const s=t.map((t=>t instanceof Float32Array?t:Float32Array.from(t)));return{duration:i,length:s[0].length,sampleRate:s[0].length/i,numberOfChannels:s.length,getChannelData:t=>{const i=s[t];if(!i){throw new Error(`Channel ${t} not found`)}return i},copyFromChannel:AudioBuffer.prototype.copyFromChannel,copyToChannel:AudioBuffer.prototype.copyToChannel}}const m={decode:v,createBuffer:g};function b(t,i){const s=i.xmlns?document.createElementNS(i.xmlns,t):document.createElement(t);for(const[t,e]of Object.entries(i)){if(t==="children"&&e){for(const[t,i]of Object.entries(e)){if(i instanceof Node){s.appendChild(i)}else if(typeof i==="string"){s.appendChild(document.createTextNode(i))}else{s.appendChild(b(t,i))}}}else if(t==="style"){Object.assign(s.style,e)}else if(t==="textContent"){s.textContent=e}else{s.setAttribute(t,e.toString())}}return s}function y(t,i,s){const e=b(t,i||{});s===null||s===void 0?void 0:s.appendChild(e);return e}function M(t){if(t instanceof HTMLElement)return true;return typeof t==="object"&&t!==null&&t.nodeType===Node.ELEMENT_NODE&&typeof t.style==="object"}const x=Object.freeze({__proto__:null,createElement:y,isHTMLElement:M,default:y});var w=undefined&&undefined.__awaiter||function(t,i,s,e){function n(t){return t instanceof s?t:new s((function(i){i(t)}))}return new(s||(s=Promise))((function(s,h){function r(t){try{a(e.next(t))}catch(t){h(t)}}function o(t){try{a(e["throw"](t))}catch(t){h(t)}}function a(t){t.done?s(t.value):n(t.value).then(r,o)}a((e=e.apply(t,i||[])).next())}))};function N(t,i,s){return w(this,void 0,void 0,(function*(){var e;if(!t.body||!t.headers)return;const n=t.body.getReader();const h=Number(t.headers.get("Content-Length"))||0;let r=0;const o=()=>{n.cancel()};if(s){if(s.aborted){n.cancel();return}s.addEventListener("abort",o,{once:true})}try{while(true){const t=yield n.read();if(t.done){break}r+=((e=t.value)===null||e===void 0?void 0:e.length)||0;if(h>0){const t=Math.round(r/h*100);i(t)}}}catch(t){if(t instanceof DOMException&&t.name==="AbortError")return;console.warn("Progress tracking error:",t)}finally{if(s){s.removeEventListener("abort",o)}}}))}function T(t,i,s){return w(this,void 0,void 0,(function*(){var e;const n=yield fetch(t,s);if(n.status>=400){throw new Error(`Failed to fetch ${t}: ${n.status} (${n.statusText})`)}N(n.clone(),i,(e=s===null||s===void 0?void 0:s.signal)!==null&&e!==void 0?e:undefined);return n.blob()}))}const D={fetchBlob:T};function k(t){let i=t;const s=new Set;return{get value(){return i},set(t){if(!Object.is(i,t)){i=t;s.forEach((t=>t(i)))}},update(t){this.set(t(i))},subscribe(t){s.add(t);return()=>s.delete(t)}}}function j(t,i){const s=k(t());i.forEach((i=>i.subscribe((()=>{const i=t();if(!Object.is(s.value,i)){s.set(i)}}))));return{get value(){return s.value},subscribe(t){return s.subscribe(t)}}}function I(t,i){let s;const e=()=>{if(s){s();s=undefined}s=t()};const n=i.map((t=>t.subscribe(e)));e();return()=>{if(s){s();s=undefined}n.forEach((t=>t()))}}var S=undefined&&undefined.__awaiter||function(t,i,s,e){function n(t){return t instanceof s?t:new s((function(i){i(t)}))}return new(s||(s=Promise))((function(s,h){function r(t){try{a(e.next(t))}catch(t){h(t)}}function o(t){try{a(e["throw"](t))}catch(t){h(t)}}function a(t){t.done?s(t.value):n(t.value).then(r,o)}a((e=e.apply(t,i||[])).next())}))};class E extends u{get isPlayingSignal(){return this._isPlaying}get currentTimeSignal(){return this._currentTime}get durationSignal(){return this._duration}get volumeSignal(){return this._volume}get mutedSignal(){return this._muted}get playbackRateSignal(){return this._playbackRate}get seekingSignal(){return this._seeking}constructor(t){super();this.isExternalMedia=false;this._ownBlobUrl=null;this.reactiveMediaEventCleanups=[];if(t.media){this.media=t.media;this.isExternalMedia=true}else{this.media=document.createElement("audio")}this._isPlaying=k(false);this._currentTime=k(0);this._duration=k(0);this._volume=k(this.media.volume);this._muted=k(this.media.muted);this._playbackRate=k(this.media.playbackRate||1);this._seeking=k(false);this.setupReactiveMediaEvents();if(t.mediaControls){this.media.controls=true}if(t.autoplay){this.media.autoplay=true}if(t.playbackRate!=null){this.onMediaEvent("canplay",(()=>{if(t.playbackRate!=null){this.media.playbackRate=t.playbackRate}}),{once:true})}}setupReactiveMediaEvents(){this.reactiveMediaEventCleanups.push(this.onMediaEvent("play",(()=>{this._isPlaying.set(true)})));this.reactiveMediaEventCleanups.push(this.onMediaEvent("pause",(()=>{this._isPlaying.set(false)})));this.reactiveMediaEventCleanups.push(this.onMediaEvent("ended",(()=>{this._isPlaying.set(false)})));this.reactiveMediaEventCleanups.push(this.onMediaEvent("timeupdate",(()=>{this._currentTime.set(this.media.currentTime)})));this.reactiveMediaEventCleanups.push(this.onMediaEvent("durationchange",(()=>{this._duration.set(this.media.duration||0)})));this.reactiveMediaEventCleanups.push(this.onMediaEvent("loadedmetadata",(()=>{this._duration.set(this.media.duration||0)})));this.reactiveMediaEventCleanups.push(this.onMediaEvent("seeking",(()=>{this._seeking.set(true)})));this.reactiveMediaEventCleanups.push(this.onMediaEvent("seeked",(()=>{this._seeking.set(false)})));this.reactiveMediaEventCleanups.push(this.onMediaEvent("volumechange",(()=>{this._volume.set(this.media.volume);this._muted.set(this.media.muted)})));this.reactiveMediaEventCleanups.push(this.onMediaEvent("ratechange",(()=>{this._playbackRate.set(this.media.playbackRate)})))}onMediaEvent(t,i,s){this.media.addEventListener(t,i,s);return()=>this.media.removeEventListener(t,i,s)}getSrc(){return this.media.currentSrc||this.media.src||""}revokeSrc(){if(this._ownBlobUrl){URL.revokeObjectURL(this._ownBlobUrl);this._ownBlobUrl=null}}canPlayType(t){return this.media.canPlayType(t)!==""}setSrc(t,i){const s=this.getSrc();if(t&&s===t)return;this.revokeSrc();const e=i instanceof Blob&&(this.canPlayType(i.type)||!t)?URL.createObjectURL(i):t;if(e!==t){this._ownBlobUrl=e}if(s){this.media.removeAttribute("src")}if(e||t){try{this.media.src=e}catch(i){this.media.src=t}}}destroy(){this.reactiveMediaEventCleanups.forEach((t=>t()));this.reactiveMediaEventCleanups=[];this.revokeSrc();this.unAll();if(this.isExternalMedia)return;this.media.pause();this.media.removeAttribute("src");this.media.load();this.media.remove()}setMediaElement(t){this.reactiveMediaEventCleanups.forEach((t=>t()));this.reactiveMediaEventCleanups=[];this.media=t;this.setupReactiveMediaEvents()}play(){return S(this,void 0,void 0,(function*(){try{return yield this.media.play()}catch(t){if(t instanceof DOMException&&t.name==="AbortError"){return}throw t}}))}pause(){this.media.pause()}isPlaying(){return!this.media.paused&&!this.media.ended}setTime(t){this.media.currentTime=Math.max(0,Math.min(t,this.getDuration()))}getDuration(){return this.media.duration}getCurrentTime(){return this.media.currentTime}getVolume(){return this.media.volume}setVolume(t){this.media.volume=t}getMuted(){return this.media.muted}setMuted(t){this.media.muted=t}getPlaybackRate(){return this.media.playbackRate}isSeeking(){return this.media.seeking}setPlaybackRate(t,i){if(i!=null){this.media.preservesPitch=i}this.media.playbackRate=t}getMediaElement(){return this.media}setSinkId(t){const i=this.media;return i.setSinkId(t)}}const A=128;const C=8e3;const L=10;function z(t){if(t<0)return 0;if(t>1)return 1;return t}function P({width:t,height:i,length:s,options:e,pixelRatio:n}){const h=i/2;const r=e.barWidth?e.barWidth*n:1;const o=e.barGap?e.barGap*n:e.barWidth?r/2:0;const a=e.barRadius||0;const c=e.barMinHeight?e.barMinHeight*n:0;const l=r+o||1;const u=s>0?t/l/s:0;return{halfHeight:h,barWidth:r,barGap:o,barRadius:a,barMinHeight:c,barIndexScale:u,barSpacing:l}}function O({maxTop:t,maxBottom:i,halfHeight:s,vScale:e,barMinHeight:n=0,barAlign:h}){let r=Math.round(t*s*e);const o=Math.round(i*s*e);let a=r+o||1;if(a<n){a=n;if(!h){r=a/2}}return{topHeight:r,totalHeight:a}}function R({barAlign:t,halfHeight:i,topHeight:s,totalHeight:e,canvasHeight:n}){if(t==="top")return 0;if(t==="bottom")return n-e;return i-s}function W({channelData:t,barIndexScale:i,barSpacing:s,barWidth:e,halfHeight:n,vScale:h,canvasHeight:r,barAlign:o,barMinHeight:a}){const c=t[0]||[];const l=t[1]||c;const u=c.length;const d=[];let f=0;let v=0;let p=0;for(let t=0;t<=u;t++){const u=Math.round(t*i);if(u>f){const{topHeight:t,totalHeight:i}=O({maxTop:v,maxBottom:p,halfHeight:n,vScale:h,barMinHeight:a,barAlign:o});const c=R({barAlign:o,halfHeight:n,topHeight:t,totalHeight:i,canvasHeight:r});d.push({x:f*s,y:c,width:e,height:i});f=u;v=0;p=0}const g=Math.abs(c[t]||0);const m=Math.abs(l[t]||0);if(g>v)v=g;if(m>p)p=m}return d}function U(t,i,s){const e=i-t.left;const n=s-t.top;const h=e/t.width;const r=n/t.height;return[h,r]}function H({optionsHeight:t,optionsSplitChannels:i,parentHeight:s,numberOfChannels:e,defaultHeight:n=A}){if(t==null)return n;const h=Number(t);if(!isNaN(h))return h;if(t==="auto"){const t=s||n;if(i===null||i===void 0?void 0:i.every((t=>!t.overlay))){return t/e}return t}return n}function V(t){return Math.max(1,t||1)}function Y(t){return Boolean(t.barWidth||t.barGap||t.barAlign)}function Q(t,i,s){if(!Array.isArray(t))return t||"";if(t.length===0)return"#999";if(t.length<2)return t[0]||"";const e=document.createElement("canvas");const n=e.getContext("2d");if(!n)return t[0]||"";const h=s||e.height*i;const r=n.createLinearGradient(0,0,0,h);const o=1/(t.length-1);t.forEach(((t,i)=>{r.addColorStop(i*o,t)}));return r}function F({duration:t,minPxPerSec:i=0,parentWidth:s,fillParent:e,pixelRatio:n}){const h=Math.ceil(t*i);const r=h>s;const o=Boolean(e&&!r);const a=(o?s:h)*n;return{scrollWidth:h,isScrollable:r,useParentWidth:o,width:a}}function $(t,i){if(!Y(i))return t;const s=i.barWidth||.5;const e=i.barGap||s/2;const n=s+e;if(n===0)return t;return Math.floor(t/n)*n}function B({clientWidth:t,totalWidth:i,options:s}){const e=Math.min(C,t,i);return $(e,s)}function Z({channelData:t,offset:i,clampedWidth:s,totalWidth:e}){return t.map((t=>{const n=Math.floor(i/e*t.length);const h=Math.floor((i+s)/e*t.length);return t.slice(n,h)}))}function _(t){return t>L}function G({scrollLeft:t,totalWidth:i,numCanvases:s}){if(i===0)return[0];const e=t/i;const n=Math.floor(e*s);return[n-1,n,n+1]}function X({channelData:t,barHeight:i,normalize:s,maxPeak:e}){var n;const h=i||1;if(!s)return h;const r=t[0];if(!r||r.length===0)return h;let o=e!==null&&e!==void 0?e:0;if(!e){for(let t=0;t<r.length;t++){const i=(n=r[t])!==null&&n!==void 0?n:0;const s=Math.abs(i);if(s>o)o=s}}if(!o)return h;return h/o}function q({channelData:t,width:i,height:s,vScale:e}){const n=s/2;const h=t[0]||[];const r=t[1]||h;const o=[h,r];return o.map(((t,s)=>{const h=t.length;const r=h?i/h:0;const o=n;const a=s===0?-1:1;const c=[{x:0,y:o}];let l=0;let u=0;for(let i=0;i<=h;i++){const s=Math.round(i*r);if(s>l){const t=Math.round(u*n*e)||1;const i=o+t*a;c.push({x:l,y:i});l=s;u=0}const h=Math.abs(t[i]||0);if(h>u)u=h}c.push({x:l,y:o});return c}))}function J(t){const i=t*2;const s=i<0?Math.floor(i):Math.ceil(i);return s/2}function K(t){const i=t._cleanup;if(typeof i==="function"){i()}}function tt(t,i={}){const{threshold:s=3,mouseButton:e=0,touchDelay:n=100}=i;const h=k(null);const r=new Map;const o=matchMedia("(pointer: coarse)").matches;let a=()=>void 0;const c=i=>{if(i.button!==e)return;if(r.has(i.pointerId))return;r.set(i.pointerId,i);if(r.size>1){return}const c=i.pointerId;let l=i.clientX;let u=i.clientY;let d=false;const f=Date.now();const v=t.getBoundingClientRect();const{left:p,top:g}=v;const m=t=>{if(t.pointerId!==c)return;if(t.defaultPrevented||r.size>1){return}if(o&&Date.now()-f<n)return;const i=t.clientX;const e=t.clientY;const a=i-l;const v=e-u;if(d||Math.abs(a)>s||Math.abs(v)>s){t.preventDefault();t.stopPropagation();if(!d){h.set({type:"start",x:l-p,y:u-g});d=true}h.set({type:"move",x:i-p,y:e-g,deltaX:a,deltaY:v});l=i;u=e}};const b=t=>{if(!r.delete(t.pointerId))return;if(t.pointerId===c&&d){const i=t.clientX;const s=t.clientY;h.set({type:"end",x:i-p,y:s-g})}if(r.size===0){a()}};const y=t=>{if(!t.relatedTarget||t.relatedTarget===document.documentElement){b(t)}};const M=t=>{if(d){t.stopPropagation();t.preventDefault()}};const x=t=>{if(t.defaultPrevented||r.size>1){return}if(d){t.preventDefault()}};document.addEventListener("pointermove",m);document.addEventListener("pointerup",b);document.addEventListener("pointerout",y);document.addEventListener("pointercancel",y);document.addEventListener("touchmove",x,{passive:false});document.addEventListener("click",M,{capture:true});a=()=>{document.removeEventListener("pointermove",m);document.removeEventListener("pointerup",b);document.removeEventListener("pointerout",y);document.removeEventListener("pointercancel",y);document.removeEventListener("touchmove",x);setTimeout((()=>{document.removeEventListener("click",M,{capture:true})}),10)}};t.addEventListener("pointerdown",c);const l=()=>{a();t.removeEventListener("pointerdown",c);r.clear();K(h)};return{signal:h,cleanup:l}}function it(t){const{scrollLeft:i,scrollWidth:s,clientWidth:e}=t;if(s===0){return{startX:0,endX:1}}const n=i/s;const h=(i+e)/s;return{startX:Math.max(0,Math.min(1,n)),endX:Math.max(0,Math.min(1,h))}}function st(t){return{left:t.scrollLeft,right:t.scrollLeft+t.clientWidth}}function et(t){const i=k({scrollLeft:t.scrollLeft,scrollWidth:t.scrollWidth,clientWidth:t.clientWidth});const s=j((()=>it(i.value)),[i]);const e=j((()=>st(i.value)),[i]);const n=()=>{i.set({scrollLeft:t.scrollLeft,scrollWidth:t.scrollWidth,clientWidth:t.clientWidth})};t.addEventListener("scroll",n,{passive:true});const h=()=>{t.removeEventListener("scroll",n);K(i)};return{scrollData:i,percentages:s,bounds:e,cleanup:h}}var nt=undefined&&undefined.__awaiter||function(t,i,s,e){function n(t){return t instanceof s?t:new s((function(i){i(t)}))}return new(s||(s=Promise))((function(s,h){function r(t){try{a(e.next(t))}catch(t){h(t)}}function o(t){try{a(e["throw"](t))}catch(t){h(t)}}function a(t){t.done?s(t.value):n(t.value).then(r,o)}a((e=e.apply(t,i||[])).next())}))};var ht=undefined&&undefined.__rest||function(t,i){var s={};for(var e in t)if(Object.prototype.hasOwnProperty.call(t,e)&&i.indexOf(e)<0)s[e]=t[e];if(t!=null&&typeof Object.getOwnPropertySymbols==="function")for(var n=0,e=Object.getOwnPropertySymbols(t);n<e.length;n++){if(i.indexOf(e[n])<0&&Object.prototype.propertyIsEnumerable.call(t,e[n]))s[e[n]]=t[e[n]]}return s};const rt=60;const ot=10;const at=ot*rt;class ct extends u{constructor(t,i){super();this.timeouts=[];this.isScrollable=false;this.audioData=null;this.resizeObserver=null;this.lastContainerWidth=0;this.isDragging=false;this.subscriptions=[];this.unsubscribeOnScroll=[];this.dragStream=null;this.scrollStream=null;this.containerInlinePadding=0;this.onClickWrapper=t=>{const i=this.wrapper.getBoundingClientRect();const[s,e]=U(i,t.clientX,t.clientY);this.emit("click",s,e)};this.onDblClickWrapper=t=>{const i=this.wrapper.getBoundingClientRect();const[s,e]=U(i,t.clientX,t.clientY);this.emit("dblclick",s,e)};this.subscriptions=[];this.options=t;const s=this.parentFromOptionsContainer(t.container);this.parent=s;const[e,n]=this.initHtml();s.appendChild(e);this.container=e;this.scrollContainer=n.querySelector(".scroll");this.wrapper=n.querySelector(".wrapper");this.canvasWrapper=n.querySelector(".canvases");this.progressWrapper=n.querySelector(".progress");this.cursor=n.querySelector(".cursor");this.calculateInlinePadding();if(i){n.appendChild(i)}this.initEvents()}parentFromOptionsContainer(t){let i;if(typeof t==="string"){i=document.querySelector(t)}else if(M(t)){i=t}if(!i){throw new Error("Container not found")}return i}initEvents(){this.wrapper.addEventListener("click",this.onClickWrapper);this.wrapper.addEventListener("dblclick",this.onDblClickWrapper);if(this.options.dragToSeek===true||typeof this.options.dragToSeek==="object"){this.initDrag()}this.scrollStream=et(this.scrollContainer);const t=I((()=>{const{startX:t,endX:i}=this.scrollStream.percentages.value;const{left:s,right:e}=this.scrollStream.bounds.value;this.emit("scroll",t,i,s,e)}),[this.scrollStream.percentages,this.scrollStream.bounds]);this.subscriptions.push(t);if(typeof ResizeObserver==="function"){const t=this.createDelay(100);this.resizeObserver=new ResizeObserver((()=>{t().then((()=>this.onContainerResize())).catch((()=>undefined))}));this.resizeObserver.observe(this.scrollContainer)}}onContainerResize(){const t=this.parent.clientWidth;this.calculateInlinePadding();if(t===this.lastContainerWidth&&this.options.height!=="auto")return;this.lastContainerWidth=t;this.reRender();this.emit("resize")}initDrag(){if(this.dragStream)return;this.dragStream=tt(this.wrapper);const t=I((()=>{const t=this.dragStream.signal.value;if(!t)return;const i=this.wrapper.getBoundingClientRect().width;const s=z(t.x/i);if(t.type==="start"){this.isDragging=true;this.emit("dragstart",s)}else if(t.type==="move"){this.emit("drag",s)}else if(t.type==="end"){this.isDragging=false;this.emit("dragend",s)}}),[this.dragStream.signal]);this.subscriptions.push(t)}calculateInlinePadding(){const{paddingLeft:t,paddingRight:i}=getComputedStyle(this.scrollContainer);const s=parseFloat(t)+parseFloat(i);this.containerInlinePadding=Number.isNaN(s)?0:s}initHtml(){const t=document.createElement("div");const i=t.attachShadow({mode:"open"});const s=this.options.cspNonce&&typeof this.options.cspNonce==="string"?this.options.cspNonce.replace(/"/g,""):"";i.innerHTML=`\n <style${s?` nonce="${s}"`:""}>\n :host {\n user-select: none;\n min-width: 1px;\n }\n :host audio {\n display: block;\n width: 100%;\n }\n :host .scroll {\n overflow-x: auto;\n overflow-y: hidden;\n width: 100%;\n position: relative;\n }\n :host .noScrollbar {\n scrollbar-color: transparent;\n scrollbar-width: none;\n }\n :host .noScrollbar::-webkit-scrollbar {\n display: none;\n -webkit-appearance: none;\n }\n :host .wrapper {\n position: relative;\n overflow: visible;\n z-index: 2;\n }\n :host .canvases {\n min-height: ${this.getHeight(this.options.height,this.options.splitChannels)}px;\n pointer-events: none;\n }\n :host .canvases > div {\n position: relative;\n }\n :host canvas {\n display: block;\n position: absolute;\n top: 0;\n image-rendering: pixelated;\n }\n :host .progress {\n pointer-events: none;\n position: absolute;\n z-index: 2;\n top: 0;\n left: 0;\n width: 0;\n height: 100%;\n overflow: hidden;\n }\n :host .progress > div {\n position: relative;\n }\n :host .cursor {\n pointer-events: none;\n position: absolute;\n z-index: 5;\n top: 0;\n left: 0;\n height: 100%;\n border-radius: 2px;\n }\n </style>\n\n <div class="scroll" part="scroll">\n <div class="wrapper" part="wrapper">\n <div class="canvases" part="canvases"></div>\n <div class="progress" part="progress"></div>\n <div class="cursor" part="cursor"></div>\n </div>\n </div>\n `;return[t,i]}setOptions(t){var i;if(this.options.container!==t.container){const i=this.parentFromOptionsContainer(t.container);i.appendChild(this.container);this.parent=i}if(t.dragToSeek===true||typeof this.options.dragToSeek==="object"){this.initDrag()}else{(i=this.dragStream)===null||i===void 0?void 0:i.cleanup();this.dragStream=null}this.options=t;this.reRender()}getWrapper(){return this.wrapper}getWidth(){return this.scrollContainer.clientWidth-this.containerInlinePadding}getScroll(){return this.scrollContainer.scrollLeft}setScroll(t){this.scrollContainer.scrollLeft=t}setScrollPercentage(t){const{scrollWidth:i}=this.scrollContainer;const s=i*t;this.setScroll(s)}destroy(){var t;this.wrapper.removeEventListener("click",this.onClickWrapper);this.wrapper.removeEventListener("dblclick",this.onDblClickWrapper);this.timeouts.forEach((t=>t()));this.timeouts=[];this.subscriptions.forEach((t=>t()));this.container.remove();if(this.resizeObserver){this.resizeObserver.disconnect();this.resizeObserver=null}(t=this.unsubscribeOnScroll)===null||t===void 0?void 0:t.forEach((t=>t()));this.unsubscribeOnScroll=[];if(this.dragStream){this.dragStream.cleanup();this.dragStream=null}if(this.scrollStream){this.scrollStream.cleanup();this.scrollStream=null}}createDelay(t=10){let i;let s;const e=()=>{if(i){clearTimeout(i);i=undefined}if(s){s();s=undefined}};this.timeouts.push(e);return()=>new Promise(((n,h)=>{e();s=h;i=setTimeout((()=>{i=undefined;s=undefined;n()}),t)}))}getHeight(t,i){var s;const e=((s=this.audioData)===null||s===void 0?void 0:s.numberOfChannels)||1;return H({optionsHeight:t,optionsSplitChannels:i,parentHeight:this.parent.clientHeight,numberOfChannels:e,defaultHeight:A})}convertColorValues(t,i){return Q(t,this.getPixelRatio(),i===null||i===void 0?void 0:i.canvas.height)}getPixelRatio(){return V(window.devicePixelRatio)}renderBarWaveform(t,i,s,e){const{width:n,height:h}=s.canvas;const{halfHeight:r,barWidth:o,barRadius:a,barIndexScale:c,barSpacing:l,barMinHeight:u}=P({width:n,height:h,length:(t[0]||[]).length,options:i,pixelRatio:this.getPixelRatio()});const d=W({channelData:t,barIndexScale:c,barSpacing:l,barWidth:o,halfHeight:r,vScale:e,canvasHeight:h,barAlign:i.barAlign,barMinHeight:u});s.beginPath();for(const t of d){if(a&&"roundRect"in s){s.roundRect(t.x,t.y,t.width,t.height,a)}else{s.rect(t.x,t.y,t.width,t.height)}}s.fill();s.closePath()}renderLineWaveform(t,i,s,e){const{width:n,height:h}=s.canvas;const r=q({channelData:t,width:n,height:h,vScale:e});s.beginPath();for(const t of r){if(!t.length)continue;s.moveTo(t[0].x,t[0].y);for(let i=1;i<t.length;i++){const e=t[i];s.lineTo(e.x,e.y)}}s.fill();s.closePath()}renderWaveform(t,i,s){s.fillStyle=this.convertColorValues(i.waveColor,s);if(i.renderFunction){i.renderFunction(t,s);return}const e=X({channelData:t,barHeight:i.barHeight,normalize:i.normalize,maxPeak:i.maxPeak});if(Y(i)){this.renderBarWaveform(t,i,s,e);return}this.renderLineWaveform(t,i,s,e)}renderSingleCanvas(t,i,s,e,n,h,r){const o=this.getPixelRatio();const a=document.createElement("canvas");a.width=Math.round(s*o);a.height=Math.round(e*o);a.style.width=`${s}px`;a.style.height=`${e}px`;a.style.left=`${Math.round(n)}px`;h.appendChild(a);const c=a.getContext("2d");if(i.renderFunction){c.fillStyle=this.convertColorValues(i.waveColor,c);i.renderFunction(t,c)}else{this.renderWaveform(t,i,c)}if(a.width>0&&a.height>0){const t=a.cloneNode();const s=t.getContext("2d");s.drawImage(a,0,0);s.globalCompositeOperation="source-in";s.fillStyle=this.convertColorValues(i.progressColor,s);s.fillRect(0,0,a.width,a.height);r.appendChild(t)}}renderMultiCanvas(t,i,s,e,n,h){const r=this.getPixelRatio();const{clientWidth:o}=this.scrollContainer;const a=s/r;const c=B({clientWidth:o,totalWidth:a,options:i});let l={};if(c===0)return;const u=s=>{if(s<0||s>=f)return;if(l[s])return;l[s]=true;const r=s*c;let o=Math.min(a-r,c);o=$(o,i);if(o<=0)return;const u=Z({channelData:t,offset:r,clampedWidth:o,totalWidth:a});this.renderSingleCanvas(u,i,o,e,r,n,h)};const d=()=>{if(_(Object.keys(l).length)){n.innerHTML="";h.innerHTML="";l={}}};const f=Math.ceil(a/c);if(!this.isScrollable){for(let t=0;t<f;t++){u(t)}return}const v=G({scrollLeft:this.scrollContainer.scrollLeft,totalWidth:a,numCanvases:f});v.forEach((t=>u(t)));if(f>1){const t=this.on("scroll",(()=>{const{scrollLeft:t}=this.scrollContainer;d();G({scrollLeft:t,totalWidth:a,numCanvases:f}).forEach((t=>u(t)))}));this.unsubscribeOnScroll.push(t)}}renderChannel(t,i,s,e){var{overlay:n}=i,h=ht(i,["overlay"]);const r=document.createElement("div");const o=this.getHeight(h.height,h.splitChannels);r.style.height=`${o}px`;if(n&&e>0){r.style.marginTop=`-${o}px`}this.canvasWrapper.style.minHeight=`${o}px`;this.canvasWrapper.appendChild(r);const a=r.cloneNode();this.progressWrapper.appendChild(a);this.renderMultiCanvas(t,h,s,o,r,a)}render(t){return nt(this,void 0,void 0,(function*(){var i;this.timeouts.forEach((t=>t()));this.timeouts=[];this.unsubscribeOnScroll.forEach((t=>t()));this.unsubscribeOnScroll=[];this.canvasWrapper.innerHTML="";this.progressWrapper.innerHTML="";if(this.options.width!=null){this.scrollContainer.style.width=typeof this.options.width==="number"?`${this.options.width}px`:this.options.width}const s=this.getPixelRatio();const e=this.scrollContainer.clientWidth-this.containerInlinePadding;const{scrollWidth:n,isScrollable:h,useParentWidth:r,width:o}=F({duration:t.duration,minPxPerSec:this.options.minPxPerSec||0,parentWidth:e,fillParent:this.options.fillParent,pixelRatio:s});this.isScrollable=h;this.wrapper.style.width=r?"100%":`${n}px`;this.scrollContainer.style.overflowX=this.isScrollable?"auto":"hidden";this.scrollContainer.classList.toggle("noScrollbar",!!this.options.hideScrollbar);this.cursor.style.backgroundColor=`${this.options.cursorColor||this.options.progressColor}`;this.cursor.style.width=`${this.options.cursorWidth}px`;this.audioData=t;this.emit("render");if(this.options.splitChannels){for(let s=0;s<t.numberOfChannels;s++){const e=Object.assign(Object.assign({},this.options),(i=this.options.splitChannels)===null||i===void 0?void 0:i[s]);this.renderChannel([t.getChannelData(s)],e,o,s)}}else{const i=[t.getChannelData(0)];if(t.numberOfChannels>1)i.push(t.getChannelData(1));this.renderChannel(i,this.options,o,0)}Promise.resolve().then((()=>this.emit("rendered")))}))}reRender(){this.unsubscribeOnScroll.forEach((t=>t()));this.unsubscribeOnScroll=[];if(!this.audioData)return;const{scrollWidth:t}=this.scrollContainer;const{right:i}=this.progressWrapper.getBoundingClientRect();this.render(this.audioData);if(!this.isScrollable&&this.scrollContainer.scrollLeft){this.scrollContainer.scrollLeft=0}else if(this.isScrollable&&t!==this.scrollContainer.scrollWidth){const{right:t}=this.progressWrapper.getBoundingClientRect();const s=J(t-i);this.scrollContainer.scrollLeft+=s}}zoom(t){this.options.minPxPerSec=t;this.reRender()}scrollIntoView(t,i=false){var s;const{scrollLeft:e,scrollWidth:n,clientWidth:h}=this.scrollContainer;const r=t*n;const o=e;const a=e+h;const c=h/2;if(this.isDragging){const t=30;if(r+t>a){this.scrollContainer.scrollLeft+=t}else if(r-t<o){this.scrollContainer.scrollLeft-=t}}else{if(r<o||r>a){this.scrollContainer.scrollLeft=r-(this.options.autoCenter?c:0)}const t=r-e-c;if(i&&this.options.autoCenter&&t>0){const i=(s=this.audioData)===null||s===void 0?void 0:s.duration;if(i===undefined||i<=0){this.scrollContainer.scrollLeft+=t;return}const e=n/i;if(e<=at){this.scrollContainer.scrollLeft+=Math.min(t,ot)}else{this.scrollContainer.scrollLeft+=t}}}}renderProgress(t,i){if(isNaN(t))return;const s=t*100;this.canvasWrapper.style.clipPath=`polygon(${s}% 0%, 100% 0%, 100% 100%, ${s}% 100%)`;this.progressWrapper.style.width=`${s}%`;this.cursor.style.left=`${s}%`;this.cursor.style.transform=this.options.cursorWidth?`translateX(-${t*this.options.cursorWidth}px)`:"";if(this.isScrollable&&this.options.autoScroll&&this.audioData&&this.audioData.duration>0){this.scrollIntoView(t,i)}}exportImage(t,i,s){return nt(this,void 0,void 0,(function*(){const e=this.canvasWrapper.querySelectorAll("canvas");if(!e.length){throw new Error("No waveform data")}if(s==="dataURL"){const s=Array.from(e).map((s=>s.toDataURL(t,i)));return Promise.resolve(s)}return Promise.all(Array.from(e).map((s=>new Promise(((e,n)=>{s.toBlob((t=>{if(t){e(t)}else{n(new Error("Could not export image"))}}),t,i)})))))}))}}class lt extends u{constructor(){super(...arguments);this.animationFrameId=null;this.isRunning=false}start(){if(this.isRunning)return;this.isRunning=true;const t=()=>{if(!this.isRunning)return;this.emit("tick");this.animationFrameId=requestAnimationFrame(t)};t()}stop(){this.isRunning=false;if(this.animationFrameId!==null){cancelAnimationFrame(this.animationFrameId);this.animationFrameId=null}}destroy(){this.stop();this.unAll()}}var ut=undefined&&undefined.__awaiter||function(t,i,s,e){function n(t){return t instanceof s?t:new s((function(i){i(t)}))}return new(s||(s=Promise))((function(s,h){function r(t){try{a(e.next(t))}catch(t){h(t)}}function o(t){try{a(e["throw"](t))}catch(t){h(t)}}function a(t){t.done?s(t.value):n(t.value).then(r,o)}a((e=e.apply(t,i||[])).next())}))};function dt(){const t=globalThis.navigator;if(!(t===null||t===void 0?void 0:t.audioSession))return;try{t.audioSession.type="playback"}catch(t){console.warn("Setting navigator.audioSession.type failed:",t)}}class ft extends u{constructor(t){super();this.bufferNode=null;this.playStartTime=0;this.playbackPosition=0;this._muted=false;this._playbackRate=1;this._duration=undefined;this.buffer=null;this.currentSrc="";this.paused=true;this.crossOrigin=null;this.seeking=false;this.autoplay=false;this.addEventListener=this.on;this.removeEventListener=this.un;this._destroyed=false;dt();this.audioContext=t||new AudioContext;this.gainNode=this.audioContext.createGain();this.gainNode.connect(this.audioContext.destination)}load(){return ut(this,void 0,void 0,(function*(){return}))}remove(){this.destroy()}destroy(){if(this._destroyed)return;this._destroyed=true;this.currentSrc="";if(this.bufferNode){this.bufferNode.onended=null;try{this.bufferNode.stop()}catch(t){}this.bufferNode.disconnect();this.bufferNode=null}this.gainNode.disconnect();if(typeof this.audioContext.close==="function"){Promise.resolve(this.audioContext.close.call(this.audioContext)).catch((()=>undefined))}this.buffer=null;this.unAll()}get src(){return this.currentSrc}set src(t){this.currentSrc=t;this._duration=undefined;if(!t){this.buffer=null;this.emit("emptied");return}fetch(t).then((i=>{if(i.status>=400){throw new Error(`Failed to fetch ${t}: ${i.status} (${i.statusText})`)}return i.arrayBuffer()})).then((i=>{if(this.currentSrc!==t)return null;return this.audioContext.decodeAudioData(i)})).then((i=>{if(this.currentSrc!==t)return;this.buffer=i;this.emit("loadedmetadata");this.emit("canplay");if(this.autoplay)this.play()})).catch((t=>{console.error("WebAudioPlayer load error:",t)}))}_play(){if(!this.paused)return;this.paused=false;if(this.bufferNode){this.bufferNode.onended=null;this.bufferNode.disconnect()}this.bufferNode=this.audioContext.createBufferSource();if(this.buffer){this.bufferNode.buffer=this.buffer}this.bufferNode.playbackRate.value=this._playbackRate;this.bufferNode.connect(this.gainNode);let t=this.playbackPosition;if(t>=this.duration||t<0){t=0;this.playbackPosition=0}this.bufferNode.start(this.audioContext.currentTime,t);this.playStartTime=this.audioContext.currentTime;this.bufferNode.onended=()=>{if(!this.paused&&this.duration-this.currentTime<.01){this.pause();this.emit("ended")}}}_pause(){this.paused=true;if(this.bufferNode){this.bufferNode.onended=null;try{this.bufferNode.stop()}catch(t){}}this.playbackPosition+=(this.audioContext.currentTime-this.playStartTime)*this._playbackRate}play(){return ut(this,void 0,void 0,(function*(){if(!this.paused)return;this._play();this.emit("play")}))}pause(){if(this.paused)return;this._pause();this.emit("pause")}stopAt(t){const i=(t-this.currentTime)/this._playbackRate;const s=this.bufferNode;s===null||s===void 0?void 0:s.stop(this.audioContext.currentTime+i);s===null||s===void 0?void 0:s.addEventListener("ended",(()=>{if(s===this.bufferNode){this.bufferNode=null;this.pause();this.playbackPosition=Math.min(t,this.duration);this.emit("timeupdate")}}),{once:true})}setSinkId(t){return ut(this,void 0,void 0,(function*(){const i=this.audioContext;return i.setSinkId(t)}))}get playbackRate(){return this._playbackRate}set playbackRate(t){const i=!this.paused;if(i)this._pause();this._playbackRate=t;if(i)this._play();if(this.bufferNode){this.bufferNode.playbackRate.value=t}}get currentTime(){return this.paused?this.playbackPosition:this.playbackPosition+(this.audioContext.currentTime-this.playStartTime)*this._playbackRate}set currentTime(t){const i=!this.paused;if(i)this._pause();this.playbackPosition=t;if(i)this._play();this.emit("seeking");this.emit("timeupdate")}get duration(){var t,i;return(t=this._duration)!==null&&t!==void 0?t:((i=this.buffer)===null||i===void 0?void 0:i.duration)||0}set duration(t){this._duration=t}get volume(){return this.gainNode.gain.value}set volume(t){this.gainNode.gain.value=t;this.emit("volumechange")}get muted(){return this._muted}set muted(t){if(this._muted===t)return;this._muted=t;if(this._muted){this.gainNode.disconnect()}else{this.gainNode.connect(this.audioContext.destination)}}canPlayType(t){return/^(audio|video)\//.test(t)}getGainNode(){return this.gainNode}getChannelData(){const t=[];if(!this.buffer)return t;const i=this.buffer.numberOfChannels;for(let s=0;s<i;s++){t.push(this.buffer.getChannelData(s))}return t}removeAttribute(t){switch(t){case"src":this.src="";break;case"playbackRate":this.playbackRate=0;break;case"currentTime":this.currentTime=0;break;case"duration":this.duration=0;break;case"volume":this.volume=0;break;case"muted":this.muted=false;break}}}function vt(t){var i,s,e,n,h,r;const o=(i=t===null||t===void 0?void 0:t.currentTime)!==null&&i!==void 0?i:k(0);const a=(s=t===null||t===void 0?void 0:t.duration)!==null&&s!==void 0?s:k(0);const c=(e=t===null||t===void 0?void 0:t.isPlaying)!==null&&e!==void 0?e:k(false);const l=(n=t===null||t===void 0?void 0:t.isSeeking)!==null&&n!==void 0?n:k(false);const u=(h=t===null||t===void 0?void 0:t.volume)!==null&&h!==void 0?h:k(1);const d=(r=t===null||t===void 0?void 0:t.playbackRate)!==null&&r!==void 0?r:k(1);const f=k(null);const v=k(null);const p=k("");const g=k(0);const m=k(0);const b=j((()=>!c.value),[c]);const y=j((()=>f.value!==null),[f]);const M=j((()=>y.value&&a.value>0),[y,a]);const x=j((()=>o.value),[o]);const w=j((()=>a.value>0?o.value/a.value:0),[o,a]);const N={currentTime:o,duration:a,isPlaying:c,isPaused:b,isSeeking:l,volume:u,playbackRate:d,audioBuffer:f,peaks:v,url:p,zoom:g,scrollPosition:m,canPlay:y,isReady:M,progress:x,progressPercent:w};const T={setCurrentTime:t=>{const i=Math.max(0,Math.min(a.value||Infinity,t));o.set(i)},setDuration:t=>{a.set(Math.max(0,t))},setPlaying:t=>{c.set(t)},setSeeking:t=>{l.set(t)},setVolume:t=>{const i=Math.max(0,Math.min(1,t));u.set(i)},setPlaybackRate:t=>{const i=Math.max(.1,Math.min(16,t));d.set(i)},setAudioBuffer:t=>{f.set(t);if(t){a.set(t.duration)}},setPeaks:t=>{v.set(t)},setUrl:t=>{p.set(t)},setZoom:t=>{g.set(Math.max(0,t))},setScrollPosition:t=>{m.set(Math.max(0,t))}};return{state:N,actions:T}}var pt=undefined&&undefined.__awaiter||function(t,i,s,e){function n(t){return t instanceof s?t:new s((function(i){i(t)}))}return new(s||(s=Promise))((function(s,h){function r(t){try{a(e.next(t))}catch(t){h(t)}}function o(t){try{a(e["throw"](t))}catch(t){h(t)}}function a(t){t.done?s(t.value):n(t.value).then(r,o)}a((e=e.apply(t,i||[])).next())}))};const gt={waveColor:"#999",progressColor:"#555",cursorWidth:1,minPxPerSec:0,fillParent:true,interact:true,dragToSeek:false,autoScroll:true,autoCenter:true,sampleRate:8e3};class mt extends E{static create(t){return new mt(t)}getState(){return this.wavesurferState}getRenderer(){return this.renderer}constructor(t){const i=t.media||(t.backend==="WebAudio"?new ft:undefined);super({media:i,mediaControls:t.mediaControls,autoplay:t.autoplay,playbackRate:t.audioRate});this.plugins=[];this.decodedData=null;this.stopAtPosition=null;this.subscriptions=[];this.mediaSubscriptions=[];this.abortController=null;this._isDestroyed=false;this._loadVersion=0;this.options=Object.assign({},gt,t);const{state:s,actions:e}=vt({isPlaying:this.isPlayingSignal,currentTime:this.currentTimeSignal,duration:this.durationSignal,volume:this.volumeSignal,playbackRate:this.playbackRateSignal,isSeeking:this.seekingSignal});this.wavesurferState=s;this.wavesurferActions=e;this.timer=new lt;const n=i?undefined:this.getMediaElement();this.renderer=new ct(this.options,n);this.initPlayerEvents();this.initRendererEvents();this.initTimerEvents();this.initPlugins();const h=this.options.url||this.getSrc()||"";Promise.resolve().then((()=>{this.emit("init");const{peaks:t,duration:i}=this.options;if(h||t&&i){this.load(h,t,i).catch((()=>{}))}}))}updateProgress(t=this.getCurrentTime()){this.renderer.renderProgress(t/this.getDuration(),this.isPlaying());return t}initTimerEvents(){this.subscriptions.push(this.timer.on("tick",(()=>{if(!this.isSeeking()){const t=this.updateProgress();this.emit("timeupdate",t);this.emit("audioprocess",t);if(this.stopAtPosition!=null&&this.isPlaying()&&t>=this.stopAtPosition){const t=this.stopAtPosition;this.pause();this.setTime(t)}}})))}initPlayerEvents(){if(this.isPlaying()){this.emit("play");this.timer.start()}this.mediaSubscriptions.push(this.onMediaEvent("timeupdate",(()=>{const t=this.updateProgress();this.emit("timeupdate",t)})),this.onMediaEvent("play",(()=>{this.emit("play");this.timer.start()})),this.onMediaEvent("pause",(()=>{this.emit("pause");this.timer.stop();this.stopAtPosition=null})),this.onMediaEvent("emptied",(()=>{this.timer.stop();this.stopAtPosition=null})),this.onMediaEvent("ended",(()=>{this.emit("timeupdate",this.getDuration());this.emit("finish");this.stopAtPosition=null})),this.onMediaEvent("seeking",(()=>{this.emit("seeking",this.getCurrentTime())})),this.onMediaEvent("error",(()=>{var t;this.emit("error",(t=this.getMediaElement().error)!==null&&t!==void 0?t:new Error("Media error"));this.stopAtPosition=null})))}initRendererEvents(){this.subscriptions.push(this.renderer.on("click",((t,i)=>{if(this.options.interact){this.seekTo(t);this.emit("interaction",t*this.getDuration());this.emit("click",t,i)}})),this.renderer.on("dblclick",((t,i)=>{this.emit("dblclick",t,i)})),this.renderer.on("scroll",((t,i,s,e)=>{const n=this.getDuration();this.emit("scroll",t*n,i*n,s,e)})),this.renderer.on("render",(()=>{this.emit("redraw")})),this.renderer.on("rendered",(()=>{this.emit("redrawcomplete")})),this.renderer.on("dragstart",(t=>{this.emit("dragstart",t)})),this.renderer.on("dragend",(t=>{this.emit("dragend",t)})),this.renderer.on("resize",(()=>{this.emit("resize")})));{let t;const i=this.renderer.on("drag",(i=>{var s;if(!this.options.interact)return;this.renderer.renderProgress(i);clearTimeout(t);let e=0;const n=this.options.dragToSeek;if(this.isPlaying()){e=0}else if(n===true){e=200}else if(n&&typeof n==="object"){e=(s=n.debounceTime)!==null&&s!==void 0?s:200}t=setTimeout((()=>{this.seekTo(i)}),e);this.emit("interaction",i*this.getDuration());this.emit("drag",i)}));this.subscriptions.push((()=>{clearTimeout(t);i()}))}}initPlugins(){var t;if(!((t=this.options.plugins)===null||t===void 0?void 0:t.length))return;this.options.plugins.forEach((t=>{this.registerPlugin(t)}))}unsubscribePlayerEvents(){this.mediaSubscriptions.forEach((t=>t()));this.mediaSubscriptions=[]}setOptions(t){this.options=Object.assign({},this.options,t);if(t.duration&&!t.peaks){this.decodedData=m.createBuffer(this.exportPeaks(),t.duration)}if(t.peaks&&t.duration){this.decodedData=m.createBuffer(t.peaks,t.duration)}this.renderer.setOptions(this.options);if(t.audioRate){this.setPlaybackRate(t.audioRate)}if(t.mediaControls!=null){this.getMediaElement().controls=t.mediaControls}}registerPlugin(t){if(this.plugins.includes(t)){return t}t._init(this);this.plugins.push(t);const i=t.once("destroy",(()=>{this.plugins=this.plugins.filter((i=>i!==t));this.subscriptions=this.subscriptions.filter((t=>t!==i))}));this.subscriptions.push(i);return t}unregisterPlugin(t){this.plugins=this.plugins.filter((i=>i!==t));t.destroy()}getWrapper(){return this.renderer.getWrapper()}getWidth(){return this.renderer.getWidth()}getScroll(){return this.renderer.getScroll()}setScroll(t){return this.renderer.setScroll(t)}setScrollTime(t){const i=t/this.getDuration();this.renderer.setScrollPercentage(i)}getActivePlugins(){return this.plugins}loadAudio(t,i,s,e){return pt(this,void 0,void 0,(function*(){var n;const h=++this._loadVersion;this._isDestroyed=false;this.emit("load",t);if(!this.options.media&&this.isPlaying())this.pause();this.decodedData=null;this.stopAtPosition=null;(n=this.abortController)===null||n===void 0?void 0:n.abort();this.abortController=null;if(!i&&!s){const s=this.options.fetchParams||{};if(window.AbortController&&!s.signal){this.abortController=new AbortController;s.signal=this.abortController.signal}const e=t=>this.emit("loading",t);i=yield D.fetchBlob(t,e,s);if(this._isDestroyed||h!==this._loadVersion)return;const n=this.options.blobMimeType;if(n){i=new Blob([i],{type:n})}}if(this._isDestroyed||h!==this._loadVersion)return;this.setSrc(t,i);const r=yield new Promise((t=>{const i=e||this.getDuration();if(i){t(i)}else{this.mediaSubscriptions.push(this.onMediaEvent("loadedmetadata",(()=>t(this.getDuration())),{once:true}))}}));if(this._isDestroyed||h!==this._loadVersion)return;if(!t&&!i){const t=this.getMediaElement();if(t instanceof ft){t.duration=r}}if(s){this.decodedData=m.createBuffer(s,r||0)}else if(i){const t=yield i.arrayBuffer();if(this._isDestroyed||h!==this._loadVersion)return;this.decodedData=yield m.decode(t,this.options.sampleRate)}if(this._isDestroyed||h!==this._loadVersion)return;if(this.decodedData){this.emit("decode",this.getDuration());this.renderer.render(this.decodedData)}this.emit("ready",this.getDuration())}))}load(t,i,s){return pt(this,void 0,void 0,(function*(){try{return yield this.loadAudio(t,undefined,i,s)}catch(t){this.emit("error",t);throw t}}))}loadBlob(t,i,s){return pt(this,void 0,void 0,(function*(){try{return yield this.loadAudio("",t,i,s)}catch(t){this.emit("error",t);throw t}}))}zoom(t){if(!this.decodedData){throw new Error("No audio loaded")}this.renderer.zoom(t);this.emit("zoom",t)}getDecodedData(){return this.decodedData}exportPeaks({channels:t=2,maxLength:i=8e3,precision:s=1e4}={}){if(!this.decodedData){throw new Error("The audio has not been decoded yet")}const e=Math.min(t,this.decodedData.numberOfChannels);const n=[];for(let t=0;t<e;t++){const e=this.decodedData.getChannelData(t);const h=[];const r=e.length/i;for(let t=0;t<i;t++){const i=e.slice(Math.floor(t*r),Math.ceil((t+1)*r));let n=0;for(let t=0;t<i.length;t++){const s=i[t];if(Math.abs(s)>Math.abs(n))n=s}h.push(Math.round(n*s)/s)}n.push(h)}return n}getDuration(){let t=super.getDuration()||0;if((t===0||t===Infinity)&&this.decodedData){t=this.decodedData.duration}return t}toggleInteraction(t){this.options.interact=t}setTime(t){this.stopAtPosition=null;super.setTime(t);this.updateProgress(t);this.emit("timeupdate",t)}seekTo(t){const i=this.getDuration()*t;this.setTime(i)}play(t,i){const s=Object.create(null,{play:{get:()=>super.play}});return pt(this,void 0,void 0,(function*(){if(t!=null){this.setTime(t)}const e=yield s.play.call(this);if(i!=null){if(this.media instanceof ft){this.media.stopAt(i)}else{this.stopAtPosition=i}}return e}))}playPause(){return pt(this,void 0,void 0,(function*(){return this.isPlaying()?this.pause():this.play()}))}stop(){this.pause();this.setTime(0)}skip(t){this.setTime(this.getCurrentTime()+t)}empty(){this.load("",[[0]],.001)}setMediaElement(t){this.unsubscribePlayerEvents();super.setMediaElement(t);this.initPlayerEvents()}exportImage(){return pt(this,arguments,void 0,(function*(t="image/png",i=1,s="dataURL"){return this.renderer.exportImage(t,i,s)}))}destroy(){var t;this._isDestroyed=true;this.emit("destroy");(t=this.abortController)===null||t===void 0?void 0:t.abort();this.plugins.forEach((t=>t.destroy()));this.subscriptions.forEach((t=>t()));this.unsubscribePlayerEvents();this.timer.destroy();this.renderer.destroy();super.destroy()}}mt.BasePlugin=d;mt.dom=x;function bt(t,i,s,e){return new(s||(s=Promise))((function(n,h){function r(t){try{a(e.next(t))}catch(t){h(t)}}function o(t){try{a(e.throw(t))}catch(t){h(t)}}function a(t){var i;t.done?n(t.value):(i=t.value,i instanceof s?i:new s((function(t){t(i)}))).then(r,o)}a((e=e.apply(t,i||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;class yt{constructor(){this.listeners={}}on(t,i,s){if(this.listeners[t]||(this.listeners[t]=new Set),null==s?void 0:s.once){const s=(...e)=>{this.un(t,s),i(...e)};return this.listeners[t].add(s),()=>this.un(t,s)}return this.listeners[t].add(i),()=>this.un(t,i)}un(t,i){var s;null===(s=this.listeners[t])||void 0===s||s.delete(i)}once(t,i){return this.on(t,i,{once:!0})}unAll(){this.listeners={}}emit(t,...i){this.listeners[t]&&this.listeners[t].forEach((t=>t(...i)))}}class Mt extends yt{constructor(t){super(),this.subscriptions=[],this.isDestroyed=!1,this.options=t}onInit(){}_init(t){this.isDestroyed&&(this.subscriptions=[],this.isDestroyed=!1),this.wavesurfer=t,this.onInit()}destroy(){this.emit("destroy"),this.subscriptions.forEach((t=>t())),this.subscriptions=[],this.isDestroyed=!0,this.wavesurfer=void 0}}class xt extends yt{constructor(){super(...arguments),this.animationFrameId=null,this.isRunning=!1}start(){if(this.isRunning)return;this.isRunning=!0;const t=()=>{this.isRunning&&(this.emit("tick"),this.animationFrameId=requestAnimationFrame(t))};t()}stop(){this.isRunning=!1,null!==this.animationFrameId&&(cancelAnimationFrame(this.animationFrameId),this.animationFrameId=null)}destroy(){this.stop(),this.unAll()}}const wt=100,Nt=["audio/webm","audio/wav","audio/mpeg","audio/mp4","audio/mp3"];class Tt extends Mt{constructor(t){var i,s,e,n,h,r;super(Object.assign(Object.assign({},t),{audioBitsPerSecond:null!==(i=t.audioBitsPerSecond)&&void 0!==i?i:128e3,scrollingWaveform:null!==(s=t.scrollingWaveform)&&void 0!==s&&s,scrollingWaveformWindow:null!==(e=t.scrollingWaveformWindow)&&void 0!==e?e:5,continuousWaveform:null!==(n=t.continuousWaveform)&&void 0!==n&&n,renderRecordedAudio:null===(h=t.renderRecordedAudio)||void 0===h||h,mediaRecorderTimeslice:null!==(r=t.mediaRecorderTimeslice)&&void 0!==r?r:void 0})),this.stream=null,this.mediaRecorder=null,this.dataWindow=null,this.isWaveformPaused=!1,this.lastStartTime=0,this.lastDuration=0,this.duration=0,this.micStream=null,this.recordedBlobUrl=null,this.timer=new xt,this.subscriptions.push(this.timer.on("tick",(()=>{const t=performance.now()-this.lastStartTime;this.duration=this.isPaused()?this.duration:this.lastDuration+t,this.emit("record-progress",this.duration)})))}static create(t){return new Tt(t||{})}renderMicStream(t){var i;const s=new AudioContext,e=s.createMediaStreamSource(t),n=s.createAnalyser();e.connect(n),(this.options.continuousWaveform||this.options.scrollingWaveform)&&(n.fftSize=32);const h=n.frequencyBinCount,r=new Float32Array(h);let o=0;this.wavesurfer&&(null!==(i=this.originalOptions)&&void 0!==i||(this.originalOptions=Object.assign({},this.wavesurfer.options)),this.wavesurfer.options.interact=!1,this.options.scrollingWaveform&&(this.wavesurfer.options.cursorWidth=0,this.wavesurfer.options.normalize=!0,this.wavesurfer.options.maxPeak=1));const a=setInterval((()=>{var t,i,s,e;if(!this.isWaveformPaused){if(n.getFloatTimeDomainData(r),this.options.scrollingWaveform){const t=Math.floor((this.options.scrollingWaveformWindow||0)*wt);let i=0;for(let t=0;t<h;t++){const s=Math.abs(r[t]);s>i&&(i=s)}this.dataWindow||(this.dataWindow=new Float32Array(t));const s=new Float32Array(t);if(this.dataWindow&&this.dataWindow.length>0){const i=t-1,e=this.dataWindow.slice(-i);s.set(e,0)}s[t-1]=i,this.dataWindow=s}else if(this.options.continuousWaveform){if(!this.dataWindow){const s=this.options.continuousWaveformDuration?Math.round(this.options.continuousWaveformDuration*wt):(null!==(i=null===(t=this.wavesurfer)||void 0===t?void 0:t.getWidth())&&void 0!==i?i:0)*window.devicePixelRatio;this.dataWindow=new Float32Array(s)}let s=0;for(let t=0;t<h;t++){const i=Math.abs(r[t]);i>s&&(s=i)}if(o+1>this.dataWindow.length){const t=new Float32Array(2*this.dataWindow.length);t.set(this.dataWindow,0),this.dataWindow=t}this.dataWindow[o]=s,o++}else this.dataWindow=r;if(this.wavesurfer){const t=(null!==(e=null===(s=this.dataWindow)||void 0===s?void 0:s.length)&&void 0!==e?e:0)/wt;this.wavesurfer.load("",[this.dataWindow],this.options.scrollingWaveform?this.options.scrollingWaveformWindow:t).then((()=>{this.wavesurfer&&this.options.continuousWaveform&&(this.wavesurfer.setTime(this.getDuration()/1e3),this.wavesurfer.options.minPxPerSec||this.wavesurfer.setOptions({minPxPerSec:this.wavesurfer.getWidth()/this.wavesurfer.getDuration()}))})).catch((t=>{console.error("Error rendering real-time recording data:",t)}))}}}),10);return{onDestroy:()=>{clearInterval(a),null==e||e.disconnect(),null==s||s.close()},onEnd:()=>{this.isWaveformPaused=!0,this.stopMic()}}}startMic(t){return bt(this,void 0,void 0,(function*(){let i;this.micStream&&this.stopMic();try{i=yield navigator.mediaDevices.getUserMedia({audio:null==t||t})}catch(i){throw new Error("Error accessing the microphone: "+i.message)}const s=this.renderMicStream(i);return this.micStream=s,this.unsubscribeDestroy=this.once("destroy",s.onDestroy),this.unsubscribeRecordEnd=this.once("record-end",s.onEnd),this.stream=i,i}))}stopMic(){var t,i,s;null===(t=this.micStream)||void 0===t||t.onDestroy(),null===(i=this.unsubscribeDestroy)||void 0===i||i.call(this),null===(s=this.unsubscribeRecordEnd)||void 0===s||s.call(this),this.micStream=null,this.unsubscribeDestroy=void 0,this.unsubscribeRecordEnd=void 0,this.stream&&(this.stream.getTracks().forEach((t=>t.stop())),this.stream=null,this.mediaRecorder=null)}startRecording(t){return bt(this,void 0,void 0,(function*(){const i=this.stream||(yield this.startMic(t));this.dataWindow=null;const s=this.mediaRecorder||new MediaRecorder(i,{mimeType:this.options.mimeType||Nt.find((t=>MediaRecorder.isTypeSupported(t))),audioBitsPerSecond:this.options.audioBitsPerSecond});this.mediaRecorder=s,this.stopRecording();const e=[];s.ondataavailable=t=>{t.data.size>0&&e.push(t.data),this.emit("record-data-available",t.data)};const n=t=>{var i;const n=new Blob(e,{type:s.mimeType});this.emit(t,n),this.options.renderRecordedAudio&&(this.applyOriginalOptionsIfNeeded(),this.recordedBlobUrl&&URL.revokeObjectURL(this.recordedBlobUrl),this.recordedBlobUrl=URL.createObjectURL(n),null===(i=this.wavesurfer)||void 0===i||i.load(this.recordedBlobUrl))};s.onpause=()=>n("record-pause"),s.onstop=()=>n("record-end"),s.start(this.options.mediaRecorderTimeslice),this.lastStartTime=performance.now(),this.lastDuration=0,this.duration=0,this.isWaveformPaused=!1,this.timer.start(),this.emit("record-start")}))}getDuration(){return this.duration}isRecording(){var t;return"recording"===(null===(t=this.mediaRecorder)||void 0===t?void 0:t.state)}isPaused(){var t;return"paused"===(null===(t=this.mediaRecorder)||void 0===t?void 0:t.state)}isActive(){var t;return"inactive"!==(null===(t=this.mediaRecorder)||void 0===t?void 0:t.state)}stopRecording(){var t;this.isActive()&&(null===(t=this.mediaRecorder)||void 0===t||t.stop(),this.timer.stop())}pauseRecording(){var t,i;this.isRecording()&&(this.isWaveformPaused=!0,null===(t=this.mediaRecorder)||void 0===t||t.requestData(),null===(i=this.mediaRecorder)||void 0===i||i.pause(),this.timer.stop(),this.lastDuration=this.duration)}resumeRecording(){var t;this.isPaused()&&(this.isWaveformPaused=!1,null===(t=this.mediaRecorder)||void 0===t||t.resume(),this.timer.start(),this.lastStartTime=performance.now(),this.emit("record-resume"))}static getAvailableAudioDevices(){return bt(this,void 0,void 0,(function*(){return navigator.mediaDevices.enumerateDevices().then((t=>t.filter((t=>"audioinput"===t.kind))))}))}destroy(){this.applyOriginalOptionsIfNeeded(),super.destroy(),this.stopRecording(),this.stopMic(),this.recordedBlobUrl&&(URL.revokeObjectURL(this.recordedBlobUrl),this.recordedBlobUrl=null)}applyOriginalOptionsIfNeeded(){this.wavesurfer&&this.originalOptions&&(this.wavesurfer.setOptions(this.originalOptions),delete this.originalOptions)}}const Dt=class{constructor(s){t(this,s);this.recordingProgress=i(this,"recordingProgress",7);this.recordingError=i(this,"recordingError",7);this.wavesurfer=null;this.recordPlugin=null;this.waveformContainer=null;this.loadAbortController=null;this.currentLoadingUrl=null;this.initializationInterval=null;this.pauseAudioHandler=()=>{if(!this.wavesurfer)return;this.isPlaying=false;this.wavesurfer.pause();this.audioDuration=n(Math.round(this.wavesurfer.getDuration()))};this.playAudioHandler=()=>{if(!this.wavesurfer){const t=this.initWaveSurfer();if(t){this.wavesurfer.once("ready",(()=>{this.isPlaying=true;this.wavesurfer.play()}))}return}this.isPlaying=true;this.wavesurfer.play()};this.audioUrl=undefined;this.audioWaveColor="#C5C5C5";this.audioProgressColor="#4A76FD";this.textColor="#4A76FD";this.isSelf=false;this.borderRadius="";this.bgColor="";this.time="";this.isRead=false;this.isDelivered=false;this.showFooter=false;this.messageId="";this.timeColor="";this.reactions={};this.messageType=undefined;this.liveRecord=false;this.isPlaying=false;this.audioDuration="0:00";this.currentAudioId=null;this.waveformContainerReady=false;this.initializationAttempts=0}componentWillLoad(){if(typeof mt!=="function"){console.error("WaveSurfer is not available as a function. Import may be failing.")}}componentDidLoad(){if(this.liveRecord){void this.startLiveRecording();return}if(this.initializationInterval){clearInterval(this.initializationInterval)}this.initializationInterval=setInterval((()=>{this.initializationAttempts++;if(this.waveformContainer&&this.audioUrl){this.initWaveSurfer();if(this.wavesurfer){clearInterval(this.initializationInterval)}}if(this.initializationAttempts>=10){clearInterval(this.initializationInterval)}}),500)}resolveWaveColor(){const t=(this.audioProgressColor||this.audioWaveColor||"").trim();if(t&&!t.startsWith("var("))return t;const i=getComputedStyle(this.el).getPropertyValue("--brand").trim();return i||"#2563eb"}ensureRecordWaveSurfer(){var t;if(!((t=this.waveformContainer)===null||t===void 0?void 0:t.isConnected))return false;if(this.wavesurfer&&this.recordPlugin)return true;if(this.wavesurfer){this.wavesurfer.destroy();this.wavesurfer=null;this.recordPlugin=null}const i=Math.max(this.waveformContainer.clientWidth||0,this.el.clientWidth||0,160);const s=this.resolveWaveColor();this.wavesurfer=mt.create({container:this.waveformContainer,waveColor:s,progressColor:s,height:28,width:i,barWidth:2,barGap:2,barRadius:2,interact:false,cursorWidth:0});this.recordPlugin=this.wavesurfer.registerPlugin(Tt.create({scrollingWaveform:true,renderRecordedAudio:false}));this.recordPlugin.on("record-progress",(t=>{this.recordingProgress.emit(t);this.audioDuration=n(Math.round(t/1e3))}));return true}async startLiveRecording(){var t;try{for(let i=0;i<20;i++){if(((t=this.waveformContainer)===null||t===void 0?void 0:t.isConnected)&&(this.waveformContainer.clientWidth>0||this.el.clientWidth>0)){break}await new Promise((t=>requestAnimationFrame((()=>t(null)))))}if(!this.ensureRecordWaveSurfer()){this.recordingError.emit("Waveform not ready");return false}await this.recordPlugin.startRecording();requestAnimationFrame((()=>{var t;const i=((t=this.waveformContainer)===null||t===void 0?void 0:t.clientWidth)||this.el.clientWidth;if(i&&this.wavesurfer){try{this.wavesurfer.setOptions({width:i})}catch(t){}}}));return true}catch(t){console.error(t);this.recordingError.emit((t===null||t===void 0?void 0:t.message)||"Microphone access denied");return false}}async pauseLiveRecording(){var t;(t=this.recordPlugin)===null||t===void 0?void 0:t.pauseRecording()}async resumeLiveRecording(){var t;(t=this.recordPlugin)===null||t===void 0?void 0:t.resumeRecording()}async stopLiveRecording(){if(!this.recordPlugin)return null;if(!this.recordPlugin.isRecording()&&!this.recordPlugin.isPaused()){this.cleanupRecord();return null}return new Promise((t=>{const i=i=>{this.cleanupRecord();t(i)};this.recordPlugin.once("record-end",(t=>i(t||null)));try{this.recordPlugin.stopRecording()}catch(t){i(null)}}))}async cancelLiveRecording(){var t,i,s,e;try{if(((i=(t=this.recordPlugin)===null||t===void 0?void 0:t.isRecording)===null||i===void 0?void 0:i.call(t))||((e=(s=this.recordPlugin)===null||s===void 0?void 0:s.isPaused)===null||e===void 0?void 0:e.call(s))){this.recordPlugin.stopRecording()}}catch(t){}this.cleanupRecord()}cleanupRecord(){var t,i;try{(i=(t=this.recordPlugin)===null||t===void 0?void 0:t.stopMic)===null||i===void 0?void 0:i.call(t)}catch(t){}if(this.wavesurfer){try{this.wavesurfer.destroy()}catch(t){}}this.wavesurfer=null;this.recordPlugin=null}initWaveSurfer(){if(!this.waveformContainer){console.error("Waveform container reference is missing");return false}if(!this.waveformContainer.isConnected){console.error("Waveform container is not connected to DOM");return false}if(!this.audioUrl){console.error("Audio URL is missing");return false}try{this.abortCurrentLoad();if(this.wavesurfer){this.wavesurfer.destroy();this.wavesurfer=null}this.loadAbortController=new AbortController;this.currentLoadingUrl=this.audioUrl;this.wavesurfer=mt.create({container:this.waveformContainer,waveColor:this.isSelf?"#000000":this.audioWaveColor,progressColor:this.audioProgressColor,height:40,barHeight:1,barWidth:4,barRadius:3,barGap:4,normalize:true,sampleRate:6e4,fetchParams:{signal:this.loadAbortController.signal}});if(!this.wavesurfer){console.error("Failed to create WaveSurfer instance");return false}this.wavesurfer.load(this.audioUrl);this.wavesurfer.on("ready",(()=>{if(this.currentLoadingUrl===this.audioUrl){const t=this.wavesurfer.getDuration();const i=n(Math.round(t));this.audioDuration=i}}));this.wavesurfer.on("audioprocess",(()=>{const t=Math.max(0,this.wavesurfer.getDuration()-this.wavesurfer.getCurrentTime());this.audioDuration=n(Math.round(t))}));this.wavesurfer.on("finish",(()=>{this.isPlaying=false;this.wavesurfer.seekTo(0);this.audioDuration=n(Math.round(this.wavesurfer.getDuration()))}));this.wavesurfer.on("error",(t=>{if(t.name!=="AbortError"){console.error("WaveSurfer error:",t)}}));return true}catch(t){console.error("Error initializing WaveSurfer:",t);return false}}abortCurrentLoad(){if(this.loadAbortController){this.loadAbortController.abort();this.loadAbortController=null}this.currentLoadingUrl=null}disconnectedCallback(){this.abortCurrentLoad();this.cleanupRecord();if(this.wavesurfer){this.wavesurfer.destroy();this.wavesurfer=null}this.isPlaying=false;if(this.initializationInterval){clearInterval(this.initializationInterval)}}chatChanged(t,i){if(t!==i){if(this.wavesurfer&&this.isPlaying){this.wavesurfer.pause();this.isPlaying=false}this.audioDuration="0:00";setTimeout((()=>{if(this.waveformContainer&&t){this.initWaveSurfer()}}),100)}}render(){const t=this.liveRecord;return s("div",{key:"fcf59ce63746eac2c6b7bc88cd7a7e50e97fad4b",style:{background:t?"transparent":this.bgColor||(this.isSelf?"var(--bg-outgoing-message)":"var(--bg-incoming-message)"),borderRadius:t?"0":this.borderRadius||"7.5px",color:this.textColor||"inherit",padding:t?"0":"10px",width:t?"100%":"336px",maxWidth:"100%",boxSizing:"border-box"}},s("div",{key:"5d5c18d89fa32e40dfbdb8a04e38a00825fd74c4",style:{display:"flex",alignItems:"center",gap:t?"0":"10px",width:"100%"}},t?null:s("button",{type:"button","aria-label":this.isPlaying?"Pause":"Play",style:{border:"none",background:"transparent",cursor:"pointer",fontSize:"18px",color:"inherit"},onClick:()=>this.isPlaying?this.pauseAudioHandler():this.playAudioHandler()},this.isPlaying?"❚❚":"▶"),s("div",{key:"e2b865bfc959a3cbd2493e84946867ad1aea045f",class:"wave-host",ref:t=>{this.waveformContainer=t},style:{flex:"1",height:t?"28px":"40px",minHeight:t?"28px":"40px",minWidth:"0"}})),t?null:s("div",{style:{display:"flex",justifyContent:"space-between",fontSize:"10px",marginTop:"4px"}},s("span",null,this.audioDuration),this.showFooter?s("span",{style:{color:this.timeColor}},this.time?(()=>{try{const t=new Date(Number(this.time));if(Number.isNaN(t.getTime()))return this.time;return new Intl.DateTimeFormat("en-US",{hour:"2-digit",minute:"2-digit",hour12:true}).format(t)}catch(t){return this.time}})():"",this.isSelf?this.isRead?" ✓✓":this.isDelivered?" ✓✓":" ✓":""):null))}get el(){return e(this)}static get watchers(){return{audioUrl:["chatChanged"]}}};Dt.style=":host {\n display: block;\n width: 100%;\n height: 100%;\n min-width: 0;\n box-sizing: border-box;\n }\n .wave-host {\n width: 100%;\n height: 100%;\n min-width: 0;\n min-height: 28px;\n }";const kt="data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz48IS0tIFVwbG9hZGVkIHRvOiBTVkcgUmVwbywgd3d3LnN2Z3JlcG8uY29tLCBHZW5lcmF0b3I6IFNWRyBSZXBvIE1peGVyIFRvb2xzIC0tPgo8c3ZnIHdpZHRoPSI4MDBweCIgaGVpZ2h0PSI4MDBweCIgdmlld0JveD0iMCAwIDI0IDI0IiBmaWxsPSJub25lIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPgo8cGF0aCBkPSJNNS42MjUgMTVDNS42MjUgMTQuNTg1OCA1LjI4OTIxIDE0LjI1IDQuODc1IDE0LjI1QzQuNDYwNzkgMTQuMjUgNC4xMjUgMTQuNTg1OCA0LjEyNSAxNUg1LjYyNVpNNC44NzUgMTZINC4xMjVINC44NzVaTTE5LjI3NSAxNUMxOS4yNzUgMTQuNTg1OCAxOC45MzkyIDE0LjI1IDE4LjUyNSAxNC4yNUMxOC4xMTA4IDE0LjI1IDE3Ljc3NSAxNC41ODU4IDE3Ljc3NSAxNUgxOS4yNzVaTTExLjEwODYgMTUuNTM4N0MxMC44NTM5IDE1Ljg2NTMgMTAuOTEyMSAxNi4zMzY2IDExLjIzODcgMTYuNTkxNEMxMS41NjUzIDE2Ljg0NjEgMTIuMDM2NiAxNi43ODc5IDEyLjI5MTQgMTYuNDYxM0wxMS4xMDg2IDE1LjUzODdaTTE2LjE5MTQgMTEuNDYxM0MxNi40NDYxIDExLjEzNDcgMTYuMzg3OSAxMC42NjM0IDE2LjA2MTMgMTAuNDA4NkMxNS43MzQ3IDEwLjE1MzkgMTUuMjYzNCAxMC4yMTIxIDE1LjAwODYgMTAuNTM4N0wxNi4xOTE0IDExLjQ2MTNaTTExLjEwODYgMTYuNDYxM0MxMS4zNjM0IDE2Ljc4NzkgMTEuODM0NyAxNi44NDYxIDEyLjE2MTMgMTYuNTkxNEMxMi40ODc5IDE2LjMzNjYgMTIuNTQ2MSAxNS44NjUzIDEyLjI5MTQgMTUuNTM4N0wxMS4xMDg2IDE2LjQ2MTNaTTguMzkxMzggMTAuNTM4N0M4LjEzNjYyIDEwLjIxMjEgNy42NjUzMyAxMC4xNTM5IDcuMzM4NzMgMTAuNDA4NkM3LjAxMjEyIDEwLjY2MzQgNi45NTM4NyAxMS4xMzQ3IDcuMjA4NjIgMTEuNDYxM0w4LjM5MTM4IDEwLjUzODdaTTEwLjk1IDE2QzEwLjk1IDE2LjQxNDIgMTEuMjg1OCAxNi43NSAxMS43IDE2Ljc1QzEyLjExNDIgMTYuNzUgMTIuNDUgMTYuNDE0MiAxMi40NSAxNkgxMC45NVpNMTIuNDUgNUMxMi40NSA0LjU4NTc5IDEyLjExNDIgNC4yNSAxMS43IDQuMjVDMTEuMjg1OCA0LjI1IDEwLjk1IDQuNTg1NzkgMTAuOTUgNUgxMi40NVpNNC4xMjUgMTVWMTZINS42MjVWMTVINC4xMjVaTTQuMTI1IDE2QzQuMTI1IDE4LjA1MzEgNS43NTI1NyAxOS43NSA3LjggMTkuNzVWMTguMjVDNi42MTY1NyAxOC4yNSA1LjYyNSAxNy4yNjA3IDUuNjI1IDE2SDQuMTI1Wk03LjggMTkuNzVIMTUuNlYxOC4yNUg3LjhWMTkuNzVaTTE1LjYgMTkuNzVDMTcuNjQ3NCAxOS43NSAxOS4yNzUgMTguMDUzMSAxOS4yNzUgMTZIMTcuNzc1QzE3Ljc3NSAxNy4yNjA3IDE2Ljc4MzQgMTguMjUgMTUuNiAxOC4yNVYxOS43NVpNMTkuMjc1IDE2VjE1SDE3Ljc3NVYxNkgxOS4yNzVaTTEyLjI5MTQgMTYuNDYxM0wxNi4xOTE0IDExLjQ2MTNMMTUuMDA4NiAxMC41Mzg3TDExLjEwODYgMTUuNTM4N0wxMi4yOTE0IDE2LjQ2MTNaTTEyLjI5MTQgMTUuNTM4N0w4LjM5MTM4IDEwLjUzODdMNy4yMDg2MiAxMS40NjEzTDExLjEwODYgMTYuNDYxM0wxMi4yOTE0IDE1LjUzODdaTTEyLjQ1IDE2VjVIMTAuOTVWMTZIMTIuNDVaIiBmaWxsPSIjMDAwMDAwIi8+Cjwvc3ZnPg==";const jt=kt;const It=class{constructor(s){t(this,s);this.tagUserClick=i(this,"tagUserClick",7);this.bgColor=undefined;this.borderRadius="6px";this.padding="10px";this.docName=undefined;this.width=undefined;this.height=undefined;this.documentNameBg=undefined;this.documentNamePadding=undefined;this.time=undefined;this.href=undefined;this.fileName=undefined;this.isRead=undefined;this.isSelf=undefined;this.isDelivered=undefined;this.docType="";this.textColor=undefined;this.message=undefined;this.mentionedUsers=[];this.messageId=undefined;this.reactions={};this.userMetaData=undefined;this.messageType=undefined;this.timeColor=undefined;this.showReactionOnHover=false;this.borderWidth=undefined;this.borderColor=undefined;this.borderStyle=undefined}truncateDocName(t){const i=t.lastIndexOf(".");const s=i!==-1?t.slice(0,i):t;const e=i!==-1?t.slice(i):"";const n=40-e.length;if(s.length<=n){return{firstLine:s.slice(0,Math.min(20,s.length)),secondLine:`${s.slice(20)}${e}`}}const h=s.slice(0,n-3)+"...";return{firstLine:h.slice(0,20),secondLine:`${h.slice(20)}${e}`}}iconSrc(){const t=(this.docType||"").toLowerCase();const i=(this.docName||this.fileName||"").toLowerCase();if(t.includes("spreadsheet")||t.includes("excel")||/\.xlsx?$/.test(i)||i.endsWith(".csv"))return o;if(t.includes("rtf")||i.endsWith(".rtf"))return a;if(t.includes("text/plain")||i.endsWith(".txt"))return c;return l}render(){const t=this.truncateDocName(this.docName||"Document");const i=this.message&&!String(this.message).includes("AttachmentMessage:");return s("message-bubble",{key:"94fe5e9b944b8043f7d21da67d56bd0a94613377",isSelf:!!this.isSelf,time:this.time,timeColor:this.timeColor,isRead:this.isRead,isDelivered:this.isDelivered,reactions:this.reactions,messageId:this.messageId,userMetaData:this.userMetaData,isForwarded:this.messageType===1,backgroundColor:this.bgColor||"var(--bg-secondary)",borderRadius:this.borderRadius||"6px",padding:this.padding||"10px",showReactionOnHover:this.showReactionOnHover},s("div",{key:"1198854dd3aa5f18e73550e86053e77dbc936409",class:"doc-container",style:{backgroundColor:this.documentNameBg||"var(--bg-tertiary)",width:this.width||"auto"}},s("div",{key:"0aca7f3453dd4cb00f6105f1ca18d926d8efdf24",class:"document-name",style:{padding:this.documentNamePadding||"5px 10px 5px 0"}},s("span",{key:"b98bcb671c73ca6500c52249429f8303548d5a04",class:"attachment-icon"},s("img",{key:"b9a6c9ed0827994813dc5100236bb3ff74e927f2",src:this.iconSrc(),alt:""})),s("span",{key:"333f5385409b143f1232b6364485b6e84a1f8047"},t.firstLine,s("br",{key:"935710220f739f90eabb87ea6de85e81edeacd0e"}),t.secondLine)),s("a",{key:"6c3fd001ef1edec41f815dd11ce6c6a0fda7dad4",class:"download-btn",href:this.href,download:this.fileName,target:"_blank",rel:"noopener noreferrer","aria-label":"Download"},s("img",{key:"0fb2d7fda4c077b0b4da7effdf7190521fd28f20",src:jt,alt:""}))),i?s("div",{style:{fontSize:"8px",color:this.textColor,marginTop:"4px"}},h(this.message,this.mentionedUsers,(t=>r(this.tagUserClick,t)),!!this.isSelf)):null)}};It.style=":host { display: block; }\n .doc-container {\n display: flex; align-items: center; justify-content: space-between; gap: 8px;\n border-radius: 8px; padding: 4px 8px;\n }\n .document-name {\n display: flex; align-items: center; gap: 8px; word-break: break-word;\n font-size: 12px; line-height: 1.35;\n }\n .attachment-icon { display: flex; flex-shrink: 0; width: 24px; height: 30px; align-items: center; justify-content: center; }\n .attachment-icon img { width: 24px; height: 24px; object-fit: contain; display: block; }\n .download-btn {\n display: flex; align-items: center; justify-content: center;\n flex-shrink: 0; line-height: 0;\n }\n .download-btn img {\n width: 28px; height: 28px; display: block;\n filter: var(--svg-icon-filter);\n }";const St=class{constructor(s){t(this,s);this.tagUserClick=i(this,"tagUserClick",7);this.openGallery=t=>{var i;(i=this.onImageClick)===null||i===void 0?void 0:i.call(this,t);this.galleryOpen=true};this.bgColor=undefined;this.borderRadius="10px";this.padding="10px";this.imageSrc=undefined;this.message=undefined;this.height="220px";this.width="250px";this.time=undefined;this.isRead=undefined;this.isSelf=undefined;this.isDelivered=undefined;this.textColor=undefined;this.allAttachments=undefined;this.isMediaGalleryOpen=undefined;this.onImageClick=undefined;this.mentionedUsers=[];this.totalMedia=0;this.mediaType=undefined;this.loadingMediaGallery=undefined;this.messageId=undefined;this.reactions={};this.userMetaData=undefined;this.messageType=undefined;this.timeColor=undefined;this.showReactionOnHover=false;this.borderWidth=undefined;this.borderColor=undefined;this.borderStyle=undefined;this.galleryOpen=false}render(){const t=this.message&&!String(this.message).includes("AttachmentMessage:");return s("div",{key:"19c188f64d94fce0375cc619d9afbf208c3075b0"},s("message-bubble",{key:"3a00af150abc7d107a90e76458fafdfd3389c3b7",isSelf:!!this.isSelf,time:this.time,timeColor:this.timeColor,isRead:this.isRead,isDelivered:this.isDelivered,reactions:this.reactions,messageId:this.messageId,userMetaData:this.userMetaData,isForwarded:this.messageType===1,backgroundColor:this.bgColor,borderRadius:this.borderRadius||"10px",padding:this.padding||"10px",showReactionOnHover:this.showReactionOnHover},s("div",{key:"1484a65d6018059a0905be46028e740196ebff8e",class:"image-container",style:{width:this.width||"250px",height:this.height||"220px",borderRadius:this.borderRadius},onClick:this.openGallery},s("img",{key:"c49d11cf6f6f87141d5a8765cf9b4c256ffc3be5",src:this.imageSrc,alt:"image"}),this.totalMedia>0?s("span",{class:"mediaCount"}," + ",this.totalMedia):null),t?s("div",{style:{fontSize:"14px",color:this.textColor,marginTop:"4px"}},h(this.message,this.mentionedUsers,(t=>r(this.tagUserClick,t)),!!this.isSelf)):null),this.galleryOpen?s("div",{class:"gallery-overlay",onClick:()=>this.galleryOpen=false},s("button",{type:"button",class:"gallery-close","aria-label":"Close"},"×"),s("img",{src:this.imageSrc,alt:"full",onClick:t=>t.stopPropagation()})):null)}};St.style=":host { display: block; font-family: var(--font-primary); }\n .image-container { cursor: pointer; overflow: hidden; position: relative; }\n .image-container img { width: var(--w-full); height: var(--h-full); object-fit: cover; display: block; }\n .mediaCount {\n position: absolute; right: var(--space-8); bottom: var(--space-8);\n background: var(--overlay); color: var(--text-on-brand);\n padding: var(--gap-2) var(--gap-6); border-radius: var(--rounded-8); font-size: var(--text-12);\n }\n .gallery-overlay {\n position: fixed; inset: 0; background: var(--overlay); z-index: 9999;\n display: flex; align-items: center; justify-content: center;\n }\n .gallery-overlay img { max-width: 90vw; max-height: 90vh; object-fit: contain; }\n .gallery-close {\n position: absolute; top: var(--space-16); right: var(--space-16);\n color: var(--text-on-brand); font-size: var(--text-24);\n background: transparent; border: none; cursor: pointer;\n }";const Et=class{constructor(s){t(this,s);this.tagUserClick=i(this,"tagUserClick",7);this.playVideo=()=>{const t=this.videoEl();if(!t)return;t.play();this.isPlaying=true};this.pauseVideo=()=>{const t=this.videoEl();if(!t)return;t.pause();this.isPlaying=false};this.toggle=()=>this.isPlaying?this.pauseVideo():this.playVideo();this.fullscreen=()=>{var t;const i=this.videoEl();(t=i===null||i===void 0?void 0:i.requestFullscreen)===null||t===void 0?void 0:t.call(i)};this.bgColor=undefined;this.borderRadius="10px";this.padding="10px";this.videoSrc=undefined;this.videoType="video/mp4";this.time=undefined;this.height="150px";this.width="150px";this.playing=undefined;this.isRead=undefined;this.isSelf=undefined;this.isDelivered=undefined;this.textColor=undefined;this.message=undefined;this.mentionedUsers=[];this.messageId=undefined;this.reactions={};this.userMetaData=undefined;this.messageType=undefined;this.timeColor=undefined;this.showReactionOnHover=false;this.type=undefined;this.borderWidth=undefined;this.borderColor=undefined;this.borderStyle=undefined;this.isPlaying=false}videoEl(){var t;return((t=this.el.shadowRoot)===null||t===void 0?void 0:t.querySelector("video"))||null}render(){const t=this.message&&!String(this.message).includes("AttachmentMessage:");return s("message-bubble",{key:"53af459d4e8ca4043b42d7d8b9fa420bd6262d6c",isSelf:!!this.isSelf,time:this.time,timeColor:this.timeColor,isRead:this.isRead,isDelivered:this.isDelivered,reactions:this.reactions,messageId:this.messageId,userMetaData:this.userMetaData,isForwarded:this.messageType===1,backgroundColor:this.bgColor,borderRadius:this.borderRadius||"10px",padding:this.padding||"10px",showReactionOnHover:this.showReactionOnHover},s("div",{key:"56e1d8c7818bd520bf05af11df528cf4caf4bdd1",class:"video-wrap"},s("video",{key:"ee7fe48179d98574e8c5a0b0013fb8d41a4f87e0",style:{height:this.height||"150px",width:this.width||"150px",objectFit:"cover",borderRadius:this.borderRadius||"8px"},onClick:this.toggle},s("source",{key:"8a6cd53a2e83f2d95e55baedf4b0226435d1d785",src:this.videoSrc,type:this.videoType||"video/mp4"})),s("div",{key:"f6effc32d79d9c09dabdece9ecfb89959eca8e7d",class:"controls"},!this.isPlaying?s("button",{type:"button",onClick:this.playVideo,"aria-label":"Play"},"▶"):s("button",{type:"button",onClick:this.pauseVideo,"aria-label":"Pause"},"❚❚"),s("button",{key:"e9900ec1cbdce69521fb5cc5b1ff6d417d013dbf",type:"button",class:"video_fullscreen",onClick:this.fullscreen,"aria-label":"Fullscreen"},"⛶"))),t?s("div",{style:{fontSize:"14px",color:this.textColor,marginTop:"4px"}},h(this.message,this.mentionedUsers,(t=>r(this.tagUserClick,t)),!!this.isSelf)):null)}get el(){return e(this)}};Et.style=":host { display: block; position: relative; }\n .video-wrap { position: relative; width: fit-content; }\n .controls {\n position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; pointer-events: none;\n }\n .controls button {\n pointer-events: auto; border: none; background: var(--overlay); color: var(--text-on-brand);\n cursor: pointer; padding: 8px 10px; border-radius: 8px; margin: 0 4px;\n }\n .video_fullscreen { position: absolute; right: 8px; bottom: 8px; }";export{Dt as audio_bubble,It as document_message,St as image_message,Et as video_message};
|
|
2
|
-
//# sourceMappingURL=p-
|
|
1
|
+
import{r as t,a as i,h as s,g as e}from"./p-17a96a2a.js";import{h as n}from"./p-e5884258.js";import{r as h,e as r}from"./p-d28c5548.js";import{i as o,j as a,k as c,l}from"./p-d424871c.js";import"./p-f24cdbbb.js";class u{constructor(){this.listeners={}}on(t,i,s){if(!this.listeners[t]){this.listeners[t]=new Set}if(s===null||s===void 0?void 0:s.once){const s=(...e)=>{this.un(t,s);i(...e)};this.listeners[t].add(s);return()=>this.un(t,s)}this.listeners[t].add(i);return()=>this.un(t,i)}un(t,i){var s;(s=this.listeners[t])===null||s===void 0?void 0:s.delete(i)}once(t,i){return this.on(t,i,{once:true})}unAll(){this.listeners={}}emit(t,...i){if(this.listeners[t]){this.listeners[t].forEach((t=>t(...i)))}}}class d extends u{constructor(t){super();this.subscriptions=[];this.isDestroyed=false;this.options=t}onInit(){return}_init(t){if(this.isDestroyed){this.subscriptions=[];this.isDestroyed=false}this.wavesurfer=t;this.onInit()}destroy(){this.emit("destroy");this.subscriptions.forEach((t=>t()));this.subscriptions=[];this.isDestroyed=true;this.wavesurfer=undefined}}var f=undefined&&undefined.__awaiter||function(t,i,s,e){function n(t){return t instanceof s?t:new s((function(i){i(t)}))}return new(s||(s=Promise))((function(s,h){function r(t){try{a(e.next(t))}catch(t){h(t)}}function o(t){try{a(e["throw"](t))}catch(t){h(t)}}function a(t){t.done?s(t.value):n(t.value).then(r,o)}a((e=e.apply(t,i||[])).next())}))};function v(t,i){return f(this,void 0,void 0,(function*(){const s=new AudioContext({sampleRate:i});try{return yield s.decodeAudioData(t)}finally{if(s.state!=="closed"){yield s.close().catch((()=>undefined))}}}))}function p(t){const i=t[0];if(i.some((t=>t>1||t<-1))){const s=i.length;let e=0;for(let t=0;t<s;t++){const s=Math.abs(i[t]);if(s>e)e=s}for(const i of t){for(let t=0;t<s;t++){i[t]/=e}}}return t}function g(t,i){if(!t||t.length===0){throw new Error("channelData must be a non-empty array")}if(i<=0){throw new Error("duration must be greater than 0")}if(typeof t[0]==="number")t=[t];if(!t[0]||t[0].length===0){throw new Error("channelData must contain non-empty channel arrays")}p(t);const s=t.map((t=>t instanceof Float32Array?t:Float32Array.from(t)));return{duration:i,length:s[0].length,sampleRate:s[0].length/i,numberOfChannels:s.length,getChannelData:t=>{const i=s[t];if(!i){throw new Error(`Channel ${t} not found`)}return i},copyFromChannel:AudioBuffer.prototype.copyFromChannel,copyToChannel:AudioBuffer.prototype.copyToChannel}}const m={decode:v,createBuffer:g};function b(t,i){const s=i.xmlns?document.createElementNS(i.xmlns,t):document.createElement(t);for(const[t,e]of Object.entries(i)){if(t==="children"&&e){for(const[t,i]of Object.entries(e)){if(i instanceof Node){s.appendChild(i)}else if(typeof i==="string"){s.appendChild(document.createTextNode(i))}else{s.appendChild(b(t,i))}}}else if(t==="style"){Object.assign(s.style,e)}else if(t==="textContent"){s.textContent=e}else{s.setAttribute(t,e.toString())}}return s}function y(t,i,s){const e=b(t,i||{});s===null||s===void 0?void 0:s.appendChild(e);return e}function M(t){if(t instanceof HTMLElement)return true;return typeof t==="object"&&t!==null&&t.nodeType===Node.ELEMENT_NODE&&typeof t.style==="object"}const x=Object.freeze({__proto__:null,createElement:y,isHTMLElement:M,default:y});var w=undefined&&undefined.__awaiter||function(t,i,s,e){function n(t){return t instanceof s?t:new s((function(i){i(t)}))}return new(s||(s=Promise))((function(s,h){function r(t){try{a(e.next(t))}catch(t){h(t)}}function o(t){try{a(e["throw"](t))}catch(t){h(t)}}function a(t){t.done?s(t.value):n(t.value).then(r,o)}a((e=e.apply(t,i||[])).next())}))};function N(t,i,s){return w(this,void 0,void 0,(function*(){var e;if(!t.body||!t.headers)return;const n=t.body.getReader();const h=Number(t.headers.get("Content-Length"))||0;let r=0;const o=()=>{n.cancel()};if(s){if(s.aborted){n.cancel();return}s.addEventListener("abort",o,{once:true})}try{while(true){const t=yield n.read();if(t.done){break}r+=((e=t.value)===null||e===void 0?void 0:e.length)||0;if(h>0){const t=Math.round(r/h*100);i(t)}}}catch(t){if(t instanceof DOMException&&t.name==="AbortError")return;console.warn("Progress tracking error:",t)}finally{if(s){s.removeEventListener("abort",o)}}}))}function T(t,i,s){return w(this,void 0,void 0,(function*(){var e;const n=yield fetch(t,s);if(n.status>=400){throw new Error(`Failed to fetch ${t}: ${n.status} (${n.statusText})`)}N(n.clone(),i,(e=s===null||s===void 0?void 0:s.signal)!==null&&e!==void 0?e:undefined);return n.blob()}))}const D={fetchBlob:T};function k(t){let i=t;const s=new Set;return{get value(){return i},set(t){if(!Object.is(i,t)){i=t;s.forEach((t=>t(i)))}},update(t){this.set(t(i))},subscribe(t){s.add(t);return()=>s.delete(t)}}}function j(t,i){const s=k(t());i.forEach((i=>i.subscribe((()=>{const i=t();if(!Object.is(s.value,i)){s.set(i)}}))));return{get value(){return s.value},subscribe(t){return s.subscribe(t)}}}function I(t,i){let s;const e=()=>{if(s){s();s=undefined}s=t()};const n=i.map((t=>t.subscribe(e)));e();return()=>{if(s){s();s=undefined}n.forEach((t=>t()))}}var S=undefined&&undefined.__awaiter||function(t,i,s,e){function n(t){return t instanceof s?t:new s((function(i){i(t)}))}return new(s||(s=Promise))((function(s,h){function r(t){try{a(e.next(t))}catch(t){h(t)}}function o(t){try{a(e["throw"](t))}catch(t){h(t)}}function a(t){t.done?s(t.value):n(t.value).then(r,o)}a((e=e.apply(t,i||[])).next())}))};class E extends u{get isPlayingSignal(){return this._isPlaying}get currentTimeSignal(){return this._currentTime}get durationSignal(){return this._duration}get volumeSignal(){return this._volume}get mutedSignal(){return this._muted}get playbackRateSignal(){return this._playbackRate}get seekingSignal(){return this._seeking}constructor(t){super();this.isExternalMedia=false;this._ownBlobUrl=null;this.reactiveMediaEventCleanups=[];if(t.media){this.media=t.media;this.isExternalMedia=true}else{this.media=document.createElement("audio")}this._isPlaying=k(false);this._currentTime=k(0);this._duration=k(0);this._volume=k(this.media.volume);this._muted=k(this.media.muted);this._playbackRate=k(this.media.playbackRate||1);this._seeking=k(false);this.setupReactiveMediaEvents();if(t.mediaControls){this.media.controls=true}if(t.autoplay){this.media.autoplay=true}if(t.playbackRate!=null){this.onMediaEvent("canplay",(()=>{if(t.playbackRate!=null){this.media.playbackRate=t.playbackRate}}),{once:true})}}setupReactiveMediaEvents(){this.reactiveMediaEventCleanups.push(this.onMediaEvent("play",(()=>{this._isPlaying.set(true)})));this.reactiveMediaEventCleanups.push(this.onMediaEvent("pause",(()=>{this._isPlaying.set(false)})));this.reactiveMediaEventCleanups.push(this.onMediaEvent("ended",(()=>{this._isPlaying.set(false)})));this.reactiveMediaEventCleanups.push(this.onMediaEvent("timeupdate",(()=>{this._currentTime.set(this.media.currentTime)})));this.reactiveMediaEventCleanups.push(this.onMediaEvent("durationchange",(()=>{this._duration.set(this.media.duration||0)})));this.reactiveMediaEventCleanups.push(this.onMediaEvent("loadedmetadata",(()=>{this._duration.set(this.media.duration||0)})));this.reactiveMediaEventCleanups.push(this.onMediaEvent("seeking",(()=>{this._seeking.set(true)})));this.reactiveMediaEventCleanups.push(this.onMediaEvent("seeked",(()=>{this._seeking.set(false)})));this.reactiveMediaEventCleanups.push(this.onMediaEvent("volumechange",(()=>{this._volume.set(this.media.volume);this._muted.set(this.media.muted)})));this.reactiveMediaEventCleanups.push(this.onMediaEvent("ratechange",(()=>{this._playbackRate.set(this.media.playbackRate)})))}onMediaEvent(t,i,s){this.media.addEventListener(t,i,s);return()=>this.media.removeEventListener(t,i,s)}getSrc(){return this.media.currentSrc||this.media.src||""}revokeSrc(){if(this._ownBlobUrl){URL.revokeObjectURL(this._ownBlobUrl);this._ownBlobUrl=null}}canPlayType(t){return this.media.canPlayType(t)!==""}setSrc(t,i){const s=this.getSrc();if(t&&s===t)return;this.revokeSrc();const e=i instanceof Blob&&(this.canPlayType(i.type)||!t)?URL.createObjectURL(i):t;if(e!==t){this._ownBlobUrl=e}if(s){this.media.removeAttribute("src")}if(e||t){try{this.media.src=e}catch(i){this.media.src=t}}}destroy(){this.reactiveMediaEventCleanups.forEach((t=>t()));this.reactiveMediaEventCleanups=[];this.revokeSrc();this.unAll();if(this.isExternalMedia)return;this.media.pause();this.media.removeAttribute("src");this.media.load();this.media.remove()}setMediaElement(t){this.reactiveMediaEventCleanups.forEach((t=>t()));this.reactiveMediaEventCleanups=[];this.media=t;this.setupReactiveMediaEvents()}play(){return S(this,void 0,void 0,(function*(){try{return yield this.media.play()}catch(t){if(t instanceof DOMException&&t.name==="AbortError"){return}throw t}}))}pause(){this.media.pause()}isPlaying(){return!this.media.paused&&!this.media.ended}setTime(t){this.media.currentTime=Math.max(0,Math.min(t,this.getDuration()))}getDuration(){return this.media.duration}getCurrentTime(){return this.media.currentTime}getVolume(){return this.media.volume}setVolume(t){this.media.volume=t}getMuted(){return this.media.muted}setMuted(t){this.media.muted=t}getPlaybackRate(){return this.media.playbackRate}isSeeking(){return this.media.seeking}setPlaybackRate(t,i){if(i!=null){this.media.preservesPitch=i}this.media.playbackRate=t}getMediaElement(){return this.media}setSinkId(t){const i=this.media;return i.setSinkId(t)}}const A=128;const C=8e3;const L=10;function z(t){if(t<0)return 0;if(t>1)return 1;return t}function P({width:t,height:i,length:s,options:e,pixelRatio:n}){const h=i/2;const r=e.barWidth?e.barWidth*n:1;const o=e.barGap?e.barGap*n:e.barWidth?r/2:0;const a=e.barRadius||0;const c=e.barMinHeight?e.barMinHeight*n:0;const l=r+o||1;const u=s>0?t/l/s:0;return{halfHeight:h,barWidth:r,barGap:o,barRadius:a,barMinHeight:c,barIndexScale:u,barSpacing:l}}function O({maxTop:t,maxBottom:i,halfHeight:s,vScale:e,barMinHeight:n=0,barAlign:h}){let r=Math.round(t*s*e);const o=Math.round(i*s*e);let a=r+o||1;if(a<n){a=n;if(!h){r=a/2}}return{topHeight:r,totalHeight:a}}function R({barAlign:t,halfHeight:i,topHeight:s,totalHeight:e,canvasHeight:n}){if(t==="top")return 0;if(t==="bottom")return n-e;return i-s}function W({channelData:t,barIndexScale:i,barSpacing:s,barWidth:e,halfHeight:n,vScale:h,canvasHeight:r,barAlign:o,barMinHeight:a}){const c=t[0]||[];const l=t[1]||c;const u=c.length;const d=[];let f=0;let v=0;let p=0;for(let t=0;t<=u;t++){const u=Math.round(t*i);if(u>f){const{topHeight:t,totalHeight:i}=O({maxTop:v,maxBottom:p,halfHeight:n,vScale:h,barMinHeight:a,barAlign:o});const c=R({barAlign:o,halfHeight:n,topHeight:t,totalHeight:i,canvasHeight:r});d.push({x:f*s,y:c,width:e,height:i});f=u;v=0;p=0}const g=Math.abs(c[t]||0);const m=Math.abs(l[t]||0);if(g>v)v=g;if(m>p)p=m}return d}function U(t,i,s){const e=i-t.left;const n=s-t.top;const h=e/t.width;const r=n/t.height;return[h,r]}function H({optionsHeight:t,optionsSplitChannels:i,parentHeight:s,numberOfChannels:e,defaultHeight:n=A}){if(t==null)return n;const h=Number(t);if(!isNaN(h))return h;if(t==="auto"){const t=s||n;if(i===null||i===void 0?void 0:i.every((t=>!t.overlay))){return t/e}return t}return n}function V(t){return Math.max(1,t||1)}function Y(t){return Boolean(t.barWidth||t.barGap||t.barAlign)}function Q(t,i,s){if(!Array.isArray(t))return t||"";if(t.length===0)return"#999";if(t.length<2)return t[0]||"";const e=document.createElement("canvas");const n=e.getContext("2d");if(!n)return t[0]||"";const h=s||e.height*i;const r=n.createLinearGradient(0,0,0,h);const o=1/(t.length-1);t.forEach(((t,i)=>{r.addColorStop(i*o,t)}));return r}function F({duration:t,minPxPerSec:i=0,parentWidth:s,fillParent:e,pixelRatio:n}){const h=Math.ceil(t*i);const r=h>s;const o=Boolean(e&&!r);const a=(o?s:h)*n;return{scrollWidth:h,isScrollable:r,useParentWidth:o,width:a}}function $(t,i){if(!Y(i))return t;const s=i.barWidth||.5;const e=i.barGap||s/2;const n=s+e;if(n===0)return t;return Math.floor(t/n)*n}function B({clientWidth:t,totalWidth:i,options:s}){const e=Math.min(C,t,i);return $(e,s)}function Z({channelData:t,offset:i,clampedWidth:s,totalWidth:e}){return t.map((t=>{const n=Math.floor(i/e*t.length);const h=Math.floor((i+s)/e*t.length);return t.slice(n,h)}))}function _(t){return t>L}function G({scrollLeft:t,totalWidth:i,numCanvases:s}){if(i===0)return[0];const e=t/i;const n=Math.floor(e*s);return[n-1,n,n+1]}function X({channelData:t,barHeight:i,normalize:s,maxPeak:e}){var n;const h=i||1;if(!s)return h;const r=t[0];if(!r||r.length===0)return h;let o=e!==null&&e!==void 0?e:0;if(!e){for(let t=0;t<r.length;t++){const i=(n=r[t])!==null&&n!==void 0?n:0;const s=Math.abs(i);if(s>o)o=s}}if(!o)return h;return h/o}function q({channelData:t,width:i,height:s,vScale:e}){const n=s/2;const h=t[0]||[];const r=t[1]||h;const o=[h,r];return o.map(((t,s)=>{const h=t.length;const r=h?i/h:0;const o=n;const a=s===0?-1:1;const c=[{x:0,y:o}];let l=0;let u=0;for(let i=0;i<=h;i++){const s=Math.round(i*r);if(s>l){const t=Math.round(u*n*e)||1;const i=o+t*a;c.push({x:l,y:i});l=s;u=0}const h=Math.abs(t[i]||0);if(h>u)u=h}c.push({x:l,y:o});return c}))}function J(t){const i=t*2;const s=i<0?Math.floor(i):Math.ceil(i);return s/2}function K(t){const i=t._cleanup;if(typeof i==="function"){i()}}function tt(t,i={}){const{threshold:s=3,mouseButton:e=0,touchDelay:n=100}=i;const h=k(null);const r=new Map;const o=matchMedia("(pointer: coarse)").matches;let a=()=>void 0;const c=i=>{if(i.button!==e)return;if(r.has(i.pointerId))return;r.set(i.pointerId,i);if(r.size>1){return}const c=i.pointerId;let l=i.clientX;let u=i.clientY;let d=false;const f=Date.now();const v=t.getBoundingClientRect();const{left:p,top:g}=v;const m=t=>{if(t.pointerId!==c)return;if(t.defaultPrevented||r.size>1){return}if(o&&Date.now()-f<n)return;const i=t.clientX;const e=t.clientY;const a=i-l;const v=e-u;if(d||Math.abs(a)>s||Math.abs(v)>s){t.preventDefault();t.stopPropagation();if(!d){h.set({type:"start",x:l-p,y:u-g});d=true}h.set({type:"move",x:i-p,y:e-g,deltaX:a,deltaY:v});l=i;u=e}};const b=t=>{if(!r.delete(t.pointerId))return;if(t.pointerId===c&&d){const i=t.clientX;const s=t.clientY;h.set({type:"end",x:i-p,y:s-g})}if(r.size===0){a()}};const y=t=>{if(!t.relatedTarget||t.relatedTarget===document.documentElement){b(t)}};const M=t=>{if(d){t.stopPropagation();t.preventDefault()}};const x=t=>{if(t.defaultPrevented||r.size>1){return}if(d){t.preventDefault()}};document.addEventListener("pointermove",m);document.addEventListener("pointerup",b);document.addEventListener("pointerout",y);document.addEventListener("pointercancel",y);document.addEventListener("touchmove",x,{passive:false});document.addEventListener("click",M,{capture:true});a=()=>{document.removeEventListener("pointermove",m);document.removeEventListener("pointerup",b);document.removeEventListener("pointerout",y);document.removeEventListener("pointercancel",y);document.removeEventListener("touchmove",x);setTimeout((()=>{document.removeEventListener("click",M,{capture:true})}),10)}};t.addEventListener("pointerdown",c);const l=()=>{a();t.removeEventListener("pointerdown",c);r.clear();K(h)};return{signal:h,cleanup:l}}function it(t){const{scrollLeft:i,scrollWidth:s,clientWidth:e}=t;if(s===0){return{startX:0,endX:1}}const n=i/s;const h=(i+e)/s;return{startX:Math.max(0,Math.min(1,n)),endX:Math.max(0,Math.min(1,h))}}function st(t){return{left:t.scrollLeft,right:t.scrollLeft+t.clientWidth}}function et(t){const i=k({scrollLeft:t.scrollLeft,scrollWidth:t.scrollWidth,clientWidth:t.clientWidth});const s=j((()=>it(i.value)),[i]);const e=j((()=>st(i.value)),[i]);const n=()=>{i.set({scrollLeft:t.scrollLeft,scrollWidth:t.scrollWidth,clientWidth:t.clientWidth})};t.addEventListener("scroll",n,{passive:true});const h=()=>{t.removeEventListener("scroll",n);K(i)};return{scrollData:i,percentages:s,bounds:e,cleanup:h}}var nt=undefined&&undefined.__awaiter||function(t,i,s,e){function n(t){return t instanceof s?t:new s((function(i){i(t)}))}return new(s||(s=Promise))((function(s,h){function r(t){try{a(e.next(t))}catch(t){h(t)}}function o(t){try{a(e["throw"](t))}catch(t){h(t)}}function a(t){t.done?s(t.value):n(t.value).then(r,o)}a((e=e.apply(t,i||[])).next())}))};var ht=undefined&&undefined.__rest||function(t,i){var s={};for(var e in t)if(Object.prototype.hasOwnProperty.call(t,e)&&i.indexOf(e)<0)s[e]=t[e];if(t!=null&&typeof Object.getOwnPropertySymbols==="function")for(var n=0,e=Object.getOwnPropertySymbols(t);n<e.length;n++){if(i.indexOf(e[n])<0&&Object.prototype.propertyIsEnumerable.call(t,e[n]))s[e[n]]=t[e[n]]}return s};const rt=60;const ot=10;const at=ot*rt;class ct extends u{constructor(t,i){super();this.timeouts=[];this.isScrollable=false;this.audioData=null;this.resizeObserver=null;this.lastContainerWidth=0;this.isDragging=false;this.subscriptions=[];this.unsubscribeOnScroll=[];this.dragStream=null;this.scrollStream=null;this.containerInlinePadding=0;this.onClickWrapper=t=>{const i=this.wrapper.getBoundingClientRect();const[s,e]=U(i,t.clientX,t.clientY);this.emit("click",s,e)};this.onDblClickWrapper=t=>{const i=this.wrapper.getBoundingClientRect();const[s,e]=U(i,t.clientX,t.clientY);this.emit("dblclick",s,e)};this.subscriptions=[];this.options=t;const s=this.parentFromOptionsContainer(t.container);this.parent=s;const[e,n]=this.initHtml();s.appendChild(e);this.container=e;this.scrollContainer=n.querySelector(".scroll");this.wrapper=n.querySelector(".wrapper");this.canvasWrapper=n.querySelector(".canvases");this.progressWrapper=n.querySelector(".progress");this.cursor=n.querySelector(".cursor");this.calculateInlinePadding();if(i){n.appendChild(i)}this.initEvents()}parentFromOptionsContainer(t){let i;if(typeof t==="string"){i=document.querySelector(t)}else if(M(t)){i=t}if(!i){throw new Error("Container not found")}return i}initEvents(){this.wrapper.addEventListener("click",this.onClickWrapper);this.wrapper.addEventListener("dblclick",this.onDblClickWrapper);if(this.options.dragToSeek===true||typeof this.options.dragToSeek==="object"){this.initDrag()}this.scrollStream=et(this.scrollContainer);const t=I((()=>{const{startX:t,endX:i}=this.scrollStream.percentages.value;const{left:s,right:e}=this.scrollStream.bounds.value;this.emit("scroll",t,i,s,e)}),[this.scrollStream.percentages,this.scrollStream.bounds]);this.subscriptions.push(t);if(typeof ResizeObserver==="function"){const t=this.createDelay(100);this.resizeObserver=new ResizeObserver((()=>{t().then((()=>this.onContainerResize())).catch((()=>undefined))}));this.resizeObserver.observe(this.scrollContainer)}}onContainerResize(){const t=this.parent.clientWidth;this.calculateInlinePadding();if(t===this.lastContainerWidth&&this.options.height!=="auto")return;this.lastContainerWidth=t;this.reRender();this.emit("resize")}initDrag(){if(this.dragStream)return;this.dragStream=tt(this.wrapper);const t=I((()=>{const t=this.dragStream.signal.value;if(!t)return;const i=this.wrapper.getBoundingClientRect().width;const s=z(t.x/i);if(t.type==="start"){this.isDragging=true;this.emit("dragstart",s)}else if(t.type==="move"){this.emit("drag",s)}else if(t.type==="end"){this.isDragging=false;this.emit("dragend",s)}}),[this.dragStream.signal]);this.subscriptions.push(t)}calculateInlinePadding(){const{paddingLeft:t,paddingRight:i}=getComputedStyle(this.scrollContainer);const s=parseFloat(t)+parseFloat(i);this.containerInlinePadding=Number.isNaN(s)?0:s}initHtml(){const t=document.createElement("div");const i=t.attachShadow({mode:"open"});const s=this.options.cspNonce&&typeof this.options.cspNonce==="string"?this.options.cspNonce.replace(/"/g,""):"";i.innerHTML=`\n <style${s?` nonce="${s}"`:""}>\n :host {\n user-select: none;\n min-width: 1px;\n }\n :host audio {\n display: block;\n width: 100%;\n }\n :host .scroll {\n overflow-x: auto;\n overflow-y: hidden;\n width: 100%;\n position: relative;\n }\n :host .noScrollbar {\n scrollbar-color: transparent;\n scrollbar-width: none;\n }\n :host .noScrollbar::-webkit-scrollbar {\n display: none;\n -webkit-appearance: none;\n }\n :host .wrapper {\n position: relative;\n overflow: visible;\n z-index: 2;\n }\n :host .canvases {\n min-height: ${this.getHeight(this.options.height,this.options.splitChannels)}px;\n pointer-events: none;\n }\n :host .canvases > div {\n position: relative;\n }\n :host canvas {\n display: block;\n position: absolute;\n top: 0;\n image-rendering: pixelated;\n }\n :host .progress {\n pointer-events: none;\n position: absolute;\n z-index: 2;\n top: 0;\n left: 0;\n width: 0;\n height: 100%;\n overflow: hidden;\n }\n :host .progress > div {\n position: relative;\n }\n :host .cursor {\n pointer-events: none;\n position: absolute;\n z-index: 5;\n top: 0;\n left: 0;\n height: 100%;\n border-radius: 2px;\n }\n </style>\n\n <div class="scroll" part="scroll">\n <div class="wrapper" part="wrapper">\n <div class="canvases" part="canvases"></div>\n <div class="progress" part="progress"></div>\n <div class="cursor" part="cursor"></div>\n </div>\n </div>\n `;return[t,i]}setOptions(t){var i;if(this.options.container!==t.container){const i=this.parentFromOptionsContainer(t.container);i.appendChild(this.container);this.parent=i}if(t.dragToSeek===true||typeof this.options.dragToSeek==="object"){this.initDrag()}else{(i=this.dragStream)===null||i===void 0?void 0:i.cleanup();this.dragStream=null}this.options=t;this.reRender()}getWrapper(){return this.wrapper}getWidth(){return this.scrollContainer.clientWidth-this.containerInlinePadding}getScroll(){return this.scrollContainer.scrollLeft}setScroll(t){this.scrollContainer.scrollLeft=t}setScrollPercentage(t){const{scrollWidth:i}=this.scrollContainer;const s=i*t;this.setScroll(s)}destroy(){var t;this.wrapper.removeEventListener("click",this.onClickWrapper);this.wrapper.removeEventListener("dblclick",this.onDblClickWrapper);this.timeouts.forEach((t=>t()));this.timeouts=[];this.subscriptions.forEach((t=>t()));this.container.remove();if(this.resizeObserver){this.resizeObserver.disconnect();this.resizeObserver=null}(t=this.unsubscribeOnScroll)===null||t===void 0?void 0:t.forEach((t=>t()));this.unsubscribeOnScroll=[];if(this.dragStream){this.dragStream.cleanup();this.dragStream=null}if(this.scrollStream){this.scrollStream.cleanup();this.scrollStream=null}}createDelay(t=10){let i;let s;const e=()=>{if(i){clearTimeout(i);i=undefined}if(s){s();s=undefined}};this.timeouts.push(e);return()=>new Promise(((n,h)=>{e();s=h;i=setTimeout((()=>{i=undefined;s=undefined;n()}),t)}))}getHeight(t,i){var s;const e=((s=this.audioData)===null||s===void 0?void 0:s.numberOfChannels)||1;return H({optionsHeight:t,optionsSplitChannels:i,parentHeight:this.parent.clientHeight,numberOfChannels:e,defaultHeight:A})}convertColorValues(t,i){return Q(t,this.getPixelRatio(),i===null||i===void 0?void 0:i.canvas.height)}getPixelRatio(){return V(window.devicePixelRatio)}renderBarWaveform(t,i,s,e){const{width:n,height:h}=s.canvas;const{halfHeight:r,barWidth:o,barRadius:a,barIndexScale:c,barSpacing:l,barMinHeight:u}=P({width:n,height:h,length:(t[0]||[]).length,options:i,pixelRatio:this.getPixelRatio()});const d=W({channelData:t,barIndexScale:c,barSpacing:l,barWidth:o,halfHeight:r,vScale:e,canvasHeight:h,barAlign:i.barAlign,barMinHeight:u});s.beginPath();for(const t of d){if(a&&"roundRect"in s){s.roundRect(t.x,t.y,t.width,t.height,a)}else{s.rect(t.x,t.y,t.width,t.height)}}s.fill();s.closePath()}renderLineWaveform(t,i,s,e){const{width:n,height:h}=s.canvas;const r=q({channelData:t,width:n,height:h,vScale:e});s.beginPath();for(const t of r){if(!t.length)continue;s.moveTo(t[0].x,t[0].y);for(let i=1;i<t.length;i++){const e=t[i];s.lineTo(e.x,e.y)}}s.fill();s.closePath()}renderWaveform(t,i,s){s.fillStyle=this.convertColorValues(i.waveColor,s);if(i.renderFunction){i.renderFunction(t,s);return}const e=X({channelData:t,barHeight:i.barHeight,normalize:i.normalize,maxPeak:i.maxPeak});if(Y(i)){this.renderBarWaveform(t,i,s,e);return}this.renderLineWaveform(t,i,s,e)}renderSingleCanvas(t,i,s,e,n,h,r){const o=this.getPixelRatio();const a=document.createElement("canvas");a.width=Math.round(s*o);a.height=Math.round(e*o);a.style.width=`${s}px`;a.style.height=`${e}px`;a.style.left=`${Math.round(n)}px`;h.appendChild(a);const c=a.getContext("2d");if(i.renderFunction){c.fillStyle=this.convertColorValues(i.waveColor,c);i.renderFunction(t,c)}else{this.renderWaveform(t,i,c)}if(a.width>0&&a.height>0){const t=a.cloneNode();const s=t.getContext("2d");s.drawImage(a,0,0);s.globalCompositeOperation="source-in";s.fillStyle=this.convertColorValues(i.progressColor,s);s.fillRect(0,0,a.width,a.height);r.appendChild(t)}}renderMultiCanvas(t,i,s,e,n,h){const r=this.getPixelRatio();const{clientWidth:o}=this.scrollContainer;const a=s/r;const c=B({clientWidth:o,totalWidth:a,options:i});let l={};if(c===0)return;const u=s=>{if(s<0||s>=f)return;if(l[s])return;l[s]=true;const r=s*c;let o=Math.min(a-r,c);o=$(o,i);if(o<=0)return;const u=Z({channelData:t,offset:r,clampedWidth:o,totalWidth:a});this.renderSingleCanvas(u,i,o,e,r,n,h)};const d=()=>{if(_(Object.keys(l).length)){n.innerHTML="";h.innerHTML="";l={}}};const f=Math.ceil(a/c);if(!this.isScrollable){for(let t=0;t<f;t++){u(t)}return}const v=G({scrollLeft:this.scrollContainer.scrollLeft,totalWidth:a,numCanvases:f});v.forEach((t=>u(t)));if(f>1){const t=this.on("scroll",(()=>{const{scrollLeft:t}=this.scrollContainer;d();G({scrollLeft:t,totalWidth:a,numCanvases:f}).forEach((t=>u(t)))}));this.unsubscribeOnScroll.push(t)}}renderChannel(t,i,s,e){var{overlay:n}=i,h=ht(i,["overlay"]);const r=document.createElement("div");const o=this.getHeight(h.height,h.splitChannels);r.style.height=`${o}px`;if(n&&e>0){r.style.marginTop=`-${o}px`}this.canvasWrapper.style.minHeight=`${o}px`;this.canvasWrapper.appendChild(r);const a=r.cloneNode();this.progressWrapper.appendChild(a);this.renderMultiCanvas(t,h,s,o,r,a)}render(t){return nt(this,void 0,void 0,(function*(){var i;this.timeouts.forEach((t=>t()));this.timeouts=[];this.unsubscribeOnScroll.forEach((t=>t()));this.unsubscribeOnScroll=[];this.canvasWrapper.innerHTML="";this.progressWrapper.innerHTML="";if(this.options.width!=null){this.scrollContainer.style.width=typeof this.options.width==="number"?`${this.options.width}px`:this.options.width}const s=this.getPixelRatio();const e=this.scrollContainer.clientWidth-this.containerInlinePadding;const{scrollWidth:n,isScrollable:h,useParentWidth:r,width:o}=F({duration:t.duration,minPxPerSec:this.options.minPxPerSec||0,parentWidth:e,fillParent:this.options.fillParent,pixelRatio:s});this.isScrollable=h;this.wrapper.style.width=r?"100%":`${n}px`;this.scrollContainer.style.overflowX=this.isScrollable?"auto":"hidden";this.scrollContainer.classList.toggle("noScrollbar",!!this.options.hideScrollbar);this.cursor.style.backgroundColor=`${this.options.cursorColor||this.options.progressColor}`;this.cursor.style.width=`${this.options.cursorWidth}px`;this.audioData=t;this.emit("render");if(this.options.splitChannels){for(let s=0;s<t.numberOfChannels;s++){const e=Object.assign(Object.assign({},this.options),(i=this.options.splitChannels)===null||i===void 0?void 0:i[s]);this.renderChannel([t.getChannelData(s)],e,o,s)}}else{const i=[t.getChannelData(0)];if(t.numberOfChannels>1)i.push(t.getChannelData(1));this.renderChannel(i,this.options,o,0)}Promise.resolve().then((()=>this.emit("rendered")))}))}reRender(){this.unsubscribeOnScroll.forEach((t=>t()));this.unsubscribeOnScroll=[];if(!this.audioData)return;const{scrollWidth:t}=this.scrollContainer;const{right:i}=this.progressWrapper.getBoundingClientRect();this.render(this.audioData);if(!this.isScrollable&&this.scrollContainer.scrollLeft){this.scrollContainer.scrollLeft=0}else if(this.isScrollable&&t!==this.scrollContainer.scrollWidth){const{right:t}=this.progressWrapper.getBoundingClientRect();const s=J(t-i);this.scrollContainer.scrollLeft+=s}}zoom(t){this.options.minPxPerSec=t;this.reRender()}scrollIntoView(t,i=false){var s;const{scrollLeft:e,scrollWidth:n,clientWidth:h}=this.scrollContainer;const r=t*n;const o=e;const a=e+h;const c=h/2;if(this.isDragging){const t=30;if(r+t>a){this.scrollContainer.scrollLeft+=t}else if(r-t<o){this.scrollContainer.scrollLeft-=t}}else{if(r<o||r>a){this.scrollContainer.scrollLeft=r-(this.options.autoCenter?c:0)}const t=r-e-c;if(i&&this.options.autoCenter&&t>0){const i=(s=this.audioData)===null||s===void 0?void 0:s.duration;if(i===undefined||i<=0){this.scrollContainer.scrollLeft+=t;return}const e=n/i;if(e<=at){this.scrollContainer.scrollLeft+=Math.min(t,ot)}else{this.scrollContainer.scrollLeft+=t}}}}renderProgress(t,i){if(isNaN(t))return;const s=t*100;this.canvasWrapper.style.clipPath=`polygon(${s}% 0%, 100% 0%, 100% 100%, ${s}% 100%)`;this.progressWrapper.style.width=`${s}%`;this.cursor.style.left=`${s}%`;this.cursor.style.transform=this.options.cursorWidth?`translateX(-${t*this.options.cursorWidth}px)`:"";if(this.isScrollable&&this.options.autoScroll&&this.audioData&&this.audioData.duration>0){this.scrollIntoView(t,i)}}exportImage(t,i,s){return nt(this,void 0,void 0,(function*(){const e=this.canvasWrapper.querySelectorAll("canvas");if(!e.length){throw new Error("No waveform data")}if(s==="dataURL"){const s=Array.from(e).map((s=>s.toDataURL(t,i)));return Promise.resolve(s)}return Promise.all(Array.from(e).map((s=>new Promise(((e,n)=>{s.toBlob((t=>{if(t){e(t)}else{n(new Error("Could not export image"))}}),t,i)})))))}))}}class lt extends u{constructor(){super(...arguments);this.animationFrameId=null;this.isRunning=false}start(){if(this.isRunning)return;this.isRunning=true;const t=()=>{if(!this.isRunning)return;this.emit("tick");this.animationFrameId=requestAnimationFrame(t)};t()}stop(){this.isRunning=false;if(this.animationFrameId!==null){cancelAnimationFrame(this.animationFrameId);this.animationFrameId=null}}destroy(){this.stop();this.unAll()}}var ut=undefined&&undefined.__awaiter||function(t,i,s,e){function n(t){return t instanceof s?t:new s((function(i){i(t)}))}return new(s||(s=Promise))((function(s,h){function r(t){try{a(e.next(t))}catch(t){h(t)}}function o(t){try{a(e["throw"](t))}catch(t){h(t)}}function a(t){t.done?s(t.value):n(t.value).then(r,o)}a((e=e.apply(t,i||[])).next())}))};function dt(){const t=globalThis.navigator;if(!(t===null||t===void 0?void 0:t.audioSession))return;try{t.audioSession.type="playback"}catch(t){console.warn("Setting navigator.audioSession.type failed:",t)}}class ft extends u{constructor(t){super();this.bufferNode=null;this.playStartTime=0;this.playbackPosition=0;this._muted=false;this._playbackRate=1;this._duration=undefined;this.buffer=null;this.currentSrc="";this.paused=true;this.crossOrigin=null;this.seeking=false;this.autoplay=false;this.addEventListener=this.on;this.removeEventListener=this.un;this._destroyed=false;dt();this.audioContext=t||new AudioContext;this.gainNode=this.audioContext.createGain();this.gainNode.connect(this.audioContext.destination)}load(){return ut(this,void 0,void 0,(function*(){return}))}remove(){this.destroy()}destroy(){if(this._destroyed)return;this._destroyed=true;this.currentSrc="";if(this.bufferNode){this.bufferNode.onended=null;try{this.bufferNode.stop()}catch(t){}this.bufferNode.disconnect();this.bufferNode=null}this.gainNode.disconnect();if(typeof this.audioContext.close==="function"){Promise.resolve(this.audioContext.close.call(this.audioContext)).catch((()=>undefined))}this.buffer=null;this.unAll()}get src(){return this.currentSrc}set src(t){this.currentSrc=t;this._duration=undefined;if(!t){this.buffer=null;this.emit("emptied");return}fetch(t).then((i=>{if(i.status>=400){throw new Error(`Failed to fetch ${t}: ${i.status} (${i.statusText})`)}return i.arrayBuffer()})).then((i=>{if(this.currentSrc!==t)return null;return this.audioContext.decodeAudioData(i)})).then((i=>{if(this.currentSrc!==t)return;this.buffer=i;this.emit("loadedmetadata");this.emit("canplay");if(this.autoplay)this.play()})).catch((t=>{console.error("WebAudioPlayer load error:",t)}))}_play(){if(!this.paused)return;this.paused=false;if(this.bufferNode){this.bufferNode.onended=null;this.bufferNode.disconnect()}this.bufferNode=this.audioContext.createBufferSource();if(this.buffer){this.bufferNode.buffer=this.buffer}this.bufferNode.playbackRate.value=this._playbackRate;this.bufferNode.connect(this.gainNode);let t=this.playbackPosition;if(t>=this.duration||t<0){t=0;this.playbackPosition=0}this.bufferNode.start(this.audioContext.currentTime,t);this.playStartTime=this.audioContext.currentTime;this.bufferNode.onended=()=>{if(!this.paused&&this.duration-this.currentTime<.01){this.pause();this.emit("ended")}}}_pause(){this.paused=true;if(this.bufferNode){this.bufferNode.onended=null;try{this.bufferNode.stop()}catch(t){}}this.playbackPosition+=(this.audioContext.currentTime-this.playStartTime)*this._playbackRate}play(){return ut(this,void 0,void 0,(function*(){if(!this.paused)return;this._play();this.emit("play")}))}pause(){if(this.paused)return;this._pause();this.emit("pause")}stopAt(t){const i=(t-this.currentTime)/this._playbackRate;const s=this.bufferNode;s===null||s===void 0?void 0:s.stop(this.audioContext.currentTime+i);s===null||s===void 0?void 0:s.addEventListener("ended",(()=>{if(s===this.bufferNode){this.bufferNode=null;this.pause();this.playbackPosition=Math.min(t,this.duration);this.emit("timeupdate")}}),{once:true})}setSinkId(t){return ut(this,void 0,void 0,(function*(){const i=this.audioContext;return i.setSinkId(t)}))}get playbackRate(){return this._playbackRate}set playbackRate(t){const i=!this.paused;if(i)this._pause();this._playbackRate=t;if(i)this._play();if(this.bufferNode){this.bufferNode.playbackRate.value=t}}get currentTime(){return this.paused?this.playbackPosition:this.playbackPosition+(this.audioContext.currentTime-this.playStartTime)*this._playbackRate}set currentTime(t){const i=!this.paused;if(i)this._pause();this.playbackPosition=t;if(i)this._play();this.emit("seeking");this.emit("timeupdate")}get duration(){var t,i;return(t=this._duration)!==null&&t!==void 0?t:((i=this.buffer)===null||i===void 0?void 0:i.duration)||0}set duration(t){this._duration=t}get volume(){return this.gainNode.gain.value}set volume(t){this.gainNode.gain.value=t;this.emit("volumechange")}get muted(){return this._muted}set muted(t){if(this._muted===t)return;this._muted=t;if(this._muted){this.gainNode.disconnect()}else{this.gainNode.connect(this.audioContext.destination)}}canPlayType(t){return/^(audio|video)\//.test(t)}getGainNode(){return this.gainNode}getChannelData(){const t=[];if(!this.buffer)return t;const i=this.buffer.numberOfChannels;for(let s=0;s<i;s++){t.push(this.buffer.getChannelData(s))}return t}removeAttribute(t){switch(t){case"src":this.src="";break;case"playbackRate":this.playbackRate=0;break;case"currentTime":this.currentTime=0;break;case"duration":this.duration=0;break;case"volume":this.volume=0;break;case"muted":this.muted=false;break}}}function vt(t){var i,s,e,n,h,r;const o=(i=t===null||t===void 0?void 0:t.currentTime)!==null&&i!==void 0?i:k(0);const a=(s=t===null||t===void 0?void 0:t.duration)!==null&&s!==void 0?s:k(0);const c=(e=t===null||t===void 0?void 0:t.isPlaying)!==null&&e!==void 0?e:k(false);const l=(n=t===null||t===void 0?void 0:t.isSeeking)!==null&&n!==void 0?n:k(false);const u=(h=t===null||t===void 0?void 0:t.volume)!==null&&h!==void 0?h:k(1);const d=(r=t===null||t===void 0?void 0:t.playbackRate)!==null&&r!==void 0?r:k(1);const f=k(null);const v=k(null);const p=k("");const g=k(0);const m=k(0);const b=j((()=>!c.value),[c]);const y=j((()=>f.value!==null),[f]);const M=j((()=>y.value&&a.value>0),[y,a]);const x=j((()=>o.value),[o]);const w=j((()=>a.value>0?o.value/a.value:0),[o,a]);const N={currentTime:o,duration:a,isPlaying:c,isPaused:b,isSeeking:l,volume:u,playbackRate:d,audioBuffer:f,peaks:v,url:p,zoom:g,scrollPosition:m,canPlay:y,isReady:M,progress:x,progressPercent:w};const T={setCurrentTime:t=>{const i=Math.max(0,Math.min(a.value||Infinity,t));o.set(i)},setDuration:t=>{a.set(Math.max(0,t))},setPlaying:t=>{c.set(t)},setSeeking:t=>{l.set(t)},setVolume:t=>{const i=Math.max(0,Math.min(1,t));u.set(i)},setPlaybackRate:t=>{const i=Math.max(.1,Math.min(16,t));d.set(i)},setAudioBuffer:t=>{f.set(t);if(t){a.set(t.duration)}},setPeaks:t=>{v.set(t)},setUrl:t=>{p.set(t)},setZoom:t=>{g.set(Math.max(0,t))},setScrollPosition:t=>{m.set(Math.max(0,t))}};return{state:N,actions:T}}var pt=undefined&&undefined.__awaiter||function(t,i,s,e){function n(t){return t instanceof s?t:new s((function(i){i(t)}))}return new(s||(s=Promise))((function(s,h){function r(t){try{a(e.next(t))}catch(t){h(t)}}function o(t){try{a(e["throw"](t))}catch(t){h(t)}}function a(t){t.done?s(t.value):n(t.value).then(r,o)}a((e=e.apply(t,i||[])).next())}))};const gt={waveColor:"#999",progressColor:"#555",cursorWidth:1,minPxPerSec:0,fillParent:true,interact:true,dragToSeek:false,autoScroll:true,autoCenter:true,sampleRate:8e3};class mt extends E{static create(t){return new mt(t)}getState(){return this.wavesurferState}getRenderer(){return this.renderer}constructor(t){const i=t.media||(t.backend==="WebAudio"?new ft:undefined);super({media:i,mediaControls:t.mediaControls,autoplay:t.autoplay,playbackRate:t.audioRate});this.plugins=[];this.decodedData=null;this.stopAtPosition=null;this.subscriptions=[];this.mediaSubscriptions=[];this.abortController=null;this._isDestroyed=false;this._loadVersion=0;this.options=Object.assign({},gt,t);const{state:s,actions:e}=vt({isPlaying:this.isPlayingSignal,currentTime:this.currentTimeSignal,duration:this.durationSignal,volume:this.volumeSignal,playbackRate:this.playbackRateSignal,isSeeking:this.seekingSignal});this.wavesurferState=s;this.wavesurferActions=e;this.timer=new lt;const n=i?undefined:this.getMediaElement();this.renderer=new ct(this.options,n);this.initPlayerEvents();this.initRendererEvents();this.initTimerEvents();this.initPlugins();const h=this.options.url||this.getSrc()||"";Promise.resolve().then((()=>{this.emit("init");const{peaks:t,duration:i}=this.options;if(h||t&&i){this.load(h,t,i).catch((()=>{}))}}))}updateProgress(t=this.getCurrentTime()){this.renderer.renderProgress(t/this.getDuration(),this.isPlaying());return t}initTimerEvents(){this.subscriptions.push(this.timer.on("tick",(()=>{if(!this.isSeeking()){const t=this.updateProgress();this.emit("timeupdate",t);this.emit("audioprocess",t);if(this.stopAtPosition!=null&&this.isPlaying()&&t>=this.stopAtPosition){const t=this.stopAtPosition;this.pause();this.setTime(t)}}})))}initPlayerEvents(){if(this.isPlaying()){this.emit("play");this.timer.start()}this.mediaSubscriptions.push(this.onMediaEvent("timeupdate",(()=>{const t=this.updateProgress();this.emit("timeupdate",t)})),this.onMediaEvent("play",(()=>{this.emit("play");this.timer.start()})),this.onMediaEvent("pause",(()=>{this.emit("pause");this.timer.stop();this.stopAtPosition=null})),this.onMediaEvent("emptied",(()=>{this.timer.stop();this.stopAtPosition=null})),this.onMediaEvent("ended",(()=>{this.emit("timeupdate",this.getDuration());this.emit("finish");this.stopAtPosition=null})),this.onMediaEvent("seeking",(()=>{this.emit("seeking",this.getCurrentTime())})),this.onMediaEvent("error",(()=>{var t;this.emit("error",(t=this.getMediaElement().error)!==null&&t!==void 0?t:new Error("Media error"));this.stopAtPosition=null})))}initRendererEvents(){this.subscriptions.push(this.renderer.on("click",((t,i)=>{if(this.options.interact){this.seekTo(t);this.emit("interaction",t*this.getDuration());this.emit("click",t,i)}})),this.renderer.on("dblclick",((t,i)=>{this.emit("dblclick",t,i)})),this.renderer.on("scroll",((t,i,s,e)=>{const n=this.getDuration();this.emit("scroll",t*n,i*n,s,e)})),this.renderer.on("render",(()=>{this.emit("redraw")})),this.renderer.on("rendered",(()=>{this.emit("redrawcomplete")})),this.renderer.on("dragstart",(t=>{this.emit("dragstart",t)})),this.renderer.on("dragend",(t=>{this.emit("dragend",t)})),this.renderer.on("resize",(()=>{this.emit("resize")})));{let t;const i=this.renderer.on("drag",(i=>{var s;if(!this.options.interact)return;this.renderer.renderProgress(i);clearTimeout(t);let e=0;const n=this.options.dragToSeek;if(this.isPlaying()){e=0}else if(n===true){e=200}else if(n&&typeof n==="object"){e=(s=n.debounceTime)!==null&&s!==void 0?s:200}t=setTimeout((()=>{this.seekTo(i)}),e);this.emit("interaction",i*this.getDuration());this.emit("drag",i)}));this.subscriptions.push((()=>{clearTimeout(t);i()}))}}initPlugins(){var t;if(!((t=this.options.plugins)===null||t===void 0?void 0:t.length))return;this.options.plugins.forEach((t=>{this.registerPlugin(t)}))}unsubscribePlayerEvents(){this.mediaSubscriptions.forEach((t=>t()));this.mediaSubscriptions=[]}setOptions(t){this.options=Object.assign({},this.options,t);if(t.duration&&!t.peaks){this.decodedData=m.createBuffer(this.exportPeaks(),t.duration)}if(t.peaks&&t.duration){this.decodedData=m.createBuffer(t.peaks,t.duration)}this.renderer.setOptions(this.options);if(t.audioRate){this.setPlaybackRate(t.audioRate)}if(t.mediaControls!=null){this.getMediaElement().controls=t.mediaControls}}registerPlugin(t){if(this.plugins.includes(t)){return t}t._init(this);this.plugins.push(t);const i=t.once("destroy",(()=>{this.plugins=this.plugins.filter((i=>i!==t));this.subscriptions=this.subscriptions.filter((t=>t!==i))}));this.subscriptions.push(i);return t}unregisterPlugin(t){this.plugins=this.plugins.filter((i=>i!==t));t.destroy()}getWrapper(){return this.renderer.getWrapper()}getWidth(){return this.renderer.getWidth()}getScroll(){return this.renderer.getScroll()}setScroll(t){return this.renderer.setScroll(t)}setScrollTime(t){const i=t/this.getDuration();this.renderer.setScrollPercentage(i)}getActivePlugins(){return this.plugins}loadAudio(t,i,s,e){return pt(this,void 0,void 0,(function*(){var n;const h=++this._loadVersion;this._isDestroyed=false;this.emit("load",t);if(!this.options.media&&this.isPlaying())this.pause();this.decodedData=null;this.stopAtPosition=null;(n=this.abortController)===null||n===void 0?void 0:n.abort();this.abortController=null;if(!i&&!s){const s=this.options.fetchParams||{};if(window.AbortController&&!s.signal){this.abortController=new AbortController;s.signal=this.abortController.signal}const e=t=>this.emit("loading",t);i=yield D.fetchBlob(t,e,s);if(this._isDestroyed||h!==this._loadVersion)return;const n=this.options.blobMimeType;if(n){i=new Blob([i],{type:n})}}if(this._isDestroyed||h!==this._loadVersion)return;this.setSrc(t,i);const r=yield new Promise((t=>{const i=e||this.getDuration();if(i){t(i)}else{this.mediaSubscriptions.push(this.onMediaEvent("loadedmetadata",(()=>t(this.getDuration())),{once:true}))}}));if(this._isDestroyed||h!==this._loadVersion)return;if(!t&&!i){const t=this.getMediaElement();if(t instanceof ft){t.duration=r}}if(s){this.decodedData=m.createBuffer(s,r||0)}else if(i){const t=yield i.arrayBuffer();if(this._isDestroyed||h!==this._loadVersion)return;this.decodedData=yield m.decode(t,this.options.sampleRate)}if(this._isDestroyed||h!==this._loadVersion)return;if(this.decodedData){this.emit("decode",this.getDuration());this.renderer.render(this.decodedData)}this.emit("ready",this.getDuration())}))}load(t,i,s){return pt(this,void 0,void 0,(function*(){try{return yield this.loadAudio(t,undefined,i,s)}catch(t){this.emit("error",t);throw t}}))}loadBlob(t,i,s){return pt(this,void 0,void 0,(function*(){try{return yield this.loadAudio("",t,i,s)}catch(t){this.emit("error",t);throw t}}))}zoom(t){if(!this.decodedData){throw new Error("No audio loaded")}this.renderer.zoom(t);this.emit("zoom",t)}getDecodedData(){return this.decodedData}exportPeaks({channels:t=2,maxLength:i=8e3,precision:s=1e4}={}){if(!this.decodedData){throw new Error("The audio has not been decoded yet")}const e=Math.min(t,this.decodedData.numberOfChannels);const n=[];for(let t=0;t<e;t++){const e=this.decodedData.getChannelData(t);const h=[];const r=e.length/i;for(let t=0;t<i;t++){const i=e.slice(Math.floor(t*r),Math.ceil((t+1)*r));let n=0;for(let t=0;t<i.length;t++){const s=i[t];if(Math.abs(s)>Math.abs(n))n=s}h.push(Math.round(n*s)/s)}n.push(h)}return n}getDuration(){let t=super.getDuration()||0;if((t===0||t===Infinity)&&this.decodedData){t=this.decodedData.duration}return t}toggleInteraction(t){this.options.interact=t}setTime(t){this.stopAtPosition=null;super.setTime(t);this.updateProgress(t);this.emit("timeupdate",t)}seekTo(t){const i=this.getDuration()*t;this.setTime(i)}play(t,i){const s=Object.create(null,{play:{get:()=>super.play}});return pt(this,void 0,void 0,(function*(){if(t!=null){this.setTime(t)}const e=yield s.play.call(this);if(i!=null){if(this.media instanceof ft){this.media.stopAt(i)}else{this.stopAtPosition=i}}return e}))}playPause(){return pt(this,void 0,void 0,(function*(){return this.isPlaying()?this.pause():this.play()}))}stop(){this.pause();this.setTime(0)}skip(t){this.setTime(this.getCurrentTime()+t)}empty(){this.load("",[[0]],.001)}setMediaElement(t){this.unsubscribePlayerEvents();super.setMediaElement(t);this.initPlayerEvents()}exportImage(){return pt(this,arguments,void 0,(function*(t="image/png",i=1,s="dataURL"){return this.renderer.exportImage(t,i,s)}))}destroy(){var t;this._isDestroyed=true;this.emit("destroy");(t=this.abortController)===null||t===void 0?void 0:t.abort();this.plugins.forEach((t=>t.destroy()));this.subscriptions.forEach((t=>t()));this.unsubscribePlayerEvents();this.timer.destroy();this.renderer.destroy();super.destroy()}}mt.BasePlugin=d;mt.dom=x;function bt(t,i,s,e){return new(s||(s=Promise))((function(n,h){function r(t){try{a(e.next(t))}catch(t){h(t)}}function o(t){try{a(e.throw(t))}catch(t){h(t)}}function a(t){var i;t.done?n(t.value):(i=t.value,i instanceof s?i:new s((function(t){t(i)}))).then(r,o)}a((e=e.apply(t,i||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;class yt{constructor(){this.listeners={}}on(t,i,s){if(this.listeners[t]||(this.listeners[t]=new Set),null==s?void 0:s.once){const s=(...e)=>{this.un(t,s),i(...e)};return this.listeners[t].add(s),()=>this.un(t,s)}return this.listeners[t].add(i),()=>this.un(t,i)}un(t,i){var s;null===(s=this.listeners[t])||void 0===s||s.delete(i)}once(t,i){return this.on(t,i,{once:!0})}unAll(){this.listeners={}}emit(t,...i){this.listeners[t]&&this.listeners[t].forEach((t=>t(...i)))}}class Mt extends yt{constructor(t){super(),this.subscriptions=[],this.isDestroyed=!1,this.options=t}onInit(){}_init(t){this.isDestroyed&&(this.subscriptions=[],this.isDestroyed=!1),this.wavesurfer=t,this.onInit()}destroy(){this.emit("destroy"),this.subscriptions.forEach((t=>t())),this.subscriptions=[],this.isDestroyed=!0,this.wavesurfer=void 0}}class xt extends yt{constructor(){super(...arguments),this.animationFrameId=null,this.isRunning=!1}start(){if(this.isRunning)return;this.isRunning=!0;const t=()=>{this.isRunning&&(this.emit("tick"),this.animationFrameId=requestAnimationFrame(t))};t()}stop(){this.isRunning=!1,null!==this.animationFrameId&&(cancelAnimationFrame(this.animationFrameId),this.animationFrameId=null)}destroy(){this.stop(),this.unAll()}}const wt=100,Nt=["audio/webm","audio/wav","audio/mpeg","audio/mp4","audio/mp3"];class Tt extends Mt{constructor(t){var i,s,e,n,h,r;super(Object.assign(Object.assign({},t),{audioBitsPerSecond:null!==(i=t.audioBitsPerSecond)&&void 0!==i?i:128e3,scrollingWaveform:null!==(s=t.scrollingWaveform)&&void 0!==s&&s,scrollingWaveformWindow:null!==(e=t.scrollingWaveformWindow)&&void 0!==e?e:5,continuousWaveform:null!==(n=t.continuousWaveform)&&void 0!==n&&n,renderRecordedAudio:null===(h=t.renderRecordedAudio)||void 0===h||h,mediaRecorderTimeslice:null!==(r=t.mediaRecorderTimeslice)&&void 0!==r?r:void 0})),this.stream=null,this.mediaRecorder=null,this.dataWindow=null,this.isWaveformPaused=!1,this.lastStartTime=0,this.lastDuration=0,this.duration=0,this.micStream=null,this.recordedBlobUrl=null,this.timer=new xt,this.subscriptions.push(this.timer.on("tick",(()=>{const t=performance.now()-this.lastStartTime;this.duration=this.isPaused()?this.duration:this.lastDuration+t,this.emit("record-progress",this.duration)})))}static create(t){return new Tt(t||{})}renderMicStream(t){var i;const s=new AudioContext,e=s.createMediaStreamSource(t),n=s.createAnalyser();e.connect(n),(this.options.continuousWaveform||this.options.scrollingWaveform)&&(n.fftSize=32);const h=n.frequencyBinCount,r=new Float32Array(h);let o=0;this.wavesurfer&&(null!==(i=this.originalOptions)&&void 0!==i||(this.originalOptions=Object.assign({},this.wavesurfer.options)),this.wavesurfer.options.interact=!1,this.options.scrollingWaveform&&(this.wavesurfer.options.cursorWidth=0,this.wavesurfer.options.normalize=!0,this.wavesurfer.options.maxPeak=1));const a=setInterval((()=>{var t,i,s,e;if(!this.isWaveformPaused){if(n.getFloatTimeDomainData(r),this.options.scrollingWaveform){const t=Math.floor((this.options.scrollingWaveformWindow||0)*wt);let i=0;for(let t=0;t<h;t++){const s=Math.abs(r[t]);s>i&&(i=s)}this.dataWindow||(this.dataWindow=new Float32Array(t));const s=new Float32Array(t);if(this.dataWindow&&this.dataWindow.length>0){const i=t-1,e=this.dataWindow.slice(-i);s.set(e,0)}s[t-1]=i,this.dataWindow=s}else if(this.options.continuousWaveform){if(!this.dataWindow){const s=this.options.continuousWaveformDuration?Math.round(this.options.continuousWaveformDuration*wt):(null!==(i=null===(t=this.wavesurfer)||void 0===t?void 0:t.getWidth())&&void 0!==i?i:0)*window.devicePixelRatio;this.dataWindow=new Float32Array(s)}let s=0;for(let t=0;t<h;t++){const i=Math.abs(r[t]);i>s&&(s=i)}if(o+1>this.dataWindow.length){const t=new Float32Array(2*this.dataWindow.length);t.set(this.dataWindow,0),this.dataWindow=t}this.dataWindow[o]=s,o++}else this.dataWindow=r;if(this.wavesurfer){const t=(null!==(e=null===(s=this.dataWindow)||void 0===s?void 0:s.length)&&void 0!==e?e:0)/wt;this.wavesurfer.load("",[this.dataWindow],this.options.scrollingWaveform?this.options.scrollingWaveformWindow:t).then((()=>{this.wavesurfer&&this.options.continuousWaveform&&(this.wavesurfer.setTime(this.getDuration()/1e3),this.wavesurfer.options.minPxPerSec||this.wavesurfer.setOptions({minPxPerSec:this.wavesurfer.getWidth()/this.wavesurfer.getDuration()}))})).catch((t=>{console.error("Error rendering real-time recording data:",t)}))}}}),10);return{onDestroy:()=>{clearInterval(a),null==e||e.disconnect(),null==s||s.close()},onEnd:()=>{this.isWaveformPaused=!0,this.stopMic()}}}startMic(t){return bt(this,void 0,void 0,(function*(){let i;this.micStream&&this.stopMic();try{i=yield navigator.mediaDevices.getUserMedia({audio:null==t||t})}catch(i){throw new Error("Error accessing the microphone: "+i.message)}const s=this.renderMicStream(i);return this.micStream=s,this.unsubscribeDestroy=this.once("destroy",s.onDestroy),this.unsubscribeRecordEnd=this.once("record-end",s.onEnd),this.stream=i,i}))}stopMic(){var t,i,s;null===(t=this.micStream)||void 0===t||t.onDestroy(),null===(i=this.unsubscribeDestroy)||void 0===i||i.call(this),null===(s=this.unsubscribeRecordEnd)||void 0===s||s.call(this),this.micStream=null,this.unsubscribeDestroy=void 0,this.unsubscribeRecordEnd=void 0,this.stream&&(this.stream.getTracks().forEach((t=>t.stop())),this.stream=null,this.mediaRecorder=null)}startRecording(t){return bt(this,void 0,void 0,(function*(){const i=this.stream||(yield this.startMic(t));this.dataWindow=null;const s=this.mediaRecorder||new MediaRecorder(i,{mimeType:this.options.mimeType||Nt.find((t=>MediaRecorder.isTypeSupported(t))),audioBitsPerSecond:this.options.audioBitsPerSecond});this.mediaRecorder=s,this.stopRecording();const e=[];s.ondataavailable=t=>{t.data.size>0&&e.push(t.data),this.emit("record-data-available",t.data)};const n=t=>{var i;const n=new Blob(e,{type:s.mimeType});this.emit(t,n),this.options.renderRecordedAudio&&(this.applyOriginalOptionsIfNeeded(),this.recordedBlobUrl&&URL.revokeObjectURL(this.recordedBlobUrl),this.recordedBlobUrl=URL.createObjectURL(n),null===(i=this.wavesurfer)||void 0===i||i.load(this.recordedBlobUrl))};s.onpause=()=>n("record-pause"),s.onstop=()=>n("record-end"),s.start(this.options.mediaRecorderTimeslice),this.lastStartTime=performance.now(),this.lastDuration=0,this.duration=0,this.isWaveformPaused=!1,this.timer.start(),this.emit("record-start")}))}getDuration(){return this.duration}isRecording(){var t;return"recording"===(null===(t=this.mediaRecorder)||void 0===t?void 0:t.state)}isPaused(){var t;return"paused"===(null===(t=this.mediaRecorder)||void 0===t?void 0:t.state)}isActive(){var t;return"inactive"!==(null===(t=this.mediaRecorder)||void 0===t?void 0:t.state)}stopRecording(){var t;this.isActive()&&(null===(t=this.mediaRecorder)||void 0===t||t.stop(),this.timer.stop())}pauseRecording(){var t,i;this.isRecording()&&(this.isWaveformPaused=!0,null===(t=this.mediaRecorder)||void 0===t||t.requestData(),null===(i=this.mediaRecorder)||void 0===i||i.pause(),this.timer.stop(),this.lastDuration=this.duration)}resumeRecording(){var t;this.isPaused()&&(this.isWaveformPaused=!1,null===(t=this.mediaRecorder)||void 0===t||t.resume(),this.timer.start(),this.lastStartTime=performance.now(),this.emit("record-resume"))}static getAvailableAudioDevices(){return bt(this,void 0,void 0,(function*(){return navigator.mediaDevices.enumerateDevices().then((t=>t.filter((t=>"audioinput"===t.kind))))}))}destroy(){this.applyOriginalOptionsIfNeeded(),super.destroy(),this.stopRecording(),this.stopMic(),this.recordedBlobUrl&&(URL.revokeObjectURL(this.recordedBlobUrl),this.recordedBlobUrl=null)}applyOriginalOptionsIfNeeded(){this.wavesurfer&&this.originalOptions&&(this.wavesurfer.setOptions(this.originalOptions),delete this.originalOptions)}}const Dt=class{constructor(s){t(this,s);this.recordingProgress=i(this,"recordingProgress",7);this.recordingError=i(this,"recordingError",7);this.wavesurfer=null;this.recordPlugin=null;this.waveformContainer=null;this.loadAbortController=null;this.currentLoadingUrl=null;this.initializationInterval=null;this.pauseAudioHandler=()=>{if(!this.wavesurfer)return;this.isPlaying=false;this.wavesurfer.pause();this.audioDuration=n(Math.round(this.wavesurfer.getDuration()))};this.playAudioHandler=()=>{if(!this.wavesurfer){const t=this.initWaveSurfer();if(t){this.wavesurfer.once("ready",(()=>{this.isPlaying=true;this.wavesurfer.play()}))}return}this.isPlaying=true;this.wavesurfer.play()};this.audioUrl=undefined;this.audioWaveColor="#C5C5C5";this.audioProgressColor="#4A76FD";this.textColor="#4A76FD";this.isSelf=false;this.borderRadius="";this.bgColor="";this.time="";this.isRead=false;this.isDelivered=false;this.showFooter=false;this.messageId="";this.timeColor="";this.reactions={};this.messageType=undefined;this.liveRecord=false;this.isPlaying=false;this.audioDuration="0:00";this.currentAudioId=null;this.waveformContainerReady=false;this.initializationAttempts=0}componentWillLoad(){if(typeof mt!=="function"){console.error("WaveSurfer is not available as a function. Import may be failing.")}}componentDidLoad(){if(this.liveRecord){void this.startLiveRecording();return}if(this.initializationInterval){clearInterval(this.initializationInterval)}this.initializationInterval=setInterval((()=>{this.initializationAttempts++;if(this.waveformContainer&&this.audioUrl){this.initWaveSurfer();if(this.wavesurfer){clearInterval(this.initializationInterval)}}if(this.initializationAttempts>=10){clearInterval(this.initializationInterval)}}),500)}resolveWaveColor(){const t=(this.audioProgressColor||this.audioWaveColor||"").trim();if(t&&!t.startsWith("var("))return t;const i=getComputedStyle(this.el).getPropertyValue("--brand").trim();return i||"#2563eb"}ensureRecordWaveSurfer(){var t;if(!((t=this.waveformContainer)===null||t===void 0?void 0:t.isConnected))return false;if(this.wavesurfer&&this.recordPlugin)return true;if(this.wavesurfer){this.wavesurfer.destroy();this.wavesurfer=null;this.recordPlugin=null}const i=Math.max(this.waveformContainer.clientWidth||0,this.el.clientWidth||0,160);const s=this.resolveWaveColor();this.wavesurfer=mt.create({container:this.waveformContainer,waveColor:s,progressColor:s,height:28,width:i,barWidth:2,barGap:2,barRadius:2,interact:false,cursorWidth:0});this.recordPlugin=this.wavesurfer.registerPlugin(Tt.create({scrollingWaveform:true,renderRecordedAudio:false}));this.recordPlugin.on("record-progress",(t=>{this.recordingProgress.emit(t);this.audioDuration=n(Math.round(t/1e3))}));return true}async startLiveRecording(){var t;try{for(let i=0;i<20;i++){if(((t=this.waveformContainer)===null||t===void 0?void 0:t.isConnected)&&(this.waveformContainer.clientWidth>0||this.el.clientWidth>0)){break}await new Promise((t=>requestAnimationFrame((()=>t(null)))))}if(!this.ensureRecordWaveSurfer()){this.recordingError.emit("Waveform not ready");return false}await this.recordPlugin.startRecording();requestAnimationFrame((()=>{var t;const i=((t=this.waveformContainer)===null||t===void 0?void 0:t.clientWidth)||this.el.clientWidth;if(i&&this.wavesurfer){try{this.wavesurfer.setOptions({width:i})}catch(t){}}}));return true}catch(t){console.error(t);this.recordingError.emit((t===null||t===void 0?void 0:t.message)||"Microphone access denied");return false}}async pauseLiveRecording(){var t;(t=this.recordPlugin)===null||t===void 0?void 0:t.pauseRecording()}async resumeLiveRecording(){var t;(t=this.recordPlugin)===null||t===void 0?void 0:t.resumeRecording()}async stopLiveRecording(){if(!this.recordPlugin)return null;if(!this.recordPlugin.isRecording()&&!this.recordPlugin.isPaused()){this.cleanupRecord();return null}return new Promise((t=>{const i=i=>{this.cleanupRecord();t(i)};this.recordPlugin.once("record-end",(t=>i(t||null)));try{this.recordPlugin.stopRecording()}catch(t){i(null)}}))}async cancelLiveRecording(){var t,i,s,e;try{if(((i=(t=this.recordPlugin)===null||t===void 0?void 0:t.isRecording)===null||i===void 0?void 0:i.call(t))||((e=(s=this.recordPlugin)===null||s===void 0?void 0:s.isPaused)===null||e===void 0?void 0:e.call(s))){this.recordPlugin.stopRecording()}}catch(t){}this.cleanupRecord()}cleanupRecord(){var t,i;try{(i=(t=this.recordPlugin)===null||t===void 0?void 0:t.stopMic)===null||i===void 0?void 0:i.call(t)}catch(t){}if(this.wavesurfer){try{this.wavesurfer.destroy()}catch(t){}}this.wavesurfer=null;this.recordPlugin=null}initWaveSurfer(){if(!this.waveformContainer){console.error("Waveform container reference is missing");return false}if(!this.waveformContainer.isConnected){console.error("Waveform container is not connected to DOM");return false}if(!this.audioUrl){console.error("Audio URL is missing");return false}try{this.abortCurrentLoad();if(this.wavesurfer){this.wavesurfer.destroy();this.wavesurfer=null}this.loadAbortController=new AbortController;this.currentLoadingUrl=this.audioUrl;this.wavesurfer=mt.create({container:this.waveformContainer,waveColor:this.isSelf?"#000000":this.audioWaveColor,progressColor:this.audioProgressColor,height:40,barHeight:1,barWidth:4,barRadius:3,barGap:4,normalize:true,sampleRate:6e4,fetchParams:{signal:this.loadAbortController.signal}});if(!this.wavesurfer){console.error("Failed to create WaveSurfer instance");return false}this.wavesurfer.load(this.audioUrl);this.wavesurfer.on("ready",(()=>{if(this.currentLoadingUrl===this.audioUrl){const t=this.wavesurfer.getDuration();const i=n(Math.round(t));this.audioDuration=i}}));this.wavesurfer.on("audioprocess",(()=>{const t=Math.max(0,this.wavesurfer.getDuration()-this.wavesurfer.getCurrentTime());this.audioDuration=n(Math.round(t))}));this.wavesurfer.on("finish",(()=>{this.isPlaying=false;this.wavesurfer.seekTo(0);this.audioDuration=n(Math.round(this.wavesurfer.getDuration()))}));this.wavesurfer.on("error",(t=>{if(t.name!=="AbortError"){console.error("WaveSurfer error:",t)}}));return true}catch(t){console.error("Error initializing WaveSurfer:",t);return false}}abortCurrentLoad(){if(this.loadAbortController){this.loadAbortController.abort();this.loadAbortController=null}this.currentLoadingUrl=null}disconnectedCallback(){this.abortCurrentLoad();this.cleanupRecord();if(this.wavesurfer){this.wavesurfer.destroy();this.wavesurfer=null}this.isPlaying=false;if(this.initializationInterval){clearInterval(this.initializationInterval)}}chatChanged(t,i){if(t!==i){if(this.wavesurfer&&this.isPlaying){this.wavesurfer.pause();this.isPlaying=false}this.audioDuration="0:00";setTimeout((()=>{if(this.waveformContainer&&t){this.initWaveSurfer()}}),100)}}render(){const t=this.liveRecord;return s("div",{key:"fcf59ce63746eac2c6b7bc88cd7a7e50e97fad4b",style:{background:t?"transparent":this.bgColor||(this.isSelf?"var(--bg-outgoing-message)":"var(--bg-incoming-message)"),borderRadius:t?"0":this.borderRadius||"7.5px",color:this.textColor||"inherit",padding:t?"0":"10px",width:t?"100%":"336px",maxWidth:"100%",boxSizing:"border-box"}},s("div",{key:"5d5c18d89fa32e40dfbdb8a04e38a00825fd74c4",style:{display:"flex",alignItems:"center",gap:t?"0":"10px",width:"100%"}},t?null:s("button",{type:"button","aria-label":this.isPlaying?"Pause":"Play",style:{border:"none",background:"transparent",cursor:"pointer",fontSize:"18px",color:"inherit"},onClick:()=>this.isPlaying?this.pauseAudioHandler():this.playAudioHandler()},this.isPlaying?"❚❚":"▶"),s("div",{key:"e2b865bfc959a3cbd2493e84946867ad1aea045f",class:"wave-host",ref:t=>{this.waveformContainer=t},style:{flex:"1",height:t?"28px":"40px",minHeight:t?"28px":"40px",minWidth:"0"}})),t?null:s("div",{style:{display:"flex",justifyContent:"space-between",fontSize:"10px",marginTop:"4px"}},s("span",null,this.audioDuration),this.showFooter?s("span",{style:{color:this.timeColor}},this.time?(()=>{try{const t=new Date(Number(this.time));if(Number.isNaN(t.getTime()))return this.time;return new Intl.DateTimeFormat("en-US",{hour:"2-digit",minute:"2-digit",hour12:true}).format(t)}catch(t){return this.time}})():"",this.isSelf?this.isRead?" ✓✓":this.isDelivered?" ✓✓":" ✓":""):null))}get el(){return e(this)}static get watchers(){return{audioUrl:["chatChanged"]}}};Dt.style=":host {\n display: block;\n width: 100%;\n height: 100%;\n min-width: 0;\n box-sizing: border-box;\n }\n .wave-host {\n width: 100%;\n height: 100%;\n min-width: 0;\n min-height: 28px;\n }";const kt="data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz48IS0tIFVwbG9hZGVkIHRvOiBTVkcgUmVwbywgd3d3LnN2Z3JlcG8uY29tLCBHZW5lcmF0b3I6IFNWRyBSZXBvIE1peGVyIFRvb2xzIC0tPgo8c3ZnIHdpZHRoPSI4MDBweCIgaGVpZ2h0PSI4MDBweCIgdmlld0JveD0iMCAwIDI0IDI0IiBmaWxsPSJub25lIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPgo8cGF0aCBkPSJNNS42MjUgMTVDNS42MjUgMTQuNTg1OCA1LjI4OTIxIDE0LjI1IDQuODc1IDE0LjI1QzQuNDYwNzkgMTQuMjUgNC4xMjUgMTQuNTg1OCA0LjEyNSAxNUg1LjYyNVpNNC44NzUgMTZINC4xMjVINC44NzVaTTE5LjI3NSAxNUMxOS4yNzUgMTQuNTg1OCAxOC45MzkyIDE0LjI1IDE4LjUyNSAxNC4yNUMxOC4xMTA4IDE0LjI1IDE3Ljc3NSAxNC41ODU4IDE3Ljc3NSAxNUgxOS4yNzVaTTExLjEwODYgMTUuNTM4N0MxMC44NTM5IDE1Ljg2NTMgMTAuOTEyMSAxNi4zMzY2IDExLjIzODcgMTYuNTkxNEMxMS41NjUzIDE2Ljg0NjEgMTIuMDM2NiAxNi43ODc5IDEyLjI5MTQgMTYuNDYxM0wxMS4xMDg2IDE1LjUzODdaTTE2LjE5MTQgMTEuNDYxM0MxNi40NDYxIDExLjEzNDcgMTYuMzg3OSAxMC42NjM0IDE2LjA2MTMgMTAuNDA4NkMxNS43MzQ3IDEwLjE1MzkgMTUuMjYzNCAxMC4yMTIxIDE1LjAwODYgMTAuNTM4N0wxNi4xOTE0IDExLjQ2MTNaTTExLjEwODYgMTYuNDYxM0MxMS4zNjM0IDE2Ljc4NzkgMTEuODM0NyAxNi44NDYxIDEyLjE2MTMgMTYuNTkxNEMxMi40ODc5IDE2LjMzNjYgMTIuNTQ2MSAxNS44NjUzIDEyLjI5MTQgMTUuNTM4N0wxMS4xMDg2IDE2LjQ2MTNaTTguMzkxMzggMTAuNTM4N0M4LjEzNjYyIDEwLjIxMjEgNy42NjUzMyAxMC4xNTM5IDcuMzM4NzMgMTAuNDA4NkM3LjAxMjEyIDEwLjY2MzQgNi45NTM4NyAxMS4xMzQ3IDcuMjA4NjIgMTEuNDYxM0w4LjM5MTM4IDEwLjUzODdaTTEwLjk1IDE2QzEwLjk1IDE2LjQxNDIgMTEuMjg1OCAxNi43NSAxMS43IDE2Ljc1QzEyLjExNDIgMTYuNzUgMTIuNDUgMTYuNDE0MiAxMi40NSAxNkgxMC45NVpNMTIuNDUgNUMxMi40NSA0LjU4NTc5IDEyLjExNDIgNC4yNSAxMS43IDQuMjVDMTEuMjg1OCA0LjI1IDEwLjk1IDQuNTg1NzkgMTAuOTUgNUgxMi40NVpNNC4xMjUgMTVWMTZINS42MjVWMTVINC4xMjVaTTQuMTI1IDE2QzQuMTI1IDE4LjA1MzEgNS43NTI1NyAxOS43NSA3LjggMTkuNzVWMTguMjVDNi42MTY1NyAxOC4yNSA1LjYyNSAxNy4yNjA3IDUuNjI1IDE2SDQuMTI1Wk03LjggMTkuNzVIMTUuNlYxOC4yNUg3LjhWMTkuNzVaTTE1LjYgMTkuNzVDMTcuNjQ3NCAxOS43NSAxOS4yNzUgMTguMDUzMSAxOS4yNzUgMTZIMTcuNzc1QzE3Ljc3NSAxNy4yNjA3IDE2Ljc4MzQgMTguMjUgMTUuNiAxOC4yNVYxOS43NVpNMTkuMjc1IDE2VjE1SDE3Ljc3NVYxNkgxOS4yNzVaTTEyLjI5MTQgMTYuNDYxM0wxNi4xOTE0IDExLjQ2MTNMMTUuMDA4NiAxMC41Mzg3TDExLjEwODYgMTUuNTM4N0wxMi4yOTE0IDE2LjQ2MTNaTTEyLjI5MTQgMTUuNTM4N0w4LjM5MTM4IDEwLjUzODdMNy4yMDg2MiAxMS40NjEzTDExLjEwODYgMTYuNDYxM0wxMi4yOTE0IDE1LjUzODdaTTEyLjQ1IDE2VjVIMTAuOTVWMTZIMTIuNDVaIiBmaWxsPSIjMDAwMDAwIi8+Cjwvc3ZnPg==";const jt=kt;const It=class{constructor(s){t(this,s);this.tagUserClick=i(this,"tagUserClick",7);this.bgColor=undefined;this.borderRadius="6px";this.padding="10px";this.docName=undefined;this.width=undefined;this.height=undefined;this.documentNameBg=undefined;this.documentNamePadding=undefined;this.time=undefined;this.href=undefined;this.fileName=undefined;this.isRead=undefined;this.isSelf=undefined;this.isDelivered=undefined;this.docType="";this.textColor=undefined;this.message=undefined;this.mentionedUsers=[];this.messageId=undefined;this.reactions={};this.userMetaData=undefined;this.messageType=undefined;this.timeColor=undefined;this.showReactionOnHover=false;this.borderWidth=undefined;this.borderColor=undefined;this.borderStyle=undefined}truncateDocName(t){const i=t.lastIndexOf(".");const s=i!==-1?t.slice(0,i):t;const e=i!==-1?t.slice(i):"";const n=40-e.length;if(s.length<=n){return{firstLine:s.slice(0,Math.min(20,s.length)),secondLine:`${s.slice(20)}${e}`}}const h=s.slice(0,n-3)+"...";return{firstLine:h.slice(0,20),secondLine:`${h.slice(20)}${e}`}}iconSrc(){const t=(this.docType||"").toLowerCase();const i=(this.docName||this.fileName||"").toLowerCase();if(t.includes("spreadsheet")||t.includes("excel")||/\.xlsx?$/.test(i)||i.endsWith(".csv"))return o;if(t.includes("rtf")||i.endsWith(".rtf"))return a;if(t.includes("text/plain")||i.endsWith(".txt"))return c;return l}render(){const t=this.truncateDocName(this.docName||"Document");const i=this.message&&!String(this.message).includes("AttachmentMessage:");return s("message-bubble",{key:"94fe5e9b944b8043f7d21da67d56bd0a94613377",isSelf:!!this.isSelf,time:this.time,timeColor:this.timeColor,isRead:this.isRead,isDelivered:this.isDelivered,reactions:this.reactions,messageId:this.messageId,userMetaData:this.userMetaData,isForwarded:this.messageType===1,backgroundColor:this.bgColor||"var(--bg-secondary)",borderRadius:this.borderRadius||"6px",padding:this.padding||"10px",showReactionOnHover:this.showReactionOnHover},s("div",{key:"1198854dd3aa5f18e73550e86053e77dbc936409",class:"doc-container",style:{backgroundColor:this.documentNameBg||"var(--bg-tertiary)",width:this.width||"auto"}},s("div",{key:"0aca7f3453dd4cb00f6105f1ca18d926d8efdf24",class:"document-name",style:{padding:this.documentNamePadding||"5px 10px 5px 0"}},s("span",{key:"b98bcb671c73ca6500c52249429f8303548d5a04",class:"attachment-icon"},s("img",{key:"b9a6c9ed0827994813dc5100236bb3ff74e927f2",src:this.iconSrc(),alt:""})),s("span",{key:"333f5385409b143f1232b6364485b6e84a1f8047"},t.firstLine,s("br",{key:"935710220f739f90eabb87ea6de85e81edeacd0e"}),t.secondLine)),s("a",{key:"6c3fd001ef1edec41f815dd11ce6c6a0fda7dad4",class:"download-btn",href:this.href,download:this.fileName,target:"_blank",rel:"noopener noreferrer","aria-label":"Download"},s("img",{key:"0fb2d7fda4c077b0b4da7effdf7190521fd28f20",src:jt,alt:""}))),i?s("div",{style:{fontSize:"8px",color:this.textColor,marginTop:"4px"}},h(this.message,this.mentionedUsers,(t=>r(this.tagUserClick,t)),!!this.isSelf)):null)}};It.style=":host { display: block; }\n .doc-container {\n display: flex; align-items: center; justify-content: space-between; gap: 8px;\n border-radius: 8px; padding: 4px 8px;\n }\n .document-name {\n display: flex; align-items: center; gap: 8px; word-break: break-word;\n font-size: 12px; line-height: 1.35;\n }\n .attachment-icon { display: flex; flex-shrink: 0; width: 24px; height: 30px; align-items: center; justify-content: center; }\n .attachment-icon img { width: 24px; height: 24px; object-fit: contain; display: block; }\n .download-btn {\n display: flex; align-items: center; justify-content: center;\n flex-shrink: 0; line-height: 0;\n }\n .download-btn img {\n width: 28px; height: 28px; display: block;\n filter: var(--svg-icon-filter);\n }";const St=class{constructor(s){t(this,s);this.tagUserClick=i(this,"tagUserClick",7);this.openGallery=t=>{var i;(i=this.onImageClick)===null||i===void 0?void 0:i.call(this,t);this.galleryOpen=true};this.bgColor=undefined;this.borderRadius="10px";this.padding="10px";this.imageSrc=undefined;this.message=undefined;this.height="220px";this.width="250px";this.time=undefined;this.isRead=undefined;this.isSelf=undefined;this.isDelivered=undefined;this.textColor=undefined;this.allAttachments=undefined;this.isMediaGalleryOpen=undefined;this.onImageClick=undefined;this.mentionedUsers=[];this.totalMedia=0;this.mediaType=undefined;this.loadingMediaGallery=undefined;this.messageId=undefined;this.reactions={};this.userMetaData=undefined;this.messageType=undefined;this.timeColor=undefined;this.showReactionOnHover=false;this.borderWidth=undefined;this.borderColor=undefined;this.borderStyle=undefined;this.galleryOpen=false}render(){const t=this.message&&!String(this.message).includes("AttachmentMessage:");return s("div",{key:"19c188f64d94fce0375cc619d9afbf208c3075b0"},s("message-bubble",{key:"3a00af150abc7d107a90e76458fafdfd3389c3b7",isSelf:!!this.isSelf,time:this.time,timeColor:this.timeColor,isRead:this.isRead,isDelivered:this.isDelivered,reactions:this.reactions,messageId:this.messageId,userMetaData:this.userMetaData,isForwarded:this.messageType===1,backgroundColor:this.bgColor,borderRadius:this.borderRadius||"10px",padding:this.padding||"10px",showReactionOnHover:this.showReactionOnHover},s("div",{key:"1484a65d6018059a0905be46028e740196ebff8e",class:"image-container",style:{width:this.width||"250px",height:this.height||"220px",borderRadius:this.borderRadius},onClick:this.openGallery},s("img",{key:"c49d11cf6f6f87141d5a8765cf9b4c256ffc3be5",src:this.imageSrc,alt:"image"}),this.totalMedia>0?s("span",{class:"mediaCount"}," + ",this.totalMedia):null),t?s("div",{style:{fontSize:"14px",color:this.textColor,marginTop:"4px"}},h(this.message,this.mentionedUsers,(t=>r(this.tagUserClick,t)),!!this.isSelf)):null),this.galleryOpen?s("div",{class:"gallery-overlay",onClick:()=>this.galleryOpen=false},s("button",{type:"button",class:"gallery-close","aria-label":"Close"},"×"),s("img",{src:this.imageSrc,alt:"full",onClick:t=>t.stopPropagation()})):null)}};St.style=":host { display: block; font-family: var(--font-primary); }\n .image-container { cursor: pointer; overflow: hidden; position: relative; }\n .image-container img { width: var(--w-full); height: var(--h-full); object-fit: cover; display: block; }\n .mediaCount {\n position: absolute; right: var(--space-8); bottom: var(--space-8);\n background: var(--overlay); color: var(--text-on-brand);\n padding: var(--gap-2) var(--gap-6); border-radius: var(--rounded-8); font-size: var(--text-12);\n }\n .gallery-overlay {\n position: fixed; inset: 0; background: var(--overlay); z-index: 9999;\n display: flex; align-items: center; justify-content: center;\n }\n .gallery-overlay img { max-width: 90vw; max-height: 90vh; object-fit: contain; }\n .gallery-close {\n position: absolute; top: var(--space-16); right: var(--space-16);\n color: var(--text-on-brand); font-size: var(--text-24);\n background: transparent; border: none; cursor: pointer;\n }";const Et=class{constructor(s){t(this,s);this.tagUserClick=i(this,"tagUserClick",7);this.playVideo=()=>{const t=this.videoEl();if(!t)return;t.play();this.isPlaying=true};this.pauseVideo=()=>{const t=this.videoEl();if(!t)return;t.pause();this.isPlaying=false};this.toggle=()=>this.isPlaying?this.pauseVideo():this.playVideo();this.fullscreen=()=>{var t;const i=this.videoEl();(t=i===null||i===void 0?void 0:i.requestFullscreen)===null||t===void 0?void 0:t.call(i)};this.bgColor=undefined;this.borderRadius="10px";this.padding="10px";this.videoSrc=undefined;this.videoType="video/mp4";this.time=undefined;this.height="150px";this.width="150px";this.playing=undefined;this.isRead=undefined;this.isSelf=undefined;this.isDelivered=undefined;this.textColor=undefined;this.message=undefined;this.mentionedUsers=[];this.messageId=undefined;this.reactions={};this.userMetaData=undefined;this.messageType=undefined;this.timeColor=undefined;this.showReactionOnHover=false;this.type=undefined;this.borderWidth=undefined;this.borderColor=undefined;this.borderStyle=undefined;this.isPlaying=false}videoEl(){var t;return((t=this.el.shadowRoot)===null||t===void 0?void 0:t.querySelector("video"))||null}render(){const t=this.message&&!String(this.message).includes("AttachmentMessage:");return s("message-bubble",{key:"53af459d4e8ca4043b42d7d8b9fa420bd6262d6c",isSelf:!!this.isSelf,time:this.time,timeColor:this.timeColor,isRead:this.isRead,isDelivered:this.isDelivered,reactions:this.reactions,messageId:this.messageId,userMetaData:this.userMetaData,isForwarded:this.messageType===1,backgroundColor:this.bgColor,borderRadius:this.borderRadius||"10px",padding:this.padding||"10px",showReactionOnHover:this.showReactionOnHover},s("div",{key:"56e1d8c7818bd520bf05af11df528cf4caf4bdd1",class:"video-wrap"},s("video",{key:"ee7fe48179d98574e8c5a0b0013fb8d41a4f87e0",style:{height:this.height||"150px",width:this.width||"150px",objectFit:"cover",borderRadius:this.borderRadius||"8px"},onClick:this.toggle},s("source",{key:"8a6cd53a2e83f2d95e55baedf4b0226435d1d785",src:this.videoSrc,type:this.videoType||"video/mp4"})),s("div",{key:"f6effc32d79d9c09dabdece9ecfb89959eca8e7d",class:"controls"},!this.isPlaying?s("button",{type:"button",onClick:this.playVideo,"aria-label":"Play"},"▶"):s("button",{type:"button",onClick:this.pauseVideo,"aria-label":"Pause"},"❚❚"),s("button",{key:"e9900ec1cbdce69521fb5cc5b1ff6d417d013dbf",type:"button",class:"video_fullscreen",onClick:this.fullscreen,"aria-label":"Fullscreen"},"⛶"))),t?s("div",{style:{fontSize:"14px",color:this.textColor,marginTop:"4px"}},h(this.message,this.mentionedUsers,(t=>r(this.tagUserClick,t)),!!this.isSelf)):null)}get el(){return e(this)}};Et.style=":host { display: block; position: relative; }\n .video-wrap { position: relative; width: fit-content; }\n .controls {\n position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; pointer-events: none;\n }\n .controls button {\n pointer-events: auto; border: none; background: var(--overlay); color: var(--text-on-brand);\n cursor: pointer; padding: 8px 10px; border-radius: 8px; margin: 0 4px;\n }\n .video_fullscreen { position: absolute; right: 8px; bottom: 8px; }";export{Dt as audio_bubble,It as document_message,St as image_message,Et as video_message};
|
|
2
|
+
//# sourceMappingURL=p-0085b397.entry.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{r as t,a as i,h as s}from"./p-17a96a2a.js";import{g as e}from"./p-e5884258.js";import{W as a}from"./p-e40e8866.js";import{G as o}from"./p-
|
|
2
|
-
//# sourceMappingURL=p-
|
|
1
|
+
import{r as t,a as i,h as s}from"./p-17a96a2a.js";import{g as e}from"./p-e5884258.js";import{W as a}from"./p-e40e8866.js";import{G as o}from"./p-d424871c.js";import"./p-f24cdbbb.js";const r=class{constructor(s){t(this,s);this.inputChanged=i(this,"new-chat-input-changed",7);this.contactSelected=i(this,"new-chat-contact-selected",7);this.scrolledToBottom=i(this,"new-chat-tile-list-scrolled-to-bottom",7);this.createGroupClicked=i(this,"create-group-clicked",7);this.createGroupcastClicked=i(this,"create-groupcast-clicked",7);this.closeGroupMemberList=i(this,"close-group-member-list",7);this.onSearch=t=>{const i=t.target.value;this.searchText=i;clearTimeout(this.debounceTimer);this.debounceTimer=setTimeout((()=>{if(!i.trim()||i.length>=3){this.inputChanged.emit({inputValue:i.trim()?i:""})}}),300)};this.onScroll=t=>{const i=t.target;if(i.scrollHeight-Math.round(i.scrollTop)<=i.clientHeight+1&&this.hasMoreMembers&&!this.isPaginationMember){this.scrolledToBottom.emit()}};this.selectContact=(t,i)=>{var s;this.contactSelected.emit({userId:t,userName:i});(s=this.closeNewChatSidebar)===null||s===void 0?void 0:s.call(this)};this.openGroup=()=>{this.searchText="";this.showGroupChatContacts=true;this.createGroupClicked.emit({isGroup:true})};this.openGroupcast=()=>{this.searchText="";this.showGroupCastContacts=true;this.createGroupcastClicked.emit({isGroup:true})};this.closeGroupOverlay=()=>{this.closeGroupMemberList.emit({isGroup:false});this.showGroupChatContacts=false;this.showGroupCastContacts=false};this.label="New Chat";this.closeNewChatSidebar=undefined;this.nonBlockedContacts=[];this.isNoContactsFound=false;this.isPaginationMember=false;this.isLoadingMember=false;this.hasMoreMembers=false;this.showGroupChatContacts=false;this.showGroupCastContacts=false;this.searchText=""}render(){if(this.showGroupCastContacts){return s("group-chat-contacts",{closeGroupChatContacts:this.closeGroupOverlay,label:"Create New Groupcast",nonBlockedContacts:this.nonBlockedContacts,isNoContactsFound:this.isNoContactsFound,isPaginationMember:this.isPaginationMember,isLoadingMember:this.isLoadingMember,hasMoreMembers:this.hasMoreMembers,isGroupCast:true,onCloseAll:()=>{var t;return(t=this.closeNewChatSidebar)===null||t===void 0?void 0:t.call(this)}})}if(this.showGroupChatContacts){return s("group-chat-contacts",{closeGroupChatContacts:this.closeGroupOverlay,label:"Create New Group",nonBlockedContacts:this.nonBlockedContacts,isNoContactsFound:this.isNoContactsFound,isPaginationMember:this.isPaginationMember,isLoadingMember:this.isLoadingMember,hasMoreMembers:this.hasMoreMembers,onCloseAll:()=>{var t;return(t=this.closeNewChatSidebar)===null||t===void 0?void 0:t.call(this)}})}return s("div",{class:"wrap"},s("div",{class:"topbar"},s("button",{type:"button",onClick:()=>{var t;return(t=this.closeNewChatSidebar)===null||t===void 0?void 0:t.call(this)},"aria-label":"Back"},s("svg",{xmlns:"http://www.w3.org/2000/svg",height:"24",viewBox:"0 -960 960 960",width:"24",fill:"currentColor"},s("path",{d:"m313-440 224 224-57 56-320-320 320-320 57 56-224 224h487v80H313Z"}))),s("span",null,this.label)),s("div",{class:"search"},s("input",{type:"search",placeholder:a.PLACEHOLDER_CONTENT.SEARCH_FOR_NAME_OR_NUMBER,value:this.searchText,onInput:this.onSearch})),s("div",{class:"action",onClick:this.openGroup},s("img",{src:o,alt:""}),s("span",null,"Create New Group")),s("div",{class:"action",onClick:this.openGroupcast},s("svg",{xmlns:"http://www.w3.org/2000/svg",height:"28",viewBox:"0 -960 960 960",width:"28",fill:"currentColor"},s("path",{d:"M720-440v-80h160v80H720Zm48 280-128-96 48-64 128 96-48 64Zm-80-480-48-64 128-96 48 64-128 96ZM200-200v-160h-40q-33 0-56.5-23.5T80-440v-80q0-33 23.5-56.5T160-600h160l200-120v480L320-360h-40v160h-80Zm240-182v-196l-98 58H160v80h182l98 58Zm120 36v-268q27 24 43.5 58.5T620-480q0 41-16.5 75.5T560-346ZM300-480Z"})),s("span",null,"Create New Groupcast")),s("div",{class:"list",onScroll:this.onScroll},this.isLoadingMember?s("div",{class:"loading"},s("spinner-loader",{height:"15px",width:"15px"})):!(this.nonBlockedContacts||[]).length?s("div",{class:"empty"},this.isNoContactsFound?"No contacts found":"No contacts available"):(this.nonBlockedContacts||[]).map((t=>s("div",{class:"row",onClick:()=>this.selectContact(t.userId,t.userName)},s("img",{src:t.userProfileImageUrl||e(t.userName||"?",80,80),alt:""}),s("span",null,t.userName)))),this.isPaginationMember?s("div",{class:"loading"},s("spinner-loader",{height:"15px",width:"15px"})):null))}};r.style=":host { display: block; height: 100%; width: 100%; }\n .wrap {\n display: flex; flex-direction: column; height: 100%;\n background: var(--bg-primary); color: var(--text-primary);\n }\n .topbar {\n display: flex; align-items: center; gap: 12px; padding: 12px;\n font-size: var(--text-18); font-weight: 500;\n }\n .topbar button { background: none; border: none; cursor: pointer; color: inherit; padding: 0; display: flex; }\n .search {\n display: flex; align-items: center; gap: 8px; margin: 8px 12px; padding: 8px 10px;\n border-radius: 8px; background: var(--bg-secondary);\n }\n .search input {\n flex: 1; border: none; outline: none; background: transparent;\n color: var(--text-primary); font-size: 14px;\n }\n .action {\n display: flex; align-items: center; gap: 10px; padding: 12px; cursor: pointer;\n border-bottom: 1px solid var(--bg-secondary);\n }\n .action img { width: 28px; height: 28px; }\n .list { flex: 1; min-height: 0; overflow-y: auto; }\n .row {\n display: flex; align-items: center; gap: 10px; padding: 12px; cursor: pointer;\n border-bottom: 1px solid var(--bg-secondary);\n }\n .row img { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; background: var(--bg-tertiary); }\n .empty, .loading { padding: 24px; text-align: center; opacity: 0.7; }\n .theme-icon { filter: var(--svg-icon-filter); }";export{r as new_chat_sidebar};
|
|
2
|
+
//# sourceMappingURL=p-1ad1127f.entry.js.map
|