@gamention/pulse-elements 0.1.20 → 0.1.21

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.
@@ -2,7 +2,7 @@
2
2
  * @license
3
3
  * Copyright 2021 Google LLC
4
4
  * SPDX-License-Identifier: BSD-3-Clause
5
- */let gt=class extends Event{constructor(e,t,i,s){super("context-request",{bubbles:!0,composed:!0}),this.context=e,this.contextTarget=t,this.callback=i,this.subscribe=s??!1}};/**
5
+ */let vt=class extends Event{constructor(e,t,i,s){super("context-request",{bubbles:!0,composed:!0}),this.context=e,this.contextTarget=t,this.callback=i,this.subscribe=s??!1}};/**
6
6
  * @license
7
7
  * Copyright 2021 Google LLC
8
8
  * SPDX-License-Identifier: BSD-3-Clause
@@ -10,41 +10,41 @@
10
10
  * @license
11
11
  * Copyright 2021 Google LLC
12
12
  * SPDX-License-Identifier: BSD-3-Clause
13
- */let Fe=class{constructor(e,t,i,s){if(this.subscribe=!1,this.provided=!1,this.value=void 0,this.t=(n,r)=>{this.unsubscribe&&(this.unsubscribe!==r&&(this.provided=!1,this.unsubscribe()),this.subscribe||this.unsubscribe()),this.value=n,this.host.requestUpdate(),this.provided&&!this.subscribe||(this.provided=!0,this.callback&&this.callback(n,r)),this.unsubscribe=r},this.host=e,t.context!==void 0){const n=t;this.context=n.context,this.callback=n.callback,this.subscribe=n.subscribe??!1}else this.context=t,this.callback=i,this.subscribe=s??!1;this.host.addController(this)}hostConnected(){this.dispatchRequest()}hostDisconnected(){this.unsubscribe&&(this.unsubscribe(),this.unsubscribe=void 0)}dispatchRequest(){this.host.dispatchEvent(new gt(this.context,this.host,this.t,this.subscribe))}};/**
13
+ */let We=class{constructor(e,t,i,s){if(this.subscribe=!1,this.provided=!1,this.value=void 0,this.t=(n,r)=>{this.unsubscribe&&(this.unsubscribe!==r&&(this.provided=!1,this.unsubscribe()),this.subscribe||this.unsubscribe()),this.value=n,this.host.requestUpdate(),this.provided&&!this.subscribe||(this.provided=!0,this.callback&&this.callback(n,r)),this.unsubscribe=r},this.host=e,t.context!==void 0){const n=t;this.context=n.context,this.callback=n.callback,this.subscribe=n.subscribe??!1}else this.context=t,this.callback=i,this.subscribe=s??!1;this.host.addController(this)}hostConnected(){this.dispatchRequest()}hostDisconnected(){this.unsubscribe&&(this.unsubscribe(),this.unsubscribe=void 0)}dispatchRequest(){this.host.dispatchEvent(new vt(this.context,this.host,this.t,this.subscribe))}};/**
14
14
  * @license
15
15
  * Copyright 2021 Google LLC
16
16
  * SPDX-License-Identifier: BSD-3-Clause
17
- */let At=class{get value(){return this.o}set value(e){this.setValue(e)}setValue(e,t=!1){const i=t||!Object.is(e,this.o);this.o=e,i&&this.updateObservers()}constructor(e){this.subscriptions=new Map,this.updateObservers=()=>{for(const[t,{disposer:i}]of this.subscriptions)t(this.o,i)},e!==void 0&&(this.value=e)}addCallback(e,t,i){if(!i)return void e(this.value);this.subscriptions.has(e)||this.subscriptions.set(e,{disposer:()=>{this.subscriptions.delete(e)},consumerHost:t});const{disposer:s}=this.subscriptions.get(e);e(this.value,s)}clearCallbacks(){this.subscriptions.clear()}};/**
17
+ */let _t=class{get value(){return this.o}set value(e){this.setValue(e)}setValue(e,t=!1){const i=t||!Object.is(e,this.o);this.o=e,i&&this.updateObservers()}constructor(e){this.subscriptions=new Map,this.updateObservers=()=>{for(const[t,{disposer:i}]of this.subscriptions)t(this.o,i)},e!==void 0&&(this.value=e)}addCallback(e,t,i){if(!i)return void e(this.value);this.subscriptions.has(e)||this.subscriptions.set(e,{disposer:()=>{this.subscriptions.delete(e)},consumerHost:t});const{disposer:s}=this.subscriptions.get(e);e(this.value,s)}clearCallbacks(){this.subscriptions.clear()}};/**
18
18
  * @license
19
19
  * Copyright 2021 Google LLC
20
20
  * SPDX-License-Identifier: BSD-3-Clause
21
- */let _t=class extends Event{constructor(e,t){super("context-provider",{bubbles:!0,composed:!0}),this.context=e,this.contextTarget=t}},We=class extends At{constructor(e,t,i){var s,n;super(t.context!==void 0?t.initialValue:i),this.onContextRequest=r=>{if(r.context!==this.context)return;const a=r.contextTarget??r.composedPath()[0];a!==this.host&&(r.stopPropagation(),this.addCallback(r.callback,a,r.subscribe))},this.onProviderRequest=r=>{if(r.context!==this.context||(r.contextTarget??r.composedPath()[0])===this.host)return;const a=new Set;for(const[l,{consumerHost:d}]of this.subscriptions)a.has(l)||(a.add(l),d.dispatchEvent(new gt(this.context,d,l,!0)));r.stopPropagation()},this.host=e,t.context!==void 0?this.context=t.context:this.context=t,this.attachListeners(),(n=(s=this.host).addController)==null||n.call(s,this)}attachListeners(){this.host.addEventListener("context-request",this.onContextRequest),this.host.addEventListener("context-provider",this.onProviderRequest)}hostConnected(){this.host.dispatchEvent(new _t(this.context,this.host))}};/**
21
+ */let It=class extends Event{constructor(e,t){super("context-provider",{bubbles:!0,composed:!0}),this.context=e,this.contextTarget=t}},qe=class extends _t{constructor(e,t,i){var s,n;super(t.context!==void 0?t.initialValue:i),this.onContextRequest=r=>{if(r.context!==this.context)return;const a=r.contextTarget??r.composedPath()[0];a!==this.host&&(r.stopPropagation(),this.addCallback(r.callback,a,r.subscribe))},this.onProviderRequest=r=>{if(r.context!==this.context||(r.contextTarget??r.composedPath()[0])===this.host)return;const a=new Set;for(const[l,{consumerHost:d}]of this.subscriptions)a.has(l)||(a.add(l),d.dispatchEvent(new vt(this.context,d,l,!0)));r.stopPropagation()},this.host=e,t.context!==void 0?this.context=t.context:this.context=t,this.attachListeners(),(n=(s=this.host).addController)==null||n.call(s,this)}attachListeners(){this.host.addEventListener("context-request",this.onContextRequest),this.host.addEventListener("context-provider",this.onProviderRequest)}hostConnected(){this.host.dispatchEvent(new It(this.context,this.host))}};/**
22
22
  * @license
23
23
  * Copyright 2017 Google LLC
24
24
  * SPDX-License-Identifier: BSD-3-Clause
25
- */function It({context:o}){return(e,t)=>{const i=new WeakMap;if(typeof t=="object")return{get(){return e.get.call(this)},set(s){return i.get(this).setValue(s),e.set.call(this,s)},init(s){return i.set(this,new We(this,{context:o,initialValue:s})),s}};{e.constructor.addInitializer((r=>{i.set(r,new We(r,{context:o}))}));const s=Object.getOwnPropertyDescriptor(e,t);let n;if(s===void 0){const r=new WeakMap;n={get(){return r.get(this)},set(a){i.get(this).setValue(a),r.set(this,a)},configurable:!0,enumerable:!0}}else{const r=s.set;n={...s,set(a){i.get(this).setValue(a),r==null||r.call(this,a)}}}return void Object.defineProperty(e,t,n)}}}/**
25
+ */function Mt({context:o}){return(e,t)=>{const i=new WeakMap;if(typeof t=="object")return{get(){return e.get.call(this)},set(s){return i.get(this).setValue(s),e.set.call(this,s)},init(s){return i.set(this,new qe(this,{context:o,initialValue:s})),s}};{e.constructor.addInitializer((r=>{i.set(r,new qe(r,{context:o}))}));const s=Object.getOwnPropertyDescriptor(e,t);let n;if(s===void 0){const r=new WeakMap;n={get(){return r.get(this)},set(a){i.get(this).setValue(a),r.set(this,a)},configurable:!0,enumerable:!0}}else{const r=s.set;n={...s,set(a){i.get(this).setValue(a),r==null||r.call(this,a)}}}return void Object.defineProperty(e,t,n)}}}/**
26
26
  * @license
27
27
  * Copyright 2022 Google LLC
28
28
  * SPDX-License-Identifier: BSD-3-Clause
29
- */function ae({context:o,subscribe:e}){return(t,i)=>{typeof i=="object"?i.addInitializer((function(){new Fe(this,{context:o,callback:s=>{t.set.call(this,s)},subscribe:e})})):t.constructor.addInitializer((s=>{new Fe(s,{context:o,callback:n=>{s[i]=n},subscribe:e})}))}}var Mt=Object.defineProperty,Ot=(o,e,t)=>e in o?Mt(o,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):o[e]=t,E=(o,e,t)=>Ot(o,typeof e!="symbol"?e+"":e,t);const ke={allowImages:!0,allowAudio:!0,allowVideo:!0,maxFileSizeMb:10,maxAttachmentsPerComment:5,allowReactions:!0,allowDrawing:!0,allowMentions:!0,showCursors:!0,showPresence:!0,showTypingIndicators:!0},Rt="ws://localhost:4567",qe=50,Lt=3e4,jt=1e3,zt=3e4;let Oe=class{constructor(){E(this,"handlers",new Map)}on(e,t){this.handlers.has(e)||this.handlers.set(e,new Set);const i=this.handlers.get(e);return i.add(t),()=>i.delete(t)}off(e,t){var i;(i=this.handlers.get(e))==null||i.delete(t)}emit(e,t){var i;(i=this.handlers.get(e))==null||i.forEach(s=>s(t))}removeAll(){this.handlers.clear()}},Ut=class extends Oe{constructor(e){super(),E(this,"ws",null),E(this,"endpoint"),E(this,"reconnectAttempt",0),E(this,"reconnectTimer",null),E(this,"_state","disconnected"),this.endpoint=e??Rt}get state(){return this._state}connect(){this.ws||(this._state="connecting",this.emit("state",this._state),this.ws=new WebSocket(this.endpoint),this.ws.addEventListener("open",()=>{this._state="connected",this.reconnectAttempt=0,this.emit("state",this._state)}),this.ws.addEventListener("message",e=>{const t=JSON.parse(e.data);this.emit("message",t)}),this.ws.addEventListener("close",()=>{this.ws=null,this._state="disconnected",this.emit("state",this._state),this.scheduleReconnect()}),this.ws.addEventListener("error",()=>{var e;(e=this.ws)==null||e.close()}))}disconnect(){var e;this.reconnectTimer&&(clearTimeout(this.reconnectTimer),this.reconnectTimer=null),this.reconnectAttempt=0,(e=this.ws)==null||e.close(),this.ws=null,this._state="disconnected",this.emit("state",this._state)}send(e){var t;((t=this.ws)==null?void 0:t.readyState)===WebSocket.OPEN&&this.ws.send(JSON.stringify(e))}scheduleReconnect(){const e=Math.min(jt*2**this.reconnectAttempt,zt);this.reconnectAttempt++,this.reconnectTimer=setTimeout(()=>{this.reconnectTimer=null,this.connect()},e)}},Dt=class extends Oe{constructor(){super(...arguments),E(this,"baseUrl",""),E(this,"_user",null),E(this,"_config",{...ke}),E(this,"_users",new Map),E(this,"_presence",new Map),E(this,"_threads",new Map),E(this,"_reactions",new Map),E(this,"_notifications",[]),E(this,"_activityLogs",[]),E(this,"_typing",new Map),E(this,"_viewports",new Map),E(this,"_selections",new Map)}get user(){return this._user}get config(){return this._config}removeComment(e){for(const[t,i]of this._threads){const s=i.comments.findIndex(n=>n.id===e);if(s!==-1){i.comments.splice(s,1),i.comments.length===0&&this._threads.delete(t),this.emit("threads",this.threads);return}}}get presence(){return[...this._presence.values()]}get threads(){return[...this._threads.values()]}get notifications(){return this._notifications}get unreadCount(){return this._notifications.filter(e=>!e.read).length}markNotificationRead(e){const t=this._notifications.find(i=>i.id===e);t&&!t.read&&(t.read=!0,this.emit("notifications",this._notifications))}markAllNotificationsRead(){let e=!1;for(const t of this._notifications)t.read||(t.read=!0,e=!0);e&&this.emit("notifications",this._notifications)}get activityLogs(){return this._activityLogs}getUser(e){return this._users.get(e)}getReactions(e){return this._reactions.get(e)??[]}getTypingUsers(e){const t=this._typing.get(e);if(!t)return[];const i=Date.now(),s=[];for(const[n,r]of t)i-r<3e3&&s.push(n);return s}get viewports(){return this._viewports}getViewport(e){return this._viewports.get(e)}get selections(){return this._selections}resolveUrl(e){return!this.baseUrl||!e||e.startsWith("http://")||e.startsWith("https://")?e:`${this.baseUrl}${e}`}resolveAttachments(e){return e.map(t=>({...t,url:this.resolveUrl(t.url),thumbnailUrl:t.thumbnailUrl?this.resolveUrl(t.thumbnailUrl):void 0}))}resolveComment(e){return!e.attachments||e.attachments.length===0?e:{...e,attachments:this.resolveAttachments(e.attachments)}}resolveThread(e){return{...e,comments:e.comments.map(t=>this.resolveComment(t))}}handleMessage(e){switch(e.type){case"auth:ok":this._config=e.config??{...ke},this._user=e.user,this._users.clear();for(const t of e.users)this._users.set(t.id,t);this._presence.clear();for(const t of e.presence)this._presence.set(t.user.id,t),this._users.set(t.user.id,t.user);this._users.set(e.user.id,e.user),this._threads.clear();for(const t of e.threads)this._threads.set(t.id,this.resolveThread(t));this._notifications=e.notifications,this._reactions.clear();for(const t of e.reactions){const i=this._reactions.get(t.targetId)??[];i.push(t),this._reactions.set(t.targetId,i)}this._activityLogs=[...e.activityLogs],this.emit("auth",e.user),this.emit("presence",this.presence),this.emit("threads",this.threads),this.emit("notifications",this._notifications),this.emit("reactions",null),this.emit("activity-logs",this._activityLogs);break;case"presence:join":this._presence.set(e.user.user.id,e.user),this._users.set(e.user.user.id,e.user.user),this.emit("presence",this.presence);break;case"presence:leave":this._presence.delete(e.userId),this._viewports.delete(e.userId),this._selections.delete(e.userId);for(const t of this._typing.values())t.delete(e.userId);this.emit("presence",this.presence);break;case"presence:update":{const t=this._presence.get(e.userId);t&&(t.status=e.status,this.emit("presence",this.presence));break}case"cursor:move":this.emit("cursor",{userId:e.userId,position:e.position});break;case"click:perform":this.emit("click",{userId:e.userId,position:e.position});break;case"thread:created":this._threads.set(e.thread.id,this.resolveThread(e.thread)),this.emit("threads",this.threads);break;case"comment:created":{const t=this._threads.get(e.threadId);t&&(t.comments.push(this.resolveComment(e.comment)),t.updatedAt=e.comment.createdAt,this.emit("threads",this.threads));break}case"comment:edited":{const t=this._threads.get(e.threadId);if(t){const i=t.comments.findIndex(s=>s.id===e.comment.id);i!==-1&&(t.comments[i]=this.resolveComment(e.comment)),this.emit("threads",this.threads)}break}case"comment:deleted":{const t=this._threads.get(e.threadId);t&&(t.comments=t.comments.filter(i=>i.id!==e.commentId),t.comments.length===0&&this._threads.delete(e.threadId),this.emit("threads",this.threads));break}case"thread:resolved":{const t=this._threads.get(e.threadId);t&&(t.resolved=e.resolved,this.emit("threads",this.threads));break}case"thread:deleted":this._threads.delete(e.threadId),this.emit("threads",this.threads);break;case"reaction:added":{const t=this._reactions.get(e.reaction.targetId)??[];t.push(e.reaction),this._reactions.set(e.reaction.targetId,t),this.emit("reactions",{targetId:e.reaction.targetId,reactions:t});break}case"reaction:removed":{const t=this._reactions.get(e.targetId);if(t){const i=t.filter(s=>s.id!==e.reactionId);this._reactions.set(e.targetId,i),this.emit("reactions",{targetId:e.targetId,reactions:i})}break}case"notification":this._notifications.unshift(e.notification),this.emit("notifications",this._notifications);break;case"typing:indicator":{this._typing.has(e.threadId)||this._typing.set(e.threadId,new Map),this._typing.get(e.threadId).set(e.userId,Date.now()),this.emit("typing",{threadId:e.threadId,userId:e.userId});break}case"viewport:update":{this._viewports.set(e.userId,{scrollX:e.scrollX,scrollY:e.scrollY,viewportWidth:e.viewportWidth,viewportHeight:e.viewportHeight,pageWidth:e.pageWidth,pageHeight:e.pageHeight}),this.emit("viewport",{userId:e.userId});break}case"selection:update":this._selections.set(e.userId,e.selection),this.emit("selection",{userId:e.userId,selection:e.selection});break;case"emoji:drop":this.emit("emoji-drop",{userId:e.userId,emoji:e.emoji,position:e.position});break;case"draw:stroke":this.emit("draw-stroke",{userId:e.userId,points:e.points,color:e.color,width:e.width});break;case"draw:clear":this.emit("draw-clear",{userId:e.userId});break;case"activity:logged":this._activityLogs.unshift(e.activityLog),this._activityLogs.length>100&&(this._activityLogs=this._activityLogs.slice(0,100)),this.emit("activity-logs",this._activityLogs);break;case"error":this.emit("error",e);break}}reset(){this._user=null,this._config={...ke},this._users.clear(),this._presence.clear(),this._threads.clear(),this._reactions.clear(),this._notifications=[],this._activityLogs=[],this._typing.clear(),this._viewports.clear(),this._selections.clear()}},vt=class extends Oe{constructor(e){var t;super(),E(this,"state"),E(this,"connection"),E(this,"config"),E(this,"heartbeatTimer",null),E(this,"lastCursorSend",0),E(this,"pendingCursor",null),E(this,"cursorTimer",null),this.config=e,this.state=new Dt,this.state.baseUrl=(e.endpoint??"").replace(/^ws(s?):/,"http$1:").replace(/\/$/,"");const i=((t=e.endpoint)==null?void 0:t.replace(/^http/,"ws"))??void 0;this.connection=new Ut(i),this.connection.on("message",s=>{this.state.handleMessage(s),this.emit(s.type,s)}),this.connection.on("state",s=>{this.emit("connection",s),s==="connected"?(this.authenticate(),this.startHeartbeat()):s==="disconnected"&&this.stopHeartbeat()})}get connectionState(){return this.connection.state}connect(){this.connection.connect()}disconnect(){this.stopHeartbeat(),this.connection.disconnect(),this.state.reset()}authenticate(){this.send({type:"auth",apiKey:this.config.apiKey,token:this.config.token,room:this.config.room})}send(e){this.connection.send(e)}moveCursor(e){const t=Date.now();this.pendingCursor=e,t-this.lastCursorSend>=qe?this.flushCursor():this.cursorTimer||(this.cursorTimer=setTimeout(()=>{this.cursorTimer=null,this.flushCursor()},qe))}flushCursor(){this.pendingCursor&&(this.send({type:"cursor:move",position:this.pendingCursor}),this.lastCursorSend=Date.now(),this.pendingCursor=null)}updatePresence(e){this.send({type:"presence:update",status:e})}startHeartbeat(){this.heartbeatTimer=setInterval(()=>{this.send({type:"presence:update",status:"online"})},Lt)}stopHeartbeat(){this.heartbeatTimer&&(clearInterval(this.heartbeatTimer),this.heartbeatTimer=null)}createThread(e,t={}){const i=crypto.randomUUID();return this.send({type:"thread:create",id:i,body:e,mentions:t.mentions??[],position:t.position??null,attachmentIds:t.attachmentIds}),i}reply(e,t,i=[],s){const n=crypto.randomUUID();return this.send({type:"comment:create",threadId:e,id:n,body:t,mentions:i,attachmentIds:s}),n}editComment(e,t,i=[]){this.send({type:"comment:edit",commentId:e,body:t,mentions:i})}deleteComment(e){this.state.removeComment(e),this.send({type:"comment:delete",commentId:e})}resolveThread(e,t=!0){this.send({type:"thread:resolve",threadId:e,resolved:t})}addReaction(e,t,i){this.send({type:"reaction:add",targetId:e,targetType:t,emoji:i})}removeReaction(e){this.send({type:"reaction:remove",reactionId:e})}markRead(e){this.state.markNotificationRead(e),this.send({type:"notification:read",notificationId:e})}markAllRead(){this.state.markAllNotificationsRead(),this.send({type:"notification:read-all"})}performClick(e){this.send({type:"click:perform",position:e})}sendTyping(e){this.send({type:"typing:start",threadId:e})}updateViewport(e){this.send({type:"viewport:update",...e})}updateSelection(e){this.send({type:"selection:update",selection:e})}dropEmoji(e,t){this.send({type:"emoji:drop",emoji:e,position:t})}drawStroke(e,t,i){this.send({type:"draw:stroke",points:e,color:t,width:i})}clearDrawing(){this.send({type:"draw:clear"})}async uploadFile(e){const t=(this.config.endpoint??window.location.origin).replace(/^ws(s?):/,"http$1:"),i=new FormData;i.append("file",e);const s=await fetch(`${t}/api/v1/upload`,{method:"POST",headers:{"X-Pulse-Key":this.config.apiKey,"X-Pulse-Token":this.config.token},body:i});if(!s.ok){const r=await s.json().catch(()=>({error:"Upload failed"}));throw new Error(r.error??"Upload failed")}const n=await s.json();return n.url&&!n.url.startsWith("http")&&(n.url=`${t}${n.url}`),n.thumbnailUrl&&!n.thumbnailUrl.startsWith("http")&&(n.thumbnailUrl=`${t}${n.thumbnailUrl}`),n}setAppearOffline(e){e?(this.stopHeartbeat(),this.send({type:"presence:update",status:"idle"})):(this.startHeartbeat(),this.send({type:"presence:update",status:"online"}))}};/**
29
+ */function ae({context:o,subscribe:e}){return(t,i)=>{typeof i=="object"?i.addInitializer((function(){new We(this,{context:o,callback:s=>{t.set.call(this,s)},subscribe:e})})):t.constructor.addInitializer((s=>{new We(s,{context:o,callback:n=>{s[i]=n},subscribe:e})}))}}var Ot=Object.defineProperty,Rt=(o,e,t)=>e in o?Ot(o,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):o[e]=t,E=(o,e,t)=>Rt(o,typeof e!="symbol"?e+"":e,t);const ke={allowImages:!0,allowAudio:!0,allowVideo:!0,maxFileSizeMb:10,maxAttachmentsPerComment:5,allowReactions:!0,allowDrawing:!0,allowMentions:!0,showCursors:!0,showPresence:!0,showTypingIndicators:!0},Lt="ws://localhost:4567",Ve=50,jt=3e4,Ut=1e3,zt=3e4;let Re=class{constructor(){E(this,"handlers",new Map)}on(e,t){this.handlers.has(e)||this.handlers.set(e,new Set);const i=this.handlers.get(e);return i.add(t),()=>i.delete(t)}off(e,t){var i;(i=this.handlers.get(e))==null||i.delete(t)}emit(e,t){var i;(i=this.handlers.get(e))==null||i.forEach(s=>s(t))}removeAll(){this.handlers.clear()}},Dt=class extends Re{constructor(e){super(),E(this,"ws",null),E(this,"endpoint"),E(this,"reconnectAttempt",0),E(this,"reconnectTimer",null),E(this,"_state","disconnected"),this.endpoint=e??Lt}get state(){return this._state}connect(){this.ws||(this._state="connecting",this.emit("state",this._state),this.ws=new WebSocket(this.endpoint),this.ws.addEventListener("open",()=>{this._state="connected",this.reconnectAttempt=0,this.emit("state",this._state)}),this.ws.addEventListener("message",e=>{const t=JSON.parse(e.data);this.emit("message",t)}),this.ws.addEventListener("close",()=>{this.ws=null,this._state="disconnected",this.emit("state",this._state),this.scheduleReconnect()}),this.ws.addEventListener("error",()=>{var e;(e=this.ws)==null||e.close()}))}disconnect(){var e;this.reconnectTimer&&(clearTimeout(this.reconnectTimer),this.reconnectTimer=null),this.reconnectAttempt=0,(e=this.ws)==null||e.close(),this.ws=null,this._state="disconnected",this.emit("state",this._state)}send(e){var t;((t=this.ws)==null?void 0:t.readyState)===WebSocket.OPEN&&this.ws.send(JSON.stringify(e))}scheduleReconnect(){const e=Math.min(Ut*2**this.reconnectAttempt,zt);this.reconnectAttempt++,this.reconnectTimer=setTimeout(()=>{this.reconnectTimer=null,this.connect()},e)}},Nt=class extends Re{constructor(){super(...arguments),E(this,"baseUrl",""),E(this,"_user",null),E(this,"_config",{...ke}),E(this,"_users",new Map),E(this,"_presence",new Map),E(this,"_threads",new Map),E(this,"_reactions",new Map),E(this,"_notifications",[]),E(this,"_activityLogs",[]),E(this,"_typing",new Map),E(this,"_viewports",new Map),E(this,"_selections",new Map)}get user(){return this._user}get config(){return this._config}removeComment(e){for(const[t,i]of this._threads){const s=i.comments.findIndex(n=>n.id===e);if(s!==-1){i.comments.splice(s,1),i.comments.length===0&&this._threads.delete(t),this.emit("threads",this.threads);return}}}get presence(){return[...this._presence.values()]}get threads(){return[...this._threads.values()]}get notifications(){return this._notifications}get unreadCount(){return this._notifications.filter(e=>!e.read).length}markNotificationRead(e){const t=this._notifications.find(i=>i.id===e);t&&!t.read&&(t.read=!0,this.emit("notifications",this._notifications))}markAllNotificationsRead(){let e=!1;for(const t of this._notifications)t.read||(t.read=!0,e=!0);e&&this.emit("notifications",this._notifications)}get activityLogs(){return this._activityLogs}getUser(e){return this._users.get(e)}get users(){return[...this._users.values()]}getReactions(e){return this._reactions.get(e)??[]}getTypingUsers(e){const t=this._typing.get(e);if(!t)return[];const i=Date.now(),s=[];for(const[n,r]of t)i-r<3e3&&s.push(n);return s}get viewports(){return this._viewports}getViewport(e){return this._viewports.get(e)}get selections(){return this._selections}resolveUrl(e){return!this.baseUrl||!e||e.startsWith("http://")||e.startsWith("https://")?e:`${this.baseUrl}${e}`}resolveAttachments(e){return e.map(t=>({...t,url:this.resolveUrl(t.url),thumbnailUrl:t.thumbnailUrl?this.resolveUrl(t.thumbnailUrl):void 0}))}resolveComment(e){return!e.attachments||e.attachments.length===0?e:{...e,attachments:this.resolveAttachments(e.attachments)}}resolveThread(e){return{...e,comments:e.comments.map(t=>this.resolveComment(t))}}handleMessage(e){switch(e.type){case"auth:ok":this._config=e.config??{...ke},this._user=e.user,this._users.clear();for(const t of e.users)this._users.set(t.id,t);this._presence.clear();for(const t of e.presence)this._presence.set(t.user.id,t),this._users.set(t.user.id,t.user);this._users.set(e.user.id,e.user),this._threads.clear();for(const t of e.threads)this._threads.set(t.id,this.resolveThread(t));this._notifications=e.notifications,this._reactions.clear();for(const t of e.reactions){const i=this._reactions.get(t.targetId)??[];i.push(t),this._reactions.set(t.targetId,i)}this._activityLogs=[...e.activityLogs],this.emit("auth",e.user),this.emit("presence",this.presence),this.emit("threads",this.threads),this.emit("notifications",this._notifications),this.emit("reactions",null),this.emit("activity-logs",this._activityLogs);break;case"presence:join":this._presence.set(e.user.user.id,e.user),this._users.set(e.user.user.id,e.user.user),this.emit("presence",this.presence);break;case"presence:leave":this._presence.delete(e.userId),this._viewports.delete(e.userId),this._selections.delete(e.userId);for(const t of this._typing.values())t.delete(e.userId);this.emit("presence",this.presence);break;case"presence:update":{const t=this._presence.get(e.userId);t&&(t.status=e.status,this.emit("presence",this.presence));break}case"cursor:move":this.emit("cursor",{userId:e.userId,position:e.position});break;case"click:perform":this.emit("click",{userId:e.userId,position:e.position});break;case"thread:created":this._threads.set(e.thread.id,this.resolveThread(e.thread)),this.emit("threads",this.threads);break;case"comment:created":{const t=this._threads.get(e.threadId);t&&(t.comments.push(this.resolveComment(e.comment)),t.updatedAt=e.comment.createdAt,this.emit("threads",this.threads));break}case"comment:edited":{const t=this._threads.get(e.threadId);if(t){const i=t.comments.findIndex(s=>s.id===e.comment.id);i!==-1&&(t.comments[i]=this.resolveComment(e.comment)),this.emit("threads",this.threads)}break}case"comment:deleted":{const t=this._threads.get(e.threadId);t&&(t.comments=t.comments.filter(i=>i.id!==e.commentId),t.comments.length===0&&this._threads.delete(e.threadId),this.emit("threads",this.threads));break}case"thread:resolved":{const t=this._threads.get(e.threadId);t&&(t.resolved=e.resolved,this.emit("threads",this.threads));break}case"thread:deleted":this._threads.delete(e.threadId),this.emit("threads",this.threads);break;case"reaction:added":{const t=this._reactions.get(e.reaction.targetId)??[];t.push(e.reaction),this._reactions.set(e.reaction.targetId,t),this.emit("reactions",{targetId:e.reaction.targetId,reactions:t});break}case"reaction:removed":{const t=this._reactions.get(e.targetId);if(t){const i=t.filter(s=>s.id!==e.reactionId);this._reactions.set(e.targetId,i),this.emit("reactions",{targetId:e.targetId,reactions:i})}break}case"notification":this._notifications.unshift(e.notification),this.emit("notifications",this._notifications);break;case"typing:indicator":{this._typing.has(e.threadId)||this._typing.set(e.threadId,new Map),this._typing.get(e.threadId).set(e.userId,Date.now()),this.emit("typing",{threadId:e.threadId,userId:e.userId});break}case"viewport:update":{this._viewports.set(e.userId,{scrollX:e.scrollX,scrollY:e.scrollY,viewportWidth:e.viewportWidth,viewportHeight:e.viewportHeight,pageWidth:e.pageWidth,pageHeight:e.pageHeight}),this.emit("viewport",{userId:e.userId});break}case"selection:update":this._selections.set(e.userId,e.selection),this.emit("selection",{userId:e.userId,selection:e.selection});break;case"emoji:drop":this.emit("emoji-drop",{userId:e.userId,emoji:e.emoji,position:e.position});break;case"draw:stroke":this.emit("draw-stroke",{userId:e.userId,points:e.points,color:e.color,width:e.width});break;case"draw:clear":this.emit("draw-clear",{userId:e.userId});break;case"activity:logged":this._activityLogs.unshift(e.activityLog),this._activityLogs.length>100&&(this._activityLogs=this._activityLogs.slice(0,100)),this.emit("activity-logs",this._activityLogs);break;case"error":this.emit("error",e);break}}reset(){this._user=null,this._config={...ke},this._users.clear(),this._presence.clear(),this._threads.clear(),this._reactions.clear(),this._notifications=[],this._activityLogs=[],this._typing.clear(),this._viewports.clear(),this._selections.clear()}},bt=class extends Re{constructor(e){var t;super(),E(this,"state"),E(this,"connection"),E(this,"config"),E(this,"heartbeatTimer",null),E(this,"lastCursorSend",0),E(this,"pendingCursor",null),E(this,"cursorTimer",null),this.config=e,this.state=new Nt,this.state.baseUrl=(e.endpoint??"").replace(/^ws(s?):/,"http$1:").replace(/\/$/,"");const i=((t=e.endpoint)==null?void 0:t.replace(/^http/,"ws"))??void 0;this.connection=new Dt(i),this.connection.on("message",s=>{this.state.handleMessage(s),this.emit(s.type,s)}),this.connection.on("state",s=>{this.emit("connection",s),s==="connected"?(this.authenticate(),this.startHeartbeat()):s==="disconnected"&&this.stopHeartbeat()})}get connectionState(){return this.connection.state}connect(){this.connection.connect()}disconnect(){this.stopHeartbeat(),this.connection.disconnect(),this.state.reset()}authenticate(){this.send({type:"auth",apiKey:this.config.apiKey,token:this.config.token,room:this.config.room})}send(e){this.connection.send(e)}moveCursor(e){const t=Date.now();this.pendingCursor=e,t-this.lastCursorSend>=Ve?this.flushCursor():this.cursorTimer||(this.cursorTimer=setTimeout(()=>{this.cursorTimer=null,this.flushCursor()},Ve))}flushCursor(){this.pendingCursor&&(this.send({type:"cursor:move",position:this.pendingCursor}),this.lastCursorSend=Date.now(),this.pendingCursor=null)}updatePresence(e){this.send({type:"presence:update",status:e})}startHeartbeat(){this.heartbeatTimer=setInterval(()=>{this.send({type:"presence:update",status:"online"})},jt)}stopHeartbeat(){this.heartbeatTimer&&(clearInterval(this.heartbeatTimer),this.heartbeatTimer=null)}createThread(e,t={}){const i=crypto.randomUUID();return this.send({type:"thread:create",id:i,body:e,mentions:t.mentions??[],position:t.position??null,attachmentIds:t.attachmentIds}),i}reply(e,t,i=[],s){const n=crypto.randomUUID();return this.send({type:"comment:create",threadId:e,id:n,body:t,mentions:i,attachmentIds:s}),n}editComment(e,t,i=[]){this.send({type:"comment:edit",commentId:e,body:t,mentions:i})}deleteComment(e){this.state.removeComment(e),this.send({type:"comment:delete",commentId:e})}resolveThread(e,t=!0){this.send({type:"thread:resolve",threadId:e,resolved:t})}addReaction(e,t,i){this.send({type:"reaction:add",targetId:e,targetType:t,emoji:i})}removeReaction(e){this.send({type:"reaction:remove",reactionId:e})}markRead(e){this.state.markNotificationRead(e),this.send({type:"notification:read",notificationId:e})}markAllRead(){this.state.markAllNotificationsRead(),this.send({type:"notification:read-all"})}performClick(e){this.send({type:"click:perform",position:e})}sendTyping(e){this.send({type:"typing:start",threadId:e})}updateViewport(e){this.send({type:"viewport:update",...e})}updateSelection(e){this.send({type:"selection:update",selection:e})}dropEmoji(e,t){this.send({type:"emoji:drop",emoji:e,position:t})}drawStroke(e,t,i){this.send({type:"draw:stroke",points:e,color:t,width:i})}clearDrawing(){this.send({type:"draw:clear"})}async uploadFile(e){const t=(this.config.endpoint??window.location.origin).replace(/^ws(s?):/,"http$1:"),i=new FormData;i.append("file",e);const s=await fetch(`${t}/api/v1/upload`,{method:"POST",headers:{"X-Pulse-Key":this.config.apiKey,"X-Pulse-Token":this.config.token},body:i});if(!s.ok){const r=await s.json().catch(()=>({error:"Upload failed"}));throw new Error(r.error??"Upload failed")}const n=await s.json();return n.url&&!n.url.startsWith("http")&&(n.url=`${t}${n.url}`),n.thumbnailUrl&&!n.thumbnailUrl.startsWith("http")&&(n.thumbnailUrl=`${t}${n.thumbnailUrl}`),n}setAppearOffline(e){e?(this.stopHeartbeat(),this.send({type:"presence:update",status:"idle"})):(this.startHeartbeat(),this.send({type:"presence:update",status:"online"}))}};/**
30
30
  * @license
31
31
  * Copyright 2019 Google LLC
32
32
  * SPDX-License-Identifier: BSD-3-Clause
33
- */const ue=globalThis,Re=ue.ShadowRoot&&(ue.ShadyCSS===void 0||ue.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,Le=Symbol(),Ve=new WeakMap;let bt=class{constructor(e,t,i){if(this._$cssResult$=!0,i!==Le)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=e,this.t=t}get styleSheet(){let e=this.o;const t=this.t;if(Re&&e===void 0){const i=t!==void 0&&t.length===1;i&&(e=Ve.get(t)),e===void 0&&((this.o=e=new CSSStyleSheet).replaceSync(this.cssText),i&&Ve.set(t,e))}return e}toString(){return this.cssText}};const Nt=o=>new bt(typeof o=="string"?o:o+"",void 0,Le),M=(o,...e)=>{const t=o.length===1?o[0]:e.reduce((i,s,n)=>i+(r=>{if(r._$cssResult$===!0)return r.cssText;if(typeof r=="number")return r;throw Error("Value passed to 'css' function must be a 'css' function result: "+r+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(s)+o[n+1],o[0]);return new bt(t,o,Le)},Ht=(o,e)=>{if(Re)o.adoptedStyleSheets=e.map(t=>t instanceof CSSStyleSheet?t:t.styleSheet);else for(const t of e){const i=document.createElement("style"),s=ue.litNonce;s!==void 0&&i.setAttribute("nonce",s),i.textContent=t.cssText,o.appendChild(i)}},Xe=Re?o=>o:o=>o instanceof CSSStyleSheet?(e=>{let t="";for(const i of e.cssRules)t+=i.cssText;return Nt(t)})(o):o;/**
33
+ */const ue=globalThis,Le=ue.ShadowRoot&&(ue.ShadyCSS===void 0||ue.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,je=Symbol(),Xe=new WeakMap;let xt=class{constructor(e,t,i){if(this._$cssResult$=!0,i!==je)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=e,this.t=t}get styleSheet(){let e=this.o;const t=this.t;if(Le&&e===void 0){const i=t!==void 0&&t.length===1;i&&(e=Xe.get(t)),e===void 0&&((this.o=e=new CSSStyleSheet).replaceSync(this.cssText),i&&Xe.set(t,e))}return e}toString(){return this.cssText}};const Ht=o=>new xt(typeof o=="string"?o:o+"",void 0,je),M=(o,...e)=>{const t=o.length===1?o[0]:e.reduce((i,s,n)=>i+(r=>{if(r._$cssResult$===!0)return r.cssText;if(typeof r=="number")return r;throw Error("Value passed to 'css' function must be a 'css' function result: "+r+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(s)+o[n+1],o[0]);return new xt(t,o,je)},Bt=(o,e)=>{if(Le)o.adoptedStyleSheets=e.map(t=>t instanceof CSSStyleSheet?t:t.styleSheet);else for(const t of e){const i=document.createElement("style"),s=ue.litNonce;s!==void 0&&i.setAttribute("nonce",s),i.textContent=t.cssText,o.appendChild(i)}},Ye=Le?o=>o:o=>o instanceof CSSStyleSheet?(e=>{let t="";for(const i of e.cssRules)t+=i.cssText;return Ht(t)})(o):o;/**
34
34
  * @license
35
35
  * Copyright 2017 Google LLC
36
36
  * SPDX-License-Identifier: BSD-3-Clause
37
- */const{is:Bt,defineProperty:Ft,getOwnPropertyDescriptor:Wt,getOwnPropertyNames:qt,getOwnPropertySymbols:Vt,getPrototypeOf:Xt}=Object,D=globalThis,Ye=D.trustedTypes,Yt=Ye?Ye.emptyScript:"",Ee=D.reactiveElementPolyfillSupport,Q=(o,e)=>o,ge={toAttribute(o,e){switch(e){case Boolean:o=o?Yt:null;break;case Object:case Array:o=o==null?o:JSON.stringify(o)}return o},fromAttribute(o,e){let t=o;switch(e){case Boolean:t=o!==null;break;case Number:t=o===null?null:Number(o);break;case Object:case Array:try{t=JSON.parse(o)}catch{t=null}}return t}},je=(o,e)=>!Bt(o,e),Ke={attribute:!0,type:String,converter:ge,reflect:!1,useDefault:!1,hasChanged:je};Symbol.metadata??(Symbol.metadata=Symbol("metadata")),D.litPropertyMetadata??(D.litPropertyMetadata=new WeakMap);let V=class extends HTMLElement{static addInitializer(e){this._$Ei(),(this.l??(this.l=[])).push(e)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(e,t=Ke){if(t.state&&(t.attribute=!1),this._$Ei(),this.prototype.hasOwnProperty(e)&&((t=Object.create(t)).wrapped=!0),this.elementProperties.set(e,t),!t.noAccessor){const i=Symbol(),s=this.getPropertyDescriptor(e,i,t);s!==void 0&&Ft(this.prototype,e,s)}}static getPropertyDescriptor(e,t,i){const{get:s,set:n}=Wt(this.prototype,e)??{get(){return this[t]},set(r){this[t]=r}};return{get:s,set(r){const a=s==null?void 0:s.call(this);n==null||n.call(this,r),this.requestUpdate(e,a,i)},configurable:!0,enumerable:!0}}static getPropertyOptions(e){return this.elementProperties.get(e)??Ke}static _$Ei(){if(this.hasOwnProperty(Q("elementProperties")))return;const e=Xt(this);e.finalize(),e.l!==void 0&&(this.l=[...e.l]),this.elementProperties=new Map(e.elementProperties)}static finalize(){if(this.hasOwnProperty(Q("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(Q("properties"))){const t=this.properties,i=[...qt(t),...Vt(t)];for(const s of i)this.createProperty(s,t[s])}const e=this[Symbol.metadata];if(e!==null){const t=litPropertyMetadata.get(e);if(t!==void 0)for(const[i,s]of t)this.elementProperties.set(i,s)}this._$Eh=new Map;for(const[t,i]of this.elementProperties){const s=this._$Eu(t,i);s!==void 0&&this._$Eh.set(s,t)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(e){const t=[];if(Array.isArray(e)){const i=new Set(e.flat(1/0).reverse());for(const s of i)t.unshift(Xe(s))}else e!==void 0&&t.push(Xe(e));return t}static _$Eu(e,t){const i=t.attribute;return i===!1?void 0:typeof i=="string"?i:typeof e=="string"?e.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Em=null,this._$Ev()}_$Ev(){var e;this._$ES=new Promise(t=>this.enableUpdating=t),this._$AL=new Map,this._$E_(),this.requestUpdate(),(e=this.constructor.l)==null||e.forEach(t=>t(this))}addController(e){var t;(this._$EO??(this._$EO=new Set)).add(e),this.renderRoot!==void 0&&this.isConnected&&((t=e.hostConnected)==null||t.call(e))}removeController(e){var t;(t=this._$EO)==null||t.delete(e)}_$E_(){const e=new Map,t=this.constructor.elementProperties;for(const i of t.keys())this.hasOwnProperty(i)&&(e.set(i,this[i]),delete this[i]);e.size>0&&(this._$Ep=e)}createRenderRoot(){const e=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return Ht(e,this.constructor.elementStyles),e}connectedCallback(){var e;this.renderRoot??(this.renderRoot=this.createRenderRoot()),this.enableUpdating(!0),(e=this._$EO)==null||e.forEach(t=>{var i;return(i=t.hostConnected)==null?void 0:i.call(t)})}enableUpdating(e){}disconnectedCallback(){var e;(e=this._$EO)==null||e.forEach(t=>{var i;return(i=t.hostDisconnected)==null?void 0:i.call(t)})}attributeChangedCallback(e,t,i){this._$AK(e,i)}_$ET(e,t){var n;const i=this.constructor.elementProperties.get(e),s=this.constructor._$Eu(e,i);if(s!==void 0&&i.reflect===!0){const r=(((n=i.converter)==null?void 0:n.toAttribute)!==void 0?i.converter:ge).toAttribute(t,i.type);this._$Em=e,r==null?this.removeAttribute(s):this.setAttribute(s,r),this._$Em=null}}_$AK(e,t){var n,r;const i=this.constructor,s=i._$Eh.get(e);if(s!==void 0&&this._$Em!==s){const a=i.getPropertyOptions(s),l=typeof a.converter=="function"?{fromAttribute:a.converter}:((n=a.converter)==null?void 0:n.fromAttribute)!==void 0?a.converter:ge;this._$Em=s;const d=l.fromAttribute(t,a.type);this[s]=d??((r=this._$Ej)==null?void 0:r.get(s))??d,this._$Em=null}}requestUpdate(e,t,i,s=!1,n){var r;if(e!==void 0){const a=this.constructor;if(s===!1&&(n=this[e]),i??(i=a.getPropertyOptions(e)),!((i.hasChanged??je)(n,t)||i.useDefault&&i.reflect&&n===((r=this._$Ej)==null?void 0:r.get(e))&&!this.hasAttribute(a._$Eu(e,i))))return;this.C(e,t,i)}this.isUpdatePending===!1&&(this._$ES=this._$EP())}C(e,t,{useDefault:i,reflect:s,wrapped:n},r){i&&!(this._$Ej??(this._$Ej=new Map)).has(e)&&(this._$Ej.set(e,r??t??this[e]),n!==!0||r!==void 0)||(this._$AL.has(e)||(this.hasUpdated||i||(t=void 0),this._$AL.set(e,t)),s===!0&&this._$Em!==e&&(this._$Eq??(this._$Eq=new Set)).add(e))}async _$EP(){this.isUpdatePending=!0;try{await this._$ES}catch(t){Promise.reject(t)}const e=this.scheduleUpdate();return e!=null&&await e,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){var i;if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??(this.renderRoot=this.createRenderRoot()),this._$Ep){for(const[n,r]of this._$Ep)this[n]=r;this._$Ep=void 0}const s=this.constructor.elementProperties;if(s.size>0)for(const[n,r]of s){const{wrapped:a}=r,l=this[n];a!==!0||this._$AL.has(n)||l===void 0||this.C(n,void 0,r,l)}}let e=!1;const t=this._$AL;try{e=this.shouldUpdate(t),e?(this.willUpdate(t),(i=this._$EO)==null||i.forEach(s=>{var n;return(n=s.hostUpdate)==null?void 0:n.call(s)}),this.update(t)):this._$EM()}catch(s){throw e=!1,this._$EM(),s}e&&this._$AE(t)}willUpdate(e){}_$AE(e){var t;(t=this._$EO)==null||t.forEach(i=>{var s;return(s=i.hostUpdated)==null?void 0:s.call(i)}),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(e)),this.updated(e)}_$EM(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$ES}shouldUpdate(e){return!0}update(e){this._$Eq&&(this._$Eq=this._$Eq.forEach(t=>this._$ET(t,this[t]))),this._$EM()}updated(e){}firstUpdated(e){}};V.elementStyles=[],V.shadowRootOptions={mode:"open"},V[Q("elementProperties")]=new Map,V[Q("finalized")]=new Map,Ee==null||Ee({ReactiveElement:V}),(D.reactiveElementVersions??(D.reactiveElementVersions=[])).push("2.1.2");/**
37
+ */const{is:Ft,defineProperty:Wt,getOwnPropertyDescriptor:qt,getOwnPropertyNames:Vt,getOwnPropertySymbols:Xt,getPrototypeOf:Yt}=Object,D=globalThis,Ke=D.trustedTypes,Kt=Ke?Ke.emptyScript:"",Ee=D.reactiveElementPolyfillSupport,Q=(o,e)=>o,ge={toAttribute(o,e){switch(e){case Boolean:o=o?Kt:null;break;case Object:case Array:o=o==null?o:JSON.stringify(o)}return o},fromAttribute(o,e){let t=o;switch(e){case Boolean:t=o!==null;break;case Number:t=o===null?null:Number(o);break;case Object:case Array:try{t=JSON.parse(o)}catch{t=null}}return t}},Ue=(o,e)=>!Ft(o,e),Ge={attribute:!0,type:String,converter:ge,reflect:!1,useDefault:!1,hasChanged:Ue};Symbol.metadata??(Symbol.metadata=Symbol("metadata")),D.litPropertyMetadata??(D.litPropertyMetadata=new WeakMap);let V=class extends HTMLElement{static addInitializer(e){this._$Ei(),(this.l??(this.l=[])).push(e)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(e,t=Ge){if(t.state&&(t.attribute=!1),this._$Ei(),this.prototype.hasOwnProperty(e)&&((t=Object.create(t)).wrapped=!0),this.elementProperties.set(e,t),!t.noAccessor){const i=Symbol(),s=this.getPropertyDescriptor(e,i,t);s!==void 0&&Wt(this.prototype,e,s)}}static getPropertyDescriptor(e,t,i){const{get:s,set:n}=qt(this.prototype,e)??{get(){return this[t]},set(r){this[t]=r}};return{get:s,set(r){const a=s==null?void 0:s.call(this);n==null||n.call(this,r),this.requestUpdate(e,a,i)},configurable:!0,enumerable:!0}}static getPropertyOptions(e){return this.elementProperties.get(e)??Ge}static _$Ei(){if(this.hasOwnProperty(Q("elementProperties")))return;const e=Yt(this);e.finalize(),e.l!==void 0&&(this.l=[...e.l]),this.elementProperties=new Map(e.elementProperties)}static finalize(){if(this.hasOwnProperty(Q("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(Q("properties"))){const t=this.properties,i=[...Vt(t),...Xt(t)];for(const s of i)this.createProperty(s,t[s])}const e=this[Symbol.metadata];if(e!==null){const t=litPropertyMetadata.get(e);if(t!==void 0)for(const[i,s]of t)this.elementProperties.set(i,s)}this._$Eh=new Map;for(const[t,i]of this.elementProperties){const s=this._$Eu(t,i);s!==void 0&&this._$Eh.set(s,t)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(e){const t=[];if(Array.isArray(e)){const i=new Set(e.flat(1/0).reverse());for(const s of i)t.unshift(Ye(s))}else e!==void 0&&t.push(Ye(e));return t}static _$Eu(e,t){const i=t.attribute;return i===!1?void 0:typeof i=="string"?i:typeof e=="string"?e.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Em=null,this._$Ev()}_$Ev(){var e;this._$ES=new Promise(t=>this.enableUpdating=t),this._$AL=new Map,this._$E_(),this.requestUpdate(),(e=this.constructor.l)==null||e.forEach(t=>t(this))}addController(e){var t;(this._$EO??(this._$EO=new Set)).add(e),this.renderRoot!==void 0&&this.isConnected&&((t=e.hostConnected)==null||t.call(e))}removeController(e){var t;(t=this._$EO)==null||t.delete(e)}_$E_(){const e=new Map,t=this.constructor.elementProperties;for(const i of t.keys())this.hasOwnProperty(i)&&(e.set(i,this[i]),delete this[i]);e.size>0&&(this._$Ep=e)}createRenderRoot(){const e=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return Bt(e,this.constructor.elementStyles),e}connectedCallback(){var e;this.renderRoot??(this.renderRoot=this.createRenderRoot()),this.enableUpdating(!0),(e=this._$EO)==null||e.forEach(t=>{var i;return(i=t.hostConnected)==null?void 0:i.call(t)})}enableUpdating(e){}disconnectedCallback(){var e;(e=this._$EO)==null||e.forEach(t=>{var i;return(i=t.hostDisconnected)==null?void 0:i.call(t)})}attributeChangedCallback(e,t,i){this._$AK(e,i)}_$ET(e,t){var n;const i=this.constructor.elementProperties.get(e),s=this.constructor._$Eu(e,i);if(s!==void 0&&i.reflect===!0){const r=(((n=i.converter)==null?void 0:n.toAttribute)!==void 0?i.converter:ge).toAttribute(t,i.type);this._$Em=e,r==null?this.removeAttribute(s):this.setAttribute(s,r),this._$Em=null}}_$AK(e,t){var n,r;const i=this.constructor,s=i._$Eh.get(e);if(s!==void 0&&this._$Em!==s){const a=i.getPropertyOptions(s),l=typeof a.converter=="function"?{fromAttribute:a.converter}:((n=a.converter)==null?void 0:n.fromAttribute)!==void 0?a.converter:ge;this._$Em=s;const d=l.fromAttribute(t,a.type);this[s]=d??((r=this._$Ej)==null?void 0:r.get(s))??d,this._$Em=null}}requestUpdate(e,t,i,s=!1,n){var r;if(e!==void 0){const a=this.constructor;if(s===!1&&(n=this[e]),i??(i=a.getPropertyOptions(e)),!((i.hasChanged??Ue)(n,t)||i.useDefault&&i.reflect&&n===((r=this._$Ej)==null?void 0:r.get(e))&&!this.hasAttribute(a._$Eu(e,i))))return;this.C(e,t,i)}this.isUpdatePending===!1&&(this._$ES=this._$EP())}C(e,t,{useDefault:i,reflect:s,wrapped:n},r){i&&!(this._$Ej??(this._$Ej=new Map)).has(e)&&(this._$Ej.set(e,r??t??this[e]),n!==!0||r!==void 0)||(this._$AL.has(e)||(this.hasUpdated||i||(t=void 0),this._$AL.set(e,t)),s===!0&&this._$Em!==e&&(this._$Eq??(this._$Eq=new Set)).add(e))}async _$EP(){this.isUpdatePending=!0;try{await this._$ES}catch(t){Promise.reject(t)}const e=this.scheduleUpdate();return e!=null&&await e,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){var i;if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??(this.renderRoot=this.createRenderRoot()),this._$Ep){for(const[n,r]of this._$Ep)this[n]=r;this._$Ep=void 0}const s=this.constructor.elementProperties;if(s.size>0)for(const[n,r]of s){const{wrapped:a}=r,l=this[n];a!==!0||this._$AL.has(n)||l===void 0||this.C(n,void 0,r,l)}}let e=!1;const t=this._$AL;try{e=this.shouldUpdate(t),e?(this.willUpdate(t),(i=this._$EO)==null||i.forEach(s=>{var n;return(n=s.hostUpdate)==null?void 0:n.call(s)}),this.update(t)):this._$EM()}catch(s){throw e=!1,this._$EM(),s}e&&this._$AE(t)}willUpdate(e){}_$AE(e){var t;(t=this._$EO)==null||t.forEach(i=>{var s;return(s=i.hostUpdated)==null?void 0:s.call(i)}),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(e)),this.updated(e)}_$EM(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$ES}shouldUpdate(e){return!0}update(e){this._$Eq&&(this._$Eq=this._$Eq.forEach(t=>this._$ET(t,this[t]))),this._$EM()}updated(e){}firstUpdated(e){}};V.elementStyles=[],V.shadowRootOptions={mode:"open"},V[Q("elementProperties")]=new Map,V[Q("finalized")]=new Map,Ee==null||Ee({ReactiveElement:V}),(D.reactiveElementVersions??(D.reactiveElementVersions=[])).push("2.1.2");/**
38
38
  * @license
39
39
  * Copyright 2017 Google LLC
40
40
  * SPDX-License-Identifier: BSD-3-Clause
41
- */const ee=globalThis,Ge=o=>o,ve=ee.trustedTypes,Je=ve?ve.createPolicy("lit-html",{createHTML:o=>o}):void 0,xt="$lit$",U=`lit$${Math.random().toFixed(9).slice(2)}$`,yt="?"+U,Kt=`<${yt}>`,F=document,ie=()=>F.createComment(""),se=o=>o===null||typeof o!="object"&&typeof o!="function",ze=Array.isArray,Gt=o=>ze(o)||typeof(o==null?void 0:o[Symbol.iterator])=="function",Ce=`[
42
- \f\r]`,Z=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,Ze=/-->/g,Qe=/>/g,N=RegExp(`>|${Ce}(?:([^\\s"'>=/]+)(${Ce}*=${Ce}*(?:[^
43
- \f\r"'\`<>=]|("|')|))|$)`,"g"),et=/'/g,tt=/"/g,wt=/^(?:script|style|textarea|title)$/i,$t=o=>(e,...t)=>({_$litType$:o,strings:e,values:t}),u=$t(1),Jt=$t(2),W=Symbol.for("lit-noChange"),v=Symbol.for("lit-nothing"),it=new WeakMap,H=F.createTreeWalker(F,129);function kt(o,e){if(!ze(o)||!o.hasOwnProperty("raw"))throw Error("invalid template strings array");return Je!==void 0?Je.createHTML(e):e}const Zt=(o,e)=>{const t=o.length-1,i=[];let s,n=e===2?"<svg>":e===3?"<math>":"",r=Z;for(let a=0;a<t;a++){const l=o[a];let d,c,h=-1,p=0;for(;p<l.length&&(r.lastIndex=p,c=r.exec(l),c!==null);)p=r.lastIndex,r===Z?c[1]==="!--"?r=Ze:c[1]!==void 0?r=Qe:c[2]!==void 0?(wt.test(c[2])&&(s=RegExp("</"+c[2],"g")),r=N):c[3]!==void 0&&(r=N):r===N?c[0]===">"?(r=s??Z,h=-1):c[1]===void 0?h=-2:(h=r.lastIndex-c[2].length,d=c[1],r=c[3]===void 0?N:c[3]==='"'?tt:et):r===tt||r===et?r=N:r===Ze||r===Qe?r=Z:(r=N,s=void 0);const m=r===N&&o[a+1].startsWith("/>")?" ":"";n+=r===Z?l+Kt:h>=0?(i.push(d),l.slice(0,h)+xt+l.slice(h)+U+m):l+U+(h===-2?a:m)}return[kt(o,n+(o[t]||"<?>")+(e===2?"</svg>":e===3?"</math>":"")),i]};class ne{constructor({strings:e,_$litType$:t},i){let s;this.parts=[];let n=0,r=0;const a=e.length-1,l=this.parts,[d,c]=Zt(e,t);if(this.el=ne.createElement(d,i),H.currentNode=this.el.content,t===2||t===3){const h=this.el.content.firstChild;h.replaceWith(...h.childNodes)}for(;(s=H.nextNode())!==null&&l.length<a;){if(s.nodeType===1){if(s.hasAttributes())for(const h of s.getAttributeNames())if(h.endsWith(xt)){const p=c[r++],m=s.getAttribute(h).split(U),g=/([.?@])?(.*)/.exec(p);l.push({type:1,index:n,name:g[2],strings:m,ctor:g[1]==="."?ei:g[1]==="?"?ti:g[1]==="@"?ii:ye}),s.removeAttribute(h)}else h.startsWith(U)&&(l.push({type:6,index:n}),s.removeAttribute(h));if(wt.test(s.tagName)){const h=s.textContent.split(U),p=h.length-1;if(p>0){s.textContent=ve?ve.emptyScript:"";for(let m=0;m<p;m++)s.append(h[m],ie()),H.nextNode(),l.push({type:2,index:++n});s.append(h[p],ie())}}}else if(s.nodeType===8)if(s.data===yt)l.push({type:2,index:n});else{let h=-1;for(;(h=s.data.indexOf(U,h+1))!==-1;)l.push({type:7,index:n}),h+=U.length-1}n++}}static createElement(e,t){const i=F.createElement("template");return i.innerHTML=e,i}}function X(o,e,t=o,i){var r,a;if(e===W)return e;let s=i!==void 0?(r=t._$Co)==null?void 0:r[i]:t._$Cl;const n=se(e)?void 0:e._$litDirective$;return(s==null?void 0:s.constructor)!==n&&((a=s==null?void 0:s._$AO)==null||a.call(s,!1),n===void 0?s=void 0:(s=new n(o),s._$AT(o,t,i)),i!==void 0?(t._$Co??(t._$Co=[]))[i]=s:t._$Cl=s),s!==void 0&&(e=X(o,s._$AS(o,e.values),s,i)),e}class Qt{constructor(e,t){this._$AV=[],this._$AN=void 0,this._$AD=e,this._$AM=t}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(e){const{el:{content:t},parts:i}=this._$AD,s=((e==null?void 0:e.creationScope)??F).importNode(t,!0);H.currentNode=s;let n=H.nextNode(),r=0,a=0,l=i[0];for(;l!==void 0;){if(r===l.index){let d;l.type===2?d=new le(n,n.nextSibling,this,e):l.type===1?d=new l.ctor(n,l.name,l.strings,this,e):l.type===6&&(d=new si(n,this,e)),this._$AV.push(d),l=i[++a]}r!==(l==null?void 0:l.index)&&(n=H.nextNode(),r++)}return H.currentNode=F,s}p(e){let t=0;for(const i of this._$AV)i!==void 0&&(i.strings!==void 0?(i._$AI(e,i,t),t+=i.strings.length-2):i._$AI(e[t])),t++}}class le{get _$AU(){var e;return((e=this._$AM)==null?void 0:e._$AU)??this._$Cv}constructor(e,t,i,s){this.type=2,this._$AH=v,this._$AN=void 0,this._$AA=e,this._$AB=t,this._$AM=i,this.options=s,this._$Cv=(s==null?void 0:s.isConnected)??!0}get parentNode(){let e=this._$AA.parentNode;const t=this._$AM;return t!==void 0&&(e==null?void 0:e.nodeType)===11&&(e=t.parentNode),e}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(e,t=this){e=X(this,e,t),se(e)?e===v||e==null||e===""?(this._$AH!==v&&this._$AR(),this._$AH=v):e!==this._$AH&&e!==W&&this._(e):e._$litType$!==void 0?this.$(e):e.nodeType!==void 0?this.T(e):Gt(e)?this.k(e):this._(e)}O(e){return this._$AA.parentNode.insertBefore(e,this._$AB)}T(e){this._$AH!==e&&(this._$AR(),this._$AH=this.O(e))}_(e){this._$AH!==v&&se(this._$AH)?this._$AA.nextSibling.data=e:this.T(F.createTextNode(e)),this._$AH=e}$(e){var n;const{values:t,_$litType$:i}=e,s=typeof i=="number"?this._$AC(e):(i.el===void 0&&(i.el=ne.createElement(kt(i.h,i.h[0]),this.options)),i);if(((n=this._$AH)==null?void 0:n._$AD)===s)this._$AH.p(t);else{const r=new Qt(s,this),a=r.u(this.options);r.p(t),this.T(a),this._$AH=r}}_$AC(e){let t=it.get(e.strings);return t===void 0&&it.set(e.strings,t=new ne(e)),t}k(e){ze(this._$AH)||(this._$AH=[],this._$AR());const t=this._$AH;let i,s=0;for(const n of e)s===t.length?t.push(i=new le(this.O(ie()),this.O(ie()),this,this.options)):i=t[s],i._$AI(n),s++;s<t.length&&(this._$AR(i&&i._$AB.nextSibling,s),t.length=s)}_$AR(e=this._$AA.nextSibling,t){var i;for((i=this._$AP)==null?void 0:i.call(this,!1,!0,t);e!==this._$AB;){const s=Ge(e).nextSibling;Ge(e).remove(),e=s}}setConnected(e){var t;this._$AM===void 0&&(this._$Cv=e,(t=this._$AP)==null||t.call(this,e))}}class ye{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(e,t,i,s,n){this.type=1,this._$AH=v,this._$AN=void 0,this.element=e,this.name=t,this._$AM=s,this.options=n,i.length>2||i[0]!==""||i[1]!==""?(this._$AH=Array(i.length-1).fill(new String),this.strings=i):this._$AH=v}_$AI(e,t=this,i,s){const n=this.strings;let r=!1;if(n===void 0)e=X(this,e,t,0),r=!se(e)||e!==this._$AH&&e!==W,r&&(this._$AH=e);else{const a=e;let l,d;for(e=n[0],l=0;l<n.length-1;l++)d=X(this,a[i+l],t,l),d===W&&(d=this._$AH[l]),r||(r=!se(d)||d!==this._$AH[l]),d===v?e=v:e!==v&&(e+=(d??"")+n[l+1]),this._$AH[l]=d}r&&!s&&this.j(e)}j(e){e===v?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,e??"")}}class ei extends ye{constructor(){super(...arguments),this.type=3}j(e){this.element[this.name]=e===v?void 0:e}}class ti extends ye{constructor(){super(...arguments),this.type=4}j(e){this.element.toggleAttribute(this.name,!!e&&e!==v)}}class ii extends ye{constructor(e,t,i,s,n){super(e,t,i,s,n),this.type=5}_$AI(e,t=this){if((e=X(this,e,t,0)??v)===W)return;const i=this._$AH,s=e===v&&i!==v||e.capture!==i.capture||e.once!==i.once||e.passive!==i.passive,n=e!==v&&(i===v||s);s&&this.element.removeEventListener(this.name,this,i),n&&this.element.addEventListener(this.name,this,e),this._$AH=e}handleEvent(e){var t;typeof this._$AH=="function"?this._$AH.call(((t=this.options)==null?void 0:t.host)??this.element,e):this._$AH.handleEvent(e)}}class si{constructor(e,t,i){this.element=e,this.type=6,this._$AN=void 0,this._$AM=t,this.options=i}get _$AU(){return this._$AM._$AU}_$AI(e){X(this,e)}}const Pe=ee.litHtmlPolyfillSupport;Pe==null||Pe(ne,le),(ee.litHtmlVersions??(ee.litHtmlVersions=[])).push("3.3.2");const ni=(o,e,t)=>{const i=(t==null?void 0:t.renderBefore)??e;let s=i._$litPart$;if(s===void 0){const n=(t==null?void 0:t.renderBefore)??null;i._$litPart$=s=new le(e.insertBefore(ie(),n),n,void 0,t??{})}return s._$AI(o),s};/**
41
+ */const ee=globalThis,Je=o=>o,ve=ee.trustedTypes,Ze=ve?ve.createPolicy("lit-html",{createHTML:o=>o}):void 0,yt="$lit$",z=`lit$${Math.random().toFixed(9).slice(2)}$`,wt="?"+z,Gt=`<${wt}>`,F=document,ie=()=>F.createComment(""),se=o=>o===null||typeof o!="object"&&typeof o!="function",ze=Array.isArray,Jt=o=>ze(o)||typeof(o==null?void 0:o[Symbol.iterator])=="function",Ce=`[
42
+ \f\r]`,Z=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,Qe=/-->/g,et=/>/g,N=RegExp(`>|${Ce}(?:([^\\s"'>=/]+)(${Ce}*=${Ce}*(?:[^
43
+ \f\r"'\`<>=]|("|')|))|$)`,"g"),tt=/'/g,it=/"/g,$t=/^(?:script|style|textarea|title)$/i,kt=o=>(e,...t)=>({_$litType$:o,strings:e,values:t}),p=kt(1),Zt=kt(2),W=Symbol.for("lit-noChange"),g=Symbol.for("lit-nothing"),st=new WeakMap,H=F.createTreeWalker(F,129);function Et(o,e){if(!ze(o)||!o.hasOwnProperty("raw"))throw Error("invalid template strings array");return Ze!==void 0?Ze.createHTML(e):e}const Qt=(o,e)=>{const t=o.length-1,i=[];let s,n=e===2?"<svg>":e===3?"<math>":"",r=Z;for(let a=0;a<t;a++){const l=o[a];let d,c,h=-1,u=0;for(;u<l.length&&(r.lastIndex=u,c=r.exec(l),c!==null);)u=r.lastIndex,r===Z?c[1]==="!--"?r=Qe:c[1]!==void 0?r=et:c[2]!==void 0?($t.test(c[2])&&(s=RegExp("</"+c[2],"g")),r=N):c[3]!==void 0&&(r=N):r===N?c[0]===">"?(r=s??Z,h=-1):c[1]===void 0?h=-2:(h=r.lastIndex-c[2].length,d=c[1],r=c[3]===void 0?N:c[3]==='"'?it:tt):r===it||r===tt?r=N:r===Qe||r===et?r=Z:(r=N,s=void 0);const f=r===N&&o[a+1].startsWith("/>")?" ":"";n+=r===Z?l+Gt:h>=0?(i.push(d),l.slice(0,h)+yt+l.slice(h)+z+f):l+z+(h===-2?a:f)}return[Et(o,n+(o[t]||"<?>")+(e===2?"</svg>":e===3?"</math>":"")),i]};class ne{constructor({strings:e,_$litType$:t},i){let s;this.parts=[];let n=0,r=0;const a=e.length-1,l=this.parts,[d,c]=Qt(e,t);if(this.el=ne.createElement(d,i),H.currentNode=this.el.content,t===2||t===3){const h=this.el.content.firstChild;h.replaceWith(...h.childNodes)}for(;(s=H.nextNode())!==null&&l.length<a;){if(s.nodeType===1){if(s.hasAttributes())for(const h of s.getAttributeNames())if(h.endsWith(yt)){const u=c[r++],f=s.getAttribute(h).split(z),b=/([.?@])?(.*)/.exec(u);l.push({type:1,index:n,name:b[2],strings:f,ctor:b[1]==="."?ti:b[1]==="?"?ii:b[1]==="@"?si:ye}),s.removeAttribute(h)}else h.startsWith(z)&&(l.push({type:6,index:n}),s.removeAttribute(h));if($t.test(s.tagName)){const h=s.textContent.split(z),u=h.length-1;if(u>0){s.textContent=ve?ve.emptyScript:"";for(let f=0;f<u;f++)s.append(h[f],ie()),H.nextNode(),l.push({type:2,index:++n});s.append(h[u],ie())}}}else if(s.nodeType===8)if(s.data===wt)l.push({type:2,index:n});else{let h=-1;for(;(h=s.data.indexOf(z,h+1))!==-1;)l.push({type:7,index:n}),h+=z.length-1}n++}}static createElement(e,t){const i=F.createElement("template");return i.innerHTML=e,i}}function X(o,e,t=o,i){var r,a;if(e===W)return e;let s=i!==void 0?(r=t._$Co)==null?void 0:r[i]:t._$Cl;const n=se(e)?void 0:e._$litDirective$;return(s==null?void 0:s.constructor)!==n&&((a=s==null?void 0:s._$AO)==null||a.call(s,!1),n===void 0?s=void 0:(s=new n(o),s._$AT(o,t,i)),i!==void 0?(t._$Co??(t._$Co=[]))[i]=s:t._$Cl=s),s!==void 0&&(e=X(o,s._$AS(o,e.values),s,i)),e}class ei{constructor(e,t){this._$AV=[],this._$AN=void 0,this._$AD=e,this._$AM=t}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(e){const{el:{content:t},parts:i}=this._$AD,s=((e==null?void 0:e.creationScope)??F).importNode(t,!0);H.currentNode=s;let n=H.nextNode(),r=0,a=0,l=i[0];for(;l!==void 0;){if(r===l.index){let d;l.type===2?d=new le(n,n.nextSibling,this,e):l.type===1?d=new l.ctor(n,l.name,l.strings,this,e):l.type===6&&(d=new ni(n,this,e)),this._$AV.push(d),l=i[++a]}r!==(l==null?void 0:l.index)&&(n=H.nextNode(),r++)}return H.currentNode=F,s}p(e){let t=0;for(const i of this._$AV)i!==void 0&&(i.strings!==void 0?(i._$AI(e,i,t),t+=i.strings.length-2):i._$AI(e[t])),t++}}class le{get _$AU(){var e;return((e=this._$AM)==null?void 0:e._$AU)??this._$Cv}constructor(e,t,i,s){this.type=2,this._$AH=g,this._$AN=void 0,this._$AA=e,this._$AB=t,this._$AM=i,this.options=s,this._$Cv=(s==null?void 0:s.isConnected)??!0}get parentNode(){let e=this._$AA.parentNode;const t=this._$AM;return t!==void 0&&(e==null?void 0:e.nodeType)===11&&(e=t.parentNode),e}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(e,t=this){e=X(this,e,t),se(e)?e===g||e==null||e===""?(this._$AH!==g&&this._$AR(),this._$AH=g):e!==this._$AH&&e!==W&&this._(e):e._$litType$!==void 0?this.$(e):e.nodeType!==void 0?this.T(e):Jt(e)?this.k(e):this._(e)}O(e){return this._$AA.parentNode.insertBefore(e,this._$AB)}T(e){this._$AH!==e&&(this._$AR(),this._$AH=this.O(e))}_(e){this._$AH!==g&&se(this._$AH)?this._$AA.nextSibling.data=e:this.T(F.createTextNode(e)),this._$AH=e}$(e){var n;const{values:t,_$litType$:i}=e,s=typeof i=="number"?this._$AC(e):(i.el===void 0&&(i.el=ne.createElement(Et(i.h,i.h[0]),this.options)),i);if(((n=this._$AH)==null?void 0:n._$AD)===s)this._$AH.p(t);else{const r=new ei(s,this),a=r.u(this.options);r.p(t),this.T(a),this._$AH=r}}_$AC(e){let t=st.get(e.strings);return t===void 0&&st.set(e.strings,t=new ne(e)),t}k(e){ze(this._$AH)||(this._$AH=[],this._$AR());const t=this._$AH;let i,s=0;for(const n of e)s===t.length?t.push(i=new le(this.O(ie()),this.O(ie()),this,this.options)):i=t[s],i._$AI(n),s++;s<t.length&&(this._$AR(i&&i._$AB.nextSibling,s),t.length=s)}_$AR(e=this._$AA.nextSibling,t){var i;for((i=this._$AP)==null?void 0:i.call(this,!1,!0,t);e!==this._$AB;){const s=Je(e).nextSibling;Je(e).remove(),e=s}}setConnected(e){var t;this._$AM===void 0&&(this._$Cv=e,(t=this._$AP)==null||t.call(this,e))}}class ye{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(e,t,i,s,n){this.type=1,this._$AH=g,this._$AN=void 0,this.element=e,this.name=t,this._$AM=s,this.options=n,i.length>2||i[0]!==""||i[1]!==""?(this._$AH=Array(i.length-1).fill(new String),this.strings=i):this._$AH=g}_$AI(e,t=this,i,s){const n=this.strings;let r=!1;if(n===void 0)e=X(this,e,t,0),r=!se(e)||e!==this._$AH&&e!==W,r&&(this._$AH=e);else{const a=e;let l,d;for(e=n[0],l=0;l<n.length-1;l++)d=X(this,a[i+l],t,l),d===W&&(d=this._$AH[l]),r||(r=!se(d)||d!==this._$AH[l]),d===g?e=g:e!==g&&(e+=(d??"")+n[l+1]),this._$AH[l]=d}r&&!s&&this.j(e)}j(e){e===g?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,e??"")}}class ti extends ye{constructor(){super(...arguments),this.type=3}j(e){this.element[this.name]=e===g?void 0:e}}class ii extends ye{constructor(){super(...arguments),this.type=4}j(e){this.element.toggleAttribute(this.name,!!e&&e!==g)}}class si extends ye{constructor(e,t,i,s,n){super(e,t,i,s,n),this.type=5}_$AI(e,t=this){if((e=X(this,e,t,0)??g)===W)return;const i=this._$AH,s=e===g&&i!==g||e.capture!==i.capture||e.once!==i.once||e.passive!==i.passive,n=e!==g&&(i===g||s);s&&this.element.removeEventListener(this.name,this,i),n&&this.element.addEventListener(this.name,this,e),this._$AH=e}handleEvent(e){var t;typeof this._$AH=="function"?this._$AH.call(((t=this.options)==null?void 0:t.host)??this.element,e):this._$AH.handleEvent(e)}}class ni{constructor(e,t,i){this.element=e,this.type=6,this._$AN=void 0,this._$AM=t,this.options=i}get _$AU(){return this._$AM._$AU}_$AI(e){X(this,e)}}const Pe=ee.litHtmlPolyfillSupport;Pe==null||Pe(ne,le),(ee.litHtmlVersions??(ee.litHtmlVersions=[])).push("3.3.2");const oi=(o,e,t)=>{const i=(t==null?void 0:t.renderBefore)??e;let s=i._$litPart$;if(s===void 0){const n=(t==null?void 0:t.renderBefore)??null;i._$litPart$=s=new le(e.insertBefore(ie(),n),n,void 0,t??{})}return s._$AI(o),s};/**
44
44
  * @license
45
45
  * Copyright 2017 Google LLC
46
46
  * SPDX-License-Identifier: BSD-3-Clause
47
- */const B=globalThis;let S=class extends V{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){var t;const e=super.createRenderRoot();return(t=this.renderOptions).renderBefore??(t.renderBefore=e.firstChild),e}update(e){const t=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(e),this._$Do=ni(t,this.renderRoot,this.renderOptions)}connectedCallback(){var e;super.connectedCallback(),(e=this._$Do)==null||e.setConnected(!0)}disconnectedCallback(){var e;super.disconnectedCallback(),(e=this._$Do)==null||e.setConnected(!1)}render(){return W}};var mt;S._$litElement$=!0,S.finalized=!0,(mt=B.litElementHydrateSupport)==null||mt.call(B,{LitElement:S});const Te=B.litElementPolyfillSupport;Te==null||Te({LitElement:S});(B.litElementVersions??(B.litElementVersions=[])).push("4.2.2");/**
47
+ */const B=globalThis;let A=class extends V{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){var t;const e=super.createRenderRoot();return(t=this.renderOptions).renderBefore??(t.renderBefore=e.firstChild),e}update(e){const t=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(e),this._$Do=oi(t,this.renderRoot,this.renderOptions)}connectedCallback(){var e;super.connectedCallback(),(e=this._$Do)==null||e.setConnected(!0)}disconnectedCallback(){var e;super.disconnectedCallback(),(e=this._$Do)==null||e.setConnected(!1)}render(){return W}};var gt;A._$litElement$=!0,A.finalized=!0,(gt=B.litElementHydrateSupport)==null||gt.call(B,{LitElement:A});const Te=B.litElementPolyfillSupport;Te==null||Te({LitElement:A});(B.litElementVersions??(B.litElementVersions=[])).push("4.2.2");/**
48
48
  * @license
49
49
  * Copyright 2017 Google LLC
50
50
  * SPDX-License-Identifier: BSD-3-Clause
@@ -52,19 +52,19 @@
52
52
  * @license
53
53
  * Copyright 2017 Google LLC
54
54
  * SPDX-License-Identifier: BSD-3-Clause
55
- */const oi={attribute:!0,type:String,converter:ge,reflect:!1,hasChanged:je},ri=(o=oi,e,t)=>{const{kind:i,metadata:s}=t;let n=globalThis.litPropertyMetadata.get(s);if(n===void 0&&globalThis.litPropertyMetadata.set(s,n=new Map),i==="setter"&&((o=Object.create(o)).wrapped=!0),n.set(t.name,o),i==="accessor"){const{name:r}=t;return{set(a){const l=e.get.call(this);e.set.call(this,a),this.requestUpdate(r,l,o,!0,a)},init(a){return a!==void 0&&this.C(r,void 0,o,a),a}}}if(i==="setter"){const{name:r}=t;return function(a){const l=this[r];e.call(this,a),this.requestUpdate(r,l,o,!0,a)}}throw Error("Unsupported decorator location: "+i)};function x(o){return(e,t)=>typeof t=="object"?ri(o,e,t):((i,s,n)=>{const r=s.hasOwnProperty(n);return s.constructor.createProperty(n,i),r?Object.getOwnPropertyDescriptor(s,n):void 0})(o,e,t)}/**
55
+ */const ri={attribute:!0,type:String,converter:ge,reflect:!1,hasChanged:Ue},ai=(o=ri,e,t)=>{const{kind:i,metadata:s}=t;let n=globalThis.litPropertyMetadata.get(s);if(n===void 0&&globalThis.litPropertyMetadata.set(s,n=new Map),i==="setter"&&((o=Object.create(o)).wrapped=!0),n.set(t.name,o),i==="accessor"){const{name:r}=t;return{set(a){const l=e.get.call(this);e.set.call(this,a),this.requestUpdate(r,l,o,!0,a)},init(a){return a!==void 0&&this.C(r,void 0,o,a),a}}}if(i==="setter"){const{name:r}=t;return function(a){const l=this[r];e.call(this,a),this.requestUpdate(r,l,o,!0,a)}}throw Error("Unsupported decorator location: "+i)};function w(o){return(e,t)=>typeof t=="object"?ai(o,e,t):((i,s,n)=>{const r=s.hasOwnProperty(n);return s.constructor.createProperty(n,i),r?Object.getOwnPropertyDescriptor(s,n):void 0})(o,e,t)}/**
56
56
  * @license
57
57
  * Copyright 2017 Google LLC
58
58
  * SPDX-License-Identifier: BSD-3-Clause
59
- */function $(o){return x({...o,state:!0,attribute:!1})}const Y="pulse-client";var ai=Object.defineProperty,li=Object.getOwnPropertyDescriptor,K=(o,e,t,i)=>{for(var s=i>1?void 0:i?li(e,t):e,n=o.length-1,r;n>=0;n--)(r=o[n])&&(s=(i?r(e,t,s):r(s))||s);return i&&s&&ai(e,t,s),s};exports.PulseProvider=class extends S{constructor(){super(...arguments),this.apiKey="",this.token="",this.room=""}connectedCallback(){super.connectedCallback();const e={apiKey:this.apiKey,token:this.token,room:this.room,endpoint:this.endpoint};this.client=new vt(e),this.client.connect()}disconnectedCallback(){var e;super.disconnectedCallback(),(e=this.client)==null||e.disconnect()}render(){return u`<slot></slot>`}};K([x({attribute:"api-key"})],exports.PulseProvider.prototype,"apiKey",2);K([x()],exports.PulseProvider.prototype,"token",2);K([x()],exports.PulseProvider.prototype,"room",2);K([x()],exports.PulseProvider.prototype,"endpoint",2);K([It({context:Y})],exports.PulseProvider.prototype,"client",2);exports.PulseProvider=K([L("pulse-provider")],exports.PulseProvider);var ci=Object.defineProperty,di=Object.getOwnPropertyDescriptor,we=(o,e,t,i)=>{for(var s=i>1?void 0:i?di(e,t):e,n=o.length-1,r;n>=0;n--)(r=o[n])&&(s=(i?r(e,t,s):r(s))||s);return i&&s&&ci(e,t,s),s};exports.PulsePresence=class extends S{constructor(){super(...arguments),this.maxVisible=5,this.users=[]}connectedCallback(){super.connectedCallback(),this.setupListener()}disconnectedCallback(){var e;super.disconnectedCallback(),(e=this.unsub)==null||e.call(this)}updated(e){var t;e.has("client")&&this.client&&((t=this.unsub)==null||t.call(this),this.setupListener())}setupListener(){this.client&&(this.users=this.client.state.presence,this.unsub=this.client.state.on("presence",e=>{this.users=e}))}getInitials(e){return e.split(" ").map(t=>t[0]).join("").toUpperCase().slice(0,2)}render(){const e=this.users.slice(0,this.maxVisible),t=this.users.length-this.maxVisible;return u`
59
+ */function k(o){return w({...o,state:!0,attribute:!1})}const Y="pulse-client";var li=Object.defineProperty,ci=Object.getOwnPropertyDescriptor,K=(o,e,t,i)=>{for(var s=i>1?void 0:i?ci(e,t):e,n=o.length-1,r;n>=0;n--)(r=o[n])&&(s=(i?r(e,t,s):r(s))||s);return i&&s&&li(e,t,s),s};exports.PulseProvider=class extends A{constructor(){super(...arguments),this.apiKey="",this.token="",this.room=""}connectedCallback(){super.connectedCallback();const e={apiKey:this.apiKey,token:this.token,room:this.room,endpoint:this.endpoint};this.client=new bt(e),this.client.connect()}disconnectedCallback(){var e;super.disconnectedCallback(),(e=this.client)==null||e.disconnect()}render(){return p`<slot></slot>`}};K([w({attribute:"api-key"})],exports.PulseProvider.prototype,"apiKey",2);K([w()],exports.PulseProvider.prototype,"token",2);K([w()],exports.PulseProvider.prototype,"room",2);K([w()],exports.PulseProvider.prototype,"endpoint",2);K([Mt({context:Y})],exports.PulseProvider.prototype,"client",2);exports.PulseProvider=K([L("pulse-provider")],exports.PulseProvider);var di=Object.defineProperty,hi=Object.getOwnPropertyDescriptor,we=(o,e,t,i)=>{for(var s=i>1?void 0:i?hi(e,t):e,n=o.length-1,r;n>=0;n--)(r=o[n])&&(s=(i?r(e,t,s):r(s))||s);return i&&s&&di(e,t,s),s};exports.PulsePresence=class extends A{constructor(){super(...arguments),this.maxVisible=5,this.users=[]}connectedCallback(){super.connectedCallback(),this.setupListener()}disconnectedCallback(){var e;super.disconnectedCallback(),(e=this.unsub)==null||e.call(this)}updated(e){var t;e.has("client")&&this.client&&((t=this.unsub)==null||t.call(this),this.setupListener())}setupListener(){this.client&&(this.users=this.client.state.presence,this.unsub=this.client.state.on("presence",e=>{this.users=e}))}getInitials(e){return e.split(" ").map(t=>t[0]).join("").toUpperCase().slice(0,2)}render(){const e=this.users.slice(0,this.maxVisible),t=this.users.length-this.maxVisible;return p`
60
60
  <div class="avatars">
61
- ${t>0?u`<div class="overflow">+${t}</div>`:null}
62
- ${e.map(i=>u`
61
+ ${t>0?p`<div class="overflow">+${t}</div>`:null}
62
+ ${e.map(i=>p`
63
63
  <div
64
64
  class="avatar"
65
65
  style="background:${i.user.color}"
66
66
  >
67
- ${i.user.avatar?u`<img src="${i.user.avatar}" alt="${i.user.name}" />`:this.getInitials(i.user.name)}
67
+ ${i.user.avatar?p`<img src="${i.user.avatar}" alt="${i.user.name}" />`:this.getInitials(i.user.name)}
68
68
  <span class="status-ring ${i.status}"></span>
69
69
  <span class="tooltip">${i.user.name}</span>
70
70
  </div>
@@ -173,8 +173,8 @@
173
173
  .avatar:hover .tooltip {
174
174
  opacity: 1;
175
175
  }
176
- `;we([ae({context:Y,subscribe:!0}),x({attribute:!1})],exports.PulsePresence.prototype,"client",2);we([x({type:Number,attribute:"max-visible"})],exports.PulsePresence.prototype,"maxVisible",2);we([$()],exports.PulsePresence.prototype,"users",2);exports.PulsePresence=we([L("pulse-presence")],exports.PulsePresence);var hi=Object.defineProperty,pi=Object.getOwnPropertyDescriptor,Ue=(o,e,t,i)=>{for(var s=i>1?void 0:i?pi(e,t):e,n=o.length-1,r;n>=0;n--)(r=o[n])&&(s=(i?r(e,t,s):r(s))||s);return i&&s&&hi(e,t,s),s};exports.PulseCursors=class extends S{constructor(){super(...arguments),this.cursors=new Map,this.unsubs=[],this.handleLocalCursor=e=>{var t;(t=this.client)==null||t.moveCursor({x:e.clientX,y:e.clientY,pageX:e.pageX,pageY:e.pageY})}}connectedCallback(){super.connectedCallback(),this.setupListeners()}disconnectedCallback(){super.disconnectedCallback(),this.unsubs.forEach(e=>e()),this.unsubs=[],document.removeEventListener("mousemove",this.handleLocalCursor)}updated(e){e.has("client")&&this.client&&(this.unsubs.forEach(t=>t()),this.unsubs=[],this.setupListeners())}setupListeners(){this.client&&(this.unsubs.push(this.client.state.on("cursor",({userId:e,position:t})=>{const i=this.cursors.get(e);if(i)i.position=t;else{const s=this.client.state.presence.find(n=>n.user.id===e);s&&this.cursors.set(e,{userId:e,name:s.user.name,color:s.user.color,position:t})}this.requestUpdate()})),this.unsubs.push(this.client.state.on("presence",e=>{const t=new Set(e.map(i=>i.user.id));for(const i of this.cursors.keys())t.has(i)||this.cursors.delete(i);this.requestUpdate()})),document.addEventListener("mousemove",this.handleLocalCursor))}render(){const e=[...this.cursors.values()];return u`
177
- ${e.map(t=>u`
176
+ `;we([ae({context:Y,subscribe:!0}),w({attribute:!1})],exports.PulsePresence.prototype,"client",2);we([w({type:Number,attribute:"max-visible"})],exports.PulsePresence.prototype,"maxVisible",2);we([k()],exports.PulsePresence.prototype,"users",2);exports.PulsePresence=we([L("pulse-presence")],exports.PulsePresence);var pi=Object.defineProperty,ui=Object.getOwnPropertyDescriptor,De=(o,e,t,i)=>{for(var s=i>1?void 0:i?ui(e,t):e,n=o.length-1,r;n>=0;n--)(r=o[n])&&(s=(i?r(e,t,s):r(s))||s);return i&&s&&pi(e,t,s),s};exports.PulseCursors=class extends A{constructor(){super(...arguments),this.cursors=new Map,this.unsubs=[],this.handleLocalCursor=e=>{var t;(t=this.client)==null||t.moveCursor({x:e.clientX,y:e.clientY,pageX:e.pageX,pageY:e.pageY})}}connectedCallback(){super.connectedCallback(),this.setupListeners()}disconnectedCallback(){super.disconnectedCallback(),this.unsubs.forEach(e=>e()),this.unsubs=[],document.removeEventListener("mousemove",this.handleLocalCursor)}updated(e){e.has("client")&&this.client&&(this.unsubs.forEach(t=>t()),this.unsubs=[],this.setupListeners())}setupListeners(){this.client&&(this.unsubs.push(this.client.state.on("cursor",({userId:e,position:t})=>{const i=this.cursors.get(e);if(i)i.position=t;else{const s=this.client.state.presence.find(n=>n.user.id===e);s&&this.cursors.set(e,{userId:e,name:s.user.name,color:s.user.color,position:t})}this.requestUpdate()})),this.unsubs.push(this.client.state.on("presence",e=>{const t=new Set(e.map(i=>i.user.id));for(const i of this.cursors.keys())t.has(i)||this.cursors.delete(i);this.requestUpdate()})),document.addEventListener("mousemove",this.handleLocalCursor))}render(){const e=[...this.cursors.values()];return p`
177
+ ${e.map(t=>p`
178
178
  <div
179
179
  class="cursor"
180
180
  style="transform:translate(${t.position.x}px,${t.position.y}px)"
@@ -227,9 +227,9 @@
227
227
  letter-spacing: 0.01em;
228
228
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
229
229
  }
230
- `;Ue([ae({context:Y,subscribe:!0}),x({attribute:!1})],exports.PulseCursors.prototype,"client",2);Ue([$()],exports.PulseCursors.prototype,"cursors",2);exports.PulseCursors=Ue([L("pulse-cursors")],exports.PulseCursors);var ui=Object.defineProperty,fi=Object.getOwnPropertyDescriptor,ce=(o,e,t,i)=>{for(var s=i>1?void 0:i?fi(e,t):e,n=o.length-1,r;n>=0;n--)(r=o[n])&&(s=(i?r(e,t,s):r(s))||s);return i&&s&&ui(e,t,s),s};exports.PulseComments=class extends S{constructor(){super(...arguments),this.showResolved=!1,this.threads=[],this.replyingTo=null}connectedCallback(){super.connectedCallback(),this.setupListener()}disconnectedCallback(){var e;super.disconnectedCallback(),(e=this.unsub)==null||e.call(this)}updated(e){var t;e.has("client")&&this.client&&((t=this.unsub)==null||t.call(this),this.setupListener())}setupListener(){this.client&&(this.threads=this.client.state.threads,this.unsub=this.client.state.on("threads",e=>{this.threads=[...e]}))}parseMentions(e){return e.split(/(@\w+)/g).map(i=>i.startsWith("@")?u`<span class="mention">${i}</span>`:i)}getInitials(e){return e.split(" ").map(t=>t[0]).join("").toUpperCase().slice(0,2)}getUserForComment(e){var t;return(t=this.client.state.presence.find(i=>i.user.id===e))==null?void 0:t.user}handleNewThread(e){e.preventDefault();const i=e.target.querySelector("textarea"),s=i.value.trim();if(!s)return;const n=[...s.matchAll(/@(\w+)/g)].map(r=>r[1]);this.client.createThread(s,{mentions:n}),i.value=""}handleReply(e,t){t.preventDefault();const s=t.target.querySelector("input"),n=s.value.trim();if(!n)return;const r=[...n.matchAll(/@(\w+)/g)].map(a=>a[1]);this.client.reply(e,n,r),s.value="",this.replyingTo=null}render(){const e=this.showResolved?this.threads:this.threads.filter(t=>!t.resolved);return u`
230
+ `;De([ae({context:Y,subscribe:!0}),w({attribute:!1})],exports.PulseCursors.prototype,"client",2);De([k()],exports.PulseCursors.prototype,"cursors",2);exports.PulseCursors=De([L("pulse-cursors")],exports.PulseCursors);var fi=Object.defineProperty,mi=Object.getOwnPropertyDescriptor,ce=(o,e,t,i)=>{for(var s=i>1?void 0:i?mi(e,t):e,n=o.length-1,r;n>=0;n--)(r=o[n])&&(s=(i?r(e,t,s):r(s))||s);return i&&s&&fi(e,t,s),s};exports.PulseComments=class extends A{constructor(){super(...arguments),this.showResolved=!1,this.threads=[],this.replyingTo=null}connectedCallback(){super.connectedCallback(),this.setupListener()}disconnectedCallback(){var e;super.disconnectedCallback(),(e=this.unsub)==null||e.call(this)}updated(e){var t;e.has("client")&&this.client&&((t=this.unsub)==null||t.call(this),this.setupListener())}setupListener(){this.client&&(this.threads=this.client.state.threads,this.unsub=this.client.state.on("threads",e=>{this.threads=[...e]}))}parseMentions(e){return e.split(/(@\w+)/g).map(i=>i.startsWith("@")?p`<span class="mention">${i}</span>`:i)}getInitials(e){return e.split(" ").map(t=>t[0]).join("").toUpperCase().slice(0,2)}getUserForComment(e){var t;return(t=this.client.state.presence.find(i=>i.user.id===e))==null?void 0:t.user}handleNewThread(e){e.preventDefault();const i=e.target.querySelector("textarea"),s=i.value.trim();if(!s)return;const n=[...s.matchAll(/@(\w+)/g)].map(r=>r[1]);this.client.createThread(s,{mentions:n}),i.value=""}handleReply(e,t){t.preventDefault();const s=t.target.querySelector("input"),n=s.value.trim();if(!n)return;const r=[...n.matchAll(/@(\w+)/g)].map(a=>a[1]);this.client.reply(e,n,r),s.value="",this.replyingTo=null}render(){const e=this.showResolved?this.threads:this.threads.filter(t=>!t.resolved);return p`
231
231
  <div class="threads">
232
- ${e.length===0?u`<div class="empty">
232
+ ${e.length===0?p`<div class="empty">
233
233
  <div class="empty-icon">&#128172;</div>
234
234
  No comments yet.<br>Start a conversation below.
235
235
  </div>`:e.map(t=>this.renderThread(t))}
@@ -240,10 +240,10 @@
240
240
  <button type="submit">Comment</button>
241
241
  </form>
242
242
  </div>
243
- `}renderThread(e){return u`
243
+ `}renderThread(e){return p`
244
244
  <div class="thread ${e.resolved?"resolved":""}">
245
- ${e.comments.map((t,i)=>{const s=this.getUserForComment(t.userId);return u`
246
- ${i>0?u`<div class="divider"></div>`:v}
245
+ ${e.comments.map((t,i)=>{const s=this.getUserForComment(t.userId);return p`
246
+ ${i>0?p`<div class="divider"></div>`:g}
247
247
  <div class="comment">
248
248
  <div class="comment-header">
249
249
  <div
@@ -274,12 +274,12 @@
274
274
  ${e.resolved?"Reopen":"Resolve"}
275
275
  </button>
276
276
  </div>
277
- ${this.replyingTo===e.id?u`
277
+ ${this.replyingTo===e.id?p`
278
278
  <form class="reply-form" @submit=${t=>this.handleReply(e.id,t)}>
279
279
  <input type="text" placeholder="Write a reply..." />
280
280
  <button type="submit">Send</button>
281
281
  </form>
282
- `:v}
282
+ `:g}
283
283
  </div>
284
284
  `}formatTime(e){const t=new Date(e),s=new Date().getTime()-t.getTime(),n=Math.floor(s/6e4);if(n<1)return"just now";if(n<60)return`${n}m ago`;const r=Math.floor(n/60);return r<24?`${r}h ago`:t.toLocaleDateString()}};exports.PulseComments.styles=M`
285
285
  :host {
@@ -492,30 +492,30 @@
492
492
  margin-bottom: 8px;
493
493
  opacity: 0.4;
494
494
  }
495
- `;ce([ae({context:Y,subscribe:!0}),x({attribute:!1})],exports.PulseComments.prototype,"client",2);ce([x({type:Boolean,attribute:"show-resolved"})],exports.PulseComments.prototype,"showResolved",2);ce([$()],exports.PulseComments.prototype,"threads",2);ce([$()],exports.PulseComments.prototype,"replyingTo",2);exports.PulseComments=ce([L("pulse-comments")],exports.PulseComments);var mi=Object.defineProperty,gi=Object.getOwnPropertyDescriptor,De=(o,e,t,i)=>{for(var s=i>1?void 0:i?gi(e,t):e,n=o.length-1,r;n>=0;n--)(r=o[n])&&(s=(i?r(e,t,s):r(s))||s);return i&&s&&mi(e,t,s),s};const vi={"comment:created":"left a comment","comment:mention":"mentioned you","comment:reply":"replied to your comment","thread:resolved":"resolved a thread","reaction:added":"reacted to your comment"},bi={"comment:created":"💬","comment:mention":"📣","comment:reply":"↩️","thread:resolved":"✅","reaction:added":"🎉"};exports.PulseNotifications=class extends S{constructor(){super(...arguments),this.notifications=[]}connectedCallback(){super.connectedCallback(),this.setupListener()}disconnectedCallback(){var e;super.disconnectedCallback(),(e=this.unsub)==null||e.call(this)}updated(e){var t;e.has("client")&&this.client&&((t=this.unsub)==null||t.call(this),this.setupListener())}setupListener(){this.client&&(this.notifications=this.client.state.notifications,this.unsub=this.client.state.on("notifications",e=>{this.notifications=[...e]}))}handleClick(e){e.read||this.client.markRead(e.id),this.dispatchEvent(new CustomEvent("pulse-notification-click",{detail:e,bubbles:!0,composed:!0}))}getActorName(e){const t=this.client.state.presence.find(i=>i.user.id===e);return(t==null?void 0:t.user.name)??"Someone"}formatTime(e){const t=new Date(e),s=new Date().getTime()-t.getTime(),n=Math.floor(s/6e4);if(n<1)return"just now";if(n<60)return`${n}m ago`;const r=Math.floor(n/60);return r<24?`${r}h ago`:t.toLocaleDateString()}render(){const e=this.notifications.filter(t=>!t.read).length;return u`
495
+ `;ce([ae({context:Y,subscribe:!0}),w({attribute:!1})],exports.PulseComments.prototype,"client",2);ce([w({type:Boolean,attribute:"show-resolved"})],exports.PulseComments.prototype,"showResolved",2);ce([k()],exports.PulseComments.prototype,"threads",2);ce([k()],exports.PulseComments.prototype,"replyingTo",2);exports.PulseComments=ce([L("pulse-comments")],exports.PulseComments);var gi=Object.defineProperty,vi=Object.getOwnPropertyDescriptor,Ne=(o,e,t,i)=>{for(var s=i>1?void 0:i?vi(e,t):e,n=o.length-1,r;n>=0;n--)(r=o[n])&&(s=(i?r(e,t,s):r(s))||s);return i&&s&&gi(e,t,s),s};const bi={"comment:created":"left a comment","comment:mention":"mentioned you","comment:reply":"replied to your comment","thread:resolved":"resolved a thread","reaction:added":"reacted to your comment"},xi={"comment:created":"💬","comment:mention":"📣","comment:reply":"↩️","thread:resolved":"✅","reaction:added":"🎉"};exports.PulseNotifications=class extends A{constructor(){super(...arguments),this.notifications=[]}connectedCallback(){super.connectedCallback(),this.setupListener()}disconnectedCallback(){var e;super.disconnectedCallback(),(e=this.unsub)==null||e.call(this)}updated(e){var t;e.has("client")&&this.client&&((t=this.unsub)==null||t.call(this),this.setupListener())}setupListener(){this.client&&(this.notifications=this.client.state.notifications,this.unsub=this.client.state.on("notifications",e=>{this.notifications=[...e]}))}handleClick(e){e.read||this.client.markRead(e.id),this.dispatchEvent(new CustomEvent("pulse-notification-click",{detail:e,bubbles:!0,composed:!0}))}getActorName(e){const t=this.client.state.presence.find(i=>i.user.id===e);return(t==null?void 0:t.user.name)??"Someone"}formatTime(e){const t=new Date(e),s=new Date().getTime()-t.getTime(),n=Math.floor(s/6e4);if(n<1)return"just now";if(n<60)return`${n}m ago`;const r=Math.floor(n/60);return r<24?`${r}h ago`:t.toLocaleDateString()}render(){const e=this.notifications.filter(t=>!t.read).length;return p`
496
496
  <div class="header">
497
497
  <span class="title">
498
498
  Notifications
499
- ${e>0?u`<span class="badge">${e}</span>`:v}
499
+ ${e>0?p`<span class="badge">${e}</span>`:g}
500
500
  </span>
501
- ${e>0?u`<button class="mark-all" @click=${()=>this.client.markAllRead()}>
501
+ ${e>0?p`<button class="mark-all" @click=${()=>this.client.markAllRead()}>
502
502
  Mark all read
503
- </button>`:v}
503
+ </button>`:g}
504
504
  </div>
505
505
  <div class="list">
506
- ${this.notifications.length===0?u`<div class="empty">
506
+ ${this.notifications.length===0?p`<div class="empty">
507
507
  <div class="empty-icon">&#128276;</div>
508
508
  No notifications yet
509
- </div>`:this.notifications.map(t=>u`
509
+ </div>`:this.notifications.map(t=>p`
510
510
  <div
511
511
  class="item ${t.read?"":"unread"}"
512
512
  @click=${()=>this.handleClick(t)}
513
513
  >
514
- <span class="icon">${bi[t.type]??"🔔"}</span>
514
+ <span class="icon">${xi[t.type]??"🔔"}</span>
515
515
  <div class="content">
516
516
  <div class="text">
517
517
  <span class="actor">${this.getActorName(t.actorId)}</span>
518
- ${vi[t.type]??t.type}
518
+ ${bi[t.type]??t.type}
519
519
  </div>
520
520
  <div class="time">${this.formatTime(t.createdAt)}</div>
521
521
  </div>
@@ -663,8 +663,8 @@
663
663
  margin-bottom: 8px;
664
664
  opacity: 0.4;
665
665
  }
666
- `;De([ae({context:Y,subscribe:!0}),x({attribute:!1})],exports.PulseNotifications.prototype,"client",2);De([$()],exports.PulseNotifications.prototype,"notifications",2);exports.PulseNotifications=De([L("pulse-notifications")],exports.PulseNotifications);var xi=Object.defineProperty,yi=Object.getOwnPropertyDescriptor,G=(o,e,t,i)=>{for(var s=i>1?void 0:i?yi(e,t):e,n=o.length-1,r;n>=0;n--)(r=o[n])&&(s=(i?r(e,t,s):r(s))||s);return i&&s&&xi(e,t,s),s};const wi=["👍","👎","❤️","🎉","👀","🚀"];exports.PulseReactions=class extends S{constructor(){super(...arguments),this.targetId="",this.targetType="comment",this.reactions=[],this.showPicker=!1}connectedCallback(){super.connectedCallback(),this.setupListener()}disconnectedCallback(){var e;super.disconnectedCallback(),(e=this.unsub)==null||e.call(this)}updated(e){var t;e.has("client")&&this.client&&((t=this.unsub)==null||t.call(this),this.setupListener())}setupListener(){this.client&&(this.reactions=this.client.state.getReactions(this.targetId),this.unsub=this.client.state.on("reactions",e=>{e.targetId===this.targetId&&(this.reactions=[...e.reactions])}))}groupReactions(){var i,s;const e=new Map,t=(s=(i=this.client)==null?void 0:i.state.user)==null?void 0:s.id;for(const n of this.reactions){const r=e.get(n.emoji)??{count:0,userReactionId:null};r.count++,n.userId===t&&(r.userReactionId=n.id),e.set(n.emoji,r)}return[...e.entries()].map(([n,r])=>({emoji:n,...r}))}toggleReaction(e){e.userReactionId?this.client.removeReaction(e.userReactionId):this.client.addReaction(this.targetId,this.targetType,e.emoji)}addEmoji(e){this.client.addReaction(this.targetId,this.targetType,e),this.showPicker=!1}render(){const e=this.groupReactions();return u`
667
- ${e.map(t=>u`
666
+ `;Ne([ae({context:Y,subscribe:!0}),w({attribute:!1})],exports.PulseNotifications.prototype,"client",2);Ne([k()],exports.PulseNotifications.prototype,"notifications",2);exports.PulseNotifications=Ne([L("pulse-notifications")],exports.PulseNotifications);var yi=Object.defineProperty,wi=Object.getOwnPropertyDescriptor,G=(o,e,t,i)=>{for(var s=i>1?void 0:i?wi(e,t):e,n=o.length-1,r;n>=0;n--)(r=o[n])&&(s=(i?r(e,t,s):r(s))||s);return i&&s&&yi(e,t,s),s};const $i=["👍","👎","❤️","🎉","👀","🚀"];exports.PulseReactions=class extends A{constructor(){super(...arguments),this.targetId="",this.targetType="comment",this.reactions=[],this.showPicker=!1}connectedCallback(){super.connectedCallback(),this.setupListener()}disconnectedCallback(){var e;super.disconnectedCallback(),(e=this.unsub)==null||e.call(this)}updated(e){var t;e.has("client")&&this.client&&((t=this.unsub)==null||t.call(this),this.setupListener())}setupListener(){this.client&&(this.reactions=this.client.state.getReactions(this.targetId),this.unsub=this.client.state.on("reactions",e=>{e.targetId===this.targetId&&(this.reactions=[...e.reactions])}))}groupReactions(){var i,s;const e=new Map,t=(s=(i=this.client)==null?void 0:i.state.user)==null?void 0:s.id;for(const n of this.reactions){const r=e.get(n.emoji)??{count:0,userReactionId:null};r.count++,n.userId===t&&(r.userReactionId=n.id),e.set(n.emoji,r)}return[...e.entries()].map(([n,r])=>({emoji:n,...r}))}toggleReaction(e){e.userReactionId?this.client.removeReaction(e.userReactionId):this.client.addReaction(this.targetId,this.targetType,e.emoji)}addEmoji(e){this.client.addReaction(this.targetId,this.targetType,e),this.showPicker=!1}render(){const e=this.groupReactions();return p`
667
+ ${e.map(t=>p`
668
668
  <button
669
669
  class="reaction ${t.userReactionId?"active":""}"
670
670
  @click=${()=>this.toggleReaction(t)}
@@ -680,15 +680,15 @@
680
680
  >
681
681
  +
682
682
  </button>
683
- ${this.showPicker?u`
683
+ ${this.showPicker?p`
684
684
  <div class="picker">
685
- ${wi.map(t=>u`
685
+ ${$i.map(t=>p`
686
686
  <button @click=${()=>this.addEmoji(t)}>
687
687
  ${t}
688
688
  </button>
689
689
  `)}
690
690
  </div>
691
- `:v}
691
+ `:g}
692
692
  </div>
693
693
  `}};exports.PulseReactions.styles=M`
694
694
  :host {
@@ -801,74 +801,74 @@
801
801
  background: #f1f5f9;
802
802
  transform: scale(1.2);
803
803
  }
804
- `;G([ae({context:Y,subscribe:!0}),x({attribute:!1})],exports.PulseReactions.prototype,"client",2);G([x({attribute:"target-id"})],exports.PulseReactions.prototype,"targetId",2);G([x({attribute:"target-type"})],exports.PulseReactions.prototype,"targetType",2);G([$()],exports.PulseReactions.prototype,"reactions",2);G([$()],exports.PulseReactions.prototype,"showPicker",2);exports.PulseReactions=G([L("pulse-reactions")],exports.PulseReactions);const Et={allowImages:!0,allowAudio:!0,allowVideo:!0,maxFileSizeMb:10,maxAttachmentsPerComment:5,allowReactions:!0,allowDrawing:!0,allowMentions:!0,showCursors:!0,showPresence:!0,showTypingIndicators:!0};/**
804
+ `;G([ae({context:Y,subscribe:!0}),w({attribute:!1})],exports.PulseReactions.prototype,"client",2);G([w({attribute:"target-id"})],exports.PulseReactions.prototype,"targetId",2);G([w({attribute:"target-type"})],exports.PulseReactions.prototype,"targetType",2);G([k()],exports.PulseReactions.prototype,"reactions",2);G([k()],exports.PulseReactions.prototype,"showPicker",2);exports.PulseReactions=G([L("pulse-reactions")],exports.PulseReactions);const Ct={allowImages:!0,allowAudio:!0,allowVideo:!0,maxFileSizeMb:10,maxAttachmentsPerComment:5,allowReactions:!0,allowDrawing:!0,allowMentions:!0,showCursors:!0,showPresence:!0,showTypingIndicators:!0};/**
805
805
  * @license
806
806
  * Copyright 2017 Google LLC
807
807
  * SPDX-License-Identifier: BSD-3-Clause
808
- */const $i={CHILD:2},ki=o=>(...e)=>({_$litDirective$:o,values:e});class Ei{constructor(e){}get _$AU(){return this._$AM._$AU}_$AT(e,t,i){this._$Ct=e,this._$AM=t,this._$Ci=i}_$AS(e,t){return this.update(e,t)}update(e,t){return this.render(...t)}}/**
808
+ */const ki={CHILD:2},Ei=o=>(...e)=>({_$litDirective$:o,values:e});class Ci{constructor(e){}get _$AU(){return this._$AM._$AU}_$AT(e,t,i){this._$Ct=e,this._$AM=t,this._$Ci=i}_$AS(e,t){return this.update(e,t)}update(e,t){return this.render(...t)}}/**
809
809
  * @license
810
810
  * Copyright 2017 Google LLC
811
811
  * SPDX-License-Identifier: BSD-3-Clause
812
- */class Se extends Ei{constructor(e){if(super(e),this.it=v,e.type!==$i.CHILD)throw Error(this.constructor.directiveName+"() can only be used in child bindings")}render(e){if(e===v||e==null)return this._t=void 0,this.it=e;if(e===W)return e;if(typeof e!="string")throw Error(this.constructor.directiveName+"() called with a non-string value");if(e===this.it)return this._t;this.it=e;const t=[e];return t.raw=t,this._t={_$litType$:this.constructor.resultType,strings:t,values:[]}}}Se.directiveName="unsafeHTML",Se.resultType=1;/**
812
+ */class Se extends Ci{constructor(e){if(super(e),this.it=g,e.type!==ki.CHILD)throw Error(this.constructor.directiveName+"() can only be used in child bindings")}render(e){if(e===g||e==null)return this._t=void 0,this.it=e;if(e===W)return e;if(typeof e!="string")throw Error(this.constructor.directiveName+"() called with a non-string value");if(e===this.it)return this._t;this.it=e;const t=[e];return t.raw=t,this._t={_$litType$:this.constructor.resultType,strings:t,values:[]}}}Se.directiveName="unsafeHTML",Se.resultType=1;/**
813
813
  * @license
814
814
  * Copyright 2017 Google LLC
815
815
  * SPDX-License-Identifier: BSD-3-Clause
816
- */class Ae extends Se{}Ae.directiveName="unsafeSVG",Ae.resultType=2;const Ci=ki(Ae);/**
816
+ */class Ae extends Se{}Ae.directiveName="unsafeSVG",Ae.resultType=2;const Pi=Ei(Ae);/**
817
817
  * @license lucide v0.577.0 - ISC
818
818
  *
819
819
  * This source code is licensed under the ISC license.
820
820
  * See the LICENSE file in the root directory of this source tree.
821
- */const Pi=[["path",{d:"M10.268 21a2 2 0 0 0 3.464 0"}],["path",{d:"M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326"}]];/**
821
+ */const Ti=[["path",{d:"M10.268 21a2 2 0 0 0 3.464 0"}],["path",{d:"M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326"}]];/**
822
822
  * @license lucide v0.577.0 - ISC
823
823
  *
824
824
  * This source code is licensed under the ISC license.
825
825
  * See the LICENSE file in the root directory of this source tree.
826
- */const Ti=[["circle",{cx:"12",cy:"12",r:"10"}],["path",{d:"M12 6v6l4 2"}]];/**
826
+ */const Si=[["circle",{cx:"12",cy:"12",r:"10"}],["path",{d:"M12 6v6l4 2"}]];/**
827
827
  * @license lucide v0.577.0 - ISC
828
828
  *
829
829
  * This source code is licensed under the ISC license.
830
830
  * See the LICENSE file in the root directory of this source tree.
831
- */const Si=[["path",{d:"M2.992 16.342a2 2 0 0 1 .094 1.167l-1.065 3.29a1 1 0 0 0 1.236 1.168l3.413-.998a2 2 0 0 1 1.099.092 10 10 0 1 0-4.777-4.719"}]];/**
831
+ */const Ai=[["path",{d:"M2.992 16.342a2 2 0 0 1 .094 1.167l-1.065 3.29a1 1 0 0 0 1.236 1.168l3.413-.998a2 2 0 0 1 1.099.092 10 10 0 1 0-4.777-4.719"}]];/**
832
832
  * @license lucide v0.577.0 - ISC
833
833
  *
834
834
  * This source code is licensed under the ISC license.
835
835
  * See the LICENSE file in the root directory of this source tree.
836
- */const Ai=[["path",{d:"M12 19v3"}],["path",{d:"M19 10v2a7 7 0 0 1-14 0v-2"}],["rect",{x:"9",y:"2",width:"6",height:"13",rx:"3"}]];/**
836
+ */const _i=[["path",{d:"M12 19v3"}],["path",{d:"M19 10v2a7 7 0 0 1-14 0v-2"}],["rect",{x:"9",y:"2",width:"6",height:"13",rx:"3"}]];/**
837
837
  * @license lucide v0.577.0 - ISC
838
838
  *
839
839
  * This source code is licensed under the ISC license.
840
840
  * See the LICENSE file in the root directory of this source tree.
841
- */const _i=[["path",{d:"m16 6-8.414 8.586a2 2 0 0 0 2.829 2.829l8.414-8.586a4 4 0 1 0-5.657-5.657l-8.379 8.551a6 6 0 1 0 8.485 8.485l8.379-8.551"}]];/**
841
+ */const Ii=[["path",{d:"m16 6-8.414 8.586a2 2 0 0 0 2.829 2.829l8.414-8.586a4 4 0 1 0-5.657-5.657l-8.379 8.551a6 6 0 1 0 8.485 8.485l8.379-8.551"}]];/**
842
842
  * @license lucide v0.577.0 - ISC
843
843
  *
844
844
  * This source code is licensed under the ISC license.
845
845
  * See the LICENSE file in the root directory of this source tree.
846
- */const Ii=[["path",{d:"M15.707 21.293a1 1 0 0 1-1.414 0l-1.586-1.586a1 1 0 0 1 0-1.414l5.586-5.586a1 1 0 0 1 1.414 0l1.586 1.586a1 1 0 0 1 0 1.414z"}],["path",{d:"m18 13-1.375-6.874a1 1 0 0 0-.746-.776L3.235 2.028a1 1 0 0 0-1.207 1.207L5.35 15.879a1 1 0 0 0 .776.746L13 18"}],["path",{d:"m2.3 2.3 7.286 7.286"}],["circle",{cx:"11",cy:"11",r:"2"}]];/**
846
+ */const Mi=[["path",{d:"M15.707 21.293a1 1 0 0 1-1.414 0l-1.586-1.586a1 1 0 0 1 0-1.414l5.586-5.586a1 1 0 0 1 1.414 0l1.586 1.586a1 1 0 0 1 0 1.414z"}],["path",{d:"m18 13-1.375-6.874a1 1 0 0 0-.746-.776L3.235 2.028a1 1 0 0 0-1.207 1.207L5.35 15.879a1 1 0 0 0 .776.746L13 18"}],["path",{d:"m2.3 2.3 7.286 7.286"}],["circle",{cx:"11",cy:"11",r:"2"}]];/**
847
847
  * @license lucide v0.577.0 - ISC
848
848
  *
849
849
  * This source code is licensed under the ISC license.
850
850
  * See the LICENSE file in the root directory of this source tree.
851
- */const Mi=[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z"}],["path",{d:"m15 5 4 4"}]];/**
851
+ */const Oi=[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z"}],["path",{d:"m15 5 4 4"}]];/**
852
852
  * @license lucide v0.577.0 - ISC
853
853
  *
854
854
  * This source code is licensed under the ISC license.
855
855
  * See the LICENSE file in the root directory of this source tree.
856
- */const Ct=[["path",{d:"M12 17v5"}],["path",{d:"M9 10.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H8a2 2 0 0 0 0 4 1 1 0 0 1 1 1z"}]];/**
856
+ */const Pt=[["path",{d:"M12 17v5"}],["path",{d:"M9 10.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H8a2 2 0 0 0 0 4 1 1 0 0 1 1 1z"}]];/**
857
857
  * @license lucide v0.577.0 - ISC
858
858
  *
859
859
  * This source code is licensed under the ISC license.
860
860
  * See the LICENSE file in the root directory of this source tree.
861
- */const Oi=[["path",{d:"M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915"}],["circle",{cx:"12",cy:"12",r:"3"}]];/**
861
+ */const Ri=[["path",{d:"M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915"}],["circle",{cx:"12",cy:"12",r:"3"}]];/**
862
862
  * @license lucide v0.577.0 - ISC
863
863
  *
864
864
  * This source code is licensed under the ISC license.
865
865
  * See the LICENSE file in the root directory of this source tree.
866
- */const Ri=[["path",{d:"M10 11v6"}],["path",{d:"M14 11v6"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6"}],["path",{d:"M3 6h18"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"}]];/**
866
+ */const Li=[["path",{d:"M10 11v6"}],["path",{d:"M14 11v6"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6"}],["path",{d:"M3 6h18"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"}]];/**
867
867
  * @license lucide v0.577.0 - ISC
868
868
  *
869
869
  * This source code is licensed under the ISC license.
870
870
  * See the LICENSE file in the root directory of this source tree.
871
- */const Li=[["path",{d:"m16 13 5.223 3.482a.5.5 0 0 0 .777-.416V7.87a.5.5 0 0 0-.752-.432L16 10.5"}],["rect",{x:"2",y:"6",width:"14",height:"12",rx:"2"}]];/**
871
+ */const ji=[["path",{d:"m16 13 5.223 3.482a.5.5 0 0 0 .777-.416V7.87a.5.5 0 0 0-.752-.432L16 10.5"}],["rect",{x:"2",y:"6",width:"14",height:"12",rx:"2"}]];/**
872
872
  * @license lucide v0.577.0 - ISC
873
873
  *
874
874
  * This source code is licensed under the ISC license.
@@ -878,7 +878,7 @@
878
878
  *
879
879
  * This source code is licensed under the ISC license.
880
880
  * See the LICENSE file in the root directory of this source tree.
881
- */const ji=[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z"}]];function zi(o){return o.map(([e,t])=>{const i=Object.entries(t).filter(([,s])=>s!=null).map(([s,n])=>`${s}="${n}"`).join(" ");return`<${e} ${i}/>`}).join("")}function C(o,e=18){return Jt`<svg
881
+ */const Ui=[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z"}]];function zi(o){return o.map(([e,t])=>{const i=Object.entries(t).filter(([,s])=>s!=null).map(([s,n])=>`${s}="${n}"`).join(" ");return`<${e} ${i}/>`}).join("")}function C(o,e=18){return Zt`<svg
882
882
  xmlns="http://www.w3.org/2000/svg"
883
883
  width="${e}"
884
884
  height="${e}"
@@ -888,7 +888,7 @@
888
888
  stroke-width="2"
889
889
  stroke-linecap="round"
890
890
  stroke-linejoin="round"
891
- >${Ci(zi(o))}</svg>`}const J=M`
891
+ >${Pi(zi(o))}</svg>`}const J=M`
892
892
  * {
893
893
  box-sizing: border-box;
894
894
  margin: 0;
@@ -986,7 +986,7 @@
986
986
  .pw-scrollable::-webkit-scrollbar-track {
987
987
  background: transparent;
988
988
  }
989
- `;var Ui=Object.defineProperty,Di=Object.getOwnPropertyDescriptor,Ne=(o,e,t,i)=>{for(var s=i>1?void 0:i?Di(e,t):e,n=o.length-1,r;n>=0;n--)(r=o[n])&&(s=(i?r(e,t,s):r(s))||s);return i&&s&&Ui(e,t,s),s};let q=class extends S{constructor(){super(...arguments),this.items=[],this.unsubs=[],this.counter=0}connectedCallback(){super.connectedCallback(),this.setupListeners()}disconnectedCallback(){super.disconnectedCallback(),this.unsubs.forEach(o=>o()),this.unsubs=[]}updated(o){o.has("client")&&this.client&&(this.unsubs.forEach(e=>e()),this.unsubs=[],this.setupListeners())}setupListeners(){if(!this.client)return;const o=this.client.state.activityLogs;o.length>0&&(this.items=o.map(e=>this.logToItem(e)),this.counter=this.items.length),this.unsubs.push(this.client.state.on("activity-logs",e=>{this.items=e.map(t=>this.logToItem(t))}))}logToItem(o){return{id:o.id,type:o.type,userId:o.userId,description:o.description,timestamp:new Date(o.createdAt).getTime(),color:q.TYPE_COLORS[o.type]??"#94a3b8"}}getUserName(o){var e;return((e=this.client.state.getUser(o))==null?void 0:e.name)??"Someone"}formatRelativeTime(o){const e=Math.floor((Date.now()-o)/1e3);return e<5?"just now":e<60?`${e}s ago`:e<3600?`${Math.floor(e/60)}m ago`:`${Math.floor(e/3600)}h ago`}fireClose(){this.dispatchEvent(new CustomEvent("panel-close",{bubbles:!0,composed:!0}))}render(){return u`
989
+ `;var Di=Object.defineProperty,Ni=Object.getOwnPropertyDescriptor,He=(o,e,t,i)=>{for(var s=i>1?void 0:i?Ni(e,t):e,n=o.length-1,r;n>=0;n--)(r=o[n])&&(s=(i?r(e,t,s):r(s))||s);return i&&s&&Di(e,t,s),s};let q=class extends A{constructor(){super(...arguments),this.items=[],this.unsubs=[],this.counter=0}connectedCallback(){super.connectedCallback(),this.setupListeners()}disconnectedCallback(){super.disconnectedCallback(),this.unsubs.forEach(o=>o()),this.unsubs=[]}updated(o){o.has("client")&&this.client&&(this.unsubs.forEach(e=>e()),this.unsubs=[],this.setupListeners())}setupListeners(){if(!this.client)return;const o=this.client.state.activityLogs;o.length>0&&(this.items=o.map(e=>this.logToItem(e)),this.counter=this.items.length),this.unsubs.push(this.client.state.on("activity-logs",e=>{this.items=e.map(t=>this.logToItem(t))}))}logToItem(o){return{id:o.id,type:o.type,userId:o.userId,description:o.description,timestamp:new Date(o.createdAt).getTime(),color:q.TYPE_COLORS[o.type]??"#94a3b8"}}getUserName(o){var e;return((e=this.client.state.getUser(o))==null?void 0:e.name)??"Someone"}formatRelativeTime(o){const e=Math.floor((Date.now()-o)/1e3);return e<5?"just now":e<60?`${e}s ago`:e<3600?`${Math.floor(e/60)}m ago`:`${Math.floor(e/3600)}h ago`}fireClose(){this.dispatchEvent(new CustomEvent("panel-close",{bubbles:!0,composed:!0}))}render(){return p`
990
990
  <div class="panel">
991
991
  <div class="panel-header">
992
992
  <span class="panel-title">Activity</span>
@@ -996,7 +996,7 @@
996
996
  </div>
997
997
 
998
998
  <div class="panel-body pw-scrollable">
999
- ${this.items.length===0?u`<div class="empty">No activity yet</div>`:this.items.map(o=>u`
999
+ ${this.items.length===0?p`<div class="empty">No activity yet</div>`:this.items.map(o=>p`
1000
1000
  <div class="activity-item">
1001
1001
  <div
1002
1002
  class="activity-dot"
@@ -1004,7 +1004,7 @@
1004
1004
  ></div>
1005
1005
  <div class="activity-content">
1006
1006
  <div class="activity-text">
1007
- ${o.userId?u`<span class="activity-user"
1007
+ ${o.userId?p`<span class="activity-user"
1008
1008
  >${this.getUserName(o.userId)}</span
1009
1009
  >
1010
1010
  ${o.description}`:o.description}
@@ -1133,30 +1133,30 @@
1133
1133
  border-radius: 16px 16px 0 0;
1134
1134
  }
1135
1135
  }
1136
- `];q.TYPE_COLORS={join:"#22c55e",leave:"#94a3b8",thread:"var(--pw-accent, #6366f1)",comment:"#3b82f6",resolve:"#22c55e"};Ne([x({attribute:!1})],q.prototype,"client",2);Ne([$()],q.prototype,"items",2);q=Ne([L("pulse-widget-activity-panel")],q);const Ni="-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif",st="#6366f1",nt="#e2e8f0",Hi="#f8fafc",Bi="#e2e8f0",ot="#64748b",fe=28,Fi=Array.from({length:fe},(o,e)=>.2+Math.abs(Math.sin(e*12.9898+78.233)*43758.5453)%1*.8);function rt(o){const e=Math.max(0,Math.floor(o)),t=Math.floor(e/60),i=e%60;return`${t}:${i.toString().padStart(2,"0")}`}class _e{static render(e,t){let i=!1,s=t!=null?t/1e3:0,n=0;const r=document.createElement("audio");r.preload="metadata",r.src=e;const a=document.createElement("div");Object.assign(a.style,{display:"inline-flex",alignItems:"center",gap:"10px",width:"220px",height:"44px",padding:"0 10px",background:Hi,borderRadius:"12px",border:`1px solid ${Bi}`,fontFamily:Ni,fontSize:"11px",color:ot,userSelect:"none",boxSizing:"border-box"});const l=document.createElement("button");Object.assign(l.style,{width:"28px",height:"28px",minWidth:"28px",borderRadius:"50%",border:"none",background:st,cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",padding:"0",outline:"none",flexShrink:"0"});const d=document.createElement("span");Object.assign(d.style,{display:"block",width:"10px",height:"12px",lineHeight:"0"});function c(){d.innerHTML=`<svg width="10" height="12" viewBox="0 0 10 12" fill="none" xmlns="http://www.w3.org/2000/svg">
1136
+ `];q.TYPE_COLORS={join:"#22c55e",leave:"#94a3b8",thread:"var(--pw-accent, #6366f1)",comment:"#3b82f6",resolve:"#22c55e"};He([w({attribute:!1})],q.prototype,"client",2);He([k()],q.prototype,"items",2);q=He([L("pulse-widget-activity-panel")],q);const Hi="-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif",nt="#6366f1",ot="#e2e8f0",Bi="#f8fafc",Fi="#e2e8f0",rt="#64748b",fe=28,Wi=Array.from({length:fe},(o,e)=>.2+Math.abs(Math.sin(e*12.9898+78.233)*43758.5453)%1*.8);function at(o){const e=Math.max(0,Math.floor(o)),t=Math.floor(e/60),i=e%60;return`${t}:${i.toString().padStart(2,"0")}`}class _e{static render(e,t){let i=!1,s=t!=null?t/1e3:0,n=0;const r=document.createElement("audio");r.preload="metadata",r.src=e;const a=document.createElement("div");Object.assign(a.style,{display:"inline-flex",alignItems:"center",gap:"10px",width:"220px",height:"44px",padding:"0 10px",background:Bi,borderRadius:"12px",border:`1px solid ${Fi}`,fontFamily:Hi,fontSize:"11px",color:rt,userSelect:"none",boxSizing:"border-box"});const l=document.createElement("button");Object.assign(l.style,{width:"28px",height:"28px",minWidth:"28px",borderRadius:"50%",border:"none",background:nt,cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",padding:"0",outline:"none",flexShrink:"0"});const d=document.createElement("span");Object.assign(d.style,{display:"block",width:"10px",height:"12px",lineHeight:"0"});function c(){d.innerHTML=`<svg width="10" height="12" viewBox="0 0 10 12" fill="none" xmlns="http://www.w3.org/2000/svg">
1137
1137
  <path d="M1 1L9 6L1 11V1Z" fill="white" stroke="white" stroke-width="1" stroke-linejoin="round"/>
1138
1138
  </svg>`}function h(){d.innerHTML=`<svg width="10" height="12" viewBox="0 0 10 12" fill="none" xmlns="http://www.w3.org/2000/svg">
1139
1139
  <rect x="1" y="1" width="2.5" height="10" rx="0.5" fill="white"/>
1140
1140
  <rect x="6.5" y="1" width="2.5" height="10" rx="0.5" fill="white"/>
1141
- </svg>`}c(),l.appendChild(d);const p=document.createElement("div");Object.assign(p.style,{flex:"1",display:"flex",flexDirection:"column",gap:"3px",overflow:"hidden",minWidth:"0"});const m=document.createElement("div");Object.assign(m.style,{display:"flex",alignItems:"center",gap:"1.5px",height:"22px",cursor:"pointer"});const g=[];for(let k=0;k<fe;k++){const _=document.createElement("div"),O=Math.round(Fi[k]*20);Object.assign(_.style,{flex:"1",height:`${Math.max(3,O)}px`,borderRadius:"1px",background:nt,transition:"background 0.1s ease",minWidth:"0"}),g.push(_),m.appendChild(_)}const y=document.createElement("div");Object.assign(y.style,{fontSize:"10px",color:ot,whiteSpace:"nowrap",lineHeight:"1"});function b(){const k=rt(n),_=rt(s);y.textContent=`${k} / ${_}`}b(),p.appendChild(m),p.appendChild(y),a.appendChild(l),a.appendChild(p);function w(){const k=s>0?n/s:0,_=Math.floor(k*fe);for(let O=0;O<fe;O++)g[O].style.background=O<=_?st:nt}return m.addEventListener("click",k=>{if(s<=0)return;const _=m.getBoundingClientRect(),O=Math.min(1,Math.max(0,(k.clientX-_.left)/_.width));r.currentTime=O*s,n=r.currentTime,w(),b()}),l.addEventListener("click",()=>{i?r.pause():r.play().catch(()=>{})}),r.addEventListener("play",()=>{i=!0,h()}),r.addEventListener("pause",()=>{i=!1,c()}),r.addEventListener("ended",()=>{i=!1,c(),n=0,w(),b()}),r.addEventListener("timeupdate",()=>{n=r.currentTime,w(),b()}),r.addEventListener("loadedmetadata",()=>{r.duration&&isFinite(r.duration)&&(s=r.duration,b())}),r.addEventListener("durationchange",()=>{r.duration&&isFinite(r.duration)&&(s=r.duration,b())}),a}}class Ie{constructor(){this.container=null,this.stream=null,this.recorder=null,this.analyser=null,this.audioCtx=null,this.recording=!1,this.animFrame=null,this.startTime=0,this.maxDuration=12e4,this.maxTimer=null,this.canvas=null,this.timerEl=null,this.resolve=null,this.animate=()=>{this.recording&&(this.drawWaveform(),this.updateTimer(),this.animFrame=requestAnimationFrame(this.animate))}}async startRecording(e){this.destroy(),this.stream=await navigator.mediaDevices.getUserMedia({audio:!0}),this.audioCtx=new AudioContext;const t=this.audioCtx.createMediaStreamSource(this.stream);this.analyser=this.audioCtx.createAnalyser(),this.analyser.fftSize=64,t.connect(this.analyser);const i=this.detectMimeType(),s={};i&&(s.mimeType=i),this.recorder=new MediaRecorder(this.stream,s);const n=[];this.recorder.ondataavailable=a=>{a.data.size>0&&n.push(a.data)},this.buildUI(e);const r=new Promise(a=>{this.resolve=a});return this.recorder.onstop=()=>{var d,c;const a=((d=this.recorder)==null?void 0:d.mimeType)||i||"audio/webm",l=new Blob(n,{type:a});(c=this.resolve)==null||c.call(this,l),this.resolve=null,this.cleanupResources()},this.recorder.start(),this.recording=!0,this.startTime=Date.now(),this.maxTimer=setTimeout(()=>{this.stopRecording()},this.maxDuration),this.animate(),r}stopRecording(){!this.recording||!this.recorder||(this.recording=!1,this.recorder.state==="recording"&&this.recorder.stop())}cancelRecording(){var e;this.recorder&&(this.recording=!1,this.recorder.ondataavailable=null,this.recorder.onstop=null,this.recorder.state==="recording"&&this.recorder.stop(),(e=this.resolve)==null||e.call(this,null),this.resolve=null,this.cleanupResources())}destroy(){this.cancelRecording(),this.cleanupResources()}detectMimeType(){if(typeof MediaRecorder.isTypeSupported=="function"){if(MediaRecorder.isTypeSupported("audio/webm;codecs=opus"))return"audio/webm;codecs=opus";if(MediaRecorder.isTypeSupported("audio/webm"))return"audio/webm";if(MediaRecorder.isTypeSupported("audio/mp4;codecs=mp4a.40.2"))return"audio/mp4;codecs=mp4a.40.2";if(MediaRecorder.isTypeSupported("audio/mp4"))return"audio/mp4"}}buildUI(e){this.container=document.createElement("div"),this.container.className="pulse-audio-recorder",Object.assign(this.container.style,{display:"flex",alignItems:"center",gap:"10px",padding:"8px 12px",background:"#ffffff",borderRadius:"12px",boxShadow:"0 2px 12px rgba(0,0,0,0.10), 0 1px 3px rgba(0,0,0,0.06)",border:"1px solid #e2e8f0",fontFamily:"-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif",fontSize:"13px",width:"fit-content"});const t=document.createElement("button");t.title="Cancel",t.innerHTML='<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="18" y1="6" x2="6" y2="18"/><line x1="6" y1="6" x2="18" y2="18"/></svg>',Object.assign(t.style,{display:"flex",alignItems:"center",justifyContent:"center",width:"28px",height:"28px",border:"none",background:"none",cursor:"pointer",color:"#64748b",borderRadius:"6px",padding:"0",transition:"background 0.15s, color 0.15s",flexShrink:"0"}),t.addEventListener("mouseenter",()=>{t.style.background="#f1f5f9",t.style.color="#0f172a"}),t.addEventListener("mouseleave",()=>{t.style.background="none",t.style.color="#64748b"}),t.addEventListener("click",()=>this.cancelRecording()),this.container.appendChild(t),this.canvas=document.createElement("canvas"),this.canvas.width=200,this.canvas.height=40,Object.assign(this.canvas.style,{display:"block",borderRadius:"4px",flexShrink:"0"}),this.container.appendChild(this.canvas),this.timerEl=document.createElement("span"),this.timerEl.textContent="00:00",Object.assign(this.timerEl.style,{color:"#ef4444",fontWeight:"600",fontSize:"13px",fontVariantNumeric:"tabular-nums",minWidth:"40px",flexShrink:"0"}),this.container.appendChild(this.timerEl);const i=document.createElement("button");i.title="Stop recording",i.innerHTML='<svg width="16" height="16" viewBox="0 0 24 24" fill="currentColor"><rect x="6" y="6" width="12" height="12" rx="2"/></svg>',Object.assign(i.style,{display:"flex",alignItems:"center",justifyContent:"center",width:"32px",height:"32px",border:"none",background:"#ef4444",cursor:"pointer",color:"#ffffff",borderRadius:"50%",padding:"0",transition:"background 0.15s, transform 0.15s",flexShrink:"0"}),i.addEventListener("mouseenter",()=>{i.style.background="#dc2626",i.style.transform="scale(1.08)"}),i.addEventListener("mouseleave",()=>{i.style.background="#ef4444",i.style.transform="scale(1)"}),i.addEventListener("click",()=>this.stopRecording()),this.container.appendChild(i),e.appendChild(this.container)}drawWaveform(){if(!this.canvas||!this.analyser)return;const e=this.canvas.getContext("2d");if(!e)return;const t=this.canvas.width,i=this.canvas.height,s=this.analyser.frequencyBinCount,n=new Uint8Array(s);this.analyser.getByteFrequencyData(n),e.clearRect(0,0,t,i);const r=s,a=Math.max(2,t/r*.7),l=(t-a*r)/(r-1||1);for(let d=0;d<r;d++){const c=n[d]/255,h=Math.max(2,c*i*.85),p=d*(a+l),m=(i-h)/2,g=.4+c*.6;e.fillStyle=`rgba(99, 102, 241, ${g})`,e.beginPath(),e.roundRect(p,m,a,h,1),e.fill()}}updateTimer(){if(!this.timerEl)return;const e=Date.now()-this.startTime,t=Math.floor(e/1e3),i=Math.floor(t/60),s=t%60;this.timerEl.textContent=`${String(i).padStart(2,"0")}:${String(s).padStart(2,"0")}`}cleanupResources(){if(this.animFrame!==null&&(cancelAnimationFrame(this.animFrame),this.animFrame=null),this.maxTimer!==null&&(clearTimeout(this.maxTimer),this.maxTimer=null),this.audioCtx&&(this.audioCtx.close().catch(()=>{}),this.audioCtx=null),this.analyser=null,this.stream){for(const e of this.stream.getTracks())e.stop();this.stream=null}this.recorder=null,this.container&&(this.container.remove(),this.container=null),this.canvas=null,this.timerEl=null}}const Wi=180,qi=120,Vi="#e2e8f0",Xi=`
1141
+ </svg>`}c(),l.appendChild(d);const u=document.createElement("div");Object.assign(u.style,{flex:"1",display:"flex",flexDirection:"column",gap:"3px",overflow:"hidden",minWidth:"0"});const f=document.createElement("div");Object.assign(f.style,{display:"flex",alignItems:"center",gap:"1.5px",height:"22px",cursor:"pointer"});const b=[];for(let $=0;$<fe;$++){const P=document.createElement("div"),O=Math.round(Wi[$]*20);Object.assign(P.style,{flex:"1",height:`${Math.max(3,O)}px`,borderRadius:"1px",background:ot,transition:"background 0.1s ease",minWidth:"0"}),b.push(P),f.appendChild(P)}const x=document.createElement("div");Object.assign(x.style,{fontSize:"10px",color:rt,whiteSpace:"nowrap",lineHeight:"1"});function y(){const $=at(n),P=at(s);x.textContent=`${$} / ${P}`}y(),u.appendChild(f),u.appendChild(x),a.appendChild(l),a.appendChild(u);function v(){const $=s>0?n/s:0,P=Math.floor($*fe);for(let O=0;O<fe;O++)b[O].style.background=O<=P?nt:ot}return f.addEventListener("click",$=>{if(s<=0)return;const P=f.getBoundingClientRect(),O=Math.min(1,Math.max(0,($.clientX-P.left)/P.width));r.currentTime=O*s,n=r.currentTime,v(),y()}),l.addEventListener("click",()=>{i?r.pause():r.play().catch(()=>{})}),r.addEventListener("play",()=>{i=!0,h()}),r.addEventListener("pause",()=>{i=!1,c()}),r.addEventListener("ended",()=>{i=!1,c(),n=0,v(),y()}),r.addEventListener("timeupdate",()=>{n=r.currentTime,v(),y()}),r.addEventListener("loadedmetadata",()=>{r.duration&&isFinite(r.duration)&&(s=r.duration,y())}),r.addEventListener("durationchange",()=>{r.duration&&isFinite(r.duration)&&(s=r.duration,y())}),a}}class Ie{constructor(){this.container=null,this.stream=null,this.recorder=null,this.analyser=null,this.audioCtx=null,this.recording=!1,this.animFrame=null,this.startTime=0,this.maxDuration=12e4,this.maxTimer=null,this.canvas=null,this.timerEl=null,this.resolve=null,this.animate=()=>{this.recording&&(this.drawWaveform(),this.updateTimer(),this.animFrame=requestAnimationFrame(this.animate))}}async startRecording(e){this.destroy(),this.stream=await navigator.mediaDevices.getUserMedia({audio:!0}),this.audioCtx=new AudioContext;const t=this.audioCtx.createMediaStreamSource(this.stream);this.analyser=this.audioCtx.createAnalyser(),this.analyser.fftSize=64,t.connect(this.analyser);const i=this.detectMimeType(),s={};i&&(s.mimeType=i),this.recorder=new MediaRecorder(this.stream,s);const n=[];this.recorder.ondataavailable=a=>{a.data.size>0&&n.push(a.data)},this.buildUI(e);const r=new Promise(a=>{this.resolve=a});return this.recorder.onstop=()=>{var d,c;const a=((d=this.recorder)==null?void 0:d.mimeType)||i||"audio/webm",l=new Blob(n,{type:a});(c=this.resolve)==null||c.call(this,l),this.resolve=null,this.cleanupResources()},this.recorder.start(),this.recording=!0,this.startTime=Date.now(),this.maxTimer=setTimeout(()=>{this.stopRecording()},this.maxDuration),this.animate(),r}stopRecording(){!this.recording||!this.recorder||(this.recording=!1,this.recorder.state==="recording"&&this.recorder.stop())}cancelRecording(){var e;this.recorder&&(this.recording=!1,this.recorder.ondataavailable=null,this.recorder.onstop=null,this.recorder.state==="recording"&&this.recorder.stop(),(e=this.resolve)==null||e.call(this,null),this.resolve=null,this.cleanupResources())}destroy(){this.cancelRecording(),this.cleanupResources()}detectMimeType(){if(typeof MediaRecorder.isTypeSupported=="function"){if(MediaRecorder.isTypeSupported("audio/webm;codecs=opus"))return"audio/webm;codecs=opus";if(MediaRecorder.isTypeSupported("audio/webm"))return"audio/webm";if(MediaRecorder.isTypeSupported("audio/mp4;codecs=mp4a.40.2"))return"audio/mp4;codecs=mp4a.40.2";if(MediaRecorder.isTypeSupported("audio/mp4"))return"audio/mp4"}}buildUI(e){this.container=document.createElement("div"),this.container.className="pulse-audio-recorder",Object.assign(this.container.style,{display:"flex",alignItems:"center",gap:"10px",padding:"8px 12px",background:"#ffffff",borderRadius:"12px",boxShadow:"0 2px 12px rgba(0,0,0,0.10), 0 1px 3px rgba(0,0,0,0.06)",border:"1px solid #e2e8f0",fontFamily:"-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif",fontSize:"13px",width:"fit-content"});const t=document.createElement("button");t.title="Cancel",t.innerHTML='<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="18" y1="6" x2="6" y2="18"/><line x1="6" y1="6" x2="18" y2="18"/></svg>',Object.assign(t.style,{display:"flex",alignItems:"center",justifyContent:"center",width:"28px",height:"28px",border:"none",background:"none",cursor:"pointer",color:"#64748b",borderRadius:"6px",padding:"0",transition:"background 0.15s, color 0.15s",flexShrink:"0"}),t.addEventListener("mouseenter",()=>{t.style.background="#f1f5f9",t.style.color="#0f172a"}),t.addEventListener("mouseleave",()=>{t.style.background="none",t.style.color="#64748b"}),t.addEventListener("click",()=>this.cancelRecording()),this.container.appendChild(t),this.canvas=document.createElement("canvas"),this.canvas.width=200,this.canvas.height=40,Object.assign(this.canvas.style,{display:"block",borderRadius:"4px",flexShrink:"0"}),this.container.appendChild(this.canvas),this.timerEl=document.createElement("span"),this.timerEl.textContent="00:00",Object.assign(this.timerEl.style,{color:"#ef4444",fontWeight:"600",fontSize:"13px",fontVariantNumeric:"tabular-nums",minWidth:"40px",flexShrink:"0"}),this.container.appendChild(this.timerEl);const i=document.createElement("button");i.title="Stop recording",i.innerHTML='<svg width="16" height="16" viewBox="0 0 24 24" fill="currentColor"><rect x="6" y="6" width="12" height="12" rx="2"/></svg>',Object.assign(i.style,{display:"flex",alignItems:"center",justifyContent:"center",width:"32px",height:"32px",border:"none",background:"#ef4444",cursor:"pointer",color:"#ffffff",borderRadius:"50%",padding:"0",transition:"background 0.15s, transform 0.15s",flexShrink:"0"}),i.addEventListener("mouseenter",()=>{i.style.background="#dc2626",i.style.transform="scale(1.08)"}),i.addEventListener("mouseleave",()=>{i.style.background="#ef4444",i.style.transform="scale(1)"}),i.addEventListener("click",()=>this.stopRecording()),this.container.appendChild(i),e.appendChild(this.container)}drawWaveform(){if(!this.canvas||!this.analyser)return;const e=this.canvas.getContext("2d");if(!e)return;const t=this.canvas.width,i=this.canvas.height,s=this.analyser.frequencyBinCount,n=new Uint8Array(s);this.analyser.getByteFrequencyData(n),e.clearRect(0,0,t,i);const r=s,a=Math.max(2,t/r*.7),l=(t-a*r)/(r-1||1);for(let d=0;d<r;d++){const c=n[d]/255,h=Math.max(2,c*i*.85),u=d*(a+l),f=(i-h)/2,b=.4+c*.6;e.fillStyle=`rgba(99, 102, 241, ${b})`,e.beginPath(),e.roundRect(u,f,a,h,1),e.fill()}}updateTimer(){if(!this.timerEl)return;const e=Date.now()-this.startTime,t=Math.floor(e/1e3),i=Math.floor(t/60),s=t%60;this.timerEl.textContent=`${String(i).padStart(2,"0")}:${String(s).padStart(2,"0")}`}cleanupResources(){if(this.animFrame!==null&&(cancelAnimationFrame(this.animFrame),this.animFrame=null),this.maxTimer!==null&&(clearTimeout(this.maxTimer),this.maxTimer=null),this.audioCtx&&(this.audioCtx.close().catch(()=>{}),this.audioCtx=null),this.analyser=null,this.stream){for(const e of this.stream.getTracks())e.stop();this.stream=null}this.recorder=null,this.container&&(this.container.remove(),this.container=null),this.canvas=null,this.timerEl=null}}const qi=180,Vi=120,Xi="#e2e8f0",Yi=`
1142
1142
  <svg width="28" height="28" viewBox="0 0 28 28" fill="none" xmlns="http://www.w3.org/2000/svg">
1143
1143
  <circle cx="14" cy="14" r="14" fill="rgba(0,0,0,0.35)"/>
1144
1144
  <polygon points="11,8 22,14 11,20" fill="rgba(255,255,255,0.9)"/>
1145
- </svg>`,at=`
1145
+ </svg>`,lt=`
1146
1146
  <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="rgba(255,255,255,0.9)" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg">
1147
1147
  <polygon points="11,5 6,9 2,9 2,15 6,15 11,19"/>
1148
1148
  <line x1="23" y1="9" x2="17" y2="15"/>
1149
1149
  <line x1="17" y1="9" x2="23" y2="15"/>
1150
- </svg>`,Yi=`
1150
+ </svg>`,Ki=`
1151
1151
  <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="rgba(255,255,255,0.9)" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg">
1152
1152
  <polygon points="11,5 6,9 2,9 2,15 6,15 11,19"/>
1153
1153
  <path d="M19.07 4.93a10 10 0 0 1 0 14.14"/>
1154
1154
  <path d="M15.54 8.46a5 5 0 0 1 0 7.07"/>
1155
- </svg>`,Ki=`
1155
+ </svg>`,Gi=`
1156
1156
  <svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="rgba(255,255,255,0.9)" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg">
1157
1157
  <polyline points="15,3 21,3 21,9"/><line x1="21" y1="3" x2="14" y2="10"/>
1158
1158
  <polyline points="9,21 3,21 3,15"/><line x1="3" y1="21" x2="10" y2="14"/>
1159
- </svg>`,P=class P{static render(e,t){let i=!1,s=!0;const n=document.createElement("div");Object.assign(n.style,{position:"relative",display:"inline-block",width:`${Wi}px`,height:`${qi}px`,borderRadius:"8px",border:`1px solid ${Vi}`,boxShadow:"0 2px 8px rgba(0,0,0,0.1)",overflow:"hidden",cursor:"pointer",flexShrink:"0",userSelect:"none",WebkitUserSelect:"none"});const r=document.createElement("video");Object.assign(r.style,{width:"100%",height:"100%",objectFit:"cover",display:"block",borderRadius:"8px"}),r.src=e,r.loop=!0,r.muted=!0,r.playsInline=!0,r.preload="metadata",t&&(r.poster=t),n.appendChild(r);const a=document.createElement("div");Object.assign(a.style,{position:"absolute",top:"0",left:"0",width:"100%",height:"100%",display:"flex",alignItems:"center",justifyContent:"center",borderRadius:"8px",transition:"opacity 0.25s ease",opacity:"1",pointerEvents:"none"}),a.innerHTML=Xi,n.appendChild(a);const l=document.createElement("div");Object.assign(l.style,{position:"absolute",bottom:"2px",right:"2px",width:"22px",height:"22px",borderRadius:"50%",background:"rgba(0,0,0,0.45)",display:"none",alignItems:"center",justifyContent:"center",pointerEvents:"none",transition:"opacity 0.2s ease"}),l.innerHTML=at,n.appendChild(l);const d=document.createElement("div");Object.assign(d.style,{position:"absolute",top:"2px",right:"2px",width:"22px",height:"22px",borderRadius:"50%",background:"rgba(0,0,0,0.45)",display:"none",alignItems:"center",justifyContent:"center",cursor:"pointer",pointerEvents:"auto",transition:"opacity 0.2s ease, background 0.15s ease"}),d.innerHTML=Ki,d.title="Fullscreen",d.addEventListener("mouseenter",()=>{d.style.background="rgba(0,0,0,0.7)"}),d.addEventListener("mouseleave",()=>{d.style.background="rgba(0,0,0,0.45)"}),d.addEventListener("click",p=>{p.stopPropagation(),P.openFullscreen(e,t)}),n.appendChild(d);function c(){a.style.opacity=i?"0":"1"}function h(){l.style.display=i?"flex":"none",l.innerHTML=s?at:Yi,d.style.display=i?"flex":"none"}return n.addEventListener("click",p=>{p.stopPropagation(),i?s?(r.muted=!1,s=!1):(r.pause(),i=!1,s=!0,r.muted=!0):(r.muted=!0,s=!0,r.play().catch(()=>{}),i=!0),c(),h()}),r.addEventListener("pause",()=>{i&&(i=!1,s=!0,r.muted=!0,c(),h())}),n}static openFullscreen(e,t){P.closeFullscreen();const i=document.createElement("div");Object.assign(i.style,{position:"fixed",top:"0",left:"0",width:"100%",height:"100%",zIndex:"100000",background:"rgba(0,0,0,0.85)",display:"flex",alignItems:"center",justifyContent:"center",opacity:"0",transition:"opacity 200ms ease",cursor:"pointer",fontFamily:"-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif"});const s=document.createElement("button");s.textContent="×",Object.assign(s.style,{position:"absolute",top:"16px",right:"16px",width:"40px",height:"40px",border:"none",borderRadius:"50%",background:"rgba(255,255,255,0.15)",color:"#fff",fontSize:"24px",cursor:"pointer",padding:"0",display:"flex",alignItems:"center",justifyContent:"center",transition:"background 150ms ease",zIndex:"1"}),s.addEventListener("mouseenter",()=>{s.style.background="rgba(255,255,255,0.3)"}),s.addEventListener("mouseleave",()=>{s.style.background="rgba(255,255,255,0.15)"}),s.addEventListener("click",a=>{a.stopPropagation(),P.closeFullscreen()});const n=document.createElement("video");Object.assign(n.style,{maxWidth:"90vw",maxHeight:"90vh",borderRadius:"8px",outline:"none",cursor:"default"}),n.src=e,n.controls=!0,n.autoplay=!0,n.playsInline=!0,t&&(n.poster=t),n.addEventListener("click",a=>a.stopPropagation()),i.appendChild(s),i.appendChild(n),i.addEventListener("click",()=>P.closeFullscreen());const r=a=>{a.key==="Escape"&&P.closeFullscreen()};document.addEventListener("keydown",r),P.fullscreenOverlay=i,P.fullscreenKeyHandler=r,document.body.appendChild(i),requestAnimationFrame(()=>{i.style.opacity="1"})}static closeFullscreen(){if(!P.fullscreenOverlay)return;const e=P.fullscreenOverlay;P.fullscreenKeyHandler&&(document.removeEventListener("keydown",P.fullscreenKeyHandler),P.fullscreenKeyHandler=null);const t=e.querySelector("video");t&&t.pause(),e.style.opacity="0",e.addEventListener("transitionend",()=>e.remove()),P.fullscreenOverlay=null}};P.fullscreenOverlay=null,P.fullscreenKeyHandler=null;let be=P;const lt=60,Gi=`
1159
+ </svg>`,T=class T{static render(e,t){let i=!1,s=!0;const n=document.createElement("div");Object.assign(n.style,{position:"relative",display:"inline-block",width:`${qi}px`,height:`${Vi}px`,borderRadius:"8px",border:`1px solid ${Xi}`,boxShadow:"0 2px 8px rgba(0,0,0,0.1)",overflow:"hidden",cursor:"pointer",flexShrink:"0",userSelect:"none",WebkitUserSelect:"none"});const r=document.createElement("video");Object.assign(r.style,{width:"100%",height:"100%",objectFit:"cover",display:"block",borderRadius:"8px"}),r.src=e,r.loop=!0,r.muted=!0,r.playsInline=!0,r.preload="metadata",t&&(r.poster=t),n.appendChild(r);const a=document.createElement("div");Object.assign(a.style,{position:"absolute",top:"0",left:"0",width:"100%",height:"100%",display:"flex",alignItems:"center",justifyContent:"center",borderRadius:"8px",transition:"opacity 0.25s ease",opacity:"1",pointerEvents:"none"}),a.innerHTML=Yi,n.appendChild(a);const l=document.createElement("div");Object.assign(l.style,{position:"absolute",bottom:"2px",right:"2px",width:"22px",height:"22px",borderRadius:"50%",background:"rgba(0,0,0,0.45)",display:"none",alignItems:"center",justifyContent:"center",pointerEvents:"none",transition:"opacity 0.2s ease"}),l.innerHTML=lt,n.appendChild(l);const d=document.createElement("div");Object.assign(d.style,{position:"absolute",top:"2px",right:"2px",width:"22px",height:"22px",borderRadius:"50%",background:"rgba(0,0,0,0.45)",display:"none",alignItems:"center",justifyContent:"center",cursor:"pointer",pointerEvents:"auto",transition:"opacity 0.2s ease, background 0.15s ease"}),d.innerHTML=Gi,d.title="Fullscreen",d.addEventListener("mouseenter",()=>{d.style.background="rgba(0,0,0,0.7)"}),d.addEventListener("mouseleave",()=>{d.style.background="rgba(0,0,0,0.45)"}),d.addEventListener("click",u=>{u.stopPropagation(),T.openFullscreen(e,t)}),n.appendChild(d);function c(){a.style.opacity=i?"0":"1"}function h(){l.style.display=i?"flex":"none",l.innerHTML=s?lt:Ki,d.style.display=i?"flex":"none"}return n.addEventListener("click",u=>{u.stopPropagation(),i?s?(r.muted=!1,s=!1):(r.pause(),i=!1,s=!0,r.muted=!0):(r.muted=!0,s=!0,r.play().catch(()=>{}),i=!0),c(),h()}),r.addEventListener("pause",()=>{i&&(i=!1,s=!0,r.muted=!0,c(),h())}),n}static openFullscreen(e,t){T.closeFullscreen();const i=document.createElement("div");Object.assign(i.style,{position:"fixed",top:"0",left:"0",width:"100%",height:"100%",zIndex:"100000",background:"rgba(0,0,0,0.85)",display:"flex",alignItems:"center",justifyContent:"center",opacity:"0",transition:"opacity 200ms ease",cursor:"pointer",fontFamily:"-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif"});const s=document.createElement("button");s.textContent="×",Object.assign(s.style,{position:"absolute",top:"16px",right:"16px",width:"40px",height:"40px",border:"none",borderRadius:"50%",background:"rgba(255,255,255,0.15)",color:"#fff",fontSize:"24px",cursor:"pointer",padding:"0",display:"flex",alignItems:"center",justifyContent:"center",transition:"background 150ms ease",zIndex:"1"}),s.addEventListener("mouseenter",()=>{s.style.background="rgba(255,255,255,0.3)"}),s.addEventListener("mouseleave",()=>{s.style.background="rgba(255,255,255,0.15)"}),s.addEventListener("click",a=>{a.stopPropagation(),T.closeFullscreen()});const n=document.createElement("video");Object.assign(n.style,{maxWidth:"90vw",maxHeight:"90vh",borderRadius:"8px",outline:"none",cursor:"default"}),n.src=e,n.controls=!0,n.autoplay=!0,n.playsInline=!0,t&&(n.poster=t),n.addEventListener("click",a=>a.stopPropagation()),i.appendChild(s),i.appendChild(n),i.addEventListener("click",()=>T.closeFullscreen());const r=a=>{a.key==="Escape"&&T.closeFullscreen()};document.addEventListener("keydown",r),T.fullscreenOverlay=i,T.fullscreenKeyHandler=r,document.body.appendChild(i),requestAnimationFrame(()=>{i.style.opacity="1"})}static closeFullscreen(){if(!T.fullscreenOverlay)return;const e=T.fullscreenOverlay;T.fullscreenKeyHandler&&(document.removeEventListener("keydown",T.fullscreenKeyHandler),T.fullscreenKeyHandler=null);const t=e.querySelector("video");t&&t.pause(),e.style.opacity="0",e.addEventListener("transitionend",()=>e.remove()),T.fullscreenOverlay=null}};T.fullscreenOverlay=null,T.fullscreenKeyHandler=null;let be=T;const ct=60,Ji=`
1160
1160
  .vr-overlay {
1161
1161
  display: flex;
1162
1162
  flex-direction: column;
@@ -1262,17 +1262,32 @@
1262
1262
  background: #e2e8f0;
1263
1263
  color: #0f172a;
1264
1264
  }
1265
- `;function ct(o){return o.toString().padStart(2,"0")}function Ji(o){const e=Math.floor(o/60),t=o%60;return`${ct(e)}:${ct(t)}`}function Zi(){const o=["video/webm;codecs=vp9,opus","video/webm;codecs=vp8,opus","video/webm","video/mp4"];for(const e of o)if(MediaRecorder.isTypeSupported(e))return e;return""}function Qi(o){return new Promise((e,t)=>{const i=URL.createObjectURL(o),s=document.createElement("video");s.muted=!0,s.playsInline=!0,s.preload="auto",s.src=i,s.addEventListener("loadeddata",()=>{s.currentTime=.01}),s.addEventListener("seeked",()=>{const n=document.createElement("canvas");n.width=s.videoWidth||240,n.height=s.videoHeight||240,n.getContext("2d").drawImage(s,0,0,n.width,n.height),URL.revokeObjectURL(i),n.toBlob(a=>{a?e(a):t(new Error("Failed to generate poster frame"))},"image/jpeg",.85)}),s.addEventListener("error",()=>{URL.revokeObjectURL(i),t(new Error("Failed to load video for poster generation"))}),s.load()})}class Me{constructor(){this.recording=!1,this.container=null,this.stream=null,this.mediaRecorder=null,this.chunks=[],this.timerInterval=null,this.elapsed=0,this.resolvePromise=null,this.root=null,this.styleEl=null,this.videoEl=null,this.timerEl=null}async startRecording(e){if(this.recording)return null;let t;try{t=await navigator.mediaDevices.getUserMedia({video:!0,audio:!0})}catch{return null}this.stream=t,this.container=e,this.recording=!0,this.elapsed=0,this.chunks=[],this.buildUI(e),this.videoEl&&(this.videoEl.srcObject=t,this.videoEl.play().catch(()=>{}));const i=Zi(),s={};i&&(s.mimeType=i);const n=new MediaRecorder(t,s);return this.mediaRecorder=n,n.ondataavailable=r=>{r.data.size>0&&this.chunks.push(r.data)},n.onstop=()=>{this.handleRecordingComplete()},n.start(),this.timerInterval=setInterval(()=>{this.elapsed++,this.updateTimer(),this.elapsed>=lt&&this.stopRecording()},1e3),new Promise(r=>{this.resolvePromise=r})}stopRecording(){!this.recording||!this.mediaRecorder||this.mediaRecorder.state==="recording"&&this.mediaRecorder.stop()}cancelRecording(){var e;this.cleanup(),(e=this.resolvePromise)==null||e.call(this,null),this.resolvePromise=null}destroy(){this.cancelRecording()}buildUI(e){this.styleEl=document.createElement("style"),this.styleEl.textContent=Gi,document.head.appendChild(this.styleEl),this.root=document.createElement("div"),this.root.className="vr-overlay";const t=document.createElement("div");t.className="vr-circle-wrapper";const i=document.createElement("div");i.className="vr-ring",t.appendChild(i);const s=document.createElement("div");s.className="vr-video-circle",this.videoEl=document.createElement("video"),this.videoEl.muted=!0,this.videoEl.playsInline=!0,this.videoEl.setAttribute("playsinline",""),s.appendChild(this.videoEl),t.appendChild(s),this.root.appendChild(t),this.timerEl=document.createElement("span"),this.timerEl.className="vr-timer",this.timerEl.textContent="00:00",this.root.appendChild(this.timerEl);const n=document.createElement("div");n.className="vr-actions";const r=document.createElement("button");r.className="vr-btn vr-btn-stop",r.textContent="Stop",r.addEventListener("click",()=>this.stopRecording()),n.appendChild(r);const a=document.createElement("button");a.className="vr-btn vr-btn-cancel",a.textContent="Cancel",a.addEventListener("click",()=>this.cancelRecording()),n.appendChild(a),this.root.appendChild(n),e.appendChild(this.root)}updateTimer(){if(!this.timerEl)return;const e=lt-this.elapsed;this.timerEl.textContent=Ji(this.elapsed),e<=10?this.timerEl.classList.add("vr-countdown"):this.timerEl.classList.remove("vr-countdown")}async handleRecordingComplete(){var s,n;const e=((s=this.mediaRecorder)==null?void 0:s.mimeType)||"video/webm",t=new Blob(this.chunks,{type:e});let i;try{i=await Qi(t)}catch{const r=document.createElement("canvas");r.width=1,r.height=1,i=await new Promise(a=>{r.toBlob(l=>a(l),"image/png")})}this.cleanup(),(n=this.resolvePromise)==null||n.call(this,{blob:t,posterBlob:i}),this.resolvePromise=null}cleanup(){if(this.recording=!1,this.timerInterval&&(clearInterval(this.timerInterval),this.timerInterval=null),this.mediaRecorder&&this.mediaRecorder.state!=="inactive")try{this.mediaRecorder.stop()}catch{}if(this.mediaRecorder=null,this.stream){for(const e of this.stream.getTracks())e.stop();this.stream=null}this.videoEl&&(this.videoEl.srcObject=null,this.videoEl=null),this.root&&this.root.parentElement&&this.root.parentElement.removeChild(this.root),this.root=null,this.styleEl&&this.styleEl.parentElement&&this.styleEl.parentElement.removeChild(this.styleEl),this.styleEl=null,this.chunks=[],this.elapsed=0}}const dt={position:"absolute",top:"50%",transform:"translateY(-50%)",width:"44px",height:"44px",border:"none",borderRadius:"50%",background:"rgba(255,255,255,0.15)",color:"#fff",fontSize:"22px",cursor:"pointer",padding:"0",display:"flex",alignItems:"center",justifyContent:"center",transition:"background 150ms ease",zIndex:"1"},f=class f{static open(e,t,i){f.close(),f.urls=t&&t.length>1?t:[e],f.currentIndex=i??0;const s=f.urls.length>1,n=document.createElement("div");n.id="pulse-widget-lightbox",Object.assign(n.style,{position:"fixed",top:"0",left:"0",width:"100%",height:"100%",zIndex:"100000",background:"rgba(0,0,0,0.85)",display:"flex",alignItems:"center",justifyContent:"center",opacity:"0",transition:"opacity 200ms ease",cursor:"pointer",fontFamily:"-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif"});const r=document.createElement("button");r.textContent="×",Object.assign(r.style,{position:"absolute",top:"16px",right:"16px",width:"40px",height:"40px",border:"none",borderRadius:"50%",background:"rgba(255,255,255,0.15)",color:"#fff",fontSize:"24px",cursor:"pointer",padding:"0",display:"flex",alignItems:"center",justifyContent:"center",transition:"background 150ms ease",zIndex:"1"}),r.addEventListener("mouseenter",()=>{r.style.background="rgba(255,255,255,0.3)"}),r.addEventListener("mouseleave",()=>{r.style.background="rgba(255,255,255,0.15)"}),r.addEventListener("click",d=>{d.stopPropagation(),f.close()}),n.appendChild(r);const a=document.createElement("img");if(a.src=f.urls[f.currentIndex],a.alt="Lightbox image",Object.assign(a.style,{maxWidth:"90vw",maxHeight:"85vh",borderRadius:"8px",objectFit:"contain",cursor:"default",userSelect:"none",transition:"opacity 150ms ease"}),a.addEventListener("click",d=>d.stopPropagation()),n.appendChild(a),f.imgEl=a,s){const d=document.createElement("button");d.innerHTML='<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><polyline points="15,18 9,12 15,6"/></svg>',Object.assign(d.style,{...dt,left:"16px"}),d.addEventListener("mouseenter",()=>{d.style.background="rgba(255,255,255,0.3)"}),d.addEventListener("mouseleave",()=>{d.style.background="rgba(255,255,255,0.15)"}),d.addEventListener("click",p=>{p.stopPropagation(),f.navigate(-1)}),n.appendChild(d),f.prevBtn=d;const c=document.createElement("button");c.innerHTML='<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><polyline points="9,18 15,12 9,6"/></svg>',Object.assign(c.style,{...dt,right:"16px"}),c.addEventListener("mouseenter",()=>{c.style.background="rgba(255,255,255,0.3)"}),c.addEventListener("mouseleave",()=>{c.style.background="rgba(255,255,255,0.15)"}),c.addEventListener("click",p=>{p.stopPropagation(),f.navigate(1)}),n.appendChild(c),f.nextBtn=c;const h=document.createElement("span");Object.assign(h.style,{position:"absolute",bottom:"20px",left:"50%",transform:"translateX(-50%)",color:"rgba(255,255,255,0.7)",fontSize:"13px",fontWeight:"500",pointerEvents:"none"}),n.appendChild(h),f.counterEl=h,f.updateNav()}n.addEventListener("click",()=>f.close());const l=d=>{d.key==="Escape"&&f.close(),s&&d.key==="ArrowLeft"&&f.navigate(-1),s&&d.key==="ArrowRight"&&f.navigate(1)};document.addEventListener("keydown",l),f.overlay=n,f.onKeyDown=l,document.body.appendChild(n),requestAnimationFrame(()=>{n.style.opacity="1"})}static navigate(e){const t=f.urls.length;f.currentIndex=(f.currentIndex+e+t)%t,f.imgEl&&(f.imgEl.style.opacity="0",setTimeout(()=>{f.imgEl&&(f.imgEl.src=f.urls[f.currentIndex],f.imgEl.style.opacity="1")},100)),f.updateNav()}static updateNav(){const e=f.currentIndex,t=f.urls.length;f.counterEl&&(f.counterEl.textContent=`${e+1} / ${t}`)}static close(){if(!f.overlay)return;const e=f.overlay;f.onKeyDown&&(document.removeEventListener("keydown",f.onKeyDown),f.onKeyDown=null),e.style.opacity="0",e.addEventListener("transitionend",()=>e.remove()),f.overlay=null,f.imgEl=null,f.prevBtn=null,f.nextBtn=null,f.counterEl=null,f.urls=[],f.currentIndex=0}};f.overlay=null,f.onKeyDown=null,f.urls=[],f.currentIndex=0,f.imgEl=null,f.prevBtn=null,f.nextBtn=null,f.counterEl=null;let xe=f;class te{constructor(e){this.uploading=!1,this.client=e,this.input=document.createElement("input"),this.input.type="file",this.input.style.display="none",document.body.appendChild(this.input)}pickFile(e){return new Promise(t=>{this.input.accept=e,this.input.value="";const i=()=>{n(),t(null)},s=async()=>{var a;n();const r=(a=this.input.files)==null?void 0:a[0];if(!r){t(null);return}this.uploading=!0;try{const l=await this.client.uploadFile(r);t(l)}catch(l){console.error("[Pulse] File upload failed:",l),t(null)}finally{this.uploading=!1}},n=()=>{this.input.removeEventListener("change",s),this.input.removeEventListener("cancel",i)};this.input.addEventListener("change",s,{once:!0}),this.input.addEventListener("cancel",i,{once:!0}),this.input.click()})}pickFiles(e,t){return new Promise(i=>{this.input.accept=e,this.input.multiple=!0,this.input.value="";const s=()=>{r(),i([])},n=async()=>{r();const a=this.input.files;if(!a||a.length===0){i([]);return}const l=Array.from(a).slice(0,t);this.uploading=!0;try{const d=await Promise.all(l.map(async c=>{try{return await this.client.uploadFile(c)}catch(h){return console.error("[Pulse] File upload failed:",h),null}}));i(d.filter(c=>c!==null))}finally{this.uploading=!1,this.input.multiple=!1}},r=()=>{this.input.removeEventListener("change",n),this.input.removeEventListener("cancel",s)};this.input.addEventListener("change",n,{once:!0}),this.input.addEventListener("cancel",s,{once:!0}),this.input.click()})}async uploadBlob(e,t){this.uploading=!0;try{const i=new File([e],t,{type:e.type});return await this.client.uploadFile(i)}catch(i){return console.error("[Pulse] Blob upload failed:",i),null}finally{this.uploading=!1}}destroy(){this.input.remove()}}const es=["👍","👎","❤️","🎉","👀","🚀"],pe="-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif",ts='<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M17 3a2.85 2.83 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5Z"/><path d="m15 5 4 4"/></svg>',is='<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M3 6h18"/><path d="M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6"/><path d="M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2"/><line x1="10" y1="11" x2="10" y2="17"/><line x1="14" y1="11" x2="14" y2="17"/></svg>',ht=`<button class="pulse-close-btn" style="
1265
+ `;function dt(o){return o.toString().padStart(2,"0")}function Zi(o){const e=Math.floor(o/60),t=o%60;return`${dt(e)}:${dt(t)}`}function Qi(){const o=["video/webm;codecs=vp9,opus","video/webm;codecs=vp8,opus","video/webm","video/mp4"];for(const e of o)if(MediaRecorder.isTypeSupported(e))return e;return""}function es(o){return new Promise((e,t)=>{const i=URL.createObjectURL(o),s=document.createElement("video");s.muted=!0,s.playsInline=!0,s.preload="auto",s.src=i,s.addEventListener("loadeddata",()=>{s.currentTime=.01}),s.addEventListener("seeked",()=>{const n=document.createElement("canvas");n.width=s.videoWidth||240,n.height=s.videoHeight||240,n.getContext("2d").drawImage(s,0,0,n.width,n.height),URL.revokeObjectURL(i),n.toBlob(a=>{a?e(a):t(new Error("Failed to generate poster frame"))},"image/jpeg",.85)}),s.addEventListener("error",()=>{URL.revokeObjectURL(i),t(new Error("Failed to load video for poster generation"))}),s.load()})}class Me{constructor(){this.recording=!1,this.container=null,this.stream=null,this.mediaRecorder=null,this.chunks=[],this.timerInterval=null,this.elapsed=0,this.resolvePromise=null,this.root=null,this.styleEl=null,this.videoEl=null,this.timerEl=null}async startRecording(e){if(this.recording)return null;let t;try{t=await navigator.mediaDevices.getUserMedia({video:!0,audio:!0})}catch{return null}this.stream=t,this.container=e,this.recording=!0,this.elapsed=0,this.chunks=[],this.buildUI(e),this.videoEl&&(this.videoEl.srcObject=t,this.videoEl.play().catch(()=>{}));const i=Qi(),s={};i&&(s.mimeType=i);const n=new MediaRecorder(t,s);return this.mediaRecorder=n,n.ondataavailable=r=>{r.data.size>0&&this.chunks.push(r.data)},n.onstop=()=>{this.handleRecordingComplete()},n.start(),this.timerInterval=setInterval(()=>{this.elapsed++,this.updateTimer(),this.elapsed>=ct&&this.stopRecording()},1e3),new Promise(r=>{this.resolvePromise=r})}stopRecording(){!this.recording||!this.mediaRecorder||this.mediaRecorder.state==="recording"&&this.mediaRecorder.stop()}cancelRecording(){var e;this.cleanup(),(e=this.resolvePromise)==null||e.call(this,null),this.resolvePromise=null}destroy(){this.cancelRecording()}buildUI(e){this.styleEl=document.createElement("style"),this.styleEl.textContent=Ji,document.head.appendChild(this.styleEl),this.root=document.createElement("div"),this.root.className="vr-overlay";const t=document.createElement("div");t.className="vr-circle-wrapper";const i=document.createElement("div");i.className="vr-ring",t.appendChild(i);const s=document.createElement("div");s.className="vr-video-circle",this.videoEl=document.createElement("video"),this.videoEl.muted=!0,this.videoEl.playsInline=!0,this.videoEl.setAttribute("playsinline",""),s.appendChild(this.videoEl),t.appendChild(s),this.root.appendChild(t),this.timerEl=document.createElement("span"),this.timerEl.className="vr-timer",this.timerEl.textContent="00:00",this.root.appendChild(this.timerEl);const n=document.createElement("div");n.className="vr-actions";const r=document.createElement("button");r.className="vr-btn vr-btn-stop",r.textContent="Stop",r.addEventListener("click",()=>this.stopRecording()),n.appendChild(r);const a=document.createElement("button");a.className="vr-btn vr-btn-cancel",a.textContent="Cancel",a.addEventListener("click",()=>this.cancelRecording()),n.appendChild(a),this.root.appendChild(n),e.appendChild(this.root)}updateTimer(){if(!this.timerEl)return;const e=ct-this.elapsed;this.timerEl.textContent=Zi(this.elapsed),e<=10?this.timerEl.classList.add("vr-countdown"):this.timerEl.classList.remove("vr-countdown")}async handleRecordingComplete(){var s,n;const e=((s=this.mediaRecorder)==null?void 0:s.mimeType)||"video/webm",t=new Blob(this.chunks,{type:e});let i;try{i=await es(t)}catch{const r=document.createElement("canvas");r.width=1,r.height=1,i=await new Promise(a=>{r.toBlob(l=>a(l),"image/png")})}this.cleanup(),(n=this.resolvePromise)==null||n.call(this,{blob:t,posterBlob:i}),this.resolvePromise=null}cleanup(){if(this.recording=!1,this.timerInterval&&(clearInterval(this.timerInterval),this.timerInterval=null),this.mediaRecorder&&this.mediaRecorder.state!=="inactive")try{this.mediaRecorder.stop()}catch{}if(this.mediaRecorder=null,this.stream){for(const e of this.stream.getTracks())e.stop();this.stream=null}this.videoEl&&(this.videoEl.srcObject=null,this.videoEl=null),this.root&&this.root.parentElement&&this.root.parentElement.removeChild(this.root),this.root=null,this.styleEl&&this.styleEl.parentElement&&this.styleEl.parentElement.removeChild(this.styleEl),this.styleEl=null,this.chunks=[],this.elapsed=0}}const ht={position:"absolute",top:"50%",transform:"translateY(-50%)",width:"44px",height:"44px",border:"none",borderRadius:"50%",background:"rgba(255,255,255,0.15)",color:"#fff",fontSize:"22px",cursor:"pointer",padding:"0",display:"flex",alignItems:"center",justifyContent:"center",transition:"background 150ms ease",zIndex:"1"},m=class m{static open(e,t,i){m.close(),m.urls=t&&t.length>1?t:[e],m.currentIndex=i??0;const s=m.urls.length>1,n=document.createElement("div");n.id="pulse-widget-lightbox",Object.assign(n.style,{position:"fixed",top:"0",left:"0",width:"100%",height:"100%",zIndex:"100000",background:"rgba(0,0,0,0.85)",display:"flex",alignItems:"center",justifyContent:"center",opacity:"0",transition:"opacity 200ms ease",cursor:"pointer",fontFamily:"-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif"});const r=document.createElement("button");r.textContent="×",Object.assign(r.style,{position:"absolute",top:"16px",right:"16px",width:"40px",height:"40px",border:"none",borderRadius:"50%",background:"rgba(255,255,255,0.15)",color:"#fff",fontSize:"24px",cursor:"pointer",padding:"0",display:"flex",alignItems:"center",justifyContent:"center",transition:"background 150ms ease",zIndex:"1"}),r.addEventListener("mouseenter",()=>{r.style.background="rgba(255,255,255,0.3)"}),r.addEventListener("mouseleave",()=>{r.style.background="rgba(255,255,255,0.15)"}),r.addEventListener("click",d=>{d.stopPropagation(),m.close()}),n.appendChild(r);const a=document.createElement("img");if(a.src=m.urls[m.currentIndex],a.alt="Lightbox image",Object.assign(a.style,{maxWidth:"90vw",maxHeight:"85vh",borderRadius:"8px",objectFit:"contain",cursor:"default",userSelect:"none",transition:"opacity 150ms ease"}),a.addEventListener("click",d=>d.stopPropagation()),n.appendChild(a),m.imgEl=a,s){const d=document.createElement("button");d.innerHTML='<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><polyline points="15,18 9,12 15,6"/></svg>',Object.assign(d.style,{...ht,left:"16px"}),d.addEventListener("mouseenter",()=>{d.style.background="rgba(255,255,255,0.3)"}),d.addEventListener("mouseleave",()=>{d.style.background="rgba(255,255,255,0.15)"}),d.addEventListener("click",u=>{u.stopPropagation(),m.navigate(-1)}),n.appendChild(d),m.prevBtn=d;const c=document.createElement("button");c.innerHTML='<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><polyline points="9,18 15,12 9,6"/></svg>',Object.assign(c.style,{...ht,right:"16px"}),c.addEventListener("mouseenter",()=>{c.style.background="rgba(255,255,255,0.3)"}),c.addEventListener("mouseleave",()=>{c.style.background="rgba(255,255,255,0.15)"}),c.addEventListener("click",u=>{u.stopPropagation(),m.navigate(1)}),n.appendChild(c),m.nextBtn=c;const h=document.createElement("span");Object.assign(h.style,{position:"absolute",bottom:"20px",left:"50%",transform:"translateX(-50%)",color:"rgba(255,255,255,0.7)",fontSize:"13px",fontWeight:"500",pointerEvents:"none"}),n.appendChild(h),m.counterEl=h,m.updateNav()}n.addEventListener("click",()=>m.close());const l=d=>{d.key==="Escape"&&m.close(),s&&d.key==="ArrowLeft"&&m.navigate(-1),s&&d.key==="ArrowRight"&&m.navigate(1)};document.addEventListener("keydown",l),m.overlay=n,m.onKeyDown=l,document.body.appendChild(n),requestAnimationFrame(()=>{n.style.opacity="1"})}static navigate(e){const t=m.urls.length;m.currentIndex=(m.currentIndex+e+t)%t,m.imgEl&&(m.imgEl.style.opacity="0",setTimeout(()=>{m.imgEl&&(m.imgEl.src=m.urls[m.currentIndex],m.imgEl.style.opacity="1")},100)),m.updateNav()}static updateNav(){const e=m.currentIndex,t=m.urls.length;m.counterEl&&(m.counterEl.textContent=`${e+1} / ${t}`)}static close(){if(!m.overlay)return;const e=m.overlay;m.onKeyDown&&(document.removeEventListener("keydown",m.onKeyDown),m.onKeyDown=null),e.style.opacity="0",e.addEventListener("transitionend",()=>e.remove()),m.overlay=null,m.imgEl=null,m.prevBtn=null,m.nextBtn=null,m.counterEl=null,m.urls=[],m.currentIndex=0}};m.overlay=null,m.onKeyDown=null,m.urls=[],m.currentIndex=0,m.imgEl=null,m.prevBtn=null,m.nextBtn=null,m.counterEl=null;let xe=m;class te{constructor(e){this.uploading=!1,this.client=e,this.input=document.createElement("input"),this.input.type="file",this.input.style.display="none",document.body.appendChild(this.input)}pickFile(e){return new Promise(t=>{this.input.accept=e,this.input.value="";const i=()=>{n(),t(null)},s=async()=>{var a;n();const r=(a=this.input.files)==null?void 0:a[0];if(!r){t(null);return}this.uploading=!0;try{const l=await this.client.uploadFile(r);t(l)}catch(l){console.error("[Pulse] File upload failed:",l),t(null)}finally{this.uploading=!1}},n=()=>{this.input.removeEventListener("change",s),this.input.removeEventListener("cancel",i)};this.input.addEventListener("change",s,{once:!0}),this.input.addEventListener("cancel",i,{once:!0}),this.input.click()})}pickFiles(e,t){return new Promise(i=>{this.input.accept=e,this.input.multiple=!0,this.input.value="";const s=()=>{r(),i([])},n=async()=>{r();const a=this.input.files;if(!a||a.length===0){i([]);return}const l=Array.from(a).slice(0,t);this.uploading=!0;try{const d=await Promise.all(l.map(async c=>{try{return await this.client.uploadFile(c)}catch(h){return console.error("[Pulse] File upload failed:",h),null}}));i(d.filter(c=>c!==null))}finally{this.uploading=!1,this.input.multiple=!1}},r=()=>{this.input.removeEventListener("change",n),this.input.removeEventListener("cancel",s)};this.input.addEventListener("change",n,{once:!0}),this.input.addEventListener("cancel",s,{once:!0}),this.input.click()})}async uploadBlob(e,t){this.uploading=!0;try{const i=new File([e],t,{type:e.type});return await this.client.uploadFile(i)}catch(i){return console.error("[Pulse] Blob upload failed:",i),null}finally{this.uploading=!1}}destroy(){this.input.remove()}}const ts="-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif";class Oe{constructor(e){this.dropdown=null,this.target=null,this.mentionStart=-1,this.selectedIndex=0,this.filteredUsers=[],this.handleInput=()=>{var l;if(!this.target)return;const t=this.target.value,i=this.target.selectionStart??t.length,s=t.slice(0,i),n=s.lastIndexOf("@");if(n===-1||n>0&&/\w/.test(s[n-1])){this.close();return}const r=s.slice(n+1).toLowerCase();if(r.includes(" ")){this.close();return}this.mentionStart=n;const a=(l=this.client.state.user)==null?void 0:l.id;if(this.filteredUsers=this.client.state.users.filter(d=>d.id!==a&&d.name.toLowerCase().includes(r)).slice(0,5),this.filteredUsers.length===0){this.close();return}this.selectedIndex=0,this.showDropdown()},this.handleKeydown=t=>{this.dropdown&&(t.key==="ArrowDown"?(t.preventDefault(),this.selectedIndex=Math.min(this.selectedIndex+1,this.filteredUsers.length-1),this.renderItems()):t.key==="ArrowUp"?(t.preventDefault(),this.selectedIndex=Math.max(this.selectedIndex-1,0),this.renderItems()):t.key==="Enter"&&this.dropdown?(t.preventDefault(),t.stopPropagation(),this.selectUser(this.filteredUsers[this.selectedIndex])):t.key==="Escape"&&this.close())},this.handleBlur=()=>{setTimeout(()=>this.close(),150)},this.client=e}attach(e){this.target=e,e.addEventListener("input",this.handleInput),e.addEventListener("keydown",this.handleKeydown),e.addEventListener("blur",this.handleBlur)}detach(){this.target&&(this.target.removeEventListener("input",this.handleInput),this.target.removeEventListener("keydown",this.handleKeydown),this.target.removeEventListener("blur",this.handleBlur),this.target=null),this.close()}selectUser(e){if(!this.target)return;const t=this.target.value,i=this.target.selectionStart??t.length,s=e.name.split(" ")[0],n=t.slice(0,this.mentionStart),r=t.slice(i);this.target.value=`${n}@${s} ${r}`;const a=this.mentionStart+s.length+2;this.target.setSelectionRange(a,a),this.target.focus(),this.target.dispatchEvent(new Event("input",{bubbles:!0})),this.close()}showDropdown(){if(!this.target)return;this.dropdown||(this.dropdown=document.createElement("div"),Object.assign(this.dropdown.style,{position:"absolute",zIndex:"100002",background:"#fff",border:"1px solid #e2e8f0",borderRadius:"8px",boxShadow:"0 4px 16px rgba(0,0,0,0.12)",overflow:"hidden",fontFamily:ts,minWidth:"160px",maxWidth:"220px"}),document.body.appendChild(this.dropdown));const e=this.target.getBoundingClientRect();this.dropdown.style.left=`${e.left}px`,this.dropdown.style.top=`${e.bottom+4}px`,this.renderItems()}renderItems(){this.dropdown&&(this.dropdown.innerHTML=this.filteredUsers.map((e,t)=>{const i=e.name.split(" ").map(n=>n[0]).join("").toUpperCase().slice(0,2),s=t===this.selectedIndex;return`
1266
+ <div class="mention-item" data-index="${t}" style="
1267
+ display:flex;align-items:center;gap:8px;padding:6px 10px;
1268
+ cursor:pointer;font-size:13px;
1269
+ background:${s?"#f1f5f9":"#fff"};
1270
+ transition:background 0.1s;
1271
+ ">
1272
+ <div style="
1273
+ width:24px;height:24px;border-radius:50%;
1274
+ background:${e.color};color:#fff;
1275
+ display:flex;align-items:center;justify-content:center;
1276
+ font-size:10px;font-weight:700;flex-shrink:0;
1277
+ ">${e.avatar?`<img src="${e.avatar}" style="width:100%;height:100%;border-radius:50%;object-fit:cover;" />`:i}</div>
1278
+ <span style="color:#0f172a;font-weight:500;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;">${this.escapeHtml(e.name)}</span>
1279
+ </div>
1280
+ `}).join(""),this.dropdown.querySelectorAll(".mention-item").forEach(e=>{e.addEventListener("mousedown",t=>{t.preventDefault();const i=parseInt(e.dataset.index,10);this.selectUser(this.filteredUsers[i])}),e.addEventListener("mouseenter",()=>{this.selectedIndex=parseInt(e.dataset.index,10),this.renderItems()})}))}close(){var e;(e=this.dropdown)==null||e.remove(),this.dropdown=null,this.mentionStart=-1,this.filteredUsers=[]}escapeHtml(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}}const is=["👍","👎","❤️","🎉","👀","🚀"],pe="-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif",ss='<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M17 3a2.85 2.83 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5Z"/><path d="m15 5 4 4"/></svg>',ns='<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M3 6h18"/><path d="M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6"/><path d="M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2"/><line x1="10" y1="11" x2="10" y2="17"/><line x1="14" y1="11" x2="14" y2="17"/></svg>',pt=`<button class="pulse-close-btn" style="
1266
1281
  border:none;background:none;cursor:pointer;color:#94a3b8;padding:4px;
1267
1282
  border-radius:6px;display:flex;align-items:center;justify-content:center;
1268
1283
  transition:all 0.15s;flex-shrink:0;
1269
1284
  " onmouseover="this.style.background='#f1f5f9';this.style.color='#0f172a'"
1270
1285
  onmouseout="this.style.background='none';this.style.color='#94a3b8'">
1271
1286
  <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="18" y1="6" x2="6" y2="18"/><line x1="6" y1="6" x2="18" y2="18"/></svg>
1272
- </button>`;class ss{constructor(e,t={}){this.container=null,this.overlay=null,this.form=null,this.popover=null,this.threads=[],this.pinEls=new Map,this._pinModeActive=!1,this.editingPopoverCommentId=null,this.popoverPickerOpen=null,this.lastTypingSendPins=new Map,this.repositionDebounce=null,this.mutationObserver=null,this.upload=null,this.audioRecorder=null,this.videoRecorder=null,this.pendingAttachmentIds=[],this.handleReposition=()=>{this.repositionDebounce||(this.repositionDebounce=setTimeout(()=>{this.repositionDebounce=null,this.renderPins()},200))},this.handleEscape=i=>{i.key==="Escape"&&this.exitPinMode()},this.handlePopoverEscape=i=>{i.key==="Escape"&&this.closePopover()},this.handlePopoverOutsideClick=i=>{var s,n;if(this.popover&&!this.popover.contains(i.target)){if((s=this.container)!=null&&s.contains(i.target)||(n=this.pickerEl)!=null&&n.contains(i.target))return;this.closePopover()}},this.handleOverlayClick=i=>{this.form&&(this.form.remove(),this.form=null);const s=window.innerWidth,n=window.innerHeight,r={x:i.clientX/s,y:i.clientY/n,scrollX:window.scrollX,scrollY:window.scrollY},a=this.overlay.style.pointerEvents;this.overlay.style.pointerEvents="none";const l=document.elementFromPoint(i.clientX,i.clientY);if(this.overlay.style.pointerEvents=a,l){r.selector=this.getSelector(l);const d=l.getBoundingClientRect();d.width>0&&d.height>0&&(r.elementOffsetX=(i.clientX-d.left)/d.width,r.elementOffsetY=(i.clientY-d.top)/d.height)}this.showPinForm(i.clientX,i.clientY,r)},this.pickerEl=null,this.client=e,this.onPinModeExit=t.onPinModeExit,this.init()}get pinModeActive(){return this._pinModeActive}init(){this.container=document.createElement("div"),this.container.id="pulse-widget-pins",Object.assign(this.container.style,{position:"fixed",top:"0",left:"0",width:"100%",height:"100%",pointerEvents:"none",zIndex:"9997"}),document.body.appendChild(this.container),this.threads=this.client.state.threads,this.renderPins(),this.unsub=this.client.state.on("threads",e=>{if(this.threads=[...e],this.renderPins(),this.popover&&this.popover.dataset.threadId){const t=this.threads.find(i=>i.id===this.popover.dataset.threadId);t?this.refreshPopoverComments(t):this.closePopover()}}),this.reactionUnsub=this.client.state.on("reactions",()=>{if(this.popover&&this.popover.dataset.threadId){const e=this.threads.find(t=>t.id===this.popover.dataset.threadId);e&&this.refreshPopoverComments(e)}}),this.typingUnsub2=this.client.state.on("typing",()=>{this.popover&&this.popover.dataset.threadId&&this.updatePopoverTyping(this.popover.dataset.threadId)}),window.addEventListener("scroll",this.handleReposition,!0),window.addEventListener("resize",this.handleReposition),this.mutationObserver=new MutationObserver(this.handleReposition),this.mutationObserver.observe(document.body,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["style","class"]})}enterPinMode(){this._pinModeActive||(this._pinModeActive=!0,this.closePopover(),this.overlay=document.createElement("div"),Object.assign(this.overlay.style,{position:"fixed",top:"0",left:"0",width:"100%",height:"100%",zIndex:"10000",cursor:"crosshair",background:"rgba(99, 102, 241, 0.04)"}),this.overlay.addEventListener("click",this.handleOverlayClick),document.addEventListener("keydown",this.handleEscape),document.body.appendChild(this.overlay))}exitPinMode(){var e,t,i;this._pinModeActive&&(this._pinModeActive=!1,(e=this.overlay)==null||e.remove(),this.overlay=null,(t=this.form)==null||t.remove(),this.form=null,document.removeEventListener("keydown",this.handleEscape),(i=this.onPinModeExit)==null||i.call(this))}setVisible(e){this.container&&(this.container.style.display=e?"":"none")}destroy(){var e,t,i,s,n,r;this.exitPinMode(),this.closePopover(),this.removePickerEl(),(e=this.unsub)==null||e.call(this),(t=this.threadUnsub)==null||t.call(this),(i=this.reactionUnsub)==null||i.call(this),(s=this.typingUnsub2)==null||s.call(this),window.removeEventListener("scroll",this.handleReposition,!0),window.removeEventListener("resize",this.handleReposition),(n=this.mutationObserver)==null||n.disconnect(),this.mutationObserver=null,this.repositionDebounce&&(clearTimeout(this.repositionDebounce),this.repositionDebounce=null),(r=this.container)==null||r.remove(),this.container=null,this.pinEls.clear()}closePopover(){var e;this.removePickerEl(),this.popoverPickerOpen=null,(e=this.popover)==null||e.remove(),this.popover=null,this.editingPopoverCommentId=null,document.removeEventListener("keydown",this.handlePopoverEscape),document.removeEventListener("pointerdown",this.handlePopoverOutsideClick)}escapeHtml(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}getSelector(e){const t=[];let i=e;for(;i&&i!==document.body&&i!==document.documentElement;){if(i.id){t.unshift(`#${i.id}`);break}const s=i.tagName.toLowerCase(),n=[...i.classList].filter(l=>!l.startsWith("pulse-")).slice(0,2);let r=n.length>0?`${s}.${n.join(".")}`:s;const a=i.parentElement;if(a){const l=[...a.children].filter(d=>d.tagName===i.tagName);if(l.length>1){const d=l.indexOf(i)+1;r+=`:nth-child(${d})`}}if(t.unshift(r),i=i.parentElement,t.length>=4)break}return t.join(" > ")}showPinForm(e,t,i){this.form=document.createElement("div");const s=Math.min(280,window.innerWidth-32),n=120;let r=e+16,a=t-10;r+s>window.innerWidth-16&&(r=e-s-16),a+n>window.innerHeight-16&&(a=window.innerHeight-n-16),a<16&&(a=16),Object.assign(this.form.style,{position:"fixed",left:`${r}px`,top:`${a}px`,width:`${s}px`,zIndex:"10001",background:"#fff",borderRadius:"12px",boxShadow:"0 8px 40px rgba(0,0,0,0.18), 0 2px 8px rgba(0,0,0,0.08)",border:"1px solid #e2e8f0",padding:"14px",fontFamily:pe}),this.form.innerHTML=`
1287
+ </button>`;class os{constructor(e,t={}){this.container=null,this.overlay=null,this.form=null,this.popover=null,this.threads=[],this.pinEls=new Map,this._pinModeActive=!1,this.editingPopoverCommentId=null,this.popoverPickerOpen=null,this.lastTypingSendPins=new Map,this.repositionDebounce=null,this.mutationObserver=null,this.upload=null,this.audioRecorder=null,this.videoRecorder=null,this.pendingAttachmentIds=[],this.handleReposition=()=>{this.repositionDebounce||(this.repositionDebounce=setTimeout(()=>{this.repositionDebounce=null,this.renderPins()},200))},this.handleEscape=i=>{i.key==="Escape"&&this.exitPinMode()},this.handlePopoverEscape=i=>{i.key==="Escape"&&this.closePopover()},this.handlePopoverOutsideClick=i=>{var s,n;if(this.popover&&!this.popover.contains(i.target)){if((s=this.container)!=null&&s.contains(i.target)||(n=this.pickerEl)!=null&&n.contains(i.target))return;this.closePopover()}},this.handleOverlayClick=i=>{this.form&&(this.form.remove(),this.form=null);const s=window.innerWidth,n=window.innerHeight,r={x:i.clientX/s,y:i.clientY/n,scrollX:window.scrollX,scrollY:window.scrollY},a=this.overlay.style.pointerEvents;this.overlay.style.pointerEvents="none";const l=document.elementFromPoint(i.clientX,i.clientY);if(this.overlay.style.pointerEvents=a,l){r.selector=this.getSelector(l);const d=l.getBoundingClientRect();d.width>0&&d.height>0&&(r.elementOffsetX=(i.clientX-d.left)/d.width,r.elementOffsetY=(i.clientY-d.top)/d.height)}this.showPinForm(i.clientX,i.clientY,r)},this.pickerEl=null,this.client=e,this.onPinModeExit=t.onPinModeExit,this.init()}get pinModeActive(){return this._pinModeActive}init(){this.container=document.createElement("div"),this.container.id="pulse-widget-pins",Object.assign(this.container.style,{position:"fixed",top:"0",left:"0",width:"100%",height:"100%",pointerEvents:"none",zIndex:"9997"}),document.body.appendChild(this.container),this.threads=this.client.state.threads,this.renderPins(),this.unsub=this.client.state.on("threads",e=>{if(this.threads=[...e],this.renderPins(),this.popover&&this.popover.dataset.threadId){const t=this.threads.find(i=>i.id===this.popover.dataset.threadId);t?this.refreshPopoverComments(t):this.closePopover()}}),this.reactionUnsub=this.client.state.on("reactions",()=>{if(this.popover&&this.popover.dataset.threadId){const e=this.threads.find(t=>t.id===this.popover.dataset.threadId);e&&this.refreshPopoverComments(e)}}),this.typingUnsub2=this.client.state.on("typing",()=>{this.popover&&this.popover.dataset.threadId&&this.updatePopoverTyping(this.popover.dataset.threadId)}),window.addEventListener("scroll",this.handleReposition,!0),window.addEventListener("resize",this.handleReposition),this.mutationObserver=new MutationObserver(this.handleReposition),this.mutationObserver.observe(document.body,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["style","class"]})}enterPinMode(){this._pinModeActive||(this._pinModeActive=!0,this.closePopover(),this.overlay=document.createElement("div"),Object.assign(this.overlay.style,{position:"fixed",top:"0",left:"0",width:"100%",height:"100%",zIndex:"10000",cursor:"crosshair",background:"rgba(99, 102, 241, 0.04)"}),this.overlay.addEventListener("click",this.handleOverlayClick),document.addEventListener("keydown",this.handleEscape),document.body.appendChild(this.overlay))}exitPinMode(){var e,t,i;this._pinModeActive&&(this._pinModeActive=!1,(e=this.overlay)==null||e.remove(),this.overlay=null,(t=this.form)==null||t.remove(),this.form=null,document.removeEventListener("keydown",this.handleEscape),(i=this.onPinModeExit)==null||i.call(this))}setVisible(e){this.container&&(this.container.style.display=e?"":"none")}destroy(){var e,t,i,s,n,r;this.exitPinMode(),this.closePopover(),this.removePickerEl(),(e=this.unsub)==null||e.call(this),(t=this.threadUnsub)==null||t.call(this),(i=this.reactionUnsub)==null||i.call(this),(s=this.typingUnsub2)==null||s.call(this),window.removeEventListener("scroll",this.handleReposition,!0),window.removeEventListener("resize",this.handleReposition),(n=this.mutationObserver)==null||n.disconnect(),this.mutationObserver=null,this.repositionDebounce&&(clearTimeout(this.repositionDebounce),this.repositionDebounce=null),(r=this.container)==null||r.remove(),this.container=null,this.pinEls.clear()}closePopover(){var e;this.removePickerEl(),this.popoverPickerOpen=null,(e=this.popover)==null||e.remove(),this.popover=null,this.editingPopoverCommentId=null,document.removeEventListener("keydown",this.handlePopoverEscape),document.removeEventListener("pointerdown",this.handlePopoverOutsideClick)}escapeHtml(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}getSelector(e){const t=[];let i=e;for(;i&&i!==document.body&&i!==document.documentElement;){if(i.id){t.unshift(`#${i.id}`);break}const s=i.tagName.toLowerCase(),n=[...i.classList].filter(l=>!l.startsWith("pulse-")).slice(0,2);let r=n.length>0?`${s}.${n.join(".")}`:s;const a=i.parentElement;if(a){const l=[...a.children].filter(d=>d.tagName===i.tagName);if(l.length>1){const d=l.indexOf(i)+1;r+=`:nth-child(${d})`}}if(t.unshift(r),i=i.parentElement,t.length>=4)break}return t.join(" > ")}showPinForm(e,t,i){this.form=document.createElement("div");const s=Math.min(280,window.innerWidth-32),n=120;let r=e+16,a=t-10;r+s>window.innerWidth-16&&(r=e-s-16),a+n>window.innerHeight-16&&(a=window.innerHeight-n-16),a<16&&(a=16),Object.assign(this.form.style,{position:"fixed",left:`${r}px`,top:`${a}px`,width:`${s}px`,zIndex:"10001",background:"#fff",borderRadius:"12px",boxShadow:"0 8px 40px rgba(0,0,0,0.18), 0 2px 8px rgba(0,0,0,0.08)",border:"1px solid #e2e8f0",padding:"14px",fontFamily:pe}),this.form.innerHTML=`
1273
1288
  <div style="display:flex;align-items:center;justify-content:space-between;margin-bottom:8px;">
1274
1289
  <span style="font-size:13px;font-weight:600;color:#0f172a;">Add a comment here</span>
1275
- ${ht}
1290
+ ${pt}
1276
1291
  </div>
1277
1292
  <textarea
1278
1293
  placeholder="Write a comment..."
@@ -1303,14 +1318,14 @@
1303
1318
  </div>
1304
1319
  </div>
1305
1320
  <div class="pin-attachments-preview" style="margin-top:6px;display:flex;flex-wrap:wrap;gap:6px;"></div>
1306
- `;const l=this.form.querySelector("textarea"),d=this.form.querySelector(".pulse-close-btn"),c=this.form.querySelector(".pin-submit");d.addEventListener("click",()=>this.exitPinMode()),this.pendingAttachmentIds=[],this.upload||(this.upload=new te(this.client));const h=this.form.querySelector(".pin-attachments-preview"),p=(g,y)=>{const b=document.createElement("div");Object.assign(b.style,{position:"relative",display:"inline-block"}),b.appendChild(y);const w=document.createElement("button");w.innerHTML="×",Object.assign(w.style,{position:"absolute",top:"-4px",right:"-4px",width:"16px",height:"16px",borderRadius:"50%",background:"#ef4444",color:"#fff",border:"none",fontSize:"11px",lineHeight:"1",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",padding:"0",fontWeight:"700"}),w.addEventListener("click",()=>{const k=this.pendingAttachmentIds.indexOf(g);k!==-1&&this.pendingAttachmentIds.splice(k,1),b.remove()}),b.appendChild(w),h.appendChild(b)},m=5;this.form.querySelector(".attach-img").addEventListener("click",async()=>{const g=m-this.pendingAttachmentIds.length;if(g<=0)return;const y=await this.upload.pickFiles("image/*",g);for(const b of y){this.pendingAttachmentIds.push(b.id);const w=document.createElement("img");w.src=b.thumbnailUrl||b.url,Object.assign(w.style,{width:"48px",height:"48px",borderRadius:"6px",objectFit:"cover",border:"1px solid #e2e8f0",display:"block"}),p(b.id,w)}}),this.form.querySelector(".attach-mic").addEventListener("click",async()=>{if(this.pendingAttachmentIds.length>=m)return;this.audioRecorder||(this.audioRecorder=new Ie);const g=await this.audioRecorder.startRecording(h);if(g){const y=await this.upload.uploadBlob(g,"audio.webm");if(y){this.pendingAttachmentIds.push(y.id);const b=document.createElement("span");Object.assign(b.style,{display:"flex",alignItems:"center",padding:"4px 10px",borderRadius:"6px",background:"#f1f5f9",fontSize:"11px",color:"#64748b",height:"48px",boxSizing:"border-box"}),b.textContent="🎤 Audio",p(y.id,b)}}}),this.form.querySelector(".attach-video").addEventListener("click",async()=>{if(this.pendingAttachmentIds.length>=m)return;this.videoRecorder||(this.videoRecorder=new Me);const g=await this.videoRecorder.startRecording(h);if(g){const y=await this.upload.uploadBlob(g.blob,"video.webm");if(y){this.pendingAttachmentIds.push(y.id);const b=document.createElement("span");Object.assign(b.style,{display:"flex",alignItems:"center",padding:"4px 10px",borderRadius:"6px",background:"#f1f5f9",fontSize:"11px",color:"#64748b",height:"48px",boxSizing:"border-box"}),b.textContent="🎥 Video",p(y.id,b)}}}),c.addEventListener("click",()=>{const g=l.value.trim();if(!g&&this.pendingAttachmentIds.length===0)return;const y=[...(g||"").matchAll(/@(\w+)/g)].map(b=>b[1]);this.client.createThread(g,{position:i,mentions:y,attachmentIds:this.pendingAttachmentIds.length>0?[...this.pendingAttachmentIds]:void 0}),this.pendingAttachmentIds=[],this.exitPinMode()}),l.addEventListener("keydown",g=>{g.key==="Escape"&&this.exitPinMode(),g.stopPropagation()}),document.body.appendChild(this.form),requestAnimationFrame(()=>l.focus())}showThreadPopover(e,t){this.closePopover(),this.popover=document.createElement("div"),this.popover.dataset.threadId=e.id;const i=window.innerWidth<=480,s=i?window.innerWidth:300,n=t.getBoundingClientRect();let r,a;i?(r=0,a=window.innerHeight*.4):(r=n.right+10,a=n.top-8,r+s>window.innerWidth-16&&(r=n.left-s-10),a<16&&(a=16)),Object.assign(this.popover.style,{position:"fixed",left:`${r}px`,top:`${a}px`,width:i?"100vw":`${s}px`,maxHeight:i?"60vh":"360px",zIndex:"10001",background:"#fff",borderRadius:i?"16px 16px 0 0":"12px",boxShadow:"0 8px 40px rgba(0,0,0,0.18), 0 2px 8px rgba(0,0,0,0.08)",border:"1px solid #e2e8f0",fontFamily:pe,display:"flex",flexDirection:"column",overflow:"hidden",pointerEvents:"auto",...i?{bottom:"0",top:"auto"}:{}});const l=document.createElement("div");Object.assign(l.style,{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"10px 14px",borderBottom:"1px solid #f1f5f9",flexShrink:"0"}),l.innerHTML=`
1321
+ `;const l=this.form.querySelector("textarea"),d=this.form.querySelector(".pulse-close-btn"),c=this.form.querySelector(".pin-submit"),h=new Oe(this.client);h.attach(l),d.addEventListener("click",()=>{h.detach(),this.exitPinMode()}),this.pendingAttachmentIds=[],this.upload||(this.upload=new te(this.client));const u=this.form.querySelector(".pin-attachments-preview"),f=(x,y)=>{const v=document.createElement("div");Object.assign(v.style,{position:"relative",display:"inline-block"}),v.appendChild(y);const $=document.createElement("button");$.innerHTML="×",Object.assign($.style,{position:"absolute",top:"-4px",right:"-4px",width:"16px",height:"16px",borderRadius:"50%",background:"#ef4444",color:"#fff",border:"none",fontSize:"11px",lineHeight:"1",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",padding:"0",fontWeight:"700"}),$.addEventListener("click",()=>{const P=this.pendingAttachmentIds.indexOf(x);P!==-1&&this.pendingAttachmentIds.splice(P,1),v.remove()}),v.appendChild($),u.appendChild(v)},b=5;this.form.querySelector(".attach-img").addEventListener("click",async()=>{const x=b-this.pendingAttachmentIds.length;if(x<=0)return;const y=await this.upload.pickFiles("image/*",x);for(const v of y){this.pendingAttachmentIds.push(v.id);const $=document.createElement("img");$.src=v.thumbnailUrl||v.url,Object.assign($.style,{width:"48px",height:"48px",borderRadius:"6px",objectFit:"cover",border:"1px solid #e2e8f0",display:"block"}),f(v.id,$)}}),this.form.querySelector(".attach-mic").addEventListener("click",async()=>{if(this.pendingAttachmentIds.length>=b)return;this.audioRecorder||(this.audioRecorder=new Ie);const x=await this.audioRecorder.startRecording(u);if(x){const y=await this.upload.uploadBlob(x,"audio.webm");if(y){this.pendingAttachmentIds.push(y.id);const v=document.createElement("span");Object.assign(v.style,{display:"flex",alignItems:"center",padding:"4px 10px",borderRadius:"6px",background:"#f1f5f9",fontSize:"11px",color:"#64748b",height:"48px",boxSizing:"border-box"}),v.textContent="🎤 Audio",f(y.id,v)}}}),this.form.querySelector(".attach-video").addEventListener("click",async()=>{if(this.pendingAttachmentIds.length>=b)return;this.videoRecorder||(this.videoRecorder=new Me);const x=await this.videoRecorder.startRecording(u);if(x){const y=await this.upload.uploadBlob(x.blob,"video.webm");if(y){this.pendingAttachmentIds.push(y.id);const v=document.createElement("span");Object.assign(v.style,{display:"flex",alignItems:"center",padding:"4px 10px",borderRadius:"6px",background:"#f1f5f9",fontSize:"11px",color:"#64748b",height:"48px",boxSizing:"border-box"}),v.textContent="🎥 Video",f(y.id,v)}}}),c.addEventListener("click",()=>{const x=l.value.trim();if(!x&&this.pendingAttachmentIds.length===0)return;const y=[...(x||"").matchAll(/@(\w+)/g)].map(v=>v[1]);this.client.createThread(x,{position:i,mentions:y,attachmentIds:this.pendingAttachmentIds.length>0?[...this.pendingAttachmentIds]:void 0}),this.pendingAttachmentIds=[],this.exitPinMode()}),l.addEventListener("keydown",x=>{x.key==="Escape"&&this.exitPinMode(),x.stopPropagation()}),document.body.appendChild(this.form),requestAnimationFrame(()=>l.focus())}showThreadPopover(e,t){this.closePopover(),this.popover=document.createElement("div"),this.popover.dataset.threadId=e.id;const i=window.innerWidth<=480,s=i?window.innerWidth:300,n=t.getBoundingClientRect();let r,a;i?(r=0,a=window.innerHeight*.4):(r=n.right+10,a=n.top-8,r+s>window.innerWidth-16&&(r=n.left-s-10),a<16&&(a=16)),Object.assign(this.popover.style,{position:"fixed",left:`${r}px`,top:`${a}px`,width:i?"100vw":`${s}px`,maxHeight:i?"60vh":"360px",zIndex:"10001",background:"#fff",borderRadius:i?"16px 16px 0 0":"12px",boxShadow:"0 8px 40px rgba(0,0,0,0.18), 0 2px 8px rgba(0,0,0,0.08)",border:"1px solid #e2e8f0",fontFamily:pe,display:"flex",flexDirection:"column",overflow:"hidden",pointerEvents:"auto",...i?{bottom:"0",top:"auto"}:{}});const l=document.createElement("div");Object.assign(l.style,{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"10px 14px",borderBottom:"1px solid #f1f5f9",flexShrink:"0"}),l.innerHTML=`
1307
1322
  <span style="font-size:13px;font-weight:700;color:#0f172a;">Thread</span>
1308
- ${ht}
1309
- `,l.querySelector(".pulse-close-btn").addEventListener("click",()=>{this.closePopover()}),this.popover.appendChild(l),this.refreshPopoverComments(e),this.addPopoverReplyForm(e),document.body.appendChild(this.popover);const d=this.popover.getBoundingClientRect();d.bottom>window.innerHeight-16&&(this.popover.style.top=`${Math.max(16,window.innerHeight-d.height-16)}px`),requestAnimationFrame(()=>{document.addEventListener("pointerdown",this.handlePopoverOutsideClick),document.addEventListener("keydown",this.handlePopoverEscape)})}refreshPopoverComments(e){var d;if(!this.popover)return;this.removePickerEl(),this.editingPopoverCommentId&&!e.comments.find(c=>c.id===this.editingPopoverCommentId)&&(this.editingPopoverCommentId=null);let t=this.popover.querySelector(".popover-comments");if(!t){t=document.createElement("div"),t.className="popover-comments",Object.assign(t.style,{flex:"1",overflowY:"auto",padding:"12px 14px",minHeight:"0"});const c=this.popover.firstElementChild;c&&c.nextSibling?this.popover.insertBefore(t,c.nextSibling):this.popover.appendChild(t)}const i=(d=this.client.state.user)==null?void 0:d.id;t.innerHTML=e.comments.map(c=>{const h=this.client.state.getUser(c.userId),p=h?h.name.split(" ").map(R=>R[0]).join("").toUpperCase().slice(0,2):"?",m=(h==null?void 0:h.color)??"#94a3b8",g=this.escapeHtml((h==null?void 0:h.name)??"Unknown"),y=this.formatTime(c.createdAt),b=i===c.userId,w=c.editedAt?'<span style="font-size:10px;color:#94a3b8;font-style:italic;">(edited)</span>':"";if(this.editingPopoverCommentId===c.id)return`
1323
+ ${pt}
1324
+ `,l.querySelector(".pulse-close-btn").addEventListener("click",()=>{this.closePopover()}),this.popover.appendChild(l),this.refreshPopoverComments(e),this.addPopoverReplyForm(e),document.body.appendChild(this.popover);const d=this.popover.getBoundingClientRect();d.bottom>window.innerHeight-16&&(this.popover.style.top=`${Math.max(16,window.innerHeight-d.height-16)}px`),requestAnimationFrame(()=>{document.addEventListener("pointerdown",this.handlePopoverOutsideClick),document.addEventListener("keydown",this.handlePopoverEscape)})}refreshPopoverComments(e){var d;if(!this.popover)return;this.removePickerEl(),this.editingPopoverCommentId&&!e.comments.find(c=>c.id===this.editingPopoverCommentId)&&(this.editingPopoverCommentId=null);let t=this.popover.querySelector(".popover-comments");if(!t){t=document.createElement("div"),t.className="popover-comments",Object.assign(t.style,{flex:"1",overflowY:"auto",padding:"12px 14px",minHeight:"0"});const c=this.popover.firstElementChild;c&&c.nextSibling?this.popover.insertBefore(t,c.nextSibling):this.popover.appendChild(t)}const i=(d=this.client.state.user)==null?void 0:d.id;t.innerHTML=e.comments.map(c=>{const h=this.client.state.getUser(c.userId),u=h?h.name.split(" ").map(R=>R[0]).join("").toUpperCase().slice(0,2):"?",f=(h==null?void 0:h.color)??"#94a3b8",b=this.escapeHtml((h==null?void 0:h.name)??"Unknown"),x=this.formatTime(c.createdAt),y=i===c.userId,v=c.editedAt?'<span style="font-size:10px;color:#94a3b8;font-style:italic;">(edited)</span>':"";if(this.editingPopoverCommentId===c.id)return`
1310
1325
  <div style="margin-bottom:10px;" data-comment-id="${c.id}">
1311
1326
  <div style="display:flex;align-items:center;gap:7px;margin-bottom:4px;">
1312
- <div style="width:22px;height:22px;border-radius:50%;background:${m};color:#fff;display:flex;align-items:center;justify-content:center;font-size:9px;font-weight:700;flex-shrink:0;">${p}</div>
1313
- <span style="font-size:12px;font-weight:600;color:#0f172a;">${g}</span>
1327
+ <div style="width:22px;height:22px;border-radius:50%;background:${f};color:#fff;display:flex;align-items:center;justify-content:center;font-size:9px;font-weight:700;flex-shrink:0;">${u}</div>
1328
+ <span style="font-size:12px;font-weight:600;color:#0f172a;">${b}</span>
1314
1329
  </div>
1315
1330
  <div style="margin-left:29px;">
1316
1331
  <textarea class="edit-textarea" style="width:100%;padding:6px 10px;border:1.5px solid #e2e8f0;border-radius:6px;font-size:12px;font-family:inherit;outline:none;resize:vertical;min-height:48px;color:#0f172a;box-sizing:border-box;">${this.escapeHtml(c.body)}</textarea>
@@ -1320,29 +1335,29 @@
1320
1335
  </div>
1321
1336
  </div>
1322
1337
  </div>
1323
- `;const k=c.body&&c.body!=="(attachment)"?c.body.replace(/@(\w+)/g,'<span style="color:#6366f1;font-weight:600;background:#eef2ff;padding:0 3px;border-radius:3px;">@$1</span>'):"",_=(c.attachments??[]).map(R=>{if(R.type==="image"){const St=R.thumbnailUrl||R.url;return`<div class="popover-attachment-img" data-full-url="${this.escapeHtml(R.url)}" style="margin:4px 0 4px 29px;cursor:pointer;">
1324
- <img src="${this.escapeHtml(St)}" alt="${this.escapeHtml(R.filename)}" style="max-width:180px;max-height:120px;border-radius:8px;border:1px solid #e2e8f0;display:block;" />
1325
- </div>`}return R.type==="audio"?`<div class="popover-attachment-audio" data-url="${this.escapeHtml(R.url)}" data-duration="${R.durationMs??""}" style="margin:4px 0 4px 29px;"></div>`:R.type==="video"?`<div class="popover-attachment-video" data-url="${this.escapeHtml(R.url)}" data-poster="${this.escapeHtml(R.thumbnailUrl??"")}" style="margin:4px 0 4px 29px;"></div>`:""}).join(""),O=b?`<div class="popover-comment-actions" style="display:flex;gap:2px;margin-top:2px;margin-left:29px;">
1338
+ `;const $=c.body&&c.body!=="(attachment)"?c.body.replace(/@(\w+)/g,'<span style="color:#6366f1;font-weight:600;background:#eef2ff;padding:0 3px;border-radius:3px;">@$1</span>'):"",P=(c.attachments??[]).map(R=>{if(R.type==="image"){const At=R.thumbnailUrl||R.url;return`<div class="popover-attachment-img" data-full-url="${this.escapeHtml(R.url)}" style="margin:4px 0 4px 29px;cursor:pointer;">
1339
+ <img src="${this.escapeHtml(At)}" alt="${this.escapeHtml(R.filename)}" style="max-width:180px;max-height:120px;border-radius:8px;border:1px solid #e2e8f0;display:block;" />
1340
+ </div>`}return R.type==="audio"?`<div class="popover-attachment-audio" data-url="${this.escapeHtml(R.url)}" data-duration="${R.durationMs??""}" style="margin:4px 0 4px 29px;"></div>`:R.type==="video"?`<div class="popover-attachment-video" data-url="${this.escapeHtml(R.url)}" data-poster="${this.escapeHtml(R.thumbnailUrl??"")}" style="margin:4px 0 4px 29px;"></div>`:""}).join(""),O=y?`<div class="popover-comment-actions" style="display:flex;gap:2px;margin-top:2px;margin-left:29px;">
1326
1341
  <button class="edit-btn" data-comment-id="${c.id}" style="border:none;background:none;cursor:pointer;color:#94a3b8;padding:3px;border-radius:4px;display:flex;align-items:center;transition:all 0.15s;" title="Edit"
1327
1342
  onmouseover="this.style.color='#6366f1';this.style.background='#eef2ff'"
1328
- onmouseout="this.style.color='#94a3b8';this.style.background='none'">${ts}</button>
1343
+ onmouseout="this.style.color='#94a3b8';this.style.background='none'">${ss}</button>
1329
1344
  <button class="delete-btn" data-comment-id="${c.id}" style="border:none;background:none;cursor:pointer;color:#94a3b8;padding:3px;border-radius:4px;display:flex;align-items:center;transition:all 0.15s;" title="Delete"
1330
1345
  onmouseover="this.style.color='#ef4444';this.style.background='#fef2f2'"
1331
- onmouseout="this.style.color='#94a3b8';this.style.background='none'">${is}</button>
1332
- </div>`:"",Tt=this.buildReactionPillsHtml(c.id);return`
1346
+ onmouseout="this.style.color='#94a3b8';this.style.background='none'">${ns}</button>
1347
+ </div>`:"",St=this.buildReactionPillsHtml(c.id);return`
1333
1348
  <div class="popover-comment" style="margin-bottom:10px;" data-comment-id="${c.id}">
1334
1349
  <div style="display:flex;align-items:center;gap:7px;margin-bottom:2px;">
1335
- <div style="width:22px;height:22px;border-radius:50%;background:${m};color:#fff;display:flex;align-items:center;justify-content:center;font-size:9px;font-weight:700;flex-shrink:0;">${p}</div>
1336
- <span style="font-size:12px;font-weight:600;color:#0f172a;">${g}</span>
1337
- <span style="font-size:10px;color:#94a3b8;">${y}</span>
1338
- ${w}
1350
+ <div style="width:22px;height:22px;border-radius:50%;background:${f};color:#fff;display:flex;align-items:center;justify-content:center;font-size:9px;font-weight:700;flex-shrink:0;">${u}</div>
1351
+ <span style="font-size:12px;font-weight:600;color:#0f172a;">${b}</span>
1352
+ <span style="font-size:10px;color:#94a3b8;">${x}</span>
1353
+ ${v}
1339
1354
  </div>
1340
- ${k?`<div style="font-size:13px;color:#334155;line-height:1.45;margin-left:29px;word-wrap:break-word;">${k}</div>`:""}
1341
- ${_}
1355
+ ${$?`<div style="font-size:13px;color:#334155;line-height:1.45;margin-left:29px;word-wrap:break-word;">${$}</div>`:""}
1356
+ ${P}
1342
1357
  ${O}
1343
- ${Tt}
1358
+ ${St}
1344
1359
  </div>
1345
- `}).join(""),t.querySelectorAll(".edit-btn").forEach(c=>{c.addEventListener("click",()=>{this.editingPopoverCommentId=c.dataset.commentId,this.refreshPopoverComments(e)})}),t.querySelectorAll(".delete-btn").forEach(c=>{c.addEventListener("click",()=>{this.client.deleteComment(c.dataset.commentId)})});const s=t.querySelector(".edit-save"),n=t.querySelector(".edit-cancel"),r=t.querySelector(".edit-textarea");s&&r&&s.addEventListener("click",()=>{const c=r.value.trim();if(!c)return;const h=[...c.matchAll(/@(\w+)/g)].map(p=>p[1]);this.client.editComment(this.editingPopoverCommentId,c,h),this.editingPopoverCommentId=null}),n&&n.addEventListener("click",()=>{this.editingPopoverCommentId=null,this.refreshPopoverComments(e)}),t.querySelectorAll("[data-reaction-emoji]").forEach(c=>{c.addEventListener("click",h=>{h.stopPropagation();const p=c.dataset.reactionEmoji,m=c.dataset.reactionTarget,g=c.dataset.reactionId;g?this.client.removeReaction(g):this.client.addReaction(m,"comment",p)})}),t.querySelectorAll(".popover-reaction-add").forEach(c=>{c.addEventListener("click",h=>{h.stopPropagation();const p=c.dataset.commentId;this.popoverPickerOpen===p?(this.popoverPickerOpen=null,this.removePickerEl()):(this.popoverPickerOpen=p,this.showPickerForButton(c,p))})});const a=t.querySelectorAll(".popover-attachment-img"),l=Array.from(a).map(c=>c.dataset.fullUrl).filter(Boolean);a.forEach((c,h)=>{c.addEventListener("click",()=>{const p=c.dataset.fullUrl;p&&xe.open(p,l,h)})}),t.querySelectorAll(".popover-attachment-audio").forEach(c=>{const h=c.dataset.url;if(h){const p=c.dataset.duration?parseInt(c.dataset.duration):void 0,m=_e.render(h,p);c.appendChild(m)}}),t.querySelectorAll(".popover-attachment-video").forEach(c=>{const h=c.dataset.url;if(h){const p=c.dataset.poster||void 0,m=be.render(h,p);c.appendChild(m)}}),t.scrollTop=t.scrollHeight}addPopoverReplyForm(e){if(!this.popover)return;const t=document.createElement("div");Object.assign(t.style,{padding:"8px 14px 12px",borderTop:"1px solid #f1f5f9"});const i="border:none;background:none;cursor:pointer;color:#94a3b8;padding:6px;border-radius:6px;display:flex;align-items:center;justify-content:center;min-width:32px;min-height:32px;transition:all 0.15s;",s='width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"';t.innerHTML=`
1360
+ `}).join(""),t.querySelectorAll(".edit-btn").forEach(c=>{c.addEventListener("click",()=>{this.editingPopoverCommentId=c.dataset.commentId,this.refreshPopoverComments(e)})}),t.querySelectorAll(".delete-btn").forEach(c=>{c.addEventListener("click",()=>{this.client.deleteComment(c.dataset.commentId)})});const s=t.querySelector(".edit-save"),n=t.querySelector(".edit-cancel"),r=t.querySelector(".edit-textarea");s&&r&&s.addEventListener("click",()=>{const c=r.value.trim();if(!c)return;const h=[...c.matchAll(/@(\w+)/g)].map(u=>u[1]);this.client.editComment(this.editingPopoverCommentId,c,h),this.editingPopoverCommentId=null}),n&&n.addEventListener("click",()=>{this.editingPopoverCommentId=null,this.refreshPopoverComments(e)}),t.querySelectorAll("[data-reaction-emoji]").forEach(c=>{c.addEventListener("click",h=>{h.stopPropagation();const u=c.dataset.reactionEmoji,f=c.dataset.reactionTarget,b=c.dataset.reactionId;b?this.client.removeReaction(b):this.client.addReaction(f,"comment",u)})}),t.querySelectorAll(".popover-reaction-add").forEach(c=>{c.addEventListener("click",h=>{h.stopPropagation();const u=c.dataset.commentId;this.popoverPickerOpen===u?(this.popoverPickerOpen=null,this.removePickerEl()):(this.popoverPickerOpen=u,this.showPickerForButton(c,u))})});const a=t.querySelectorAll(".popover-attachment-img"),l=Array.from(a).map(c=>c.dataset.fullUrl).filter(Boolean);a.forEach((c,h)=>{c.addEventListener("click",()=>{const u=c.dataset.fullUrl;u&&xe.open(u,l,h)})}),t.querySelectorAll(".popover-attachment-audio").forEach(c=>{const h=c.dataset.url;if(h){const u=c.dataset.duration?parseInt(c.dataset.duration):void 0,f=_e.render(h,u);c.appendChild(f)}}),t.querySelectorAll(".popover-attachment-video").forEach(c=>{const h=c.dataset.url;if(h){const u=c.dataset.poster||void 0,f=be.render(h,u);c.appendChild(f)}}),t.scrollTop=t.scrollHeight}addPopoverReplyForm(e){if(!this.popover)return;const t=document.createElement("div");Object.assign(t.style,{padding:"8px 14px 12px",borderTop:"1px solid #f1f5f9"});const i="border:none;background:none;cursor:pointer;color:#94a3b8;padding:6px;border-radius:6px;display:flex;align-items:center;justify-content:center;min-width:32px;min-height:32px;transition:all 0.15s;",s='width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"';t.innerHTML=`
1346
1361
  <div style="display:flex;align-items:center;gap:4px;margin-bottom:6px;">
1347
1362
  <input type="text" placeholder="Reply..."
1348
1363
  style="flex:1;padding:8px 12px;border:1.5px solid #e2e8f0;border-radius:8px;font-size:13px;font-family:inherit;outline:none;color:#0f172a;min-width:0;min-height:36px;transition:border-color 0.15s;" />
@@ -1360,9 +1375,9 @@
1360
1375
  </button>
1361
1376
  <div class="reply-attachments-preview" style="flex:1;display:flex;gap:4px;flex-wrap:wrap;margin-left:4px;"></div>
1362
1377
  </div>
1363
- `;const n=t.querySelector("input"),r=t.querySelector(".reply-send"),a=t.querySelector(".reply-attachments-preview");this.upload||(this.upload=new te(this.client));const l=[],d=(p,m)=>{const g=document.createElement("span");Object.assign(g.style,{position:"relative",display:"inline-flex",alignItems:"center",padding:"2px 18px 2px 8px",borderRadius:"4px",background:"#f1f5f9",fontSize:"10px",color:"#64748b"}),g.textContent=m;const y=document.createElement("button");y.innerHTML="×",Object.assign(y.style,{position:"absolute",top:"-3px",right:"-3px",width:"14px",height:"14px",borderRadius:"50%",background:"#ef4444",color:"#fff",border:"none",fontSize:"10px",lineHeight:"1",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",padding:"0",fontWeight:"700"}),y.addEventListener("click",()=>{const b=l.indexOf(p);b!==-1&&l.splice(b,1),g.remove()}),g.appendChild(y),a.appendChild(g)},c=5;t.querySelector(".reply-attach-img").addEventListener("click",async()=>{const p=c-l.length;if(p<=0)return;const m=await this.upload.pickFiles("image/*",p);for(const g of m)l.push(g.id),d(g.id,"📎 Image")}),t.querySelector(".reply-attach-mic").addEventListener("click",async()=>{if(l.length>=c)return;this.audioRecorder||(this.audioRecorder=new Ie);const p=await this.audioRecorder.startRecording(t);if(p){const m=await this.upload.uploadBlob(p,"audio.webm");m&&(l.push(m.id),d(m.id,"🎤 Audio"))}}),t.querySelector(".reply-attach-video").addEventListener("click",async()=>{if(l.length>=c)return;this.videoRecorder||(this.videoRecorder=new Me);const p=await this.videoRecorder.startRecording(t);if(p){const m=await this.upload.uploadBlob(p.blob,"video.webm");m&&(l.push(m.id),d(m.id,"🎥 Video"))}});const h=()=>{const p=n.value.trim();if(!p&&l.length===0)return;const m=[...(p||"").matchAll(/@(\w+)/g)].map(g=>g[1]);this.client.reply(e.id,p,m,l.length>0?[...l]:void 0),n.value="",l.length=0,a.innerHTML=""};r.addEventListener("click",h),n.addEventListener("input",()=>{const p=Date.now(),m=this.lastTypingSendPins.get(e.id)??0;p-m>=2e3&&(this.client.sendTyping(e.id),this.lastTypingSendPins.set(e.id,p))}),n.addEventListener("keydown",p=>{p.key==="Enter"&&(p.preventDefault(),h()),p.key==="Escape"&&this.closePopover(),p.stopPropagation()}),this.popover.appendChild(t)}removePickerEl(){var e;(e=this.pickerEl)==null||e.remove(),this.pickerEl=null}showPickerForButton(e,t){this.removePickerEl();const i=e.getBoundingClientRect();this.pickerEl=document.createElement("div"),Object.assign(this.pickerEl.style,{position:"fixed",left:`${i.left}px`,top:`${i.top-4}px`,transform:"translateY(-100%)",display:"flex",gap:"2px",padding:"4px 6px",background:"#fff",border:"1px solid #e2e8f0",borderRadius:"8px",boxShadow:"0 4px 24px rgba(0,0,0,0.12)",zIndex:"10002",fontFamily:pe});for(const s of es){const n=document.createElement("button");Object.assign(n.style,{border:"none",background:"none",cursor:"pointer",fontSize:"16px",padding:"4px",borderRadius:"4px",lineHeight:"1"}),n.textContent=s,n.addEventListener("click",r=>{r.stopPropagation();const l=this.client.state.getReactions(t).find(d=>{var c;return d.emoji===s&&d.userId===((c=this.client.state.user)==null?void 0:c.id)});l?this.client.removeReaction(l.id):this.client.addReaction(t,"comment",s),this.popoverPickerOpen=null,this.removePickerEl()}),this.pickerEl.appendChild(n)}document.body.appendChild(this.pickerEl)}buildReactionPillsHtml(e){var l;const t=this.client.state.getReactions(e),i=(l=this.client.state.user)==null?void 0:l.id,s=new Map;for(const d of t){const c=s.get(d.emoji)??{count:0,ownId:null};c.count++,d.userId===i&&(c.ownId=d.id),s.set(d.emoji,c)}const n="display:inline-flex;align-items:center;gap:3px;padding:2px 8px;border-radius:12px;border:1px solid #e2e8f0;background:#fff;font-size:12px;cursor:pointer;transition:all 0.15s;line-height:1.4;",r=n+"background:#eef2ff;border-color:#6366f1;";let a='<div style="margin-left:29px;display:flex;gap:4px;flex-wrap:wrap;margin-top:4px;">';for(const[d,{count:c,ownId:h}]of s){const p=h?r:n;a+=`<button data-reaction-emoji="${d}" data-reaction-target="${e}" ${h?`data-reaction-id="${h}"`:""} style="${p}">
1378
+ `;const n=t.querySelector("input"),r=t.querySelector(".reply-send"),a=t.querySelector(".reply-attachments-preview");this.upload||(this.upload=new te(this.client));const l=[];new Oe(this.client).attach(n);const c=(f,b)=>{const x=document.createElement("span");Object.assign(x.style,{position:"relative",display:"inline-flex",alignItems:"center",padding:"2px 18px 2px 8px",borderRadius:"4px",background:"#f1f5f9",fontSize:"10px",color:"#64748b"}),x.textContent=b;const y=document.createElement("button");y.innerHTML="×",Object.assign(y.style,{position:"absolute",top:"-3px",right:"-3px",width:"14px",height:"14px",borderRadius:"50%",background:"#ef4444",color:"#fff",border:"none",fontSize:"10px",lineHeight:"1",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",padding:"0",fontWeight:"700"}),y.addEventListener("click",()=>{const v=l.indexOf(f);v!==-1&&l.splice(v,1),x.remove()}),x.appendChild(y),a.appendChild(x)},h=5;t.querySelector(".reply-attach-img").addEventListener("click",async()=>{const f=h-l.length;if(f<=0)return;const b=await this.upload.pickFiles("image/*",f);for(const x of b)l.push(x.id),c(x.id,"📎 Image")}),t.querySelector(".reply-attach-mic").addEventListener("click",async()=>{if(l.length>=h)return;this.audioRecorder||(this.audioRecorder=new Ie);const f=await this.audioRecorder.startRecording(t);if(f){const b=await this.upload.uploadBlob(f,"audio.webm");b&&(l.push(b.id),c(b.id,"🎤 Audio"))}}),t.querySelector(".reply-attach-video").addEventListener("click",async()=>{if(l.length>=h)return;this.videoRecorder||(this.videoRecorder=new Me);const f=await this.videoRecorder.startRecording(t);if(f){const b=await this.upload.uploadBlob(f.blob,"video.webm");b&&(l.push(b.id),c(b.id,"🎥 Video"))}});const u=()=>{const f=n.value.trim();if(!f&&l.length===0)return;const b=[...(f||"").matchAll(/@(\w+)/g)].map(x=>x[1]);this.client.reply(e.id,f,b,l.length>0?[...l]:void 0),n.value="",l.length=0,a.innerHTML=""};r.addEventListener("click",u),n.addEventListener("input",()=>{const f=Date.now(),b=this.lastTypingSendPins.get(e.id)??0;f-b>=2e3&&(this.client.sendTyping(e.id),this.lastTypingSendPins.set(e.id,f))}),n.addEventListener("keydown",f=>{f.key==="Enter"&&(f.preventDefault(),u()),f.key==="Escape"&&this.closePopover(),f.stopPropagation()}),this.popover.appendChild(t)}removePickerEl(){var e;(e=this.pickerEl)==null||e.remove(),this.pickerEl=null}showPickerForButton(e,t){this.removePickerEl();const i=e.getBoundingClientRect();this.pickerEl=document.createElement("div"),Object.assign(this.pickerEl.style,{position:"fixed",left:`${i.left}px`,top:`${i.top-4}px`,transform:"translateY(-100%)",display:"flex",gap:"2px",padding:"4px 6px",background:"#fff",border:"1px solid #e2e8f0",borderRadius:"8px",boxShadow:"0 4px 24px rgba(0,0,0,0.12)",zIndex:"10002",fontFamily:pe});for(const s of is){const n=document.createElement("button");Object.assign(n.style,{border:"none",background:"none",cursor:"pointer",fontSize:"16px",padding:"4px",borderRadius:"4px",lineHeight:"1"}),n.textContent=s,n.addEventListener("click",r=>{r.stopPropagation();const l=this.client.state.getReactions(t).find(d=>{var c;return d.emoji===s&&d.userId===((c=this.client.state.user)==null?void 0:c.id)});l?this.client.removeReaction(l.id):this.client.addReaction(t,"comment",s),this.popoverPickerOpen=null,this.removePickerEl()}),this.pickerEl.appendChild(n)}document.body.appendChild(this.pickerEl)}buildReactionPillsHtml(e){var l;const t=this.client.state.getReactions(e),i=(l=this.client.state.user)==null?void 0:l.id,s=new Map;for(const d of t){const c=s.get(d.emoji)??{count:0,ownId:null};c.count++,d.userId===i&&(c.ownId=d.id),s.set(d.emoji,c)}const n="display:inline-flex;align-items:center;gap:3px;padding:2px 8px;border-radius:12px;border:1px solid #e2e8f0;background:#fff;font-size:12px;cursor:pointer;transition:all 0.15s;line-height:1.4;",r=n+"background:#eef2ff;border-color:#6366f1;";let a='<div style="margin-left:29px;display:flex;gap:4px;flex-wrap:wrap;margin-top:4px;">';for(const[d,{count:c,ownId:h}]of s){const u=h?r:n;a+=`<button data-reaction-emoji="${d}" data-reaction-target="${e}" ${h?`data-reaction-id="${h}"`:""} style="${u}">
1364
1379
  <span>${d}</span><span style="font-size:11px;font-weight:600;color:#64748b;">${c}</span>
1365
- </button>`}return a+=`<button class="popover-reaction-add" data-comment-id="${e}" style="display:inline-flex;align-items:center;justify-content:center;width:26px;height:26px;border-radius:50%;border:1px dashed #e2e8f0;background:none;cursor:pointer;color:#94a3b8;font-size:14px;">+</button>`,a+="</div>",a}updatePopoverTyping(e){if(!this.popover)return;let t=this.popover.querySelector(".popover-typing");if(!t){t=document.createElement("div"),t.className="popover-typing",Object.assign(t.style,{padding:"0 14px 4px",fontSize:"11px",color:"#94a3b8",fontStyle:"italic",minHeight:"16px"});const s=this.popover.lastElementChild;s&&this.popover.insertBefore(t,s)}const i=this.client.state.getTypingUsers(e).filter(s=>{var n;return s!==((n=this.client.state.user)==null?void 0:n.id)}).map(s=>{const n=this.client.state.presence.find(r=>r.user.id===s);return(n==null?void 0:n.user.name)??"Someone"});i.length===0?t.textContent="":i.length===1?t.textContent=`${i[0]} is typing...`:t.textContent=`${i.join(", ")} are typing...`}formatTime(e){const t=new Date(e),s=new Date().getTime()-t.getTime(),n=Math.floor(s/6e4);if(n<1)return"now";if(n<60)return`${n}m`;const r=Math.floor(n/60);return r<24?`${r}h`:t.toLocaleDateString()}resolvePosition(e){if(e.selector&&e.elementOffsetX!=null&&e.elementOffsetY!=null)try{const t=document.querySelector(e.selector);if(t){const i=t.getBoundingClientRect();return{x:i.left+e.elementOffsetX*i.width,y:i.top+e.elementOffsetY*i.height}}}catch{}return{x:e.x*window.innerWidth,y:e.y*window.innerHeight}}renderPins(){if(!this.container)return;const e=this.threads.filter(i=>i.position&&!i.resolved),t=new Set(e.map(i=>i.id));for(const[i,s]of this.pinEls)t.has(i)||(s.remove(),this.pinEls.delete(i));e.forEach((i,s)=>{const n=i.position;let r=this.pinEls.get(i.id);r||(r=document.createElement("div"),Object.assign(r.style,{position:"fixed",width:"24px",height:"24px",borderRadius:"50%",background:"#6366f1",color:"#fff",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"11px",fontWeight:"700",fontFamily:pe,cursor:"pointer",pointerEvents:"auto",boxShadow:"0 2px 8px rgba(99,102,241,0.4)",border:"2px solid #fff",transition:"left 0.15s ease, top 0.15s ease, transform 0.15s ease",zIndex:"9997",transform:"translate(-50%, -50%)"}),r.addEventListener("mouseenter",()=>{r.style.transform="translate(-50%, -50%) scale(1.15)"}),r.addEventListener("mouseleave",()=>{r.style.transform="translate(-50%, -50%)"}),r.addEventListener("click",()=>{if(this.popover&&this.popover.dataset.threadId===i.id){this.closePopover();return}const l=this.threads.find(d=>d.id===i.id);l&&this.showThreadPopover(l,r)}),this.container.appendChild(r),this.pinEls.set(i.id,r)),r.textContent=`${s+1}`;const a=this.resolvePosition(n);r.style.left=`${a.x}px`,r.style.top=`${a.y}px`})}}var ns=Object.defineProperty,os=Object.getOwnPropertyDescriptor,z=(o,e,t,i)=>{for(var s=i>1?void 0:i?os(e,t):e,n=o.length-1,r;n>=0;n--)(r=o[n])&&(s=(i?r(e,t,s):r(s))||s);return i&&s&&ns(e,t,s),s};const rs=["👍","👎","❤️","🎉","👀","🚀"];let A=class extends S{constructor(){super(...arguments),this.highlightThreadId=null,this.threadsVersion=0,this.replyingTo=null,this.editingCommentId=null,this.editBody="",this.pickerOpenForComment=null,this.typingByThread=new Map,this.reactionsVersion=0,this.typingTimers=new Map,this.lastTypingSend=new Map,this.replyAttachmentIds=[]}get threads(){return this.threadsVersion,this.client?[...this.client.state.threads]:[]}connectedCallback(){super.connectedCallback(),this.ensureListener()}disconnectedCallback(){super.disconnectedCallback(),this.teardownListeners()}willUpdate(o){this.client&&!this.unsub&&this.ensureListener()}updated(o){var e,t;(e=this.shadowRoot)==null||e.querySelectorAll(".audio-player-host").forEach(i=>{if(i.children.length>0)return;const s=i.dataset.url;if(s){const n=i.dataset.duration?parseInt(i.dataset.duration):void 0;i.appendChild(_e.render(s,n))}}),(t=this.shadowRoot)==null||t.querySelectorAll(".video-player-host").forEach(i=>{if(i.children.length>0)return;const s=i.dataset.url;s&&i.appendChild(be.render(s,i.dataset.poster||void 0))})}teardownListeners(){var o,e,t,i;(o=this.unsub)==null||o.call(this),this.unsub=void 0,(e=this.authUnsub)==null||e.call(this),this.authUnsub=void 0,(t=this.reactionUnsub)==null||t.call(this),this.reactionUnsub=void 0,(i=this.typingUnsub)==null||i.call(this),this.typingUnsub=void 0;for(const s of this.typingTimers.values())clearTimeout(s);this.typingTimers.clear()}ensureListener(){this.client&&(this.teardownListeners(),this.threadsVersion++,this.setupListener())}setupListener(){this.client&&(this.unsub=this.client.state.on("threads",()=>{this.threadsVersion++}),this.authUnsub=this.client.state.on("auth",()=>{this.threadsVersion++}),this.reactionUnsub=this.client.state.on("reactions",()=>{this.reactionsVersion++}),this.typingUnsub=this.client.state.on("typing",({threadId:o})=>{this.refreshTyping(o)}))}refreshTyping(o){const t=this.client.state.getTypingUsers(o).filter(s=>{var n;return s!==((n=this.client.state.user)==null?void 0:n.id)}).map(s=>{const n=this.client.state.presence.find(r=>r.user.id===s);return(n==null?void 0:n.user.name)??"Someone"}),i=new Map(this.typingByThread);i.set(o,t),this.typingByThread=i,this.typingTimers.has(o)&&clearTimeout(this.typingTimers.get(o)),this.typingTimers.set(o,setTimeout(()=>{this.refreshTyping(o)},3500))}handleTypingInput(o){const e=Date.now(),t=this.lastTypingSend.get(o)??0;e-t>=2e3&&(this.client.sendTyping(o),this.lastTypingSend.set(o,e))}toggleReaction(o,e){var n;const t=this.client.state.getReactions(o),i=(n=this.client.state.user)==null?void 0:n.id,s=t.find(r=>r.emoji===e&&r.userId===i);s?this.client.removeReaction(s.id):this.client.addReaction(o,"comment",e),this.pickerOpenForComment=null}fireClose(){this.dispatchEvent(new CustomEvent("panel-close",{bubbles:!0,composed:!0}))}scrollToThread(o){this.updateComplete.then(()=>{var t;const e=(t=this.shadowRoot)==null?void 0:t.querySelector(`[data-thread-id="${o}"]`);e==null||e.scrollIntoView({behavior:"smooth",block:"center"})})}parseMentions(o){return o.split(/(@\w+)/g).map(t=>t.startsWith("@")?u`<span class="mention">${t}</span>`:t)}getInitials(o){return o.split(" ").map(e=>e[0]).join("").toUpperCase().slice(0,2)}getUserForComment(o){return this.client.state.getUser(o)}formatTime(o){const e=new Date(o),i=new Date().getTime()-e.getTime(),s=Math.floor(i/6e4);if(s<1)return"now";if(s<60)return`${s}m`;const n=Math.floor(s/60);return n<24?`${n}h`:e.toLocaleDateString()}async handleAttachImage(){this.upload||(this.upload=new te(this.client));const o=A.MAX_ATTACHMENTS-this.replyAttachmentIds.length;if(o<=0)return;const e=await this.upload.pickFiles("image/*",o);e.length>0&&(this.replyAttachmentIds.push(...e.map(t=>t.id)),this.requestUpdate())}async handleRecordAudio(o){var i;if(this.replyAttachmentIds.length>=A.MAX_ATTACHMENTS)return;this.upload||(this.upload=new te(this.client)),this.audioRecorder||(this.audioRecorder=new Ie);const e=(i=this.shadowRoot)==null?void 0:i.querySelector(`[data-thread-id="${o}"]`),t=await this.audioRecorder.startRecording(e??document.body);if(t){const s=await this.upload.uploadBlob(t,"audio.webm");s&&(this.replyAttachmentIds.push(s.id),this.requestUpdate())}}async handleRecordVideo(o){var i;if(this.replyAttachmentIds.length>=A.MAX_ATTACHMENTS)return;this.upload||(this.upload=new te(this.client)),this.videoRecorder||(this.videoRecorder=new Me);const e=(i=this.shadowRoot)==null?void 0:i.querySelector(`[data-thread-id="${o}"]`),t=await this.videoRecorder.startRecording(e??document.body);if(t){const s=await this.upload.uploadBlob(t.blob,"video.webm");s&&(this.replyAttachmentIds.push(s.id),this.requestUpdate())}}removeReplyAttachment(o){this.replyAttachmentIds=this.replyAttachmentIds.filter(e=>e!==o),this.requestUpdate()}handleReply(o,e){e.preventDefault();const i=e.target.querySelector("input"),s=i.value.trim();if(!s&&this.replyAttachmentIds.length===0)return;const n=[...(s||"").matchAll(/@(\w+)/g)].map(r=>r[1]);this.client.reply(o,s,n,this.replyAttachmentIds.length>0?[...this.replyAttachmentIds]:void 0),i.value="",this.replyAttachmentIds=[],this.replyingTo=null}isOwnComment(o){var e,t;return((t=(e=this.client)==null?void 0:e.state.user)==null?void 0:t.id)===o.userId}startEdit(o){this.editingCommentId=o.id,this.editBody=o.body}cancelEdit(){this.editingCommentId=null,this.editBody=""}saveEdit(o){const e=this.editBody.trim();if(!e)return;const t=[...e.matchAll(/@(\w+)/g)].map(i=>i[1]);this.client.editComment(o,e,t),this.editingCommentId=null,this.editBody=""}deleteComment(o){this.client.deleteComment(o)}renderEditForm(o){return u`
1380
+ </button>`}return a+=`<button class="popover-reaction-add" data-comment-id="${e}" style="display:inline-flex;align-items:center;justify-content:center;width:26px;height:26px;border-radius:50%;border:1px dashed #e2e8f0;background:none;cursor:pointer;color:#94a3b8;font-size:14px;">+</button>`,a+="</div>",a}updatePopoverTyping(e){if(!this.popover)return;let t=this.popover.querySelector(".popover-typing");if(!t){t=document.createElement("div"),t.className="popover-typing",Object.assign(t.style,{padding:"0 14px 4px",fontSize:"11px",color:"#94a3b8",fontStyle:"italic",minHeight:"16px"});const s=this.popover.lastElementChild;s&&this.popover.insertBefore(t,s)}const i=this.client.state.getTypingUsers(e).filter(s=>{var n;return s!==((n=this.client.state.user)==null?void 0:n.id)}).map(s=>{const n=this.client.state.presence.find(r=>r.user.id===s);return(n==null?void 0:n.user.name)??"Someone"});i.length===0?t.textContent="":i.length===1?t.textContent=`${i[0]} is typing...`:t.textContent=`${i.join(", ")} are typing...`}formatTime(e){const t=new Date(e),s=new Date().getTime()-t.getTime(),n=Math.floor(s/6e4);if(n<1)return"now";if(n<60)return`${n}m`;const r=Math.floor(n/60);return r<24?`${r}h`:t.toLocaleDateString()}resolvePosition(e){if(e.selector&&e.elementOffsetX!=null&&e.elementOffsetY!=null)try{const t=document.querySelector(e.selector);if(t){const i=t.getBoundingClientRect();return{x:i.left+e.elementOffsetX*i.width,y:i.top+e.elementOffsetY*i.height}}}catch{}return{x:e.x*window.innerWidth,y:e.y*window.innerHeight}}renderPins(){if(!this.container)return;const e=this.threads.filter(i=>i.position&&!i.resolved),t=new Set(e.map(i=>i.id));for(const[i,s]of this.pinEls)t.has(i)||(s.remove(),this.pinEls.delete(i));e.forEach((i,s)=>{const n=i.position;let r=this.pinEls.get(i.id);r||(r=document.createElement("div"),Object.assign(r.style,{position:"fixed",width:"24px",height:"24px",borderRadius:"50%",background:"#6366f1",color:"#fff",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"11px",fontWeight:"700",fontFamily:pe,cursor:"pointer",pointerEvents:"auto",boxShadow:"0 2px 8px rgba(99,102,241,0.4)",border:"2px solid #fff",transition:"left 0.15s ease, top 0.15s ease, transform 0.15s ease",zIndex:"9997",transform:"translate(-50%, -50%)"}),r.addEventListener("mouseenter",()=>{r.style.transform="translate(-50%, -50%) scale(1.15)"}),r.addEventListener("mouseleave",()=>{r.style.transform="translate(-50%, -50%)"}),r.addEventListener("click",()=>{if(this.popover&&this.popover.dataset.threadId===i.id){this.closePopover();return}const l=this.threads.find(d=>d.id===i.id);l&&this.showThreadPopover(l,r)}),this.container.appendChild(r),this.pinEls.set(i.id,r)),r.textContent=`${s+1}`;const a=this.resolvePosition(n);r.style.left=`${a.x}px`,r.style.top=`${a.y}px`})}}var rs=Object.defineProperty,as=Object.getOwnPropertyDescriptor,U=(o,e,t,i)=>{for(var s=i>1?void 0:i?as(e,t):e,n=o.length-1,r;n>=0;n--)(r=o[n])&&(s=(i?r(e,t,s):r(s))||s);return i&&s&&rs(e,t,s),s};const ls=["👍","👎","❤️","🎉","👀","🚀"];let _=class extends A{constructor(){super(...arguments),this.highlightThreadId=null,this.threadsVersion=0,this.replyingTo=null,this.editingCommentId=null,this.editBody="",this.pickerOpenForComment=null,this.typingByThread=new Map,this.reactionsVersion=0,this.typingTimers=new Map,this.lastTypingSend=new Map,this.replyAttachmentIds=[]}get threads(){return this.threadsVersion,this.client?[...this.client.state.threads]:[]}connectedCallback(){super.connectedCallback(),this.ensureListener()}disconnectedCallback(){super.disconnectedCallback(),this.teardownListeners()}willUpdate(o){this.client&&!this.unsub&&this.ensureListener()}updated(o){var t,i,s;const e=(t=this.shadowRoot)==null?void 0:t.querySelector(".reply-form input");e&&this.client&&(this.mentionPicker||(this.mentionPicker=new Oe(this.client)),e.dataset.mentionAttached||(this.mentionPicker.attach(e),e.dataset.mentionAttached="1")),(i=this.shadowRoot)==null||i.querySelectorAll(".audio-player-host").forEach(n=>{if(n.children.length>0)return;const r=n.dataset.url;if(r){const a=n.dataset.duration?parseInt(n.dataset.duration):void 0;n.appendChild(_e.render(r,a))}}),(s=this.shadowRoot)==null||s.querySelectorAll(".video-player-host").forEach(n=>{if(n.children.length>0)return;const r=n.dataset.url;r&&n.appendChild(be.render(r,n.dataset.poster||void 0))})}teardownListeners(){var o,e,t,i;(o=this.unsub)==null||o.call(this),this.unsub=void 0,(e=this.authUnsub)==null||e.call(this),this.authUnsub=void 0,(t=this.reactionUnsub)==null||t.call(this),this.reactionUnsub=void 0,(i=this.typingUnsub)==null||i.call(this),this.typingUnsub=void 0;for(const s of this.typingTimers.values())clearTimeout(s);this.typingTimers.clear()}ensureListener(){this.client&&(this.teardownListeners(),this.threadsVersion++,this.setupListener())}setupListener(){this.client&&(this.unsub=this.client.state.on("threads",()=>{this.threadsVersion++}),this.authUnsub=this.client.state.on("auth",()=>{this.threadsVersion++}),this.reactionUnsub=this.client.state.on("reactions",()=>{this.reactionsVersion++}),this.typingUnsub=this.client.state.on("typing",({threadId:o})=>{this.refreshTyping(o)}))}refreshTyping(o){const t=this.client.state.getTypingUsers(o).filter(s=>{var n;return s!==((n=this.client.state.user)==null?void 0:n.id)}).map(s=>{const n=this.client.state.presence.find(r=>r.user.id===s);return(n==null?void 0:n.user.name)??"Someone"}),i=new Map(this.typingByThread);i.set(o,t),this.typingByThread=i,this.typingTimers.has(o)&&clearTimeout(this.typingTimers.get(o)),this.typingTimers.set(o,setTimeout(()=>{this.refreshTyping(o)},3500))}handleTypingInput(o){const e=Date.now(),t=this.lastTypingSend.get(o)??0;e-t>=2e3&&(this.client.sendTyping(o),this.lastTypingSend.set(o,e))}toggleReaction(o,e){var n;const t=this.client.state.getReactions(o),i=(n=this.client.state.user)==null?void 0:n.id,s=t.find(r=>r.emoji===e&&r.userId===i);s?this.client.removeReaction(s.id):this.client.addReaction(o,"comment",e),this.pickerOpenForComment=null}fireClose(){this.dispatchEvent(new CustomEvent("panel-close",{bubbles:!0,composed:!0}))}scrollToThread(o){this.updateComplete.then(()=>{var t;const e=(t=this.shadowRoot)==null?void 0:t.querySelector(`[data-thread-id="${o}"]`);e==null||e.scrollIntoView({behavior:"smooth",block:"center"})})}parseMentions(o){return o.split(/(@\w+)/g).map(t=>t.startsWith("@")?p`<span class="mention">${t}</span>`:t)}getInitials(o){return o.split(" ").map(e=>e[0]).join("").toUpperCase().slice(0,2)}getUserForComment(o){return this.client.state.getUser(o)}formatTime(o){const e=new Date(o),i=new Date().getTime()-e.getTime(),s=Math.floor(i/6e4);if(s<1)return"now";if(s<60)return`${s}m`;const n=Math.floor(s/60);return n<24?`${n}h`:e.toLocaleDateString()}async handleAttachImage(){this.upload||(this.upload=new te(this.client));const o=_.MAX_ATTACHMENTS-this.replyAttachmentIds.length;if(o<=0)return;const e=await this.upload.pickFiles("image/*",o);e.length>0&&(this.replyAttachmentIds.push(...e.map(t=>t.id)),this.requestUpdate())}async handleRecordAudio(o){var i;if(this.replyAttachmentIds.length>=_.MAX_ATTACHMENTS)return;this.upload||(this.upload=new te(this.client)),this.audioRecorder||(this.audioRecorder=new Ie);const e=(i=this.shadowRoot)==null?void 0:i.querySelector(`[data-thread-id="${o}"]`),t=await this.audioRecorder.startRecording(e??document.body);if(t){const s=await this.upload.uploadBlob(t,"audio.webm");s&&(this.replyAttachmentIds.push(s.id),this.requestUpdate())}}async handleRecordVideo(o){var i;if(this.replyAttachmentIds.length>=_.MAX_ATTACHMENTS)return;this.upload||(this.upload=new te(this.client)),this.videoRecorder||(this.videoRecorder=new Me);const e=(i=this.shadowRoot)==null?void 0:i.querySelector(`[data-thread-id="${o}"]`),t=await this.videoRecorder.startRecording(e??document.body);if(t){const s=await this.upload.uploadBlob(t.blob,"video.webm");s&&(this.replyAttachmentIds.push(s.id),this.requestUpdate())}}removeReplyAttachment(o){this.replyAttachmentIds=this.replyAttachmentIds.filter(e=>e!==o),this.requestUpdate()}handleReply(o,e){e.preventDefault();const i=e.target.querySelector("input"),s=i.value.trim();if(!s&&this.replyAttachmentIds.length===0)return;const n=[...(s||"").matchAll(/@(\w+)/g)].map(r=>r[1]);this.client.reply(o,s,n,this.replyAttachmentIds.length>0?[...this.replyAttachmentIds]:void 0),i.value="",this.replyAttachmentIds=[],this.replyingTo=null}isOwnComment(o){var e,t;return((t=(e=this.client)==null?void 0:e.state.user)==null?void 0:t.id)===o.userId}startEdit(o){this.editingCommentId=o.id,this.editBody=o.body}cancelEdit(){this.editingCommentId=null,this.editBody=""}saveEdit(o){const e=this.editBody.trim();if(!e)return;const t=[...e.matchAll(/@(\w+)/g)].map(i=>i[1]);this.client.editComment(o,e,t),this.editingCommentId=null,this.editBody=""}deleteComment(o){this.client.deleteComment(o)}renderEditForm(o){return p`
1366
1381
  <div class="edit-form">
1367
1382
  <textarea
1368
1383
  .value=${this.editBody}
@@ -1373,9 +1388,9 @@
1373
1388
  <button class="pw-btn" @click=${this.cancelEdit}>Cancel</button>
1374
1389
  </div>
1375
1390
  </div>
1376
- `}renderReactions(o){var s;this.reactionsVersion;const e=this.client.state.getReactions(o.id),t=(s=this.client.state.user)==null?void 0:s.id,i=new Map;for(const n of e)i.has(n.emoji)||i.set(n.emoji,[]),i.get(n.emoji).push(n);return u`
1391
+ `}renderReactions(o){var s;this.reactionsVersion;const e=this.client.state.getReactions(o.id),t=(s=this.client.state.user)==null?void 0:s.id,i=new Map;for(const n of e)i.has(n.emoji)||i.set(n.emoji,[]),i.get(n.emoji).push(n);return p`
1377
1392
  <div class="comment-reactions">
1378
- ${[...i.entries()].map(([n,r])=>{const a=r.some(l=>l.userId===t);return u`
1393
+ ${[...i.entries()].map(([n,r])=>{const a=r.some(l=>l.userId===t);return p`
1379
1394
  <button
1380
1395
  class="reaction-pill ${a?"own":""}"
1381
1396
  @click=${()=>this.toggleReaction(o.id,n)}
@@ -1390,16 +1405,16 @@
1390
1405
  title="Add reaction"
1391
1406
  >
1392
1407
  +
1393
- ${this.pickerOpenForComment===o.id?u`
1408
+ ${this.pickerOpenForComment===o.id?p`
1394
1409
  <div class="emoji-picker">
1395
- ${rs.map(n=>u`
1410
+ ${ls.map(n=>p`
1396
1411
  <button @click=${r=>{r.stopPropagation(),this.toggleReaction(o.id,n)}}>${n}</button>
1397
1412
  `)}
1398
1413
  </div>
1399
- `:v}
1414
+ `:g}
1400
1415
  </button>
1401
1416
  </div>
1402
- `}renderTypingIndicator(o){const e=this.typingByThread.get(o)??[];if(e.length===0)return v;const t=e.length===1?`${e[0]} is typing...`:`${e.join(", ")} are typing...`;return u`<div class="typing-indicator">${t}</div>`}sortedThreads(){return[...this.threads].sort((o,e)=>{if(o.resolved!==e.resolved)return o.resolved?1:-1;const t=o.comments.length?new Date(o.comments[o.comments.length-1].createdAt).getTime():0;return(e.comments.length?new Date(e.comments[e.comments.length-1].createdAt).getTime():0)-t})}render(){const o=this.sortedThreads();return u`
1417
+ `}renderTypingIndicator(o){const e=this.typingByThread.get(o)??[];if(e.length===0)return g;const t=e.length===1?`${e[0]} is typing...`:`${e.join(", ")} are typing...`;return p`<div class="typing-indicator">${t}</div>`}sortedThreads(){return[...this.threads].sort((o,e)=>{if(o.resolved!==e.resolved)return o.resolved?1:-1;const t=o.comments.length?new Date(o.comments[o.comments.length-1].createdAt).getTime():0;return(e.comments.length?new Date(e.comments[e.comments.length-1].createdAt).getTime():0)-t})}render(){const o=this.sortedThreads();return p`
1403
1418
  <div class="panel">
1404
1419
  <div class="panel-header">
1405
1420
  <span class="panel-title">
@@ -1412,7 +1427,7 @@
1412
1427
  </div>
1413
1428
 
1414
1429
  <div class="panel-body pw-scrollable">
1415
- ${o.length===0?u`<div class="empty">
1430
+ ${o.length===0?p`<div class="empty">
1416
1431
  <div class="empty-icon">&#128172;</div>
1417
1432
  No comments yet
1418
1433
  </div>`:o.map(e=>this.renderThread(e))}
@@ -1422,8 +1437,8 @@
1422
1437
  Use the pin button to comment anywhere on the page
1423
1438
  </div>
1424
1439
  </div>
1425
- `}renderAttachments(o){if(!o||o.length===0)return v;const e=o.filter(t=>t.type==="image").map(t=>t.url);return u`
1426
- ${o.map(t=>{if(t.type==="image"){const i=t.thumbnailUrl||t.url,s=e.indexOf(t.url);return u`
1440
+ `}renderAttachments(o){if(!o||o.length===0)return g;const e=o.filter(t=>t.type==="image").map(t=>t.url);return p`
1441
+ ${o.map(t=>{if(t.type==="image"){const i=t.thumbnailUrl||t.url,s=e.indexOf(t.url);return p`
1427
1442
  <div class="comment-attachment-media">
1428
1443
  <img
1429
1444
  class="comment-attachment-img"
@@ -1432,26 +1447,26 @@
1432
1447
  @click=${()=>xe.open(t.url,e,s)}
1433
1448
  />
1434
1449
  </div>
1435
- `}return t.type==="audio"?u`
1450
+ `}return t.type==="audio"?p`
1436
1451
  <div class="comment-attachment-media" id="audio-${t.id}">
1437
1452
  ${this.renderAudioPlayer(t)}
1438
1453
  </div>
1439
- `:t.type==="video"?u`
1454
+ `:t.type==="video"?p`
1440
1455
  <div class="comment-attachment-media" id="video-${t.id}">
1441
1456
  ${this.renderVideoPlayer(t)}
1442
1457
  </div>
1443
- `:v})}
1444
- `}renderAudioPlayer(o){const e=document.createElement("div"),t=_e.render(o.url,o.durationMs);return e.appendChild(t),u`<div class="audio-player-host" data-url=${o.url} data-duration=${o.durationMs??""}></div>`}renderVideoPlayer(o){return u`<div class="video-player-host" data-url=${o.url} data-poster=${o.thumbnailUrl??""}></div>`}renderThread(o){const e=this.highlightThreadId===o.id;return u`
1458
+ `:g})}
1459
+ `}renderAudioPlayer(o){const e=document.createElement("div"),t=_e.render(o.url,o.durationMs);return e.appendChild(t),p`<div class="audio-player-host" data-url=${o.url} data-duration=${o.durationMs??""}></div>`}renderVideoPlayer(o){return p`<div class="video-player-host" data-url=${o.url} data-poster=${o.thumbnailUrl??""}></div>`}renderThread(o){const e=this.highlightThreadId===o.id;return p`
1445
1460
  <div
1446
1461
  class="thread ${o.resolved?"resolved":""} ${e?"highlighted":""}"
1447
1462
  data-thread-id=${o.id}
1448
1463
  >
1449
- ${o.position?u`<div class="pin-badge">
1450
- ${C(Ct,12)}
1464
+ ${o.position?p`<div class="pin-badge">
1465
+ ${C(Pt,12)}
1451
1466
  Pinned
1452
- </div>`:v}
1453
- ${o.comments.map((t,i)=>{const s=this.getUserForComment(t.userId),n=this.isOwnComment(t),r=this.editingCommentId===t.id;return u`
1454
- ${i>0?u`<div class="comment-divider"></div>`:v}
1467
+ </div>`:g}
1468
+ ${o.comments.map((t,i)=>{const s=this.getUserForComment(t.userId),n=this.isOwnComment(t),r=this.editingCommentId===t.id;return p`
1469
+ ${i>0?p`<div class="comment-divider"></div>`:g}
1455
1470
  <div class="comment">
1456
1471
  <div class="comment-header">
1457
1472
  <div
@@ -1462,16 +1477,16 @@
1462
1477
  </div>
1463
1478
  <span class="comment-author">${(s==null?void 0:s.name)??"Unknown"}</span>
1464
1479
  <span class="comment-time">${this.formatTime(t.createdAt)}</span>
1465
- ${t.editedAt?u`<span class="edited-badge">(edited)</span>`:v}
1480
+ ${t.editedAt?p`<span class="edited-badge">(edited)</span>`:g}
1466
1481
  </div>
1467
- ${r?this.renderEditForm(t):u`
1468
- ${t.body&&t.body!=="(attachment)"?u`<div class="comment-body">${this.parseMentions(t.body)}</div>`:v}
1482
+ ${r?this.renderEditForm(t):p`
1483
+ ${t.body&&t.body!=="(attachment)"?p`<div class="comment-body">${this.parseMentions(t.body)}</div>`:g}
1469
1484
  ${this.renderAttachments(t.attachments??[])}
1470
1485
  `}
1471
- ${n&&!r?u`<div class="comment-actions">
1472
- <button @click=${()=>this.startEdit(t)} title="Edit">${C(Mi,14)}</button>
1473
- <button class="danger" @click=${()=>this.deleteComment(t.id)} title="Delete">${C(Ri,14)}</button>
1474
- </div>`:v}
1486
+ ${n&&!r?p`<div class="comment-actions">
1487
+ <button @click=${()=>this.startEdit(t)} title="Edit">${C(Oi,14)}</button>
1488
+ <button class="danger" @click=${()=>this.deleteComment(t.id)} title="Delete">${C(Li,14)}</button>
1489
+ </div>`:g}
1475
1490
  ${this.renderReactions(t)}
1476
1491
  </div>
1477
1492
  `})}
@@ -1491,7 +1506,7 @@
1491
1506
 
1492
1507
  ${this.renderTypingIndicator(o.id)}
1493
1508
 
1494
- ${this.replyingTo===o.id?u`
1509
+ ${this.replyingTo===o.id?p`
1495
1510
  <form
1496
1511
  class="reply-form"
1497
1512
  @submit=${t=>this.handleReply(o.id,t)}
@@ -1510,21 +1525,21 @@
1510
1525
  class="reply-media-btn"
1511
1526
  title="Attach image"
1512
1527
  @click=${()=>this.handleAttachImage()}
1513
- >${C(_i,16)}</button>
1528
+ >${C(Ii,16)}</button>
1514
1529
  <button
1515
1530
  type="button"
1516
1531
  class="reply-media-btn"
1517
1532
  title="Record audio"
1518
1533
  @click=${()=>this.handleRecordAudio(o.id)}
1519
- >${C(Ai,16)}</button>
1534
+ >${C(_i,16)}</button>
1520
1535
  <button
1521
1536
  type="button"
1522
1537
  class="reply-media-btn"
1523
1538
  title="Record video"
1524
1539
  @click=${()=>this.handleRecordVideo(o.id)}
1525
- >${C(Li,16)}</button>
1540
+ >${C(ji,16)}</button>
1526
1541
  <div class="reply-preview">
1527
- ${this.replyAttachmentIds.map((t,i)=>u`<span class="reply-preview-badge">
1542
+ ${this.replyAttachmentIds.map((t,i)=>p`<span class="reply-preview-badge">
1528
1543
  Attached #${i+1}
1529
1544
  <button
1530
1545
  type="button"
@@ -1535,9 +1550,9 @@
1535
1550
  </div>
1536
1551
  </div>
1537
1552
  </form>
1538
- `:v}
1553
+ `:g}
1539
1554
  </div>
1540
- `}};A.styles=[J,he,$e,M`
1555
+ `}};_.styles=[J,he,$e,M`
1541
1556
  :host {
1542
1557
  display: block;
1543
1558
  }
@@ -2075,17 +2090,17 @@
2075
2090
  background: var(--pw-surface-hover);
2076
2091
  color: var(--pw-text);
2077
2092
  }
2078
- `];A.MAX_ATTACHMENTS=5;z([x({attribute:!1})],A.prototype,"client",2);z([x()],A.prototype,"highlightThreadId",2);z([$()],A.prototype,"threadsVersion",2);z([$()],A.prototype,"replyingTo",2);z([$()],A.prototype,"editingCommentId",2);z([$()],A.prototype,"editBody",2);z([$()],A.prototype,"pickerOpenForComment",2);z([$()],A.prototype,"typingByThread",2);z([$()],A.prototype,"reactionsVersion",2);A=z([L("pulse-widget-comments-panel")],A);var as=Object.defineProperty,ls=Object.getOwnPropertyDescriptor,He=(o,e,t,i)=>{for(var s=i>1?void 0:i?ls(e,t):e,n=o.length-1,r;n>=0;n--)(r=o[n])&&(s=(i?r(e,t,s):r(s))||s);return i&&s&&as(e,t,s),s};const cs={"comment:created":"left a comment","comment:mention":"mentioned you","comment:reply":"replied to your comment","thread:resolved":"resolved a thread","reaction:added":"reacted to your comment"},ds={"comment:created":"💬","comment:mention":"📣","comment:reply":"↩️","thread:resolved":"✅","reaction:added":"🎉"};let oe=class extends S{constructor(){super(...arguments),this.notifications=[]}connectedCallback(){super.connectedCallback(),this.setupListener()}disconnectedCallback(){var o;super.disconnectedCallback(),(o=this.unsub)==null||o.call(this)}updated(o){var e;o.has("client")&&this.client&&((e=this.unsub)==null||e.call(this),this.setupListener())}setupListener(){this.client&&(this.notifications=this.client.state.notifications,this.unsub=this.client.state.on("notifications",o=>{this.notifications=[...o]}))}fireClose(){this.dispatchEvent(new CustomEvent("panel-close",{bubbles:!0,composed:!0}))}handleClick(o){o.read||this.client.markRead(o.id)}getActorName(o){var e;return((e=this.client.state.getUser(o))==null?void 0:e.name)??"Someone"}formatTime(o){const e=new Date(o),i=new Date().getTime()-e.getTime(),s=Math.floor(i/6e4);if(s<1)return"now";if(s<60)return`${s}m`;const n=Math.floor(s/60);return n<24?`${n}h`:e.toLocaleDateString()}render(){const o=this.notifications.filter(e=>!e.read).length;return u`
2093
+ `];_.MAX_ATTACHMENTS=5;U([w({attribute:!1})],_.prototype,"client",2);U([w()],_.prototype,"highlightThreadId",2);U([k()],_.prototype,"threadsVersion",2);U([k()],_.prototype,"replyingTo",2);U([k()],_.prototype,"editingCommentId",2);U([k()],_.prototype,"editBody",2);U([k()],_.prototype,"pickerOpenForComment",2);U([k()],_.prototype,"typingByThread",2);U([k()],_.prototype,"reactionsVersion",2);_=U([L("pulse-widget-comments-panel")],_);var cs=Object.defineProperty,ds=Object.getOwnPropertyDescriptor,Be=(o,e,t,i)=>{for(var s=i>1?void 0:i?ds(e,t):e,n=o.length-1,r;n>=0;n--)(r=o[n])&&(s=(i?r(e,t,s):r(s))||s);return i&&s&&cs(e,t,s),s};const hs={"comment:created":"left a comment","comment:mention":"mentioned you","comment:reply":"replied to your comment","thread:resolved":"resolved a thread","reaction:added":"reacted to your comment"},ps={"comment:created":"💬","comment:mention":"📣","comment:reply":"↩️","thread:resolved":"✅","reaction:added":"🎉"};let oe=class extends A{constructor(){super(...arguments),this.notifications=[]}connectedCallback(){super.connectedCallback(),this.setupListener()}disconnectedCallback(){var o;super.disconnectedCallback(),(o=this.unsub)==null||o.call(this)}updated(o){var e;o.has("client")&&this.client&&((e=this.unsub)==null||e.call(this),this.setupListener())}setupListener(){this.client&&(this.notifications=this.client.state.notifications,this.unsub=this.client.state.on("notifications",o=>{this.notifications=[...o]}))}fireClose(){this.dispatchEvent(new CustomEvent("panel-close",{bubbles:!0,composed:!0}))}handleClick(o){o.read||this.client.markRead(o.id)}getActorName(o){var e;return((e=this.client.state.getUser(o))==null?void 0:e.name)??"Someone"}formatTime(o){const e=new Date(o),i=new Date().getTime()-e.getTime(),s=Math.floor(i/6e4);if(s<1)return"now";if(s<60)return`${s}m`;const n=Math.floor(s/60);return n<24?`${n}h`:e.toLocaleDateString()}render(){const o=this.notifications.filter(e=>!e.read).length;return p`
2079
2094
  <div class="panel">
2080
2095
  <div class="panel-header">
2081
2096
  <span class="panel-title">
2082
2097
  Notifications
2083
- ${o>0?u`<span class="unread-badge">${o}</span>`:v}
2098
+ ${o>0?p`<span class="unread-badge">${o}</span>`:g}
2084
2099
  </span>
2085
2100
  <div style="display:flex;align-items:center;gap:4px;">
2086
- ${o>0?u`<button class="mark-all" @click=${()=>this.client.markAllRead()}>
2101
+ ${o>0?p`<button class="mark-all" @click=${()=>this.client.markAllRead()}>
2087
2102
  Mark all read
2088
- </button>`:v}
2103
+ </button>`:g}
2089
2104
  <button class="close-btn" @click=${this.fireClose} title="Close">
2090
2105
  ${C(de,16)}
2091
2106
  </button>
@@ -2093,19 +2108,19 @@
2093
2108
  </div>
2094
2109
 
2095
2110
  <div class="panel-body pw-scrollable">
2096
- ${this.notifications.length===0?u`<div class="empty">
2111
+ ${this.notifications.length===0?p`<div class="empty">
2097
2112
  <div class="empty-icon">&#128276;</div>
2098
2113
  No notifications
2099
- </div>`:this.notifications.map(e=>u`
2114
+ </div>`:this.notifications.map(e=>p`
2100
2115
  <div
2101
2116
  class="item ${e.read?"":"unread"}"
2102
2117
  @click=${()=>this.handleClick(e)}
2103
2118
  >
2104
- <span class="icon">${ds[e.type]??"🔔"}</span>
2119
+ <span class="icon">${ps[e.type]??"🔔"}</span>
2105
2120
  <div class="content">
2106
2121
  <div class="text">
2107
2122
  <span class="actor">${this.getActorName(e.actorId)}</span>
2108
- ${cs[e.type]??e.type}
2123
+ ${hs[e.type]??e.type}
2109
2124
  </div>
2110
2125
  <div class="time">${this.formatTime(e.createdAt)}</div>
2111
2126
  </div>
@@ -2305,7 +2320,7 @@
2305
2320
  min-height: 44px;
2306
2321
  }
2307
2322
  }
2308
- `];He([x({attribute:!1})],oe.prototype,"client",2);He([$()],oe.prototype,"notifications",2);oe=He([L("pulse-widget-notifications-panel")],oe);const hs=3e3;class ps{constructor(e){this.container=null,this.cursors=new Map,this.cursorEls=new Map,this.cursorLastSeen=new Map,this.unsubs=[],this.enabled=!1,this.sending=!1,this.staleTimer=null,this.handleLocalCursor=t=>{t.pointerType!=="touch"&&this.client.moveCursor({x:t.clientX,y:t.clientY,pageX:t.pageX,pageY:t.pageY})},this.client=e}enable(){this.enabled||(this.enabled=!0,this.container=document.createElement("div"),this.container.id="pulse-widget-cursors",Object.assign(this.container.style,{position:"fixed",top:"0",left:"0",width:"100%",height:"100%",pointerEvents:"none",zIndex:"9998",overflow:"hidden"}),document.body.appendChild(this.container),this.unsubs.push(this.client.state.on("cursor",({userId:e,position:t})=>{const i=this.cursors.get(e);if(i)i.position=t;else{const s=this.client.state.presence.find(n=>n.user.id===e);s&&this.cursors.set(e,{userId:e,name:s.user.name,color:s.user.color,position:t})}this.cursorLastSeen.set(e,Date.now()),this.renderCursor(e)})),this.unsubs.push(this.client.state.on("presence",e=>{var i;const t=new Set(e.map(s=>s.user.id));for(const s of this.cursors.keys())t.has(s)||(this.cursors.delete(s),(i=this.cursorEls.get(s))==null||i.remove(),this.cursorEls.delete(s),this.cursorLastSeen.delete(s))})),this.setSending(!0),this.staleTimer=setInterval(()=>{const e=Date.now();for(const[t,i]of this.cursorLastSeen)if(e-i>hs){this.cursors.delete(t);const s=this.cursorEls.get(t);s&&s.remove(),this.cursorEls.delete(t),this.cursorLastSeen.delete(t)}},1e3))}disable(){var e;this.enabled&&(this.enabled=!1,this.setSending(!1),this.unsubs.forEach(t=>t()),this.unsubs=[],this.staleTimer&&(clearInterval(this.staleTimer),this.staleTimer=null),(e=this.container)==null||e.remove(),this.container=null,this.cursors.clear(),this.cursorEls.clear(),this.cursorLastSeen.clear())}get isEnabled(){return this.enabled}get isSending(){return this.sending}setSending(e){e!==this.sending&&(this.sending=e,e?document.addEventListener("pointermove",this.handleLocalCursor):document.removeEventListener("pointermove",this.handleLocalCursor))}setReceiving(e){this.container&&(this.container.style.display=e?"":"none")}showClickRipple(e,t){if(!this.container)return;const i=this.client.state.presence.find(r=>r.user.id===e),s=(i==null?void 0:i.user.color)??"#6366f1",n=document.createElement("div");Object.assign(n.style,{position:"absolute",left:`${t.x}px`,top:`${t.y}px`,width:"0px",height:"0px",borderRadius:"50%",border:`3px solid ${s}`,transform:"translate(-50%, -50%)",pointerEvents:"none",opacity:"1",transition:"width 0.6s ease-out, height 0.6s ease-out, opacity 0.6s ease-out"}),this.container.appendChild(n),requestAnimationFrame(()=>{n.style.width="60px",n.style.height="60px",n.style.opacity="0"}),setTimeout(()=>n.remove(),600)}showEmojiDrop(e,t,i){if(!this.container)return;const s=document.createElement("div");Object.assign(s.style,{position:"absolute",left:`${i.x}px`,top:`${i.y}px`,fontSize:"32px",pointerEvents:"none",transition:"transform 2s ease-out, opacity 2s ease-out",transform:"translate(-50%, 0)",zIndex:"10",lineHeight:"1"}),s.textContent=t,this.container.appendChild(s),requestAnimationFrame(()=>{s.style.transform="translate(-50%, -80px)",s.style.opacity="0"}),setTimeout(()=>s.remove(),2e3)}destroy(){this.disable()}renderCursor(e){if(!this.container)return;const t=this.cursors.get(e);if(!t)return;let i=this.cursorEls.get(e);if(!i){i=document.createElement("div"),Object.assign(i.style,{position:"absolute",transition:"transform 60ms cubic-bezier(0.22,1,0.36,1)",willChange:"transform",pointerEvents:"none"});const s=t.color||"#e74c3c";i.innerHTML=`
2323
+ `];Be([w({attribute:!1})],oe.prototype,"client",2);Be([k()],oe.prototype,"notifications",2);oe=Be([L("pulse-widget-notifications-panel")],oe);const us=3e3;class fs{constructor(e){this.container=null,this.cursors=new Map,this.cursorEls=new Map,this.cursorLastSeen=new Map,this.unsubs=[],this.enabled=!1,this.sending=!1,this.staleTimer=null,this.handleLocalCursor=t=>{t.pointerType!=="touch"&&this.client.moveCursor({x:t.clientX,y:t.clientY,pageX:t.pageX,pageY:t.pageY})},this.client=e}enable(){this.enabled||(this.enabled=!0,this.container=document.createElement("div"),this.container.id="pulse-widget-cursors",Object.assign(this.container.style,{position:"fixed",top:"0",left:"0",width:"100%",height:"100%",pointerEvents:"none",zIndex:"9998",overflow:"hidden"}),document.body.appendChild(this.container),this.unsubs.push(this.client.state.on("cursor",({userId:e,position:t})=>{const i=this.cursors.get(e);if(i)i.position=t;else{const s=this.client.state.presence.find(n=>n.user.id===e);s&&this.cursors.set(e,{userId:e,name:s.user.name,color:s.user.color,position:t})}this.cursorLastSeen.set(e,Date.now()),this.renderCursor(e)})),this.unsubs.push(this.client.state.on("presence",e=>{var i;const t=new Set(e.map(s=>s.user.id));for(const s of this.cursors.keys())t.has(s)||(this.cursors.delete(s),(i=this.cursorEls.get(s))==null||i.remove(),this.cursorEls.delete(s),this.cursorLastSeen.delete(s))})),this.setSending(!0),this.staleTimer=setInterval(()=>{const e=Date.now();for(const[t,i]of this.cursorLastSeen)if(e-i>us){this.cursors.delete(t);const s=this.cursorEls.get(t);s&&s.remove(),this.cursorEls.delete(t),this.cursorLastSeen.delete(t)}},1e3))}disable(){var e;this.enabled&&(this.enabled=!1,this.setSending(!1),this.unsubs.forEach(t=>t()),this.unsubs=[],this.staleTimer&&(clearInterval(this.staleTimer),this.staleTimer=null),(e=this.container)==null||e.remove(),this.container=null,this.cursors.clear(),this.cursorEls.clear(),this.cursorLastSeen.clear())}get isEnabled(){return this.enabled}get isSending(){return this.sending}setSending(e){e!==this.sending&&(this.sending=e,e?document.addEventListener("pointermove",this.handleLocalCursor):document.removeEventListener("pointermove",this.handleLocalCursor))}setReceiving(e){this.container&&(this.container.style.display=e?"":"none")}showClickRipple(e,t){if(!this.container)return;const i=this.client.state.presence.find(r=>r.user.id===e),s=(i==null?void 0:i.user.color)??"#6366f1",n=document.createElement("div");Object.assign(n.style,{position:"absolute",left:`${t.x}px`,top:`${t.y}px`,width:"0px",height:"0px",borderRadius:"50%",border:`3px solid ${s}`,transform:"translate(-50%, -50%)",pointerEvents:"none",opacity:"1",transition:"width 0.6s ease-out, height 0.6s ease-out, opacity 0.6s ease-out"}),this.container.appendChild(n),requestAnimationFrame(()=>{n.style.width="60px",n.style.height="60px",n.style.opacity="0"}),setTimeout(()=>n.remove(),600)}showEmojiDrop(e,t,i){if(!this.container)return;const s=document.createElement("div");Object.assign(s.style,{position:"absolute",left:`${i.x}px`,top:`${i.y}px`,fontSize:"32px",pointerEvents:"none",transition:"transform 2s ease-out, opacity 2s ease-out",transform:"translate(-50%, 0)",zIndex:"10",lineHeight:"1"}),s.textContent=t,this.container.appendChild(s),requestAnimationFrame(()=>{s.style.transform="translate(-50%, -80px)",s.style.opacity="0"}),setTimeout(()=>s.remove(),2e3)}destroy(){this.disable()}renderCursor(e){if(!this.container)return;const t=this.cursors.get(e);if(!t)return;let i=this.cursorEls.get(e);if(!i){i=document.createElement("div"),Object.assign(i.style,{position:"absolute",transition:"transform 60ms cubic-bezier(0.22,1,0.36,1)",willChange:"transform",pointerEvents:"none"});const s=t.color||"#e74c3c";i.innerHTML=`
2309
2324
  <svg width="24" height="24" viewBox="0 0 16 16" fill="${s}" style="filter:drop-shadow(0 2px 4px rgba(0,0,0,0.4))">
2310
2325
  <path d="M0 0l6.5 16L8 9l7-2.5z" stroke="#fff" stroke-width="1"/>
2311
2326
  </svg>
@@ -2319,7 +2334,7 @@
2319
2334
  box-shadow:0 2px 10px rgba(0,0,0,0.25);
2320
2335
  letter-spacing:0.01em;
2321
2336
  ">${t.name}</span>
2322
- `,this.container.appendChild(i),this.cursorEls.set(e,i)}i.style.transform=`translate(${t.position.x}px, ${t.position.y}px)`}}class us{constructor(e){this.container=null,this.unsubs=[],this.enabled=!1,this.drawMode=!1,this.currentPoints=[],this.currentPath=null,this.lastPoint=null,this.fadeTimers=new Map,this.handlePointerDown=t=>{var a,l,d;t.preventDefault(),(l=(a=t.target)==null?void 0:a.setPointerCapture)==null||l.call(a,t.pointerId),this.currentPoints=[{x:t.clientX,y:t.clientY}],this.lastPoint={x:t.clientX,y:t.clientY};const i=this.client.state.user,s=(i==null?void 0:i.color)??"#6366f1",r=2+(t.pressure>0?t.pressure:.5)*4;this.currentPath=document.createElementNS("http://www.w3.org/2000/svg","polyline"),this.currentPath.setAttribute("fill","none"),this.currentPath.setAttribute("stroke",s),this.currentPath.setAttribute("stroke-width",String(r)),this.currentPath.setAttribute("stroke-linecap","round"),this.currentPath.setAttribute("stroke-linejoin","round"),this.currentPath.setAttribute("points",`${t.clientX},${t.clientY}`),(d=this.container)==null||d.appendChild(this.currentPath),document.addEventListener("pointermove",this.handlePointerMove),document.addEventListener("pointerup",this.handlePointerUp)},this.handlePointerMove=t=>{if(!this.currentPath||!this.lastPoint)return;const i=t.clientX-this.lastPoint.x,s=t.clientY-this.lastPoint.y;if(i*i+s*s<4)return;this.currentPoints.push({x:t.clientX,y:t.clientY}),this.lastPoint={x:t.clientX,y:t.clientY};const n=this.currentPoints.map(r=>`${r.x},${r.y}`).join(" ");this.currentPath.setAttribute("points",n)},this.handlePointerUp=()=>{var t;if(document.removeEventListener("pointermove",this.handlePointerMove),document.removeEventListener("pointerup",this.handlePointerUp),this.currentPoints.length>1){const i=this.client.state.user,s=(i==null?void 0:i.color)??"#6366f1";this.client.drawStroke(this.currentPoints,s,3),this.currentPath&&this.scheduleFade(this.currentPath)}else(t=this.currentPath)==null||t.remove();this.currentPoints=[],this.currentPath=null,this.lastPoint=null},this.client=e}enable(){this.enabled||(this.enabled=!0,this.container=document.createElementNS("http://www.w3.org/2000/svg","svg"),this.container.id="pulse-widget-drawing",this.container.setAttribute("style","position:fixed;top:0;left:0;width:100%;height:100%;pointer-events:none;z-index:9989;"),document.body.appendChild(this.container),this.unsubs.push(this.client.state.on("draw-stroke",({userId:e,points:t,color:i,width:s})=>{this.renderStroke(t,i,s)})),this.unsubs.push(this.client.state.on("draw-clear",({userId:e})=>{})))}disable(){var e;if(this.enabled){this.enabled=!1,this.disableDrawMode(),this.unsubs.forEach(t=>t()),this.unsubs=[];for(const t of this.fadeTimers.values())clearTimeout(t);this.fadeTimers.clear(),(e=this.container)==null||e.remove(),this.container=null}}destroy(){this.disable()}enableDrawMode(){!this.container||this.drawMode||(this.drawMode=!0,this.container.style.pointerEvents="auto",this.container.style.cursor="crosshair",this.container.style.touchAction="none",this.container.addEventListener("pointerdown",this.handlePointerDown))}disableDrawMode(){this.drawMode&&(this.drawMode=!1,this.container&&(this.container.style.pointerEvents="none",this.container.style.cursor="",this.container.style.touchAction="",this.container.removeEventListener("pointerdown",this.handlePointerDown)),document.removeEventListener("pointermove",this.handlePointerMove),document.removeEventListener("pointerup",this.handlePointerUp),this.currentPoints=[],this.currentPath=null,this.lastPoint=null)}renderStroke(e,t,i){if(!this.container||e.length<2)return;const s=document.createElementNS("http://www.w3.org/2000/svg","polyline");s.setAttribute("fill","none"),s.setAttribute("stroke",t),s.setAttribute("stroke-width",String(i)),s.setAttribute("stroke-linecap","round"),s.setAttribute("stroke-linejoin","round"),s.setAttribute("points",e.map(n=>`${n.x},${n.y}`).join(" ")),s.style.willChange="opacity",this.container.appendChild(s),this.scheduleFade(s)}scheduleFade(e){const t=setTimeout(()=>{e.style.transition="opacity 1s ease-out",e.style.opacity="0",setTimeout(()=>{e.remove(),this.fadeTimers.delete(e)},1e3)},1e4);this.fadeTimers.set(e,t)}}function fs(o){if(!o.rangeCount||o.isCollapsed)return null;const e=o.getRangeAt(0),t=e.startContainer,i=e.endContainer,s=pt(t),n=pt(i);return!s||!n?null:{startSelector:s,startOffset:e.startOffset,endSelector:n,endOffset:e.endOffset}}function ms(o){var e,t;try{const i=ft(o.startSelector),s=ft(o.endSelector);if(!i||!s)return null;const n=document.createRange(),r=i.nodeType===Node.TEXT_NODE?((e=i.textContent)==null?void 0:e.length)??0:i.childNodes.length,a=s.nodeType===Node.TEXT_NODE?((t=s.textContent)==null?void 0:t.length)??0:s.childNodes.length;return n.setStart(i,Math.min(o.startOffset,r)),n.setEnd(s,Math.min(o.endOffset,a)),n}catch{return null}}function pt(o){if(o.nodeType===Node.TEXT_NODE){const e=o.parentElement;if(!e)return null;const t=ut(e);if(!t)return null;const i=Array.from(e.childNodes).indexOf(o);return`${t}::text(${i})`}return o.nodeType===Node.ELEMENT_NODE?ut(o):null}function ut(o){if(!o||o===document.documentElement)return"html";if(o===document.body)return"body";if(o.id)return`#${CSS.escape(o.id)}`;const e=[];let t=o,i=0;for(;t&&t!==document.body&&i<10;){const s=t.parentElement;if(!s)break;const n=t.tagName.toLowerCase(),r=t.tagName,a=Array.from(s.children).filter(l=>l.tagName===r);if(a.length===1)e.unshift(n);else{const l=a.indexOf(t)+1;e.unshift(`${n}:nth-of-type(${l})`)}if(s.id){e.unshift(`#${CSS.escape(s.id)}`);break}t=s,i++}return e.length>0?e.join(" > "):null}function ft(o){const e=o.match(/^(.+)::text\((\d+)\)$/);if(e){const t=e[1],i=parseInt(e[2],10);try{const s=document.querySelector(t);return s?s.childNodes[i]??null:null}catch{return null}}try{return document.querySelector(o)}catch{return null}}class gs{constructor(e){this.container=null,this.unsubs=[],this.enabled=!1,this.selectionEls=new Map,this.clearTimers=new Map,this.client=e}enable(){this.enabled||(this.enabled=!0,this.container=document.createElement("div"),this.container.id="pulse-widget-selections",Object.assign(this.container.style,{position:"fixed",top:"0",left:"0",width:"100%",height:"100%",pointerEvents:"none",zIndex:"9995"}),document.body.appendChild(this.container),this.unsubs.push(this.client.state.on("selection",({userId:e,selection:t})=>{this.renderSelection(e,t)})),this.unsubs.push(this.client.state.on("presence",e=>{const t=new Set(e.map(i=>i.user.id));for(const i of this.selectionEls.keys())t.has(i)||this.clearSelection(i)})))}disable(){var e;if(this.enabled){this.enabled=!1,this.unsubs.forEach(t=>t()),this.unsubs=[];for(const t of this.clearTimers.values())clearTimeout(t);this.clearTimers.clear(),(e=this.container)==null||e.remove(),this.container=null,this.selectionEls.clear()}}destroy(){this.disable()}renderSelection(e,t){var a;if(!this.container)return;const i=(a=this.client.state.user)==null?void 0:a.id;if(e===i||(this.clearSelection(e),!t))return;const s=ms(t);if(!s)return;const n=this.client.state.presence.find(l=>l.user.id===e),r=(n==null?void 0:n.user.color)??"#6366f1";try{const l=s.getClientRects(),d=[];for(let c=0;c<l.length;c++){const h=l[c],p=document.createElement("div");Object.assign(p.style,{position:"absolute",left:`${h.left}px`,top:`${h.top}px`,width:`${h.width}px`,height:`${h.height}px`,background:r,opacity:"0.2",borderRadius:"2px",pointerEvents:"none"}),this.container.appendChild(p),d.push(p)}this.selectionEls.set(e,d)}catch{}this.clearTimers.has(e)&&clearTimeout(this.clearTimers.get(e)),this.clearTimers.set(e,setTimeout(()=>{this.clearSelection(e),this.clearTimers.delete(e)},5e3))}clearSelection(e){const t=this.selectionEls.get(e);if(t){for(const i of t)i.remove();this.selectionEls.delete(e)}}}var vs=Object.defineProperty,bs=Object.getOwnPropertyDescriptor,Be=(o,e,t,i)=>{for(var s=i>1?void 0:i?bs(e,t):e,n=o.length-1,r;n>=0;n--)(r=o[n])&&(s=(i?r(e,t,s):r(s))||s);return i&&s&&vs(e,t,s),s};let re=class extends S{constructor(){super(...arguments),this.roomId=""}fireClose(){this.dispatchEvent(new CustomEvent("panel-close",{bubbles:!0,composed:!0}))}toggle(o){const e={...this.settings,[o]:!this.settings[o]};this.dispatchEvent(new CustomEvent("settings-change",{detail:e,bubbles:!0,composed:!0}))}renderToggle(o,e){return u`
2337
+ `,this.container.appendChild(i),this.cursorEls.set(e,i)}i.style.transform=`translate(${t.position.x}px, ${t.position.y}px)`}}class ms{constructor(e){this.container=null,this.unsubs=[],this.enabled=!1,this.drawMode=!1,this.currentPoints=[],this.currentPath=null,this.lastPoint=null,this.fadeTimers=new Map,this.handlePointerDown=t=>{var a,l,d;t.preventDefault(),(l=(a=t.target)==null?void 0:a.setPointerCapture)==null||l.call(a,t.pointerId),this.currentPoints=[{x:t.clientX,y:t.clientY}],this.lastPoint={x:t.clientX,y:t.clientY};const i=this.client.state.user,s=(i==null?void 0:i.color)??"#6366f1",r=2+(t.pressure>0?t.pressure:.5)*4;this.currentPath=document.createElementNS("http://www.w3.org/2000/svg","polyline"),this.currentPath.setAttribute("fill","none"),this.currentPath.setAttribute("stroke",s),this.currentPath.setAttribute("stroke-width",String(r)),this.currentPath.setAttribute("stroke-linecap","round"),this.currentPath.setAttribute("stroke-linejoin","round"),this.currentPath.setAttribute("points",`${t.clientX},${t.clientY}`),(d=this.container)==null||d.appendChild(this.currentPath),document.addEventListener("pointermove",this.handlePointerMove),document.addEventListener("pointerup",this.handlePointerUp)},this.handlePointerMove=t=>{if(!this.currentPath||!this.lastPoint)return;const i=t.clientX-this.lastPoint.x,s=t.clientY-this.lastPoint.y;if(i*i+s*s<4)return;this.currentPoints.push({x:t.clientX,y:t.clientY}),this.lastPoint={x:t.clientX,y:t.clientY};const n=this.currentPoints.map(r=>`${r.x},${r.y}`).join(" ");this.currentPath.setAttribute("points",n)},this.handlePointerUp=()=>{var t;if(document.removeEventListener("pointermove",this.handlePointerMove),document.removeEventListener("pointerup",this.handlePointerUp),this.currentPoints.length>1){const i=this.client.state.user,s=(i==null?void 0:i.color)??"#6366f1";this.client.drawStroke(this.currentPoints,s,3),this.currentPath&&this.scheduleFade(this.currentPath)}else(t=this.currentPath)==null||t.remove();this.currentPoints=[],this.currentPath=null,this.lastPoint=null},this.client=e}enable(){this.enabled||(this.enabled=!0,this.container=document.createElementNS("http://www.w3.org/2000/svg","svg"),this.container.id="pulse-widget-drawing",this.container.setAttribute("style","position:fixed;top:0;left:0;width:100%;height:100%;pointer-events:none;z-index:9989;"),document.body.appendChild(this.container),this.unsubs.push(this.client.state.on("draw-stroke",({userId:e,points:t,color:i,width:s})=>{this.renderStroke(t,i,s)})),this.unsubs.push(this.client.state.on("draw-clear",({userId:e})=>{})))}disable(){var e;if(this.enabled){this.enabled=!1,this.disableDrawMode(),this.unsubs.forEach(t=>t()),this.unsubs=[];for(const t of this.fadeTimers.values())clearTimeout(t);this.fadeTimers.clear(),(e=this.container)==null||e.remove(),this.container=null}}destroy(){this.disable()}enableDrawMode(){!this.container||this.drawMode||(this.drawMode=!0,this.container.style.pointerEvents="auto",this.container.style.cursor="crosshair",this.container.style.touchAction="none",this.container.addEventListener("pointerdown",this.handlePointerDown))}disableDrawMode(){this.drawMode&&(this.drawMode=!1,this.container&&(this.container.style.pointerEvents="none",this.container.style.cursor="",this.container.style.touchAction="",this.container.removeEventListener("pointerdown",this.handlePointerDown)),document.removeEventListener("pointermove",this.handlePointerMove),document.removeEventListener("pointerup",this.handlePointerUp),this.currentPoints=[],this.currentPath=null,this.lastPoint=null)}renderStroke(e,t,i){if(!this.container||e.length<2)return;const s=document.createElementNS("http://www.w3.org/2000/svg","polyline");s.setAttribute("fill","none"),s.setAttribute("stroke",t),s.setAttribute("stroke-width",String(i)),s.setAttribute("stroke-linecap","round"),s.setAttribute("stroke-linejoin","round"),s.setAttribute("points",e.map(n=>`${n.x},${n.y}`).join(" ")),s.style.willChange="opacity",this.container.appendChild(s),this.scheduleFade(s)}scheduleFade(e){const t=setTimeout(()=>{e.style.transition="opacity 1s ease-out",e.style.opacity="0",setTimeout(()=>{e.remove(),this.fadeTimers.delete(e)},1e3)},1e4);this.fadeTimers.set(e,t)}}function gs(o){if(!o.rangeCount||o.isCollapsed)return null;const e=o.getRangeAt(0),t=e.startContainer,i=e.endContainer,s=ut(t),n=ut(i);return!s||!n?null:{startSelector:s,startOffset:e.startOffset,endSelector:n,endOffset:e.endOffset}}function vs(o){var e,t;try{const i=mt(o.startSelector),s=mt(o.endSelector);if(!i||!s)return null;const n=document.createRange(),r=i.nodeType===Node.TEXT_NODE?((e=i.textContent)==null?void 0:e.length)??0:i.childNodes.length,a=s.nodeType===Node.TEXT_NODE?((t=s.textContent)==null?void 0:t.length)??0:s.childNodes.length;return n.setStart(i,Math.min(o.startOffset,r)),n.setEnd(s,Math.min(o.endOffset,a)),n}catch{return null}}function ut(o){if(o.nodeType===Node.TEXT_NODE){const e=o.parentElement;if(!e)return null;const t=ft(e);if(!t)return null;const i=Array.from(e.childNodes).indexOf(o);return`${t}::text(${i})`}return o.nodeType===Node.ELEMENT_NODE?ft(o):null}function ft(o){if(!o||o===document.documentElement)return"html";if(o===document.body)return"body";if(o.id)return`#${CSS.escape(o.id)}`;const e=[];let t=o,i=0;for(;t&&t!==document.body&&i<10;){const s=t.parentElement;if(!s)break;const n=t.tagName.toLowerCase(),r=t.tagName,a=Array.from(s.children).filter(l=>l.tagName===r);if(a.length===1)e.unshift(n);else{const l=a.indexOf(t)+1;e.unshift(`${n}:nth-of-type(${l})`)}if(s.id){e.unshift(`#${CSS.escape(s.id)}`);break}t=s,i++}return e.length>0?e.join(" > "):null}function mt(o){const e=o.match(/^(.+)::text\((\d+)\)$/);if(e){const t=e[1],i=parseInt(e[2],10);try{const s=document.querySelector(t);return s?s.childNodes[i]??null:null}catch{return null}}try{return document.querySelector(o)}catch{return null}}class bs{constructor(e){this.container=null,this.unsubs=[],this.enabled=!1,this.selectionEls=new Map,this.clearTimers=new Map,this.client=e}enable(){this.enabled||(this.enabled=!0,this.container=document.createElement("div"),this.container.id="pulse-widget-selections",Object.assign(this.container.style,{position:"fixed",top:"0",left:"0",width:"100%",height:"100%",pointerEvents:"none",zIndex:"9995"}),document.body.appendChild(this.container),this.unsubs.push(this.client.state.on("selection",({userId:e,selection:t})=>{this.renderSelection(e,t)})),this.unsubs.push(this.client.state.on("presence",e=>{const t=new Set(e.map(i=>i.user.id));for(const i of this.selectionEls.keys())t.has(i)||this.clearSelection(i)})))}disable(){var e;if(this.enabled){this.enabled=!1,this.unsubs.forEach(t=>t()),this.unsubs=[];for(const t of this.clearTimers.values())clearTimeout(t);this.clearTimers.clear(),(e=this.container)==null||e.remove(),this.container=null,this.selectionEls.clear()}}destroy(){this.disable()}renderSelection(e,t){var a;if(!this.container)return;const i=(a=this.client.state.user)==null?void 0:a.id;if(e===i||(this.clearSelection(e),!t))return;const s=vs(t);if(!s)return;const n=this.client.state.presence.find(l=>l.user.id===e),r=(n==null?void 0:n.user.color)??"#6366f1";try{const l=s.getClientRects(),d=[];for(let c=0;c<l.length;c++){const h=l[c],u=document.createElement("div");Object.assign(u.style,{position:"absolute",left:`${h.left}px`,top:`${h.top}px`,width:`${h.width}px`,height:`${h.height}px`,background:r,opacity:"0.2",borderRadius:"2px",pointerEvents:"none"}),this.container.appendChild(u),d.push(u)}this.selectionEls.set(e,d)}catch{}this.clearTimers.has(e)&&clearTimeout(this.clearTimers.get(e)),this.clearTimers.set(e,setTimeout(()=>{this.clearSelection(e),this.clearTimers.delete(e)},5e3))}clearSelection(e){const t=this.selectionEls.get(e);if(t){for(const i of t)i.remove();this.selectionEls.delete(e)}}}var xs=Object.defineProperty,ys=Object.getOwnPropertyDescriptor,Fe=(o,e,t,i)=>{for(var s=i>1?void 0:i?ys(e,t):e,n=o.length-1,r;n>=0;n--)(r=o[n])&&(s=(i?r(e,t,s):r(s))||s);return i&&s&&xs(e,t,s),s};let re=class extends A{constructor(){super(...arguments),this.roomId=""}fireClose(){this.dispatchEvent(new CustomEvent("panel-close",{bubbles:!0,composed:!0}))}toggle(o){const e={...this.settings,[o]:!this.settings[o]};this.dispatchEvent(new CustomEvent("settings-change",{detail:e,bubbles:!0,composed:!0}))}renderToggle(o,e){return p`
2323
2338
  <div class="setting-row">
2324
2339
  <span class="setting-label">${o}</span>
2325
2340
  <label class="toggle">
@@ -2331,7 +2346,7 @@
2331
2346
  <span class="toggle-track"></span>
2332
2347
  </label>
2333
2348
  </div>
2334
- `}render(){const o=!this.settings.enabled;return u`
2349
+ `}render(){const o=!this.settings.enabled;return p`
2335
2350
  <div class="panel">
2336
2351
  <div class="panel-header">
2337
2352
  <span class="panel-title">Settings</span>
@@ -2547,31 +2562,31 @@
2547
2562
  min-height: 44px;
2548
2563
  }
2549
2564
  }
2550
- `];Be([x({attribute:!1})],re.prototype,"settings",2);Be([x()],re.prototype,"roomId",2);re=Be([L("pulse-widget-settings-panel")],re);const me={enabled:!0,showMyCursor:!0,showOthersCursors:!0,showMyClicks:!0,showOthersClicks:!0,appearOffline:!1,showCommentPins:!0,showViewportIndicators:!0,showSelections:!0,showDrawings:!0},Pt="pulse:settings:";function xs(o){try{const e=localStorage.getItem(`${Pt}${o}`);return e?{...me,...JSON.parse(e)}:{...me}}catch{return{...me}}}function ys(o,e){localStorage.setItem(`${Pt}${o}`,JSON.stringify(e))}var ws=Object.defineProperty,$s=Object.getOwnPropertyDescriptor,j=(o,e,t,i)=>{for(var s=i>1?void 0:i?$s(e,t):e,n=o.length-1,r;n>=0;n--)(r=o[n])&&(s=(i?r(e,t,s):r(s))||s);return i&&s&&ws(e,t,s),s};let I=class extends S{constructor(){super(...arguments),this.collapsed=!1,this.activePanel=null,this.pinModeActive=!1,this.featuresDisabled=!1,this.drawModeActive=!1,this.followingUserId=null,this.display="floating",this.envConfig={...Et},this.users=[],this.unreadCount=0}connectedCallback(){super.connectedCallback(),this.setupPresence()}disconnectedCallback(){var o,e,t;super.disconnectedCallback(),(o=this.unsub)==null||o.call(this),(e=this.authUnsub)==null||e.call(this),(t=this.notifUnsub)==null||t.call(this)}updated(o){var e,t,i;o.has("client")&&this.client&&((e=this.unsub)==null||e.call(this),(t=this.authUnsub)==null||t.call(this),(i=this.notifUnsub)==null||i.call(this),this.setupPresence())}setupPresence(){this.client&&(this.users=this.client.state.presence,this.unreadCount=this.client.state.unreadCount,this.unsub=this.client.state.on("presence",o=>{this.users=[...o]}),this.authUnsub=this.client.state.on("auth",()=>{this.users=this.client.state.presence,this.unreadCount=this.client.state.unreadCount}),this.notifUnsub=this.client.state.on("notifications",()=>{this.unreadCount=this.client.state.unreadCount}))}getInitials(o){return o.split(" ").map(e=>e[0]).join("").toUpperCase().slice(0,2)}fire(o){this.dispatchEvent(new CustomEvent("toolbar-action",{detail:o,bubbles:!0,composed:!0}))}fireFollow(o){this.dispatchEvent(new CustomEvent("toolbar-follow",{detail:o,bubbles:!0,composed:!0}))}fireToggle(){this.dispatchEvent(new CustomEvent("toolbar-toggle",{bubbles:!0,composed:!0}))}render(){const o=this.display==="inline";if(this.collapsed)return u`
2565
+ `];Fe([w({attribute:!1})],re.prototype,"settings",2);Fe([w()],re.prototype,"roomId",2);re=Fe([L("pulse-widget-settings-panel")],re);const me={enabled:!0,showMyCursor:!0,showOthersCursors:!0,showMyClicks:!0,showOthersClicks:!0,appearOffline:!1,showCommentPins:!0,showViewportIndicators:!0,showSelections:!0,showDrawings:!0},Tt="pulse:settings:";function ws(o){try{const e=localStorage.getItem(`${Tt}${o}`);return e?{...me,...JSON.parse(e)}:{...me}}catch{return{...me}}}function $s(o,e){localStorage.setItem(`${Tt}${o}`,JSON.stringify(e))}var ks=Object.defineProperty,Es=Object.getOwnPropertyDescriptor,j=(o,e,t,i)=>{for(var s=i>1?void 0:i?Es(e,t):e,n=o.length-1,r;n>=0;n--)(r=o[n])&&(s=(i?r(e,t,s):r(s))||s);return i&&s&&ks(e,t,s),s};let I=class extends A{constructor(){super(...arguments),this.collapsed=!1,this.activePanel=null,this.pinModeActive=!1,this.featuresDisabled=!1,this.drawModeActive=!1,this.followingUserId=null,this.display="floating",this.envConfig={...Ct},this.users=[],this.unreadCount=0}connectedCallback(){super.connectedCallback(),this.setupPresence()}disconnectedCallback(){var o,e,t;super.disconnectedCallback(),(o=this.unsub)==null||o.call(this),(e=this.authUnsub)==null||e.call(this),(t=this.notifUnsub)==null||t.call(this)}updated(o){var e,t,i;o.has("client")&&this.client&&((e=this.unsub)==null||e.call(this),(t=this.authUnsub)==null||t.call(this),(i=this.notifUnsub)==null||i.call(this),this.setupPresence())}setupPresence(){this.client&&(this.users=this.client.state.presence,this.unreadCount=this.client.state.unreadCount,this.unsub=this.client.state.on("presence",o=>{this.users=[...o]}),this.authUnsub=this.client.state.on("auth",()=>{this.users=this.client.state.presence,this.unreadCount=this.client.state.unreadCount}),this.notifUnsub=this.client.state.on("notifications",()=>{this.unreadCount=this.client.state.unreadCount}))}getInitials(o){return o.split(" ").map(e=>e[0]).join("").toUpperCase().slice(0,2)}fire(o){this.dispatchEvent(new CustomEvent("toolbar-action",{detail:o,bubbles:!0,composed:!0}))}fireFollow(o){this.dispatchEvent(new CustomEvent("toolbar-follow",{detail:o,bubbles:!0,composed:!0}))}fireToggle(){this.dispatchEvent(new CustomEvent("toolbar-toggle",{bubbles:!0,composed:!0}))}render(){const o=this.display==="inline";if(this.collapsed)return p`
2551
2566
  <div class="toolbar collapsed ${o?"inline":""}" @click=${this.fireToggle}>
2552
- <span class="fab-icon">${C(ji,o?18:24)}</span>
2567
+ <span class="fab-icon">${C(Ui,o?18:24)}</span>
2553
2568
  </div>
2554
- `;const e=this.users.slice(0,3),t=this.users.length-3;return u`
2569
+ `;const e=this.users.slice(0,3),t=this.users.length-3;return p`
2555
2570
  <div class="toolbar ${o?"inline":""}"
2556
2571
  <!-- Presence avatars -->
2557
- ${this.users.length>0&&this.envConfig.showPresence?u`
2572
+ ${this.users.length>0&&this.envConfig.showPresence?p`
2558
2573
  <div class="presence">
2559
- ${t>0?u`<div class="presence-overflow">+${t}</div>`:v}
2560
- ${e.map(i=>u`
2574
+ ${t>0?p`<div class="presence-overflow">+${t}</div>`:g}
2575
+ ${e.map(i=>p`
2561
2576
  <div
2562
2577
  class="presence-avatar clickable ${this.followingUserId===i.user.id?"following":""}"
2563
2578
  style="background:${i.user.color}"
2564
2579
  @click=${()=>this.fireFollow(i.user.id)}
2565
2580
  title="Click to follow ${i.user.name}"
2566
2581
  >
2567
- ${i.user.avatar?u`<img src="${i.user.avatar}" alt="${i.user.name}" />`:this.getInitials(i.user.name)}
2582
+ ${i.user.avatar?p`<img src="${i.user.avatar}" alt="${i.user.name}" />`:this.getInitials(i.user.name)}
2568
2583
  <span class="presence-tooltip">${i.user.name}</span>
2569
- ${i.deviceType&&i.deviceType!=="desktop"?u`<span class="device-icon">${i.deviceType==="mobile"?"📱":"📲"}</span>`:v}
2584
+ ${i.deviceType&&i.deviceType!=="desktop"?p`<span class="device-icon">${i.deviceType==="mobile"?"📱":"📲"}</span>`:g}
2570
2585
  </div>
2571
2586
  `)}
2572
2587
  </div>
2573
2588
  <div class="separator"></div>
2574
- `:v}
2589
+ `:g}
2575
2590
 
2576
2591
  <!-- Pin comment (primary) -->
2577
2592
  <button
@@ -2581,7 +2596,7 @@
2581
2596
  ?disabled=${this.featuresDisabled}
2582
2597
  style="${this.featuresDisabled?"opacity:0.35;pointer-events:none":""}"
2583
2598
  >
2584
- ${C(Ct)}
2599
+ ${C(Pt)}
2585
2600
  </button>
2586
2601
 
2587
2602
  <!-- View comments -->
@@ -2592,7 +2607,7 @@
2592
2607
  ?disabled=${this.featuresDisabled}
2593
2608
  style="${this.featuresDisabled?"opacity:0.35;pointer-events:none":""}"
2594
2609
  >
2595
- ${C(Si)}
2610
+ ${C(Ai)}
2596
2611
  </button>
2597
2612
 
2598
2613
  <!-- Activity feed -->
@@ -2603,11 +2618,11 @@
2603
2618
  ?disabled=${this.featuresDisabled}
2604
2619
  style="${this.featuresDisabled?"opacity:0.35;pointer-events:none":""}"
2605
2620
  >
2606
- ${C(Ti)}
2621
+ ${C(Si)}
2607
2622
  </button>
2608
2623
 
2609
2624
  <!-- Draw mode -->
2610
- ${this.envConfig.allowDrawing?u`
2625
+ ${this.envConfig.allowDrawing?p`
2611
2626
  <button
2612
2627
  class="pw-btn pw-btn-icon ${this.drawModeActive?"active":""}"
2613
2628
  @click=${()=>this.fire("draw-mode")}
@@ -2615,9 +2630,9 @@
2615
2630
  ?disabled=${this.featuresDisabled}
2616
2631
  style="${this.featuresDisabled?"opacity:0.35;pointer-events:none":""}"
2617
2632
  >
2618
- ${C(Ii)}
2633
+ ${C(Mi)}
2619
2634
  </button>
2620
- `:v}
2635
+ `:g}
2621
2636
 
2622
2637
  <!-- Notifications -->
2623
2638
  <button
@@ -2627,8 +2642,8 @@
2627
2642
  ?disabled=${this.featuresDisabled}
2628
2643
  style="${this.featuresDisabled?"opacity:0.35;pointer-events:none":"position:relative"}"
2629
2644
  >
2630
- ${C(Pi)}
2631
- ${this.unreadCount>0?u`<span class="badge">${this.unreadCount>9?"9+":this.unreadCount}</span>`:v}
2645
+ ${C(Ti)}
2646
+ ${this.unreadCount>0?p`<span class="badge">${this.unreadCount>9?"9+":this.unreadCount}</span>`:g}
2632
2647
  </button>
2633
2648
 
2634
2649
  <!-- Settings -->
@@ -2637,7 +2652,7 @@
2637
2652
  @click=${()=>this.fire("settings")}
2638
2653
  title="Settings"
2639
2654
  >
2640
- ${C(Oi)}
2655
+ ${C(Ri)}
2641
2656
  </button>
2642
2657
 
2643
2658
  <div class="separator"></div>
@@ -2861,40 +2876,40 @@
2861
2876
  height: 32px;
2862
2877
  }
2863
2878
  }
2864
- `];j([x({attribute:!1})],I.prototype,"client",2);j([x({type:Boolean})],I.prototype,"collapsed",2);j([x()],I.prototype,"activePanel",2);j([x({type:Boolean})],I.prototype,"pinModeActive",2);j([x({type:Boolean})],I.prototype,"featuresDisabled",2);j([x({type:Boolean})],I.prototype,"drawModeActive",2);j([x()],I.prototype,"followingUserId",2);j([x()],I.prototype,"display",2);j([x({attribute:!1})],I.prototype,"envConfig",2);j([$()],I.prototype,"users",2);j([$()],I.prototype,"unreadCount",2);I=j([L("pulse-widget-toolbar")],I);class ks{constructor(e){this.container=null,this.unsubs=[],this.enabled=!1,this.pillEls=new Map,this.client=e}enable(){this.enabled||(this.enabled=!0,this.container=document.createElement("div"),this.container.id="pulse-widget-viewports",Object.assign(this.container.style,{position:"fixed",top:"0",left:"0",width:"100%",height:"100%",pointerEvents:"none",zIndex:"9996"}),document.body.appendChild(this.container),this.unsubs.push(this.client.state.on("viewport",()=>{this.render()})),this.unsubs.push(this.client.state.on("presence",()=>{this.render()})),this.render())}disable(){var e;this.enabled&&(this.enabled=!1,this.unsubs.forEach(t=>t()),this.unsubs=[],(e=this.container)==null||e.remove(),this.container=null,this.pillEls.clear())}destroy(){this.disable()}render(){var r;if(!this.container)return;if(document.documentElement.scrollHeight<=window.innerHeight){for(const a of this.pillEls.values())a.remove();this.pillEls.clear();return}const e=window.scrollY,t=window.innerHeight,i=document.documentElement.scrollHeight,s=(r=this.client.state.user)==null?void 0:r.id,n=new Set;for(const[a,l]of this.client.state.viewports){if(a===s)continue;const d=l.scrollY,c=l.scrollY+l.viewportHeight,h=e,p=e+t;if(d>=h&&c<=p){const k=this.pillEls.get(a);k&&(k.style.display="none");continue}n.add(a);const m=this.client.state.presence.find(k=>k.user.id===a);if(!m)continue;const g=l.scrollY+l.viewportHeight/2,y=i>0?g/i:0,b=Math.max(8,Math.min(t-28,y*t));let w=this.pillEls.get(a);w||(w=document.createElement("div"),Object.assign(w.style,{position:"absolute",right:"8px",padding:"2px 6px",borderRadius:"10px",fontSize:"10px",fontWeight:"700",color:"#fff",fontFamily:"-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif",whiteSpace:"nowrap",pointerEvents:"none",transition:"top 0.3s ease"}),this.container.appendChild(w),this.pillEls.set(a,w)),w.style.display="",w.style.background=m.user.color,w.style.top=`${b}px`,w.textContent=this.getInitials(m.user.name)}for(const[a,l]of this.pillEls)!n.has(a)&&!this.client.state.viewports.has(a)&&(l.remove(),this.pillEls.delete(a))}getInitials(e){return e.split(" ").map(t=>t[0]).join("").toUpperCase().slice(0,2)}}var Es=Object.defineProperty,Cs=Object.getOwnPropertyDescriptor,T=(o,e,t,i)=>{for(var s=i>1?void 0:i?Cs(e,t):e,n=o.length-1,r;n>=0;n--)(r=o[n])&&(s=(i?r(e,t,s):r(s))||s);return i&&s&&Es(e,t,s),s};exports.PulseWidget=class extends S{constructor(){super(...arguments),this.apiKey="",this.token="",this.room="",this.position="bottom-right",this.display="floating",this.collapsed=!0,this.activePanel=null,this.pinModeActive=!1,this.highlightThreadId=null,this.settings={...me},this.followingUserId=null,this.drawModeActive=!1,this.connectionState="disconnected",this.showConnectedFlash=!1,this.envConfig={...Et},this.unsubs=[],this.clientConfigKey="",this._isFollowScrolling=!1,this._viewportThrottleTimer=null,this._selectionThrottleTimer=null,this._connectedFlashTimer=null,this._wasDisconnected=!1,this.handleScroll=()=>{!this.settings.enabled||!this.client||this._isFollowScrolling||(this.followingUserId&&(this.followingUserId=null),!this._viewportThrottleTimer&&(this._viewportThrottleTimer=setTimeout(()=>{var e;this._viewportThrottleTimer=null,(e=this.client)==null||e.updateViewport({scrollX:window.scrollX,scrollY:window.scrollY,viewportWidth:window.innerWidth,viewportHeight:window.innerHeight,pageWidth:document.documentElement.scrollWidth,pageHeight:document.documentElement.scrollHeight})},200)))},this.handleSelectionChange=()=>{!this.settings.enabled||!this.settings.showSelections||!this.client||this._selectionThrottleTimer||(this._selectionThrottleTimer=setTimeout(()=>{var i,s;this._selectionThrottleTimer=null;const e=window.getSelection();if(!e||e.isCollapsed){(i=this.client)==null||i.updateSelection(null);return}const t=fs(e);(s=this.client)==null||s.updateSelection(t)},500))},this.handleDocumentClick=e=>{var t;this.settings.enabled&&this.settings.showMyClicks&&(this.contains(e.target)||(t=this.client)==null||t.performClick({x:e.clientX,y:e.clientY,pageX:e.pageX,pageY:e.pageY}))},this.handleKeydown=e=>{var t,i;e.key==="Escape"&&(this.drawModeActive?((t=this.drawingOverlay)==null||t.disableDrawMode(),this.drawModeActive=!1):this.followingUserId?this.followingUserId=null:this.pinModeActive?((i=this.commentPins)==null||i.exitPinMode(),this.pinModeActive=!1):this.activePanel&&(this.activePanel=null,this.highlightThreadId=null))}}connectedCallback(){super.connectedCallback(),document.addEventListener("keydown",this.handleKeydown),document.addEventListener("pointerup",this.handleDocumentClick),this.apiKey&&this.token&&this.room&&this.initClient()}disconnectedCallback(){super.disconnectedCallback(),document.removeEventListener("keydown",this.handleKeydown),document.removeEventListener("pointerup",this.handleDocumentClick),this.teardownClient()}getConfigKey(){return`${this.apiKey}\0${this.token}\0${this.room}\0${this.endpoint??""}`}initClient(){const e={apiKey:this.apiKey,token:this.token,room:this.room,endpoint:this.endpoint};this.client=new vt(e),this.clientConfigKey=this.getConfigKey(),this.cursorOverlay=new ps(this.client),this.commentPins=new ss(this.client,{onPinModeExit:()=>{this.pinModeActive=!1}}),this.viewportOverlay=new ks(this.client),this.selectionOverlay=new gs(this.client),this.drawingOverlay=new us(this.client),this.settings=xs(this.room),this.applySettings(this.settings),this.unsubs.push(this.client.state.on("auth",()=>{var t,i;this.envConfig=this.client.state.config,this.envConfig.showCursors||(t=this.cursorOverlay)==null||t.disable(),!this.envConfig.allowDrawing&&this.drawModeActive&&((i=this.drawingOverlay)==null||i.disableDrawMode(),this.drawModeActive=!1)})),this.unsubs.push(this.client.on("connection",t=>{this.connectionState=t,t==="connected"&&this._wasDisconnected?(this.showConnectedFlash=!0,this._connectedFlashTimer&&clearTimeout(this._connectedFlashTimer),this._connectedFlashTimer=setTimeout(()=>{this.showConnectedFlash=!1,this._connectedFlashTimer=null},2e3),this._wasDisconnected=!1):(t==="connecting"||t==="disconnected")&&(this._wasDisconnected=!0,this.showConnectedFlash=!1,this._connectedFlashTimer&&(clearTimeout(this._connectedFlashTimer),this._connectedFlashTimer=null))})),this.unsubs.push(this.client.state.on("click",({userId:t,position:i})=>{var s;this.settings.showOthersClicks&&((s=this.cursorOverlay)!=null&&s.isEnabled)&&this.cursorOverlay.showClickRipple(t,i)})),this.unsubs.push(this.client.state.on("viewport",({userId:t})=>{if(this.followingUserId===t){const i=this.client.state.getViewport(t);i&&(this._isFollowScrolling=!0,window.scrollTo({top:i.scrollY,left:i.scrollX,behavior:"smooth"}),setTimeout(()=>{this._isFollowScrolling=!1},500))}})),window.addEventListener("scroll",this.handleScroll),document.addEventListener("selectionchange",this.handleSelectionChange),this.client.connect()}teardownClient(){var e,t,i,s,n,r;this.unsubs.forEach(a=>a()),this.unsubs=[],window.removeEventListener("scroll",this.handleScroll),document.removeEventListener("selectionchange",this.handleSelectionChange),this._viewportThrottleTimer&&(clearTimeout(this._viewportThrottleTimer),this._viewportThrottleTimer=null),this._selectionThrottleTimer&&(clearTimeout(this._selectionThrottleTimer),this._selectionThrottleTimer=null),(e=this.cursorOverlay)==null||e.destroy(),(t=this.commentPins)==null||t.destroy(),(i=this.viewportOverlay)==null||i.destroy(),(s=this.selectionOverlay)==null||s.destroy(),(n=this.drawingOverlay)==null||n.destroy(),(r=this.client)==null||r.disconnect(),this.client=void 0,this.cursorOverlay=void 0,this.commentPins=void 0,this.viewportOverlay=void 0,this.selectionOverlay=void 0,this.drawingOverlay=void 0,this.clientConfigKey="",this.followingUserId=null,this.drawModeActive=!1,this.connectionState="disconnected",this.showConnectedFlash=!1,this._wasDisconnected=!1,this._connectedFlashTimer&&(clearTimeout(this._connectedFlashTimer),this._connectedFlashTimer=null)}handlePanelClose(){this.activePanel=null,this.highlightThreadId=null}handleToolbarAction(e){var s,n,r,a;const t=e.detail;if(!this.settings.enabled&&t!=="settings")return;const i=t==="comments"||t==="settings"||t==="notifications"||t==="activity";switch((i||t==="pin-mode")&&this.drawModeActive&&(this.drawModeActive=!1,(s=this.drawingOverlay)==null||s.disableDrawMode()),(i||t==="draw-mode")&&this.pinModeActive&&(this.pinModeActive=!1,(n=this.commentPins)==null||n.exitPinMode()),(t==="pin-mode"||t==="draw-mode")&&(this.activePanel=null),t){case"comments":this.activePanel=this.activePanel==="comments"?null:"comments",this.highlightThreadId=null;break;case"settings":this.activePanel=this.activePanel==="settings"?null:"settings";break;case"notifications":this.activePanel=this.activePanel==="notifications"?null:"notifications";break;case"activity":this.activePanel=this.activePanel==="activity"?null:"activity";break;case"pin-mode":this.pinModeActive=!this.pinModeActive,this.pinModeActive&&((r=this.commentPins)==null||r.enterPinMode());break;case"draw-mode":if(!this.envConfig.allowDrawing)break;this.drawModeActive=!this.drawModeActive,this.drawModeActive&&((a=this.drawingOverlay)==null||a.enableDrawMode());break}}handleFollow(e){const t=e.detail;this.followingUserId===t?this.followingUserId=null:this.followingUserId=t}handleSettingsChange(e){const t=e.detail;this.settings=t,ys(this.room,t),this.applySettings(t)}applySettings(e){var t,i,s,n,r,a,l,d,c,h,p,m,g,y,b,w,k;if(!e.enabled){(t=this.cursorOverlay)==null||t.disable(),(i=this.viewportOverlay)==null||i.disable(),(s=this.selectionOverlay)==null||s.disable(),(n=this.drawingOverlay)==null||n.disable(),this.drawModeActive&&((r=this.drawingOverlay)==null||r.disableDrawMode(),this.drawModeActive=!1),(a=this.client)==null||a.setAppearOffline(!0),(l=this.commentPins)==null||l.setVisible(!1),this.followingUserId=null,this.pinModeActive&&((d=this.commentPins)==null||d.exitPinMode(),this.pinModeActive=!1),this.activePanel=this.activePanel==="settings"?"settings":null,this.highlightThreadId=null;return}this.applyCursorSettings(e),(c=this.client)==null||c.setAppearOffline(e.appearOffline),(h=this.commentPins)==null||h.setVisible(e.showCommentPins),e.showViewportIndicators?(p=this.viewportOverlay)==null||p.enable():(m=this.viewportOverlay)==null||m.disable(),e.showSelections?(g=this.selectionOverlay)==null||g.enable():(y=this.selectionOverlay)==null||y.disable(),e.showDrawings?(b=this.drawingOverlay)==null||b.enable():((w=this.drawingOverlay)==null||w.disable(),this.drawModeActive&&((k=this.drawingOverlay)==null||k.disableDrawMode(),this.drawModeActive=!1))}applyCursorSettings(e){if(!this.cursorOverlay)return;e.showMyCursor||e.showOthersCursors?(this.cursorOverlay.enable(),this.cursorOverlay.setSending(e.showMyCursor),this.cursorOverlay.setReceiving(e.showOthersCursors)):this.cursorOverlay.disable()}updated(e){(e.has("room")||e.has("token")||e.has("apiKey")||e.has("endpoint"))&&this.apiKey&&this.token&&this.room&&this.getConfigKey()!==this.clientConfigKey&&(this.teardownClient(),this.initClient(),this.activePanel=null,this.highlightThreadId=null,this.pinModeActive=!1),(e.has("activePanel")||e.has("collapsed"))&&requestAnimationFrame(()=>this.positionPopups())}positionPopups(){var y,b,w,k;const e=this.display==="inline",t=(y=this.shadowRoot)==null?void 0:y.querySelector(".inline-trigger"),i=(b=this.shadowRoot)==null?void 0:b.querySelector("pulse-widget-toolbar"),s=e?t:i;if(!s)return;const n=s.getBoundingClientRect(),r=window.innerWidth,a=window.innerHeight,l=8,d=(w=this.shadowRoot)==null?void 0:w.querySelector(".toolbar-popover");if(d){Object.assign(d.style,{top:"auto",left:"auto"});const _=d.getBoundingClientRect(),O=this.computePosition(n,_,r,a,l);d.style.top=`${O.top}px`,d.style.left=`${O.left}px`}const c=(k=this.shadowRoot)==null?void 0:k.querySelector(".panel-container");if(!c)return;Object.assign(c.style,{top:"auto",left:"auto"});const h=d??i;if(!h)return;const p=h.getBoundingClientRect(),m=c.getBoundingClientRect(),g=this.computePosition(p,m,r,a,l);c.style.top=`${g.top}px`,c.style.left=`${g.left}px`}computePosition(e,t,i,s,n){const r=e.top,a=s-e.bottom;let l;r>=t.height+n?l=e.top-t.height-n:a>=t.height+n?l=e.bottom+n:l=r>=a?Math.max(n,e.top-t.height-n):e.bottom+n;let d;const c=e.right-t.width;return c>=n?d=c:e.left+t.width+n<=i?d=e.left:d=Math.max(n,Math.min(i-t.width-n,e.left)),l=Math.max(n,Math.min(s-t.height-n,l)),d=Math.max(n,Math.min(i-t.width-n,d)),{top:l,left:d}}getFollowUserName(){var t;if(!this.followingUserId)return"";const e=(t=this.client)==null?void 0:t.state.presence.find(i=>i.user.id===this.followingUserId);return(e==null?void 0:e.user.name)??"user"}renderConnectionBanner(){return this.showConnectedFlash?u`<div class="connection-banner connected">
2879
+ `];j([w({attribute:!1})],I.prototype,"client",2);j([w({type:Boolean})],I.prototype,"collapsed",2);j([w()],I.prototype,"activePanel",2);j([w({type:Boolean})],I.prototype,"pinModeActive",2);j([w({type:Boolean})],I.prototype,"featuresDisabled",2);j([w({type:Boolean})],I.prototype,"drawModeActive",2);j([w()],I.prototype,"followingUserId",2);j([w()],I.prototype,"display",2);j([w({attribute:!1})],I.prototype,"envConfig",2);j([k()],I.prototype,"users",2);j([k()],I.prototype,"unreadCount",2);I=j([L("pulse-widget-toolbar")],I);class Cs{constructor(e){this.container=null,this.unsubs=[],this.enabled=!1,this.pillEls=new Map,this.client=e}enable(){this.enabled||(this.enabled=!0,this.container=document.createElement("div"),this.container.id="pulse-widget-viewports",Object.assign(this.container.style,{position:"fixed",top:"0",left:"0",width:"100%",height:"100%",pointerEvents:"none",zIndex:"9996"}),document.body.appendChild(this.container),this.unsubs.push(this.client.state.on("viewport",()=>{this.render()})),this.unsubs.push(this.client.state.on("presence",()=>{this.render()})),this.render())}disable(){var e;this.enabled&&(this.enabled=!1,this.unsubs.forEach(t=>t()),this.unsubs=[],(e=this.container)==null||e.remove(),this.container=null,this.pillEls.clear())}destroy(){this.disable()}render(){var r;if(!this.container)return;if(document.documentElement.scrollHeight<=window.innerHeight){for(const a of this.pillEls.values())a.remove();this.pillEls.clear();return}const e=window.scrollY,t=window.innerHeight,i=document.documentElement.scrollHeight,s=(r=this.client.state.user)==null?void 0:r.id,n=new Set;for(const[a,l]of this.client.state.viewports){if(a===s)continue;const d=l.scrollY,c=l.scrollY+l.viewportHeight,h=e,u=e+t;if(d>=h&&c<=u){const $=this.pillEls.get(a);$&&($.style.display="none");continue}n.add(a);const f=this.client.state.presence.find($=>$.user.id===a);if(!f)continue;const b=l.scrollY+l.viewportHeight/2,x=i>0?b/i:0,y=Math.max(8,Math.min(t-28,x*t));let v=this.pillEls.get(a);v||(v=document.createElement("div"),Object.assign(v.style,{position:"absolute",right:"8px",padding:"2px 6px",borderRadius:"10px",fontSize:"10px",fontWeight:"700",color:"#fff",fontFamily:"-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif",whiteSpace:"nowrap",pointerEvents:"none",transition:"top 0.3s ease"}),this.container.appendChild(v),this.pillEls.set(a,v)),v.style.display="",v.style.background=f.user.color,v.style.top=`${y}px`,v.textContent=this.getInitials(f.user.name)}for(const[a,l]of this.pillEls)!n.has(a)&&!this.client.state.viewports.has(a)&&(l.remove(),this.pillEls.delete(a))}getInitials(e){return e.split(" ").map(t=>t[0]).join("").toUpperCase().slice(0,2)}}var Ps=Object.defineProperty,Ts=Object.getOwnPropertyDescriptor,S=(o,e,t,i)=>{for(var s=i>1?void 0:i?Ts(e,t):e,n=o.length-1,r;n>=0;n--)(r=o[n])&&(s=(i?r(e,t,s):r(s))||s);return i&&s&&Ps(e,t,s),s};exports.PulseWidget=class extends A{constructor(){super(...arguments),this.apiKey="",this.token="",this.room="",this.position="bottom-right",this.display="floating",this.collapsed=!0,this.activePanel=null,this.pinModeActive=!1,this.highlightThreadId=null,this.settings={...me},this.followingUserId=null,this.drawModeActive=!1,this.connectionState="disconnected",this.showConnectedFlash=!1,this.envConfig={...Ct},this.unsubs=[],this.clientConfigKey="",this._isFollowScrolling=!1,this._viewportThrottleTimer=null,this._selectionThrottleTimer=null,this._connectedFlashTimer=null,this._wasDisconnected=!1,this.handleScroll=()=>{!this.settings.enabled||!this.client||this._isFollowScrolling||(this.followingUserId&&(this.followingUserId=null),!this._viewportThrottleTimer&&(this._viewportThrottleTimer=setTimeout(()=>{var e;this._viewportThrottleTimer=null,(e=this.client)==null||e.updateViewport({scrollX:window.scrollX,scrollY:window.scrollY,viewportWidth:window.innerWidth,viewportHeight:window.innerHeight,pageWidth:document.documentElement.scrollWidth,pageHeight:document.documentElement.scrollHeight})},200)))},this.handleSelectionChange=()=>{!this.settings.enabled||!this.settings.showSelections||!this.client||this._selectionThrottleTimer||(this._selectionThrottleTimer=setTimeout(()=>{var i,s;this._selectionThrottleTimer=null;const e=window.getSelection();if(!e||e.isCollapsed){(i=this.client)==null||i.updateSelection(null);return}const t=gs(e);(s=this.client)==null||s.updateSelection(t)},500))},this.handleDocumentClick=e=>{var t;this.settings.enabled&&this.settings.showMyClicks&&(this.contains(e.target)||(t=this.client)==null||t.performClick({x:e.clientX,y:e.clientY,pageX:e.pageX,pageY:e.pageY}))},this.handleKeydown=e=>{var t,i;e.key==="Escape"&&(this.drawModeActive?((t=this.drawingOverlay)==null||t.disableDrawMode(),this.drawModeActive=!1):this.followingUserId?this.followingUserId=null:this.pinModeActive?((i=this.commentPins)==null||i.exitPinMode(),this.pinModeActive=!1):this.activePanel&&(this.activePanel=null,this.highlightThreadId=null))}}connectedCallback(){super.connectedCallback(),document.addEventListener("keydown",this.handleKeydown),document.addEventListener("pointerup",this.handleDocumentClick),this.apiKey&&this.token&&this.room&&this.initClient()}disconnectedCallback(){super.disconnectedCallback(),document.removeEventListener("keydown",this.handleKeydown),document.removeEventListener("pointerup",this.handleDocumentClick),this.teardownClient()}getConfigKey(){return`${this.apiKey}\0${this.token}\0${this.room}\0${this.endpoint??""}`}initClient(){const e={apiKey:this.apiKey,token:this.token,room:this.room,endpoint:this.endpoint};this.client=new bt(e),this.clientConfigKey=this.getConfigKey(),this.cursorOverlay=new fs(this.client),this.commentPins=new os(this.client,{onPinModeExit:()=>{this.pinModeActive=!1}}),this.viewportOverlay=new Cs(this.client),this.selectionOverlay=new bs(this.client),this.drawingOverlay=new ms(this.client),this.settings=ws(this.room),this.applySettings(this.settings),this.unsubs.push(this.client.state.on("auth",()=>{var t,i;this.envConfig=this.client.state.config,this.envConfig.showCursors||(t=this.cursorOverlay)==null||t.disable(),!this.envConfig.allowDrawing&&this.drawModeActive&&((i=this.drawingOverlay)==null||i.disableDrawMode(),this.drawModeActive=!1)})),this.unsubs.push(this.client.on("connection",t=>{this.connectionState=t,t==="connected"&&this._wasDisconnected?(this.showConnectedFlash=!0,this._connectedFlashTimer&&clearTimeout(this._connectedFlashTimer),this._connectedFlashTimer=setTimeout(()=>{this.showConnectedFlash=!1,this._connectedFlashTimer=null},2e3),this._wasDisconnected=!1):(t==="connecting"||t==="disconnected")&&(this._wasDisconnected=!0,this.showConnectedFlash=!1,this._connectedFlashTimer&&(clearTimeout(this._connectedFlashTimer),this._connectedFlashTimer=null))})),this.unsubs.push(this.client.state.on("click",({userId:t,position:i})=>{var s;this.settings.showOthersClicks&&((s=this.cursorOverlay)!=null&&s.isEnabled)&&this.cursorOverlay.showClickRipple(t,i)})),this.unsubs.push(this.client.state.on("viewport",({userId:t})=>{if(this.followingUserId===t){const i=this.client.state.getViewport(t);i&&(this._isFollowScrolling=!0,window.scrollTo({top:i.scrollY,left:i.scrollX,behavior:"smooth"}),setTimeout(()=>{this._isFollowScrolling=!1},500))}})),window.addEventListener("scroll",this.handleScroll),document.addEventListener("selectionchange",this.handleSelectionChange),this.client.connect()}teardownClient(){var e,t,i,s,n,r;this.unsubs.forEach(a=>a()),this.unsubs=[],window.removeEventListener("scroll",this.handleScroll),document.removeEventListener("selectionchange",this.handleSelectionChange),this._viewportThrottleTimer&&(clearTimeout(this._viewportThrottleTimer),this._viewportThrottleTimer=null),this._selectionThrottleTimer&&(clearTimeout(this._selectionThrottleTimer),this._selectionThrottleTimer=null),(e=this.cursorOverlay)==null||e.destroy(),(t=this.commentPins)==null||t.destroy(),(i=this.viewportOverlay)==null||i.destroy(),(s=this.selectionOverlay)==null||s.destroy(),(n=this.drawingOverlay)==null||n.destroy(),(r=this.client)==null||r.disconnect(),this.client=void 0,this.cursorOverlay=void 0,this.commentPins=void 0,this.viewportOverlay=void 0,this.selectionOverlay=void 0,this.drawingOverlay=void 0,this.clientConfigKey="",this.followingUserId=null,this.drawModeActive=!1,this.connectionState="disconnected",this.showConnectedFlash=!1,this._wasDisconnected=!1,this._connectedFlashTimer&&(clearTimeout(this._connectedFlashTimer),this._connectedFlashTimer=null)}handlePanelClose(){this.activePanel=null,this.highlightThreadId=null}handleToolbarAction(e){var s,n,r,a;const t=e.detail;if(!this.settings.enabled&&t!=="settings")return;const i=t==="comments"||t==="settings"||t==="notifications"||t==="activity";switch((i||t==="pin-mode")&&this.drawModeActive&&(this.drawModeActive=!1,(s=this.drawingOverlay)==null||s.disableDrawMode()),(i||t==="draw-mode")&&this.pinModeActive&&(this.pinModeActive=!1,(n=this.commentPins)==null||n.exitPinMode()),(t==="pin-mode"||t==="draw-mode")&&(this.activePanel=null),t){case"comments":this.activePanel=this.activePanel==="comments"?null:"comments",this.highlightThreadId=null;break;case"settings":this.activePanel=this.activePanel==="settings"?null:"settings";break;case"notifications":this.activePanel=this.activePanel==="notifications"?null:"notifications";break;case"activity":this.activePanel=this.activePanel==="activity"?null:"activity";break;case"pin-mode":this.pinModeActive=!this.pinModeActive,this.pinModeActive&&((r=this.commentPins)==null||r.enterPinMode());break;case"draw-mode":if(!this.envConfig.allowDrawing)break;this.drawModeActive=!this.drawModeActive,this.drawModeActive&&((a=this.drawingOverlay)==null||a.enableDrawMode());break}}handleFollow(e){const t=e.detail;this.followingUserId===t?this.followingUserId=null:this.followingUserId=t}handleSettingsChange(e){const t=e.detail;this.settings=t,$s(this.room,t),this.applySettings(t)}applySettings(e){var t,i,s,n,r,a,l,d,c,h,u,f,b,x,y,v,$;if(!e.enabled){(t=this.cursorOverlay)==null||t.disable(),(i=this.viewportOverlay)==null||i.disable(),(s=this.selectionOverlay)==null||s.disable(),(n=this.drawingOverlay)==null||n.disable(),this.drawModeActive&&((r=this.drawingOverlay)==null||r.disableDrawMode(),this.drawModeActive=!1),(a=this.client)==null||a.setAppearOffline(!0),(l=this.commentPins)==null||l.setVisible(!1),this.followingUserId=null,this.pinModeActive&&((d=this.commentPins)==null||d.exitPinMode(),this.pinModeActive=!1),this.activePanel=this.activePanel==="settings"?"settings":null,this.highlightThreadId=null;return}this.applyCursorSettings(e),(c=this.client)==null||c.setAppearOffline(e.appearOffline),(h=this.commentPins)==null||h.setVisible(e.showCommentPins),e.showViewportIndicators?(u=this.viewportOverlay)==null||u.enable():(f=this.viewportOverlay)==null||f.disable(),e.showSelections?(b=this.selectionOverlay)==null||b.enable():(x=this.selectionOverlay)==null||x.disable(),e.showDrawings?(y=this.drawingOverlay)==null||y.enable():((v=this.drawingOverlay)==null||v.disable(),this.drawModeActive&&(($=this.drawingOverlay)==null||$.disableDrawMode(),this.drawModeActive=!1))}applyCursorSettings(e){if(!this.cursorOverlay)return;e.showMyCursor||e.showOthersCursors?(this.cursorOverlay.enable(),this.cursorOverlay.setSending(e.showMyCursor),this.cursorOverlay.setReceiving(e.showOthersCursors)):this.cursorOverlay.disable()}updated(e){(e.has("room")||e.has("token")||e.has("apiKey")||e.has("endpoint"))&&this.apiKey&&this.token&&this.room&&this.getConfigKey()!==this.clientConfigKey&&(this.teardownClient(),this.initClient(),this.activePanel=null,this.highlightThreadId=null,this.pinModeActive=!1),(e.has("activePanel")||e.has("collapsed"))&&requestAnimationFrame(()=>this.positionPopups())}positionPopups(){var x,y,v,$;const e=this.display==="inline",t=(x=this.shadowRoot)==null?void 0:x.querySelector(".inline-trigger"),i=(y=this.shadowRoot)==null?void 0:y.querySelector("pulse-widget-toolbar"),s=e?t:i;if(!s)return;const n=s.getBoundingClientRect(),r=window.innerWidth,a=window.innerHeight,l=8,d=(v=this.shadowRoot)==null?void 0:v.querySelector(".toolbar-popover");if(d){Object.assign(d.style,{top:"auto",left:"auto"});const P=d.getBoundingClientRect(),O=this.computePosition(n,P,r,a,l);d.style.top=`${O.top}px`,d.style.left=`${O.left}px`}const c=($=this.shadowRoot)==null?void 0:$.querySelector(".panel-container");if(!c)return;Object.assign(c.style,{top:"auto",left:"auto"});const h=d??i;if(!h)return;const u=h.getBoundingClientRect(),f=c.getBoundingClientRect(),b=this.computePosition(u,f,r,a,l);c.style.top=`${b.top}px`,c.style.left=`${b.left}px`}computePosition(e,t,i,s,n){const r=e.top,a=s-e.bottom;let l;r>=t.height+n?l=e.top-t.height-n:a>=t.height+n?l=e.bottom+n:l=r>=a?Math.max(n,e.top-t.height-n):e.bottom+n;let d;const c=e.right-t.width;return c>=n?d=c:e.left+t.width+n<=i?d=e.left:d=Math.max(n,Math.min(i-t.width-n,e.left)),l=Math.max(n,Math.min(s-t.height-n,l)),d=Math.max(n,Math.min(i-t.width-n,d)),{top:l,left:d}}getFollowUserName(){var t;if(!this.followingUserId)return"";const e=(t=this.client)==null?void 0:t.state.presence.find(i=>i.user.id===this.followingUserId);return(e==null?void 0:e.user.name)??"user"}renderConnectionBanner(){return this.showConnectedFlash?p`<div class="connection-banner connected">
2865
2880
  <span class="connection-dot"></span>Connected
2866
- </div>`:this.connectionState==="connecting"?u`<div class="connection-banner connecting">
2881
+ </div>`:this.connectionState==="connecting"?p`<div class="connection-banner connecting">
2867
2882
  <span class="connection-dot"></span>Reconnecting...
2868
- </div>`:this.connectionState==="disconnected"&&this.client?u`<div class="connection-banner disconnected">
2883
+ </div>`:this.connectionState==="disconnected"&&this.client?p`<div class="connection-banner disconnected">
2869
2884
  <span class="connection-dot"></span>Disconnected
2870
- </div>`:v}handleToolbarToggle(){this.collapsed=!this.collapsed,this.collapsed&&(this.activePanel=null,this.highlightThreadId=null)}render(){const e=this.display==="inline";if(e&&this.collapsed)return u`
2885
+ </div>`:g}handleToolbarToggle(){this.collapsed=!this.collapsed,this.collapsed&&(this.activePanel=null,this.highlightThreadId=null)}render(){const e=this.display==="inline";if(e&&this.collapsed)return p`
2871
2886
  <div class="widget-root">
2872
2887
  <div class="inline-trigger" @click=${this.handleToolbarToggle}>
2873
2888
  <slot>Collaborate</slot>
2874
2889
  </div>
2875
2890
  </div>
2876
- `;const t=this.activePanel?u`
2891
+ `;const t=this.activePanel?p`
2877
2892
  <div class="panel-container anchored" @panel-close=${this.handlePanelClose}>
2878
- ${this.activePanel==="comments"?u`<pulse-widget-comments-panel
2893
+ ${this.activePanel==="comments"?p`<pulse-widget-comments-panel
2879
2894
  .client=${this.client}
2880
2895
  .highlightThreadId=${this.highlightThreadId}
2881
- ></pulse-widget-comments-panel>`:v}
2882
- ${this.activePanel==="settings"?u`<pulse-widget-settings-panel
2896
+ ></pulse-widget-comments-panel>`:g}
2897
+ ${this.activePanel==="settings"?p`<pulse-widget-settings-panel
2883
2898
  .settings=${this.settings}
2884
2899
  .roomId=${this.room}
2885
2900
  @settings-change=${this.handleSettingsChange}
2886
- ></pulse-widget-settings-panel>`:v}
2887
- ${this.activePanel==="notifications"?u`<pulse-widget-notifications-panel
2901
+ ></pulse-widget-settings-panel>`:g}
2902
+ ${this.activePanel==="notifications"?p`<pulse-widget-notifications-panel
2888
2903
  .client=${this.client}
2889
- ></pulse-widget-notifications-panel>`:v}
2890
- ${this.activePanel==="activity"?u`<pulse-widget-activity-panel
2904
+ ></pulse-widget-notifications-panel>`:g}
2905
+ ${this.activePanel==="activity"?p`<pulse-widget-activity-panel
2891
2906
  .client=${this.client}
2892
- ></pulse-widget-activity-panel>`:v}
2907
+ ></pulse-widget-activity-panel>`:g}
2893
2908
  </div>
2894
- `:v,i=this.followingUserId?u`<div class="follow-banner">
2909
+ `:g,i=this.followingUserId?p`<div class="follow-banner">
2895
2910
  Following ${this.getFollowUserName()}
2896
2911
  <button @click=${()=>{this.followingUserId=null}}>Stop</button>
2897
- </div>`:v;return e?u`
2912
+ </div>`:g;return e?p`
2898
2913
  ${i}
2899
2914
  <div class="widget-root">
2900
2915
  <div class="inline-trigger" @click=${this.handleToolbarToggle}>
@@ -2919,7 +2934,7 @@
2919
2934
  </div>
2920
2935
  ${t}
2921
2936
  </div>
2922
- `:u`
2937
+ `:p`
2923
2938
  ${i}
2924
2939
  <div class="widget-root">
2925
2940
  ${t}
@@ -3113,4 +3128,4 @@
3113
3128
  from { opacity: 1; }
3114
3129
  to { opacity: 0; }
3115
3130
  }
3116
- `];T([x({attribute:"api-key"})],exports.PulseWidget.prototype,"apiKey",2);T([x()],exports.PulseWidget.prototype,"token",2);T([x()],exports.PulseWidget.prototype,"room",2);T([x()],exports.PulseWidget.prototype,"endpoint",2);T([x({reflect:!0})],exports.PulseWidget.prototype,"position",2);T([x({reflect:!0})],exports.PulseWidget.prototype,"display",2);T([$()],exports.PulseWidget.prototype,"collapsed",2);T([$()],exports.PulseWidget.prototype,"activePanel",2);T([$()],exports.PulseWidget.prototype,"pinModeActive",2);T([$()],exports.PulseWidget.prototype,"highlightThreadId",2);T([$()],exports.PulseWidget.prototype,"settings",2);T([$()],exports.PulseWidget.prototype,"followingUserId",2);T([$()],exports.PulseWidget.prototype,"drawModeActive",2);T([$()],exports.PulseWidget.prototype,"connectionState",2);T([$()],exports.PulseWidget.prototype,"showConnectedFlash",2);T([$()],exports.PulseWidget.prototype,"envConfig",2);exports.PulseWidget=T([L("pulse-widget")],exports.PulseWidget);
3131
+ `];S([w({attribute:"api-key"})],exports.PulseWidget.prototype,"apiKey",2);S([w()],exports.PulseWidget.prototype,"token",2);S([w()],exports.PulseWidget.prototype,"room",2);S([w()],exports.PulseWidget.prototype,"endpoint",2);S([w({reflect:!0})],exports.PulseWidget.prototype,"position",2);S([w({reflect:!0})],exports.PulseWidget.prototype,"display",2);S([k()],exports.PulseWidget.prototype,"collapsed",2);S([k()],exports.PulseWidget.prototype,"activePanel",2);S([k()],exports.PulseWidget.prototype,"pinModeActive",2);S([k()],exports.PulseWidget.prototype,"highlightThreadId",2);S([k()],exports.PulseWidget.prototype,"settings",2);S([k()],exports.PulseWidget.prototype,"followingUserId",2);S([k()],exports.PulseWidget.prototype,"drawModeActive",2);S([k()],exports.PulseWidget.prototype,"connectionState",2);S([k()],exports.PulseWidget.prototype,"showConnectedFlash",2);S([k()],exports.PulseWidget.prototype,"envConfig",2);exports.PulseWidget=S([L("pulse-widget")],exports.PulseWidget);