@chat-leo/chatleo 2.1.0 → 2.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- import{p as e,b as a}from"./p-DmL518NK.js";export{s as setNonce}from"./p-DmL518NK.js";import{g as o}from"./p-DQuL1Twl.js";(()=>{const a=import.meta.url,o={};return""!==a&&(o.resourcesUrl=new URL(".",a).href),e(o)})().then((async e=>(await o(),a([["p-aed60255",[[513,"chatleo-chat-input",{disabled:[4],sendOnModifierEnter:[4,"send-on-modifier-enter"],inputValue:[32]}]]],["p-43ada232",[[513,"my-component",{first:[1],middle:[1],last:[1]}]]],["p-4485e141",[[513,"chatleo-component",{username:[1],ticket:[1],useTray:[4,"use-tray"],useMain:[4,"use-main"],useRoomView:[4,"use-room-view"],roomId:[1,"room-id"],chatLeoLib:[16],chatStore:[16],serverUrl:[1,"server-url"],transport:[1],calls:[1],push:[1],pushSwPath:[1,"push-sw-path"],isLoggedIn:[32],loading:[32],isSessionExpired:[32],connectionStatus:[32],callsAvailable:[32],incomingCall:[32],callView:[32],showCall:[32],pushState:[32],pushPromptDismissed:[32],getConnectionStatus:[64],openRoom:[64],closeRoom:[64],getActiveRoomId:[64],getDraft:[64],setDraft:[64],addFiles:[64],focusComposer:[64],openDirectMessageWithUser:[64],openNewChatDraft:[64]},[[0,"callError","onCallError"],[0,"callLeft","onCallLeft"],[0,"callRequested","onCallRequested"],[0,"newChatClicked","onNewChatClicked"],[0,"messageChatSent","onChatMessage"],[0,"userSelected","onUserSelectedForChat"]],{chatLeoLib:[{onChatLeoLibChange:0}],chatStore:[{onChatStoreChange:0}],ticket:[{onTicketChange:0}],calls:[{onCallsChange:0}],incomingCall:[{onIncomingCallChange:0}]}],[513,"chatleo-chat",{chatStore:[16],isOnline:[4,"is-online"],pending:[4],callsAvailable:[4,"calls-available"],inCall:[4,"in-call"],selectedRoomId:[32],_version:[32],_showRoomDetail:[32],openRoom:[64],closeRoom:[64],getDraft:[64],setDraft:[64],addFiles:[64],focusComposer:[64]},[[0,"messageInputSent","handleSendMessage"],[0,"messageSend","messageSendHandler"],[0,"roomClicked","handleRoomClicked"]],{chatStore:[{onChatStoreChange:0}]}],[513,"chatleo-tray-component",{chatStore:[16],isChatOpen:[32],isNewChatSelectorOpen:[32],isMessagesOpen:[32],selectedRoomId:[32],isPending:[32],_version:[32],isSessionExpired:[32],connectionStatus:[32],openChatPanel:[64]},[[0,"roomClicked","roomClickedHandler"],[0,"messageSend","messageSendHandler"]],{chatStore:[{onChatStoreChange:0}],selectedRoomId:[{onSelectedRoomIdChanged:0}]}],[513,"chatleo-room-view",{chatStore:[16],roomId:[1,"room-id"],isOnline:[4,"is-online"],pending:[4],callsAvailable:[4,"calls-available"],inCall:[4,"in-call"],_version:[32],getDraft:[64],setDraft:[64],addFiles:[64],focusComposer:[64]},[[0,"messageRetry","messageRetryHandler"],[0,"messageDiscard","messageDiscardHandler"],[0,"messageSend","messageSendHandler"]],{chatStore:[{onChatStoreChange:0}],roomId:[{onRoomIdChanged:0}]}],[513,"chatleo-room-list",{rooms:[16],chatStore:[16],selectedRoomId:[1,"selected-room-id"],_version:[32],isNewChatOpen:[32]},[[0,"userSelected","onUserSelected"]],{chatStore:[{onChatStoreChange:0}]}],[513,"chatleo-chat-message",{message:[16],sender:[16],senderIsOnline:[4,"sender-is-online"],isOwnMessage:[4,"is-own-message"],locale:[1],translations:[16]}],[513,"chatleo-new-message-selector",{chatStore:[16],placeholder:[1],filterText:[32],filteredUsers:[32],_version:[32]},null,{chatStore:[{onChatStoreChange:0}]}],[513,"chatleo-chat-header",{name:[1],avatar:[1],isOnline:[4,"is-online"]}],[513,"chatleo-room-tile-component",{room:[16],chatStore:[16],onlineUserIds:[16],lastMessage:[1,"last-message"],timestamp:[1],unreadCount:[2,"unread-count"],isActive:[4,"is-active"]}],[513,"chatleo-rich-input",{disabled:[4],placeholder:[1],maxHeight:[1,"max-height"],acceptFiles:[1,"accept-files"],isDragOver:[32],hasContent:[32],getText:[64],setText:[64],addFiles:[64],focusEditor:[64]}],[513,"chatleo-user-tile",{profile:[16],isOnline:[4,"is-online"],lastSeen:[1,"last-seen"]}],[513,"chatleo-rich-message-renderer",{content:[16],downloadUrls:[16],alignment:[1],translations:[16],attachmentStates:[32]}],[513,"chatleo-avatar",{name:[1],url:[1],isOnline:[4,"is-online"]}]]]],e))));
1
+ import{p as e,b as a}from"./p-DmL518NK.js";export{s as setNonce}from"./p-DmL518NK.js";import{g as o}from"./p-DQuL1Twl.js";(()=>{const a=import.meta.url,o={};return""!==a&&(o.resourcesUrl=new URL(".",a).href),e(o)})().then((async e=>(await o(),a([["p-aed60255",[[513,"chatleo-chat-input",{disabled:[4],sendOnModifierEnter:[4,"send-on-modifier-enter"],inputValue:[32]}]]],["p-43ada232",[[513,"my-component",{first:[1],middle:[1],last:[1]}]]],["p-75e4078d",[[513,"chatleo-component",{username:[1],ticket:[1],useTray:[4,"use-tray"],useMain:[4,"use-main"],useRoomView:[4,"use-room-view"],roomId:[1,"room-id"],chatLeoLib:[16],chatStore:[16],serverUrl:[1,"server-url"],transport:[1],calls:[1],push:[1],pushSwPath:[1,"push-sw-path"],isLoggedIn:[32],loading:[32],isSessionExpired:[32],connectionStatus:[32],callsAvailable:[32],incomingCall:[32],callView:[32],showCall:[32],pushState:[32],pushPromptDismissed:[32],getConnectionStatus:[64],openRoom:[64],closeRoom:[64],getActiveRoomId:[64],getDraft:[64],setDraft:[64],addFiles:[64],focusComposer:[64],openDirectMessageWithUser:[64],openNewChatDraft:[64]},[[0,"callError","onCallError"],[0,"callLeft","onCallLeft"],[0,"callRequested","onCallRequested"],[0,"newChatClicked","onNewChatClicked"],[0,"messageChatSent","onChatMessage"],[0,"userSelected","onUserSelectedForChat"]],{chatLeoLib:[{onChatLeoLibChange:0}],chatStore:[{onChatStoreChange:0}],ticket:[{onTicketChange:0}],calls:[{onCallsChange:0}],incomingCall:[{onIncomingCallChange:0}]}],[513,"chatleo-chat",{chatStore:[16],isOnline:[4,"is-online"],pending:[4],callsAvailable:[4,"calls-available"],inCall:[4,"in-call"],selectedRoomId:[32],_version:[32],_showRoomDetail:[32],openRoom:[64],closeRoom:[64],getDraft:[64],setDraft:[64],addFiles:[64],focusComposer:[64]},[[0,"messageInputSent","handleSendMessage"],[0,"messageSend","messageSendHandler"],[0,"roomClicked","handleRoomClicked"]],{chatStore:[{onChatStoreChange:0}]}],[513,"chatleo-tray-component",{chatStore:[16],isChatOpen:[32],isNewChatSelectorOpen:[32],isMessagesOpen:[32],selectedRoomId:[32],isPending:[32],_version:[32],isSessionExpired:[32],connectionStatus:[32],openChatPanel:[64]},[[0,"roomClicked","roomClickedHandler"],[0,"messageSend","messageSendHandler"]],{chatStore:[{onChatStoreChange:0}],selectedRoomId:[{onSelectedRoomIdChanged:0}]}],[513,"chatleo-room-view",{chatStore:[16],roomId:[1,"room-id"],isOnline:[4,"is-online"],pending:[4],callsAvailable:[4,"calls-available"],inCall:[4,"in-call"],_version:[32],getDraft:[64],setDraft:[64],addFiles:[64],focusComposer:[64]},[[0,"messageRetry","messageRetryHandler"],[0,"messageDiscard","messageDiscardHandler"],[0,"messageSend","messageSendHandler"]],{chatStore:[{onChatStoreChange:0}],roomId:[{onRoomIdChanged:0}]}],[513,"chatleo-room-list",{rooms:[16],chatStore:[16],selectedRoomId:[1,"selected-room-id"],_version:[32],isNewChatOpen:[32]},[[0,"userSelected","onUserSelected"]],{chatStore:[{onChatStoreChange:0}]}],[513,"chatleo-chat-message",{message:[16],sender:[16],senderIsOnline:[4,"sender-is-online"],isOwnMessage:[4,"is-own-message"],locale:[1],translations:[16]}],[513,"chatleo-new-message-selector",{chatStore:[16],placeholder:[1],filterText:[32],filteredUsers:[32],_version:[32]},null,{chatStore:[{onChatStoreChange:0}]}],[513,"chatleo-chat-header",{name:[1],avatar:[1],isOnline:[4,"is-online"]}],[513,"chatleo-room-tile-component",{room:[16],chatStore:[16],onlineUserIds:[16],lastMessage:[1,"last-message"],timestamp:[1],unreadCount:[2,"unread-count"],isActive:[4,"is-active"]}],[513,"chatleo-rich-input",{disabled:[4],placeholder:[1],maxHeight:[1,"max-height"],acceptFiles:[1,"accept-files"],isDragOver:[32],hasContent:[32],getText:[64],setText:[64],addFiles:[64],focusEditor:[64]}],[513,"chatleo-user-tile",{profile:[16],isOnline:[4,"is-online"],lastSeen:[1,"last-seen"]}],[513,"chatleo-rich-message-renderer",{content:[16],downloadUrls:[16],alignment:[1],translations:[16],attachmentStates:[32]}],[513,"chatleo-avatar",{name:[1],url:[1],isOnline:[4,"is-online"]}]]]],e))));
@@ -0,0 +1 @@
1
+ import{r as e,h as t,c as a,g as i}from"./p-DmL518NK.js";import{g as n}from"./p-C-l90Wre.js";const o=class{constructor(t){e(this,t)}name;url;isOnline=!1;render(){const e=`\n <svg width="100" height="100" xmlns="http://www.w3.org/2000/svg">\n <circle cx="50" cy="50" r="45" fill="royalblue" />\n <text x="50" y="55" font-size="12" text-anchor="middle" fill="white">${this.name.substring(0,2)}</text>\n </svg>\n `,a="data:image/svg+xml,"+encodeURIComponent(e);return t("div",{key:"e7b5846df55e2088312546869f50c32fc1b3f809",class:"user-avatar"},t("img",{key:"ef7af555265926a194ce8f972286ca3be5746b40",src:this.url??a,alt:this.name,title:this.name}),t("div",{key:"46e7627446b02d7f1e42d110cbb5fd5a55ff333b",class:"status-indicator "+(this.isOnline?"online":"offline")}))}};o.style=":host{--avatar-bg:#dddddd;--status-size:12px;--status-border:2px;--status-position:2px}.user-avatar{position:relative;flex-shrink:0}.user-avatar img{width:var(--avatar-size, 48px);height:var(--avatar-size, 48px);border-radius:50%;object-fit:cover;background-color:var(--avatar-bg);overflow:hidden}.status-indicator{position:absolute;bottom:var(--status-position);right:var(--status-position);width:var(--status-size);height:var(--status-size);border-radius:50%;border:var(--status-border) solid var(--bg-primary)}.status-indicator.online{background-color:var(--status-online)}.status-indicator.offline{background-color:var(--status-offline)}";const s=class{constructor(t){e(this,t),this.messageChatSent=a(this,"messageChatSent")}chatStore;isOnline=!1;pending=!1;callsAvailable=!1;inCall=!1;selectedRoomId;_version=0;_showRoomDetail=!1;roomViewRef;handleToggleMobileView(){this._showRoomDetail=!this._showRoomDetail}isMobileViewport(){return window.innerWidth<768}async openRoom(e){e&&(this.selectedRoomId=e,this.chatStore?.setActiveRoomId(e),this.chatStore?.markRoomAsRead(e),this.isMobileViewport()&&(this._showRoomDetail=!0))}async closeRoom(){this._showRoomDetail=!1,this.chatStore?.setActiveRoomId(null)}async getDraft(){return await(this.roomViewRef?.getDraft?.())??""}async setDraft(e){e&&await(this.roomViewRef?.setDraft?.(e))}async addFiles(e){await(this.roomViewRef?.addFiles?.(e??[]))}async focusComposer(){await(this.roomViewRef?.focusComposer?.())}onChatStoreChange(e,t){console.debug("onChatStoreChange",e,t),e.addEventListener("roomAdded",(e=>{console.debug("roomAdded",e),this._version++})),e.addEventListener("roomMessageAdded",(t=>{console.debug("roomMessageAdded",t),this._version++;const a=t.detail;a?.roomId&&a.roomId===this.selectedRoomId&&e.markRoomAsRead(a.roomId)})),e.addEventListener("roomReadCountChanged",(()=>{this._version++})),e.addEventListener("presenceChanged",(e=>{console.debug("onPresenceChange",e),this._version++}))}messageChatSent;handleSendMessage(e){this.messageChatSent.emit({room_id:this.selectedRoomId,content:e.detail,sender:this.chatStore?.profile?.id,content_type:"text/plain"})}messageSendHandler(e){console.log("Received the messageSend event: ",JSON.stringify(e.detail));const t=(e.detail?.blocks??[]).map((e=>{if("attachment"===e?.type&&Array.isArray(e.attachments)){const t=e.attachments.map((e=>{const{preview:t,...a}=e??{};return a}));return{...e,attachments:t}}return e}));this.messageChatSent.emit({room_id:this.selectedRoomId,content:{blocks:t,version:e.detail.version},content_type:"application/json+blocks",sender:this.chatStore?.profile?.id})}async handleRoomClicked(e){console.debug("ChatleoChat.roomClicked",e),await this.openRoom(e.detail.id)}render(){return t("div",{key:"759aa942b6cfba0635119d0064afe7bc4e2ef901",class:"chat-container-list-and-chat "+(this._showRoomDetail?"show-room-view":"show-room-list")},t("chatleo-room-list",{key:"feecf22c1ab746ec5af8cb1e61708f131946a260",rooms:this.chatStore?.rooms,chatStore:this.chatStore,selectedRoomId:this.selectedRoomId}),t("chatleo-room-view",{key:"c90a58b6946c949288176b3aa5a411b3d7722e7e",ref:e=>this.roomViewRef=e,chatStore:this.chatStore,roomId:this.selectedRoomId,isOnline:this.isOnline,pending:this.pending,callsAvailable:this.callsAvailable,inCall:this.inCall}),t("button",{key:"d1ccaa37c2135f5a0f2945d82cc5becda60ea6e0",class:"toggle-btn",onClick:()=>this.handleToggleMobileView()},t("svg",{key:"e5af148d5cfd19d7bc44cdd76fea530bc6683ea9",viewBox:"0 0 24 24"},t("path",this._showRoomDetail?{d:"M15.41 7.41L14 6l-6 6 6 6 1.41-1.41L10.83 12z"}:{d:"M10 6L8.59 7.41 13.17 12l-4.58 4.59L10 18l6-6z"}))))}static get watchers(){return{chatStore:[{onChatStoreChange:0}]}}};s.style=":host{display:flex;flex-direction:column;flex:1;min-height:0;overflow:hidden}.chat-container-list-and-chat{display:flex;flex-direction:row;height:100%;max-width:100%;min-height:0;overflow:hidden;padding:2px;border:1px solid var(--border-light);box-sizing:border-box;background:var(--bg-primary);position:relative}chatleo-room-view{flex:1;min-width:0;min-height:0;border-left:1px solid var(--border-light);transition:transform 0.3s ease-out}chatleo-room-list{flex:0 0 auto;min-height:0;transition:transform 0.3s ease-out}.toggle-btn{display:none;position:absolute;top:50%;left:50%;transform:translate(-50%, -50%);z-index:100;width:48px;height:48px;border-radius:50%;border:1px solid var(--border-light);background:var(--bg-primary);cursor:pointer;box-shadow:0 2px 8px rgba(0, 0, 0, 0.15);align-items:center;justify-content:center;padding:0}.toggle-btn svg{width:24px;height:24px;fill:var(--text-primary)}@media (max-width: 768px){.chat-container-list-and-chat{overflow-x:hidden}.toggle-btn{display:flex;right:8px;left:auto;top:8px;transform:none}chatleo-room-list{width:100%;flex:1}chatleo-room-view{width:100%;position:absolute;top:0;left:0;right:0;bottom:0;border-left:none}.show-room-list chatleo-room-list{transform:translateX(0)}.show-room-list chatleo-room-view{transform:translateX(100%)}.show-room-view chatleo-room-list{transform:translateX(-100%)}.show-room-view chatleo-room-view{transform:translateX(0)}}";const r=class{constructor(t){e(this,t)}name="";avatar;isOnline=!1;render(){return t("div",{key:"ff841f251f2e9a0065ac166e09e08fa5e0d9dd33",class:"chat-header"},t("chatleo-avatar",{key:"9f3a6ee1fdae519dec06bc28c345440e410f8571",name:this.name,url:this.avatar,isOnline:this.isOnline}),t("div",{key:"ab55b0c38ed957115a34fe5dda24e5f0fa888514",class:"header-name"},this.name))}};r.style=":host{--header-padding:16px;--header-gap:16px}.chat-header{display:flex;align-items:center;gap:var(--header-gap);padding:var(--header-padding);background:var(--bg-primary)}.header-name{font-family:var(--font-primary);font-weight:700;font-size:16px;line-height:1.6;color:var(--text-primary)}";const c=class{constructor(t){e(this,t),this.messageRetry=a(this,"messageRetry"),this.messageDiscard=a(this,"messageDiscard")}message;sender=void 0;senderIsOnline=!1;isOwnMessage=!1;locale="en-US";translations={};messageRetry;messageDiscard;isStructuredContent(e){try{const t=JSON.parse(e);if(t&&t.blocks&&Array.isArray(t.blocks)&&t.version)return t}catch(e){}return null}formatTimestamp(e){try{return new Intl.DateTimeFormat(this.locale,{hour:"numeric",minute:"numeric"}).format(new Date(e))}catch(t){return e}}defaultTranslations={you:"You",sending:"Sending…",failed:"Not sent",retry:"Retry",discard:"Discard"};t(e){return console.log(`Translating key: ${e}`,this.translations,this.defaultTranslations),this.translations[e]||this.defaultTranslations[e]||e}callEntry(){return function(e){try{const t=JSON.parse(e),a=t?.call??(Array.isArray(t?.blocks)?t.blocks.find((e=>"call"===e?.type)):void 0);if(!a)return null;const i=a.fallback_text??t.fallback_text;if(i)return String(i);const n=a.event??a.state,o="number"==typeof a.duration_ms?Math.round(a.duration_ms/1e3):void 0,s=o?` · ${Math.floor(o/60)}:${String(o%60).padStart(2,"0")}`:"";return"missed"===n||"missed"===a.reason?"Missed call":"declined"===n||"declined"===a.reason?"Call declined":"ended"===n||"failed"===n?`Call ended${s}`:"started"===n||"active"===n?"group"===a.mode?"Group call started":"Call started":"Call"}catch{return null}}(this.message.content_body)}renderMessageContent(){const e=this.callEntry();if(e)return t("div",{class:"call-message"},e);const a=this.isStructuredContent(this.message.content_body);return a?t(t.Fragment,null,t("chatleo-rich-message-renderer",{content:a,downloadUrls:this.message.attachment_details,alignment:this.isOwnMessage?"right":"left"})):t("div",{class:"message-text",style:{textAlign:this.isOwnMessage?"right":"left"}},this.message.content_body)}renderDeliveryStatus(){const e=(a=this.message,this.isOwnMessage&&a?.delivery&&"sent"!==a.delivery?{status:a.delivery,error:a.error,canRetry:Boolean(a.client_id)}:{status:"none",canRetry:!1});var a;if("none"===e.status)return null;const i=this.message.client_id;return"pending"===e.status?t("div",{class:"message-status pending","aria-live":"polite"},this.t("sending")):t("div",{class:"message-status failed"},t("span",{class:"message-status-text"},this.t("failed"),e.error?`: ${e.error}`:""),e.canRetry&&i&&t("span",{class:"message-status-actions"},t("button",{type:"button",class:"status-action",onClick:()=>this.messageRetry.emit(i)},this.t("retry")),t("button",{type:"button",class:"status-action discard",onClick:()=>this.messageDiscard.emit(i)},this.t("discard"))))}render(){const e=this.isOwnMessage?this.t("you"):this.sender?.display_name??"";return t("div",{key:"c91f01cbf694c79d4e68b8445a99ffbc5b0b9790",class:"message-row"},!this.isOwnMessage&&t("chatleo-avatar",{key:"6f05c378fd18203d9917f1edbc61b20bf94b81b9",name:e,url:this.sender?.profile_picture_url??null,isOnline:this.senderIsOnline}),t("div",{key:"b1f4df458b587cace3423637b5bad8350a5c3a14",class:"message-content"},t("div",{key:"f7c565319462013dac380d21a813e21861544833",class:"message-header",style:{justifyContent:this.isOwnMessage?"end":"start"}},t("span",{key:"4d30b5eb0c55abb854b6192f0fe9c78bb54aff33",class:"message-author"},e),t("span",{key:"13867dc122764cbdbdd7fa60f5ff7e6916ed49e7",class:"message-timestamp"},this.formatTimestamp(this.message.created_at))),this.renderMessageContent(),this.renderDeliveryStatus()),this.isOwnMessage&&t("chatleo-avatar",{key:"c818e945cb494c07356fae74c00719e32a2c6b23",name:e,url:this.sender?.profile_picture_url??null,isOnline:this.senderIsOnline}))}};c.style=":host{--status-size:9px;--status-border:1.5px}.message-row{display:flex;gap:16px;padding-left:16px}.message-avatar-container{position:relative;width:var(--avatar-size);height:var(--avatar-size);flex-shrink:0}.message-avatar{width:100%;height:100%;border-radius:50%;object-fit:cover;background:var(--bg-light)}.message-status-indicator{position:absolute;bottom:0;right:0;width:var(--status-size);height:var(--status-size);border-radius:50%;border:var(--status-border) solid var(--bg-primary)}.message-status-indicator.online{background:var(--status-online)}.message-status-indicator.offline{background:var(--border-color)}.message-content{flex:1;display:flex;flex-direction:column;gap:4px}.message-header{display:flex;align-items:center;gap:8px}.message-author{font-family:var(--font-primary);font-weight:700;font-size:14px;line-height:1.6;color:var(--text-primary)}.message-timestamp{font-family:var(--font-primary);font-weight:400;font-size:12px;line-height:1.65;color:var(--text-secondary)}.message-timestamp::before{content:'•';margin-right:8px}.message-text{font-family:var(--font-primary);font-weight:400;font-size:14px;line-height:1.6;color:var(--text-primary);word-wrap:break-word;}.message-status{display:flex;align-items:center;gap:8px;font-family:var(--font-primary);font-size:12px;line-height:1.5}.message-status.pending{color:var(--text-secondary);font-style:italic}.message-status.failed{color:#c62828;flex-wrap:wrap}.message-status-actions{display:inline-flex;gap:6px}.status-action{border:1px solid currentColor;background:transparent;color:inherit;border-radius:4px;padding:1px 8px;font:inherit;cursor:pointer}.status-action:hover{background:rgba(198, 40, 40, 0.08)}.status-action.discard{opacity:0.8}.call-message{display:inline-flex;align-items:center;gap:6px;padding:6px 10px;border:1px solid var(--border-light, #ddd);border-radius:8px;font-family:var(--font-primary);font-size:13px;color:var(--text-secondary, #667);background:var(--bg-secondary, transparent)}.call-message::before{content:'☎';font-size:15px}";const d=class{constructor(t){e(this,t),this.activeRoomChange=a(this,"activeRoomChange"),this.unreadTotalChange=a(this,"unreadTotalChange")}username;ticket;useTray;useMain=!1;useRoomView=!1;roomId;chatLeoLib;chatStore;serverUrl;transport;calls="auto";push="manual";pushSwPath;isLoggedIn=!1;loading=!1;isSessionExpired=!1;connectionStatus="disconnected";callsAvailable=!1;incomingCall=null;callView=null;showCall=!1;pushState=null;pushPromptDismissed=!1;activeRoomChange;unreadTotalChange;chatEl;boundActiveRoomChanged=e=>this.activeRoomChange.emit(e.detail??{roomId:null});boundUnreadTotalChanged=e=>this.unreadTotalChange.emit(e.detail??{count:0});callRingtoneTimer;incomingRef;callRingtoneContext;callsChannel;callAdapterRef;trayEl;static OPEN_ROOM_EVENT="chatleo:openRoom";static START_DM_EVENT="chatleo:startDM";static NEW_CHAT_EVENT="chatleo:newChat";boundOpenRoomListener=e=>this.handleExternalOpenRoom(e);boundStartDmListener=e=>this.handleExternalStartDm(e);boundNewChatListener=e=>this.handleExternalNewChat(e);boundStartCallListener=e=>this.handleExternalStartCall(e);boundCallRinging=e=>this.handleCallRinging(e);boundCallChanged=e=>this.handleCallChanged(e);boundCallRole=e=>this.handleCallRole(e);boundServiceWorkerMessage=e=>this.handleServiceWorkerMessage(e);onChatLeoLibChange(e){console.debug("onChatLeoLibChange",e),e&&this.requestLibConnection()}onChatStoreChange(e,t){console.debug("onChatStoreChange",e,t),t?.removeEventListener("callRinging",this.boundCallRinging),t?.removeEventListener("callChanged",this.boundCallChanged),t?.removeEventListener("callRole",this.boundCallRole),t?.removeEventListener("activeRoomChanged",this.boundActiveRoomChanged),t?.removeEventListener("unreadTotalChanged",this.boundUnreadTotalChanged),e.addEventListener("callRinging",this.boundCallRinging),e.addEventListener("callChanged",this.boundCallChanged),e.addEventListener("callRole",this.boundCallRole),e.addEventListener("activeRoomChanged",this.boundActiveRoomChanged),e.addEventListener("unreadTotalChanged",this.boundUnreadTotalChanged),e.addEventListener("roomAdded",(e=>{console.warn(e)})),this.activeRoomChange.emit({roomId:e.activeRoomId}),this.unreadTotalChange.emit({count:e.unreadTotal})}onTicketChange(e){console.debug("onTicketChange",e),this.requestLibConnection()}onCallsChange(e){this.chatLeoLib?.setCallsEnabled?.("off"!==e),this.refreshCallsAvailability()}componentDidLoad(){console.debug("ChatLeoComponent:componentDidLoad",this.serverUrl),this.requestLibConnection()}connectedCallback(){console.debug("ChatLeoComponent:connectedCallback"),window.addEventListener(d.OPEN_ROOM_EVENT,this.boundOpenRoomListener),window.addEventListener(d.START_DM_EVENT,this.boundStartDmListener),window.addEventListener(d.NEW_CHAT_EVENT,this.boundNewChatListener),window.addEventListener("chatleo:startCall",this.boundStartCallListener),"undefined"!=typeof navigator&&"serviceWorker"in navigator&&navigator.serviceWorker.addEventListener("message",this.boundServiceWorkerMessage)}disconnectedCallback(){console.debug("ChatLeoComponent:disconnectedCallback"),this.chatLeoLib?.unregisterClient(this),window.removeEventListener(d.OPEN_ROOM_EVENT,this.boundOpenRoomListener),window.removeEventListener(d.START_DM_EVENT,this.boundStartDmListener),window.removeEventListener(d.NEW_CHAT_EVENT,this.boundNewChatListener),window.removeEventListener("chatleo:startCall",this.boundStartCallListener),"undefined"!=typeof navigator&&"serviceWorker"in navigator&&navigator.serviceWorker.removeEventListener("message",this.boundServiceWorkerMessage),this.chatStore?.removeEventListener("callRinging",this.boundCallRinging),this.chatStore?.removeEventListener("callChanged",this.boundCallChanged),this.chatStore?.removeEventListener("activeRoomChanged",this.boundActiveRoomChanged),this.chatStore?.removeEventListener("unreadTotalChanged",this.boundUnreadTotalChanged),this.chatStore?.removeEventListener("callRole",this.boundCallRole),this.stopRingtone(),this.callsChannel?.close()}async requestLibConnection(){console.debug("requestLibConnection",this.chatLeoLib),this.chatLeoLib?.setCallsEnabled?.("off"!==this.calls),this.pushSwPath&&this.chatLeoLib?.setPushServiceWorkerPath?.(this.pushSwPath),await(this.chatLeoLib?.requestConnection(this,{...this.ticket?{ticket:this.ticket}:{},...this.transport?{transport:this.transport}:{}}))}setLoading(e){this.loading=e}setLoggedIn(e){this.isLoggedIn=e,e&&(this.refreshCallsAvailability(),this.refreshPush())}setSessionExpired(e){this.isSessionExpired=e}setConnectionStatus(e){this.connectionStatus=e}async getConnectionStatus(){return{isConnected:this.chatStore?.isConnected??!1,isSessionExpired:this.isSessionExpired||(this.chatStore?.isSessionExpired??!1),connectionStatus:this.chatStore?.connectionStatus??this.connectionStatus}}async openRoom(e){e?this.useTray?await(this.trayEl?.openChatPanel(e,!1)):await(this.chatEl?.openRoom?.(e)):console.warn("[chatleo-component] openRoom called without roomId")}async closeRoom(){this.useTray?await(this.trayEl?.closeChatPanel?.()):await(this.chatEl?.closeRoom?.())}async getActiveRoomId(){return this.chatStore?.activeRoomId??null}async getDraft(){return await(this.chatEl?.getDraft?.())??""}async setDraft(e){e&&await(this.chatEl?.setDraft?.(e))}async addFiles(e){await(this.chatEl?.addFiles?.(e??[]))}async focusComposer(){await(this.chatEl?.focusComposer?.())}async openDirectMessageWithUser(e,t=!1){e?await this.internalStartDmFlow(e,t):console.warn("[chatleo-component] openDirectMessageWithUser called without userId")}async openNewChatDraft(){await(this.trayEl?.openChatPanel(void 0,!0))}async internalStartDmFlow(e,t=!1){if(e)try{const a=this.chatLeoLib?.findDirectMessageRoomIdByUser(e);if(console.debug("internalStartDmFlow",{existingRoomId:a}),a)return void await this.openRoom(a);const i=await(this.chatLeoLib?.ensureDirectMessageRoom(e,t)),n=i?.roomId;n?await this.openRoom(n):(console.warn("[chatleo-component] ensureDirectMessageRoom returned no roomId"),await(this.trayEl?.openChatPanel(void 0,!1)))}catch(e){console.error("[chatleo-component] Failed to start DM",e),await(this.trayEl?.openChatPanel(void 0,!1))}}async handleExternalOpenRoom(e){const t=e.roomId,a=e?.detail?.roomId||t;a?await this.openRoom(a):e?.detail||console.warn('[chatleo-component] chatleo:openRoom event missing detail. Use new CustomEvent("chatleo:openRoom", { detail: { roomId: "..." } })')}async handleExternalStartDm(e){console.log("handleExternalStartDm",e);const t=e.userId,a=e?.detail?.userId||t,i=e?.detail?.use_external_id??!1;a?await this.openDirectMessageWithUser(a,i):e?.detail||console.warn('[chatleo-component] chatleo:startDM event missing detail. Dispatch like: new CustomEvent("chatleo:startDM", { detail: { userId: "123" } })')}async handleExternalNewChat(e){await this.openNewChatDraft()}async refreshCallsAvailability(){this.callsAvailable=!("off"===this.calls||!this.chatLeoLib?.ensureCallsAvailable)&&await this.chatLeoLib.ensureCallsAvailable()}async loadCallComponents(){if("undefined"==typeof window||window.customElements.get("chatleo-call-adapter"))return!0;try{return await import("./p-BnCPdbII.js"),!!window.customElements.get("chatleo-call-adapter")}catch(e){return console.warn("[chatleo-component] call components could not be loaded",e),!1}}async startOrJoinCall(e,t,a){if(this.chatLeoLib)if(this.callView&&(t?this.callView.callId===t:this.callView.roomId===e))this.showCall=!0;else try{const i=this.chatStore?.rooms.find((t=>t.id===e)),n=t?{id:t,mode:"DirectMessage"===i?.type?"direct":"group"}:await this.chatLeoLib.startCall(e,a),o=await this.chatLeoLib.joinCall(n.id);if(!await this.loadCallComponents())return;this.callView={callId:n.id,roomId:e,mode:o.mode??n.mode,credentials:{sfuUrl:o.sfu_url,token:o.token,roomId:o.room_id,mode:o.mode,iceServers:o.ice_servers}},this.showCall=!0,this.incomingCall=null,this.stopRingtone()}catch(e){console.warn("[chatleo-component] call start/join failed",e)}}onIncomingCallChange(e){e&&setTimeout((()=>this.incomingRef?.focus()),0)}handleCallRinging(e){this.incomingCall=e.detail?.call??null,this.incomingCall?this.startRingtone(this.incomingCall.id):this.stopRingtone()}handleCallChanged(e){this.callView&&!e.detail?.call&&(this.callView=null,this.showCall=!1,this.stopRingtone())}async acceptIncomingCall(){if(!this.incomingCall)return;const e=this.incomingCall;this.incomingCall=null,this.stopRingtone(),await this.startOrJoinCall(e.room_id,e.id)}async declineIncomingCall(){if(!this.incomingCall||!this.chatLeoLib)return;const e=this.incomingCall;this.incomingCall=null,this.stopRingtone();try{await this.chatLeoLib.declineCall(e.id)}catch(e){console.warn("[chatleo-component] decline failed",e)}}handleExternalStartCall(e){const t=e?.detail?.roomId;t&&this.startOrJoinCall(t,void 0,e.detail.mode)}handleCallRole(e){const{callId:t,userId:a}=e.detail??{};this.callView&&this.callView.callId===t&&(a&&a!==this.chatStore?.profile?.id||this.callAdapterRef?.refreshToken?.().catch((e=>console.warn("[chatleo-component] token refresh after a role change failed",e))))}callToken=async()=>{const e=this.callView;if(!e||!this.chatLeoLib)throw new Error("no call");const t=await this.chatLeoLib.refreshCallToken(e.callId);return{token:t.token,sfuUrl:t.sfu_url,iceServers:t.ice_servers}};promoteInCall=async(e,t,a)=>{const i=this.callView;if(!i||!this.chatLeoLib||!a?.userId)throw new Error("unknown participant");await this.chatLeoLib.promoteCallParticipant(i.callId,a.userId)};demoteInCall=async(e,t)=>{const a=this.callView;if(!a||!this.chatLeoLib||!t?.userId)throw new Error("unknown participant");await this.chatLeoLib.demoteCallParticipant(a.callId,t.userId)};startRingtone(e){if("undefined"!=typeof window){if(this.callsChannel??="undefined"!=typeof BroadcastChannel?new BroadcastChannel("chatleo-calls"):void 0,this.callsChannel){const t=this.callsChannel;t.addEventListener("message",(t=>{"ring"===t.data?.type&&t.data.callId===e&&this.stopRingtone()}),{once:!0}),t.postMessage({type:"ring",callId:e})}try{const e=this.callRingtoneContext??new AudioContext;this.callRingtoneContext=e;const t=()=>{const t=e.createOscillator(),a=e.createGain();t.frequency.value=660,a.gain.value=.04,t.connect(a).connect(e.destination),t.start(),setTimeout((()=>t.stop()),180)};t(),this.callRingtoneTimer=setInterval(t,1200)}catch{}}}stopRingtone(){this.callRingtoneTimer&&(clearInterval(this.callRingtoneTimer),this.callRingtoneTimer=void 0)}async refreshPush(){if("off"!==this.push&&this.chatLeoLib?.pushState)try{this.pushState=await this.chatLeoLib.pushState()}catch{this.pushState=null}else this.pushState=null}async enablePush(){if(this.chatLeoLib?.enablePush)try{this.pushState=await this.chatLeoLib.enablePush(),this.pushPromptDismissed=!0}catch(e){console.warn("[chatleo-component] enabling push failed",e),await this.refreshPush()}}async disablePush(){if(this.chatLeoLib?.disablePush)try{this.pushState=await this.chatLeoLib.disablePush()}catch(e){console.warn("[chatleo-component] disabling push failed",e)}}handleServiceWorkerMessage(e){if("chatleo:pushVisibility"!==e.data?.type)"chatleo:openRoom"===e.data?.type&&e.data.roomId&&(this.openRoom(String(e.data.roomId)),"undefined"!=typeof navigator&&"clearAppBadge"in navigator&&navigator.clearAppBadge());else{const t=String(e.data.roomId??""),a="undefined"!=typeof document&&"visible"===document.visibilityState&&this.chatStore?.activeRoomId===t;e.ports?.[0]?.postMessage({visible:a})}}renderPushControl(){if("off"===this.push||!this.pushState)return null;const e=this.pushState;return"ios_install_required"===e.availability?t("div",{class:"push-control push-control--hint"},"Add ChatLeo to your home screen to enable notifications."):"available"!==e.availability?null:"denied"===e.permission?t("div",{class:"push-control push-control--hint"},"Notifications are blocked in your browser settings."):e.subscribed&&e.accountEnabled?t("button",{type:"button",class:"push-control",onClick:()=>{this.disablePush()}},"Notifications on"):"prompt"!==this.push||this.pushPromptDismissed?t("button",{type:"button",class:"push-control",onClick:()=>{this.enablePush()}},"Enable notifications"):t("div",{class:"push-control push-control--prompt",role:"region","aria-label":"Enable notifications"},t("span",null,"Get notified about new messages when ChatLeo is in the background."),t("button",{type:"button",onClick:()=>{this.enablePush()}},"Enable"),t("button",{type:"button",class:"push-control__secondary",onClick:()=>{this.pushPromptDismissed=!0}},"Not now"))}identityResolver={resolve:e=>Object.fromEntries(e.map((e=>{const t=this.chatStore?.usernameResolver(e);return[e,{displayName:t?.display_name??e,avatarUrl:t?.profile_picture_url??void 0}]})))};onCallError(e){const t=this.callView,a=e.detail?.code;t&&a&&["auth_rejected","removed","session_replaced","room_ended","room_full","network_failed"].includes(a)&&(this.callView=null,this.showCall=!1,"network_failed"===a&&this.chatLeoLib?.leaveCall(t.callId).catch((()=>{})))}onCallLeft(){const e=this.callView;e&&(this.callView=null,this.showCall=!1,this.chatLeoLib?.leaveCall(e.callId).catch((e=>console.warn("[chatleo-component] leave failed",e))))}onCallRequested(e){const t=e.detail;t?.roomId&&this.startOrJoinCall(t.roomId,t.callId)}onNewChatClicked(e){}onChatMessage(e){console.debug("messageChatSent",e),this.chatLeoLib?.sendChatMessage(e.detail)}async onUserSelectedForChat(e){const t=e.detail;t&&t.id&&await this.internalStartDmFlow(t.id)}get _connectionBannerLabel(){switch(this.connectionStatus){case"connecting":return"Verbindung wird hergestellt…";case"reconnecting":return"Verbindung wird wiederhergestellt…";case"disconnected":return"Offline";default:return null}}render(){const e=this._connectionBannerLabel;return t("div",{key:"d0c7c84ebf5fe164868f6e2250252a0899493ee3",style:{height:"100%",maxHeight:"inherit",width:"100%",display:"flex",flexDirection:"column",position:"relative",overflow:"hidden",minHeight:"0"}},this.renderPushControl(),e&&!this.isSessionExpired&&t("div",{key:"d5147662da351b027aba0542ae3dc5af161d2aa3",class:`connection-banner connection-banner--${this.connectionStatus}`},t("span",{key:"43cad2fcb7fd75d099fa8b73f482e7eb282c0957",class:"connection-banner__dot"}),e),this.useMain&&t("chatleo-chat",{key:"c3e5795f34cfa9cec09567ce6c1ef4fba3af1ed7",ref:e=>this.chatEl=e,chatStore:this.chatStore,callsAvailable:this.callsAvailable,inCall:!!this.callView,isOnline:this.chatStore?.isConnected??!1}),this.useTray&&t("chatleo-tray-component",{key:"1c11b399fedbf010e83fafccba106713771be48d",chatStore:this.chatStore,ref:e=>this.trayEl=e}),this.useRoomView&&t("chatleo-room-view",{key:"cd3e086d542ff5e93eed78e094552a19c9201c55",chatStore:this.chatStore,roomId:this.roomId,isOnline:this.chatStore?.isConnected??!1,pending:this.loading,callsAvailable:this.callsAvailable,inCall:!!this.callView}),this.callView&&t("div",{key:"579ab895faaba67e3c51841e57aa70b3d333e8ae",class:"call-layer",style:{display:this.showCall?"flex":"none"}},t("button",{key:"44f57f78e5111909d929403180aa3ec180dcf8d6",type:"button",class:"call-layer__back",onClick:()=>{this.showCall=!1}},"Chat"),t("chatleo-call-adapter",{ref:e=>this.callAdapterRef=e,callId:this.callView.callId,mode:this.callView.mode,connection:this.callView.credentials,autoJoin:!0,identity:this.identityResolver,getToken:this.callToken,promoteHandler:this.promoteInCall,demoteHandler:this.demoteInCall,style:{flex:"1",minHeight:"0"}})),this.incomingCall&&t("div",{key:"9a40dd687e2c9a717deecac05ab160919e6c91e4",class:"incoming-call",role:"dialog","aria-modal":"true","aria-label":`Incoming call from ${this.incomingCall.caller.display_name??this.incomingCall.caller.id}`,tabIndex:-1,ref:e=>this.incomingRef=e},t("div",{key:"901a91dc9d594aa6c22d34bb076b294ca7f4baff",class:"incoming-call__box"},t("p",{key:"de8604f814c54ff31365c71ff017529f65ad4562",class:"incoming-call__eyebrow"},"Incoming call"),t("chatleo-avatar",{key:"edbe19c7df4faebb8c82c124998242ab3ac057b4",name:this.incomingCall.caller.display_name??this.incomingCall.caller.id,url:this.incomingCall.caller.profile_picture_url??null,isOnline:!1}),t("p",{key:"12775d0d86490918c57e22afd0d132158c8970a8",class:"incoming-call__name"},this.incomingCall.caller.display_name??this.incomingCall.caller.id),t("div",{key:"1746d49c0b8df234a095d4738d3b86f3c0dadb5d",class:"incoming-call__actions"},t("button",{key:"269ad5b6bfc735321cc55cc20e9adcd6c0239a18",type:"button",class:"incoming-call__accept",onClick:()=>{this.acceptIncomingCall()}},"Accept"),t("button",{key:"8656c479150d95ea6fb2ec93aa06bda5f2fa4359",type:"button",class:"incoming-call__decline",onClick:()=>{this.declineIncomingCall()}},"Decline")))),this.isSessionExpired&&t("div",{key:"f46db890a91aa5c5e3aef489b93765bf1702fd8c",class:"session-expired-overlay"},t("div",{key:"1581ef80235822ace8660ff35fe6f493d69df0d2",class:"session-expired-box"},t("svg",{key:"6fe3be249ebfaec0871c6323057dbd8bdc106799",class:"session-expired-icon",xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none"},t("path",{key:"82078e08d808f6e8c5671c343c95d54c9cf35118",d:"M12 9v4M12 17h.01M10.29 3.86L1.82 18a2 2 0 001.71 3h16.94a2 2 0 001.71-3L13.71 3.86a2 2 0 00-3.42 0z",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"})),t("p",{key:"3611ca9c18813f4238dacadc669533a27f99da31",class:"session-expired-title"},"Session abgelaufen"),t("p",{key:"7140324b6246ed5eb1917c694b85c8ee5c491408",class:"session-expired-message"},"Deine Sitzung ist abgelaufen. Bitte lade die Seite neu, um fortzufahren."),t("button",{key:"f11ecf3aeb0cbd64ce064e90761d5736806619b4",class:"session-expired-button",onClick:()=>window.location.reload()},"Seite neu laden"))))}static get watchers(){return{chatLeoLib:[{onChatLeoLibChange:0}],chatStore:[{onChatStoreChange:0}],ticket:[{onTicketChange:0}],calls:[{onCallsChange:0}],incomingCall:[{onIncomingCallChange:0}]}}};d.style=":host{overflow:hidden;position:relative;height:100%;max-height:100%;min-height:0;--display:block;--bg-primary:#ffffff;--bg-secondary:#f3f4f6;--bg-light:#e7effc;--text-primary:#171a1f;--text-secondary:#9095a1;--border-color:#bdc1ca;--border-light:#eeeeee;--accent-color:#4a86e8;--accent-hover:#3a7bd8;--status-online:#21d184;--status-offline:#6b7280;--font-primary:'Manrope', sans-serif;--avatar-size:36px;--border-radius:8px;--transition-duration:0.2s;display:var(--display)}.connection-banner{display:flex;align-items:center;gap:6px;padding:5px 12px;font-family:var(--font-primary, 'Manrope', sans-serif);font-size:12px;font-weight:600;color:#fff;background:#6b7280;z-index:100;flex-shrink:0}.connection-banner--connecting,.connection-banner--reconnecting{background:#f59e0b;color:#fff}.connection-banner--disconnected{background:#ef4444;color:#fff}.connection-banner__dot{width:7px;height:7px;border-radius:50%;background:rgba(255, 255, 255, 0.8);flex-shrink:0;animation:pulse-dot 1.4s ease-in-out infinite}.connection-banner--disconnected .connection-banner__dot{animation:none}@keyframes pulse-dot{0%,100%{opacity:1}50%{opacity:0.3}}.session-expired-overlay{position:absolute;inset:0;z-index:9999;background:rgba(255, 255, 255, 0.85);backdrop-filter:blur(4px);display:flex;align-items:center;justify-content:center}.session-expired-box{background:var(--bg-primary, #fff);border:1px solid var(--border-color, #bdc1ca);border-radius:var(--border-radius, 8px);box-shadow:0 4px 24px rgba(0, 0, 0, 0.12);padding:32px 28px;max-width:340px;width:100%;text-align:center;display:flex;flex-direction:column;align-items:center;gap:12px}.session-expired-icon{color:#f59e0b;width:32px;height:32px}.session-expired-title{margin:0;font-family:var(--font-primary, 'Manrope', sans-serif);font-size:16px;font-weight:700;color:var(--text-primary, #171a1f)}.session-expired-message{margin:0;font-family:var(--font-primary, 'Manrope', sans-serif);font-size:13px;color:var(--text-secondary, #9095a1);line-height:1.6}.session-expired-button{margin-top:4px;padding:8px 20px;background:var(--accent-color, #4a86e8);color:#fff;border:none;border-radius:var(--border-radius, 8px);font-family:var(--font-primary, 'Manrope', sans-serif);font-size:14px;font-weight:600;cursor:pointer;transition:background var(--transition-duration, 0.2s)}.session-expired-button:hover{background:var(--accent-hover, #3a7bd8)}.call-layer{position:absolute;inset:0;z-index:40;background:var(--bg-primary, #fff);flex-direction:column}.call-layer__back{align-self:flex-end;margin:8px 16px 0;border:1px solid var(--border-color, #ddd);background:transparent;border-radius:6px;padding:4px 10px;font:inherit;cursor:pointer}.incoming-call{position:absolute;inset:0;z-index:50;display:flex;align-items:center;justify-content:center;background:rgba(15, 23, 42, 0.45)}.incoming-call:focus{outline:none}.incoming-call__box{width:min(320px, calc(100% - 32px));background:var(--bg-primary, #fff);border-radius:12px;padding:24px;text-align:center;box-shadow:0 18px 50px rgba(15, 23, 42, 0.25)}.incoming-call__eyebrow{margin:0 0 12px;font-size:12px;letter-spacing:0.08em;text-transform:uppercase;color:var(--text-secondary, #667)}.incoming-call__name{margin:12px 0 20px;font-size:18px;font-weight:700}.incoming-call__actions{display:flex;gap:10px;justify-content:center}.incoming-call__accept,.incoming-call__decline{border-radius:8px;padding:8px 18px;font:inherit;cursor:pointer}.incoming-call__accept{border:none;background:#1b8a3a;color:#fff}.incoming-call__decline{border:1px solid var(--border-color, #ddd);background:transparent;color:inherit}.push-control{display:flex;align-items:center;gap:8px;padding:6px 12px;border:0;border-bottom:1px solid var(--border-light, #eee);background:var(--bg-secondary, #f7f8fa);color:var(--text-primary, #222);font:inherit;font-size:12px;text-align:left;cursor:pointer}.push-control--hint{cursor:default;color:var(--text-secondary, #667)}.push-control--prompt{flex-wrap:wrap}.push-control--prompt button{border:1px solid var(--accent-color, #4a86e8);border-radius:6px;background:transparent;color:var(--accent-color, #4a86e8);padding:3px 10px;font:inherit;cursor:pointer}.push-control__secondary{border-color:var(--border-color, #ddd) !important;color:var(--text-secondary, #667) !important}";const h=class{constructor(t){e(this,t),this.userSelected=a(this,"userSelected"),this.doClose=a(this,"doClose")}chatStore;placeholder="Suche";filterText="";filteredUsers=[];_version=0;boundOnUserAdded=()=>this.onUserAdded();boundOnPresenceChange=()=>this.onPresenceChange();userSelected;doClose;onChatStoreChange(e,t){this.unbindChatStore(t),this.bindChatStore(e)}connectedCallback(){this.bindChatStore(this.chatStore)}disconnectedCallback(){this.unbindChatStore(this.chatStore)}bindChatStore(e){e&&(e.addEventListener("userAdded",this.boundOnUserAdded),e.addEventListener("presenceChanged",this.boundOnPresenceChange),this.updateFilteredUsers())}unbindChatStore(e){e&&(e.removeEventListener("userAdded",this.boundOnUserAdded),e.removeEventListener("presenceChanged",this.boundOnPresenceChange))}onUserAdded(){this.updateFilteredUsers()}onPresenceChange(){console.debug("onPresenceChange"),this._version++}onDoClose(e){e.preventDefault(),this.doClose.emit()}onFilterChange=e=>{this.filterText=e.target.value.toLowerCase(),this.updateFilteredUsers()};updateFilteredUsers(){const e=this.chatStore?.users??[],t=this.chatStore?.profile?.id,a=this.filterText;this.filteredUsers=e.filter((e=>e.id!==t&&(!a||(e.display_name||"").toLowerCase().includes(a))))}onUserSelected=e=>{const t=e.detail;t&&this.userSelected.emit(t)};render(){return t("div",{key:"ec5c9b8d53cce3ff5bc812dc4fc4ba3ab12bf6f8",class:"new-message-selector"},t("div",{key:"62d0468365a42452ccdd3de9aad50aa79d8eb029",class:"title"},"Neue Nachricht",t("button",{key:"74338599974c932922193040da99815d472d79da",class:"close-button",onClick:this.onDoClose.bind(this)},t("svg",{key:"c277fd2307e0fc618a4ea07146ac026828900cb7",width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg"},t("path",{key:"a30e06e02089d91366bc5bb9a653cf15ebb2f367",d:"M12 4L4 12",stroke:"#565D6D","stroke-width":"1.37143","stroke-miterlimit":"10","stroke-linecap":"square"}),t("path",{key:"f2583d2faf8f1ffefe43e273f2c07cde71dd5502",d:"M12 12L4 4",stroke:"#565D6D","stroke-width":"1.37143","stroke-miterlimit":"10","stroke-linecap":"square"})))),t("div",{key:"04983dc0b38f3f7c2bf133dfdfd8aba9a57358e4",class:"search-container"},t("input",{key:"77f351f89f4c78735d1ce34ef0f925d5bea92746",type:"text",class:"search-input",placeholder:this.placeholder,value:this.filterText,onInput:this.onFilterChange})),t("span",{key:"26ac88fea8e9855246a74e9196bd6da4c3ea1c88",class:"suggestions"},"Vorschläge"),t("div",{key:"58f1bfe2385d0f7ecaace341c6575135d1c84e63",class:"users-list"},this.filteredUsers.map((e=>{const a=this.chatStore?.isOnline(e.id)??!1;return t("chatleo-user-tile",{key:e.id,profile:e,isOnline:a,lastSeen:void 0,onUserClicked:this.onUserSelected})}))))}static get watchers(){return{chatStore:[{onChatStoreChange:0}]}}};h.style=":host{--input-bg:#F3F4F6;--text-placeholder:#9ca3af;--accent-shadow:rgba(59, 130, 246, 0.1);--container-padding:16px;--input-font-size:16px;--list-padding:8px;--tile-padding:12px 16px;display:block}.new-message-selector{display:flex;flex-direction:column;height:100%;max-height:70vh;background-color:var(--bg-primary);color:var(--text-secondary);box-sizing:border-box;width:100%}.title{padding:16px 16px 8px 16px;border-bottom:1px solid var(--border-color);font-weight:700;font-size:16px;color:#171A1F;display:flex;flex-direction:row;justify-content:space-between}.close-button{background:none;border:none;cursor:pointer;font-size:16px;color:var(--text-secondary)}.search-container{padding:16px;flex-shrink:0}.search-input{width:100%;border:0;font-size:14px;border-radius:var(--border-radius);outline:none;background-color:var(--input-bg);color:var(--text-secondary);padding:8px;box-sizing:border-box}.search-input:focus{border-color:var(--accent-color);}.search-input::placeholder{color:var(--text-placeholder)}.suggestions{padding:0 16px;font-size:14px}.users-list{flex:1;overflow-y:auto;}.users-list chatleo-user-tile{padding:8px 16px;display:block;--user-tile-border:none}.users-list chatleo-user-tile:hover{background-color:var(--hover-color)}chatleo-user-tile chatleo-avatar{--avatar-size:36px}";const l=class{constructor(t){e(this,t),this.contentChange=a(this,"contentChange"),this.messageSend=a(this,"messageSend")}get hostElement(){return i(this)}disabled=!1;placeholder="Write a message...";maxHeight="200px";acceptFiles="image/*,.pdf,.doc,.docx,.txt";isDragOver=!1;hasContent=!1;contentChange;messageSend;editorRef;fileInputRef;async getText(){return this.editorRef?.innerText??""}async setText(e){this.editorRef&&(this.editorRef.innerText=e??"",this.placeCaretAtEnd(this.editorRef),this.emitContentChange())}async addFiles(e){e?.length&&await this.handleFiles(e)}async focusEditor(){this.editorRef&&(this.editorRef.focus(),this.placeCaretAtEnd(this.editorRef))}generateAttachmentId(){return crypto.randomUUID()}isImageFile(e){return e.type.startsWith("image/")}async generateThumbnail(e){if(this.isImageFile(e))return new Promise((t=>{const a=new FileReader;a.onload=e=>{const a=new Image;a.onload=()=>{const e=document.createElement("canvas"),i=e.getContext("2d"),n=100;let{width:o,height:s}=a;o>s?o>n&&(s*=n/o,o=n):s>n&&(o*=n/s,s=n),e.width=o,e.height=s,i?.drawImage(a,0,0,o,s),t(e.toDataURL("image/jpeg",.8))},a.src=e.target?.result},a.readAsDataURL(e)}))}async handleFiles(e){const t=Array.from(e),a=[];for(const e of t){const t={mime_type:e.type,id:this.generateAttachmentId(),file:e,name:e.name,size:e.size};t.mime_type.startsWith("image")&&(t.preview=await this.generateThumbnail(e)),a.push(t)}a.length>0&&this.insertAttachmentsAtCursor(a),this.emitContentChange()}getEditorSelection(){if(!this.editorRef)return null;const e=this.hostElement.shadowRoot,t=e&&"function"==typeof e.getSelection?e.getSelection():window.getSelection();if(!t||0===t.rangeCount)return null;const a=t.anchorNode;return a&&this.editorRef.contains(a)?t:null}placeCaretAtEnd(e){const t=document.createRange();t.selectNodeContents(e),t.collapse(!1);const a=this.hostElement.shadowRoot?.getSelection?.()??window.getSelection();a?.removeAllRanges(),a?.addRange(t)}insertAttachmentsAtCursor(e){if(!this.editorRef)return;const t=this.createAttachmentBlock(e);this.editorRef.focus();let a=this.getEditorSelection();if(a||(this.placeCaretAtEnd(this.editorRef),a=this.getEditorSelection()),a&&a.rangeCount>0){const e=a.getRangeAt(0);if(e.startContainer.nodeType===Node.TEXT_NODE&&e.startOffset>0){e.setStart(e.startContainer,e.startContainer.textContent?.length||0),e.collapse(!0);const t=document.createElement("br");e.insertNode(t),e.setStartAfter(t)}e.insertNode(t);const i=document.createElement("br");return e.setStartAfter(t),e.insertNode(i),e.setStartAfter(i),e.collapse(!0),a.removeAllRanges(),void a.addRange(e)}this.editorRef.innerHTML.trim()&&!this.editorRef.innerHTML.endsWith("<br>")&&this.editorRef.appendChild(document.createElement("br")),this.editorRef.appendChild(t);const i=document.createElement("br");this.editorRef.appendChild(i),this.placeCaretAtEnd(this.editorRef)}createAttachmentBlock(e){const t=document.createElement("div");t.className="attachment-block",t.contentEditable="false",1===e.length&&(t.setAttribute("data-attachment-id",e[0].id),t._attachmentData=e[0]),t._attachmentsData=e;const a=document.createElement("div");return a.className="attachment-content",e.forEach((e=>{const i=document.createElement("div");if(i.className="attachment-item",e.mime_type.startsWith("image")&&e.preview){const t=document.createElement("img");t.src=e.preview,t.alt=e.name,t.className="attachment-thumbnail",i.appendChild(t)}else{const e=document.createElement("div");e.className="attachment-icon",e.innerHTML='\n <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none">\n <path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>\n <polyline points="14,2 14,8 20,8" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>\n </svg>\n ',i.appendChild(e)}const n=document.createElement("div");n.className="attachment-info";const o=document.createElement("div");o.className="attachment-name",o.textContent=e.name,n.appendChild(o);const s=document.createElement("div");s.className="attachment-size",s.textContent=this.formatFileSize(e.size),n.appendChild(s),i.appendChild(n);const r=document.createElement("button");r.className="attachment-remove",r.type="button",r.innerHTML='\n <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16" fill="none">\n <path d="M12 4L4 12M4 4l8 8" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>\n </svg>\n ',r.onclick=a=>{a.preventDefault(),a.stopPropagation(),this.removeAttachmentFromBlock(t,e.id)},i.appendChild(r),a.appendChild(i)})),t.appendChild(a),t}removeAttachmentFromBlock(e,t){const a=e._attachmentsData;if(a){const i=a.filter((e=>e.id!==t));if(0===i.length)this.removeAttachmentBlock(e);else{e._attachmentsData=i,1===i.length?(e._attachmentData=i[0],e.setAttribute("data-attachment-id",i[0].id)):(delete e._attachmentData,e.removeAttribute("data-attachment-id"));const t=this.createAttachmentBlock(i);e.replaceWith(t),this.emitContentChange()}}}removeAttachmentBlock(e){if(e.parentNode){const t=e.nextSibling;t&&"BR"===t.nodeName&&t.parentNode?.removeChild(t),e.parentNode.removeChild(e),this.emitContentChange()}}handleInput=()=>{this.emitContentChange()};extractContent(){if(!this.editorRef)return{text:"",attachments:[]};let e="";const t=[];if(document.createTreeWalker){const a=document.createTreeWalker(this.editorRef,NodeFilter.SHOW_TEXT|NodeFilter.SHOW_ELEMENT,{acceptNode:e=>{if(e.nodeType===Node.TEXT_NODE)return NodeFilter.FILTER_ACCEPT;if(e.nodeType===Node.ELEMENT_NODE){const t=e;if(t.classList.contains("attachment-block"))return NodeFilter.FILTER_ACCEPT;if("BR"===t.tagName)return NodeFilter.FILTER_ACCEPT}return NodeFilter.FILTER_SKIP}});let i;for(;i=a.nextNode();)if(i.nodeType===Node.TEXT_NODE)e+=i.textContent||"";else if(i.nodeType===Node.ELEMENT_NODE){const a=i;if(a.classList.contains("attachment-block")){const i=a._attachmentsData,n=a._attachmentData;i?t.push(...i):n&&t.push(n),e+="\n[attachment]\n"}else"BR"===a.tagName&&(e+="\n")}}else{const a=[],i=e=>{a.push(e),e.childNodes.forEach(i)};i(this.editorRef);for(const i of a)if(i.nodeType===Node.TEXT_NODE)e+=i.textContent||"";else if(i.nodeType===Node.ELEMENT_NODE){const a=i;if(a.classList.contains("attachment-block")){const i=a._attachmentsData,n=a._attachmentData;i?t.push(...i):n&&t.push(n),e+="\n[attachment]\n"}else"BR"===a.tagName&&(e+="\n")}}return{text:e.trim(),attachments:t}}generateHtmlContent(e){const t=[];for(const a of e)if("text"===a.type){const e=a.content.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/\n/g,"<br>");t.push(`<div data-block-id="${a.id}" data-block-type="text">${e}</div>`)}else if("attachment"===a.type){const e=a.attachments,i=e.map((e=>`\n <div class="attachment-item" data-attachment-id="${e.id}" data-attachment-type="${e.mime_type}" data-attachment-name="${this.escapeHtml(e.name)}" data-attachment-size="${e.size}">\n ${e.mime_type?.startsWith("image")&&e.preview?`<img src="${e.preview}" alt="${this.escapeHtml(e.name)}" class="attachment-thumbnail">`:'<div class="attachment-icon">\n <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none">\n <path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>\n <polyline points="14,2 14,8 20,8" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>\n </svg>\n </div>'}\n <div class="attachment-info">\n <div class="attachment-name">${this.escapeHtml(e.name)}</div>\n <div class="attachment-size">${this.formatFileSize(e.size)}</div>\n </div>\n </div>\n `)).join("\n");t.push(`\n <div class="attachment-block" data-block-id="${a.id}" data-block-type="attachment" data-attachment-count="${e.length}">\n <div class="attachment-content">\n ${i}\n </div>\n </div>`.trim())}return t.join("\n")}escapeHtml(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}extractStructuredContent(){if(!this.editorRef)return{blocks:[],version:"1.0",html:""};const e=[];let t=0;const a=Array.from(this.editorRef.childNodes);let i="";const n=()=>{if(i.length>0){const a={id:"text_"+ ++t,type:"text",content:i};e.push(a),i=""}};for(const o of a)if(o.nodeType===Node.TEXT_NODE){const e=o.textContent??"";e.length>0&&(i+=e)}else if(o.nodeType===Node.ELEMENT_NODE){const a=o;if(a.classList.contains("attachment-block")){n();const i=a._attachmentsData,o=a._attachmentData;if(i){const a={id:"attachment_"+ ++t,type:"attachment",attachments:i};e.push(a)}else if(o){const a={id:"attachment_"+ ++t,type:"attachment",attachments:[o]};e.push(a)}}else if("BR"===a.tagName)i+="\n";else{const e=a.textContent??"";e.length>0&&(i+=e),this.isBlockElement(a)&&!i.endsWith("\n")&&(i+="\n")}}n();const o=this.generateHtmlContent(e);return{blocks:e,version:"1.0",html:o}}isBlockElement(e){return new Set(["DIV","P","PRE","LI","UL","OL","H1","H2","H3","H4","H5","H6","BLOCKQUOTE"]).has(e.tagName)}handleKeyDown=e=>{"Enter"!==e.key||e.shiftKey||(e.preventDefault(),this.handleSendMessage())};handleFileButtonClick=()=>{this.fileInputRef?.click()};handleFileInputChange=e=>{const t=e.target;t.files&&t.files.length>0&&(this.handleFiles(t.files),t.value="")};handleDragOver=e=>{e.preventDefault(),e.stopPropagation(),this.isDragOver=!0};handleDragLeave=e=>{e.preventDefault(),e.stopPropagation(),this.isDragOver=!1};handleDrop=async e=>{e.preventDefault(),e.stopPropagation(),this.isDragOver=!1;const t=e.dataTransfer?.files;if(t&&t.length>0){const a=document.caretRangeFromPoint(e.clientX,e.clientY);if(a&&this.editorRef?.contains(a.startContainer)){const e=window.getSelection();e?.removeAllRanges(),e?.addRange(a)}await this.handleFiles(t)}};handleSendMessage=()=>{const e=this.extractContent(),t=this.extractStructuredContent();console.debug("handleSendMessage",t.blocks),(e.text.trim()||e.attachments.length>0)&&(this.messageSend.emit(t),this.editorRef&&(this.editorRef.innerHTML=""),this.emitContentChange())};emitContentChange=()=>{const e=this.extractContent(),t=!!(e.text.trim()||e.attachments.length>0);this.hasContent!==t&&(this.hasContent=t),this.contentChange.emit(e)};formatFileSize=e=>{if(0===e)return"0 Bytes";const t=Math.floor(Math.log(e)/Math.log(1024));return parseFloat((e/Math.pow(1024,t)).toFixed(2))+" "+["Bytes","KB","MB","GB"][t]};render(){const e=this.hasContent;return t("div",{key:"2a3b14309017d69790c17db7591a28f82f49cee4",class:"rich-input-container "+(this.isDragOver?"drag-over":""),onDragOver:this.handleDragOver,onDragLeave:this.handleDragLeave,onDrop:this.handleDrop},t("div",{key:"4a2310a460ed29c6d47dd1683f070ebbd054b73a",class:"editor-area"},t("div",{key:"922433e6227fdd46fa71fdc5b05f1c508fcab423",class:"editor-wrapper"},t("div",{key:"6fd7691dab9e056058a0109dfe708e6bd3236c4b",ref:e=>this.editorRef=e,class:"rich-editor",contentEditable:!this.disabled,onInput:this.handleInput,onKeyDown:this.handleKeyDown,"data-placeholder":this.placeholder,style:{maxHeight:this.maxHeight}}),t("div",{key:"7ef1ab99474753beafcbf08e85d55e1037b887ff",class:"input-actions"},t("button",{key:"622970886800a5f602a079598d283eea9a1f0689",class:"action-button file-button",onClick:this.handleFileButtonClick,disabled:this.disabled,type:"button"},t("svg",{key:"722d7fb7a68b08888039e36f58d16d39472ad229",xmlns:"http://www.w3.org/2000/svg",width:"17",height:"16",viewBox:"0 0 17 16",fill:"none"},t("path",{key:"e06306ea498415db01f587e218637594b90a8983",d:"M11.9286 3.42858L11.9286 10.5714C11.9286 12.6286 10.2714 14.2857 8.21429 14.2857C6.15714 14.2857 4.5 12.6286 4.5 10.5714L4.5 4.28572C4.5 2.85715 5.64286 1.71429 7.07143 1.71429C8.5 1.71429 9.64286 2.85715 9.64286 4.28572L9.64286 10C9.64286 10.8 9.01429 11.4286 8.21429 11.4286C7.41429 11.4286 6.78571 10.8 6.78571 10L6.78571 5.14287",stroke:"#4A86E8","stroke-width":"1.5","stroke-miterlimit":"10","stroke-linecap":"square"}))),t("button",{key:"717f2e6f57f4b8316ffa58da639f695f4e55ca6f",class:"action-button file-button",onClick:this.handleFileButtonClick,disabled:this.disabled,type:"button"},t("svg",{key:"08a5a232a719d8e4e18053d469e868aeeba1972b",xmlns:"http://www.w3.org/2000/svg",width:"33",height:"32",viewBox:"0 0 33 32",fill:"none"},t("path",{key:"c642251b6186dde4ab105f7655c212f510734693",d:"M10.5 18.5312L14.3226 14.7683C14.6047 14.4907 15.062 14.4907 15.344 14.7683L18.4444 17.8203M18.4444 17.8203L17.3611 18.8867M18.4444 17.8203L19.7393 16.5457C20.0214 16.268 20.4786 16.268 20.7607 16.5457L23.5 19.2422M11.9444 21.375H22.0556C22.8533 21.375 23.5 20.7384 23.5 19.9531V11.4219C23.5 10.6366 22.8533 10 22.0556 10H11.9444C11.1467 10 10.5 10.6366 10.5 11.4219V19.9531C10.5 20.7384 11.1467 21.375 11.9444 21.375ZM21.6944 13.1992C21.6944 13.9845 21.0477 14.6211 20.25 14.6211C19.4523 14.6211 18.8056 13.9845 18.8056 13.1992C18.8056 12.4139 19.4523 11.7773 20.25 11.7773C21.0477 11.7773 21.6944 12.4139 21.6944 13.1992Z",stroke:"#4A86E8","stroke-width":"1.5","stroke-linecap":"round","stroke-linejoin":"round"}))),t("button",{key:"caa33c6d18525872a4ee2d672bee04a549779499",class:"action-button send-button",onClick:this.handleSendMessage,disabled:this.disabled||!e,type:"button"},t("svg",{key:"c111af09449b62afeb754eb691abdeee59c092ce",xmlns:"http://www.w3.org/2000/svg",width:"17",height:"16",viewBox:"0 0 17 16",fill:"none"},t("path",{key:"c7a9328a8abe02f7aa16dbae45574639bc94eb37",d:"M14.214 2.28564L5.64258 9.14279L5.64258 13.1428L7.69972 10.6856",stroke:"#4A86E8","stroke-width":"1.5","stroke-miterlimit":"10"}),t("path",{key:"0e141532e3694d564b8eab7240fd80a2ce172a7c",d:"M2.78613 6.85707L14.2147 2.28564L11.929 13.7142L2.78613 6.85707Z",stroke:"#4A86E8","stroke-width":"1.5","stroke-miterlimit":"10","stroke-linecap":"square"})))))),t("input",{key:"ed2eb79d5e731a3c324943439f5fcc8cee484e66",ref:e=>this.fileInputRef=e,type:"file",accept:this.acceptFiles,multiple:!0,onChange:this.handleFileInputChange,style:{display:"none"}}),this.isDragOver&&t("div",{key:"7d1deb8bc1c5cceac823ea6aa08de5c81e412e3d",class:"drag-overlay"},t("div",{key:"c27aff7a27b17eb06c4b79f25901e2db7c11be69",class:"drag-content"},t("svg",{key:"13c7243782c1fb604113ec8e09a53cd44aabb1e4",xmlns:"http://www.w3.org/2000/svg",width:"48",height:"48",viewBox:"0 0 48 48",fill:"none"},t("path",{key:"0ac333bcd102668edcf034e559a75cbd64e7bdd8",d:"M38 20v16a4 4 0 0 1-4 4H14a4 4 0 0 1-4-4V20M32 10L24 2l-8 8M24 2v28",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"})),t("p",{key:"4addb3c7733503a556958fa9b46b2c520cc3bf5d"},"Dateien hier ziehen"))))}};l.style=":host{display:block;--rich-input-border-radius:12px;--rich-input-padding:4px;--attachment-item-radius:8px;--attachment-preview-size:60px;--min-input-height:18px;--max-input-height:120px;--transition-duration:0.2s}.rich-input-container{position:relative;background:var(--bg-primary, #ffffff);}.rich-input-container:focus-within{border-color:var(--accent-color, #4a86e8);box-shadow:0 0 0 2px rgba(74, 134, 232, 0.1)}.rich-input-container.drag-over{border-color:var(--accent-color, #4a86e8);background:var(--bg-light, #f8fafc)}.editor-area{padding:var(--rich-input-padding)}.editor-wrapper{display:flex;align-items:flex-end;gap:12px}.rich-editor{flex:1;min-height:var(--min-input-height);max-height:var(--max-input-height, 200px);overflow-y:auto;padding:12px 16px;border:none;outline:none;background:var(--bg-secondary, #f8f9fa);border-radius:20px;font-family:var(--font-primary, system-ui, sans-serif);font-size:14px;line-height:1.4;color:var(--text-primary, #212529);white-space:pre-wrap;word-wrap:break-word;resize:none;transition:background-color var(--transition-duration) ease}.rich-editor:focus{}@media (max-width: 768px){.rich-editor{font-size:16px}}.rich-editor:empty::before{content:attr(data-placeholder);color:var(--text-secondary, #6c757d);pointer-events:none}.rich-editor:focus:empty::before{content:''}.attachment-block{display:block;background:var(--bg-secondary, #f8f9fa);border:1px solid var(--border-light, #e9ecef);border-radius:var(--attachment-item-radius);padding:8px;margin:8px 0;max-width:300px;position:relative;box-sizing:border-box;user-select:none;-webkit-user-select:none}.attachment-block .attachment-content{display:flex;flex-direction:column;gap:8px;flex:1;min-width:0}.attachment-item{display:flex;align-items:center;gap:8px;position:relative;min-width:0}.attachment-block .attachment-thumbnail{width:var(--attachment-preview-size);height:var(--attachment-preview-size);object-fit:cover;border-radius:4px;flex-shrink:0}.attachment-item .attachment-thumbnail{width:var(--attachment-preview-size);height:var(--attachment-preview-size);object-fit:cover;border-radius:4px;flex-shrink:0}.attachment-block .attachment-icon{width:var(--attachment-preview-size);height:var(--attachment-preview-size);display:flex;align-items:center;justify-content:center;background:var(--bg-light, #f1f3f4);border-radius:4px;color:var(--text-secondary, #6c757d);flex-shrink:0}.attachment-item .attachment-icon{width:var(--attachment-preview-size);height:var(--attachment-preview-size);display:flex;align-items:center;justify-content:center;background:var(--bg-light, #f1f3f4);border-radius:4px;color:var(--text-secondary, #6c757d);flex-shrink:0}.attachment-block .attachment-info{flex:1;min-width:0}.attachment-item .attachment-info{flex:1;min-width:0}.attachment-block .attachment-name{font-size:12px;font-weight:500;color:var(--text-primary, #212529);white-space:nowrap;overflow:hidden;text-overflow:ellipsis;line-height:1.3}.attachment-item .attachment-name{font-size:12px;font-weight:500;color:var(--text-primary, #212529);white-space:nowrap;overflow:hidden;text-overflow:ellipsis;line-height:1.3}.attachment-block .attachment-size{font-size:11px;color:var(--text-secondary, #6c757d);line-height:1.2}.attachment-item .attachment-size{font-size:11px;color:var(--text-secondary, #6c757d);line-height:1.2}.attachment-block .attachment-remove{position:absolute;top:-6px;right:-6px;width:20px;height:20px;border:none;background:var(--bg-primary, #ffffff);border-radius:50%;display:flex;align-items:center;justify-content:center;cursor:pointer;box-shadow:0 2px 4px rgba(0, 0, 0, 0.1);color:var(--text-secondary, #6c757d);transition:all var(--transition-duration) ease}.attachment-item .attachment-remove{position:absolute;top:-6px;right:-6px;width:20px;height:20px;border:none;background:var(--bg-primary, #ffffff);border-radius:50%;display:flex;align-items:center;justify-content:center;cursor:pointer;box-shadow:0 2px 4px rgba(0, 0, 0, 0.1);color:var(--text-secondary, #6c757d);transition:all var(--transition-duration) ease}.attachment-block .attachment-remove:hover{background:#dc3545;color:white;transform:scale(1.1)}.attachment-item .attachment-remove:hover{background:#dc3545;color:white;transform:scale(1.1)}.rich-editor::-webkit-scrollbar{width:4px}.rich-editor::-webkit-scrollbar-track{background:transparent}.rich-editor::-webkit-scrollbar-thumb{background:var(--border-color, #dee2e6);border-radius:2px}.rich-editor::-webkit-scrollbar-thumb:hover{background:var(--text-secondary, #6c757d)}.input-actions{display:flex;flex-direction:row;align-items:flex-end;gap:2px}.action-button{width:36px;height:36px;border:none;background:transparent;border-radius:18px;cursor:pointer;display:flex;align-items:center;justify-content:center;color:var(--accent-color, #4a86e8);transition:all var(--transition-duration) ease;flex-shrink:0}.action-button:hover:not(:disabled){background:var(--bg-light, #f1f3f4);transform:scale(1.05)}.action-button:disabled{color:var(--text-secondary, #6c757d);cursor:not-allowed;opacity:0.5}.send-button:not(:disabled){color:white}.send-button:hover:not(:disabled){background:var(--accent-hover, #3d71d9)}.drag-overlay{position:absolute;top:0;left:0;right:0;bottom:0;background:rgba(74, 134, 232, 0.05);border:2px dashed var(--accent-color, #4a86e8);border-radius:var(--rich-input-border-radius);display:flex;align-items:center;justify-content:center;z-index:10}.drag-content{text-align:center;color:var(--accent-color, #4a86e8)}.drag-content svg{margin-bottom:8px}.drag-content p{margin:0;font-size:14px;font-weight:500}@media (max-width: 768px){:host{--rich-input-padding:12px;--attachment-preview-size:48px}.attachment-block{max-width:260px}.action-button{width:32px;height:32px}}";const f=class{constructor(t){e(this,t)}content;downloadUrls={};alignment="left";translations={};attachmentStates={};MAX_RETRIES=3;INITIAL_RETRY_DELAY_MS=1e3;FETCH_TIMEOUT_MS=5e3;initAttachmentState(e){this.attachmentStates[e]||(this.attachmentStates={...this.attachmentStates,[e]:{isLoading:!1,retryCount:0,hasError:!1}})}async handleImageError(e,t,a){this.initAttachmentState(e);const i=this.attachmentStates[e];if(console.log("handleImageError",e,i),!t.startsWith("image/")||i.retryCount>=this.MAX_RETRIES)return this.attachmentStates={...this.attachmentStates,[e]:{...i,isLoading:!1,hasError:!0}},void(a.src=this.getPlaceholderIcon(t));const n=this.downloadUrls[e];if(!n)return this.attachmentStates={...this.attachmentStates,[e]:{...i,isLoading:!1,hasError:!0}},void(a.src=this.getPlaceholderIcon(t));try{const o=new AbortController,s=setTimeout((()=>o.abort()),this.FETCH_TIMEOUT_MS);try{const r=await fetch(n.download_url,{method:"HEAD",signal:o.signal});if(clearTimeout(s),console.debug("HEAD response",r),404===r.status){this.attachmentStates={...this.attachmentStates,[e]:{...i,isLoading:!0,retryCount:i.retryCount+1}};const t=this.INITIAL_RETRY_DELAY_MS*Math.pow(2,i.retryCount);await new Promise((e=>setTimeout(e,t))),this.attachmentStates={...this.attachmentStates,[e]:{...this.attachmentStates[e],isLoading:!1}};const o=new URL(n.download_url);o.searchParams.set("retry",String(Date.now())),a.src=o.toString()}else this.attachmentStates={...this.attachmentStates,[e]:{...i,isLoading:!1,hasError:!0}},a.src=this.getPlaceholderIcon(t)}catch(n){clearTimeout(s),this.attachmentStates={...this.attachmentStates,[e]:{...i,isLoading:!1,hasError:!0}},a.src=this.getPlaceholderIcon(t)}}catch(n){this.attachmentStates={...this.attachmentStates,[e]:{...i,isLoading:!1,hasError:!0}},a.src=this.getPlaceholderIcon(t)}}renderLoadingSpinner(){return t("div",{class:"loading-spinner"},t("svg",{width:"24",height:"24",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg"},t("circle",{class:"spinner-circle",cx:"12",cy:"12",r:"10",fill:"none",stroke:"#6b7280","stroke-width":"2"})))}defaultTranslations={unsupported_content:"Unsupported content"};t(e){return this.translations[e]||this.defaultTranslations[e]||e}renderPlainText(e){const a=e.split("\n"),i=[];return a.forEach(((e,n)=>{e&&i.push(e),n<a.length-1&&i.push(t("br",null))})),i}renderTextBlock(e){return e.content?t("p",null,this.renderPlainText(String(e.content))):null}renderUnknownBlock(e){return"string"==typeof e?.fallback_text&&e.fallback_text.length>0?t("p",null,this.renderPlainText(e.fallback_text)):t("p",{class:"unsupported-content"},this.t("unsupported_content"))}blockRenderers={text:e=>this.renderTextBlock(e),attachment:e=>this.renderAttachmentBlock(e)};generateThumbnail(e,t){const a=this.downloadUrls[e];return console.debug("generateThumbnail",{downloadUrls:this.downloadUrls,attachmentId:e,downloadInfo:a}),a&&a.mime_type.startsWith("image/")?a.download_url:this.getPlaceholderIcon(t)}getPlaceholderIcon(e){const t="#6b7280";return e.startsWith("image/")?`data:image/svg+xml,${encodeURIComponent(`\n <svg width="48" height="48" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">\n <rect x="3" y="3" width="18" height="18" rx="2" ry="2" stroke="${t}" stroke-width="2" fill="none"/>\n <circle cx="8.5" cy="8.5" r="1.5" fill="${t}"/>\n <polyline points="21,15 16,10 5,21" stroke="${t}" stroke-width="2" fill="none"/>\n </svg>\n `)}`:e.includes("pdf")?`data:image/svg+xml,${encodeURIComponent(`\n <svg width="48" height="48" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">\n <path d="M14,2H6A2,2 0 0,0 4,4V20A2,2 0 0,0 6,22H18A2,2 0 0,0 20,20V8L14,2M18,20H6V4H13V9H18V20Z" fill="${t}"/>\n </svg>\n `)}`:`data:image/svg+xml,${encodeURIComponent(`\n <svg width="48" height="48" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">\n <path d="M14,2H6A2,2 0 0,0 4,4V20A2,2 0 0,0 6,22H18A2,2 0 0,0 20,20V8L14,2M18,20H6V4H13V9H18V20Z" stroke="${t}" stroke-width="2" fill="none"/>\n <polyline points="14,2 14,8 20,8" stroke="${t}" stroke-width="2" fill="none"/>\n </svg>\n `)}`}renderAttachmentBlock(e){if(!e.attachments||0===e.attachments.length)return null;const a=e.attachments.map((e=>{const a=this.generateThumbnail(e.id,e.mime_type),i=this.downloadUrls[e.id];this.initAttachmentState(e.id);const n=this.attachmentStates[e.id];return t("div",{class:"attachment-item",key:e.id},t("div",{class:"attachment-thumbnail"},e.mime_type.startsWith("image/")?t("div",{class:"image-container"},t("img",{src:a,alt:"Image attachment",onError:t=>{this.handleImageError(e.id,e.mime_type,t.target)},style:{display:n.isLoading?"none":"block"}}),n.isLoading&&this.renderLoadingSpinner()):t("img",{src:a,alt:"File attachment"})),i&&t("div",{class:"attachment-overlay"},t("a",{href:i.download_url,target:"_blank",rel:"noopener noreferrer"},t("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},t("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",stroke:"white","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"}),t("polyline",{points:"7,10 12,15 17,10",stroke:"white","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"}),t("line",{x1:"12",y1:"15",x2:"12",y2:"3",stroke:"white","stroke-width":"2","stroke-linecap":"round"})))))}));return t("p",null,t("div",{class:"attachment-container"},a))}render(){if(!this.content||!this.content.blocks)return t("div",{class:`rich-message-content ${this.alignment}`});const e=this.content.blocks.map((e=>{const t=Object.prototype.hasOwnProperty.call(this.blockRenderers,e?.type)?this.blockRenderers[e.type]:void 0;return t?t(e):this.renderUnknownBlock(e)}));return t("div",{class:`rich-message-content ${this.alignment}`},e)}};f.style=":host{display:block}.rich-message-content{width:100%}.rich-message-content.left{text-align:left}.rich-message-content.right{text-align:right}.rich-message-content p{margin:0.5em 0;line-height:1.4}.rich-message-content p:first-child{margin-top:0}.rich-message-content p:last-child{margin-bottom:0}.attachment-container{display:flex;gap:8px;overflow-x:auto;padding:4px 0;scrollbar-width:thin}.attachment-container::-webkit-scrollbar{height:4px}.attachment-container::-webkit-scrollbar-track{background:#f1f1f1;border-radius:2px}.attachment-container::-webkit-scrollbar-thumb{background:#c1c1c1;border-radius:2px}.attachment-container::-webkit-scrollbar-thumb:hover{background:#a8a8a8}.attachment-item{position:relative;flex-shrink:0;width:80px;height:80px;border-radius:8px;overflow:hidden;background-color:#f5f5f5;border:1px solid #e5e5e5;cursor:pointer;transition:transform 0.2s ease, box-shadow 0.2s ease}.attachment-item:hover{transform:scale(1.05);box-shadow:0 4px 8px rgba(0, 0, 0, 0.1)}.attachment-thumbnail{width:100%;height:100%;display:flex;align-items:center;justify-content:center}.attachment-thumbnail img{width:100%;height:100%;object-fit:cover;border-radius:7px}.image-container{width:100%;height:100%;display:flex;align-items:center;justify-content:center;position:relative}.loading-spinner{display:flex;align-items:center;justify-content:center;width:100%;height:100%}.spinner-circle{animation:spin 1s linear infinite;transform-origin:center;stroke-dasharray:50;stroke-dashoffset:0}@keyframes spin{0%{transform:rotate(0deg);stroke-dashoffset:0}50%{stroke-dashoffset:25}100%{transform:rotate(360deg);stroke-dashoffset:50}}.attachment-overlay{position:absolute;top:0;left:0;right:0;bottom:0;background:rgba(0, 0, 0, 0.3);display:flex;align-items:center;justify-content:center;opacity:0;transition:opacity 0.2s ease;border-radius:7px}.attachment-item:hover .attachment-overlay{opacity:1}.attachment-overlay a{display:flex;align-items:center;justify-content:center;width:32px;height:32px;background:rgba(0, 0, 0, 0.6);border-radius:50%;text-decoration:none;transition:background 0.2s ease}.attachment-overlay a:hover{background:rgba(0, 0, 0, 0.8)}.rich-message-content.right .attachment-container{justify-content:flex-end}";const p=class{constructor(t){e(this,t)}rooms=[];chatStore;selectedRoomId;_version=0;isNewChatOpen=!1;onChatStoreChange(e,t){e&&(e.addEventListener("presenceChanged",this.onPresenceChange.bind(this)),e.addEventListener("roomReadCountChanged",(()=>{this._version++})),e.addEventListener("callChanged",(()=>{this._version++})))}onPresenceChange(){console.debug("onPresenceChange"),this._version++}toggleNewChat=e=>{e.preventDefault(),this.isNewChatOpen=!this.isNewChatOpen};closeNewChat=()=>{this.isNewChatOpen=!1};onUserSelected(){this.isNewChatOpen=!1}renderHeader(){return t("div",{class:"room-list-header"},t("span",{class:"room-list-title"},"Nachrichten"),t("button",{class:"new-chat-btn",type:"button",title:"Neue Nachricht","aria-label":"Neue Nachricht",onClick:this.toggleNewChat},t("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 16 16",fill:"none"},t("path",{d:"M8 3V13",stroke:"currentColor","stroke-width":"1.5","stroke-linecap":"round"}),t("path",{d:"M3 8H13",stroke:"currentColor","stroke-width":"1.5","stroke-linecap":"round"}))))}render(){return t("div",{key:"089d5a42173af13d39cb150ff87af731239d481a",class:"room-list-container"},this.renderHeader(),this.isNewChatOpen?t("chatleo-new-message-selector",{chatStore:this.chatStore,onDoClose:this.closeNewChat}):t("div",{class:"room-list"},this.rooms?.map((e=>{const a=e.participantIdsWithoutSelf?.filter((e=>this.chatStore?.isOnline(e)))??[],i=this.selectedRoomId===e.id;return t("div",{style:{padding:"6px 4px"},class:i?"active":""},t("chatleo-room-tile-component",{room:e,chatStore:this.chatStore,onlineUserIds:a,lastMessage:void 0,timestamp:void 0,unreadCount:e.unreadCount,isActive:i}))})),!this.rooms?.length&&t("div",{class:"room-list-empty"},t("p",null,"Noch keine Unterhaltungen"),t("button",{class:"empty-new-chat-btn",type:"button",onClick:this.toggleNewChat},"Neue Nachricht"))))}static get watchers(){return{chatStore:[{onChatStoreChange:0}]}}};p.style=":host{--room-list-width:250px;display:flex;flex-direction:column;max-height:100%;min-height:0;overflow:hidden}.room-list-container{display:flex;flex-direction:column;flex:1;min-height:0;min-width:var(--room-list-width);overflow:hidden}.room-list-header{display:flex;align-items:center;justify-content:space-between;gap:8px;padding:12px 16px;border-bottom:1px solid var(--border-light);flex-shrink:0;font-family:var(--font-primary), sans-serif}.room-list-title{font-weight:700;font-size:16px;color:var(--text-primary, #171A1F)}.new-chat-btn{display:flex;align-items:center;justify-content:center;width:28px;height:28px;border:1px solid var(--border-light);border-radius:6px;background:transparent;cursor:pointer;padding:0;margin:0;flex:0 0 auto;color:#565D6D}.new-chat-btn:hover{color:var(--text-primary, #171A1F);background-color:var(--hover-color, #f3f4f6)}.room-list{min-width:var(--room-list-width);max-height:100%;max-width:100%;display:flex;flex-direction:column;overflow-y:auto;overflow-x:hidden;font-family:var(--font-primary), sans-serif;min-height:0;flex:1}.room-list-empty{display:flex;flex-direction:column;align-items:flex-start;gap:8px;padding:16px;font-family:var(--font-primary), sans-serif;color:var(--text-secondary, #565D6D)}.room-list-empty p{margin:0;font-size:14px}.empty-new-chat-btn{border:1px solid var(--border-light);background:transparent;color:var(--text-primary, #171A1F);border-radius:var(--border-radius, 6px);padding:6px 12px;cursor:pointer;font-size:14px}.empty-new-chat-btn:hover{background-color:var(--hover-color, #f3f4f6)}.active{background-color:var(--bg-secondary, #f0f0f0)}.room-list>*{flex-shrink:0}chatleo-new-message-selector{flex:1;min-height:0;overflow-y:auto}";const g=class{constructor(t){e(this,t),this.roomClicked=a(this,"roomClicked")}room;chatStore;onlineUserIds;lastMessage;timestamp;unreadCount;isActive=!1;roomClicked;onClick(){console.log("Room clicked",this.room.id),this.roomClicked.emit({id:this.room.id})}render(){const e=this.onlineUserIds.includes(this.room.participantIdsWithoutSelf[0]),a=this.chatStore?.users.find((e=>e.id===this.room.participantIdsWithoutSelf[0]))?.profile_picture_url,i=this.isActive?"room-tile active":"room-tile",n=this.chatStore?.activeCall(this.room.id);return t("div",{key:"2f667c91928a5dc65554d2204372b322b0e43272",class:i,onClick:()=>this.onClick()},t("chatleo-avatar",{key:"2b072a48103fad1cfe23a0eec2c18645572e8071",name:this.room.name,url:a,isOnline:e}),t("div",{key:"bfb0d3b61dbd0bc816b8c0c578e04c622214a3ad",class:"room-content"},t("div",{key:"2ce0fda6bcd7af24a8bb823f7ba75329449239cf",class:"room-header"},t("h3",{key:"fa5ed3dd1401c147f2996bc93bed06d8f096a521",class:"room-name"},this.room.name),t("span",{key:"308d082b266a01fad292839ae69c4edd0a21d1bb",class:"timestamp"},this.timestamp??"")),t("div",{key:"f7b3206df5b8f9870ff358f693d4600fb21302d4",class:"room-footer"},t("p",{key:"a69f70a6b237b7e0c1f5776627f7ffd3ed16685d",class:"last-message"},n?"Call in progress":this.lastMessage??" "),n&&t("span",{key:"03e324140c78c3bce371fd14725eca835596a600",class:"call-marker",title:"Call in progress"},"Call"),this.room.isReadOnly?t("span",{class:"read-only-badge"},"Read only"):this.unreadCount>0&&t("span",{class:"unread-count"},this.unreadCount))))}};g.style=":host{--room-name-size:16px;--timestamp-size:12px;--message-size:14px;--unread-size:12px;--room-name-weight:600;--unread-weight:600;--room-margin:4px;--room-spacing:8px;--unread-padding:2px 8px;--unread-radius:10px;--unread-min-width:20px;display:block}.room-tile{display:flex;align-items:center;cursor:pointer;transition:background-color var(--transition-duration) ease}.room-tile.active{background-color:var(--bg-secondary, #f0f0f0)}.room-content{padding-left:var(--room-spacing);flex:1;min-width:0}.room-header{display:flex;align-items:center;justify-content:space-between;margin-bottom:var(--room-margin)}.room-name{font-size:var(--room-name-size);font-weight:var(--room-name-weight);margin:0;color:var(--text-primary);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.timestamp{font-size:var(--timestamp-size);color:var(--text-secondary);flex-shrink:0;margin-left:var(--room-spacing)}.room-footer{display:flex;align-items:center;justify-content:space-between}.last-message{font-size:var(--message-size);color:var(--text-secondary);margin:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;flex:1}.read-only-badge{font-size:var(--timestamp-size);color:var(--text-secondary);flex-shrink:0;margin-left:var(--room-spacing)}.unread-count{background-color:var(--accent-color);color:white;font-size:0.7rem;line-height:1;text-align:center;display:flex;justify-content:center;align-items:center;width:1rem;height:1rem;border-radius:50%;overflow:hidden;flex-shrink:0}.call-marker{margin-left:6px;padding:1px 6px;border-radius:999px;background:#1b8a3a;color:#fff;font-size:10px;font-weight:700;text-transform:uppercase}";const m=class{constructor(t){e(this,t),this.callRequested=a(this,"callRequested"),this.messageChatSent=a(this,"messageChatSent")}chatStore;roomId;isOnline=!1;pending=!1;callsAvailable=!1;inCall=!1;callRequested;_version=0;messagesContainerRef;richInputRef;resizeObserver;stickToBottom=!0;lastMessageCount=-1;boundRoomAddedHandler;boundRoomMessageAddedHandler;boundRoomMessageChangedHandler;boundPresenceChangedHandler;loadingOlder=!1;olderExhausted=!1;previousScrollHeight=0;previousScrollTop=0;restoreScrollAfterRender=!1;onChatStoreChange(e,t){console.debug("ChatleoRoomView.onChatStoreChange",e,t),t&&(this.boundRoomAddedHandler&&t.removeEventListener("roomAdded",this.boundRoomAddedHandler),this.boundRoomMessageAddedHandler&&t.removeEventListener("roomMessageAdded",this.boundRoomMessageAddedHandler),this.boundRoomMessageChangedHandler&&(t.removeEventListener("roomMessageUpdated",this.boundRoomMessageChangedHandler),t.removeEventListener("roomMessageRemoved",this.boundRoomMessageChangedHandler)),this.boundPresenceChangedHandler&&t.removeEventListener("presenceChanged",this.boundPresenceChangedHandler)),e&&(this.boundRoomAddedHandler=e=>{console.debug("roomAdded",e),this._version++},this.boundRoomMessageAddedHandler=e=>{console.debug("roomMessageAdded",e),this._version++},this.boundRoomMessageChangedHandler=e=>{console.debug("roomMessageChanged",e),this._version++},this.boundPresenceChangedHandler=e=>{console.debug("onPresenceChange",e),this._version++},e.addEventListener("roomAdded",this.boundRoomAddedHandler),e.addEventListener("roomMessageAdded",this.boundRoomMessageAddedHandler),e.addEventListener("roomMessageUpdated",this.boundRoomMessageChangedHandler),e.addEventListener("roomMessageRemoved",this.boundRoomMessageChangedHandler),e.addEventListener("presenceChanged",this.boundPresenceChangedHandler),this.roomId&&(e.setActiveRoomId(this.roomId),e.markRoomAsRead(this.roomId)))}disconnectedCallback(){this.resizeObserver?.disconnect(),this.resizeObserver=void 0,this.chatStore&&(this.boundRoomAddedHandler&&this.chatStore.removeEventListener("roomAdded",this.boundRoomAddedHandler),this.boundRoomMessageAddedHandler&&this.chatStore.removeEventListener("roomMessageAdded",this.boundRoomMessageAddedHandler),this.boundRoomMessageChangedHandler&&(this.chatStore.removeEventListener("roomMessageUpdated",this.boundRoomMessageChangedHandler),this.chatStore.removeEventListener("roomMessageRemoved",this.boundRoomMessageChangedHandler)),this.boundPresenceChangedHandler&&this.chatStore.removeEventListener("presenceChanged",this.boundPresenceChangedHandler))}onRoomIdChanged(){this.lastMessageCount=-1,this.olderExhausted=!1,this.loadingOlder=!1,this.restoreScrollAfterRender=!1,this.roomId&&(this.chatStore?.setActiveRoomId(this.roomId),this.chatStore?.markRoomAsRead(this.roomId))}componentDidLoad(){this.roomId&&(this.chatStore?.setActiveRoomId(this.roomId),this.chatStore?.markRoomAsRead(this.roomId)),"undefined"!=typeof ResizeObserver&&this.messagesContainerRef&&!this.resizeObserver&&(this.resizeObserver=new ResizeObserver((()=>{this.stickToBottom&&this.scrollToBottom()})),this.resizeObserver.observe(this.messagesContainerRef))}async getDraft(){return await(this.richInputRef?.getText?.())??""}async setDraft(e){await(this.richInputRef?.setText?.(e??""))}async addFiles(e){await(this.richInputRef?.addFiles?.(e??[]))}async focusComposer(){await(this.richInputRef?.focusEditor?.())}messageRetryHandler(e){this.roomId&&e.detail&&this.chatStore?.retryMessage(this.roomId,e.detail)}requestCall(){if(!this.roomId)return;const e=this.chatStore?.activeCall(this.roomId);this.callRequested.emit({roomId:this.roomId,callId:e?.id})}messageDiscardHandler(e){this.roomId&&e.detail&&this.chatStore?.discardMessage(this.roomId,e.detail)}messageChatSent;messageSendHandler(e){if(!this.roomId)return void console.warn("ChatleoRoomView: Cannot send message without roomId");e.stopPropagation(),console.log("Received the messageSend event: ",JSON.stringify(e.detail));const t=(e.detail?.blocks??[]).map((e=>{if("attachment"===e?.type&&Array.isArray(e.attachments)){const t=e.attachments.map((e=>{const{preview:t,...a}=e??{};return a}));return{...e,attachments:t}}return e}));this.messageChatSent.emit({room_id:this.roomId,content:{blocks:t,version:e.detail.version},content_type:"application/json+blocks",sender:this.chatStore?.profile?.id})}scrollToBottom(){if(this.messagesContainerRef)try{this.messagesContainerRef.scrollTop=this.messagesContainerRef.scrollHeight,this.stickToBottom=!0}catch(e){}}scrollToBottomNextTick(){requestAnimationFrame((()=>this.scrollToBottom()))}async onMessagesScroll(){if(!this.roomId||!this.chatStore||!this.messagesContainerRef)return;const e=this.messagesContainerRef;if(this.stickToBottom=e.scrollTop+e.clientHeight>=e.scrollHeight-24,this.loadingOlder||this.olderExhausted)return;if(e.scrollTop>40)return;this.loadingOlder=!0,this.previousScrollHeight=this.messagesContainerRef.scrollHeight,this.previousScrollTop=this.messagesContainerRef.scrollTop;const t=this.chatStore.roomMessages(this.roomId).length;try{const e=await this.chatStore.loadOlderMessages(this.roomId),a=this.chatStore.roomMessages(this.roomId).length;a>t&&(this.restoreScrollAfterRender=!0),e||a!==t||(this.olderExhausted=!0)}finally{this.loadingOlder=!1}}componentDidRender(){if(this.pending)return;if(!this.roomId)return;const e=(this.chatStore?.roomMessages(this.roomId)??[]).length;if(this.restoreScrollAfterRender&&this.messagesContainerRef)return this.messagesContainerRef.scrollTop=this.previousScrollTop+Math.max(0,this.messagesContainerRef.scrollHeight-this.previousScrollHeight),this.restoreScrollAfterRender=!1,void(this.lastMessageCount=e);e!==this.lastMessageCount&&(this.scrollToBottomNextTick(),this.lastMessageCount=e)}render(){const e=n(this.chatStore?.roomMessages(this.roomId)??[]),a=this.chatStore?.rooms.find((e=>e.id===this.roomId)),i=a?.isReadOnly??!1;return console.debug("ChatleoRoomView.render",e),t("div",{key:"3eb9ef978132245f3f6d41299123021f4a32d55b",class:"chat-container-chat"},t("div",{key:"6bbc3f4dbdd677fcc227550627eb939af7ec17b8",class:"chat-container-header-container"},t("chatleo-chat-header",{key:"1a17709cc4e699fdb3fcd40e39bad9d8f105fef9",name:this.chatStore?.profile?.display_name,avatar:this.chatStore?.profile?.profile_picture_url??void 0,isOnline:this.isOnline})),this.callsAvailable&&this.roomId&&t("div",{key:"a9696dd64448fcee1d47ea7559dd80a7993e33d0",class:"call-bar"},this.chatStore?.activeCall(this.roomId)&&!this.inCall?t("span",{class:"call-banner"},"direct"===this.chatStore?.activeCall(this.roomId)?.mode?"Call in progress":"Group call in progress"):null,t("button",{key:"40cf2f4c7d7d1dfd9e1ebe57a9e315e1ff884d22",type:"button",class:"call-button",onClick:()=>this.requestCall()},this.inCall?"Call running":this.chatStore?.activeCall(this.roomId)?"Join call":"DirectMessage"===this.chatStore?.rooms.find((e=>e.id===this.roomId))?.type?"Call":"Start call")),this.pending?t("div",{class:"messages-container"},t("div",null,"Loading chat...")):t("div",{class:"messages-container",ref:e=>this.messagesContainerRef=e,onScroll:()=>this.onMessagesScroll()},Object.entries(e).sort((([e],[t])=>new Date(e).getTime()-new Date(t).getTime())).map((([e,a])=>t("div",{class:"message-group"},t("div",{class:"date-separator"},e),a.map((e=>t("chatleo-chat-message",{message:e,sender:this.chatStore?.usernameResolver(e.sender_id),senderIsOnline:e.sender_id===this.chatStore?.profile.id?this.chatStore?.isConnected:this.chatStore?.isOnline(e.sender_id),isOwnMessage:e.sender_id===this.chatStore?.profile.id,translations:{you:this.chatStore?.usernameResolver(e.sender_id)?.display_name}}))))))),!i&&t("div",{key:"42592e707c67d41114596fdcf654631c2f39ee6e",class:"rich-input-container-wrapper"},t("chatleo-rich-input",{key:"2a4fd69962ca7c2ac3c0ded1f5b46088855d9cea",ref:e=>this.richInputRef=e,disabled:!this.roomId,placeholder:"Nachricht schreiben"})))}static get watchers(){return{chatStore:[{onChatStoreChange:0}],roomId:[{onRoomIdChanged:0}]}}};m.style=":host{display:flex;flex-direction:column;max-height:100%;min-height:0;overflow:hidden}.chat-container-chat{display:flex;flex-direction:column;height:100%;width:100%;font-family:var(--font-primary), sans-serif;min-height:0;overflow:hidden;}chatleo-chat-header{flex:0 0 auto;display:block}.chat-container-header-container{flex:0 0 auto;border-bottom:1px solid var(--border-light)}.rich-input-container-wrapper{flex:0 0 auto;padding-top:2px}.messages-container{display:block;flex:1 1 auto;min-height:0;overflow-y:auto;overflow-x:hidden;padding-right:12px;overscroll-behavior:contain;scrollbar-gutter:stable;max-width:100%;border-bottom:1px solid var(--border-light);}.message-group{display:flex;flex-direction:column;gap:16px}.date-separator{text-align:center;font-family:var(--font-primary), sans-serif;font-weight:400;font-size:12px;line-height:1.65;color:var(--text-secondary)}.call-bar{display:flex;align-items:center;justify-content:flex-end;gap:8px;padding:6px 16px;border-bottom:1px solid var(--border-light)}.call-banner{margin-right:auto;font-size:12px;color:var(--text-secondary)}.call-button{border:1px solid var(--accent-color, #4a86e8);background:transparent;color:var(--accent-color, #4a86e8);border-radius:var(--border-radius, 6px);padding:4px 10px;font:inherit;font-size:12px;cursor:pointer}.call-button:hover{background:color-mix(in srgb, var(--accent-color, #4a86e8) 10%, transparent)}";const b=class{constructor(t){e(this,t),this.newChatClicked=a(this,"newChatClicked"),this.messageChatSent=a(this,"messageChatSent")}chatStore;isChatOpen=!1;isNewChatSelectorOpen=!1;isMessagesOpen=!1;selectedRoomId;isPending=!1;_version=0;isSessionExpired=!1;connectionStatus="disconnected";messagesContainerRef;lastMessageCount=-1;boundOnPresenceChange=()=>this.onPresenceChange();boundOnRoomMessageAdded=e=>this.onRoomMessageAdded(e);boundOnSessionExpiredChanged=e=>this.onSessionExpiredChanged(e);boundOnConnectionStatusChanged=e=>this.onConnectionStatusChanged(e);boundOnRoomReadCountChanged=()=>{this._version++};onChatStoreChange(e,t){t&&(t.removeEventListener("presenceChanged",this.boundOnPresenceChange),t.removeEventListener("roomMessageAdded",this.boundOnRoomMessageAdded),t.removeEventListener("sessionExpiredChanged",this.boundOnSessionExpiredChanged),t.removeEventListener("connectionStatusChanged",this.boundOnConnectionStatusChanged),t.removeEventListener("roomReadCountChanged",this.boundOnRoomReadCountChanged)),e&&(e.addEventListener("presenceChanged",this.boundOnPresenceChange),e.addEventListener("roomMessageAdded",this.boundOnRoomMessageAdded),e.addEventListener("sessionExpiredChanged",this.boundOnSessionExpiredChanged),e.addEventListener("connectionStatusChanged",this.boundOnConnectionStatusChanged),this.isSessionExpired=e.isSessionExpired,this.connectionStatus=e.connectionStatus,e.addEventListener("roomReadCountChanged",this.boundOnRoomReadCountChanged))}onSelectedRoomIdChanged(){this.lastMessageCount=-1,this._version++,this.chatStore?.setActiveRoomId(this.selectedRoomId??null)}onPresenceChange(){console.debug("onPresenceChange"),this._version++}onRoomMessageAdded(e){console.debug("onRoomMessageAdded",e),this._version++,this.isMessagesOpen&&e.detail?.roomId===this.selectedRoomId&&this.chatStore?.markRoomAsRead(this.selectedRoomId)}onSessionExpiredChanged(e){this.isSessionExpired=e.detail.isSessionExpired,this.isSessionExpired&&(this.isChatOpen=!0)}onConnectionStatusChanged(e){this.connectionStatus=e.detail.status}toggleChat=()=>{this.isChatOpen=!this.isChatOpen,this._version++};newChatClicked;onNewChatClicked(){this.isNewChatSelectorOpen?this.isNewChatSelectorOpen=!1:(this.isNewChatSelectorOpen=!0,this.isMessagesOpen=!1,this.newChatClicked.emit())}onUserSelected=()=>{this.isNewChatSelectorOpen=!1};onSelectorClose=()=>{this.isNewChatSelectorOpen=!1};roomClickedHandler(e){console.log("Received the roomClicked event: ",e.detail),this.isNewChatSelectorOpen=!1,this.isMessagesOpen=!0,this.selectedRoomId=e.detail.id,this.chatStore?.markRoomAsRead(e.detail.id)}messageChatSent;messageSendHandler(e){console.log("Received the messageSend event: ",JSON.stringify(e.detail));const t=(e.detail?.blocks??[]).map((e=>{if("attachment"===e?.type&&Array.isArray(e.attachments)){const t=e.attachments.map((e=>{const{preview:t,...a}=e??{};return a}));return{...e,attachments:t}}return e}));this.messageChatSent.emit({room_id:this.selectedRoomId,content:{blocks:t,version:e.detail.version},content_type:"application/json+blocks",sender:this.chatStore?.profile?.id})}async openChatPanel(e,t=!1){console.debug(`openChatPanel ${e} ${t}`),this.selectedRoomId=e,this.isPending=t,this.isChatOpen=!1,this.isMessagesOpen=!0,e&&this.chatStore?.markRoomAsRead(e),this._version++}onDoClose(e){e.preventDefault(),this.isMessagesOpen=!1}scrollToBottom(){if(this.messagesContainerRef)try{this.messagesContainerRef.scrollTop=this.messagesContainerRef.scrollHeight}catch(e){}}scrollToBottomNextTick(){requestAnimationFrame((()=>{this.scrollToBottom()}))}componentDidRender(){if(!this.isMessagesOpen||!this.selectedRoomId)return;const e=(this.chatStore?.roomMessages(this.selectedRoomId)??[]).length;e!==this.lastMessageCount&&(this.scrollToBottomNextTick(),this.lastMessageCount=e)}render(){const e=n(this.chatStore?.roomMessages(this.selectedRoomId)??[]);return t("div",{key:"16d13ecf2c8d78c822b66ee140fdf3aedb03d1fa",class:"tray-container"},t("div",{key:"2087230f83fa231255a127bcf25935c96bb5a89d",class:this.isNewChatSelectorOpen?"selector-panel open":"selector-panel"},t("chatleo-new-message-selector",{key:"346f747952e4c2d3872db97adfd9fab7434526cf",chatStore:this.chatStore,onUserSelected:this.onUserSelected,onDoClose:this.onSelectorClose})),t("div",{key:"245326a45ffdea0c3c8a8507a449391635576c95",class:this.isMessagesOpen?"messages-panel open":"messages-panel"},t("div",{key:"b5b82048cbee06bdb73967c2ff342d4bad66a89a",class:"messages-container-header-closer"},t("button",{key:"0196b861999831d834df3407cc5c350fba9338f9",class:"close-button",onClick:this.onDoClose.bind(this)},t("svg",{key:"1db85ebbbb9291ecd8674d25a063bcbe215bd6d0",width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg"},t("path",{key:"d5f23bc40608fac8577860d6ff03e0e5c47e26cf",d:"M12 4L4 12",stroke:"#565D6D","stroke-width":"1.37143","stroke-miterlimit":"10","stroke-linecap":"square"}),t("path",{key:"6f27dd8b4a9969dd19bdae6059cad74d5e466d6f",d:"M12 12L4 4",stroke:"#565D6D","stroke-width":"1.37143","stroke-miterlimit":"10","stroke-linecap":"square"})))),t("chatleo-chat-header",{key:"d4320c822ed8ed5e4472c91a8c03508137bb3985",name:this.chatStore?.profile?.display_name,avatar:this.chatStore?.profile?.profile_picture_url??"https://placehold.co/48x48?text=AV",isOnline:this.chatStore?.isConnected}),t("div",{key:"ffb54f65c17f3ecf51f661aaa2cd1777d57e2468",class:"messages-container",ref:e=>this.messagesContainerRef=e},Object.entries(e).sort((([e],[t])=>new Date(e).getTime()-new Date(t).getTime())).map((([e,a])=>t("div",{class:"message-group"},t("div",{class:"date-separator"},e),a.map((e=>t("chatleo-chat-message",{message:e,sender:this.chatStore?.usernameResolver(e.sender_id),isOwnMessage:e.sender_id===this.chatStore?.profile.id,translations:{you:this.chatStore?.usernameResolver(e.sender_id)?.display_name}}))))))),t("chatleo-rich-input",{key:"5db7ffd32df847bbe103659d4f8ededfcc3105b2",disabled:!this.selectedRoomId,placeholder:"Nachricht schreiben"})),t("div",{key:"a4374b9f51b6f4f528ca0099df022272d41e8062",id:"chats",class:this.isChatOpen?"chat-panel open":"chat-panel"},this.isSessionExpired&&t("div",{key:"77f04c709823b47590588651b78531fa23d84254",class:"session-expired-banner"},t("svg",{key:"7a9e8a3baba8576df14229384f67c4e771e4280e",class:"session-expired-banner-icon",xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none"},t("path",{key:"bededb8359f4374f131f914124f89cae938c63f2",d:"M12 9v4M12 17h.01M10.29 3.86L1.82 18a2 2 0 001.71 3h16.94a2 2 0 001.71-3L13.71 3.86a2 2 0 00-3.42 0z",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"})),t("span",{key:"49ede701a42a2c16954859e5c0443c6c94168376"},"Session abgelaufen –"),t("button",{key:"1533de4c91c3e496e82781e03e34d8df9cd92bf7",class:"session-expired-banner-btn",onClick:()=>window.location.reload()},"Seite neu laden")),!this.isSessionExpired&&("connecting"===this.connectionStatus||"reconnecting"===this.connectionStatus||"disconnected"===this.connectionStatus)&&t("div",{key:"5f11759ba32e228f990b2866d09e2d25c647315c",class:`connection-status-banner connection-status-banner--${this.connectionStatus}`},t("span",{key:"55ad4bf597fcf0ee3a1e180ebfac85a8c271da16",class:"connection-status-banner__dot"}),"connecting"===this.connectionStatus?"Verbindung wird hergestellt…":"reconnecting"===this.connectionStatus?"Verbindung wird wiederhergestellt…":"Offline"),t("div",{key:"c8adfe1c61695332bef014492c7abe3d641160b0",class:"tray"},t("chatleo-avatar",{key:"8ee785cd081f4509aa8a68c1fa8ec3584e729c5a",name:this.chatStore?.profile?.display_name??"",url:this.chatStore?.profile?.profile_picture_url,isOnline:this.chatStore?.isConnected??!1}),t("div",{key:"e52ee5d7ca448912dd98913f1ba5cc1126212207",class:"title"},"Nachrichten"),t("button",{key:"ab06ce2f106a288b350342e2b0d9494452d1eda7",class:"new-chat-btn",onClick:()=>this.onNewChatClicked()},t("svg",{key:"1c6c9a6c1a8b76cc7e0144568e40779421ee71cc",xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 16 16",fill:"none"},t("path",{key:"d449d4cce2e6f07f44708f0eaf374f95b1642267",d:"M10.497 2.43838L12.7094 4.62657M12.9439 1.6838L13.4519 2.19178C13.9192 2.6591 13.9192 3.41677 13.4519 3.8841L6.72919 10.6068C6.59783 10.7381 6.43768 10.8371 6.26144 10.8958L3.79663 11.7174C3.56275 11.7954 3.34026 11.5729 3.41821 11.339L4.23982 8.87421C4.29857 8.69797 4.39754 8.53783 4.5289 8.40647L11.2516 1.6838C11.7189 1.21648 12.4766 1.21648 12.9439 1.6838Z",stroke:"#565D6D","stroke-width":"1.5","stroke-linecap":"round","stroke-linejoin":"round"}),t("path",{key:"6a19c104fcf6457c2cf9b24bdbf89df1045bdc0b",d:"M8 2.13312H7.2H1.8C1.35817 2.13312 1 2.49129 1 2.93312V13.7331C1 14.1749 1.35817 14.5331 1.8 14.5331H12.6C13.0418 14.5331 13.4 14.1749 13.4 13.7331V8.33312V6.99998",stroke:"#565D6D","stroke-width":"1.5","stroke-linecap":"round"}))),t("button",{key:"e235b7fe2a990954fd4ba18838a7bcf60ef5cd3f",class:"chat-tray-btn",onClick:this.toggleChat},t("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 16 16",fill:"none"},t("path",this.isChatOpen?{d:"M3.07273 4.66669L2 5.73941L8 11.7394L14 5.73941L12.9273 4.66669L8 9.59393L3.07273 4.66669Z",fill:"#565D6D"}:{d:"M12.9273 11.7393L14 10.6665L8 4.66655L2 10.6665L3.07273 11.7393L8 6.81202L12.9273 11.7393Z",fill:"#565D6D"})))),t("div",{key:"49495cb8b42d1e730be1c2c5d5594511b93016e6",class:"chat-content"},t("ul",{key:"4fd54a4d2c5b42d2fc37e1257e9fdc6b87be4532"},this.chatStore?.rooms.map((e=>{const a=e.participantIdsWithoutSelf?.filter((e=>this.chatStore.isOnline(e)))??[];return t("li",null,t("chatleo-room-tile-component",{chatStore:this.chatStore,room:e,onlineUserIds:a,lastMessage:void 0,timestamp:void 0,unreadCount:e.unreadCount}))}))))))}static get watchers(){return{chatStore:[{onChatStoreChange:0}],selectedRoomId:[{onSelectedRoomIdChanged:0}]}}};b.style=":host{--hover-color:#f9f9f9;--shadow-light:rgba(0, 0, 0, 0.1);--z-index-tray:1000;--tray-height:52px;--gap-small:12px;--gap-medium:16px;--transition-duration:0.3s;--gray-black:#171A1F;--chat-panel-width:280px;--selector-panel-width:320px;--messages-panel-width:50vw}.tray-container{position:fixed;bottom:0;right:20px;z-index:var(--z-index-tray);display:flex;flex-direction:row;align-items:flex-end;gap:var(--gap-small);font-family:var(--font-primary), sans-serif}.chat-panel{width:var(--chat-panel-width);flex:0 0 var(--chat-panel-width);box-sizing:border-box;position:relative;background:var(--bg-primary);border:1px solid var(--border-color);border-radius:var(--border-radius) var(--border-radius) 0 0;box-shadow:0 -2px 10px var(--shadow-light);overflow:hidden;max-height:var(--tray-height);transition:max-height var(--transition-duration) ease-in-out}.chat-panel.open{max-height:calc(50vh + var(--tray-height));}.tray{display:flex;flex-direction:row;align-items:center;background:var(--bg-primary);border-bottom:1px solid var(--border-light);height:var(--tray-height);box-sizing:border-box;width:100%;padding:0 8px;margin:0;}chatleo-avatar{--avatar-size:36px}.title{margin:0 8px;flex:1 1 auto;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;color:var(--gray-black, #171A1F);font-size:14px}.selector-panel{display:none;background:var(--bg-primary);border:1px solid var(--border-color);border-radius:var(--border-radius) var(--border-radius) 0 0;box-shadow:0 -2px 10px var(--shadow-light);box-sizing:border-box;width:var(--selector-panel-width);flex:0 0 var(--selector-panel-width);overflow:hidden;max-height:var(--tray-height);}.selector-panel.open{display:flex;flex-direction:column;max-height:calc(50vh + var(--tray-height))}.messages-panel{display:none;background:var(--bg-primary);border:1px solid var(--border-color);border-radius:var(--border-radius) var(--border-radius) 0 0;box-shadow:0 -2px 10px var(--shadow-light);box-sizing:border-box;width:var(--messages-panel-width);overflow:hidden;position:relative;max-height:70vh;flex-direction:column}.messages-panel.open{display:flex}.new-chat-btn{border:0;background:transparent;cursor:pointer;padding:0;margin:0 8px;flex:0 0 auto;color:#565D6D}.chat-tray-btn{border:0;background:transparent;cursor:pointer;padding:0;margin:0 8px;flex:0 0 auto;color:#565D6D}.chat-content{overflow:hidden}.chat-content ul{margin:0;padding:0;list-style:none;overflow-y:auto;max-height:calc(50vh - var(--tray-height));}.chat-content li{padding:16px;cursor:pointer}.chat-content li:hover{background:var(--hover-color)}@media (max-width: 768px){.chat-panel.open,.selector-panel.open{max-height:calc(80vh + 60px)}.chat-content ul{max-height:calc(80vh - 60px)}}.messages-container-header-closer{position:absolute;top:4px;right:4px}.messages-container{display:block;flex:1 1 auto;min-height:0;overflow-y:auto;overflow-x:hidden;padding-right:16px;overscroll-behavior:contain;scrollbar-gutter:stable;max-width:100%}.message-group{display:flex;flex-direction:column;gap:16px}.date-separator{text-align:center;font-family:var(--font-primary), sans-serif;font-weight:400;font-size:12px;line-height:1.65;color:var(--text-secondary)}.close-button{background:none;border:none;cursor:pointer;font-size:16px;color:var(--text-secondary)}.connection-status-banner{display:flex;align-items:center;gap:6px;padding:5px 12px;font-family:var(--font-primary), sans-serif;font-size:12px;font-weight:600;color:#fff;background:#f59e0b}.connection-status-banner--disconnected{background:#ef4444}.connection-status-banner__dot{width:6px;height:6px;border-radius:50%;background:rgba(255,255,255,0.8);flex-shrink:0;animation:tray-pulse-dot 1.4s ease-in-out infinite}.connection-status-banner--disconnected .connection-status-banner__dot{animation:none}@keyframes tray-pulse-dot{0%,100%{opacity:1}50%{opacity:0.3}}.session-expired-banner{display:flex;align-items:center;gap:6px;background:#fff8e1;border-bottom:1px solid #ffe082;padding:6px 12px;font-family:var(--font-primary), sans-serif;font-size:12px;color:#795548}.session-expired-banner-icon{flex-shrink:0;color:#f59e0b}.session-expired-banner-btn{margin-left:auto;padding:3px 10px;background:#f59e0b;color:#fff;border:none;border-radius:4px;font-family:var(--font-primary), sans-serif;font-size:12px;font-weight:600;cursor:pointer;white-space:nowrap}.session-expired-banner-btn:hover{background:#d97706}";const u=class{constructor(t){e(this,t),this.userClicked=a(this,"userClicked")}profile;isOnline=!1;lastSeen;userClicked;onClick(){this.profile&&this.userClicked.emit(this.profile)}render(){const e=this.profile,a=e?.profile_picture_url,i=e?.display_name??"Unknown user";return t("div",{key:"a1e0334d626b162edba9e5bcb93472ab1d75ea8d",class:"user-tile",onClick:()=>this.onClick()},t("chatleo-avatar",{key:"3eed64212482962fe151dbcdb275d2396d91a39f",name:i,url:a,isOnline:this.isOnline}),t("div",{key:"9438ec481cd480b576ef18e95a9fc30003b200ea",class:"user-content"},t("div",{key:"62a9cd55c2e1061c28934f419addbd3ac28b6dca",class:"user-header"},t("h3",{key:"e8f36bfd9e972193fc066b0a0de8a599180104a9",class:"user-name"},i)),t("div",{key:"dbffef93dbe1aff1b85a73669d020df94159b014",class:"user-footer"},t("p",{key:"ee7c35805b645f520b8ef9913c282e0651770684",class:"user-status"},this.isOnline?"Online":this.lastSeen?`Zuletzt online ${this.lastSeen}`:""))))}};u.style=":host{--hover-color:#f5f7fa;--user-tile-border:1px solid var(--border-color);--font-size-name:16px;--font-size-status:14px;--font-weight-name:600;--tile-margin:2px;display:block}.user-tile{display:flex;align-items:center;cursor:pointer;transition:background-color var(--transition-duration) ease;border-bottom:var(--user-tile-border)}.user-tile:hover{background-color:var(--hover-color)}.user-content{flex:1;min-width:0;margin-left:8px}.user-header{margin-bottom:var(--tile-margin)}.user-name{font-size:var(--font-size-name);font-weight:var(--font-weight-name);margin:0;color:var(--text-primary);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.user-footer{display:flex;align-items:center}.user-status{font-size:var(--font-size-status);color:var(--text-secondary);margin:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}";export{o as chatleo_avatar,s as chatleo_chat,r as chatleo_chat_header,c as chatleo_chat_message,d as chatleo_component,h as chatleo_new_message_selector,l as chatleo_rich_input,f as chatleo_rich_message_renderer,p as chatleo_room_list,g as chatleo_room_tile_component,m as chatleo_room_view,b as chatleo_tray_component,u as chatleo_user_tile}
@@ -1078,7 +1078,7 @@ const ChatLeoComponent = class {
1078
1078
  }
1079
1079
  render() {
1080
1080
  const bannerLabel = this._connectionBannerLabel;
1081
- return (index.h("div", { key: 'd0c7c84ebf5fe164868f6e2250252a0899493ee3', style: { height: '100%', maxHeight: 'inherit', width: '100%', display: 'flex', flexDirection: 'column', position: 'relative', overflow: 'hidden', minHeight: '0' } }, this.renderPushControl(), bannerLabel && !this.isSessionExpired && (index.h("div", { key: 'd5147662da351b027aba0542ae3dc5af161d2aa3', class: `connection-banner connection-banner--${this.connectionStatus}` }, index.h("span", { key: '43cad2fcb7fd75d099fa8b73f482e7eb282c0957', class: "connection-banner__dot" }), bannerLabel)), this.useMain && index.h("chatleo-chat", { key: '609457ee0ab1ceaa2484d91d4c54d734770f4d01', ref: el => (this.chatEl = el), chatStore: this.chatStore, callsAvailable: this.callsAvailable, inCall: !!this.callView }), this.useTray && index.h("chatleo-tray-component", { key: 'ebd656fd966561d4f982859b9c36a1e233b204b6', chatStore: this.chatStore, ref: el => (this.trayEl = el) }), this.useRoomView && (index.h("chatleo-room-view", { key: '6af1a89788728c21f72ee1a31b7e70bd7d096f0f', chatStore: this.chatStore, roomId: this.roomId, isOnline: this.chatStore?.isConnected ?? false, pending: this.loading, callsAvailable: this.callsAvailable, inCall: !!this.callView })), this.callView && (index.h("div", { key: '3a346cdaf24c1fe758f86e1233cc4626db023a32', class: "call-layer", style: { display: this.showCall ? 'flex' : 'none' } }, index.h("button", { key: '7720dc641239eb8da833c63c1f30d4ed29fece7c', type: "button", class: "call-layer__back", onClick: () => {
1081
+ return (index.h("div", { key: 'd0c7c84ebf5fe164868f6e2250252a0899493ee3', style: { height: '100%', maxHeight: 'inherit', width: '100%', display: 'flex', flexDirection: 'column', position: 'relative', overflow: 'hidden', minHeight: '0' } }, this.renderPushControl(), bannerLabel && !this.isSessionExpired && (index.h("div", { key: 'd5147662da351b027aba0542ae3dc5af161d2aa3', class: `connection-banner connection-banner--${this.connectionStatus}` }, index.h("span", { key: '43cad2fcb7fd75d099fa8b73f482e7eb282c0957', class: "connection-banner__dot" }), bannerLabel)), this.useMain && index.h("chatleo-chat", { key: 'c3e5795f34cfa9cec09567ce6c1ef4fba3af1ed7', ref: el => (this.chatEl = el), chatStore: this.chatStore, callsAvailable: this.callsAvailable, inCall: !!this.callView, isOnline: this.chatStore?.isConnected ?? false }), this.useTray && index.h("chatleo-tray-component", { key: '1c11b399fedbf010e83fafccba106713771be48d', chatStore: this.chatStore, ref: el => (this.trayEl = el) }), this.useRoomView && (index.h("chatleo-room-view", { key: 'cd3e086d542ff5e93eed78e094552a19c9201c55', chatStore: this.chatStore, roomId: this.roomId, isOnline: this.chatStore?.isConnected ?? false, pending: this.loading, callsAvailable: this.callsAvailable, inCall: !!this.callView })), this.callView && (index.h("div", { key: '579ab895faaba67e3c51841e57aa70b3d333e8ae', class: "call-layer", style: { display: this.showCall ? 'flex' : 'none' } }, index.h("button", { key: '44f57f78e5111909d929403180aa3ec180dcf8d6', type: "button", class: "call-layer__back", onClick: () => {
1082
1082
  this.showCall = false;
1083
1083
  } }, "Chat"), index.h('chatleo-call-adapter', {
1084
1084
  ref: (el) => (this.callAdapterRef = el),
@@ -1091,7 +1091,7 @@ const ChatLeoComponent = class {
1091
1091
  promoteHandler: this.promoteInCall,
1092
1092
  demoteHandler: this.demoteInCall,
1093
1093
  style: { flex: '1', minHeight: '0' },
1094
- }))), this.incomingCall && (index.h("div", { key: 'ebdc317f30b07009f41f7f729b9e8631ea039752', class: "incoming-call", role: "dialog", "aria-modal": "true", "aria-label": `Incoming call from ${this.incomingCall.caller.display_name ?? this.incomingCall.caller.id}`, tabIndex: -1, ref: el => (this.incomingRef = el) }, index.h("div", { key: '4eac45f10551a47c7bf1ad8035a9da5ed2955e29', class: "incoming-call__box" }, index.h("p", { key: '6f74dee9aa261dc889b70c18e5b110e18b1a2111', class: "incoming-call__eyebrow" }, "Incoming call"), index.h("chatleo-avatar", { key: 'e097d46809d6202d64ebc1eaf42418b74c990e80', name: this.incomingCall.caller.display_name ?? this.incomingCall.caller.id, url: this.incomingCall.caller.profile_picture_url ?? null, isOnline: false }), index.h("p", { key: 'b160c0021f003d230d5fb544d82fd8d23f7df332', class: "incoming-call__name" }, this.incomingCall.caller.display_name ?? this.incomingCall.caller.id), index.h("div", { key: 'b238c1352384a0f14a2abd130fe0f3495da156f3', class: "incoming-call__actions" }, index.h("button", { key: '1b44cc1c87dfb89b4715fb370c490a05d97b6512', type: "button", class: "incoming-call__accept", onClick: () => void this.acceptIncomingCall() }, "Accept"), index.h("button", { key: '97276ec614d0be526f16573a3d0e9f6cb9e24b7c', type: "button", class: "incoming-call__decline", onClick: () => void this.declineIncomingCall() }, "Decline"))))), this.isSessionExpired && (index.h("div", { key: 'b387b49bc31378c63c6520a95bf732c47a142e88', class: "session-expired-overlay" }, index.h("div", { key: '118687b87cc612d9ad47692a3e8f2a38f3b71f32', class: "session-expired-box" }, index.h("svg", { key: '562cf50bb4f6cdd0e4076267c6dea5f8b76b06d7', class: "session-expired-icon", xmlns: "http://www.w3.org/2000/svg", width: "24", height: "24", viewBox: "0 0 24 24", fill: "none" }, index.h("path", { key: '628579c8dad4064d6fcfdfd75801160fe8f0ef8f', d: "M12 9v4M12 17h.01M10.29 3.86L1.82 18a2 2 0 001.71 3h16.94a2 2 0 001.71-3L13.71 3.86a2 2 0 00-3.42 0z", stroke: "currentColor", "stroke-width": "2", "stroke-linecap": "round", "stroke-linejoin": "round" })), index.h("p", { key: 'e49e2388dad8df0e961cb7e0dc605a4011775eed', class: "session-expired-title" }, "Session abgelaufen"), index.h("p", { key: '0b69cf4687411c7e9f117712b28da57bc798ce07', class: "session-expired-message" }, "Deine Sitzung ist abgelaufen. Bitte lade die Seite neu, um fortzufahren."), index.h("button", { key: '9532b50dccc9f05dc3ee4a5ea2b28eea462a0ed1', class: "session-expired-button", onClick: () => window.location.reload() }, "Seite neu laden"))))));
1094
+ }))), this.incomingCall && (index.h("div", { key: '9a40dd687e2c9a717deecac05ab160919e6c91e4', class: "incoming-call", role: "dialog", "aria-modal": "true", "aria-label": `Incoming call from ${this.incomingCall.caller.display_name ?? this.incomingCall.caller.id}`, tabIndex: -1, ref: el => (this.incomingRef = el) }, index.h("div", { key: '901a91dc9d594aa6c22d34bb076b294ca7f4baff', class: "incoming-call__box" }, index.h("p", { key: 'de8604f814c54ff31365c71ff017529f65ad4562', class: "incoming-call__eyebrow" }, "Incoming call"), index.h("chatleo-avatar", { key: 'edbe19c7df4faebb8c82c124998242ab3ac057b4', name: this.incomingCall.caller.display_name ?? this.incomingCall.caller.id, url: this.incomingCall.caller.profile_picture_url ?? null, isOnline: false }), index.h("p", { key: '12775d0d86490918c57e22afd0d132158c8970a8', class: "incoming-call__name" }, this.incomingCall.caller.display_name ?? this.incomingCall.caller.id), index.h("div", { key: '1746d49c0b8df234a095d4738d3b86f3c0dadb5d', class: "incoming-call__actions" }, index.h("button", { key: '269ad5b6bfc735321cc55cc20e9adcd6c0239a18', type: "button", class: "incoming-call__accept", onClick: () => void this.acceptIncomingCall() }, "Accept"), index.h("button", { key: '8656c479150d95ea6fb2ec93aa06bda5f2fa4359', type: "button", class: "incoming-call__decline", onClick: () => void this.declineIncomingCall() }, "Decline"))))), this.isSessionExpired && (index.h("div", { key: 'f46db890a91aa5c5e3aef489b93765bf1702fd8c', class: "session-expired-overlay" }, index.h("div", { key: '1581ef80235822ace8660ff35fe6f493d69df0d2', class: "session-expired-box" }, index.h("svg", { key: '6fe3be249ebfaec0871c6323057dbd8bdc106799', class: "session-expired-icon", xmlns: "http://www.w3.org/2000/svg", width: "24", height: "24", viewBox: "0 0 24 24", fill: "none" }, index.h("path", { key: '82078e08d808f6e8c5671c343c95d54c9cf35118', d: "M12 9v4M12 17h.01M10.29 3.86L1.82 18a2 2 0 001.71 3h16.94a2 2 0 001.71-3L13.71 3.86a2 2 0 00-3.42 0z", stroke: "currentColor", "stroke-width": "2", "stroke-linecap": "round", "stroke-linejoin": "round" })), index.h("p", { key: '3611ca9c18813f4238dacadc669533a27f99da31', class: "session-expired-title" }, "Session abgelaufen"), index.h("p", { key: '7140324b6246ed5eb1917c694b85c8ee5c491408', class: "session-expired-message" }, "Deine Sitzung ist abgelaufen. Bitte lade die Seite neu, um fortzufahren."), index.h("button", { key: 'f11ecf3aeb0cbd64ce064e90761d5736806619b4', class: "session-expired-button", onClick: () => window.location.reload() }, "Seite neu laden"))))));
1095
1095
  }
1096
1096
  static get watchers() { return {
1097
1097
  "chatLeoLib": [{
@@ -2912,7 +2912,7 @@ const ChatLeoTrayComponent = class {
2912
2912
  .sort(([dateA], [dateB]) => new Date(dateA).getTime() - new Date(dateB).getTime())
2913
2913
  .map(([date, messages]) => (index.h("div", { class: "message-group" }, index.h("div", { class: "date-separator" }, date), messages.map(message => (index.h("chatleo-chat-message", { message: message, sender: this.chatStore?.usernameResolver(message.sender_id), isOwnMessage: message.sender_id === this.chatStore?.profile.id, translations: { 'you': this.chatStore?.usernameResolver(message.sender_id)?.display_name } }))))))), index.h("chatleo-rich-input", { key: '5db7ffd32df847bbe103659d4f8ededfcc3105b2', disabled: !!!this.selectedRoomId, placeholder: "Nachricht schreiben" })), index.h("div", { key: 'a4374b9f51b6f4f528ca0099df022272d41e8062', id: "chats", class: this.isChatOpen ? 'chat-panel open' : 'chat-panel' }, this.isSessionExpired && (index.h("div", { key: '77f04c709823b47590588651b78531fa23d84254', class: "session-expired-banner" }, index.h("svg", { key: '7a9e8a3baba8576df14229384f67c4e771e4280e', class: "session-expired-banner-icon", xmlns: "http://www.w3.org/2000/svg", width: "16", height: "16", viewBox: "0 0 24 24", fill: "none" }, index.h("path", { key: 'bededb8359f4374f131f914124f89cae938c63f2', d: "M12 9v4M12 17h.01M10.29 3.86L1.82 18a2 2 0 001.71 3h16.94a2 2 0 001.71-3L13.71 3.86a2 2 0 00-3.42 0z", stroke: "currentColor", "stroke-width": "2", "stroke-linecap": "round", "stroke-linejoin": "round" })), index.h("span", { key: '49ede701a42a2c16954859e5c0443c6c94168376' }, "Session abgelaufen \u2013"), index.h("button", { key: '1533de4c91c3e496e82781e03e34d8df9cd92bf7', class: "session-expired-banner-btn", onClick: () => window.location.reload() }, "Seite neu laden"))), !this.isSessionExpired && (this.connectionStatus === 'connecting' || this.connectionStatus === 'reconnecting' || this.connectionStatus === 'disconnected') && (index.h("div", { key: '5f11759ba32e228f990b2866d09e2d25c647315c', class: `connection-status-banner connection-status-banner--${this.connectionStatus}` }, index.h("span", { key: '55ad4bf597fcf0ee3a1e180ebfac85a8c271da16', class: "connection-status-banner__dot" }), this.connectionStatus === 'connecting' ? 'Verbindung wird hergestellt…'
2914
2914
  : this.connectionStatus === 'reconnecting' ? 'Verbindung wird wiederhergestellt…'
2915
- : 'Offline')), index.h("div", { key: 'c8adfe1c61695332bef014492c7abe3d641160b0', class: "tray" }, index.h("chatleo-avatar", { key: 'e5ca63cb0a77c19c75ca8404a0ec92833f9881f2', name: this.chatStore?.profile?.display_name ?? "", url: this.chatStore?.profile?.profile_picture_url, isOnline: this.chatStore?.profile?.id ? (this.chatStore?.isOnline(this.chatStore.profile.id) ?? false) : false }), index.h("div", { key: 'a7bbd2492328f400a7e349f8296f3c1a499e171e', class: "title" }, "Nachrichten"), index.h("button", { key: '7c2450e2977563c59a41efc874fc9ca5c6ecbea7', class: "new-chat-btn", onClick: () => this.onNewChatClicked() }, index.h("svg", { key: 'a7de1919583f9264c85d2f8a0879e8f993ff848c', xmlns: "http://www.w3.org/2000/svg", width: "16", height: "16", viewBox: "0 0 16 16", fill: "none" }, index.h("path", { key: '63e200bbf4038f0ceb626000b53f685318cd19f8', d: "M10.497 2.43838L12.7094 4.62657M12.9439 1.6838L13.4519 2.19178C13.9192 2.6591 13.9192 3.41677 13.4519 3.8841L6.72919 10.6068C6.59783 10.7381 6.43768 10.8371 6.26144 10.8958L3.79663 11.7174C3.56275 11.7954 3.34026 11.5729 3.41821 11.339L4.23982 8.87421C4.29857 8.69797 4.39754 8.53783 4.5289 8.40647L11.2516 1.6838C11.7189 1.21648 12.4766 1.21648 12.9439 1.6838Z", stroke: "#565D6D", "stroke-width": "1.5", "stroke-linecap": "round", "stroke-linejoin": "round" }), index.h("path", { key: '222831ec61fc41f09ba0296731aed27050ff1b55', d: "M8 2.13312H7.2H1.8C1.35817 2.13312 1 2.49129 1 2.93312V13.7331C1 14.1749 1.35817 14.5331 1.8 14.5331H12.6C13.0418 14.5331 13.4 14.1749 13.4 13.7331V8.33312V6.99998", stroke: "#565D6D", "stroke-width": "1.5", "stroke-linecap": "round" }))), index.h("button", { key: '51ce8b2bc912659e7347f9eb9bfe1a1c56b23b75', class: "chat-tray-btn", onClick: this.toggleChat }, this.isChatOpen ? (index.h("svg", { xmlns: "http://www.w3.org/2000/svg", width: "16", height: "16", viewBox: "0 0 16 16", fill: "none" }, index.h("path", { d: "M3.07273 4.66669L2 5.73941L8 11.7394L14 5.73941L12.9273 4.66669L8 9.59393L3.07273 4.66669Z", fill: "#565D6D" }))) : (index.h("svg", { xmlns: "http://www.w3.org/2000/svg", width: "16", height: "16", viewBox: "0 0 16 16", fill: "none" }, index.h("path", { d: "M12.9273 11.7393L14 10.6665L8 4.66655L2 10.6665L3.07273 11.7393L8 6.81202L12.9273 11.7393Z", fill: "#565D6D" }))))), index.h("div", { key: '9f46873326aab72ba87cfa6b387de9c5616bb497', class: "chat-content" }, index.h("ul", { key: 'f1f9da34aab6ae95a9d3910de295e1dc64f31c2c' }, this.chatStore?.rooms.map(room => {
2915
+ : 'Offline')), index.h("div", { key: 'c8adfe1c61695332bef014492c7abe3d641160b0', class: "tray" }, index.h("chatleo-avatar", { key: '8ee785cd081f4509aa8a68c1fa8ec3584e729c5a', name: this.chatStore?.profile?.display_name ?? "", url: this.chatStore?.profile?.profile_picture_url, isOnline: this.chatStore?.isConnected ?? false }), index.h("div", { key: 'e52ee5d7ca448912dd98913f1ba5cc1126212207', class: "title" }, "Nachrichten"), index.h("button", { key: 'ab06ce2f106a288b350342e2b0d9494452d1eda7', class: "new-chat-btn", onClick: () => this.onNewChatClicked() }, index.h("svg", { key: '1c6c9a6c1a8b76cc7e0144568e40779421ee71cc', xmlns: "http://www.w3.org/2000/svg", width: "16", height: "16", viewBox: "0 0 16 16", fill: "none" }, index.h("path", { key: 'd449d4cce2e6f07f44708f0eaf374f95b1642267', d: "M10.497 2.43838L12.7094 4.62657M12.9439 1.6838L13.4519 2.19178C13.9192 2.6591 13.9192 3.41677 13.4519 3.8841L6.72919 10.6068C6.59783 10.7381 6.43768 10.8371 6.26144 10.8958L3.79663 11.7174C3.56275 11.7954 3.34026 11.5729 3.41821 11.339L4.23982 8.87421C4.29857 8.69797 4.39754 8.53783 4.5289 8.40647L11.2516 1.6838C11.7189 1.21648 12.4766 1.21648 12.9439 1.6838Z", stroke: "#565D6D", "stroke-width": "1.5", "stroke-linecap": "round", "stroke-linejoin": "round" }), index.h("path", { key: '6a19c104fcf6457c2cf9b24bdbf89df1045bdc0b', d: "M8 2.13312H7.2H1.8C1.35817 2.13312 1 2.49129 1 2.93312V13.7331C1 14.1749 1.35817 14.5331 1.8 14.5331H12.6C13.0418 14.5331 13.4 14.1749 13.4 13.7331V8.33312V6.99998", stroke: "#565D6D", "stroke-width": "1.5", "stroke-linecap": "round" }))), index.h("button", { key: 'e235b7fe2a990954fd4ba18838a7bcf60ef5cd3f', class: "chat-tray-btn", onClick: this.toggleChat }, this.isChatOpen ? (index.h("svg", { xmlns: "http://www.w3.org/2000/svg", width: "16", height: "16", viewBox: "0 0 16 16", fill: "none" }, index.h("path", { d: "M3.07273 4.66669L2 5.73941L8 11.7394L14 5.73941L12.9273 4.66669L8 9.59393L3.07273 4.66669Z", fill: "#565D6D" }))) : (index.h("svg", { xmlns: "http://www.w3.org/2000/svg", width: "16", height: "16", viewBox: "0 0 16 16", fill: "none" }, index.h("path", { d: "M12.9273 11.7393L14 10.6665L8 4.66655L2 10.6665L3.07273 11.7393L8 6.81202L12.9273 11.7393Z", fill: "#565D6D" }))))), index.h("div", { key: '49495cb8b42d1e730be1c2c5d5594511b93016e6', class: "chat-content" }, index.h("ul", { key: '4fd54a4d2c5b42d2fc37e1257e9fdc6b87be4532' }, this.chatStore?.rooms.map(room => {
2916
2916
  const online = room.participantIdsWithoutSelf?.filter((id) => this.chatStore.isOnline(id)) ?? [];
2917
2917
  return (index.h("li", null, index.h("chatleo-room-tile-component", { chatStore: this.chatStore, room: room, onlineUserIds: online, lastMessage: undefined, timestamp: undefined, unreadCount: room.unreadCount })));
2918
2918
  }))))));
@@ -18,8 +18,10 @@ export const Listen = noop;
18
18
  export const Watch = noop;
19
19
  export const Element = noop;
20
20
  export const Host = noop;
21
- /** Minimal no-op h (hyperscript) function */
22
- export const h = (..._args) => null;
21
+ /** Minimal hyperscript: records tag/props/children so render() output can be asserted. */
22
+ export const h = (tag, props, ...children) => ({ tag, props, children });
23
+ /** Fragment support for the classic JSX runtime. */
24
+ h.Fragment = (...children) => ({ tag: 'Fragment', props: null, children });
23
25
  /** EventEmitter stub */
24
26
  export class EventEmitter {
25
27
  emit(_value) { }
@@ -718,7 +718,7 @@ export class ChatLeoComponent {
718
718
  }
719
719
  render() {
720
720
  const bannerLabel = this._connectionBannerLabel;
721
- return (h("div", { key: 'd0c7c84ebf5fe164868f6e2250252a0899493ee3', style: { height: '100%', maxHeight: 'inherit', width: '100%', display: 'flex', flexDirection: 'column', position: 'relative', overflow: 'hidden', minHeight: '0' } }, this.renderPushControl(), bannerLabel && !this.isSessionExpired && (h("div", { key: 'd5147662da351b027aba0542ae3dc5af161d2aa3', class: `connection-banner connection-banner--${this.connectionStatus}` }, h("span", { key: '43cad2fcb7fd75d099fa8b73f482e7eb282c0957', class: "connection-banner__dot" }), bannerLabel)), this.useMain && h("chatleo-chat", { key: '609457ee0ab1ceaa2484d91d4c54d734770f4d01', ref: el => (this.chatEl = el), chatStore: this.chatStore, callsAvailable: this.callsAvailable, inCall: !!this.callView }), this.useTray && h("chatleo-tray-component", { key: 'ebd656fd966561d4f982859b9c36a1e233b204b6', chatStore: this.chatStore, ref: el => (this.trayEl = el) }), this.useRoomView && (h("chatleo-room-view", { key: '6af1a89788728c21f72ee1a31b7e70bd7d096f0f', chatStore: this.chatStore, roomId: this.roomId, isOnline: this.chatStore?.isConnected ?? false, pending: this.loading, callsAvailable: this.callsAvailable, inCall: !!this.callView })), this.callView && (h("div", { key: '3a346cdaf24c1fe758f86e1233cc4626db023a32', class: "call-layer", style: { display: this.showCall ? 'flex' : 'none' } }, h("button", { key: '7720dc641239eb8da833c63c1f30d4ed29fece7c', type: "button", class: "call-layer__back", onClick: () => {
721
+ return (h("div", { key: 'd0c7c84ebf5fe164868f6e2250252a0899493ee3', style: { height: '100%', maxHeight: 'inherit', width: '100%', display: 'flex', flexDirection: 'column', position: 'relative', overflow: 'hidden', minHeight: '0' } }, this.renderPushControl(), bannerLabel && !this.isSessionExpired && (h("div", { key: 'd5147662da351b027aba0542ae3dc5af161d2aa3', class: `connection-banner connection-banner--${this.connectionStatus}` }, h("span", { key: '43cad2fcb7fd75d099fa8b73f482e7eb282c0957', class: "connection-banner__dot" }), bannerLabel)), this.useMain && h("chatleo-chat", { key: 'c3e5795f34cfa9cec09567ce6c1ef4fba3af1ed7', ref: el => (this.chatEl = el), chatStore: this.chatStore, callsAvailable: this.callsAvailable, inCall: !!this.callView, isOnline: this.chatStore?.isConnected ?? false }), this.useTray && h("chatleo-tray-component", { key: '1c11b399fedbf010e83fafccba106713771be48d', chatStore: this.chatStore, ref: el => (this.trayEl = el) }), this.useRoomView && (h("chatleo-room-view", { key: 'cd3e086d542ff5e93eed78e094552a19c9201c55', chatStore: this.chatStore, roomId: this.roomId, isOnline: this.chatStore?.isConnected ?? false, pending: this.loading, callsAvailable: this.callsAvailable, inCall: !!this.callView })), this.callView && (h("div", { key: '579ab895faaba67e3c51841e57aa70b3d333e8ae', class: "call-layer", style: { display: this.showCall ? 'flex' : 'none' } }, h("button", { key: '44f57f78e5111909d929403180aa3ec180dcf8d6', type: "button", class: "call-layer__back", onClick: () => {
722
722
  this.showCall = false;
723
723
  } }, "Chat"), h('chatleo-call-adapter', {
724
724
  ref: (el) => (this.callAdapterRef = el),
@@ -731,7 +731,7 @@ export class ChatLeoComponent {
731
731
  promoteHandler: this.promoteInCall,
732
732
  demoteHandler: this.demoteInCall,
733
733
  style: { flex: '1', minHeight: '0' },
734
- }))), this.incomingCall && (h("div", { key: 'ebdc317f30b07009f41f7f729b9e8631ea039752', class: "incoming-call", role: "dialog", "aria-modal": "true", "aria-label": `Incoming call from ${this.incomingCall.caller.display_name ?? this.incomingCall.caller.id}`, tabIndex: -1, ref: el => (this.incomingRef = el) }, h("div", { key: '4eac45f10551a47c7bf1ad8035a9da5ed2955e29', class: "incoming-call__box" }, h("p", { key: '6f74dee9aa261dc889b70c18e5b110e18b1a2111', class: "incoming-call__eyebrow" }, "Incoming call"), h("chatleo-avatar", { key: 'e097d46809d6202d64ebc1eaf42418b74c990e80', name: this.incomingCall.caller.display_name ?? this.incomingCall.caller.id, url: this.incomingCall.caller.profile_picture_url ?? null, isOnline: false }), h("p", { key: 'b160c0021f003d230d5fb544d82fd8d23f7df332', class: "incoming-call__name" }, this.incomingCall.caller.display_name ?? this.incomingCall.caller.id), h("div", { key: 'b238c1352384a0f14a2abd130fe0f3495da156f3', class: "incoming-call__actions" }, h("button", { key: '1b44cc1c87dfb89b4715fb370c490a05d97b6512', type: "button", class: "incoming-call__accept", onClick: () => void this.acceptIncomingCall() }, "Accept"), h("button", { key: '97276ec614d0be526f16573a3d0e9f6cb9e24b7c', type: "button", class: "incoming-call__decline", onClick: () => void this.declineIncomingCall() }, "Decline"))))), this.isSessionExpired && (h("div", { key: 'b387b49bc31378c63c6520a95bf732c47a142e88', class: "session-expired-overlay" }, h("div", { key: '118687b87cc612d9ad47692a3e8f2a38f3b71f32', class: "session-expired-box" }, h("svg", { key: '562cf50bb4f6cdd0e4076267c6dea5f8b76b06d7', class: "session-expired-icon", xmlns: "http://www.w3.org/2000/svg", width: "24", height: "24", viewBox: "0 0 24 24", fill: "none" }, h("path", { key: '628579c8dad4064d6fcfdfd75801160fe8f0ef8f', d: "M12 9v4M12 17h.01M10.29 3.86L1.82 18a2 2 0 001.71 3h16.94a2 2 0 001.71-3L13.71 3.86a2 2 0 00-3.42 0z", stroke: "currentColor", "stroke-width": "2", "stroke-linecap": "round", "stroke-linejoin": "round" })), h("p", { key: 'e49e2388dad8df0e961cb7e0dc605a4011775eed', class: "session-expired-title" }, "Session abgelaufen"), h("p", { key: '0b69cf4687411c7e9f117712b28da57bc798ce07', class: "session-expired-message" }, "Deine Sitzung ist abgelaufen. Bitte lade die Seite neu, um fortzufahren."), h("button", { key: '9532b50dccc9f05dc3ee4a5ea2b28eea462a0ed1', class: "session-expired-button", onClick: () => window.location.reload() }, "Seite neu laden"))))));
734
+ }))), this.incomingCall && (h("div", { key: '9a40dd687e2c9a717deecac05ab160919e6c91e4', class: "incoming-call", role: "dialog", "aria-modal": "true", "aria-label": `Incoming call from ${this.incomingCall.caller.display_name ?? this.incomingCall.caller.id}`, tabIndex: -1, ref: el => (this.incomingRef = el) }, h("div", { key: '901a91dc9d594aa6c22d34bb076b294ca7f4baff', class: "incoming-call__box" }, h("p", { key: 'de8604f814c54ff31365c71ff017529f65ad4562', class: "incoming-call__eyebrow" }, "Incoming call"), h("chatleo-avatar", { key: 'edbe19c7df4faebb8c82c124998242ab3ac057b4', name: this.incomingCall.caller.display_name ?? this.incomingCall.caller.id, url: this.incomingCall.caller.profile_picture_url ?? null, isOnline: false }), h("p", { key: '12775d0d86490918c57e22afd0d132158c8970a8', class: "incoming-call__name" }, this.incomingCall.caller.display_name ?? this.incomingCall.caller.id), h("div", { key: '1746d49c0b8df234a095d4738d3b86f3c0dadb5d', class: "incoming-call__actions" }, h("button", { key: '269ad5b6bfc735321cc55cc20e9adcd6c0239a18', type: "button", class: "incoming-call__accept", onClick: () => void this.acceptIncomingCall() }, "Accept"), h("button", { key: '8656c479150d95ea6fb2ec93aa06bda5f2fa4359', type: "button", class: "incoming-call__decline", onClick: () => void this.declineIncomingCall() }, "Decline"))))), this.isSessionExpired && (h("div", { key: 'f46db890a91aa5c5e3aef489b93765bf1702fd8c', class: "session-expired-overlay" }, h("div", { key: '1581ef80235822ace8660ff35fe6f493d69df0d2', class: "session-expired-box" }, h("svg", { key: '6fe3be249ebfaec0871c6323057dbd8bdc106799', class: "session-expired-icon", xmlns: "http://www.w3.org/2000/svg", width: "24", height: "24", viewBox: "0 0 24 24", fill: "none" }, h("path", { key: '82078e08d808f6e8c5671c343c95d54c9cf35118', d: "M12 9v4M12 17h.01M10.29 3.86L1.82 18a2 2 0 001.71 3h16.94a2 2 0 001.71-3L13.71 3.86a2 2 0 00-3.42 0z", stroke: "currentColor", "stroke-width": "2", "stroke-linecap": "round", "stroke-linejoin": "round" })), h("p", { key: '3611ca9c18813f4238dacadc669533a27f99da31', class: "session-expired-title" }, "Session abgelaufen"), h("p", { key: '7140324b6246ed5eb1917c694b85c8ee5c491408', class: "session-expired-message" }, "Deine Sitzung ist abgelaufen. Bitte lade die Seite neu, um fortzufahren."), h("button", { key: 'f11ecf3aeb0cbd64ce064e90761d5736806619b4', class: "session-expired-button", onClick: () => window.location.reload() }, "Seite neu laden"))))));
735
735
  }
736
736
  static get is() { return "chatleo-component"; }
737
737
  static get encapsulation() { return "shadow"; }
@@ -226,7 +226,7 @@ export class ChatLeoTrayComponent {
226
226
  .sort(([dateA], [dateB]) => new Date(dateA).getTime() - new Date(dateB).getTime())
227
227
  .map(([date, messages]) => (h("div", { class: "message-group" }, h("div", { class: "date-separator" }, date), messages.map(message => (h("chatleo-chat-message", { message: message, sender: this.chatStore?.usernameResolver(message.sender_id), isOwnMessage: message.sender_id === this.chatStore?.profile.id, translations: { 'you': this.chatStore?.usernameResolver(message.sender_id)?.display_name } }))))))), h("chatleo-rich-input", { key: '5db7ffd32df847bbe103659d4f8ededfcc3105b2', disabled: !!!this.selectedRoomId, placeholder: "Nachricht schreiben" })), h("div", { key: 'a4374b9f51b6f4f528ca0099df022272d41e8062', id: "chats", class: this.isChatOpen ? 'chat-panel open' : 'chat-panel' }, this.isSessionExpired && (h("div", { key: '77f04c709823b47590588651b78531fa23d84254', class: "session-expired-banner" }, h("svg", { key: '7a9e8a3baba8576df14229384f67c4e771e4280e', class: "session-expired-banner-icon", xmlns: "http://www.w3.org/2000/svg", width: "16", height: "16", viewBox: "0 0 24 24", fill: "none" }, h("path", { key: 'bededb8359f4374f131f914124f89cae938c63f2', d: "M12 9v4M12 17h.01M10.29 3.86L1.82 18a2 2 0 001.71 3h16.94a2 2 0 001.71-3L13.71 3.86a2 2 0 00-3.42 0z", stroke: "currentColor", "stroke-width": "2", "stroke-linecap": "round", "stroke-linejoin": "round" })), h("span", { key: '49ede701a42a2c16954859e5c0443c6c94168376' }, "Session abgelaufen \u2013"), h("button", { key: '1533de4c91c3e496e82781e03e34d8df9cd92bf7', class: "session-expired-banner-btn", onClick: () => window.location.reload() }, "Seite neu laden"))), !this.isSessionExpired && (this.connectionStatus === 'connecting' || this.connectionStatus === 'reconnecting' || this.connectionStatus === 'disconnected') && (h("div", { key: '5f11759ba32e228f990b2866d09e2d25c647315c', class: `connection-status-banner connection-status-banner--${this.connectionStatus}` }, h("span", { key: '55ad4bf597fcf0ee3a1e180ebfac85a8c271da16', class: "connection-status-banner__dot" }), this.connectionStatus === 'connecting' ? 'Verbindung wird hergestellt…'
228
228
  : this.connectionStatus === 'reconnecting' ? 'Verbindung wird wiederhergestellt…'
229
- : 'Offline')), h("div", { key: 'c8adfe1c61695332bef014492c7abe3d641160b0', class: "tray" }, h("chatleo-avatar", { key: 'e5ca63cb0a77c19c75ca8404a0ec92833f9881f2', name: this.chatStore?.profile?.display_name ?? "", url: this.chatStore?.profile?.profile_picture_url, isOnline: this.chatStore?.profile?.id ? (this.chatStore?.isOnline(this.chatStore.profile.id) ?? false) : false }), h("div", { key: 'a7bbd2492328f400a7e349f8296f3c1a499e171e', class: "title" }, "Nachrichten"), h("button", { key: '7c2450e2977563c59a41efc874fc9ca5c6ecbea7', class: "new-chat-btn", onClick: () => this.onNewChatClicked() }, h("svg", { key: 'a7de1919583f9264c85d2f8a0879e8f993ff848c', xmlns: "http://www.w3.org/2000/svg", width: "16", height: "16", viewBox: "0 0 16 16", fill: "none" }, h("path", { key: '63e200bbf4038f0ceb626000b53f685318cd19f8', d: "M10.497 2.43838L12.7094 4.62657M12.9439 1.6838L13.4519 2.19178C13.9192 2.6591 13.9192 3.41677 13.4519 3.8841L6.72919 10.6068C6.59783 10.7381 6.43768 10.8371 6.26144 10.8958L3.79663 11.7174C3.56275 11.7954 3.34026 11.5729 3.41821 11.339L4.23982 8.87421C4.29857 8.69797 4.39754 8.53783 4.5289 8.40647L11.2516 1.6838C11.7189 1.21648 12.4766 1.21648 12.9439 1.6838Z", stroke: "#565D6D", "stroke-width": "1.5", "stroke-linecap": "round", "stroke-linejoin": "round" }), h("path", { key: '222831ec61fc41f09ba0296731aed27050ff1b55', d: "M8 2.13312H7.2H1.8C1.35817 2.13312 1 2.49129 1 2.93312V13.7331C1 14.1749 1.35817 14.5331 1.8 14.5331H12.6C13.0418 14.5331 13.4 14.1749 13.4 13.7331V8.33312V6.99998", stroke: "#565D6D", "stroke-width": "1.5", "stroke-linecap": "round" }))), h("button", { key: '51ce8b2bc912659e7347f9eb9bfe1a1c56b23b75', class: "chat-tray-btn", onClick: this.toggleChat }, this.isChatOpen ? (h("svg", { xmlns: "http://www.w3.org/2000/svg", width: "16", height: "16", viewBox: "0 0 16 16", fill: "none" }, h("path", { d: "M3.07273 4.66669L2 5.73941L8 11.7394L14 5.73941L12.9273 4.66669L8 9.59393L3.07273 4.66669Z", fill: "#565D6D" }))) : (h("svg", { xmlns: "http://www.w3.org/2000/svg", width: "16", height: "16", viewBox: "0 0 16 16", fill: "none" }, h("path", { d: "M12.9273 11.7393L14 10.6665L8 4.66655L2 10.6665L3.07273 11.7393L8 6.81202L12.9273 11.7393Z", fill: "#565D6D" }))))), h("div", { key: '9f46873326aab72ba87cfa6b387de9c5616bb497', class: "chat-content" }, h("ul", { key: 'f1f9da34aab6ae95a9d3910de295e1dc64f31c2c' }, this.chatStore?.rooms.map(room => {
229
+ : 'Offline')), h("div", { key: 'c8adfe1c61695332bef014492c7abe3d641160b0', class: "tray" }, h("chatleo-avatar", { key: '8ee785cd081f4509aa8a68c1fa8ec3584e729c5a', name: this.chatStore?.profile?.display_name ?? "", url: this.chatStore?.profile?.profile_picture_url, isOnline: this.chatStore?.isConnected ?? false }), h("div", { key: 'e52ee5d7ca448912dd98913f1ba5cc1126212207', class: "title" }, "Nachrichten"), h("button", { key: 'ab06ce2f106a288b350342e2b0d9494452d1eda7', class: "new-chat-btn", onClick: () => this.onNewChatClicked() }, h("svg", { key: '1c6c9a6c1a8b76cc7e0144568e40779421ee71cc', xmlns: "http://www.w3.org/2000/svg", width: "16", height: "16", viewBox: "0 0 16 16", fill: "none" }, h("path", { key: 'd449d4cce2e6f07f44708f0eaf374f95b1642267', d: "M10.497 2.43838L12.7094 4.62657M12.9439 1.6838L13.4519 2.19178C13.9192 2.6591 13.9192 3.41677 13.4519 3.8841L6.72919 10.6068C6.59783 10.7381 6.43768 10.8371 6.26144 10.8958L3.79663 11.7174C3.56275 11.7954 3.34026 11.5729 3.41821 11.339L4.23982 8.87421C4.29857 8.69797 4.39754 8.53783 4.5289 8.40647L11.2516 1.6838C11.7189 1.21648 12.4766 1.21648 12.9439 1.6838Z", stroke: "#565D6D", "stroke-width": "1.5", "stroke-linecap": "round", "stroke-linejoin": "round" }), h("path", { key: '6a19c104fcf6457c2cf9b24bdbf89df1045bdc0b', d: "M8 2.13312H7.2H1.8C1.35817 2.13312 1 2.49129 1 2.93312V13.7331C1 14.1749 1.35817 14.5331 1.8 14.5331H12.6C13.0418 14.5331 13.4 14.1749 13.4 13.7331V8.33312V6.99998", stroke: "#565D6D", "stroke-width": "1.5", "stroke-linecap": "round" }))), h("button", { key: 'e235b7fe2a990954fd4ba18838a7bcf60ef5cd3f', class: "chat-tray-btn", onClick: this.toggleChat }, this.isChatOpen ? (h("svg", { xmlns: "http://www.w3.org/2000/svg", width: "16", height: "16", viewBox: "0 0 16 16", fill: "none" }, h("path", { d: "M3.07273 4.66669L2 5.73941L8 11.7394L14 5.73941L12.9273 4.66669L8 9.59393L3.07273 4.66669Z", fill: "#565D6D" }))) : (h("svg", { xmlns: "http://www.w3.org/2000/svg", width: "16", height: "16", viewBox: "0 0 16 16", fill: "none" }, h("path", { d: "M12.9273 11.7393L14 10.6665L8 4.66655L2 10.6665L3.07273 11.7393L8 6.81202L12.9273 11.7393Z", fill: "#565D6D" }))))), h("div", { key: '49495cb8b42d1e730be1c2c5d5594511b93016e6', class: "chat-content" }, h("ul", { key: '4fd54a4d2c5b42d2fc37e1257e9fdc6b87be4532' }, this.chatStore?.rooms.map(room => {
230
230
  const online = room.participantIdsWithoutSelf?.filter((id) => this.chatStore.isOnline(id)) ?? [];
231
231
  return (h("li", null, h("chatleo-room-tile-component", { chatStore: this.chatStore, room: room, onlineUserIds: online, lastMessage: undefined, timestamp: undefined, unreadCount: room.unreadCount })));
232
232
  }))))));
@@ -1 +1 @@
1
- import{t as e,p as t,H as o,c as a,h as n}from"./p-C-v19aUJ.js";import{d as i}from"./p-Exj_2-yI.js";import{d as s}from"./p-DGjAxoQy.js";import{d as c}from"./p-B7cdqAgv.js";import{d as r}from"./p-XlwGxsqT.js";import{d as l}from"./p-BdiOcOYZ.js";import{d as h}from"./p-C1mF0s8g.js";import{d}from"./p-CRtBdzP3.js";import{d as p}from"./p-8kvQ-Uh-.js";import{d as f}from"./p-fjMaTJam.js";import{d as m}from"./p-BlbDSb7D.js";import{d as u}from"./p-CfayCm9O.js";import{d as g}from"./p-xt4kzz3B.js";const b=t(class e extends o{constructor(e){super(),!1!==e&&this.__registerHost(),this.__attachShadow(),this.activeRoomChange=a(this,"activeRoomChange"),this.unreadTotalChange=a(this,"unreadTotalChange")}username;ticket;useTray;useMain=!1;useRoomView=!1;roomId;chatLeoLib;chatStore;serverUrl;transport;calls="auto";push="manual";pushSwPath;isLoggedIn=!1;loading=!1;isSessionExpired=!1;connectionStatus="disconnected";callsAvailable=!1;incomingCall=null;callView=null;showCall=!1;pushState=null;pushPromptDismissed=!1;activeRoomChange;unreadTotalChange;chatEl;boundActiveRoomChanged=e=>this.activeRoomChange.emit(e.detail??{roomId:null});boundUnreadTotalChanged=e=>this.unreadTotalChange.emit(e.detail??{count:0});callRingtoneTimer;incomingRef;callRingtoneContext;callsChannel;callAdapterRef;trayEl;static OPEN_ROOM_EVENT="chatleo:openRoom";static START_DM_EVENT="chatleo:startDM";static NEW_CHAT_EVENT="chatleo:newChat";boundOpenRoomListener=e=>this.handleExternalOpenRoom(e);boundStartDmListener=e=>this.handleExternalStartDm(e);boundNewChatListener=e=>this.handleExternalNewChat(e);boundStartCallListener=e=>this.handleExternalStartCall(e);boundCallRinging=e=>this.handleCallRinging(e);boundCallChanged=e=>this.handleCallChanged(e);boundCallRole=e=>this.handleCallRole(e);boundServiceWorkerMessage=e=>this.handleServiceWorkerMessage(e);onChatLeoLibChange(e){console.debug("onChatLeoLibChange",e),e&&this.requestLibConnection()}onChatStoreChange(e,t){console.debug("onChatStoreChange",e,t),t?.removeEventListener("callRinging",this.boundCallRinging),t?.removeEventListener("callChanged",this.boundCallChanged),t?.removeEventListener("callRole",this.boundCallRole),t?.removeEventListener("activeRoomChanged",this.boundActiveRoomChanged),t?.removeEventListener("unreadTotalChanged",this.boundUnreadTotalChanged),e.addEventListener("callRinging",this.boundCallRinging),e.addEventListener("callChanged",this.boundCallChanged),e.addEventListener("callRole",this.boundCallRole),e.addEventListener("activeRoomChanged",this.boundActiveRoomChanged),e.addEventListener("unreadTotalChanged",this.boundUnreadTotalChanged),e.addEventListener("roomAdded",(e=>{console.warn(e)})),this.activeRoomChange.emit({roomId:e.activeRoomId}),this.unreadTotalChange.emit({count:e.unreadTotal})}onTicketChange(e){console.debug("onTicketChange",e),this.requestLibConnection()}onCallsChange(e){this.chatLeoLib?.setCallsEnabled?.("off"!==e),this.refreshCallsAvailability()}componentDidLoad(){console.debug("ChatLeoComponent:componentDidLoad",this.serverUrl),this.requestLibConnection()}connectedCallback(){console.debug("ChatLeoComponent:connectedCallback"),window.addEventListener(e.OPEN_ROOM_EVENT,this.boundOpenRoomListener),window.addEventListener(e.START_DM_EVENT,this.boundStartDmListener),window.addEventListener(e.NEW_CHAT_EVENT,this.boundNewChatListener),window.addEventListener("chatleo:startCall",this.boundStartCallListener),"undefined"!=typeof navigator&&"serviceWorker"in navigator&&navigator.serviceWorker.addEventListener("message",this.boundServiceWorkerMessage)}disconnectedCallback(){console.debug("ChatLeoComponent:disconnectedCallback"),this.chatLeoLib?.unregisterClient(this),window.removeEventListener(e.OPEN_ROOM_EVENT,this.boundOpenRoomListener),window.removeEventListener(e.START_DM_EVENT,this.boundStartDmListener),window.removeEventListener(e.NEW_CHAT_EVENT,this.boundNewChatListener),window.removeEventListener("chatleo:startCall",this.boundStartCallListener),"undefined"!=typeof navigator&&"serviceWorker"in navigator&&navigator.serviceWorker.removeEventListener("message",this.boundServiceWorkerMessage),this.chatStore?.removeEventListener("callRinging",this.boundCallRinging),this.chatStore?.removeEventListener("callChanged",this.boundCallChanged),this.chatStore?.removeEventListener("activeRoomChanged",this.boundActiveRoomChanged),this.chatStore?.removeEventListener("unreadTotalChanged",this.boundUnreadTotalChanged),this.chatStore?.removeEventListener("callRole",this.boundCallRole),this.stopRingtone(),this.callsChannel?.close()}async requestLibConnection(){console.debug("requestLibConnection",this.chatLeoLib),this.chatLeoLib?.setCallsEnabled?.("off"!==this.calls),this.pushSwPath&&this.chatLeoLib?.setPushServiceWorkerPath?.(this.pushSwPath),await(this.chatLeoLib?.requestConnection(this,{...this.ticket?{ticket:this.ticket}:{},...this.transport?{transport:this.transport}:{}}))}setLoading(e){this.loading=e}setLoggedIn(e){this.isLoggedIn=e,e&&(this.refreshCallsAvailability(),this.refreshPush())}setSessionExpired(e){this.isSessionExpired=e}setConnectionStatus(e){this.connectionStatus=e}async getConnectionStatus(){return{isConnected:this.chatStore?.isConnected??!1,isSessionExpired:this.isSessionExpired||(this.chatStore?.isSessionExpired??!1),connectionStatus:this.chatStore?.connectionStatus??this.connectionStatus}}async openRoom(e){e?this.useTray?await(this.trayEl?.openChatPanel(e,!1)):await(this.chatEl?.openRoom?.(e)):console.warn("[chatleo-component] openRoom called without roomId")}async closeRoom(){this.useTray?await(this.trayEl?.closeChatPanel?.()):await(this.chatEl?.closeRoom?.())}async getActiveRoomId(){return this.chatStore?.activeRoomId??null}async getDraft(){return await(this.chatEl?.getDraft?.())??""}async setDraft(e){e&&await(this.chatEl?.setDraft?.(e))}async addFiles(e){await(this.chatEl?.addFiles?.(e??[]))}async focusComposer(){await(this.chatEl?.focusComposer?.())}async openDirectMessageWithUser(e,t=!1){e?await this.internalStartDmFlow(e,t):console.warn("[chatleo-component] openDirectMessageWithUser called without userId")}async openNewChatDraft(){await(this.trayEl?.openChatPanel(void 0,!0))}async internalStartDmFlow(e,t=!1){if(e)try{const o=this.chatLeoLib?.findDirectMessageRoomIdByUser(e);if(console.debug("internalStartDmFlow",{existingRoomId:o}),o)return void await this.openRoom(o);const a=await(this.chatLeoLib?.ensureDirectMessageRoom(e,t)),n=a?.roomId;n?await this.openRoom(n):(console.warn("[chatleo-component] ensureDirectMessageRoom returned no roomId"),await(this.trayEl?.openChatPanel(void 0,!1)))}catch(e){console.error("[chatleo-component] Failed to start DM",e),await(this.trayEl?.openChatPanel(void 0,!1))}}async handleExternalOpenRoom(e){const t=e.roomId,o=e?.detail?.roomId||t;o?await this.openRoom(o):e?.detail||console.warn('[chatleo-component] chatleo:openRoom event missing detail. Use new CustomEvent("chatleo:openRoom", { detail: { roomId: "..." } })')}async handleExternalStartDm(e){console.log("handleExternalStartDm",e);const t=e.userId,o=e?.detail?.userId||t,a=e?.detail?.use_external_id??!1;o?await this.openDirectMessageWithUser(o,a):e?.detail||console.warn('[chatleo-component] chatleo:startDM event missing detail. Dispatch like: new CustomEvent("chatleo:startDM", { detail: { userId: "123" } })')}async handleExternalNewChat(e){await this.openNewChatDraft()}async refreshCallsAvailability(){this.callsAvailable=!("off"===this.calls||!this.chatLeoLib?.ensureCallsAvailable)&&await this.chatLeoLib.ensureCallsAvailable()}async loadCallComponents(){if("undefined"==typeof window||window.customElements.get("chatleo-call-adapter"))return!0;try{return await import("./p-BnCPdbII.js"),!!window.customElements.get("chatleo-call-adapter")}catch(e){return console.warn("[chatleo-component] call components could not be loaded",e),!1}}async startOrJoinCall(e,t,o){if(this.chatLeoLib)if(this.callView&&(t?this.callView.callId===t:this.callView.roomId===e))this.showCall=!0;else try{const a=this.chatStore?.rooms.find((t=>t.id===e)),n=t?{id:t,mode:"DirectMessage"===a?.type?"direct":"group"}:await this.chatLeoLib.startCall(e,o),i=await this.chatLeoLib.joinCall(n.id);if(!await this.loadCallComponents())return;this.callView={callId:n.id,roomId:e,mode:i.mode??n.mode,credentials:{sfuUrl:i.sfu_url,token:i.token,roomId:i.room_id,mode:i.mode,iceServers:i.ice_servers}},this.showCall=!0,this.incomingCall=null,this.stopRingtone()}catch(e){console.warn("[chatleo-component] call start/join failed",e)}}onIncomingCallChange(e){e&&setTimeout((()=>this.incomingRef?.focus()),0)}handleCallRinging(e){this.incomingCall=e.detail?.call??null,this.incomingCall?this.startRingtone(this.incomingCall.id):this.stopRingtone()}handleCallChanged(e){this.callView&&!e.detail?.call&&(this.callView=null,this.showCall=!1,this.stopRingtone())}async acceptIncomingCall(){if(!this.incomingCall)return;const e=this.incomingCall;this.incomingCall=null,this.stopRingtone(),await this.startOrJoinCall(e.room_id,e.id)}async declineIncomingCall(){if(!this.incomingCall||!this.chatLeoLib)return;const e=this.incomingCall;this.incomingCall=null,this.stopRingtone();try{await this.chatLeoLib.declineCall(e.id)}catch(e){console.warn("[chatleo-component] decline failed",e)}}handleExternalStartCall(e){const t=e?.detail?.roomId;t&&this.startOrJoinCall(t,void 0,e.detail.mode)}handleCallRole(e){const{callId:t,userId:o}=e.detail??{};this.callView&&this.callView.callId===t&&(o&&o!==this.chatStore?.profile?.id||this.callAdapterRef?.refreshToken?.().catch((e=>console.warn("[chatleo-component] token refresh after a role change failed",e))))}callToken=async()=>{const e=this.callView;if(!e||!this.chatLeoLib)throw Error("no call");const t=await this.chatLeoLib.refreshCallToken(e.callId);return{token:t.token,sfuUrl:t.sfu_url,iceServers:t.ice_servers}};promoteInCall=async(e,t,o)=>{const a=this.callView;if(!a||!this.chatLeoLib||!o?.userId)throw Error("unknown participant");await this.chatLeoLib.promoteCallParticipant(a.callId,o.userId)};demoteInCall=async(e,t)=>{const o=this.callView;if(!o||!this.chatLeoLib||!t?.userId)throw Error("unknown participant");await this.chatLeoLib.demoteCallParticipant(o.callId,t.userId)};startRingtone(e){if("undefined"!=typeof window){if(this.callsChannel??="undefined"!=typeof BroadcastChannel?new BroadcastChannel("chatleo-calls"):void 0,this.callsChannel){const t=this.callsChannel;t.addEventListener("message",(t=>{"ring"===t.data?.type&&t.data.callId===e&&this.stopRingtone()}),{once:!0}),t.postMessage({type:"ring",callId:e})}try{const e=this.callRingtoneContext??new AudioContext;this.callRingtoneContext=e;const t=()=>{const t=e.createOscillator(),o=e.createGain();t.frequency.value=660,o.gain.value=.04,t.connect(o).connect(e.destination),t.start(),setTimeout((()=>t.stop()),180)};t(),this.callRingtoneTimer=setInterval(t,1200)}catch{}}}stopRingtone(){this.callRingtoneTimer&&(clearInterval(this.callRingtoneTimer),this.callRingtoneTimer=void 0)}async refreshPush(){if("off"!==this.push&&this.chatLeoLib?.pushState)try{this.pushState=await this.chatLeoLib.pushState()}catch{this.pushState=null}else this.pushState=null}async enablePush(){if(this.chatLeoLib?.enablePush)try{this.pushState=await this.chatLeoLib.enablePush(),this.pushPromptDismissed=!0}catch(e){console.warn("[chatleo-component] enabling push failed",e),await this.refreshPush()}}async disablePush(){if(this.chatLeoLib?.disablePush)try{this.pushState=await this.chatLeoLib.disablePush()}catch(e){console.warn("[chatleo-component] disabling push failed",e)}}handleServiceWorkerMessage(e){if("chatleo:pushVisibility"!==e.data?.type)"chatleo:openRoom"===e.data?.type&&e.data.roomId&&(this.openRoom(e.data.roomId+""),"undefined"!=typeof navigator&&"clearAppBadge"in navigator&&navigator.clearAppBadge());else{const t=(e.data.roomId??"")+"",o="undefined"!=typeof document&&"visible"===document.visibilityState&&this.chatStore?.activeRoomId===t;e.ports?.[0]?.postMessage({visible:o})}}renderPushControl(){if("off"===this.push||!this.pushState)return null;const e=this.pushState;return"ios_install_required"===e.availability?n("div",{class:"push-control push-control--hint"},"Add ChatLeo to your home screen to enable notifications."):"available"!==e.availability?null:"denied"===e.permission?n("div",{class:"push-control push-control--hint"},"Notifications are blocked in your browser settings."):e.subscribed&&e.accountEnabled?n("button",{type:"button",class:"push-control",onClick:()=>{this.disablePush()}},"Notifications on"):"prompt"!==this.push||this.pushPromptDismissed?n("button",{type:"button",class:"push-control",onClick:()=>{this.enablePush()}},"Enable notifications"):n("div",{class:"push-control push-control--prompt",role:"region","aria-label":"Enable notifications"},n("span",null,"Get notified about new messages when ChatLeo is in the background."),n("button",{type:"button",onClick:()=>{this.enablePush()}},"Enable"),n("button",{type:"button",class:"push-control__secondary",onClick:()=>{this.pushPromptDismissed=!0}},"Not now"))}identityResolver={resolve:e=>Object.fromEntries(e.map((e=>{const t=this.chatStore?.usernameResolver(e);return[e,{displayName:t?.display_name??e,avatarUrl:t?.profile_picture_url??void 0}]})))};onCallError(e){const t=this.callView,o=e.detail?.code;t&&o&&["auth_rejected","removed","session_replaced","room_ended","room_full","network_failed"].includes(o)&&(this.callView=null,this.showCall=!1,"network_failed"===o&&this.chatLeoLib?.leaveCall(t.callId).catch((()=>{})))}onCallLeft(){const e=this.callView;e&&(this.callView=null,this.showCall=!1,this.chatLeoLib?.leaveCall(e.callId).catch((e=>console.warn("[chatleo-component] leave failed",e))))}onCallRequested(e){const t=e.detail;t?.roomId&&this.startOrJoinCall(t.roomId,t.callId)}onNewChatClicked(e){}onChatMessage(e){console.debug("messageChatSent",e),this.chatLeoLib?.sendChatMessage(e.detail)}async onUserSelectedForChat(e){const t=e.detail;t&&t.id&&await this.internalStartDmFlow(t.id)}get _connectionBannerLabel(){switch(this.connectionStatus){case"connecting":return"Verbindung wird hergestellt…";case"reconnecting":return"Verbindung wird wiederhergestellt…";case"disconnected":return"Offline";default:return null}}render(){const e=this._connectionBannerLabel;return n("div",{key:"d0c7c84ebf5fe164868f6e2250252a0899493ee3",style:{height:"100%",maxHeight:"inherit",width:"100%",display:"flex",flexDirection:"column",position:"relative",overflow:"hidden",minHeight:"0"}},this.renderPushControl(),e&&!this.isSessionExpired&&n("div",{key:"d5147662da351b027aba0542ae3dc5af161d2aa3",class:"connection-banner connection-banner--"+this.connectionStatus},n("span",{key:"43cad2fcb7fd75d099fa8b73f482e7eb282c0957",class:"connection-banner__dot"}),e),this.useMain&&n("chatleo-chat",{key:"609457ee0ab1ceaa2484d91d4c54d734770f4d01",ref:e=>this.chatEl=e,chatStore:this.chatStore,callsAvailable:this.callsAvailable,inCall:!!this.callView}),this.useTray&&n("chatleo-tray-component",{key:"ebd656fd966561d4f982859b9c36a1e233b204b6",chatStore:this.chatStore,ref:e=>this.trayEl=e}),this.useRoomView&&n("chatleo-room-view",{key:"6af1a89788728c21f72ee1a31b7e70bd7d096f0f",chatStore:this.chatStore,roomId:this.roomId,isOnline:this.chatStore?.isConnected??!1,pending:this.loading,callsAvailable:this.callsAvailable,inCall:!!this.callView}),this.callView&&n("div",{key:"3a346cdaf24c1fe758f86e1233cc4626db023a32",class:"call-layer",style:{display:this.showCall?"flex":"none"}},n("button",{key:"7720dc641239eb8da833c63c1f30d4ed29fece7c",type:"button",class:"call-layer__back",onClick:()=>{this.showCall=!1}},"Chat"),n("chatleo-call-adapter",{ref:e=>this.callAdapterRef=e,callId:this.callView.callId,mode:this.callView.mode,connection:this.callView.credentials,autoJoin:!0,identity:this.identityResolver,getToken:this.callToken,promoteHandler:this.promoteInCall,demoteHandler:this.demoteInCall,style:{flex:"1",minHeight:"0"}})),this.incomingCall&&n("div",{key:"ebdc317f30b07009f41f7f729b9e8631ea039752",class:"incoming-call",role:"dialog","aria-modal":"true","aria-label":"Incoming call from "+(this.incomingCall.caller.display_name??this.incomingCall.caller.id),tabIndex:-1,ref:e=>this.incomingRef=e},n("div",{key:"4eac45f10551a47c7bf1ad8035a9da5ed2955e29",class:"incoming-call__box"},n("p",{key:"6f74dee9aa261dc889b70c18e5b110e18b1a2111",class:"incoming-call__eyebrow"},"Incoming call"),n("chatleo-avatar",{key:"e097d46809d6202d64ebc1eaf42418b74c990e80",name:this.incomingCall.caller.display_name??this.incomingCall.caller.id,url:this.incomingCall.caller.profile_picture_url??null,isOnline:!1}),n("p",{key:"b160c0021f003d230d5fb544d82fd8d23f7df332",class:"incoming-call__name"},this.incomingCall.caller.display_name??this.incomingCall.caller.id),n("div",{key:"b238c1352384a0f14a2abd130fe0f3495da156f3",class:"incoming-call__actions"},n("button",{key:"1b44cc1c87dfb89b4715fb370c490a05d97b6512",type:"button",class:"incoming-call__accept",onClick:()=>{this.acceptIncomingCall()}},"Accept"),n("button",{key:"97276ec614d0be526f16573a3d0e9f6cb9e24b7c",type:"button",class:"incoming-call__decline",onClick:()=>{this.declineIncomingCall()}},"Decline")))),this.isSessionExpired&&n("div",{key:"b387b49bc31378c63c6520a95bf732c47a142e88",class:"session-expired-overlay"},n("div",{key:"118687b87cc612d9ad47692a3e8f2a38f3b71f32",class:"session-expired-box"},n("svg",{key:"562cf50bb4f6cdd0e4076267c6dea5f8b76b06d7",class:"session-expired-icon",xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none"},n("path",{key:"628579c8dad4064d6fcfdfd75801160fe8f0ef8f",d:"M12 9v4M12 17h.01M10.29 3.86L1.82 18a2 2 0 001.71 3h16.94a2 2 0 001.71-3L13.71 3.86a2 2 0 00-3.42 0z",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"})),n("p",{key:"e49e2388dad8df0e961cb7e0dc605a4011775eed",class:"session-expired-title"},"Session abgelaufen"),n("p",{key:"0b69cf4687411c7e9f117712b28da57bc798ce07",class:"session-expired-message"},"Deine Sitzung ist abgelaufen. Bitte lade die Seite neu, um fortzufahren."),n("button",{key:"9532b50dccc9f05dc3ee4a5ea2b28eea462a0ed1",class:"session-expired-button",onClick:()=>window.location.reload()},"Seite neu laden"))))}static get watchers(){return{chatLeoLib:[{onChatLeoLibChange:0}],chatStore:[{onChatStoreChange:0}],ticket:[{onTicketChange:0}],calls:[{onCallsChange:0}],incomingCall:[{onIncomingCallChange:0}]}}static get style(){return":host{overflow:hidden;position:relative;height:100%;max-height:100%;min-height:0;--display:block;--bg-primary:#ffffff;--bg-secondary:#f3f4f6;--bg-light:#e7effc;--text-primary:#171a1f;--text-secondary:#9095a1;--border-color:#bdc1ca;--border-light:#eeeeee;--accent-color:#4a86e8;--accent-hover:#3a7bd8;--status-online:#21d184;--status-offline:#6b7280;--font-primary:'Manrope', sans-serif;--avatar-size:36px;--border-radius:8px;--transition-duration:0.2s;display:var(--display)}.connection-banner{display:flex;align-items:center;gap:6px;padding:5px 12px;font-family:var(--font-primary, 'Manrope', sans-serif);font-size:12px;font-weight:600;color:#fff;background:#6b7280;z-index:100;flex-shrink:0}.connection-banner--connecting,.connection-banner--reconnecting{background:#f59e0b;color:#fff}.connection-banner--disconnected{background:#ef4444;color:#fff}.connection-banner__dot{width:7px;height:7px;border-radius:50%;background:rgba(255, 255, 255, 0.8);flex-shrink:0;animation:pulse-dot 1.4s ease-in-out infinite}.connection-banner--disconnected .connection-banner__dot{animation:none}@keyframes pulse-dot{0%,100%{opacity:1}50%{opacity:0.3}}.session-expired-overlay{position:absolute;inset:0;z-index:9999;background:rgba(255, 255, 255, 0.85);backdrop-filter:blur(4px);display:flex;align-items:center;justify-content:center}.session-expired-box{background:var(--bg-primary, #fff);border:1px solid var(--border-color, #bdc1ca);border-radius:var(--border-radius, 8px);box-shadow:0 4px 24px rgba(0, 0, 0, 0.12);padding:32px 28px;max-width:340px;width:100%;text-align:center;display:flex;flex-direction:column;align-items:center;gap:12px}.session-expired-icon{color:#f59e0b;width:32px;height:32px}.session-expired-title{margin:0;font-family:var(--font-primary, 'Manrope', sans-serif);font-size:16px;font-weight:700;color:var(--text-primary, #171a1f)}.session-expired-message{margin:0;font-family:var(--font-primary, 'Manrope', sans-serif);font-size:13px;color:var(--text-secondary, #9095a1);line-height:1.6}.session-expired-button{margin-top:4px;padding:8px 20px;background:var(--accent-color, #4a86e8);color:#fff;border:none;border-radius:var(--border-radius, 8px);font-family:var(--font-primary, 'Manrope', sans-serif);font-size:14px;font-weight:600;cursor:pointer;transition:background var(--transition-duration, 0.2s)}.session-expired-button:hover{background:var(--accent-hover, #3a7bd8)}.call-layer{position:absolute;inset:0;z-index:40;background:var(--bg-primary, #fff);flex-direction:column}.call-layer__back{align-self:flex-end;margin:8px 16px 0;border:1px solid var(--border-color, #ddd);background:transparent;border-radius:6px;padding:4px 10px;font:inherit;cursor:pointer}.incoming-call{position:absolute;inset:0;z-index:50;display:flex;align-items:center;justify-content:center;background:rgba(15, 23, 42, 0.45)}.incoming-call:focus{outline:none}.incoming-call__box{width:min(320px, calc(100% - 32px));background:var(--bg-primary, #fff);border-radius:12px;padding:24px;text-align:center;box-shadow:0 18px 50px rgba(15, 23, 42, 0.25)}.incoming-call__eyebrow{margin:0 0 12px;font-size:12px;letter-spacing:0.08em;text-transform:uppercase;color:var(--text-secondary, #667)}.incoming-call__name{margin:12px 0 20px;font-size:18px;font-weight:700}.incoming-call__actions{display:flex;gap:10px;justify-content:center}.incoming-call__accept,.incoming-call__decline{border-radius:8px;padding:8px 18px;font:inherit;cursor:pointer}.incoming-call__accept{border:none;background:#1b8a3a;color:#fff}.incoming-call__decline{border:1px solid var(--border-color, #ddd);background:transparent;color:inherit}.push-control{display:flex;align-items:center;gap:8px;padding:6px 12px;border:0;border-bottom:1px solid var(--border-light, #eee);background:var(--bg-secondary, #f7f8fa);color:var(--text-primary, #222);font:inherit;font-size:12px;text-align:left;cursor:pointer}.push-control--hint{cursor:default;color:var(--text-secondary, #667)}.push-control--prompt{flex-wrap:wrap}.push-control--prompt button{border:1px solid var(--accent-color, #4a86e8);border-radius:6px;background:transparent;color:var(--accent-color, #4a86e8);padding:3px 10px;font:inherit;cursor:pointer}.push-control__secondary{border-color:var(--border-color, #ddd) !important;color:var(--text-secondary, #667) !important}"}},[513,"chatleo-component",{username:[1],ticket:[1],useTray:[4,"use-tray"],useMain:[4,"use-main"],useRoomView:[4,"use-room-view"],roomId:[1,"room-id"],chatLeoLib:[16],chatStore:[16],serverUrl:[1,"server-url"],transport:[1],calls:[1],push:[1],pushSwPath:[1,"push-sw-path"],isLoggedIn:[32],loading:[32],isSessionExpired:[32],connectionStatus:[32],callsAvailable:[32],incomingCall:[32],callView:[32],showCall:[32],pushState:[32],pushPromptDismissed:[32],getConnectionStatus:[64],openRoom:[64],closeRoom:[64],getActiveRoomId:[64],getDraft:[64],setDraft:[64],addFiles:[64],focusComposer:[64],openDirectMessageWithUser:[64],openNewChatDraft:[64]},[[0,"callError","onCallError"],[0,"callLeft","onCallLeft"],[0,"callRequested","onCallRequested"],[0,"newChatClicked","onNewChatClicked"],[0,"messageChatSent","onChatMessage"],[0,"userSelected","onUserSelectedForChat"]],{chatLeoLib:[{onChatLeoLibChange:0}],chatStore:[{onChatStoreChange:0}],ticket:[{onTicketChange:0}],calls:[{onCallsChange:0}],incomingCall:[{onIncomingCallChange:0}]}]);function y(){"undefined"!=typeof customElements&&["chatleo-component","chatleo-avatar","chatleo-chat","chatleo-chat-header","chatleo-chat-message","chatleo-new-message-selector","chatleo-rich-input","chatleo-rich-message-renderer","chatleo-room-list","chatleo-room-tile-component","chatleo-room-view","chatleo-tray-component","chatleo-user-tile"].forEach((t=>{switch(t){case"chatleo-component":customElements.get(e(t))||customElements.define(e(t),b);break;case"chatleo-avatar":customElements.get(e(t))||i();break;case"chatleo-chat":customElements.get(e(t))||s();break;case"chatleo-chat-header":customElements.get(e(t))||c();break;case"chatleo-chat-message":customElements.get(e(t))||r();break;case"chatleo-new-message-selector":customElements.get(e(t))||l();break;case"chatleo-rich-input":customElements.get(e(t))||h();break;case"chatleo-rich-message-renderer":customElements.get(e(t))||d();break;case"chatleo-room-list":customElements.get(e(t))||p();break;case"chatleo-room-tile-component":customElements.get(e(t))||f();break;case"chatleo-room-view":customElements.get(e(t))||m();break;case"chatleo-tray-component":customElements.get(e(t))||u();break;case"chatleo-user-tile":customElements.get(e(t))||g()}}))}y();const C=b,w=y;export{C as ChatleoComponent,w as defineCustomElement}
1
+ import{t as e,p as t,H as o,c as a,h as n}from"./p-C-v19aUJ.js";import{d as i}from"./p-Exj_2-yI.js";import{d as s}from"./p-DGjAxoQy.js";import{d as c}from"./p-B7cdqAgv.js";import{d as r}from"./p-XlwGxsqT.js";import{d as l}from"./p-BdiOcOYZ.js";import{d as h}from"./p-C1mF0s8g.js";import{d}from"./p-CRtBdzP3.js";import{d as p}from"./p-8kvQ-Uh-.js";import{d as f}from"./p-fjMaTJam.js";import{d as m}from"./p-BlbDSb7D.js";import{d as u}from"./p-XuNqYCqC.js";import{d as g}from"./p-xt4kzz3B.js";const b=t(class e extends o{constructor(e){super(),!1!==e&&this.__registerHost(),this.__attachShadow(),this.activeRoomChange=a(this,"activeRoomChange"),this.unreadTotalChange=a(this,"unreadTotalChange")}username;ticket;useTray;useMain=!1;useRoomView=!1;roomId;chatLeoLib;chatStore;serverUrl;transport;calls="auto";push="manual";pushSwPath;isLoggedIn=!1;loading=!1;isSessionExpired=!1;connectionStatus="disconnected";callsAvailable=!1;incomingCall=null;callView=null;showCall=!1;pushState=null;pushPromptDismissed=!1;activeRoomChange;unreadTotalChange;chatEl;boundActiveRoomChanged=e=>this.activeRoomChange.emit(e.detail??{roomId:null});boundUnreadTotalChanged=e=>this.unreadTotalChange.emit(e.detail??{count:0});callRingtoneTimer;incomingRef;callRingtoneContext;callsChannel;callAdapterRef;trayEl;static OPEN_ROOM_EVENT="chatleo:openRoom";static START_DM_EVENT="chatleo:startDM";static NEW_CHAT_EVENT="chatleo:newChat";boundOpenRoomListener=e=>this.handleExternalOpenRoom(e);boundStartDmListener=e=>this.handleExternalStartDm(e);boundNewChatListener=e=>this.handleExternalNewChat(e);boundStartCallListener=e=>this.handleExternalStartCall(e);boundCallRinging=e=>this.handleCallRinging(e);boundCallChanged=e=>this.handleCallChanged(e);boundCallRole=e=>this.handleCallRole(e);boundServiceWorkerMessage=e=>this.handleServiceWorkerMessage(e);onChatLeoLibChange(e){console.debug("onChatLeoLibChange",e),e&&this.requestLibConnection()}onChatStoreChange(e,t){console.debug("onChatStoreChange",e,t),t?.removeEventListener("callRinging",this.boundCallRinging),t?.removeEventListener("callChanged",this.boundCallChanged),t?.removeEventListener("callRole",this.boundCallRole),t?.removeEventListener("activeRoomChanged",this.boundActiveRoomChanged),t?.removeEventListener("unreadTotalChanged",this.boundUnreadTotalChanged),e.addEventListener("callRinging",this.boundCallRinging),e.addEventListener("callChanged",this.boundCallChanged),e.addEventListener("callRole",this.boundCallRole),e.addEventListener("activeRoomChanged",this.boundActiveRoomChanged),e.addEventListener("unreadTotalChanged",this.boundUnreadTotalChanged),e.addEventListener("roomAdded",(e=>{console.warn(e)})),this.activeRoomChange.emit({roomId:e.activeRoomId}),this.unreadTotalChange.emit({count:e.unreadTotal})}onTicketChange(e){console.debug("onTicketChange",e),this.requestLibConnection()}onCallsChange(e){this.chatLeoLib?.setCallsEnabled?.("off"!==e),this.refreshCallsAvailability()}componentDidLoad(){console.debug("ChatLeoComponent:componentDidLoad",this.serverUrl),this.requestLibConnection()}connectedCallback(){console.debug("ChatLeoComponent:connectedCallback"),window.addEventListener(e.OPEN_ROOM_EVENT,this.boundOpenRoomListener),window.addEventListener(e.START_DM_EVENT,this.boundStartDmListener),window.addEventListener(e.NEW_CHAT_EVENT,this.boundNewChatListener),window.addEventListener("chatleo:startCall",this.boundStartCallListener),"undefined"!=typeof navigator&&"serviceWorker"in navigator&&navigator.serviceWorker.addEventListener("message",this.boundServiceWorkerMessage)}disconnectedCallback(){console.debug("ChatLeoComponent:disconnectedCallback"),this.chatLeoLib?.unregisterClient(this),window.removeEventListener(e.OPEN_ROOM_EVENT,this.boundOpenRoomListener),window.removeEventListener(e.START_DM_EVENT,this.boundStartDmListener),window.removeEventListener(e.NEW_CHAT_EVENT,this.boundNewChatListener),window.removeEventListener("chatleo:startCall",this.boundStartCallListener),"undefined"!=typeof navigator&&"serviceWorker"in navigator&&navigator.serviceWorker.removeEventListener("message",this.boundServiceWorkerMessage),this.chatStore?.removeEventListener("callRinging",this.boundCallRinging),this.chatStore?.removeEventListener("callChanged",this.boundCallChanged),this.chatStore?.removeEventListener("activeRoomChanged",this.boundActiveRoomChanged),this.chatStore?.removeEventListener("unreadTotalChanged",this.boundUnreadTotalChanged),this.chatStore?.removeEventListener("callRole",this.boundCallRole),this.stopRingtone(),this.callsChannel?.close()}async requestLibConnection(){console.debug("requestLibConnection",this.chatLeoLib),this.chatLeoLib?.setCallsEnabled?.("off"!==this.calls),this.pushSwPath&&this.chatLeoLib?.setPushServiceWorkerPath?.(this.pushSwPath),await(this.chatLeoLib?.requestConnection(this,{...this.ticket?{ticket:this.ticket}:{},...this.transport?{transport:this.transport}:{}}))}setLoading(e){this.loading=e}setLoggedIn(e){this.isLoggedIn=e,e&&(this.refreshCallsAvailability(),this.refreshPush())}setSessionExpired(e){this.isSessionExpired=e}setConnectionStatus(e){this.connectionStatus=e}async getConnectionStatus(){return{isConnected:this.chatStore?.isConnected??!1,isSessionExpired:this.isSessionExpired||(this.chatStore?.isSessionExpired??!1),connectionStatus:this.chatStore?.connectionStatus??this.connectionStatus}}async openRoom(e){e?this.useTray?await(this.trayEl?.openChatPanel(e,!1)):await(this.chatEl?.openRoom?.(e)):console.warn("[chatleo-component] openRoom called without roomId")}async closeRoom(){this.useTray?await(this.trayEl?.closeChatPanel?.()):await(this.chatEl?.closeRoom?.())}async getActiveRoomId(){return this.chatStore?.activeRoomId??null}async getDraft(){return await(this.chatEl?.getDraft?.())??""}async setDraft(e){e&&await(this.chatEl?.setDraft?.(e))}async addFiles(e){await(this.chatEl?.addFiles?.(e??[]))}async focusComposer(){await(this.chatEl?.focusComposer?.())}async openDirectMessageWithUser(e,t=!1){e?await this.internalStartDmFlow(e,t):console.warn("[chatleo-component] openDirectMessageWithUser called without userId")}async openNewChatDraft(){await(this.trayEl?.openChatPanel(void 0,!0))}async internalStartDmFlow(e,t=!1){if(e)try{const o=this.chatLeoLib?.findDirectMessageRoomIdByUser(e);if(console.debug("internalStartDmFlow",{existingRoomId:o}),o)return void await this.openRoom(o);const a=await(this.chatLeoLib?.ensureDirectMessageRoom(e,t)),n=a?.roomId;n?await this.openRoom(n):(console.warn("[chatleo-component] ensureDirectMessageRoom returned no roomId"),await(this.trayEl?.openChatPanel(void 0,!1)))}catch(e){console.error("[chatleo-component] Failed to start DM",e),await(this.trayEl?.openChatPanel(void 0,!1))}}async handleExternalOpenRoom(e){const t=e.roomId,o=e?.detail?.roomId||t;o?await this.openRoom(o):e?.detail||console.warn('[chatleo-component] chatleo:openRoom event missing detail. Use new CustomEvent("chatleo:openRoom", { detail: { roomId: "..." } })')}async handleExternalStartDm(e){console.log("handleExternalStartDm",e);const t=e.userId,o=e?.detail?.userId||t,a=e?.detail?.use_external_id??!1;o?await this.openDirectMessageWithUser(o,a):e?.detail||console.warn('[chatleo-component] chatleo:startDM event missing detail. Dispatch like: new CustomEvent("chatleo:startDM", { detail: { userId: "123" } })')}async handleExternalNewChat(e){await this.openNewChatDraft()}async refreshCallsAvailability(){this.callsAvailable=!("off"===this.calls||!this.chatLeoLib?.ensureCallsAvailable)&&await this.chatLeoLib.ensureCallsAvailable()}async loadCallComponents(){if("undefined"==typeof window||window.customElements.get("chatleo-call-adapter"))return!0;try{return await import("./p-BnCPdbII.js"),!!window.customElements.get("chatleo-call-adapter")}catch(e){return console.warn("[chatleo-component] call components could not be loaded",e),!1}}async startOrJoinCall(e,t,o){if(this.chatLeoLib)if(this.callView&&(t?this.callView.callId===t:this.callView.roomId===e))this.showCall=!0;else try{const a=this.chatStore?.rooms.find((t=>t.id===e)),n=t?{id:t,mode:"DirectMessage"===a?.type?"direct":"group"}:await this.chatLeoLib.startCall(e,o),i=await this.chatLeoLib.joinCall(n.id);if(!await this.loadCallComponents())return;this.callView={callId:n.id,roomId:e,mode:i.mode??n.mode,credentials:{sfuUrl:i.sfu_url,token:i.token,roomId:i.room_id,mode:i.mode,iceServers:i.ice_servers}},this.showCall=!0,this.incomingCall=null,this.stopRingtone()}catch(e){console.warn("[chatleo-component] call start/join failed",e)}}onIncomingCallChange(e){e&&setTimeout((()=>this.incomingRef?.focus()),0)}handleCallRinging(e){this.incomingCall=e.detail?.call??null,this.incomingCall?this.startRingtone(this.incomingCall.id):this.stopRingtone()}handleCallChanged(e){this.callView&&!e.detail?.call&&(this.callView=null,this.showCall=!1,this.stopRingtone())}async acceptIncomingCall(){if(!this.incomingCall)return;const e=this.incomingCall;this.incomingCall=null,this.stopRingtone(),await this.startOrJoinCall(e.room_id,e.id)}async declineIncomingCall(){if(!this.incomingCall||!this.chatLeoLib)return;const e=this.incomingCall;this.incomingCall=null,this.stopRingtone();try{await this.chatLeoLib.declineCall(e.id)}catch(e){console.warn("[chatleo-component] decline failed",e)}}handleExternalStartCall(e){const t=e?.detail?.roomId;t&&this.startOrJoinCall(t,void 0,e.detail.mode)}handleCallRole(e){const{callId:t,userId:o}=e.detail??{};this.callView&&this.callView.callId===t&&(o&&o!==this.chatStore?.profile?.id||this.callAdapterRef?.refreshToken?.().catch((e=>console.warn("[chatleo-component] token refresh after a role change failed",e))))}callToken=async()=>{const e=this.callView;if(!e||!this.chatLeoLib)throw Error("no call");const t=await this.chatLeoLib.refreshCallToken(e.callId);return{token:t.token,sfuUrl:t.sfu_url,iceServers:t.ice_servers}};promoteInCall=async(e,t,o)=>{const a=this.callView;if(!a||!this.chatLeoLib||!o?.userId)throw Error("unknown participant");await this.chatLeoLib.promoteCallParticipant(a.callId,o.userId)};demoteInCall=async(e,t)=>{const o=this.callView;if(!o||!this.chatLeoLib||!t?.userId)throw Error("unknown participant");await this.chatLeoLib.demoteCallParticipant(o.callId,t.userId)};startRingtone(e){if("undefined"!=typeof window){if(this.callsChannel??="undefined"!=typeof BroadcastChannel?new BroadcastChannel("chatleo-calls"):void 0,this.callsChannel){const t=this.callsChannel;t.addEventListener("message",(t=>{"ring"===t.data?.type&&t.data.callId===e&&this.stopRingtone()}),{once:!0}),t.postMessage({type:"ring",callId:e})}try{const e=this.callRingtoneContext??new AudioContext;this.callRingtoneContext=e;const t=()=>{const t=e.createOscillator(),o=e.createGain();t.frequency.value=660,o.gain.value=.04,t.connect(o).connect(e.destination),t.start(),setTimeout((()=>t.stop()),180)};t(),this.callRingtoneTimer=setInterval(t,1200)}catch{}}}stopRingtone(){this.callRingtoneTimer&&(clearInterval(this.callRingtoneTimer),this.callRingtoneTimer=void 0)}async refreshPush(){if("off"!==this.push&&this.chatLeoLib?.pushState)try{this.pushState=await this.chatLeoLib.pushState()}catch{this.pushState=null}else this.pushState=null}async enablePush(){if(this.chatLeoLib?.enablePush)try{this.pushState=await this.chatLeoLib.enablePush(),this.pushPromptDismissed=!0}catch(e){console.warn("[chatleo-component] enabling push failed",e),await this.refreshPush()}}async disablePush(){if(this.chatLeoLib?.disablePush)try{this.pushState=await this.chatLeoLib.disablePush()}catch(e){console.warn("[chatleo-component] disabling push failed",e)}}handleServiceWorkerMessage(e){if("chatleo:pushVisibility"!==e.data?.type)"chatleo:openRoom"===e.data?.type&&e.data.roomId&&(this.openRoom(e.data.roomId+""),"undefined"!=typeof navigator&&"clearAppBadge"in navigator&&navigator.clearAppBadge());else{const t=(e.data.roomId??"")+"",o="undefined"!=typeof document&&"visible"===document.visibilityState&&this.chatStore?.activeRoomId===t;e.ports?.[0]?.postMessage({visible:o})}}renderPushControl(){if("off"===this.push||!this.pushState)return null;const e=this.pushState;return"ios_install_required"===e.availability?n("div",{class:"push-control push-control--hint"},"Add ChatLeo to your home screen to enable notifications."):"available"!==e.availability?null:"denied"===e.permission?n("div",{class:"push-control push-control--hint"},"Notifications are blocked in your browser settings."):e.subscribed&&e.accountEnabled?n("button",{type:"button",class:"push-control",onClick:()=>{this.disablePush()}},"Notifications on"):"prompt"!==this.push||this.pushPromptDismissed?n("button",{type:"button",class:"push-control",onClick:()=>{this.enablePush()}},"Enable notifications"):n("div",{class:"push-control push-control--prompt",role:"region","aria-label":"Enable notifications"},n("span",null,"Get notified about new messages when ChatLeo is in the background."),n("button",{type:"button",onClick:()=>{this.enablePush()}},"Enable"),n("button",{type:"button",class:"push-control__secondary",onClick:()=>{this.pushPromptDismissed=!0}},"Not now"))}identityResolver={resolve:e=>Object.fromEntries(e.map((e=>{const t=this.chatStore?.usernameResolver(e);return[e,{displayName:t?.display_name??e,avatarUrl:t?.profile_picture_url??void 0}]})))};onCallError(e){const t=this.callView,o=e.detail?.code;t&&o&&["auth_rejected","removed","session_replaced","room_ended","room_full","network_failed"].includes(o)&&(this.callView=null,this.showCall=!1,"network_failed"===o&&this.chatLeoLib?.leaveCall(t.callId).catch((()=>{})))}onCallLeft(){const e=this.callView;e&&(this.callView=null,this.showCall=!1,this.chatLeoLib?.leaveCall(e.callId).catch((e=>console.warn("[chatleo-component] leave failed",e))))}onCallRequested(e){const t=e.detail;t?.roomId&&this.startOrJoinCall(t.roomId,t.callId)}onNewChatClicked(e){}onChatMessage(e){console.debug("messageChatSent",e),this.chatLeoLib?.sendChatMessage(e.detail)}async onUserSelectedForChat(e){const t=e.detail;t&&t.id&&await this.internalStartDmFlow(t.id)}get _connectionBannerLabel(){switch(this.connectionStatus){case"connecting":return"Verbindung wird hergestellt…";case"reconnecting":return"Verbindung wird wiederhergestellt…";case"disconnected":return"Offline";default:return null}}render(){const e=this._connectionBannerLabel;return n("div",{key:"d0c7c84ebf5fe164868f6e2250252a0899493ee3",style:{height:"100%",maxHeight:"inherit",width:"100%",display:"flex",flexDirection:"column",position:"relative",overflow:"hidden",minHeight:"0"}},this.renderPushControl(),e&&!this.isSessionExpired&&n("div",{key:"d5147662da351b027aba0542ae3dc5af161d2aa3",class:"connection-banner connection-banner--"+this.connectionStatus},n("span",{key:"43cad2fcb7fd75d099fa8b73f482e7eb282c0957",class:"connection-banner__dot"}),e),this.useMain&&n("chatleo-chat",{key:"c3e5795f34cfa9cec09567ce6c1ef4fba3af1ed7",ref:e=>this.chatEl=e,chatStore:this.chatStore,callsAvailable:this.callsAvailable,inCall:!!this.callView,isOnline:this.chatStore?.isConnected??!1}),this.useTray&&n("chatleo-tray-component",{key:"1c11b399fedbf010e83fafccba106713771be48d",chatStore:this.chatStore,ref:e=>this.trayEl=e}),this.useRoomView&&n("chatleo-room-view",{key:"cd3e086d542ff5e93eed78e094552a19c9201c55",chatStore:this.chatStore,roomId:this.roomId,isOnline:this.chatStore?.isConnected??!1,pending:this.loading,callsAvailable:this.callsAvailable,inCall:!!this.callView}),this.callView&&n("div",{key:"579ab895faaba67e3c51841e57aa70b3d333e8ae",class:"call-layer",style:{display:this.showCall?"flex":"none"}},n("button",{key:"44f57f78e5111909d929403180aa3ec180dcf8d6",type:"button",class:"call-layer__back",onClick:()=>{this.showCall=!1}},"Chat"),n("chatleo-call-adapter",{ref:e=>this.callAdapterRef=e,callId:this.callView.callId,mode:this.callView.mode,connection:this.callView.credentials,autoJoin:!0,identity:this.identityResolver,getToken:this.callToken,promoteHandler:this.promoteInCall,demoteHandler:this.demoteInCall,style:{flex:"1",minHeight:"0"}})),this.incomingCall&&n("div",{key:"9a40dd687e2c9a717deecac05ab160919e6c91e4",class:"incoming-call",role:"dialog","aria-modal":"true","aria-label":"Incoming call from "+(this.incomingCall.caller.display_name??this.incomingCall.caller.id),tabIndex:-1,ref:e=>this.incomingRef=e},n("div",{key:"901a91dc9d594aa6c22d34bb076b294ca7f4baff",class:"incoming-call__box"},n("p",{key:"de8604f814c54ff31365c71ff017529f65ad4562",class:"incoming-call__eyebrow"},"Incoming call"),n("chatleo-avatar",{key:"edbe19c7df4faebb8c82c124998242ab3ac057b4",name:this.incomingCall.caller.display_name??this.incomingCall.caller.id,url:this.incomingCall.caller.profile_picture_url??null,isOnline:!1}),n("p",{key:"12775d0d86490918c57e22afd0d132158c8970a8",class:"incoming-call__name"},this.incomingCall.caller.display_name??this.incomingCall.caller.id),n("div",{key:"1746d49c0b8df234a095d4738d3b86f3c0dadb5d",class:"incoming-call__actions"},n("button",{key:"269ad5b6bfc735321cc55cc20e9adcd6c0239a18",type:"button",class:"incoming-call__accept",onClick:()=>{this.acceptIncomingCall()}},"Accept"),n("button",{key:"8656c479150d95ea6fb2ec93aa06bda5f2fa4359",type:"button",class:"incoming-call__decline",onClick:()=>{this.declineIncomingCall()}},"Decline")))),this.isSessionExpired&&n("div",{key:"f46db890a91aa5c5e3aef489b93765bf1702fd8c",class:"session-expired-overlay"},n("div",{key:"1581ef80235822ace8660ff35fe6f493d69df0d2",class:"session-expired-box"},n("svg",{key:"6fe3be249ebfaec0871c6323057dbd8bdc106799",class:"session-expired-icon",xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none"},n("path",{key:"82078e08d808f6e8c5671c343c95d54c9cf35118",d:"M12 9v4M12 17h.01M10.29 3.86L1.82 18a2 2 0 001.71 3h16.94a2 2 0 001.71-3L13.71 3.86a2 2 0 00-3.42 0z",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"})),n("p",{key:"3611ca9c18813f4238dacadc669533a27f99da31",class:"session-expired-title"},"Session abgelaufen"),n("p",{key:"7140324b6246ed5eb1917c694b85c8ee5c491408",class:"session-expired-message"},"Deine Sitzung ist abgelaufen. Bitte lade die Seite neu, um fortzufahren."),n("button",{key:"f11ecf3aeb0cbd64ce064e90761d5736806619b4",class:"session-expired-button",onClick:()=>window.location.reload()},"Seite neu laden"))))}static get watchers(){return{chatLeoLib:[{onChatLeoLibChange:0}],chatStore:[{onChatStoreChange:0}],ticket:[{onTicketChange:0}],calls:[{onCallsChange:0}],incomingCall:[{onIncomingCallChange:0}]}}static get style(){return":host{overflow:hidden;position:relative;height:100%;max-height:100%;min-height:0;--display:block;--bg-primary:#ffffff;--bg-secondary:#f3f4f6;--bg-light:#e7effc;--text-primary:#171a1f;--text-secondary:#9095a1;--border-color:#bdc1ca;--border-light:#eeeeee;--accent-color:#4a86e8;--accent-hover:#3a7bd8;--status-online:#21d184;--status-offline:#6b7280;--font-primary:'Manrope', sans-serif;--avatar-size:36px;--border-radius:8px;--transition-duration:0.2s;display:var(--display)}.connection-banner{display:flex;align-items:center;gap:6px;padding:5px 12px;font-family:var(--font-primary, 'Manrope', sans-serif);font-size:12px;font-weight:600;color:#fff;background:#6b7280;z-index:100;flex-shrink:0}.connection-banner--connecting,.connection-banner--reconnecting{background:#f59e0b;color:#fff}.connection-banner--disconnected{background:#ef4444;color:#fff}.connection-banner__dot{width:7px;height:7px;border-radius:50%;background:rgba(255, 255, 255, 0.8);flex-shrink:0;animation:pulse-dot 1.4s ease-in-out infinite}.connection-banner--disconnected .connection-banner__dot{animation:none}@keyframes pulse-dot{0%,100%{opacity:1}50%{opacity:0.3}}.session-expired-overlay{position:absolute;inset:0;z-index:9999;background:rgba(255, 255, 255, 0.85);backdrop-filter:blur(4px);display:flex;align-items:center;justify-content:center}.session-expired-box{background:var(--bg-primary, #fff);border:1px solid var(--border-color, #bdc1ca);border-radius:var(--border-radius, 8px);box-shadow:0 4px 24px rgba(0, 0, 0, 0.12);padding:32px 28px;max-width:340px;width:100%;text-align:center;display:flex;flex-direction:column;align-items:center;gap:12px}.session-expired-icon{color:#f59e0b;width:32px;height:32px}.session-expired-title{margin:0;font-family:var(--font-primary, 'Manrope', sans-serif);font-size:16px;font-weight:700;color:var(--text-primary, #171a1f)}.session-expired-message{margin:0;font-family:var(--font-primary, 'Manrope', sans-serif);font-size:13px;color:var(--text-secondary, #9095a1);line-height:1.6}.session-expired-button{margin-top:4px;padding:8px 20px;background:var(--accent-color, #4a86e8);color:#fff;border:none;border-radius:var(--border-radius, 8px);font-family:var(--font-primary, 'Manrope', sans-serif);font-size:14px;font-weight:600;cursor:pointer;transition:background var(--transition-duration, 0.2s)}.session-expired-button:hover{background:var(--accent-hover, #3a7bd8)}.call-layer{position:absolute;inset:0;z-index:40;background:var(--bg-primary, #fff);flex-direction:column}.call-layer__back{align-self:flex-end;margin:8px 16px 0;border:1px solid var(--border-color, #ddd);background:transparent;border-radius:6px;padding:4px 10px;font:inherit;cursor:pointer}.incoming-call{position:absolute;inset:0;z-index:50;display:flex;align-items:center;justify-content:center;background:rgba(15, 23, 42, 0.45)}.incoming-call:focus{outline:none}.incoming-call__box{width:min(320px, calc(100% - 32px));background:var(--bg-primary, #fff);border-radius:12px;padding:24px;text-align:center;box-shadow:0 18px 50px rgba(15, 23, 42, 0.25)}.incoming-call__eyebrow{margin:0 0 12px;font-size:12px;letter-spacing:0.08em;text-transform:uppercase;color:var(--text-secondary, #667)}.incoming-call__name{margin:12px 0 20px;font-size:18px;font-weight:700}.incoming-call__actions{display:flex;gap:10px;justify-content:center}.incoming-call__accept,.incoming-call__decline{border-radius:8px;padding:8px 18px;font:inherit;cursor:pointer}.incoming-call__accept{border:none;background:#1b8a3a;color:#fff}.incoming-call__decline{border:1px solid var(--border-color, #ddd);background:transparent;color:inherit}.push-control{display:flex;align-items:center;gap:8px;padding:6px 12px;border:0;border-bottom:1px solid var(--border-light, #eee);background:var(--bg-secondary, #f7f8fa);color:var(--text-primary, #222);font:inherit;font-size:12px;text-align:left;cursor:pointer}.push-control--hint{cursor:default;color:var(--text-secondary, #667)}.push-control--prompt{flex-wrap:wrap}.push-control--prompt button{border:1px solid var(--accent-color, #4a86e8);border-radius:6px;background:transparent;color:var(--accent-color, #4a86e8);padding:3px 10px;font:inherit;cursor:pointer}.push-control__secondary{border-color:var(--border-color, #ddd) !important;color:var(--text-secondary, #667) !important}"}},[513,"chatleo-component",{username:[1],ticket:[1],useTray:[4,"use-tray"],useMain:[4,"use-main"],useRoomView:[4,"use-room-view"],roomId:[1,"room-id"],chatLeoLib:[16],chatStore:[16],serverUrl:[1,"server-url"],transport:[1],calls:[1],push:[1],pushSwPath:[1,"push-sw-path"],isLoggedIn:[32],loading:[32],isSessionExpired:[32],connectionStatus:[32],callsAvailable:[32],incomingCall:[32],callView:[32],showCall:[32],pushState:[32],pushPromptDismissed:[32],getConnectionStatus:[64],openRoom:[64],closeRoom:[64],getActiveRoomId:[64],getDraft:[64],setDraft:[64],addFiles:[64],focusComposer:[64],openDirectMessageWithUser:[64],openNewChatDraft:[64]},[[0,"callError","onCallError"],[0,"callLeft","onCallLeft"],[0,"callRequested","onCallRequested"],[0,"newChatClicked","onNewChatClicked"],[0,"messageChatSent","onChatMessage"],[0,"userSelected","onUserSelectedForChat"]],{chatLeoLib:[{onChatLeoLibChange:0}],chatStore:[{onChatStoreChange:0}],ticket:[{onTicketChange:0}],calls:[{onCallsChange:0}],incomingCall:[{onIncomingCallChange:0}]}]);function y(){"undefined"!=typeof customElements&&["chatleo-component","chatleo-avatar","chatleo-chat","chatleo-chat-header","chatleo-chat-message","chatleo-new-message-selector","chatleo-rich-input","chatleo-rich-message-renderer","chatleo-room-list","chatleo-room-tile-component","chatleo-room-view","chatleo-tray-component","chatleo-user-tile"].forEach((t=>{switch(t){case"chatleo-component":customElements.get(e(t))||customElements.define(e(t),b);break;case"chatleo-avatar":customElements.get(e(t))||i();break;case"chatleo-chat":customElements.get(e(t))||s();break;case"chatleo-chat-header":customElements.get(e(t))||c();break;case"chatleo-chat-message":customElements.get(e(t))||r();break;case"chatleo-new-message-selector":customElements.get(e(t))||l();break;case"chatleo-rich-input":customElements.get(e(t))||h();break;case"chatleo-rich-message-renderer":customElements.get(e(t))||d();break;case"chatleo-room-list":customElements.get(e(t))||p();break;case"chatleo-room-tile-component":customElements.get(e(t))||f();break;case"chatleo-room-view":customElements.get(e(t))||m();break;case"chatleo-tray-component":customElements.get(e(t))||u();break;case"chatleo-user-tile":customElements.get(e(t))||g()}}))}y();const C=b,w=y;export{C as ChatleoComponent,w as defineCustomElement}
@@ -1 +1 @@
1
- import{C as o,d as s}from"./p-CfayCm9O.js";const a=o,m=s;export{a as ChatleoTrayComponent,m as defineCustomElement}
1
+ import{C as o,d as s}from"./p-XuNqYCqC.js";const p=o,r=s;export{p as ChatleoTrayComponent,r as defineCustomElement}
@@ -0,0 +1 @@
1
+ import{t as e,p as t,H as a,c as s,h as o}from"./p-C-v19aUJ.js";import{g as n}from"./index.js";import{d as i}from"./p-Exj_2-yI.js";import{d as r}from"./p-B7cdqAgv.js";import{d as c}from"./p-XlwGxsqT.js";import{d}from"./p-BdiOcOYZ.js";import{d as h}from"./p-C1mF0s8g.js";import{d as l}from"./p-CRtBdzP3.js";import{d as p}from"./p-fjMaTJam.js";import{d as b}from"./p-xt4kzz3B.js";const f=t(class extends a{constructor(e){super(),!1!==e&&this.__registerHost(),this.__attachShadow(),this.newChatClicked=s(this,"newChatClicked"),this.messageChatSent=s(this,"messageChatSent")}chatStore;isChatOpen=!1;isNewChatSelectorOpen=!1;isMessagesOpen=!1;selectedRoomId;isPending=!1;_version=0;isSessionExpired=!1;connectionStatus="disconnected";messagesContainerRef;lastMessageCount=-1;boundOnPresenceChange=()=>this.onPresenceChange();boundOnRoomMessageAdded=e=>this.onRoomMessageAdded(e);boundOnSessionExpiredChanged=e=>this.onSessionExpiredChanged(e);boundOnConnectionStatusChanged=e=>this.onConnectionStatusChanged(e);boundOnRoomReadCountChanged=()=>{this._version++};onChatStoreChange(e,t){t&&(t.removeEventListener("presenceChanged",this.boundOnPresenceChange),t.removeEventListener("roomMessageAdded",this.boundOnRoomMessageAdded),t.removeEventListener("sessionExpiredChanged",this.boundOnSessionExpiredChanged),t.removeEventListener("connectionStatusChanged",this.boundOnConnectionStatusChanged),t.removeEventListener("roomReadCountChanged",this.boundOnRoomReadCountChanged)),e&&(e.addEventListener("presenceChanged",this.boundOnPresenceChange),e.addEventListener("roomMessageAdded",this.boundOnRoomMessageAdded),e.addEventListener("sessionExpiredChanged",this.boundOnSessionExpiredChanged),e.addEventListener("connectionStatusChanged",this.boundOnConnectionStatusChanged),this.isSessionExpired=e.isSessionExpired,this.connectionStatus=e.connectionStatus,e.addEventListener("roomReadCountChanged",this.boundOnRoomReadCountChanged))}onSelectedRoomIdChanged(){this.lastMessageCount=-1,this._version++,this.chatStore?.setActiveRoomId(this.selectedRoomId??null)}onPresenceChange(){console.debug("onPresenceChange"),this._version++}onRoomMessageAdded(e){console.debug("onRoomMessageAdded",e),this._version++,this.isMessagesOpen&&e.detail?.roomId===this.selectedRoomId&&this.chatStore?.markRoomAsRead(this.selectedRoomId)}onSessionExpiredChanged(e){this.isSessionExpired=e.detail.isSessionExpired,this.isSessionExpired&&(this.isChatOpen=!0)}onConnectionStatusChanged(e){this.connectionStatus=e.detail.status}toggleChat=()=>{this.isChatOpen=!this.isChatOpen,this._version++};newChatClicked;onNewChatClicked(){this.isNewChatSelectorOpen?this.isNewChatSelectorOpen=!1:(this.isNewChatSelectorOpen=!0,this.isMessagesOpen=!1,this.newChatClicked.emit())}onUserSelected=()=>{this.isNewChatSelectorOpen=!1};onSelectorClose=()=>{this.isNewChatSelectorOpen=!1};roomClickedHandler(e){console.log("Received the roomClicked event: ",e.detail),this.isNewChatSelectorOpen=!1,this.isMessagesOpen=!0,this.selectedRoomId=e.detail.id,this.chatStore?.markRoomAsRead(e.detail.id)}messageChatSent;messageSendHandler(e){console.log("Received the messageSend event: ",JSON.stringify(e.detail));const t=(e.detail?.blocks??[]).map((e=>{if("attachment"===e?.type&&Array.isArray(e.attachments)){const t=e.attachments.map((e=>{const{preview:t,...a}=e??{};return a}));return{...e,attachments:t}}return e}));this.messageChatSent.emit({room_id:this.selectedRoomId,content:{blocks:t,version:e.detail.version},content_type:"application/json+blocks",sender:this.chatStore?.profile?.id})}async openChatPanel(e,t=!1){console.debug(`openChatPanel ${e} ${t}`),this.selectedRoomId=e,this.isPending=t,this.isChatOpen=!1,this.isMessagesOpen=!0,e&&this.chatStore?.markRoomAsRead(e),this._version++}onDoClose(e){e.preventDefault(),this.isMessagesOpen=!1}scrollToBottom(){if(this.messagesContainerRef)try{this.messagesContainerRef.scrollTop=this.messagesContainerRef.scrollHeight}catch(e){}}scrollToBottomNextTick(){requestAnimationFrame((()=>{this.scrollToBottom()}))}componentDidRender(){if(!this.isMessagesOpen||!this.selectedRoomId)return;const e=(this.chatStore?.roomMessages(this.selectedRoomId)??[]).length;e!==this.lastMessageCount&&(this.scrollToBottomNextTick(),this.lastMessageCount=e)}render(){const e=n(this.chatStore?.roomMessages(this.selectedRoomId)??[]);return o("div",{key:"16d13ecf2c8d78c822b66ee140fdf3aedb03d1fa",class:"tray-container"},o("div",{key:"2087230f83fa231255a127bcf25935c96bb5a89d",class:this.isNewChatSelectorOpen?"selector-panel open":"selector-panel"},o("chatleo-new-message-selector",{key:"346f747952e4c2d3872db97adfd9fab7434526cf",chatStore:this.chatStore,onUserSelected:this.onUserSelected,onDoClose:this.onSelectorClose})),o("div",{key:"245326a45ffdea0c3c8a8507a449391635576c95",class:this.isMessagesOpen?"messages-panel open":"messages-panel"},o("div",{key:"b5b82048cbee06bdb73967c2ff342d4bad66a89a",class:"messages-container-header-closer"},o("button",{key:"0196b861999831d834df3407cc5c350fba9338f9",class:"close-button",onClick:this.onDoClose.bind(this)},o("svg",{key:"1db85ebbbb9291ecd8674d25a063bcbe215bd6d0",width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg"},o("path",{key:"d5f23bc40608fac8577860d6ff03e0e5c47e26cf",d:"M12 4L4 12",stroke:"#565D6D","stroke-width":"1.37143","stroke-miterlimit":"10","stroke-linecap":"square"}),o("path",{key:"6f27dd8b4a9969dd19bdae6059cad74d5e466d6f",d:"M12 12L4 4",stroke:"#565D6D","stroke-width":"1.37143","stroke-miterlimit":"10","stroke-linecap":"square"})))),o("chatleo-chat-header",{key:"d4320c822ed8ed5e4472c91a8c03508137bb3985",name:this.chatStore?.profile?.display_name,avatar:this.chatStore?.profile?.profile_picture_url??"https://placehold.co/48x48?text=AV",isOnline:this.chatStore?.isConnected}),o("div",{key:"ffb54f65c17f3ecf51f661aaa2cd1777d57e2468",class:"messages-container",ref:e=>this.messagesContainerRef=e},Object.entries(e).sort((([e],[t])=>new Date(e).getTime()-new Date(t).getTime())).map((([e,t])=>o("div",{class:"message-group"},o("div",{class:"date-separator"},e),t.map((e=>o("chatleo-chat-message",{message:e,sender:this.chatStore?.usernameResolver(e.sender_id),isOwnMessage:e.sender_id===this.chatStore?.profile.id,translations:{you:this.chatStore?.usernameResolver(e.sender_id)?.display_name}}))))))),o("chatleo-rich-input",{key:"5db7ffd32df847bbe103659d4f8ededfcc3105b2",disabled:!this.selectedRoomId,placeholder:"Nachricht schreiben"})),o("div",{key:"a4374b9f51b6f4f528ca0099df022272d41e8062",id:"chats",class:this.isChatOpen?"chat-panel open":"chat-panel"},this.isSessionExpired&&o("div",{key:"77f04c709823b47590588651b78531fa23d84254",class:"session-expired-banner"},o("svg",{key:"7a9e8a3baba8576df14229384f67c4e771e4280e",class:"session-expired-banner-icon",xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none"},o("path",{key:"bededb8359f4374f131f914124f89cae938c63f2",d:"M12 9v4M12 17h.01M10.29 3.86L1.82 18a2 2 0 001.71 3h16.94a2 2 0 001.71-3L13.71 3.86a2 2 0 00-3.42 0z",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"})),o("span",{key:"49ede701a42a2c16954859e5c0443c6c94168376"},"Session abgelaufen –"),o("button",{key:"1533de4c91c3e496e82781e03e34d8df9cd92bf7",class:"session-expired-banner-btn",onClick:()=>window.location.reload()},"Seite neu laden")),!this.isSessionExpired&&("connecting"===this.connectionStatus||"reconnecting"===this.connectionStatus||"disconnected"===this.connectionStatus)&&o("div",{key:"5f11759ba32e228f990b2866d09e2d25c647315c",class:`connection-status-banner connection-status-banner--${this.connectionStatus}`},o("span",{key:"55ad4bf597fcf0ee3a1e180ebfac85a8c271da16",class:"connection-status-banner__dot"}),"connecting"===this.connectionStatus?"Verbindung wird hergestellt…":"reconnecting"===this.connectionStatus?"Verbindung wird wiederhergestellt…":"Offline"),o("div",{key:"c8adfe1c61695332bef014492c7abe3d641160b0",class:"tray"},o("chatleo-avatar",{key:"8ee785cd081f4509aa8a68c1fa8ec3584e729c5a",name:this.chatStore?.profile?.display_name??"",url:this.chatStore?.profile?.profile_picture_url,isOnline:this.chatStore?.isConnected??!1}),o("div",{key:"e52ee5d7ca448912dd98913f1ba5cc1126212207",class:"title"},"Nachrichten"),o("button",{key:"ab06ce2f106a288b350342e2b0d9494452d1eda7",class:"new-chat-btn",onClick:()=>this.onNewChatClicked()},o("svg",{key:"1c6c9a6c1a8b76cc7e0144568e40779421ee71cc",xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 16 16",fill:"none"},o("path",{key:"d449d4cce2e6f07f44708f0eaf374f95b1642267",d:"M10.497 2.43838L12.7094 4.62657M12.9439 1.6838L13.4519 2.19178C13.9192 2.6591 13.9192 3.41677 13.4519 3.8841L6.72919 10.6068C6.59783 10.7381 6.43768 10.8371 6.26144 10.8958L3.79663 11.7174C3.56275 11.7954 3.34026 11.5729 3.41821 11.339L4.23982 8.87421C4.29857 8.69797 4.39754 8.53783 4.5289 8.40647L11.2516 1.6838C11.7189 1.21648 12.4766 1.21648 12.9439 1.6838Z",stroke:"#565D6D","stroke-width":"1.5","stroke-linecap":"round","stroke-linejoin":"round"}),o("path",{key:"6a19c104fcf6457c2cf9b24bdbf89df1045bdc0b",d:"M8 2.13312H7.2H1.8C1.35817 2.13312 1 2.49129 1 2.93312V13.7331C1 14.1749 1.35817 14.5331 1.8 14.5331H12.6C13.0418 14.5331 13.4 14.1749 13.4 13.7331V8.33312V6.99998",stroke:"#565D6D","stroke-width":"1.5","stroke-linecap":"round"}))),o("button",{key:"e235b7fe2a990954fd4ba18838a7bcf60ef5cd3f",class:"chat-tray-btn",onClick:this.toggleChat},o("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 16 16",fill:"none"},o("path",this.isChatOpen?{d:"M3.07273 4.66669L2 5.73941L8 11.7394L14 5.73941L12.9273 4.66669L8 9.59393L3.07273 4.66669Z",fill:"#565D6D"}:{d:"M12.9273 11.7393L14 10.6665L8 4.66655L2 10.6665L3.07273 11.7393L8 6.81202L12.9273 11.7393Z",fill:"#565D6D"})))),o("div",{key:"49495cb8b42d1e730be1c2c5d5594511b93016e6",class:"chat-content"},o("ul",{key:"4fd54a4d2c5b42d2fc37e1257e9fdc6b87be4532"},this.chatStore?.rooms.map((e=>{const t=e.participantIdsWithoutSelf?.filter((e=>this.chatStore.isOnline(e)))??[];return o("li",null,o("chatleo-room-tile-component",{chatStore:this.chatStore,room:e,onlineUserIds:t,lastMessage:void 0,timestamp:void 0,unreadCount:e.unreadCount}))}))))))}static get watchers(){return{chatStore:[{onChatStoreChange:0}],selectedRoomId:[{onSelectedRoomIdChanged:0}]}}static get style(){return":host{--hover-color:#f9f9f9;--shadow-light:rgba(0, 0, 0, 0.1);--z-index-tray:1000;--tray-height:52px;--gap-small:12px;--gap-medium:16px;--transition-duration:0.3s;--gray-black:#171A1F;--chat-panel-width:280px;--selector-panel-width:320px;--messages-panel-width:50vw}.tray-container{position:fixed;bottom:0;right:20px;z-index:var(--z-index-tray);display:flex;flex-direction:row;align-items:flex-end;gap:var(--gap-small);font-family:var(--font-primary), sans-serif}.chat-panel{width:var(--chat-panel-width);flex:0 0 var(--chat-panel-width);box-sizing:border-box;position:relative;background:var(--bg-primary);border:1px solid var(--border-color);border-radius:var(--border-radius) var(--border-radius) 0 0;box-shadow:0 -2px 10px var(--shadow-light);overflow:hidden;max-height:var(--tray-height);transition:max-height var(--transition-duration) ease-in-out}.chat-panel.open{max-height:calc(50vh + var(--tray-height));}.tray{display:flex;flex-direction:row;align-items:center;background:var(--bg-primary);border-bottom:1px solid var(--border-light);height:var(--tray-height);box-sizing:border-box;width:100%;padding:0 8px;margin:0;}chatleo-avatar{--avatar-size:36px}.title{margin:0 8px;flex:1 1 auto;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;color:var(--gray-black, #171A1F);font-size:14px}.selector-panel{display:none;background:var(--bg-primary);border:1px solid var(--border-color);border-radius:var(--border-radius) var(--border-radius) 0 0;box-shadow:0 -2px 10px var(--shadow-light);box-sizing:border-box;width:var(--selector-panel-width);flex:0 0 var(--selector-panel-width);overflow:hidden;max-height:var(--tray-height);}.selector-panel.open{display:flex;flex-direction:column;max-height:calc(50vh + var(--tray-height))}.messages-panel{display:none;background:var(--bg-primary);border:1px solid var(--border-color);border-radius:var(--border-radius) var(--border-radius) 0 0;box-shadow:0 -2px 10px var(--shadow-light);box-sizing:border-box;width:var(--messages-panel-width);overflow:hidden;position:relative;max-height:70vh;flex-direction:column}.messages-panel.open{display:flex}.new-chat-btn{border:0;background:transparent;cursor:pointer;padding:0;margin:0 8px;flex:0 0 auto;color:#565D6D}.chat-tray-btn{border:0;background:transparent;cursor:pointer;padding:0;margin:0 8px;flex:0 0 auto;color:#565D6D}.chat-content{overflow:hidden}.chat-content ul{margin:0;padding:0;list-style:none;overflow-y:auto;max-height:calc(50vh - var(--tray-height));}.chat-content li{padding:16px;cursor:pointer}.chat-content li:hover{background:var(--hover-color)}@media (max-width: 768px){.chat-panel.open,.selector-panel.open{max-height:calc(80vh + 60px)}.chat-content ul{max-height:calc(80vh - 60px)}}.messages-container-header-closer{position:absolute;top:4px;right:4px}.messages-container{display:block;flex:1 1 auto;min-height:0;overflow-y:auto;overflow-x:hidden;padding-right:16px;overscroll-behavior:contain;scrollbar-gutter:stable;max-width:100%}.message-group{display:flex;flex-direction:column;gap:16px}.date-separator{text-align:center;font-family:var(--font-primary), sans-serif;font-weight:400;font-size:12px;line-height:1.65;color:var(--text-secondary)}.close-button{background:none;border:none;cursor:pointer;font-size:16px;color:var(--text-secondary)}.connection-status-banner{display:flex;align-items:center;gap:6px;padding:5px 12px;font-family:var(--font-primary), sans-serif;font-size:12px;font-weight:600;color:#fff;background:#f59e0b}.connection-status-banner--disconnected{background:#ef4444}.connection-status-banner__dot{width:6px;height:6px;border-radius:50%;background:rgba(255,255,255,0.8);flex-shrink:0;animation:tray-pulse-dot 1.4s ease-in-out infinite}.connection-status-banner--disconnected .connection-status-banner__dot{animation:none}@keyframes tray-pulse-dot{0%,100%{opacity:1}50%{opacity:0.3}}.session-expired-banner{display:flex;align-items:center;gap:6px;background:#fff8e1;border-bottom:1px solid #ffe082;padding:6px 12px;font-family:var(--font-primary), sans-serif;font-size:12px;color:#795548}.session-expired-banner-icon{flex-shrink:0;color:#f59e0b}.session-expired-banner-btn{margin-left:auto;padding:3px 10px;background:#f59e0b;color:#fff;border:none;border-radius:4px;font-family:var(--font-primary), sans-serif;font-size:12px;font-weight:600;cursor:pointer;white-space:nowrap}.session-expired-banner-btn:hover{background:#d97706}"}},[513,"chatleo-tray-component",{chatStore:[16],isChatOpen:[32],isNewChatSelectorOpen:[32],isMessagesOpen:[32],selectedRoomId:[32],isPending:[32],_version:[32],isSessionExpired:[32],connectionStatus:[32],openChatPanel:[64]},[[0,"roomClicked","roomClickedHandler"],[0,"messageSend","messageSendHandler"]],{chatStore:[{onChatStoreChange:0}],selectedRoomId:[{onSelectedRoomIdChanged:0}]}]);function g(){"undefined"!=typeof customElements&&["chatleo-tray-component","chatleo-avatar","chatleo-chat-header","chatleo-chat-message","chatleo-new-message-selector","chatleo-rich-input","chatleo-rich-message-renderer","chatleo-room-tile-component","chatleo-user-tile"].forEach((t=>{switch(t){case"chatleo-tray-component":customElements.get(e(t))||customElements.define(e(t),f);break;case"chatleo-avatar":customElements.get(e(t))||i();break;case"chatleo-chat-header":customElements.get(e(t))||r();break;case"chatleo-chat-message":customElements.get(e(t))||c();break;case"chatleo-new-message-selector":customElements.get(e(t))||d();break;case"chatleo-rich-input":customElements.get(e(t))||h();break;case"chatleo-rich-message-renderer":customElements.get(e(t))||l();break;case"chatleo-room-tile-component":customElements.get(e(t))||p();break;case"chatleo-user-tile":customElements.get(e(t))||b()}}))}g();export{f as C,g as d}
@@ -1076,7 +1076,7 @@ const ChatLeoComponent = class {
1076
1076
  }
1077
1077
  render() {
1078
1078
  const bannerLabel = this._connectionBannerLabel;
1079
- return (h("div", { key: 'd0c7c84ebf5fe164868f6e2250252a0899493ee3', style: { height: '100%', maxHeight: 'inherit', width: '100%', display: 'flex', flexDirection: 'column', position: 'relative', overflow: 'hidden', minHeight: '0' } }, this.renderPushControl(), bannerLabel && !this.isSessionExpired && (h("div", { key: 'd5147662da351b027aba0542ae3dc5af161d2aa3', class: `connection-banner connection-banner--${this.connectionStatus}` }, h("span", { key: '43cad2fcb7fd75d099fa8b73f482e7eb282c0957', class: "connection-banner__dot" }), bannerLabel)), this.useMain && h("chatleo-chat", { key: '609457ee0ab1ceaa2484d91d4c54d734770f4d01', ref: el => (this.chatEl = el), chatStore: this.chatStore, callsAvailable: this.callsAvailable, inCall: !!this.callView }), this.useTray && h("chatleo-tray-component", { key: 'ebd656fd966561d4f982859b9c36a1e233b204b6', chatStore: this.chatStore, ref: el => (this.trayEl = el) }), this.useRoomView && (h("chatleo-room-view", { key: '6af1a89788728c21f72ee1a31b7e70bd7d096f0f', chatStore: this.chatStore, roomId: this.roomId, isOnline: this.chatStore?.isConnected ?? false, pending: this.loading, callsAvailable: this.callsAvailable, inCall: !!this.callView })), this.callView && (h("div", { key: '3a346cdaf24c1fe758f86e1233cc4626db023a32', class: "call-layer", style: { display: this.showCall ? 'flex' : 'none' } }, h("button", { key: '7720dc641239eb8da833c63c1f30d4ed29fece7c', type: "button", class: "call-layer__back", onClick: () => {
1079
+ return (h("div", { key: 'd0c7c84ebf5fe164868f6e2250252a0899493ee3', style: { height: '100%', maxHeight: 'inherit', width: '100%', display: 'flex', flexDirection: 'column', position: 'relative', overflow: 'hidden', minHeight: '0' } }, this.renderPushControl(), bannerLabel && !this.isSessionExpired && (h("div", { key: 'd5147662da351b027aba0542ae3dc5af161d2aa3', class: `connection-banner connection-banner--${this.connectionStatus}` }, h("span", { key: '43cad2fcb7fd75d099fa8b73f482e7eb282c0957', class: "connection-banner__dot" }), bannerLabel)), this.useMain && h("chatleo-chat", { key: 'c3e5795f34cfa9cec09567ce6c1ef4fba3af1ed7', ref: el => (this.chatEl = el), chatStore: this.chatStore, callsAvailable: this.callsAvailable, inCall: !!this.callView, isOnline: this.chatStore?.isConnected ?? false }), this.useTray && h("chatleo-tray-component", { key: '1c11b399fedbf010e83fafccba106713771be48d', chatStore: this.chatStore, ref: el => (this.trayEl = el) }), this.useRoomView && (h("chatleo-room-view", { key: 'cd3e086d542ff5e93eed78e094552a19c9201c55', chatStore: this.chatStore, roomId: this.roomId, isOnline: this.chatStore?.isConnected ?? false, pending: this.loading, callsAvailable: this.callsAvailable, inCall: !!this.callView })), this.callView && (h("div", { key: '579ab895faaba67e3c51841e57aa70b3d333e8ae', class: "call-layer", style: { display: this.showCall ? 'flex' : 'none' } }, h("button", { key: '44f57f78e5111909d929403180aa3ec180dcf8d6', type: "button", class: "call-layer__back", onClick: () => {
1080
1080
  this.showCall = false;
1081
1081
  } }, "Chat"), h('chatleo-call-adapter', {
1082
1082
  ref: (el) => (this.callAdapterRef = el),
@@ -1089,7 +1089,7 @@ const ChatLeoComponent = class {
1089
1089
  promoteHandler: this.promoteInCall,
1090
1090
  demoteHandler: this.demoteInCall,
1091
1091
  style: { flex: '1', minHeight: '0' },
1092
- }))), this.incomingCall && (h("div", { key: 'ebdc317f30b07009f41f7f729b9e8631ea039752', class: "incoming-call", role: "dialog", "aria-modal": "true", "aria-label": `Incoming call from ${this.incomingCall.caller.display_name ?? this.incomingCall.caller.id}`, tabIndex: -1, ref: el => (this.incomingRef = el) }, h("div", { key: '4eac45f10551a47c7bf1ad8035a9da5ed2955e29', class: "incoming-call__box" }, h("p", { key: '6f74dee9aa261dc889b70c18e5b110e18b1a2111', class: "incoming-call__eyebrow" }, "Incoming call"), h("chatleo-avatar", { key: 'e097d46809d6202d64ebc1eaf42418b74c990e80', name: this.incomingCall.caller.display_name ?? this.incomingCall.caller.id, url: this.incomingCall.caller.profile_picture_url ?? null, isOnline: false }), h("p", { key: 'b160c0021f003d230d5fb544d82fd8d23f7df332', class: "incoming-call__name" }, this.incomingCall.caller.display_name ?? this.incomingCall.caller.id), h("div", { key: 'b238c1352384a0f14a2abd130fe0f3495da156f3', class: "incoming-call__actions" }, h("button", { key: '1b44cc1c87dfb89b4715fb370c490a05d97b6512', type: "button", class: "incoming-call__accept", onClick: () => void this.acceptIncomingCall() }, "Accept"), h("button", { key: '97276ec614d0be526f16573a3d0e9f6cb9e24b7c', type: "button", class: "incoming-call__decline", onClick: () => void this.declineIncomingCall() }, "Decline"))))), this.isSessionExpired && (h("div", { key: 'b387b49bc31378c63c6520a95bf732c47a142e88', class: "session-expired-overlay" }, h("div", { key: '118687b87cc612d9ad47692a3e8f2a38f3b71f32', class: "session-expired-box" }, h("svg", { key: '562cf50bb4f6cdd0e4076267c6dea5f8b76b06d7', class: "session-expired-icon", xmlns: "http://www.w3.org/2000/svg", width: "24", height: "24", viewBox: "0 0 24 24", fill: "none" }, h("path", { key: '628579c8dad4064d6fcfdfd75801160fe8f0ef8f', d: "M12 9v4M12 17h.01M10.29 3.86L1.82 18a2 2 0 001.71 3h16.94a2 2 0 001.71-3L13.71 3.86a2 2 0 00-3.42 0z", stroke: "currentColor", "stroke-width": "2", "stroke-linecap": "round", "stroke-linejoin": "round" })), h("p", { key: 'e49e2388dad8df0e961cb7e0dc605a4011775eed', class: "session-expired-title" }, "Session abgelaufen"), h("p", { key: '0b69cf4687411c7e9f117712b28da57bc798ce07', class: "session-expired-message" }, "Deine Sitzung ist abgelaufen. Bitte lade die Seite neu, um fortzufahren."), h("button", { key: '9532b50dccc9f05dc3ee4a5ea2b28eea462a0ed1', class: "session-expired-button", onClick: () => window.location.reload() }, "Seite neu laden"))))));
1092
+ }))), this.incomingCall && (h("div", { key: '9a40dd687e2c9a717deecac05ab160919e6c91e4', class: "incoming-call", role: "dialog", "aria-modal": "true", "aria-label": `Incoming call from ${this.incomingCall.caller.display_name ?? this.incomingCall.caller.id}`, tabIndex: -1, ref: el => (this.incomingRef = el) }, h("div", { key: '901a91dc9d594aa6c22d34bb076b294ca7f4baff', class: "incoming-call__box" }, h("p", { key: 'de8604f814c54ff31365c71ff017529f65ad4562', class: "incoming-call__eyebrow" }, "Incoming call"), h("chatleo-avatar", { key: 'edbe19c7df4faebb8c82c124998242ab3ac057b4', name: this.incomingCall.caller.display_name ?? this.incomingCall.caller.id, url: this.incomingCall.caller.profile_picture_url ?? null, isOnline: false }), h("p", { key: '12775d0d86490918c57e22afd0d132158c8970a8', class: "incoming-call__name" }, this.incomingCall.caller.display_name ?? this.incomingCall.caller.id), h("div", { key: '1746d49c0b8df234a095d4738d3b86f3c0dadb5d', class: "incoming-call__actions" }, h("button", { key: '269ad5b6bfc735321cc55cc20e9adcd6c0239a18', type: "button", class: "incoming-call__accept", onClick: () => void this.acceptIncomingCall() }, "Accept"), h("button", { key: '8656c479150d95ea6fb2ec93aa06bda5f2fa4359', type: "button", class: "incoming-call__decline", onClick: () => void this.declineIncomingCall() }, "Decline"))))), this.isSessionExpired && (h("div", { key: 'f46db890a91aa5c5e3aef489b93765bf1702fd8c', class: "session-expired-overlay" }, h("div", { key: '1581ef80235822ace8660ff35fe6f493d69df0d2', class: "session-expired-box" }, h("svg", { key: '6fe3be249ebfaec0871c6323057dbd8bdc106799', class: "session-expired-icon", xmlns: "http://www.w3.org/2000/svg", width: "24", height: "24", viewBox: "0 0 24 24", fill: "none" }, h("path", { key: '82078e08d808f6e8c5671c343c95d54c9cf35118', d: "M12 9v4M12 17h.01M10.29 3.86L1.82 18a2 2 0 001.71 3h16.94a2 2 0 001.71-3L13.71 3.86a2 2 0 00-3.42 0z", stroke: "currentColor", "stroke-width": "2", "stroke-linecap": "round", "stroke-linejoin": "round" })), h("p", { key: '3611ca9c18813f4238dacadc669533a27f99da31', class: "session-expired-title" }, "Session abgelaufen"), h("p", { key: '7140324b6246ed5eb1917c694b85c8ee5c491408', class: "session-expired-message" }, "Deine Sitzung ist abgelaufen. Bitte lade die Seite neu, um fortzufahren."), h("button", { key: 'f11ecf3aeb0cbd64ce064e90761d5736806619b4', class: "session-expired-button", onClick: () => window.location.reload() }, "Seite neu laden"))))));
1093
1093
  }
1094
1094
  static get watchers() { return {
1095
1095
  "chatLeoLib": [{
@@ -2910,7 +2910,7 @@ const ChatLeoTrayComponent = class {
2910
2910
  .sort(([dateA], [dateB]) => new Date(dateA).getTime() - new Date(dateB).getTime())
2911
2911
  .map(([date, messages]) => (h("div", { class: "message-group" }, h("div", { class: "date-separator" }, date), messages.map(message => (h("chatleo-chat-message", { message: message, sender: this.chatStore?.usernameResolver(message.sender_id), isOwnMessage: message.sender_id === this.chatStore?.profile.id, translations: { 'you': this.chatStore?.usernameResolver(message.sender_id)?.display_name } }))))))), h("chatleo-rich-input", { key: '5db7ffd32df847bbe103659d4f8ededfcc3105b2', disabled: !!!this.selectedRoomId, placeholder: "Nachricht schreiben" })), h("div", { key: 'a4374b9f51b6f4f528ca0099df022272d41e8062', id: "chats", class: this.isChatOpen ? 'chat-panel open' : 'chat-panel' }, this.isSessionExpired && (h("div", { key: '77f04c709823b47590588651b78531fa23d84254', class: "session-expired-banner" }, h("svg", { key: '7a9e8a3baba8576df14229384f67c4e771e4280e', class: "session-expired-banner-icon", xmlns: "http://www.w3.org/2000/svg", width: "16", height: "16", viewBox: "0 0 24 24", fill: "none" }, h("path", { key: 'bededb8359f4374f131f914124f89cae938c63f2', d: "M12 9v4M12 17h.01M10.29 3.86L1.82 18a2 2 0 001.71 3h16.94a2 2 0 001.71-3L13.71 3.86a2 2 0 00-3.42 0z", stroke: "currentColor", "stroke-width": "2", "stroke-linecap": "round", "stroke-linejoin": "round" })), h("span", { key: '49ede701a42a2c16954859e5c0443c6c94168376' }, "Session abgelaufen \u2013"), h("button", { key: '1533de4c91c3e496e82781e03e34d8df9cd92bf7', class: "session-expired-banner-btn", onClick: () => window.location.reload() }, "Seite neu laden"))), !this.isSessionExpired && (this.connectionStatus === 'connecting' || this.connectionStatus === 'reconnecting' || this.connectionStatus === 'disconnected') && (h("div", { key: '5f11759ba32e228f990b2866d09e2d25c647315c', class: `connection-status-banner connection-status-banner--${this.connectionStatus}` }, h("span", { key: '55ad4bf597fcf0ee3a1e180ebfac85a8c271da16', class: "connection-status-banner__dot" }), this.connectionStatus === 'connecting' ? 'Verbindung wird hergestellt…'
2912
2912
  : this.connectionStatus === 'reconnecting' ? 'Verbindung wird wiederhergestellt…'
2913
- : 'Offline')), h("div", { key: 'c8adfe1c61695332bef014492c7abe3d641160b0', class: "tray" }, h("chatleo-avatar", { key: 'e5ca63cb0a77c19c75ca8404a0ec92833f9881f2', name: this.chatStore?.profile?.display_name ?? "", url: this.chatStore?.profile?.profile_picture_url, isOnline: this.chatStore?.profile?.id ? (this.chatStore?.isOnline(this.chatStore.profile.id) ?? false) : false }), h("div", { key: 'a7bbd2492328f400a7e349f8296f3c1a499e171e', class: "title" }, "Nachrichten"), h("button", { key: '7c2450e2977563c59a41efc874fc9ca5c6ecbea7', class: "new-chat-btn", onClick: () => this.onNewChatClicked() }, h("svg", { key: 'a7de1919583f9264c85d2f8a0879e8f993ff848c', xmlns: "http://www.w3.org/2000/svg", width: "16", height: "16", viewBox: "0 0 16 16", fill: "none" }, h("path", { key: '63e200bbf4038f0ceb626000b53f685318cd19f8', d: "M10.497 2.43838L12.7094 4.62657M12.9439 1.6838L13.4519 2.19178C13.9192 2.6591 13.9192 3.41677 13.4519 3.8841L6.72919 10.6068C6.59783 10.7381 6.43768 10.8371 6.26144 10.8958L3.79663 11.7174C3.56275 11.7954 3.34026 11.5729 3.41821 11.339L4.23982 8.87421C4.29857 8.69797 4.39754 8.53783 4.5289 8.40647L11.2516 1.6838C11.7189 1.21648 12.4766 1.21648 12.9439 1.6838Z", stroke: "#565D6D", "stroke-width": "1.5", "stroke-linecap": "round", "stroke-linejoin": "round" }), h("path", { key: '222831ec61fc41f09ba0296731aed27050ff1b55', d: "M8 2.13312H7.2H1.8C1.35817 2.13312 1 2.49129 1 2.93312V13.7331C1 14.1749 1.35817 14.5331 1.8 14.5331H12.6C13.0418 14.5331 13.4 14.1749 13.4 13.7331V8.33312V6.99998", stroke: "#565D6D", "stroke-width": "1.5", "stroke-linecap": "round" }))), h("button", { key: '51ce8b2bc912659e7347f9eb9bfe1a1c56b23b75', class: "chat-tray-btn", onClick: this.toggleChat }, this.isChatOpen ? (h("svg", { xmlns: "http://www.w3.org/2000/svg", width: "16", height: "16", viewBox: "0 0 16 16", fill: "none" }, h("path", { d: "M3.07273 4.66669L2 5.73941L8 11.7394L14 5.73941L12.9273 4.66669L8 9.59393L3.07273 4.66669Z", fill: "#565D6D" }))) : (h("svg", { xmlns: "http://www.w3.org/2000/svg", width: "16", height: "16", viewBox: "0 0 16 16", fill: "none" }, h("path", { d: "M12.9273 11.7393L14 10.6665L8 4.66655L2 10.6665L3.07273 11.7393L8 6.81202L12.9273 11.7393Z", fill: "#565D6D" }))))), h("div", { key: '9f46873326aab72ba87cfa6b387de9c5616bb497', class: "chat-content" }, h("ul", { key: 'f1f9da34aab6ae95a9d3910de295e1dc64f31c2c' }, this.chatStore?.rooms.map(room => {
2913
+ : 'Offline')), h("div", { key: 'c8adfe1c61695332bef014492c7abe3d641160b0', class: "tray" }, h("chatleo-avatar", { key: '8ee785cd081f4509aa8a68c1fa8ec3584e729c5a', name: this.chatStore?.profile?.display_name ?? "", url: this.chatStore?.profile?.profile_picture_url, isOnline: this.chatStore?.isConnected ?? false }), h("div", { key: 'e52ee5d7ca448912dd98913f1ba5cc1126212207', class: "title" }, "Nachrichten"), h("button", { key: 'ab06ce2f106a288b350342e2b0d9494452d1eda7', class: "new-chat-btn", onClick: () => this.onNewChatClicked() }, h("svg", { key: '1c6c9a6c1a8b76cc7e0144568e40779421ee71cc', xmlns: "http://www.w3.org/2000/svg", width: "16", height: "16", viewBox: "0 0 16 16", fill: "none" }, h("path", { key: 'd449d4cce2e6f07f44708f0eaf374f95b1642267', d: "M10.497 2.43838L12.7094 4.62657M12.9439 1.6838L13.4519 2.19178C13.9192 2.6591 13.9192 3.41677 13.4519 3.8841L6.72919 10.6068C6.59783 10.7381 6.43768 10.8371 6.26144 10.8958L3.79663 11.7174C3.56275 11.7954 3.34026 11.5729 3.41821 11.339L4.23982 8.87421C4.29857 8.69797 4.39754 8.53783 4.5289 8.40647L11.2516 1.6838C11.7189 1.21648 12.4766 1.21648 12.9439 1.6838Z", stroke: "#565D6D", "stroke-width": "1.5", "stroke-linecap": "round", "stroke-linejoin": "round" }), h("path", { key: '6a19c104fcf6457c2cf9b24bdbf89df1045bdc0b', d: "M8 2.13312H7.2H1.8C1.35817 2.13312 1 2.49129 1 2.93312V13.7331C1 14.1749 1.35817 14.5331 1.8 14.5331H12.6C13.0418 14.5331 13.4 14.1749 13.4 13.7331V8.33312V6.99998", stroke: "#565D6D", "stroke-width": "1.5", "stroke-linecap": "round" }))), h("button", { key: 'e235b7fe2a990954fd4ba18838a7bcf60ef5cd3f', class: "chat-tray-btn", onClick: this.toggleChat }, this.isChatOpen ? (h("svg", { xmlns: "http://www.w3.org/2000/svg", width: "16", height: "16", viewBox: "0 0 16 16", fill: "none" }, h("path", { d: "M3.07273 4.66669L2 5.73941L8 11.7394L14 5.73941L12.9273 4.66669L8 9.59393L3.07273 4.66669Z", fill: "#565D6D" }))) : (h("svg", { xmlns: "http://www.w3.org/2000/svg", width: "16", height: "16", viewBox: "0 0 16 16", fill: "none" }, h("path", { d: "M12.9273 11.7393L14 10.6665L8 4.66655L2 10.6665L3.07273 11.7393L8 6.81202L12.9273 11.7393Z", fill: "#565D6D" }))))), h("div", { key: '49495cb8b42d1e730be1c2c5d5594511b93016e6', class: "chat-content" }, h("ul", { key: '4fd54a4d2c5b42d2fc37e1257e9fdc6b87be4532' }, this.chatStore?.rooms.map(room => {
2914
2914
  const online = room.participantIdsWithoutSelf?.filter((id) => this.chatStore.isOnline(id)) ?? [];
2915
2915
  return (h("li", null, h("chatleo-room-tile-component", { chatStore: this.chatStore, room: room, onlineUserIds: online, lastMessage: undefined, timestamp: undefined, unreadCount: room.unreadCount })));
2916
2916
  }))))));
@@ -16,8 +16,19 @@ export declare const Listen: () => () => void;
16
16
  export declare const Watch: () => () => void;
17
17
  export declare const Element: () => () => void;
18
18
  export declare const Host: () => () => void;
19
- /** Minimal no-op h (hyperscript) function */
20
- export declare const h: (..._args: any[]) => any;
19
+ /** Minimal hyperscript: records tag/props/children so render() output can be asserted. */
20
+ export declare const h: {
21
+ (tag: any, props?: any | null, ...children: any[]): {
22
+ tag: any;
23
+ props: any;
24
+ children: any[];
25
+ };
26
+ Fragment(...children: any[]): {
27
+ tag: string;
28
+ props: any;
29
+ children: any[];
30
+ };
31
+ };
21
32
  /** EventEmitter stub */
22
33
  export declare class EventEmitter<T = any> {
23
34
  emit(_value?: T): void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@chat-leo/chatleo",
3
- "version": "2.1.0",
3
+ "version": "2.1.1",
4
4
  "description": "ChatLeo chat web components — embeddable <chatleo-component> UI for a ChatLeo server",
5
5
  "main": "dist/index.cjs.js",
6
6
  "module": "dist/index.js",
@@ -47,10 +47,10 @@
47
47
  "loader/"
48
48
  ],
49
49
  "dependencies": {
50
- "@chat-leo/chatleolib": "^2.1.0"
50
+ "@chat-leo/chatleolib": "^2.1.1"
51
51
  },
52
52
  "devDependencies": {
53
- "@chat-leo/call-components": "^2.1.0",
53
+ "@chat-leo/call-components": "^2.1.1",
54
54
  "@stencil/core": "^4.45.2",
55
55
  "@types/jest": "^30.0.0",
56
56
  "@types/node": "^26.6.6",
@@ -65,9 +65,9 @@
65
65
  "build": "stencil build",
66
66
  "clean": "rm -rf dist www loader .stencil",
67
67
  "dev": "stencil build --dev --watch --serve",
68
- "test": "jest --testPathPatterns=\"(chatleo-component|chatleo-chat-message|utils)\\.spec\"",
68
+ "test": "jest --testPathPatterns=\"(chatleo-component|chatleo-tray-component|chatleo-chat-message|utils)\\.spec\"",
69
69
  "test:stencil": "stencil test --spec",
70
- "test.watch": "jest --watch --testPathPatterns=\"(chatleo-component|chatleo-chat-message|utils)\\.spec\"",
70
+ "test.watch": "jest --watch --testPathPatterns=\"(chatleo-component|chatleo-tray-component|chatleo-chat-message|utils)\\.spec\"",
71
71
  "generate": "stencil generate"
72
72
  }
73
73
  }
@@ -1 +0,0 @@
1
- import{r as e,h as t,c as a,g as i}from"./p-DmL518NK.js";import{g as n}from"./p-C-l90Wre.js";const o=class{constructor(t){e(this,t)}name;url;isOnline=!1;render(){const e=`\n <svg width="100" height="100" xmlns="http://www.w3.org/2000/svg">\n <circle cx="50" cy="50" r="45" fill="royalblue" />\n <text x="50" y="55" font-size="12" text-anchor="middle" fill="white">${this.name.substring(0,2)}</text>\n </svg>\n `,a="data:image/svg+xml,"+encodeURIComponent(e);return t("div",{key:"e7b5846df55e2088312546869f50c32fc1b3f809",class:"user-avatar"},t("img",{key:"ef7af555265926a194ce8f972286ca3be5746b40",src:this.url??a,alt:this.name,title:this.name}),t("div",{key:"46e7627446b02d7f1e42d110cbb5fd5a55ff333b",class:"status-indicator "+(this.isOnline?"online":"offline")}))}};o.style=":host{--avatar-bg:#dddddd;--status-size:12px;--status-border:2px;--status-position:2px}.user-avatar{position:relative;flex-shrink:0}.user-avatar img{width:var(--avatar-size, 48px);height:var(--avatar-size, 48px);border-radius:50%;object-fit:cover;background-color:var(--avatar-bg);overflow:hidden}.status-indicator{position:absolute;bottom:var(--status-position);right:var(--status-position);width:var(--status-size);height:var(--status-size);border-radius:50%;border:var(--status-border) solid var(--bg-primary)}.status-indicator.online{background-color:var(--status-online)}.status-indicator.offline{background-color:var(--status-offline)}";const s=class{constructor(t){e(this,t),this.messageChatSent=a(this,"messageChatSent")}chatStore;isOnline=!1;pending=!1;callsAvailable=!1;inCall=!1;selectedRoomId;_version=0;_showRoomDetail=!1;roomViewRef;handleToggleMobileView(){this._showRoomDetail=!this._showRoomDetail}isMobileViewport(){return window.innerWidth<768}async openRoom(e){e&&(this.selectedRoomId=e,this.chatStore?.setActiveRoomId(e),this.chatStore?.markRoomAsRead(e),this.isMobileViewport()&&(this._showRoomDetail=!0))}async closeRoom(){this._showRoomDetail=!1,this.chatStore?.setActiveRoomId(null)}async getDraft(){return await(this.roomViewRef?.getDraft?.())??""}async setDraft(e){e&&await(this.roomViewRef?.setDraft?.(e))}async addFiles(e){await(this.roomViewRef?.addFiles?.(e??[]))}async focusComposer(){await(this.roomViewRef?.focusComposer?.())}onChatStoreChange(e,t){console.debug("onChatStoreChange",e,t),e.addEventListener("roomAdded",(e=>{console.debug("roomAdded",e),this._version++})),e.addEventListener("roomMessageAdded",(t=>{console.debug("roomMessageAdded",t),this._version++;const a=t.detail;a?.roomId&&a.roomId===this.selectedRoomId&&e.markRoomAsRead(a.roomId)})),e.addEventListener("roomReadCountChanged",(()=>{this._version++})),e.addEventListener("presenceChanged",(e=>{console.debug("onPresenceChange",e),this._version++}))}messageChatSent;handleSendMessage(e){this.messageChatSent.emit({room_id:this.selectedRoomId,content:e.detail,sender:this.chatStore?.profile?.id,content_type:"text/plain"})}messageSendHandler(e){console.log("Received the messageSend event: ",JSON.stringify(e.detail));const t=(e.detail?.blocks??[]).map((e=>{if("attachment"===e?.type&&Array.isArray(e.attachments)){const t=e.attachments.map((e=>{const{preview:t,...a}=e??{};return a}));return{...e,attachments:t}}return e}));this.messageChatSent.emit({room_id:this.selectedRoomId,content:{blocks:t,version:e.detail.version},content_type:"application/json+blocks",sender:this.chatStore?.profile?.id})}async handleRoomClicked(e){console.debug("ChatleoChat.roomClicked",e),await this.openRoom(e.detail.id)}render(){return t("div",{key:"759aa942b6cfba0635119d0064afe7bc4e2ef901",class:"chat-container-list-and-chat "+(this._showRoomDetail?"show-room-view":"show-room-list")},t("chatleo-room-list",{key:"feecf22c1ab746ec5af8cb1e61708f131946a260",rooms:this.chatStore?.rooms,chatStore:this.chatStore,selectedRoomId:this.selectedRoomId}),t("chatleo-room-view",{key:"c90a58b6946c949288176b3aa5a411b3d7722e7e",ref:e=>this.roomViewRef=e,chatStore:this.chatStore,roomId:this.selectedRoomId,isOnline:this.isOnline,pending:this.pending,callsAvailable:this.callsAvailable,inCall:this.inCall}),t("button",{key:"d1ccaa37c2135f5a0f2945d82cc5becda60ea6e0",class:"toggle-btn",onClick:()=>this.handleToggleMobileView()},t("svg",{key:"e5af148d5cfd19d7bc44cdd76fea530bc6683ea9",viewBox:"0 0 24 24"},t("path",this._showRoomDetail?{d:"M15.41 7.41L14 6l-6 6 6 6 1.41-1.41L10.83 12z"}:{d:"M10 6L8.59 7.41 13.17 12l-4.58 4.59L10 18l6-6z"}))))}static get watchers(){return{chatStore:[{onChatStoreChange:0}]}}};s.style=":host{display:flex;flex-direction:column;flex:1;min-height:0;overflow:hidden}.chat-container-list-and-chat{display:flex;flex-direction:row;height:100%;max-width:100%;min-height:0;overflow:hidden;padding:2px;border:1px solid var(--border-light);box-sizing:border-box;background:var(--bg-primary);position:relative}chatleo-room-view{flex:1;min-width:0;min-height:0;border-left:1px solid var(--border-light);transition:transform 0.3s ease-out}chatleo-room-list{flex:0 0 auto;min-height:0;transition:transform 0.3s ease-out}.toggle-btn{display:none;position:absolute;top:50%;left:50%;transform:translate(-50%, -50%);z-index:100;width:48px;height:48px;border-radius:50%;border:1px solid var(--border-light);background:var(--bg-primary);cursor:pointer;box-shadow:0 2px 8px rgba(0, 0, 0, 0.15);align-items:center;justify-content:center;padding:0}.toggle-btn svg{width:24px;height:24px;fill:var(--text-primary)}@media (max-width: 768px){.chat-container-list-and-chat{overflow-x:hidden}.toggle-btn{display:flex;right:8px;left:auto;top:8px;transform:none}chatleo-room-list{width:100%;flex:1}chatleo-room-view{width:100%;position:absolute;top:0;left:0;right:0;bottom:0;border-left:none}.show-room-list chatleo-room-list{transform:translateX(0)}.show-room-list chatleo-room-view{transform:translateX(100%)}.show-room-view chatleo-room-list{transform:translateX(-100%)}.show-room-view chatleo-room-view{transform:translateX(0)}}";const r=class{constructor(t){e(this,t)}name="";avatar;isOnline=!1;render(){return t("div",{key:"ff841f251f2e9a0065ac166e09e08fa5e0d9dd33",class:"chat-header"},t("chatleo-avatar",{key:"9f3a6ee1fdae519dec06bc28c345440e410f8571",name:this.name,url:this.avatar,isOnline:this.isOnline}),t("div",{key:"ab55b0c38ed957115a34fe5dda24e5f0fa888514",class:"header-name"},this.name))}};r.style=":host{--header-padding:16px;--header-gap:16px}.chat-header{display:flex;align-items:center;gap:var(--header-gap);padding:var(--header-padding);background:var(--bg-primary)}.header-name{font-family:var(--font-primary);font-weight:700;font-size:16px;line-height:1.6;color:var(--text-primary)}";const c=class{constructor(t){e(this,t),this.messageRetry=a(this,"messageRetry"),this.messageDiscard=a(this,"messageDiscard")}message;sender=void 0;senderIsOnline=!1;isOwnMessage=!1;locale="en-US";translations={};messageRetry;messageDiscard;isStructuredContent(e){try{const t=JSON.parse(e);if(t&&t.blocks&&Array.isArray(t.blocks)&&t.version)return t}catch(e){}return null}formatTimestamp(e){try{return new Intl.DateTimeFormat(this.locale,{hour:"numeric",minute:"numeric"}).format(new Date(e))}catch(t){return e}}defaultTranslations={you:"You",sending:"Sending…",failed:"Not sent",retry:"Retry",discard:"Discard"};t(e){return console.log(`Translating key: ${e}`,this.translations,this.defaultTranslations),this.translations[e]||this.defaultTranslations[e]||e}callEntry(){return function(e){try{const t=JSON.parse(e),a=t?.call??(Array.isArray(t?.blocks)?t.blocks.find((e=>"call"===e?.type)):void 0);if(!a)return null;const i=a.fallback_text??t.fallback_text;if(i)return String(i);const n=a.event??a.state,o="number"==typeof a.duration_ms?Math.round(a.duration_ms/1e3):void 0,s=o?` · ${Math.floor(o/60)}:${String(o%60).padStart(2,"0")}`:"";return"missed"===n||"missed"===a.reason?"Missed call":"declined"===n||"declined"===a.reason?"Call declined":"ended"===n||"failed"===n?`Call ended${s}`:"started"===n||"active"===n?"group"===a.mode?"Group call started":"Call started":"Call"}catch{return null}}(this.message.content_body)}renderMessageContent(){const e=this.callEntry();if(e)return t("div",{class:"call-message"},e);const a=this.isStructuredContent(this.message.content_body);return a?t(t.Fragment,null,t("chatleo-rich-message-renderer",{content:a,downloadUrls:this.message.attachment_details,alignment:this.isOwnMessage?"right":"left"})):t("div",{class:"message-text",style:{textAlign:this.isOwnMessage?"right":"left"}},this.message.content_body)}renderDeliveryStatus(){const e=(a=this.message,this.isOwnMessage&&a?.delivery&&"sent"!==a.delivery?{status:a.delivery,error:a.error,canRetry:Boolean(a.client_id)}:{status:"none",canRetry:!1});var a;if("none"===e.status)return null;const i=this.message.client_id;return"pending"===e.status?t("div",{class:"message-status pending","aria-live":"polite"},this.t("sending")):t("div",{class:"message-status failed"},t("span",{class:"message-status-text"},this.t("failed"),e.error?`: ${e.error}`:""),e.canRetry&&i&&t("span",{class:"message-status-actions"},t("button",{type:"button",class:"status-action",onClick:()=>this.messageRetry.emit(i)},this.t("retry")),t("button",{type:"button",class:"status-action discard",onClick:()=>this.messageDiscard.emit(i)},this.t("discard"))))}render(){const e=this.isOwnMessage?this.t("you"):this.sender?.display_name??"";return t("div",{key:"c91f01cbf694c79d4e68b8445a99ffbc5b0b9790",class:"message-row"},!this.isOwnMessage&&t("chatleo-avatar",{key:"6f05c378fd18203d9917f1edbc61b20bf94b81b9",name:e,url:this.sender?.profile_picture_url??null,isOnline:this.senderIsOnline}),t("div",{key:"b1f4df458b587cace3423637b5bad8350a5c3a14",class:"message-content"},t("div",{key:"f7c565319462013dac380d21a813e21861544833",class:"message-header",style:{justifyContent:this.isOwnMessage?"end":"start"}},t("span",{key:"4d30b5eb0c55abb854b6192f0fe9c78bb54aff33",class:"message-author"},e),t("span",{key:"13867dc122764cbdbdd7fa60f5ff7e6916ed49e7",class:"message-timestamp"},this.formatTimestamp(this.message.created_at))),this.renderMessageContent(),this.renderDeliveryStatus()),this.isOwnMessage&&t("chatleo-avatar",{key:"c818e945cb494c07356fae74c00719e32a2c6b23",name:e,url:this.sender?.profile_picture_url??null,isOnline:this.senderIsOnline}))}};c.style=":host{--status-size:9px;--status-border:1.5px}.message-row{display:flex;gap:16px;padding-left:16px}.message-avatar-container{position:relative;width:var(--avatar-size);height:var(--avatar-size);flex-shrink:0}.message-avatar{width:100%;height:100%;border-radius:50%;object-fit:cover;background:var(--bg-light)}.message-status-indicator{position:absolute;bottom:0;right:0;width:var(--status-size);height:var(--status-size);border-radius:50%;border:var(--status-border) solid var(--bg-primary)}.message-status-indicator.online{background:var(--status-online)}.message-status-indicator.offline{background:var(--border-color)}.message-content{flex:1;display:flex;flex-direction:column;gap:4px}.message-header{display:flex;align-items:center;gap:8px}.message-author{font-family:var(--font-primary);font-weight:700;font-size:14px;line-height:1.6;color:var(--text-primary)}.message-timestamp{font-family:var(--font-primary);font-weight:400;font-size:12px;line-height:1.65;color:var(--text-secondary)}.message-timestamp::before{content:'•';margin-right:8px}.message-text{font-family:var(--font-primary);font-weight:400;font-size:14px;line-height:1.6;color:var(--text-primary);word-wrap:break-word;}.message-status{display:flex;align-items:center;gap:8px;font-family:var(--font-primary);font-size:12px;line-height:1.5}.message-status.pending{color:var(--text-secondary);font-style:italic}.message-status.failed{color:#c62828;flex-wrap:wrap}.message-status-actions{display:inline-flex;gap:6px}.status-action{border:1px solid currentColor;background:transparent;color:inherit;border-radius:4px;padding:1px 8px;font:inherit;cursor:pointer}.status-action:hover{background:rgba(198, 40, 40, 0.08)}.status-action.discard{opacity:0.8}.call-message{display:inline-flex;align-items:center;gap:6px;padding:6px 10px;border:1px solid var(--border-light, #ddd);border-radius:8px;font-family:var(--font-primary);font-size:13px;color:var(--text-secondary, #667);background:var(--bg-secondary, transparent)}.call-message::before{content:'☎';font-size:15px}";const h=class{constructor(t){e(this,t),this.activeRoomChange=a(this,"activeRoomChange"),this.unreadTotalChange=a(this,"unreadTotalChange")}username;ticket;useTray;useMain=!1;useRoomView=!1;roomId;chatLeoLib;chatStore;serverUrl;transport;calls="auto";push="manual";pushSwPath;isLoggedIn=!1;loading=!1;isSessionExpired=!1;connectionStatus="disconnected";callsAvailable=!1;incomingCall=null;callView=null;showCall=!1;pushState=null;pushPromptDismissed=!1;activeRoomChange;unreadTotalChange;chatEl;boundActiveRoomChanged=e=>this.activeRoomChange.emit(e.detail??{roomId:null});boundUnreadTotalChanged=e=>this.unreadTotalChange.emit(e.detail??{count:0});callRingtoneTimer;incomingRef;callRingtoneContext;callsChannel;callAdapterRef;trayEl;static OPEN_ROOM_EVENT="chatleo:openRoom";static START_DM_EVENT="chatleo:startDM";static NEW_CHAT_EVENT="chatleo:newChat";boundOpenRoomListener=e=>this.handleExternalOpenRoom(e);boundStartDmListener=e=>this.handleExternalStartDm(e);boundNewChatListener=e=>this.handleExternalNewChat(e);boundStartCallListener=e=>this.handleExternalStartCall(e);boundCallRinging=e=>this.handleCallRinging(e);boundCallChanged=e=>this.handleCallChanged(e);boundCallRole=e=>this.handleCallRole(e);boundServiceWorkerMessage=e=>this.handleServiceWorkerMessage(e);onChatLeoLibChange(e){console.debug("onChatLeoLibChange",e),e&&this.requestLibConnection()}onChatStoreChange(e,t){console.debug("onChatStoreChange",e,t),t?.removeEventListener("callRinging",this.boundCallRinging),t?.removeEventListener("callChanged",this.boundCallChanged),t?.removeEventListener("callRole",this.boundCallRole),t?.removeEventListener("activeRoomChanged",this.boundActiveRoomChanged),t?.removeEventListener("unreadTotalChanged",this.boundUnreadTotalChanged),e.addEventListener("callRinging",this.boundCallRinging),e.addEventListener("callChanged",this.boundCallChanged),e.addEventListener("callRole",this.boundCallRole),e.addEventListener("activeRoomChanged",this.boundActiveRoomChanged),e.addEventListener("unreadTotalChanged",this.boundUnreadTotalChanged),e.addEventListener("roomAdded",(e=>{console.warn(e)})),this.activeRoomChange.emit({roomId:e.activeRoomId}),this.unreadTotalChange.emit({count:e.unreadTotal})}onTicketChange(e){console.debug("onTicketChange",e),this.requestLibConnection()}onCallsChange(e){this.chatLeoLib?.setCallsEnabled?.("off"!==e),this.refreshCallsAvailability()}componentDidLoad(){console.debug("ChatLeoComponent:componentDidLoad",this.serverUrl),this.requestLibConnection()}connectedCallback(){console.debug("ChatLeoComponent:connectedCallback"),window.addEventListener(h.OPEN_ROOM_EVENT,this.boundOpenRoomListener),window.addEventListener(h.START_DM_EVENT,this.boundStartDmListener),window.addEventListener(h.NEW_CHAT_EVENT,this.boundNewChatListener),window.addEventListener("chatleo:startCall",this.boundStartCallListener),"undefined"!=typeof navigator&&"serviceWorker"in navigator&&navigator.serviceWorker.addEventListener("message",this.boundServiceWorkerMessage)}disconnectedCallback(){console.debug("ChatLeoComponent:disconnectedCallback"),this.chatLeoLib?.unregisterClient(this),window.removeEventListener(h.OPEN_ROOM_EVENT,this.boundOpenRoomListener),window.removeEventListener(h.START_DM_EVENT,this.boundStartDmListener),window.removeEventListener(h.NEW_CHAT_EVENT,this.boundNewChatListener),window.removeEventListener("chatleo:startCall",this.boundStartCallListener),"undefined"!=typeof navigator&&"serviceWorker"in navigator&&navigator.serviceWorker.removeEventListener("message",this.boundServiceWorkerMessage),this.chatStore?.removeEventListener("callRinging",this.boundCallRinging),this.chatStore?.removeEventListener("callChanged",this.boundCallChanged),this.chatStore?.removeEventListener("activeRoomChanged",this.boundActiveRoomChanged),this.chatStore?.removeEventListener("unreadTotalChanged",this.boundUnreadTotalChanged),this.chatStore?.removeEventListener("callRole",this.boundCallRole),this.stopRingtone(),this.callsChannel?.close()}async requestLibConnection(){console.debug("requestLibConnection",this.chatLeoLib),this.chatLeoLib?.setCallsEnabled?.("off"!==this.calls),this.pushSwPath&&this.chatLeoLib?.setPushServiceWorkerPath?.(this.pushSwPath),await(this.chatLeoLib?.requestConnection(this,{...this.ticket?{ticket:this.ticket}:{},...this.transport?{transport:this.transport}:{}}))}setLoading(e){this.loading=e}setLoggedIn(e){this.isLoggedIn=e,e&&(this.refreshCallsAvailability(),this.refreshPush())}setSessionExpired(e){this.isSessionExpired=e}setConnectionStatus(e){this.connectionStatus=e}async getConnectionStatus(){return{isConnected:this.chatStore?.isConnected??!1,isSessionExpired:this.isSessionExpired||(this.chatStore?.isSessionExpired??!1),connectionStatus:this.chatStore?.connectionStatus??this.connectionStatus}}async openRoom(e){e?this.useTray?await(this.trayEl?.openChatPanel(e,!1)):await(this.chatEl?.openRoom?.(e)):console.warn("[chatleo-component] openRoom called without roomId")}async closeRoom(){this.useTray?await(this.trayEl?.closeChatPanel?.()):await(this.chatEl?.closeRoom?.())}async getActiveRoomId(){return this.chatStore?.activeRoomId??null}async getDraft(){return await(this.chatEl?.getDraft?.())??""}async setDraft(e){e&&await(this.chatEl?.setDraft?.(e))}async addFiles(e){await(this.chatEl?.addFiles?.(e??[]))}async focusComposer(){await(this.chatEl?.focusComposer?.())}async openDirectMessageWithUser(e,t=!1){e?await this.internalStartDmFlow(e,t):console.warn("[chatleo-component] openDirectMessageWithUser called without userId")}async openNewChatDraft(){await(this.trayEl?.openChatPanel(void 0,!0))}async internalStartDmFlow(e,t=!1){if(e)try{const a=this.chatLeoLib?.findDirectMessageRoomIdByUser(e);if(console.debug("internalStartDmFlow",{existingRoomId:a}),a)return void await this.openRoom(a);const i=await(this.chatLeoLib?.ensureDirectMessageRoom(e,t)),n=i?.roomId;n?await this.openRoom(n):(console.warn("[chatleo-component] ensureDirectMessageRoom returned no roomId"),await(this.trayEl?.openChatPanel(void 0,!1)))}catch(e){console.error("[chatleo-component] Failed to start DM",e),await(this.trayEl?.openChatPanel(void 0,!1))}}async handleExternalOpenRoom(e){const t=e.roomId,a=e?.detail?.roomId||t;a?await this.openRoom(a):e?.detail||console.warn('[chatleo-component] chatleo:openRoom event missing detail. Use new CustomEvent("chatleo:openRoom", { detail: { roomId: "..." } })')}async handleExternalStartDm(e){console.log("handleExternalStartDm",e);const t=e.userId,a=e?.detail?.userId||t,i=e?.detail?.use_external_id??!1;a?await this.openDirectMessageWithUser(a,i):e?.detail||console.warn('[chatleo-component] chatleo:startDM event missing detail. Dispatch like: new CustomEvent("chatleo:startDM", { detail: { userId: "123" } })')}async handleExternalNewChat(e){await this.openNewChatDraft()}async refreshCallsAvailability(){this.callsAvailable=!("off"===this.calls||!this.chatLeoLib?.ensureCallsAvailable)&&await this.chatLeoLib.ensureCallsAvailable()}async loadCallComponents(){if("undefined"==typeof window||window.customElements.get("chatleo-call-adapter"))return!0;try{return await import("./p-BnCPdbII.js"),!!window.customElements.get("chatleo-call-adapter")}catch(e){return console.warn("[chatleo-component] call components could not be loaded",e),!1}}async startOrJoinCall(e,t,a){if(this.chatLeoLib)if(this.callView&&(t?this.callView.callId===t:this.callView.roomId===e))this.showCall=!0;else try{const i=this.chatStore?.rooms.find((t=>t.id===e)),n=t?{id:t,mode:"DirectMessage"===i?.type?"direct":"group"}:await this.chatLeoLib.startCall(e,a),o=await this.chatLeoLib.joinCall(n.id);if(!await this.loadCallComponents())return;this.callView={callId:n.id,roomId:e,mode:o.mode??n.mode,credentials:{sfuUrl:o.sfu_url,token:o.token,roomId:o.room_id,mode:o.mode,iceServers:o.ice_servers}},this.showCall=!0,this.incomingCall=null,this.stopRingtone()}catch(e){console.warn("[chatleo-component] call start/join failed",e)}}onIncomingCallChange(e){e&&setTimeout((()=>this.incomingRef?.focus()),0)}handleCallRinging(e){this.incomingCall=e.detail?.call??null,this.incomingCall?this.startRingtone(this.incomingCall.id):this.stopRingtone()}handleCallChanged(e){this.callView&&!e.detail?.call&&(this.callView=null,this.showCall=!1,this.stopRingtone())}async acceptIncomingCall(){if(!this.incomingCall)return;const e=this.incomingCall;this.incomingCall=null,this.stopRingtone(),await this.startOrJoinCall(e.room_id,e.id)}async declineIncomingCall(){if(!this.incomingCall||!this.chatLeoLib)return;const e=this.incomingCall;this.incomingCall=null,this.stopRingtone();try{await this.chatLeoLib.declineCall(e.id)}catch(e){console.warn("[chatleo-component] decline failed",e)}}handleExternalStartCall(e){const t=e?.detail?.roomId;t&&this.startOrJoinCall(t,void 0,e.detail.mode)}handleCallRole(e){const{callId:t,userId:a}=e.detail??{};this.callView&&this.callView.callId===t&&(a&&a!==this.chatStore?.profile?.id||this.callAdapterRef?.refreshToken?.().catch((e=>console.warn("[chatleo-component] token refresh after a role change failed",e))))}callToken=async()=>{const e=this.callView;if(!e||!this.chatLeoLib)throw new Error("no call");const t=await this.chatLeoLib.refreshCallToken(e.callId);return{token:t.token,sfuUrl:t.sfu_url,iceServers:t.ice_servers}};promoteInCall=async(e,t,a)=>{const i=this.callView;if(!i||!this.chatLeoLib||!a?.userId)throw new Error("unknown participant");await this.chatLeoLib.promoteCallParticipant(i.callId,a.userId)};demoteInCall=async(e,t)=>{const a=this.callView;if(!a||!this.chatLeoLib||!t?.userId)throw new Error("unknown participant");await this.chatLeoLib.demoteCallParticipant(a.callId,t.userId)};startRingtone(e){if("undefined"!=typeof window){if(this.callsChannel??="undefined"!=typeof BroadcastChannel?new BroadcastChannel("chatleo-calls"):void 0,this.callsChannel){const t=this.callsChannel;t.addEventListener("message",(t=>{"ring"===t.data?.type&&t.data.callId===e&&this.stopRingtone()}),{once:!0}),t.postMessage({type:"ring",callId:e})}try{const e=this.callRingtoneContext??new AudioContext;this.callRingtoneContext=e;const t=()=>{const t=e.createOscillator(),a=e.createGain();t.frequency.value=660,a.gain.value=.04,t.connect(a).connect(e.destination),t.start(),setTimeout((()=>t.stop()),180)};t(),this.callRingtoneTimer=setInterval(t,1200)}catch{}}}stopRingtone(){this.callRingtoneTimer&&(clearInterval(this.callRingtoneTimer),this.callRingtoneTimer=void 0)}async refreshPush(){if("off"!==this.push&&this.chatLeoLib?.pushState)try{this.pushState=await this.chatLeoLib.pushState()}catch{this.pushState=null}else this.pushState=null}async enablePush(){if(this.chatLeoLib?.enablePush)try{this.pushState=await this.chatLeoLib.enablePush(),this.pushPromptDismissed=!0}catch(e){console.warn("[chatleo-component] enabling push failed",e),await this.refreshPush()}}async disablePush(){if(this.chatLeoLib?.disablePush)try{this.pushState=await this.chatLeoLib.disablePush()}catch(e){console.warn("[chatleo-component] disabling push failed",e)}}handleServiceWorkerMessage(e){if("chatleo:pushVisibility"!==e.data?.type)"chatleo:openRoom"===e.data?.type&&e.data.roomId&&(this.openRoom(String(e.data.roomId)),"undefined"!=typeof navigator&&"clearAppBadge"in navigator&&navigator.clearAppBadge());else{const t=String(e.data.roomId??""),a="undefined"!=typeof document&&"visible"===document.visibilityState&&this.chatStore?.activeRoomId===t;e.ports?.[0]?.postMessage({visible:a})}}renderPushControl(){if("off"===this.push||!this.pushState)return null;const e=this.pushState;return"ios_install_required"===e.availability?t("div",{class:"push-control push-control--hint"},"Add ChatLeo to your home screen to enable notifications."):"available"!==e.availability?null:"denied"===e.permission?t("div",{class:"push-control push-control--hint"},"Notifications are blocked in your browser settings."):e.subscribed&&e.accountEnabled?t("button",{type:"button",class:"push-control",onClick:()=>{this.disablePush()}},"Notifications on"):"prompt"!==this.push||this.pushPromptDismissed?t("button",{type:"button",class:"push-control",onClick:()=>{this.enablePush()}},"Enable notifications"):t("div",{class:"push-control push-control--prompt",role:"region","aria-label":"Enable notifications"},t("span",null,"Get notified about new messages when ChatLeo is in the background."),t("button",{type:"button",onClick:()=>{this.enablePush()}},"Enable"),t("button",{type:"button",class:"push-control__secondary",onClick:()=>{this.pushPromptDismissed=!0}},"Not now"))}identityResolver={resolve:e=>Object.fromEntries(e.map((e=>{const t=this.chatStore?.usernameResolver(e);return[e,{displayName:t?.display_name??e,avatarUrl:t?.profile_picture_url??void 0}]})))};onCallError(e){const t=this.callView,a=e.detail?.code;t&&a&&["auth_rejected","removed","session_replaced","room_ended","room_full","network_failed"].includes(a)&&(this.callView=null,this.showCall=!1,"network_failed"===a&&this.chatLeoLib?.leaveCall(t.callId).catch((()=>{})))}onCallLeft(){const e=this.callView;e&&(this.callView=null,this.showCall=!1,this.chatLeoLib?.leaveCall(e.callId).catch((e=>console.warn("[chatleo-component] leave failed",e))))}onCallRequested(e){const t=e.detail;t?.roomId&&this.startOrJoinCall(t.roomId,t.callId)}onNewChatClicked(e){}onChatMessage(e){console.debug("messageChatSent",e),this.chatLeoLib?.sendChatMessage(e.detail)}async onUserSelectedForChat(e){const t=e.detail;t&&t.id&&await this.internalStartDmFlow(t.id)}get _connectionBannerLabel(){switch(this.connectionStatus){case"connecting":return"Verbindung wird hergestellt…";case"reconnecting":return"Verbindung wird wiederhergestellt…";case"disconnected":return"Offline";default:return null}}render(){const e=this._connectionBannerLabel;return t("div",{key:"d0c7c84ebf5fe164868f6e2250252a0899493ee3",style:{height:"100%",maxHeight:"inherit",width:"100%",display:"flex",flexDirection:"column",position:"relative",overflow:"hidden",minHeight:"0"}},this.renderPushControl(),e&&!this.isSessionExpired&&t("div",{key:"d5147662da351b027aba0542ae3dc5af161d2aa3",class:`connection-banner connection-banner--${this.connectionStatus}`},t("span",{key:"43cad2fcb7fd75d099fa8b73f482e7eb282c0957",class:"connection-banner__dot"}),e),this.useMain&&t("chatleo-chat",{key:"609457ee0ab1ceaa2484d91d4c54d734770f4d01",ref:e=>this.chatEl=e,chatStore:this.chatStore,callsAvailable:this.callsAvailable,inCall:!!this.callView}),this.useTray&&t("chatleo-tray-component",{key:"ebd656fd966561d4f982859b9c36a1e233b204b6",chatStore:this.chatStore,ref:e=>this.trayEl=e}),this.useRoomView&&t("chatleo-room-view",{key:"6af1a89788728c21f72ee1a31b7e70bd7d096f0f",chatStore:this.chatStore,roomId:this.roomId,isOnline:this.chatStore?.isConnected??!1,pending:this.loading,callsAvailable:this.callsAvailable,inCall:!!this.callView}),this.callView&&t("div",{key:"3a346cdaf24c1fe758f86e1233cc4626db023a32",class:"call-layer",style:{display:this.showCall?"flex":"none"}},t("button",{key:"7720dc641239eb8da833c63c1f30d4ed29fece7c",type:"button",class:"call-layer__back",onClick:()=>{this.showCall=!1}},"Chat"),t("chatleo-call-adapter",{ref:e=>this.callAdapterRef=e,callId:this.callView.callId,mode:this.callView.mode,connection:this.callView.credentials,autoJoin:!0,identity:this.identityResolver,getToken:this.callToken,promoteHandler:this.promoteInCall,demoteHandler:this.demoteInCall,style:{flex:"1",minHeight:"0"}})),this.incomingCall&&t("div",{key:"ebdc317f30b07009f41f7f729b9e8631ea039752",class:"incoming-call",role:"dialog","aria-modal":"true","aria-label":`Incoming call from ${this.incomingCall.caller.display_name??this.incomingCall.caller.id}`,tabIndex:-1,ref:e=>this.incomingRef=e},t("div",{key:"4eac45f10551a47c7bf1ad8035a9da5ed2955e29",class:"incoming-call__box"},t("p",{key:"6f74dee9aa261dc889b70c18e5b110e18b1a2111",class:"incoming-call__eyebrow"},"Incoming call"),t("chatleo-avatar",{key:"e097d46809d6202d64ebc1eaf42418b74c990e80",name:this.incomingCall.caller.display_name??this.incomingCall.caller.id,url:this.incomingCall.caller.profile_picture_url??null,isOnline:!1}),t("p",{key:"b160c0021f003d230d5fb544d82fd8d23f7df332",class:"incoming-call__name"},this.incomingCall.caller.display_name??this.incomingCall.caller.id),t("div",{key:"b238c1352384a0f14a2abd130fe0f3495da156f3",class:"incoming-call__actions"},t("button",{key:"1b44cc1c87dfb89b4715fb370c490a05d97b6512",type:"button",class:"incoming-call__accept",onClick:()=>{this.acceptIncomingCall()}},"Accept"),t("button",{key:"97276ec614d0be526f16573a3d0e9f6cb9e24b7c",type:"button",class:"incoming-call__decline",onClick:()=>{this.declineIncomingCall()}},"Decline")))),this.isSessionExpired&&t("div",{key:"b387b49bc31378c63c6520a95bf732c47a142e88",class:"session-expired-overlay"},t("div",{key:"118687b87cc612d9ad47692a3e8f2a38f3b71f32",class:"session-expired-box"},t("svg",{key:"562cf50bb4f6cdd0e4076267c6dea5f8b76b06d7",class:"session-expired-icon",xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none"},t("path",{key:"628579c8dad4064d6fcfdfd75801160fe8f0ef8f",d:"M12 9v4M12 17h.01M10.29 3.86L1.82 18a2 2 0 001.71 3h16.94a2 2 0 001.71-3L13.71 3.86a2 2 0 00-3.42 0z",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"})),t("p",{key:"e49e2388dad8df0e961cb7e0dc605a4011775eed",class:"session-expired-title"},"Session abgelaufen"),t("p",{key:"0b69cf4687411c7e9f117712b28da57bc798ce07",class:"session-expired-message"},"Deine Sitzung ist abgelaufen. Bitte lade die Seite neu, um fortzufahren."),t("button",{key:"9532b50dccc9f05dc3ee4a5ea2b28eea462a0ed1",class:"session-expired-button",onClick:()=>window.location.reload()},"Seite neu laden"))))}static get watchers(){return{chatLeoLib:[{onChatLeoLibChange:0}],chatStore:[{onChatStoreChange:0}],ticket:[{onTicketChange:0}],calls:[{onCallsChange:0}],incomingCall:[{onIncomingCallChange:0}]}}};h.style=":host{overflow:hidden;position:relative;height:100%;max-height:100%;min-height:0;--display:block;--bg-primary:#ffffff;--bg-secondary:#f3f4f6;--bg-light:#e7effc;--text-primary:#171a1f;--text-secondary:#9095a1;--border-color:#bdc1ca;--border-light:#eeeeee;--accent-color:#4a86e8;--accent-hover:#3a7bd8;--status-online:#21d184;--status-offline:#6b7280;--font-primary:'Manrope', sans-serif;--avatar-size:36px;--border-radius:8px;--transition-duration:0.2s;display:var(--display)}.connection-banner{display:flex;align-items:center;gap:6px;padding:5px 12px;font-family:var(--font-primary, 'Manrope', sans-serif);font-size:12px;font-weight:600;color:#fff;background:#6b7280;z-index:100;flex-shrink:0}.connection-banner--connecting,.connection-banner--reconnecting{background:#f59e0b;color:#fff}.connection-banner--disconnected{background:#ef4444;color:#fff}.connection-banner__dot{width:7px;height:7px;border-radius:50%;background:rgba(255, 255, 255, 0.8);flex-shrink:0;animation:pulse-dot 1.4s ease-in-out infinite}.connection-banner--disconnected .connection-banner__dot{animation:none}@keyframes pulse-dot{0%,100%{opacity:1}50%{opacity:0.3}}.session-expired-overlay{position:absolute;inset:0;z-index:9999;background:rgba(255, 255, 255, 0.85);backdrop-filter:blur(4px);display:flex;align-items:center;justify-content:center}.session-expired-box{background:var(--bg-primary, #fff);border:1px solid var(--border-color, #bdc1ca);border-radius:var(--border-radius, 8px);box-shadow:0 4px 24px rgba(0, 0, 0, 0.12);padding:32px 28px;max-width:340px;width:100%;text-align:center;display:flex;flex-direction:column;align-items:center;gap:12px}.session-expired-icon{color:#f59e0b;width:32px;height:32px}.session-expired-title{margin:0;font-family:var(--font-primary, 'Manrope', sans-serif);font-size:16px;font-weight:700;color:var(--text-primary, #171a1f)}.session-expired-message{margin:0;font-family:var(--font-primary, 'Manrope', sans-serif);font-size:13px;color:var(--text-secondary, #9095a1);line-height:1.6}.session-expired-button{margin-top:4px;padding:8px 20px;background:var(--accent-color, #4a86e8);color:#fff;border:none;border-radius:var(--border-radius, 8px);font-family:var(--font-primary, 'Manrope', sans-serif);font-size:14px;font-weight:600;cursor:pointer;transition:background var(--transition-duration, 0.2s)}.session-expired-button:hover{background:var(--accent-hover, #3a7bd8)}.call-layer{position:absolute;inset:0;z-index:40;background:var(--bg-primary, #fff);flex-direction:column}.call-layer__back{align-self:flex-end;margin:8px 16px 0;border:1px solid var(--border-color, #ddd);background:transparent;border-radius:6px;padding:4px 10px;font:inherit;cursor:pointer}.incoming-call{position:absolute;inset:0;z-index:50;display:flex;align-items:center;justify-content:center;background:rgba(15, 23, 42, 0.45)}.incoming-call:focus{outline:none}.incoming-call__box{width:min(320px, calc(100% - 32px));background:var(--bg-primary, #fff);border-radius:12px;padding:24px;text-align:center;box-shadow:0 18px 50px rgba(15, 23, 42, 0.25)}.incoming-call__eyebrow{margin:0 0 12px;font-size:12px;letter-spacing:0.08em;text-transform:uppercase;color:var(--text-secondary, #667)}.incoming-call__name{margin:12px 0 20px;font-size:18px;font-weight:700}.incoming-call__actions{display:flex;gap:10px;justify-content:center}.incoming-call__accept,.incoming-call__decline{border-radius:8px;padding:8px 18px;font:inherit;cursor:pointer}.incoming-call__accept{border:none;background:#1b8a3a;color:#fff}.incoming-call__decline{border:1px solid var(--border-color, #ddd);background:transparent;color:inherit}.push-control{display:flex;align-items:center;gap:8px;padding:6px 12px;border:0;border-bottom:1px solid var(--border-light, #eee);background:var(--bg-secondary, #f7f8fa);color:var(--text-primary, #222);font:inherit;font-size:12px;text-align:left;cursor:pointer}.push-control--hint{cursor:default;color:var(--text-secondary, #667)}.push-control--prompt{flex-wrap:wrap}.push-control--prompt button{border:1px solid var(--accent-color, #4a86e8);border-radius:6px;background:transparent;color:var(--accent-color, #4a86e8);padding:3px 10px;font:inherit;cursor:pointer}.push-control__secondary{border-color:var(--border-color, #ddd) !important;color:var(--text-secondary, #667) !important}";const d=class{constructor(t){e(this,t),this.userSelected=a(this,"userSelected"),this.doClose=a(this,"doClose")}chatStore;placeholder="Suche";filterText="";filteredUsers=[];_version=0;boundOnUserAdded=()=>this.onUserAdded();boundOnPresenceChange=()=>this.onPresenceChange();userSelected;doClose;onChatStoreChange(e,t){this.unbindChatStore(t),this.bindChatStore(e)}connectedCallback(){this.bindChatStore(this.chatStore)}disconnectedCallback(){this.unbindChatStore(this.chatStore)}bindChatStore(e){e&&(e.addEventListener("userAdded",this.boundOnUserAdded),e.addEventListener("presenceChanged",this.boundOnPresenceChange),this.updateFilteredUsers())}unbindChatStore(e){e&&(e.removeEventListener("userAdded",this.boundOnUserAdded),e.removeEventListener("presenceChanged",this.boundOnPresenceChange))}onUserAdded(){this.updateFilteredUsers()}onPresenceChange(){console.debug("onPresenceChange"),this._version++}onDoClose(e){e.preventDefault(),this.doClose.emit()}onFilterChange=e=>{this.filterText=e.target.value.toLowerCase(),this.updateFilteredUsers()};updateFilteredUsers(){const e=this.chatStore?.users??[],t=this.chatStore?.profile?.id,a=this.filterText;this.filteredUsers=e.filter((e=>e.id!==t&&(!a||(e.display_name||"").toLowerCase().includes(a))))}onUserSelected=e=>{const t=e.detail;t&&this.userSelected.emit(t)};render(){return t("div",{key:"ec5c9b8d53cce3ff5bc812dc4fc4ba3ab12bf6f8",class:"new-message-selector"},t("div",{key:"62d0468365a42452ccdd3de9aad50aa79d8eb029",class:"title"},"Neue Nachricht",t("button",{key:"74338599974c932922193040da99815d472d79da",class:"close-button",onClick:this.onDoClose.bind(this)},t("svg",{key:"c277fd2307e0fc618a4ea07146ac026828900cb7",width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg"},t("path",{key:"a30e06e02089d91366bc5bb9a653cf15ebb2f367",d:"M12 4L4 12",stroke:"#565D6D","stroke-width":"1.37143","stroke-miterlimit":"10","stroke-linecap":"square"}),t("path",{key:"f2583d2faf8f1ffefe43e273f2c07cde71dd5502",d:"M12 12L4 4",stroke:"#565D6D","stroke-width":"1.37143","stroke-miterlimit":"10","stroke-linecap":"square"})))),t("div",{key:"04983dc0b38f3f7c2bf133dfdfd8aba9a57358e4",class:"search-container"},t("input",{key:"77f351f89f4c78735d1ce34ef0f925d5bea92746",type:"text",class:"search-input",placeholder:this.placeholder,value:this.filterText,onInput:this.onFilterChange})),t("span",{key:"26ac88fea8e9855246a74e9196bd6da4c3ea1c88",class:"suggestions"},"Vorschläge"),t("div",{key:"58f1bfe2385d0f7ecaace341c6575135d1c84e63",class:"users-list"},this.filteredUsers.map((e=>{const a=this.chatStore?.isOnline(e.id)??!1;return t("chatleo-user-tile",{key:e.id,profile:e,isOnline:a,lastSeen:void 0,onUserClicked:this.onUserSelected})}))))}static get watchers(){return{chatStore:[{onChatStoreChange:0}]}}};d.style=":host{--input-bg:#F3F4F6;--text-placeholder:#9ca3af;--accent-shadow:rgba(59, 130, 246, 0.1);--container-padding:16px;--input-font-size:16px;--list-padding:8px;--tile-padding:12px 16px;display:block}.new-message-selector{display:flex;flex-direction:column;height:100%;max-height:70vh;background-color:var(--bg-primary);color:var(--text-secondary);box-sizing:border-box;width:100%}.title{padding:16px 16px 8px 16px;border-bottom:1px solid var(--border-color);font-weight:700;font-size:16px;color:#171A1F;display:flex;flex-direction:row;justify-content:space-between}.close-button{background:none;border:none;cursor:pointer;font-size:16px;color:var(--text-secondary)}.search-container{padding:16px;flex-shrink:0}.search-input{width:100%;border:0;font-size:14px;border-radius:var(--border-radius);outline:none;background-color:var(--input-bg);color:var(--text-secondary);padding:8px;box-sizing:border-box}.search-input:focus{border-color:var(--accent-color);}.search-input::placeholder{color:var(--text-placeholder)}.suggestions{padding:0 16px;font-size:14px}.users-list{flex:1;overflow-y:auto;}.users-list chatleo-user-tile{padding:8px 16px;display:block;--user-tile-border:none}.users-list chatleo-user-tile:hover{background-color:var(--hover-color)}chatleo-user-tile chatleo-avatar{--avatar-size:36px}";const l=class{constructor(t){e(this,t),this.contentChange=a(this,"contentChange"),this.messageSend=a(this,"messageSend")}get hostElement(){return i(this)}disabled=!1;placeholder="Write a message...";maxHeight="200px";acceptFiles="image/*,.pdf,.doc,.docx,.txt";isDragOver=!1;hasContent=!1;contentChange;messageSend;editorRef;fileInputRef;async getText(){return this.editorRef?.innerText??""}async setText(e){this.editorRef&&(this.editorRef.innerText=e??"",this.placeCaretAtEnd(this.editorRef),this.emitContentChange())}async addFiles(e){e?.length&&await this.handleFiles(e)}async focusEditor(){this.editorRef&&(this.editorRef.focus(),this.placeCaretAtEnd(this.editorRef))}generateAttachmentId(){return crypto.randomUUID()}isImageFile(e){return e.type.startsWith("image/")}async generateThumbnail(e){if(this.isImageFile(e))return new Promise((t=>{const a=new FileReader;a.onload=e=>{const a=new Image;a.onload=()=>{const e=document.createElement("canvas"),i=e.getContext("2d"),n=100;let{width:o,height:s}=a;o>s?o>n&&(s*=n/o,o=n):s>n&&(o*=n/s,s=n),e.width=o,e.height=s,i?.drawImage(a,0,0,o,s),t(e.toDataURL("image/jpeg",.8))},a.src=e.target?.result},a.readAsDataURL(e)}))}async handleFiles(e){const t=Array.from(e),a=[];for(const e of t){const t={mime_type:e.type,id:this.generateAttachmentId(),file:e,name:e.name,size:e.size};t.mime_type.startsWith("image")&&(t.preview=await this.generateThumbnail(e)),a.push(t)}a.length>0&&this.insertAttachmentsAtCursor(a),this.emitContentChange()}getEditorSelection(){if(!this.editorRef)return null;const e=this.hostElement.shadowRoot,t=e&&"function"==typeof e.getSelection?e.getSelection():window.getSelection();if(!t||0===t.rangeCount)return null;const a=t.anchorNode;return a&&this.editorRef.contains(a)?t:null}placeCaretAtEnd(e){const t=document.createRange();t.selectNodeContents(e),t.collapse(!1);const a=this.hostElement.shadowRoot?.getSelection?.()??window.getSelection();a?.removeAllRanges(),a?.addRange(t)}insertAttachmentsAtCursor(e){if(!this.editorRef)return;const t=this.createAttachmentBlock(e);this.editorRef.focus();let a=this.getEditorSelection();if(a||(this.placeCaretAtEnd(this.editorRef),a=this.getEditorSelection()),a&&a.rangeCount>0){const e=a.getRangeAt(0);if(e.startContainer.nodeType===Node.TEXT_NODE&&e.startOffset>0){e.setStart(e.startContainer,e.startContainer.textContent?.length||0),e.collapse(!0);const t=document.createElement("br");e.insertNode(t),e.setStartAfter(t)}e.insertNode(t);const i=document.createElement("br");return e.setStartAfter(t),e.insertNode(i),e.setStartAfter(i),e.collapse(!0),a.removeAllRanges(),void a.addRange(e)}this.editorRef.innerHTML.trim()&&!this.editorRef.innerHTML.endsWith("<br>")&&this.editorRef.appendChild(document.createElement("br")),this.editorRef.appendChild(t);const i=document.createElement("br");this.editorRef.appendChild(i),this.placeCaretAtEnd(this.editorRef)}createAttachmentBlock(e){const t=document.createElement("div");t.className="attachment-block",t.contentEditable="false",1===e.length&&(t.setAttribute("data-attachment-id",e[0].id),t._attachmentData=e[0]),t._attachmentsData=e;const a=document.createElement("div");return a.className="attachment-content",e.forEach((e=>{const i=document.createElement("div");if(i.className="attachment-item",e.mime_type.startsWith("image")&&e.preview){const t=document.createElement("img");t.src=e.preview,t.alt=e.name,t.className="attachment-thumbnail",i.appendChild(t)}else{const e=document.createElement("div");e.className="attachment-icon",e.innerHTML='\n <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none">\n <path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>\n <polyline points="14,2 14,8 20,8" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>\n </svg>\n ',i.appendChild(e)}const n=document.createElement("div");n.className="attachment-info";const o=document.createElement("div");o.className="attachment-name",o.textContent=e.name,n.appendChild(o);const s=document.createElement("div");s.className="attachment-size",s.textContent=this.formatFileSize(e.size),n.appendChild(s),i.appendChild(n);const r=document.createElement("button");r.className="attachment-remove",r.type="button",r.innerHTML='\n <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16" fill="none">\n <path d="M12 4L4 12M4 4l8 8" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>\n </svg>\n ',r.onclick=a=>{a.preventDefault(),a.stopPropagation(),this.removeAttachmentFromBlock(t,e.id)},i.appendChild(r),a.appendChild(i)})),t.appendChild(a),t}removeAttachmentFromBlock(e,t){const a=e._attachmentsData;if(a){const i=a.filter((e=>e.id!==t));if(0===i.length)this.removeAttachmentBlock(e);else{e._attachmentsData=i,1===i.length?(e._attachmentData=i[0],e.setAttribute("data-attachment-id",i[0].id)):(delete e._attachmentData,e.removeAttribute("data-attachment-id"));const t=this.createAttachmentBlock(i);e.replaceWith(t),this.emitContentChange()}}}removeAttachmentBlock(e){if(e.parentNode){const t=e.nextSibling;t&&"BR"===t.nodeName&&t.parentNode?.removeChild(t),e.parentNode.removeChild(e),this.emitContentChange()}}handleInput=()=>{this.emitContentChange()};extractContent(){if(!this.editorRef)return{text:"",attachments:[]};let e="";const t=[];if(document.createTreeWalker){const a=document.createTreeWalker(this.editorRef,NodeFilter.SHOW_TEXT|NodeFilter.SHOW_ELEMENT,{acceptNode:e=>{if(e.nodeType===Node.TEXT_NODE)return NodeFilter.FILTER_ACCEPT;if(e.nodeType===Node.ELEMENT_NODE){const t=e;if(t.classList.contains("attachment-block"))return NodeFilter.FILTER_ACCEPT;if("BR"===t.tagName)return NodeFilter.FILTER_ACCEPT}return NodeFilter.FILTER_SKIP}});let i;for(;i=a.nextNode();)if(i.nodeType===Node.TEXT_NODE)e+=i.textContent||"";else if(i.nodeType===Node.ELEMENT_NODE){const a=i;if(a.classList.contains("attachment-block")){const i=a._attachmentsData,n=a._attachmentData;i?t.push(...i):n&&t.push(n),e+="\n[attachment]\n"}else"BR"===a.tagName&&(e+="\n")}}else{const a=[],i=e=>{a.push(e),e.childNodes.forEach(i)};i(this.editorRef);for(const i of a)if(i.nodeType===Node.TEXT_NODE)e+=i.textContent||"";else if(i.nodeType===Node.ELEMENT_NODE){const a=i;if(a.classList.contains("attachment-block")){const i=a._attachmentsData,n=a._attachmentData;i?t.push(...i):n&&t.push(n),e+="\n[attachment]\n"}else"BR"===a.tagName&&(e+="\n")}}return{text:e.trim(),attachments:t}}generateHtmlContent(e){const t=[];for(const a of e)if("text"===a.type){const e=a.content.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/\n/g,"<br>");t.push(`<div data-block-id="${a.id}" data-block-type="text">${e}</div>`)}else if("attachment"===a.type){const e=a.attachments,i=e.map((e=>`\n <div class="attachment-item" data-attachment-id="${e.id}" data-attachment-type="${e.mime_type}" data-attachment-name="${this.escapeHtml(e.name)}" data-attachment-size="${e.size}">\n ${e.mime_type?.startsWith("image")&&e.preview?`<img src="${e.preview}" alt="${this.escapeHtml(e.name)}" class="attachment-thumbnail">`:'<div class="attachment-icon">\n <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none">\n <path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>\n <polyline points="14,2 14,8 20,8" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>\n </svg>\n </div>'}\n <div class="attachment-info">\n <div class="attachment-name">${this.escapeHtml(e.name)}</div>\n <div class="attachment-size">${this.formatFileSize(e.size)}</div>\n </div>\n </div>\n `)).join("\n");t.push(`\n <div class="attachment-block" data-block-id="${a.id}" data-block-type="attachment" data-attachment-count="${e.length}">\n <div class="attachment-content">\n ${i}\n </div>\n </div>`.trim())}return t.join("\n")}escapeHtml(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}extractStructuredContent(){if(!this.editorRef)return{blocks:[],version:"1.0",html:""};const e=[];let t=0;const a=Array.from(this.editorRef.childNodes);let i="";const n=()=>{if(i.length>0){const a={id:"text_"+ ++t,type:"text",content:i};e.push(a),i=""}};for(const o of a)if(o.nodeType===Node.TEXT_NODE){const e=o.textContent??"";e.length>0&&(i+=e)}else if(o.nodeType===Node.ELEMENT_NODE){const a=o;if(a.classList.contains("attachment-block")){n();const i=a._attachmentsData,o=a._attachmentData;if(i){const a={id:"attachment_"+ ++t,type:"attachment",attachments:i};e.push(a)}else if(o){const a={id:"attachment_"+ ++t,type:"attachment",attachments:[o]};e.push(a)}}else if("BR"===a.tagName)i+="\n";else{const e=a.textContent??"";e.length>0&&(i+=e),this.isBlockElement(a)&&!i.endsWith("\n")&&(i+="\n")}}n();const o=this.generateHtmlContent(e);return{blocks:e,version:"1.0",html:o}}isBlockElement(e){return new Set(["DIV","P","PRE","LI","UL","OL","H1","H2","H3","H4","H5","H6","BLOCKQUOTE"]).has(e.tagName)}handleKeyDown=e=>{"Enter"!==e.key||e.shiftKey||(e.preventDefault(),this.handleSendMessage())};handleFileButtonClick=()=>{this.fileInputRef?.click()};handleFileInputChange=e=>{const t=e.target;t.files&&t.files.length>0&&(this.handleFiles(t.files),t.value="")};handleDragOver=e=>{e.preventDefault(),e.stopPropagation(),this.isDragOver=!0};handleDragLeave=e=>{e.preventDefault(),e.stopPropagation(),this.isDragOver=!1};handleDrop=async e=>{e.preventDefault(),e.stopPropagation(),this.isDragOver=!1;const t=e.dataTransfer?.files;if(t&&t.length>0){const a=document.caretRangeFromPoint(e.clientX,e.clientY);if(a&&this.editorRef?.contains(a.startContainer)){const e=window.getSelection();e?.removeAllRanges(),e?.addRange(a)}await this.handleFiles(t)}};handleSendMessage=()=>{const e=this.extractContent(),t=this.extractStructuredContent();console.debug("handleSendMessage",t.blocks),(e.text.trim()||e.attachments.length>0)&&(this.messageSend.emit(t),this.editorRef&&(this.editorRef.innerHTML=""),this.emitContentChange())};emitContentChange=()=>{const e=this.extractContent(),t=!!(e.text.trim()||e.attachments.length>0);this.hasContent!==t&&(this.hasContent=t),this.contentChange.emit(e)};formatFileSize=e=>{if(0===e)return"0 Bytes";const t=Math.floor(Math.log(e)/Math.log(1024));return parseFloat((e/Math.pow(1024,t)).toFixed(2))+" "+["Bytes","KB","MB","GB"][t]};render(){const e=this.hasContent;return t("div",{key:"2a3b14309017d69790c17db7591a28f82f49cee4",class:"rich-input-container "+(this.isDragOver?"drag-over":""),onDragOver:this.handleDragOver,onDragLeave:this.handleDragLeave,onDrop:this.handleDrop},t("div",{key:"4a2310a460ed29c6d47dd1683f070ebbd054b73a",class:"editor-area"},t("div",{key:"922433e6227fdd46fa71fdc5b05f1c508fcab423",class:"editor-wrapper"},t("div",{key:"6fd7691dab9e056058a0109dfe708e6bd3236c4b",ref:e=>this.editorRef=e,class:"rich-editor",contentEditable:!this.disabled,onInput:this.handleInput,onKeyDown:this.handleKeyDown,"data-placeholder":this.placeholder,style:{maxHeight:this.maxHeight}}),t("div",{key:"7ef1ab99474753beafcbf08e85d55e1037b887ff",class:"input-actions"},t("button",{key:"622970886800a5f602a079598d283eea9a1f0689",class:"action-button file-button",onClick:this.handleFileButtonClick,disabled:this.disabled,type:"button"},t("svg",{key:"722d7fb7a68b08888039e36f58d16d39472ad229",xmlns:"http://www.w3.org/2000/svg",width:"17",height:"16",viewBox:"0 0 17 16",fill:"none"},t("path",{key:"e06306ea498415db01f587e218637594b90a8983",d:"M11.9286 3.42858L11.9286 10.5714C11.9286 12.6286 10.2714 14.2857 8.21429 14.2857C6.15714 14.2857 4.5 12.6286 4.5 10.5714L4.5 4.28572C4.5 2.85715 5.64286 1.71429 7.07143 1.71429C8.5 1.71429 9.64286 2.85715 9.64286 4.28572L9.64286 10C9.64286 10.8 9.01429 11.4286 8.21429 11.4286C7.41429 11.4286 6.78571 10.8 6.78571 10L6.78571 5.14287",stroke:"#4A86E8","stroke-width":"1.5","stroke-miterlimit":"10","stroke-linecap":"square"}))),t("button",{key:"717f2e6f57f4b8316ffa58da639f695f4e55ca6f",class:"action-button file-button",onClick:this.handleFileButtonClick,disabled:this.disabled,type:"button"},t("svg",{key:"08a5a232a719d8e4e18053d469e868aeeba1972b",xmlns:"http://www.w3.org/2000/svg",width:"33",height:"32",viewBox:"0 0 33 32",fill:"none"},t("path",{key:"c642251b6186dde4ab105f7655c212f510734693",d:"M10.5 18.5312L14.3226 14.7683C14.6047 14.4907 15.062 14.4907 15.344 14.7683L18.4444 17.8203M18.4444 17.8203L17.3611 18.8867M18.4444 17.8203L19.7393 16.5457C20.0214 16.268 20.4786 16.268 20.7607 16.5457L23.5 19.2422M11.9444 21.375H22.0556C22.8533 21.375 23.5 20.7384 23.5 19.9531V11.4219C23.5 10.6366 22.8533 10 22.0556 10H11.9444C11.1467 10 10.5 10.6366 10.5 11.4219V19.9531C10.5 20.7384 11.1467 21.375 11.9444 21.375ZM21.6944 13.1992C21.6944 13.9845 21.0477 14.6211 20.25 14.6211C19.4523 14.6211 18.8056 13.9845 18.8056 13.1992C18.8056 12.4139 19.4523 11.7773 20.25 11.7773C21.0477 11.7773 21.6944 12.4139 21.6944 13.1992Z",stroke:"#4A86E8","stroke-width":"1.5","stroke-linecap":"round","stroke-linejoin":"round"}))),t("button",{key:"caa33c6d18525872a4ee2d672bee04a549779499",class:"action-button send-button",onClick:this.handleSendMessage,disabled:this.disabled||!e,type:"button"},t("svg",{key:"c111af09449b62afeb754eb691abdeee59c092ce",xmlns:"http://www.w3.org/2000/svg",width:"17",height:"16",viewBox:"0 0 17 16",fill:"none"},t("path",{key:"c7a9328a8abe02f7aa16dbae45574639bc94eb37",d:"M14.214 2.28564L5.64258 9.14279L5.64258 13.1428L7.69972 10.6856",stroke:"#4A86E8","stroke-width":"1.5","stroke-miterlimit":"10"}),t("path",{key:"0e141532e3694d564b8eab7240fd80a2ce172a7c",d:"M2.78613 6.85707L14.2147 2.28564L11.929 13.7142L2.78613 6.85707Z",stroke:"#4A86E8","stroke-width":"1.5","stroke-miterlimit":"10","stroke-linecap":"square"})))))),t("input",{key:"ed2eb79d5e731a3c324943439f5fcc8cee484e66",ref:e=>this.fileInputRef=e,type:"file",accept:this.acceptFiles,multiple:!0,onChange:this.handleFileInputChange,style:{display:"none"}}),this.isDragOver&&t("div",{key:"7d1deb8bc1c5cceac823ea6aa08de5c81e412e3d",class:"drag-overlay"},t("div",{key:"c27aff7a27b17eb06c4b79f25901e2db7c11be69",class:"drag-content"},t("svg",{key:"13c7243782c1fb604113ec8e09a53cd44aabb1e4",xmlns:"http://www.w3.org/2000/svg",width:"48",height:"48",viewBox:"0 0 48 48",fill:"none"},t("path",{key:"0ac333bcd102668edcf034e559a75cbd64e7bdd8",d:"M38 20v16a4 4 0 0 1-4 4H14a4 4 0 0 1-4-4V20M32 10L24 2l-8 8M24 2v28",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"})),t("p",{key:"4addb3c7733503a556958fa9b46b2c520cc3bf5d"},"Dateien hier ziehen"))))}};l.style=":host{display:block;--rich-input-border-radius:12px;--rich-input-padding:4px;--attachment-item-radius:8px;--attachment-preview-size:60px;--min-input-height:18px;--max-input-height:120px;--transition-duration:0.2s}.rich-input-container{position:relative;background:var(--bg-primary, #ffffff);}.rich-input-container:focus-within{border-color:var(--accent-color, #4a86e8);box-shadow:0 0 0 2px rgba(74, 134, 232, 0.1)}.rich-input-container.drag-over{border-color:var(--accent-color, #4a86e8);background:var(--bg-light, #f8fafc)}.editor-area{padding:var(--rich-input-padding)}.editor-wrapper{display:flex;align-items:flex-end;gap:12px}.rich-editor{flex:1;min-height:var(--min-input-height);max-height:var(--max-input-height, 200px);overflow-y:auto;padding:12px 16px;border:none;outline:none;background:var(--bg-secondary, #f8f9fa);border-radius:20px;font-family:var(--font-primary, system-ui, sans-serif);font-size:14px;line-height:1.4;color:var(--text-primary, #212529);white-space:pre-wrap;word-wrap:break-word;resize:none;transition:background-color var(--transition-duration) ease}.rich-editor:focus{}@media (max-width: 768px){.rich-editor{font-size:16px}}.rich-editor:empty::before{content:attr(data-placeholder);color:var(--text-secondary, #6c757d);pointer-events:none}.rich-editor:focus:empty::before{content:''}.attachment-block{display:block;background:var(--bg-secondary, #f8f9fa);border:1px solid var(--border-light, #e9ecef);border-radius:var(--attachment-item-radius);padding:8px;margin:8px 0;max-width:300px;position:relative;box-sizing:border-box;user-select:none;-webkit-user-select:none}.attachment-block .attachment-content{display:flex;flex-direction:column;gap:8px;flex:1;min-width:0}.attachment-item{display:flex;align-items:center;gap:8px;position:relative;min-width:0}.attachment-block .attachment-thumbnail{width:var(--attachment-preview-size);height:var(--attachment-preview-size);object-fit:cover;border-radius:4px;flex-shrink:0}.attachment-item .attachment-thumbnail{width:var(--attachment-preview-size);height:var(--attachment-preview-size);object-fit:cover;border-radius:4px;flex-shrink:0}.attachment-block .attachment-icon{width:var(--attachment-preview-size);height:var(--attachment-preview-size);display:flex;align-items:center;justify-content:center;background:var(--bg-light, #f1f3f4);border-radius:4px;color:var(--text-secondary, #6c757d);flex-shrink:0}.attachment-item .attachment-icon{width:var(--attachment-preview-size);height:var(--attachment-preview-size);display:flex;align-items:center;justify-content:center;background:var(--bg-light, #f1f3f4);border-radius:4px;color:var(--text-secondary, #6c757d);flex-shrink:0}.attachment-block .attachment-info{flex:1;min-width:0}.attachment-item .attachment-info{flex:1;min-width:0}.attachment-block .attachment-name{font-size:12px;font-weight:500;color:var(--text-primary, #212529);white-space:nowrap;overflow:hidden;text-overflow:ellipsis;line-height:1.3}.attachment-item .attachment-name{font-size:12px;font-weight:500;color:var(--text-primary, #212529);white-space:nowrap;overflow:hidden;text-overflow:ellipsis;line-height:1.3}.attachment-block .attachment-size{font-size:11px;color:var(--text-secondary, #6c757d);line-height:1.2}.attachment-item .attachment-size{font-size:11px;color:var(--text-secondary, #6c757d);line-height:1.2}.attachment-block .attachment-remove{position:absolute;top:-6px;right:-6px;width:20px;height:20px;border:none;background:var(--bg-primary, #ffffff);border-radius:50%;display:flex;align-items:center;justify-content:center;cursor:pointer;box-shadow:0 2px 4px rgba(0, 0, 0, 0.1);color:var(--text-secondary, #6c757d);transition:all var(--transition-duration) ease}.attachment-item .attachment-remove{position:absolute;top:-6px;right:-6px;width:20px;height:20px;border:none;background:var(--bg-primary, #ffffff);border-radius:50%;display:flex;align-items:center;justify-content:center;cursor:pointer;box-shadow:0 2px 4px rgba(0, 0, 0, 0.1);color:var(--text-secondary, #6c757d);transition:all var(--transition-duration) ease}.attachment-block .attachment-remove:hover{background:#dc3545;color:white;transform:scale(1.1)}.attachment-item .attachment-remove:hover{background:#dc3545;color:white;transform:scale(1.1)}.rich-editor::-webkit-scrollbar{width:4px}.rich-editor::-webkit-scrollbar-track{background:transparent}.rich-editor::-webkit-scrollbar-thumb{background:var(--border-color, #dee2e6);border-radius:2px}.rich-editor::-webkit-scrollbar-thumb:hover{background:var(--text-secondary, #6c757d)}.input-actions{display:flex;flex-direction:row;align-items:flex-end;gap:2px}.action-button{width:36px;height:36px;border:none;background:transparent;border-radius:18px;cursor:pointer;display:flex;align-items:center;justify-content:center;color:var(--accent-color, #4a86e8);transition:all var(--transition-duration) ease;flex-shrink:0}.action-button:hover:not(:disabled){background:var(--bg-light, #f1f3f4);transform:scale(1.05)}.action-button:disabled{color:var(--text-secondary, #6c757d);cursor:not-allowed;opacity:0.5}.send-button:not(:disabled){color:white}.send-button:hover:not(:disabled){background:var(--accent-hover, #3d71d9)}.drag-overlay{position:absolute;top:0;left:0;right:0;bottom:0;background:rgba(74, 134, 232, 0.05);border:2px dashed var(--accent-color, #4a86e8);border-radius:var(--rich-input-border-radius);display:flex;align-items:center;justify-content:center;z-index:10}.drag-content{text-align:center;color:var(--accent-color, #4a86e8)}.drag-content svg{margin-bottom:8px}.drag-content p{margin:0;font-size:14px;font-weight:500}@media (max-width: 768px){:host{--rich-input-padding:12px;--attachment-preview-size:48px}.attachment-block{max-width:260px}.action-button{width:32px;height:32px}}";const f=class{constructor(t){e(this,t)}content;downloadUrls={};alignment="left";translations={};attachmentStates={};MAX_RETRIES=3;INITIAL_RETRY_DELAY_MS=1e3;FETCH_TIMEOUT_MS=5e3;initAttachmentState(e){this.attachmentStates[e]||(this.attachmentStates={...this.attachmentStates,[e]:{isLoading:!1,retryCount:0,hasError:!1}})}async handleImageError(e,t,a){this.initAttachmentState(e);const i=this.attachmentStates[e];if(console.log("handleImageError",e,i),!t.startsWith("image/")||i.retryCount>=this.MAX_RETRIES)return this.attachmentStates={...this.attachmentStates,[e]:{...i,isLoading:!1,hasError:!0}},void(a.src=this.getPlaceholderIcon(t));const n=this.downloadUrls[e];if(!n)return this.attachmentStates={...this.attachmentStates,[e]:{...i,isLoading:!1,hasError:!0}},void(a.src=this.getPlaceholderIcon(t));try{const o=new AbortController,s=setTimeout((()=>o.abort()),this.FETCH_TIMEOUT_MS);try{const r=await fetch(n.download_url,{method:"HEAD",signal:o.signal});if(clearTimeout(s),console.debug("HEAD response",r),404===r.status){this.attachmentStates={...this.attachmentStates,[e]:{...i,isLoading:!0,retryCount:i.retryCount+1}};const t=this.INITIAL_RETRY_DELAY_MS*Math.pow(2,i.retryCount);await new Promise((e=>setTimeout(e,t))),this.attachmentStates={...this.attachmentStates,[e]:{...this.attachmentStates[e],isLoading:!1}};const o=new URL(n.download_url);o.searchParams.set("retry",String(Date.now())),a.src=o.toString()}else this.attachmentStates={...this.attachmentStates,[e]:{...i,isLoading:!1,hasError:!0}},a.src=this.getPlaceholderIcon(t)}catch(n){clearTimeout(s),this.attachmentStates={...this.attachmentStates,[e]:{...i,isLoading:!1,hasError:!0}},a.src=this.getPlaceholderIcon(t)}}catch(n){this.attachmentStates={...this.attachmentStates,[e]:{...i,isLoading:!1,hasError:!0}},a.src=this.getPlaceholderIcon(t)}}renderLoadingSpinner(){return t("div",{class:"loading-spinner"},t("svg",{width:"24",height:"24",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg"},t("circle",{class:"spinner-circle",cx:"12",cy:"12",r:"10",fill:"none",stroke:"#6b7280","stroke-width":"2"})))}defaultTranslations={unsupported_content:"Unsupported content"};t(e){return this.translations[e]||this.defaultTranslations[e]||e}renderPlainText(e){const a=e.split("\n"),i=[];return a.forEach(((e,n)=>{e&&i.push(e),n<a.length-1&&i.push(t("br",null))})),i}renderTextBlock(e){return e.content?t("p",null,this.renderPlainText(String(e.content))):null}renderUnknownBlock(e){return"string"==typeof e?.fallback_text&&e.fallback_text.length>0?t("p",null,this.renderPlainText(e.fallback_text)):t("p",{class:"unsupported-content"},this.t("unsupported_content"))}blockRenderers={text:e=>this.renderTextBlock(e),attachment:e=>this.renderAttachmentBlock(e)};generateThumbnail(e,t){const a=this.downloadUrls[e];return console.debug("generateThumbnail",{downloadUrls:this.downloadUrls,attachmentId:e,downloadInfo:a}),a&&a.mime_type.startsWith("image/")?a.download_url:this.getPlaceholderIcon(t)}getPlaceholderIcon(e){const t="#6b7280";return e.startsWith("image/")?`data:image/svg+xml,${encodeURIComponent(`\n <svg width="48" height="48" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">\n <rect x="3" y="3" width="18" height="18" rx="2" ry="2" stroke="${t}" stroke-width="2" fill="none"/>\n <circle cx="8.5" cy="8.5" r="1.5" fill="${t}"/>\n <polyline points="21,15 16,10 5,21" stroke="${t}" stroke-width="2" fill="none"/>\n </svg>\n `)}`:e.includes("pdf")?`data:image/svg+xml,${encodeURIComponent(`\n <svg width="48" height="48" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">\n <path d="M14,2H6A2,2 0 0,0 4,4V20A2,2 0 0,0 6,22H18A2,2 0 0,0 20,20V8L14,2M18,20H6V4H13V9H18V20Z" fill="${t}"/>\n </svg>\n `)}`:`data:image/svg+xml,${encodeURIComponent(`\n <svg width="48" height="48" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">\n <path d="M14,2H6A2,2 0 0,0 4,4V20A2,2 0 0,0 6,22H18A2,2 0 0,0 20,20V8L14,2M18,20H6V4H13V9H18V20Z" stroke="${t}" stroke-width="2" fill="none"/>\n <polyline points="14,2 14,8 20,8" stroke="${t}" stroke-width="2" fill="none"/>\n </svg>\n `)}`}renderAttachmentBlock(e){if(!e.attachments||0===e.attachments.length)return null;const a=e.attachments.map((e=>{const a=this.generateThumbnail(e.id,e.mime_type),i=this.downloadUrls[e.id];this.initAttachmentState(e.id);const n=this.attachmentStates[e.id];return t("div",{class:"attachment-item",key:e.id},t("div",{class:"attachment-thumbnail"},e.mime_type.startsWith("image/")?t("div",{class:"image-container"},t("img",{src:a,alt:"Image attachment",onError:t=>{this.handleImageError(e.id,e.mime_type,t.target)},style:{display:n.isLoading?"none":"block"}}),n.isLoading&&this.renderLoadingSpinner()):t("img",{src:a,alt:"File attachment"})),i&&t("div",{class:"attachment-overlay"},t("a",{href:i.download_url,target:"_blank",rel:"noopener noreferrer"},t("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},t("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",stroke:"white","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"}),t("polyline",{points:"7,10 12,15 17,10",stroke:"white","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"}),t("line",{x1:"12",y1:"15",x2:"12",y2:"3",stroke:"white","stroke-width":"2","stroke-linecap":"round"})))))}));return t("p",null,t("div",{class:"attachment-container"},a))}render(){if(!this.content||!this.content.blocks)return t("div",{class:`rich-message-content ${this.alignment}`});const e=this.content.blocks.map((e=>{const t=Object.prototype.hasOwnProperty.call(this.blockRenderers,e?.type)?this.blockRenderers[e.type]:void 0;return t?t(e):this.renderUnknownBlock(e)}));return t("div",{class:`rich-message-content ${this.alignment}`},e)}};f.style=":host{display:block}.rich-message-content{width:100%}.rich-message-content.left{text-align:left}.rich-message-content.right{text-align:right}.rich-message-content p{margin:0.5em 0;line-height:1.4}.rich-message-content p:first-child{margin-top:0}.rich-message-content p:last-child{margin-bottom:0}.attachment-container{display:flex;gap:8px;overflow-x:auto;padding:4px 0;scrollbar-width:thin}.attachment-container::-webkit-scrollbar{height:4px}.attachment-container::-webkit-scrollbar-track{background:#f1f1f1;border-radius:2px}.attachment-container::-webkit-scrollbar-thumb{background:#c1c1c1;border-radius:2px}.attachment-container::-webkit-scrollbar-thumb:hover{background:#a8a8a8}.attachment-item{position:relative;flex-shrink:0;width:80px;height:80px;border-radius:8px;overflow:hidden;background-color:#f5f5f5;border:1px solid #e5e5e5;cursor:pointer;transition:transform 0.2s ease, box-shadow 0.2s ease}.attachment-item:hover{transform:scale(1.05);box-shadow:0 4px 8px rgba(0, 0, 0, 0.1)}.attachment-thumbnail{width:100%;height:100%;display:flex;align-items:center;justify-content:center}.attachment-thumbnail img{width:100%;height:100%;object-fit:cover;border-radius:7px}.image-container{width:100%;height:100%;display:flex;align-items:center;justify-content:center;position:relative}.loading-spinner{display:flex;align-items:center;justify-content:center;width:100%;height:100%}.spinner-circle{animation:spin 1s linear infinite;transform-origin:center;stroke-dasharray:50;stroke-dashoffset:0}@keyframes spin{0%{transform:rotate(0deg);stroke-dashoffset:0}50%{stroke-dashoffset:25}100%{transform:rotate(360deg);stroke-dashoffset:50}}.attachment-overlay{position:absolute;top:0;left:0;right:0;bottom:0;background:rgba(0, 0, 0, 0.3);display:flex;align-items:center;justify-content:center;opacity:0;transition:opacity 0.2s ease;border-radius:7px}.attachment-item:hover .attachment-overlay{opacity:1}.attachment-overlay a{display:flex;align-items:center;justify-content:center;width:32px;height:32px;background:rgba(0, 0, 0, 0.6);border-radius:50%;text-decoration:none;transition:background 0.2s ease}.attachment-overlay a:hover{background:rgba(0, 0, 0, 0.8)}.rich-message-content.right .attachment-container{justify-content:flex-end}";const p=class{constructor(t){e(this,t)}rooms=[];chatStore;selectedRoomId;_version=0;isNewChatOpen=!1;onChatStoreChange(e,t){e&&(e.addEventListener("presenceChanged",this.onPresenceChange.bind(this)),e.addEventListener("roomReadCountChanged",(()=>{this._version++})),e.addEventListener("callChanged",(()=>{this._version++})))}onPresenceChange(){console.debug("onPresenceChange"),this._version++}toggleNewChat=e=>{e.preventDefault(),this.isNewChatOpen=!this.isNewChatOpen};closeNewChat=()=>{this.isNewChatOpen=!1};onUserSelected(){this.isNewChatOpen=!1}renderHeader(){return t("div",{class:"room-list-header"},t("span",{class:"room-list-title"},"Nachrichten"),t("button",{class:"new-chat-btn",type:"button",title:"Neue Nachricht","aria-label":"Neue Nachricht",onClick:this.toggleNewChat},t("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 16 16",fill:"none"},t("path",{d:"M8 3V13",stroke:"currentColor","stroke-width":"1.5","stroke-linecap":"round"}),t("path",{d:"M3 8H13",stroke:"currentColor","stroke-width":"1.5","stroke-linecap":"round"}))))}render(){return t("div",{key:"089d5a42173af13d39cb150ff87af731239d481a",class:"room-list-container"},this.renderHeader(),this.isNewChatOpen?t("chatleo-new-message-selector",{chatStore:this.chatStore,onDoClose:this.closeNewChat}):t("div",{class:"room-list"},this.rooms?.map((e=>{const a=e.participantIdsWithoutSelf?.filter((e=>this.chatStore?.isOnline(e)))??[],i=this.selectedRoomId===e.id;return t("div",{style:{padding:"6px 4px"},class:i?"active":""},t("chatleo-room-tile-component",{room:e,chatStore:this.chatStore,onlineUserIds:a,lastMessage:void 0,timestamp:void 0,unreadCount:e.unreadCount,isActive:i}))})),!this.rooms?.length&&t("div",{class:"room-list-empty"},t("p",null,"Noch keine Unterhaltungen"),t("button",{class:"empty-new-chat-btn",type:"button",onClick:this.toggleNewChat},"Neue Nachricht"))))}static get watchers(){return{chatStore:[{onChatStoreChange:0}]}}};p.style=":host{--room-list-width:250px;display:flex;flex-direction:column;max-height:100%;min-height:0;overflow:hidden}.room-list-container{display:flex;flex-direction:column;flex:1;min-height:0;min-width:var(--room-list-width);overflow:hidden}.room-list-header{display:flex;align-items:center;justify-content:space-between;gap:8px;padding:12px 16px;border-bottom:1px solid var(--border-light);flex-shrink:0;font-family:var(--font-primary), sans-serif}.room-list-title{font-weight:700;font-size:16px;color:var(--text-primary, #171A1F)}.new-chat-btn{display:flex;align-items:center;justify-content:center;width:28px;height:28px;border:1px solid var(--border-light);border-radius:6px;background:transparent;cursor:pointer;padding:0;margin:0;flex:0 0 auto;color:#565D6D}.new-chat-btn:hover{color:var(--text-primary, #171A1F);background-color:var(--hover-color, #f3f4f6)}.room-list{min-width:var(--room-list-width);max-height:100%;max-width:100%;display:flex;flex-direction:column;overflow-y:auto;overflow-x:hidden;font-family:var(--font-primary), sans-serif;min-height:0;flex:1}.room-list-empty{display:flex;flex-direction:column;align-items:flex-start;gap:8px;padding:16px;font-family:var(--font-primary), sans-serif;color:var(--text-secondary, #565D6D)}.room-list-empty p{margin:0;font-size:14px}.empty-new-chat-btn{border:1px solid var(--border-light);background:transparent;color:var(--text-primary, #171A1F);border-radius:var(--border-radius, 6px);padding:6px 12px;cursor:pointer;font-size:14px}.empty-new-chat-btn:hover{background-color:var(--hover-color, #f3f4f6)}.active{background-color:var(--bg-secondary, #f0f0f0)}.room-list>*{flex-shrink:0}chatleo-new-message-selector{flex:1;min-height:0;overflow-y:auto}";const g=class{constructor(t){e(this,t),this.roomClicked=a(this,"roomClicked")}room;chatStore;onlineUserIds;lastMessage;timestamp;unreadCount;isActive=!1;roomClicked;onClick(){console.log("Room clicked",this.room.id),this.roomClicked.emit({id:this.room.id})}render(){const e=this.onlineUserIds.includes(this.room.participantIdsWithoutSelf[0]),a=this.chatStore?.users.find((e=>e.id===this.room.participantIdsWithoutSelf[0]))?.profile_picture_url,i=this.isActive?"room-tile active":"room-tile",n=this.chatStore?.activeCall(this.room.id);return t("div",{key:"2f667c91928a5dc65554d2204372b322b0e43272",class:i,onClick:()=>this.onClick()},t("chatleo-avatar",{key:"2b072a48103fad1cfe23a0eec2c18645572e8071",name:this.room.name,url:a,isOnline:e}),t("div",{key:"bfb0d3b61dbd0bc816b8c0c578e04c622214a3ad",class:"room-content"},t("div",{key:"2ce0fda6bcd7af24a8bb823f7ba75329449239cf",class:"room-header"},t("h3",{key:"fa5ed3dd1401c147f2996bc93bed06d8f096a521",class:"room-name"},this.room.name),t("span",{key:"308d082b266a01fad292839ae69c4edd0a21d1bb",class:"timestamp"},this.timestamp??"")),t("div",{key:"f7b3206df5b8f9870ff358f693d4600fb21302d4",class:"room-footer"},t("p",{key:"a69f70a6b237b7e0c1f5776627f7ffd3ed16685d",class:"last-message"},n?"Call in progress":this.lastMessage??" "),n&&t("span",{key:"03e324140c78c3bce371fd14725eca835596a600",class:"call-marker",title:"Call in progress"},"Call"),this.room.isReadOnly?t("span",{class:"read-only-badge"},"Read only"):this.unreadCount>0&&t("span",{class:"unread-count"},this.unreadCount))))}};g.style=":host{--room-name-size:16px;--timestamp-size:12px;--message-size:14px;--unread-size:12px;--room-name-weight:600;--unread-weight:600;--room-margin:4px;--room-spacing:8px;--unread-padding:2px 8px;--unread-radius:10px;--unread-min-width:20px;display:block}.room-tile{display:flex;align-items:center;cursor:pointer;transition:background-color var(--transition-duration) ease}.room-tile.active{background-color:var(--bg-secondary, #f0f0f0)}.room-content{padding-left:var(--room-spacing);flex:1;min-width:0}.room-header{display:flex;align-items:center;justify-content:space-between;margin-bottom:var(--room-margin)}.room-name{font-size:var(--room-name-size);font-weight:var(--room-name-weight);margin:0;color:var(--text-primary);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.timestamp{font-size:var(--timestamp-size);color:var(--text-secondary);flex-shrink:0;margin-left:var(--room-spacing)}.room-footer{display:flex;align-items:center;justify-content:space-between}.last-message{font-size:var(--message-size);color:var(--text-secondary);margin:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;flex:1}.read-only-badge{font-size:var(--timestamp-size);color:var(--text-secondary);flex-shrink:0;margin-left:var(--room-spacing)}.unread-count{background-color:var(--accent-color);color:white;font-size:0.7rem;line-height:1;text-align:center;display:flex;justify-content:center;align-items:center;width:1rem;height:1rem;border-radius:50%;overflow:hidden;flex-shrink:0}.call-marker{margin-left:6px;padding:1px 6px;border-radius:999px;background:#1b8a3a;color:#fff;font-size:10px;font-weight:700;text-transform:uppercase}";const m=class{constructor(t){e(this,t),this.callRequested=a(this,"callRequested"),this.messageChatSent=a(this,"messageChatSent")}chatStore;roomId;isOnline=!1;pending=!1;callsAvailable=!1;inCall=!1;callRequested;_version=0;messagesContainerRef;richInputRef;resizeObserver;stickToBottom=!0;lastMessageCount=-1;boundRoomAddedHandler;boundRoomMessageAddedHandler;boundRoomMessageChangedHandler;boundPresenceChangedHandler;loadingOlder=!1;olderExhausted=!1;previousScrollHeight=0;previousScrollTop=0;restoreScrollAfterRender=!1;onChatStoreChange(e,t){console.debug("ChatleoRoomView.onChatStoreChange",e,t),t&&(this.boundRoomAddedHandler&&t.removeEventListener("roomAdded",this.boundRoomAddedHandler),this.boundRoomMessageAddedHandler&&t.removeEventListener("roomMessageAdded",this.boundRoomMessageAddedHandler),this.boundRoomMessageChangedHandler&&(t.removeEventListener("roomMessageUpdated",this.boundRoomMessageChangedHandler),t.removeEventListener("roomMessageRemoved",this.boundRoomMessageChangedHandler)),this.boundPresenceChangedHandler&&t.removeEventListener("presenceChanged",this.boundPresenceChangedHandler)),e&&(this.boundRoomAddedHandler=e=>{console.debug("roomAdded",e),this._version++},this.boundRoomMessageAddedHandler=e=>{console.debug("roomMessageAdded",e),this._version++},this.boundRoomMessageChangedHandler=e=>{console.debug("roomMessageChanged",e),this._version++},this.boundPresenceChangedHandler=e=>{console.debug("onPresenceChange",e),this._version++},e.addEventListener("roomAdded",this.boundRoomAddedHandler),e.addEventListener("roomMessageAdded",this.boundRoomMessageAddedHandler),e.addEventListener("roomMessageUpdated",this.boundRoomMessageChangedHandler),e.addEventListener("roomMessageRemoved",this.boundRoomMessageChangedHandler),e.addEventListener("presenceChanged",this.boundPresenceChangedHandler),this.roomId&&(e.setActiveRoomId(this.roomId),e.markRoomAsRead(this.roomId)))}disconnectedCallback(){this.resizeObserver?.disconnect(),this.resizeObserver=void 0,this.chatStore&&(this.boundRoomAddedHandler&&this.chatStore.removeEventListener("roomAdded",this.boundRoomAddedHandler),this.boundRoomMessageAddedHandler&&this.chatStore.removeEventListener("roomMessageAdded",this.boundRoomMessageAddedHandler),this.boundRoomMessageChangedHandler&&(this.chatStore.removeEventListener("roomMessageUpdated",this.boundRoomMessageChangedHandler),this.chatStore.removeEventListener("roomMessageRemoved",this.boundRoomMessageChangedHandler)),this.boundPresenceChangedHandler&&this.chatStore.removeEventListener("presenceChanged",this.boundPresenceChangedHandler))}onRoomIdChanged(){this.lastMessageCount=-1,this.olderExhausted=!1,this.loadingOlder=!1,this.restoreScrollAfterRender=!1,this.roomId&&(this.chatStore?.setActiveRoomId(this.roomId),this.chatStore?.markRoomAsRead(this.roomId))}componentDidLoad(){this.roomId&&(this.chatStore?.setActiveRoomId(this.roomId),this.chatStore?.markRoomAsRead(this.roomId)),"undefined"!=typeof ResizeObserver&&this.messagesContainerRef&&!this.resizeObserver&&(this.resizeObserver=new ResizeObserver((()=>{this.stickToBottom&&this.scrollToBottom()})),this.resizeObserver.observe(this.messagesContainerRef))}async getDraft(){return await(this.richInputRef?.getText?.())??""}async setDraft(e){await(this.richInputRef?.setText?.(e??""))}async addFiles(e){await(this.richInputRef?.addFiles?.(e??[]))}async focusComposer(){await(this.richInputRef?.focusEditor?.())}messageRetryHandler(e){this.roomId&&e.detail&&this.chatStore?.retryMessage(this.roomId,e.detail)}requestCall(){if(!this.roomId)return;const e=this.chatStore?.activeCall(this.roomId);this.callRequested.emit({roomId:this.roomId,callId:e?.id})}messageDiscardHandler(e){this.roomId&&e.detail&&this.chatStore?.discardMessage(this.roomId,e.detail)}messageChatSent;messageSendHandler(e){if(!this.roomId)return void console.warn("ChatleoRoomView: Cannot send message without roomId");e.stopPropagation(),console.log("Received the messageSend event: ",JSON.stringify(e.detail));const t=(e.detail?.blocks??[]).map((e=>{if("attachment"===e?.type&&Array.isArray(e.attachments)){const t=e.attachments.map((e=>{const{preview:t,...a}=e??{};return a}));return{...e,attachments:t}}return e}));this.messageChatSent.emit({room_id:this.roomId,content:{blocks:t,version:e.detail.version},content_type:"application/json+blocks",sender:this.chatStore?.profile?.id})}scrollToBottom(){if(this.messagesContainerRef)try{this.messagesContainerRef.scrollTop=this.messagesContainerRef.scrollHeight,this.stickToBottom=!0}catch(e){}}scrollToBottomNextTick(){requestAnimationFrame((()=>this.scrollToBottom()))}async onMessagesScroll(){if(!this.roomId||!this.chatStore||!this.messagesContainerRef)return;const e=this.messagesContainerRef;if(this.stickToBottom=e.scrollTop+e.clientHeight>=e.scrollHeight-24,this.loadingOlder||this.olderExhausted)return;if(e.scrollTop>40)return;this.loadingOlder=!0,this.previousScrollHeight=this.messagesContainerRef.scrollHeight,this.previousScrollTop=this.messagesContainerRef.scrollTop;const t=this.chatStore.roomMessages(this.roomId).length;try{const e=await this.chatStore.loadOlderMessages(this.roomId),a=this.chatStore.roomMessages(this.roomId).length;a>t&&(this.restoreScrollAfterRender=!0),e||a!==t||(this.olderExhausted=!0)}finally{this.loadingOlder=!1}}componentDidRender(){if(this.pending)return;if(!this.roomId)return;const e=(this.chatStore?.roomMessages(this.roomId)??[]).length;if(this.restoreScrollAfterRender&&this.messagesContainerRef)return this.messagesContainerRef.scrollTop=this.previousScrollTop+Math.max(0,this.messagesContainerRef.scrollHeight-this.previousScrollHeight),this.restoreScrollAfterRender=!1,void(this.lastMessageCount=e);e!==this.lastMessageCount&&(this.scrollToBottomNextTick(),this.lastMessageCount=e)}render(){const e=n(this.chatStore?.roomMessages(this.roomId)??[]),a=this.chatStore?.rooms.find((e=>e.id===this.roomId)),i=a?.isReadOnly??!1;return console.debug("ChatleoRoomView.render",e),t("div",{key:"3eb9ef978132245f3f6d41299123021f4a32d55b",class:"chat-container-chat"},t("div",{key:"6bbc3f4dbdd677fcc227550627eb939af7ec17b8",class:"chat-container-header-container"},t("chatleo-chat-header",{key:"1a17709cc4e699fdb3fcd40e39bad9d8f105fef9",name:this.chatStore?.profile?.display_name,avatar:this.chatStore?.profile?.profile_picture_url??void 0,isOnline:this.isOnline})),this.callsAvailable&&this.roomId&&t("div",{key:"a9696dd64448fcee1d47ea7559dd80a7993e33d0",class:"call-bar"},this.chatStore?.activeCall(this.roomId)&&!this.inCall?t("span",{class:"call-banner"},"direct"===this.chatStore?.activeCall(this.roomId)?.mode?"Call in progress":"Group call in progress"):null,t("button",{key:"40cf2f4c7d7d1dfd9e1ebe57a9e315e1ff884d22",type:"button",class:"call-button",onClick:()=>this.requestCall()},this.inCall?"Call running":this.chatStore?.activeCall(this.roomId)?"Join call":"DirectMessage"===this.chatStore?.rooms.find((e=>e.id===this.roomId))?.type?"Call":"Start call")),this.pending?t("div",{class:"messages-container"},t("div",null,"Loading chat...")):t("div",{class:"messages-container",ref:e=>this.messagesContainerRef=e,onScroll:()=>this.onMessagesScroll()},Object.entries(e).sort((([e],[t])=>new Date(e).getTime()-new Date(t).getTime())).map((([e,a])=>t("div",{class:"message-group"},t("div",{class:"date-separator"},e),a.map((e=>t("chatleo-chat-message",{message:e,sender:this.chatStore?.usernameResolver(e.sender_id),senderIsOnline:e.sender_id===this.chatStore?.profile.id?this.chatStore?.isConnected:this.chatStore?.isOnline(e.sender_id),isOwnMessage:e.sender_id===this.chatStore?.profile.id,translations:{you:this.chatStore?.usernameResolver(e.sender_id)?.display_name}}))))))),!i&&t("div",{key:"42592e707c67d41114596fdcf654631c2f39ee6e",class:"rich-input-container-wrapper"},t("chatleo-rich-input",{key:"2a4fd69962ca7c2ac3c0ded1f5b46088855d9cea",ref:e=>this.richInputRef=e,disabled:!this.roomId,placeholder:"Nachricht schreiben"})))}static get watchers(){return{chatStore:[{onChatStoreChange:0}],roomId:[{onRoomIdChanged:0}]}}};m.style=":host{display:flex;flex-direction:column;max-height:100%;min-height:0;overflow:hidden}.chat-container-chat{display:flex;flex-direction:column;height:100%;width:100%;font-family:var(--font-primary), sans-serif;min-height:0;overflow:hidden;}chatleo-chat-header{flex:0 0 auto;display:block}.chat-container-header-container{flex:0 0 auto;border-bottom:1px solid var(--border-light)}.rich-input-container-wrapper{flex:0 0 auto;padding-top:2px}.messages-container{display:block;flex:1 1 auto;min-height:0;overflow-y:auto;overflow-x:hidden;padding-right:12px;overscroll-behavior:contain;scrollbar-gutter:stable;max-width:100%;border-bottom:1px solid var(--border-light);}.message-group{display:flex;flex-direction:column;gap:16px}.date-separator{text-align:center;font-family:var(--font-primary), sans-serif;font-weight:400;font-size:12px;line-height:1.65;color:var(--text-secondary)}.call-bar{display:flex;align-items:center;justify-content:flex-end;gap:8px;padding:6px 16px;border-bottom:1px solid var(--border-light)}.call-banner{margin-right:auto;font-size:12px;color:var(--text-secondary)}.call-button{border:1px solid var(--accent-color, #4a86e8);background:transparent;color:var(--accent-color, #4a86e8);border-radius:var(--border-radius, 6px);padding:4px 10px;font:inherit;font-size:12px;cursor:pointer}.call-button:hover{background:color-mix(in srgb, var(--accent-color, #4a86e8) 10%, transparent)}";const b=class{constructor(t){e(this,t),this.newChatClicked=a(this,"newChatClicked"),this.messageChatSent=a(this,"messageChatSent")}chatStore;isChatOpen=!1;isNewChatSelectorOpen=!1;isMessagesOpen=!1;selectedRoomId;isPending=!1;_version=0;isSessionExpired=!1;connectionStatus="disconnected";messagesContainerRef;lastMessageCount=-1;boundOnPresenceChange=()=>this.onPresenceChange();boundOnRoomMessageAdded=e=>this.onRoomMessageAdded(e);boundOnSessionExpiredChanged=e=>this.onSessionExpiredChanged(e);boundOnConnectionStatusChanged=e=>this.onConnectionStatusChanged(e);boundOnRoomReadCountChanged=()=>{this._version++};onChatStoreChange(e,t){t&&(t.removeEventListener("presenceChanged",this.boundOnPresenceChange),t.removeEventListener("roomMessageAdded",this.boundOnRoomMessageAdded),t.removeEventListener("sessionExpiredChanged",this.boundOnSessionExpiredChanged),t.removeEventListener("connectionStatusChanged",this.boundOnConnectionStatusChanged),t.removeEventListener("roomReadCountChanged",this.boundOnRoomReadCountChanged)),e&&(e.addEventListener("presenceChanged",this.boundOnPresenceChange),e.addEventListener("roomMessageAdded",this.boundOnRoomMessageAdded),e.addEventListener("sessionExpiredChanged",this.boundOnSessionExpiredChanged),e.addEventListener("connectionStatusChanged",this.boundOnConnectionStatusChanged),this.isSessionExpired=e.isSessionExpired,this.connectionStatus=e.connectionStatus,e.addEventListener("roomReadCountChanged",this.boundOnRoomReadCountChanged))}onSelectedRoomIdChanged(){this.lastMessageCount=-1,this._version++,this.chatStore?.setActiveRoomId(this.selectedRoomId??null)}onPresenceChange(){console.debug("onPresenceChange"),this._version++}onRoomMessageAdded(e){console.debug("onRoomMessageAdded",e),this._version++,this.isMessagesOpen&&e.detail?.roomId===this.selectedRoomId&&this.chatStore?.markRoomAsRead(this.selectedRoomId)}onSessionExpiredChanged(e){this.isSessionExpired=e.detail.isSessionExpired,this.isSessionExpired&&(this.isChatOpen=!0)}onConnectionStatusChanged(e){this.connectionStatus=e.detail.status}toggleChat=()=>{this.isChatOpen=!this.isChatOpen,this._version++};newChatClicked;onNewChatClicked(){this.isNewChatSelectorOpen?this.isNewChatSelectorOpen=!1:(this.isNewChatSelectorOpen=!0,this.isMessagesOpen=!1,this.newChatClicked.emit())}onUserSelected=()=>{this.isNewChatSelectorOpen=!1};onSelectorClose=()=>{this.isNewChatSelectorOpen=!1};roomClickedHandler(e){console.log("Received the roomClicked event: ",e.detail),this.isNewChatSelectorOpen=!1,this.isMessagesOpen=!0,this.selectedRoomId=e.detail.id,this.chatStore?.markRoomAsRead(e.detail.id)}messageChatSent;messageSendHandler(e){console.log("Received the messageSend event: ",JSON.stringify(e.detail));const t=(e.detail?.blocks??[]).map((e=>{if("attachment"===e?.type&&Array.isArray(e.attachments)){const t=e.attachments.map((e=>{const{preview:t,...a}=e??{};return a}));return{...e,attachments:t}}return e}));this.messageChatSent.emit({room_id:this.selectedRoomId,content:{blocks:t,version:e.detail.version},content_type:"application/json+blocks",sender:this.chatStore?.profile?.id})}async openChatPanel(e,t=!1){console.debug(`openChatPanel ${e} ${t}`),this.selectedRoomId=e,this.isPending=t,this.isChatOpen=!1,this.isMessagesOpen=!0,e&&this.chatStore?.markRoomAsRead(e),this._version++}onDoClose(e){e.preventDefault(),this.isMessagesOpen=!1}scrollToBottom(){if(this.messagesContainerRef)try{this.messagesContainerRef.scrollTop=this.messagesContainerRef.scrollHeight}catch(e){}}scrollToBottomNextTick(){requestAnimationFrame((()=>{this.scrollToBottom()}))}componentDidRender(){if(!this.isMessagesOpen||!this.selectedRoomId)return;const e=(this.chatStore?.roomMessages(this.selectedRoomId)??[]).length;e!==this.lastMessageCount&&(this.scrollToBottomNextTick(),this.lastMessageCount=e)}render(){const e=n(this.chatStore?.roomMessages(this.selectedRoomId)??[]);return t("div",{key:"16d13ecf2c8d78c822b66ee140fdf3aedb03d1fa",class:"tray-container"},t("div",{key:"2087230f83fa231255a127bcf25935c96bb5a89d",class:this.isNewChatSelectorOpen?"selector-panel open":"selector-panel"},t("chatleo-new-message-selector",{key:"346f747952e4c2d3872db97adfd9fab7434526cf",chatStore:this.chatStore,onUserSelected:this.onUserSelected,onDoClose:this.onSelectorClose})),t("div",{key:"245326a45ffdea0c3c8a8507a449391635576c95",class:this.isMessagesOpen?"messages-panel open":"messages-panel"},t("div",{key:"b5b82048cbee06bdb73967c2ff342d4bad66a89a",class:"messages-container-header-closer"},t("button",{key:"0196b861999831d834df3407cc5c350fba9338f9",class:"close-button",onClick:this.onDoClose.bind(this)},t("svg",{key:"1db85ebbbb9291ecd8674d25a063bcbe215bd6d0",width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg"},t("path",{key:"d5f23bc40608fac8577860d6ff03e0e5c47e26cf",d:"M12 4L4 12",stroke:"#565D6D","stroke-width":"1.37143","stroke-miterlimit":"10","stroke-linecap":"square"}),t("path",{key:"6f27dd8b4a9969dd19bdae6059cad74d5e466d6f",d:"M12 12L4 4",stroke:"#565D6D","stroke-width":"1.37143","stroke-miterlimit":"10","stroke-linecap":"square"})))),t("chatleo-chat-header",{key:"d4320c822ed8ed5e4472c91a8c03508137bb3985",name:this.chatStore?.profile?.display_name,avatar:this.chatStore?.profile?.profile_picture_url??"https://placehold.co/48x48?text=AV",isOnline:this.chatStore?.isConnected}),t("div",{key:"ffb54f65c17f3ecf51f661aaa2cd1777d57e2468",class:"messages-container",ref:e=>this.messagesContainerRef=e},Object.entries(e).sort((([e],[t])=>new Date(e).getTime()-new Date(t).getTime())).map((([e,a])=>t("div",{class:"message-group"},t("div",{class:"date-separator"},e),a.map((e=>t("chatleo-chat-message",{message:e,sender:this.chatStore?.usernameResolver(e.sender_id),isOwnMessage:e.sender_id===this.chatStore?.profile.id,translations:{you:this.chatStore?.usernameResolver(e.sender_id)?.display_name}}))))))),t("chatleo-rich-input",{key:"5db7ffd32df847bbe103659d4f8ededfcc3105b2",disabled:!this.selectedRoomId,placeholder:"Nachricht schreiben"})),t("div",{key:"a4374b9f51b6f4f528ca0099df022272d41e8062",id:"chats",class:this.isChatOpen?"chat-panel open":"chat-panel"},this.isSessionExpired&&t("div",{key:"77f04c709823b47590588651b78531fa23d84254",class:"session-expired-banner"},t("svg",{key:"7a9e8a3baba8576df14229384f67c4e771e4280e",class:"session-expired-banner-icon",xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none"},t("path",{key:"bededb8359f4374f131f914124f89cae938c63f2",d:"M12 9v4M12 17h.01M10.29 3.86L1.82 18a2 2 0 001.71 3h16.94a2 2 0 001.71-3L13.71 3.86a2 2 0 00-3.42 0z",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"})),t("span",{key:"49ede701a42a2c16954859e5c0443c6c94168376"},"Session abgelaufen –"),t("button",{key:"1533de4c91c3e496e82781e03e34d8df9cd92bf7",class:"session-expired-banner-btn",onClick:()=>window.location.reload()},"Seite neu laden")),!this.isSessionExpired&&("connecting"===this.connectionStatus||"reconnecting"===this.connectionStatus||"disconnected"===this.connectionStatus)&&t("div",{key:"5f11759ba32e228f990b2866d09e2d25c647315c",class:`connection-status-banner connection-status-banner--${this.connectionStatus}`},t("span",{key:"55ad4bf597fcf0ee3a1e180ebfac85a8c271da16",class:"connection-status-banner__dot"}),"connecting"===this.connectionStatus?"Verbindung wird hergestellt…":"reconnecting"===this.connectionStatus?"Verbindung wird wiederhergestellt…":"Offline"),t("div",{key:"c8adfe1c61695332bef014492c7abe3d641160b0",class:"tray"},t("chatleo-avatar",{key:"e5ca63cb0a77c19c75ca8404a0ec92833f9881f2",name:this.chatStore?.profile?.display_name??"",url:this.chatStore?.profile?.profile_picture_url,isOnline:!!this.chatStore?.profile?.id&&(this.chatStore?.isOnline(this.chatStore.profile.id)??!1)}),t("div",{key:"a7bbd2492328f400a7e349f8296f3c1a499e171e",class:"title"},"Nachrichten"),t("button",{key:"7c2450e2977563c59a41efc874fc9ca5c6ecbea7",class:"new-chat-btn",onClick:()=>this.onNewChatClicked()},t("svg",{key:"a7de1919583f9264c85d2f8a0879e8f993ff848c",xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 16 16",fill:"none"},t("path",{key:"63e200bbf4038f0ceb626000b53f685318cd19f8",d:"M10.497 2.43838L12.7094 4.62657M12.9439 1.6838L13.4519 2.19178C13.9192 2.6591 13.9192 3.41677 13.4519 3.8841L6.72919 10.6068C6.59783 10.7381 6.43768 10.8371 6.26144 10.8958L3.79663 11.7174C3.56275 11.7954 3.34026 11.5729 3.41821 11.339L4.23982 8.87421C4.29857 8.69797 4.39754 8.53783 4.5289 8.40647L11.2516 1.6838C11.7189 1.21648 12.4766 1.21648 12.9439 1.6838Z",stroke:"#565D6D","stroke-width":"1.5","stroke-linecap":"round","stroke-linejoin":"round"}),t("path",{key:"222831ec61fc41f09ba0296731aed27050ff1b55",d:"M8 2.13312H7.2H1.8C1.35817 2.13312 1 2.49129 1 2.93312V13.7331C1 14.1749 1.35817 14.5331 1.8 14.5331H12.6C13.0418 14.5331 13.4 14.1749 13.4 13.7331V8.33312V6.99998",stroke:"#565D6D","stroke-width":"1.5","stroke-linecap":"round"}))),t("button",{key:"51ce8b2bc912659e7347f9eb9bfe1a1c56b23b75",class:"chat-tray-btn",onClick:this.toggleChat},t("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 16 16",fill:"none"},t("path",this.isChatOpen?{d:"M3.07273 4.66669L2 5.73941L8 11.7394L14 5.73941L12.9273 4.66669L8 9.59393L3.07273 4.66669Z",fill:"#565D6D"}:{d:"M12.9273 11.7393L14 10.6665L8 4.66655L2 10.6665L3.07273 11.7393L8 6.81202L12.9273 11.7393Z",fill:"#565D6D"})))),t("div",{key:"9f46873326aab72ba87cfa6b387de9c5616bb497",class:"chat-content"},t("ul",{key:"f1f9da34aab6ae95a9d3910de295e1dc64f31c2c"},this.chatStore?.rooms.map((e=>{const a=e.participantIdsWithoutSelf?.filter((e=>this.chatStore.isOnline(e)))??[];return t("li",null,t("chatleo-room-tile-component",{chatStore:this.chatStore,room:e,onlineUserIds:a,lastMessage:void 0,timestamp:void 0,unreadCount:e.unreadCount}))}))))))}static get watchers(){return{chatStore:[{onChatStoreChange:0}],selectedRoomId:[{onSelectedRoomIdChanged:0}]}}};b.style=":host{--hover-color:#f9f9f9;--shadow-light:rgba(0, 0, 0, 0.1);--z-index-tray:1000;--tray-height:52px;--gap-small:12px;--gap-medium:16px;--transition-duration:0.3s;--gray-black:#171A1F;--chat-panel-width:280px;--selector-panel-width:320px;--messages-panel-width:50vw}.tray-container{position:fixed;bottom:0;right:20px;z-index:var(--z-index-tray);display:flex;flex-direction:row;align-items:flex-end;gap:var(--gap-small);font-family:var(--font-primary), sans-serif}.chat-panel{width:var(--chat-panel-width);flex:0 0 var(--chat-panel-width);box-sizing:border-box;position:relative;background:var(--bg-primary);border:1px solid var(--border-color);border-radius:var(--border-radius) var(--border-radius) 0 0;box-shadow:0 -2px 10px var(--shadow-light);overflow:hidden;max-height:var(--tray-height);transition:max-height var(--transition-duration) ease-in-out}.chat-panel.open{max-height:calc(50vh + var(--tray-height));}.tray{display:flex;flex-direction:row;align-items:center;background:var(--bg-primary);border-bottom:1px solid var(--border-light);height:var(--tray-height);box-sizing:border-box;width:100%;padding:0 8px;margin:0;}chatleo-avatar{--avatar-size:36px}.title{margin:0 8px;flex:1 1 auto;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;color:var(--gray-black, #171A1F);font-size:14px}.selector-panel{display:none;background:var(--bg-primary);border:1px solid var(--border-color);border-radius:var(--border-radius) var(--border-radius) 0 0;box-shadow:0 -2px 10px var(--shadow-light);box-sizing:border-box;width:var(--selector-panel-width);flex:0 0 var(--selector-panel-width);overflow:hidden;max-height:var(--tray-height);}.selector-panel.open{display:flex;flex-direction:column;max-height:calc(50vh + var(--tray-height))}.messages-panel{display:none;background:var(--bg-primary);border:1px solid var(--border-color);border-radius:var(--border-radius) var(--border-radius) 0 0;box-shadow:0 -2px 10px var(--shadow-light);box-sizing:border-box;width:var(--messages-panel-width);overflow:hidden;position:relative;max-height:70vh;flex-direction:column}.messages-panel.open{display:flex}.new-chat-btn{border:0;background:transparent;cursor:pointer;padding:0;margin:0 8px;flex:0 0 auto;color:#565D6D}.chat-tray-btn{border:0;background:transparent;cursor:pointer;padding:0;margin:0 8px;flex:0 0 auto;color:#565D6D}.chat-content{overflow:hidden}.chat-content ul{margin:0;padding:0;list-style:none;overflow-y:auto;max-height:calc(50vh - var(--tray-height));}.chat-content li{padding:16px;cursor:pointer}.chat-content li:hover{background:var(--hover-color)}@media (max-width: 768px){.chat-panel.open,.selector-panel.open{max-height:calc(80vh + 60px)}.chat-content ul{max-height:calc(80vh - 60px)}}.messages-container-header-closer{position:absolute;top:4px;right:4px}.messages-container{display:block;flex:1 1 auto;min-height:0;overflow-y:auto;overflow-x:hidden;padding-right:16px;overscroll-behavior:contain;scrollbar-gutter:stable;max-width:100%}.message-group{display:flex;flex-direction:column;gap:16px}.date-separator{text-align:center;font-family:var(--font-primary), sans-serif;font-weight:400;font-size:12px;line-height:1.65;color:var(--text-secondary)}.close-button{background:none;border:none;cursor:pointer;font-size:16px;color:var(--text-secondary)}.connection-status-banner{display:flex;align-items:center;gap:6px;padding:5px 12px;font-family:var(--font-primary), sans-serif;font-size:12px;font-weight:600;color:#fff;background:#f59e0b}.connection-status-banner--disconnected{background:#ef4444}.connection-status-banner__dot{width:6px;height:6px;border-radius:50%;background:rgba(255,255,255,0.8);flex-shrink:0;animation:tray-pulse-dot 1.4s ease-in-out infinite}.connection-status-banner--disconnected .connection-status-banner__dot{animation:none}@keyframes tray-pulse-dot{0%,100%{opacity:1}50%{opacity:0.3}}.session-expired-banner{display:flex;align-items:center;gap:6px;background:#fff8e1;border-bottom:1px solid #ffe082;padding:6px 12px;font-family:var(--font-primary), sans-serif;font-size:12px;color:#795548}.session-expired-banner-icon{flex-shrink:0;color:#f59e0b}.session-expired-banner-btn{margin-left:auto;padding:3px 10px;background:#f59e0b;color:#fff;border:none;border-radius:4px;font-family:var(--font-primary), sans-serif;font-size:12px;font-weight:600;cursor:pointer;white-space:nowrap}.session-expired-banner-btn:hover{background:#d97706}";const u=class{constructor(t){e(this,t),this.userClicked=a(this,"userClicked")}profile;isOnline=!1;lastSeen;userClicked;onClick(){this.profile&&this.userClicked.emit(this.profile)}render(){const e=this.profile,a=e?.profile_picture_url,i=e?.display_name??"Unknown user";return t("div",{key:"a1e0334d626b162edba9e5bcb93472ab1d75ea8d",class:"user-tile",onClick:()=>this.onClick()},t("chatleo-avatar",{key:"3eed64212482962fe151dbcdb275d2396d91a39f",name:i,url:a,isOnline:this.isOnline}),t("div",{key:"9438ec481cd480b576ef18e95a9fc30003b200ea",class:"user-content"},t("div",{key:"62a9cd55c2e1061c28934f419addbd3ac28b6dca",class:"user-header"},t("h3",{key:"e8f36bfd9e972193fc066b0a0de8a599180104a9",class:"user-name"},i)),t("div",{key:"dbffef93dbe1aff1b85a73669d020df94159b014",class:"user-footer"},t("p",{key:"ee7c35805b645f520b8ef9913c282e0651770684",class:"user-status"},this.isOnline?"Online":this.lastSeen?`Zuletzt online ${this.lastSeen}`:""))))}};u.style=":host{--hover-color:#f5f7fa;--user-tile-border:1px solid var(--border-color);--font-size-name:16px;--font-size-status:14px;--font-weight-name:600;--tile-margin:2px;display:block}.user-tile{display:flex;align-items:center;cursor:pointer;transition:background-color var(--transition-duration) ease;border-bottom:var(--user-tile-border)}.user-tile:hover{background-color:var(--hover-color)}.user-content{flex:1;min-width:0;margin-left:8px}.user-header{margin-bottom:var(--tile-margin)}.user-name{font-size:var(--font-size-name);font-weight:var(--font-weight-name);margin:0;color:var(--text-primary);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.user-footer{display:flex;align-items:center}.user-status{font-size:var(--font-size-status);color:var(--text-secondary);margin:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}";export{o as chatleo_avatar,s as chatleo_chat,r as chatleo_chat_header,c as chatleo_chat_message,h as chatleo_component,d as chatleo_new_message_selector,l as chatleo_rich_input,f as chatleo_rich_message_renderer,p as chatleo_room_list,g as chatleo_room_tile_component,m as chatleo_room_view,b as chatleo_tray_component,u as chatleo_user_tile}
@@ -1 +0,0 @@
1
- import{t as e,p as t,H as a,c as s,h as o}from"./p-C-v19aUJ.js";import{g as n}from"./index.js";import{d as i}from"./p-Exj_2-yI.js";import{d as r}from"./p-B7cdqAgv.js";import{d as c}from"./p-XlwGxsqT.js";import{d}from"./p-BdiOcOYZ.js";import{d as h}from"./p-C1mF0s8g.js";import{d as l}from"./p-CRtBdzP3.js";import{d as p}from"./p-fjMaTJam.js";import{d as f}from"./p-xt4kzz3B.js";const b=t(class extends a{constructor(e){super(),!1!==e&&this.__registerHost(),this.__attachShadow(),this.newChatClicked=s(this,"newChatClicked"),this.messageChatSent=s(this,"messageChatSent")}chatStore;isChatOpen=!1;isNewChatSelectorOpen=!1;isMessagesOpen=!1;selectedRoomId;isPending=!1;_version=0;isSessionExpired=!1;connectionStatus="disconnected";messagesContainerRef;lastMessageCount=-1;boundOnPresenceChange=()=>this.onPresenceChange();boundOnRoomMessageAdded=e=>this.onRoomMessageAdded(e);boundOnSessionExpiredChanged=e=>this.onSessionExpiredChanged(e);boundOnConnectionStatusChanged=e=>this.onConnectionStatusChanged(e);boundOnRoomReadCountChanged=()=>{this._version++};onChatStoreChange(e,t){t&&(t.removeEventListener("presenceChanged",this.boundOnPresenceChange),t.removeEventListener("roomMessageAdded",this.boundOnRoomMessageAdded),t.removeEventListener("sessionExpiredChanged",this.boundOnSessionExpiredChanged),t.removeEventListener("connectionStatusChanged",this.boundOnConnectionStatusChanged),t.removeEventListener("roomReadCountChanged",this.boundOnRoomReadCountChanged)),e&&(e.addEventListener("presenceChanged",this.boundOnPresenceChange),e.addEventListener("roomMessageAdded",this.boundOnRoomMessageAdded),e.addEventListener("sessionExpiredChanged",this.boundOnSessionExpiredChanged),e.addEventListener("connectionStatusChanged",this.boundOnConnectionStatusChanged),this.isSessionExpired=e.isSessionExpired,this.connectionStatus=e.connectionStatus,e.addEventListener("roomReadCountChanged",this.boundOnRoomReadCountChanged))}onSelectedRoomIdChanged(){this.lastMessageCount=-1,this._version++,this.chatStore?.setActiveRoomId(this.selectedRoomId??null)}onPresenceChange(){console.debug("onPresenceChange"),this._version++}onRoomMessageAdded(e){console.debug("onRoomMessageAdded",e),this._version++,this.isMessagesOpen&&e.detail?.roomId===this.selectedRoomId&&this.chatStore?.markRoomAsRead(this.selectedRoomId)}onSessionExpiredChanged(e){this.isSessionExpired=e.detail.isSessionExpired,this.isSessionExpired&&(this.isChatOpen=!0)}onConnectionStatusChanged(e){this.connectionStatus=e.detail.status}toggleChat=()=>{this.isChatOpen=!this.isChatOpen,this._version++};newChatClicked;onNewChatClicked(){this.isNewChatSelectorOpen?this.isNewChatSelectorOpen=!1:(this.isNewChatSelectorOpen=!0,this.isMessagesOpen=!1,this.newChatClicked.emit())}onUserSelected=()=>{this.isNewChatSelectorOpen=!1};onSelectorClose=()=>{this.isNewChatSelectorOpen=!1};roomClickedHandler(e){console.log("Received the roomClicked event: ",e.detail),this.isNewChatSelectorOpen=!1,this.isMessagesOpen=!0,this.selectedRoomId=e.detail.id,this.chatStore?.markRoomAsRead(e.detail.id)}messageChatSent;messageSendHandler(e){console.log("Received the messageSend event: ",JSON.stringify(e.detail));const t=(e.detail?.blocks??[]).map((e=>{if("attachment"===e?.type&&Array.isArray(e.attachments)){const t=e.attachments.map((e=>{const{preview:t,...a}=e??{};return a}));return{...e,attachments:t}}return e}));this.messageChatSent.emit({room_id:this.selectedRoomId,content:{blocks:t,version:e.detail.version},content_type:"application/json+blocks",sender:this.chatStore?.profile?.id})}async openChatPanel(e,t=!1){console.debug(`openChatPanel ${e} ${t}`),this.selectedRoomId=e,this.isPending=t,this.isChatOpen=!1,this.isMessagesOpen=!0,e&&this.chatStore?.markRoomAsRead(e),this._version++}onDoClose(e){e.preventDefault(),this.isMessagesOpen=!1}scrollToBottom(){if(this.messagesContainerRef)try{this.messagesContainerRef.scrollTop=this.messagesContainerRef.scrollHeight}catch(e){}}scrollToBottomNextTick(){requestAnimationFrame((()=>{this.scrollToBottom()}))}componentDidRender(){if(!this.isMessagesOpen||!this.selectedRoomId)return;const e=(this.chatStore?.roomMessages(this.selectedRoomId)??[]).length;e!==this.lastMessageCount&&(this.scrollToBottomNextTick(),this.lastMessageCount=e)}render(){const e=n(this.chatStore?.roomMessages(this.selectedRoomId)??[]);return o("div",{key:"16d13ecf2c8d78c822b66ee140fdf3aedb03d1fa",class:"tray-container"},o("div",{key:"2087230f83fa231255a127bcf25935c96bb5a89d",class:this.isNewChatSelectorOpen?"selector-panel open":"selector-panel"},o("chatleo-new-message-selector",{key:"346f747952e4c2d3872db97adfd9fab7434526cf",chatStore:this.chatStore,onUserSelected:this.onUserSelected,onDoClose:this.onSelectorClose})),o("div",{key:"245326a45ffdea0c3c8a8507a449391635576c95",class:this.isMessagesOpen?"messages-panel open":"messages-panel"},o("div",{key:"b5b82048cbee06bdb73967c2ff342d4bad66a89a",class:"messages-container-header-closer"},o("button",{key:"0196b861999831d834df3407cc5c350fba9338f9",class:"close-button",onClick:this.onDoClose.bind(this)},o("svg",{key:"1db85ebbbb9291ecd8674d25a063bcbe215bd6d0",width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg"},o("path",{key:"d5f23bc40608fac8577860d6ff03e0e5c47e26cf",d:"M12 4L4 12",stroke:"#565D6D","stroke-width":"1.37143","stroke-miterlimit":"10","stroke-linecap":"square"}),o("path",{key:"6f27dd8b4a9969dd19bdae6059cad74d5e466d6f",d:"M12 12L4 4",stroke:"#565D6D","stroke-width":"1.37143","stroke-miterlimit":"10","stroke-linecap":"square"})))),o("chatleo-chat-header",{key:"d4320c822ed8ed5e4472c91a8c03508137bb3985",name:this.chatStore?.profile?.display_name,avatar:this.chatStore?.profile?.profile_picture_url??"https://placehold.co/48x48?text=AV",isOnline:this.chatStore?.isConnected}),o("div",{key:"ffb54f65c17f3ecf51f661aaa2cd1777d57e2468",class:"messages-container",ref:e=>this.messagesContainerRef=e},Object.entries(e).sort((([e],[t])=>new Date(e).getTime()-new Date(t).getTime())).map((([e,t])=>o("div",{class:"message-group"},o("div",{class:"date-separator"},e),t.map((e=>o("chatleo-chat-message",{message:e,sender:this.chatStore?.usernameResolver(e.sender_id),isOwnMessage:e.sender_id===this.chatStore?.profile.id,translations:{you:this.chatStore?.usernameResolver(e.sender_id)?.display_name}}))))))),o("chatleo-rich-input",{key:"5db7ffd32df847bbe103659d4f8ededfcc3105b2",disabled:!this.selectedRoomId,placeholder:"Nachricht schreiben"})),o("div",{key:"a4374b9f51b6f4f528ca0099df022272d41e8062",id:"chats",class:this.isChatOpen?"chat-panel open":"chat-panel"},this.isSessionExpired&&o("div",{key:"77f04c709823b47590588651b78531fa23d84254",class:"session-expired-banner"},o("svg",{key:"7a9e8a3baba8576df14229384f67c4e771e4280e",class:"session-expired-banner-icon",xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none"},o("path",{key:"bededb8359f4374f131f914124f89cae938c63f2",d:"M12 9v4M12 17h.01M10.29 3.86L1.82 18a2 2 0 001.71 3h16.94a2 2 0 001.71-3L13.71 3.86a2 2 0 00-3.42 0z",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"})),o("span",{key:"49ede701a42a2c16954859e5c0443c6c94168376"},"Session abgelaufen –"),o("button",{key:"1533de4c91c3e496e82781e03e34d8df9cd92bf7",class:"session-expired-banner-btn",onClick:()=>window.location.reload()},"Seite neu laden")),!this.isSessionExpired&&("connecting"===this.connectionStatus||"reconnecting"===this.connectionStatus||"disconnected"===this.connectionStatus)&&o("div",{key:"5f11759ba32e228f990b2866d09e2d25c647315c",class:`connection-status-banner connection-status-banner--${this.connectionStatus}`},o("span",{key:"55ad4bf597fcf0ee3a1e180ebfac85a8c271da16",class:"connection-status-banner__dot"}),"connecting"===this.connectionStatus?"Verbindung wird hergestellt…":"reconnecting"===this.connectionStatus?"Verbindung wird wiederhergestellt…":"Offline"),o("div",{key:"c8adfe1c61695332bef014492c7abe3d641160b0",class:"tray"},o("chatleo-avatar",{key:"e5ca63cb0a77c19c75ca8404a0ec92833f9881f2",name:this.chatStore?.profile?.display_name??"",url:this.chatStore?.profile?.profile_picture_url,isOnline:!!this.chatStore?.profile?.id&&(this.chatStore?.isOnline(this.chatStore.profile.id)??!1)}),o("div",{key:"a7bbd2492328f400a7e349f8296f3c1a499e171e",class:"title"},"Nachrichten"),o("button",{key:"7c2450e2977563c59a41efc874fc9ca5c6ecbea7",class:"new-chat-btn",onClick:()=>this.onNewChatClicked()},o("svg",{key:"a7de1919583f9264c85d2f8a0879e8f993ff848c",xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 16 16",fill:"none"},o("path",{key:"63e200bbf4038f0ceb626000b53f685318cd19f8",d:"M10.497 2.43838L12.7094 4.62657M12.9439 1.6838L13.4519 2.19178C13.9192 2.6591 13.9192 3.41677 13.4519 3.8841L6.72919 10.6068C6.59783 10.7381 6.43768 10.8371 6.26144 10.8958L3.79663 11.7174C3.56275 11.7954 3.34026 11.5729 3.41821 11.339L4.23982 8.87421C4.29857 8.69797 4.39754 8.53783 4.5289 8.40647L11.2516 1.6838C11.7189 1.21648 12.4766 1.21648 12.9439 1.6838Z",stroke:"#565D6D","stroke-width":"1.5","stroke-linecap":"round","stroke-linejoin":"round"}),o("path",{key:"222831ec61fc41f09ba0296731aed27050ff1b55",d:"M8 2.13312H7.2H1.8C1.35817 2.13312 1 2.49129 1 2.93312V13.7331C1 14.1749 1.35817 14.5331 1.8 14.5331H12.6C13.0418 14.5331 13.4 14.1749 13.4 13.7331V8.33312V6.99998",stroke:"#565D6D","stroke-width":"1.5","stroke-linecap":"round"}))),o("button",{key:"51ce8b2bc912659e7347f9eb9bfe1a1c56b23b75",class:"chat-tray-btn",onClick:this.toggleChat},o("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 16 16",fill:"none"},o("path",this.isChatOpen?{d:"M3.07273 4.66669L2 5.73941L8 11.7394L14 5.73941L12.9273 4.66669L8 9.59393L3.07273 4.66669Z",fill:"#565D6D"}:{d:"M12.9273 11.7393L14 10.6665L8 4.66655L2 10.6665L3.07273 11.7393L8 6.81202L12.9273 11.7393Z",fill:"#565D6D"})))),o("div",{key:"9f46873326aab72ba87cfa6b387de9c5616bb497",class:"chat-content"},o("ul",{key:"f1f9da34aab6ae95a9d3910de295e1dc64f31c2c"},this.chatStore?.rooms.map((e=>{const t=e.participantIdsWithoutSelf?.filter((e=>this.chatStore.isOnline(e)))??[];return o("li",null,o("chatleo-room-tile-component",{chatStore:this.chatStore,room:e,onlineUserIds:t,lastMessage:void 0,timestamp:void 0,unreadCount:e.unreadCount}))}))))))}static get watchers(){return{chatStore:[{onChatStoreChange:0}],selectedRoomId:[{onSelectedRoomIdChanged:0}]}}static get style(){return":host{--hover-color:#f9f9f9;--shadow-light:rgba(0, 0, 0, 0.1);--z-index-tray:1000;--tray-height:52px;--gap-small:12px;--gap-medium:16px;--transition-duration:0.3s;--gray-black:#171A1F;--chat-panel-width:280px;--selector-panel-width:320px;--messages-panel-width:50vw}.tray-container{position:fixed;bottom:0;right:20px;z-index:var(--z-index-tray);display:flex;flex-direction:row;align-items:flex-end;gap:var(--gap-small);font-family:var(--font-primary), sans-serif}.chat-panel{width:var(--chat-panel-width);flex:0 0 var(--chat-panel-width);box-sizing:border-box;position:relative;background:var(--bg-primary);border:1px solid var(--border-color);border-radius:var(--border-radius) var(--border-radius) 0 0;box-shadow:0 -2px 10px var(--shadow-light);overflow:hidden;max-height:var(--tray-height);transition:max-height var(--transition-duration) ease-in-out}.chat-panel.open{max-height:calc(50vh + var(--tray-height));}.tray{display:flex;flex-direction:row;align-items:center;background:var(--bg-primary);border-bottom:1px solid var(--border-light);height:var(--tray-height);box-sizing:border-box;width:100%;padding:0 8px;margin:0;}chatleo-avatar{--avatar-size:36px}.title{margin:0 8px;flex:1 1 auto;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;color:var(--gray-black, #171A1F);font-size:14px}.selector-panel{display:none;background:var(--bg-primary);border:1px solid var(--border-color);border-radius:var(--border-radius) var(--border-radius) 0 0;box-shadow:0 -2px 10px var(--shadow-light);box-sizing:border-box;width:var(--selector-panel-width);flex:0 0 var(--selector-panel-width);overflow:hidden;max-height:var(--tray-height);}.selector-panel.open{display:flex;flex-direction:column;max-height:calc(50vh + var(--tray-height))}.messages-panel{display:none;background:var(--bg-primary);border:1px solid var(--border-color);border-radius:var(--border-radius) var(--border-radius) 0 0;box-shadow:0 -2px 10px var(--shadow-light);box-sizing:border-box;width:var(--messages-panel-width);overflow:hidden;position:relative;max-height:70vh;flex-direction:column}.messages-panel.open{display:flex}.new-chat-btn{border:0;background:transparent;cursor:pointer;padding:0;margin:0 8px;flex:0 0 auto;color:#565D6D}.chat-tray-btn{border:0;background:transparent;cursor:pointer;padding:0;margin:0 8px;flex:0 0 auto;color:#565D6D}.chat-content{overflow:hidden}.chat-content ul{margin:0;padding:0;list-style:none;overflow-y:auto;max-height:calc(50vh - var(--tray-height));}.chat-content li{padding:16px;cursor:pointer}.chat-content li:hover{background:var(--hover-color)}@media (max-width: 768px){.chat-panel.open,.selector-panel.open{max-height:calc(80vh + 60px)}.chat-content ul{max-height:calc(80vh - 60px)}}.messages-container-header-closer{position:absolute;top:4px;right:4px}.messages-container{display:block;flex:1 1 auto;min-height:0;overflow-y:auto;overflow-x:hidden;padding-right:16px;overscroll-behavior:contain;scrollbar-gutter:stable;max-width:100%}.message-group{display:flex;flex-direction:column;gap:16px}.date-separator{text-align:center;font-family:var(--font-primary), sans-serif;font-weight:400;font-size:12px;line-height:1.65;color:var(--text-secondary)}.close-button{background:none;border:none;cursor:pointer;font-size:16px;color:var(--text-secondary)}.connection-status-banner{display:flex;align-items:center;gap:6px;padding:5px 12px;font-family:var(--font-primary), sans-serif;font-size:12px;font-weight:600;color:#fff;background:#f59e0b}.connection-status-banner--disconnected{background:#ef4444}.connection-status-banner__dot{width:6px;height:6px;border-radius:50%;background:rgba(255,255,255,0.8);flex-shrink:0;animation:tray-pulse-dot 1.4s ease-in-out infinite}.connection-status-banner--disconnected .connection-status-banner__dot{animation:none}@keyframes tray-pulse-dot{0%,100%{opacity:1}50%{opacity:0.3}}.session-expired-banner{display:flex;align-items:center;gap:6px;background:#fff8e1;border-bottom:1px solid #ffe082;padding:6px 12px;font-family:var(--font-primary), sans-serif;font-size:12px;color:#795548}.session-expired-banner-icon{flex-shrink:0;color:#f59e0b}.session-expired-banner-btn{margin-left:auto;padding:3px 10px;background:#f59e0b;color:#fff;border:none;border-radius:4px;font-family:var(--font-primary), sans-serif;font-size:12px;font-weight:600;cursor:pointer;white-space:nowrap}.session-expired-banner-btn:hover{background:#d97706}"}},[513,"chatleo-tray-component",{chatStore:[16],isChatOpen:[32],isNewChatSelectorOpen:[32],isMessagesOpen:[32],selectedRoomId:[32],isPending:[32],_version:[32],isSessionExpired:[32],connectionStatus:[32],openChatPanel:[64]},[[0,"roomClicked","roomClickedHandler"],[0,"messageSend","messageSendHandler"]],{chatStore:[{onChatStoreChange:0}],selectedRoomId:[{onSelectedRoomIdChanged:0}]}]);function g(){"undefined"!=typeof customElements&&["chatleo-tray-component","chatleo-avatar","chatleo-chat-header","chatleo-chat-message","chatleo-new-message-selector","chatleo-rich-input","chatleo-rich-message-renderer","chatleo-room-tile-component","chatleo-user-tile"].forEach((t=>{switch(t){case"chatleo-tray-component":customElements.get(e(t))||customElements.define(e(t),b);break;case"chatleo-avatar":customElements.get(e(t))||i();break;case"chatleo-chat-header":customElements.get(e(t))||r();break;case"chatleo-chat-message":customElements.get(e(t))||c();break;case"chatleo-new-message-selector":customElements.get(e(t))||d();break;case"chatleo-rich-input":customElements.get(e(t))||h();break;case"chatleo-rich-message-renderer":customElements.get(e(t))||l();break;case"chatleo-room-tile-component":customElements.get(e(t))||p();break;case"chatleo-user-tile":customElements.get(e(t))||f()}}))}g();export{b as C,g as d}