@gamention/pulse-elements 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +160 -0
- package/dist/pulse-elements.cjs +2851 -0
- package/dist/pulse-elements.js +6509 -0
- package/package.json +47 -0
|
@@ -0,0 +1,2851 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2021 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
5
|
+
*/let rt=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
|
+
* @license
|
|
7
|
+
* Copyright 2021 Google LLC
|
|
8
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
9
|
+
*//**
|
|
10
|
+
* @license
|
|
11
|
+
* Copyright 2021 Google LLC
|
|
12
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
13
|
+
*/let Re=class{constructor(e,t,i,s){if(this.subscribe=!1,this.provided=!1,this.value=void 0,this.t=(r,o)=>{this.unsubscribe&&(this.unsubscribe!==o&&(this.provided=!1,this.unsubscribe()),this.subscribe||this.unsubscribe()),this.value=r,this.host.requestUpdate(),this.provided&&!this.subscribe||(this.provided=!0,this.callback&&this.callback(r,o)),this.unsubscribe=o},this.host=e,t.context!==void 0){const r=t;this.context=r.context,this.callback=r.callback,this.subscribe=r.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 rt(this.context,this.host,this.t,this.subscribe))}};/**
|
|
14
|
+
* @license
|
|
15
|
+
* Copyright 2021 Google LLC
|
|
16
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
17
|
+
*/let vt=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
|
+
* @license
|
|
19
|
+
* Copyright 2021 Google LLC
|
|
20
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
21
|
+
*/let xt=class extends Event{constructor(e,t){super("context-provider",{bubbles:!0,composed:!0}),this.context=e,this.contextTarget=t}},ze=class extends vt{constructor(e,t,i){var s,r;super(t.context!==void 0?t.initialValue:i),this.onContextRequest=o=>{if(o.context!==this.context)return;const l=o.contextTarget??o.composedPath()[0];l!==this.host&&(o.stopPropagation(),this.addCallback(o.callback,l,o.subscribe))},this.onProviderRequest=o=>{if(o.context!==this.context||(o.contextTarget??o.composedPath()[0])===this.host)return;const l=new Set;for(const[a,{consumerHost:c}]of this.subscriptions)l.has(a)||(l.add(a),c.dispatchEvent(new rt(this.context,c,a,!0)));o.stopPropagation()},this.host=e,t.context!==void 0?this.context=t.context:this.context=t,this.attachListeners(),(r=(s=this.host).addController)==null||r.call(s,this)}attachListeners(){this.host.addEventListener("context-request",this.onContextRequest),this.host.addEventListener("context-provider",this.onProviderRequest)}hostConnected(){this.host.dispatchEvent(new xt(this.context,this.host))}};/**
|
|
22
|
+
* @license
|
|
23
|
+
* Copyright 2017 Google LLC
|
|
24
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
25
|
+
*/function yt({context:n}){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 ze(this,{context:n,initialValue:s})),s}};{e.constructor.addInitializer((o=>{i.set(o,new ze(o,{context:n}))}));const s=Object.getOwnPropertyDescriptor(e,t);let r;if(s===void 0){const o=new WeakMap;r={get(){return o.get(this)},set(l){i.get(this).setValue(l),o.set(this,l)},configurable:!0,enumerable:!0}}else{const o=s.set;r={...s,set(l){i.get(this).setValue(l),o==null||o.call(this,l)}}}return void Object.defineProperty(e,t,r)}}}/**
|
|
26
|
+
* @license
|
|
27
|
+
* Copyright 2022 Google LLC
|
|
28
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
29
|
+
*/function ne({context:n,subscribe:e}){return(t,i)=>{typeof i=="object"?i.addInitializer((function(){new Re(this,{context:n,callback:s=>{t.set.call(this,s)},subscribe:e})})):t.constructor.addInitializer((s=>{new Re(s,{context:n,callback:r=>{s[i]=r},subscribe:e})}))}}var wt=Object.defineProperty,$t=(n,e,t)=>e in n?wt(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,x=(n,e,t)=>$t(n,typeof e!="symbol"?e+"":e,t);const kt="ws://localhost:4567";let _e=class{constructor(){x(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()}},Ct=class extends _e{constructor(e){super(),x(this,"ws",null),x(this,"endpoint"),x(this,"reconnectAttempt",0),x(this,"reconnectTimer",null),x(this,"_state","disconnected"),this.endpoint=e??kt}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(1e3*2**this.reconnectAttempt,3e4);this.reconnectAttempt++,this.reconnectTimer=setTimeout(()=>{this.reconnectTimer=null,this.connect()},e)}},Pt=class extends _e{constructor(){super(...arguments),x(this,"_user",null),x(this,"_users",new Map),x(this,"_presence",new Map),x(this,"_threads",new Map),x(this,"_reactions",new Map),x(this,"_notifications",[]),x(this,"_activityLogs",[]),x(this,"_typing",new Map),x(this,"_viewports",new Map),x(this,"_selections",new Map)}get user(){return this._user}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}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[r,o]of t)i-o<3e3&&s.push(r);return s}get viewports(){return this._viewports}getViewport(e){return this._viewports.get(e)}get selections(){return this._selections}handleMessage(e){switch(e.type){case"auth:ok":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,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,e.thread),this.emit("threads",this.threads);break;case"comment:created":{const t=this._threads.get(e.threadId);t&&(t.comments.push(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]=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._users.clear(),this._presence.clear(),this._threads.clear(),this._reactions.clear(),this._notifications=[],this._activityLogs=[],this._typing.clear(),this._viewports.clear(),this._selections.clear()}},at=class extends _e{constructor(e){var t;super(),x(this,"state"),x(this,"connection"),x(this,"config"),x(this,"heartbeatTimer",null),x(this,"lastCursorSend",0),x(this,"pendingCursor",null),x(this,"cursorTimer",null),this.config=e,this.state=new Pt;const i=((t=e.endpoint)==null?void 0:t.replace(/^http/,"ws"))??void 0;this.connection=new Ct(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>=50?this.flushCursor():this.cursorTimer||(this.cursorTimer=setTimeout(()=>{this.cursorTimer=null,this.flushCursor()},50))}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"})},3e4)}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}),i}reply(e,t,i=[]){const s=crypto.randomUUID();return this.send({type:"comment:create",threadId:e,id:s,body:t,mentions:i}),s}editComment(e,t,i=[]){this.send({type:"comment:edit",commentId:e,body:t,mentions:i})}deleteComment(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.send({type:"notification:read",notificationId:e})}markAllRead(){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,i=new FormData;i.append("file",e);const s=await fetch(`${t}/api/v1/upload`,{method:"POST",headers:{Authorization:`Bearer ${this.config.apiKey}`},body:i});if(!s.ok){const r=await s.json().catch(()=>({error:"Upload failed"}));throw new Error(r.error??"Upload failed")}return s.json()}setAppearOffline(e){e?(this.stopHeartbeat(),this.send({type:"presence:update",status:"idle"})):(this.startHeartbeat(),this.send({type:"presence:update",status:"online"}))}};/**
|
|
30
|
+
* @license
|
|
31
|
+
* Copyright 2019 Google LLC
|
|
32
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
33
|
+
*/const de=globalThis,Ee=de.ShadowRoot&&(de.ShadyCSS===void 0||de.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,Te=Symbol(),De=new WeakMap;let lt=class{constructor(e,t,i){if(this._$cssResult$=!0,i!==Te)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(Ee&&e===void 0){const i=t!==void 0&&t.length===1;i&&(e=De.get(t)),e===void 0&&((this.o=e=new CSSStyleSheet).replaceSync(this.cssText),i&&De.set(t,e))}return e}toString(){return this.cssText}};const _t=n=>new lt(typeof n=="string"?n:n+"",void 0,Te),S=(n,...e)=>{const t=n.length===1?n[0]:e.reduce((i,s,r)=>i+(o=>{if(o._$cssResult$===!0)return o.cssText;if(typeof o=="number")return o;throw Error("Value passed to 'css' function must be a 'css' function result: "+o+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(s)+n[r+1],n[0]);return new lt(t,n,Te)},Et=(n,e)=>{if(Ee)n.adoptedStyleSheets=e.map(t=>t instanceof CSSStyleSheet?t:t.styleSheet);else for(const t of e){const i=document.createElement("style"),s=de.litNonce;s!==void 0&&i.setAttribute("nonce",s),i.textContent=t.cssText,n.appendChild(i)}},Ue=Ee?n=>n:n=>n instanceof CSSStyleSheet?(e=>{let t="";for(const i of e.cssRules)t+=i.cssText;return _t(t)})(n):n;/**
|
|
34
|
+
* @license
|
|
35
|
+
* Copyright 2017 Google LLC
|
|
36
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
37
|
+
*/const{is:Tt,defineProperty:St,getOwnPropertyDescriptor:At,getOwnPropertyNames:Mt,getOwnPropertySymbols:Ot,getPrototypeOf:It}=Object,z=globalThis,He=z.trustedTypes,jt=He?He.emptyScript:"",xe=z.reactiveElementPolyfillSupport,J=(n,e)=>n,ue={toAttribute(n,e){switch(e){case Boolean:n=n?jt:null;break;case Object:case Array:n=n==null?n:JSON.stringify(n)}return n},fromAttribute(n,e){let t=n;switch(e){case Boolean:t=n!==null;break;case Number:t=n===null?null:Number(n);break;case Object:case Array:try{t=JSON.parse(n)}catch{t=null}}return t}},Se=(n,e)=>!Tt(n,e),Ne={attribute:!0,type:String,converter:ue,reflect:!1,useDefault:!1,hasChanged:Se};Symbol.metadata??(Symbol.metadata=Symbol("metadata")),z.litPropertyMetadata??(z.litPropertyMetadata=new WeakMap);let W=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=Ne){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&&St(this.prototype,e,s)}}static getPropertyDescriptor(e,t,i){const{get:s,set:r}=At(this.prototype,e)??{get(){return this[t]},set(o){this[t]=o}};return{get:s,set(o){const l=s==null?void 0:s.call(this);r==null||r.call(this,o),this.requestUpdate(e,l,i)},configurable:!0,enumerable:!0}}static getPropertyOptions(e){return this.elementProperties.get(e)??Ne}static _$Ei(){if(this.hasOwnProperty(J("elementProperties")))return;const e=It(this);e.finalize(),e.l!==void 0&&(this.l=[...e.l]),this.elementProperties=new Map(e.elementProperties)}static finalize(){if(this.hasOwnProperty(J("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(J("properties"))){const t=this.properties,i=[...Mt(t),...Ot(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(Ue(s))}else e!==void 0&&t.push(Ue(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 Et(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 r;const i=this.constructor.elementProperties.get(e),s=this.constructor._$Eu(e,i);if(s!==void 0&&i.reflect===!0){const o=(((r=i.converter)==null?void 0:r.toAttribute)!==void 0?i.converter:ue).toAttribute(t,i.type);this._$Em=e,o==null?this.removeAttribute(s):this.setAttribute(s,o),this._$Em=null}}_$AK(e,t){var r,o;const i=this.constructor,s=i._$Eh.get(e);if(s!==void 0&&this._$Em!==s){const l=i.getPropertyOptions(s),a=typeof l.converter=="function"?{fromAttribute:l.converter}:((r=l.converter)==null?void 0:r.fromAttribute)!==void 0?l.converter:ue;this._$Em=s;const c=a.fromAttribute(t,l.type);this[s]=c??((o=this._$Ej)==null?void 0:o.get(s))??c,this._$Em=null}}requestUpdate(e,t,i,s=!1,r){var o;if(e!==void 0){const l=this.constructor;if(s===!1&&(r=this[e]),i??(i=l.getPropertyOptions(e)),!((i.hasChanged??Se)(r,t)||i.useDefault&&i.reflect&&r===((o=this._$Ej)==null?void 0:o.get(e))&&!this.hasAttribute(l._$Eu(e,i))))return;this.C(e,t,i)}this.isUpdatePending===!1&&(this._$ES=this._$EP())}C(e,t,{useDefault:i,reflect:s,wrapped:r},o){i&&!(this._$Ej??(this._$Ej=new Map)).has(e)&&(this._$Ej.set(e,o??t??this[e]),r!==!0||o!==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[r,o]of this._$Ep)this[r]=o;this._$Ep=void 0}const s=this.constructor.elementProperties;if(s.size>0)for(const[r,o]of s){const{wrapped:l}=o,a=this[r];l!==!0||this._$AL.has(r)||a===void 0||this.C(r,void 0,o,a)}}let e=!1;const t=this._$AL;try{e=this.shouldUpdate(t),e?(this.willUpdate(t),(i=this._$EO)==null||i.forEach(s=>{var r;return(r=s.hostUpdate)==null?void 0:r.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){}};W.elementStyles=[],W.shadowRootOptions={mode:"open"},W[J("elementProperties")]=new Map,W[J("finalized")]=new Map,xe==null||xe({ReactiveElement:W}),(z.reactiveElementVersions??(z.reactiveElementVersions=[])).push("2.1.2");/**
|
|
38
|
+
* @license
|
|
39
|
+
* Copyright 2017 Google LLC
|
|
40
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
41
|
+
*/const Z=globalThis,Be=n=>n,fe=Z.trustedTypes,Fe=fe?fe.createPolicy("lit-html",{createHTML:n=>n}):void 0,ct="$lit$",R=`lit$${Math.random().toFixed(9).slice(2)}$`,dt="?"+R,Lt=`<${dt}>`,N=document,Q=()=>N.createComment(""),ee=n=>n===null||typeof n!="object"&&typeof n!="function",Ae=Array.isArray,Rt=n=>Ae(n)||typeof(n==null?void 0:n[Symbol.iterator])=="function",ye=`[
|
|
42
|
+
\f\r]`,G=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,We=/-->/g,qe=/>/g,D=RegExp(`>|${ye}(?:([^\\s"'>=/]+)(${ye}*=${ye}*(?:[^
|
|
43
|
+
\f\r"'\`<>=]|("|')|))|$)`,"g"),Ve=/'/g,Ye=/"/g,pt=/^(?:script|style|textarea|title)$/i,ht=n=>(e,...t)=>({_$litType$:n,strings:e,values:t}),d=ht(1),zt=ht(2),B=Symbol.for("lit-noChange"),u=Symbol.for("lit-nothing"),Xe=new WeakMap,U=N.createTreeWalker(N,129);function ut(n,e){if(!Ae(n)||!n.hasOwnProperty("raw"))throw Error("invalid template strings array");return Fe!==void 0?Fe.createHTML(e):e}const Dt=(n,e)=>{const t=n.length-1,i=[];let s,r=e===2?"<svg>":e===3?"<math>":"",o=G;for(let l=0;l<t;l++){const a=n[l];let c,p,h=-1,f=0;for(;f<a.length&&(o.lastIndex=f,p=o.exec(a),p!==null);)f=o.lastIndex,o===G?p[1]==="!--"?o=We:p[1]!==void 0?o=qe:p[2]!==void 0?(pt.test(p[2])&&(s=RegExp("</"+p[2],"g")),o=D):p[3]!==void 0&&(o=D):o===D?p[0]===">"?(o=s??G,h=-1):p[1]===void 0?h=-2:(h=o.lastIndex-p[2].length,c=p[1],o=p[3]===void 0?D:p[3]==='"'?Ye:Ve):o===Ye||o===Ve?o=D:o===We||o===qe?o=G:(o=D,s=void 0);const g=o===D&&n[l+1].startsWith("/>")?" ":"";r+=o===G?a+Lt:h>=0?(i.push(c),a.slice(0,h)+ct+a.slice(h)+R+g):a+R+(h===-2?l:g)}return[ut(n,r+(n[t]||"<?>")+(e===2?"</svg>":e===3?"</math>":"")),i]};class te{constructor({strings:e,_$litType$:t},i){let s;this.parts=[];let r=0,o=0;const l=e.length-1,a=this.parts,[c,p]=Dt(e,t);if(this.el=te.createElement(c,i),U.currentNode=this.el.content,t===2||t===3){const h=this.el.content.firstChild;h.replaceWith(...h.childNodes)}for(;(s=U.nextNode())!==null&&a.length<l;){if(s.nodeType===1){if(s.hasAttributes())for(const h of s.getAttributeNames())if(h.endsWith(ct)){const f=p[o++],g=s.getAttribute(h).split(R),$=/([.?@])?(.*)/.exec(f);a.push({type:1,index:r,name:$[2],strings:g,ctor:$[1]==="."?Ht:$[1]==="?"?Nt:$[1]==="@"?Bt:ge}),s.removeAttribute(h)}else h.startsWith(R)&&(a.push({type:6,index:r}),s.removeAttribute(h));if(pt.test(s.tagName)){const h=s.textContent.split(R),f=h.length-1;if(f>0){s.textContent=fe?fe.emptyScript:"";for(let g=0;g<f;g++)s.append(h[g],Q()),U.nextNode(),a.push({type:2,index:++r});s.append(h[f],Q())}}}else if(s.nodeType===8)if(s.data===dt)a.push({type:2,index:r});else{let h=-1;for(;(h=s.data.indexOf(R,h+1))!==-1;)a.push({type:7,index:r}),h+=R.length-1}r++}}static createElement(e,t){const i=N.createElement("template");return i.innerHTML=e,i}}function q(n,e,t=n,i){var o,l;if(e===B)return e;let s=i!==void 0?(o=t._$Co)==null?void 0:o[i]:t._$Cl;const r=ee(e)?void 0:e._$litDirective$;return(s==null?void 0:s.constructor)!==r&&((l=s==null?void 0:s._$AO)==null||l.call(s,!1),r===void 0?s=void 0:(s=new r(n),s._$AT(n,t,i)),i!==void 0?(t._$Co??(t._$Co=[]))[i]=s:t._$Cl=s),s!==void 0&&(e=q(n,s._$AS(n,e.values),s,i)),e}class Ut{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)??N).importNode(t,!0);U.currentNode=s;let r=U.nextNode(),o=0,l=0,a=i[0];for(;a!==void 0;){if(o===a.index){let c;a.type===2?c=new oe(r,r.nextSibling,this,e):a.type===1?c=new a.ctor(r,a.name,a.strings,this,e):a.type===6&&(c=new Ft(r,this,e)),this._$AV.push(c),a=i[++l]}o!==(a==null?void 0:a.index)&&(r=U.nextNode(),o++)}return U.currentNode=N,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 oe{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=u,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=q(this,e,t),ee(e)?e===u||e==null||e===""?(this._$AH!==u&&this._$AR(),this._$AH=u):e!==this._$AH&&e!==B&&this._(e):e._$litType$!==void 0?this.$(e):e.nodeType!==void 0?this.T(e):Rt(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!==u&&ee(this._$AH)?this._$AA.nextSibling.data=e:this.T(N.createTextNode(e)),this._$AH=e}$(e){var r;const{values:t,_$litType$:i}=e,s=typeof i=="number"?this._$AC(e):(i.el===void 0&&(i.el=te.createElement(ut(i.h,i.h[0]),this.options)),i);if(((r=this._$AH)==null?void 0:r._$AD)===s)this._$AH.p(t);else{const o=new Ut(s,this),l=o.u(this.options);o.p(t),this.T(l),this._$AH=o}}_$AC(e){let t=Xe.get(e.strings);return t===void 0&&Xe.set(e.strings,t=new te(e)),t}k(e){Ae(this._$AH)||(this._$AH=[],this._$AR());const t=this._$AH;let i,s=0;for(const r of e)s===t.length?t.push(i=new oe(this.O(Q()),this.O(Q()),this,this.options)):i=t[s],i._$AI(r),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=Be(e).nextSibling;Be(e).remove(),e=s}}setConnected(e){var t;this._$AM===void 0&&(this._$Cv=e,(t=this._$AP)==null||t.call(this,e))}}class ge{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(e,t,i,s,r){this.type=1,this._$AH=u,this._$AN=void 0,this.element=e,this.name=t,this._$AM=s,this.options=r,i.length>2||i[0]!==""||i[1]!==""?(this._$AH=Array(i.length-1).fill(new String),this.strings=i):this._$AH=u}_$AI(e,t=this,i,s){const r=this.strings;let o=!1;if(r===void 0)e=q(this,e,t,0),o=!ee(e)||e!==this._$AH&&e!==B,o&&(this._$AH=e);else{const l=e;let a,c;for(e=r[0],a=0;a<r.length-1;a++)c=q(this,l[i+a],t,a),c===B&&(c=this._$AH[a]),o||(o=!ee(c)||c!==this._$AH[a]),c===u?e=u:e!==u&&(e+=(c??"")+r[a+1]),this._$AH[a]=c}o&&!s&&this.j(e)}j(e){e===u?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,e??"")}}class Ht extends ge{constructor(){super(...arguments),this.type=3}j(e){this.element[this.name]=e===u?void 0:e}}class Nt extends ge{constructor(){super(...arguments),this.type=4}j(e){this.element.toggleAttribute(this.name,!!e&&e!==u)}}class Bt extends ge{constructor(e,t,i,s,r){super(e,t,i,s,r),this.type=5}_$AI(e,t=this){if((e=q(this,e,t,0)??u)===B)return;const i=this._$AH,s=e===u&&i!==u||e.capture!==i.capture||e.once!==i.once||e.passive!==i.passive,r=e!==u&&(i===u||s);s&&this.element.removeEventListener(this.name,this,i),r&&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 Ft{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){q(this,e)}}const we=Z.litHtmlPolyfillSupport;we==null||we(te,oe),(Z.litHtmlVersions??(Z.litHtmlVersions=[])).push("3.3.2");const Wt=(n,e,t)=>{const i=(t==null?void 0:t.renderBefore)??e;let s=i._$litPart$;if(s===void 0){const r=(t==null?void 0:t.renderBefore)??null;i._$litPart$=s=new oe(e.insertBefore(Q(),r),r,void 0,t??{})}return s._$AI(n),s};/**
|
|
44
|
+
* @license
|
|
45
|
+
* Copyright 2017 Google LLC
|
|
46
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
47
|
+
*/const H=globalThis;let P=class extends W{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=Wt(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 B}};var ot;P._$litElement$=!0,P.finalized=!0,(ot=H.litElementHydrateSupport)==null||ot.call(H,{LitElement:P});const $e=H.litElementPolyfillSupport;$e==null||$e({LitElement:P});(H.litElementVersions??(H.litElementVersions=[])).push("4.2.2");/**
|
|
48
|
+
* @license
|
|
49
|
+
* Copyright 2017 Google LLC
|
|
50
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
51
|
+
*/const I=n=>(e,t)=>{t!==void 0?t.addInitializer(()=>{customElements.define(n,e)}):customElements.define(n,e)};/**
|
|
52
|
+
* @license
|
|
53
|
+
* Copyright 2017 Google LLC
|
|
54
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
55
|
+
*/const qt={attribute:!0,type:String,converter:ue,reflect:!1,hasChanged:Se},Vt=(n=qt,e,t)=>{const{kind:i,metadata:s}=t;let r=globalThis.litPropertyMetadata.get(s);if(r===void 0&&globalThis.litPropertyMetadata.set(s,r=new Map),i==="setter"&&((n=Object.create(n)).wrapped=!0),r.set(t.name,n),i==="accessor"){const{name:o}=t;return{set(l){const a=e.get.call(this);e.set.call(this,l),this.requestUpdate(o,a,n,!0,l)},init(l){return l!==void 0&&this.C(o,void 0,n,l),l}}}if(i==="setter"){const{name:o}=t;return function(l){const a=this[o];e.call(this,l),this.requestUpdate(o,a,n,!0,l)}}throw Error("Unsupported decorator location: "+i)};function m(n){return(e,t)=>typeof t=="object"?Vt(n,e,t):((i,s,r)=>{const o=s.hasOwnProperty(r);return s.constructor.createProperty(r,i),o?Object.getOwnPropertyDescriptor(s,r):void 0})(n,e,t)}/**
|
|
56
|
+
* @license
|
|
57
|
+
* Copyright 2017 Google LLC
|
|
58
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
59
|
+
*/function b(n){return m({...n,state:!0,attribute:!1})}const V="pulse-client";var Yt=Object.defineProperty,Xt=Object.getOwnPropertyDescriptor,Y=(n,e,t,i)=>{for(var s=i>1?void 0:i?Xt(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&Yt(e,t,s),s};exports.PulseProvider=class extends P{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 at(e),this.client.connect()}disconnectedCallback(){var e;super.disconnectedCallback(),(e=this.client)==null||e.disconnect()}render(){return d`<slot></slot>`}};Y([m({attribute:"api-key"})],exports.PulseProvider.prototype,"apiKey",2);Y([m()],exports.PulseProvider.prototype,"token",2);Y([m()],exports.PulseProvider.prototype,"room",2);Y([m()],exports.PulseProvider.prototype,"endpoint",2);Y([yt({context:V})],exports.PulseProvider.prototype,"client",2);exports.PulseProvider=Y([I("pulse-provider")],exports.PulseProvider);var Kt=Object.defineProperty,Gt=Object.getOwnPropertyDescriptor,be=(n,e,t,i)=>{for(var s=i>1?void 0:i?Gt(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&Kt(e,t,s),s};exports.PulsePresence=class extends P{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 d`
|
|
60
|
+
<div class="avatars">
|
|
61
|
+
${t>0?d`<div class="overflow">+${t}</div>`:null}
|
|
62
|
+
${e.map(i=>d`
|
|
63
|
+
<div
|
|
64
|
+
class="avatar"
|
|
65
|
+
style="background:${i.user.color}"
|
|
66
|
+
>
|
|
67
|
+
${i.user.avatar?d`<img src="${i.user.avatar}" alt="${i.user.name}" />`:this.getInitials(i.user.name)}
|
|
68
|
+
<span class="status-ring ${i.status}"></span>
|
|
69
|
+
<span class="tooltip">${i.user.name}</span>
|
|
70
|
+
</div>
|
|
71
|
+
`)}
|
|
72
|
+
</div>
|
|
73
|
+
`}};exports.PulsePresence.styles=S`
|
|
74
|
+
:host {
|
|
75
|
+
display: inline-flex;
|
|
76
|
+
align-items: center;
|
|
77
|
+
gap: 6px;
|
|
78
|
+
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
|
|
79
|
+
"Helvetica Neue", sans-serif;
|
|
80
|
+
}
|
|
81
|
+
.avatars {
|
|
82
|
+
display: flex;
|
|
83
|
+
flex-direction: row-reverse;
|
|
84
|
+
}
|
|
85
|
+
.avatar {
|
|
86
|
+
width: 34px;
|
|
87
|
+
height: 34px;
|
|
88
|
+
border-radius: 50%;
|
|
89
|
+
border: 2.5px solid var(--pulse-bg, #fff);
|
|
90
|
+
margin-left: -10px;
|
|
91
|
+
display: flex;
|
|
92
|
+
align-items: center;
|
|
93
|
+
justify-content: center;
|
|
94
|
+
font-size: 12px;
|
|
95
|
+
font-weight: 700;
|
|
96
|
+
letter-spacing: 0.02em;
|
|
97
|
+
color: #fff;
|
|
98
|
+
overflow: hidden;
|
|
99
|
+
position: relative;
|
|
100
|
+
cursor: default;
|
|
101
|
+
transition: transform 0.15s ease, box-shadow 0.15s ease;
|
|
102
|
+
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
|
|
103
|
+
}
|
|
104
|
+
.avatar:hover {
|
|
105
|
+
transform: translateY(-2px) scale(1.08);
|
|
106
|
+
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
|
|
107
|
+
z-index: 2;
|
|
108
|
+
}
|
|
109
|
+
.avatar:last-child {
|
|
110
|
+
margin-left: 0;
|
|
111
|
+
}
|
|
112
|
+
.avatar img {
|
|
113
|
+
width: 100%;
|
|
114
|
+
height: 100%;
|
|
115
|
+
object-fit: cover;
|
|
116
|
+
}
|
|
117
|
+
.status-ring {
|
|
118
|
+
position: absolute;
|
|
119
|
+
bottom: -1px;
|
|
120
|
+
right: -1px;
|
|
121
|
+
width: 10px;
|
|
122
|
+
height: 10px;
|
|
123
|
+
border-radius: 50%;
|
|
124
|
+
border: 2px solid var(--pulse-bg, #fff);
|
|
125
|
+
}
|
|
126
|
+
.status-ring.online {
|
|
127
|
+
background: #22c55e;
|
|
128
|
+
}
|
|
129
|
+
.status-ring.idle {
|
|
130
|
+
background: #eab308;
|
|
131
|
+
}
|
|
132
|
+
.overflow {
|
|
133
|
+
width: 34px;
|
|
134
|
+
height: 34px;
|
|
135
|
+
border-radius: 50%;
|
|
136
|
+
border: 2.5px solid var(--pulse-bg, #fff);
|
|
137
|
+
margin-left: -10px;
|
|
138
|
+
display: flex;
|
|
139
|
+
align-items: center;
|
|
140
|
+
justify-content: center;
|
|
141
|
+
font-size: 11px;
|
|
142
|
+
font-weight: 700;
|
|
143
|
+
color: #64748b;
|
|
144
|
+
background: #e2e8f0;
|
|
145
|
+
cursor: default;
|
|
146
|
+
}
|
|
147
|
+
.tooltip {
|
|
148
|
+
position: absolute;
|
|
149
|
+
bottom: calc(100% + 8px);
|
|
150
|
+
left: 50%;
|
|
151
|
+
transform: translateX(-50%);
|
|
152
|
+
padding: 4px 10px;
|
|
153
|
+
background: #0f172a;
|
|
154
|
+
color: #fff;
|
|
155
|
+
font-size: 11px;
|
|
156
|
+
font-weight: 500;
|
|
157
|
+
border-radius: 6px;
|
|
158
|
+
white-space: nowrap;
|
|
159
|
+
pointer-events: none;
|
|
160
|
+
opacity: 0;
|
|
161
|
+
transition: opacity 0.15s ease;
|
|
162
|
+
z-index: 10;
|
|
163
|
+
}
|
|
164
|
+
.tooltip::after {
|
|
165
|
+
content: "";
|
|
166
|
+
position: absolute;
|
|
167
|
+
top: 100%;
|
|
168
|
+
left: 50%;
|
|
169
|
+
transform: translateX(-50%);
|
|
170
|
+
border: 4px solid transparent;
|
|
171
|
+
border-top-color: #0f172a;
|
|
172
|
+
}
|
|
173
|
+
.avatar:hover .tooltip {
|
|
174
|
+
opacity: 1;
|
|
175
|
+
}
|
|
176
|
+
`;be([ne({context:V,subscribe:!0}),m({attribute:!1})],exports.PulsePresence.prototype,"client",2);be([m({type:Number,attribute:"max-visible"})],exports.PulsePresence.prototype,"maxVisible",2);be([b()],exports.PulsePresence.prototype,"users",2);exports.PulsePresence=be([I("pulse-presence")],exports.PulsePresence);var Jt=Object.defineProperty,Zt=Object.getOwnPropertyDescriptor,Me=(n,e,t,i)=>{for(var s=i>1?void 0:i?Zt(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&Jt(e,t,s),s};exports.PulseCursors=class extends P{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(r=>r.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 d`
|
|
177
|
+
${e.map(t=>d`
|
|
178
|
+
<div
|
|
179
|
+
class="cursor"
|
|
180
|
+
style="transform:translate(${t.position.x}px,${t.position.y}px)"
|
|
181
|
+
>
|
|
182
|
+
<svg viewBox="0 0 16 16" fill="${t.color}">
|
|
183
|
+
<path
|
|
184
|
+
d="M0 0l6.5 16L8 9l7-2.5z"
|
|
185
|
+
stroke="#fff"
|
|
186
|
+
stroke-width="0.8"
|
|
187
|
+
/>
|
|
188
|
+
</svg>
|
|
189
|
+
<span class="cursor-label" style="background:${t.color}">
|
|
190
|
+
${t.name}
|
|
191
|
+
</span>
|
|
192
|
+
</div>
|
|
193
|
+
`)}
|
|
194
|
+
`}};exports.PulseCursors.styles=S`
|
|
195
|
+
:host {
|
|
196
|
+
position: fixed;
|
|
197
|
+
top: 0;
|
|
198
|
+
left: 0;
|
|
199
|
+
width: 100%;
|
|
200
|
+
height: 100%;
|
|
201
|
+
pointer-events: none;
|
|
202
|
+
z-index: 9999;
|
|
203
|
+
overflow: hidden;
|
|
204
|
+
}
|
|
205
|
+
.cursor {
|
|
206
|
+
position: absolute;
|
|
207
|
+
transition: transform 60ms cubic-bezier(0.22, 1, 0.36, 1);
|
|
208
|
+
will-change: transform;
|
|
209
|
+
}
|
|
210
|
+
.cursor svg {
|
|
211
|
+
width: 18px;
|
|
212
|
+
height: 18px;
|
|
213
|
+
filter: drop-shadow(0 1px 3px rgba(0, 0, 0, 0.3));
|
|
214
|
+
}
|
|
215
|
+
.cursor-label {
|
|
216
|
+
position: absolute;
|
|
217
|
+
left: 18px;
|
|
218
|
+
top: 16px;
|
|
219
|
+
padding: 3px 8px;
|
|
220
|
+
border-radius: 6px;
|
|
221
|
+
font-size: 11px;
|
|
222
|
+
font-weight: 600;
|
|
223
|
+
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
|
|
224
|
+
color: #fff;
|
|
225
|
+
white-space: nowrap;
|
|
226
|
+
pointer-events: none;
|
|
227
|
+
letter-spacing: 0.01em;
|
|
228
|
+
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
|
|
229
|
+
}
|
|
230
|
+
`;Me([ne({context:V,subscribe:!0}),m({attribute:!1})],exports.PulseCursors.prototype,"client",2);Me([b()],exports.PulseCursors.prototype,"cursors",2);exports.PulseCursors=Me([I("pulse-cursors")],exports.PulseCursors);var Qt=Object.defineProperty,ei=Object.getOwnPropertyDescriptor,re=(n,e,t,i)=>{for(var s=i>1?void 0:i?ei(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&Qt(e,t,s),s};exports.PulseComments=class extends P{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("@")?d`<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 r=[...s.matchAll(/@(\w+)/g)].map(o=>o[1]);this.client.createThread(s,{mentions:r}),i.value=""}handleReply(e,t){t.preventDefault();const s=t.target.querySelector("input"),r=s.value.trim();if(!r)return;const o=[...r.matchAll(/@(\w+)/g)].map(l=>l[1]);this.client.reply(e,r,o),s.value="",this.replyingTo=null}render(){const e=this.showResolved?this.threads:this.threads.filter(t=>!t.resolved);return d`
|
|
231
|
+
<div class="threads">
|
|
232
|
+
${e.length===0?d`<div class="empty">
|
|
233
|
+
<div class="empty-icon">💬</div>
|
|
234
|
+
No comments yet.<br>Start a conversation below.
|
|
235
|
+
</div>`:e.map(t=>this.renderThread(t))}
|
|
236
|
+
</div>
|
|
237
|
+
<div class="new-thread">
|
|
238
|
+
<form @submit=${this.handleNewThread}>
|
|
239
|
+
<textarea placeholder="Write a comment... Use @name to mention"></textarea>
|
|
240
|
+
<button type="submit">Comment</button>
|
|
241
|
+
</form>
|
|
242
|
+
</div>
|
|
243
|
+
`}renderThread(e){return d`
|
|
244
|
+
<div class="thread ${e.resolved?"resolved":""}">
|
|
245
|
+
${e.comments.map((t,i)=>{const s=this.getUserForComment(t.userId);return d`
|
|
246
|
+
${i>0?d`<div class="divider"></div>`:u}
|
|
247
|
+
<div class="comment">
|
|
248
|
+
<div class="comment-header">
|
|
249
|
+
<div
|
|
250
|
+
class="comment-avatar"
|
|
251
|
+
style="background:${(s==null?void 0:s.color)??"#94a3b8"}"
|
|
252
|
+
>
|
|
253
|
+
${s?this.getInitials(s.name):"?"}
|
|
254
|
+
</div>
|
|
255
|
+
<div class="comment-meta">
|
|
256
|
+
<span class="comment-author">${(s==null?void 0:s.name)??"Unknown"}</span>
|
|
257
|
+
<span class="comment-time">${this.formatTime(t.createdAt)}</span>
|
|
258
|
+
</div>
|
|
259
|
+
</div>
|
|
260
|
+
<div class="comment-body">
|
|
261
|
+
${this.parseMentions(t.body)}
|
|
262
|
+
</div>
|
|
263
|
+
</div>
|
|
264
|
+
`})}
|
|
265
|
+
<div class="thread-actions">
|
|
266
|
+
<button
|
|
267
|
+
@click=${()=>this.replyingTo=this.replyingTo===e.id?null:e.id}
|
|
268
|
+
>
|
|
269
|
+
Reply
|
|
270
|
+
</button>
|
|
271
|
+
<button
|
|
272
|
+
@click=${()=>this.client.resolveThread(e.id,!e.resolved)}
|
|
273
|
+
>
|
|
274
|
+
${e.resolved?"Reopen":"Resolve"}
|
|
275
|
+
</button>
|
|
276
|
+
</div>
|
|
277
|
+
${this.replyingTo===e.id?d`
|
|
278
|
+
<form class="reply-form" @submit=${t=>this.handleReply(e.id,t)}>
|
|
279
|
+
<input type="text" placeholder="Write a reply..." />
|
|
280
|
+
<button type="submit">Send</button>
|
|
281
|
+
</form>
|
|
282
|
+
`:u}
|
|
283
|
+
</div>
|
|
284
|
+
`}formatTime(e){const t=new Date(e),s=new Date().getTime()-t.getTime(),r=Math.floor(s/6e4);if(r<1)return"just now";if(r<60)return`${r}m ago`;const o=Math.floor(r/60);return o<24?`${o}h ago`:t.toLocaleDateString()}};exports.PulseComments.styles=S`
|
|
285
|
+
:host {
|
|
286
|
+
display: block;
|
|
287
|
+
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
|
|
288
|
+
"Helvetica Neue", sans-serif;
|
|
289
|
+
--accent: #6366f1;
|
|
290
|
+
--accent-hover: #4f46e5;
|
|
291
|
+
--accent-light: #eef2ff;
|
|
292
|
+
--border: #e2e8f0;
|
|
293
|
+
--border-light: #f1f5f9;
|
|
294
|
+
--text: #0f172a;
|
|
295
|
+
--text-secondary: #64748b;
|
|
296
|
+
--text-muted: #94a3b8;
|
|
297
|
+
--surface: #ffffff;
|
|
298
|
+
--surface-hover: #f8fafc;
|
|
299
|
+
}
|
|
300
|
+
.threads {
|
|
301
|
+
display: flex;
|
|
302
|
+
flex-direction: column;
|
|
303
|
+
gap: 2px;
|
|
304
|
+
padding: 8px;
|
|
305
|
+
}
|
|
306
|
+
.thread {
|
|
307
|
+
border-radius: 12px;
|
|
308
|
+
padding: 14px 16px;
|
|
309
|
+
background: var(--surface);
|
|
310
|
+
transition: background 0.15s ease;
|
|
311
|
+
}
|
|
312
|
+
.thread:hover {
|
|
313
|
+
background: var(--surface-hover);
|
|
314
|
+
}
|
|
315
|
+
.thread.resolved {
|
|
316
|
+
opacity: 0.5;
|
|
317
|
+
}
|
|
318
|
+
.comment {
|
|
319
|
+
margin-bottom: 12px;
|
|
320
|
+
}
|
|
321
|
+
.comment:last-child {
|
|
322
|
+
margin-bottom: 0;
|
|
323
|
+
}
|
|
324
|
+
.comment-header {
|
|
325
|
+
display: flex;
|
|
326
|
+
align-items: center;
|
|
327
|
+
gap: 8px;
|
|
328
|
+
margin-bottom: 4px;
|
|
329
|
+
}
|
|
330
|
+
.comment-avatar {
|
|
331
|
+
width: 28px;
|
|
332
|
+
height: 28px;
|
|
333
|
+
border-radius: 50%;
|
|
334
|
+
display: flex;
|
|
335
|
+
align-items: center;
|
|
336
|
+
justify-content: center;
|
|
337
|
+
font-size: 10px;
|
|
338
|
+
font-weight: 700;
|
|
339
|
+
color: #fff;
|
|
340
|
+
flex-shrink: 0;
|
|
341
|
+
}
|
|
342
|
+
.comment-meta {
|
|
343
|
+
display: flex;
|
|
344
|
+
align-items: baseline;
|
|
345
|
+
gap: 6px;
|
|
346
|
+
}
|
|
347
|
+
.comment-author {
|
|
348
|
+
font-weight: 600;
|
|
349
|
+
font-size: 13px;
|
|
350
|
+
color: var(--text);
|
|
351
|
+
}
|
|
352
|
+
.comment-time {
|
|
353
|
+
font-size: 11px;
|
|
354
|
+
color: var(--text-muted);
|
|
355
|
+
}
|
|
356
|
+
.comment-body {
|
|
357
|
+
font-size: 14px;
|
|
358
|
+
color: var(--text-secondary);
|
|
359
|
+
line-height: 1.5;
|
|
360
|
+
margin-left: 36px;
|
|
361
|
+
word-wrap: break-word;
|
|
362
|
+
}
|
|
363
|
+
.mention {
|
|
364
|
+
color: var(--accent);
|
|
365
|
+
font-weight: 600;
|
|
366
|
+
background: var(--accent-light);
|
|
367
|
+
padding: 0 3px;
|
|
368
|
+
border-radius: 3px;
|
|
369
|
+
}
|
|
370
|
+
.divider {
|
|
371
|
+
height: 1px;
|
|
372
|
+
background: var(--border-light);
|
|
373
|
+
margin: 8px 0 8px 36px;
|
|
374
|
+
}
|
|
375
|
+
.thread-actions {
|
|
376
|
+
display: flex;
|
|
377
|
+
gap: 4px;
|
|
378
|
+
margin-top: 8px;
|
|
379
|
+
margin-left: 36px;
|
|
380
|
+
}
|
|
381
|
+
.thread-actions button {
|
|
382
|
+
border: none;
|
|
383
|
+
background: none;
|
|
384
|
+
cursor: pointer;
|
|
385
|
+
font-size: 12px;
|
|
386
|
+
font-weight: 500;
|
|
387
|
+
color: var(--text-muted);
|
|
388
|
+
padding: 4px 10px;
|
|
389
|
+
border-radius: 6px;
|
|
390
|
+
transition: all 0.15s ease;
|
|
391
|
+
}
|
|
392
|
+
.thread-actions button:hover {
|
|
393
|
+
background: var(--accent-light);
|
|
394
|
+
color: var(--accent);
|
|
395
|
+
}
|
|
396
|
+
.reply-form {
|
|
397
|
+
display: flex;
|
|
398
|
+
gap: 8px;
|
|
399
|
+
margin-top: 10px;
|
|
400
|
+
margin-left: 36px;
|
|
401
|
+
}
|
|
402
|
+
.reply-form input {
|
|
403
|
+
flex: 1;
|
|
404
|
+
padding: 8px 12px;
|
|
405
|
+
border: 1.5px solid var(--border);
|
|
406
|
+
border-radius: 8px;
|
|
407
|
+
font-size: 13px;
|
|
408
|
+
font-family: inherit;
|
|
409
|
+
outline: none;
|
|
410
|
+
transition: border-color 0.15s ease, box-shadow 0.15s ease;
|
|
411
|
+
background: var(--surface);
|
|
412
|
+
color: var(--text);
|
|
413
|
+
}
|
|
414
|
+
.reply-form input:focus {
|
|
415
|
+
border-color: var(--accent);
|
|
416
|
+
box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
|
|
417
|
+
}
|
|
418
|
+
.reply-form input::placeholder {
|
|
419
|
+
color: var(--text-muted);
|
|
420
|
+
}
|
|
421
|
+
.reply-form button {
|
|
422
|
+
padding: 8px 16px;
|
|
423
|
+
background: var(--accent);
|
|
424
|
+
color: #fff;
|
|
425
|
+
border: none;
|
|
426
|
+
border-radius: 8px;
|
|
427
|
+
cursor: pointer;
|
|
428
|
+
font-size: 13px;
|
|
429
|
+
font-weight: 600;
|
|
430
|
+
font-family: inherit;
|
|
431
|
+
transition: background 0.15s ease, transform 0.1s ease;
|
|
432
|
+
}
|
|
433
|
+
.reply-form button:hover {
|
|
434
|
+
background: var(--accent-hover);
|
|
435
|
+
}
|
|
436
|
+
.reply-form button:active {
|
|
437
|
+
transform: scale(0.97);
|
|
438
|
+
}
|
|
439
|
+
.new-thread {
|
|
440
|
+
padding: 12px 16px;
|
|
441
|
+
border-top: 1px solid var(--border-light);
|
|
442
|
+
}
|
|
443
|
+
.new-thread textarea {
|
|
444
|
+
width: 100%;
|
|
445
|
+
padding: 10px 12px;
|
|
446
|
+
border: 1.5px solid var(--border);
|
|
447
|
+
border-radius: 10px;
|
|
448
|
+
font-size: 14px;
|
|
449
|
+
font-family: inherit;
|
|
450
|
+
resize: vertical;
|
|
451
|
+
min-height: 72px;
|
|
452
|
+
outline: none;
|
|
453
|
+
box-sizing: border-box;
|
|
454
|
+
transition: border-color 0.15s ease, box-shadow 0.15s ease;
|
|
455
|
+
background: var(--surface);
|
|
456
|
+
color: var(--text);
|
|
457
|
+
}
|
|
458
|
+
.new-thread textarea:focus {
|
|
459
|
+
border-color: var(--accent);
|
|
460
|
+
box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
|
|
461
|
+
}
|
|
462
|
+
.new-thread textarea::placeholder {
|
|
463
|
+
color: var(--text-muted);
|
|
464
|
+
}
|
|
465
|
+
.new-thread button {
|
|
466
|
+
margin-top: 8px;
|
|
467
|
+
padding: 8px 20px;
|
|
468
|
+
background: var(--accent);
|
|
469
|
+
color: #fff;
|
|
470
|
+
border: none;
|
|
471
|
+
border-radius: 8px;
|
|
472
|
+
cursor: pointer;
|
|
473
|
+
font-size: 13px;
|
|
474
|
+
font-weight: 600;
|
|
475
|
+
font-family: inherit;
|
|
476
|
+
transition: background 0.15s ease, transform 0.1s ease;
|
|
477
|
+
}
|
|
478
|
+
.new-thread button:hover {
|
|
479
|
+
background: var(--accent-hover);
|
|
480
|
+
}
|
|
481
|
+
.new-thread button:active {
|
|
482
|
+
transform: scale(0.97);
|
|
483
|
+
}
|
|
484
|
+
.empty {
|
|
485
|
+
text-align: center;
|
|
486
|
+
padding: 40px 24px;
|
|
487
|
+
color: var(--text-muted);
|
|
488
|
+
font-size: 14px;
|
|
489
|
+
}
|
|
490
|
+
.empty-icon {
|
|
491
|
+
font-size: 32px;
|
|
492
|
+
margin-bottom: 8px;
|
|
493
|
+
opacity: 0.4;
|
|
494
|
+
}
|
|
495
|
+
`;re([ne({context:V,subscribe:!0}),m({attribute:!1})],exports.PulseComments.prototype,"client",2);re([m({type:Boolean,attribute:"show-resolved"})],exports.PulseComments.prototype,"showResolved",2);re([b()],exports.PulseComments.prototype,"threads",2);re([b()],exports.PulseComments.prototype,"replyingTo",2);exports.PulseComments=re([I("pulse-comments")],exports.PulseComments);var ti=Object.defineProperty,ii=Object.getOwnPropertyDescriptor,Oe=(n,e,t,i)=>{for(var s=i>1?void 0:i?ii(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&ti(e,t,s),s};const si={"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"},ni={"comment:created":"💬","comment:mention":"📣","comment:reply":"↩️","thread:resolved":"✅","reaction:added":"🎉"};exports.PulseNotifications=class extends P{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(),r=Math.floor(s/6e4);if(r<1)return"just now";if(r<60)return`${r}m ago`;const o=Math.floor(r/60);return o<24?`${o}h ago`:t.toLocaleDateString()}render(){const e=this.notifications.filter(t=>!t.read).length;return d`
|
|
496
|
+
<div class="header">
|
|
497
|
+
<span class="title">
|
|
498
|
+
Notifications
|
|
499
|
+
${e>0?d`<span class="badge">${e}</span>`:u}
|
|
500
|
+
</span>
|
|
501
|
+
${e>0?d`<button class="mark-all" @click=${()=>this.client.markAllRead()}>
|
|
502
|
+
Mark all read
|
|
503
|
+
</button>`:u}
|
|
504
|
+
</div>
|
|
505
|
+
<div class="list">
|
|
506
|
+
${this.notifications.length===0?d`<div class="empty">
|
|
507
|
+
<div class="empty-icon">🔔</div>
|
|
508
|
+
No notifications yet
|
|
509
|
+
</div>`:this.notifications.map(t=>d`
|
|
510
|
+
<div
|
|
511
|
+
class="item ${t.read?"":"unread"}"
|
|
512
|
+
@click=${()=>this.handleClick(t)}
|
|
513
|
+
>
|
|
514
|
+
<span class="icon">${ni[t.type]??"🔔"}</span>
|
|
515
|
+
<div class="content">
|
|
516
|
+
<div class="text">
|
|
517
|
+
<span class="actor">${this.getActorName(t.actorId)}</span>
|
|
518
|
+
${si[t.type]??t.type}
|
|
519
|
+
</div>
|
|
520
|
+
<div class="time">${this.formatTime(t.createdAt)}</div>
|
|
521
|
+
</div>
|
|
522
|
+
<span class="unread-dot ${t.read?"read":""}"></span>
|
|
523
|
+
</div>
|
|
524
|
+
`)}
|
|
525
|
+
</div>
|
|
526
|
+
`}};exports.PulseNotifications.styles=S`
|
|
527
|
+
:host {
|
|
528
|
+
display: block;
|
|
529
|
+
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
|
|
530
|
+
"Helvetica Neue", sans-serif;
|
|
531
|
+
--accent: #6366f1;
|
|
532
|
+
--accent-light: #eef2ff;
|
|
533
|
+
--border: #e2e8f0;
|
|
534
|
+
--text: #0f172a;
|
|
535
|
+
--text-secondary: #64748b;
|
|
536
|
+
--text-muted: #94a3b8;
|
|
537
|
+
--surface: #ffffff;
|
|
538
|
+
}
|
|
539
|
+
.header {
|
|
540
|
+
display: flex;
|
|
541
|
+
justify-content: space-between;
|
|
542
|
+
align-items: center;
|
|
543
|
+
padding: 16px 20px;
|
|
544
|
+
border-bottom: 1px solid var(--border);
|
|
545
|
+
}
|
|
546
|
+
.title {
|
|
547
|
+
display: flex;
|
|
548
|
+
align-items: center;
|
|
549
|
+
gap: 8px;
|
|
550
|
+
font-size: 15px;
|
|
551
|
+
font-weight: 700;
|
|
552
|
+
color: var(--text);
|
|
553
|
+
}
|
|
554
|
+
.badge {
|
|
555
|
+
background: #ef4444;
|
|
556
|
+
color: #fff;
|
|
557
|
+
font-size: 10px;
|
|
558
|
+
font-weight: 700;
|
|
559
|
+
padding: 2px 7px;
|
|
560
|
+
border-radius: 10px;
|
|
561
|
+
min-width: 18px;
|
|
562
|
+
text-align: center;
|
|
563
|
+
line-height: 1.4;
|
|
564
|
+
}
|
|
565
|
+
.mark-all {
|
|
566
|
+
border: none;
|
|
567
|
+
background: none;
|
|
568
|
+
color: var(--accent);
|
|
569
|
+
cursor: pointer;
|
|
570
|
+
font-size: 12px;
|
|
571
|
+
font-weight: 600;
|
|
572
|
+
padding: 4px 10px;
|
|
573
|
+
border-radius: 6px;
|
|
574
|
+
font-family: inherit;
|
|
575
|
+
transition: background 0.15s ease;
|
|
576
|
+
}
|
|
577
|
+
.mark-all:hover {
|
|
578
|
+
background: var(--accent-light);
|
|
579
|
+
}
|
|
580
|
+
.list {
|
|
581
|
+
max-height: 400px;
|
|
582
|
+
overflow-y: auto;
|
|
583
|
+
}
|
|
584
|
+
.list::-webkit-scrollbar {
|
|
585
|
+
width: 4px;
|
|
586
|
+
}
|
|
587
|
+
.list::-webkit-scrollbar-thumb {
|
|
588
|
+
background: #cbd5e1;
|
|
589
|
+
border-radius: 2px;
|
|
590
|
+
}
|
|
591
|
+
.item {
|
|
592
|
+
display: flex;
|
|
593
|
+
align-items: flex-start;
|
|
594
|
+
gap: 12px;
|
|
595
|
+
padding: 14px 20px;
|
|
596
|
+
cursor: pointer;
|
|
597
|
+
transition: background 0.15s ease;
|
|
598
|
+
border-bottom: 1px solid #f8fafc;
|
|
599
|
+
}
|
|
600
|
+
.item:last-child {
|
|
601
|
+
border-bottom: none;
|
|
602
|
+
}
|
|
603
|
+
.item:hover {
|
|
604
|
+
background: #f8fafc;
|
|
605
|
+
}
|
|
606
|
+
.item.unread {
|
|
607
|
+
background: var(--accent-light);
|
|
608
|
+
}
|
|
609
|
+
.item.unread:hover {
|
|
610
|
+
background: #e0e7ff;
|
|
611
|
+
}
|
|
612
|
+
.icon {
|
|
613
|
+
width: 32px;
|
|
614
|
+
height: 32px;
|
|
615
|
+
border-radius: 8px;
|
|
616
|
+
background: #f1f5f9;
|
|
617
|
+
display: flex;
|
|
618
|
+
align-items: center;
|
|
619
|
+
justify-content: center;
|
|
620
|
+
font-size: 14px;
|
|
621
|
+
flex-shrink: 0;
|
|
622
|
+
}
|
|
623
|
+
.item.unread .icon {
|
|
624
|
+
background: #c7d2fe;
|
|
625
|
+
}
|
|
626
|
+
.content {
|
|
627
|
+
flex: 1;
|
|
628
|
+
min-width: 0;
|
|
629
|
+
}
|
|
630
|
+
.text {
|
|
631
|
+
font-size: 13px;
|
|
632
|
+
color: var(--text-secondary);
|
|
633
|
+
line-height: 1.4;
|
|
634
|
+
}
|
|
635
|
+
.actor {
|
|
636
|
+
font-weight: 600;
|
|
637
|
+
color: var(--text);
|
|
638
|
+
}
|
|
639
|
+
.time {
|
|
640
|
+
font-size: 11px;
|
|
641
|
+
color: var(--text-muted);
|
|
642
|
+
margin-top: 3px;
|
|
643
|
+
}
|
|
644
|
+
.unread-dot {
|
|
645
|
+
width: 6px;
|
|
646
|
+
height: 6px;
|
|
647
|
+
border-radius: 50%;
|
|
648
|
+
background: var(--accent);
|
|
649
|
+
flex-shrink: 0;
|
|
650
|
+
margin-top: 6px;
|
|
651
|
+
}
|
|
652
|
+
.unread-dot.read {
|
|
653
|
+
visibility: hidden;
|
|
654
|
+
}
|
|
655
|
+
.empty {
|
|
656
|
+
text-align: center;
|
|
657
|
+
padding: 40px 24px;
|
|
658
|
+
color: var(--text-muted);
|
|
659
|
+
font-size: 14px;
|
|
660
|
+
}
|
|
661
|
+
.empty-icon {
|
|
662
|
+
font-size: 28px;
|
|
663
|
+
margin-bottom: 8px;
|
|
664
|
+
opacity: 0.4;
|
|
665
|
+
}
|
|
666
|
+
`;Oe([ne({context:V,subscribe:!0}),m({attribute:!1})],exports.PulseNotifications.prototype,"client",2);Oe([b()],exports.PulseNotifications.prototype,"notifications",2);exports.PulseNotifications=Oe([I("pulse-notifications")],exports.PulseNotifications);var oi=Object.defineProperty,ri=Object.getOwnPropertyDescriptor,X=(n,e,t,i)=>{for(var s=i>1?void 0:i?ri(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&oi(e,t,s),s};const ai=["👍","👎","❤️","🎉","👀","🚀"];exports.PulseReactions=class extends P{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 r of this.reactions){const o=e.get(r.emoji)??{count:0,userReactionId:null};o.count++,r.userId===t&&(o.userReactionId=r.id),e.set(r.emoji,o)}return[...e.entries()].map(([r,o])=>({emoji:r,...o}))}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 d`
|
|
667
|
+
${e.map(t=>d`
|
|
668
|
+
<button
|
|
669
|
+
class="reaction ${t.userReactionId?"active":""}"
|
|
670
|
+
@click=${()=>this.toggleReaction(t)}
|
|
671
|
+
>
|
|
672
|
+
<span class="emoji">${t.emoji}</span>
|
|
673
|
+
<span class="count">${t.count}</span>
|
|
674
|
+
</button>
|
|
675
|
+
`)}
|
|
676
|
+
<div class="picker-wrap">
|
|
677
|
+
<button
|
|
678
|
+
class="add-btn"
|
|
679
|
+
@click=${()=>this.showPicker=!this.showPicker}
|
|
680
|
+
>
|
|
681
|
+
+
|
|
682
|
+
</button>
|
|
683
|
+
${this.showPicker?d`
|
|
684
|
+
<div class="picker">
|
|
685
|
+
${ai.map(t=>d`
|
|
686
|
+
<button @click=${()=>this.addEmoji(t)}>
|
|
687
|
+
${t}
|
|
688
|
+
</button>
|
|
689
|
+
`)}
|
|
690
|
+
</div>
|
|
691
|
+
`:u}
|
|
692
|
+
</div>
|
|
693
|
+
`}};exports.PulseReactions.styles=S`
|
|
694
|
+
:host {
|
|
695
|
+
display: inline-flex;
|
|
696
|
+
align-items: center;
|
|
697
|
+
gap: 6px;
|
|
698
|
+
flex-wrap: wrap;
|
|
699
|
+
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
|
|
700
|
+
}
|
|
701
|
+
.reaction {
|
|
702
|
+
display: inline-flex;
|
|
703
|
+
align-items: center;
|
|
704
|
+
gap: 4px;
|
|
705
|
+
padding: 4px 10px;
|
|
706
|
+
border: 1.5px solid #e2e8f0;
|
|
707
|
+
border-radius: 20px;
|
|
708
|
+
cursor: pointer;
|
|
709
|
+
font-size: 13px;
|
|
710
|
+
background: #fff;
|
|
711
|
+
transition: all 0.15s ease;
|
|
712
|
+
user-select: none;
|
|
713
|
+
}
|
|
714
|
+
.reaction:hover {
|
|
715
|
+
background: #f8fafc;
|
|
716
|
+
border-color: #cbd5e1;
|
|
717
|
+
transform: translateY(-1px);
|
|
718
|
+
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.06);
|
|
719
|
+
}
|
|
720
|
+
.reaction.active {
|
|
721
|
+
border-color: #a5b4fc;
|
|
722
|
+
background: #eef2ff;
|
|
723
|
+
}
|
|
724
|
+
.reaction.active:hover {
|
|
725
|
+
border-color: #818cf8;
|
|
726
|
+
background: #e0e7ff;
|
|
727
|
+
}
|
|
728
|
+
.reaction .emoji {
|
|
729
|
+
font-size: 16px;
|
|
730
|
+
line-height: 1;
|
|
731
|
+
}
|
|
732
|
+
.reaction .count {
|
|
733
|
+
font-size: 12px;
|
|
734
|
+
color: #64748b;
|
|
735
|
+
font-weight: 600;
|
|
736
|
+
min-width: 8px;
|
|
737
|
+
text-align: center;
|
|
738
|
+
}
|
|
739
|
+
.reaction.active .count {
|
|
740
|
+
color: #6366f1;
|
|
741
|
+
}
|
|
742
|
+
.add-btn {
|
|
743
|
+
display: inline-flex;
|
|
744
|
+
align-items: center;
|
|
745
|
+
justify-content: center;
|
|
746
|
+
width: 32px;
|
|
747
|
+
height: 32px;
|
|
748
|
+
border: 1.5px dashed #cbd5e1;
|
|
749
|
+
border-radius: 50%;
|
|
750
|
+
cursor: pointer;
|
|
751
|
+
font-size: 16px;
|
|
752
|
+
background: none;
|
|
753
|
+
color: #94a3b8;
|
|
754
|
+
transition: all 0.15s ease;
|
|
755
|
+
line-height: 1;
|
|
756
|
+
}
|
|
757
|
+
.add-btn:hover {
|
|
758
|
+
border-color: #6366f1;
|
|
759
|
+
color: #6366f1;
|
|
760
|
+
background: #eef2ff;
|
|
761
|
+
transform: scale(1.08);
|
|
762
|
+
}
|
|
763
|
+
.picker-wrap {
|
|
764
|
+
position: relative;
|
|
765
|
+
display: inline-flex;
|
|
766
|
+
}
|
|
767
|
+
.picker {
|
|
768
|
+
position: absolute;
|
|
769
|
+
bottom: calc(100% + 8px);
|
|
770
|
+
left: 50%;
|
|
771
|
+
transform: translateX(-50%);
|
|
772
|
+
display: flex;
|
|
773
|
+
gap: 2px;
|
|
774
|
+
padding: 6px 8px;
|
|
775
|
+
background: #fff;
|
|
776
|
+
border: 1px solid #e2e8f0;
|
|
777
|
+
border-radius: 12px;
|
|
778
|
+
box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
|
|
779
|
+
z-index: 100;
|
|
780
|
+
}
|
|
781
|
+
.picker::after {
|
|
782
|
+
content: "";
|
|
783
|
+
position: absolute;
|
|
784
|
+
top: 100%;
|
|
785
|
+
left: 50%;
|
|
786
|
+
transform: translateX(-50%);
|
|
787
|
+
border: 6px solid transparent;
|
|
788
|
+
border-top-color: #fff;
|
|
789
|
+
}
|
|
790
|
+
.picker button {
|
|
791
|
+
border: none;
|
|
792
|
+
background: none;
|
|
793
|
+
cursor: pointer;
|
|
794
|
+
font-size: 20px;
|
|
795
|
+
padding: 4px 6px;
|
|
796
|
+
border-radius: 6px;
|
|
797
|
+
line-height: 1;
|
|
798
|
+
transition: all 0.1s ease;
|
|
799
|
+
}
|
|
800
|
+
.picker button:hover {
|
|
801
|
+
background: #f1f5f9;
|
|
802
|
+
transform: scale(1.2);
|
|
803
|
+
}
|
|
804
|
+
`;X([ne({context:V,subscribe:!0}),m({attribute:!1})],exports.PulseReactions.prototype,"client",2);X([m({attribute:"target-id"})],exports.PulseReactions.prototype,"targetId",2);X([m({attribute:"target-type"})],exports.PulseReactions.prototype,"targetType",2);X([b()],exports.PulseReactions.prototype,"reactions",2);X([b()],exports.PulseReactions.prototype,"showPicker",2);exports.PulseReactions=X([I("pulse-reactions")],exports.PulseReactions);/**
|
|
805
|
+
* @license
|
|
806
|
+
* Copyright 2017 Google LLC
|
|
807
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
808
|
+
*/const li={CHILD:2},ci=n=>(...e)=>({_$litDirective$:n,values:e});class di{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
|
+
* @license
|
|
810
|
+
* Copyright 2017 Google LLC
|
|
811
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
812
|
+
*/class ke extends di{constructor(e){if(super(e),this.it=u,e.type!==li.CHILD)throw Error(this.constructor.directiveName+"() can only be used in child bindings")}render(e){if(e===u||e==null)return this._t=void 0,this.it=e;if(e===B)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:[]}}}ke.directiveName="unsafeHTML",ke.resultType=1;/**
|
|
813
|
+
* @license
|
|
814
|
+
* Copyright 2017 Google LLC
|
|
815
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
816
|
+
*/class Ce extends ke{}Ce.directiveName="unsafeSVG",Ce.resultType=2;const pi=ci(Ce);/**
|
|
817
|
+
* @license lucide v0.577.0 - ISC
|
|
818
|
+
*
|
|
819
|
+
* This source code is licensed under the ISC license.
|
|
820
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
821
|
+
*/const hi=[["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
|
+
* @license lucide v0.577.0 - ISC
|
|
823
|
+
*
|
|
824
|
+
* This source code is licensed under the ISC license.
|
|
825
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
826
|
+
*/const ui=[["circle",{cx:"12",cy:"12",r:"10"}],["path",{d:"M12 6v6l4 2"}]];/**
|
|
827
|
+
* @license lucide v0.577.0 - ISC
|
|
828
|
+
*
|
|
829
|
+
* This source code is licensed under the ISC license.
|
|
830
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
831
|
+
*/const fi=[["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
|
+
* @license lucide v0.577.0 - ISC
|
|
833
|
+
*
|
|
834
|
+
* This source code is licensed under the ISC license.
|
|
835
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
836
|
+
*/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"}]];/**
|
|
837
|
+
* @license lucide v0.577.0 - ISC
|
|
838
|
+
*
|
|
839
|
+
* This source code is licensed under the ISC license.
|
|
840
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
841
|
+
*/const gi=[["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"}]];/**
|
|
842
|
+
* @license lucide v0.577.0 - ISC
|
|
843
|
+
*
|
|
844
|
+
* This source code is licensed under the ISC license.
|
|
845
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
846
|
+
*/const ft=[["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"}]];/**
|
|
847
|
+
* @license lucide v0.577.0 - ISC
|
|
848
|
+
*
|
|
849
|
+
* This source code is licensed under the ISC license.
|
|
850
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
851
|
+
*/const bi=[["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"}]];/**
|
|
852
|
+
* @license lucide v0.577.0 - ISC
|
|
853
|
+
*
|
|
854
|
+
* This source code is licensed under the ISC license.
|
|
855
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
856
|
+
*/const vi=[["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"}]];/**
|
|
857
|
+
* @license lucide v0.577.0 - ISC
|
|
858
|
+
*
|
|
859
|
+
* This source code is licensed under the ISC license.
|
|
860
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
861
|
+
*/const ae=[["path",{d:"M18 6 6 18"}],["path",{d:"m6 6 12 12"}]];/**
|
|
862
|
+
* @license lucide v0.577.0 - ISC
|
|
863
|
+
*
|
|
864
|
+
* This source code is licensed under the ISC license.
|
|
865
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
866
|
+
*/const xi=[["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 yi(n){return n.map(([e,t])=>{const i=Object.entries(t).filter(([,s])=>s!=null).map(([s,r])=>`${s}="${r}"`).join(" ");return`<${e} ${i}/>`}).join("")}function E(n,e=18){return zt`<svg
|
|
867
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
868
|
+
width="${e}"
|
|
869
|
+
height="${e}"
|
|
870
|
+
viewBox="0 0 24 24"
|
|
871
|
+
fill="none"
|
|
872
|
+
stroke="currentColor"
|
|
873
|
+
stroke-width="2"
|
|
874
|
+
stroke-linecap="round"
|
|
875
|
+
stroke-linejoin="round"
|
|
876
|
+
>${pi(yi(n))}</svg>`}const K=S`
|
|
877
|
+
* {
|
|
878
|
+
box-sizing: border-box;
|
|
879
|
+
margin: 0;
|
|
880
|
+
padding: 0;
|
|
881
|
+
}
|
|
882
|
+
|
|
883
|
+
:host {
|
|
884
|
+
/* ── Public CSS custom properties (overridable by SDK users) ── */
|
|
885
|
+
--pulse-primary: #6366f1;
|
|
886
|
+
--pulse-primary-hover: #4f46e5;
|
|
887
|
+
--pulse-bg: #ffffff;
|
|
888
|
+
--pulse-bg-secondary: #f8fafc;
|
|
889
|
+
--pulse-text: #0f172a;
|
|
890
|
+
--pulse-text-secondary: #64748b;
|
|
891
|
+
--pulse-border: #e2e8f0;
|
|
892
|
+
--pulse-radius: 12px;
|
|
893
|
+
--pulse-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
|
|
894
|
+
"Helvetica Neue", sans-serif;
|
|
895
|
+
--pulse-font-size: 14px;
|
|
896
|
+
--pulse-shadow: 0 4px 24px rgba(0, 0, 0, 0.12),
|
|
897
|
+
0 1px 4px rgba(0, 0, 0, 0.08);
|
|
898
|
+
|
|
899
|
+
/* ── Internal variables (derived from public ones) ── */
|
|
900
|
+
font-family: var(--pulse-font);
|
|
901
|
+
font-size: var(--pulse-font-size);
|
|
902
|
+
--pw-accent: var(--pulse-primary);
|
|
903
|
+
--pw-accent-hover: var(--pulse-primary-hover);
|
|
904
|
+
--pw-accent-light: #eef2ff;
|
|
905
|
+
--pw-border: var(--pulse-border);
|
|
906
|
+
--pw-border-light: #f1f5f9;
|
|
907
|
+
--pw-text: var(--pulse-text);
|
|
908
|
+
--pw-text-secondary: var(--pulse-text-secondary);
|
|
909
|
+
--pw-text-muted: #94a3b8;
|
|
910
|
+
--pw-surface: var(--pulse-bg);
|
|
911
|
+
--pw-surface-hover: var(--pulse-bg-secondary);
|
|
912
|
+
--pw-danger: #ef4444;
|
|
913
|
+
--pw-success: #22c55e;
|
|
914
|
+
--pw-warning: #eab308;
|
|
915
|
+
--pw-radius: var(--pulse-radius);
|
|
916
|
+
--pw-shadow: var(--pulse-shadow);
|
|
917
|
+
--pw-shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.16), 0 2px 8px rgba(0, 0, 0, 0.08);
|
|
918
|
+
}
|
|
919
|
+
`,le=S`
|
|
920
|
+
.pw-btn {
|
|
921
|
+
display: inline-flex;
|
|
922
|
+
align-items: center;
|
|
923
|
+
justify-content: center;
|
|
924
|
+
border: none;
|
|
925
|
+
background: none;
|
|
926
|
+
cursor: pointer;
|
|
927
|
+
font-family: inherit;
|
|
928
|
+
transition: all 0.15s ease;
|
|
929
|
+
}
|
|
930
|
+
.pw-btn:active {
|
|
931
|
+
transform: scale(0.95);
|
|
932
|
+
}
|
|
933
|
+
.pw-btn-primary {
|
|
934
|
+
background: var(--pw-accent);
|
|
935
|
+
color: #fff;
|
|
936
|
+
padding: 8px 16px;
|
|
937
|
+
border-radius: 8px;
|
|
938
|
+
font-size: 13px;
|
|
939
|
+
font-weight: 600;
|
|
940
|
+
}
|
|
941
|
+
.pw-btn-primary:hover {
|
|
942
|
+
background: var(--pw-accent-hover);
|
|
943
|
+
}
|
|
944
|
+
.pw-btn-icon {
|
|
945
|
+
width: 36px;
|
|
946
|
+
height: 36px;
|
|
947
|
+
border-radius: 8px;
|
|
948
|
+
color: var(--pw-text-secondary);
|
|
949
|
+
position: relative;
|
|
950
|
+
}
|
|
951
|
+
.pw-btn-icon:hover {
|
|
952
|
+
background: var(--pw-surface-hover);
|
|
953
|
+
color: var(--pw-text);
|
|
954
|
+
}
|
|
955
|
+
.pw-btn-icon.active {
|
|
956
|
+
background: var(--pw-accent-light);
|
|
957
|
+
color: var(--pw-accent);
|
|
958
|
+
}
|
|
959
|
+
.pw-btn-icon svg {
|
|
960
|
+
width: 18px;
|
|
961
|
+
height: 18px;
|
|
962
|
+
}
|
|
963
|
+
`,ve=S`
|
|
964
|
+
.pw-scrollable::-webkit-scrollbar {
|
|
965
|
+
width: 4px;
|
|
966
|
+
}
|
|
967
|
+
.pw-scrollable::-webkit-scrollbar-thumb {
|
|
968
|
+
background: #cbd5e1;
|
|
969
|
+
border-radius: 2px;
|
|
970
|
+
}
|
|
971
|
+
.pw-scrollable::-webkit-scrollbar-track {
|
|
972
|
+
background: transparent;
|
|
973
|
+
}
|
|
974
|
+
`;var wi=Object.defineProperty,$i=Object.getOwnPropertyDescriptor,Ie=(n,e,t,i)=>{for(var s=i>1?void 0:i?$i(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&wi(e,t,s),s};let F=class extends P{constructor(){super(...arguments),this.items=[],this.unsubs=[],this.counter=0}connectedCallback(){super.connectedCallback(),this.setupListeners()}disconnectedCallback(){super.disconnectedCallback(),this.unsubs.forEach(n=>n()),this.unsubs=[]}updated(n){n.has("client")&&this.client&&(this.unsubs.forEach(e=>e()),this.unsubs=[],this.setupListeners())}setupListeners(){if(!this.client)return;const n=this.client.state.activityLogs;n.length>0&&(this.items=n.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(n){return{id:n.id,type:n.type,userId:n.userId,description:n.description,timestamp:new Date(n.createdAt).getTime(),color:F.TYPE_COLORS[n.type]??"#94a3b8"}}getUserName(n){var e;return((e=this.client.state.getUser(n))==null?void 0:e.name)??"Someone"}formatRelativeTime(n){const e=Math.floor((Date.now()-n)/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 d`
|
|
975
|
+
<div class="panel">
|
|
976
|
+
<div class="panel-header">
|
|
977
|
+
<span class="panel-title">Activity</span>
|
|
978
|
+
<button class="close-btn" @click=${this.fireClose} title="Close">
|
|
979
|
+
${E(ae,16)}
|
|
980
|
+
</button>
|
|
981
|
+
</div>
|
|
982
|
+
|
|
983
|
+
<div class="panel-body pw-scrollable">
|
|
984
|
+
${this.items.length===0?d`<div class="empty">No activity yet</div>`:this.items.map(n=>d`
|
|
985
|
+
<div class="activity-item">
|
|
986
|
+
<div
|
|
987
|
+
class="activity-dot"
|
|
988
|
+
style="background:${n.color}"
|
|
989
|
+
></div>
|
|
990
|
+
<div class="activity-content">
|
|
991
|
+
<div class="activity-text">
|
|
992
|
+
${n.userId?d`<span class="activity-user"
|
|
993
|
+
>${this.getUserName(n.userId)}</span
|
|
994
|
+
>
|
|
995
|
+
${n.description}`:n.description}
|
|
996
|
+
</div>
|
|
997
|
+
<div class="activity-time">
|
|
998
|
+
${this.formatRelativeTime(n.timestamp)}
|
|
999
|
+
</div>
|
|
1000
|
+
</div>
|
|
1001
|
+
</div>
|
|
1002
|
+
`)}
|
|
1003
|
+
</div>
|
|
1004
|
+
</div>
|
|
1005
|
+
`}};F.styles=[K,le,ve,S`
|
|
1006
|
+
:host {
|
|
1007
|
+
display: block;
|
|
1008
|
+
}
|
|
1009
|
+
|
|
1010
|
+
.panel {
|
|
1011
|
+
width: 340px;
|
|
1012
|
+
max-height: 480px;
|
|
1013
|
+
background: var(--pw-surface);
|
|
1014
|
+
border-radius: var(--pw-radius);
|
|
1015
|
+
box-shadow: var(--pw-shadow-lg);
|
|
1016
|
+
border: 1px solid var(--pw-border);
|
|
1017
|
+
display: flex;
|
|
1018
|
+
flex-direction: column;
|
|
1019
|
+
overflow: hidden;
|
|
1020
|
+
}
|
|
1021
|
+
|
|
1022
|
+
.panel-header {
|
|
1023
|
+
display: flex;
|
|
1024
|
+
align-items: center;
|
|
1025
|
+
justify-content: space-between;
|
|
1026
|
+
padding: 14px 16px;
|
|
1027
|
+
border-bottom: 1px solid var(--pw-border-light);
|
|
1028
|
+
flex-shrink: 0;
|
|
1029
|
+
}
|
|
1030
|
+
|
|
1031
|
+
.panel-title {
|
|
1032
|
+
font-size: 14px;
|
|
1033
|
+
font-weight: 700;
|
|
1034
|
+
color: var(--pw-text);
|
|
1035
|
+
}
|
|
1036
|
+
|
|
1037
|
+
.close-btn {
|
|
1038
|
+
border: none;
|
|
1039
|
+
background: none;
|
|
1040
|
+
cursor: pointer;
|
|
1041
|
+
color: var(--pw-text-muted);
|
|
1042
|
+
padding: 4px;
|
|
1043
|
+
border-radius: 6px;
|
|
1044
|
+
display: flex;
|
|
1045
|
+
align-items: center;
|
|
1046
|
+
justify-content: center;
|
|
1047
|
+
transition: all 0.15s;
|
|
1048
|
+
}
|
|
1049
|
+
.close-btn:hover {
|
|
1050
|
+
background: var(--pw-surface-hover);
|
|
1051
|
+
color: var(--pw-text);
|
|
1052
|
+
}
|
|
1053
|
+
|
|
1054
|
+
.panel-body {
|
|
1055
|
+
flex: 1;
|
|
1056
|
+
overflow-y: auto;
|
|
1057
|
+
min-height: 0;
|
|
1058
|
+
padding: 8px 0;
|
|
1059
|
+
}
|
|
1060
|
+
|
|
1061
|
+
.activity-item {
|
|
1062
|
+
display: flex;
|
|
1063
|
+
align-items: flex-start;
|
|
1064
|
+
gap: 10px;
|
|
1065
|
+
padding: 8px 16px;
|
|
1066
|
+
transition: background 0.1s;
|
|
1067
|
+
}
|
|
1068
|
+
|
|
1069
|
+
.activity-item:hover {
|
|
1070
|
+
background: var(--pw-surface-hover);
|
|
1071
|
+
}
|
|
1072
|
+
|
|
1073
|
+
.activity-dot {
|
|
1074
|
+
width: 8px;
|
|
1075
|
+
height: 8px;
|
|
1076
|
+
border-radius: 50%;
|
|
1077
|
+
flex-shrink: 0;
|
|
1078
|
+
margin-top: 5px;
|
|
1079
|
+
}
|
|
1080
|
+
|
|
1081
|
+
.activity-content {
|
|
1082
|
+
flex: 1;
|
|
1083
|
+
min-width: 0;
|
|
1084
|
+
}
|
|
1085
|
+
|
|
1086
|
+
.activity-text {
|
|
1087
|
+
font-size: 12px;
|
|
1088
|
+
color: var(--pw-text-secondary);
|
|
1089
|
+
line-height: 1.4;
|
|
1090
|
+
}
|
|
1091
|
+
|
|
1092
|
+
.activity-user {
|
|
1093
|
+
font-weight: 600;
|
|
1094
|
+
color: var(--pw-text);
|
|
1095
|
+
}
|
|
1096
|
+
|
|
1097
|
+
.activity-time {
|
|
1098
|
+
font-size: 10px;
|
|
1099
|
+
color: var(--pw-text-muted);
|
|
1100
|
+
margin-top: 1px;
|
|
1101
|
+
}
|
|
1102
|
+
|
|
1103
|
+
.empty {
|
|
1104
|
+
text-align: center;
|
|
1105
|
+
padding: 32px 20px;
|
|
1106
|
+
color: var(--pw-text-muted);
|
|
1107
|
+
font-size: 13px;
|
|
1108
|
+
}
|
|
1109
|
+
|
|
1110
|
+
/* Mobile responsive */
|
|
1111
|
+
@media (max-width: 480px) {
|
|
1112
|
+
.panel {
|
|
1113
|
+
width: 100vw;
|
|
1114
|
+
max-height: 60vh;
|
|
1115
|
+
position: fixed;
|
|
1116
|
+
bottom: 0;
|
|
1117
|
+
left: 0;
|
|
1118
|
+
border-radius: 16px 16px 0 0;
|
|
1119
|
+
}
|
|
1120
|
+
}
|
|
1121
|
+
`];F.TYPE_COLORS={join:"#22c55e",leave:"#94a3b8",thread:"var(--pw-accent, #6366f1)",comment:"#3b82f6",resolve:"#22c55e"};Ie([m({attribute:!1})],F.prototype,"client",2);Ie([b()],F.prototype,"items",2);F=Ie([I("pulse-widget-activity-panel")],F);const ki="-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif",Ke="#6366f1",Ge="#e2e8f0",Ci="#f8fafc",Pi="#e2e8f0",Je="#64748b",pe=28,_i=Array.from({length:pe},(n,e)=>.2+Math.abs(Math.sin(e*12.9898+78.233)*43758.5453)%1*.8);function Ze(n){const e=Math.max(0,Math.floor(n)),t=Math.floor(e/60),i=e%60;return`${t}:${i.toString().padStart(2,"0")}`}class Pe{static render(e,t){let i=!1,s=t!=null?t/1e3:0,r=0;const o=document.createElement("audio");o.preload="metadata",o.src=e;const l=document.createElement("div");Object.assign(l.style,{display:"inline-flex",alignItems:"center",gap:"10px",width:"220px",height:"44px",padding:"0 10px",background:Ci,borderRadius:"12px",border:`1px solid ${Pi}`,fontFamily:ki,fontSize:"11px",color:Je,userSelect:"none",boxSizing:"border-box"});const a=document.createElement("button");Object.assign(a.style,{width:"28px",height:"28px",minWidth:"28px",borderRadius:"50%",border:"none",background:Ke,cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",padding:"0",outline:"none",flexShrink:"0"});const c=document.createElement("span");Object.assign(c.style,{display:"block",width:"10px",height:"12px",lineHeight:"0"});function p(){c.innerHTML=`<svg width="10" height="12" viewBox="0 0 10 12" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
1122
|
+
<path d="M1 1L9 6L1 11V1Z" fill="white" stroke="white" stroke-width="1" stroke-linejoin="round"/>
|
|
1123
|
+
</svg>`}function h(){c.innerHTML=`<svg width="10" height="12" viewBox="0 0 10 12" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
1124
|
+
<rect x="1" y="1" width="2.5" height="10" rx="0.5" fill="white"/>
|
|
1125
|
+
<rect x="6.5" y="1" width="2.5" height="10" rx="0.5" fill="white"/>
|
|
1126
|
+
</svg>`}p(),a.appendChild(c);const f=document.createElement("div");Object.assign(f.style,{flex:"1",display:"flex",flexDirection:"column",gap:"3px",overflow:"hidden",minWidth:"0"});const g=document.createElement("div");Object.assign(g.style,{display:"flex",alignItems:"center",gap:"1.5px",height:"22px",cursor:"pointer"});const $=[];for(let y=0;y<pe;y++){const T=document.createElement("div"),v=Math.round(_i[y]*20);Object.assign(T.style,{flex:"1",height:`${Math.max(3,v)}px`,borderRadius:"1px",background:Ge,transition:"background 0.1s ease",minWidth:"0"}),$.push(T),g.appendChild(T)}const A=document.createElement("div");Object.assign(A.style,{fontSize:"10px",color:Je,whiteSpace:"nowrap",lineHeight:"1"});function k(){const y=Ze(r),T=Ze(s);A.textContent=`${y} / ${T}`}k(),f.appendChild(g),f.appendChild(A),l.appendChild(a),l.appendChild(f);function w(){const y=s>0?r/s:0,T=Math.floor(y*pe);for(let v=0;v<pe;v++)$[v].style.background=v<=T?Ke:Ge}return g.addEventListener("click",y=>{if(s<=0)return;const T=g.getBoundingClientRect(),v=Math.min(1,Math.max(0,(y.clientX-T.left)/T.width));o.currentTime=v*s,r=o.currentTime,w(),k()}),a.addEventListener("click",()=>{i?o.pause():o.play().catch(()=>{})}),o.addEventListener("play",()=>{i=!0,h()}),o.addEventListener("pause",()=>{i=!1,p()}),o.addEventListener("ended",()=>{i=!1,p(),r=0,w(),k()}),o.addEventListener("timeupdate",()=>{r=o.currentTime,w(),k()}),o.addEventListener("loadedmetadata",()=>{o.duration&&isFinite(o.duration)&&(s=o.duration,k())}),o.addEventListener("durationchange",()=>{o.duration&&isFinite(o.duration)&&(s=o.duration,k())}),l}}const Qe=80,Ei="#e2e8f0",Ti=`
|
|
1127
|
+
<svg width="28" height="28" viewBox="0 0 28 28" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
1128
|
+
<circle cx="14" cy="14" r="14" fill="rgba(0,0,0,0.35)"/>
|
|
1129
|
+
<polygon points="11,8 22,14 11,20" fill="rgba(255,255,255,0.9)"/>
|
|
1130
|
+
</svg>`,et=`
|
|
1131
|
+
<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">
|
|
1132
|
+
<polygon points="11,5 6,9 2,9 2,15 6,15 11,19"/>
|
|
1133
|
+
<line x1="23" y1="9" x2="17" y2="15"/>
|
|
1134
|
+
<line x1="17" y1="9" x2="23" y2="15"/>
|
|
1135
|
+
</svg>`,Si=`
|
|
1136
|
+
<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">
|
|
1137
|
+
<polygon points="11,5 6,9 2,9 2,15 6,15 11,19"/>
|
|
1138
|
+
<path d="M19.07 4.93a10 10 0 0 1 0 14.14"/>
|
|
1139
|
+
<path d="M15.54 8.46a5 5 0 0 1 0 7.07"/>
|
|
1140
|
+
</svg>`;class mt{static render(e,t){let i=!1,s=!0;const r=document.createElement("div");Object.assign(r.style,{position:"relative",display:"inline-block",width:`${Qe}px`,height:`${Qe}px`,borderRadius:"50%",border:`2px solid ${Ei}`,boxShadow:"0 2px 8px rgba(0,0,0,0.1)",overflow:"hidden",cursor:"pointer",flexShrink:"0",userSelect:"none",WebkitUserSelect:"none"});const o=document.createElement("video");Object.assign(o.style,{width:"100%",height:"100%",objectFit:"cover",display:"block",borderRadius:"50%"}),o.src=e,o.loop=!0,o.muted=!0,o.playsInline=!0,o.preload="metadata",t&&(o.poster=t),r.appendChild(o);const l=document.createElement("div");Object.assign(l.style,{position:"absolute",top:"0",left:"0",width:"100%",height:"100%",display:"flex",alignItems:"center",justifyContent:"center",borderRadius:"50%",transition:"opacity 0.25s ease",opacity:"1",pointerEvents:"none"}),l.innerHTML=Ti,r.appendChild(l);const a=document.createElement("div");Object.assign(a.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"}),a.innerHTML=et,r.appendChild(a);function c(){l.style.opacity=i?"0":"1"}function p(){a.style.display=i?"flex":"none",a.innerHTML=s?et:Si}return r.addEventListener("click",h=>{h.stopPropagation(),i?s?(o.muted=!1,s=!1):(o.pause(),i=!1,s=!0,o.muted=!0):(o.muted=!0,s=!0,o.play().catch(()=>{}),i=!0),c(),p()}),o.addEventListener("pause",()=>{i&&(i=!1,s=!0,o.muted=!0,c(),p())}),r}}const C=class C{static open(e){C.close();const t=document.createElement("div");t.id="pulse-widget-lightbox",Object.assign(t.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 i=document.createElement("button");i.textContent="×",Object.assign(i.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",lineHeight:"40px",textAlign:"center",cursor:"pointer",padding:"0",fontFamily:"inherit",display:"flex",alignItems:"center",justifyContent:"center",transition:"background 150ms ease"}),i.addEventListener("mouseenter",()=>{i.style.background="rgba(255,255,255,0.3)"}),i.addEventListener("mouseleave",()=>{i.style.background="rgba(255,255,255,0.15)"}),i.addEventListener("click",o=>{o.stopPropagation(),C.close()});const s=document.createElement("img");s.src=e,s.alt="Lightbox image",Object.assign(s.style,{maxWidth:"90vw",maxHeight:"90vh",borderRadius:"8px",objectFit:"contain",cursor:"default",userSelect:"none"}),s.addEventListener("click",o=>{o.stopPropagation()}),t.appendChild(i),t.appendChild(s),t.addEventListener("click",()=>{C.close()});const r=o=>{o.key==="Escape"&&C.close()};document.addEventListener("keydown",r),C.overlay=t,C.onKeyDown=r,document.body.appendChild(t),requestAnimationFrame(()=>{t.style.opacity="1"})}static close(){if(!C.overlay)return;const e=C.overlay;C.onKeyDown&&(document.removeEventListener("keydown",C.onKeyDown),C.onKeyDown=null),e.style.opacity="0",e.addEventListener("transitionend",()=>{e.remove()}),C.overlay=null}};C.overlay=null,C.onKeyDown=null;let me=C;const Ai=["👍","👎","❤️","🎉","👀","🚀"],ce="-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif",Mi='<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>',Oi='<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>',tt=`<button class="pulse-close-btn" style="
|
|
1141
|
+
border:none;background:none;cursor:pointer;color:#94a3b8;padding:4px;
|
|
1142
|
+
border-radius:6px;display:flex;align-items:center;justify-content:center;
|
|
1143
|
+
transition:all 0.15s;flex-shrink:0;
|
|
1144
|
+
" onmouseover="this.style.background='#f1f5f9';this.style.color='#0f172a'"
|
|
1145
|
+
onmouseout="this.style.background='none';this.style.color='#94a3b8'">
|
|
1146
|
+
<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>
|
|
1147
|
+
</button>`;class Ii{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.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,r;if(this.popover&&!this.popover.contains(i.target)){if((s=this.container)!=null&&s.contains(i.target)||(r=this.pickerEl)!=null&&r.contains(i.target))return;this.closePopover()}},this.handleOverlayClick=i=>{this.form&&(this.form.remove(),this.form=null);const s=window.innerWidth,r=window.innerHeight,o={x:i.clientX/s,y:i.clientY/r,scrollX:window.scrollX,scrollY:window.scrollY},l=this.overlay.style.pointerEvents;this.overlay.style.pointerEvents="none";const a=document.elementFromPoint(i.clientX,i.clientY);if(this.overlay.style.pointerEvents=l,a){o.selector=this.getSelector(a);const c=a.getBoundingClientRect();c.width>0&&c.height>0&&(o.elementOffsetX=(i.clientX-c.left)/c.width,o.elementOffsetY=(i.clientY-c.top)/c.height)}this.showPinForm(i.clientX,i.clientY,o)},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,r,o;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),(r=this.mutationObserver)==null||r.disconnect(),this.mutationObserver=null,this.repositionDebounce&&(clearTimeout(this.repositionDebounce),this.repositionDebounce=null),(o=this.container)==null||o.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,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}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(),r=[...i.classList].filter(a=>!a.startsWith("pulse-")).slice(0,2);let o=r.length>0?`${s}.${r.join(".")}`:s;const l=i.parentElement;if(l){const a=[...l.children].filter(c=>c.tagName===i.tagName);if(a.length>1){const c=a.indexOf(i)+1;o+=`:nth-child(${c})`}}if(t.unshift(o),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),r=120;let o=e+16,l=t-10;o+s>window.innerWidth-16&&(o=e-s-16),l+r>window.innerHeight-16&&(l=window.innerHeight-r-16),l<16&&(l=16),Object.assign(this.form.style,{position:"fixed",left:`${o}px`,top:`${l}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:ce}),this.form.innerHTML=`
|
|
1148
|
+
<div style="display:flex;align-items:center;justify-content:space-between;margin-bottom:8px;">
|
|
1149
|
+
<span style="font-size:13px;font-weight:600;color:#0f172a;">Add a comment here</span>
|
|
1150
|
+
${tt}
|
|
1151
|
+
</div>
|
|
1152
|
+
<textarea
|
|
1153
|
+
placeholder="Write a comment..."
|
|
1154
|
+
style="
|
|
1155
|
+
width:100%;padding:8px 10px;border:1.5px solid #e2e8f0;border-radius:8px;
|
|
1156
|
+
font-size:13px;font-family:inherit;resize:none;min-height:48px;
|
|
1157
|
+
outline:none;box-sizing:border-box;color:#0f172a;
|
|
1158
|
+
"
|
|
1159
|
+
></textarea>
|
|
1160
|
+
<div style="display:flex;gap:6px;margin-top:8px;justify-content:flex-end;">
|
|
1161
|
+
<button class="pin-cancel" style="
|
|
1162
|
+
padding:6px 14px;border:1px solid #e2e8f0;border-radius:6px;
|
|
1163
|
+
font-size:12px;font-weight:500;cursor:pointer;background:#fff;
|
|
1164
|
+
font-family:inherit;color:#64748b;
|
|
1165
|
+
">Cancel</button>
|
|
1166
|
+
<button class="pin-submit" style="
|
|
1167
|
+
padding:6px 14px;background:#6366f1;color:#fff;border:none;
|
|
1168
|
+
border-radius:6px;font-size:12px;font-weight:600;cursor:pointer;
|
|
1169
|
+
font-family:inherit;
|
|
1170
|
+
">Pin Comment</button>
|
|
1171
|
+
</div>
|
|
1172
|
+
`;const a=this.form.querySelector("textarea"),c=this.form.querySelector(".pulse-close-btn"),p=this.form.querySelector(".pin-cancel"),h=this.form.querySelector(".pin-submit");c.addEventListener("click",()=>this.exitPinMode()),p.addEventListener("click",()=>this.exitPinMode()),h.addEventListener("click",()=>{const f=a.value.trim();if(!f)return;const g=[...f.matchAll(/@(\w+)/g)].map($=>$[1]);this.client.createThread(f,{position:i,mentions:g}),this.exitPinMode()}),a.addEventListener("keydown",f=>{f.key==="Escape"&&this.exitPinMode(),f.stopPropagation()}),document.body.appendChild(this.form),requestAnimationFrame(()=>a.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,r=t.getBoundingClientRect();let o,l;i?(o=0,l=window.innerHeight*.4):(o=r.right+10,l=r.top-8,o+s>window.innerWidth-16&&(o=r.left-s-10),l<16&&(l=16)),Object.assign(this.popover.style,{position:"fixed",left:`${o}px`,top:`${l}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:ce,display:"flex",flexDirection:"column",overflow:"hidden",pointerEvents:"auto",...i?{bottom:"0",top:"auto"}:{}});const a=document.createElement("div");Object.assign(a.style,{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"10px 14px",borderBottom:"1px solid #f1f5f9",flexShrink:"0"}),a.innerHTML=`
|
|
1173
|
+
<span style="font-size:13px;font-weight:700;color:#0f172a;">Thread</span>
|
|
1174
|
+
${tt}
|
|
1175
|
+
`,a.querySelector(".pulse-close-btn").addEventListener("click",()=>{this.closePopover()}),this.popover.appendChild(a),this.refreshPopoverComments(e),this.addPopoverReplyForm(e),document.body.appendChild(this.popover);const c=this.popover.getBoundingClientRect();c.bottom>window.innerHeight-16&&(this.popover.style.top=`${Math.max(16,window.innerHeight-c.height-16)}px`),requestAnimationFrame(()=>{document.addEventListener("pointerdown",this.handlePopoverOutsideClick),document.addEventListener("keydown",this.handlePopoverEscape)})}refreshPopoverComments(e){var l;if(!this.popover)return;this.removePickerEl(),this.editingPopoverCommentId&&!e.comments.find(a=>a.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 a=this.popover.firstElementChild;a&&a.nextSibling?this.popover.insertBefore(t,a.nextSibling):this.popover.appendChild(t)}const i=(l=this.client.state.user)==null?void 0:l.id;t.innerHTML=e.comments.map(a=>{const c=this.client.state.getUser(a.userId),p=c?c.name.split(" ").map(v=>v[0]).join("").toUpperCase().slice(0,2):"?",h=(c==null?void 0:c.color)??"#94a3b8",f=this.escapeHtml((c==null?void 0:c.name)??"Unknown"),g=this.formatTime(a.createdAt),$=i===a.userId,A=a.editedAt?'<span style="font-size:10px;color:#94a3b8;font-style:italic;">(edited)</span>':"";if(this.editingPopoverCommentId===a.id)return`
|
|
1176
|
+
<div style="margin-bottom:10px;" data-comment-id="${a.id}">
|
|
1177
|
+
<div style="display:flex;align-items:center;gap:7px;margin-bottom:4px;">
|
|
1178
|
+
<div style="width:22px;height:22px;border-radius:50%;background:${h};color:#fff;display:flex;align-items:center;justify-content:center;font-size:9px;font-weight:700;flex-shrink:0;">${p}</div>
|
|
1179
|
+
<span style="font-size:12px;font-weight:600;color:#0f172a;">${f}</span>
|
|
1180
|
+
</div>
|
|
1181
|
+
<div style="margin-left:29px;">
|
|
1182
|
+
<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(a.body)}</textarea>
|
|
1183
|
+
<div style="display:flex;gap:6px;margin-top:6px;">
|
|
1184
|
+
<button class="edit-save" style="padding:4px 10px;background:#6366f1;color:#fff;border:none;border-radius:6px;font-size:11px;font-weight:600;cursor:pointer;font-family:inherit;">Save</button>
|
|
1185
|
+
<button class="edit-cancel" style="padding:4px 10px;border:1px solid #e2e8f0;border-radius:6px;font-size:11px;font-weight:500;cursor:pointer;background:#fff;font-family:inherit;color:#64748b;">Cancel</button>
|
|
1186
|
+
</div>
|
|
1187
|
+
</div>
|
|
1188
|
+
</div>
|
|
1189
|
+
`;const k=a.body.replace(/@(\w+)/g,'<span style="color:#6366f1;font-weight:600;background:#eef2ff;padding:0 3px;border-radius:3px;">@$1</span>'),w=(a.attachments??[]).map(v=>{if(v.type==="image"){const bt=v.thumbnailUrl||v.url;return`<div class="popover-attachment-img" data-full-url="${this.escapeHtml(v.url)}" style="margin:4px 0 4px 29px;cursor:pointer;">
|
|
1190
|
+
<img src="${this.escapeHtml(bt)}" alt="${this.escapeHtml(v.filename)}" style="max-width:180px;max-height:120px;border-radius:8px;border:1px solid #e2e8f0;display:block;" />
|
|
1191
|
+
</div>`}return v.type==="audio"?`<div class="popover-attachment-audio" data-url="${this.escapeHtml(v.url)}" data-duration="${v.durationMs??""}" style="margin:4px 0 4px 29px;"></div>`:v.type==="video"?`<div class="popover-attachment-video" data-url="${this.escapeHtml(v.url)}" data-poster="${this.escapeHtml(v.thumbnailUrl??"")}" style="margin:4px 0 4px 29px;"></div>`:""}).join(""),y=$?`<div class="popover-comment-actions" style="display:flex;gap:2px;margin-top:2px;margin-left:29px;">
|
|
1192
|
+
<button class="edit-btn" data-comment-id="${a.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"
|
|
1193
|
+
onmouseover="this.style.color='#6366f1';this.style.background='#eef2ff'"
|
|
1194
|
+
onmouseout="this.style.color='#94a3b8';this.style.background='none'">${Mi}</button>
|
|
1195
|
+
<button class="delete-btn" data-comment-id="${a.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"
|
|
1196
|
+
onmouseover="this.style.color='#ef4444';this.style.background='#fef2f2'"
|
|
1197
|
+
onmouseout="this.style.color='#94a3b8';this.style.background='none'">${Oi}</button>
|
|
1198
|
+
</div>`:"",T=this.buildReactionPillsHtml(a.id);return`
|
|
1199
|
+
<div class="popover-comment" style="margin-bottom:10px;" data-comment-id="${a.id}">
|
|
1200
|
+
<div style="display:flex;align-items:center;gap:7px;margin-bottom:2px;">
|
|
1201
|
+
<div style="width:22px;height:22px;border-radius:50%;background:${h};color:#fff;display:flex;align-items:center;justify-content:center;font-size:9px;font-weight:700;flex-shrink:0;">${p}</div>
|
|
1202
|
+
<span style="font-size:12px;font-weight:600;color:#0f172a;">${f}</span>
|
|
1203
|
+
<span style="font-size:10px;color:#94a3b8;">${g}</span>
|
|
1204
|
+
${A}
|
|
1205
|
+
</div>
|
|
1206
|
+
<div style="font-size:13px;color:#334155;line-height:1.45;margin-left:29px;word-wrap:break-word;">${k}</div>
|
|
1207
|
+
${w}
|
|
1208
|
+
${y}
|
|
1209
|
+
${T}
|
|
1210
|
+
</div>
|
|
1211
|
+
`}).join(""),t.querySelectorAll(".edit-btn").forEach(a=>{a.addEventListener("click",()=>{this.editingPopoverCommentId=a.dataset.commentId,this.refreshPopoverComments(e)})}),t.querySelectorAll(".delete-btn").forEach(a=>{a.addEventListener("click",()=>{this.client.deleteComment(a.dataset.commentId)})});const s=t.querySelector(".edit-save"),r=t.querySelector(".edit-cancel"),o=t.querySelector(".edit-textarea");s&&o&&s.addEventListener("click",()=>{const a=o.value.trim();if(!a)return;const c=[...a.matchAll(/@(\w+)/g)].map(p=>p[1]);this.client.editComment(this.editingPopoverCommentId,a,c),this.editingPopoverCommentId=null}),r&&r.addEventListener("click",()=>{this.editingPopoverCommentId=null,this.refreshPopoverComments(e)}),t.querySelectorAll("[data-reaction-emoji]").forEach(a=>{a.addEventListener("click",c=>{c.stopPropagation();const p=a.dataset.reactionEmoji,h=a.dataset.reactionTarget,f=a.dataset.reactionId;f?this.client.removeReaction(f):this.client.addReaction(h,"comment",p)})}),t.querySelectorAll(".popover-reaction-add").forEach(a=>{a.addEventListener("click",c=>{c.stopPropagation();const p=a.dataset.commentId;this.popoverPickerOpen===p?(this.popoverPickerOpen=null,this.removePickerEl()):(this.popoverPickerOpen=p,this.showPickerForButton(a,p))})}),t.querySelectorAll(".popover-attachment-img").forEach(a=>{a.addEventListener("click",()=>{const c=a.dataset.fullUrl;c&&me.open(c)})}),t.querySelectorAll(".popover-attachment-audio").forEach(a=>{const c=a.dataset.url;if(c){const p=a.dataset.duration?parseInt(a.dataset.duration):void 0,h=Pe.render(c,p);a.appendChild(h)}}),t.querySelectorAll(".popover-attachment-video").forEach(a=>{const c=a.dataset.url;if(c){const p=a.dataset.poster||void 0,h=mt.render(c,p);a.appendChild(h)}}),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",display:"flex",gap:"6px"}),t.innerHTML=`
|
|
1212
|
+
<input type="text" placeholder="Reply..."
|
|
1213
|
+
style="flex:1;padding:7px 10px;border:1.5px solid #e2e8f0;border-radius:8px;font-size:12px;font-family:inherit;outline:none;color:#0f172a;" />
|
|
1214
|
+
<button style="padding:7px 14px;background:#6366f1;color:#fff;border:none;border-radius:8px;font-size:12px;font-weight:600;cursor:pointer;font-family:inherit;white-space:nowrap;">Send</button>
|
|
1215
|
+
`;const i=t.querySelector("input"),s=t.querySelector("button"),r=()=>{const o=i.value.trim();if(!o)return;const l=[...o.matchAll(/@(\w+)/g)].map(a=>a[1]);this.client.reply(e.id,o,l),i.value=""};s.addEventListener("click",r),i.addEventListener("input",()=>{const o=Date.now(),l=this.lastTypingSendPins.get(e.id)??0;o-l>=2e3&&(this.client.sendTyping(e.id),this.lastTypingSendPins.set(e.id,o))}),i.addEventListener("keydown",o=>{o.key==="Enter"&&(o.preventDefault(),r()),o.key==="Escape"&&this.closePopover(),o.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:ce});for(const s of Ai){const r=document.createElement("button");Object.assign(r.style,{border:"none",background:"none",cursor:"pointer",fontSize:"16px",padding:"4px",borderRadius:"4px",lineHeight:"1"}),r.textContent=s,r.addEventListener("click",o=>{o.stopPropagation();const a=this.client.state.getReactions(t).find(c=>{var p;return c.emoji===s&&c.userId===((p=this.client.state.user)==null?void 0:p.id)});a?this.client.removeReaction(a.id):this.client.addReaction(t,"comment",s),this.popoverPickerOpen=null,this.removePickerEl()}),this.pickerEl.appendChild(r)}document.body.appendChild(this.pickerEl)}buildReactionPillsHtml(e){var a;const t=this.client.state.getReactions(e),i=(a=this.client.state.user)==null?void 0:a.id,s=new Map;for(const c of t){const p=s.get(c.emoji)??{count:0,ownId:null};p.count++,c.userId===i&&(p.ownId=c.id),s.set(c.emoji,p)}const r="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;",o=r+"background:#eef2ff;border-color:#6366f1;";let l='<div style="margin-left:29px;display:flex;gap:4px;flex-wrap:wrap;margin-top:4px;">';for(const[c,{count:p,ownId:h}]of s){const f=h?o:r;l+=`<button data-reaction-emoji="${c}" data-reaction-target="${e}" ${h?`data-reaction-id="${h}"`:""} style="${f}">
|
|
1216
|
+
<span>${c}</span><span style="font-size:11px;font-weight:600;color:#64748b;">${p}</span>
|
|
1217
|
+
</button>`}return l+=`<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>`,l+="</div>",l}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 r;return s!==((r=this.client.state.user)==null?void 0:r.id)}).map(s=>{const r=this.client.state.presence.find(o=>o.user.id===s);return(r==null?void 0:r.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(),r=Math.floor(s/6e4);if(r<1)return"now";if(r<60)return`${r}m`;const o=Math.floor(r/60);return o<24?`${o}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 r=i.position;let o=this.pinEls.get(i.id);o||(o=document.createElement("div"),Object.assign(o.style,{position:"fixed",width:"24px",height:"24px",borderRadius:"50%",background:"#6366f1",color:"#fff",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"11px",fontWeight:"700",fontFamily:ce,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%)"}),o.addEventListener("mouseenter",()=>{o.style.transform="translate(-50%, -50%) scale(1.15)"}),o.addEventListener("mouseleave",()=>{o.style.transform="translate(-50%, -50%)"}),o.addEventListener("click",()=>{if(this.popover&&this.popover.dataset.threadId===i.id){this.closePopover();return}const a=this.threads.find(c=>c.id===i.id);a&&this.showThreadPopover(a,o)}),this.container.appendChild(o),this.pinEls.set(i.id,o)),o.textContent=`${s+1}`;const l=this.resolvePosition(r);o.style.left=`${l.x}px`,o.style.top=`${l.y}px`})}}var ji=Object.defineProperty,Li=Object.getOwnPropertyDescriptor,L=(n,e,t,i)=>{for(var s=i>1?void 0:i?Li(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&ji(e,t,s),s};const Ri=["👍","👎","❤️","🎉","👀","🚀"];let O=class extends P{constructor(){super(...arguments),this.highlightThreadId=null,this.threads=[],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}connectedCallback(){super.connectedCallback(),this.setupListener()}disconnectedCallback(){var n,e,t;super.disconnectedCallback(),(n=this.unsub)==null||n.call(this),(e=this.reactionUnsub)==null||e.call(this),(t=this.typingUnsub)==null||t.call(this);for(const i of this.typingTimers.values())clearTimeout(i);this.typingTimers.clear()}updated(n){var e,t,i,s,r;n.has("client")&&this.client&&((e=this.unsub)==null||e.call(this),(t=this.reactionUnsub)==null||t.call(this),(i=this.typingUnsub)==null||i.call(this),this.setupListener()),(s=this.shadowRoot)==null||s.querySelectorAll(".audio-player-host").forEach(o=>{if(o.children.length>0)return;const l=o.dataset.url;if(l){const a=o.dataset.duration?parseInt(o.dataset.duration):void 0;o.appendChild(Pe.render(l,a))}}),(r=this.shadowRoot)==null||r.querySelectorAll(".video-player-host").forEach(o=>{if(o.children.length>0)return;const l=o.dataset.url;l&&o.appendChild(mt.render(l,o.dataset.poster||void 0))})}setupListener(){this.client&&(this.threads=this.client.state.threads,this.unsub=this.client.state.on("threads",n=>{this.threads=[...n]}),this.reactionUnsub=this.client.state.on("reactions",()=>{this.reactionsVersion++}),this.typingUnsub=this.client.state.on("typing",({threadId:n})=>{this.refreshTyping(n)}))}refreshTyping(n){const t=this.client.state.getTypingUsers(n).filter(s=>{var r;return s!==((r=this.client.state.user)==null?void 0:r.id)}).map(s=>{const r=this.client.state.presence.find(o=>o.user.id===s);return(r==null?void 0:r.user.name)??"Someone"}),i=new Map(this.typingByThread);i.set(n,t),this.typingByThread=i,this.typingTimers.has(n)&&clearTimeout(this.typingTimers.get(n)),this.typingTimers.set(n,setTimeout(()=>{this.refreshTyping(n)},3500))}handleTypingInput(n){const e=Date.now(),t=this.lastTypingSend.get(n)??0;e-t>=2e3&&(this.client.sendTyping(n),this.lastTypingSend.set(n,e))}toggleReaction(n,e){var r;const t=this.client.state.getReactions(n),i=(r=this.client.state.user)==null?void 0:r.id,s=t.find(o=>o.emoji===e&&o.userId===i);s?this.client.removeReaction(s.id):this.client.addReaction(n,"comment",e),this.pickerOpenForComment=null}fireClose(){this.dispatchEvent(new CustomEvent("panel-close",{bubbles:!0,composed:!0}))}scrollToThread(n){this.updateComplete.then(()=>{var t;const e=(t=this.shadowRoot)==null?void 0:t.querySelector(`[data-thread-id="${n}"]`);e==null||e.scrollIntoView({behavior:"smooth",block:"center"})})}parseMentions(n){return n.split(/(@\w+)/g).map(t=>t.startsWith("@")?d`<span class="mention">${t}</span>`:t)}getInitials(n){return n.split(" ").map(e=>e[0]).join("").toUpperCase().slice(0,2)}getUserForComment(n){return this.client.state.getUser(n)}formatTime(n){const e=new Date(n),i=new Date().getTime()-e.getTime(),s=Math.floor(i/6e4);if(s<1)return"now";if(s<60)return`${s}m`;const r=Math.floor(s/60);return r<24?`${r}h`:e.toLocaleDateString()}handleReply(n,e){e.preventDefault();const i=e.target.querySelector("input"),s=i.value.trim();if(!s)return;const r=[...s.matchAll(/@(\w+)/g)].map(o=>o[1]);this.client.reply(n,s,r),i.value="",this.replyingTo=null}isOwnComment(n){var e,t;return((t=(e=this.client)==null?void 0:e.state.user)==null?void 0:t.id)===n.userId}startEdit(n){this.editingCommentId=n.id,this.editBody=n.body}cancelEdit(){this.editingCommentId=null,this.editBody=""}saveEdit(n){const e=this.editBody.trim();if(!e)return;const t=[...e.matchAll(/@(\w+)/g)].map(i=>i[1]);this.client.editComment(n,e,t),this.editingCommentId=null,this.editBody=""}deleteComment(n){this.client.deleteComment(n)}renderEditForm(n){return d`
|
|
1218
|
+
<div class="edit-form">
|
|
1219
|
+
<textarea
|
|
1220
|
+
.value=${this.editBody}
|
|
1221
|
+
@input=${e=>{this.editBody=e.target.value}}
|
|
1222
|
+
></textarea>
|
|
1223
|
+
<div class="edit-actions">
|
|
1224
|
+
<button class="pw-btn pw-btn-primary" @click=${()=>this.saveEdit(n.id)}>Save</button>
|
|
1225
|
+
<button class="pw-btn" @click=${this.cancelEdit}>Cancel</button>
|
|
1226
|
+
</div>
|
|
1227
|
+
</div>
|
|
1228
|
+
`}renderReactions(n){var s;this.reactionsVersion;const e=this.client.state.getReactions(n.id),t=(s=this.client.state.user)==null?void 0:s.id,i=new Map;for(const r of e)i.has(r.emoji)||i.set(r.emoji,[]),i.get(r.emoji).push(r);return d`
|
|
1229
|
+
<div class="comment-reactions">
|
|
1230
|
+
${[...i.entries()].map(([r,o])=>{const l=o.some(a=>a.userId===t);return d`
|
|
1231
|
+
<button
|
|
1232
|
+
class="reaction-pill ${l?"own":""}"
|
|
1233
|
+
@click=${()=>this.toggleReaction(n.id,r)}
|
|
1234
|
+
>
|
|
1235
|
+
<span>${r}</span>
|
|
1236
|
+
<span class="count">${o.length}</span>
|
|
1237
|
+
</button>
|
|
1238
|
+
`})}
|
|
1239
|
+
<button
|
|
1240
|
+
class="reaction-add-btn"
|
|
1241
|
+
@click=${()=>{this.pickerOpenForComment=this.pickerOpenForComment===n.id?null:n.id}}
|
|
1242
|
+
title="Add reaction"
|
|
1243
|
+
>
|
|
1244
|
+
+
|
|
1245
|
+
${this.pickerOpenForComment===n.id?d`
|
|
1246
|
+
<div class="emoji-picker">
|
|
1247
|
+
${Ri.map(r=>d`
|
|
1248
|
+
<button @click=${o=>{o.stopPropagation(),this.toggleReaction(n.id,r)}}>${r}</button>
|
|
1249
|
+
`)}
|
|
1250
|
+
</div>
|
|
1251
|
+
`:u}
|
|
1252
|
+
</button>
|
|
1253
|
+
</div>
|
|
1254
|
+
`}renderTypingIndicator(n){const e=this.typingByThread.get(n)??[];if(e.length===0)return u;const t=e.length===1?`${e[0]} is typing...`:`${e.join(", ")} are typing...`;return d`<div class="typing-indicator">${t}</div>`}sortedThreads(){return[...this.threads].sort((n,e)=>{if(n.resolved!==e.resolved)return n.resolved?1:-1;const t=n.comments.length?new Date(n.comments[n.comments.length-1].createdAt).getTime():0;return(e.comments.length?new Date(e.comments[e.comments.length-1].createdAt).getTime():0)-t})}render(){const n=this.sortedThreads();return d`
|
|
1255
|
+
<div class="panel">
|
|
1256
|
+
<div class="panel-header">
|
|
1257
|
+
<span class="panel-title">
|
|
1258
|
+
Comments
|
|
1259
|
+
<span class="thread-count">${this.threads.length}</span>
|
|
1260
|
+
</span>
|
|
1261
|
+
<button class="close-btn" @click=${this.fireClose} title="Close">
|
|
1262
|
+
${E(ae,16)}
|
|
1263
|
+
</button>
|
|
1264
|
+
</div>
|
|
1265
|
+
|
|
1266
|
+
<div class="panel-body pw-scrollable">
|
|
1267
|
+
${n.length===0?d`<div class="empty">
|
|
1268
|
+
<div class="empty-icon">💬</div>
|
|
1269
|
+
No comments yet
|
|
1270
|
+
</div>`:n.map(e=>this.renderThread(e))}
|
|
1271
|
+
</div>
|
|
1272
|
+
|
|
1273
|
+
<div class="pin-hint">
|
|
1274
|
+
Use the pin button to comment anywhere on the page
|
|
1275
|
+
</div>
|
|
1276
|
+
</div>
|
|
1277
|
+
`}renderAttachments(n){return!n||n.length===0?u:d`
|
|
1278
|
+
${n.map(e=>{if(e.type==="image"){const t=e.thumbnailUrl||e.url;return d`
|
|
1279
|
+
<div class="comment-attachment-media">
|
|
1280
|
+
<img
|
|
1281
|
+
class="comment-attachment-img"
|
|
1282
|
+
src=${t}
|
|
1283
|
+
alt=${e.filename}
|
|
1284
|
+
@click=${()=>me.open(e.url)}
|
|
1285
|
+
/>
|
|
1286
|
+
</div>
|
|
1287
|
+
`}return e.type==="audio"?d`
|
|
1288
|
+
<div class="comment-attachment-media" id="audio-${e.id}">
|
|
1289
|
+
${this.renderAudioPlayer(e)}
|
|
1290
|
+
</div>
|
|
1291
|
+
`:e.type==="video"?d`
|
|
1292
|
+
<div class="comment-attachment-media" id="video-${e.id}">
|
|
1293
|
+
${this.renderVideoPlayer(e)}
|
|
1294
|
+
</div>
|
|
1295
|
+
`:u})}
|
|
1296
|
+
`}renderAudioPlayer(n){const e=document.createElement("div"),t=Pe.render(n.url,n.durationMs);return e.appendChild(t),d`<div class="audio-player-host" data-url=${n.url} data-duration=${n.durationMs??""}></div>`}renderVideoPlayer(n){return d`<div class="video-player-host" data-url=${n.url} data-poster=${n.thumbnailUrl??""}></div>`}renderThread(n){const e=this.highlightThreadId===n.id;return d`
|
|
1297
|
+
<div
|
|
1298
|
+
class="thread ${n.resolved?"resolved":""} ${e?"highlighted":""}"
|
|
1299
|
+
data-thread-id=${n.id}
|
|
1300
|
+
>
|
|
1301
|
+
${n.position?d`<div class="pin-badge">
|
|
1302
|
+
${E(ft,12)}
|
|
1303
|
+
Pinned
|
|
1304
|
+
</div>`:u}
|
|
1305
|
+
${n.comments.map((t,i)=>{const s=this.getUserForComment(t.userId),r=this.isOwnComment(t),o=this.editingCommentId===t.id;return d`
|
|
1306
|
+
${i>0?d`<div class="comment-divider"></div>`:u}
|
|
1307
|
+
<div class="comment">
|
|
1308
|
+
<div class="comment-header">
|
|
1309
|
+
<div
|
|
1310
|
+
class="comment-avatar"
|
|
1311
|
+
style="background:${(s==null?void 0:s.color)??"#94a3b8"}"
|
|
1312
|
+
>
|
|
1313
|
+
${s?this.getInitials(s.name):"?"}
|
|
1314
|
+
</div>
|
|
1315
|
+
<span class="comment-author">${(s==null?void 0:s.name)??"Unknown"}</span>
|
|
1316
|
+
<span class="comment-time">${this.formatTime(t.createdAt)}</span>
|
|
1317
|
+
${t.editedAt?d`<span class="edited-badge">(edited)</span>`:u}
|
|
1318
|
+
</div>
|
|
1319
|
+
${o?this.renderEditForm(t):d`
|
|
1320
|
+
<div class="comment-body">${this.parseMentions(t.body)}</div>
|
|
1321
|
+
${this.renderAttachments(t.attachments??[])}
|
|
1322
|
+
`}
|
|
1323
|
+
${r&&!o?d`<div class="comment-actions">
|
|
1324
|
+
<button @click=${()=>this.startEdit(t)} title="Edit">${E(gi,14)}</button>
|
|
1325
|
+
<button class="danger" @click=${()=>this.deleteComment(t.id)} title="Delete">${E(vi,14)}</button>
|
|
1326
|
+
</div>`:u}
|
|
1327
|
+
${this.renderReactions(t)}
|
|
1328
|
+
</div>
|
|
1329
|
+
`})}
|
|
1330
|
+
|
|
1331
|
+
<div class="thread-actions">
|
|
1332
|
+
<button
|
|
1333
|
+
@click=${()=>this.replyingTo=this.replyingTo===n.id?null:n.id}
|
|
1334
|
+
>
|
|
1335
|
+
Reply
|
|
1336
|
+
</button>
|
|
1337
|
+
<button
|
|
1338
|
+
@click=${()=>this.client.resolveThread(n.id,!n.resolved)}
|
|
1339
|
+
>
|
|
1340
|
+
${n.resolved?"Reopen":"Resolve"}
|
|
1341
|
+
</button>
|
|
1342
|
+
</div>
|
|
1343
|
+
|
|
1344
|
+
${this.renderTypingIndicator(n.id)}
|
|
1345
|
+
|
|
1346
|
+
${this.replyingTo===n.id?d`
|
|
1347
|
+
<form
|
|
1348
|
+
class="reply-form"
|
|
1349
|
+
@submit=${t=>this.handleReply(n.id,t)}
|
|
1350
|
+
>
|
|
1351
|
+
<input
|
|
1352
|
+
type="text"
|
|
1353
|
+
placeholder="Reply..."
|
|
1354
|
+
@input=${()=>this.handleTypingInput(n.id)}
|
|
1355
|
+
/>
|
|
1356
|
+
<button class="pw-btn pw-btn-primary" type="submit">Send</button>
|
|
1357
|
+
</form>
|
|
1358
|
+
`:u}
|
|
1359
|
+
</div>
|
|
1360
|
+
`}};O.styles=[K,le,ve,S`
|
|
1361
|
+
:host {
|
|
1362
|
+
display: block;
|
|
1363
|
+
}
|
|
1364
|
+
|
|
1365
|
+
.panel {
|
|
1366
|
+
width: 340px;
|
|
1367
|
+
max-height: 480px;
|
|
1368
|
+
background: var(--pw-surface);
|
|
1369
|
+
border-radius: var(--pw-radius);
|
|
1370
|
+
box-shadow: var(--pw-shadow-lg);
|
|
1371
|
+
border: 1px solid var(--pw-border);
|
|
1372
|
+
display: flex;
|
|
1373
|
+
flex-direction: column;
|
|
1374
|
+
overflow: hidden;
|
|
1375
|
+
}
|
|
1376
|
+
|
|
1377
|
+
.panel-header {
|
|
1378
|
+
display: flex;
|
|
1379
|
+
align-items: center;
|
|
1380
|
+
justify-content: space-between;
|
|
1381
|
+
padding: 14px 16px;
|
|
1382
|
+
border-bottom: 1px solid var(--pw-border-light);
|
|
1383
|
+
flex-shrink: 0;
|
|
1384
|
+
}
|
|
1385
|
+
|
|
1386
|
+
.panel-title {
|
|
1387
|
+
font-size: 14px;
|
|
1388
|
+
font-weight: 700;
|
|
1389
|
+
color: var(--pw-text);
|
|
1390
|
+
}
|
|
1391
|
+
|
|
1392
|
+
.thread-count {
|
|
1393
|
+
font-size: 11px;
|
|
1394
|
+
color: var(--pw-text-muted);
|
|
1395
|
+
font-weight: 500;
|
|
1396
|
+
margin-left: 6px;
|
|
1397
|
+
}
|
|
1398
|
+
|
|
1399
|
+
.panel-body {
|
|
1400
|
+
flex: 1;
|
|
1401
|
+
overflow-y: auto;
|
|
1402
|
+
min-height: 0;
|
|
1403
|
+
}
|
|
1404
|
+
|
|
1405
|
+
/* Thread list */
|
|
1406
|
+
.thread {
|
|
1407
|
+
padding: 12px 16px;
|
|
1408
|
+
border-bottom: 1px solid var(--pw-border-light);
|
|
1409
|
+
transition: background 0.1s;
|
|
1410
|
+
cursor: default;
|
|
1411
|
+
}
|
|
1412
|
+
|
|
1413
|
+
.thread:last-child {
|
|
1414
|
+
border-bottom: none;
|
|
1415
|
+
}
|
|
1416
|
+
|
|
1417
|
+
.thread:hover {
|
|
1418
|
+
background: var(--pw-surface-hover);
|
|
1419
|
+
}
|
|
1420
|
+
|
|
1421
|
+
.thread.resolved {
|
|
1422
|
+
opacity: 0.55;
|
|
1423
|
+
}
|
|
1424
|
+
|
|
1425
|
+
.thread.highlighted {
|
|
1426
|
+
background: var(--pw-accent-light);
|
|
1427
|
+
}
|
|
1428
|
+
|
|
1429
|
+
.comment {
|
|
1430
|
+
margin-bottom: 10px;
|
|
1431
|
+
}
|
|
1432
|
+
|
|
1433
|
+
.comment:last-child {
|
|
1434
|
+
margin-bottom: 0;
|
|
1435
|
+
}
|
|
1436
|
+
|
|
1437
|
+
.comment-header {
|
|
1438
|
+
display: flex;
|
|
1439
|
+
align-items: center;
|
|
1440
|
+
gap: 8px;
|
|
1441
|
+
margin-bottom: 3px;
|
|
1442
|
+
}
|
|
1443
|
+
|
|
1444
|
+
.comment-avatar {
|
|
1445
|
+
width: 24px;
|
|
1446
|
+
height: 24px;
|
|
1447
|
+
border-radius: 50%;
|
|
1448
|
+
display: flex;
|
|
1449
|
+
align-items: center;
|
|
1450
|
+
justify-content: center;
|
|
1451
|
+
font-size: 9px;
|
|
1452
|
+
font-weight: 700;
|
|
1453
|
+
color: #fff;
|
|
1454
|
+
flex-shrink: 0;
|
|
1455
|
+
}
|
|
1456
|
+
|
|
1457
|
+
.comment-author {
|
|
1458
|
+
font-size: 12px;
|
|
1459
|
+
font-weight: 600;
|
|
1460
|
+
color: var(--pw-text);
|
|
1461
|
+
}
|
|
1462
|
+
|
|
1463
|
+
.comment-time {
|
|
1464
|
+
font-size: 10px;
|
|
1465
|
+
color: var(--pw-text-muted);
|
|
1466
|
+
}
|
|
1467
|
+
|
|
1468
|
+
.comment-body {
|
|
1469
|
+
font-size: 13px;
|
|
1470
|
+
color: var(--pw-text-secondary);
|
|
1471
|
+
line-height: 1.45;
|
|
1472
|
+
margin-left: 32px;
|
|
1473
|
+
word-wrap: break-word;
|
|
1474
|
+
}
|
|
1475
|
+
|
|
1476
|
+
.mention {
|
|
1477
|
+
color: var(--pw-accent);
|
|
1478
|
+
font-weight: 600;
|
|
1479
|
+
background: var(--pw-accent-light);
|
|
1480
|
+
padding: 0 3px;
|
|
1481
|
+
border-radius: 3px;
|
|
1482
|
+
}
|
|
1483
|
+
|
|
1484
|
+
.comment-divider {
|
|
1485
|
+
height: 1px;
|
|
1486
|
+
background: var(--pw-border-light);
|
|
1487
|
+
margin: 6px 0 6px 32px;
|
|
1488
|
+
}
|
|
1489
|
+
|
|
1490
|
+
.thread-actions {
|
|
1491
|
+
display: flex;
|
|
1492
|
+
gap: 2px;
|
|
1493
|
+
margin-top: 6px;
|
|
1494
|
+
margin-left: 32px;
|
|
1495
|
+
}
|
|
1496
|
+
|
|
1497
|
+
.thread-actions button {
|
|
1498
|
+
border: none;
|
|
1499
|
+
background: none;
|
|
1500
|
+
cursor: pointer;
|
|
1501
|
+
font-size: 11px;
|
|
1502
|
+
font-weight: 500;
|
|
1503
|
+
color: var(--pw-text-muted);
|
|
1504
|
+
padding: 3px 8px;
|
|
1505
|
+
border-radius: 4px;
|
|
1506
|
+
font-family: inherit;
|
|
1507
|
+
transition: all 0.15s;
|
|
1508
|
+
}
|
|
1509
|
+
|
|
1510
|
+
.thread-actions button:hover {
|
|
1511
|
+
background: var(--pw-accent-light);
|
|
1512
|
+
color: var(--pw-accent);
|
|
1513
|
+
}
|
|
1514
|
+
|
|
1515
|
+
/* Pin indicator on thread */
|
|
1516
|
+
.pin-badge {
|
|
1517
|
+
display: inline-flex;
|
|
1518
|
+
align-items: center;
|
|
1519
|
+
gap: 3px;
|
|
1520
|
+
font-size: 10px;
|
|
1521
|
+
color: var(--pw-accent);
|
|
1522
|
+
font-weight: 600;
|
|
1523
|
+
margin-left: 32px;
|
|
1524
|
+
margin-bottom: 4px;
|
|
1525
|
+
}
|
|
1526
|
+
|
|
1527
|
+
.pin-badge svg {
|
|
1528
|
+
width: 12px;
|
|
1529
|
+
height: 12px;
|
|
1530
|
+
vertical-align: middle;
|
|
1531
|
+
}
|
|
1532
|
+
|
|
1533
|
+
/* Reply form */
|
|
1534
|
+
.reply-form {
|
|
1535
|
+
display: flex;
|
|
1536
|
+
gap: 6px;
|
|
1537
|
+
margin-top: 8px;
|
|
1538
|
+
margin-left: 32px;
|
|
1539
|
+
}
|
|
1540
|
+
|
|
1541
|
+
.reply-form input {
|
|
1542
|
+
flex: 1;
|
|
1543
|
+
padding: 6px 10px;
|
|
1544
|
+
border: 1.5px solid var(--pw-border);
|
|
1545
|
+
border-radius: 6px;
|
|
1546
|
+
font-size: 12px;
|
|
1547
|
+
font-family: inherit;
|
|
1548
|
+
outline: none;
|
|
1549
|
+
transition: border-color 0.15s, box-shadow 0.15s;
|
|
1550
|
+
color: var(--pw-text);
|
|
1551
|
+
background: var(--pw-surface);
|
|
1552
|
+
}
|
|
1553
|
+
|
|
1554
|
+
.reply-form input:focus {
|
|
1555
|
+
border-color: var(--pw-accent);
|
|
1556
|
+
box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.1);
|
|
1557
|
+
}
|
|
1558
|
+
|
|
1559
|
+
.reply-form button {
|
|
1560
|
+
padding: 6px 12px;
|
|
1561
|
+
font-size: 12px;
|
|
1562
|
+
}
|
|
1563
|
+
|
|
1564
|
+
.pin-hint {
|
|
1565
|
+
padding: 10px 16px;
|
|
1566
|
+
border-top: 1px solid var(--pw-border-light);
|
|
1567
|
+
flex-shrink: 0;
|
|
1568
|
+
font-size: 11px;
|
|
1569
|
+
color: var(--pw-text-muted);
|
|
1570
|
+
text-align: center;
|
|
1571
|
+
}
|
|
1572
|
+
|
|
1573
|
+
/* Attachment rendering in comments */
|
|
1574
|
+
.comment-attachment-img {
|
|
1575
|
+
max-width: 200px;
|
|
1576
|
+
max-height: 140px;
|
|
1577
|
+
border-radius: 8px;
|
|
1578
|
+
border: 1px solid var(--pw-border);
|
|
1579
|
+
cursor: pointer;
|
|
1580
|
+
display: block;
|
|
1581
|
+
margin-top: 4px;
|
|
1582
|
+
}
|
|
1583
|
+
|
|
1584
|
+
.comment-attachment-img:hover {
|
|
1585
|
+
opacity: 0.9;
|
|
1586
|
+
}
|
|
1587
|
+
|
|
1588
|
+
.comment-attachment-media {
|
|
1589
|
+
margin-top: 4px;
|
|
1590
|
+
margin-left: 32px;
|
|
1591
|
+
}
|
|
1592
|
+
|
|
1593
|
+
/* Mobile responsive */
|
|
1594
|
+
@media (max-width: 480px) {
|
|
1595
|
+
.panel {
|
|
1596
|
+
width: 100vw;
|
|
1597
|
+
max-height: 60vh;
|
|
1598
|
+
position: fixed;
|
|
1599
|
+
bottom: 0;
|
|
1600
|
+
left: 0;
|
|
1601
|
+
border-radius: 16px 16px 0 0;
|
|
1602
|
+
}
|
|
1603
|
+
|
|
1604
|
+
.reply-form input,
|
|
1605
|
+
.reply-form button {
|
|
1606
|
+
min-height: 44px;
|
|
1607
|
+
}
|
|
1608
|
+
|
|
1609
|
+
.thread-actions button {
|
|
1610
|
+
min-height: 44px;
|
|
1611
|
+
padding: 8px 12px;
|
|
1612
|
+
}
|
|
1613
|
+
}
|
|
1614
|
+
|
|
1615
|
+
.empty {
|
|
1616
|
+
text-align: center;
|
|
1617
|
+
padding: 32px 20px;
|
|
1618
|
+
color: var(--pw-text-muted);
|
|
1619
|
+
font-size: 13px;
|
|
1620
|
+
}
|
|
1621
|
+
|
|
1622
|
+
.empty-icon {
|
|
1623
|
+
font-size: 28px;
|
|
1624
|
+
margin-bottom: 6px;
|
|
1625
|
+
opacity: 0.4;
|
|
1626
|
+
}
|
|
1627
|
+
|
|
1628
|
+
/* Per-comment actions (edit/delete) */
|
|
1629
|
+
.comment-actions {
|
|
1630
|
+
display: flex;
|
|
1631
|
+
gap: 2px;
|
|
1632
|
+
margin-top: 2px;
|
|
1633
|
+
margin-left: 32px;
|
|
1634
|
+
}
|
|
1635
|
+
|
|
1636
|
+
.comment-actions button {
|
|
1637
|
+
border: none;
|
|
1638
|
+
background: none;
|
|
1639
|
+
cursor: pointer;
|
|
1640
|
+
color: var(--pw-text-muted);
|
|
1641
|
+
padding: 3px;
|
|
1642
|
+
border-radius: 4px;
|
|
1643
|
+
display: flex;
|
|
1644
|
+
align-items: center;
|
|
1645
|
+
justify-content: center;
|
|
1646
|
+
transition: all 0.15s;
|
|
1647
|
+
}
|
|
1648
|
+
|
|
1649
|
+
.comment-actions button:hover {
|
|
1650
|
+
background: var(--pw-accent-light);
|
|
1651
|
+
color: var(--pw-accent);
|
|
1652
|
+
}
|
|
1653
|
+
|
|
1654
|
+
.comment-actions button.danger:hover {
|
|
1655
|
+
background: #fef2f2;
|
|
1656
|
+
color: var(--pw-danger);
|
|
1657
|
+
}
|
|
1658
|
+
|
|
1659
|
+
.edited-badge {
|
|
1660
|
+
font-size: 10px;
|
|
1661
|
+
color: var(--pw-text-muted);
|
|
1662
|
+
font-style: italic;
|
|
1663
|
+
}
|
|
1664
|
+
|
|
1665
|
+
/* Reactions */
|
|
1666
|
+
.comment-reactions {
|
|
1667
|
+
margin-left: 32px;
|
|
1668
|
+
display: flex;
|
|
1669
|
+
gap: 4px;
|
|
1670
|
+
flex-wrap: wrap;
|
|
1671
|
+
margin-top: 4px;
|
|
1672
|
+
}
|
|
1673
|
+
|
|
1674
|
+
.reaction-pill {
|
|
1675
|
+
display: inline-flex;
|
|
1676
|
+
align-items: center;
|
|
1677
|
+
gap: 3px;
|
|
1678
|
+
padding: 2px 8px;
|
|
1679
|
+
border-radius: 12px;
|
|
1680
|
+
border: 1px solid var(--pw-border);
|
|
1681
|
+
background: var(--pw-surface);
|
|
1682
|
+
font-size: 12px;
|
|
1683
|
+
cursor: pointer;
|
|
1684
|
+
transition: all 0.15s;
|
|
1685
|
+
line-height: 1.4;
|
|
1686
|
+
}
|
|
1687
|
+
|
|
1688
|
+
.reaction-pill:hover {
|
|
1689
|
+
background: var(--pw-accent-light);
|
|
1690
|
+
border-color: var(--pw-accent);
|
|
1691
|
+
}
|
|
1692
|
+
|
|
1693
|
+
.reaction-pill.own {
|
|
1694
|
+
background: var(--pw-accent-light);
|
|
1695
|
+
border-color: var(--pw-accent);
|
|
1696
|
+
}
|
|
1697
|
+
|
|
1698
|
+
.reaction-pill .count {
|
|
1699
|
+
font-size: 11px;
|
|
1700
|
+
font-weight: 600;
|
|
1701
|
+
color: var(--pw-text-secondary);
|
|
1702
|
+
}
|
|
1703
|
+
|
|
1704
|
+
.reaction-add-btn {
|
|
1705
|
+
display: inline-flex;
|
|
1706
|
+
align-items: center;
|
|
1707
|
+
justify-content: center;
|
|
1708
|
+
width: 26px;
|
|
1709
|
+
height: 26px;
|
|
1710
|
+
border-radius: 50%;
|
|
1711
|
+
border: 1px dashed var(--pw-border);
|
|
1712
|
+
background: none;
|
|
1713
|
+
cursor: pointer;
|
|
1714
|
+
color: var(--pw-text-muted);
|
|
1715
|
+
font-size: 14px;
|
|
1716
|
+
transition: all 0.15s;
|
|
1717
|
+
position: relative;
|
|
1718
|
+
}
|
|
1719
|
+
|
|
1720
|
+
.reaction-add-btn:hover {
|
|
1721
|
+
background: var(--pw-surface-hover);
|
|
1722
|
+
border-color: var(--pw-text-muted);
|
|
1723
|
+
}
|
|
1724
|
+
|
|
1725
|
+
.emoji-picker {
|
|
1726
|
+
position: absolute;
|
|
1727
|
+
bottom: calc(100% + 4px);
|
|
1728
|
+
left: 0;
|
|
1729
|
+
display: flex;
|
|
1730
|
+
gap: 2px;
|
|
1731
|
+
padding: 4px 6px;
|
|
1732
|
+
background: var(--pw-surface);
|
|
1733
|
+
border: 1px solid var(--pw-border);
|
|
1734
|
+
border-radius: 8px;
|
|
1735
|
+
box-shadow: var(--pw-shadow);
|
|
1736
|
+
z-index: 10;
|
|
1737
|
+
}
|
|
1738
|
+
|
|
1739
|
+
.emoji-picker button {
|
|
1740
|
+
border: none;
|
|
1741
|
+
background: none;
|
|
1742
|
+
cursor: pointer;
|
|
1743
|
+
font-size: 16px;
|
|
1744
|
+
padding: 4px;
|
|
1745
|
+
border-radius: 4px;
|
|
1746
|
+
transition: background 0.1s;
|
|
1747
|
+
line-height: 1;
|
|
1748
|
+
}
|
|
1749
|
+
|
|
1750
|
+
.emoji-picker button:hover {
|
|
1751
|
+
background: var(--pw-surface-hover);
|
|
1752
|
+
}
|
|
1753
|
+
|
|
1754
|
+
/* Typing indicator */
|
|
1755
|
+
.typing-indicator {
|
|
1756
|
+
font-size: 11px;
|
|
1757
|
+
color: var(--pw-text-muted);
|
|
1758
|
+
font-style: italic;
|
|
1759
|
+
margin-left: 32px;
|
|
1760
|
+
margin-top: 4px;
|
|
1761
|
+
min-height: 16px;
|
|
1762
|
+
}
|
|
1763
|
+
|
|
1764
|
+
.edit-form {
|
|
1765
|
+
margin-left: 32px;
|
|
1766
|
+
margin-top: 4px;
|
|
1767
|
+
}
|
|
1768
|
+
|
|
1769
|
+
.edit-form textarea {
|
|
1770
|
+
width: 100%;
|
|
1771
|
+
padding: 6px 10px;
|
|
1772
|
+
border: 1.5px solid var(--pw-border);
|
|
1773
|
+
border-radius: 6px;
|
|
1774
|
+
font-size: 12px;
|
|
1775
|
+
font-family: inherit;
|
|
1776
|
+
outline: none;
|
|
1777
|
+
resize: vertical;
|
|
1778
|
+
min-height: 56px;
|
|
1779
|
+
color: var(--pw-text);
|
|
1780
|
+
background: var(--pw-surface);
|
|
1781
|
+
box-sizing: border-box;
|
|
1782
|
+
transition: border-color 0.15s, box-shadow 0.15s;
|
|
1783
|
+
}
|
|
1784
|
+
|
|
1785
|
+
.edit-form textarea:focus {
|
|
1786
|
+
border-color: var(--pw-accent);
|
|
1787
|
+
box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.1);
|
|
1788
|
+
}
|
|
1789
|
+
|
|
1790
|
+
.edit-actions {
|
|
1791
|
+
display: flex;
|
|
1792
|
+
gap: 6px;
|
|
1793
|
+
margin-top: 6px;
|
|
1794
|
+
}
|
|
1795
|
+
|
|
1796
|
+
.edit-actions button {
|
|
1797
|
+
font-size: 11px;
|
|
1798
|
+
padding: 4px 10px;
|
|
1799
|
+
}
|
|
1800
|
+
|
|
1801
|
+
.close-btn {
|
|
1802
|
+
border: none;
|
|
1803
|
+
background: none;
|
|
1804
|
+
cursor: pointer;
|
|
1805
|
+
color: var(--pw-text-muted);
|
|
1806
|
+
padding: 4px;
|
|
1807
|
+
border-radius: 6px;
|
|
1808
|
+
display: flex;
|
|
1809
|
+
align-items: center;
|
|
1810
|
+
justify-content: center;
|
|
1811
|
+
transition: all 0.15s;
|
|
1812
|
+
}
|
|
1813
|
+
.close-btn:hover {
|
|
1814
|
+
background: var(--pw-surface-hover);
|
|
1815
|
+
color: var(--pw-text);
|
|
1816
|
+
}
|
|
1817
|
+
`];L([m({attribute:!1})],O.prototype,"client",2);L([m()],O.prototype,"highlightThreadId",2);L([b()],O.prototype,"threads",2);L([b()],O.prototype,"replyingTo",2);L([b()],O.prototype,"editingCommentId",2);L([b()],O.prototype,"editBody",2);L([b()],O.prototype,"pickerOpenForComment",2);L([b()],O.prototype,"typingByThread",2);L([b()],O.prototype,"reactionsVersion",2);O=L([I("pulse-widget-comments-panel")],O);var zi=Object.defineProperty,Di=Object.getOwnPropertyDescriptor,je=(n,e,t,i)=>{for(var s=i>1?void 0:i?Di(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&zi(e,t,s),s};const Ui={"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"},Hi={"comment:created":"💬","comment:mention":"📣","comment:reply":"↩️","thread:resolved":"✅","reaction:added":"🎉"};let ie=class extends P{constructor(){super(...arguments),this.notifications=[]}connectedCallback(){super.connectedCallback(),this.setupListener()}disconnectedCallback(){var n;super.disconnectedCallback(),(n=this.unsub)==null||n.call(this)}updated(n){var e;n.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",n=>{this.notifications=[...n]}))}fireClose(){this.dispatchEvent(new CustomEvent("panel-close",{bubbles:!0,composed:!0}))}handleClick(n){n.read||this.client.markRead(n.id)}getActorName(n){var e;return((e=this.client.state.getUser(n))==null?void 0:e.name)??"Someone"}formatTime(n){const e=new Date(n),i=new Date().getTime()-e.getTime(),s=Math.floor(i/6e4);if(s<1)return"now";if(s<60)return`${s}m`;const r=Math.floor(s/60);return r<24?`${r}h`:e.toLocaleDateString()}render(){const n=this.notifications.filter(e=>!e.read).length;return d`
|
|
1818
|
+
<div class="panel">
|
|
1819
|
+
<div class="panel-header">
|
|
1820
|
+
<span class="panel-title">
|
|
1821
|
+
Notifications
|
|
1822
|
+
${n>0?d`<span class="unread-badge">${n}</span>`:u}
|
|
1823
|
+
</span>
|
|
1824
|
+
<div style="display:flex;align-items:center;gap:4px;">
|
|
1825
|
+
${n>0?d`<button class="mark-all" @click=${()=>this.client.markAllRead()}>
|
|
1826
|
+
Mark all read
|
|
1827
|
+
</button>`:u}
|
|
1828
|
+
<button class="close-btn" @click=${this.fireClose} title="Close">
|
|
1829
|
+
${E(ae,16)}
|
|
1830
|
+
</button>
|
|
1831
|
+
</div>
|
|
1832
|
+
</div>
|
|
1833
|
+
|
|
1834
|
+
<div class="panel-body pw-scrollable">
|
|
1835
|
+
${this.notifications.length===0?d`<div class="empty">
|
|
1836
|
+
<div class="empty-icon">🔔</div>
|
|
1837
|
+
No notifications
|
|
1838
|
+
</div>`:this.notifications.map(e=>d`
|
|
1839
|
+
<div
|
|
1840
|
+
class="item ${e.read?"":"unread"}"
|
|
1841
|
+
@click=${()=>this.handleClick(e)}
|
|
1842
|
+
>
|
|
1843
|
+
<span class="icon">${Hi[e.type]??"🔔"}</span>
|
|
1844
|
+
<div class="content">
|
|
1845
|
+
<div class="text">
|
|
1846
|
+
<span class="actor">${this.getActorName(e.actorId)}</span>
|
|
1847
|
+
${Ui[e.type]??e.type}
|
|
1848
|
+
</div>
|
|
1849
|
+
<div class="time">${this.formatTime(e.createdAt)}</div>
|
|
1850
|
+
</div>
|
|
1851
|
+
<span class="dot ${e.read?"read":""}"></span>
|
|
1852
|
+
</div>
|
|
1853
|
+
`)}
|
|
1854
|
+
</div>
|
|
1855
|
+
</div>
|
|
1856
|
+
`}};ie.styles=[K,le,ve,S`
|
|
1857
|
+
:host {
|
|
1858
|
+
display: block;
|
|
1859
|
+
}
|
|
1860
|
+
|
|
1861
|
+
.panel {
|
|
1862
|
+
width: 340px;
|
|
1863
|
+
max-height: 400px;
|
|
1864
|
+
background: var(--pw-surface);
|
|
1865
|
+
border-radius: var(--pw-radius);
|
|
1866
|
+
box-shadow: var(--pw-shadow-lg);
|
|
1867
|
+
border: 1px solid var(--pw-border);
|
|
1868
|
+
display: flex;
|
|
1869
|
+
flex-direction: column;
|
|
1870
|
+
overflow: hidden;
|
|
1871
|
+
}
|
|
1872
|
+
|
|
1873
|
+
.panel-header {
|
|
1874
|
+
display: flex;
|
|
1875
|
+
align-items: center;
|
|
1876
|
+
justify-content: space-between;
|
|
1877
|
+
padding: 14px 16px;
|
|
1878
|
+
border-bottom: 1px solid var(--pw-border-light);
|
|
1879
|
+
flex-shrink: 0;
|
|
1880
|
+
}
|
|
1881
|
+
|
|
1882
|
+
.panel-title {
|
|
1883
|
+
font-size: 14px;
|
|
1884
|
+
font-weight: 700;
|
|
1885
|
+
color: var(--pw-text);
|
|
1886
|
+
display: flex;
|
|
1887
|
+
align-items: center;
|
|
1888
|
+
gap: 6px;
|
|
1889
|
+
}
|
|
1890
|
+
|
|
1891
|
+
.unread-badge {
|
|
1892
|
+
background: var(--pw-danger);
|
|
1893
|
+
color: #fff;
|
|
1894
|
+
font-size: 10px;
|
|
1895
|
+
font-weight: 700;
|
|
1896
|
+
padding: 1px 6px;
|
|
1897
|
+
border-radius: 8px;
|
|
1898
|
+
min-width: 16px;
|
|
1899
|
+
text-align: center;
|
|
1900
|
+
}
|
|
1901
|
+
|
|
1902
|
+
.mark-all {
|
|
1903
|
+
border: none;
|
|
1904
|
+
background: none;
|
|
1905
|
+
color: var(--pw-accent);
|
|
1906
|
+
cursor: pointer;
|
|
1907
|
+
font-size: 11px;
|
|
1908
|
+
font-weight: 600;
|
|
1909
|
+
padding: 3px 8px;
|
|
1910
|
+
border-radius: 4px;
|
|
1911
|
+
font-family: inherit;
|
|
1912
|
+
transition: background 0.15s;
|
|
1913
|
+
}
|
|
1914
|
+
|
|
1915
|
+
.mark-all:hover {
|
|
1916
|
+
background: var(--pw-accent-light);
|
|
1917
|
+
}
|
|
1918
|
+
|
|
1919
|
+
.panel-body {
|
|
1920
|
+
flex: 1;
|
|
1921
|
+
overflow-y: auto;
|
|
1922
|
+
min-height: 0;
|
|
1923
|
+
}
|
|
1924
|
+
|
|
1925
|
+
.item {
|
|
1926
|
+
display: flex;
|
|
1927
|
+
align-items: flex-start;
|
|
1928
|
+
gap: 10px;
|
|
1929
|
+
padding: 12px 16px;
|
|
1930
|
+
cursor: pointer;
|
|
1931
|
+
transition: background 0.1s;
|
|
1932
|
+
border-bottom: 1px solid var(--pw-border-light);
|
|
1933
|
+
}
|
|
1934
|
+
|
|
1935
|
+
.item:last-child {
|
|
1936
|
+
border-bottom: none;
|
|
1937
|
+
}
|
|
1938
|
+
|
|
1939
|
+
.item:hover {
|
|
1940
|
+
background: var(--pw-surface-hover);
|
|
1941
|
+
}
|
|
1942
|
+
|
|
1943
|
+
.item.unread {
|
|
1944
|
+
background: var(--pw-accent-light);
|
|
1945
|
+
}
|
|
1946
|
+
|
|
1947
|
+
.item.unread:hover {
|
|
1948
|
+
background: #e0e7ff;
|
|
1949
|
+
}
|
|
1950
|
+
|
|
1951
|
+
.icon {
|
|
1952
|
+
width: 28px;
|
|
1953
|
+
height: 28px;
|
|
1954
|
+
border-radius: 6px;
|
|
1955
|
+
background: var(--pw-border-light);
|
|
1956
|
+
display: flex;
|
|
1957
|
+
align-items: center;
|
|
1958
|
+
justify-content: center;
|
|
1959
|
+
font-size: 13px;
|
|
1960
|
+
flex-shrink: 0;
|
|
1961
|
+
}
|
|
1962
|
+
|
|
1963
|
+
.item.unread .icon {
|
|
1964
|
+
background: #c7d2fe;
|
|
1965
|
+
}
|
|
1966
|
+
|
|
1967
|
+
.content {
|
|
1968
|
+
flex: 1;
|
|
1969
|
+
min-width: 0;
|
|
1970
|
+
}
|
|
1971
|
+
|
|
1972
|
+
.text {
|
|
1973
|
+
font-size: 12px;
|
|
1974
|
+
color: var(--pw-text-secondary);
|
|
1975
|
+
line-height: 1.4;
|
|
1976
|
+
}
|
|
1977
|
+
|
|
1978
|
+
.actor {
|
|
1979
|
+
font-weight: 600;
|
|
1980
|
+
color: var(--pw-text);
|
|
1981
|
+
}
|
|
1982
|
+
|
|
1983
|
+
.time {
|
|
1984
|
+
font-size: 10px;
|
|
1985
|
+
color: var(--pw-text-muted);
|
|
1986
|
+
margin-top: 2px;
|
|
1987
|
+
}
|
|
1988
|
+
|
|
1989
|
+
.dot {
|
|
1990
|
+
width: 6px;
|
|
1991
|
+
height: 6px;
|
|
1992
|
+
border-radius: 50%;
|
|
1993
|
+
background: var(--pw-accent);
|
|
1994
|
+
flex-shrink: 0;
|
|
1995
|
+
margin-top: 5px;
|
|
1996
|
+
}
|
|
1997
|
+
|
|
1998
|
+
.dot.read {
|
|
1999
|
+
visibility: hidden;
|
|
2000
|
+
}
|
|
2001
|
+
|
|
2002
|
+
.empty {
|
|
2003
|
+
text-align: center;
|
|
2004
|
+
padding: 32px 20px;
|
|
2005
|
+
color: var(--pw-text-muted);
|
|
2006
|
+
font-size: 13px;
|
|
2007
|
+
}
|
|
2008
|
+
|
|
2009
|
+
.empty-icon {
|
|
2010
|
+
font-size: 24px;
|
|
2011
|
+
margin-bottom: 6px;
|
|
2012
|
+
opacity: 0.4;
|
|
2013
|
+
}
|
|
2014
|
+
|
|
2015
|
+
.close-btn {
|
|
2016
|
+
border: none;
|
|
2017
|
+
background: none;
|
|
2018
|
+
cursor: pointer;
|
|
2019
|
+
color: var(--pw-text-muted);
|
|
2020
|
+
padding: 4px;
|
|
2021
|
+
border-radius: 6px;
|
|
2022
|
+
display: flex;
|
|
2023
|
+
align-items: center;
|
|
2024
|
+
justify-content: center;
|
|
2025
|
+
transition: all 0.15s;
|
|
2026
|
+
}
|
|
2027
|
+
.close-btn:hover {
|
|
2028
|
+
background: var(--pw-surface-hover);
|
|
2029
|
+
color: var(--pw-text);
|
|
2030
|
+
}
|
|
2031
|
+
|
|
2032
|
+
/* Mobile responsive */
|
|
2033
|
+
@media (max-width: 480px) {
|
|
2034
|
+
.panel {
|
|
2035
|
+
width: 100vw;
|
|
2036
|
+
max-height: 60vh;
|
|
2037
|
+
position: fixed;
|
|
2038
|
+
bottom: 0;
|
|
2039
|
+
left: 0;
|
|
2040
|
+
border-radius: 16px 16px 0 0;
|
|
2041
|
+
}
|
|
2042
|
+
|
|
2043
|
+
.item {
|
|
2044
|
+
min-height: 44px;
|
|
2045
|
+
}
|
|
2046
|
+
}
|
|
2047
|
+
`];je([m({attribute:!1})],ie.prototype,"client",2);je([b()],ie.prototype,"notifications",2);ie=je([I("pulse-widget-notifications-panel")],ie);const Ni=3e3;class Bi{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(r=>r.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>Ni){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(o=>o.user.id===e),s=(i==null?void 0:i.user.color)??"#6366f1",r=document.createElement("div");Object.assign(r.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(r),requestAnimationFrame(()=>{r.style.width="60px",r.style.height="60px",r.style.opacity="0"}),setTimeout(()=>r.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=`
|
|
2048
|
+
<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))">
|
|
2049
|
+
<path d="M0 0l6.5 16L8 9l7-2.5z" stroke="#fff" stroke-width="1"/>
|
|
2050
|
+
</svg>
|
|
2051
|
+
<span style="
|
|
2052
|
+
position:absolute;left:20px;top:18px;
|
|
2053
|
+
padding:4px 10px;border-radius:6px;
|
|
2054
|
+
font-size:12px;font-weight:700;
|
|
2055
|
+
font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,sans-serif;
|
|
2056
|
+
color:#fff;white-space:nowrap;
|
|
2057
|
+
background:${s};
|
|
2058
|
+
box-shadow:0 2px 10px rgba(0,0,0,0.25);
|
|
2059
|
+
letter-spacing:0.01em;
|
|
2060
|
+
">${t.name}</span>
|
|
2061
|
+
`,this.container.appendChild(i),this.cursorEls.set(e,i)}i.style.transform=`translate(${t.position.x}px, ${t.position.y}px)`}}class Fi{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 l,a,c;t.preventDefault(),(a=(l=t.target)==null?void 0:l.setPointerCapture)==null||a.call(l,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",o=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(o)),this.currentPath.setAttribute("stroke-linecap","round"),this.currentPath.setAttribute("stroke-linejoin","round"),this.currentPath.setAttribute("points",`${t.clientX},${t.clientY}`),(c=this.container)==null||c.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 r=this.currentPoints.map(o=>`${o.x},${o.y}`).join(" ");this.currentPath.setAttribute("points",r)},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(r=>`${r.x},${r.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 Wi(n){if(!n.rangeCount||n.isCollapsed)return null;const e=n.getRangeAt(0),t=e.startContainer,i=e.endContainer,s=it(t),r=it(i);return!s||!r?null:{startSelector:s,startOffset:e.startOffset,endSelector:r,endOffset:e.endOffset}}function qi(n){var e,t;try{const i=nt(n.startSelector),s=nt(n.endSelector);if(!i||!s)return null;const r=document.createRange(),o=i.nodeType===Node.TEXT_NODE?((e=i.textContent)==null?void 0:e.length)??0:i.childNodes.length,l=s.nodeType===Node.TEXT_NODE?((t=s.textContent)==null?void 0:t.length)??0:s.childNodes.length;return r.setStart(i,Math.min(n.startOffset,o)),r.setEnd(s,Math.min(n.endOffset,l)),r}catch{return null}}function it(n){if(n.nodeType===Node.TEXT_NODE){const e=n.parentElement;if(!e)return null;const t=st(e);if(!t)return null;const i=Array.from(e.childNodes).indexOf(n);return`${t}::text(${i})`}return n.nodeType===Node.ELEMENT_NODE?st(n):null}function st(n){if(!n||n===document.documentElement)return"html";if(n===document.body)return"body";if(n.id)return`#${CSS.escape(n.id)}`;const e=[];let t=n,i=0;for(;t&&t!==document.body&&i<10;){const s=t.parentElement;if(!s)break;const r=t.tagName.toLowerCase(),o=t.tagName,l=Array.from(s.children).filter(a=>a.tagName===o);if(l.length===1)e.unshift(r);else{const a=l.indexOf(t)+1;e.unshift(`${r}:nth-of-type(${a})`)}if(s.id){e.unshift(`#${CSS.escape(s.id)}`);break}t=s,i++}return e.length>0?e.join(" > "):null}function nt(n){const e=n.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(n)}catch{return null}}class Vi{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 l;if(!this.container)return;const i=(l=this.client.state.user)==null?void 0:l.id;if(e===i||(this.clearSelection(e),!t))return;const s=qi(t);if(!s)return;const r=this.client.state.presence.find(a=>a.user.id===e),o=(r==null?void 0:r.user.color)??"#6366f1";try{const a=s.getClientRects(),c=[];for(let p=0;p<a.length;p++){const h=a[p],f=document.createElement("div");Object.assign(f.style,{position:"absolute",left:`${h.left}px`,top:`${h.top}px`,width:`${h.width}px`,height:`${h.height}px`,background:o,opacity:"0.2",borderRadius:"2px",pointerEvents:"none"}),this.container.appendChild(f),c.push(f)}this.selectionEls.set(e,c)}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 Yi=Object.defineProperty,Xi=Object.getOwnPropertyDescriptor,Le=(n,e,t,i)=>{for(var s=i>1?void 0:i?Xi(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&Yi(e,t,s),s};let se=class extends P{constructor(){super(...arguments),this.roomId=""}fireClose(){this.dispatchEvent(new CustomEvent("panel-close",{bubbles:!0,composed:!0}))}toggle(n){const e={...this.settings,[n]:!this.settings[n]};this.dispatchEvent(new CustomEvent("settings-change",{detail:e,bubbles:!0,composed:!0}))}renderToggle(n,e){return d`
|
|
2062
|
+
<div class="setting-row">
|
|
2063
|
+
<span class="setting-label">${n}</span>
|
|
2064
|
+
<label class="toggle">
|
|
2065
|
+
<input
|
|
2066
|
+
type="checkbox"
|
|
2067
|
+
.checked=${this.settings[e]}
|
|
2068
|
+
@change=${()=>this.toggle(e)}
|
|
2069
|
+
/>
|
|
2070
|
+
<span class="toggle-track"></span>
|
|
2071
|
+
</label>
|
|
2072
|
+
</div>
|
|
2073
|
+
`}render(){const n=!this.settings.enabled;return d`
|
|
2074
|
+
<div class="panel">
|
|
2075
|
+
<div class="panel-header">
|
|
2076
|
+
<span class="panel-title">Settings</span>
|
|
2077
|
+
<button class="close-btn" @click=${this.fireClose} title="Close">
|
|
2078
|
+
${E(ae,16)}
|
|
2079
|
+
</button>
|
|
2080
|
+
</div>
|
|
2081
|
+
|
|
2082
|
+
<div class="master-row">
|
|
2083
|
+
<div>
|
|
2084
|
+
<div class="master-label">Enable collaboration</div>
|
|
2085
|
+
<div class="master-hint">Cursors, clicks, presence & pins</div>
|
|
2086
|
+
</div>
|
|
2087
|
+
<label class="toggle">
|
|
2088
|
+
<input
|
|
2089
|
+
type="checkbox"
|
|
2090
|
+
.checked=${this.settings.enabled}
|
|
2091
|
+
@change=${()=>this.toggle("enabled")}
|
|
2092
|
+
/>
|
|
2093
|
+
<span class="toggle-track"></span>
|
|
2094
|
+
</label>
|
|
2095
|
+
</div>
|
|
2096
|
+
|
|
2097
|
+
<div class="panel-body pw-scrollable ${n?"settings-disabled":""}">
|
|
2098
|
+
<div class="section-label">Cursors</div>
|
|
2099
|
+
${this.renderToggle("Show my cursor to others","showMyCursor")}
|
|
2100
|
+
${this.renderToggle("Show others' cursors","showOthersCursors")}
|
|
2101
|
+
|
|
2102
|
+
<div class="section-label">Click Indicators</div>
|
|
2103
|
+
${this.renderToggle("Show my clicks to others","showMyClicks")}
|
|
2104
|
+
${this.renderToggle("Show others' clicks","showOthersClicks")}
|
|
2105
|
+
|
|
2106
|
+
<div class="section-label">Presence</div>
|
|
2107
|
+
${this.renderToggle("Appear offline","appearOffline")}
|
|
2108
|
+
|
|
2109
|
+
<div class="section-label">Comments</div>
|
|
2110
|
+
${this.renderToggle("Show comment pins","showCommentPins")}
|
|
2111
|
+
|
|
2112
|
+
<div class="section-label">Viewport & Selection</div>
|
|
2113
|
+
${this.renderToggle("Show viewport indicators","showViewportIndicators")}
|
|
2114
|
+
${this.renderToggle("Show text selections","showSelections")}
|
|
2115
|
+
|
|
2116
|
+
<div class="section-label">Interactions</div>
|
|
2117
|
+
${this.renderToggle("Show drawings","showDrawings")}
|
|
2118
|
+
</div>
|
|
2119
|
+
</div>
|
|
2120
|
+
`}};se.styles=[K,le,ve,S`
|
|
2121
|
+
:host {
|
|
2122
|
+
display: block;
|
|
2123
|
+
}
|
|
2124
|
+
|
|
2125
|
+
.panel {
|
|
2126
|
+
width: 340px;
|
|
2127
|
+
max-height: 480px;
|
|
2128
|
+
background: var(--pw-surface);
|
|
2129
|
+
border-radius: var(--pw-radius);
|
|
2130
|
+
box-shadow: var(--pw-shadow-lg);
|
|
2131
|
+
border: 1px solid var(--pw-border);
|
|
2132
|
+
display: flex;
|
|
2133
|
+
flex-direction: column;
|
|
2134
|
+
overflow: hidden;
|
|
2135
|
+
}
|
|
2136
|
+
|
|
2137
|
+
.panel-header {
|
|
2138
|
+
display: flex;
|
|
2139
|
+
align-items: center;
|
|
2140
|
+
justify-content: space-between;
|
|
2141
|
+
padding: 14px 16px;
|
|
2142
|
+
border-bottom: 1px solid var(--pw-border-light);
|
|
2143
|
+
flex-shrink: 0;
|
|
2144
|
+
}
|
|
2145
|
+
|
|
2146
|
+
.panel-title {
|
|
2147
|
+
font-size: 14px;
|
|
2148
|
+
font-weight: 700;
|
|
2149
|
+
color: var(--pw-text);
|
|
2150
|
+
}
|
|
2151
|
+
|
|
2152
|
+
.close-btn {
|
|
2153
|
+
border: none;
|
|
2154
|
+
background: none;
|
|
2155
|
+
cursor: pointer;
|
|
2156
|
+
color: var(--pw-text-muted);
|
|
2157
|
+
padding: 4px;
|
|
2158
|
+
border-radius: 6px;
|
|
2159
|
+
display: flex;
|
|
2160
|
+
align-items: center;
|
|
2161
|
+
justify-content: center;
|
|
2162
|
+
transition: all 0.15s;
|
|
2163
|
+
}
|
|
2164
|
+
.close-btn:hover {
|
|
2165
|
+
background: var(--pw-surface-hover);
|
|
2166
|
+
color: var(--pw-text);
|
|
2167
|
+
}
|
|
2168
|
+
|
|
2169
|
+
.panel-body {
|
|
2170
|
+
flex: 1;
|
|
2171
|
+
overflow-y: auto;
|
|
2172
|
+
min-height: 0;
|
|
2173
|
+
padding: 8px 0;
|
|
2174
|
+
}
|
|
2175
|
+
|
|
2176
|
+
.section-label {
|
|
2177
|
+
font-size: 10px;
|
|
2178
|
+
font-weight: 700;
|
|
2179
|
+
color: var(--pw-text-muted);
|
|
2180
|
+
letter-spacing: 0.05em;
|
|
2181
|
+
text-transform: uppercase;
|
|
2182
|
+
padding: 10px 16px 4px;
|
|
2183
|
+
}
|
|
2184
|
+
|
|
2185
|
+
.setting-row {
|
|
2186
|
+
display: flex;
|
|
2187
|
+
align-items: center;
|
|
2188
|
+
justify-content: space-between;
|
|
2189
|
+
padding: 8px 16px;
|
|
2190
|
+
transition: background 0.1s;
|
|
2191
|
+
}
|
|
2192
|
+
|
|
2193
|
+
.setting-row:hover {
|
|
2194
|
+
background: var(--pw-surface-hover);
|
|
2195
|
+
}
|
|
2196
|
+
|
|
2197
|
+
.setting-label {
|
|
2198
|
+
font-size: 13px;
|
|
2199
|
+
color: var(--pw-text-secondary);
|
|
2200
|
+
}
|
|
2201
|
+
|
|
2202
|
+
/* Toggle switch */
|
|
2203
|
+
.toggle {
|
|
2204
|
+
position: relative;
|
|
2205
|
+
width: 36px;
|
|
2206
|
+
height: 20px;
|
|
2207
|
+
flex-shrink: 0;
|
|
2208
|
+
}
|
|
2209
|
+
|
|
2210
|
+
.toggle input {
|
|
2211
|
+
opacity: 0;
|
|
2212
|
+
width: 0;
|
|
2213
|
+
height: 0;
|
|
2214
|
+
position: absolute;
|
|
2215
|
+
}
|
|
2216
|
+
|
|
2217
|
+
.toggle-track {
|
|
2218
|
+
position: absolute;
|
|
2219
|
+
inset: 0;
|
|
2220
|
+
background: var(--pw-border);
|
|
2221
|
+
border-radius: 10px;
|
|
2222
|
+
cursor: pointer;
|
|
2223
|
+
transition: background 0.2s;
|
|
2224
|
+
}
|
|
2225
|
+
|
|
2226
|
+
.toggle-track::after {
|
|
2227
|
+
content: "";
|
|
2228
|
+
position: absolute;
|
|
2229
|
+
top: 2px;
|
|
2230
|
+
left: 2px;
|
|
2231
|
+
width: 16px;
|
|
2232
|
+
height: 16px;
|
|
2233
|
+
background: #fff;
|
|
2234
|
+
border-radius: 50%;
|
|
2235
|
+
transition: transform 0.2s;
|
|
2236
|
+
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
|
|
2237
|
+
}
|
|
2238
|
+
|
|
2239
|
+
.toggle input:checked + .toggle-track {
|
|
2240
|
+
background: var(--pw-accent);
|
|
2241
|
+
}
|
|
2242
|
+
|
|
2243
|
+
.toggle input:checked + .toggle-track::after {
|
|
2244
|
+
transform: translateX(16px);
|
|
2245
|
+
}
|
|
2246
|
+
|
|
2247
|
+
/* Master toggle row */
|
|
2248
|
+
.master-row {
|
|
2249
|
+
display: flex;
|
|
2250
|
+
align-items: center;
|
|
2251
|
+
justify-content: space-between;
|
|
2252
|
+
padding: 12px 16px;
|
|
2253
|
+
border-bottom: 1px solid var(--pw-border-light);
|
|
2254
|
+
}
|
|
2255
|
+
|
|
2256
|
+
.master-label {
|
|
2257
|
+
font-size: 13px;
|
|
2258
|
+
font-weight: 600;
|
|
2259
|
+
color: var(--pw-text);
|
|
2260
|
+
}
|
|
2261
|
+
|
|
2262
|
+
.master-hint {
|
|
2263
|
+
font-size: 11px;
|
|
2264
|
+
color: var(--pw-text-muted);
|
|
2265
|
+
margin-top: 1px;
|
|
2266
|
+
}
|
|
2267
|
+
|
|
2268
|
+
/* Dim all settings when master is off */
|
|
2269
|
+
.settings-disabled {
|
|
2270
|
+
opacity: 0.4;
|
|
2271
|
+
pointer-events: none;
|
|
2272
|
+
}
|
|
2273
|
+
|
|
2274
|
+
/* Mobile responsive */
|
|
2275
|
+
@media (max-width: 480px) {
|
|
2276
|
+
.panel {
|
|
2277
|
+
width: 100vw;
|
|
2278
|
+
max-height: 60vh;
|
|
2279
|
+
position: fixed;
|
|
2280
|
+
bottom: 0;
|
|
2281
|
+
left: 0;
|
|
2282
|
+
border-radius: 16px 16px 0 0;
|
|
2283
|
+
}
|
|
2284
|
+
|
|
2285
|
+
.setting-row {
|
|
2286
|
+
min-height: 44px;
|
|
2287
|
+
}
|
|
2288
|
+
}
|
|
2289
|
+
`];Le([m({attribute:!1})],se.prototype,"settings",2);Le([m()],se.prototype,"roomId",2);se=Le([I("pulse-widget-settings-panel")],se);const he={enabled:!0,showMyCursor:!0,showOthersCursors:!0,showMyClicks:!0,showOthersClicks:!0,appearOffline:!1,showCommentPins:!0,showViewportIndicators:!0,showSelections:!0,showDrawings:!0},gt="pulse:settings:";function Ki(n){try{const e=localStorage.getItem(`${gt}${n}`);return e?{...he,...JSON.parse(e)}:{...he}}catch{return{...he}}}function Gi(n,e){localStorage.setItem(`${gt}${n}`,JSON.stringify(e))}var Ji=Object.defineProperty,Zi=Object.getOwnPropertyDescriptor,j=(n,e,t,i)=>{for(var s=i>1?void 0:i?Zi(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&Ji(e,t,s),s};let M=class extends P{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.users=[],this.unreadCount=0}connectedCallback(){super.connectedCallback(),this.setupPresence()}disconnectedCallback(){var n,e;super.disconnectedCallback(),(n=this.unsub)==null||n.call(this),(e=this.notifUnsub)==null||e.call(this)}updated(n){var e,t;n.has("client")&&this.client&&((e=this.unsub)==null||e.call(this),(t=this.notifUnsub)==null||t.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",n=>{this.users=n}),this.notifUnsub=this.client.state.on("notifications",()=>{this.unreadCount=this.client.state.unreadCount}))}getInitials(n){return n.split(" ").map(e=>e[0]).join("").toUpperCase().slice(0,2)}fire(n){this.dispatchEvent(new CustomEvent("toolbar-action",{detail:n,bubbles:!0,composed:!0}))}fireFollow(n){this.dispatchEvent(new CustomEvent("toolbar-follow",{detail:n,bubbles:!0,composed:!0}))}fireToggle(){this.dispatchEvent(new CustomEvent("toolbar-toggle",{bubbles:!0,composed:!0}))}render(){const n=this.display==="inline";if(this.collapsed)return d`
|
|
2290
|
+
<div class="toolbar collapsed ${n?"inline":""}" @click=${this.fireToggle}>
|
|
2291
|
+
<span class="fab-icon">${E(xi,n?18:24)}</span>
|
|
2292
|
+
</div>
|
|
2293
|
+
`;const e=this.users.slice(0,3),t=this.users.length-3;return d`
|
|
2294
|
+
<div class="toolbar ${n?"inline":""}"
|
|
2295
|
+
<!-- Presence avatars -->
|
|
2296
|
+
${this.users.length>0?d`
|
|
2297
|
+
<div class="presence">
|
|
2298
|
+
${t>0?d`<div class="presence-overflow">+${t}</div>`:u}
|
|
2299
|
+
${e.map(i=>d`
|
|
2300
|
+
<div
|
|
2301
|
+
class="presence-avatar clickable ${this.followingUserId===i.user.id?"following":""}"
|
|
2302
|
+
style="background:${i.user.color}"
|
|
2303
|
+
@click=${()=>this.fireFollow(i.user.id)}
|
|
2304
|
+
title="Click to follow ${i.user.name}"
|
|
2305
|
+
>
|
|
2306
|
+
${i.user.avatar?d`<img src="${i.user.avatar}" alt="${i.user.name}" />`:this.getInitials(i.user.name)}
|
|
2307
|
+
<span class="presence-tooltip">${i.user.name}</span>
|
|
2308
|
+
${i.deviceType&&i.deviceType!=="desktop"?d`<span class="device-icon">${i.deviceType==="mobile"?"📱":"📲"}</span>`:u}
|
|
2309
|
+
</div>
|
|
2310
|
+
`)}
|
|
2311
|
+
</div>
|
|
2312
|
+
<div class="separator"></div>
|
|
2313
|
+
`:u}
|
|
2314
|
+
|
|
2315
|
+
<!-- Pin comment (primary) -->
|
|
2316
|
+
<button
|
|
2317
|
+
class="pw-btn pw-btn-icon ${this.pinModeActive?"active":""}"
|
|
2318
|
+
@click=${()=>this.fire("pin-mode")}
|
|
2319
|
+
title="Comment anywhere"
|
|
2320
|
+
?disabled=${this.featuresDisabled}
|
|
2321
|
+
style="${this.featuresDisabled?"opacity:0.35;pointer-events:none":""}"
|
|
2322
|
+
>
|
|
2323
|
+
${E(ft)}
|
|
2324
|
+
</button>
|
|
2325
|
+
|
|
2326
|
+
<!-- View comments -->
|
|
2327
|
+
<button
|
|
2328
|
+
class="pw-btn pw-btn-icon ${this.activePanel==="comments"?"active":""}"
|
|
2329
|
+
@click=${()=>this.fire("comments")}
|
|
2330
|
+
title="View comments"
|
|
2331
|
+
?disabled=${this.featuresDisabled}
|
|
2332
|
+
style="${this.featuresDisabled?"opacity:0.35;pointer-events:none":""}"
|
|
2333
|
+
>
|
|
2334
|
+
${E(fi)}
|
|
2335
|
+
</button>
|
|
2336
|
+
|
|
2337
|
+
<!-- Activity feed -->
|
|
2338
|
+
<button
|
|
2339
|
+
class="pw-btn pw-btn-icon ${this.activePanel==="activity"?"active":""}"
|
|
2340
|
+
@click=${()=>this.fire("activity")}
|
|
2341
|
+
title="Activity feed"
|
|
2342
|
+
?disabled=${this.featuresDisabled}
|
|
2343
|
+
style="${this.featuresDisabled?"opacity:0.35;pointer-events:none":""}"
|
|
2344
|
+
>
|
|
2345
|
+
${E(ui)}
|
|
2346
|
+
</button>
|
|
2347
|
+
|
|
2348
|
+
<!-- Draw mode -->
|
|
2349
|
+
<button
|
|
2350
|
+
class="pw-btn pw-btn-icon ${this.drawModeActive?"active":""}"
|
|
2351
|
+
@click=${()=>this.fire("draw-mode")}
|
|
2352
|
+
title="Draw on page"
|
|
2353
|
+
?disabled=${this.featuresDisabled}
|
|
2354
|
+
style="${this.featuresDisabled?"opacity:0.35;pointer-events:none":""}"
|
|
2355
|
+
>
|
|
2356
|
+
${E(mi)}
|
|
2357
|
+
</button>
|
|
2358
|
+
|
|
2359
|
+
<!-- Notifications -->
|
|
2360
|
+
<button
|
|
2361
|
+
class="pw-btn pw-btn-icon ${this.activePanel==="notifications"?"active":""}"
|
|
2362
|
+
@click=${()=>this.fire("notifications")}
|
|
2363
|
+
title="Notifications"
|
|
2364
|
+
?disabled=${this.featuresDisabled}
|
|
2365
|
+
style="${this.featuresDisabled?"opacity:0.35;pointer-events:none":"position:relative"}"
|
|
2366
|
+
>
|
|
2367
|
+
${E(hi)}
|
|
2368
|
+
${this.unreadCount>0?d`<span class="badge">${this.unreadCount>9?"9+":this.unreadCount}</span>`:u}
|
|
2369
|
+
</button>
|
|
2370
|
+
|
|
2371
|
+
<!-- Settings -->
|
|
2372
|
+
<button
|
|
2373
|
+
class="pw-btn pw-btn-icon ${this.activePanel==="settings"?"active":""}"
|
|
2374
|
+
@click=${()=>this.fire("settings")}
|
|
2375
|
+
title="Settings"
|
|
2376
|
+
>
|
|
2377
|
+
${E(bi)}
|
|
2378
|
+
</button>
|
|
2379
|
+
|
|
2380
|
+
<div class="separator"></div>
|
|
2381
|
+
|
|
2382
|
+
<!-- Collapse -->
|
|
2383
|
+
<button
|
|
2384
|
+
class="pw-btn pw-btn-icon close-btn"
|
|
2385
|
+
@click=${this.fireToggle}
|
|
2386
|
+
title="Collapse"
|
|
2387
|
+
>
|
|
2388
|
+
${E(ae,14)}
|
|
2389
|
+
</button>
|
|
2390
|
+
</div>
|
|
2391
|
+
`}};M.styles=[K,le,S`
|
|
2392
|
+
:host {
|
|
2393
|
+
display: block;
|
|
2394
|
+
}
|
|
2395
|
+
|
|
2396
|
+
.toolbar {
|
|
2397
|
+
display: flex;
|
|
2398
|
+
align-items: center;
|
|
2399
|
+
gap: 4px;
|
|
2400
|
+
padding: 6px;
|
|
2401
|
+
background: var(--pw-surface);
|
|
2402
|
+
border-radius: 20px;
|
|
2403
|
+
box-shadow: var(--pw-shadow);
|
|
2404
|
+
border: 1px solid var(--pw-border);
|
|
2405
|
+
transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
|
|
2406
|
+
}
|
|
2407
|
+
|
|
2408
|
+
.toolbar.collapsed {
|
|
2409
|
+
padding: 0;
|
|
2410
|
+
border-radius: 50%;
|
|
2411
|
+
width: 48px;
|
|
2412
|
+
height: 48px;
|
|
2413
|
+
justify-content: center;
|
|
2414
|
+
cursor: pointer;
|
|
2415
|
+
}
|
|
2416
|
+
|
|
2417
|
+
.toolbar.collapsed:hover {
|
|
2418
|
+
transform: scale(1.08);
|
|
2419
|
+
box-shadow: var(--pw-shadow-lg);
|
|
2420
|
+
}
|
|
2421
|
+
|
|
2422
|
+
/* Inline expanded: no outer shadow, lighter border */
|
|
2423
|
+
.toolbar.inline {
|
|
2424
|
+
box-shadow: none;
|
|
2425
|
+
border-radius: 8px;
|
|
2426
|
+
}
|
|
2427
|
+
|
|
2428
|
+
.fab-icon {
|
|
2429
|
+
color: var(--pw-accent);
|
|
2430
|
+
}
|
|
2431
|
+
|
|
2432
|
+
.separator {
|
|
2433
|
+
width: 1px;
|
|
2434
|
+
height: 24px;
|
|
2435
|
+
background: var(--pw-border);
|
|
2436
|
+
margin: 0 2px;
|
|
2437
|
+
flex-shrink: 0;
|
|
2438
|
+
}
|
|
2439
|
+
|
|
2440
|
+
/* Compact presence avatars */
|
|
2441
|
+
.presence {
|
|
2442
|
+
display: flex;
|
|
2443
|
+
flex-direction: row-reverse;
|
|
2444
|
+
margin-left: 4px;
|
|
2445
|
+
margin-right: 2px;
|
|
2446
|
+
}
|
|
2447
|
+
|
|
2448
|
+
.presence-avatar {
|
|
2449
|
+
width: 28px;
|
|
2450
|
+
height: 28px;
|
|
2451
|
+
border-radius: 50%;
|
|
2452
|
+
border: 2px solid var(--pw-surface);
|
|
2453
|
+
margin-left: -8px;
|
|
2454
|
+
display: flex;
|
|
2455
|
+
align-items: center;
|
|
2456
|
+
justify-content: center;
|
|
2457
|
+
font-size: 10px;
|
|
2458
|
+
font-weight: 700;
|
|
2459
|
+
color: #fff;
|
|
2460
|
+
cursor: default;
|
|
2461
|
+
position: relative;
|
|
2462
|
+
flex-shrink: 0;
|
|
2463
|
+
transition: transform 0.15s ease;
|
|
2464
|
+
}
|
|
2465
|
+
|
|
2466
|
+
.presence-avatar:hover {
|
|
2467
|
+
transform: scale(1.1);
|
|
2468
|
+
z-index: 2;
|
|
2469
|
+
}
|
|
2470
|
+
|
|
2471
|
+
.presence-avatar:last-child {
|
|
2472
|
+
margin-left: 0;
|
|
2473
|
+
}
|
|
2474
|
+
|
|
2475
|
+
.presence-avatar img {
|
|
2476
|
+
width: 100%;
|
|
2477
|
+
height: 100%;
|
|
2478
|
+
object-fit: cover;
|
|
2479
|
+
border-radius: 50%;
|
|
2480
|
+
}
|
|
2481
|
+
|
|
2482
|
+
.presence-overflow {
|
|
2483
|
+
width: 28px;
|
|
2484
|
+
height: 28px;
|
|
2485
|
+
border-radius: 50%;
|
|
2486
|
+
border: 2px solid var(--pw-surface);
|
|
2487
|
+
margin-left: -8px;
|
|
2488
|
+
display: flex;
|
|
2489
|
+
align-items: center;
|
|
2490
|
+
justify-content: center;
|
|
2491
|
+
font-size: 9px;
|
|
2492
|
+
font-weight: 700;
|
|
2493
|
+
color: var(--pw-text-secondary);
|
|
2494
|
+
background: var(--pw-border);
|
|
2495
|
+
}
|
|
2496
|
+
|
|
2497
|
+
.presence-tooltip {
|
|
2498
|
+
position: absolute;
|
|
2499
|
+
bottom: calc(100% + 6px);
|
|
2500
|
+
left: 50%;
|
|
2501
|
+
transform: translateX(-50%);
|
|
2502
|
+
padding: 3px 8px;
|
|
2503
|
+
background: var(--pw-text);
|
|
2504
|
+
color: #fff;
|
|
2505
|
+
font-size: 10px;
|
|
2506
|
+
font-weight: 500;
|
|
2507
|
+
border-radius: 4px;
|
|
2508
|
+
white-space: nowrap;
|
|
2509
|
+
pointer-events: none;
|
|
2510
|
+
opacity: 0;
|
|
2511
|
+
transition: opacity 0.15s;
|
|
2512
|
+
z-index: 10;
|
|
2513
|
+
}
|
|
2514
|
+
.presence-tooltip::after {
|
|
2515
|
+
content: "";
|
|
2516
|
+
position: absolute;
|
|
2517
|
+
top: 100%;
|
|
2518
|
+
left: 50%;
|
|
2519
|
+
transform: translateX(-50%);
|
|
2520
|
+
border: 3px solid transparent;
|
|
2521
|
+
border-top-color: var(--pw-text);
|
|
2522
|
+
}
|
|
2523
|
+
.presence-avatar:hover .presence-tooltip {
|
|
2524
|
+
opacity: 1;
|
|
2525
|
+
}
|
|
2526
|
+
|
|
2527
|
+
/* Badge */
|
|
2528
|
+
.badge {
|
|
2529
|
+
position: absolute;
|
|
2530
|
+
top: -2px;
|
|
2531
|
+
right: -2px;
|
|
2532
|
+
background: var(--pw-danger);
|
|
2533
|
+
color: #fff;
|
|
2534
|
+
font-size: 9px;
|
|
2535
|
+
font-weight: 700;
|
|
2536
|
+
min-width: 16px;
|
|
2537
|
+
height: 16px;
|
|
2538
|
+
padding: 0 4px;
|
|
2539
|
+
border-radius: 8px;
|
|
2540
|
+
display: flex;
|
|
2541
|
+
align-items: center;
|
|
2542
|
+
justify-content: center;
|
|
2543
|
+
line-height: 1;
|
|
2544
|
+
border: 2px solid var(--pw-surface);
|
|
2545
|
+
}
|
|
2546
|
+
|
|
2547
|
+
.presence-avatar.clickable {
|
|
2548
|
+
cursor: pointer;
|
|
2549
|
+
}
|
|
2550
|
+
|
|
2551
|
+
.presence-avatar.following {
|
|
2552
|
+
box-shadow: 0 0 0 2px var(--pw-accent);
|
|
2553
|
+
animation: pulse-follow 1.5s ease-in-out infinite;
|
|
2554
|
+
}
|
|
2555
|
+
|
|
2556
|
+
@keyframes pulse-follow {
|
|
2557
|
+
0%, 100% { box-shadow: 0 0 0 2px var(--pw-accent); }
|
|
2558
|
+
50% { box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.4); }
|
|
2559
|
+
}
|
|
2560
|
+
|
|
2561
|
+
.close-btn {
|
|
2562
|
+
width: 28px;
|
|
2563
|
+
height: 28px;
|
|
2564
|
+
border-radius: 6px;
|
|
2565
|
+
margin-left: 2px;
|
|
2566
|
+
}
|
|
2567
|
+
|
|
2568
|
+
.device-icon {
|
|
2569
|
+
position: absolute;
|
|
2570
|
+
bottom: -2px;
|
|
2571
|
+
right: -2px;
|
|
2572
|
+
width: 14px;
|
|
2573
|
+
height: 14px;
|
|
2574
|
+
border-radius: 50%;
|
|
2575
|
+
background: var(--pw-surface);
|
|
2576
|
+
border: 1.5px solid var(--pw-border);
|
|
2577
|
+
display: flex;
|
|
2578
|
+
align-items: center;
|
|
2579
|
+
justify-content: center;
|
|
2580
|
+
font-size: 8px;
|
|
2581
|
+
color: var(--pw-text-muted);
|
|
2582
|
+
}
|
|
2583
|
+
|
|
2584
|
+
/* Mobile responsive */
|
|
2585
|
+
@media (max-width: 480px) {
|
|
2586
|
+
.pw-btn-icon {
|
|
2587
|
+
min-width: 44px;
|
|
2588
|
+
min-height: 44px;
|
|
2589
|
+
}
|
|
2590
|
+
|
|
2591
|
+
.toolbar {
|
|
2592
|
+
gap: 2px;
|
|
2593
|
+
padding: 4px;
|
|
2594
|
+
}
|
|
2595
|
+
|
|
2596
|
+
.presence-avatar {
|
|
2597
|
+
width: 32px;
|
|
2598
|
+
height: 32px;
|
|
2599
|
+
}
|
|
2600
|
+
}
|
|
2601
|
+
`];j([m({attribute:!1})],M.prototype,"client",2);j([m({type:Boolean})],M.prototype,"collapsed",2);j([m()],M.prototype,"activePanel",2);j([m({type:Boolean})],M.prototype,"pinModeActive",2);j([m({type:Boolean})],M.prototype,"featuresDisabled",2);j([m({type:Boolean})],M.prototype,"drawModeActive",2);j([m()],M.prototype,"followingUserId",2);j([m()],M.prototype,"display",2);j([b()],M.prototype,"users",2);j([b()],M.prototype,"unreadCount",2);M=j([I("pulse-widget-toolbar")],M);class Qi{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 o;if(!this.container)return;if(document.documentElement.scrollHeight<=window.innerHeight){for(const l of this.pillEls.values())l.remove();this.pillEls.clear();return}const e=window.scrollY,t=window.innerHeight,i=document.documentElement.scrollHeight,s=(o=this.client.state.user)==null?void 0:o.id,r=new Set;for(const[l,a]of this.client.state.viewports){if(l===s)continue;const c=a.scrollY,p=a.scrollY+a.viewportHeight,h=e,f=e+t;if(c>=h&&p<=f){const y=this.pillEls.get(l);y&&(y.style.display="none");continue}r.add(l);const g=this.client.state.presence.find(y=>y.user.id===l);if(!g)continue;const $=a.scrollY+a.viewportHeight/2,A=i>0?$/i:0,k=Math.max(8,Math.min(t-28,A*t));let w=this.pillEls.get(l);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(l,w)),w.style.display="",w.style.background=g.user.color,w.style.top=`${k}px`,w.textContent=this.getInitials(g.user.name)}for(const[l,a]of this.pillEls)!r.has(l)&&!this.client.state.viewports.has(l)&&(a.remove(),this.pillEls.delete(l))}getInitials(e){return e.split(" ").map(t=>t[0]).join("").toUpperCase().slice(0,2)}}var es=Object.defineProperty,ts=Object.getOwnPropertyDescriptor,_=(n,e,t,i)=>{for(var s=i>1?void 0:i?ts(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&es(e,t,s),s};exports.PulseWidget=class extends P{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={...he},this.followingUserId=null,this.drawModeActive=!1,this.connectionState="disconnected",this.showConnectedFlash=!1,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=Wi(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 at(e),this.clientConfigKey=this.getConfigKey(),this.cursorOverlay=new Bi(this.client),this.commentPins=new Ii(this.client,{onPinModeExit:()=>{this.pinModeActive=!1}}),this.viewportOverlay=new Qi(this.client),this.selectionOverlay=new Vi(this.client),this.drawingOverlay=new Fi(this.client),this.settings=Ki(this.room),this.applySettings(this.settings),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,r,o;this.unsubs.forEach(l=>l()),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(),(r=this.drawingOverlay)==null||r.destroy(),(o=this.client)==null||o.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 i,s,r,o;const t=e.detail;if(!(!this.settings.enabled&&t!=="settings"))switch(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?(i=this.commentPins)==null||i.enterPinMode():(s=this.commentPins)==null||s.exitPinMode();break;case"draw-mode":this.drawModeActive=!this.drawModeActive,this.drawModeActive?(r=this.drawingOverlay)==null||r.enableDrawMode():(o=this.drawingOverlay)==null||o.disableDrawMode();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,Gi(this.room,t),this.applySettings(t)}applySettings(e){var t,i,s,r,o,l,a,c,p,h,f,g,$,A,k,w,y;if(!e.enabled){(t=this.cursorOverlay)==null||t.disable(),(i=this.viewportOverlay)==null||i.disable(),(s=this.selectionOverlay)==null||s.disable(),(r=this.drawingOverlay)==null||r.disable(),this.drawModeActive&&((o=this.drawingOverlay)==null||o.disableDrawMode(),this.drawModeActive=!1),(l=this.client)==null||l.setAppearOffline(!0),(a=this.commentPins)==null||a.setVisible(!1),this.followingUserId=null,this.pinModeActive&&((c=this.commentPins)==null||c.exitPinMode(),this.pinModeActive=!1),this.activePanel=this.activePanel==="settings"?"settings":null,this.highlightThreadId=null;return}this.applyCursorSettings(e),(p=this.client)==null||p.setAppearOffline(e.appearOffline),(h=this.commentPins)==null||h.setVisible(e.showCommentPins),e.showViewportIndicators?(f=this.viewportOverlay)==null||f.enable():(g=this.viewportOverlay)==null||g.disable(),e.showSelections?($=this.selectionOverlay)==null||$.enable():(A=this.selectionOverlay)==null||A.disable(),e.showDrawings?(k=this.drawingOverlay)==null||k.enable():((w=this.drawingOverlay)==null||w.disable(),this.drawModeActive&&((y=this.drawingOverlay)==null||y.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 A,k,w,y;const e=this.display==="inline",t=(A=this.shadowRoot)==null?void 0:A.querySelector(".inline-trigger"),i=(k=this.shadowRoot)==null?void 0:k.querySelector("pulse-widget-toolbar"),s=e?t:i;if(!s)return;const r=s.getBoundingClientRect(),o=window.innerWidth,l=window.innerHeight,a=8,c=(w=this.shadowRoot)==null?void 0:w.querySelector(".toolbar-popover");if(c){Object.assign(c.style,{top:"auto",left:"auto"});const T=c.getBoundingClientRect(),v=this.computePosition(r,T,o,l,a);c.style.top=`${v.top}px`,c.style.left=`${v.left}px`}const p=(y=this.shadowRoot)==null?void 0:y.querySelector(".panel-container");if(!p)return;Object.assign(p.style,{top:"auto",left:"auto"});const h=c??i;if(!h)return;const f=h.getBoundingClientRect(),g=p.getBoundingClientRect(),$=this.computePosition(f,g,o,l,a);p.style.top=`${$.top}px`,p.style.left=`${$.left}px`}computePosition(e,t,i,s,r){const o=e.top,l=s-e.bottom;let a;o>=t.height+r?a=e.top-t.height-r:l>=t.height+r?a=e.bottom+r:a=o>=l?Math.max(r,e.top-t.height-r):e.bottom+r;let c;const p=e.right-t.width;return p>=r?c=p:e.left+t.width+r<=i?c=e.left:c=Math.max(r,Math.min(i-t.width-r,e.left)),a=Math.max(r,Math.min(s-t.height-r,a)),c=Math.max(r,Math.min(i-t.width-r,c)),{top:a,left:c}}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?d`<div class="connection-banner connected">
|
|
2602
|
+
<span class="connection-dot"></span>Connected
|
|
2603
|
+
</div>`:this.connectionState==="connecting"?d`<div class="connection-banner connecting">
|
|
2604
|
+
<span class="connection-dot"></span>Reconnecting...
|
|
2605
|
+
</div>`:this.connectionState==="disconnected"&&this.client?d`<div class="connection-banner disconnected">
|
|
2606
|
+
<span class="connection-dot"></span>Disconnected
|
|
2607
|
+
</div>`:u}handleToolbarToggle(){this.collapsed=!this.collapsed,this.collapsed&&(this.activePanel=null,this.highlightThreadId=null)}render(){const e=this.display==="inline";if(e&&this.collapsed)return d`
|
|
2608
|
+
<div class="widget-root">
|
|
2609
|
+
<div class="inline-trigger" @click=${this.handleToolbarToggle}>
|
|
2610
|
+
<slot>Collaborate</slot>
|
|
2611
|
+
</div>
|
|
2612
|
+
</div>
|
|
2613
|
+
`;const t=this.activePanel?d`
|
|
2614
|
+
<div class="panel-container anchored" @panel-close=${this.handlePanelClose}>
|
|
2615
|
+
${this.activePanel==="comments"?d`<pulse-widget-comments-panel
|
|
2616
|
+
.client=${this.client}
|
|
2617
|
+
.highlightThreadId=${this.highlightThreadId}
|
|
2618
|
+
></pulse-widget-comments-panel>`:u}
|
|
2619
|
+
${this.activePanel==="settings"?d`<pulse-widget-settings-panel
|
|
2620
|
+
.settings=${this.settings}
|
|
2621
|
+
.roomId=${this.room}
|
|
2622
|
+
@settings-change=${this.handleSettingsChange}
|
|
2623
|
+
></pulse-widget-settings-panel>`:u}
|
|
2624
|
+
${this.activePanel==="notifications"?d`<pulse-widget-notifications-panel
|
|
2625
|
+
.client=${this.client}
|
|
2626
|
+
></pulse-widget-notifications-panel>`:u}
|
|
2627
|
+
${this.activePanel==="activity"?d`<pulse-widget-activity-panel
|
|
2628
|
+
.client=${this.client}
|
|
2629
|
+
></pulse-widget-activity-panel>`:u}
|
|
2630
|
+
</div>
|
|
2631
|
+
`:u,i=this.followingUserId?d`<div class="follow-banner">
|
|
2632
|
+
Following ${this.getFollowUserName()}
|
|
2633
|
+
<button @click=${()=>{this.followingUserId=null}}>Stop</button>
|
|
2634
|
+
</div>`:u;return e?d`
|
|
2635
|
+
${i}
|
|
2636
|
+
<div class="widget-root">
|
|
2637
|
+
<div class="inline-trigger" @click=${this.handleToolbarToggle}>
|
|
2638
|
+
<slot>Collaborate</slot>
|
|
2639
|
+
</div>
|
|
2640
|
+
${this.renderConnectionBanner()}
|
|
2641
|
+
<div class="toolbar-popover anchored">
|
|
2642
|
+
<pulse-widget-toolbar
|
|
2643
|
+
.client=${this.client}
|
|
2644
|
+
.collapsed=${!1}
|
|
2645
|
+
.activePanel=${this.activePanel}
|
|
2646
|
+
.pinModeActive=${this.pinModeActive}
|
|
2647
|
+
.featuresDisabled=${!this.settings.enabled}
|
|
2648
|
+
.drawModeActive=${this.drawModeActive}
|
|
2649
|
+
.followingUserId=${this.followingUserId}
|
|
2650
|
+
.display=${this.display}
|
|
2651
|
+
@toolbar-action=${this.handleToolbarAction}
|
|
2652
|
+
@toolbar-toggle=${this.handleToolbarToggle}
|
|
2653
|
+
@toolbar-follow=${this.handleFollow}
|
|
2654
|
+
></pulse-widget-toolbar>
|
|
2655
|
+
</div>
|
|
2656
|
+
${t}
|
|
2657
|
+
</div>
|
|
2658
|
+
`:d`
|
|
2659
|
+
${i}
|
|
2660
|
+
<div class="widget-root">
|
|
2661
|
+
${t}
|
|
2662
|
+
${this.renderConnectionBanner()}
|
|
2663
|
+
<pulse-widget-toolbar
|
|
2664
|
+
.client=${this.client}
|
|
2665
|
+
.collapsed=${this.collapsed}
|
|
2666
|
+
.activePanel=${this.activePanel}
|
|
2667
|
+
.pinModeActive=${this.pinModeActive}
|
|
2668
|
+
.featuresDisabled=${!this.settings.enabled}
|
|
2669
|
+
.drawModeActive=${this.drawModeActive}
|
|
2670
|
+
.followingUserId=${this.followingUserId}
|
|
2671
|
+
.display=${this.display}
|
|
2672
|
+
@toolbar-action=${this.handleToolbarAction}
|
|
2673
|
+
@toolbar-toggle=${this.handleToolbarToggle}
|
|
2674
|
+
@toolbar-follow=${this.handleFollow}
|
|
2675
|
+
></pulse-widget-toolbar>
|
|
2676
|
+
</div>
|
|
2677
|
+
`}};exports.PulseWidget.styles=[K,S`
|
|
2678
|
+
:host {
|
|
2679
|
+
display: block;
|
|
2680
|
+
}
|
|
2681
|
+
|
|
2682
|
+
/* Floating mode (default) */
|
|
2683
|
+
:host(:not([display="inline"])) {
|
|
2684
|
+
position: fixed;
|
|
2685
|
+
z-index: 9990;
|
|
2686
|
+
}
|
|
2687
|
+
|
|
2688
|
+
:host(:not([display="inline"])[position="bottom-right"]),
|
|
2689
|
+
:host(:not([display="inline"]):not([position])) {
|
|
2690
|
+
bottom: 20px;
|
|
2691
|
+
right: 20px;
|
|
2692
|
+
}
|
|
2693
|
+
:host(:not([display="inline"])[position="bottom-left"]) {
|
|
2694
|
+
bottom: 20px;
|
|
2695
|
+
left: 20px;
|
|
2696
|
+
}
|
|
2697
|
+
:host(:not([display="inline"])[position="top-right"]) {
|
|
2698
|
+
top: 20px;
|
|
2699
|
+
right: 20px;
|
|
2700
|
+
}
|
|
2701
|
+
:host(:not([display="inline"])[position="top-left"]) {
|
|
2702
|
+
top: 20px;
|
|
2703
|
+
left: 20px;
|
|
2704
|
+
}
|
|
2705
|
+
|
|
2706
|
+
/* Inline mode */
|
|
2707
|
+
:host([display="inline"]) {
|
|
2708
|
+
position: relative;
|
|
2709
|
+
}
|
|
2710
|
+
|
|
2711
|
+
/* Inline trigger (slotted content) */
|
|
2712
|
+
.inline-trigger {
|
|
2713
|
+
cursor: pointer;
|
|
2714
|
+
display: inline-flex;
|
|
2715
|
+
align-items: center;
|
|
2716
|
+
}
|
|
2717
|
+
|
|
2718
|
+
.widget-root {
|
|
2719
|
+
display: flex;
|
|
2720
|
+
flex-direction: column;
|
|
2721
|
+
align-items: flex-end;
|
|
2722
|
+
gap: 8px;
|
|
2723
|
+
}
|
|
2724
|
+
|
|
2725
|
+
:host([position="bottom-left"]) .widget-root,
|
|
2726
|
+
:host([position="top-left"]) .widget-root {
|
|
2727
|
+
align-items: flex-start;
|
|
2728
|
+
}
|
|
2729
|
+
|
|
2730
|
+
.panel-container {
|
|
2731
|
+
animation: pw-slide-in 0.2s cubic-bezier(0.4, 0, 0.2, 1);
|
|
2732
|
+
}
|
|
2733
|
+
|
|
2734
|
+
/* Fixed positioning computed by JS */
|
|
2735
|
+
.anchored {
|
|
2736
|
+
position: fixed;
|
|
2737
|
+
z-index: 9999;
|
|
2738
|
+
}
|
|
2739
|
+
|
|
2740
|
+
.toolbar-popover {
|
|
2741
|
+
z-index: 9998;
|
|
2742
|
+
}
|
|
2743
|
+
|
|
2744
|
+
.follow-banner {
|
|
2745
|
+
position: fixed;
|
|
2746
|
+
top: 12px;
|
|
2747
|
+
left: 50%;
|
|
2748
|
+
transform: translateX(-50%);
|
|
2749
|
+
padding: 8px 20px;
|
|
2750
|
+
background: var(--pw-accent);
|
|
2751
|
+
color: #fff;
|
|
2752
|
+
border-radius: 8px;
|
|
2753
|
+
box-shadow: var(--pw-shadow);
|
|
2754
|
+
font-size: 13px;
|
|
2755
|
+
font-weight: 600;
|
|
2756
|
+
z-index: 10001;
|
|
2757
|
+
display: flex;
|
|
2758
|
+
align-items: center;
|
|
2759
|
+
gap: 10px;
|
|
2760
|
+
}
|
|
2761
|
+
|
|
2762
|
+
.follow-banner button {
|
|
2763
|
+
border: none;
|
|
2764
|
+
background: rgba(255,255,255,0.2);
|
|
2765
|
+
color: #fff;
|
|
2766
|
+
padding: 4px 12px;
|
|
2767
|
+
border-radius: 6px;
|
|
2768
|
+
font-size: 12px;
|
|
2769
|
+
font-weight: 600;
|
|
2770
|
+
cursor: pointer;
|
|
2771
|
+
font-family: inherit;
|
|
2772
|
+
}
|
|
2773
|
+
|
|
2774
|
+
.follow-banner button:hover {
|
|
2775
|
+
background: rgba(255,255,255,0.3);
|
|
2776
|
+
}
|
|
2777
|
+
|
|
2778
|
+
@keyframes pw-slide-in {
|
|
2779
|
+
from {
|
|
2780
|
+
opacity: 0;
|
|
2781
|
+
transform: translateY(8px);
|
|
2782
|
+
}
|
|
2783
|
+
to {
|
|
2784
|
+
opacity: 1;
|
|
2785
|
+
transform: translateY(0);
|
|
2786
|
+
}
|
|
2787
|
+
}
|
|
2788
|
+
|
|
2789
|
+
/* Connection status banner */
|
|
2790
|
+
.connection-banner {
|
|
2791
|
+
display: flex;
|
|
2792
|
+
align-items: center;
|
|
2793
|
+
gap: 6px;
|
|
2794
|
+
padding: 6px 14px;
|
|
2795
|
+
border-radius: 20px;
|
|
2796
|
+
font-size: 12px;
|
|
2797
|
+
font-weight: 600;
|
|
2798
|
+
box-shadow: var(--pw-shadow);
|
|
2799
|
+
animation: pw-slide-in 0.2s ease;
|
|
2800
|
+
pointer-events: none;
|
|
2801
|
+
}
|
|
2802
|
+
|
|
2803
|
+
.connection-banner.connecting {
|
|
2804
|
+
background: #fef3c7;
|
|
2805
|
+
color: #92400e;
|
|
2806
|
+
border: 1px solid #fde68a;
|
|
2807
|
+
}
|
|
2808
|
+
|
|
2809
|
+
.connection-banner.disconnected {
|
|
2810
|
+
background: #fef2f2;
|
|
2811
|
+
color: #991b1b;
|
|
2812
|
+
border: 1px solid #fecaca;
|
|
2813
|
+
}
|
|
2814
|
+
|
|
2815
|
+
.connection-banner.connected {
|
|
2816
|
+
background: #f0fdf4;
|
|
2817
|
+
color: #166534;
|
|
2818
|
+
border: 1px solid #bbf7d0;
|
|
2819
|
+
animation: pw-slide-in 0.2s ease, pw-fade-out 0.4s ease 1.6s forwards;
|
|
2820
|
+
}
|
|
2821
|
+
|
|
2822
|
+
.connection-dot {
|
|
2823
|
+
width: 8px;
|
|
2824
|
+
height: 8px;
|
|
2825
|
+
border-radius: 50%;
|
|
2826
|
+
flex-shrink: 0;
|
|
2827
|
+
}
|
|
2828
|
+
|
|
2829
|
+
.connecting .connection-dot {
|
|
2830
|
+
background: #f59e0b;
|
|
2831
|
+
animation: pw-pulse-dot 1.2s ease-in-out infinite;
|
|
2832
|
+
}
|
|
2833
|
+
|
|
2834
|
+
.disconnected .connection-dot {
|
|
2835
|
+
background: #ef4444;
|
|
2836
|
+
}
|
|
2837
|
+
|
|
2838
|
+
.connected .connection-dot {
|
|
2839
|
+
background: #22c55e;
|
|
2840
|
+
}
|
|
2841
|
+
|
|
2842
|
+
@keyframes pw-pulse-dot {
|
|
2843
|
+
0%, 100% { opacity: 1; }
|
|
2844
|
+
50% { opacity: 0.3; }
|
|
2845
|
+
}
|
|
2846
|
+
|
|
2847
|
+
@keyframes pw-fade-out {
|
|
2848
|
+
from { opacity: 1; }
|
|
2849
|
+
to { opacity: 0; }
|
|
2850
|
+
}
|
|
2851
|
+
`];_([m({attribute:"api-key"})],exports.PulseWidget.prototype,"apiKey",2);_([m()],exports.PulseWidget.prototype,"token",2);_([m()],exports.PulseWidget.prototype,"room",2);_([m()],exports.PulseWidget.prototype,"endpoint",2);_([m({reflect:!0})],exports.PulseWidget.prototype,"position",2);_([m({reflect:!0})],exports.PulseWidget.prototype,"display",2);_([b()],exports.PulseWidget.prototype,"collapsed",2);_([b()],exports.PulseWidget.prototype,"activePanel",2);_([b()],exports.PulseWidget.prototype,"pinModeActive",2);_([b()],exports.PulseWidget.prototype,"highlightThreadId",2);_([b()],exports.PulseWidget.prototype,"settings",2);_([b()],exports.PulseWidget.prototype,"followingUserId",2);_([b()],exports.PulseWidget.prototype,"drawModeActive",2);_([b()],exports.PulseWidget.prototype,"connectionState",2);_([b()],exports.PulseWidget.prototype,"showConnectedFlash",2);exports.PulseWidget=_([I("pulse-widget")],exports.PulseWidget);
|